|
@@ -82,39 +82,34 @@ public class AdmShaftController {
|
|
|
@PostMapping("/create")
|
|
|
public AdmResponse create(@RequestBody AdmCreateRequest<AdmShaft> createRequest, @QueryParam("projectId") String projectId) throws Exception {
|
|
|
List<AdmShaft> vos = CollUtil.newArrayList(createRequest.getContent());
|
|
|
+ List<AdmShaft> unRelationShaft = new ArrayList<>();
|
|
|
+ List<AdmShaft> admShafts = new ArrayList<>(vos.size());
|
|
|
+ List<RelationDTO> relationDTOS = new ArrayList<>(vos.size());
|
|
|
vos.stream().forEach(admShaft -> {
|
|
|
if (StrUtil.isEmpty(admShaft.getName())) {
|
|
|
admShaft.setName(ObjectNameUtil.objectName("竖井-"));
|
|
|
}
|
|
|
- });
|
|
|
- vos = service.doInsert(AdmContextUtil.toDmpContext(), AdmShaft.class, vos);
|
|
|
-
|
|
|
- //TODO 创建竖井和建筑的关系
|
|
|
- /*if (!entity.buildingList.isNullOrEmpty()){
|
|
|
- for (building in entity.buildingList!!) {
|
|
|
- try {
|
|
|
- val rShInBd = RShInBd()
|
|
|
- rShInBd.buildingId = building.id
|
|
|
- rShInBd.shaftId = entity.id
|
|
|
- rShInBd.projectId = entity.projectId
|
|
|
- rShInBd.type = "bd2sh"
|
|
|
- val insert = rShInBdService.insert(rShInBd)
|
|
|
- if (insert) {
|
|
|
- try {
|
|
|
- *//** 发送消息 *//*
|
|
|
- RService.rabbitMqService.sendRel(Opt.projectId!!, "sh2bd","11",rShInBd.buildingId!!,rShInBd.shaftId!!)
|
|
|
- } catch (e: Exception) {
|
|
|
- e.printStackTrace()
|
|
|
- }
|
|
|
+ if(CollUtil.isEmpty(admShaft.getBuildingList())){
|
|
|
+ unRelationShaft.add(admShaft);
|
|
|
+ }else{
|
|
|
+ //插入对象 添加关系
|
|
|
+ List<AdmShaft> shafts = service.doInsert(AdmContextUtil.toDmpContext(), AdmShaft.class, unRelationShaft);
|
|
|
+ admShaft.getBuildingList().stream().forEach(admBuilding ->{
|
|
|
+ if(StrUtil.isNotEmpty(admBuilding.getId())){
|
|
|
+ relationDTOS.add(new RelationDTO(null, "ArchSubset", "Bd2Sh", null, shafts.get(0).getId() , admBuilding.getId()));
|
|
|
}
|
|
|
- } catch (e: Exception) {
|
|
|
- e.printStackTrace()
|
|
|
- }
|
|
|
+ });
|
|
|
+ admShafts.addAll(shafts);
|
|
|
}
|
|
|
- }*/
|
|
|
-
|
|
|
-
|
|
|
- return AdmResponse.success(vos);
|
|
|
+ });
|
|
|
+ if(CollUtil.isNotEmpty(relationDTOS)){
|
|
|
+ relationService.doSave(AdmContextUtil.toDmpContext(), relationDTOS);
|
|
|
+ }
|
|
|
+ if(CollUtil.isNotEmpty(unRelationShaft)){
|
|
|
+ List shaftList = service.doInsert(AdmContextUtil.toDmpContext(), AdmShaft.class, unRelationShaft);
|
|
|
+ admShafts.addAll(shaftList);
|
|
|
+ }
|
|
|
+ return AdmResponse.success(admShafts);
|
|
|
}
|
|
|
|
|
|
/**
|