Kaynağa Gözat

优化代码

java110 5 yıl önce
ebeveyn
işleme
b3144a944a
17 değiştirilmiş dosya ile 405 ekleme ve 243 silme
  1. 0 194
      service-job/src/main/java/com/java110/job/adapt/hcIot/AddCommunityToIotAdapt.java
  2. 4 2
      service-job/src/main/java/com/java110/job/adapt/hcIot/GetToken.java
  3. 12 0
      service-job/src/main/java/com/java110/job/adapt/hcIot/IotConstant.java
  4. 1 0
      service-job/src/main/java/com/java110/job/adapt/hcIot/OpenDoorAdapt.java
  5. 33 1
      service-job/src/main/java/com/java110/job/adapt/hcIot/asyn/IIotSendAsyn.java
  6. 52 37
      service-job/src/main/java/com/java110/job/adapt/hcIot/asyn/impl/IotSendAsynImpl.java
  7. 94 0
      service-job/src/main/java/com/java110/job/adapt/hcIot/community/AddCommunityToIotAdapt.java
  8. 92 0
      service-job/src/main/java/com/java110/job/adapt/hcIot/community/DeleteCommunityToIotAdapt.java
  9. 95 0
      service-job/src/main/java/com/java110/job/adapt/hcIot/community/EditCommunityToIotAdapt.java
  10. 3 1
      service-job/src/main/java/com/java110/job/adapt/hcIot/AddMachineToIotAdapt.java
  11. 3 1
      service-job/src/main/java/com/java110/job/adapt/hcIot/DeleteMachineToIotAdapt.java
  12. 3 2
      service-job/src/main/java/com/java110/job/adapt/hcIot/ModifyMachineToIotAdapt.java
  13. 3 1
      service-job/src/main/java/com/java110/job/adapt/hcIot/AddOwnerToIotAdapt.java
  14. 3 1
      service-job/src/main/java/com/java110/job/adapt/hcIot/DeleteOwnerToIotAdapt.java
  15. 3 1
      service-job/src/main/java/com/java110/job/adapt/hcIot/EditOwnerToIotAdapt.java
  16. 2 1
      service-job/src/main/java/com/java110/job/adapt/hcIot/OwnerBindRoomToIotAdapt.java
  17. 2 1
      service-job/src/main/java/com/java110/job/adapt/hcIot/OwnerUnBindRoomToIotAdapt.java

+ 0 - 194
service-job/src/main/java/com/java110/job/adapt/hcIot/AddCommunityToIotAdapt.java

