|
@@ -1,10 +1,15 @@
|
|
|
package com.huimv.guowei.admin.controller;
|
|
|
|
|
|
|
|
|
-import org.springframework.web.bind.annotation.CrossOrigin;
|
|
|
-import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
|
|
+import com.huimv.guowei.admin.common.utils.Result;
|
|
|
+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 org.springframework.web.bind.annotation.RestController;
|
|
|
+import javax.annotation.Resource;
|
|
|
+import java.util.Map;
|
|
|
|
|
|
/**
|
|
|
* <p>
|
|
@@ -18,5 +23,73 @@ import org.springframework.web.bind.annotation.RestController;
|
|
|
@RequestMapping("/energy-warning-threshold")
|
|
|
@CrossOrigin
|
|
|
public class EnergyWarningThresholdController {
|
|
|
+ @Resource
|
|
|
+ private IEnergyWarningThresholdService energyWarningThresholdService;
|
|
|
+
|
|
|
+ @PostMapping("/saveThreshold")
|
|
|
+ @Transactional
|
|
|
+ //TODO 目前先写死 水线芯片号
|
|
|
+ public Result saveThreshold(@RequestBody Map<String ,String> paramsMap){
|
|
|
+ String maxWater = paramsMap.get("maxWater");
|
|
|
+ String maxEle = paramsMap.get("maxEle");
|
|
|
+ String maxWaterLine1 = paramsMap.get("maxWaterLine1");
|
|
|
+ String maxWaterLine2 = paramsMap.get("maxWaterLine2");
|
|
|
+ String maxWaterLine3 = paramsMap.get("maxWaterLine3");
|
|
|
+ String maxWaterLine4 = paramsMap.get("maxWaterLine4");
|
|
|
+ String farmId = paramsMap.get("farmId");
|
|
|
+ EnergyWarningThreshold energyWarningThreshold0 = new EnergyWarningThreshold();
|
|
|
+ energyWarningThreshold0.setMaxValue(maxWater);
|
|
|
+ energyWarningThreshold0.setFarmId(Integer.parseInt(farmId));
|
|
|
+ energyWarningThreshold0.setWarningType(0);
|
|
|
+ energyWarningThresholdService.saveOrUpdate(energyWarningThreshold0,new UpdateWrapper<EnergyWarningThreshold>()
|
|
|
+ .eq("farm_id",farmId)
|
|
|
+ .eq("warning_type",0));
|
|
|
+
|
|
|
+ EnergyWarningThreshold energyWarningThreshold1 = new EnergyWarningThreshold();
|
|
|
+ energyWarningThreshold1.setMaxValue(maxEle);
|
|
|
+ energyWarningThreshold1.setFarmId(Integer.parseInt(farmId));
|
|
|
+ energyWarningThreshold1.setWarningType(1);
|
|
|
+ energyWarningThresholdService.saveOrUpdate(energyWarningThreshold1,new UpdateWrapper<EnergyWarningThreshold>()
|
|
|
+ .eq("farm_id",farmId)
|
|
|
+ .eq("warning_type",1));
|
|
|
+
|
|
|
+ EnergyWarningThreshold energyWarningThreshold2 = new EnergyWarningThreshold();
|
|
|
+ energyWarningThreshold2.setMaxValue(maxWaterLine1);
|
|
|
+ energyWarningThreshold2.setFarmId(Integer.parseInt(farmId));
|
|
|
+ energyWarningThreshold2.setWarningType(2);
|
|
|
+ energyWarningThreshold2.setChipCode("1001");
|
|
|
+ energyWarningThresholdService.saveOrUpdate(energyWarningThreshold2,new UpdateWrapper<EnergyWarningThreshold>()
|
|
|
+ .eq("farm_id",farmId)
|
|
|
+ .eq("warning_type",2).eq("chip_code","1001"));
|
|
|
+
|
|
|
+ EnergyWarningThreshold energyWarningThreshold3 = new EnergyWarningThreshold();
|
|
|
+ energyWarningThreshold3.setMaxValue(maxWaterLine2);
|
|
|
+ energyWarningThreshold3.setFarmId(Integer.parseInt(farmId));
|
|
|
+ energyWarningThreshold3.setWarningType(2);
|
|
|
+ energyWarningThreshold3.setChipCode("1002");
|
|
|
+ energyWarningThresholdService.saveOrUpdate(energyWarningThreshold3,new UpdateWrapper<EnergyWarningThreshold>()
|
|
|
+ .eq("farm_id",farmId)
|
|
|
+ .eq("warning_type",2).eq("chip_code","1002"));
|
|
|
+
|
|
|
+ EnergyWarningThreshold energyWarningThreshold4 = new EnergyWarningThreshold();
|
|
|
+ energyWarningThreshold4.setMaxValue(maxWaterLine3);
|
|
|
+ energyWarningThreshold4.setFarmId(Integer.parseInt(farmId));
|
|
|
+ energyWarningThreshold4.setWarningType(2);
|
|
|
+ energyWarningThreshold4.setChipCode("1003");
|
|
|
+ energyWarningThresholdService.saveOrUpdate(energyWarningThreshold4,new UpdateWrapper<EnergyWarningThreshold>()
|
|
|
+ .eq("farm_id",farmId)
|
|
|
+ .eq("warning_type",2).eq("chip_code","1003"));
|
|
|
+
|
|
|
+ EnergyWarningThreshold energyWarningThreshold5 = new EnergyWarningThreshold();
|
|
|
+ energyWarningThreshold5.setMaxValue(maxWaterLine4);
|
|
|
+ energyWarningThreshold5.setFarmId(Integer.parseInt(farmId));
|
|
|
+ energyWarningThreshold5.setWarningType(2);
|
|
|
+ energyWarningThreshold5.setChipCode("1004");
|
|
|
+ energyWarningThresholdService.saveOrUpdate(energyWarningThreshold5,new UpdateWrapper<EnergyWarningThreshold>()
|
|
|
+ .eq("farm_id",farmId)
|
|
|
+ .eq("warning_type",2).eq("chip_code","1004"));
|
|
|
+ return Result.SUCCESS();
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
}
|