Browse Source

能耗修改

wwh 2 years ago
parent
commit
34d700e4fe

+ 46 - 1
huimv-admin/src/main/java/com/huimv/admin/controller/EnergyWarningThresholdController.java

@@ -1,13 +1,25 @@
 package com.huimv.admin.controller;
 
 
+import com.huimv.admin.common.utils.Result;
+import com.huimv.admin.entity.EnergyWarningThreshold;
+import com.huimv.admin.entity.vo.EnergyThresholdVo;
+import com.huimv.admin.service.IEnergyWarningThresholdService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.CrossOrigin;
+import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
 
 import org.springframework.web.bind.annotation.RestController;
 
+import javax.servlet.http.HttpServletRequest;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
 /**
  * <p>
- *  前端控制器
+ * 前端控制器
  * </p>
  *
  * @author author
@@ -15,6 +27,39 @@ import org.springframework.web.bind.annotation.RestController;
  */
 @RestController
 @RequestMapping("/energy-warning-threshold")
+@CrossOrigin
 public class EnergyWarningThresholdController {
 
+    @Autowired
+    private IEnergyWarningThresholdService warningThresholdService;
+
+    @RequestMapping("/list")
+    public Result list(HttpServletRequest httpServletRequest, @RequestBody Map<String,String> paramsMap) {
+        return warningThresholdService.list(httpServletRequest,paramsMap);
+    }
+
+    @RequestMapping("/add")
+    public Result add(HttpServletRequest httpServletRequest, @RequestBody EnergyThresholdVo thresholdVo) {
+        String farmId = thresholdVo.getFarmId();
+        EnergyWarningThreshold energyWarningThreshold = thresholdVo.getRenChen().setFarmId(Integer.parseInt(farmId));
+        EnergyWarningThreshold energyWarningThreshold1 = thresholdVo.getChanFang().setFarmId(Integer.parseInt(farmId));
+        EnergyWarningThreshold energyWarningThreshold2 = thresholdVo.getBaoYu().setFarmId(Integer.parseInt(farmId));
+        EnergyWarningThreshold energyWarningThreshold3 = thresholdVo.getYuFei().setFarmId(Integer.parseInt(farmId));
+        EnergyWarningThreshold energyWarningThreshold4 = thresholdVo.getHouBei().setFarmId(Integer.parseInt(farmId));
+        EnergyWarningThreshold energyWarningThreshold5 = thresholdVo.getGeLi().setFarmId(Integer.parseInt(farmId));
+        energyWarningThreshold.setOther1("1");
+        energyWarningThreshold.setOther1("2");
+        energyWarningThreshold.setOther1("3");
+        energyWarningThreshold.setOther1("4");
+        energyWarningThreshold.setOther1("5");
+        energyWarningThreshold.setOther1("6");
+        List<EnergyWarningThreshold> energyWarningThresholdList = new ArrayList<>();
+        energyWarningThresholdList.add(energyWarningThreshold);
+        energyWarningThresholdList.add(energyWarningThreshold1);
+        energyWarningThresholdList.add(energyWarningThreshold2);
+        energyWarningThresholdList.add(energyWarningThreshold3);
+        energyWarningThresholdList.add(energyWarningThreshold4);
+        energyWarningThresholdList.add(energyWarningThreshold5);
+        return warningThresholdService.add(httpServletRequest, energyWarningThresholdList);
+    }
 }

+ 3 - 1
huimv-admin/src/main/java/com/huimv/admin/entity/EnergyWarningInfo.java

@@ -5,6 +5,8 @@ import com.baomidou.mybatisplus.annotation.IdType;
 import com.baomidou.mybatisplus.annotation.TableId;
 import java.time.LocalTime;
 import java.io.Serializable;
+import java.util.Date;
+
 import lombok.Data;
 import lombok.EqualsAndHashCode;
 import lombok.experimental.Accessors;
