Pārlūkot izejas kodu

造数据修改类型

wwh 2 gadi atpakaļ
vecāks
revīzija
1ddbde251c

+ 5 - 12
huimv-admin/src/main/java/com/huimv/admin/service/impl/ProtThresholdServiceImpl.java

@@ -17,7 +17,6 @@ import com.huimv.admin.service.IProtThresholdService;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
-import org.springframework.transaction.annotation.Transactional;
 
 import javax.servlet.http.HttpServletRequest;
 import java.util.ArrayList;
@@ -52,10 +51,7 @@ public class ProtThresholdServiceImpl extends ServiceImpl<ProtThresholdMapper, P
         Integer userId = TokenSign.getMemberIdByJwtToken(httpServletRequest);
         List<Integer> userIds =sysAccountMultilevelMapper.getLowerLevel( userId,farmId);
         List<Integer> collect =new ArrayList<>();
-        String userIds1 = "";
-        if (ObjectUtil.isNotEmpty(protThresholdList)){
-            userIds1 = protThresholdList.get(0).getUserIds();
-        }
+        String userIds1 = protThresholdList.get(0).getUserIds();
         if (StringUtils.isNotBlank(userIds1)){
             collect = Arrays.stream(userIds1.split(",")).map(Integer::valueOf).filter(userIds::contains).collect(Collectors.toList());
         }
@@ -75,7 +71,6 @@ public class ProtThresholdServiceImpl extends ServiceImpl<ProtThresholdMapper, P
             jsonObject.put("FLOW1", 0);
             jsonObject.put("FLOW2", 0);
             jsonObject.put("userIds", 0);
-            jsonObject.put("protType", 0);
             jsonObject.put("dataType", 0);
             return new Result(ResultCode.SUCCESS, jsonObject);
         } else {
@@ -96,7 +91,6 @@ public class ProtThresholdServiceImpl extends ServiceImpl<ProtThresholdMapper, P
     }
 
     @Override
