wwh 11 月之前
父节点
当前提交
d89c39fbeb

+ 16 - 0
huimv-env-admin/src/main/java/com/huimv/env/admin/timer/WaterAndElectricity.java

@@ -40,6 +40,19 @@ public class WaterAndElectricity {
     @Autowired
     private EnergyEnvDeviceMapper envDeviceMapper;
 
+    //发送设备状态到华统平台
+    @Scheduled(cron = "0 0/5 * * * ? ")
+    private void sendDeviceStatus() {
+        List<EnergyEnvDevice> devices = envDeviceMapper.selectList(null);
+        HashMap<String, String> paramsMap = new HashMap<>();
+        JSONObject jsonObject = new JSONObject();
+        jsonObject.put("result", devices);
+        System.out.println(jsonObject);
+        paramsMap.put("Content-Type", "application/json;charset=utf-8");
+        String post = HttpRequest.post("https://huatong.ifarmcloud.com/huatongApi/energy-data/getDeviceStatus")
+                .headerMap(paramsMap, false).body(jsonObject.toJSONString()).timeout(30 * 1000).execute().body();
+        System.out.println(post);
+    }
 
 
     @Scheduled(cron = "0 59 * * * ? ")
@@ -370,6 +383,7 @@ public class WaterAndElectricity {
                 .headerMap(paramsMap, false).body(jsonObject.toJSONString()).timeout(30 * 1000).execute().body();
         System.out.println(post);
     }
+
     //百风林31
     @Scheduled(cron = "0 59 * * * ? ")
     private void sendDate7() throws Exception {
@@ -419,6 +433,7 @@ public class WaterAndElectricity {
                 .headerMap(paramsMap, false).body(jsonObject.toJSONString()).timeout(30 * 1000).execute().body();
         System.out.println(post);
     }
+
     //瑞溪32
     @Scheduled(cron = "0 59 * * * ? ")
     private void sendDate8() throws Exception {
@@ -566,6 +581,7 @@ public class WaterAndElectricity {
                 .headerMap(paramsMap, false).body(jsonObject.toJSONString()).timeout(30 * 1000).execute().body();
         System.out.println(post);
     }
+
     //下各水34
     @Scheduled(cron = "0 59 * * * ? ")
     private void sendDate11() throws Exception {

+ 6 - 1
huimv-env-device/src/main/java/com/huimv/env/device/service/impl/DataServiceImpl.java

@@ -206,6 +206,8 @@ public class DataServiceImpl implements DataService {
         } else {
             str = 0;
         }
+
+
         //差值
 
 
@@ -224,7 +226,10 @@ public class DataServiceImpl implements DataService {
         envWater.setOriginalDate(payload);
         BigDecimal bigDecimal = BigDecimal.valueOf(0);
         if (one.size() > 0) {
-            bigDecimal = new BigDecimal(one.get(0).getOther3());
+            if (!"".equals(one.get(0).getOther3()) && null != one.get(0).getOther3()) {
+                bigDecimal = new BigDecimal(one.get(0).getOther3());
+            }
+
         }
         if (str < 0) {
             envWater.setWaterValue(String.format("%.1f", (double) originalData * transformer / 10.0));