@@ -61,7 +63,7 @@ public class EnergyWarningInfo implements Serializable {
     /**
      * 日期
      */
-    private LocalTime date;
+    private Date date;
 
     /**
      * 人员id

+ 3 - 3
huimv-admin/src/main/java/com/huimv/admin/entity/EnergyWarningThreshold.java

@@ -50,11 +50,11 @@ public class EnergyWarningThreshold implements Serializable {
 
     private Integer farmId;
 
-    private String othre1;
+    private String other1;
 
-    private String othre2;
+    private String other2;
 
-    private String othre3;
+    private String other3;
 
 
 }

+ 16 - 0
huimv-admin/src/main/java/com/huimv/admin/entity/vo/EnergyThresholdVo.java

@@ -0,0 +1,16 @@
+package com.huimv.admin.entity.vo;
+
+import com.huimv.admin.entity.EnergyWarningThreshold;
+import lombok.Data;
+
+@Data
+public class EnergyThresholdVo {
+    String farmId;
+    private EnergyWarningThreshold renChen;
+    private EnergyWarningThreshold chanFang;
+    private EnergyWarningThreshold baoYu;
+    private EnergyWarningThreshold yuFei;
+    private EnergyWarningThreshold houBei;
+    private EnergyWarningThreshold geLi;
+
+}

+ 3 - 0
huimv-admin/src/main/java/com/huimv/admin/mapper/EnergyDataMapper.java

@@ -55,4 +55,7 @@ public interface EnergyDataMapper extends BaseMapper<EnergyData> {
     List<EnergyAllDataVo> listDayFeed(@Param(Constants.WRAPPER) QueryWrapper<EnergyData> queryWrapper);
 
     List<EnergyAllDataVo> listDayElectricity(@Param(Constants.WRAPPER) QueryWrapper<EnergyData> queryWrapper);
+
+    //能耗使用
+    EnergyData listDataCount(@Param(Constants.WRAPPER) QueryWrapper<EnergyData> queryWrapper);
 }

+ 7 - 0
huimv-admin/src/main/java/com/huimv/admin/service/IEnergyWarningThresholdService.java

@@ -1,8 +1,13 @@
 package com.huimv.admin.service;
 
+import com.huimv.admin.common.utils.Result;
 import com.huimv.admin.entity.EnergyWarningThreshold;
 import com.baomidou.mybatisplus.extension.service.IService;
 
+import javax.servlet.http.HttpServletRequest;
+import java.util.List;
+import java.util.Map;
+
 /**
  * <p>
  *  服务类
@@ -12,5 +17,7 @@ import com.baomidou.mybatisplus.extension.service.IService;
  * @since 2023-02-14
  */
 public interface IEnergyWarningThresholdService extends IService<EnergyWarningThreshold> {
+    Result list(HttpServletRequest httpServletRequest, Map<String,String> paramsMap);
 
+    Result add(HttpServletRequest httpServletRequest, List<EnergyWarningThreshold> energyWarningThresholds);
 }

+ 113 - 1
huimv-admin/src/main/java/com/huimv/admin/service/impl/EnergyWarningThresholdServiceImpl.java

@@ -1,14 +1,30 @@
 package com.huimv.admin.service.impl;
 
+import cn.hutool.core.util.ObjectUtil;
+import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.toolkit.StringUtils;
+import com.huimv.admin.common.token.TokenSign;
+import com.huimv.admin.common.utils.Result;
+import com.huimv.admin.common.utils.ResultCode;
 import com.huimv.admin.entity.EnergyWarningThreshold;
 import com.huimv.admin.mapper.EnergyWarningThresholdMapper;
+import com.huimv.admin.mapper.SysAccountMultilevelMapper;
 import com.huimv.admin.service.IEnergyWarningThresholdService;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
+import javax.servlet.http.HttpServletRequest;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
+
 /**
  * <p>
- *  服务实现类
+ * 服务实现类
  * </p>
  *
  * @author author
@@ -17,4 +33,100 @@ import org.springframework.stereotype.Service;
 @Service
 public class EnergyWarningThresholdServiceImpl extends ServiceImpl<EnergyWarningThresholdMapper, EnergyWarningThreshold> implements IEnergyWarningThresholdService {
 
+    @Autowired
+    private EnergyWarningThresholdMapper warningThresholdMapper;
+    @Autowired
+    SysAccountMultilevelMapper sysAccountMultilevelMapper;
+
+    @Override
+    public Result list(HttpServletRequest httpServletRequest, Map<String, String> paramsMap) {
+        String farmId = paramsMap.get("farmId");
+        QueryWrapper<EnergyWarningThreshold> queryWrapper = new QueryWrapper<>();
+        queryWrapper.eq("farm_id", farmId);
+        List<EnergyWarningThreshold> energyWarningThresholds = warningThresholdMapper.selectList(queryWrapper);
+
+        Integer userId = TokenSign.getMemberIdByJwtToken(httpServletRequest);
+        List<Integer> userIds = sysAccountMultilevelMapper.getLowerLevel(userId, farmId);
+        List<Integer> collect = new ArrayList<>();
+        if (ObjectUtil.isNotEmpty(energyWarningThresholds) && StringUtils.isNotBlank(energyWarningThresholds.get(0).getUserIds())) {
+            collect = Arrays.stream(energyWarningThresholds.get(0).getUserIds().split(",")).map(Integer::valueOf).filter(userIds::contains).collect(Collectors.toList());
+        }
+
+        if (energyWarningThresholds.size() == 0) {
+            JSONObject jsonObject = new JSONObject();
+            jsonObject.put("maxWater", 0);
+            jsonObject.put("maxElectricity", 0);
+            jsonObject.put("maxFeed", 0);
+            jsonObject.put("maxGas", 0);
+            return new Result(ResultCode.SUCCESS, jsonObject);
+        } else {
+            JSONObject jsonObject = new JSONObject();
+            for (int i = 0; i < energyWarningThresholds.size(); i++) {
+                if ("1".equals(energyWarningThresholds.get(i).getOther1())) {
+                    jsonObject.put("renChen", energyWarningThresholds.get(i));
+                } else if ("2".equals(energyWarningThresholds.get(i).getOther1())) {
+                    jsonObject.put("chanFang", energyWarningThresholds.get(i));
+                } else if ("3".equals(energyWarningThresholds.get(i).getOther1())) {
+                    jsonObject.put("baoYu", energyWarningThresholds.get(i));
+                } else if ("4".equals(energyWarningThresholds.get(i).getOther1())) {
+                    jsonObject.put("yuFei", energyWarningThresholds.get(i));
+                } else if ("5".equals(energyWarningThresholds.get(i).getOther1())) {
+                    jsonObject.put("houBei", energyWarningThresholds.get(i));
+                } else if ("6".equals(energyWarningThresholds.get(i).getOther1())) {
+                    jsonObject.put("geLi", energyWarningThresholds.get(i));
+                }
+            }
+            jsonObject.put("userIds", collect);
+            return new Result(ResultCode.SUCCESS, jsonObject);
+        }
+
+    }
+
+    @Override
+    public Result add(HttpServletRequest httpServletRequest, List<EnergyWarningThreshold> energyWarningThresholds) {
+        for (EnergyWarningThreshold energyWarningThreshold : energyWarningThresholds) {
+            if (ObjectUtil.isNotEmpty(energyWarningThreshold)) {
+
+                Integer farmId = energyWarningThreshold.getFarmId();
+                String userIds = energyWarningThreshold.getUserIds();
+                QueryWrapper<EnergyWarningThreshold> queryWrapper = new QueryWrapper<>();
+                queryWrapper.eq("farmId", farmId).eq("other1", energyWarningThreshold.getOther1());
+                EnergyWarningThreshold energyWarningThreshold1 = warningThresholdMapper.selectOne(queryWrapper);
+
+                //去掉属于该人物的id
+                Integer userId = TokenSign.getMemberIdByJwtToken(httpServletRequest);
+                //下属id
+                List<Integer> lowerLevelIds = sysAccountMultilevelMapper.getLowerLevel(userId, farmId + "");
+                //上传id
+                List<Integer> uoloadIds = new ArrayList<>();
+                if (StringUtils.isNotBlank(userIds)) {
+                    uoloadIds = Arrays.stream(userIds.split(",")).map(Integer::valueOf).collect(Collectors.toList());
+                }
+                //现有id
+                String oldUserIds = energyWarningThreshold1.getUserIds();
+                List<Integer> oldUsersIds = new ArrayList<>();
+                if (StringUtils.isNotBlank(oldUserIds)) {
+                    oldUsersIds = Arrays.stream(oldUserIds.split(",")).map(Integer::valueOf).collect(Collectors.toList());
+                }
+                // 现有 -下属 + 上传
+                oldUsersIds.removeAll(lowerLevelIds);
+                oldUsersIds.addAll(uoloadIds);
+
+                EnergyWarningThreshold threshold = new EnergyWarningThreshold();
+                threshold.setMaxWater(energyWarningThreshold.getMaxWater());
+                threshold.setMaxElectricity(energyWarningThreshold.getMaxElectricity());
+                threshold.setMaxFeed(energyWarningThreshold.getMaxFeed());
+                threshold.setMaxGas(energyWarningThreshold.getMaxGas());
+                threshold.setUserIds(oldUsersIds.stream().map(String::valueOf).collect(Collectors.joining(",")));
+
+                if (ObjectUtil.isEmpty(energyWarningThreshold1)) {
+                    warningThresholdMapper.insert(threshold);
+                } else {
+                    threshold.setId(energyWarningThreshold.getId());
+                    warningThresholdMapper.updateById(threshold);
+                }
+            }
+        }
+        return new Result(ResultCode.SUCCESS,"修改成功");
+    }
 }

+ 100 - 9
huimv-admin/src/main/java/com/huimv/admin/timer/EnergyTimer.java

@@ -1,16 +1,18 @@
 package com.huimv.admin.timer;
 
+import cn.hutool.core.date.DateTime;
+import cn.hutool.core.date.DateUtil;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.huimv.admin.common.utils.NumberUtils;
-import com.huimv.admin.entity.EnergyData;
-import com.huimv.admin.entity.EnergyEnvDevice;
-import com.huimv.admin.mapper.EnergyDataMapper;
-import com.huimv.admin.mapper.EnergyEnvDeviceMapper;
+import com.huimv.admin.entity.*;
+import com.huimv.admin.mapper.*;
+import org.apache.commons.lang.time.DateUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.context.annotation.Configuration;
 import org.springframework.scheduling.annotation.EnableScheduling;
 import org.springframework.scheduling.annotation.Scheduled;
 
+import java.text.DecimalFormat;
 import java.util.Date;
 import java.util.List;
 
@@ -22,21 +24,110 @@ public class EnergyTimer {
     private EnergyEnvDeviceMapper deviceMapper;
     @Autowired
     private EnergyDataMapper dataMapper;
+    @Autowired
+    private BasePigpenMapper basePigpenMapper;
+    @Autowired
+    private EnergyWarningThresholdMapper warningThresholdMapper;
+    @Autowired
+    private EnergyWarningInfoMapper infoMapper;
 
-//    能耗数据
+    //    能耗数据
     @Scheduled(cron = "0 0 */1 * * ? ")
     private void getShenChan() throws Exception {
         List<EnergyEnvDevice> energyEnvDevices = deviceMapper.selectList(null);
+
         for (EnergyEnvDevice energyEnvDevice : energyEnvDevices) {
+            QueryWrapper<BasePigpen> basePigpenQueryWrapper = new QueryWrapper<>();
+            basePigpenQueryWrapper.eq("id", energyEnvDevice.getUnitId()).eq("farm_id", energyEnvDevice.getFarmId());
+            BasePigpen basePigpen = basePigpenMapper.selectOne(basePigpenQueryWrapper);
+
+            String feed = NumberUtils.getNum(83, 85, 1);
+            String water = NumberUtils.getNum(250, 270, 1);
+            String gas = NumberUtils.getNum(250, 270, 1);
+            String electricity = NumberUtils.getNum(83, 85, 1);
+
             EnergyData energyData = new EnergyData();
             energyData.setCreateDate(new Date());
             energyData.setFarmId(energyEnvDevice.getFarmId());
             energyData.setUnitId(energyEnvDevice.getUnitId());
-            energyData.setFeedValue(NumberUtils.getNum(1, 10, 1));
-            energyData.setWaterValue(NumberUtils.getNum(1, 5, 1));
-            energyData.setGasValue(NumberUtils.getNum(1, 5, 1));
-            energyData.setElectricityValue(NumberUtils.getNum(5, 10, 1));
+            energyData.setFeedValue(feed);
+            energyData.setWaterValue(water);
+            energyData.setGasValue(gas);
+            energyData.setElectricityValue(electricity);
             dataMapper.insert(energyData);
+
+            QueryWrapper<EnergyWarningThreshold> wrapper = new QueryWrapper<>();
+            wrapper.eq("other1", basePigpen.getStageCode()).eq("farm_id",energyEnvDevice.getFarmId());
+            EnergyWarningThreshold threshold = warningThresholdMapper.selectOne(wrapper);
+
+            QueryWrapper<EnergyData> dataQueryWrapper = new QueryWrapper<>();
+            dataQueryWrapper.eq("farm_id", energyEnvDevice.getFarmId()).eq("unit_id", energyEnvDevice.getUnitId());
+            DateTime dateTime = DateUtil.beginOfDay(new Date());
+            dataQueryWrapper.ge("create_date", dateTime);
+            EnergyData energyData1 = dataMapper.listDataCount(dataQueryWrapper);
+
+            if (Float.parseFloat(energyData1.getWaterValue())+Float.parseFloat(water) >Float.parseFloat(threshold.getMaxWater())) {
+                float waterCount = Float.parseFloat(energyData1.getWaterValue()) + Float.parseFloat(water);
+                DecimalFormat df = new DecimalFormat("#.00");
+                String format = df.format(waterCount);
+                EnergyWarningInfo warningInfo = new EnergyWarningInfo();
+                warningInfo.setWarningType(1);
+                warningInfo.setWarningContent("今日累计用水量" + format + "超过阈值");
+                warningInfo.setUnitName(basePigpen.getBuildName());
+                warningInfo.setUnitId(energyEnvDevice.getUnitId());
+                warningInfo.setDeviceId(energyEnvDevice.getId());
+                warningInfo.setDate(new Date());
+                warningInfo.setFarmId(energyEnvDevice.getFarmId());
+                warningInfo.setUserIds(threshold.getUserIds());
+                infoMapper.insert(warningInfo);
+            }
+            if (Float.parseFloat(energyData1.getElectricityValue())+Float.parseFloat(electricity) >Float.parseFloat(threshold.getMaxElectricity())) {
+                float electricityCount = Float.parseFloat(energyData1.getElectricityValue()) + Float.parseFloat(electricity);
+                DecimalFormat df = new DecimalFormat("#.00");
+                String format = df.format(electricityCount);
+                EnergyWarningInfo warningInfo = new EnergyWarningInfo();
+                warningInfo.setWarningType(2);
+                warningInfo.setWarningContent("今日累计用电量" + format + "超过阈值");
+                warningInfo.setUnitName(basePigpen.getBuildName());
+                warningInfo.setUnitId(energyEnvDevice.getUnitId());
+                warningInfo.setDeviceId(energyEnvDevice.getId());
+                warningInfo.setDate(new Date());
+                warningInfo.setFarmId(energyEnvDevice.getFarmId());
+                warningInfo.setUserIds(threshold.getUserIds());
+                infoMapper.insert(warningInfo);
+            }
+            if (Float.parseFloat(energyData1.getFeedValue())+Float.parseFloat(feed) >Float.parseFloat(threshold.getMaxFeed())) {
+                float feedCount = Float.parseFloat(energyData1.getFeedValue()) + Float.parseFloat(feed);
+                DecimalFormat df = new DecimalFormat("#.00");
+                String format = df.format(feedCount);
+                EnergyWarningInfo warningInfo = new EnergyWarningInfo();
+                warningInfo.setWarningType(3);
+                warningInfo.setWarningContent("今日累计用料量" + format + "超过阈值");
+                warningInfo.setUnitName(basePigpen.getBuildName());
+                warningInfo.setUnitId(energyEnvDevice.getUnitId());
+                warningInfo.setDeviceId(energyEnvDevice.getId());
+                warningInfo.setDate(new Date());
+                warningInfo.setFarmId(energyEnvDevice.getFarmId());
+                warningInfo.setUserIds(threshold.getUserIds());
+                infoMapper.insert(warningInfo);
+            }
+            if (Float.parseFloat(energyData1.getGasValue())+Float.parseFloat(gas) >Float.parseFloat(threshold.getMaxGas())) {
+                float gasCount = Float.parseFloat(energyData1.getGasValue()) + Float.parseFloat(gas);
+                DecimalFormat df = new DecimalFormat("#.00");
+                String format = df.format(gasCount);
+                EnergyWarningInfo warningInfo = new EnergyWarningInfo();
+                warningInfo.setWarningType(4);
+                warningInfo.setWarningContent("今日累计用气量" + format + "超过阈值");
+                warningInfo.setUnitName(basePigpen.getBuildName());
+                warningInfo.setUnitId(energyEnvDevice.getUnitId());
+                warningInfo.setDeviceId(energyEnvDevice.getId());
+                warningInfo.setDate(new Date());
+                warningInfo.setFarmId(energyEnvDevice.getFarmId());
+                warningInfo.setUserIds(threshold.getUserIds());
+                infoMapper.insert(warningInfo);
+            }
+
         }
+
     }
 }