@@ -1,194 +0,0 @@
-/*
- * Copyright 2017-2020 吴学文 and java110 team.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.java110.job.adapt.hcIot;
-
-import com.alibaba.fastjson.JSONArray;
-import com.alibaba.fastjson.JSONObject;
-import com.java110.dto.RoomDto;
-import com.java110.dto.communityLocation.CommunityLocationDto;
-import com.java110.dto.file.FileDto;
-import com.java110.dto.file.FileRelDto;
-import com.java110.dto.owner.OwnerDto;
-import com.java110.entity.order.Business;
-import com.java110.intf.common.IFileInnerServiceSMO;
-import com.java110.intf.common.IFileRelInnerServiceSMO;
-import com.java110.intf.common.IMachineInnerServiceSMO;
-import com.java110.intf.community.ICommunityLocationInnerServiceSMO;
-import com.java110.intf.community.IRoomInnerServiceSMO;
-import com.java110.intf.user.IOwnerInnerServiceSMO;
-import com.java110.job.adapt.DatabusAdaptImpl;
-import com.java110.job.adapt.hcIot.asyn.IIotSendAsyn;
-import com.java110.po.community.CommunityPo;
-import com.java110.po.machine.MachinePo;
-import com.java110.utils.util.BeanConvertUtil;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Component;
-import org.springframework.util.LinkedMultiValueMap;
-import org.springframework.util.MultiValueMap;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * HC 小区同步适配器
- *
- * @desc add by 吴学文 18:58
- */
-@Component(value = "addCommunityToIotAdapt")
-public class AddCommunityToIotAdapt extends DatabusAdaptImpl {
-
-    @Autowired
-    private IIotSendAsyn hcMachineAsynImpl;
-    @Autowired
-    IMachineInnerServiceSMO machineInnerServiceSMOImpl;
-
-    @Autowired
-    private ICommunityLocationInnerServiceSMO communityLocationInnerServiceSMOImpl;
-
-    @Autowired
-    private IOwnerInnerServiceSMO ownerInnerServiceSMOImpl;
-
-    @Autowired
-    private IRoomInnerServiceSMO roomInnerServiceSMOImpl;
-
-    @Autowired
-    private IFileRelInnerServiceSMO fileRelInnerServiceSMOImpl;
-
-    @Autowired
-    private IFileInnerServiceSMO fileInnerServiceSMOImpl;
-
-    /**
-     * 添加小区执行类
-     * {
-     * "name": "HC小区",
-     * "address": "青海省西宁市",
-     * "cityCode": "510104",
-     * "extCommunityId": "702020042194860039"
-     * }
-     *
-     * @param business   当前处理业务
-     * @param businesses 所有业务信息
-     */
-    @Override
-    public void execute(Business business, List<Business> businesses) {
-        JSONObject data = business.getData();
-        if (data.containsKey(CommunityPo.class.getSimpleName())) {
-            Object bObj = data.get(CommunityPo.class.getSimpleName());
-            JSONArray businessMachines = null;
-            if (bObj instanceof JSONObject) {
-                businessMachines = new JSONArray();
-                businessMachines.add(bObj);
-            } else if (bObj instanceof List) {
-                businessMachines = JSONArray.parseArray(JSONObject.toJSONString(bObj));
-            } else {
-                businessMachines = (JSONArray) bObj;
-            }
-            //JSONObject businessMachine = data.getJSONObject("businessMachine");
-            for (int bMachineIndex = 0; bMachineIndex < businessMachines.size(); bMachineIndex++) {
-                JSONObject businessMachine = businessMachines.getJSONObject(bMachineIndex);
-                doSendMachine(business, businessMachine);
-            }
-        }
-    }
-
-    private void doSendMachine(Business business, JSONObject businessMachine) {
-
-        CommunityPo communityPo = BeanConvertUtil.covertBean(businessMachine, CommunityPo.class);
-        JSONObject postParameters = new JSONObject();
-        postParameters.put("name", communityPo.getName());
-        postParameters.put("address", communityPo.getAddress());
-        postParameters.put("cityCode", communityPo.getCityCode());
-        postParameters.put("extCommunityId", communityPo.getCommunityId());
-        hcMachineAsynImpl.addCommunity(postParameters);
-    }
-
-    private List<MultiValueMap<String, Object>> getOwners(MachinePo machinePo) {
-        //拿到小区ID
-        String communityId = machinePo.getCommunityId();
-
-        List<MultiValueMap<String, Object>> ownerDtos = new ArrayList<>();
-
-        List<OwnerDto> owners = null;
-        //根据小区ID查询现有设备
-        OwnerDto ownerDto = new OwnerDto();
-        ownerDto.setCommunityId(communityId);
-        String locationTypeCd = machinePo.getLocationTypeCd();
-        CommunityLocationDto communityLocationDto = new CommunityLocationDto();
-        communityLocationDto.setLocationId(locationTypeCd);
-        communityLocationDto.setCommunityId(machinePo.getCommunityId());
-        List<CommunityLocationDto> communityLocationDtos = communityLocationInnerServiceSMOImpl.queryCommunityLocations(communityLocationDto);
-
-        if (communityLocationDtos == null || communityLocationDtos.size() < 1) {
-            return ownerDtos;
-        }
-        communityLocationDto = communityLocationDtos.get(0);
-
-        if ("1000".contains(communityLocationDto.getLocationType())) {//查询整个小区的业主
-            owners = ownerInnerServiceSMOImpl.queryOwnerMembers(ownerDto);
-        } else if ("2000".equals(communityLocationDto.getLocationType())) {//2000 单元门 ,则这个单元下的业主同步
-            //先根据单元门ID 查询 房屋
-            RoomDto roomDto = new RoomDto();
-            roomDto.setUnitId(machinePo.getLocationObjId());
-            roomDto.setCommunityId(machinePo.getCommunityId());
-            List<RoomDto> roomDtos = roomInnerServiceSMOImpl.queryRooms(roomDto);
-            if (roomDtos == null || roomDtos.size() == 0) { // 单元下没有房屋
-                return ownerDtos;
-            }
-            ownerDto.setRoomIds(getRoomIds(roomDtos));
-            owners = ownerInnerServiceSMOImpl.queryOwnerMembers(ownerDto);
-        } else if ("3000".equals(communityLocationDto.getLocationType())) {// 3000 房屋门
-            ownerDto.setRoomId(machinePo.getLocationObjId());
-            owners = ownerInnerServiceSMOImpl.queryOwnerMembers(ownerDto);
-        }
-
-        for (OwnerDto tOwnerDto : owners) {
-            FileRelDto fileRelDto = new FileRelDto();
-            fileRelDto.setObjId(tOwnerDto.getMemberId());
-            fileRelDto.setRelTypeCd("10000");
-            List<FileRelDto> fileRelDtos = fileRelInnerServiceSMOImpl.queryFileRels(fileRelDto);
-            if (fileRelDtos == null || fileRelDtos.size() != 1) {
-                continue;
-            }
-            FileDto fileDto = new FileDto();
-            fileDto.setFileId(fileRelDtos.get(0).getFileSaveName());
-            fileDto.setFileSaveName(fileRelDtos.get(0).getFileSaveName());
-            fileDto.setCommunityId(tOwnerDto.getCommunityId());
-            List<FileDto> fileDtos = fileInnerServiceSMOImpl.queryFiles(fileDto);
-            if (fileDtos == null || fileDtos.size() != 1) {
-                continue;
-            }
-            MultiValueMap<String, Object> postParameters = new LinkedMultiValueMap<>();
-
-            postParameters.add("extCommunityUuid", tOwnerDto.getCommunityId());
-            postParameters.add("addAuthorizationDevSn", machinePo.getMachineCode());
-            postParameters.add("uuid", tOwnerDto.getMemberId());
-            postParameters.add("name", tOwnerDto.getName());
-            postParameters.add("faceFileBase64Array", fileDtos.get(0).getContext());
-
-            ownerDtos.add(postParameters);
-        }
-
-        return ownerDtos;
-    }
-
-    private String[] getRoomIds(List<RoomDto> roomDtos) {
-        List<String> roomIds = new ArrayList<String>();
-        for (RoomDto roomDto : roomDtos) {
-            roomIds.add(roomDto.getRoomId());
-        }
-        return roomIds.toArray(new String[roomIds.size()]);
-    }
-}