-    @Transactional
     public Result add(HttpServletRequest httpServletRequest, List<ProtThreshold> protThresholds) {
         for (ProtThreshold protThreshold : protThresholds) {
             if (ObjectUtil.isNotEmpty(protThreshold)) {
@@ -116,12 +110,10 @@ public class ProtThresholdServiceImpl extends ServiceImpl<ProtThresholdMapper, P
                     uoloadIds = Arrays.stream(userIds.split(",")).map(Integer::valueOf).collect(Collectors.toList());
                 }
                 //现有id
+                String oldUserIds = threshold.getUserIds();
                 List<Integer> oldUsersIds = new ArrayList<>();
-                if(ObjectUtil.isNotEmpty(threshold)){
-                    String oldUserIds =   threshold.getUserIds();
-                    if (StringUtils.isNotBlank(oldUserIds)){
-                        oldUsersIds = Arrays.stream(oldUserIds.split(",")).map(Integer::valueOf).collect(Collectors.toList());
-                    }
+                if (StringUtils.isNotBlank(oldUserIds)){
+                    oldUsersIds = Arrays.stream(oldUserIds.split(",")).map(Integer::valueOf).collect(Collectors.toList());
                 }
                 // 现有 -下属 + 上传
                 oldUsersIds.removeAll(lowerLevelIds);
@@ -159,6 +151,7 @@ public class ProtThresholdServiceImpl extends ServiceImpl<ProtThresholdMapper, P
                 } else if (Integer.parseInt(protThreshold.getFlow2()) < Integer.parseInt(protThreshold.getFlow1())) {
                     return new Result(ResultCode.FAIL, "红色预警浓度不能低于橙色预警浓度");
                 } else {
+
                     if (ObjectUtil.isEmpty(threshold)) {
                         protThresholdMapper.insert(protThreshold1);
                     } else {

+ 50 - 12
huimv-admin/src/main/java/com/huimv/admin/timer/GasTimer.java

@@ -64,36 +64,45 @@ public class GasTimer {
             GasThreshold gasThreshold = thresholdMapper.selectOne(queryWrapper);
             if (Double.parseDouble(nh3n) > Double.parseDouble(gasThreshold.getNh3N())) {
                 warningInfo.setWarningContent(nh3n + "超过阈值,系统预警提醒");
+                warningInfo.setWarningType(0);
             }
             if (Double.parseDouble(jlm) > Double.parseDouble(gasThreshold.getJlm())) {
                 warningInfo.setWarningContent(jlm + "超过阈值,系统预警提醒");
+                warningInfo.setWarningType(1);
             }
             if (Double.parseDouble(elht) > Double.parseDouble(gasThreshold.getElht())) {
                 warningInfo.setWarningContent(elht + "超过阈值,系统预警提醒");
+                warningInfo.setWarningType(2);
             }
             if (Double.parseDouble(ejel) > Double.parseDouble(gasThreshold.getEjel())) {
                 warningInfo.setWarningContent(ejel + "超过阈值,系统预警提醒");
+                warningInfo.setWarningType(3);
             }
             if (Double.parseDouble(h2s) > Double.parseDouble(gasThreshold.getH2s())) {
                 warningInfo.setWarningContent(h2s + "超过阈值,系统预警提醒");
+                warningInfo.setWarningType(4);
             }
             if (Double.parseDouble(byx) > Double.parseDouble(gasThreshold.getByx())) {
                 warningInfo.setWarningContent(byx + "超过阈值,系统预警提醒");
+                warningInfo.setWarningType(5);
             }
             if (Double.parseDouble(ch3) > Double.parseDouble(gasThreshold.getCh3sh())) {
                 warningInfo.setWarningContent(ch3 + "超过阈值,系统预警提醒");
+                warningInfo.setWarningType(6);
             }
             if (Double.parseDouble(sja) > Double.parseDouble(gasThreshold.getSja())) {
                 warningInfo.setWarningContent(sja + "超过阈值,系统预警提醒");
+                warningInfo.setWarningType(7);
             }
             if (Double.parseDouble(cq) > Double.parseDouble(gasThreshold.getCq())) {
                 warningInfo.setWarningContent(cq + "超过阈值,系统预警提醒");
+                warningInfo.setWarningType(8);
             }
-            warningInfo.setWarningType(1);
+
             warningInfo.setBuildLocation("屋顶");
             warningInfo.setDate(new Date());
-            warningInfo.setFarmId(21);
-            warningInfo.setUserIds("1,2");
+            warningInfo.setFarmId(gasThreshold.getFarmId());
+            warningInfo.setUserIds(gasThreshold.getUserIds());
             warningInfoMapper.insert(warningInfo);
 
         } else if ("2".equals(type)) {
@@ -101,108 +110,137 @@ public class GasTimer {
             GasThreshold gasThreshold = thresholdMapper.selectOne(queryWrapper);
             if (Double.parseDouble(nh3n) > Double.parseDouble(gasThreshold.getNh3N())) {
                 warningInfo.setWarningContent(nh3n + "超过阈值,系统预警提醒");
+                warningInfo.setWarningType(0);
             }
             if (Double.parseDouble(jlm) > Double.parseDouble(gasThreshold.getJlm())) {
                 warningInfo.setWarningContent(jlm + "超过阈值,系统预警提醒");
+                warningInfo.setWarningType(1);
             }
             if (Double.parseDouble(elht) > Double.parseDouble(gasThreshold.getElht())) {
                 warningInfo.setWarningContent(elht + "超过阈值,系统预警提醒");
+                warningInfo.setWarningType(2);
             }
             if (Double.parseDouble(ejel) > Double.parseDouble(gasThreshold.getEjel())) {
                 warningInfo.setWarningContent(ejel + "超过阈值,系统预警提醒");
+                warningInfo.setWarningType(3);
             }
             if (Double.parseDouble(h2s) > Double.parseDouble(gasThreshold.getH2s())) {
                 warningInfo.setWarningContent(h2s + "超过阈值,系统预警提醒");
+                warningInfo.setWarningType(4);
+
             }
             if (Double.parseDouble(byx) > Double.parseDouble(gasThreshold.getByx())) {
                 warningInfo.setWarningContent(byx + "超过阈值,系统预警提醒");
+                warningInfo.setWarningType(5);
             }
             if (Double.parseDouble(ch3) > Double.parseDouble(gasThreshold.getCh3sh())) {
                 warningInfo.setWarningContent(ch3 + "超过阈值,系统预警提醒");
+                warningInfo.setWarningType(6);
             }
             if (Double.parseDouble(sja) > Double.parseDouble(gasThreshold.getSja())) {
                 warningInfo.setWarningContent(sja + "超过阈值,系统预警提醒");
+                warningInfo.setWarningType(7);
             }
             if (Double.parseDouble(cq) > Double.parseDouble(gasThreshold.getCq())) {
                 warningInfo.setWarningContent(cq + "超过阈值,系统预警提醒");
+                warningInfo.setWarningType(8);
             }
-            warningInfo.setWarningType(2);
+
             warningInfo.setBuildLocation("厂界上");
             warningInfo.setDate(new Date());
-            warningInfo.setFarmId(21);
-            warningInfo.setUserIds("1,2");
+            warningInfo.setFarmId(gasThreshold.getFarmId());
+            warningInfo.setUserIds(gasThreshold.getUserIds());
             warningInfoMapper.insert(warningInfo);
         } else if ("3".equals(type)) {
             queryWrapper.eq("farm_id", 21).eq("gas_type", 3);
             GasThreshold gasThreshold = thresholdMapper.selectOne(queryWrapper);
             if (Double.parseDouble(nh3n) > Double.parseDouble(gasThreshold.getNh3N())) {
                 warningInfo.setWarningContent(nh3n + "超过阈值,系统预警提醒");
+                warningInfo.setWarningType(0);
             }
             if (Double.parseDouble(jlm) > Double.parseDouble(gasThreshold.getJlm())) {
                 warningInfo.setWarningContent(jlm + "超过阈值,系统预警提醒");
+                warningInfo.setWarningType(1);
             }
             if (Double.parseDouble(elht) > Double.parseDouble(gasThreshold.getElht())) {
                 warningInfo.setWarningContent(elht + "超过阈值,系统预警提醒");
+                warningInfo.setWarningType(2);
             }
             if (Double.parseDouble(ejel) > Double.parseDouble(gasThreshold.getEjel())) {
                 warningInfo.setWarningContent(ejel + "超过阈值,系统预警提醒");
+                warningInfo.setWarningType(3);
             }
             if (Double.parseDouble(h2s) > Double.parseDouble(gasThreshold.getH2s())) {
                 warningInfo.setWarningContent(h2s + "超过阈值,系统预警提醒");
+                warningInfo.setWarningType(4);
+
             }
             if (Double.parseDouble(byx) > Double.parseDouble(gasThreshold.getByx())) {
                 warningInfo.setWarningContent(byx + "超过阈值,系统预警提醒");
+                warningInfo.setWarningType(5);
             }
             if (Double.parseDouble(ch3) > Double.parseDouble(gasThreshold.getCh3sh())) {
                 warningInfo.setWarningContent(ch3 + "超过阈值,系统预警提醒");
+                warningInfo.setWarningType(6);
             }
             if (Double.parseDouble(sja) > Double.parseDouble(gasThreshold.getSja())) {
                 warningInfo.setWarningContent(sja + "超过阈值,系统预警提醒");
+                warningInfo.setWarningType(7);
             }
             if (Double.parseDouble(cq) > Double.parseDouble(gasThreshold.getCq())) {
                 warningInfo.setWarningContent(cq + "超过阈值,系统预警提醒");
+                warningInfo.setWarningType(8);
             }
-            warningInfo.setWarningType(3);
+
             warningInfo.setBuildLocation("厂界下");
             warningInfo.setDate(new Date());
-            warningInfo.setFarmId(21);
-            warningInfo.setUserIds("1,2");
+            warningInfo.setFarmId(gasThreshold.getFarmId());
+            warningInfo.setUserIds(gasThreshold.getUserIds());
             warningInfoMapper.insert(warningInfo);
         } else if ("4".equals(type)) {
             queryWrapper.eq("farm_id", 21).eq("gas_type", 4);
             GasThreshold gasThreshold = thresholdMapper.selectOne(queryWrapper);
             if (Double.parseDouble(nh3n) > Double.parseDouble(gasThreshold.getNh3N())) {
                 warningInfo.setWarningContent(nh3n + "超过阈值,系统预警提醒");
+                warningInfo.setWarningType(0);
             }
             if (Double.parseDouble(jlm) > Double.parseDouble(gasThreshold.getJlm())) {
                 warningInfo.setWarningContent(jlm + "超过阈值,系统预警提醒");
+                warningInfo.setWarningType(1);
             }
             if (Double.parseDouble(elht) > Double.parseDouble(gasThreshold.getElht())) {
                 warningInfo.setWarningContent(elht + "超过阈值,系统预警提醒");
+                warningInfo.setWarningType(2);
             }
             if (Double.parseDouble(ejel) > Double.parseDouble(gasThreshold.getEjel())) {
                 warningInfo.setWarningContent(ejel + "超过阈值,系统预警提醒");
+                warningInfo.setWarningType(3);
             }
             if (Double.parseDouble(h2s) > Double.parseDouble(gasThreshold.getH2s())) {
                 warningInfo.setWarningContent(h2s + "超过阈值,系统预警提醒");
+                warningInfo.setWarningType(4);
             }
             if (Double.parseDouble(byx) > Double.parseDouble(gasThreshold.getByx())) {
                 warningInfo.setWarningContent(byx + "超过阈值,系统预警提醒");
+                warningInfo.setWarningType(5);
             }
             if (Double.parseDouble(ch3) > Double.parseDouble(gasThreshold.getCh3sh())) {
                 warningInfo.setWarningContent(ch3 + "超过阈值,系统预警提醒");
+                warningInfo.setWarningType(6);
             }
             if (Double.parseDouble(sja) > Double.parseDouble(gasThreshold.getSja())) {
                 warningInfo.setWarningContent(sja + "超过阈值,系统预警提醒");
+                warningInfo.setWarningType(7);
             }
             if (Double.parseDouble(cq) > Double.parseDouble(gasThreshold.getCq())) {
                 warningInfo.setWarningContent(cq + "超过阈值,系统预警提醒");
+                warningInfo.setWarningType(8);
             }
-            warningInfo.setWarningType(4);
+
             warningInfo.setBuildLocation("厂界居民");
             warningInfo.setDate(new Date());
-            warningInfo.setFarmId(21);
-            warningInfo.setUserIds("1,2");
+            warningInfo.setFarmId(gasThreshold.getFarmId());
+            warningInfo.setUserIds(gasThreshold.getUserIds());
             warningInfoMapper.insert(warningInfo);
         }
     }

+ 60 - 40
huimv-admin/src/main/java/com/huimv/admin/timer/ProtTimer.java

@@ -63,38 +63,44 @@ public class ProtTimer {
             ProtThreshold protThreshold = protThresholdMapper.selectOne(queryWrapper);//进污口
             if (Double.parseDouble(num) > Double.parseDouble(protThreshold.getPh2())) {
                 protWarningInfo.setWarningContent("进污口ph值为" + num + "达到红色预警");
+                protWarningInfo.setWarningType(1);
             } else if (Double.parseDouble(num) > Double.parseDouble(protThreshold.getPh1())) {
                 protWarningInfo.setWarningContent("进污口ph值为" + num + "达到橙色预警");
-            }
-            if (Double.parseDouble(num1) > Double.parseDouble(protThreshold.getCod2())) {
+                protWarningInfo.setWarningType(1);
+            } else if (Double.parseDouble(num1) > Double.parseDouble(protThreshold.getCod2())) {
                 protWarningInfo.setWarningContent("进污口cod值为" + num1 + "达到红色预警");
+                protWarningInfo.setWarningType(0);
             } else if (Double.parseDouble(num1) > Double.parseDouble(protThreshold.getCod1())) {
                 protWarningInfo.setWarningContent("进污口cod值为" + num1 + "达到橙色预警");
-            }
-            if (Double.parseDouble(num2) > Double.parseDouble(protThreshold.getNh3n2())) {
+                protWarningInfo.setWarningType(0);
+            } else if (Double.parseDouble(num2) > Double.parseDouble(protThreshold.getNh3n2())) {
                 protWarningInfo.setWarningContent("进污口NH3N值为" + num2 + "达到红色预警");
+                protWarningInfo.setWarningType(2);
             } else if (Double.parseDouble(num2) > Double.parseDouble(protThreshold.getNh3n1())) {
                 protWarningInfo.setWarningContent("进污口NH3N值为" + num2 + "达到橙色预警");
-            }
-            if (Double.parseDouble(num3) > Double.parseDouble(protThreshold.getTp2())) {
+                protWarningInfo.setWarningType(2);
+            } else if (Double.parseDouble(num3) > Double.parseDouble(protThreshold.getTp2())) {
                 protWarningInfo.setWarningContent("进污口TP值为" + num3 + "达到红色预警");
+                protWarningInfo.setWarningType(3);
             } else if (Double.parseDouble(num3) > Double.parseDouble(protThreshold.getTp1())) {
                 protWarningInfo.setWarningContent("进污口TP值为" + num3 + "达到橙色预警");
-            }
-            if (Double.parseDouble(num4) > Double.parseDouble(protThreshold.getTn2())) {
+                protWarningInfo.setWarningType(3);
+            } else if (Double.parseDouble(num4) > Double.parseDouble(protThreshold.getTn2())) {
                 protWarningInfo.setWarningContent("进污口TN值为" + num4 + "达到红色预警");
+                protWarningInfo.setWarningType(4);
             } else if (Double.parseDouble(num4) > Double.parseDouble(protThreshold.getTn1())) {
-                protWarningInfo.setWarningContent("进污口TN值为" + num4+ "达到橙色预警");
-            }
-            if (Double.parseDouble(num5) > Double.parseDouble(protThreshold.getFlow2())) {
+                protWarningInfo.setWarningContent("进污口TN值为" + num4 + "达到橙色预警");
+                protWarningInfo.setWarningType(4);
+            } else if (Double.parseDouble(num5) > Double.parseDouble(protThreshold.getFlow2())) {
                 protWarningInfo.setWarningContent("进污口累计流量值为" + num5 + "达到红色预警");
+                protWarningInfo.setWarningType(5);
             } else if (Double.parseDouble(num5) > Double.parseDouble(protThreshold.getFlow1())) {
                 protWarningInfo.setWarningContent("进污口累计流量值为" + num5 + "达到橙色预警");
+                protWarningInfo.setWarningType(5);
             }
-            protWarningInfo.setFarmId(21);
-            protWarningInfo.setWarningType(Integer.parseInt(num6));
+            protWarningInfo.setFarmId(protThreshold.getFarmId());
             protWarningInfo.setDate(new Date());
-            protWarningInfo.setUserIds("1,2");
+            protWarningInfo.setUserIds(protThreshold.getUserIds());
             protWarningInfo.setDeviceId(Integer.parseInt(num6));
             protWarningInfo.setBuildLocation("进污口");
             warningInfoMapper.insert(protWarningInfo);
@@ -103,38 +109,45 @@ public class ProtTimer {
             ProtThreshold protThreshold = protThresholdMapper.selectOne(queryWrapper);//污口
             if (Double.parseDouble(num) > Double.parseDouble(protThreshold.getPh2())) {
                 protWarningInfo.setWarningContent("处理口ph值为" + num + "达到红色预警");
+                protWarningInfo.setWarningType(1);
             } else if (Double.parseDouble(num) > Double.parseDouble(protThreshold.getPh1())) {
                 protWarningInfo.setWarningContent("处理口ph值为" + num + "达到橙色预警");
-            }
-            if (Double.parseDouble(num1) > Double.parseDouble(protThreshold.getCod2())) {
+                protWarningInfo.setWarningType(1);
+            } else if (Double.parseDouble(num1) > Double.parseDouble(protThreshold.getCod2())) {
                 protWarningInfo.setWarningContent("处理口cod值为" + num1 + "达到红色预警");
+                protWarningInfo.setWarningType(0);
             } else if (Double.parseDouble(num1) > Double.parseDouble(protThreshold.getCod1())) {
                 protWarningInfo.setWarningContent("处理口cod值为" + num1 + "达到橙色预警");
-            }
-            if (Double.parseDouble(num2) > Double.parseDouble(protThreshold.getNh3n2())) {
+                protWarningInfo.setWarningType(0);
+            } else if (Double.parseDouble(num2) > Double.parseDouble(protThreshold.getNh3n2())) {
                 protWarningInfo.setWarningContent("处理口NH3N值为" + num2 + "达到红色预警");
+                protWarningInfo.setWarningType(2);
             } else if (Double.parseDouble(num2) > Double.parseDouble(protThreshold.getNh3n1())) {
                 protWarningInfo.setWarningContent("处理口NH3N值为" + num2 + "达到橙色预警");
-            }
-            if (Double.parseDouble(num3) > Double.parseDouble(protThreshold.getTp2())) {
+                protWarningInfo.setWarningType(2);
+            } else if (Double.parseDouble(num3) > Double.parseDouble(protThreshold.getTp2())) {
                 protWarningInfo.setWarningContent("处理口TP值为" + num3 + "达到红色预警");
+                protWarningInfo.setWarningType(3);
             } else if (Double.parseDouble(num3) > Double.parseDouble(protThreshold.getTp1())) {
                 protWarningInfo.setWarningContent("处理口TP值为" + num3 + "达到橙色预警");
-            }
-            if (Double.parseDouble(num4) > Double.parseDouble(protThreshold.getTn2())) {
+                protWarningInfo.setWarningType(3);
+            } else if (Double.parseDouble(num4) > Double.parseDouble(protThreshold.getTn2())) {
                 protWarningInfo.setWarningContent("处理口TN值为" + num4 + "达到红色预警");
+                protWarningInfo.setWarningType(4);
             } else if (Double.parseDouble(num4) > Double.parseDouble(protThreshold.getTn1())) {
-                protWarningInfo.setWarningContent("处理口TN值为" + num4+ "达到橙色预警");
-            }
-            if (Double.parseDouble(num5) > Double.parseDouble(protThreshold.getFlow2())) {
+                protWarningInfo.setWarningContent("处理口TN值为" + num4 + "达到橙色预警");
+                protWarningInfo.setWarningType(4);
+            } else if (Double.parseDouble(num5) > Double.parseDouble(protThreshold.getFlow2())) {
                 protWarningInfo.setWarningContent("处理口累计流量值为" + num5 + "达到红色预警");
+                protWarningInfo.setWarningType(5);
             } else if (Double.parseDouble(num5) > Double.parseDouble(protThreshold.getFlow1())) {
                 protWarningInfo.setWarningContent("处理口累计流量值为" + num5 + "达到橙色预警");
+                protWarningInfo.setWarningType(5);
             }
-            protWarningInfo.setFarmId(21);
+            protWarningInfo.setFarmId(protThreshold.getFarmId());
             protWarningInfo.setWarningType(Integer.parseInt(num6));
             protWarningInfo.setDate(new Date());
-            protWarningInfo.setUserIds("1,2");
+            protWarningInfo.setUserIds(protThreshold.getUserIds());
             protWarningInfo.setDeviceId(Integer.parseInt(num6));
             protWarningInfo.setBuildLocation("处理口");
             warningInfoMapper.insert(protWarningInfo);
@@ -143,38 +156,45 @@ public class ProtTimer {
             ProtThreshold protThreshold = protThresholdMapper.selectOne(queryWrapper);//进污口
             if (Double.parseDouble(num) > Double.parseDouble(protThreshold.getPh2())) {
                 protWarningInfo.setWarningContent("排污口ph值为" + num + "达到红色预警");
+                protWarningInfo.setWarningType(1);
             } else if (Double.parseDouble(num) > Double.parseDouble(protThreshold.getPh1())) {
                 protWarningInfo.setWarningContent("排污口ph值为" + num + "达到橙色预警");
-            }
-            if (Double.parseDouble(num1) > Double.parseDouble(protThreshold.getCod2())) {
+                protWarningInfo.setWarningType(1);
+            } else if (Double.parseDouble(num1) > Double.parseDouble(protThreshold.getCod2())) {
                 protWarningInfo.setWarningContent("排污口cod值为" + num1 + "达到红色预警");
+                protWarningInfo.setWarningType(0);
             } else if (Double.parseDouble(num1) > Double.parseDouble(protThreshold.getCod1())) {
                 protWarningInfo.setWarningContent("排污口cod值为" + num1 + "达到橙色预警");
-            }
-            if (Double.parseDouble(num2) > Double.parseDouble(protThreshold.getNh3n2())) {
+                protWarningInfo.setWarningType(0);
+            } else if (Double.parseDouble(num2) > Double.parseDouble(protThreshold.getNh3n2())) {
                 protWarningInfo.setWarningContent("排污口NH3N值为" + num2 + "达到红色预警");
+                protWarningInfo.setWarningType(2);
             } else if (Double.parseDouble(num2) > Double.parseDouble(protThreshold.getNh3n1())) {
                 protWarningInfo.setWarningContent("排污口NH3N值为" + num2 + "达到橙色预警");
-            }
-            if (Double.parseDouble(num3) > Double.parseDouble(protThreshold.getTp2())) {
+                protWarningInfo.setWarningType(2);
+            } else if (Double.parseDouble(num3) > Double.parseDouble(protThreshold.getTp2())) {
                 protWarningInfo.setWarningContent("排污口TP值为" + num3 + "达到红色预警");
+                protWarningInfo.setWarningType(3);
             } else if (Double.parseDouble(num3) > Double.parseDouble(protThreshold.getTp1())) {
                 protWarningInfo.setWarningContent("排污口TP值为" + num3 + "达到橙色预警");
-            }
-            if (Double.parseDouble(num4) > Double.parseDouble(protThreshold.getTn2())) {
+                protWarningInfo.setWarningType(3);
+            } else if (Double.parseDouble(num4) > Double.parseDouble(protThreshold.getTn2())) {
                 protWarningInfo.setWarningContent("排污口TN值为" + num4 + "达到红色预警");
+                protWarningInfo.setWarningType(4);
             } else if (Double.parseDouble(num4) > Double.parseDouble(protThreshold.getTn1())) {
-                protWarningInfo.setWarningContent("排污口TN值为" + num4+ "达到橙色预警");
-            }
-            if (Double.parseDouble(num5) > Double.parseDouble(protThreshold.getFlow2())) {
+                protWarningInfo.setWarningContent("排污口TN值为" + num4 + "达到橙色预警");
+                protWarningInfo.setWarningType(4);
+            } else if (Double.parseDouble(num5) > Double.parseDouble(protThreshold.getFlow2())) {
                 protWarningInfo.setWarningContent("排污口累计流量值为" + num5 + "达到红色预警");
+                protWarningInfo.setWarningType(5);
             } else if (Double.parseDouble(num5) > Double.parseDouble(protThreshold.getFlow1())) {
                 protWarningInfo.setWarningContent("排污口累计流量值为" + num5 + "达到橙色预警");
+                protWarningInfo.setWarningType(5);
             }
-            protWarningInfo.setFarmId(21);
+            protWarningInfo.setFarmId(protThreshold.getFarmId());
             protWarningInfo.setWarningType(Integer.parseInt(num6));
             protWarningInfo.setDate(new Date());
-            protWarningInfo.setUserIds("1,2");
+            protWarningInfo.setUserIds(protThreshold.getUserIds());
             protWarningInfo.setDeviceId(Integer.parseInt(num6));
             protWarningInfo.setBuildLocation("排污口");
             warningInfoMapper.insert(protWarningInfo);