duhongyu 3 weken geleden
bovenliggende
commit
cab7cb174c

+ 6 - 6
smart-steward-api/src/main/java/com/smartSteward/web/controller/security/SecurityStatisticsController.java

@@ -17,11 +17,12 @@ import org.springframework.web.bind.annotation.RestController;
17 17
  * @author smart-steward
18 18
  */
19 19
 @RestController
20
-@Api(value = "摄像头安全统计",tags = "摄像头安全统计")
20
+@Api(value = "摄像头安全统计", tags = "摄像头安全统计")
21 21
 @RequestMapping("/security/statistics")
22 22
 public class SecurityStatisticsController extends BaseController {
23 23
     @Autowired
24
-   private ISecurityStatisticsService securityStatisticsService;
24
+    private ISecurityStatisticsService securityStatisticsService;
25
+
25 26
     /**
26 27
      * 检测统计
27 28
      *
@@ -29,10 +30,10 @@ public class SecurityStatisticsController extends BaseController {
29 30
      */
30 31
     @ApiOperation("查询检测统计")
31 32
     @GetMapping("/detect")
32
-    public AjaxResult detect(@RequestParam(required = false) Long stationId)
33
-    {
33
+    public AjaxResult detect(@RequestParam(required = false) Long stationId) {
34 34
         return success(securityStatisticsService.selectDetectStatistics(stationId));
35 35
     }
36
+
36 37
     /**
37 38
      * 查询每个分类的预警未处理数量
38 39
      *
@@ -40,8 +41,7 @@ public class SecurityStatisticsController extends BaseController {
40 41
      */
41 42
     @ApiOperation("查询每个分类的预警未处理数量")
42 43
     @GetMapping("/warning")
43
-    public AjaxResult warning(@RequestParam(required = false) Long stationId)
44
-    {
44
+    public AjaxResult warning(@RequestParam(required = false) Long stationId) {
45 45
         return success(securityStatisticsService.selectWarningStatistics(stationId));
46 46
     }
47 47
 }

+ 8 - 0
smart-steward-mapper/src/main/java/com/smartSteward/mapper/security/SecurityAlertMapper.java

@@ -87,4 +87,12 @@ public interface SecurityAlertMapper
87 87
       */
88 88
     @DataSource(DataSourceType.SLAVE)
89 89
     public List<HashMap<String, Object>> selectWarningStatistics(@Param("stationId") Long stationId);
90
+     /**
91
+      * 查询本月每个分类的预警未处理数量
92
+      *
93
+      * @param stationId 站点ID
94
+      * @return 结果
95
+      */
96
+    @DataSource(DataSourceType.SLAVE)
97
+    public List<HashMap<String, Object>> selectMonthWarningStatistics(@Param("stationId") Long stationId);
90 98
 }

+ 10 - 0
smart-steward-mapper/src/main/resources/mapper/security/SecurityAlertMapper.xml

@@ -225,6 +225,16 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
225 225
         group by alert_type
226 226
     </select>
227 227
 
228
+    <select id="selectMonthWarningStatistics" parameterType="Long" resultType="HashMap">
229
+        select alert_type as alertType, count(*) as count from security_alert
230
+         <where>
231
+            and  status='unhandled'
232
+             <if test="stationId != null">and station_id = #{stationId}</if>
233
+             and alert_time between date_format(now(), '%Y-%m-01') and date_format(now(), '%Y-%m-%d')
234
+         </where>
235
+        group by alert_type
236
+    </select>
237
+
228 238
 
229 239
 
230 240
 

+ 10 - 0
smart-steward-service/src/main/java/com/smartSteward/service/security/impl/SecurityStatisticsServiceImpl.java

@@ -55,6 +55,8 @@ public class SecurityStatisticsServiceImpl implements ISecurityStatisticsService
55 55
     public List<HashMap<String, Object>> selectWarningStatistics(Long stationId) {
56 56
         List<HashMap<String, Object>> statistics =new ArrayList<>();
57 57
         List<HashMap<String, Object>> warningStatistics = alertMapper.selectWarningStatistics(stationId);
58
+        //查询本月每个类型的数量
59
+        List<HashMap<String, Object>> monthStatistics = alertMapper.selectMonthWarningStatistics(stationId);
58 60
         List<SysDictData > alertTypes = DictUtils.getDictCache("warning_type");
59 61
         if (alertTypes != null) {
60 62
            for (SysDictData alertType : alertTypes) {
@@ -62,6 +64,14 @@ public class SecurityStatisticsServiceImpl implements ISecurityStatisticsService
62 64
                map.put("alertType", alertType.getDictValue());
63 65
                map.put("alertTypeName", alertType.getDictLabel());
64 66
                map.put("count", 0);
67
+               map.put("monthCount", 0);
68
+               //查询本月每个类型的数量
69
+               for (HashMap<String, Object> monthStatistic : monthStatistics) {
70
+                   if (monthStatistic.get("alertType").equals(alertType.getDictValue())) {
71
+                       map.put("monthCount", monthStatistic.get("count"));
72
+                       break;
73
+                   }
74
+               }
65 75
                for (HashMap<String, Object> warningStatistic : warningStatistics) {
66 76
                    if (warningStatistic.get("alertType").equals(alertType.getDictValue())) {
67 77
                        map.put("count", warningStatistic.get("count"));