|
@@ -4,6 +4,7 @@ import cn.hutool.core.util.StrUtil;
|
|
|
import com.fasterxml.jackson.databind.node.JsonNodeFactory;
|
|
|
import com.fasterxml.jackson.databind.node.ObjectNode;
|
|
|
import com.persagy.dmp.basic.model.QueryCriteria;
|
|
|
+import com.persagy.dmp.common.context.AppContext;
|
|
|
import com.persagy.proxy.adm.constant.AdmRelationTypeEnum;
|
|
|
import com.persagy.proxy.object.model.AdmSpace;
|
|
|
import com.persagy.proxy.relation.model.UpDataFloorAndBuilding;
|
|
@@ -48,12 +49,16 @@ public class RelationFlAndBuController {
|
|
|
/**
|
|
|
* 修改空间和楼层建筑的关系
|
|
|
* spaceId 业务空间id,id 楼层或建筑id,type 业务空间的类型
|
|
|
+ *
|
|
|
+ * @param upDataFloorAndBuildings
|
|
|
+ * @return
|
|
|
*/
|
|
|
@PostMapping("/update-sp")
|
|
|
public AdmResponse spFloorAndBuilding(@RequestBody List<UpDataFloorAndBuilding> upDataFloorAndBuildings) {
|
|
|
if (CollectionUtils.isEmpty(upDataFloorAndBuildings)) {
|
|
|
- return AdmResponse.failure("修改内容不能为空");
|
|
|
+ return AdmResponse.failure("不可以传入空数据");
|
|
|
}
|
|
|
+
|
|
|
AdmRelationTypeEnum bd2sp = AdmRelationTypeEnum.BD2SP;
|
|
|
AdmRelationTypeEnum fl2sp = AdmRelationTypeEnum.FL2SP;
|
|
|
List<RelationDTO> voList = new ArrayList<>();
|
|
@@ -63,22 +68,25 @@ public class RelationFlAndBuController {
|
|
|
String id = upDataFloorAndBuilding.getId();
|
|
|
String spaceId = upDataFloorAndBuilding.getSpaceId();
|
|
|
idList.add(spaceId);
|
|
|
- if (id.startsWith("Bd")) {
|
|
|
- deleteByObjId(null, spaceId, null, bd2sp, context);
|
|
|
- RelationDTO relation = new RelationDTO(null, bd2sp.getGraphCode(), bd2sp.getRelCode(), null, id, spaceId);
|
|
|
- voList.add(relation);
|
|
|
- } else if (id.startsWith("Fl")) {
|
|
|
+ if (StrUtil.isBlank(id)) {
|
|
|
+ deleteByObjId(null, spaceId, null, bd2sp, context);
|
|
|
deleteByObjId(null, spaceId, null, fl2sp, context);
|
|
|
- RelationDTO relation = new RelationDTO(null, fl2sp.getGraphCode(), fl2sp.getRelCode(), null, id, spaceId);
|
|
|
- voList.add(relation);
|
|
|
- } else {
|
|
|
- deleteByObjId(null, spaceId, null, bd2sp, context);
|
|
|
- deleteByObjId(null, spaceId, null, fl2sp, context);
|
|
|
- }
|
|
|
+ } else {
|
|
|
+ if (id.startsWith("Bd")) {
|
|
|
+ deleteByObjId(null, spaceId, null, bd2sp, context);
|
|
|
+ RelationDTO relation = new RelationDTO(null, bd2sp.getGraphCode(), bd2sp.getRelCode(), null, id, spaceId);
|
|
|
+ voList.add(relation);
|
|
|
+ } else if (id.startsWith("Fl")) {
|
|
|
+ deleteByObjId(null, spaceId, null, fl2sp, context);
|
|
|
+ RelationDTO relation = new RelationDTO(null, fl2sp.getGraphCode(), fl2sp.getRelCode(), null, id, spaceId);
|
|
|
+ voList.add(relation);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
if (!CollectionUtils.isEmpty(voList)) {
|
|
|
service.doSave(context, voList);
|
|
|
}
|
|
|
+
|
|
|
String filter = " id in ('" + StrUtil.join("','", idList) + "') ";
|
|
|
AdmQueryCriteria criteria = new AdmQueryCriteria();
|
|
|
criteria.setFilters(filter);
|
|
@@ -86,7 +94,6 @@ public class RelationFlAndBuController {
|
|
|
List<AdmSpace> spaces = (List<AdmSpace>) rs.getContent();
|
|
|
Map<String, AdmSpace> admSpaceMap = spaces.stream().collect(Collectors.toMap(AdmSpace::getId, Function.identity()));
|
|
|
List<AdmSpace> updateSpace = new ArrayList<>();
|
|
|
- List<AdmSpace> deleteSpace = new ArrayList<>();
|
|
|
for (UpDataFloorAndBuilding upDataFloorAndBuilding : upDataFloorAndBuildings) {
|
|
|
String spaceId = upDataFloorAndBuilding.getSpaceId();
|
|
|
AdmSpace admSpace = admSpaceMap.get(spaceId);
|
|
@@ -94,24 +101,20 @@ public class RelationFlAndBuController {
|
|
|
continue;
|
|
|
}
|
|
|
String id = upDataFloorAndBuilding.getId();
|
|
|
- if (id.startsWith("Bd")) {
|
|
|
- admSpace.setBuildingId(id);
|
|
|
- updateSpace.add(admSpace);
|
|
|
- } else if (id.startsWith("Fl")) {
|
|
|
- admSpace.setFloorId(id);
|
|
|
- updateSpace.add(admSpace);
|
|
|
- } else {
|
|
|
- deleteSpace.add(admSpace);
|
|
|
- }
|
|
|
+ if (StrUtil.isNotBlank(id)) {
|
|
|
+ if (id.startsWith("Bd")) {
|
|
|
+ admSpace.setBuildingId(id);
|
|
|
+ updateSpace.add(admSpace);
|
|
|
+ } else if (id.startsWith("Fl")) {
|
|
|
+ admSpace.setFloorId(id);
|
|
|
+ updateSpace.add(admSpace);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
//更新空间
|
|
|
if (!CollectionUtils.isEmpty(updateSpace)) {
|
|
|
spaceService.doUpdate(context, AdmSpace.class, updateSpace);
|
|
|
}
|
|
|
- //删除空间
|
|
|
- if (!CollectionUtils.isEmpty(deleteSpace)) {
|
|
|
- spaceService.doDelete(context, deleteSpace);
|
|
|
- }
|
|
|
|
|
|
return AdmResponse.success();
|
|
|
}
|
|
@@ -130,9 +133,15 @@ public class RelationFlAndBuController {
|
|
|
ObjectNode node = JsonNodeFactory.instance.objectNode();
|
|
|
node.put("graphCode", typeEnum.getGraphCode());
|
|
|
node.put("relCode", typeEnum.getRelCode());
|
|
|
- node.put("relValue", type);
|
|
|
- node.put("objFrom", objFrom);
|
|
|
- node.put("objTo", objTo);
|
|
|
+ if (StrUtil.isNotBlank(type)) {
|
|
|
+ node.put("relValue", type);
|
|
|
+ }
|
|
|
+ if (StrUtil.isNotBlank(objFrom)) {
|
|
|
+ node.put("objFrom", objFrom);
|
|
|
+ }
|
|
|
+ if (StrUtil.isNotBlank(objTo)) {
|
|
|
+ node.put("objTo", objTo);
|
|
|
+ }
|
|
|
criteria.setCriteria(node);
|
|
|
service.doDelete(context, criteria);
|
|
|
}
|