+ 4 - 2
service-job/src/main/java/com/java110/job/adapt/hcIot/GetToken.java

@@ -25,6 +25,8 @@ import org.springframework.http.*;
 
 /**
  * 获取token
+ * <p>
+ * 接口协议地址: https://gitee.com/java110/MicroCommunityThings/blob/master/back/docs/api.md
  *
  * @desc add by 吴学文 9:46
  */
@@ -51,8 +53,8 @@ public class GetToken {
             throw new IllegalArgumentException("获取token失败" + tokenRes.getBody());
         }
 
-        token = tokenObj.getJSONObject("data").getString("accessToken");
-        int expiresIn = tokenObj.getJSONObject("data").getInteger("expiresIn");
+        token = tokenObj.getJSONObject("data").getString("access_token");
+        int expiresIn = tokenObj.getJSONObject("data").getInteger("expires_in");
 
         CommonCache.setValue(IotConstant.HC_TOKEN, token, expiresIn - 200);
 

+ 12 - 0
service-job/src/main/java/com/java110/job/adapt/hcIot/IotConstant.java

@@ -17,6 +17,7 @@ package com.java110.job.adapt.hcIot;
 
 /**
  * HC 物联网常量类
+ * 接口协议地址: https://gitee.com/java110/MicroCommunityThings/blob/master/back/docs/api.md
  *
  * @desc add by 吴学文 9:49
  */
