Newspaper 1 rok pred
rodič
commit
06e797a6e7

+ 30 - 0
huimv-admin/src/main/java/com/huimv/guowei/admin/controller/EnvWarningThresholdController.java

@@ -1,10 +1,21 @@
 package com.huimv.guowei.admin.controller;
 
 
+import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
+import com.huimv.guowei.admin.common.utils.Result;
+import com.huimv.guowei.admin.entity.EnvWarningThreshold;
+import com.huimv.guowei.admin.service.IEnvWarningInfoService;
+import com.huimv.guowei.admin.service.IEnvWarningThresholdService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
 
 import org.springframework.web.bind.annotation.RestController;
 
+import javax.annotation.Resource;
+import java.util.Map;
+
 /**
  * <p>
  *  前端控制器
@@ -16,5 +27,24 @@ import org.springframework.web.bind.annotation.RestController;
 @RestController
 @RequestMapping("/env-warning-threshold")
 public class EnvWarningThresholdController {
+    @Autowired
+    private IEnvWarningThresholdService envWarningThresholdService;
+
+    @PostMapping("/saveThreshold")
+    public Result saveThreshold(@RequestBody 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");
+        EnvWarningThreshold envWarningThreshold = new EnvWarningThreshold();
+        envWarningThreshold.setFarmId(Integer.parseInt(farmId));
+        envWarningThreshold.setMaxHum(maxHum);
+        envWarningThreshold.setMinHum(minHum);
+        envWarningThreshold.setMaxTem(maxTem);
+        envWarningThreshold.setMinTem(minTem);
+        envWarningThresholdService.saveOrUpdate(envWarningThreshold,new UpdateWrapper<EnvWarningThreshold>().eq("farm_id",farmId));
+        return Result.SUCCESS();
+    }
 
 }