|
@@ -17,9 +17,19 @@ package com.java110.job.adapt.ximoIot;
|
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
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.machine.MachineDto;
|
|
import com.java110.dto.machine.MachineDto;
|
|
|
|
|
+import com.java110.dto.owner.OwnerDto;
|
|
|
import com.java110.entity.order.Business;
|
|
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.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.DatabusAdaptImpl;
|
|
|
import com.java110.job.adapt.ximoIot.asyn.IXimoMachineAsyn;
|
|
import com.java110.job.adapt.ximoIot.asyn.IXimoMachineAsyn;
|
|
|
import com.java110.po.machine.MachinePo;
|
|
import com.java110.po.machine.MachinePo;
|
|
@@ -30,6 +40,7 @@ import org.springframework.stereotype.Component;
|
|
|
import org.springframework.util.LinkedMultiValueMap;
|
|
import org.springframework.util.LinkedMultiValueMap;
|
|
|
import org.springframework.util.MultiValueMap;
|
|
import org.springframework.util.MultiValueMap;
|
|
|
|
|
|
|
|
|
|
+import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -45,6 +56,21 @@ public class XimoAddMachineTransactionIotAdapt extends DatabusAdaptImpl {
|
|
|
@Autowired
|
|
@Autowired
|
|
|
IMachineInnerServiceSMO machineInnerServiceSMOImpl;
|
|
IMachineInnerServiceSMO machineInnerServiceSMOImpl;
|
|
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private ICommunityLocationInnerServiceSMO communityLocationInnerServiceSMOImpl;
|
|
|
|
|
+
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private IOwnerInnerServiceSMO ownerInnerServiceSMOImpl;
|
|
|
|
|
+
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private IRoomInnerServiceSMO roomInnerServiceSMOImpl;
|
|
|
|
|
+
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private IFileRelInnerServiceSMO fileRelInnerServiceSMOImpl;
|
|
|
|
|
+
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private IFileInnerServiceSMO fileInnerServiceSMOImpl;
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* accessToken={access_token}
|
|
* accessToken={access_token}
|
|
|
* &extCommunityUuid=01000
|
|
* &extCommunityUuid=01000
|
|
@@ -90,6 +116,12 @@ public class XimoAddMachineTransactionIotAdapt extends DatabusAdaptImpl {
|
|
|
|
|
|
|
|
Assert.listOnlyOne(machineDtos, "未找到设备");
|
|
Assert.listOnlyOne(machineDtos, "未找到设备");
|
|
|
|
|
|
|
|
|
|
+ if (!"9999".equals(machineDtos.get(0).getMachineTypeCd())) {
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ List<MultiValueMap<String, Object>> ownerDtos = getOwners(machinePo);
|
|
|
|
|
+
|
|
|
MultiValueMap<String, Object> postParameters = new LinkedMultiValueMap<>();
|
|
MultiValueMap<String, Object> postParameters = new LinkedMultiValueMap<>();
|
|
|
|
|
|
|
|
postParameters.add("extCommunityUuid", machinePo.getCommunityId());
|
|
postParameters.add("extCommunityUuid", machinePo.getCommunityId());
|
|
@@ -98,6 +130,83 @@ public class XimoAddMachineTransactionIotAdapt extends DatabusAdaptImpl {
|
|
|
postParameters.add("name", machinePo.getMachineName());
|
|
postParameters.add("name", machinePo.getMachineName());
|
|
|
postParameters.add("positionType", "0");
|
|
postParameters.add("positionType", "0");
|
|
|
postParameters.add("positionUuid", machinePo.getCommunityId());
|
|
postParameters.add("positionUuid", machinePo.getCommunityId());
|
|
|
- ximoMachineAsynImpl.send(postParameters);
|
|
|
|
|
|
|
+ ximoMachineAsynImpl.send(postParameters, ownerDtos);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ 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()]);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|