@@ -29,11 +30,22 @@ public class IotConstant {
 
     public static final String GET_TOKEN_URL = IOT_URL + " /extApi/auth/getAccessToken?appId=" + APP_ID + "&appSecret=" + APP_SECRET;
 
+    //添加小区
+    public static final String ADD_COMMUNITY_URL = IOT_URL + "/extApi/community/addCommunity";
+    //修改小区
+    public static final String UPDATE_COMMUNITY_URL = IOT_URL + "/extApi/community/updateCommunity";
+    //删除小区
+    public static final String DELETE_COMMUNITY_URL = IOT_URL + "/extApi/community/deleteCommunity";
+
     //添加设备
     public static final String ADD_MACHINE_URL = IOT_URL + "/extApi/machine/addMachine";
+    //修改设备
     public static final String UPDATE_MACHINE_URL = IOT_URL + "/extApi/machine/updateMachine";
+    //删除设备
     public static final String DELETE_MACHINE_URL = IOT_URL + "/extApi/machine/deleteMachine";
+    //开门接口
     public static final String OPEN_DOOR = IOT_URL + "/extApi/machine/openDoor";
+    //重启接口
     public static final String RESTART_MACHINE = IOT_URL + "/extApi/machine/restartMachine";
 
     public static final String HC_TOKEN = "HC_ACCESS_TOKEN";

+ 1 - 0
service-job/src/main/java/com/java110/job/adapt/hcIot/OpenDoorAdapt.java

@@ -30,6 +30,7 @@ import java.util.List;
 
 /**
  * 开门适配器
+ * 接口协议地址: https://gitee.com/java110/MicroCommunityThings/blob/master/back/docs/api.md
  *
  * @desc add by 吴学文 15:29
  */

+ 33 - 1
service-job/src/main/java/com/java110/job/adapt/hcIot/asyn/IIotSendAsyn.java

@@ -20,6 +20,13 @@ import org.springframework.util.MultiValueMap;
 
 import java.util.List;
 
+/**
+ * IOT信息异步同步处理接口类
+ * <p>
+ * add by wuxw 2020-12-19
+ * <p>
+ * 接口协议地址: https://gitee.com/java110/MicroCommunityThings/blob/master/back/docs/api.md
+ */
 public interface IIotSendAsyn {
 
     /**
@@ -29,9 +36,34 @@ public interface IIotSendAsyn {
      */
     public void addCommunity(JSONObject postParameters);
 
+    /**
+     * 编辑小区信息
+     *
+     * @param postParameters
+     */
+    public void editCommunity(JSONObject postParameters);
+
+    /**
+     * 删除小区信息
+     *
+     * @param postParameters
+     */
+    public void deleteCommunity(JSONObject postParameters);
+
+    /**
+     * 添加 设备 至 HC IOT
+     *
+     * @param postParameters
+     * @param ownerDtos
+     */
     public void addMachine(MultiValueMap<String, Object> postParameters, List<MultiValueMap<String, Object>> ownerDtos);
 
-    void updateSend(MultiValueMap<String, Object> postParameters);
+    /**
+     * 修改 设备 至 HC IOT
+     *
+     * @param postParameters
+     */
+    void updateMachine(MultiValueMap<String, Object> postParameters);
 
     void deleteSend(MultiValueMap<String, Object> postParameters);
 

+ 52 - 37
service-job/src/main/java/com/java110/job/adapt/hcIot/asyn/impl/IotSendAsynImpl.java

@@ -37,6 +37,10 @@ import org.springframework.util.MultiValueMap;
 import java.util.List;
 
 /**
+ * IOT信息异步同步处理实现类
+ * <p>
+ * 接口协议地址: https://gitee.com/java110/MicroCommunityThings/blob/master/back/docs/api.md
+ *
  * @desc add by 吴学文 11:55
  */
 @Service
@@ -53,29 +57,55 @@ public class IotSendAsynImpl implements IIotSendAsyn {
     @Autowired
     private IMachineAttrInnerServiceSMO machineAttrInnerServiceSMOImpl;
 
+    /**
+     * 封装头信息
+     *
+     * @return
+     */
+    private HttpHeaders getHeaders() {
+        HttpHeaders httpHeaders = new HttpHeaders();
+        httpHeaders.add("access_token", GetToken.get(outRestTemplate));
+        //httpHeaders.add("Content-Type", "application/x-www-form-urlencoded");
+
+        return httpHeaders;
+    }
 
     @Override
     @Async
     public void addCommunity(JSONObject postParameters) {
-        postParameters.put("accessToken", GetToken.get(outRestTemplate));
-        HttpHeaders httpHeaders = new HttpHeaders();
-        HttpEntity<MultiValueMap<String, Object>> httpEntity = new HttpEntity(postParameters, httpHeaders);
-        ResponseEntity<String> responseEntity = outRestTemplate.exchange(IotConstant.DELETE_MACHINE_URL, HttpMethod.POST, httpEntity, String.class);
+        HttpEntity<MultiValueMap<String, Object>> httpEntity = new HttpEntity(postParameters, getHeaders());
+        ResponseEntity<String> responseEntity = outRestTemplate.exchange(IotConstant.ADD_COMMUNITY_URL, HttpMethod.POST, httpEntity, String.class);
+        logger.debug("调用HC IOT信息:" + responseEntity);
+    }
 
-        logger.debug("调用吸墨信息:" + responseEntity);
+    @Override
+    @Async
+    public void editCommunity(JSONObject postParameters) {
+        HttpEntity<MultiValueMap<String, Object>> httpEntity = new HttpEntity(postParameters, getHeaders());
+        ResponseEntity<String> responseEntity = outRestTemplate.exchange(IotConstant.UPDATE_COMMUNITY_URL, HttpMethod.POST, httpEntity, String.class);
+        logger.debug("调用HC IOT信息:" + responseEntity);
     }
 
     @Override
     @Async
-    public void addMachine(MultiValueMap<String, Object> postParameters, List<MultiValueMap<String, Object>> ownerDtos) {
-        postParameters.add("accessToken", GetToken.get(outRestTemplate));
-        HttpHeaders httpHeaders = new HttpHeaders();
-        httpHeaders.add("Content-Type", "application/x-www-form-urlencoded");
+    public void deleteCommunity(JSONObject postParameters) {
+        HttpEntity<MultiValueMap<String, Object>> httpEntity = new HttpEntity(postParameters, getHeaders());
+        ResponseEntity<String> responseEntity = outRestTemplate.exchange(IotConstant.DELETE_COMMUNITY_URL, HttpMethod.POST, httpEntity, String.class);
+        logger.debug("调用HC IOT信息:" + responseEntity);
+    }
 
-        HttpEntity<MultiValueMap<String, Object>> httpEntity = new HttpEntity(postParameters, httpHeaders);
+    /**
+     * 添加设备
+     * @param postParameters
+     * @param ownerDtos
+     */
+    @Override
+    @Async
+    public void addMachine(MultiValueMap<String, Object> postParameters, List<MultiValueMap<String, Object>> ownerDtos) {
+        HttpEntity<MultiValueMap<String, Object>> httpEntity = new HttpEntity(postParameters, getHeaders());
         ResponseEntity<String> responseEntity = outRestTemplate.exchange(IotConstant.ADD_MACHINE_URL, HttpMethod.POST, httpEntity, String.class);
 
-        logger.debug("调用吸墨信息:" + responseEntity);
+        logger.debug("调用HC IOT信息:" + responseEntity);
 
         if (responseEntity.getStatusCode() != HttpStatus.OK) {
             return;
@@ -111,62 +141,47 @@ public class IotSendAsynImpl implements IIotSendAsyn {
 
     @Override
     @Async
-    public void updateSend(MultiValueMap<String, Object> postParameters) {
-        postParameters.add("accessToken", GetToken.get(outRestTemplate));
-        HttpHeaders httpHeaders = new HttpHeaders();
-        httpHeaders.add("Content-Type", "application/x-www-form-urlencoded");
+    public void updateMachine(MultiValueMap<String, Object> postParameters) {
 
-        HttpEntity<MultiValueMap<String, Object>> httpEntity = new HttpEntity(postParameters, httpHeaders);
+        HttpEntity<MultiValueMap<String, Object>> httpEntity = new HttpEntity(postParameters, getHeaders());
         ResponseEntity<String> responseEntity = outRestTemplate.exchange(IotConstant.UPDATE_MACHINE_URL, HttpMethod.POST, httpEntity, String.class);
 
-        logger.debug("调用吸墨信息:" + responseEntity);
+        logger.debug("调用HC IOT信息:" + responseEntity);
     }
 
     @Override
     public void deleteSend(MultiValueMap<String, Object> postParameters) {
-        postParameters.add("accessToken", GetToken.get(outRestTemplate));
-        HttpHeaders httpHeaders = new HttpHeaders();
-        httpHeaders.add("Content-Type", "application/x-www-form-urlencoded");
 
-        HttpEntity<MultiValueMap<String, Object>> httpEntity = new HttpEntity(postParameters, httpHeaders);
+        HttpEntity<MultiValueMap<String, Object>> httpEntity = new HttpEntity(postParameters, getHeaders());
         ResponseEntity<String> responseEntity = outRestTemplate.exchange(IotConstant.DELETE_MACHINE_URL, HttpMethod.POST, httpEntity, String.class);
 
-        logger.debug("调用吸墨信息:" + responseEntity);
+        logger.debug("调用HC IOT信息:" + responseEntity);
     }
 
     @Override
     public void sendOwner(MultiValueMap<String, Object> postParameters) {
-        postParameters.add("accessToken", GetToken.get(outRestTemplate));
-        HttpHeaders httpHeaders = new HttpHeaders();
-        httpHeaders.add("Content-Type", "application/x-www-form-urlencoded");
 
-        HttpEntity<MultiValueMap<String, Object>> httpEntity = new HttpEntity(postParameters, httpHeaders);
+        HttpEntity<MultiValueMap<String, Object>> httpEntity = new HttpEntity(postParameters, getHeaders());
         ResponseEntity<String> responseEntity = outRestTemplate.exchange(IotConstant.ADD_OWNER, HttpMethod.POST, httpEntity, String.class);
 
-        logger.debug("调用吸墨信息:" + responseEntity);
+        logger.debug("调用HC IOT信息:" + responseEntity);
     }
 
     @Override
     public void sendUpdateOwner(MultiValueMap<String, Object> postParameters) {
-        postParameters.add("accessToken", GetToken.get(outRestTemplate));
-        HttpHeaders httpHeaders = new HttpHeaders();
-        httpHeaders.add("Content-Type", "application/x-www-form-urlencoded");
 
-        HttpEntity<MultiValueMap<String, Object>> httpEntity = new HttpEntity(postParameters, httpHeaders);
+        HttpEntity<MultiValueMap<String, Object>> httpEntity = new HttpEntity(postParameters, getHeaders());
         ResponseEntity<String> responseEntity = outRestTemplate.exchange(IotConstant.EDIT_OWNER, HttpMethod.POST, httpEntity, String.class);
 
-        logger.debug("调用吸墨信息:" + responseEntity);
+        logger.debug("调用HC IOT信息:" + responseEntity);
     }
 
     @Override
     public void sendDeleteOwner(MultiValueMap<String, Object> postParameters) {
-        postParameters.add("accessToken", GetToken.get(outRestTemplate));
-        HttpHeaders httpHeaders = new HttpHeaders();
-        httpHeaders.add("Content-Type", "application/x-www-form-urlencoded");
 
-        HttpEntity<MultiValueMap<String, Object>> httpEntity = new HttpEntity(postParameters, httpHeaders);
+        HttpEntity<MultiValueMap<String, Object>> httpEntity = new HttpEntity(postParameters, getHeaders());
         ResponseEntity<String> responseEntity = outRestTemplate.exchange(IotConstant.DELETE_OWNER, HttpMethod.POST, httpEntity, String.class);
 
-        logger.debug("调用吸墨信息:" + responseEntity);
+        logger.debug("调用HC IOT信息:" + responseEntity);
     }
 }

+ 94 - 0
service-job/src/main/java/com/java110/job/adapt/hcIot/community/AddCommunityToIotAdapt.java

@@ -0,0 +1,94 @@
+/*
+ * Copyright 2017-2020 吴学文 and java110 team.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.java110.job.adapt.hcIot.community;
+
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.java110.entity.order.Business;
+import com.java110.job.adapt.DatabusAdaptImpl;
+import com.java110.job.adapt.hcIot.asyn.IIotSendAsyn;
+import com.java110.po.community.CommunityPo;
+import com.java110.utils.util.BeanConvertUtil;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+import java.util.List;
+
+/**
+ * HC 小区信息 同步HC物联网系统
+ * <p>
+ * 接口协议地址: https://gitee.com/java110/MicroCommunityThings/blob/master/back/docs/api.md
+ *
+ * @desc add by 吴学文 18:58
+ */
+@Component(value = "addCommunityToIotAdapt")
+public class AddCommunityToIotAdapt extends DatabusAdaptImpl {
+
+    @Autowired
+    private IIotSendAsyn iotSendAsynImpl;
+
+
+    /**
+     * 添加小区执行类
+     * {
+     * "name": "HC小区",
+     * "address": "青海省西宁市",
+     * "cityCode": "510104",
+     * "extCommunityId": "702020042194860039"
+     * }
+     *
+     * @param business   当前处理业务
+     * @param businesses 所有业务信息
+     */
+    @Override
+    public void execute(Business business, List<Business> businesses) {
+        JSONObject data = business.getData();
+        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);
+            } else if (bObj instanceof List) {
+                businessCommunitys = JSONArray.parseArray(JSONObject.toJSONString(bObj));
+            } else {
+                businessCommunitys = (JSONArray) bObj;
+            }
+            for (int bMachineIndex = 0; bMachineIndex < businessCommunitys.size(); bMachineIndex++) {
+                JSONObject businessCommunity = businessCommunitys.getJSONObject(bMachineIndex);
+                doAddCommunity(business, businessCommunity);
+            }
+        }
+    }
+
+    /**
+     * 添加小区信息
+     *
+     * @param business
+     * @param businessCommunity
+     */
+    private void doAddCommunity(Business business, JSONObject businessCommunity) {
+        CommunityPo communityPo = BeanConvertUtil.covertBean(businessCommunity, CommunityPo.class);
+        JSONObject postParameters = new JSONObject();
+        postParameters.put("name", communityPo.getName());
+        postParameters.put("address", communityPo.getAddress());
+        postParameters.put("cityCode", communityPo.getCityCode());
+        postParameters.put("extCommunityId", communityPo.getCommunityId());
+        iotSendAsynImpl.addCommunity(postParameters);
+    }
+
+
+}

+ 92 - 0
service-job/src/main/java/com/java110/job/adapt/hcIot/community/DeleteCommunityToIotAdapt.java

@@ -0,0 +1,92 @@
+/*
+ * Copyright 2017-2020 吴学文 and java110 team.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.java110.job.adapt.hcIot.community;
+
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.java110.entity.order.Business;
+import com.java110.job.adapt.DatabusAdaptImpl;
+import com.java110.job.adapt.hcIot.asyn.IIotSendAsyn;
+import com.java110.po.community.CommunityPo;
+import com.java110.utils.util.BeanConvertUtil;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+import java.util.List;
+
+/**
+ * 编辑小区小区时同步
+ * HC 小区信息 同步HC物联网系统
+ * <p>
+ * 接口协议地址: https://gitee.com/java110/MicroCommunityThings/blob/master/back/docs/api.md
+ *
+ * @desc add by 吴学文 18:58
+ */
+@Component(value = "deleteCommunityToIotAdapt")
+public class DeleteCommunityToIotAdapt extends DatabusAdaptImpl {
+
+    @Autowired
+    private IIotSendAsyn iotSendAsynImpl;
+
+
+    /**
+     * 添加小区执行类
+     * {
+     * "name": "HC小区",
+     * "address": "青海省西宁市",
+     * "cityCode": "510104",
+     * "extCommunityId": "702020042194860039"
+     * }
+     *
+     * @param business   当前处理业务
+     * @param businesses 所有业务信息
+     */
+    @Override
+    public void execute(Business business, List<Business> businesses) {
+        JSONObject data = business.getData();
+        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);
+            } else if (bObj instanceof List) {
+                businessCommunitys = JSONArray.parseArray(JSONObject.toJSONString(bObj));
+            } else {
+                businessCommunitys = (JSONArray) bObj;
+            }
+            for (int bMachineIndex = 0; bMachineIndex < businessCommunitys.size(); bMachineIndex++) {
+                JSONObject businessCommunity = businessCommunitys.getJSONObject(bMachineIndex);
+                doDeleteCommunity(business, businessCommunity);
+            }
+        }
+    }
+
+    /**
+     * 删除小区信息
+     *
+     * @param business
+     * @param businessCommunity
+     */
+    private void doDeleteCommunity(Business business, JSONObject businessCommunity) {
+        CommunityPo communityPo = BeanConvertUtil.covertBean(businessCommunity, CommunityPo.class);
+        JSONObject postParameters = new JSONObject();
+        postParameters.put("extCommunityId", communityPo.getCommunityId());
+        iotSendAsynImpl.deleteCommunity(postParameters);
+    }
+
+
+}

+ 95 - 0
service-job/src/main/java/com/java110/job/adapt/hcIot/community/EditCommunityToIotAdapt.java

@@ -0,0 +1,95 @@
+/*
+ * Copyright 2017-2020 吴学文 and java110 team.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.java110.job.adapt.hcIot.community;
+
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.java110.entity.order.Business;
+import com.java110.job.adapt.DatabusAdaptImpl;
+import com.java110.job.adapt.hcIot.asyn.IIotSendAsyn;
+import com.java110.po.community.CommunityPo;
+import com.java110.utils.util.BeanConvertUtil;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+import java.util.List;
+
+/**
+ * 编辑小区小区时同步
+ * HC 小区信息 同步HC物联网系统
+ * <p>
+ * 接口协议地址: https://gitee.com/java110/MicroCommunityThings/blob/master/back/docs/api.md
+ *
+ * @desc add by 吴学文 18:58
+ */
+@Component(value = "editCommunityToIotAdapt")
+public class EditCommunityToIotAdapt extends DatabusAdaptImpl {
+
+    @Autowired
+    private IIotSendAsyn iotSendAsynImpl;
+
+
+    /**
+     * 添加小区执行类
+     * {
+     * "name": "HC小区",
+     * "address": "青海省西宁市",
+     * "cityCode": "510104",
+     * "extCommunityId": "702020042194860039"
+     * }
+     *
+     * @param business   当前处理业务
+     * @param businesses 所有业务信息
+     */
+    @Override
+    public void execute(Business business, List<Business> businesses) {
+        JSONObject data = business.getData();
+        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);
+            } else if (bObj instanceof List) {
+                businessCommunitys = JSONArray.parseArray(JSONObject.toJSONString(bObj));
+            } else {
+                businessCommunitys = (JSONArray) bObj;
+            }
+            for (int bMachineIndex = 0; bMachineIndex < businessCommunitys.size(); bMachineIndex++) {
+                JSONObject businessCommunity = businessCommunitys.getJSONObject(bMachineIndex);
+                doEditCommunity(business, businessCommunity);
+            }
+        }
+    }
+
+    /**
+     * 修改小区信息
+     *
+     * @param business
+     * @param businessCommunity
+     */
+    private void doEditCommunity(Business business, JSONObject businessCommunity) {
+        CommunityPo communityPo = BeanConvertUtil.covertBean(businessCommunity, CommunityPo.class);
+        JSONObject postParameters = new JSONObject();
+        postParameters.put("name", communityPo.getName());
+        postParameters.put("address", communityPo.getAddress());
+        postParameters.put("cityCode", communityPo.getCityCode());
+        postParameters.put("extCommunityId", communityPo.getCommunityId());
+        iotSendAsynImpl.editCommunity(postParameters);
+    }
+
+
+}

