From 597cae7743fde0ca86efb4659a2ded937fc308ae Mon Sep 17 00:00:00 2001
From: java110 <928255095@qq.com>
Date: 星期二, 19 一月 2021 00:32:28 +0800
Subject: [PATCH] Merge branch 'master' of http://git.homecommunity.cn/supervip/MicroCommunity

---
 service-job/src/main/java/com/java110/job/adapt/hcIot/machine/ModifyMachineToIotAdapt.java |   52 +++++++++++++++++++++++++++++++++++++++++++++-------
 1 files changed, 45 insertions(+), 7 deletions(-)

diff --git a/service-job/src/main/java/com/java110/job/adapt/hcIot/machine/ModifyMachineToIotAdapt.java b/service-job/src/main/java/com/java110/job/adapt/hcIot/machine/ModifyMachineToIotAdapt.java
index 4ad6994..28bca98 100644
--- a/service-job/src/main/java/com/java110/job/adapt/hcIot/machine/ModifyMachineToIotAdapt.java
+++ b/service-job/src/main/java/com/java110/job/adapt/hcIot/machine/ModifyMachineToIotAdapt.java
@@ -17,9 +17,13 @@
 
 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;
@@ -46,6 +50,12 @@
 
     @Autowired
     IMachineInnerServiceSMO machineInnerServiceSMOImpl;
+
+    @Autowired
+    private IMachineAttrInnerServiceSMO machineAttrInnerServiceSMOImpl;
+
+    @Autowired
+    private ICommunityLocationInnerServiceSMO communityLocationInnerServiceSMOImpl;
 
     /**
      * accessToken={access_token}
@@ -90,14 +100,42 @@
 
         Assert.listOnlyOne(machineDtos, "鏈壘鍒拌澶�");
 
-        MultiValueMap<String, Object> postParameters = new LinkedMultiValueMap<>();
+        CommunityLocationDto communityLocationDto = new CommunityLocationDto();
+        communityLocationDto.setLocationId(machineDtos.get(0).getLocationTypeCd());
+        communityLocationDto.setCommunityId(machineDtos.get(0).getCommunityId());
+        List<CommunityLocationDto> communityLocationDtos = communityLocationInnerServiceSMOImpl.queryCommunityLocations(communityLocationDto);
 
-        postParameters.add("extCommunityUuid", machineDtos.get(0).getCommunityId());
-        postParameters.add("devSn", machinePo.getMachineCode());
-        //postParameters.add("uuid", machinePo.getMachineId());
-        postParameters.add("name", machinePo.getMachineName());
-        postParameters.add("positionType", "0");
-        postParameters.add("positionUuid", machinePo.getCommunityId());
+        Assert.listOnlyOne(communityLocationDtos, "璁惧浣嶇疆涓嶅瓨鍦�");
+
+        String hmId = getHmId(machineDtos.get(0));
+        JSONObject postParameters = new JSONObject();
+
+        postParameters.put("machineCode", machinePo.getMachineCode());
+        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());
+        postParameters.put("machineMac", machinePo.getMachineMac());
+        postParameters.put("direction", machinePo.getDirection());
+        postParameters.put("hmId", hmId);
         hcMachineAsynImpl.updateMachine(postParameters);
     }
+
+    private String getHmId(MachineDto machineDto) {
+        MachineAttrDto machineAttrDto = new MachineAttrDto();
+        machineAttrDto.setCommunityId(machineDto.getCommunityId());
+        machineAttrDto.setMachineId(machineDto.getMachineId());
+        List<MachineAttrDto> machineAttrDtos = machineAttrInnerServiceSMOImpl.queryMachineAttrs(machineAttrDto);
+
+        for (MachineAttrDto tmpMachineAttrDto : machineAttrDtos) {
+            if (MachineAttrDto.SPEC_HM.equals(tmpMachineAttrDto.getSpecCd())) {
+                return tmpMachineAttrDto.getValue();
+            }
+        }
+        return "";
+    }
 }

--
Gitblit v1.8.0