From e55c8b0a92eb9715edd90c31dfd4de51a47b588b Mon Sep 17 00:00:00 2001
From: liuhaonan <31457034@qq.com>
Date: 星期五, 04 十一月 2022 17:40:08 +0800
Subject: [PATCH] changes
---
ximon-admin/src/main/java/com/sandu/ximon/admin/service/LightReportDataService.java | 71 ++++++++++++++++++++++++++++++-----
1 files changed, 61 insertions(+), 10 deletions(-)
diff --git a/ximon-admin/src/main/java/com/sandu/ximon/admin/service/LightReportDataService.java b/ximon-admin/src/main/java/com/sandu/ximon/admin/service/LightReportDataService.java
index d4df841..3090329 100644
--- a/ximon-admin/src/main/java/com/sandu/ximon/admin/service/LightReportDataService.java
+++ b/ximon-admin/src/main/java/com/sandu/ximon/admin/service/LightReportDataService.java
@@ -5,10 +5,12 @@
import com.alibaba.excel.EasyExcel;
import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
+import com.github.pagehelper.PageHelper;
import com.sandu.common.domain.CommonPage;
import com.sandu.common.execption.BusinessException;
import com.sandu.common.file.config.FileProperties;
import com.sandu.common.file.impl.AliOssFileServiceImpl;
+import com.sandu.common.object.BaseConditionVO;
import com.sandu.common.service.impl.BaseServiceImpl;
import com.sandu.common.util.SpringContextHolder;
import com.sandu.ximon.admin.manager.iot.frame.inner.report.A5LightHeartbeatReportInnerFrame;
@@ -16,9 +18,11 @@
import com.sandu.ximon.admin.security.SecurityUtils;
import com.sandu.ximon.admin.utils.RedisUtils;
import com.sandu.ximon.dao.bo.LightReportDataBo;
+import com.sandu.ximon.dao.domain.Light;
import com.sandu.ximon.dao.domain.LightReportData;
import com.sandu.ximon.dao.domain.Pole;
import com.sandu.ximon.dao.domain.PoleBinding;
+import com.sandu.ximon.dao.enums.OrderByEnums;
import com.sandu.ximon.dao.mapper.LightReportDataMapper;
import lombok.AllArgsConstructor;
import lombok.SneakyThrows;
@@ -47,6 +51,7 @@
private final FileProperties properties;
private final AliOssFileServiceImpl fileService;
+ private final LightReportDataMapper lightReportDataMapper;
/**
* 淇濆瓨涓婃姤鐨勭伅蹇冭烦鏁版嵁
@@ -64,7 +69,6 @@
lightReportData = new LightReportData();
lightReportData.setCreateTime(format);
}
- //todo
lightReportData.setCreateTime(format);
BeanUtils.copyProperties(heartBeatDataPackage, lightReportData);
lightReportData.setDeviceCode(deviceName);
@@ -92,11 +96,36 @@
* @param keyword 鍏抽敭璇�
* @param deviceCode 璁惧鐮�
*/
- public CommonPage listReportData(int pageNo, int pageSize, String keyword, String deviceCode) {
+ public CommonPage listReportData(int pageNo, int pageSize, String keyword, String deviceCode, Integer order, Integer seq) {
List<LightReportDataBo> lightReportDataBos = new ArrayList<>(pageSize);
-
- CommonPage<String> stringCommonPage = SpringContextHolder.getBean(LightService.class).listDeviceCode(pageNo, pageSize, keyword, deviceCode);
+ //鎺掑簭瀛楁
+ String orderByResult = "t1.create_time";
+ //姝e簭銆佸�掑彊
+ String orderBySeq = OrderByEnums.ASC.getCode();
+ if (order != null) {
+ switch (order) {
+ case 1:
+ orderByResult = OrderByEnums.LIGHT_DATA_CREATE_TIME.getCode();
+ break;
+ default:
+ }
+ }
+ if (seq != null) {
+ switch (seq) {
+ case 1:
+ orderBySeq = " ASC";
+ break;
+ case 2:
+ orderBySeq = " DESC";
+ break;
+ default:
+ break;
+ }
+ }
+ //鎺掑簭鏂瑰紡
+ String orderBy = orderByResult + " " + orderBySeq;
+ CommonPage<String> stringCommonPage = SpringContextHolder.getBean(LightService.class).listDeviceCode(pageNo, pageSize, keyword, deviceCode, orderBy);
List<String> macList = stringCommonPage.getList();
if (CollUtil.isEmpty(macList)) {
return new CommonPage();
@@ -132,7 +161,7 @@
}
@SneakyThrows
- public String exportList(HttpServletRequest request, HttpServletResponse response, String deviceCode) {
+ public void exportList(HttpServletRequest request, HttpServletResponse response, String deviceCode) {
if (SecurityUtils.getClientId() != null) {
PoleBinding one = SpringContextHolder.getBean(PoleBindingService.class).getOne(Wrappers.lambdaQuery(PoleBinding.class).eq(PoleBinding::getDeviceCode, deviceCode)
@@ -149,7 +178,7 @@
}
}
- List<LightReportDataBo> list = baseMapper.listReportData(null, deviceCode);
+ List<LightReportDataBo> list = lightReportDataMapper.listReportData(null, deviceCode);
File file = new File("./" + RandomUtil.randomString(12) + ".xlsx");
@@ -158,8 +187,7 @@
//鏂囦欢娴佸寲杩斿洖缁欏墠绔�
findfile(request, response, file);
//鍒犻櫎鏂囦欢
- file.delete();
- return null;
+ // file.delete();
}
/**
@@ -174,8 +202,6 @@
ServletOutputStream out = null;
FileInputStream ips = null;
try {
- //鑾峰彇鏂囦欢瀛樻斁鐨勮矾寰�
- String fileName = file.getName();
//鑾峰彇鍒版枃瀛� 鏁版嵁搴撻噷瀵瑰簲鐨勯檮浠跺悕瀛楀姞涓婅�佺殑鏂囦欢鍚嶅瓧锛歠ilename 鎴彇鍒板悗闈㈢殑鏂囦欢绫诲瀷 渚嬶細txt 缁勬垚涓�涓柊鐨勬枃浠跺悕瀛楋細newFileName
//鐢熸垚3涓殢鏈烘暟锛岀敤鏉ョ敓鎴愭柊鐨勬枃浠跺悕瀛�
String newFileName = "鍗曠伅鏁版嵁" + RandomUtil.randomString(3) + ".xlsx";
@@ -201,10 +227,35 @@
try {
out.close();
ips.close();
+ file.delete();
} catch (IOException e) {
System.out.println("鍏抽棴娴佸嚭鐜板紓甯�");
e.printStackTrace();
}
}
}
+
+ /**
+ * 鏍规嵁macCode鑾峰彇鐏殑鏁版嵁
+ */
+ public List<LightReportData> getReportDataList(BaseConditionVO conditionVO, String macCode) {
+ if (macCode.isEmpty()) {
+ throw new BusinessException("mac涓嶈兘涓虹┖");
+ }
+
+ Light light = SpringContextHolder.getBean(LightService.class)
+ .getOne(Wrappers.lambdaQuery(Light.class).eq(Light::getDeviceCode, macCode));
+ if (light == null) {
+ throw new BusinessException("绯荤粺涓笉瀛樺湪璇ュ崟鐏�");
+ }
+ PageHelper.startPage(conditionVO.getPageNo(), conditionVO.getPageSize());
+ List<LightReportData> list = list(Wrappers.lambdaQuery(LightReportData.class).eq(LightReportData::getDeviceCode, macCode));
+ list.forEach(
+ lightReportData -> {
+ lightReportData.setCreateTime(lightReportData.getCreateTime1().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
+ lightReportData.setUpdateTime(lightReportData.getUpdateTime1().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
+ }
+ );
+ return list;
+ }
}
--
Gitblit v1.9.3