+ 3 - 1
service-job/src/main/java/com/java110/job/adapt/hcIot/AddMachineToIotAdapt.java

@@ -13,7 +13,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package com.java110.job.adapt.hcIot;
+package com.java110.job.adapt.hcIot.machine;
 
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
@@ -45,6 +45,8 @@ import java.util.List;
 
 /**
  * HC iot 设备同步适配器
+ * <p>
+ * 接口协议地址: https://gitee.com/java110/MicroCommunityThings/blob/master/back/docs/api.md
  *
  * @desc add by 吴学文 18:58
  */

+ 3 - 1
service-job/src/main/java/com/java110/job/adapt/hcIot/DeleteMachineToIotAdapt.java

@@ -13,7 +13,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package com.java110.job.adapt.hcIot;
+package com.java110.job.adapt.hcIot.machine;
 
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
@@ -33,6 +33,8 @@ import java.util.List;
 
 /**
  * HC iot 设备同步适配器
+ * <p>
+ * 接口协议地址: https://gitee.com/java110/MicroCommunityThings/blob/master/back/docs/api.md
  *
  * @desc add by 吴学文 18:58
  */

+ 3 - 2
service-job/src/main/java/com/java110/job/adapt/hcIot/ModifyMachineToIotAdapt.java

@@ -13,7 +13,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package com.java110.job.adapt.hcIot;
+package com.java110.job.adapt.hcIot.machine;
 
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
@@ -34,6 +34,7 @@ import java.util.List;
 
 /**
  * HC iot 设备同步适配器
+ * 接口协议地址: https://gitee.com/java110/MicroCommunityThings/blob/master/back/docs/api.md
  *
  * @desc add by 吴学文 18:58
  */
