| | |
| | | import com.gkhy.safePlatform.commons.vo.ResultVO; |
| | | import com.gkhy.safePlatform.commons.vo.SearchResultVO; |
| | | import com.gkhy.safePlatform.equipment.entity.*; |
| | | import com.gkhy.safePlatform.equipment.enums.EquipmentLifeCycleEnum; |
| | | import com.gkhy.safePlatform.equipment.enums.EquipmentRepairStatusEnum; |
| | | import com.gkhy.safePlatform.equipment.enums.EquipmentResultCodes; |
| | | import com.gkhy.safePlatform.equipment.enums.EquipmentStopStatusEnum; |
| | | import com.gkhy.safePlatform.equipment.excepiton.EquipmentException; |
| | | import com.gkhy.safePlatform.equipment.model.dto.req.*; |
| | | import com.gkhy.safePlatform.equipment.model.dto.resp.EquipmentInfoDto; |
| | |
| | | |
| | | @Override |
| | | public void addOrUpdate(EquipmentInfoSaveOrUpdate infoDto) { |
| | | |
| | | // 验证枚举 |
| | | checkEnum(infoDto); |
| | | |
| | | if(infoDto.getInfoType() == null || infoDto.getEquipmentTypeId() == null){ |
| | | throw new EquipmentException(ResultCodes.CLIENT_PARAM_ILLEGAL); |
| | | } |
| | |
| | | |
| | | //保存设备保养 |
| | | List<EquipmentTakecareDetail> takecareDetailList = infoDto.getTakecareDetailList(); |
| | | takecareDetailList.forEach(f->{ |
| | | f.setEquipmentId(equipmentInfo.getId()); |
| | | f.setInfoTpe(equipmentInfo.getInfoType()); |
| | | }); |
| | | equipmentTakecareDetailBaseService.saveOrUpdateBatch(takecareDetailList); |
| | | if(StringUtils.hasText(infoDto.getDelTakecareDetails())){ |
| | | List<Long> idList = Arrays.stream(infoDto.getDelTakecareDetails().split(",")).map(s-> Long.parseLong(s.trim())) |
| | | .collect(Collectors.toList()); |
| | | |
| | | List<EquipmentTakecareDetail> delList = new ArrayList<>(); |
| | | idList.forEach(f->{ |
| | | EquipmentTakecareDetail info = new EquipmentTakecareDetail(); |
| | | info.setDelFlag(1); |
| | | info.setId(f); |
| | | delList.add(info); |
| | | if(takecareDetailList != null && !takecareDetailList.isEmpty()){ |
| | | takecareDetailList.forEach(f->{ |
| | | f.setEquipmentId(equipmentInfo.getId()); |
| | | f.setInfoTpe(equipmentInfo.getInfoType()); |
| | | }); |
| | | equipmentTakecareDetailBaseService.updateBatchById(delList); |
| | | equipmentTakecareDetailBaseService.saveOrUpdateBatch(takecareDetailList); |
| | | } |
| | | if(infoDto.getTakecareDetailList() != null){ |
| | | if(StringUtils.hasText(infoDto.getDelTakecareDetails())){ |
| | | List<Long> idList = Arrays.stream(infoDto.getDelTakecareDetails().split(",")).map(s-> Long.parseLong(s.trim())) |
| | | .collect(Collectors.toList()); |
| | | |
| | | if(idList != null && !idList.isEmpty()){ |
| | | List<EquipmentTakecareDetail> delList = new ArrayList<>(); |
| | | idList.forEach(f->{ |
| | | EquipmentTakecareDetail info = new EquipmentTakecareDetail(); |
| | | info.setDelFlag(1); |
| | | info.setId(f); |
| | | delList.add(info); |
| | | }); |
| | | equipmentTakecareDetailBaseService.updateBatchById(delList); |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | //保存设备检测 |
| | | List<EquipmentTestDetail> testDetailList = infoDto.getTestDetailList(); |
| | | testDetailList.forEach(f->{ |
| | | f.setEquipmentId(equipmentInfo.getId()); |
| | | f.setInfoTpe(equipmentInfo.getInfoType()); |
| | | }); |
| | | equipmentTestDetailBaseService.saveOrUpdateBatch(testDetailList); |
| | | if(StringUtils.hasText(infoDto.getDelTestDetails())){ |
| | | List<Long> idList = Arrays.stream(infoDto.getDelTestDetails().split(",")).map(s-> Long.parseLong(s.trim())) |
| | | .collect(Collectors.toList()); |
| | | List<EquipmentTestDetail> delList = new ArrayList<>(); |
| | | idList.forEach(f->{ |
| | | EquipmentTestDetail info = new EquipmentTestDetail(); |
| | | info.setDelFlag(1); |
| | | info.setId(f); |
| | | delList.add(info); |
| | | if(testDetailList != null && !testDetailList.isEmpty()){ |
| | | testDetailList.forEach(f->{ |
| | | f.setEquipmentId(equipmentInfo.getId()); |
| | | f.setInfoTpe(equipmentInfo.getInfoType()); |
| | | }); |
| | | equipmentTestDetailBaseService.updateBatchById(delList); |
| | | equipmentTestDetailBaseService.saveOrUpdateBatch(testDetailList); |
| | | } |
| | | if(infoDto.getDelTestDetails() != null && !infoDto.getDelTestDetails().isEmpty()){ |
| | | if(StringUtils.hasText(infoDto.getDelTestDetails())){ |
| | | List<Long> idList = Arrays.stream(infoDto.getDelTestDetails().split(",")).map(s-> Long.parseLong(s.trim())) |
| | | .collect(Collectors.toList()); |
| | | List<EquipmentTestDetail> delList = new ArrayList<>(); |
| | | idList.forEach(f->{ |
| | | EquipmentTestDetail info = new EquipmentTestDetail(); |
| | | info.setDelFlag(1); |
| | | info.setId(f); |
| | | delList.add(info); |
| | | }); |
| | | equipmentTestDetailBaseService.updateBatchById(delList); |
| | | } |
| | | } |
| | | |
| | | //设备检查 TODO |
| | |
| | | |
| | | //保存设备维修 |
| | | List<EquipmentRepairDetail> repaireDetailList = infoDto.getRepaireDetailList(); |
| | | repaireDetailList.forEach(f->{ |
| | | f.setEquipmentId(equipmentInfo.getId()); |
| | | f.setInfoTpe(equipmentInfo.getInfoType()); |
| | | }); |
| | | equipmentRepairDetailBaseService.saveOrUpdateBatch(repaireDetailList); |
| | | if(StringUtils.hasText(infoDto.getDelRepaireDetails())){ |
| | | List<Long> idList = Arrays.stream(infoDto.getDelRepaireDetails().split(",")).map(s-> Long.parseLong(s.trim())) |
| | | .collect(Collectors.toList()); |
| | | List<EquipmentRepairDetail> delList = new ArrayList<>(); |
| | | idList.forEach(f->{ |
| | | EquipmentRepairDetail info = new EquipmentRepairDetail(); |
| | | info.setDelFlag(1); |
| | | info.setId(f); |
| | | delList.add(info); |
| | | if(repaireDetailList != null && !repaireDetailList.isEmpty()){ |
| | | repaireDetailList.forEach(f->{ |
| | | f.setEquipmentId(equipmentInfo.getId()); |
| | | f.setInfoTpe(equipmentInfo.getInfoType()); |
| | | }); |
| | | equipmentRepairDetailBaseService.updateBatchById(delList); |
| | | equipmentRepairDetailBaseService.saveOrUpdateBatch(repaireDetailList); |
| | | } |
| | | if(infoDto.getDelRepaireDetails() != null && !infoDto.getDelRepaireDetails().isEmpty()){ |
| | | if(StringUtils.hasText(infoDto.getDelRepaireDetails())){ |
| | | List<Long> idList = Arrays.stream(infoDto.getDelRepaireDetails().split(",")).map(s-> Long.parseLong(s.trim())) |
| | | .collect(Collectors.toList()); |
| | | List<EquipmentRepairDetail> delList = new ArrayList<>(); |
| | | idList.forEach(f->{ |
| | | EquipmentRepairDetail info = new EquipmentRepairDetail(); |
| | | info.setDelFlag(1); |
| | | info.setId(f); |
| | | delList.add(info); |
| | | }); |
| | | equipmentRepairDetailBaseService.updateBatchById(delList); |
| | | } |
| | | } |
| | | |
| | | |
| | | //保存检查标准 |
| | | List<EquipmentCheckStandardDetail> checkStandardeDetailList = infoDto.getCheckStandardeDetailList(); |
| | | checkStandardeDetailList.forEach(f->{ |
| | | f.setEquipmentId(equipmentInfo.getId()); |
| | | f.setInfoTpe(equipmentInfo.getInfoType()); |
| | | }); |
| | | equipmentCheckStandardDetailBaseService.saveOrUpdateBatch(checkStandardeDetailList); |
| | | if(StringUtils.hasText(infoDto.getDelCheckStandardeDetails())){ |
| | | List<Long> idList = Arrays.stream(infoDto.getDelCheckStandardeDetails().split(",")).map(s-> Long.parseLong(s.trim())) |
| | | .collect(Collectors.toList()); |
| | | List<EquipmentCheckStandardDetail> delList = new ArrayList<>(); |
| | | idList.forEach(f->{ |
| | | EquipmentCheckStandardDetail info = new EquipmentCheckStandardDetail(); |
| | | info.setDelFlag(1); |
| | | info.setId(f); |
| | | delList.add(info); |
| | | if(checkStandardeDetailList != null && !checkStandardeDetailList.isEmpty()){ |
| | | checkStandardeDetailList.forEach(f->{ |
| | | f.setEquipmentId(equipmentInfo.getId()); |
| | | f.setInfoTpe(equipmentInfo.getInfoType()); |
| | | }); |
| | | equipmentCheckStandardDetailBaseService.updateBatchById(delList); |
| | | equipmentCheckStandardDetailBaseService.saveOrUpdateBatch(checkStandardeDetailList); |
| | | } |
| | | if(infoDto.getDelCheckStandardeDetails() != null && !infoDto.getDelCheckStandardeDetails().isEmpty()){ |
| | | if(StringUtils.hasText(infoDto.getDelCheckStandardeDetails())){ |
| | | List<Long> idList = Arrays.stream(infoDto.getDelCheckStandardeDetails().split(",")).map(s-> Long.parseLong(s.trim())) |
| | | .collect(Collectors.toList()); |
| | | List<EquipmentCheckStandardDetail> delList = new ArrayList<>(); |
| | | idList.forEach(f->{ |
| | | EquipmentCheckStandardDetail info = new EquipmentCheckStandardDetail(); |
| | | info.setDelFlag(1); |
| | | info.setId(f); |
| | | delList.add(info); |
| | | }); |
| | | equipmentCheckStandardDetailBaseService.updateBatchById(delList); |
| | | } |
| | | } |
| | | |
| | | |
| | | //保存保养标准 |
| | | List<EquipmentTakecareStardardDetail> takecareStardardeDetailList = infoDto.getTakecareStardardeDetailList(); |
| | | takecareStardardeDetailList.forEach(f->{ |
| | | f.setEquipmentId(equipmentInfo.getId()); |
| | | f.setInfoTpe(equipmentInfo.getInfoType()); |
| | | }); |
| | | equipmentTakecareStardardDetailBaseService.saveOrUpdateBatch(takecareStardardeDetailList); |
| | | if(StringUtils.hasText(infoDto.getDelTakecareStardardeDetails())){ |
| | | List<Long> idList = Arrays.stream(infoDto.getDelTakecareStardardeDetails().split(",")).map(s-> Long.parseLong(s.trim())) |
| | | .collect(Collectors.toList()); |
| | | List<EquipmentTakecareStardardDetail> delList = new ArrayList<>(); |
| | | idList.forEach(f->{ |
| | | EquipmentTakecareStardardDetail info = new EquipmentTakecareStardardDetail(); |
| | | info.setDelFlag(1); |
| | | info.setId(f); |
| | | delList.add(info); |
| | | if(takecareStardardeDetailList != null && !takecareStardardeDetailList.isEmpty()){ |
| | | takecareStardardeDetailList.forEach(f->{ |
| | | f.setEquipmentId(equipmentInfo.getId()); |
| | | f.setInfoTpe(equipmentInfo.getInfoType()); |
| | | }); |
| | | equipmentTakecareStardardDetailBaseService.updateBatchById(delList); |
| | | equipmentTakecareStardardDetailBaseService.saveOrUpdateBatch(takecareStardardeDetailList); |
| | | } |
| | | |
| | | if(infoDto.getDelTakecareStardardeDetails() != null && !infoDto.getDelTakecareStardardeDetails().isEmpty()){ |
| | | if(StringUtils.hasText(infoDto.getDelTakecareStardardeDetails())){ |
| | | List<Long> idList = Arrays.stream(infoDto.getDelTakecareStardardeDetails().split(",")).map(s-> Long.parseLong(s.trim())) |
| | | .collect(Collectors.toList()); |
| | | List<EquipmentTakecareStardardDetail> delList = new ArrayList<>(); |
| | | idList.forEach(f->{ |
| | | EquipmentTakecareStardardDetail info = new EquipmentTakecareStardardDetail(); |
| | | info.setDelFlag(1); |
| | | info.setId(f); |
| | | delList.add(info); |
| | | }); |
| | | equipmentTakecareStardardDetailBaseService.updateBatchById(delList); |
| | | } |
| | | } |
| | | |
| | | } |
| | | |
| | |
| | | ExcelUtil.exportExcel(map,respList , response.getOutputStream(),DateUtils.PATTERN_STANDARD); |
| | | response.getOutputStream().close(); |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 枚举验证 |
| | | * @param infoDto |
| | | */ |
| | | public void checkEnum(EquipmentInfoSaveOrUpdate infoDto){ |
| | | if (EquipmentLifeCycleEnum.getByCode(infoDto.getLifeCycle()) == null) { |
| | | throw new EquipmentException(EquipmentResultCodes.EQUIPMENT_ENUM_LIFE_CYCLE_NOT_EXIST); |
| | | } |
| | | |
| | | if (EquipmentRepairStatusEnum.getByCode(infoDto.getRepairStatus()) == null) { |
| | | throw new EquipmentException(EquipmentResultCodes.EQUIPMENT_ENUM_STOP_STATUS_NOT_EXIST); |
| | | } |
| | | |
| | | if (EquipmentStopStatusEnum.getByCode(infoDto.getStopStatus()) == null) { |
| | | throw new EquipmentException(EquipmentResultCodes.EQUIPMENT_ENUM_REPAIR_STATUS_NOT_EXIST); |
| | | } |
| | | } |
| | | } |