From 2fad5b9483d3e6fec4b8bd1e6f8c578e270b4688 Mon Sep 17 00:00:00 2001
From: aijinhui <aijinhui>
Date: 星期日, 08 十月 2023 13:33:50 +0800
Subject: [PATCH] 报警数量统计

---
 ard-work/src/main/java/com/ruoyi/statistical/service/impl/StatisticalServiceImpl.java |  262 ++++++++++++++++++++++++++++++++++++++++++++++++----
 1 files changed, 242 insertions(+), 20 deletions(-)

diff --git a/ard-work/src/main/java/com/ruoyi/statistical/service/impl/StatisticalServiceImpl.java b/ard-work/src/main/java/com/ruoyi/statistical/service/impl/StatisticalServiceImpl.java
index 7b0e13a..c65b702 100644
--- a/ard-work/src/main/java/com/ruoyi/statistical/service/impl/StatisticalServiceImpl.java
+++ b/ard-work/src/main/java/com/ruoyi/statistical/service/impl/StatisticalServiceImpl.java
@@ -1,16 +1,32 @@
 package com.ruoyi.statistical.service.impl;
 
+import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.ruoyi.alarm.access.mapper.ArdAlarmAccessMapper;
+import com.ruoyi.alarm.apponekey.mapper.ArdAlarmApponekeyMapper;
+import com.ruoyi.alarm.camera.mapper.ArdAlarmCameraMapper;
+import com.ruoyi.alarm.digitization3.mapper.ArdAlarmDigitization3Mapper;
+import com.ruoyi.alarm.external.mapper.ArdAlarmExternalMapper;
+import com.ruoyi.alarm.radar.mapper.ArdAlarmRadarFireMapper;
+import com.ruoyi.alarm.radar.mapper.ArdAlarmRadarMoveMapper;
+import com.ruoyi.alarm.radar.mapper.ArdAlarmRadarPumpMapper;
+import com.ruoyi.alarm.steal.mapper.ArdAlarmStealelecMapper;
+import com.ruoyi.alarm.tube.mapper.ArdAlarmTubeMapper;
+import com.ruoyi.alarm.wall.mapper.ArdAlarmWallMapper;
 import com.ruoyi.alarmpoints.well.domain.ArdAlarmpointsWell;
 import com.ruoyi.alarmpoints.well.mapper.ArdAlarmpointsWellMapper;
 import com.ruoyi.common.core.domain.entity.SysConfig;
 import com.ruoyi.common.utils.SecurityUtils;
+import com.ruoyi.statistical.param.ESParam;
 import com.ruoyi.statistical.service.StatisticalService;
+import com.ruoyi.statistical.vo.CountVo;
 import com.ruoyi.system.mapper.SysConfigMapper;
 import com.ruoyi.utils.result.Results;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