+ 180 - 21
huimv-admin/src/main/java/com/huimv/admin/timer/GasTimer.java

@@ -66,183 +66,342 @@ public class  GasTimer {
                 if (Double.parseDouble(nh3n) > Double.parseDouble(gasThreshold.getNh3N())) {
                     warningInfo.setWarningContent("NH3N"+nh3n + "超过阈值,系统预警提醒");
                     warningInfo.setWarningType(0);
+                    warningInfo.setBuildLocation("屋顶");
+                    warningInfo.setDate(new Date());
+                    warningInfo.setFarmId(gasThreshold.getFarmId());
+                    warningInfo.setUserIds(gasThreshold.getUserIds());
+                    warningInfoMapper.insert(warningInfo);
                 }
                 if (Double.parseDouble(jlm) > Double.parseDouble(gasThreshold.getJlm())) {
                     warningInfo.setWarningContent("甲硫醚"+jlm + "超过阈值,系统预警提醒");
                     warningInfo.setWarningType(1);
+                    warningInfo.setBuildLocation("屋顶");
+                    warningInfo.setDate(new Date());
+                    warningInfo.setFarmId(gasThreshold.getFarmId());
+                    warningInfo.setUserIds(gasThreshold.getUserIds());
+                    warningInfoMapper.insert(warningInfo);
                 }
                 if (Double.parseDouble(elht) > Double.parseDouble(gasThreshold.getElht())) {
                     warningInfo.setWarningContent("二硫化碳"+elht + "超过阈值,系统预警提醒");
                     warningInfo.setWarningType(2);
+                    warningInfo.setBuildLocation("屋顶");
+                    warningInfo.setDate(new Date());
+                    warningInfo.setFarmId(gasThreshold.getFarmId());
+                    warningInfo.setUserIds(gasThreshold.getUserIds());
+                    warningInfoMapper.insert(warningInfo);
                 }
                 if (Double.parseDouble(ejel) > Double.parseDouble(gasThreshold.getEjel())) {
                     warningInfo.setWarningContent("二甲二硫"+ejel + "超过阈值,系统预警提醒");
                     warningInfo.setWarningType(3);
+                    warningInfo.setBuildLocation("屋顶");
+                    warningInfo.setDate(new Date());
+                    warningInfo.setFarmId(gasThreshold.getFarmId());
+                    warningInfo.setUserIds(gasThreshold.getUserIds());
+                    warningInfoMapper.insert(warningInfo);
                 }
                 if (Double.parseDouble(h2s) > Double.parseDouble(gasThreshold.getH2s())) {
                     warningInfo.setWarningContent("H2S"+h2s + "超过阈值,系统预警提醒");
                     warningInfo.setWarningType(4);
+                    warningInfo.setBuildLocation("屋顶");
+                    warningInfo.setDate(new Date());
+                    warningInfo.setFarmId(gasThreshold.getFarmId());
+                    warningInfo.setUserIds(gasThreshold.getUserIds());
+                    warningInfoMapper.insert(warningInfo);
                 }
                 if (Double.parseDouble(byx) > Double.parseDouble(gasThreshold.getByx())) {
                     warningInfo.setWarningContent("苯乙烯"+byx + "超过阈值,系统预警提醒");
                     warningInfo.setWarningType(5);
+                    warningInfo.setBuildLocation("屋顶");
+                    warningInfo.setDate(new Date());
+                    warningInfo.setFarmId(gasThreshold.getFarmId());
+                    warningInfo.setUserIds(gasThreshold.getUserIds());
+                    warningInfoMapper.insert(warningInfo);
                 }
                 if (Double.parseDouble(ch3) > Double.parseDouble(gasThreshold.getCh3sh())) {
                     warningInfo.setWarningContent("CH3SH"+ch3 + "超过阈值,系统预警提醒");
                     warningInfo.setWarningType(6);
+                    warningInfo.setBuildLocation("屋顶");
+                    warningInfo.setDate(new Date());
+                    warningInfo.setFarmId(gasThreshold.getFarmId());
+                    warningInfo.setUserIds(gasThreshold.getUserIds());
+                    warningInfoMapper.insert(warningInfo);
                 }
                 if (Double.parseDouble(sja) > Double.parseDouble(gasThreshold.getSja())) {
                     warningInfo.setWarningContent("三甲胺"+sja + "超过阈值,系统预警提醒");
                     warningInfo.setWarningType(7);
+                    warningInfo.setBuildLocation("屋顶");
+                    warningInfo.setDate(new Date());
+                    warningInfo.setFarmId(gasThreshold.getFarmId());
+                    warningInfo.setUserIds(gasThreshold.getUserIds());
+                    warningInfoMapper.insert(warningInfo);
                 }
                 if (Double.parseDouble(cq) > Double.parseDouble(gasThreshold.getCq())) {
                     warningInfo.setWarningContent("臭气"+cq + "超过阈值,系统预警提醒");
                     warningInfo.setWarningType(8);
+                    warningInfo.setBuildLocation("屋顶");
+                    warningInfo.setDate(new Date());
+                    warningInfo.setFarmId(gasThreshold.getFarmId());
+                    warningInfo.setUserIds(gasThreshold.getUserIds());
+                    warningInfoMapper.insert(warningInfo);
                 }
 
-                warningInfo.setBuildLocation("屋顶");
-                warningInfo.setDate(new Date());
-                warningInfo.setFarmId(gasThreshold.getFarmId());
-                warningInfo.setUserIds(gasThreshold.getUserIds());
-                warningInfoMapper.insert(warningInfo);
-
             } else if (i==2) {
                 queryWrapper.eq("farm_id", 21).eq("gas_type", 2);
                 GasThreshold gasThreshold = thresholdMapper.selectOne(queryWrapper);
                 if (Double.parseDouble(nh3n) > Double.parseDouble(gasThreshold.getNh3N())) {
                     warningInfo.setWarningContent("NH3N"+nh3n + "超过阈值,系统预警提醒");
                     warningInfo.setWarningType(0);
+                    warningInfo.setBuildLocation("厂界上");
+                    warningInfo.setDate(new Date());
+                    warningInfo.setFarmId(gasThreshold.getFarmId());
+                    warningInfo.setUserIds(gasThreshold.getUserIds());
+                    warningInfoMapper.insert(warningInfo);
                 }
                 if (Double.parseDouble(jlm) > Double.parseDouble(gasThreshold.getJlm())) {
                     warningInfo.setWarningContent("甲硫醚"+jlm + "超过阈值,系统预警提醒");
                     warningInfo.setWarningType(1);
+                    warningInfo.setBuildLocation("厂界上");
+                    warningInfo.setDate(new Date());
+                    warningInfo.setFarmId(gasThreshold.getFarmId());
+                    warningInfo.setUserIds(gasThreshold.getUserIds());
+                    warningInfoMapper.insert(warningInfo);
                 }
                 if (Double.parseDouble(elht) > Double.parseDouble(gasThreshold.getElht())) {
                     warningInfo.setWarningContent("二硫化碳"+elht + "超过阈值,系统预警提醒");
                     warningInfo.setWarningType(2);
+                    warningInfo.setBuildLocation("厂界上");
+                    warningInfo.setDate(new Date());
+                    warningInfo.setFarmId(gasThreshold.getFarmId());
+                    warningInfo.setUserIds(gasThreshold.getUserIds());
+                    warningInfoMapper.insert(warningInfo);
                 }
                 if (Double.parseDouble(ejel) > Double.parseDouble(gasThreshold.getEjel())) {
                     warningInfo.setWarningContent("二甲二硫"+ejel + "超过阈值,系统预警提醒");
                     warningInfo.setWarningType(3);
+                    warningInfo.setBuildLocation("厂界上");
+                    warningInfo.setDate(new Date());
+                    warningInfo.setFarmId(gasThreshold.getFarmId());
+                    warningInfo.setUserIds(gasThreshold.getUserIds());
+                    warningInfoMapper.insert(warningInfo);
                 }
                 if (Double.parseDouble(h2s) > Double.parseDouble(gasThreshold.getH2s())) {
                     warningInfo.setWarningContent("H2S"+h2s + "超过阈值,系统预警提醒");
                     warningInfo.setWarningType(4);
+                    warningInfo.setBuildLocation("厂界上");
+                    warningInfo.setDate(new Date());
+                    warningInfo.setFarmId(gasThreshold.getFarmId());
+                    warningInfo.setUserIds(gasThreshold.getUserIds());
+                    warningInfoMapper.insert(warningInfo);
 
                 }
                 if (Double.parseDouble(byx) > Double.parseDouble(gasThreshold.getByx())) {
                     warningInfo.setWarningContent("苯乙烯"+byx + "超过阈值,系统预警提醒");
                     warningInfo.setWarningType(5);
+                    warningInfo.setBuildLocation("厂界上");
+                    warningInfo.setDate(new Date());
+                    warningInfo.setFarmId(gasThreshold.getFarmId());
+                    warningInfo.setUserIds(gasThreshold.getUserIds());
+                    warningInfoMapper.insert(warningInfo);
                 }
                 if (Double.parseDouble(ch3) > Double.parseDouble(gasThreshold.getCh3sh())) {
                     warningInfo.setWarningContent("CH3SH"+ch3 + "超过阈值,系统预警提醒");
                     warningInfo.setWarningType(6);
+                    warningInfo.setBuildLocation("厂界上");
+                    warningInfo.setDate(new Date());
+                    warningInfo.setFarmId(gasThreshold.getFarmId());
+                    warningInfo.setUserIds(gasThreshold.getUserIds());
+                    warningInfoMapper.insert(warningInfo);
                 }
                 if (Double.parseDouble(sja) > Double.parseDouble(gasThreshold.getSja())) {
                     warningInfo.setWarningContent("三甲胺"+sja + "超过阈值,系统预警提醒");
                     warningInfo.setWarningType(7);
+                    warningInfo.setBuildLocation("厂界上");
+                    warningInfo.setDate(new Date());
+                    warningInfo.setFarmId(gasThreshold.getFarmId());
+                    warningInfo.setUserIds(gasThreshold.getUserIds());
+                    warningInfoMapper.insert(warningInfo);
                 }
                 if (Double.parseDouble(cq) > Double.parseDouble(gasThreshold.getCq())) {
                     warningInfo.setWarningContent("臭气"+cq + "超过阈值,系统预警提醒");
                     warningInfo.setWarningType(8);
+                    warningInfo.setBuildLocation("厂界上");
+                    warningInfo.setDate(new Date());
+                    warningInfo.setFarmId(gasThreshold.getFarmId());
+                    warningInfo.setUserIds(gasThreshold.getUserIds());
+                    warningInfoMapper.insert(warningInfo);
                 }
 
-                warningInfo.setBuildLocation("厂界上");
-                warningInfo.setDate(new Date());
-                warningInfo.setFarmId(gasThreshold.getFarmId());
-                warningInfo.setUserIds(gasThreshold.getUserIds());
-                warningInfoMapper.insert(warningInfo);
             } else if (i==3) {
                 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"+nh3n + "超过阈值,系统预警提醒");
                     warningInfo.setWarningType(0);
+                    warningInfo.setBuildLocation("厂界下");
+                    warningInfo.setDate(new Date());
+                    warningInfo.setFarmId(gasThreshold.getFarmId());
+                    warningInfo.setUserIds(gasThreshold.getUserIds());
+                    warningInfoMapper.insert(warningInfo);
                 }
                 if (Double.parseDouble(jlm) > Double.parseDouble(gasThreshold.getJlm())) {
                     warningInfo.setWarningContent("甲硫醚"+jlm + "超过阈值,系统预警提醒");
                     warningInfo.setWarningType(1);
+                    warningInfo.setBuildLocation("厂界下");
+                    warningInfo.setDate(new Date());
+                    warningInfo.setFarmId(gasThreshold.getFarmId());
+                    warningInfo.setUserIds(gasThreshold.getUserIds());
+                    warningInfoMapper.insert(warningInfo);
                 }
                 if (Double.parseDouble(elht) > Double.parseDouble(gasThreshold.getElht())) {
                     warningInfo.setWarningContent("二硫化碳"+elht + "超过阈值,系统预警提醒");
                     warningInfo.setWarningType(2);
+                    warningInfo.setBuildLocation("厂界下");
+                    warningInfo.setDate(new Date());
+                    warningInfo.setFarmId(gasThreshold.getFarmId());
+                    warningInfo.setUserIds(gasThreshold.getUserIds());
+                    warningInfoMapper.insert(warningInfo);
                 }
                 if (Double.parseDouble(ejel) > Double.parseDouble(gasThreshold.getEjel())) {
                     warningInfo.setWarningContent("二甲二硫"+ejel + "超过阈值,系统预警提醒");
                     warningInfo.setWarningType(3);
+                    warningInfo.setBuildLocation("厂界下");
+                    warningInfo.setDate(new Date());
+                    warningInfo.setFarmId(gasThreshold.getFarmId());
+                    warningInfo.setUserIds(gasThreshold.getUserIds());
+                    warningInfoMapper.insert(warningInfo);
                 }
                 if (Double.parseDouble(h2s) > Double.parseDouble(gasThreshold.getH2s())) {
                     warningInfo.setWarningContent("H2S"+h2s + "超过阈值,系统预警提醒");
                     warningInfo.setWarningType(4);
+                    warningInfo.setBuildLocation("厂界下");
+                    warningInfo.setDate(new Date());
+                    warningInfo.setFarmId(gasThreshold.getFarmId());
+                    warningInfo.setUserIds(gasThreshold.getUserIds());
+                    warningInfoMapper.insert(warningInfo);
 
                 }
                 if (Double.parseDouble(byx) > Double.parseDouble(gasThreshold.getByx())) {
                     warningInfo.setWarningContent("苯乙烯"+byx + "超过阈值,系统预警提醒");
                     warningInfo.setWarningType(5);
+                    warningInfo.setBuildLocation("厂界下");
+                    warningInfo.setDate(new Date());
+                    warningInfo.setFarmId(gasThreshold.getFarmId());
+                    warningInfo.setUserIds(gasThreshold.getUserIds());
+                    warningInfoMapper.insert(warningInfo);
                 }
                 if (Double.parseDouble(ch3) > Double.parseDouble(gasThreshold.getCh3sh())) {
                     warningInfo.setWarningContent("CH3SH"+ch3 + "超过阈值,系统预警提醒");
                     warningInfo.setWarningType(6);
+                    warningInfo.setBuildLocation("厂界下");
+                    warningInfo.setDate(new Date());
+                    warningInfo.setFarmId(gasThreshold.getFarmId());
+                    warningInfo.setUserIds(gasThreshold.getUserIds());
+                    warningInfoMapper.insert(warningInfo);
                 }
                 if (Double.parseDouble(sja) > Double.parseDouble(gasThreshold.getSja())) {
                     warningInfo.setWarningContent("三甲胺"+sja + "超过阈值,系统预警提醒");
                     warningInfo.setWarningType(7);
+                    warningInfo.setBuildLocation("厂界下");
+                    warningInfo.setDate(new Date());
+                    warningInfo.setFarmId(gasThreshold.getFarmId());
+                    warningInfo.setUserIds(gasThreshold.getUserIds());
+                    warningInfoMapper.insert(warningInfo);
                 }
                 if (Double.parseDouble(cq) > Double.parseDouble(gasThreshold.getCq())) {
                     warningInfo.setWarningContent("臭气"+cq + "超过阈值,系统预警提醒");
                     warningInfo.setWarningType(8);
+                    warningInfo.setBuildLocation("厂界下");
+                    warningInfo.setDate(new Date());
+                    warningInfo.setFarmId(gasThreshold.getFarmId());
+                    warningInfo.setUserIds(gasThreshold.getUserIds());
+                    warningInfoMapper.insert(warningInfo);
                 }
 
