|
@@ -9,8 +9,10 @@ import com.persagy.proxy.adm.request.AdmCreateRequest;
|
|
|
import com.persagy.proxy.adm.request.AdmQueryCriteria;
|
|
|
import com.persagy.proxy.adm.request.AdmResponse;
|
|
|
import com.persagy.proxy.adm.service.IAdmEquipmentService;
|
|
|
+import com.persagy.proxy.adm.service.IAdmRelationService;
|
|
|
import com.persagy.proxy.adm.utils.AdmContextUtil;
|
|
|
import com.persagy.proxy.adm.utils.ObjectNameUtil;
|
|
|
+import com.persagy.proxy.common.entity.RelationDTO;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
@@ -28,6 +30,8 @@ import java.util.List;
|
|
|
public class AdmEquipmentController {
|
|
|
@Autowired
|
|
|
private IAdmEquipmentService service;
|
|
|
+ @Autowired
|
|
|
+ private IAdmRelationService relationService;
|
|
|
|
|
|
/**
|
|
|
* 统计
|
|
@@ -175,7 +179,7 @@ public class AdmEquipmentController {
|
|
|
*/
|
|
|
@PostMapping("/creat-equip-pro")
|
|
|
public AdmResponse createExt(@RequestBody AdmCreateRequest<AdmEquipment> admEquipment) throws Exception {
|
|
|
- List<AdmEquipment> vos = CollUtil.newArrayList(admEquipment.getContent());
|
|
|
+ List<AdmEquipment> vos = admEquipment.getContent();
|
|
|
if(CollUtil.isEmpty(vos)){
|
|
|
return AdmResponse.success();
|
|
|
}
|
|
@@ -185,8 +189,33 @@ public class AdmEquipmentController {
|
|
|
equipment.setName(ObjectNameUtil.objectName("设备-"));
|
|
|
}
|
|
|
});
|
|
|
- vos = service.doInsertExt(AdmContextUtil.toDmpContext(), AdmEquipment.class, vos);
|
|
|
- return AdmResponse.success(vos);
|
|
|
+ List<AdmEquipment> reVos = new ArrayList<>(vos.size());
|
|
|
+ List<RelationDTO> relationDTOS = new ArrayList<>(16);
|
|
|
+ vos.stream().forEach(admEq -> {
|
|
|
+ //创建设备
|
|
|
+ List<AdmEquipment> vosR = service.doInsert(AdmContextUtil.toDmpContext(), AdmEquipment.class, CollUtil.newArrayList(admEq));
|
|
|
+ //TODO 创建资产
|
|
|
+ //添加设备和系统、建筑、楼层的关系
|
|
|
+ if(CollUtil.isNotEmpty(vosR)){
|
|
|
+ String equipId = vosR.get(0).getId();
|
|
|
+ if(StrUtil.isNotEmpty(equipId)){
|
|
|
+ if(CollUtil.isNotEmpty(admEq.getLinkSystem())){
|
|
|
+ admEq.getLinkSystem().stream().forEach(admSystem -> {
|
|
|
+ relationDTOS.add(new RelationDTO(null, "MechSubset", "Sy2Eq", null , admSystem.getId(), equipId));
|
|
|
+ });
|
|
|
+ }
|
|
|
+ if(StrUtil.isNotEmpty(admEq.getBuildingId())){
|
|
|
+ relationDTOS.add(new RelationDTO(null, "MechInArch", "Eq2Bd", null , equipId, admEq.getBuildingId()));
|
|
|
+ }
|
|
|
+ if(StrUtil.isNotEmpty(admEq.getFloorId())){
|
|
|
+ relationDTOS.add(new RelationDTO(null, "MechInArch", "Eq2Fl", null , equipId, admEq.getBuildingId()));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ reVos.addAll(vosR);
|
|
|
+ });
|
|
|
+ relationService.doSave(AdmContextUtil.toDmpContext(),relationDTOS);
|
|
|
+ return AdmResponse.success(reVos);
|
|
|
}
|
|
|
|
|
|
|