Quellcode durchsuchen

Merge branch 'master' of http://60.171.161.56:20000/tjf/deviceManage

wangmengwei vor 11 Stunden
Ursprung
Commit
f261928f9b
23 geänderte Dateien mit 995 neuen und 369 gelöschten Zeilen
  1. 40 0
      ruoyi-admin/src/main/java/com/ruoyi/web/controller/manage/IndexController.java
  2. 20 33
      ruoyi-admin/src/main/java/com/ruoyi/web/controller/manage/NetworkManageController.java
  3. 21 34
      ruoyi-admin/src/main/java/com/ruoyi/web/controller/manage/WarnManageController.java
  4. 10 19
      ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysDictDataController.java
  5. 3 6
      ruoyi-admin/src/main/resources/application-prod.yml
  6. 12 7
      ruoyi-admin/src/main/resources/application.yml
  7. 7 0
      ruoyi-common/src/main/java/com/ruoyi/common/constant/Constants.java
  8. 67 57
      ruoyi-common/src/main/java/com/ruoyi/common/utils/DateUtils.java
  9. 0 1
      ruoyi-framework/src/main/java/com/ruoyi/framework/config/SecurityConfig.java
  10. 54 37
      ruoyi-system/src/main/java/com/ruoyi/manage/domain/ChannelNumber.java
  11. 48 20
      ruoyi-system/src/main/java/com/ruoyi/manage/domain/EquipmentManage.java
  12. 132 60
      ruoyi-system/src/main/java/com/ruoyi/manage/domain/WarnManage.java
  13. 1 1
      ruoyi-system/src/main/java/com/ruoyi/manage/mapper/EquipmentManageMapper.java
  14. 2 1
      ruoyi-system/src/main/java/com/ruoyi/manage/mapper/WarnManageMapper.java
  15. 14 1
      ruoyi-system/src/main/java/com/ruoyi/manage/service/IWarnManageService.java
  16. 28 5
      ruoyi-system/src/main/java/com/ruoyi/manage/service/impl/ChannelNumberServiceImpl.java
  17. 4 4
      ruoyi-system/src/main/java/com/ruoyi/manage/service/impl/EquipmentManageServiceImpl.java
  18. 6 5
      ruoyi-system/src/main/java/com/ruoyi/manage/service/impl/ParameterSetServiceImpl.java
  19. 344 23
      ruoyi-system/src/main/java/com/ruoyi/manage/service/impl/WarnManageServiceImpl.java
  20. 32 3
      ruoyi-system/src/main/java/com/ruoyi/mqtt/service/MqttMessageListener.java
  21. 2 1
      ruoyi-system/src/main/java/com/ruoyi/mqtt/service/MqttService.java
  22. 36 3
      ruoyi-system/src/main/resources/mapper/manage/EquipmentManageMapper.xml
  23. 112 48
      ruoyi-system/src/main/resources/mapper/manage/WarnManageMapper.xml

+ 40 - 0
ruoyi-admin/src/main/java/com/ruoyi/web/controller/manage/IndexController.java

@@ -0,0 +1,40 @@
+package com.ruoyi.web.controller.manage;
+
+import com.ruoyi.common.core.controller.BaseController;
+import com.ruoyi.common.core.domain.AjaxResult;
+import com.ruoyi.manage.service.IWarnManageService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+/**
+ * @Author: tjf
+ * @Date: 2025/6/19 星期四 15:00
+ * @Describe: 主页统计
+ */
+@RestController
+@RequestMapping("/manage/index")
+public class IndexController extends BaseController {
+    @Autowired
+    private IWarnManageService warnManageService;
+
+    /**
+     * 告警内容+部门统计
+     */
+    @GetMapping("/warnManageIndex")
+    public AjaxResult warnManageIndex() {
+        return  warnManageService.getWarnManageIndex();
+    }
+
+
+    /**
+     * 年度告警统计
+     */
+    @GetMapping("/warnManageIndexYear/{year}")
+    public AjaxResult warnManageIndexYear(@PathVariable String year) {
+        return  warnManageService.warnManageIndexYear(year);
+    }
+
+}

+ 20 - 33
ruoyi-admin/src/main/java/com/ruoyi/web/controller/manage/NetworkManageController.java

@@ -1,25 +1,19 @@
 package com.ruoyi.web.controller.manage;
 
-import java.util.List;
-import javax.servlet.http.HttpServletResponse;
-import org.springframework.security.access.prepost.PreAuthorize;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.PutMapping;
-import org.springframework.web.bind.annotation.DeleteMapping;
-import org.springframework.web.bind.annotation.PathVariable;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
 import com.ruoyi.common.annotation.Log;
 import com.ruoyi.common.core.controller.BaseController;
 import com.ruoyi.common.core.domain.AjaxResult;
+import com.ruoyi.common.core.page.TableDataInfo;
 import com.ruoyi.common.enums.BusinessType;
+import com.ruoyi.common.utils.poi.ExcelUtil;
 import com.ruoyi.manage.domain.NetworkManage;
 import com.ruoyi.manage.service.INetworkManageService;
-import com.ruoyi.common.utils.poi.ExcelUtil;
-import com.ruoyi.common.core.page.TableDataInfo;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.web.bind.annotation.*;
+
+import javax.servlet.http.HttpServletResponse;
+import java.util.List;
 
 /**
  * 网络管理Controller
@@ -29,18 +23,16 @@ import com.ruoyi.common.core.page.TableDataInfo;
  */
 @RestController
 @RequestMapping("/manage/NetworkManage")
