Преглед изворни кода

新增 杀虫灯状态数据导出接口

zhaiyifei пре 1 година
родитељ
комит
1360df6fde

+ 22 - 17
src/main/java/com/yunfeiyun/agmp/iotm/device/scd/service/impl/IotYfScdServiceImpl.java

@@ -57,18 +57,16 @@ public class IotYfScdServiceImpl extends IIotScdCommService {
     @Resource
     private IIotDeviceconfigService iIotDeviceconfigService;
 
-    public TableDataInfo dataList(IotDeviceDataListReqVo reqVo, boolean isCheckDevice) {
+    public TableDataInfo dataList(IotDeviceDataListReqVo reqVo) {
         TableDataInfo rspData = new TableDataInfo();
         rspData.setCode(ErrorCode.SUCCESS.getCode());
         rspData.setMsg(ErrorCode.SUCCESS.getMessage());
         rspData.setData(new ArrayList<>());
         rspData.setTotal(0);
 
-        if (isCheckDevice) {
-            IotDevice findDevice = iotDeviceService.selectIotDeviceByDevBid(reqVo.getDevBid());
-            if (findDevice == null) {
-                throw new IotBizException(ErrorCode.INVALID_PARAMETER.getCode(), "设备不存在");
-            }
+        IotDevice findDevice = iotDeviceService.selectIotDeviceByDevBid(reqVo.getDevBid());
+        if (findDevice == null) {
+            throw new IotBizException(ErrorCode.INVALID_PARAMETER.getCode(), "设备不存在");
         }
 
         String startTime = reqVo.getStartTime();
@@ -82,6 +80,8 @@ public class IotYfScdServiceImpl extends IIotScdCommService {
         cases.put("time_scddataCreatedDate", startTime + "," + endTime);
 
         PageDomain pageDomain = TableSupport.buildPageRequest();
+        pageDomain.setIsAsc("desc");
+        pageDomain.setOrderByColumn("scddataCreatedDate");
         IPage<IotYfScddata> iotYfScddataIPage = mongoService.findListPage(IotYfScddata.class, cases, pageDomain);
         rspData.setData(iotYfScddataIPage.getRecords());
         rspData.setTotal(iotYfScddataIPage.getTotal());
@@ -89,13 +89,6 @@ public class IotYfScdServiceImpl extends IIotScdCommService {
     }
 
     /**
-     * 获取数据列表接口
-     */
-    public TableDataInfo dataList(IotDeviceDataListReqVo reqVo) {
-        return dataList(reqVo, true);
-    }
-
-    /**
      * 获取折线图数据列表接口
      *
      * @param reqVo
@@ -238,6 +231,20 @@ public class IotYfScdServiceImpl extends IIotScdCommService {
     }
 
     /**
+     * 数据导出列表
+     */
+    public List<IotYfScddata> getExportDataList(IotDeviceDataListReqVo reqVo) {
+        String startTime = reqVo.getStartTime();
+        String endTime = reqVo.getEndTime();
+
+        Map<String, Object> mapParam = new HashMap<>();
+        mapParam.put("devBid", reqVo.getDevBid());
+        mapParam.put("time_scddataCreatedDate", startTime + "," + endTime);
+        List<IotYfScddata> iotYfScddataList = mongoService.findAll(IotYfScddata.class, mapParam, "scddataCreatedDate desc");
+        return iotYfScddataList;
+    }
+
+    /**
      * 数据导出
      *
      * @param iotDeviceExportReqVo
@@ -266,8 +273,7 @@ public class IotYfScdServiceImpl extends IIotScdCommService {
             throw new IotBizException(ErrorCode.INVALID_PARAMETER.getCode(), "设备不存在");
         }
 
-        TableDataInfo tableDataInfo = dataList(iotDeviceDataListReqVo, false);
-        List<IotYfScddata> iotYfScddataList = (List<IotYfScddata>) tableDataInfo.getData();
+        List<IotYfScddata> iotYfScddataList = getExportDataList(iotDeviceDataListReqVo);
         if (Objects.equals(findDevice.getDevtypeBid(), IotDeviceDictConst.TYPE_YF_SCD)) {
             List<IotYfScdDataExportVo> exportVoList = new ArrayList<>();
             for (IotYfScddata iotYfScddata : iotYfScddataList) {
@@ -339,8 +345,7 @@ public class IotYfScdServiceImpl extends IIotScdCommService {
             throw new IotBizException(ErrorCode.INVALID_PARAMETER.getCode(), "设备不存在");
         }
 
-        TableDataInfo tableDataInfo = dataList(iotDeviceDataListReqVo, false);
-        List<IotYfScddata> iotYfScddataList = (List<IotYfScddata>) tableDataInfo.getData();
+        List<IotYfScddata> iotYfScddataList = getExportDataList(iotDeviceDataListReqVo);
         List<IotYfScdStatusExportVo> exportVoList = new ArrayList<>();
         for (IotYfScddata iotYfScddata : iotYfScddataList) {
             JSONObject jsonObject = iotYfScddata.getScddataContent();