|
@@ -25,7 +25,6 @@ import com.persagy.dmp.common.helper.SpringHelper;
|
|
|
import com.persagy.dmp.common.model.entity.BaseEntity;
|
|
|
import com.persagy.dmp.common.model.response.CommonResult;
|
|
|
import com.persagy.dmp.define.client.DigitalDefineFacade;
|
|
|
-import com.persagy.dmp.define.client.DigitalObjectInfoFacade;
|
|
|
import com.persagy.dmp.define.entity.ObjectInfoDefine;
|
|
|
import com.persagy.dmp.define.entity.ObjectTypeDefine;
|
|
|
import com.persagy.dmp.digital.client.DigitalObjectFacade;
|
|
@@ -35,6 +34,7 @@ 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.AdmCreateRequest;
|
|
|
+import com.persagy.proxy.adm.request.AdmCreateResponse;
|
|
|
import com.persagy.proxy.adm.request.AdmQueryCriteria;
|
|
|
import com.persagy.proxy.adm.request.AdmResponse;
|
|
|
import com.persagy.proxy.adm.service.IAdmRelationService;
|
|
@@ -50,7 +50,8 @@ import com.persagy.proxy.object.service.IAdmEquipmentService;
|
|
|
import com.persagy.proxy.report.service.IRelationReportService;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.poi.ss.usermodel.*;
|
|
|
-import org.apache.poi.xssf.usermodel.*;
|
|
|
+import org.apache.poi.xssf.usermodel.XSSFCellStyle;
|
|
|
+import org.apache.poi.xssf.usermodel.XSSFColor;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
@@ -103,10 +104,10 @@ public class AdmEquipmentController {
|
|
|
* @throws Exception
|
|
|
*/
|
|
|
@PostMapping("/create")
|
|
|
- public AdmResponse create(@RequestBody AdmCreateRequest<AdmEquipment> createRequest) throws Exception {
|
|
|
+ public AdmCreateResponse create(@RequestBody AdmCreateRequest<AdmEquipment> createRequest) throws Exception {
|
|
|
List<AdmEquipment> vos = CollUtil.newArrayList(createRequest.getContent());
|
|
|
if(CollUtil.isEmpty(vos)){
|
|
|
- return AdmResponse.success();
|
|
|
+ return AdmCreateResponse.success();
|
|
|
}
|
|
|
// 查询所有设备类型
|
|
|
AdmDict dictCond = AdmDict.builder().type(AdmDictCategoryEnum.EQUIPMENT.getValue()).build();
|
|
@@ -149,10 +150,12 @@ public class AdmEquipmentController {
|
|
|
}
|
|
|
}
|
|
|
if(CollUtil.isEmpty(filterVOs)){
|
|
|
- return AdmResponse.success();
|
|
|
+ return AdmCreateResponse.success();
|
|
|
}
|
|
|
filterVOs = service.doInsert(AdmContextUtil.toDmpContext(), AdmEquipment.class, filterVOs);
|
|
|
- return AdmResponse.success(filterVOs);
|
|
|
+ //处理关系
|
|
|
+ processRelations(filterVOs);
|
|
|
+ return AdmCreateResponse.success(filterVOs);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -165,6 +168,12 @@ public class AdmEquipmentController {
|
|
|
public AdmResponse delete( @RequestBody List<AdmEquipment> vos) throws Exception {
|
|
|
// 组装上下文条件
|
|
|
service.doDelete(AdmContextUtil.toDmpContext(), vos);
|
|
|
+ QueryCriteria queryCriteria = new QueryCriteria();
|
|
|
+ vos.forEach(vo -> {
|
|
|
+ /** 清除空间和建筑楼层的的数据 */
|
|
|
+ dealRelation(vo.getId(), queryCriteria, AdmRelationTypeEnum.EQ2BD.getRelCode());
|
|
|
+ dealRelation(vo.getId(), queryCriteria, AdmRelationTypeEnum.EQ2FL.getRelCode());
|
|
|
+ });
|
|
|
return AdmResponse.success();
|
|
|
}
|
|
|
|
|
@@ -351,10 +360,10 @@ public class AdmEquipmentController {
|
|
|
* @throws Exception
|
|
|
*/
|
|
|
@PostMapping("/creat-equip-pro")
|
|
|
- public AdmResponse createExt(@RequestBody AdmCreateRequest<AdmEquipment> admEquipment) throws Exception {
|
|
|
+ public AdmCreateResponse createExt(@RequestBody AdmCreateRequest<AdmEquipment> admEquipment) throws Exception {
|
|
|
List<AdmEquipment> vos = admEquipment.getContent();
|
|
|
if(CollUtil.isEmpty(vos)){
|
|
|
- return AdmResponse.success();
|
|
|
+ return AdmCreateResponse.success();
|
|
|
}
|
|
|
//创建设备
|
|
|
vos.stream().forEach(equipment -> {
|
|
@@ -388,7 +397,7 @@ public class AdmEquipmentController {
|
|
|
reVos.addAll(vosR);
|
|
|
});
|
|
|
relationService.doSave(AdmContextUtil.toDmpContext(),relationDTOS);
|
|
|
- return AdmResponse.success(reVos);
|
|
|
+ return AdmCreateResponse.success(reVos);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -1105,4 +1114,37 @@ public class AdmEquipmentController {
|
|
|
this.setColor(workbook,56,94,15,createCell);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 添加绑定关系
|
|
|
+ */
|
|
|
+ private void processRelations(List<AdmEquipment> vosR){
|
|
|
+ if(CollUtil.isNotEmpty(vosR)) {
|
|
|
+ List<RelationDTO> relationDTOS = new ArrayList<>(vosR.size());
|
|
|
+ vosR.forEach(admEquipment -> {
|
|
|
+ if (StrUtil.isNotEmpty(admEquipment.getBuildingId())) {
|
|
|
+ relationDTOS.add(new RelationDTO(null, AdmRelationTypeEnum.EQ2BD.getGraphCode(), AdmRelationTypeEnum.EQ2BD.getRelCode(), admEquipment.getClassCode(), admEquipment.getId(), admEquipment.getBuildingId()));
|
|
|
+ }
|
|
|
+ if (StrUtil.isNotEmpty(admEquipment.getFloorId())) {
|
|
|
+ relationDTOS.add(new RelationDTO(null, AdmRelationTypeEnum.EQ2FL.getGraphCode(), AdmRelationTypeEnum.EQ2FL.getRelCode(), admEquipment.getClassCode(), admEquipment.getId(),admEquipment.getFloorId()));
|
|
|
+ }
|
|
|
+ });
|
|
|
+ if (CollUtil.isNotEmpty(relationDTOS)) {
|
|
|
+ relationService.doSave(AdmContextUtil.toDmpContext(), relationDTOS);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 删除关系
|
|
|
+ * @param euipId
|
|
|
+ * @param queryCriteria
|
|
|
+ * @param relCode
|
|
|
+ */
|
|
|
+ private void dealRelation(String euipId, QueryCriteria queryCriteria, String relCode){
|
|
|
+ ObjectNode rBd = JsonNodeFactory.instance.objectNode();
|
|
|
+ rBd.put("objFrom",euipId);
|
|
|
+ rBd.put("relCode",relCode);
|
|
|
+ queryCriteria.setCriteria(rBd);
|
|
|
+ relationService.doDelete(AdmContextUtil.toDmpContext(), queryCriteria);
|
|
|
+ }
|
|
|
}
|