Newspaper 1 tahun lalu
induk
melakukan
37ff6d3b50

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

@@ -11,11 +11,7 @@ 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 org.springframework.web.bind.annotation.*;
 
 import javax.annotation.Resource;
 import java.util.Map;
@@ -30,6 +26,7 @@ import java.util.Map;
  */
 @RestController
 @RequestMapping("/env-warning-threshold")
+@CrossOrigin
 public class EnvWarningThresholdController {
     @Autowired
     private IEnvWarningThresholdService envWarningThresholdService;
@@ -48,10 +45,10 @@ public class EnvWarningThresholdController {
 
         EnvWarningThreshold envWarningThreshold = new EnvWarningThreshold();
         envWarningThreshold.setFarmId(Integer.parseInt(farmId));
-        envWarningThreshold.setMaxHum(maxHum);
-        envWarningThreshold.setMinHum(minHum);
-        envWarningThreshold.setMaxTem(maxTem);
-        envWarningThreshold.setMinTem(minTem);
+        envWarningThreshold.setMaxHum(Double.parseDouble(maxHum));
+        envWarningThreshold.setMinHum(Double.parseDouble(minHum));
+        envWarningThreshold.setMaxTem(Double.parseDouble(maxTem));
+        envWarningThreshold.setMinTem(Double.parseDouble(minTem));
         envWarningThresholdService.saveOrUpdate(envWarningThreshold,new UpdateWrapper<EnvWarningThreshold>().eq("farm_id",farmId));
         return Result.SUCCESS();
     }
@@ -60,12 +57,15 @@ public class EnvWarningThresholdController {
         String farmId = paramsMap.get("farmId");
         EnvWarningThreshold envWarningThreshold = envWarningThresholdService.getOne(new QueryWrapper<EnvWarningThreshold>().eq("farm_id", farmId));
         if (ObjectUtil.isEmpty(envWarningThreshold)) {
-            envWarningThreshold.setMaxTem("0");
-            envWarningThreshold.setMinTem("0");
-            envWarningThreshold.setMaxHum("0");
-            envWarningThreshold.setMinHum("0");
+            EnvWarningThreshold envWarningThreshold1 = new EnvWarningThreshold();
+            envWarningThreshold1.setMaxTem((double) 0);
+            envWarningThreshold1.setMinTem((double) 0);
+            envWarningThreshold1.setMaxHum((double) 0);
+            envWarningThreshold1.setMinHum((double) 0);
+            return new Result(ResultCode.SUCCESS,envWarningThreshold1);
+        }else {
+            return new Result(ResultCode.SUCCESS,envWarningThreshold);
         }
-        return new Result(ResultCode.SUCCESS,envWarningThreshold);
     }
     public String nullParameter(String param){
         if (StringUtils.isEmpty(param)){

+ 4 - 4
huimv-admin/src/main/java/com/huimv/guowei/admin/entity/EnvWarningThreshold.java

@@ -30,22 +30,22 @@ public class EnvWarningThreshold implements Serializable {
     /**
      * 高温
      */
-    private String maxTem;
+    private Double maxTem;
 
     /**
      * 低温
      */
-    private String minTem;
+    private Double minTem;
 
     /**
      * 高湿度
      */
-    private String maxHum;
+    private Double maxHum;
 
     /**
      * 低湿度
      */
-    private String minHum;
+    private Double minHum;
 
     private Integer farmId;