songhuangfeng123
2022-08-01 c188e4980adbe855c237c0c9f8bd2910298323d7
incident-manage/incident-manage-service/src/main/java/com/gkhy/safePlatform/incidentManage/service/impl/AccidentExpressServiceImpl.java
@@ -10,14 +10,17 @@
import com.gkhy.safePlatform.incidentManage.entity.*;
import com.gkhy.safePlatform.incidentManage.enums.AccidentResultCodes;
import com.gkhy.safePlatform.incidentManage.exception.AccidentException;
import com.gkhy.safePlatform.incidentManage.model.dto.req.AccidentExpressCasualtyReqDTO;
import com.gkhy.safePlatform.incidentManage.model.dto.req.AccidentExpressFileReqDTO;
import com.gkhy.safePlatform.incidentManage.model.dto.req.AccidentExpressReqDTO;
import com.gkhy.safePlatform.incidentManage.model.dto.resp.AccidentExpressCasualtyRespDTO;
import com.gkhy.safePlatform.incidentManage.model.dto.resp.AccidentExpressDetailRespDTO;
import com.gkhy.safePlatform.incidentManage.model.dto.resp.AccidentExpressFileRespDTO;
import com.gkhy.safePlatform.incidentManage.model.dto.resp.AccidentExpressPageRespDTO;
import com.gkhy.safePlatform.incidentManage.query.AccidentExpressQuery;
import com.gkhy.safePlatform.incidentManage.query.db.AccidentExpressDBQuery;
import com.gkhy.safePlatform.incidentManage.service.AccidentExpressService;
import com.gkhy.safePlatform.incidentManage.service.baseService.AccidentExpressCasualtyInfoService;
import com.gkhy.safePlatform.incidentManage.service.baseService.AccidentExpressFileInfoService;
import com.gkhy.safePlatform.incidentManage.service.baseService.AccidentExpressInfoService;
import org.springframework.beans.BeanUtils;
@@ -39,6 +42,9 @@
    @Autowired
    private AccidentExpressFileInfoService accidentExpressFileInfoService;
    @Autowired
    private AccidentExpressCasualtyInfoService accidentExpressCasualtyInfoService;
    @Override
    public SearchResultVO<List<AccidentExpressPageRespDTO>> selectAccidentExpressList(PageQuery<AccidentExpressQuery> query) {
@@ -51,9 +57,12 @@
            BeanUtils.copyProperties(query.getSearchParams(), accidentExpressDBQuery);
        }
        List<AccidentExpressInfoPageDO> accidentExpressInfoPageDOList = accidentExpressInfoService.selectAccidentExpressList(page, accidentExpressDBQuery);
        List<AccidentExpressPageRespDTO> respList = BeanCopyUtils.copyBeanList(accidentExpressInfoPageDOList, AccidentExpressPageRespDTO.class);
        respList.forEach(AccidentExpressPageRespDTO ->{
            // 设置人员名称
        });
        return new SearchResultVO<>(
                true,
@@ -203,6 +212,33 @@
        }
    }
    @Override
    public ResultVO selectAccidentExpressCasualtyList(Long accidentExpressId) {
        List<AccidentExpressCasualtyInfoDO> accidentExpressCasualtyInfoDOList = accidentExpressCasualtyInfoService.selectByAccidentExpressId(accidentExpressId);
        List<AccidentExpressCasualtyRespDTO> respList =BeanCopyUtils.copyBeanList(accidentExpressCasualtyInfoDOList, AccidentExpressCasualtyRespDTO.class);
        return new ResultVO<>(ResultCodes.OK,respList);
    }
    @Override
    public ResultVO addAccidentExpressCasualty(Long uid, AccidentExpressCasualtyReqDTO accidentExpressCasualtyReqDTO) {
        if (accidentExpressCasualtyReqDTO.getAccidentExpressId()==null){
            throw new AccidentException(AccidentResultCodes.ACCIDENT_EXPRESS_NULL);
        }else{
            AccidentExpressCasualtyInfo accidentExpressCasualtyInfo = new AccidentExpressCasualtyInfo();
            BeanUtils.copyProperties(accidentExpressCasualtyReqDTO,accidentExpressCasualtyInfo);
            accidentExpressCasualtyInfo.setDelFlag(false);
            accidentExpressCasualtyInfo.setGmtCreate(new Date());
            accidentExpressCasualtyInfo.setCreateUid(uid);
            accidentExpressCasualtyInfoService.addAccidentExpressCasualty(accidentExpressCasualtyInfo);
            return new ResultVO(ResultCodes.OK);
        }
    }
    @Override
    public ResultVO delAccidentExpressCasualty(Long accidentExpressId) {
        accidentExpressCasualtyInfoService.deleteAccidentExpressCasualtyById(accidentExpressId);
        return new ResultVO(ResultCodes.OK);
    }
