| | |
| | | import com.gkhy.safePlatform.commons.vo.ResultVO; |
| | | import com.gkhy.safePlatform.commons.vo.SearchResultVO; |
| | | import com.gkhy.safePlatform.incidentManage.entity.*; |
| | | import com.gkhy.safePlatform.incidentManage.enums.AccidentReportGradeEnum; |
| | | import com.gkhy.safePlatform.incidentManage.enums.AccidentReportLevelEnum; |
| | | import com.gkhy.safePlatform.incidentManage.enums.AccidentReportTypeEnum; |
| | | import com.gkhy.safePlatform.incidentManage.enums.AccidentResultCodes; |
| | | import com.gkhy.safePlatform.incidentManage.exception.AccidentException; |
| | | import com.gkhy.safePlatform.incidentManage.model.dto.req.AccidentReportFileReqDTO; |
| | | import com.gkhy.safePlatform.incidentManage.model.dto.req.AccidentReportReqDTO; |
| | | import com.gkhy.safePlatform.incidentManage.model.dto.resp.AccidentReportCountRespDTO; |
| | | import com.gkhy.safePlatform.incidentManage.model.dto.resp.AccidentReportDetailRespDTO; |
| | | import com.gkhy.safePlatform.incidentManage.model.dto.resp.AccidentReportFileRespDTO; |
| | | import com.gkhy.safePlatform.incidentManage.model.dto.resp.AccidentReportPageRespDTO; |
| | | import com.gkhy.safePlatform.incidentManage.model.dto.resp.*; |
| | | import com.gkhy.safePlatform.incidentManage.query.AccidentReportQuery; |
| | | import com.gkhy.safePlatform.incidentManage.query.AccidentReportRPCQuery; |
| | | import com.gkhy.safePlatform.incidentManage.query.db.AccidentReportDBQuery; |
| | | import com.gkhy.safePlatform.incidentManage.query.db.AccidentReportRPCDBQuery; |
| | | import com.gkhy.safePlatform.incidentManage.service.AccidentReportService; |
| | | import com.gkhy.safePlatform.incidentManage.service.baseService.AccidentExpressFileInfoService; |
| | | import com.gkhy.safePlatform.incidentManage.service.baseService.AccidentExpressInfoService; |
| | | import com.gkhy.safePlatform.incidentManage.service.baseService.AccidentReportFileInfoService; |
| | | import com.gkhy.safePlatform.incidentManage.service.baseService.AccidentReportInfoService; |
| | | import com.gkhy.safePlatform.incidentManage.utils.TimeUtils; |
| | | import org.apache.dubbo.config.annotation.DubboReference; |
| | | import org.checkerframework.checker.units.qual.A; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.util.CollectionUtils; |
| | | |
| | | import java.text.ParseException; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | |
| | | |
| | | @Autowired |
| | | private AccidentExpressInfoService accidentExpressInfoService; |
| | | |
| | | @Autowired |
| | | private AccidentExpressFileInfoService accidentExpressFileInfoService; |
| | | |
| | | |
| | | @Override |
| | |
| | | public ResultVO addAccidentReport(Long uid, AccidentReportReqDTO accidentReportReqDTO) { |
| | | //必填项验证 |
| | | checkRequired(accidentReportReqDTO); |
| | | // 验证枚举 |
| | | checkEnum(accidentReportReqDTO); |
| | | |
| | | Date nowDate = new Date(); |
| | | //1.新增事故报告 |
| | |
| | | throw new AccidentException(AccidentResultCodes.ACCIDENT_REPORT_NOT_EXIST); |
| | | } else { |
| | | BeanUtils.copyProperties(AccidentReportInfoDetailDO, AccidentReportDetailRespDTO); |
| | | //查找对应的附件 |
| | | //查找事故报告对应的附件 |
| | | List<AccidentReportFileInfoDO> AccidentReportFileInfoDOList = accidentReportFileInfoService.selectByAccidentReportId(id); |
| | | if (!CollectionUtils.isEmpty(AccidentReportFileInfoDOList)) { |
| | | List<AccidentReportFileRespDTO> accidentReportFileRespDTOList = BeanCopyUtils.copyBeanList(AccidentReportFileInfoDOList, AccidentReportFileRespDTO.class); |
| | | AccidentReportDetailRespDTO.setFileList(accidentReportFileRespDTOList); |
| | | } |
| | | // 查找事故快报对应的附件 |
| | | List<AccidentExpressFileInfoDO> AccidentExpressFileInfoDOList = accidentExpressFileInfoService.selectByAccidentExpressId(AccidentReportDetailRespDTO.getAccidentExpressId()); |
| | | if (!CollectionUtils.isEmpty(AccidentExpressFileInfoDOList)) { |
| | | List<AccidentExpressFileRespDTO> accidentExpressFileRespDTOList = BeanCopyUtils.copyBeanList(AccidentExpressFileInfoDOList, AccidentExpressFileRespDTO.class); |
| | | AccidentReportDetailRespDTO.setExpressFileList(accidentExpressFileRespDTOList); |
| | | } |
| | | |
| | | |
| | | return new ResultVO<>(ResultCodes.OK, AccidentReportDetailRespDTO); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public ResultVO updateAccidentReport(Long uid, AccidentReportReqDTO accidentReportReqDTO) { |
| | | // 验证枚举 |
| | | checkEnum(accidentReportReqDTO); |
| | | |
| | | Date nowDate = new Date(); |
| | | //查询是否存在 |
| | | AccidentReportInfoDetailDO AccidentReportInfoDetailDO = accidentReportInfoService.selectAccidentReportById(accidentReportReqDTO.getId()); |
| | |
| | | |
| | | @Override |
| | | public ResultVO batchDeleteAccidentReport(Long[] ids) { |
| | | if (ids == null || ids.length==0){ |
| | | if (ids == null || ids.length == 0) { |
| | | throw new AccidentException(AccidentResultCodes.ACCIDENT_REPORT_NULL); |
| | | } else { |
| | | |
| | | for (Long id : ids){ |
| | | for (Long id : ids) { |
| | | deleteAccidentReport(id); |
| | | } |
| | | return new ResultVO(ResultCodes.OK); |
| | |
| | | * |
| | | * @return |
| | | */ |
| | | private void checkRequired(AccidentReportReqDTO AccidentReportReqDTO) { |
| | | private void checkRequired(AccidentReportReqDTO accidentReportReqDTO) { |
| | | //事故快报 |
| | | if (AccidentReportReqDTO.getAccidentExpressId() == null) { |
| | | if (accidentReportReqDTO.getAccidentExpressId() == null) { |
| | | throw new AccidentException(AccidentResultCodes.ACCIDENT_EXPRESS_NULL); |
| | | } |
| | | AccidentExpressInfoDetailDO accidentExpressInfo = accidentExpressInfoService.selectAccidentExpressById(AccidentReportReqDTO.getAccidentExpressId()); |
| | | AccidentExpressInfoDetailDO accidentExpressInfo = accidentExpressInfoService.selectAccidentExpressById(accidentReportReqDTO.getAccidentExpressId()); |
| | | if (accidentExpressInfo == null) { |
| | | throw new AccidentException(AccidentResultCodes.ACCIDENT_EXPRESS_NOT_EXIST); |
| | | } |
| | | |
| | | //事故类型 |
| | | if (StringUtils.isBlank(AccidentReportReqDTO.getAccidentType())) { |
| | | if (accidentReportReqDTO.getAccidentType() == null) { |
| | | throw new AccidentException(AccidentResultCodes.REPORT_TYPE_NULL); |
| | | } |
| | | //事故等级 |
| | | if (StringUtils.isBlank(AccidentReportReqDTO.getAccidentGrade())) { |
| | | if (accidentReportReqDTO.getAccidentGrade() == null) { |
| | | throw new AccidentException(AccidentResultCodes.REPORT_GRADE_NULL); |
| | | } |
| | | //经济损失 |
| | | if (AccidentReportReqDTO.getEconomicLoss() == null) { |
| | | if (accidentReportReqDTO.getEconomicLoss() == null) { |
| | | throw new AccidentException(AccidentResultCodes.REPORT_ECONOMIC_LOSS_NULL); |
| | | } |
| | | //要求报告完成期限 |
| | | if (AccidentReportReqDTO.getReportDeadline() == null) { |
| | | if (accidentReportReqDTO.getReportDeadline() == null) { |
| | | throw new AccidentException(AccidentResultCodes.REPORT_REPORT_DEADLINE_NULL); |
| | | } |
| | | //事故级别 |
| | | if (StringUtils.isBlank(AccidentReportReqDTO.getAccidentLevel())) { |
| | | if (accidentReportReqDTO.getAccidentLevel() == null) { |
| | | throw new AccidentException(AccidentResultCodes.REPORT_LEVEL_NULL); |
| | | } |
| | | //原因综合分析(直接) |
| | | if (StringUtils.isBlank(AccidentReportReqDTO.getComprehensiveAnalysisDirect())) { |
| | | if (StringUtils.isBlank(accidentReportReqDTO.getComprehensiveAnalysisDirect())) { |
| | | throw new AccidentException(AccidentResultCodes.REPORT_COMPREHENSIVE_ANALYSIS_DIRECT_NULL); |
| | | } |
| | | //原因综合分析(直接) |
| | | if (StringUtils.isBlank(AccidentReportReqDTO.getComprehensiveAnalysisDirect())) { |
| | | if (StringUtils.isBlank(accidentReportReqDTO.getComprehensiveAnalysisDirect())) { |
| | | throw new AccidentException(AccidentResultCodes.REPORT_COMPREHENSIVE_ANALYSIS_DIRECT_NULL); |
| | | } |
| | | //原因综合分析(间接) |
| | | if (StringUtils.isBlank(AccidentReportReqDTO.getComprehensiveAnalysisIndirect())) { |
| | | if (StringUtils.isBlank(accidentReportReqDTO.getComprehensiveAnalysisIndirect())) { |
| | | throw new AccidentException(AccidentResultCodes.REPORT_COMPREHENSIVE_ANALYSIS_INDIRECT_NULL); |
| | | } |
| | | //整改措施 |
| | | if (StringUtils.isBlank(AccidentReportReqDTO.getRectificationMeasures())) { |
| | | if (StringUtils.isBlank(accidentReportReqDTO.getRectificationMeasures())) { |
| | | throw new AccidentException(AccidentResultCodes.REPORT_RECTIFICATION_MEASURES_NULL); |
| | | } |
| | | //事故处理 |
| | | if (StringUtils.isBlank(AccidentReportReqDTO.getAccidentHandling())) { |
| | | if (StringUtils.isBlank(accidentReportReqDTO.getAccidentHandling())) { |
| | | throw new AccidentException(AccidentResultCodes.REPORT_ACCIDENT_HANDLING_NULL); |
| | | } |
| | | //填写人 |
| | | if (AccidentReportReqDTO.getFillInUserUid() == null) { |
| | | if (accidentReportReqDTO.getFillInUserUid() == null) { |
| | | throw new AccidentException(AccidentResultCodes.REPORT_FILL_IN_USER_UID_NULL); |
| | | } |
| | | //填写日期 |
| | | if (AccidentReportReqDTO.getFillInTime() == null) { |
| | | if (accidentReportReqDTO.getFillInTime() == null) { |
| | | throw new AccidentException(AccidentResultCodes.REPORT_FILL_IN_TIME_NULL); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public ResultVO<List<AccidentReportCountRespDTO>> countAccidentReport(AccidentReportRPCQuery query) { |
| | | |
| | | List<AccidentReportCount> list = new ArrayList<>(); |
| | | AccidentReportRPCDBQuery dbQuery = new AccidentReportRPCDBQuery(); |
| | | if (query.getType()==1){ |
| | | // 月 |
| | | int year = query.getYear(); |
| | | int month = query.getMonth(); |
| | | dbQuery.setStartTime(TimeUtils.getMonthFirst(year,month)); |
| | | dbQuery.setEndTime(TimeUtils.getMonthLast(year,month)); |
| | | list = accidentReportInfoService.selectByTimeAndType(dbQuery); |
| | | /** |
| | | * 枚举验证 |
| | | */ |
| | | private void checkEnum(AccidentReportReqDTO accidentExpressReqDTO) { |
| | | if (AccidentReportTypeEnum.getByCode(accidentExpressReqDTO.getAccidentType()) == null) { |
| | | throw new AccidentException(AccidentResultCodes.REPORT_ENUMS_TYPE_NOT_EXIST); |
| | | } |
| | | if (query.getType()==2){ |
| | | // 年 |
| | | int year = query.getYear(); |
| | | dbQuery.setStartTime(TimeUtils.getYearFirst(year)); |
| | | dbQuery.setEndTime(TimeUtils.getYearLast(year)); |
| | | list = accidentReportInfoService.selectByTimeAndType(dbQuery); |
| | | if (AccidentReportGradeEnum.getByCode(accidentExpressReqDTO.getAccidentGrade()) == null) { |
| | | throw new AccidentException(AccidentResultCodes.REPORT_ENUMS_GRADE_NOT_EXIST); |
| | | } |
| | | |
| | | List<AccidentReportCountRespDTO> accidentReportCountRespDTOList = BeanCopyUtils.copyBeanList(list,AccidentReportCountRespDTO.class); |
| | | return new ResultVO<>(ResultCodes.OK,accidentReportCountRespDTOList); |
| | | if (AccidentReportLevelEnum.getByCode(accidentExpressReqDTO.getAccidentLevel()) == null) { |
| | | throw new AccidentException(AccidentResultCodes.REPORT_ENUMS_LEVEL_NOT_EXIST); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | } |