瀏覽代碼

违规计量接口开发

qiangxuan 5 月之前
父節點
當前提交
ff9dbbabe1

+ 3 - 7
zgztBus/jeecg-module-lesm/src/main/java/org/jeecg/modules/homePageData/controller/HomePageDataController.java

@@ -7,7 +7,6 @@ import lombok.extern.slf4j.Slf4j;
 import org.jeecg.common.api.vo.Result;
 import org.jeecg.common.aspect.annotation.AutoLog;
 import org.jeecg.common.util.oConvertUtils;
-import org.jeecg.modules.deviceLesm.entity.DeviceOperationLog;
 import org.jeecg.modules.homePageData.service.IHomePageDataService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.GetMapping;
@@ -73,11 +72,8 @@ public class HomePageDataController {
     @AutoLog(value = " 违规计量")
     @ApiOperation(value="违规计量", notes="违规计量")
     @GetMapping(value = "/illegalMetering")
-    public Result<List<Map<String, String>>> illegalMetering(@RequestParam(name="modelId",required=false) String modelId) {
-        if (oConvertUtils.isEmpty(modelId)){
-            return Result.error("查询失败,请设置模型!");
-        }
-        List<Map<String, String>> res = homePageDataService.illegalMetering(modelId);
+    public Result<List<Map<String, String>>> illegalMetering() {
+        List<Map<String, String>> res = homePageDataService.illegalMetering();
         return Result.OK(res);
     }
 
@@ -107,7 +103,7 @@ public class HomePageDataController {
     @ApiOperation(value="峰平谷时间段用电量", notes="峰平谷时间段用电量")
     @GetMapping(value = "/fpvTimeElectricity")
     public Result<Map<String, List>> fpvTimeElectricity(@RequestParam(name="modelId",required=false) String modelId) {
-        if (oConvertUtils.isEmpty(modelId)){
+        if (oConvertUtils.isEmpty(modelId) || "0".equals(modelId)){
             return Result.error("查询失败,请设置模型!");
         }
         Map<String, List> res = homePageDataService.fpvTimeElectricity(modelId);

+ 14 - 0
zgztBus/jeecg-module-lesm/src/main/java/org/jeecg/modules/homePageData/entity/ViolationStatisticsResult.java

@@ -0,0 +1,14 @@
+package org.jeecg.modules.homePageData.entity;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+@Data
+public class ViolationStatisticsResult {
+
+    @ApiModelProperty(value = "区域ID")
+    private String deviceRegionId;
+
+    @ApiModelProperty(value = "违规计量总数")
+    private Integer counts;
+}

+ 8 - 0
zgztBus/jeecg-module-lesm/src/main/java/org/jeecg/modules/homePageData/mapper/LeanEventWarnInfoMapper.java

@@ -1,9 +1,12 @@
 package org.jeecg.modules.homePageData.mapper;
 
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.apache.ibatis.annotations.Param;
 import org.jeecg.modules.homePageData.entity.LeanEventWarnInfo;
 import org.jeecg.modules.homePageData.entity.LeanEventWarnInfoResult;
+import org.jeecg.modules.homePageData.entity.ViolationStatisticsResult;
 
+import java.util.Date;
 import java.util.List;
 
 /**
@@ -13,5 +16,10 @@ import java.util.List;
  * @Version: V1.0
  */
 public interface LeanEventWarnInfoMapper extends BaseMapper<LeanEventWarnInfo> {
+
     List<LeanEventWarnInfoResult> queryLeanEventWarnInfo();
+
+    ViolationStatisticsResult queryViolationDayStatistics(@Param("deviceRegionId") String deviceRegionId);
+
+    ViolationStatisticsResult queryViolationMonthStatistics(@Param("deviceRegionId") String deviceRegionId, @Param("currentDate") Date currentDate);
 }

+ 33 - 0
zgztBus/jeecg-module-lesm/src/main/java/org/jeecg/modules/homePageData/mapper/xml/LeanEventWarnInfoMapper.xml

@@ -14,4 +14,37 @@
         ORDER BY
             lewi.create_time DESC
     </select>
+
+
+    <select id="queryViolationDayStatistics"
+            resultType="org.jeecg.modules.homePageData.entity.ViolationStatisticsResult">
+        SELECT
+            device_region_id,
+            COUNT(*) AS counts
+        FROM
+            lean_event_warn_info
+        WHERE
+            device_region_id = #{deviceRegionId}
+            AND DATE ( create_time ) = CURDATE()
+        GROUP BY
+            device_region_id
+    </select>
+
+
+    <select id="queryViolationMonthStatistics"
+            resultType="org.jeecg.modules.homePageData.entity.ViolationStatisticsResult">
+        SELECT
+            device_region_id,
+            COUNT(*) AS counts
+        FROM
+            lean_event_warn_info
+        WHERE
+          device_region_id = #{deviceRegionId}
+          AND YEAR ( create_time ) = YEAR (
+            #{currentDate,jdbcType=DATE})
+          AND MONTH ( create_time ) = MONTH (
+            #{currentDate,jdbcType=DATE})
+        GROUP BY
+            device_region_id
+    </select>
 </mapper>

+ 1 - 3
zgztBus/jeecg-module-lesm/src/main/java/org/jeecg/modules/homePageData/service/IHomePageDataService.java

@@ -1,7 +1,5 @@
 package org.jeecg.modules.homePageData.service;
 
-import org.jeecg.modules.deviceLesm.entity.DeviceOperationLog;
-
 import java.util.List;
 import java.util.Map;
 
@@ -26,7 +24,7 @@ public interface IHomePageDataService {
      *
      * @return
      */
-    List<Map<String, String>> illegalMetering(String modelId);
+    List<Map<String, String>> illegalMetering();
 
     /**
      * 区域用电占比

+ 7 - 7
zgztBus/jeecg-module-lesm/src/main/java/org/jeecg/modules/homePageData/service/impl/HomePageDataServiceImpl.java

@@ -1,7 +1,6 @@
 package org.jeecg.modules.homePageData.service.impl;
 
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
-import org.jeecg.common.util.DateUtils;
 import org.jeecg.common.util.oConvertUtils;
 import org.jeecg.modules.common.ModelCodeContant;
 import org.jeecg.modules.deviceLesm.entity.DeviceInformation;
@@ -16,6 +15,7 @@ import org.jeecg.modules.fpgLeanModel.entity.FpgLeanModel;
 import org.jeecg.modules.fpgLeanModel.service.IFpgLeanModelService;
 import org.jeecg.modules.gatherData.mapper.FpgGatherDataMapper;
 import org.jeecg.modules.homePageData.entity.LeanEventWarnInfoResult;
+import org.jeecg.modules.homePageData.entity.ViolationStatisticsResult;
 import org.jeecg.modules.homePageData.mapper.LeanEventWarnInfoMapper;
 import org.jeecg.modules.homePageData.service.IHomePageDataService;
 import org.jeecg.modules.systemConfig.peaksAndValleysTimeConfig.entity.PeaksAndValleysTimeConfig;
@@ -164,16 +164,16 @@ public class HomePageDataServiceImpl implements IHomePageDataService {
     }
 
     @Override
-    public List<Map<String, String>> illegalMetering(String modelId) {
+    public List<Map<String, String>> illegalMetering() {
         List<Map<String, String>> res = new ArrayList<>();
-        String leanModelCode = queryLeanModelCodeById(modelId);
-
         List<DeviceRegion> list = deviceRegionService.list();
         list.forEach(deviceRegion -> {
             Map<String,String> map = new HashMap<>();
-            map.put("name",deviceRegion.getRegionTitle());
-            map.put("month",((int)(Math.random()*50+50))+"");
-            map.put("day",((int)(Math.random()*20))+"");
+            ViolationStatisticsResult dayViolationStatisticsResult = leanEventWarnInfoMapper.queryViolationDayStatistics(deviceRegion.getId());
+            ViolationStatisticsResult monthViolationStatisticsResult = leanEventWarnInfoMapper.queryViolationMonthStatistics(deviceRegion.getId(), new Date());
+            map.put("name", deviceRegion.getRegionTitle());
+            map.put("month", String.valueOf(oConvertUtils.isEmpty(monthViolationStatisticsResult) ? 0 : monthViolationStatisticsResult.getCounts()));
+            map.put("day", String.valueOf(oConvertUtils.isEmpty(dayViolationStatisticsResult) ? 0 : dayViolationStatisticsResult.getCounts()));
             res.add(map);
         });
         return res;