-public class NetworkManageController extends BaseController
-{
+public class NetworkManageController extends BaseController {
     @Autowired
     private INetworkManageService networkManageService;
 
-/**
- * 查询网络管理列表
- */
-@PreAuthorize("@ss.hasPermi('manage:NetworkManage:list')")
-@GetMapping("/list")
-    public TableDataInfo list(NetworkManage networkManage)
-    {
+    /**
+     * 查询网络管理列表
+     */
+    @PreAuthorize("@ss.hasPermi('manage:NetworkManage:list')")
+    @GetMapping("/list")
+    public TableDataInfo list(NetworkManage networkManage) {
         startPage();
         List<NetworkManage> list = networkManageService.selectNetworkManageList(networkManage);
         return getDataTable(list);
@@ -52,8 +44,7 @@ public class NetworkManageController extends BaseController
     @PreAuthorize("@ss.hasPermi('manage:NetworkManage:export')")
     @Log(title = "网络管理", businessType = BusinessType.EXPORT)
     @PostMapping("/export")
-    public void export(HttpServletResponse response, NetworkManage networkManage)
-    {
+    public void export(HttpServletResponse response, NetworkManage networkManage) {
         List<NetworkManage> list = networkManageService.selectNetworkManageList(networkManage);
         ExcelUtil<NetworkManage> util = new ExcelUtil<NetworkManage>(NetworkManage.class);
         util.exportExcel(response, list, "网络管理数据");
@@ -64,8 +55,7 @@ public class NetworkManageController extends BaseController
      */
     @PreAuthorize("@ss.hasPermi('manage:NetworkManage:query')")
     @GetMapping(value = "/{networkId}")
-    public AjaxResult getInfo(@PathVariable("networkId") Long networkId)
-    {
+    public AjaxResult getInfo(@PathVariable("networkId") Long networkId) {
         return success(networkManageService.selectNetworkManageByNetworkId(networkId));
     }
 
@@ -75,8 +65,7 @@ public class NetworkManageController extends BaseController
     @PreAuthorize("@ss.hasPermi('manage:NetworkManage:add')")
     @Log(title = "网络管理", businessType = BusinessType.INSERT)
     @PostMapping
-    public AjaxResult add(@RequestBody NetworkManage networkManage)
-    {
+    public AjaxResult add(@RequestBody NetworkManage networkManage) {
         return toAjax(networkManageService.insertNetworkManage(networkManage));
     }
 
@@ -86,8 +75,7 @@ public class NetworkManageController extends BaseController
     @PreAuthorize("@ss.hasPermi('manage:NetworkManage:edit')")
     @Log(title = "网络管理", businessType = BusinessType.UPDATE)
     @PostMapping("/put")
-    public AjaxResult edit(@RequestBody NetworkManage networkManage)
-    {
+    public AjaxResult edit(@RequestBody NetworkManage networkManage) {
         return toAjax(networkManageService.updateNetworkManage(networkManage));
     }
 
@@ -97,8 +85,7 @@ public class NetworkManageController extends BaseController
     @PreAuthorize("@ss.hasPermi('manage:NetworkManage:remove')")
     @Log(title = "网络管理", businessType = BusinessType.DELETE)
     @GetMapping("/delete/{networkIds}")
-    public AjaxResult remove(@PathVariable Long[] networkIds)
-    {
+    public AjaxResult remove(@PathVariable Long[] networkIds) {
         return toAjax(networkManageService.deleteNetworkManageByNetworkIds(networkIds));
     }
 }

+ 21 - 34
ruoyi-admin/src/main/java/com/ruoyi/web/controller/manage/WarnManageController.java

@@ -1,46 +1,38 @@
 package com.ruoyi.web.controller.manage;
 
-import java.util.List;
-import javax.servlet.http.HttpServletResponse;
-import org.springframework.security.access.prepost.PreAuthorize;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.PutMapping;
-import org.springframework.web.bind.annotation.DeleteMapping;
-import org.springframework.web.bind.annotation.PathVariable;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
 import com.ruoyi.common.annotation.Log;
 import com.ruoyi.common.core.controller.BaseController;
 import com.ruoyi.common.core.domain.AjaxResult;
+import com.ruoyi.common.core.page.TableDataInfo;
 import com.ruoyi.common.enums.BusinessType;
+import com.ruoyi.common.utils.poi.ExcelUtil;
 import com.ruoyi.manage.domain.WarnManage;
 import com.ruoyi.manage.service.IWarnManageService;
-import com.ruoyi.common.utils.poi.ExcelUtil;
-import com.ruoyi.common.core.page.TableDataInfo;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.web.bind.annotation.*;
+
+import javax.servlet.http.HttpServletResponse;
+import java.util.List;
 
 /**
  * 告警管理Controller
  *
  * @author boman
- * @date 2025-05-07
+ * @date 2025-06-19
  */
 @RestController
 @RequestMapping("/manage/warnManage")
-public class WarnManageController extends BaseController
-{
+public class WarnManageController extends BaseController {
     @Autowired
     private IWarnManageService warnManageService;
 
-/**
- * 查询告警管理列表
- */
-@PreAuthorize("@ss.hasPermi('manage:warnManage:list')")
-@GetMapping("/list")
-    public TableDataInfo list(WarnManage warnManage)
-    {
+    /**
+     * 查询告警管理列表
+     */
+    @PreAuthorize("@ss.hasPermi('manage:warnManage:list')")
+    @GetMapping("/list")
+    public TableDataInfo list(WarnManage warnManage) {
         startPage();
         List<WarnManage> list = warnManageService.selectWarnManageList(warnManage);
         return getDataTable(list);
@@ -52,8 +44,7 @@ public class WarnManageController extends BaseController
     @PreAuthorize("@ss.hasPermi('manage:warnManage:export')")
     @Log(title = "告警管理", businessType = BusinessType.EXPORT)
     @PostMapping("/export")
-    public void export(HttpServletResponse response, WarnManage warnManage)
-    {
+    public void export(HttpServletResponse response, WarnManage warnManage) {
         List<WarnManage> list = warnManageService.selectWarnManageList(warnManage);
         ExcelUtil<WarnManage> util = new ExcelUtil<WarnManage>(WarnManage.class);
         util.exportExcel(response, list, "告警管理数据");
@@ -64,8 +55,7 @@ public class WarnManageController extends BaseController
      */
     @PreAuthorize("@ss.hasPermi('manage:warnManage:query')")
     @GetMapping(value = "/{warnId}")
-    public AjaxResult getInfo(@PathVariable("warnId") Long warnId)
-    {
+    public AjaxResult getInfo(@PathVariable("warnId") Long warnId) {
         return success(warnManageService.selectWarnManageByWarnId(warnId));
     }
 
@@ -75,8 +65,7 @@ public class WarnManageController extends BaseController
     @PreAuthorize("@ss.hasPermi('manage:warnManage:add')")
     @Log(title = "告警管理", businessType = BusinessType.INSERT)
     @PostMapping
-    public AjaxResult add(@RequestBody WarnManage warnManage)
-    {
+    public AjaxResult add(@RequestBody WarnManage warnManage) {
         return toAjax(warnManageService.insertWarnManage(warnManage));
     }
 
@@ -86,8 +75,7 @@ public class WarnManageController extends BaseController
     @PreAuthorize("@ss.hasPermi('manage:warnManage:edit')")
     @Log(title = "告警管理", businessType = BusinessType.UPDATE)
     @PostMapping("/put")
-    public AjaxResult edit(@RequestBody WarnManage warnManage)
-    {
+    public AjaxResult edit(@RequestBody WarnManage warnManage) {
         return toAjax(warnManageService.updateWarnManage(warnManage));
     }
 
@@ -97,8 +85,7 @@ public class WarnManageController extends BaseController
     @PreAuthorize("@ss.hasPermi('manage:warnManage:remove')")
     @Log(title = "告警管理", businessType = BusinessType.DELETE)
     @GetMapping("/delete/{warnIds}")
-    public AjaxResult remove(@PathVariable Long[] warnIds)
-    {
+    public AjaxResult remove(@PathVariable Long[] warnIds) {
         return toAjax(warnManageService.deleteWarnManageByWarnIds(warnIds));
     }
 }

+ 10 - 19
ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysDictDataController.java

@@ -21,13 +21,12 @@ import java.util.List;
 
 /**
  * 数据字典信息
- * 
+ *
  * @author ruoyi
  */
 @RestController
 @RequestMapping("/system/dict/data")
-public class SysDictDataController extends BaseController
-{
+public class SysDictDataController extends BaseController {
     @Autowired
     private ISysDictDataService dictDataService;
 
@@ -36,8 +35,7 @@ public class SysDictDataController extends BaseController
 
     @PreAuthorize("@ss.hasPermi('system:dict:list')")
     @GetMapping("/list")
-    public TableDataInfo list(SysDictData dictData)
-    {
+    public TableDataInfo list(SysDictData dictData) {
         startPage();
         List<SysDictData> list = dictDataService.selectDictDataList(dictData);
         return getDataTable(list);
@@ -46,8 +44,7 @@ public class SysDictDataController extends BaseController
     @Log(title = "字典数据", businessType = BusinessType.EXPORT)
     @PreAuthorize("@ss.hasPermi('system:dict:export')")
     @PostMapping("/export")
-    public void export(HttpServletResponse response, SysDictData dictData)
-    {
+    public void export(HttpServletResponse response, SysDictData dictData) {
         List<SysDictData> list = dictDataService.selectDictDataList(dictData);
         ExcelUtil<SysDictData> util = new ExcelUtil<SysDictData>(SysDictData.class);
         util.exportExcel(response, list, "字典数据");
@@ -58,8 +55,7 @@ public class SysDictDataController extends BaseController
      */
     @PreAuthorize("@ss.hasPermi('system:dict:query')")
     @GetMapping(value = "/{dictCode}")
-    public AjaxResult getInfo(@PathVariable Long dictCode)
-    {
+    public AjaxResult getInfo(@PathVariable Long dictCode) {
         return success(dictDataService.selectDictDataById(dictCode));
     }
 
@@ -67,11 +63,9 @@ public class SysDictDataController extends BaseController
      * 根据字典类型查询字典数据信息
      */
     @GetMapping(value = "/type/{dictType}")
-    public AjaxResult dictType(@PathVariable String dictType)
-    {
+    public AjaxResult dictType(@PathVariable String dictType) {
         List<SysDictData> data = dictTypeService.selectDictDataByType(dictType);
-        if (StringUtils.isNull(data))
-        {
+        if (StringUtils.isNull(data)) {
             data = new ArrayList<SysDictData>();
         }
         return success(data);
@@ -83,8 +77,7 @@ public class SysDictDataController extends BaseController
     @PreAuthorize("@ss.hasPermi('system:dict:add')")
     @Log(title = "字典数据", businessType = BusinessType.INSERT)
     @PostMapping
-    public AjaxResult add(@Validated @RequestBody SysDictData dict)
-    {
+    public AjaxResult add(@Validated @RequestBody SysDictData dict) {
         dict.setCreateBy(getUsername());
         return toAjax(dictDataService.insertDictData(dict));
     }
@@ -95,8 +88,7 @@ public class SysDictDataController extends BaseController
     @PreAuthorize("@ss.hasPermi('system:dict:edit')")
     @Log(title = "字典数据", businessType = BusinessType.UPDATE)
     @PostMapping("/put")
-    public AjaxResult edit(@Validated @RequestBody SysDictData dict)
-    {
+    public AjaxResult edit(@Validated @RequestBody SysDictData dict) {
         dict.setUpdateBy(getUsername());
         return toAjax(dictDataService.updateDictData(dict));
     }
@@ -107,8 +99,7 @@ public class SysDictDataController extends BaseController
     @PreAuthorize("@ss.hasPermi('system:dict:remove')")
     @Log(title = "字典类型", businessType = BusinessType.DELETE)
     @GetMapping("/delete/{dictCodes}")
-    public AjaxResult remove(@PathVariable Long[] dictCodes)
-    {
+    public AjaxResult remove(@PathVariable Long[] dictCodes) {
         dictDataService.deleteDictDataByIds(dictCodes);
         return success();
     }

+ 3 - 6
ruoyi-admin/src/main/resources/application-prod.yml

@@ -9,7 +9,7 @@ ruoyi:
     # 实例演示开关
     demoEnabled: false
     # 文件路径 示例( Windows配置D:/ruoyi/uploadPath,Linux配置 /home/ruoyi/uploadPath)
-    profile: /home/ruoyi/uploadPath/deviceManage
+    profile: /home/boman/uploadPath/deviceManage
     # 获取ip地址开关
     addressEnabled: false
     # 验证码类型 math 数组计算 char 字符验证
@@ -39,7 +39,7 @@ spring:
         # 端口,默认为6379
         port: 6379
         # 数据库索引
-        database: 6
+        database: 1
         # 密码
         password: D3fQYAsw
         # 连接超时时间
@@ -63,7 +63,7 @@ spring:
             master:
                 url: jdbc:mysql://127.0.0.1:3306/device_manage?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&nullCatalogMeansCurrent=true
                 username: root
-                password: zhaoshang@2018
+                password: 1q2w!Q@W
             # 从库数据源
             slave:
                 # 从数据源开关/默认关闭
@@ -114,6 +114,3 @@ spring:
                 wall:
                     config:
                         multi-statement-allow: true
-
-
-#极光推送

+ 12 - 7
ruoyi-admin/src/main/resources/application.yml

@@ -39,7 +39,7 @@ token:
   # 令牌自定义标识
   header: Authorization
   # 令牌密钥
-  secret: abcdefghijklmnopqrstuvwxyz
+  secret: abcdefghijklmnopqrstuvwxyz123
   # 令牌有效期(默认30分钟)
   expireTime: 720
 
@@ -76,12 +76,17 @@ xss:
 
 # MQTT配置
 mqtt:
-  server-uri: tcp://13.229.167.76:1883
-  #  server-uri: tcp://127.0.0.1:1883
-  client-id: JavaClient
-  username:
-  password:
-  default-topic: test/topic
+#  server-uri: tcp://13.229.167.76:1883
+  server-uri: tcp://60.171.161.56:20009
+#  server-uri: tcp://127.0.0.1:1883
+#  server-uri: tcp://192.168.101.147:1883
+#  server-uri: tcp://127.0.0.1:1883
+  client-id: JavaClientBoMan
+  username: admin
+  password: 1qaz!QAZ
+#  username:
+#  password:
+  default-topic: toServer_leaveStat,toServer_playStat
   default-qos: 1
   timeout: 30
   keep-alive: 60

+ 7 - 0
ruoyi-common/src/main/java/com/ruoyi/common/constant/Constants.java

@@ -173,6 +173,11 @@ public class Constants {
 
     public static final String Y = "Y";
     public static final String N = "N";
+    public static final String ZERO = "0";
+    public static final String ONE = "1";
+    public static final String TWO = "2";
+    //上月告警统计key
+    public static final String WARN_LAST_MONTH = "warn_last_month:";
     //坐标
     public static final String DETECTION_RECT = "detection/rect";
     //离岗时间
@@ -185,4 +190,6 @@ public class Constants {
     public static final String DETECTION_PLAYRATE = "detection/playrate";
     //rtsp地址
     public static final String DETECTION_RTSP = "detection/rtsp";
+    //首页统计折线图往期年份数据
+    public static final String WARN_MANAGE_LAST_YEAR = "warn_manage_last_year:";
 }

+ 67 - 57
ruoyi-common/src/main/java/com/ruoyi/common/utils/DateUtils.java

@@ -1,23 +1,20 @@
 package com.ruoyi.common.utils;
 
+import org.apache.commons.lang3.time.DateFormatUtils;
+
 import java.lang.management.ManagementFactory;
 import java.text.ParseException;
 import java.text.SimpleDateFormat;
-import java.time.LocalDate;
-import java.time.LocalDateTime;
-import java.time.LocalTime;
-import java.time.ZoneId;
-import java.time.ZonedDateTime;
+import java.time.*;
+import java.util.Calendar;
 import java.util.Date;
-import org.apache.commons.lang3.time.DateFormatUtils;
 
 /**
  * 时间工具类
- * 
+ *
  * @author ruoyi
  */
-public class DateUtils extends org.apache.commons.lang3.time.DateUtils
-{
+public class DateUtils extends org.apache.commons.lang3.time.DateUtils {
     public static String YYYY = "yyyy";
 
     public static String YYYY_MM = "yyyy-MM";
@@ -29,63 +26,81 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils
     public static String YYYY_MM_DD_HH_MM_SS = "yyyy-MM-dd HH:mm:ss";
 
     private static String[] parsePatterns = {
-            "yyyy-MM-dd", "yyyy-MM-dd HH:mm:ss", "yyyy-MM-dd HH:mm", "yyyy-MM", 
+            "yyyy-MM-dd", "yyyy-MM-dd HH:mm:ss", "yyyy-MM-dd HH:mm", "yyyy-MM",
             "yyyy/MM/dd", "yyyy/MM/dd HH:mm:ss", "yyyy/MM/dd HH:mm", "yyyy/MM",
             "yyyy.MM.dd", "yyyy.MM.dd HH:mm:ss", "yyyy.MM.dd HH:mm", "yyyy.MM"};
 
     /**
      * 获取当前Date型日期
-     * 
+     *
      * @return Date() 当前日期
      */
-    public static Date getNowDate()
-    {
+    public static Date getNowDate() {
         return new Date();
     }
 
     /**
      * 获取当前日期, 默认格式为yyyy-MM-dd
-     * 
+     *
      * @return String
      */
-    public static String getDate()
-    {
+    public static String getDate() {
         return dateTimeNow(YYYY_MM_DD);
     }
 
-    public static final String getTime()
-    {
+    /**
+     * 获取当前日期, 默认格式为yyyy-MM-dd
+     *
+     * @return String
+     */
+    public static String getMonth() {
+        return dateTimeNow(YYYY_MM);
+    }
+
+    /**
+     * 获取当前日期, 默认格式为yyyy-MM-dd
+     *
+     * @return String
+     */
+    public static String getYear() {
+        return dateTimeNow(YYYY);
+    }
+
+    /**
+     * 获取上月日期
+     *
+     * @return
+     */
+    public static Date getLastMonth() {
+        Calendar calendar = Calendar.getInstance();
+        calendar.add(Calendar.MONTH, -1);
+        return calendar.getTime();
+    }
+
+    public static final String getTime() {
         return dateTimeNow(YYYY_MM_DD_HH_MM_SS);
     }
 
-    public static final String dateTimeNow()
-    {
+    public static final String dateTimeNow() {
         return dateTimeNow(YYYYMMDDHHMMSS);
     }
 
-    public static final String dateTimeNow(final String format)
-    {
+    public static final String dateTimeNow(final String format) {
         return parseDateToStr(format, new Date());
     }
 
-    public static final String dateTime(final Date date)
-    {
+    public static final String dateTime(final Date date) {
         return parseDateToStr(YYYY_MM_DD, date);
     }
 
-    public static final String parseDateToStr(final String format, final Date date)
-    {
+    public static final String parseDateToStr(final String format, final Date date) {
         return new SimpleDateFormat(format).format(date);
     }
 
-    public static final Date dateTime(final String format, final String ts)
-    {
-        try
-        {
+    public static final Date dateTime(final String format, final String ts) {
+        try {
             return new SimpleDateFormat(format).parse(ts);
-        }
-        catch (ParseException e)
-        {
+        } catch (ParseException e) {
             throw new RuntimeException(e);
         }
     }
@@ -93,8 +108,7 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils
     /**
      * 日期路径 即年/月/日 如2018/08/08
      */
-    public static final String datePath()
-    {
+    public static final String datePath() {
         Date now = new Date();
         return DateFormatUtils.format(now, "yyyy/MM/dd");
     }
@@ -102,8 +116,7 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils
     /**
      * 日期路径 即年/月/日 如20180808
      */
-    public static final String dateTime()
-    {
+    public static final String dateTime() {
         Date now = new Date();
         return DateFormatUtils.format(now, "yyyyMMdd");
     }
@@ -111,18 +124,13 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils
     /**
      * 日期型字符串转化为日期 格式
      */
-    public static Date parseDate(Object str)
-    {
-        if (str == null)
-        {
+    public static Date parseDate(Object str) {
+        if (str == null) {
             return null;
         }
-        try
-        {
+        try {
             return parseDate(str.toString(), parsePatterns);
-        }
-        catch (ParseException e)
-        {
+        } catch (ParseException e) {
             return null;
         }
     }
@@ -130,8 +138,7 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils
     /**
      * 获取服务器启动时间
      */
-    public static Date getServerStartDate()
-    {
+    public static Date getServerStartDate() {
         long time = ManagementFactory.getRuntimeMXBean().getStartTime();
         return new Date(time);
     }
@@ -139,20 +146,18 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils
     /**
      * 计算相差天数
      */
-    public static int differentDaysByMillisecond(Date date1, Date date2)
-    {
+    public static int differentDaysByMillisecond(Date date1, Date date2) {
         return Math.abs((int) ((date2.getTime() - date1.getTime()) / (1000 * 3600 * 24)));
     }
 
     /**
      * 计算时间差
      *
-     * @param endDate 最后时间
+     * @param endDate   最后时间
      * @param startTime 开始时间
      * @return 时间差(天/小时/分钟)
      */
-    public static String timeDistance(Date endDate, Date startTime)
-    {
+    public static String timeDistance(Date endDate, Date startTime) {
         long nd = 1000 * 24 * 60 * 60;
         long nh = 1000 * 60 * 60;
         long nm = 1000 * 60;
@@ -173,8 +178,7 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils
     /**
      * 增加 LocalDateTime ==> Date
      */
-    public static Date toDate(LocalDateTime temporalAccessor)
-    {
+    public static Date toDate(LocalDateTime temporalAccessor) {
         ZonedDateTime zdt = temporalAccessor.atZone(ZoneId.systemDefault());
         return Date.from(zdt.toInstant());
     }
@@ -182,10 +186,16 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils
     /**
      * 增加 LocalDate ==> Date
      */
-    public static Date toDate(LocalDate temporalAccessor)
-    {
+    public static Date toDate(LocalDate temporalAccessor) {
         LocalDateTime localDateTime = LocalDateTime.of(temporalAccessor, LocalTime.of(0, 0, 0));
         ZonedDateTime zdt = localDateTime.atZone(ZoneId.systemDefault());
         return Date.from(zdt.toInstant());
     }
+
+    public static int getMonth(Date date) {
+        Calendar cal = Calendar.getInstance();
+        cal.setTime(date);
+        return cal.get(Calendar.MONTH) + 1;
+    }
+
 }

+ 0 - 1
ruoyi-framework/src/main/java/com/ruoyi/framework/config/SecurityConfig.java

@@ -115,7 +115,6 @@ public class SecurityConfig
                     // 静态资源,可匿名访问
                     .antMatchers(HttpMethod.GET, "/", "/*.html", "/**/*.html", "/**/*.css", "/**/*.js", "/profile/**").permitAll()
                     .antMatchers("/swagger-ui.html", "/swagger-resources/**", "/webjars/**", "/*/api-docs", "/druid/**").permitAll()
-                    .antMatchers("/hk/**").permitAll()
                     // 除上面外的所有请求全部需要鉴权认证
                     .anyRequest().authenticated();
             })

+ 54 - 37
ruoyi-system/src/main/java/com/ruoyi/manage/domain/ChannelNumber.java

@@ -7,28 +7,40 @@ import javax.validation.constraints.NotNull;
 
 /**
  * 通道管理对象 channel_number
- * 
+ *
  * @author boman
  * @date 2025-05-07
  */
-public class ChannelNumber extends BaseEntity
-{
+public class ChannelNumber extends BaseEntity {
     private static final long serialVersionUID = 1L;
 
-    /** 通道ID */
+    /**
+     * 通道ID
+     */
     private Long channelId;
-
-    /** 设备ID */
+    /**
+     * 设备Ip
+     */
+    private String equipmentIp;
+    /**
+     * 设备ID
+     */
     @NotNull
     private Long equipmentId;
-    /** 设备编号 */
+    /**
+     * 设备编号
+     */
     @Excel(name = "设备编号")
     private String equipmentNum;
 
-    /** 设备名称 */
+    /**
+     * 设备名称
+     */
     @Excel(name = "设备名称")
     private String equipmentName;
-    /** 通道编号 */
+    /**
+     * 通道编号
+     */
     @Excel(name = "通道编号")
     @NotNull
     private String channelNum;
@@ -38,7 +50,9 @@ public class ChannelNumber extends BaseEntity
      */
     private String port;
 
-    /** 视频地址 */
+    /**
+     * 视频地址
+     */
     @Excel(name = "视频地址")
     private String videoAddress;
     /**
@@ -50,15 +64,21 @@ public class ChannelNumber extends BaseEntity
      */
     private String password;
 
-    /** 探测协议类型 */
+    /**
+     * 探测协议类型
+     */
     @Excel(name = "探测协议类型")
     private String protocolType;
 
-    /** 通道描述 */
+    /**
+     * 通道描述
+     */
     @Excel(name = "通道描述")
     private String channelDetails;
 
-    /** 删除标志(0代表存在 1代表删除) */
+    /**
+     * 删除标志(0代表存在 1代表删除)
+     */
     private String delFlag;
     /**
      * 是否设置过参数 N Y 不在数据库中
@@ -70,6 +90,14 @@ public class ChannelNumber extends BaseEntity
      */
     private ParameterSet parameterSet;
 
+    public String getEquipmentIp() {
+        return equipmentIp;
+    }
+
+    public void setEquipmentIp(String equipmentIp) {
+        this.equipmentIp = equipmentIp;
+    }
+
     public ParameterSet getParameterSet() {
         return parameterSet;
     }
@@ -134,63 +162,51 @@ public class ChannelNumber extends BaseEntity
         this.password = password;
     }
 
-    public void setChannelId(Long channelId)
-    {
+    public void setChannelId(Long channelId) {
         this.channelId = channelId;
     }
 
-    public Long getChannelId() 
-    {
+    public Long getChannelId() {
         return channelId;
     }
 
-    public void setChannelNum(String channelNum) 
-    {
+    public void setChannelNum(String channelNum) {
         this.channelNum = channelNum;
     }
 
-    public String getChannelNum() 
-    {
+    public String getChannelNum() {
         return channelNum;
     }
 
-    public void setVideoAddress(String videoAddress) 
-    {
+    public void setVideoAddress(String videoAddress) {
         this.videoAddress = videoAddress;
     }
 
-    public String getVideoAddress() 
-    {
+    public String getVideoAddress() {
         return videoAddress;
     }
 
-    public void setProtocolType(String protocolType) 
-    {
+    public void setProtocolType(String protocolType) {
         this.protocolType = protocolType;
     }
 
-    public String getProtocolType() 
-    {
+    public String getProtocolType() {
         return protocolType;
     }
 
-    public void setChannelDetails(String channelDetails) 
-    {
+    public void setChannelDetails(String channelDetails) {
         this.channelDetails = channelDetails;
     }
 
-    public String getChannelDetails() 
-    {
+    public String getChannelDetails() {
         return channelDetails;
     }
 
-    public void setDelFlag(String delFlag) 
-    {
+    public void setDelFlag(String delFlag) {
         this.delFlag = delFlag;
     }
 
-    public String getDelFlag() 
-    {
+    public String getDelFlag() {
         return delFlag;
     }
 
@@ -198,6 +214,7 @@ public class ChannelNumber extends BaseEntity
     public String toString() {
         return "ChannelNumber{" +
                 "channelId=" + channelId +
+                ", equipmentIp='" + equipmentIp + '\'' +
                 ", equipmentId=" + equipmentId +
                 ", equipmentNum='" + equipmentNum + '\'' +
                 ", equipmentName='" + equipmentName + '\'' +

+ 48 - 20
ruoyi-system/src/main/java/com/ruoyi/manage/domain/EquipmentManage.java

@@ -3,8 +3,6 @@ package com.ruoyi.manage.domain;
 import com.fasterxml.jackson.annotation.JsonFormat;
 import com.ruoyi.common.annotation.Excel;
 import com.ruoyi.common.core.domain.BaseEntity;
-import org.apache.commons.lang3.builder.ToStringBuilder;
-import org.apache.commons.lang3.builder.ToStringStyle;
 
 import javax.validation.constraints.NotNull;
 import java.util.Date;
@@ -21,6 +19,8 @@ public class EquipmentManage extends BaseEntity
 
     /** 设备ID */
     private Long equipmentId;
+    /** 设备Ip */
+    private String equipmentIp;
 
     /** 设备编号 */
     @Excel(name = "设备编号")
@@ -59,7 +59,37 @@ public class EquipmentManage extends BaseEntity
     /** 删除标志(0代表存在 1代表删除) */
     private String delFlag;
 
-    public void setEquipmentId(Long equipmentId) 
+    /** 部门ID */
+    private Long deptId;
+
+    /** 部门名称 */
+    private String deptName;
+
+    public Long getDeptId() {
+        return deptId;
+    }
+
+    public void setDeptId(Long deptId) {
+        this.deptId = deptId;
+    }
+
+    public String getDeptName() {
+        return deptName;
+    }
+
+    public void setDeptName(String deptName) {
+        this.deptName = deptName;
+    }
+
+    public String getEquipmentIp() {
+        return equipmentIp;
+    }
+
+    public void setEquipmentIp(String equipmentIp) {
+        this.equipmentIp = equipmentIp;
+    }
+
+    public void setEquipmentId(Long equipmentId)
     {
         this.equipmentId = equipmentId;
     }
@@ -161,22 +191,20 @@ public class EquipmentManage extends BaseEntity
 
     @Override
     public String toString() {
-        return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
-            .append("equipmentId", getEquipmentId())
-            .append("equipmentNum", getEquipmentNum())
-            .append("equipmentName", getEquipmentName())
-            .append("equipmentType", getEquipmentType())
-            .append("equipmentAddress", getEquipmentAddress())
-            .append("equipmentRegion", getEquipmentRegion())
-            .append("equipmentTime", getEquipmentTime())
-            .append("equipmentImage", getEquipmentImage())
-            .append("runState", getRunState())
-            .append("delFlag", getDelFlag())
-            .append("createBy", getCreateBy())
-            .append("createTime", getCreateTime())
-            .append("updateBy", getUpdateBy())
-            .append("updateTime", getUpdateTime())
-            .append("remark", getRemark())
-            .toString();
+        return "EquipmentManage{" +
+                "equipmentId=" + equipmentId +
+                ", equipmentIp='" + equipmentIp + '\'' +
+                ", equipmentNum='" + equipmentNum + '\'' +
+                ", equipmentName='" + equipmentName + '\'' +
+                ", equipmentType='" + equipmentType + '\'' +
+                ", equipmentAddress='" + equipmentAddress + '\'' +
+                ", equipmentRegion='" + equipmentRegion + '\'' +
+                ", equipmentTime=" + equipmentTime +
+                ", equipmentImage='" + equipmentImage + '\'' +
+                ", runState='" + runState + '\'' +
+                ", delFlag='" + delFlag + '\'' +
+                ", deptId=" + deptId +
+                ", deptName='" + deptName + '\'' +
+                '}';
     }
 }

+ 132 - 60
ruoyi-system/src/main/java/com/ruoyi/manage/domain/WarnManage.java

@@ -3,8 +3,6 @@ package com.ruoyi.manage.domain;
 import com.fasterxml.jackson.annotation.JsonFormat;
 import com.ruoyi.common.annotation.Excel;
 import com.ruoyi.common.core.domain.BaseEntity;
-import org.apache.commons.lang3.builder.ToStringBuilder;
-import org.apache.commons.lang3.builder.ToStringStyle;
 
 import java.util.Date;
 
@@ -12,7 +10,7 @@ import java.util.Date;
  * 告警管理对象 warn_manage
  * 
  * @author boman
- * @date 2025-05-07
+ * @date 2025-06-19
  */
 public class WarnManage extends BaseEntity
 {
@@ -21,28 +19,47 @@ public class WarnManage extends BaseEntity
     /** 告警ID */
     private Long warnId;
 
-    /** 告警类别 */
-    @Excel(name = "告警类别")
-    private String warnType;
+    /** 设备ID */
+    private Long equipmentId;
 
-    /** 告警标识 */
-    @Excel(name = "告警标识")
-    private String warnSign;
+    /** 设备ip */
+    @Excel(name = "设备ip")
+    private String equipmentIp;
+
+    /** 设备名称 */
+    @Excel(name = "设备名称")
+    private String equipmentName;
 
     /** 通道ID */
     @Excel(name = "通道ID")
     private Long channelId;
 
-    /** 视频地址 */
-    @Excel(name = "视频地址")
+    /** 通道编号 */
+    @Excel(name = "通道编号")
+    private String channelNum;
+
+    /** 算法类型 0:离岗 1:玩手机 */
+    @Excel(name = "算法类型 0:离岗 1:玩手机")
+    private String algorithmType;
+
+    /** 算法参数设置的值 */
+    @Excel(name = "算法参数设置的值")
+    private String parameterSet;
+
+    /** 告警视频地址 */
+    @Excel(name = "告警视频地址")
     private String videoAddress;
 
-    /** 上报地址 */
-    @Excel(name = "上报地址")
-    private String reportAddress;
+    /** 告警预览图片 */
+    @Excel(name = "告警预览图片")
+    private String warnImage;
+    /**
+     * 区域名称(画框)
+     */
+    private String rangName;
 
-    /** 上报状态 */
-    @Excel(name = "上报状态")
+    /** 上报状态 0:成功 1:失败 */
+    @Excel(name = "上报状态 0:成功 1:失败")
     private String reportStatus;
 
     /** 告警时间 */
@@ -50,14 +67,48 @@ public class WarnManage extends BaseEntity
     @Excel(name = "告警时间", width = 30, dateFormat = "yyyy-MM-dd")
     private Date warnTime;
 
-    /** 告警预览图片 */
-    @Excel(name = "告警预览图片")
-    private String warnImage;
-
     /** 删除标志(0代表存在 1代表删除) */
     private String delFlag;
 
-    public void setWarnId(Long warnId) 
+    /** 部门ID */
+    private Long deptId;
+
+    /** 部门名称 */
+    private String deptName;
+
+    public Long getEquipmentId() {
+        return equipmentId;
+    }
+
+    public void setEquipmentId(Long equipmentId) {
+        this.equipmentId = equipmentId;
+    }
+
+    public String getRangName() {
+        return rangName;
+    }
+
+    public void setRangName(String rangName) {
+        this.rangName = rangName;
+    }
+
+    public Long getDeptId() {
+        return deptId;
+    }
+
+    public void setDeptId(Long deptId) {
+        this.deptId = deptId;
+    }
+
+    public String getDeptName() {
+        return deptName;
+    }
+
+    public void setDeptName(String deptName) {
+        this.deptName = deptName;
+    }
+
+    public void setWarnId(Long warnId)
     {
         this.warnId = warnId;
     }
@@ -67,24 +118,24 @@ public class WarnManage extends BaseEntity
         return warnId;
     }
 
-    public void setWarnType(String warnType) 
+    public void setEquipmentIp(String equipmentIp) 
     {
-        this.warnType = warnType;
+        this.equipmentIp = equipmentIp;
     }
 
-    public String getWarnType() 
+    public String getEquipmentIp() 
     {
-        return warnType;
+        return equipmentIp;
     }
 
-    public void setWarnSign(String warnSign) 
+    public void setEquipmentName(String equipmentName) 
     {
-        this.warnSign = warnSign;
+        this.equipmentName = equipmentName;
     }
 
-    public String getWarnSign() 
+    public String getEquipmentName() 
     {
-        return warnSign;
+        return equipmentName;
     }
 
     public void setChannelId(Long channelId) 
@@ -97,6 +148,36 @@ public class WarnManage extends BaseEntity
         return channelId;
     }
 
+    public void setChannelNum(String channelNum) 
+    {
+        this.channelNum = channelNum;
+    }
+
+    public String getChannelNum() 
+    {
+        return channelNum;
+    }
+
+    public void setAlgorithmType(String algorithmType) 
+    {
+        this.algorithmType = algorithmType;
+    }
+
+    public String getAlgorithmType() 
+    {
+        return algorithmType;
+    }
+
+    public void setParameterSet(String parameterSet) 
+    {
+        this.parameterSet = parameterSet;
+    }
+
+    public String getParameterSet() 
+    {
+        return parameterSet;
+    }
+
     public void setVideoAddress(String videoAddress) 
     {
         this.videoAddress = videoAddress;
@@ -107,14 +188,14 @@ public class WarnManage extends BaseEntity
         return videoAddress;
     }
 
-    public void setReportAddress(String reportAddress) 
+    public void setWarnImage(String warnImage) 
     {
-        this.reportAddress = reportAddress;
+        this.warnImage = warnImage;
     }
 
-    public String getReportAddress() 
+    public String getWarnImage() 
     {
-        return reportAddress;
+        return warnImage;
     }
 
     public void setReportStatus(String reportStatus) 
@@ -137,16 +218,6 @@ public class WarnManage extends BaseEntity
         return warnTime;
     }
 
-    public void setWarnImage(String warnImage) 
-    {
-        this.warnImage = warnImage;
-    }
-
-    public String getWarnImage() 
-    {
-        return warnImage;
-    }
-
     public void setDelFlag(String delFlag) 
     {
         this.delFlag = delFlag;
@@ -159,22 +230,23 @@ public class WarnManage extends BaseEntity
 
     @Override
     public String toString() {
-        return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
-            .append("warnId", getWarnId())
-            .append("warnType", getWarnType())
-            .append("warnSign", getWarnSign())
-            .append("channelId", getChannelId())
-            .append("videoAddress", getVideoAddress())
-            .append("reportAddress", getReportAddress())
-            .append("reportStatus", getReportStatus())
-            .append("warnTime", getWarnTime())
-            .append("warnImage", getWarnImage())
-            .append("delFlag", getDelFlag())
-            .append("createBy", getCreateBy())
-            .append("createTime", getCreateTime())
-            .append("updateBy", getUpdateBy())
-            .append("updateTime", getUpdateTime())
-            .append("remark", getRemark())
-            .toString();
+        return "WarnManage{" +
+                "warnId=" + warnId +
+                ", equipmentId=" + equipmentId +
+                ", equipmentIp='" + equipmentIp + '\'' +
+                ", equipmentName='" + equipmentName + '\'' +
+                ", channelId=" + channelId +
+                ", channelNum='" + channelNum + '\'' +
+                ", algorithmType='" + algorithmType + '\'' +
+                ", parameterSet='" + parameterSet + '\'' +
+                ", videoAddress='" + videoAddress + '\'' +
+                ", warnImage='" + warnImage + '\'' +
+                ", rangName='" + rangName + '\'' +
+                ", reportStatus='" + reportStatus + '\'' +
+                ", warnTime=" + warnTime +
+                ", delFlag='" + delFlag + '\'' +
+                ", deptId=" + deptId +
+                ", deptName='" + deptName + '\'' +
+                '}';
     }
 }

+ 1 - 1
ruoyi-system/src/main/java/com/ruoyi/manage/mapper/EquipmentManageMapper.java

@@ -27,7 +27,7 @@ public interface EquipmentManageMapper
      * @return 设备管理集合
      */
     public List<EquipmentManage> selectEquipmentManageList(EquipmentManage equipmentManage);
-    public EquipmentManage selectEquipmentManageByEquipmentNum(EquipmentManage equipmentManage);
+    public EquipmentManage selectEquipmentManageByEquipmentIp(EquipmentManage equipmentManage);
 
     /**
      * 新增设备管理

+ 2 - 1
ruoyi-system/src/main/java/com/ruoyi/manage/mapper/WarnManageMapper.java

@@ -8,7 +8,7 @@ import java.util.List;
  * 告警管理Mapper接口
  * 
  * @author boman
- * @date 2025-05-07
+ * @date 2025-06-19
  */
 public interface WarnManageMapper 
 {
@@ -27,6 +27,7 @@ public interface WarnManageMapper
      * @return 告警管理集合
      */
     public List<WarnManage> selectWarnManageList(WarnManage warnManage);
+    public List<WarnManage> selectWarnManageDeptListByTime(WarnManage warnManage);
 
     /**
      * 新增告警管理

+ 14 - 1
ruoyi-system/src/main/java/com/ruoyi/manage/service/IWarnManageService.java

@@ -1,5 +1,6 @@
 package com.ruoyi.manage.service;
 
+import com.ruoyi.common.core.domain.AjaxResult;
 import com.ruoyi.manage.domain.WarnManage;
 
 import java.util.List;
@@ -8,7 +9,7 @@ import java.util.List;
  * 告警管理Service接口
  * 
  * @author boman
- * @date 2025-05-07
+ * @date 2025-06-19
  */
 public interface IWarnManageService 
 {
@@ -59,4 +60,16 @@ public interface IWarnManageService
      * @return 结果
      */
     public int deleteWarnManageByWarnId(Long warnId);
+
+
+    /**
+     * 告警内容统计
+     * @return
+     */
+   AjaxResult getWarnManageIndex();
+
+    /**
+     * 年度告警统计
+     */
+   AjaxResult warnManageIndexYear(String year);
 }

+ 28 - 5
ruoyi-system/src/main/java/com/ruoyi/manage/service/impl/ChannelNumberServiceImpl.java

@@ -4,8 +4,10 @@ import com.ruoyi.common.core.domain.AjaxResult;
 import com.ruoyi.common.utils.DateUtils;
 import com.ruoyi.common.utils.StringUtils;
 import com.ruoyi.manage.domain.ChannelNumber;
+import com.ruoyi.manage.domain.EquipmentManage;
 import com.ruoyi.manage.domain.ParameterSet;
 import com.ruoyi.manage.mapper.ChannelNumberMapper;
+import com.ruoyi.manage.mapper.EquipmentManageMapper;
 import com.ruoyi.manage.mapper.ParameterSetMapper;
 import com.ruoyi.manage.service.IChannelNumberService;
 import com.ruoyi.mqtt.service.MqttService;
@@ -34,6 +36,8 @@ public class ChannelNumberServiceImpl implements IChannelNumberService {
 
     @Autowired
     private ParameterSetMapper parameterSetMapper;
+    @Autowired
+    private EquipmentManageMapper equipmentManageMapper;
 
     @Autowired
     private MqttService mqttService;
@@ -54,6 +58,11 @@ public class ChannelNumberServiceImpl implements IChannelNumberService {
             channelNumber.setIsChannel(Y);
             channelNumber.setParameterSet(parameterSet);
         }
+        Long equipmentId = channelNumber.getEquipmentId();
+        EquipmentManage equipmentManage = equipmentManageMapper.selectEquipmentManageByEquipmentId(equipmentId);
+        if (equipmentManage != null) {
+            channelNumber.setEquipmentIp(equipmentManage.getEquipmentIp());
+        }
         return channelNumber;
     }
 
@@ -65,7 +74,19 @@ public class ChannelNumberServiceImpl implements IChannelNumberService {
      */
     @Override
     public List<ChannelNumber> selectChannelNumberList(ChannelNumber channelNumber) {
-        return channelNumberMapper.selectChannelNumberList(channelNumber);
+        List<ChannelNumber> channelNumbers = channelNumberMapper.selectChannelNumberList(channelNumber);
+        if (channelNumbers != null && !channelNumbers.isEmpty()) {
+            ChannelNumber channelNumberOne = channelNumbers.get(0);
+            Long channelId = channelNumberOne.getChannelId();
+            //判断是否设置过参数
+            ParameterSet parameterSet = parameterSetMapper.selectParameterSetByChannelId(channelId);
+            channelNumberOne.setIsChannel(N);
+            if (parameterSet != null) {
+                channelNumberOne.setIsChannel(Y);
+                channelNumberOne.setParameterSet(parameterSet);
+            }
+        }
+        return channelNumbers;
     }
 
     /**
@@ -80,17 +101,18 @@ public class ChannelNumberServiceImpl implements IChannelNumberService {
         if (channelNumberOld != null) {
             return AjaxResult.error("设备已存在当前通道编号");
         }
+        channelNumber.setCreateTime(DateUtils.getNowDate());
+        channelNumberMapper.insertChannelNumber(channelNumber);
+        Long channelId = channelNumber.getChannelId();
         String videoAddress = channelNumber.getVideoAddress();
         if (StringUtils.isNotEmpty(videoAddress)) {
             try {
-                CompletableFuture<Void> future = mqttService.publish(DETECTION_RTSP, videoAddress);
+                CompletableFuture<Void> future = mqttService.publish(DETECTION_RTSP, channelId + "_" + videoAddress);
                 future.get(10, TimeUnit.SECONDS);
             } catch (InterruptedException | ExecutionException | TimeoutException e) {
                 return AjaxResult.error("发布消息失败:" + DETECTION_RTSP);
             }
         }
-        channelNumber.setCreateTime(DateUtils.getNowDate());
-        channelNumberMapper.insertChannelNumber(channelNumber);
         return AjaxResult.success();
     }
 
@@ -102,6 +124,7 @@ public class ChannelNumberServiceImpl implements IChannelNumberService {
      */
     @Override
     public AjaxResult updateChannelNumber(ChannelNumber channelNumber) {
+        Long channelId = channelNumber.getChannelId();
         ChannelNumber channelNumberOld = channelNumberMapper.selectChannelNumberByChannelNum(channelNumber);
         if (channelNumberOld != null && !channelNumber.getChannelId().equals(channelNumberOld.getChannelId())) {
             return AjaxResult.error("设备已存在当前通道编号");
@@ -109,7 +132,7 @@ public class ChannelNumberServiceImpl implements IChannelNumberService {
         String videoAddress = channelNumber.getVideoAddress();
         if (StringUtils.isNotEmpty(videoAddress)) {
             try {
-                CompletableFuture<Void> future = mqttService.publish(DETECTION_RTSP, videoAddress);
+                CompletableFuture<Void> future = mqttService.publish(DETECTION_RTSP, channelId + "_" + videoAddress);
                 future.get(10, TimeUnit.SECONDS);
             } catch (InterruptedException | ExecutionException | TimeoutException e) {
                 return AjaxResult.error("发布消息失败:" + DETECTION_RTSP);

+ 4 - 4
ruoyi-system/src/main/java/com/ruoyi/manage/service/impl/EquipmentManageServiceImpl.java

@@ -51,9 +51,9 @@ public class EquipmentManageServiceImpl implements IEquipmentManageService {
      */
     @Override
     public AjaxResult insertEquipmentManage(EquipmentManage equipmentManage) {
-        EquipmentManage equipmentManageOld = equipmentManageMapper.selectEquipmentManageByEquipmentNum(equipmentManage);
+        EquipmentManage equipmentManageOld = equipmentManageMapper.selectEquipmentManageByEquipmentIp(equipmentManage);
         if (equipmentManageOld != null) {
-            return AjaxResult.error("当前设备编号已存在");
+            return AjaxResult.error("当前设备ip已存在");
         }
         equipmentManage.setCreateTime(DateUtils.getNowDate());
         equipmentManageMapper.insertEquipmentManage(equipmentManage);
@@ -68,9 +68,9 @@ public class EquipmentManageServiceImpl implements IEquipmentManageService {
      */
     @Override
     public AjaxResult updateEquipmentManage(EquipmentManage equipmentManage) {
-        EquipmentManage equipmentManageOld = equipmentManageMapper.selectEquipmentManageByEquipmentNum(equipmentManage);
+        EquipmentManage equipmentManageOld = equipmentManageMapper.selectEquipmentManageByEquipmentIp(equipmentManage);
         if (equipmentManageOld != null && !equipmentManage.getEquipmentId().equals(equipmentManageOld.getEquipmentId())) {
-            return AjaxResult.error("当前设备编号已存在");
+            return AjaxResult.error("当前设备ip已存在");
         }
         equipmentManage.setUpdateTime(DateUtils.getNowDate());
         equipmentManageMapper.updateEquipmentManage(equipmentManage);

+ 6 - 5
ruoyi-system/src/main/java/com/ruoyi/manage/service/impl/ParameterSetServiceImpl.java

@@ -77,6 +77,7 @@ public class ParameterSetServiceImpl implements IParameterSetService {
 
     //校验是否需要下发参数
     public AjaxResult checkParameter(ParameterSet parameterSet) {
+        Long channelId = parameterSet.getChannelId();
         //下发指令
         String channelRange = parameterSet.getChannelRange();
         String leaveTime = parameterSet.getLeaveTime();
@@ -85,35 +86,35 @@ public class ParameterSetServiceImpl implements IParameterSetService {
         String playRate = parameterSet.getPlayRate();
         if (StringUtils.isNotEmpty(channelRange)) {
             try {
-                CompletableFuture<Void> future = mqttService.publish(DETECTION_RECT, channelRange);
+                CompletableFuture<Void> future = mqttService.publish(DETECTION_RECT, channelId+"_"+channelRange);
                 future.get(10, TimeUnit.SECONDS);
             } catch (InterruptedException | ExecutionException | TimeoutException e) {
                 return AjaxResult.error("发布消息失败:" + DETECTION_RECT);
             }
         } else if (StringUtils.isNotEmpty(leaveTime)) {
             try {
-                CompletableFuture<Void> future = mqttService.publish(DETECTION_LEAVETIME, leaveTime);
+                CompletableFuture<Void> future = mqttService.publish(DETECTION_LEAVETIME, channelId+"_"+leaveTime);
                 future.get(10, TimeUnit.SECONDS);
             } catch (InterruptedException | ExecutionException | TimeoutException e) {
                 return AjaxResult.error("发布消息失败:" + DETECTION_LEAVETIME);
             }
         } else if (StringUtils.isNotEmpty(playTime)) {
             try {
-                CompletableFuture<Void> future = mqttService.publish(DETECTION_PLAYTIME, playTime);
+                CompletableFuture<Void> future = mqttService.publish(DETECTION_PLAYTIME, channelId+"_"+playTime);
                 future.get(10, TimeUnit.SECONDS);
             } catch (InterruptedException | ExecutionException | TimeoutException e) {
                 return AjaxResult.error("发布消息失败:" + DETECTION_PLAYTIME);
             }
         } else if (StringUtils.isNotEmpty(leaveRate)) {
             try {
-                CompletableFuture<Void> future = mqttService.publish(DETECTION_LEAVERATE, leaveRate);
+                CompletableFuture<Void> future = mqttService.publish(DETECTION_LEAVERATE, channelId+"_"+leaveRate);
                 future.get(10, TimeUnit.SECONDS);
             } catch (InterruptedException | ExecutionException | TimeoutException e) {
                 return AjaxResult.error("发布消息失败:" + DETECTION_LEAVERATE);
             }
         } else if (StringUtils.isNotEmpty(playRate)) {
             try {
-                CompletableFuture<Void> future = mqttService.publish(DETECTION_PLAYRATE, playRate);
+                CompletableFuture<Void> future = mqttService.publish(DETECTION_PLAYRATE, channelId+"_"+playRate);
                 future.get(10, TimeUnit.SECONDS);
             } catch (InterruptedException | ExecutionException | TimeoutException e) {
                 return AjaxResult.error("发布消息失败:" + DETECTION_PLAYRATE);

+ 344 - 23
ruoyi-system/src/main/java/com/ruoyi/manage/service/impl/WarnManageServiceImpl.java

@@ -1,97 +1,418 @@
 package com.ruoyi.manage.service.impl;
 
+import com.alibaba.fastjson2.JSONObject;
+import com.ruoyi.common.core.domain.AjaxResult;
+import com.ruoyi.common.core.redis.RedisCache;
+import com.ruoyi.common.model.MqttMessage;
 import com.ruoyi.common.utils.DateUtils;
+import com.ruoyi.common.utils.StringUtils;
+import com.ruoyi.manage.domain.EquipmentManage;
 import com.ruoyi.manage.domain.WarnManage;
+import com.ruoyi.manage.mapper.EquipmentManageMapper;
 import com.ruoyi.manage.mapper.WarnManageMapper;
 import com.ruoyi.manage.service.IWarnManageService;
+import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
-import java.util.List;
+import java.text.DecimalFormat;
+import java.text.SimpleDateFormat;
+import java.util.*;
+import java.util.stream.Collectors;
+
+import static com.ruoyi.common.constant.Constants.*;
 
 /**
  * 告警管理Service业务层处理
- * 
+ *
  * @author boman
- * @date 2025-05-07
+ * @date 2025-06-19
  */
+@Slf4j
 @Service
-public class WarnManageServiceImpl implements IWarnManageService 
-{
+public class WarnManageServiceImpl implements IWarnManageService {
     @Autowired
     private WarnManageMapper warnManageMapper;
+    @Autowired
+    private EquipmentManageMapper equipmentManageMapper;
+    @Autowired
+    private RedisCache redisCache;
 
     /**
      * 查询告警管理
-     * 
+     *
      * @param warnId 告警管理主键
      * @return 告警管理
      */
     @Override
-    public WarnManage selectWarnManageByWarnId(Long warnId)
-    {
+    public WarnManage selectWarnManageByWarnId(Long warnId) {
         return warnManageMapper.selectWarnManageByWarnId(warnId);
     }
 
     /**
      * 查询告警管理列表
-     * 
+     *
      * @param warnManage 告警管理
      * @return 告警管理
      */
     @Override
-    public List<WarnManage> selectWarnManageList(WarnManage warnManage)
-    {
+    public List<WarnManage> selectWarnManageList(WarnManage warnManage) {
         return warnManageMapper.selectWarnManageList(warnManage);
     }
 
     /**
      * 新增告警管理
-     * 
+     *
      * @param warnManage 告警管理
      * @return 结果
      */
     @Override
-    public int insertWarnManage(WarnManage warnManage)
-    {
+    public int insertWarnManage(WarnManage warnManage) {
         warnManage.setCreateTime(DateUtils.getNowDate());
         return warnManageMapper.insertWarnManage(warnManage);
     }
 
     /**
      * 修改告警管理
-     * 
+     *
      * @param warnManage 告警管理
      * @return 结果
      */
     @Override
-    public int updateWarnManage(WarnManage warnManage)
-    {
+    public int updateWarnManage(WarnManage warnManage) {
         warnManage.setUpdateTime(DateUtils.getNowDate());
         return warnManageMapper.updateWarnManage(warnManage);
     }
 
     /**
      * 批量删除告警管理
-     * 
+     *
      * @param warnIds 需要删除的告警管理主键
      * @return 结果
      */
     @Override
-    public int deleteWarnManageByWarnIds(Long[] warnIds)
-    {
+    public int deleteWarnManageByWarnIds(Long[] warnIds) {
         return warnManageMapper.deleteWarnManageByWarnIds(warnIds);
     }
 
     /**
      * 删除告警管理信息
-     * 
+     *
      * @param warnId 告警管理主键
      * @return 结果
      */
     @Override
-    public int deleteWarnManageByWarnId(Long warnId)
-    {
+    public int deleteWarnManageByWarnId(Long warnId) {
         return warnManageMapper.deleteWarnManageByWarnId(warnId);
     }
+
+    /**
+     * 告警内容+部门统计
+     *
+     * @return
+     */
+    @Override
+    public AjaxResult getWarnManageIndex() {
+        //定义返回值
+        Map<String, Object> map = new HashMap<>(9);
+        WarnManage warnManage = new WarnManage();
+        warnManage.setWarnTime(DateUtils.getNowDate());
+        //当月告警数据
+        List<WarnManage> warnManages = warnManageMapper.selectWarnManageDeptListByTime(warnManage);
+        int warnMonthAll = 0;
+        int warnMonthLeave = 0;
+        int warnMonthPlay = 0;
+        int warnMonthLastAll = 0;
+        int warnMonthLastLeave = 0;
+        int warnMonthLastPlay = 0;
+        //本月部门数据
+        List<Map<String, Object>> deptNameMapList = new ArrayList<>();
+        //上月部门数据
+        List<Map<String, Object>> deptNameLastMapList = new ArrayList<>();
+        //计算告警数据
+        if (warnManages != null && !warnManages.isEmpty()) {
+            warnMonthAll = warnManages.size();
+            Map<String, List<WarnManage>> collect = warnManages.stream().collect(Collectors.groupingBy(WarnManage::getAlgorithmType));
+            if (!collect.isEmpty()) {
+                //离岗
+                if (collect.get(ZERO) != null && !collect.get(ZERO).isEmpty()) {
+                    warnMonthLeave = collect.get(ZERO).size();
+                }
+                //玩手机
+                if (collect.get(ONE) != null && !collect.get(ONE).isEmpty()) {
+                    warnMonthPlay = collect.get(ONE).size();
+                }
+            }
+            //插入当月部门数据
+            Map<Long, List<WarnManage>> deptNameCollect = warnManages.stream().filter( e ->e.getDeptId() != null).collect(Collectors.groupingBy(WarnManage::getDeptId));
+            List<Map<String, Object>> finalDeptNameMapList = new ArrayList<>();
+            deptNameCollect.forEach((deptId, v) -> {
+                Map<String, Object> deptMap = new HashMap<>(3);
+                deptMap.put("deptName", v.get(0).getDeptName());
+                deptMap.put("warnNum", String.valueOf(v.size()));
+                deptMap.put("deptId", deptId);
+                finalDeptNameMapList.add(deptMap);
+            });
+            deptNameMapList = finalDeptNameMapList;
+        }
+
+        //上月告警数据
+        Map<String, Object> warnLastMonth = redisCache.getCacheMap(WARN_LAST_MONTH + DateUtils.getMonth());
+        if (warnLastMonth.isEmpty()) {
+            Map<String, Object> lastMap = new HashMap<>();
+            //从数据库查询
+            warnManage.setWarnTime(DateUtils.getLastMonth());
+            List<WarnManage> warnManagesLast = warnManageMapper.selectWarnManageDeptListByTime(warnManage);
+            if (warnManagesLast != null && !warnManagesLast.isEmpty()) {
+                warnMonthLastAll = warnManagesLast.size();
+                Map<String, List<WarnManage>> collect = warnManagesLast.stream().collect(Collectors.groupingBy(WarnManage::getAlgorithmType));
+                if (!collect.isEmpty()) {
+                    //离岗
+                    if (collect.get(ZERO) != null && !collect.get(ZERO).isEmpty()) {
+                        warnMonthLastLeave = collect.get(ZERO).size();
+                    }
+                    //玩手机
+                    if (collect.get(ONE) != null && !collect.get(ONE).isEmpty()) {
+                        warnMonthLastPlay = collect.get(ONE).size();
+                    }
+                }
+                //插入上月部门数据
+                Map<Long, List<WarnManage>> deptNameCollect = warnManagesLast.stream().filter( e ->e.getDeptId() != null).collect(Collectors.groupingBy(WarnManage::getDeptId));
+                List<Map<String, Object>> finalDeptNameLastMapList = new ArrayList<>();
+                deptNameCollect.forEach((deptId, v) -> {
+                    Map<String, Object> deptMap = new HashMap<>(3);
+                    deptMap.put("deptName", v.get(0).getDeptName());
+                    deptMap.put("warnNum", String.valueOf(v.size()));
+                    deptMap.put("deptId", deptId);
+                    finalDeptNameLastMapList.add(deptMap);
+                });
+                deptNameLastMapList = finalDeptNameLastMapList;
+            }
+            lastMap.put("deptNameCollect", deptNameLastMapList);
+            lastMap.put("warnMonthLastAll", warnMonthLastAll);
+            lastMap.put("warnMonthLastLeave", warnMonthLastLeave);
+            lastMap.put("warnMonthLastPlay", warnMonthLastPlay);
+            redisCache.setCacheMap(WARN_LAST_MONTH + DateUtils.getMonth(), lastMap);
+        } else {
+            warnMonthLastAll = Integer.parseInt(warnLastMonth.get("warnMonthLastAll").toString());
+            warnMonthLastLeave = Integer.parseInt(warnLastMonth.get("warnMonthLastLeave").toString());
+            warnMonthLastPlay = Integer.parseInt(warnLastMonth.get("warnMonthLastPlay").toString());
+            deptNameLastMapList = convertObjectToList(warnLastMonth.get("deptNameCollect"));
+        }
+
+        //进行本月部门数据和上月部门数据对比,已本月部门数据为主
+        if (!deptNameMapList.isEmpty()) {
+            List<Map<String, Object>> finalDeptNameMapList = deptNameLastMapList;
+            deptNameMapList.forEach(deptNameMap -> {
+                String deptId = deptNameMap.get("deptId").toString();
+                String warnNum = deptNameMap.get("warnNum").toString();
+                String warnNumLast = "0";
+                if (!finalDeptNameMapList.isEmpty()) {
+                    for (Map<String, Object> lastMonthDeptMap : finalDeptNameMapList) {
+                        String deptIdLast = lastMonthDeptMap.get(deptId).toString();
+                        if (StringUtils.isNotEmpty(deptIdLast)) {
+                            warnNumLast = lastMonthDeptMap.get("warnNum").toString();
+                        }
+                    }
+                }
+                //计算百分比
+                Map<String, String> numPt = getNumPt(Double.parseDouble(warnNum), Double.parseDouble(warnNumLast));
+                String warnDeptPt = numPt.get("pt");
+                String warnDeptPtStatus = numPt.get("ptStatus");
+                deptNameMap.put("warnDeptPt", warnDeptPt);
+                deptNameMap.put("warnDeptPtStatus", warnDeptPtStatus);
+            });
+        }
+        map.put("warnMonthAll", warnMonthAll);
+        Map<String, String> numPt = getNumPt(warnMonthAll, warnMonthLastAll);
+        map.put("warnMonthPt", numPt.get("pt"));
+        map.put("warnMonthPtStatus", numPt.get("ptStatus"));
+        map.put("warnMonthLeave", warnMonthLeave);
+        Map<String, String> numPt1 = getNumPt(warnMonthLeave, warnMonthLastLeave);
+        map.put("warnMonthLeavePt", numPt1.get("pt"));
+        map.put("warnMonthLeavePtStatus", numPt1.get("ptStatus"));
+        map.put("warnMonthPlay", warnMonthPlay);
+        Map<String, String> numPt2 = getNumPt(warnMonthPlay, warnMonthLastPlay);
+        map.put("warnMonthPlayPt", numPt2.get("pt"));
+        map.put("warnMonthPlayPtStatus", numPt2.get("ptStatus"));
+        map.put("deptNameMapList", deptNameMapList);
+        return AjaxResult.success(map);
+    }
+
+    /**
+     * 年度告警统计
+     * 接收年份查询
+     */
+    @Override
+    public AjaxResult warnManageIndexYear(String year) {
+        Map<String, Object> map = new HashMap<>();
+        //当前年份数据从数据库查询
+        if (StringUtils.isNotEmpty(year) && DateUtils.getYear().equals(year)) {
+            return warnManageIndexYearData(year);
+        } else {
+            map = redisCache.getCacheMap(WARN_MANAGE_LAST_YEAR + year);
+            if (map == null) {
+                return warnManageIndexYearData(year);
+            }
+        }
+        return AjaxResult.success(map);
+
+    }
+
+
+    /**
+     * 从数据库查询
+     *
+     * @param year
+     * @return
+     */
+    public AjaxResult warnManageIndexYearData(String year) {
+        //定义返回值
+        Map<String, Object> map = new HashMap<>(3);
+        List<String> x = new ArrayList<>(Arrays.asList("01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12"));
+        List<Integer> y1 = new ArrayList<>();
+        List<Integer> y2 = new ArrayList<>();
+        WarnManage warnManage = new WarnManage();
+        Map<String, Object> params = new HashMap<>();
+        params.put("year", year);
+        warnManage.setParams(params);
+        //按年份检索的数据
+        List<WarnManage> warnManages = warnManageMapper.selectWarnManageList(warnManage);
+        if (warnManages != null && !warnManages.isEmpty()) {
+            // 使用Collectors.groupingBy按月份分组
+            Map<String, List<WarnManage>> WarnManageCollectMonth = warnManages.stream().collect(Collectors.groupingBy(item ->
+                    new SimpleDateFormat("MM").format(item.getWarnTime())));
+            for (String month : x) {
+                List<WarnManage> warnManagesMonthList = WarnManageCollectMonth.get(month);
+                //如果当月没有告警
+                if (warnManagesMonthList != null && !warnManagesMonthList.isEmpty()) {
+                    Map<String, List<WarnManage>> algorithmTypeCollect = warnManagesMonthList.stream().collect(Collectors.groupingBy(WarnManage::getAlgorithmType));
+                    if (algorithmTypeCollect != null && !algorithmTypeCollect.isEmpty()) {
+                        //离岗
+                        if (algorithmTypeCollect.get(ZERO) != null && !algorithmTypeCollect.get(ZERO).isEmpty()) {
+                            y1.add(algorithmTypeCollect.get(ZERO).size());
+                        } else {
+                            y1.add(0);
+                        }
+                        //玩手机
+                        if (algorithmTypeCollect.get(ONE) != null && !algorithmTypeCollect.get(ONE).isEmpty()) {
+                            y2.add(algorithmTypeCollect.get(ONE).size());
+                        } else {
+                            y2.add(0);
+                        }
+                    }
+                } else {
+                    y1.add(0);
+                    y2.add(0);
+                }
+            }
+        }
+        map.put("x", x);
+        map.put("y1", y1);
+        map.put("y2", y2);
+        //把非当前年份的数据存储到redis
+        if (StringUtils.isNotEmpty(year) && !DateUtils.getYear().equals(year)) {
+            redisCache.setCacheMap(WARN_MANAGE_LAST_YEAR + year, map);
+        }
+        return AjaxResult.success(map);
+    }
+
+    public static List<Map<String, Object>> convertObjectToList(Object obj) {
+        // 1. 检查是否为 List 类型
+        if (!(obj instanceof List<?>)) {
+            throw new IllegalArgumentException("Object is not a List");
+        }
+
+        List<?> rawList = (List<?>) obj;
+
+        // 2. 遍历检查内部元素是否为 Map 类型
+        for (Object item : rawList) {
+            if (!(item instanceof Map<?, ?>)) {
+                throw new IllegalArgumentException("List contains non-Map elements");
+            }
+
+            Map<?, ?> map = (Map<?, ?>) item;
+            // 3. 检查 Map 的键值类型(可选但推荐)
+            for (Map.Entry<?, ?> entry : map.entrySet()) {
+                if (!(entry.getKey() instanceof String) || !(entry.getValue() instanceof String)) {
+                    throw new IllegalArgumentException(
+                            "Map contains non-String key/value: " + entry.getKey() + "=" + entry.getValue()
+                    );
+                }
+            }
+        }
+
+        // 4. 安全强制转换(已验证类型)
+        return (List<Map<String, Object>>) obj;
+    }
+
+
+    //计算两个数的百分比和是上升还是下降
+    public static Map<String, String> getNumPt(double a, double b) {
+        DecimalFormat df = new DecimalFormat("##.##%");
+        Map<String, String> map = new HashMap<>(2);
+        if (a > 0 && b < 1) {
+            map.put("ptStatus", ONE);
+            map.put("pt", "100.00%");
+            return map;
+        } else if (a < 1 && b > 0) {
+            map.put("ptStatus", TWO);
+            map.put("pt", "100.00%");
+            return map;
+        } else if (a < 1 && b < 1) {
+            map.put("ptStatus", ONE);
+            map.put("pt", "0.00%");
+            return map;
+        } else if (a > 0 && b > 0) {
+            if (a > b) {
+                map.put("ptStatus", ONE);
+                String format = df.format((a - b) / b);
+                map.put("pt", format);
+            }
+            if (b > a) {
+                map.put("ptStatus", TWO);
+                String format = df.format((b - a) / b);
+                map.put("pt", format);
+            }
+        }
+        return map;
+    }
+
+    /**
+     * 算法回调新增告警信息
+     *
+     * @param message
+     */
+    public void addWarnManage(MqttMessage message, String algorithmType) {
+        try {
+            String payload = message.getPayload();
+            JSONObject jsonObject = JSONObject.parseObject(payload);
+            String equipmentIp = jsonObject.getString("equipmentIp");
+            EquipmentManage equipmentManage = new EquipmentManage();
+            equipmentManage.setEquipmentIp(equipmentIp);
+            EquipmentManage equipmentManageOld = equipmentManageMapper.selectEquipmentManageByEquipmentIp(equipmentManage);
+            Long channelId = jsonObject.getLong("channelId");
+            String parameterSet = jsonObject.getString("parameterSet");
+            String algorithmResult = jsonObject.getString("algorithmResult");
+            String photoUrl = jsonObject.getString("photoUrl");
+            String videoUrl = jsonObject.getString("videoUrl");
+            String rangName = jsonObject.getString("name");
+            WarnManage warnManage = new WarnManage();
+            warnManage.setEquipmentIp(equipmentIp);
+            warnManage.setEquipmentName(equipmentManageOld.getEquipmentName());
+            warnManage.setEquipmentId(equipmentManageOld.getEquipmentId());
+            warnManage.setChannelId(channelId);
+            warnManage.setParameterSet(parameterSet);
+            warnManage.setAlgorithmType(algorithmType);
+            warnManage.setReportStatus(algorithmResult);
+            warnManage.setVideoAddress(videoUrl);
+            warnManage.setWarnImage(photoUrl);
+            warnManage.setCreateTime(DateUtils.getNowDate());
+            warnManage.setWarnTime(DateUtils.getNowDate());
+            warnManage.setRangName(rangName);
+            warnManageMapper.insertWarnManage(warnManage);
+        } catch (Exception e) {
+            log.info("新增告警信息异常:{}", e.getMessage());
+        }
+    }
 }

+ 32 - 3
ruoyi-system/src/main/java/com/ruoyi/mqtt/service/MqttMessageListener.java

@@ -1,7 +1,9 @@
 package com.ruoyi.mqtt.service;
 
 import com.ruoyi.common.model.MqttMessage;
+import com.ruoyi.manage.service.impl.WarnManageServiceImpl;
 import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.context.event.EventListener;
 import org.springframework.stereotype.Component;
 
@@ -19,6 +21,10 @@ import org.springframework.stereotype.Component;
 @Component
 public class MqttMessageListener {
 
+    @Autowired
+    private WarnManageServiceImpl warnManageService;
+
+
     /**
      * 处理接收到的MQTT消息
      *
@@ -27,18 +33,41 @@ public class MqttMessageListener {
     @EventListener
     public void handleMqttMessage(MqttMessage message) {
         log.info("收到MQTT消息事件: 主题={}, 消息内容={}", message.getTopic(), message.getPayload());
-
         // TODO: 添加自定义的业务逻辑来处理消息
+        /**
+         * 返回值为
+         {
+         "equipmentIp":"设备ip",
+         "name":"区域名称",
+        "channelId":"通道ID",
+          "parameterSet":"当前参数设置的值",
+         "algorithmType":"算法类型",
+         "algorithmResult":"算法结果  是否离岗(手机)0:正常 1:异常",
+          "photoUrl":"算法截图URL",
+          "videoUrl":"违规视频URL"
+         }
+         */
+        if(message.getTopic().equals("toServer_leaveStat")){
+            //插入告警信息
+            warnManageService.addWarnManage(message,"0");
+        }
+        else if(message.getTopic().equals("toServer_playStat")){
+            //插入告警信息
+            warnManageService.addWarnManage(message,"1");
+        }
+
         // 例如:解析JSON消息内容,更新数据库,触发其他操作等
 
-        // 可以根据主题进行不同的处理
+/*        // 可以根据主题进行不同的处理
         if (message.getTopic().startsWith("device/")) {
             handleDeviceMessage(message);
         } else if (message.getTopic().startsWith("alert/")) {
             handleAlertMessage(message);
-        }
+        }*/
     }
 
+
+
     /**
      * 处理设备相关消息
      *

+ 2 - 1
ruoyi-system/src/main/java/com/ruoyi/mqtt/service/MqttService.java

@@ -42,7 +42,8 @@ public class MqttService {
         // 如果配置了默认主题,则自动订阅
         if (mqttProperties.getDefaultTopic() != null && !mqttProperties.getDefaultTopic().isEmpty()) {
             try {
-                subscribe(mqttProperties.getDefaultTopic());
+                List<String> topics = Arrays.asList(mqttProperties.getDefaultTopic().split(","));
+                subscribe(topics);
                 log.info("已自动订阅默认主题: {}", mqttProperties.getDefaultTopic());
             } catch (MqttException e) {
                 log.error("自动订阅默认主题失败: {}", e.getMessage(), e);

+ 36 - 3
ruoyi-system/src/main/resources/mapper/manage/EquipmentManageMapper.xml

@@ -6,6 +6,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     
     <resultMap type="EquipmentManage" id="EquipmentManageResult">
         <result property="equipmentId"    column="equipment_id"    />
+        <result property="equipmentIp"    column="equipment_ip"    />
         <result property="equipmentNum"    column="equipment_num"    />
         <result property="equipmentName"    column="equipment_name"    />
         <result property="equipmentType"    column="equipment_type"    />
@@ -14,6 +15,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <result property="equipmentTime"    column="equipment_time"    />
         <result property="equipmentImage"    column="equipment_image"    />
         <result property="runState"    column="run_state"    />
+        <result property="deptId"    column="dept_id"    />
+        <result property="deptName"    column="dept_name"    />
         <result property="delFlag"    column="del_flag"    />
         <result property="createBy"    column="create_by"    />
         <result property="createTime"    column="create_time"    />
@@ -23,13 +26,32 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     </resultMap>
 
     <sql id="selectEquipmentManageVo">
-        select equipment_id, equipment_num, equipment_name, equipment_type, equipment_address, equipment_region, equipment_time, equipment_image, run_state, del_flag, create_by, create_time, update_by, update_time, remark from equipment_manage
+        select equipment_id,
+               equipment_ip,
+               equipment_num,
+               equipment_name,
+               equipment_type,
+               equipment_address,
+               equipment_region,
+               equipment_time,
+               equipment_image,
+               run_state,
+               dept_id,
+               dept_name,
+               del_flag,
+               create_by,
+               create_time,
+               update_by,
+               update_time,
+               remark
+        from equipment_manage
     </sql>
 
     <select id="selectEquipmentManageList" parameterType="EquipmentManage" resultMap="EquipmentManageResult">
         <include refid="selectEquipmentManageVo"/>
         <where>  
             <if test="equipmentNum != null  and equipmentNum != ''"> and equipment_num  like concat('%', #{equipmentNum}, '%')</if>
+            <if test="equipmentIp != null  and equipmentIp != ''"> and equipment_id  like concat('%', #{equipmentIp}, '%')</if>
             <if test="equipmentName != null  and equipmentName != ''"> and equipment_name like concat('%', #{equipmentName}, '%')</if>
             <if test="equipmentType != null  and equipmentType != ''"> and equipment_type = #{equipmentType}</if>
             <if test="equipmentAddress != null  and equipmentAddress != ''"> and equipment_address = #{equipmentAddress}</if>
@@ -37,13 +59,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="equipmentTime != null "> and equipment_time = #{equipmentTime}</if>
             <if test="equipmentImage != null  and equipmentImage != ''"> and equipment_image = #{equipmentImage}</if>
             <if test="runState != null  and runState != ''"> and run_state = #{runState}</if>
+            <if test="deptId != null  "> and dept_id = #{deptId}</if>
+            <if test="deptName != null  and deptName != ''"> and dept_name = #{deptName}</if>
         </where>
     </select>
 
-    <select id="selectEquipmentManageByEquipmentNum" parameterType="EquipmentManage" resultMap="EquipmentManageResult">
+    <select id="selectEquipmentManageByEquipmentIp" parameterType="EquipmentManage" resultMap="EquipmentManageResult">
         <include refid="selectEquipmentManageVo"/>
         <where>
-            <if test="equipmentNum != null  and equipmentNum != ''">and equipment_num = #{equipmentNum}</if>
+            <if test="equipmentIp != null  and equipmentIp != ''">and equipment_ip= #{equipmentIp}</if>
         </where>
     </select>
     <select id="selectEquipmentManageByEquipmentId" parameterType="Long" resultMap="EquipmentManageResult">
@@ -54,6 +78,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     <insert id="insertEquipmentManage" parameterType="EquipmentManage" useGeneratedKeys="true" keyProperty="equipmentId">
         insert into equipment_manage
         <trim prefix="(" suffix=")" suffixOverrides=",">
+            <if test="equipmentIp != null">equipment_ip,</if>
             <if test="equipmentNum != null">equipment_num,</if>
             <if test="equipmentName != null">equipment_name,</if>
             <if test="equipmentType != null">equipment_type,</if>
@@ -62,6 +87,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="equipmentTime != null">equipment_time,</if>
             <if test="equipmentImage != null">equipment_image,</if>
             <if test="runState != null">run_state,</if>
+            <if test="deptId != null">dept_id,</if>
+            <if test="deptName != null">dept_name,</if>
             <if test="delFlag != null">del_flag,</if>
             <if test="createBy != null">create_by,</if>
             <if test="createTime != null">create_time,</if>
@@ -70,6 +97,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="remark != null">remark,</if>
          </trim>
         <trim prefix="values (" suffix=")" suffixOverrides=",">
+            <if test="equipmentIp != null">#{equipmentIp},</if>
             <if test="equipmentNum != null">#{equipmentNum},</if>
             <if test="equipmentName != null">#{equipmentName},</if>
             <if test="equipmentType != null">#{equipmentType},</if>
@@ -78,6 +106,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="equipmentTime != null">#{equipmentTime},</if>
             <if test="equipmentImage != null">#{equipmentImage},</if>
             <if test="runState != null">#{runState},</if>
+            <if test="deptId != null">#{deptId},</if>
+            <if test="deptName != null">#{deptName},</if>
             <if test="delFlag != null">#{delFlag},</if>
             <if test="createBy != null">#{createBy},</if>
             <if test="createTime != null">#{createTime},</if>
@@ -90,6 +120,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     <update id="updateEquipmentManage" parameterType="EquipmentManage">
         update equipment_manage
         <trim prefix="SET" suffixOverrides=",">
+            <if test="equipmentIp != null">equipment_ip = #{equipmentIp},</if>
             <if test="equipmentNum != null">equipment_num = #{equipmentNum},</if>
             <if test="equipmentName != null">equipment_name = #{equipmentName},</if>
             <if test="equipmentType != null">equipment_type = #{equipmentType},</if>
@@ -98,6 +129,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="equipmentTime != null">equipment_time = #{equipmentTime},</if>
             <if test="equipmentImage != null">equipment_image = #{equipmentImage},</if>
             <if test="runState != null">run_state = #{runState},</if>
+            <if test="deptId != null">dept_id = #{deptId},</if>
+            <if test="deptName != null">dept_name = #{deptName},</if>
             <if test="delFlag != null">del_flag = #{delFlag},</if>
             <if test="createBy != null">create_by = #{createBy},</if>
             <if test="createTime != null">create_time = #{createTime},</if>

+ 112 - 48
ruoyi-system/src/main/resources/mapper/manage/WarnManageMapper.xml

@@ -1,45 +1,95 @@
 <?xml version="1.0" encoding="UTF-8" ?>
 <!DOCTYPE mapper
-PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
-"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.ruoyi.manage.mapper.WarnManageMapper">
-    
+
     <resultMap type="WarnManage" id="WarnManageResult">
-        <result property="warnId"    column="warn_id"    />
-        <result property="warnType"    column="warn_type"    />
-        <result property="warnSign"    column="warn_sign"    />
-        <result property="channelId"    column="channel_id"    />
-        <result property="videoAddress"    column="video_address"    />
-        <result property="reportAddress"    column="report_address"    />
-        <result property="reportStatus"    column="report_status"    />
-        <result property="warnTime"    column="warn_time"    />
-        <result property="warnImage"    column="warn_image"    />
-        <result property="delFlag"    column="del_flag"    />
-        <result property="createBy"    column="create_by"    />
-        <result property="createTime"    column="create_time"    />
-        <result property="updateBy"    column="update_by"    />
-        <result property="updateTime"    column="update_time"    />
-        <result property="remark"    column="remark"    />
+        <result property="warnId" column="warn_id"/>
+        <result property="equipmentId" column="equipment_id"/>
+        <result property="equipmentIp" column="equipment_ip"/>
+        <result property="equipmentName" column="equipment_name"/>
+        <result property="channelId" column="channel_id"/>
+        <result property="channelNum" column="channel_num"/>
+        <result property="algorithmType" column="algorithm_type"/>
+        <result property="parameterSet" column="parameter_set"/>
+        <result property="videoAddress" column="video_address"/>
+        <result property="warnImage" column="warn_image"/>
+        <result property="reportStatus" column="report_status"/>
+        <result property="warnTime" column="warn_time"/>
+        <result property="rangName" column="rang_name"/>
+        <result property="deptId" column="dept_id"/>
+        <result property="deptName" column="dept_name"/>
+        <result property="delFlag" column="del_flag"/>
+        <result property="createBy" column="create_by"/>
+        <result property="createTime" column="create_time"/>
+        <result property="updateBy" column="update_by"/>
+        <result property="updateTime" column="update_time"/>
+        <result property="remark" column="remark"/>
     </resultMap>
 
     <sql id="selectWarnManageVo">
-        select warn_id, warn_type, warn_sign, channel_id, video_address, report_address, report_status, warn_time, warn_image, del_flag, create_by, create_time, update_by, update_time, remark from warn_manage
+        select warn_id,
+               equipment_id,
+               equipment_ip,
+               equipment_name,
+               channel_id,
+               channel_num,
+               algorithm_type,
+               parameter_set,
+               video_address,
+               warn_image,
+               report_status,
+               warn_time,
+               rang_name,
+               del_flag,
+               create_by,
+               create_time,
+               update_by,
+               update_time,
+               remark
+        from warn_manage
     </sql>
 
     <select id="selectWarnManageList" parameterType="WarnManage" resultMap="WarnManageResult">
-        <include refid="selectWarnManageVo"/>
-        <where>  
-            <if test="warnType != null  and warnType != ''"> and warn_type = #{warnType}</if>
-            <if test="warnSign != null  and warnSign != ''"> and warn_sign = #{warnSign}</if>
-            <if test="channelId != null "> and channel_id = #{channelId}</if>
-            <if test="videoAddress != null  and videoAddress != ''"> and video_address = #{videoAddress}</if>
-            <if test="reportAddress != null  and reportAddress != ''"> and report_address = #{reportAddress}</if>
-            <if test="reportStatus != null  and reportStatus != ''"> and report_status = #{reportStatus}</if>
-            <if test="warnTime != null "> and warn_time = #{warnTime}</if>
-            <if test="warnImage != null  and warnImage != ''"> and warn_image = #{warnImage}</if>
+        select w.warn_id, w.equipment_ip, w.equipment_name, w.channel_id, w.channel_num, w.algorithm_type,
+        w.parameter_set, w.video_address, w.warn_image, w.report_status, w.warn_time,w.rang_name, w.del_flag, w.create_time,
+        e.dept_name,e.dept_id
+        from warn_manage w left join equipment_manage e on e.equipment_id = w.equipment_id
+        <where>
+            w.del_flag = '0'
+            <if test="equipmentIp != null  and equipmentIp != ''">and w.equipment_ip = #{equipmentIp}</if>
+            <if test="equipmentName != null  and equipmentName != ''">and w.equipment_name like concat('%',
+                #{equipmentName}, '%')
+            </if>
+            <if test="channelId != null ">and w.channel_id = #{channelId}</if>
+            <if test="channelNum != null  and channelNum != ''">and w.channel_num = #{channelNum}</if>
+            <if test="algorithmType != null  and algorithmType != ''">and w.algorithm_type = #{algorithmType}</if>
+            <if test="parameterSet != null  and parameterSet != ''">and w.parameter_set = #{parameterSet}</if>
+            <if test="videoAddress != null  and videoAddress != ''">and w.video_address = #{videoAddress}</if>
+            <if test="warnImage != null  and warnImage != ''">and w.warn_image = #{warnImage}</if>
+            <if test="reportStatus != null  and reportStatus != ''">and w.report_status = #{reportStatus}</if>
+            <if test="rangName != null  and rangName != ''">and w.rang_name like concat('%',#{rangName}, '%') </if>
+            <if test="deptId != null  ">and e.dept_id = #{deptId}</if>
+            <if test="warnTime != null ">and date_format(w.warn_time,'%Y%m%d') =date_format(#{warnTime},'%Y%m%d')</if>
+            <if test="params.month != null ">and date_format(w.warn_time,'%Y%m') =date_format(#{warnTime},'%Y%m')</if>
+            <if test="params.year != null and params.year != ''"><!-- 年份检索 -->
+                AND date_format(w.warn_time,'%Y') = #{params.year}
+            </if>
+        </where>
+    </select>
+
+    <select id="selectWarnManageDeptListByTime" parameterType="WarnManage" resultMap="WarnManageResult">
+        select w.warn_id, w.equipment_ip, w.equipment_name, w.channel_id, w.channel_num, w.algorithm_type,
+        w.parameter_set, w.video_address, w.warn_image, w.report_status, w.warn_time,w.rang_name, w.del_flag, w.create_time,
+        e.dept_name,e.dept_id
+        from warn_manage w left join equipment_manage e on e.equipment_id = w.equipment_id
+        <where>
+            w.del_flag = '0'
+            <if test="warnTime != null ">and date_format(warn_time,'%Y%m') =date_format(#{warnTime},'%Y%m')</if>
         </where>
     </select>
-    
+
     <select id="selectWarnManageByWarnId" parameterType="Long" resultMap="WarnManageResult">
         <include refid="selectWarnManageVo"/>
         where warn_id = #{warnId}
@@ -48,50 +98,62 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     <insert id="insertWarnManage" parameterType="WarnManage" useGeneratedKeys="true" keyProperty="warnId">
         insert into warn_manage
         <trim prefix="(" suffix=")" suffixOverrides=",">
-            <if test="warnType != null">warn_type,</if>
-            <if test="warnSign != null">warn_sign,</if>
+            <if test="equipmentId != null and equipmentId != ''">equipment_id,</if>
+            <if test="equipmentIp != null and equipmentIp != ''">equipment_ip,</if>
+            <if test="equipmentName != null and equipmentName != ''">equipment_name,</if>
             <if test="channelId != null">channel_id,</if>
+            <if test="channelNum != null and channelNum != ''">channel_num,</if>
+            <if test="algorithmType != null and algorithmType != ''">algorithm_type,</if>
+            <if test="parameterSet != null and parameterSet != ''">parameter_set,</if>
             <if test="videoAddress != null">video_address,</if>
-            <if test="reportAddress != null">report_address,</if>
+            <if test="warnImage != null">warn_image,</if>
             <if test="reportStatus != null">report_status,</if>
             <if test="warnTime != null">warn_time,</if>
-            <if test="warnImage != null">warn_image,</if>
+            <if test="rangName != null">rang_name,</if>
             <if test="delFlag != null">del_flag,</if>
             <if test="createBy != null">create_by,</if>
-            <if test="createTime != null">create_time,</if>
             <if test="updateBy != null">update_by,</if>
             <if test="updateTime != null">update_time,</if>
             <if test="remark != null">remark,</if>
-         </trim>
+            create_time
+        </trim>
         <trim prefix="values (" suffix=")" suffixOverrides=",">
-            <if test="warnType != null">#{warnType},</if>
-            <if test="warnSign != null">#{warnSign},</if>
+            <if test="equipmentId != null and equipmentId != ''">#{equipmentId},</if>
+            <if test="equipmentIp != null and equipmentIp != ''">#{equipmentIp},</if>
+            <if test="equipmentName != null and equipmentName != ''">#{equipmentName},</if>
             <if test="channelId != null">#{channelId},</if>
+            <if test="channelNum != null and channelNum != ''">#{channelNum},</if>
+            <if test="algorithmType != null and algorithmType != ''">#{algorithmType},</if>
+            <if test="parameterSet != null and parameterSet != ''">#{parameterSet},</if>
             <if test="videoAddress != null">#{videoAddress},</if>
-            <if test="reportAddress != null">#{reportAddress},</if>
+            <if test="warnImage != null">#{warnImage},</if>
             <if test="reportStatus != null">#{reportStatus},</if>
             <if test="warnTime != null">#{warnTime},</if>
-            <if test="warnImage != null">#{warnImage},</if>
+            <if test="rangName != null">#{rangName},</if>
             <if test="delFlag != null">#{delFlag},</if>
             <if test="createBy != null">#{createBy},</if>
-            <if test="createTime != null">#{createTime},</if>
             <if test="updateBy != null">#{updateBy},</if>
             <if test="updateTime != null">#{updateTime},</if>
             <if test="remark != null">#{remark},</if>
-         </trim>
+            sysdate()
+        </trim>
     </insert>
 
     <update id="updateWarnManage" parameterType="WarnManage">
         update warn_manage
         <trim prefix="SET" suffixOverrides=",">
-            <if test="warnType != null">warn_type = #{warnType},</if>
-            <if test="warnSign != null">warn_sign = #{warnSign},</if>
+            <if test="equipmentId != null and equipmentId != ''">equipment_id = #{equipmentId},</if>
+            <if test="equipmentIp != null and equipmentIp != ''">equipment_ip = #{equipmentIp},</if>
+            <if test="equipmentName != null and equipmentName != ''">equipment_name = #{equipmentName},</if>
             <if test="channelId != null">channel_id = #{channelId},</if>
+            <if test="channelNum != null and channelNum != ''">channel_num = #{channelNum},</if>
+            <if test="algorithmType != null and algorithmType != ''">algorithm_type = #{algorithmType},</if>
+            <if test="parameterSet != null and parameterSet != ''">parameter_set = #{parameterSet},</if>
             <if test="videoAddress != null">video_address = #{videoAddress},</if>
-            <if test="reportAddress != null">report_address = #{reportAddress},</if>
+            <if test="warnImage != null">warn_image = #{warnImage},</if>
             <if test="reportStatus != null">report_status = #{reportStatus},</if>
             <if test="warnTime != null">warn_time = #{warnTime},</if>
-            <if test="warnImage != null">warn_image = #{warnImage},</if>
+            <if test="rangName != null">rang_name = #{rangName},</if>
             <if test="delFlag != null">del_flag = #{delFlag},</if>
             <if test="createBy != null">create_by = #{createBy},</if>
             <if test="createTime != null">create_time = #{createTime},</if>
@@ -103,11 +165,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     </update>
 
     <delete id="deleteWarnManageByWarnId" parameterType="Long">
-        delete from warn_manage where warn_id = #{warnId}
+        delete
+        from warn_manage
+        where warn_id = #{warnId}
     </delete>
 
     <delete id="deleteWarnManageByWarnIds" parameterType="String">
-        delete from warn_manage where warn_id in 
+        delete from warn_manage where warn_id in
         <foreach item="warnId" collection="array" open="(" separator="," close=")">
             #{warnId}
         </foreach>