-                warningInfo.setBuildLocation("厂界下");
-                warningInfo.setDate(new Date());
-                warningInfo.setFarmId(gasThreshold.getFarmId());
-                warningInfo.setUserIds(gasThreshold.getUserIds());
-                warningInfoMapper.insert(warningInfo);
             } else if (i==4) {
                 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"+nh3n + "超过阈值,系统预警提醒");
                     warningInfo.setWarningType(0);
+                    warningInfo.setBuildLocation("厂界居民");
+                    warningInfo.setDate(new Date());
+                    warningInfo.setFarmId(gasThreshold.getFarmId());
+                    warningInfo.setUserIds(gasThreshold.getUserIds());
+                    warningInfoMapper.insert(warningInfo);
                 }
                 if (Double.parseDouble(jlm) > Double.parseDouble(gasThreshold.getJlm())) {
                     warningInfo.setWarningContent("甲硫醚"+jlm + "超过阈值,系统预警提醒");
                     warningInfo.setWarningType(1);
+                    warningInfo.setBuildLocation("厂界居民");
+                    warningInfo.setDate(new Date());
+                    warningInfo.setFarmId(gasThreshold.getFarmId());
+                    warningInfo.setUserIds(gasThreshold.getUserIds());
+                    warningInfoMapper.insert(warningInfo);
                 }
                 if (Double.parseDouble(elht) > Double.parseDouble(gasThreshold.getElht())) {
                     warningInfo.setWarningContent("二硫化碳"+elht + "超过阈值,系统预警提醒");
                     warningInfo.setWarningType(2);
+                    warningInfo.setBuildLocation("厂界居民");
+                    warningInfo.setDate(new Date());
+                    warningInfo.setFarmId(gasThreshold.getFarmId());
+                    warningInfo.setUserIds(gasThreshold.getUserIds());
+                    warningInfoMapper.insert(warningInfo);
                 }
                 if (Double.parseDouble(ejel) > Double.parseDouble(gasThreshold.getEjel())) {
                     warningInfo.setWarningContent("二甲二硫"+ejel + "超过阈值,系统预警提醒");
                     warningInfo.setWarningType(3);
+                    warningInfo.setBuildLocation("厂界居民");
+                    warningInfo.setDate(new Date());
+                    warningInfo.setFarmId(gasThreshold.getFarmId());
+                    warningInfo.setUserIds(gasThreshold.getUserIds());
+                    warningInfoMapper.insert(warningInfo);
                 }
                 if (Double.parseDouble(h2s) > Double.parseDouble(gasThreshold.getH2s())) {
                     warningInfo.setWarningContent("H2S"+h2s + "超过阈值,系统预警提醒");
                     warningInfo.setWarningType(4);
+                    warningInfo.setBuildLocation("厂界居民");
+                    warningInfo.setDate(new Date());
+                    warningInfo.setFarmId(gasThreshold.getFarmId());
+                    warningInfo.setUserIds(gasThreshold.getUserIds());
+                    warningInfoMapper.insert(warningInfo);
                 }
                 if (Double.parseDouble(byx) > Double.parseDouble(gasThreshold.getByx())) {
                     warningInfo.setWarningContent("苯乙烯"+byx + "超过阈值,系统预警提醒");
                     warningInfo.setWarningType(5);
+                    warningInfo.setBuildLocation("厂界居民");
+                    warningInfo.setDate(new Date());
+                    warningInfo.setFarmId(gasThreshold.getFarmId());
+                    warningInfo.setUserIds(gasThreshold.getUserIds());
+                    warningInfoMapper.insert(warningInfo);
                 }
                 if (Double.parseDouble(ch3) > Double.parseDouble(gasThreshold.getCh3sh())) {
                     warningInfo.setWarningContent("CH3SH"+ch3 + "超过阈值,系统预警提醒");
                     warningInfo.setWarningType(6);
+                    warningInfo.setBuildLocation("厂界居民");
+                    warningInfo.setDate(new Date());
+                    warningInfo.setFarmId(gasThreshold.getFarmId());
+                    warningInfo.setUserIds(gasThreshold.getUserIds());
+                    warningInfoMapper.insert(warningInfo);
                 }
                 if (Double.parseDouble(sja) > Double.parseDouble(gasThreshold.getSja())) {
                     warningInfo.setWarningContent("三甲胺"+sja + "超过阈值,系统预警提醒");
                     warningInfo.setWarningType(7);
+                    warningInfo.setBuildLocation("厂界居民");
+                    warningInfo.setDate(new Date());
+                    warningInfo.setFarmId(gasThreshold.getFarmId());
+                    warningInfo.setUserIds(gasThreshold.getUserIds());
+                    warningInfoMapper.insert(warningInfo);
                 }
                 if (Double.parseDouble(cq) > Double.parseDouble(gasThreshold.getCq())) {
                     warningInfo.setWarningContent("臭气"+cq + "超过阈值,系统预警提醒");
                     warningInfo.setWarningType(8);
+                    warningInfo.setBuildLocation("厂界居民");
+                    warningInfo.setDate(new Date());
+                    warningInfo.setFarmId(gasThreshold.getFarmId());
+                    warningInfo.setUserIds(gasThreshold.getUserIds());
+                    warningInfoMapper.insert(warningInfo);
                 }
 