@@ -97,6 +98,6 @@ public class ModifyMachineToIotAdapt extends DatabusAdaptImpl {
         postParameters.add("name", machinePo.getMachineName());
         postParameters.add("positionType", "0");
         postParameters.add("positionUuid", machinePo.getCommunityId());
-        hcMachineAsynImpl.updateSend(postParameters);
+        hcMachineAsynImpl.updateMachine(postParameters);
     }
 }

+ 3 - 1
service-job/src/main/java/com/java110/job/adapt/hcIot/AddOwnerToIotAdapt.java

@@ -13,7 +13,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package com.java110.job.adapt.hcIot;
+package com.java110.job.adapt.hcIot.owner;
 
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
@@ -41,6 +41,8 @@ import java.util.List;
 
 /**
  * HC iot 添加业主同步iot
+ * <p>
+ * 接口协议地址: https://gitee.com/java110/MicroCommunityThings/blob/master/back/docs/api.md
  *
  * @desc add by 吴学文 18:58
  */

+ 3 - 1
service-job/src/main/java/com/java110/job/adapt/hcIot/DeleteOwnerToIotAdapt.java

@@ -13,7 +13,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package com.java110.job.adapt.hcIot;
+package com.java110.job.adapt.hcIot.owner;
 
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
@@ -35,6 +35,8 @@ import java.util.List;
 
 /**
  * HC  添加业主同步iot
+ * <p>
+ * 接口协议地址: https://gitee.com/java110/MicroCommunityThings/blob/master/back/docs/api.md
  *
  * @desc add by 吴学文 18:58
  */

