|
@@ -72,6 +72,8 @@ public class SysThresholdServiceImpl extends ServiceImpl<SysThresholdMapper, Sys
|
|
|
sysThreshold.setMaxTem("0");
|
|
|
sysThreshold.setMinHum("0");
|
|
|
sysThreshold.setMinTem("0");
|
|
|
+ sysThreshold.setDryDuration("0");
|
|
|
+ sysThreshold.setDryNormalTemp("30");
|
|
|
sysThresholdMapper.insert(sysThreshold);
|
|
|
}
|
|
|
return new Result(ResultCode.SUCCESS,sysThreshold);
|
|
@@ -80,18 +82,14 @@ public class SysThresholdServiceImpl extends ServiceImpl<SysThresholdMapper, Sys
|
|
|
@Override
|
|
|
public Result addThreshold(HttpServletRequest request, Map<String, String> paramsMap) {
|
|
|
String farmId = paramsMap.get("farmId");
|
|
|
-
|
|
|
String maxTem = paramsMap.get("maxTem");
|
|
|
-
|
|
|
String minTem = paramsMap.get("minTem");
|
|
|
-
|
|
|
String maxHum = paramsMap.get("maxHum");
|
|
|
-
|
|
|
String minHum = paramsMap.get("minHum");
|
|
|
-
|
|
|
String dryTem = paramsMap.get("dryTem");
|
|
|
-
|
|
|
String dryMin = paramsMap.get("dryMin");
|
|
|
+ String dryDuration = paramsMap.get("dryDuration");
|
|
|
+ String dryNormalTemp = paramsMap.get("dryNormalTemp");
|
|
|
|
|
|
SysThreshold newSysThreshold = new SysThreshold();
|
|
|
newSysThreshold.setFarmId(Integer.parseInt(farmId));
|
|
@@ -101,13 +99,22 @@ public class SysThresholdServiceImpl extends ServiceImpl<SysThresholdMapper, Sys
|
|
|
newSysThreshold.setMinHum(minHum);
|
|
|
newSysThreshold.setDryTem(dryTem);
|
|
|
newSysThreshold.setDryMin(dryMin);
|
|
|
- QueryWrapper<SysThreshold> queryWrapper = new QueryWrapper<>();
|
|
|
- queryWrapper.eq("farm_Id",farmId);
|
|
|
- if (sysThresholdMapper.exists(queryWrapper)) {
|
|
|
- sysThresholdMapper.updateById(newSysThreshold);
|
|
|
+ newSysThreshold.setDryDuration(dryDuration);
|
|
|
+ newSysThreshold.setDryNormalTemp(dryNormalTemp);
|
|
|
+
|
|
|
+ if (Integer.parseInt(maxTem)<Integer.parseInt(minTem)){
|
|
|
+ return new Result(10001,"最高温度不能小于最低温度!",false);
|
|
|
+ }else if (Integer.parseInt(maxHum)<Integer.parseInt(minHum)){
|
|
|
+ return new Result(10001,"最高湿度不能小于最低湿度!",false);
|
|
|
}else{
|
|
|
- sysThresholdMapper.insert(newSysThreshold);
|
|
|
+ QueryWrapper<SysThreshold> queryWrapper = new QueryWrapper<>();
|
|
|
+ queryWrapper.eq("farm_Id",farmId);
|
|
|
+ if (sysThresholdMapper.exists(queryWrapper)) {
|
|
|
+ sysThresholdMapper.updateById(newSysThreshold);
|
|
|
+ }else{
|
|
|
+ sysThresholdMapper.insert(newSysThreshold);
|
|
|
+ }
|
|
|
+ return Result.SUCCESS();
|
|
|
}
|
|
|
- return Result.SUCCESS();
|
|
|
}
|
|
|
}
|