|
@@ -1,14 +1,19 @@
|
|
|
package com.huimv.guowei.admin.controller;
|
|
|
|
|
|
|
|
|
+import cn.hutool.core.util.ObjectUtil;
|
|
|
+import com.alibaba.druid.util.StringUtils;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
|
|
import com.huimv.guowei.admin.common.utils.Result;
|
|
|
+import com.huimv.guowei.admin.common.utils.ResultCode;
|
|
|
import com.huimv.guowei.admin.entity.EnergyWarningThreshold;
|
|
|
import com.huimv.guowei.admin.service.IEnergyWarningThresholdService;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
+import java.util.HashMap;
|
|
|
import java.util.Map;
|
|
|
|
|
|
/**
|
|
@@ -37,6 +42,14 @@ public class EnergyWarningThresholdController {
|
|
|
String maxWaterLine3 = paramsMap.get("maxWaterLine3");
|
|
|
String maxWaterLine4 = paramsMap.get("maxWaterLine4");
|
|
|
String farmId = paramsMap.get("farmId");
|
|
|
+
|
|
|
+ maxWater = nullParameter(maxWater);
|
|
|
+ maxEle = nullParameter(maxEle);
|
|
|
+ maxWaterLine1 = nullParameter(maxWaterLine1);
|
|
|
+ maxWaterLine2 = nullParameter(maxWaterLine2);
|
|
|
+ maxWaterLine3 = nullParameter(maxWaterLine3);
|
|
|
+ maxWaterLine4 = nullParameter(maxWaterLine4);
|
|
|
+
|
|
|
EnergyWarningThreshold energyWarningThreshold0 = new EnergyWarningThreshold();
|
|
|
energyWarningThreshold0.setMaxValue(maxWater);
|
|
|
energyWarningThreshold0.setFarmId(Integer.parseInt(farmId));
|
|
@@ -91,5 +104,81 @@ public class EnergyWarningThresholdController {
|
|
|
return Result.SUCCESS();
|
|
|
}
|
|
|
|
|
|
+ @PostMapping("/getThreshold")
|
|
|
+ public Result getThreshold(@RequestBody Map<String ,String> paramsMap){
|
|
|
+ String farmId = paramsMap.get("farmId");
|
|
|
+ Map resultMap = new HashMap();
|
|
|
+ EnergyWarningThreshold waterThreshold = energyWarningThresholdService.getOne(new QueryWrapper<EnergyWarningThreshold>().eq("farm_id", farmId).eq("warning_type", 0));
|
|
|
+ if (ObjectUtil.isEmpty(waterThreshold)){
|
|
|
+ resultMap.put("maxWater",0);
|
|
|
+ }else {
|
|
|
+ if(!StringUtils.isEmpty(waterThreshold.getMaxValue())){
|
|
|
+ resultMap.put("maxWater", waterThreshold.getMaxValue());
|
|
|
+ }else {
|
|
|
+ resultMap.put("maxWater",0);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ EnergyWarningThreshold eleThreshold = energyWarningThresholdService.getOne(new QueryWrapper<EnergyWarningThreshold>().eq("farm_id", farmId).eq("warning_type", 1));
|
|
|
+ if (ObjectUtil.isEmpty(eleThreshold)){
|
|
|
+ resultMap.put("maxEle",0);
|
|
|
+ }else {
|
|
|
+ if(!StringUtils.isEmpty(eleThreshold.getMaxValue())){
|
|
|
+ resultMap.put("maxEle",eleThreshold.getMaxValue());
|
|
|
+ }else {
|
|
|
+ resultMap.put("maxEle",0);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //TODO 写死水线芯片号
|
|
|
+ EnergyWarningThreshold water1 = energyWarningThresholdService.getOne(new QueryWrapper<EnergyWarningThreshold>().eq("farm_id", farmId).eq("warning_type", 2).eq("chip_code", "1001"));
|
|
|
+ if (ObjectUtil.isEmpty(water1)){
|
|
|
+ resultMap.put("maxWaterLine1",0);
|
|
|
+ }else {
|
|
|
+ if(!StringUtils.isEmpty(water1.getMaxValue())){
|
|
|
+ resultMap.put("maxWaterLine1",water1.getMaxValue());
|
|
|
+ }else {
|
|
|
+ resultMap.put("maxWaterLine1",0);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ EnergyWarningThreshold water2 = energyWarningThresholdService.getOne(new QueryWrapper<EnergyWarningThreshold>().eq("farm_id", farmId).eq("warning_type", 2).eq("chip_code", "1002"));
|
|
|
+ if (ObjectUtil.isEmpty(water2)){
|
|
|
+ resultMap.put("maxWaterLine2",0);
|
|
|
+ }else {
|
|
|
+ if(!StringUtils.isEmpty(water2.getMaxValue())){
|
|
|
+ resultMap.put("maxWaterLine2",water2.getMaxValue());
|
|
|
+ }else {
|
|
|
+ resultMap.put("maxWaterLine2",0);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ EnergyWarningThreshold water3 = energyWarningThresholdService.getOne(new QueryWrapper<EnergyWarningThreshold>().eq("farm_id", farmId).eq("warning_type", 2).eq("chip_code", "1003"));
|
|
|
+ if (ObjectUtil.isEmpty(water3)){
|
|
|
+ resultMap.put("maxWaterLine3",0);
|
|
|
+ }else {
|
|
|
+ if(!StringUtils.isEmpty(water3.getMaxValue())){
|
|
|
+ resultMap.put("maxWaterLine3",water3.getMaxValue());
|
|
|
+ }else {
|
|
|
+ resultMap.put("maxWaterLine3",0);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ EnergyWarningThreshold water4 = energyWarningThresholdService.getOne(new QueryWrapper<EnergyWarningThreshold>().eq("farm_id", farmId).eq("warning_type", 2).eq("chip_code", "1004"));
|
|
|
+ if (ObjectUtil.isEmpty(water4)){
|
|
|
+ resultMap.put("maxWaterLine4",0);
|
|
|
+ }else {
|
|
|
+ if(!StringUtils.isEmpty(water4.getMaxValue())){
|
|
|
+ resultMap.put("maxWaterLine4",water4.getMaxValue());
|
|
|
+ }else {
|
|
|
+ resultMap.put("maxWaterLine4",0);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return new Result(ResultCode.SUCCESS,resultMap);
|
|
|
+ }
|
|
|
+
|
|
|
+ public String nullParameter(String param){
|
|
|
+ if (StringUtils.isEmpty(param)){
|
|
|
+ param = "0";
|
|
|
+ }
|
|
|
+ return param;
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
}
|