|
@@ -53,78 +53,74 @@ public class ProtThresholdServiceImpl extends ServiceImpl<ProtThresholdMapper, P
|
|
|
jsonObject.put("FLOW1", 0);
|
|
|
jsonObject.put("FLOW2", 0);
|
|
|
jsonObject.put("userIds", 0);
|
|
|
+ jsonObject.put("dataType", 0);
|
|
|
return new Result(ResultCode.SUCCESS, jsonObject);
|
|
|
} else {
|
|
|
JSONObject jsonObject = new JSONObject();
|
|
|
for (int i = 0; i < protThresholdList.size(); i++) {
|
|
|
- ProtThreshold protThreshold = protThresholdList.get(i);
|
|
|
- jsonObject.put(String.valueOf(i+1), protThreshold);
|
|
|
+ if (protThresholdList.get(i).getProtType()==1) {
|
|
|
+ jsonObject.put("in", protThresholdList.get(i));
|
|
|
+ } else if (protThresholdList.get(i).getProtType()==2) {
|
|
|
+ jsonObject.put("deal", protThresholdList.get(i));
|
|
|
+ } else if (protThresholdList.get(i).getProtType()==3) {
|
|
|
+ jsonObject.put("out", protThresholdList.get(i));
|
|
|
+ }
|
|
|
}
|
|
|
+ jsonObject.put("userIds", protThresholdList.get(1).getUserIds());
|
|
|
return new Result(ResultCode.SUCCESS,jsonObject);
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public Result add(HttpServletRequest httpServletRequest, Map<String, String> paramsMap) {
|
|
|
- String farmId = paramsMap.get("farmId");
|
|
|
- String protType = paramsMap.get("protType");
|
|
|
- String COD1 = paramsMap.get("COD1");
|
|
|
- String COD2 = paramsMap.get("COD2");
|
|
|
- String PH1 = paramsMap.get("PH1");
|
|
|
- String PH2 = paramsMap.get("PH2");
|
|
|
- String NH3N1 = paramsMap.get("NH3N1");
|
|
|
- String NH3N2 = paramsMap.get("NH3N2");
|
|
|
- String TP1 = paramsMap.get("TP1");
|
|
|
- String TP2 = paramsMap.get("TP2");
|
|
|
- String TN1 = paramsMap.get("TN1");
|
|
|
- String TN2 = paramsMap.get("TN2");
|
|
|
- String FLOW1 = paramsMap.get("FLOW1");
|
|
|
- String FLOW2 = paramsMap.get("FLOW2");
|
|
|
- String userIds = paramsMap.get("userIds");
|
|
|
+ public Result add(HttpServletRequest httpServletRequest, List<ProtThreshold> protThresholds) {
|
|
|
+ for (ProtThreshold protThreshold : protThresholds) {
|
|
|
+ if (ObjectUtil.isNotEmpty(protThreshold)) {
|
|
|
+ ProtThreshold protThreshold1 = new ProtThreshold();
|
|
|
+ protThreshold1.setProtType(protThreshold.getProtType());
|
|
|
+ protThreshold1.setFarmId(protThreshold.getFarmId());
|
|
|
+ protThreshold1.setCod1(protThreshold.getCod1());
|
|
|
+ protThreshold1.setCod2(protThreshold.getCod2());
|
|
|
+ protThreshold1.setPh1(protThreshold.getPh1());
|
|
|
+ protThreshold1.setPh2(protThreshold.getPh2());
|
|
|
+ protThreshold1.setNh3n1(protThreshold.getNh3n1());
|
|
|
+ protThreshold1.setNh3n2(protThreshold.getNh3n2());
|
|
|
+ protThreshold1.setTp1(protThreshold.getTp1());
|
|
|
+ protThreshold1.setTp2(protThreshold.getTp2());
|
|
|
+ protThreshold1.setTn1(protThreshold.getTn1());
|
|
|
+ protThreshold1.setTn2(protThreshold.getTn2());
|
|
|
+ protThreshold1.setFlow1(protThreshold.getFlow1());
|
|
|
+ protThreshold1.setFlow2(protThreshold.getFlow2());
|
|
|
+ protThreshold1.setUserIds(protThreshold.getUserIds());
|
|
|
+ protThreshold1.setDataType(protThreshold.getDataType());
|
|
|
|
|
|
- ProtThreshold protThreshold = new ProtThreshold();
|
|
|
- protThreshold.setCod1(COD1);
|
|
|
- protThreshold.setCod2(COD2);
|
|
|
- protThreshold.setPh1(PH1);
|
|
|
- protThreshold.setPh2(PH2);
|
|
|
- protThreshold.setNh3n1(NH3N1);
|
|
|
- protThreshold.setNh3n2(NH3N2);
|
|
|
- protThreshold.setTp1(TP1);
|
|
|
- protThreshold.setTp2(TP2);
|
|
|
- protThreshold.setTn1(TN1);
|
|
|
- protThreshold.setTn2(TN2);
|
|
|
- protThreshold.setFlow1(FLOW1);
|
|
|
- protThreshold.setFlow2(FLOW2);
|
|
|
- protThreshold.setUserIds(userIds);
|
|
|
- protThreshold.setProtType(Integer.parseInt(protType));
|
|
|
- protThreshold.setFarmId(Integer.parseInt(farmId));
|
|
|
|
|
|
+ if (Integer.parseInt(protThreshold.getCod2()) < Integer.parseInt(protThreshold.getCod1())) {
|
|
|
+ return new Result(ResultCode.FAIL, "红色预警浓度不能低于橙色预警浓度");
|
|
|
+ } else if (Integer.parseInt(protThreshold.getPh2()) < Integer.parseInt(protThreshold.getPh1())) {
|
|
|
+ return new Result(ResultCode.FAIL, "红色预警浓度不能低于橙色预警浓度");
|
|
|
+ } else if (Integer.parseInt(protThreshold.getNh3n2()) < Integer.parseInt(protThreshold.getNh3n1())) {
|
|
|
+ return new Result(ResultCode.FAIL, "红色预警浓度不能低于橙色预警浓度");
|
|
|
+ } else if (Integer.parseInt(protThreshold.getTp2()) < Integer.parseInt(protThreshold.getTp1())) {
|
|
|
+ return new Result(ResultCode.FAIL, "红色预警浓度不能低于橙色预警浓度");
|
|
|
+ } else if (Integer.parseInt(protThreshold.getTn2()) < Integer.parseInt(protThreshold.getTn1())) {
|
|
|
+ return new Result(ResultCode.FAIL, "红色预警浓度不能低于橙色预警浓度");
|
|
|
+ } else if (Integer.parseInt(protThreshold.getFlow2()) < Integer.parseInt(protThreshold.getFlow1())) {
|
|
|
+ return new Result(ResultCode.FAIL, "红色预警浓度不能低于橙色预警浓度");
|
|
|
+ } else {
|
|
|
+ QueryWrapper<ProtThreshold> queryWrapper = new QueryWrapper<>();
|
|
|
+ queryWrapper.eq("farm_id", protThreshold.getFarmId()).eq("prot_type",protThreshold.getProtType());
|
|
|
+ ProtThreshold threshold = protThresholdMapper.selectOne(queryWrapper);
|
|
|
+ if (ObjectUtil.isEmpty(threshold)) {
|
|
|
+ protThresholdMapper.insert(protThreshold1);
|
|
|
+ } else {
|
|
|
+ protThreshold1.setId(protThreshold.getId());
|
|
|
+ protThresholdMapper.updateById(protThreshold1);
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
- if (Integer.parseInt(COD2) < Integer.parseInt(COD1)) {
|
|
|
- return new Result(ResultCode.FAIL, "红色预警浓度不能低于橙色预警浓度");
|
|
|
- } else if (Integer.parseInt(PH2) < Integer.parseInt(PH1)) {
|
|
|
- return new Result(ResultCode.FAIL, "红色预警浓度不能低于橙色预警浓度");
|
|
|
- } else if (Integer.parseInt(NH3N2) < Integer.parseInt(NH3N1)) {
|
|
|
- return new Result(ResultCode.FAIL, "红色预警浓度不能低于橙色预警浓度");
|
|
|
- } else if (Integer.parseInt(TP2) < Integer.parseInt(TP1)) {
|
|
|
- return new Result(ResultCode.FAIL, "红色预警浓度不能低于橙色预警浓度");
|
|
|
- } else if (Integer.parseInt(TN2) < Integer.parseInt(TN1)) {
|
|
|
- return new Result(ResultCode.FAIL, "红色预警浓度不能低于橙色预警浓度");
|
|
|
- } else if (Integer.parseInt(FLOW2) < Integer.parseInt(FLOW1)) {
|
|
|
- return new Result(ResultCode.FAIL, "红色预警浓度不能低于橙色预警浓度");
|
|
|
- } else {
|
|
|
- QueryWrapper<ProtThreshold> queryWrapper = new QueryWrapper<>();
|
|
|
- queryWrapper.eq("farm_id", farmId).eq("prot_type",protType);
|
|
|
- ProtThreshold threshold = protThresholdMapper.selectOne(queryWrapper);
|
|
|
- if (ObjectUtil.isEmpty(threshold)) {
|
|
|
- protThresholdMapper.insert(protThreshold);
|
|
|
- return new Result(ResultCode.SUCCESS, "添加成功");
|
|
|
- } else {
|
|
|
- protThreshold.setId(threshold.getId());
|
|
|
- protThresholdMapper.updateById(protThreshold);
|
|
|
- return new Result(ResultCode.SUCCESS, "修改成功");
|
|
|
}
|
|
|
}
|
|
|
+ return new Result(ResultCode.SUCCESS, "修改成功");
|
|
|
}
|
|
|
}
|