+import java.util.Calendar;
+import java.util.List;
 import java.util.Map;
 
 /**
@@ -23,6 +39,29 @@
     private SysConfigMapper sysConfigMapper;
     @Autowired
     private ArdAlarmpointsWellMapper wellMapper;
+    @Autowired
+    private ArdAlarmStealelecMapper stealelecMapper;
+    @Autowired
+    private ArdAlarmCameraMapper cameraMapper;
+    @Autowired
+    private ArdAlarmRadarMoveMapper moveMapper;
+    @Autowired
+    private ArdAlarmRadarFireMapper fireMapper;
+    @Autowired
+    private ArdAlarmExternalMapper externalMapper;
+    @Autowired
+    private ArdAlarmAccessMapper accessMapper;
+    @Autowired
+    private ArdAlarmApponekeyMapper apponekeyMapper;
+    @Autowired
+    private ArdAlarmRadarPumpMapper pumpMapper;
+    @Autowired
+    private ArdAlarmWallMapper wallMapper;
+    @Autowired
+    private ArdAlarmDigitization3Mapper digitization3Mapper;
+    @Autowired
+    private ArdAlarmTubeMapper tubeMapper;
+
 
     @Override
     public Results factorySave(Map<String, String> map) {
@@ -69,26 +108,209 @@
                 }
             }
         }
-        //璁板綍well琛ㄤ腑oil_production涓烘娊娌规満鐨勬暟鎹湁澶氬皯鏉�
-        QueryWrapper<ArdAlarmpointsWell> queryWrapper = new QueryWrapper<>();
-        queryWrapper.eq("oil_production","鎶芥补鏈�");
-        int num = wellMapper.selectCount(queryWrapper);
-        SysConfig sysConfigUpd = sysConfigMapper.checkConfigKeyUnique("well");
-        if(sysConfigUpd!=null){
-            sysConfigUpd.setConfigValue(String.valueOf(num));
-            sysConfigUpd.setUpdateBy(SecurityUtils.getUsername());
-            sysConfigMapper.updateConfig(sysConfigUpd);
-        }else {
-            SysConfig sysConfig = new SysConfig();
-            int randomNum = (int) (Math.random() * (1000 - 1 + 1)) + 1;
-            sysConfig.setConfigId((long) randomNum);
-            sysConfig.setConfigType("Y");
-            sysConfig.setConfigName("鎶芥按浜�");
-            sysConfig.setConfigKey("well");
-            sysConfig.setConfigValue(String.valueOf(num));
-            sysConfig.setCreateBy(SecurityUtils.getUsername());
-            sysConfigMapper.insertConfig(sysConfig);
-        }
         return Results.succeed("娣诲姞鎴愬姛锛�");
     }
+
+    @Override
+    public Results factorySelect() {
+        JSONObject jsonObject = new JSONObject();
+        QueryWrapper<SysConfig> queryWrapper = new QueryWrapper<>();
+        queryWrapper.in("config_key","area","store","people","well","depot","unit");
+        List<SysConfig> list = sysConfigMapper.selectList(queryWrapper);
+        for (int i = 0; i < list.size(); i++) {
+            SysConfig sysConfig = list.get(i);
+            jsonObject.put(sysConfig.getConfigKey(),sysConfig.getConfigValue());
+        }
+        //璁板綍well琛ㄤ腑oil_production涓烘娊娌规満鐨勬暟鎹湁澶氬皯鏉�
+        QueryWrapper<ArdAlarmpointsWell> queryWrapperWell = new QueryWrapper<>();
+        queryWrapperWell.eq("oil_production","鎶芥补鏈�");
+        int num = wellMapper.selectCount(queryWrapperWell);
+        jsonObject.put("well",String.valueOf(num));
+        return Results.succeed(jsonObject);
+    }
+
+    @Override
+    public List<CountVo> stealelecYear(ESParam esParam) {
+        List<CountVo> list = stealelecMapper.stealelecYear(esParam);
+        return es(list);
+    }
+
+    @Override
+    public List<CountVo> cameraYear(ESParam esParam) {
+        List<CountVo> list = cameraMapper.cameraYear(esParam);
+        return es(list);
+    }
+
+    @Override
+    public List<CountVo> moveYear(ESParam esParam) {
+        List<CountVo> list = moveMapper.moveYear(esParam);
+        return es(list);
+    }
+
+    @Override
+    public List<CountVo> fireYear(ESParam esParam) {
+        List<CountVo> list = fireMapper.fileYear(esParam);
+        return es(list);
+    }
+
+    @Override
+    public List<CountVo> externalYear(ESParam esParam) {
+        List<CountVo> list = externalMapper.externalYear(esParam);
+        return es(list);
+    }
+
+    @Override
+    public List<CountVo> accessYear(ESParam esParam) {
+        List<CountVo> list = accessMapper.accessYear(esParam);
+        return es(list);
+    }
+
+    @Override
+    public List<CountVo> apponekeyYear(ESParam esParam) {
+        List<CountVo> list = apponekeyMapper.apponekeyYear(esParam);
+        return es(list);
+    }
+
+    @Override
+    public List<CountVo> pumpYear(ESParam esParam) {
+        List<CountVo> list = pumpMapper.pumpYear(esParam);
+        return es(list);
+    }
+
+    @Override
+    public List<CountVo> wallYear(ESParam esParam) {
+        List<CountVo> list = wallMapper.wallYear(esParam);
+        return es(list);
+    }
+
+    @Override
+    public List<CountVo> digitizationYear(ESParam esParam) {
+        List<CountVo> list = digitization3Mapper.digitizationYear(esParam);
+        return es(list);
+    }
+
+    @Override
+    public List<CountVo> tubeYear(ESParam esParam) {
+        List<CountVo> list = tubeMapper.tubeYear(esParam);
+        return es(list);
+    }
+
+    @Override
+    public List<CountVo> stealelecMonth(ESParam esParam) {
+        List<CountVo> list = stealelecMapper.stealelecMonth(esParam);
+        return esMonth(list,esParam.getEnd());
+    }
+
+    @Override
+    public List<CountVo> cameraMonth(ESParam esParam) {
+        List<CountVo> list = cameraMapper.cameraMonth(esParam);
+        return esMonth(list,esParam.getEnd());
+    }
+
+    @Override
+    public List<CountVo> moveMonth(ESParam esParam) {
+        List<CountVo> list = moveMapper.moveMonth(esParam);
+        return esMonth(list,esParam.getEnd());
+    }
+
+    @Override
+    public List<CountVo> fireMonth(ESParam esParam) {
+        List<CountVo> list = fireMapper.fileMonth(esParam);
+        return esMonth(list,esParam.getEnd());
+    }
+
+    @Override
+    public List<CountVo> externalMonth(ESParam esParam) {
+        List<CountVo> list = externalMapper.externalMonth(esParam);
+        return esMonth(list,esParam.getEnd());
+    }
+
+    @Override
+    public List<CountVo> accessMonth(ESParam esParam) {
+        List<CountVo> list = accessMapper.accessMonth(esParam);
+        return esMonth(list,esParam.getEnd());
+    }
+
+    @Override
+    public List<CountVo> apponekeyMonth(ESParam esParam) {
+        List<CountVo> list = apponekeyMapper.apponekeyMonth(esParam);
+        return esMonth(list,esParam.getEnd());
+    }
+
+    @Override
+    public List<CountVo> pumpMonth(ESParam esParam) {
+        List<CountVo> list = pumpMapper.pumpMonth(esParam);
+        return esMonth(list,esParam.getEnd());
+    }
+
+    @Override
+    public List<CountVo> wallMonth(ESParam esParam) {
+        List<CountVo> list = wallMapper.wallMonth(esParam);
+        return esMonth(list,esParam.getEnd());
+    }
+
+    @Override
+    public List<CountVo> digitizationMonth(ESParam esParam) {
+        List<CountVo> list = digitization3Mapper.digitizationMonth(esParam);
+        return esMonth(list,esParam.getEnd());
+    }
+
+    @Override
+    public List<CountVo> tubeMonth(ESParam esParam) {
+        List<CountVo> list = tubeMapper.tubeMonth(esParam);
+        return esMonth(list,esParam.getEnd());
+    }
+
+    public List<CountVo> es(List<CountVo> list){
+        for (int i = 1; i <= 12 ; i++) {
+            String month;
+            if(i<=10){
+                month = "0"+i;
+            }else {
+                month = String.valueOf(i);
+            }
+            Boolean bo = false;
+            for (int j = 0; j < list.size(); j++) {
+                CountVo countVo = list.get(j);
+                String mon = countVo.getDate();
+                if(mon.equals(month)){
+                    bo = true;
+                }
+            }
+            if(!bo){
+                CountVo countVo = new CountVo();
+                countVo.setDate(month);
+                countVo.setCount(0);
+                list.add(countVo);
+            }
+        }
+        return list;
+    }
+
+    public List<CountVo> esMonth(List<CountVo> list,String end){
+        Integer day = Integer.valueOf(end.substring(end.length() - 2));
+        for (int i = 1; i <= day ; i++) {
+            String d;
+            if(i<=10){
+                d = "0"+i;
+            }else {
+                d = String.valueOf(i);
+            }
+            Boolean bo = false;
+            for (int j = 0; j < list.size(); j++) {
+                CountVo countVo = list.get(j);
+                String mon = countVo.getDate();
+                if(mon.equals(d)){
+                    bo = true;
+                }
+            }
+            if(!bo){
+                CountVo countVo = new CountVo();
+                countVo.setDate(d);
+                countVo.setCount(0);
+                list.add(countVo);
+            }
+        }
+        return list;
+    }
 }

--
Gitblit v1.9.3