|
@@ -54,6 +54,9 @@ public class SyncAppImpl implements ISyncApp {
|
|
|
private AdmRelationMapper relationMapper;
|
|
|
|
|
|
@Autowired
|
|
|
+ private AdmPipeMapper pipeMapper;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
private AdmJobSpaceMapper jobSpaceMapper;
|
|
|
|
|
|
@Autowired
|
|
@@ -215,6 +218,7 @@ public class SyncAppImpl implements ISyncApp {
|
|
|
public SyncData downloadBuildingData(String projectId, String buildingId, String uploadFlag, String lastDownloadTime) {
|
|
|
List<AdmObject> bdData = admObjMapper.selectList(buildDownloadQueryWrapper(new QueryWrapper<AdmObject>(), projectId, buildingId, uploadFlag, lastDownloadTime));
|
|
|
List<AdmRelation> bdRel = relationMapper.selectList(buildDownloadQueryWrapper(new QueryWrapper<AdmRelation>(), projectId, buildingId, uploadFlag, lastDownloadTime));
|
|
|
+ List<AdmPipe> pipes = pipeMapper.selectList(buildDownloadQueryWrapper(new QueryWrapper<AdmPipe>(), projectId, buildingId, uploadFlag, lastDownloadTime));
|
|
|
|
|
|
//任务相关数据查询
|
|
|
List<AdmJobSpace> jobSpace = jobSpaceMapper.selectList(buildDownloadQueryWrapper(new QueryWrapper<AdmJobSpace>(), projectId, buildingId, uploadFlag, lastDownloadTime));
|
|
@@ -228,6 +232,7 @@ public class SyncAppImpl implements ISyncApp {
|
|
|
|
|
|
data.setObjects(serializeJsonProp(bdData));
|
|
|
data.setRelations(bdRel);
|
|
|
+ data.setPipes(serializeJsonProp(pipes));
|
|
|
|
|
|
data.setJobSpace(serializeJsonProp(jobSpace));
|
|
|
data.setProblemArch(serializeJsonProp(problemArch));
|
|
@@ -265,7 +270,7 @@ public class SyncAppImpl implements ISyncApp {
|
|
|
|
|
|
if (CollUtil.isNotEmpty(uploadData.getObjects())) {
|
|
|
List<AdmObject> dbObjs = admObjMapper.selectList(new QueryWrapper<AdmObject>().eq("building_id", uploadData.getBuildingId()).eq("valid", ValidEnum.TRUE.getType()));
|
|
|
- List<AdmObject> expired = uploadBdtpData(uploadData.getObjects(), dbObjs, uploadFlag, timestamp, admObjMapper, "object");
|
|
|
+ List<AdmObject> expired = uploadBdtpData(deserializeJsonProp(uploadData.getObjects()), dbObjs, uploadFlag, timestamp, admObjMapper, "object");
|
|
|
rtn.setExpiredObjectIds(buildExpiredIds(expired));
|
|
|
}
|
|
|
if (CollUtil.isNotEmpty(uploadData.getRelations())) {
|
|
@@ -275,29 +280,35 @@ public class SyncAppImpl implements ISyncApp {
|
|
|
}
|
|
|
|
|
|
String timestampStr = timestamp.toString();
|
|
|
+ if (CollUtil.isNotEmpty(uploadData.getPipes())) {
|
|
|
+ List<AdmPipe> dbObjs = pipeMapper.selectList(new QueryWrapper<AdmPipe>().eq("building_id", uploadData.getBuildingId()).eq("valid", ValidEnum.TRUE.getType()));
|
|
|
+ List<AdmPipe> expired = uploadAdmData(deserializeJsonProp(uploadData.getPipes()), dbObjs, uploadFlag, timestampStr, pipeMapper, "pipe");
|
|
|
+ rtn.setExpiredPipeIds(buildExpiredIds(expired));
|
|
|
+ }
|
|
|
+
|
|
|
if (CollUtil.isNotEmpty(uploadData.getJobSpace())) {
|
|
|
List<AdmJobSpace> dbObjs = jobSpaceMapper.selectList(new QueryWrapper<AdmJobSpace>().eq("building_id", uploadData.getBuildingId()).eq("valid", ValidEnum.TRUE.getType()));
|
|
|
- List<AdmJobSpace> expired = uploadAdmData(uploadData.getJobSpace(), dbObjs, uploadFlag, timestampStr, jobSpaceMapper);
|
|
|
+ List<AdmJobSpace> expired = uploadAdmData(deserializeJsonProp(uploadData.getJobSpace()), dbObjs, uploadFlag, timestampStr, jobSpaceMapper, null);
|
|
|
rtn.setExpiredJobSpaceIds(buildExpiredIds(expired));
|
|
|
}
|
|
|
if (CollUtil.isNotEmpty(uploadData.getProblemArch())) {
|
|
|
List<AdmProblemArch> dbObjs = problemArchMapper.selectList(new QueryWrapper<AdmProblemArch>().eq("building_id", uploadData.getBuildingId()).eq("valid", ValidEnum.TRUE.getType()));
|
|
|
- List<AdmProblemArch> expired = uploadAdmData(uploadData.getProblemArch(), dbObjs, uploadFlag, timestampStr, problemArchMapper);
|
|
|
+ List<AdmProblemArch> expired = uploadAdmData(deserializeJsonProp(uploadData.getProblemArch()), dbObjs, uploadFlag, timestampStr, problemArchMapper, null);
|
|
|
rtn.setExpiredProblemArchIds(buildExpiredIds(expired));
|
|
|
}
|
|
|
if (CollUtil.isNotEmpty(uploadData.getProblemEquip())) {
|
|
|
List<AdmProblemEquip> dbObjs = problemEquipMapper.selectList(new QueryWrapper<AdmProblemEquip>().eq("building_id", uploadData.getBuildingId()).eq("valid", ValidEnum.TRUE.getType()));
|
|
|
- List<AdmProblemEquip> expired = uploadAdmData(uploadData.getProblemEquip(), dbObjs, uploadFlag, timestampStr, problemEquipMapper);
|
|
|
+ List<AdmProblemEquip> expired = uploadAdmData(uploadData.getProblemEquip(), dbObjs, uploadFlag, timestampStr, problemEquipMapper, null);
|
|
|
rtn.setExpiredProblemEquipIds(buildExpiredIds(expired));
|
|
|
}
|
|
|
if (CollUtil.isNotEmpty(uploadData.getFile())) {
|
|
|
List<AdmFile> dbObjs = fileMapper.selectList(new QueryWrapper<AdmFile>().eq("building_id", uploadData.getBuildingId()).eq("valid", ValidEnum.TRUE.getType()));
|
|
|
- List<AdmFile> expired = uploadAdmData(uploadData.getFile(), dbObjs, uploadFlag, timestampStr, fileMapper);
|
|
|
+ List<AdmFile> expired = uploadAdmData(uploadData.getFile(), dbObjs, uploadFlag, timestampStr, fileMapper, null);
|
|
|
rtn.setExpiredFileIds(buildExpiredIds(expired));
|
|
|
}
|
|
|
if (CollUtil.isNotEmpty(uploadData.getQrCode())) {
|
|
|
List<AdmQrCode> dbObjs = qrCodeMapper.selectList(new QueryWrapper<AdmQrCode>().eq("building_id", uploadData.getBuildingId()).eq("valid", ValidEnum.TRUE.getType()));
|
|
|
- List<AdmQrCode> expired = uploadAdmData(uploadData.getQrCode(), dbObjs, uploadFlag, timestampStr, qrCodeMapper);
|
|
|
+ List<AdmQrCode> expired = uploadAdmData(deserializeJsonProp(uploadData.getQrCode()), dbObjs, uploadFlag, timestampStr, qrCodeMapper, null);
|
|
|
rtn.setExpiredQrCodeIds(buildExpiredIds(expired));
|
|
|
}
|
|
|
|
|
@@ -356,12 +367,7 @@ public class SyncAppImpl implements ISyncApp {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- D2mMessage message = new D2mMessage();
|
|
|
- message.setItemType(objectType);
|
|
|
- message.setAddItems(msgAdd);
|
|
|
- message.setModifyItems(msgModify);
|
|
|
- message.setRemoveItems(msgRemove);
|
|
|
- syncModel.sendMessageToModel(message);
|
|
|
+ sendD2mMessage(objectType, msgAdd, msgModify, msgRemove);
|
|
|
|
|
|
return expired;
|
|
|
}
|
|
@@ -374,14 +380,24 @@ public class SyncAppImpl implements ISyncApp {
|
|
|
obj.setClientDevice(dbObj.getClientDevice());
|
|
|
}
|
|
|
|
|
|
- private <T extends BaseAdmDataEntity> List<T> uploadAdmData(List<T> objs, List<T> dbObjs, String uploadFlag, String timestamp, BaseMapper<T> mapper){
|
|
|
+ private <T extends BaseAdmDataEntity> List<T> uploadAdmData(List<T> objs, List<T> dbObjs, String uploadFlag, String timestamp, BaseMapper<T> mapper, String d2mType){
|
|
|
List<T> expired = new ArrayList<>();
|
|
|
HashMap<String, T> dbMap = new HashMap<>(dbObjs.size());
|
|
|
for(T dbObj : dbObjs) {
|
|
|
dbMap.put(dbObj.getId(), dbObj);
|
|
|
}
|
|
|
|
|
|
+ List<T> msgAdd = new ArrayList<>();
|
|
|
+ List<T> msgModify = new ArrayList<>();
|
|
|
+ List<T> msgRemove = new ArrayList<>();
|
|
|
for (T obj : objs) {
|
|
|
+ if(d2mType != null) {
|
|
|
+ if(obj instanceof AdmPipe) {
|
|
|
+ ((AdmPipe) obj).setD2mState(ValidEnum.FALSE.getType());
|
|
|
+ ((AdmPipe) obj).setDeliveryState(ValidEnum.FALSE.getType());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
T dbObj = dbMap.get(obj.getId());
|
|
|
if (dbObj == null) {
|
|
|
if(obj.getValid().intValue() == ValidEnum.FALSE.getType())
|
|
@@ -390,7 +406,11 @@ public class SyncAppImpl implements ISyncApp {
|
|
|
obj.setCreationTime(timestamp);
|
|
|
obj.setCreator(AdmConst.CREATOR_APP);
|
|
|
obj.setUploadFlag(uploadFlag);
|
|
|
+
|
|
|
mapper.insert(obj);
|
|
|
+
|
|
|
+ if(d2mType != null)
|
|
|
+ msgAdd.add(obj);
|
|
|
} else {
|
|
|
String dbTs;
|
|
|
String ts;
|
|
@@ -408,13 +428,34 @@ public class SyncAppImpl implements ISyncApp {
|
|
|
obj.setModifiedTime(timestamp);
|
|
|
obj.setModifier(AdmConst.CREATOR_APP);
|
|
|
obj.setUploadFlag(uploadFlag);
|
|
|
+
|
|
|
mapper.updateById(obj);
|
|
|
+
|
|
|
+ if(d2mType != null) {
|
|
|
+ if(obj.getValid().intValue() == ValidEnum.FALSE.getType())
|
|
|
+ msgRemove.add(obj);
|
|
|
+ else
|
|
|
+ msgModify.add(obj);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ if(d2mType != null)
|
|
|
+ sendD2mMessage(d2mType, msgAdd, msgModify, msgRemove);
|
|
|
+
|
|
|
return expired;
|
|
|
}
|
|
|
|
|
|
+ private void sendD2mMessage(String objectType, List<?> msgAdd, List<?> msgModify, List<?> msgRemove){
|
|
|
+ D2mMessage message = new D2mMessage();
|
|
|
+ message.setItemType(objectType);
|
|
|
+ message.setAddItems(msgAdd);
|
|
|
+ message.setModifyItems(msgModify);
|
|
|
+ message.setRemoveItems(msgRemove);
|
|
|
+ syncModel.sendMessageToModel(message);
|
|
|
+ }
|
|
|
+
|
|
|
private List<String> buildExpiredIds(List<? extends IAdmEntity> expired){
|
|
|
if(expired.size() > 0) {
|
|
|
List<String> ids = new ArrayList<>();
|
|
@@ -433,4 +474,11 @@ public class SyncAppImpl implements ISyncApp {
|
|
|
return list;
|
|
|
}
|
|
|
|
|
|
+ private <T extends IAdmEntity> List<T> deserializeJsonProp(List<T> list){
|
|
|
+ for(IAdmEntity entity : list) {
|
|
|
+ entity.deserializeJsonProp();
|
|
|
+ }
|
|
|
+ return list;
|
|
|
+ }
|
|
|
+
|
|
|
}
|