-                warningInfo.setBuildLocation("厂界居民");
-                warningInfo.setDate(new Date());
-                warningInfo.setFarmId(gasThreshold.getFarmId());
-                warningInfo.setUserIds(gasThreshold.getUserIds());
-                warningInfoMapper.insert(warningInfo);
             }
         }
     }

+ 242 - 20
huimv-admin/src/main/java/com/huimv/admin/timer/ProtTimer.java

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

+ 6 - 0
huimv-admin/src/main/resources/com/huimv/admin/mapper/EnergyDataMapper.xml

@@ -132,4 +132,10 @@
         GROUP BY DATE_FORMAT(create_date,'%Y-%m-%d')
         ORDER BY create_date ASC
     </select>
+
+    <select id="listDataCount" resultType="com.huimv.admin.entity.EnergyData">
+        select Convert(IFNULL(SUM(water_value),0),DECIMAL(10,2)) 'waterValue',Convert(IFNULL(SUM(electricity_value),0),DECIMAL(10,2)) 'electricityValue',
+Convert(IFNULL(SUM(feed_value),0),DECIMAL(10,2)) 'feedValue',Convert(IFNULL(SUM(gas_value),0),DECIMAL(10,2)) 'gasValue' FROM energy_data
+ ${ew.customSqlSegment}
+    </select>
 </mapper>

+ 3 - 3
huimv-admin/src/main/resources/com/huimv/admin/mapper/EnergyWarningThresholdMapper.xml

@@ -15,9 +15,9 @@
         <result column="min_gas" property="minGas" />
         <result column="user_ids" property="userIds" />
         <result column="farm_id" property="farmId" />
-        <result column="othre1" property="othre1" />
-        <result column="othre2" property="othre2" />
-        <result column="othre3" property="othre3" />
+        <result column="othre1" property="other1" />
+        <result column="othre2" property="other2" />
+        <result column="othre3" property="other3" />
     </resultMap>
 
 </mapper>