Преглед изворни кода

加入停车场信息增删改同步HC物联网系统

java110 пре 5 година
родитељ
комит
aab1f5ca1f

+ 4 - 0
java110-bean/src/main/java/com/java110/dto/machine/MachineTranslateDto.java

@@ -36,12 +36,16 @@ public class MachineTranslateDto extends PageDto implements Serializable {
     public static final String CMD_ADD_OWNER_FACE = "501";
     public static final String CMD_UPDATE_OWNER_FACE = "502";
     public static final String CMD_DELETE_OWNER_FACE = "503";
+    public static final String CMD_ADD_PARKING_AREA = "601";
+    public static final String CMD_UPDATE_PARKING_AREA = "602";
+    public static final String CMD_DELETE_PARKING_AREA = "603";
     public static final String CMD_OPEN_DOOR = "5";
 
     //小区信息
     public static final String TYPE_COMMUNITY = "9988";
     public static final String TYPE_MACHINE = "3344";
     public static final String TYPE_OWNER = "8899";
+    public static final String TYPE_PARKING_AREA = "2233";
 
     //同步状态
     public static final String STATE_SUCCESS = "20000";

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

@@ -51,6 +51,13 @@ public class IotConstant {
     public static final String UPDATE_MACHINE_URL = "/extApi/machine/updateMachine";
     //删除设备
     public static final String DELETE_MACHINE_URL = "/extApi/machine/deleteMachine";
+
+    //添加停车场
+    public static final String ADD_PARKING_AREA_URL = "/extApi/parkingArea/addParkingArea";
+    //修改停车场
+    public static final String UPDATE_PARKING_AREA_URL = "/extApi/parkingArea/updateParkingArea";
+    //删除停车场
+    public static final String DELETE_PARKING_AREA_URL = "/extApi/parkingArea/deleteParkingArea";
     //开门接口
     public static final String OPEN_DOOR = "/extApi/machine/openDoor";
     //重启接口

+ 11 - 0
service-job/src/main/java/com/java110/job/adapt/hcIot/asyn/IIotSendAsyn.java

@@ -88,4 +88,15 @@ public interface IIotSendAsyn {
      * @param reqJson
      */
     void reSendIot(JSONObject reqJson);
+
+    /**
+     * 添加 停车场
+     *
+     * @param postParameters
+     */
+    void addParkingArea(JSONObject postParameters);
+
+    void updateParkingArea(JSONObject postParameters);
+
+    void deleteParkingArea(JSONObject postParameters);
 }

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

@@ -30,7 +30,6 @@ import com.java110.job.adapt.hcIot.IotConstant;
 import com.java110.job.adapt.hcIot.asyn.IIotSendAsyn;
 import com.java110.po.machineTranslateError.MachineTranslateErrorPo;
 import com.java110.utils.util.DateUtil;
-import com.java110.utils.util.StringUtil;
 import com.java110.vo.ResultVo;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -114,7 +113,7 @@ public class IotSendAsynImpl implements IIotSendAsyn {
         ResponseEntity<String> responseEntity = null;
         String url = IotConstant.getUrl(IotConstant.ADD_COMMUNITY_URL);
         try {
-            postParameters.put("taskId",machineTranslateDto.getMachineTranslateId());
+            postParameters.put("taskId", machineTranslateDto.getMachineTranslateId());
             HttpEntity httpEntity = new HttpEntity(postParameters.toJSONString(), getHeaders());
             responseEntity = outRestTemplate.exchange(url, HttpMethod.POST, httpEntity, String.class);
             logger.debug("调用HC IOT信息:" + responseEntity);
@@ -153,7 +152,7 @@ public class IotSendAsynImpl implements IIotSendAsyn {
         ResponseEntity<String> responseEntity = null;
         String url = IotConstant.getUrl(IotConstant.UPDATE_COMMUNITY_URL);
         try {
-            postParameters.put("taskId",machineTranslateDto.getMachineTranslateId());
+            postParameters.put("taskId", machineTranslateDto.getMachineTranslateId());
             HttpEntity httpEntity = new HttpEntity(postParameters.toJSONString(), getHeaders());
             responseEntity = outRestTemplate.exchange(url, HttpMethod.POST, httpEntity, String.class);
             logger.debug("调用HC IOT信息:" + responseEntity);
@@ -194,7 +193,7 @@ public class IotSendAsynImpl implements IIotSendAsyn {
         ResponseEntity<String> responseEntity = null;
         String url = IotConstant.getUrl(IotConstant.DELETE_COMMUNITY_URL);
         try {
-            postParameters.put("taskId",machineTranslateDto.getMachineTranslateId());
+            postParameters.put("taskId", machineTranslateDto.getMachineTranslateId());
             HttpEntity httpEntity = new HttpEntity(postParameters.toJSONString(), getHeaders());
             responseEntity = outRestTemplate.exchange(url, HttpMethod.POST, httpEntity, String.class);
             logger.debug("调用HC IOT信息:" + responseEntity);
@@ -240,7 +239,7 @@ public class IotSendAsynImpl implements IIotSendAsyn {
         ResponseEntity<String> responseEntity = null;
         String url = IotConstant.getUrl(IotConstant.ADD_MACHINE_URL);
         try {
-            postParameters.put("taskId",machineTranslateDto.getMachineTranslateId());
+            postParameters.put("taskId", machineTranslateDto.getMachineTranslateId());
             HttpEntity httpEntity = new HttpEntity(postParameters.toJSONString(), getHeaders());
             responseEntity = outRestTemplate.exchange(IotConstant.getUrl(IotConstant.ADD_MACHINE_URL), HttpMethod.POST, httpEntity, String.class);
 
@@ -302,7 +301,7 @@ public class IotSendAsynImpl implements IIotSendAsyn {
         ResponseEntity<String> responseEntity = null;
         String url = IotConstant.getUrl(IotConstant.UPDATE_MACHINE_URL);
         try {
-            postParameters.put("taskId",machineTranslateDto.getMachineTranslateId());
+            postParameters.put("taskId", machineTranslateDto.getMachineTranslateId());
             HttpEntity httpEntity = new HttpEntity(postParameters.toJSONString(), getHeaders());
             responseEntity = outRestTemplate.exchange(url, HttpMethod.POST, httpEntity, String.class);
 
@@ -357,7 +356,7 @@ public class IotSendAsynImpl implements IIotSendAsyn {
         ResponseEntity<String> responseEntity = null;
         String url = IotConstant.getUrl(IotConstant.DELETE_MACHINE_URL);
         try {
-            postParameters.put("taskId",machineTranslateDto.getMachineTranslateId());
+            postParameters.put("taskId", machineTranslateDto.getMachineTranslateId());
             HttpEntity httpEntity = new HttpEntity(postParameters.toJSONString(), getHeaders());
             responseEntity = outRestTemplate.exchange(url, HttpMethod.POST, httpEntity, String.class);
             logger.debug("调用HC IOT信息:" + responseEntity);
@@ -405,7 +404,7 @@ public class IotSendAsynImpl implements IIotSendAsyn {
         ResponseEntity<String> responseEntity = null;
         String url = IotConstant.getUrl(IotConstant.ADD_OWNER);
         try {
-            postParameters.put("taskId",machineTranslateDto.getMachineTranslateId());
+            postParameters.put("taskId", machineTranslateDto.getMachineTranslateId());
             HttpEntity httpEntity = new HttpEntity(postParameters.toJSONString(), getHeaders());
             responseEntity = outRestTemplate.exchange(url, HttpMethod.POST, httpEntity, String.class);
 
@@ -454,7 +453,7 @@ public class IotSendAsynImpl implements IIotSendAsyn {
         ResponseEntity<String> responseEntity = null;
         String url = IotConstant.getUrl(IotConstant.EDIT_OWNER);
         try {
-            postParameters.put("taskId",machineTranslateDto.getMachineTranslateId());
+            postParameters.put("taskId", machineTranslateDto.getMachineTranslateId());
             HttpEntity httpEntity = new HttpEntity(postParameters.toJSONString(), getHeaders());
             responseEntity = outRestTemplate.exchange(url, HttpMethod.POST, httpEntity, String.class);
             logger.debug("调用HC IOT信息:" + responseEntity);
@@ -503,7 +502,7 @@ public class IotSendAsynImpl implements IIotSendAsyn {
         ResponseEntity<String> responseEntity = null;
         String url = IotConstant.getUrl(IotConstant.DELETE_OWNER);
         try {
-            postParameters.put("taskId",machineTranslateDto.getMachineTranslateId());
+            postParameters.put("taskId", machineTranslateDto.getMachineTranslateId());
             HttpEntity httpEntity = new HttpEntity(postParameters.toJSONString(), getHeaders());
             responseEntity = outRestTemplate.exchange(url, HttpMethod.POST, httpEntity, String.class);
 
@@ -573,6 +572,159 @@ public class IotSendAsynImpl implements IIotSendAsyn {
         machineTranslateInnerServiceSMOImpl.updateMachineTranslateState(machineTranslateDto);
     }
 
+    @Override
+    public void addParkingArea(JSONObject postParameters) {
+        MachineTranslateDto machineTranslateDto = new MachineTranslateDto();
+        machineTranslateDto.setMachineTranslateId(GenerateCodeFactory.getGeneratorId(GenerateCodeFactory.CODE_PREFIX_machineTranslateId));
+        machineTranslateDto.setCommunityId(postParameters.getString("extCommunityId"));
+        machineTranslateDto.setMachineCmd(MachineTranslateDto.CMD_ADD_PARKING_AREA);
+        machineTranslateDto.setMachineCode("-");
+        machineTranslateDto.setMachineId("-");
+        machineTranslateDto.setObjId(postParameters.getString("extPaId"));
+        machineTranslateDto.setObjName(postParameters.getString("num"));
+        machineTranslateDto.setTypeCd(MachineTranslateDto.TYPE_PARKING_AREA);
+        machineTranslateDto.setState(MachineTranslateDto.STATE_SUCCESS);
+        machineTranslateDto.setRemark("同步物联网系统成功");
+        ResponseEntity<String> responseEntity = null;
+        String url = IotConstant.getUrl(IotConstant.ADD_PARKING_AREA_URL);
+        try {
+            postParameters.put("taskId", machineTranslateDto.getMachineTranslateId());
+            HttpEntity httpEntity = new HttpEntity(postParameters.toJSONString(), getHeaders());
+            responseEntity = outRestTemplate.exchange(url, HttpMethod.POST, httpEntity, String.class);
+
+            logger.debug("调用HC IOT信息:" + responseEntity);
+
+            if (responseEntity.getStatusCode() != HttpStatus.OK) {
+                machineTranslateDto.setState(MachineTranslateDto.STATE_ERROR);
+                machineTranslateDto.setRemark(responseEntity.getBody());
+                saveTranslateError(machineTranslateDto, postParameters.toJSONString(), responseEntity != null ? responseEntity.getBody() : "", url);
+                return;
+            }
+            JSONObject tokenObj = JSONObject.parseObject(responseEntity.getBody());
+
+            if (!tokenObj.containsKey("code") || ResultVo.CODE_OK != tokenObj.getInteger("code")) {
+                machineTranslateDto.setState(MachineTranslateDto.STATE_ERROR);
+                machineTranslateDto.setRemark(tokenObj.getString("msg"));
+                //保存 失败报文
+                saveTranslateError(machineTranslateDto, postParameters.toJSONString(), responseEntity != null ? responseEntity.getBody() : "", url);
+
+                return;
+            }
+        } catch (Exception e) {
+            machineTranslateDto.setState(MachineTranslateDto.STATE_ERROR);
+            machineTranslateDto.setRemark(e.getLocalizedMessage());
+            //保存 失败报文
+            saveTranslateError(machineTranslateDto, postParameters.toJSONString(), responseEntity != null ? responseEntity.getBody() : "", url);
+
+            return;
+        } finally {
+            saveTranslateLog(machineTranslateDto);
+            refreshAccessToken(responseEntity);
+        }
+    }
+
+    @Override
+    public void updateParkingArea(JSONObject postParameters) {
+        MachineTranslateDto machineTranslateDto = new MachineTranslateDto();
+        machineTranslateDto.setMachineTranslateId(GenerateCodeFactory.getGeneratorId(GenerateCodeFactory.CODE_PREFIX_machineTranslateId));
+        machineTranslateDto.setCommunityId(postParameters.getString("extCommunityId"));
+        machineTranslateDto.setMachineCmd(MachineTranslateDto.CMD_UPDATE_PARKING_AREA);
+        machineTranslateDto.setMachineCode("-");
+        machineTranslateDto.setMachineId("-");
+        machineTranslateDto.setObjId(postParameters.getString("extPaId"));
+        machineTranslateDto.setObjName(postParameters.getString("num"));
+        machineTranslateDto.setTypeCd(MachineTranslateDto.TYPE_PARKING_AREA);
+        machineTranslateDto.setState(MachineTranslateDto.STATE_SUCCESS);
+        machineTranslateDto.setRemark("同步物联网系统成功");
+        ResponseEntity<String> responseEntity = null;
+        String url = IotConstant.getUrl(IotConstant.UPDATE_PARKING_AREA_URL);
+        try {
+            postParameters.put("taskId", machineTranslateDto.getMachineTranslateId());
+            HttpEntity httpEntity = new HttpEntity(postParameters.toJSONString(), getHeaders());
+            responseEntity = outRestTemplate.exchange(url, HttpMethod.POST, httpEntity, String.class);
+
+            logger.debug("调用HC IOT信息:" + responseEntity);
+
+            if (responseEntity.getStatusCode() != HttpStatus.OK) {
+                machineTranslateDto.setState(MachineTranslateDto.STATE_ERROR);
+                machineTranslateDto.setRemark(responseEntity.getBody());
+                saveTranslateError(machineTranslateDto, postParameters.toJSONString(), responseEntity != null ? responseEntity.getBody() : "", url);
+                return;
+            }
+            JSONObject tokenObj = JSONObject.parseObject(responseEntity.getBody());
+
+            if (!tokenObj.containsKey("code") || ResultVo.CODE_OK != tokenObj.getInteger("code")) {
+                machineTranslateDto.setState(MachineTranslateDto.STATE_ERROR);
+                machineTranslateDto.setRemark(tokenObj.getString("msg"));
+                //保存 失败报文
+                saveTranslateError(machineTranslateDto, postParameters.toJSONString(), responseEntity != null ? responseEntity.getBody() : "", url);
+
+                return;
+            }
+        } catch (Exception e) {
+            machineTranslateDto.setState(MachineTranslateDto.STATE_ERROR);
+            machineTranslateDto.setRemark(e.getLocalizedMessage());
+            //保存 失败报文
+            saveTranslateError(machineTranslateDto, postParameters.toJSONString(), responseEntity != null ? responseEntity.getBody() : "", url);
+
+            return;
+        } finally {
+            saveTranslateLog(machineTranslateDto);
+            refreshAccessToken(responseEntity);
+        }
+    }
+
+    @Override
+    public void deleteParkingArea(JSONObject postParameters) {
+        MachineTranslateDto machineTranslateDto = new MachineTranslateDto();
+        machineTranslateDto.setMachineTranslateId(GenerateCodeFactory.getGeneratorId(GenerateCodeFactory.CODE_PREFIX_machineTranslateId));
+        machineTranslateDto.setCommunityId(postParameters.getString("extCommunityId"));
+        machineTranslateDto.setMachineCmd(MachineTranslateDto.CMD_DELETE_PARKING_AREA);
+        machineTranslateDto.setMachineCode("-");
+        machineTranslateDto.setMachineId("-");
+        machineTranslateDto.setObjId(postParameters.getString("extPaId"));
+        machineTranslateDto.setObjName(postParameters.getString("num"));
+        machineTranslateDto.setTypeCd(MachineTranslateDto.TYPE_PARKING_AREA);
+        machineTranslateDto.setState(MachineTranslateDto.STATE_SUCCESS);
+        machineTranslateDto.setRemark("同步物联网系统成功");
+        ResponseEntity<String> responseEntity = null;
+        String url = IotConstant.getUrl(IotConstant.DELETE_PARKING_AREA_URL);
+        try {
+            postParameters.put("taskId", machineTranslateDto.getMachineTranslateId());
+            HttpEntity httpEntity = new HttpEntity(postParameters.toJSONString(), getHeaders());
+            responseEntity = outRestTemplate.exchange(url, HttpMethod.POST, httpEntity, String.class);
+
+            logger.debug("调用HC IOT信息:" + responseEntity);
+
+            if (responseEntity.getStatusCode() != HttpStatus.OK) {
+                machineTranslateDto.setState(MachineTranslateDto.STATE_ERROR);
+                machineTranslateDto.setRemark(responseEntity.getBody());
+                saveTranslateError(machineTranslateDto, postParameters.toJSONString(), responseEntity != null ? responseEntity.getBody() : "", url);
+                return;
+            }
+            JSONObject tokenObj = JSONObject.parseObject(responseEntity.getBody());
+
+            if (!tokenObj.containsKey("code") || ResultVo.CODE_OK != tokenObj.getInteger("code")) {
+                machineTranslateDto.setState(MachineTranslateDto.STATE_ERROR);
+                machineTranslateDto.setRemark(tokenObj.getString("msg"));
+                //保存 失败报文
+                saveTranslateError(machineTranslateDto, postParameters.toJSONString(), responseEntity != null ? responseEntity.getBody() : "", url);
+
+                return;
+            }
+        } catch (Exception e) {
+            machineTranslateDto.setState(MachineTranslateDto.STATE_ERROR);
+            machineTranslateDto.setRemark(e.getLocalizedMessage());
+            //保存 失败报文
+            saveTranslateError(machineTranslateDto, postParameters.toJSONString(), responseEntity != null ? responseEntity.getBody() : "", url);
+
+            return;
+        } finally {
+            saveTranslateLog(machineTranslateDto);
+            refreshAccessToken(responseEntity);
+        }
+    }
+
     /**
      * 存储交互 记录
      *

+ 10 - 0
service-job/src/main/java/com/java110/job/adapt/hcIot/machine/AddMachineToIotAdapt.java

@@ -77,6 +77,7 @@ public class AddMachineToIotAdapt extends DatabusAdaptImpl {
     @Autowired
     private IFileInnerServiceSMO fileInnerServiceSMOImpl;
 
+
     /**
      * accessToken={access_token}
      * &extCommunityUuid=01000
@@ -122,6 +123,13 @@ public class AddMachineToIotAdapt extends DatabusAdaptImpl {
 
         Assert.listOnlyOne(machineDtos, "未找到设备");
 
+        CommunityLocationDto communityLocationDto = new CommunityLocationDto();
+        communityLocationDto.setLocationId(machineDtos.get(0).getLocationTypeCd());
+        communityLocationDto.setCommunityId(machineDtos.get(0).getCommunityId());
+        List<CommunityLocationDto> communityLocationDtos = communityLocationInnerServiceSMOImpl.queryCommunityLocations(communityLocationDto);
+
+        Assert.listOnlyOne(communityLocationDtos, "设备位置不存在");
+
         String hmId = getHmId(machineDtos.get(0));
 
         List<JSONObject> ownerDtos = getOwners(machinePo);
@@ -132,6 +140,8 @@ public class AddMachineToIotAdapt extends DatabusAdaptImpl {
         postParameters.put("machineName", machinePo.getMachineName());
         postParameters.put("machineVersion", machinePo.getMachineVersion());
         postParameters.put("machineTypeCd", machinePo.getMachineTypeCd());
+        postParameters.put("locationType", communityLocationDtos.get(0).getLocationType());
+        postParameters.put("locationObjId", machineDtos.get(0).getLocationObjId());
         postParameters.put("extMachineId", machineDtos.get(0).getMachineId());
         postParameters.put("extCommunityId", machinePo.getCommunityId());
         postParameters.put("machineIp", machinePo.getMachineIp());

+ 15 - 0
service-job/src/main/java/com/java110/job/adapt/hcIot/machine/ModifyMachineToIotAdapt.java

@@ -17,11 +17,13 @@ package com.java110.job.adapt.hcIot.machine;
 
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
+import com.java110.dto.communityLocation.CommunityLocationDto;
 import com.java110.dto.machine.MachineAttrDto;
 import com.java110.dto.machine.MachineDto;
 import com.java110.entity.order.Business;
 import com.java110.intf.common.IMachineAttrInnerServiceSMO;
 import com.java110.intf.common.IMachineInnerServiceSMO;
+import com.java110.intf.community.ICommunityLocationInnerServiceSMO;
 import com.java110.job.adapt.DatabusAdaptImpl;
 import com.java110.job.adapt.hcIot.asyn.IIotSendAsyn;
 import com.java110.po.machine.MachinePo;
@@ -52,6 +54,9 @@ public class ModifyMachineToIotAdapt extends DatabusAdaptImpl {
     @Autowired
     private IMachineAttrInnerServiceSMO machineAttrInnerServiceSMOImpl;
 
+    @Autowired
+    private ICommunityLocationInnerServiceSMO communityLocationInnerServiceSMOImpl;
+
     /**
      * accessToken={access_token}
      * &extCommunityUuid=01000
@@ -94,6 +99,14 @@ public class ModifyMachineToIotAdapt extends DatabusAdaptImpl {
         List<MachineDto> machineDtos = machineInnerServiceSMOImpl.queryMachines(machineDto);
 
         Assert.listOnlyOne(machineDtos, "未找到设备");
+
+        CommunityLocationDto communityLocationDto = new CommunityLocationDto();
+        communityLocationDto.setLocationId(machineDtos.get(0).getLocationTypeCd());
+        communityLocationDto.setCommunityId(machineDtos.get(0).getCommunityId());
+        List<CommunityLocationDto> communityLocationDtos = communityLocationInnerServiceSMOImpl.queryCommunityLocations(communityLocationDto);
+
+        Assert.listOnlyOne(communityLocationDtos, "设备位置不存在");
+
         String hmId = getHmId(machineDtos.get(0));
         JSONObject postParameters = new JSONObject();
 
@@ -101,6 +114,8 @@ public class ModifyMachineToIotAdapt extends DatabusAdaptImpl {
         postParameters.put("machineName", machinePo.getMachineName());
         postParameters.put("machineVersion", machinePo.getMachineVersion());
         postParameters.put("machineTypeCd", machinePo.getMachineTypeCd());
+        postParameters.put("locationType", communityLocationDtos.get(0).getLocationType());
+        postParameters.put("locationObjId", machineDtos.get(0).getLocationObjId());
         postParameters.put("extMachineId", machineDtos.get(0).getMachineId());
         postParameters.put("extCommunityId", machinePo.getCommunityId());
         postParameters.put("machineIp", machinePo.getMachineIp());

+ 107 - 0
service-job/src/main/java/com/java110/job/adapt/hcIot/parkingArea/AddParkingAreaToIotAdapt.java

@@ -0,0 +1,107 @@
+/*
+ * 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.parkingArea;
+
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.java110.dto.parking.ParkingAreaDto;
+import com.java110.entity.order.Business;
+import com.java110.intf.community.IParkingAreaInnerServiceSMO;
+import com.java110.intf.user.IOwnerInnerServiceSMO;
+import com.java110.job.adapt.DatabusAdaptImpl;
+import com.java110.job.adapt.hcIot.asyn.IIotSendAsyn;
+import com.java110.po.parking.ParkingAreaPo;
+import com.java110.utils.util.Assert;
+import com.java110.utils.util.BeanConvertUtil;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+import java.util.List;
+
+/**
+ * HC iot 停车场同步适配器
+ * <p>
+ * 接口协议地址: https://gitee.com/java110/MicroCommunityThings/blob/master/back/docs/api.md
+ *
+ * @desc add by 吴学文 18:58
+ */
+@Component(value = "addParkingAreaToIotAdapt")
+public class AddParkingAreaToIotAdapt extends DatabusAdaptImpl {
+
+    @Autowired
+    private IIotSendAsyn hcParkingAreaAsynImpl;
+
+
+    @Autowired
+    private IParkingAreaInnerServiceSMO parkingAreaInnerServiceSMOImpl;
+
+    @Autowired
+    private IOwnerInnerServiceSMO ownerInnerServiceSMOImpl;
+
+
+    /**
+     * accessToken={access_token}
+     * &extCommunityUuid=01000
+     * &extCommunityId=1
+     * &devSn=111111111
+     * &name=设备名称
+     * &positionType=0
+     * &positionUuid=1
+     *
+     * @param business   当前处理业务
+     * @param businesses 所有业务信息
+     */
+    @Override
+    public void execute(Business business, List<Business> businesses) {
+        JSONObject data = business.getData();
+        if (data.containsKey(ParkingAreaPo.class.getSimpleName())) {
+            Object bObj = data.get(ParkingAreaPo.class.getSimpleName());
+            JSONArray businessParkingAreas = null;
+            if (bObj instanceof JSONObject) {
+                businessParkingAreas = new JSONArray();
+                businessParkingAreas.add(bObj);
+            } else if (bObj instanceof List) {
+                businessParkingAreas = JSONArray.parseArray(JSONObject.toJSONString(bObj));
+            } else {
+                businessParkingAreas = (JSONArray) bObj;
+            }
+            //JSONObject businessParkingArea = data.getJSONObject("businessParkingArea");
+            for (int bParkingAreaIndex = 0; bParkingAreaIndex < businessParkingAreas.size(); bParkingAreaIndex++) {
+                JSONObject businessParkingArea = businessParkingAreas.getJSONObject(bParkingAreaIndex);
+                doSendParkingArea(business, businessParkingArea);
+            }
+        }
+    }
+
+    private void doSendParkingArea(Business business, JSONObject businessParkingArea) {
+
+        ParkingAreaPo parkingAreaPo = BeanConvertUtil.covertBean(businessParkingArea, ParkingAreaPo.class);
+
+        ParkingAreaDto parkingAreaDto = new ParkingAreaDto();
+        parkingAreaDto.setNum(parkingAreaPo.getNum());
+        parkingAreaDto.setCommunityId(parkingAreaPo.getCommunityId());
+        List<ParkingAreaDto> parkingAreaDtos = parkingAreaInnerServiceSMOImpl.queryParkingAreas(parkingAreaDto);
+
+        Assert.listOnlyOne(parkingAreaDtos, "未找到停车场");
+
+        JSONObject postParameters = new JSONObject();
+
+        postParameters.put("num", parkingAreaDtos.get(0).getNum());
+        postParameters.put("extPaId", parkingAreaDtos.get(0).getPaId());
+        postParameters.put("extCommunityId", parkingAreaDtos.get(0).getCommunityId());
+        hcParkingAreaAsynImpl.addParkingArea(postParameters);
+    }
+}

+ 92 - 0
service-job/src/main/java/com/java110/job/adapt/hcIot/parkingArea/DeleteParkingAreaToIotAdapt.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.parkingArea;
+
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.java110.dto.parking.ParkingAreaDto;
+import com.java110.entity.order.Business;
+import com.java110.intf.community.IParkingAreaInnerServiceSMO;
+import com.java110.job.adapt.DatabusAdaptImpl;
+import com.java110.job.adapt.hcIot.asyn.IIotSendAsyn;
+import com.java110.po.parking.ParkingAreaPo;
+import com.java110.utils.constant.StatusConstant;
+import com.java110.utils.util.Assert;
+import com.java110.utils.util.BeanConvertUtil;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+import java.util.List;
+
+/**
+ * HC iot 设备同步适配器
+ * <p>
+ * 接口协议地址: https://gitee.com/java110/MicroCommunityThings/blob/master/back/docs/api.md
+ *
+ * @desc add by 吴学文 18:58
+ */
+@Component(value = "deleteParkingAreaToIotAdapt")
+public class DeleteParkingAreaToIotAdapt extends DatabusAdaptImpl {
+
+    @Autowired
+    private IIotSendAsyn hcParkingAreaAsynImpl;
+
+    @Autowired
+    private IParkingAreaInnerServiceSMO parkingAreaInnerServiceSMOImpl;
+
+    /**
+     * {
+     * "extParkingAreaId": "702020042194860037"
+     * }
+     *
+     * @param business   当前处理业务
+     * @param businesses 所有业务信息
+     */
+    @Override
+    public void execute(Business business, List<Business> businesses) {
+        JSONObject data = business.getData();
+        if (data.containsKey(ParkingAreaPo.class.getSimpleName())) {
+            Object bObj = data.get(ParkingAreaPo.class.getSimpleName());
+            JSONArray businessParkingAreas = null;
+            if (bObj instanceof JSONObject) {
+                businessParkingAreas = new JSONArray();
+                businessParkingAreas.add(bObj);
+            } else if (bObj instanceof List) {
+                businessParkingAreas = JSONArray.parseArray(JSONObject.toJSONString(bObj));
+            } else {
+                businessParkingAreas = (JSONArray) bObj;
+            }
+            //JSONObject businessParkingArea = data.getJSONObject("businessParkingArea");
+            for (int bParkingAreaIndex = 0; bParkingAreaIndex < businessParkingAreas.size(); bParkingAreaIndex++) {
+                JSONObject businessParkingArea = businessParkingAreas.getJSONObject(bParkingAreaIndex);
+                doSendParkingArea(business, businessParkingArea);
+            }
+        }
+    }
+
+    private void doSendParkingArea(Business business, JSONObject businessParkingArea) {
+        ParkingAreaPo parkingAreaPo = BeanConvertUtil.covertBean(businessParkingArea, ParkingAreaPo.class);
+        ParkingAreaDto parkingAreaDto = new ParkingAreaDto();
+        parkingAreaDto.setPaId(parkingAreaPo.getPaId());
+        parkingAreaDto.setStatusCd(StatusConstant.STATUS_CD_INVALID);
+        List<ParkingAreaDto> parkingAreaDtos = parkingAreaInnerServiceSMOImpl.queryParkingAreas(parkingAreaDto);
+        Assert.listOnlyOne(parkingAreaDtos, "未找到停车场");
+        JSONObject postParameters = new JSONObject();
+        postParameters.put("extPaId", parkingAreaDtos.get(0).getPaId());
+        postParameters.put("extCommunityId", parkingAreaDtos.get(0).getCommunityId());
+        hcParkingAreaAsynImpl.deleteParkingArea(postParameters);
+    }
+}

+ 112 - 0
service-job/src/main/java/com/java110/job/adapt/hcIot/parkingArea/ModifyParkingAreaToIotAdapt.java

@@ -0,0 +1,112 @@
+/*
+ * 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.parkingArea;
+
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.java110.dto.communityLocation.CommunityLocationDto;
+import com.java110.dto.machine.MachineAttrDto;
+import com.java110.dto.machine.MachineDto;
+import com.java110.dto.parking.ParkingAreaDto;
+import com.java110.entity.order.Business;
+import com.java110.intf.common.IMachineAttrInnerServiceSMO;
+import com.java110.intf.common.IMachineInnerServiceSMO;
+import com.java110.intf.community.ICommunityLocationInnerServiceSMO;
+import com.java110.intf.community.IParkingAreaInnerServiceSMO;
+import com.java110.intf.user.IOwnerInnerServiceSMO;
+import com.java110.job.adapt.DatabusAdaptImpl;
+import com.java110.job.adapt.hcIot.asyn.IIotSendAsyn;
+import com.java110.po.machine.MachinePo;
+import com.java110.po.parking.ParkingAreaPo;
+import com.java110.utils.util.Assert;
+import com.java110.utils.util.BeanConvertUtil;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+import java.util.List;
+
+/**
+ * HC iot 设备同步适配器
+ * 接口协议地址: https://gitee.com/java110/MicroCommunityThings/blob/master/back/docs/api.md
+ *
+ * @desc add by 吴学文 18:58
+ */
+@Component(value = "modifyParkingAreaToIotAdapt")
+public class ModifyParkingAreaToIotAdapt extends DatabusAdaptImpl {
+
+    @Autowired
+    private IIotSendAsyn hcParkingAreaAsynImpl;
+
+
+    @Autowired
+    private IParkingAreaInnerServiceSMO parkingAreaInnerServiceSMOImpl;
+
+
+
+
+    /**
+     * accessToken={access_token}
+     * &extCommunityUuid=01000
+     * &extCommunityId=1
+     * &devSn=111111111
+     * &name=设备名称
+     * &positionType=0
+     * &positionUuid=1
+     *
+     * @param business   当前处理业务
+     * @param businesses 所有业务信息
+     */
+    @Override
+    public void execute(Business business, List<Business> businesses) {
+        JSONObject data = business.getData();
+        if (data.containsKey(ParkingAreaPo.class.getSimpleName())) {
+            Object bObj = data.get(ParkingAreaPo.class.getSimpleName());
+            JSONArray businessParkingAreas = null;
+            if (bObj instanceof JSONObject) {
+                businessParkingAreas = new JSONArray();
+                businessParkingAreas.add(bObj);
+            } else if (bObj instanceof List) {
+                businessParkingAreas = JSONArray.parseArray(JSONObject.toJSONString(bObj));
+            } else {
+                businessParkingAreas = (JSONArray) bObj;
+            }
+            //JSONObject businessParkingArea = data.getJSONObject("businessParkingArea");
+            for (int bParkingAreaIndex = 0; bParkingAreaIndex < businessParkingAreas.size(); bParkingAreaIndex++) {
+                JSONObject businessParkingArea = businessParkingAreas.getJSONObject(bParkingAreaIndex);
+                doSendParkingArea(business, businessParkingArea);
+            }
+        }
+    }
+
+    private void doSendParkingArea(Business business, JSONObject businessParkingArea) {
+
+        ParkingAreaPo parkingAreaPo = BeanConvertUtil.covertBean(businessParkingArea, ParkingAreaPo.class);
+
+        ParkingAreaDto parkingAreaDto = new ParkingAreaDto();
+        parkingAreaDto.setNum(parkingAreaPo.getPaId());
+        parkingAreaDto.setCommunityId(parkingAreaPo.getCommunityId());
+        List<ParkingAreaDto> parkingAreaDtos = parkingAreaInnerServiceSMOImpl.queryParkingAreas(parkingAreaDto);
+
+        Assert.listOnlyOne(parkingAreaDtos, "未找到停车场");
+
+        JSONObject postParameters = new JSONObject();
+
+        postParameters.put("num", parkingAreaDtos.get(0).getNum());
+        postParameters.put("extPaId", parkingAreaDtos.get(0).getPaId());
+        postParameters.put("extCommunityId", parkingAreaDtos.get(0).getCommunityId());
+        hcParkingAreaAsynImpl.updateParkingArea(postParameters);
+    }
+}