Procházet zdrojové kódy

优化小区无法同步 问题

java110 před 3 roky
rodič
revize
bf4bab696a

+ 6 - 1
service-job/src/main/java/com/java110/job/adapt/hcIot/community/AddCommunityToIotAdapt.java

@@ -56,9 +56,9 @@ public class AddCommunityToIotAdapt extends DatabusAdaptImpl {
     @Override
     public void execute(Business business, List<Business> businesses) throws Exception{
         JSONObject data = business.getData();
+        JSONArray businessCommunitys = null;
         if (data.containsKey(CommunityPo.class.getSimpleName())) {
             Object bObj = data.get(CommunityPo.class.getSimpleName());
-            JSONArray businessCommunitys = null;
             if (bObj instanceof JSONObject) {
                 businessCommunitys = new JSONArray();
                 businessCommunitys.add(bObj);
@@ -71,6 +71,11 @@ public class AddCommunityToIotAdapt extends DatabusAdaptImpl {
                 JSONObject businessCommunity = businessCommunitys.getJSONObject(bMachineIndex);
                 doAddCommunity(business, businessCommunity);
             }
+        }else {
+            if (data instanceof JSONObject) {
+                businessCommunitys = new JSONArray();
+                businessCommunitys.add(data);
+            }
         }
     }
 

+ 7 - 1
service-job/src/main/java/com/java110/job/adapt/hcIot/community/DeleteCommunityToIotAdapt.java

@@ -57,9 +57,10 @@ public class DeleteCommunityToIotAdapt extends DatabusAdaptImpl {
     @Override
     public void execute(Business business, List<Business> businesses) {
         JSONObject data = business.getData();
+        JSONArray businessCommunitys = null;
         if (data.containsKey(CommunityPo.class.getSimpleName())) {
             Object bObj = data.get(CommunityPo.class.getSimpleName());
-            JSONArray businessCommunitys = null;
+
             if (bObj instanceof JSONObject) {
                 businessCommunitys = new JSONArray();
                 businessCommunitys.add(bObj);
@@ -72,6 +73,11 @@ public class DeleteCommunityToIotAdapt extends DatabusAdaptImpl {
                 JSONObject businessCommunity = businessCommunitys.getJSONObject(bMachineIndex);
                 doDeleteCommunity(business, businessCommunity);
             }
+        }else {
+            if (data instanceof JSONObject) {
+                businessCommunitys = new JSONArray();
+                businessCommunitys.add(data);
+            }
         }
     }
 

+ 6 - 1
service-job/src/main/java/com/java110/job/adapt/hcIot/community/EditCommunityToIotAdapt.java

@@ -57,9 +57,9 @@ public class EditCommunityToIotAdapt extends DatabusAdaptImpl {
     @Override
     public void execute(Business business, List<Business> businesses) {
         JSONObject data = business.getData();
+        JSONArray businessCommunitys = null;
         if (data.containsKey(CommunityPo.class.getSimpleName())) {
             Object bObj = data.get(CommunityPo.class.getSimpleName());
-            JSONArray businessCommunitys = null;
             if (bObj instanceof JSONObject) {
                 businessCommunitys = new JSONArray();
                 businessCommunitys.add(bObj);
@@ -72,6 +72,11 @@ public class EditCommunityToIotAdapt extends DatabusAdaptImpl {
                 JSONObject businessCommunity = businessCommunitys.getJSONObject(bMachineIndex);
                 doEditCommunity(business, businessCommunity);
             }
+        }else {
+            if (data instanceof JSONObject) {
+                businessCommunitys = new JSONArray();
+                businessCommunitys.add(data);
+            }
         }
     }