浏览代码

积木报表接口开发

qiangxuan 8 月之前
父节点
当前提交
6491e0f56c

+ 41 - 3
zgztBus/jeecg-module-lesm/src/main/java/org/jeecg/modules/fpgLeanModel/controller/FpgLeanModelController.java

@@ -198,16 +198,27 @@ public class FpgLeanModelController extends JeecgController<FpgLeanModel, IFpgLe
 	 }
 
 
-	@ApiOperation(value="龙钢变各工序报表-通过模型编码导出报表", notes="峰平谷模型报表-通过模型编码导出报表")
+	/**
+	 * 	龙钢变各工序报表		http://localhost:7004/fpgLeanModel/fpgLeanModel/exportModelDataByCode?leanModelCode=total_day_wp_report			       total_day_wp_report
+	 * 	总用电量报表	    	http://localhost:7004/fpgLeanModel/fpgLeanModel/exportModelDataPowerByCode?leanModelCode=total_day_eu_report		   total_day_eu_report
+	 * 	峰平谷用电控制日报报表  http://localhost:7004/fpgLeanModel/fpgLeanModel/exportModelDataControlByCode?leanModelCode=total_day_ec_report         total_day_ec_report
+	 * 	线路峰平谷日报 		http://localhost:7004/fpgLeanModel/fpgLeanModel/exportModelDataRunByCode?leanModelCode=total_day_dn_report             total_day_dn_report
+	 * 	谷峰差统计报表    		http://localhost:7004/fpgLeanModel/fpgLeanModel/exportModelDataDifferenceByCode?leanModelCode=total_day_ds_report      total_day_ds_report
+	 *
+ 	 * @param leanModelCode
+	 * @return
+	 */
+
+	@ApiOperation(value="龙钢变各工序报表-通过模型编码导出", notes="龙钢变各工序报表-通过模型编码导出")
 	@GetMapping(value = "/exportModelDataByCode")
 	public JSONObject exportModelDataByLeanModelCode(@RequestParam(name="leanModelCode") String leanModelCode) {
 
-		JSONObject result = fpgLeanModelService.queryFpgDataByLeanModelCode(leanModelCode);
+		JSONObject result = fpgLeanModelService.queryFpgPowerDataByLeanModelCode(leanModelCode);
 
 		return result;
 	}
 
-	@ApiOperation(value="用电总量报表-通过模型编码导出报表", notes="峰平谷模型报表-通过模型编码导出报表")
+	@ApiOperation(value="总用电量报表-通过模型编码导出", notes="用电总量报表-通过模型编码导出")
 	@GetMapping(value = "/exportModelDataPowerByCode")
 	public JSONObject exportModelPowerDataByLeanModelCode(@RequestParam(name="leanModelCode") String leanModelCode) {
 
@@ -215,4 +226,31 @@ public class FpgLeanModelController extends JeecgController<FpgLeanModel, IFpgLe
 
 		return result;
 	}
+
+	@ApiOperation(value="峰平谷用电控制日报报表-通过模型编码导出", notes="峰平谷用电控制日报报表-通过模型编码导出")
+	@GetMapping(value = "/exportModelDataControlByCode")
+	public JSONObject exportModelControlDataByLeanModelCode(@RequestParam(name="leanModelCode") String leanModelCode) {
+
+		JSONObject result = fpgLeanModelService.queryFpgPowerDataByLeanModelCode(leanModelCode);
+
+		return result;
+	}
+
+	@ApiOperation(value="线路峰平谷日报报表-通过模型编码导出", notes="线路峰平谷日报报表-通过模型编码导出")
+	@GetMapping(value = "/exportModelDataRunByCode")
+	public JSONObject exportModelRunDataByLeanModelCode(@RequestParam(name="leanModelCode") String leanModelCode) {
+
+		JSONObject result = fpgLeanModelService.queryFpgPowerDataByLeanModelCode(leanModelCode);
+
+		return result;
+	}
+
+	@ApiOperation(value="谷峰差统计报表-通过模型编码导出", notes="谷峰差统计报表-通过模型编码导出")
+	@GetMapping(value = "/exportModelDataDifferenceByCode")
+	public JSONObject exportModelDifferenceDataByLeanModelCode(@RequestParam(name="leanModelCode") String leanModelCode) {
+
+		JSONObject result = fpgLeanModelService.queryFpgPowerDataByLeanModelCode(leanModelCode);
+
+		return result;
+	}
 }

+ 0 - 2
zgztBus/jeecg-module-lesm/src/main/java/org/jeecg/modules/fpgLeanModel/service/IFpgLeanModelService.java

@@ -24,7 +24,5 @@ public interface IFpgLeanModelService extends IService<FpgLeanModel> {
 
     List<DeviceStatiscsModelMongodb> queryRealTimeDataById(String deviceInformationId);
 
-    JSONObject queryFpgDataByLeanModelCode(String leanModelCode);
-
     JSONObject queryFpgPowerDataByLeanModelCode(String leanModelCode);
 }

+ 26 - 47
zgztBus/jeecg-module-lesm/src/main/java/org/jeecg/modules/fpgLeanModel/service/impl/FpgLeanModelServiceImpl.java

@@ -133,55 +133,19 @@ public class FpgLeanModelServiceImpl extends ServiceImpl<FpgLeanModelMapper, Fpg
         return deviceStatiscsModelMongodbList;
     }
 
