tjf il y a 6 jours
Parent
commit
fa24199ef6

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

@@ -0,0 +1,30 @@
+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.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();
+    }
+
+}

+ 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));
     }
 }

+ 12 - 19
ruoyi-admin/src/main/java/com/ruoyi/web/controller/manage/WarnManageController.java

@@ -23,18 +23,16 @@ import java.util.List;
  */
 @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);
@@ -46,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, "告警管理数据");
@@ -58,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));
     }
 
@@ -69,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));
     }
 
@@ -80,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));
     }
 
@@ -91,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));
     }
 }

+ 1 - 1
ruoyi-admin/src/main/resources/application.yml

@@ -80,7 +80,7 @@ mqtt:
   server-uri: tcp://60.171.161.56:20009
 #  server-uri: tcp://192.168.101.147:1883
 #  server-uri: tcp://127.0.0.1:1883
-  client-id: JavaClient
+  client-id: JavaClientBoman
   username: admin
   password: 9o0p(O)P
   default-topic: toServer_leaveStat,toServer_playStat

+ 5 - 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";
     //离岗时间

+ 51 - 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,72 @@ 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);
+    }
+
+    /**
+     * 获取上月日期
+     *
+     * @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 +99,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 +107,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 +115,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 +129,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 +137,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 +169,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,8 +177,7 @@ 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());

+ 24 - 0
ruoyi-system/src/main/java/com/ruoyi/manage/domain/EquipmentManage.java

@@ -59,6 +59,28 @@ public class EquipmentManage extends BaseEntity
     /** 删除标志(0代表存在 1代表删除) */
     private String delFlag;
 
+    /** 部门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;
     }
@@ -181,6 +203,8 @@ public class EquipmentManage extends BaseEntity
                 ", equipmentImage='" + equipmentImage + '\'' +
                 ", runState='" + runState + '\'' +
                 ", delFlag='" + delFlag + '\'' +
+                ", deptId=" + deptId +
+                ", deptName='" + deptName + '\'' +
                 '}';
     }
 }

+ 39 - 22
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;
 
@@ -65,7 +63,29 @@ public class WarnManage extends BaseEntity
     /** 删除标志(0代表存在 1代表删除) */
     private String delFlag;
 
-    public void setWarnId(Long warnId) 
+    /** 部门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 void setWarnId(Long warnId)
     {
         this.warnId = warnId;
     }
@@ -187,24 +207,21 @@ public class WarnManage extends BaseEntity
 
     @Override
     public String toString() {
-        return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
-            .append("warnId", getWarnId())
-            .append("equipmentIp", getEquipmentIp())
-            .append("equipmentName", getEquipmentName())
-            .append("channelId", getChannelId())
-            .append("channelNum", getChannelNum())
-            .append("algorithmType", getAlgorithmType())
-            .append("parameterSet", getParameterSet())
-            .append("videoAddress", getVideoAddress())
-            .append("warnImage", getWarnImage())
-            .append("reportStatus", getReportStatus())
-            .append("warnTime", getWarnTime())
-            .append("delFlag", getDelFlag())
-            .append("createBy", getCreateBy())
-            .append("createTime", getCreateTime())
-            .append("updateBy", getUpdateBy())
-            .append("updateTime", getUpdateTime())
-            .append("remark", getRemark())
-            .toString();
+        return "WarnManage{" +
+                "warnId=" + warnId +
+                ", equipmentIp='" + equipmentIp + '\'' +
+                ", equipmentName='" + equipmentName + '\'' +
+                ", channelId=" + channelId +
+                ", channelNum='" + channelNum + '\'' +
+                ", algorithmType='" + algorithmType + '\'' +
+                ", parameterSet='" + parameterSet + '\'' +
+                ", videoAddress='" + videoAddress + '\'' +
+                ", warnImage='" + warnImage + '\'' +
+                ", 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);
 
     /**
      * 新增设备管理

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

@@ -27,6 +27,7 @@ public interface WarnManageMapper
      * @return 告警管理集合
      */
     public List<WarnManage> selectWarnManageList(WarnManage warnManage);
+    public List<WarnManage> selectWarnManageDeptListByTime(WarnManage warnManage);
 
     /**
      * 新增告警管理

+ 8 - 0
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;
@@ -59,4 +60,11 @@ public interface IWarnManageService
      * @return 结果
      */
     public int deleteWarnManageByWarnId(Long warnId);
