|
@@ -1,6 +1,7 @@
|
|
|
package com.huimv.produce.warning.service.impl;
|
|
|
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.huimv.common.utils.Result;
|
|
|
import com.huimv.common.utils.ResultCode;
|
|
@@ -9,7 +10,8 @@ import com.huimv.produce.warning.mapper.SysThresholdMapper;
|
|
|
import com.huimv.produce.warning.service.ISysThresholdService;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
-import java.util.HashMap;
|
|
|
+import javax.annotation.Resource;
|
|
|
+import javax.servlet.http.HttpServletRequest;
|
|
|
import java.util.Map;
|
|
|
|
|
|
/**
|
|
@@ -23,34 +25,79 @@ import java.util.Map;
|
|
|
@Service
|
|
|
public class SysThresholdServiceImpl extends ServiceImpl<SysThresholdMapper, SysThreshold> implements ISysThresholdService {
|
|
|
|
|
|
+ @Resource
|
|
|
+ private SysThresholdMapper sysThresholdMapper;
|
|
|
+
|
|
|
+
|
|
|
@Override
|
|
|
public Result listWarningInfoWeater(Map<String, String> map) {
|
|
|
String farmId = map.get("farmId");
|
|
|
String maxTem = map.get("maxTem");
|
|
|
String minTem = map.get("minTem");
|
|
|
SysThreshold threshold = this.getById(farmId);
|
|
|
- if(ObjectUtil.isEmpty(threshold)){
|
|
|
- return new Result(10001,"该牧场未设置天气阈值",false);
|
|
|
- }
|
|
|
- String weatherMaxTem = threshold.getWeatherMaxTem();
|
|
|
- String weatherMixTem = threshold.getWeatherMinTem();
|
|
|
- Map endMap =new HashMap();
|
|
|
- if (Double.parseDouble(maxTem) > Double.parseDouble(weatherMaxTem)){
|
|
|
- endMap.put("maxTem",true);
|
|
|
- endMap.put("maxTemStr","今日最高温度为"+maxTem+"℃,高于阈值"+weatherMaxTem+"℃");
|
|
|
- }else {
|
|
|
- endMap.put("maxTem",false);
|
|
|
- endMap.put("maxTemStr",null);
|
|
|
- }
|
|
|
- if (Double.parseDouble(minTem) < Double.parseDouble(weatherMixTem)){
|
|
|
- endMap.put("minTem",true);
|
|
|
- endMap.put("minTemStr","今日最低温度为"+minTem+"℃,低于阈值"+weatherMixTem+"℃");
|
|
|
- }else {
|
|
|
- endMap.put("minTem",false);
|
|
|
- endMap.put("minTemStr",null);
|
|
|
- }
|
|
|
+// if(ObjectUtil.isEmpty(threshold)){
|
|
|
+// return new Result(10001,"该牧场未设置天气阈值",false);
|
|
|
+// }
|
|
|
+// String weatherMaxTem = threshold.getWeatherMaxTem();
|
|
|
+// String weatherMixTem = threshold.getWeatherMinTem();
|
|
|
+// Map endMap =new HashMap();
|
|
|
+// if (Double.parseDouble(maxTem) > Double.parseDouble(weatherMaxTem)){
|
|
|
+// endMap.put("maxTem",true);
|
|
|
+// endMap.put("maxTemStr","今日最高温度为"+maxTem+"℃,高于阈值"+weatherMaxTem+"℃");
|
|
|
+// }else {
|
|
|
+// endMap.put("maxTem",false);
|
|
|
+// endMap.put("maxTemStr",null);
|
|
|
+// }
|
|
|
+// if (Double.parseDouble(minTem) < Double.parseDouble(weatherMixTem)){
|
|
|
+// endMap.put("minTem",true);
|
|
|
+// endMap.put("minTemStr","今日最低温度为"+minTem+"℃,低于阈值"+weatherMixTem+"℃");
|
|
|
+// }else {
|
|
|
+// endMap.put("minTem",false);
|
|
|
+// endMap.put("minTemStr",null);
|
|
|
+// }
|
|
|
|
|
|
|
|
|
- return new Result(ResultCode.SUCCESS,endMap);
|
|
|
+ return new Result(ResultCode.SUCCESS,map);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ //阈值
|
|
|
+ public Result getThreshold(HttpServletRequest request) {
|
|
|
+ String farmId = request.getHeader("farmId");
|
|
|
+ return new Result(ResultCode.SUCCESS,sysThresholdMapper.selectById(farmId));
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Result addThreshold(HttpServletRequest request, Map<String, String> paramsMap) {
|
|
|
+ String farmId = request.getHeader("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");
|
|
|
+
|
|
|
+ SysThreshold newSysThreshold = new SysThreshold();
|
|
|
+ newSysThreshold.setFarmId(Integer.parseInt(farmId));
|
|
|
+ newSysThreshold.setMaxTem(maxTem);
|
|
|
+ newSysThreshold.setMinTem(minTem);
|
|
|
+ newSysThreshold.setMaxHum(maxHum);
|
|
|
+ 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);
|
|
|
+ }else{
|
|
|
+ sysThresholdMapper.insert(newSysThreshold);
|
|
|
+ }
|
|
|
+ return Result.SUCCESS();
|
|
|
}
|
|
|
}
|