-    @Override
-    public JSONObject queryFpgDataByLeanModelCode(String leanModelCode) {
-
-        JSONObject result = new JSONObject();
-
-        List<DeviceStatiscsModelMongodb> fpgStatiscsModelDataList = queryByTimeRanges(mongoTemplate, leanModelCode, null, null, null, null, null);
-        if (oConvertUtils.listIsEmpty(fpgStatiscsModelDataList)){
-            log.info("{}{}", "mongo数据查询为空,峰平谷模型报表导出失败!", leanModelCode);
-            result.put("data", new ArrayList<>());
-            return result;
-        }
-        List<String> deviceInformationIds = fpgStatiscsModelDataList.stream().map(DeviceStatiscsModelMongodb::getDeviceInformationId).collect(Collectors.toList());
-        LambdaQueryWrapper<DeviceInformation> queryWrapper = new LambdaQueryWrapper<>();
-        queryWrapper.in(DeviceInformation::getId, deviceInformationIds);
-        List<DeviceInformation> deviceInformationList = deviceInformationMapper.selectList(queryWrapper);
-        // 将listA转换为以(设备Id, 区域Id)为键的Map
-        Map<String, DeviceInformation> mapA = deviceInformationList.stream()
-                .collect(Collectors.toMap(a -> a.getId() + "_" + a.getDeviceRegionId(), a -> a));
-
-        // 遍历listB,根据相同的(设备Id, 区域Id)与mapA中的对象合并成新的ModelResult并添加到新列表
-        List<ModelReportFormResult> combinedList = fpgStatiscsModelDataList.stream()
-                .map(b -> {
-                    String key = b.getDeviceInformationId() + "_" + b.getDeviceRegionId();
-                    DeviceInformation a = mapA.get(key);
-                    if (a != null) {
-                        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
-                        String dateString = sdf.format(b.getCreateTime());
-                        return new ModelReportFormResult(a.getDeviceTitle(), b.getDevicePointId(), b.getDeviceRegionId(), b.getDeviceInformationId(),
-                                b.getIngTime(), b.getSelectricCurrent(), b.getPower(), b.getTopsPower(), b.getPeaksPower(), b.getFlatPower(), b.getValleysPower(),
-                                b.getTopsIngTime(), b.getPeaksIngTime(), b.getFlatIngTime(), b.getValleysIngTime(),
-                                b.getTopsSelectricCurrent(), b.getPeaksSelectricCurrent(), b.getFlatSelectricCurrent(), b.getValleysSelectricCurrent(),
-                                b.getTopsProportion(), b.getPeaksProportion(), b.getFlatProportion(), b.getValleysProportion(), b.getProportion(), b.getDates(), dateString);
-                    }
-                    return null;
-                }).filter(x -> x != null).collect(Collectors.toList());
-
-        JSONArray jArray = JSON.parseArray(JSON.toJSONString(combinedList));
-        result.put("data", jArray);
-        return result;
-    }
-
+    /**
+     * 龙钢峰平谷积木报表导出逻辑处理
+     * @param leanModelCode
+     * @return JSONObject
+     */
     @Override
     public JSONObject queryFpgPowerDataByLeanModelCode(String leanModelCode) {
 
         JSONObject result = new JSONObject();
         List<DeviceStatiscsModelMongodb> fpgStatiscsModelDataList = queryByTimeRanges(mongoTemplate, leanModelCode, null, null, null, null, null);
         if (oConvertUtils.listIsEmpty(fpgStatiscsModelDataList)){
-            log.info("{}{}", "mongo数据查询为空,峰平谷功率报表导出失败!", leanModelCode);
-            result.put("data", new ArrayList<>());
+            log.info("{}{}", "mongo数据查询为空,峰平谷报表导出失败!", leanModelCode);
+            result.put("data", new JSONArray());
             return result;
         }
         List<String> deviceInformationIds = fpgStatiscsModelDataList.stream().map(DeviceStatiscsModelMongodb::getDeviceInformationId).collect(Collectors.toList());
@@ -208,13 +172,28 @@ public class FpgLeanModelServiceImpl extends ServiceImpl<FpgLeanModelMapper, Fpg
                     }
                     return null;
                 }).filter(x -> x != null).collect(Collectors.toList());
-        List<ModelDataResult> modelDataResults = generateModelDataResults(combinedList);
-        JSONArray jArray = JSON.parseArray(JSON.toJSONString(modelDataResults));
-        result.put("data", jArray);
+        JSONArray jsonResult = new JSONArray();
+        if ("total_day_eu_report".equals(leanModelCode)){
+            // 总用电量报表
+            List<ModelDataResult> modelDataResults = generateModelDataResults(combinedList);
+            jsonResult = JSON.parseArray(JSON.toJSONString(modelDataResults));
+        } else if ("total_day_ec_report".equals(leanModelCode)) {
+            // 峰平谷用电控制日报报表
+            jsonResult = JSON.parseArray(JSON.toJSONString(combinedList));
+        }else if ("total_day_dn_report".equals(leanModelCode)) {
+            // 线路峰平谷日报
+            jsonResult = JSON.parseArray(JSON.toJSONString(combinedList));
+        }else if ("total_day_ds_report".equals(leanModelCode)) {
+            // 谷峰差统计报表
+            jsonResult = JSON.parseArray(JSON.toJSONString(combinedList));
+        }else if ("total_day_wp_report".equals(leanModelCode)) {
+            // 龙钢变各工序报表
+            jsonResult = JSON.parseArray(JSON.toJSONString(combinedList));
+        }
+        result.put("data", jsonResult);
         return result;
     }
 
-
     /**
      * 基于模型编码、采集点ID、设备ID、区域ID、峰平谷配置时间范围 动态查询mongoDB
      * @param mongoTemplate