+
+
+    /**
+     * 告警内容统计
+     * @return
+     */
+   AjaxResult getWarnManageIndex();
 }

+ 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);

+ 220 - 22
ruoyi-system/src/main/java/com/ruoyi/manage/service/impl/WarnManageServiceImpl.java

@@ -1,107 +1,305 @@
 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.WarnManage;
 import com.ruoyi.manage.mapper.WarnManageMapper;
 import com.ruoyi.manage.service.IWarnManageService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
+import java.text.DecimalFormat;
+import java.util.ArrayList;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
+
+import static com.ruoyi.common.constant.Constants.*;
 
 /**
  * 告警管理Service业务层处理
- * 
+ *
  * @author boman
  * @date 2025-06-19
  */
 @Service
-public class WarnManageServiceImpl implements IWarnManageService 
-{
+public class WarnManageServiceImpl implements IWarnManageService {
     @Autowired
     private WarnManageMapper warnManageMapper;
+    @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, String>> deptNameMapList = new ArrayList<>();
+        //上月部门数据
+        List<Map<String, String>> 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).isEmpty()) {
+                    warnMonthLastLeave = collect.get(ZERO).size();
+                }
+                //玩手机
+                if (!collect.get(ONE).isEmpty()) {
+                    warnMonthLastPlay = collect.get(ONE).size();
+                }
+            }
+            //插入当月部门数据
+            Map<String, List<WarnManage>> deptNameCollect = warnManages.stream().collect(Collectors.groupingBy(WarnManage::getDeptName));
+            List<Map<String, String>> finalDeptNameMapList = new ArrayList<>();
+            deptNameCollect.forEach((deptName, v) -> {
+                Map<String, String> deptMap = new HashMap<>(9);
+                deptMap.put("deptName", deptName);
+                deptMap.put("warnNum", String.valueOf(v.size()));
+                finalDeptNameMapList.add(deptMap);
+            });
+            deptNameMapList = finalDeptNameMapList;
+        }
+        //上月告警数据
+        Map<String, Object> warnLastMonth = redisCache.getCacheMap(WARN_LAST_MONTH + DateUtils.getMonth());
+        if (warnLastMonth.isEmpty()) {
+            //从数据库查询
+            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).isEmpty()) {
+                        warnMonthLeave = collect.get(ZERO).size();
+                    }
+                    //玩手机
+                    if (!collect.get(ONE).isEmpty()) {
+                        warnMonthLastPlay = collect.get(ONE).size();
+                    }
+                }
+            }
+            Map<String, Object> lastMap = new HashMap<>();
+            lastMap.put("warnMonthLastAll", warnMonthLastAll);
+            lastMap.put("warnMonthLastLeave", warnMonthLastLeave);
+            lastMap.put("warnMonthLastPlay", warnMonthLastPlay);
+
+            //插入上月部门数据
+            Map<String, List<WarnManage>> deptNameCollect = warnManages.stream().collect(Collectors.groupingBy(WarnManage::getDeptName));
+            List<Map<String, String>> finalDeptNameLastMapList = new ArrayList<>();
+            deptNameCollect.forEach((deptName, v) -> {
+                Map<String, String> deptMap = new HashMap<>(9);
+                deptMap.put("deptName", deptName);
+                deptMap.put("warnNum", String.valueOf(v.size()));
+                finalDeptNameLastMapList.add(deptMap);
+            });
+            lastMap.put("deptNameCollect", finalDeptNameLastMapList);
+            deptNameLastMapList = finalDeptNameLastMapList;
+            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, String>> finalDeptNameMapList = deptNameLastMapList;
+            deptNameMapList.forEach(deptNameMap -> {
+                String deptName = deptNameMap.get("deptName");
+                String warnNum = deptNameMap.get("warnNum");
+                String warnNumLast = "0";
+                if (!finalDeptNameMapList.isEmpty()) {
+                    for (Map<String, String> lastMonthDeptMap : finalDeptNameMapList) {
+                        String deptNameLast = lastMonthDeptMap.get(deptName);
+                        if (StringUtils.isNotEmpty(deptNameLast)) {
+                             warnNumLast = lastMonthDeptMap.get("warnNum");
+                        }
+                    }
+                }
+                //计算百分比
+                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);
+    }
+
+    public static List<Map<String, String>> 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, String>>) 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){
+    public void addWarnManage(MqttMessage message, String algorithmType) {
         String payload = message.getPayload();
         JSONObject jsonObject = JSONObject.parseObject(payload);
         String equipmentIp = jsonObject.getString("equipmentIp");

+ 14 - 2
ruoyi-system/src/main/resources/mapper/manage/EquipmentManageMapper.xml

@@ -15,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"    />
@@ -34,6 +36,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
                equipment_time,
                equipment_image,
                run_state,
+               dept_id,
+               dept_name,
                del_flag,
                create_by,
                create_time,
@@ -55,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">
@@ -81,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>
@@ -98,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>
@@ -119,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>

+ 72 - 37
ruoyi-system/src/main/resources/mapper/manage/WarnManageMapper.xml

@@ -1,49 +1,82 @@
 <?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="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="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="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="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, equipment_ip, equipment_name, channel_id, channel_num, algorithm_type, parameter_set, video_address, warn_image, report_status, warn_time, del_flag, create_by, create_time, update_by, update_time, remark from warn_manage
+        select warn_id,
+               equipment_ip,
+               equipment_name,
+               channel_id,
+               channel_num,
+               algorithm_type,
+               parameter_set,
+               video_address,
+               warn_image,
+               report_status,
+               warn_time,
+               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="equipmentIp != null  and equipmentIp != ''"> and equipment_ip = #{equipmentIp}</if>
-            <if test="equipmentName != null  and equipmentName != ''"> and equipment_name like concat('%', #{equipmentName}, '%')</if>
-            <if test="channelId != null "> and channel_id = #{channelId}</if>
-            <if test="channelNum != null  and channelNum != ''"> and channel_num = #{channelNum}</if>
-            <if test="algorithmType != null  and algorithmType != ''"> and algorithm_type = #{algorithmType}</if>
-            <if test="parameterSet != null  and parameterSet != ''"> and parameter_set = #{parameterSet}</if>
-            <if test="videoAddress != null  and videoAddress != ''"> and video_address = #{videoAddress}</if>
-            <if test="warnImage != null  and warnImage != ''"> and warn_image = #{warnImage}</if>
-            <if test="reportStatus != null  and reportStatus != ''"> and report_status = #{reportStatus}</if>
-            <if test="warnTime != null "> and warn_time = #{warnTime}</if>
+        <where>
+            del_flag = '0'
+            <if test="equipmentIp != null  and equipmentIp != ''">and equipment_ip = #{equipmentIp}</if>
+            <if test="equipmentName != null  and equipmentName != ''">and equipment_name like concat('%',
+                #{equipmentName}, '%')
+            </if>
+            <if test="channelId != null ">and channel_id = #{channelId}</if>
+            <if test="channelNum != null  and channelNum != ''">and channel_num = #{channelNum}</if>
+            <if test="algorithmType != null  and algorithmType != ''">and algorithm_type = #{algorithmType}</if>
+            <if test="parameterSet != null  and parameterSet != ''">and parameter_set = #{parameterSet}</if>
+            <if test="videoAddress != null  and videoAddress != ''">and video_address = #{videoAddress}</if>
+            <if test="warnImage != null  and warnImage != ''">and warn_image = #{warnImage}</if>
+            <if test="reportStatus != null  and reportStatus != ''">and report_status = #{reportStatus}</if>
+            <if test="warnTime != null ">and date_format(warn_time,'%Y%m%d') =date_format(#{warnTime},'%Y%m%d'</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.del_flag, w.create_time,
+        e.dept_name,e.dept_id
+        from warn_manage w left join equipment_manage e on e.equipment_ip = w.equipment_ip
+        <where>
+            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}
@@ -68,7 +101,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="updateBy != null">update_by,</if>
             <if test="updateTime != null">update_time,</if>
             <if test="remark != null">remark,</if>
-         </trim>
+        </trim>
         <trim prefix="values (" suffix=")" suffixOverrides=",">
             <if test="equipmentIp != null and equipmentIp != ''">#{equipmentIp},</if>
             <if test="equipmentName != null and equipmentName != ''">#{equipmentName},</if>
@@ -86,7 +119,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="updateBy != null">#{updateBy},</if>
             <if test="updateTime != null">#{updateTime},</if>
             <if test="remark != null">#{remark},</if>
-         </trim>
+        </trim>
     </insert>
 
     <update id="updateWarnManage" parameterType="WarnManage">
@@ -113,11 +146,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>