|
@@ -79,6 +79,7 @@ public class SyncOldAdmImpl implements ISyncOldAdm {
|
|
|
transEntities(spObjs, spList, (spObj, oSp) -> setSpData(spObj, (OSpace) oSp));
|
|
|
transEntities(eqObjs, eqList, (eqObj, oEq) -> setEqData(eqObj, (OEquip) oEq));
|
|
|
|
|
|
+ Map<String, String> floorIdMap = new HashMap<>();
|
|
|
List<AdmObject> dbBds = objectService.queryM2dByObjType(projectId, AdmConst.OBJ_TYPE_BUILDING);
|
|
|
List<AdmObject> dbFls = objectService.queryM2dByObjType(projectId, AdmConst.OBJ_TYPE_FLOOR);
|
|
|
List<AdmObject> dbSps = objectService.queryM2dByObjType(projectId, AdmConst.OBJ_TYPE_SPACE);
|
|
@@ -86,10 +87,10 @@ public class SyncOldAdmImpl implements ISyncOldAdm {
|
|
|
|
|
|
List<AdmObject>[] operations = new List[]{new ArrayList<>(), new ArrayList<>()};
|
|
|
|
|
|
- syncObjs(bdObjs, dbBds, operations, 1);
|
|
|
- syncObjs(flObjs, dbFls, operations, 2);
|
|
|
- syncObjs(spObjs, dbSps, operations, 3);
|
|
|
- syncObjs(eqObjs, dbEqs, operations, 4);
|
|
|
+ syncObjs(bdObjs, dbBds, operations, 1, floorIdMap);
|
|
|
+ syncObjs(flObjs, dbFls, operations, 2, floorIdMap);
|
|
|
+ syncObjs(spObjs, dbSps, operations, 3, floorIdMap);
|
|
|
+ syncObjs(eqObjs, dbEqs, operations, 4, floorIdMap);
|
|
|
|
|
|
objectService.insert(operations[0]);
|
|
|
objectService.update(operations[1]);
|
|
@@ -107,7 +108,7 @@ public class SyncOldAdmImpl implements ISyncOldAdm {
|
|
|
}
|
|
|
|
|
|
//TODO 设备同步时,按正逆向规则过滤
|
|
|
- private void syncObjs(List<AdmObject> objs, List<AdmObject> dbItems, List<AdmObject>[] operations, int objMark){
|
|
|
+ private void syncObjs(List<AdmObject> objs, List<AdmObject> dbItems, List<AdmObject>[] operations, int objMark, Map<String, String> floorIdMap){
|
|
|
HashMap<String, AdmObject> dbMap = new HashMap<>();
|
|
|
for (AdmObject dbItem : dbItems){
|
|
|
dbMap.put(getFixedIdForSync(dbItem, objMark), dbItem);
|
|
@@ -118,11 +119,24 @@ public class SyncOldAdmImpl implements ISyncOldAdm {
|
|
|
if(dbItem == null) {
|
|
|
obj.setD2mState(ValidEnum.TRUE.getType());
|
|
|
obj.setDeliveryState(ValidEnum.FALSE.getType());
|
|
|
+
|
|
|
+ if(objMark == 3 || objMark == 4) { //新增空间|设备
|
|
|
+ if(floorIdMap.size() > 0){
|
|
|
+ String fixedFloorId = floorIdMap.get(obj.getFloorId());
|
|
|
+ if(fixedFloorId != null)
|
|
|
+ obj.setFloorId(fixedFloorId);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
operations[0].add(obj); //add
|
|
|
} else {
|
|
|
AdmObject updateItem = mergeObj(obj, dbItem, objMark);
|
|
|
if(updateItem != null)
|
|
|
operations[1].add(updateItem); //modify
|
|
|
+
|
|
|
+ if(objMark == 2 && !obj.getId().equals(dbItem.getId())) {
|
|
|
+ floorIdMap.put(obj.getId(), dbItem.getId());
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|