@@ -211,55 +247,42 @@
     * @return
     */
    private void checkRequired(AccidentExpressReqDTO AccidentExpressReqDTO) {
       /* //名称
        if (StringUtils.isBlank(AccidentExpressReqDTO.getTeamName())) {
            throw new EmergencyException(EmergencyResultCodes.TEAM_NAME_NULL);
        //名称
        if (StringUtils.isBlank(AccidentExpressReqDTO.getAccidentName())) {
            throw new AccidentException(AccidentResultCodes.EXPRESS_NAME_NULL);
        }
        //级别
        if (StringUtils.isBlank(AccidentExpressReqDTO.getTeamLevel())) {
            throw new EmergencyException(EmergencyResultCodes.TEAM_LEVEL_NULL);
        //部门
        if (AccidentExpressReqDTO.getAccidentDepartmentId()==null) {
            throw new AccidentException(AccidentResultCodes.EXPRESS_DEPARTMENT_NULL);
        }
        //负责人
        if (AccidentExpressReqDTO.getPrincipalUid() == null || AccidentExpressReqDTO.getPrincipalUid() == 0) {
            throw new EmergencyException(EmergencyResultCodes.TEAM_PRINCIPAL_NULL);
        //发生时间
        if (AccidentExpressReqDTO.getOccurrenceTime() == null ) {
            throw new AccidentException(AccidentResultCodes.EXPRESS_TIME_NULL);
        }
        //负责人部门
        if (AccidentExpressReqDTO.getPrincipalDepartmentId() == null || AccidentExpressReqDTO.getPrincipalDepartmentId() == 0) {
            throw new EmergencyException(EmergencyResultCodes.TEAM_PRINCIPAL_DEPARTMENT_NULL);
        //发生地点
        if (StringUtils.isBlank(AccidentExpressReqDTO.getOccurrencePlace())) {
            throw new AccidentException(AccidentResultCodes.EXPRESS_PLACE_NULL);
        }
        //负责人手机
        if (StringUtils.isBlank(AccidentExpressReqDTO.getPrincipalPhone())) {
            throw new EmergencyException(EmergencyResultCodes.TEAM_PRINCIPAL_PHONE_NULL);
        //事故原因
        if (StringUtils.isBlank(AccidentExpressReqDTO.getAccidentCause())) {
            throw new AccidentException(AccidentResultCodes.EXPRESS_CAUSE_NULL);
        }
        //固定电话
        if (StringUtils.isBlank(AccidentExpressReqDTO.getTelephoneNumber())) {
            throw new EmergencyException(EmergencyResultCodes.TEAM_TELEPHONE_NUMBER_NULL);
        //是否有伤亡
        if (AccidentExpressReqDTO.getCasualties()==null) {
            throw new AccidentException(AccidentResultCodes.EXPRESS_CASUALTIES_NULL);
        }
        //人员列表如果不为空,则需要验证其中的必填项
        if (!CollectionUtils.isEmpty(AccidentExpressReqDTO.getMemberList())){
            for(AccidentExpressMemberReqDTO AccidentExpressMemberReqDTO : AccidentExpressReqDTO.getMemberList()){
                //工号
                if (StringUtils.isBlank(AccidentExpressMemberReqDTO.getJobNumber())) {
                    throw new EmergencyException(EmergencyResultCodes.TEAM_USER_JOB_NUMBER_NULL);
                }
                //名称
                if (StringUtils.isBlank(AccidentExpressMemberReqDTO.getName())) {
                    throw new EmergencyException(EmergencyResultCodes.TEAM_USER_NAME_NULL);
                }
                //性别
                if (AccidentExpressMemberReqDTO.getGender()==null) {
                    throw new EmergencyException(EmergencyResultCodes.TEAM_USER_GENDER_NULL);
                }
                //手机号码
                if (StringUtils.isBlank(AccidentExpressMemberReqDTO.getPhone())) {
                    throw new EmergencyException(EmergencyResultCodes.TEAM_USER_PHONE_NULL);
                }
                //职务
                if (StringUtils.isBlank(AccidentExpressMemberReqDTO.getPosition())) {
                    throw new EmergencyException(EmergencyResultCodes.TEAM_USER_POSITION_NULL);
                }
            }
        }*/
        //简要经过
        if (StringUtils.isBlank(AccidentExpressReqDTO.getAccidentBriefProcess())) {
            throw new AccidentException(AccidentResultCodes.EXPRESS_BRIEF_PROCESS_NULL);
        }
        //初步分析
        if (StringUtils.isBlank(AccidentExpressReqDTO.getAccidentCausesPreliminaryAnalysis())) {
            throw new AccidentException(AccidentResultCodes.EXPRESS_CASE_PRELIMINARY_ANALYSIS_NULL);
        }
        //应急防范措施
        if (StringUtils.isBlank(AccidentExpressReqDTO.getEmergencyPrecautions())) {
            throw new AccidentException(AccidentResultCodes.EXPRESS_EMERGENCY_PRECAUTIONS_NULL);
        }
    }
}