+ 3 - 1
service-job/src/main/java/com/java110/job/adapt/hcIot/EditOwnerToIotAdapt.java

@@ -13,7 +13,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package com.java110.job.adapt.hcIot;
+package com.java110.job.adapt.hcIot.owner;
 
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
@@ -41,6 +41,8 @@ import java.util.List;
 
 /**
  * HC iot 添加业主同步iot
+ * <p>
+ * 接口协议地址: https://gitee.com/java110/MicroCommunityThings/blob/master/back/docs/api.md
  *
  * @desc add by 吴学文 18:58
  */

+ 2 - 1
service-job/src/main/java/com/java110/job/adapt/hcIot/OwnerBindRoomToIotAdapt.java

@@ -13,7 +13,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package com.java110.job.adapt.hcIot;
+package com.java110.job.adapt.hcIot.owner;
 
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
@@ -44,6 +44,7 @@ import java.util.List;
 
 /**
  * HC  添加业主同步iot
+ * 接口协议地址: https://gitee.com/java110/MicroCommunityThings/blob/master/back/docs/api.md
  *
  * @desc add by 吴学文 18:58
  */

+ 2 - 1
service-job/src/main/java/com/java110/job/adapt/hcIot/OwnerUnBindRoomToIotAdapt.java

@@ -13,7 +13,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package com.java110.job.adapt.hcIot;
+package com.java110.job.adapt.hcIot.owner;
 
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
@@ -42,6 +42,7 @@ import java.util.List;
 
 /**
  * HC  添加业主同步iot
+ * 接口协议地址: https://gitee.com/java110/MicroCommunityThings/blob/master/back/docs/api.md
  *
  * @desc add by 吴学文 18:58
  */