|
@@ -4,8 +4,6 @@ import cn.hutool.core.collection.CollUtil;
|
|
|
import cn.hutool.core.collection.CollectionUtil;
|
|
|
import cn.hutool.core.date.DateUtil;
|
|
|
import cn.hutool.core.io.IoUtil;
|
|
|
-import cn.hutool.core.map.MapUtil;
|
|
|
-import cn.hutool.core.util.IdUtil;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
import cn.hutool.json.JSONUtil;
|
|
|
import cn.hutool.poi.excel.ExcelReader;
|
|
@@ -31,7 +29,6 @@ import com.persagy.dmp.define.entity.ObjectTypeDefine;
|
|
|
import com.persagy.dmp.digital.client.DigitalObjectFacade;
|
|
|
import com.persagy.dmp.simple.client.DigitalObjectSimpleFacade;
|
|
|
import com.persagy.proxy.adm.constant.AdmCommonConstant;
|
|
|
-import com.persagy.proxy.adm.constant.AdmDictCategoryEnum;
|
|
|
import com.persagy.proxy.adm.constant.AdmRelationTypeEnum;
|
|
|
import com.persagy.proxy.adm.request.*;
|
|
|
import com.persagy.proxy.adm.service.IAdmRelationService;
|
|
@@ -41,8 +38,6 @@ import com.persagy.proxy.adm.utils.AdmQueryCriteriaHelper;
|
|
|
import com.persagy.proxy.adm.utils.ObjectNameUtil;
|
|
|
import com.persagy.proxy.common.entity.InstanceUrlParam;
|
|
|
import com.persagy.proxy.common.entity.RelationDTO;
|
|
|
-import com.persagy.proxy.dictionary.model.AdmDict;
|
|
|
-import com.persagy.proxy.dictionary.model.AdmObjectType;
|
|
|
import com.persagy.proxy.dictionary.service.IAdmDictService;
|
|
|
import com.persagy.proxy.object.model.AdmEquipment;
|
|
|
import com.persagy.proxy.object.model.AdmProject;
|
|
@@ -115,51 +110,8 @@ public class AdmEquipmentController {
|
|
|
if(CollUtil.isEmpty(vos)){
|
|
|
return AdmCreateResponse.success();
|
|
|
}
|
|
|
- // 查询所有设备类型
|
|
|
- AdmDict dictCond = AdmDict.builder().type(AdmDictCategoryEnum.EQUIPMENT.getValue()).build();
|
|
|
- AdmResponse dictResponse = dictService.queryCategory(AdmContextUtil.toDmpContext(), dictCond, AdmObjectType.class);
|
|
|
- List<AdmObjectType> dicts = (List<AdmObjectType>) dictResponse.getContent();
|
|
|
- // 转换为Map,key为编码后4位。用于适配旧类型编码
|
|
|
- Map<String, AdmObjectType> shortDictMap = new HashMap<>();
|
|
|
- Map<String, AdmObjectType> fullDictMap = new HashMap<>();
|
|
|
- for(int i = 0,j = CollUtil.size(dicts);i < j;i++) {
|
|
|
- AdmObjectType dict = dicts.get(i);
|
|
|
- shortDictMap.put(StrUtil.subSufByLength(dict.getCode(), 4), dict);
|
|
|
- fullDictMap.put(dict.getCode(), dict);
|
|
|
- }
|
|
|
- // 设备属性调整
|
|
|
- List<AdmEquipment> filterVOs = new ArrayList<>();
|
|
|
- for(AdmEquipment equipment:vos) {
|
|
|
- // 如果不是Eq开头,则重新生成ID
|
|
|
- if(StrUtil.startWith(equipment.getId(), "Eq")) {
|
|
|
- equipment.setId("Eq"+ IdUtil.simpleUUID());
|
|
|
- }
|
|
|
- // 类型编码适配
|
|
|
- String classCode = equipment.getClassCode();
|
|
|
- // 如果编码为空,或在4位、6位里都不存在,则报错
|
|
|
- if(StrUtil.isBlank(classCode) ||
|
|
|
- (shortDictMap.get(classCode) == null && fullDictMap.get(classCode) == null)) {
|
|
|
- log.error(StrUtil.format("没有找到对象类型【{}】!", equipment.getClassCode()));
|
|
|
- continue;
|
|
|
- }
|
|
|
- filterVOs.add(equipment);
|
|
|
- // 如果少于6位,则需要适配新编码
|
|
|
- if(classCode.length() < 6) {
|
|
|
- AdmObjectType dict = MapUtil.get(shortDictMap, classCode, AdmObjectType.class);
|
|
|
- equipment.setClassCode(dict.getCode());
|
|
|
- }
|
|
|
- // 如果名称为空,则提供默认名称
|
|
|
- if (StrUtil.isEmpty(equipment.getName())){
|
|
|
- AdmObjectType dict = MapUtil.get(fullDictMap, equipment.getClassCode(), AdmObjectType.class);
|
|
|
- String preName = dict == null ? "设备" : dict.getName();
|
|
|
- equipment.setName(ObjectNameUtil.objectName(preName + "-"));
|
|
|
- }
|
|
|
- }
|
|
|
- if(CollUtil.isEmpty(filterVOs)){
|
|
|
- return AdmCreateResponse.success();
|
|
|
- }
|
|
|
- filterVOs = service.doInsert(AdmContextUtil.toDmpContext(), AdmEquipment.class, filterVOs);
|
|
|
- return AdmCreateResponse.success(filterVOs);
|
|
|
+ vos = service.doInsert(AdmContextUtil.toDmpContext(), AdmEquipment.class, vos);
|
|
|
+ return AdmCreateResponse.success(vos);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -187,20 +139,6 @@ public class AdmEquipmentController {
|
|
|
if(CollUtil.isEmpty(vos)) {
|
|
|
return AdmResponse.success(vos);
|
|
|
}
|
|
|
- for(AdmEquipment vo:vos) {
|
|
|
- if(StrUtil.isNotBlank(vo.getFlowBuild())) {
|
|
|
- // 处理建筑-楼层信息点
|
|
|
- List<String> flows = StrUtil.splitTrim(vo.getFlowBuild(), "-");
|
|
|
- for(String flow:flows) {
|
|
|
- if(StrUtil.startWith(flow, "Bd")) {
|
|
|
- vo.setBuildingId(flow);
|
|
|
- } else if(StrUtil.startWith(flow, "fl")) {
|
|
|
- vo.setFloorId(flow);
|
|
|
- }
|
|
|
- }
|
|
|
- vo.setFlowBuild(null);
|
|
|
- }
|
|
|
- }
|
|
|
vos = service.doUpdate(AdmContextUtil.toDmpContext(), AdmEquipment.class, vos);
|
|
|
return AdmResponse.success(vos);
|
|
|
}
|