songhuangfeng123
2022-08-02 d4c032bd81ac3320a2ef54a83fe24decc0e6b63c
incident-manage/incident-manage-service/src/main/java/com/gkhy/safePlatform/incidentManage/service/impl/AccidentReportServiceImpl.java
@@ -1,6 +1,8 @@
package com.gkhy.safePlatform.incidentManage.service.impl;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.gkhy.safePlatform.account.rpc.apimodel.AccountDepartmentService;
import com.gkhy.safePlatform.account.rpc.apimodel.model.resp.DepInfoRPCRespDTO;
import com.gkhy.safePlatform.commons.enums.ResultCodes;
import com.gkhy.safePlatform.commons.query.PageQuery;
import com.gkhy.safePlatform.commons.utils.BeanCopyUtils;
@@ -18,16 +20,16 @@
import com.gkhy.safePlatform.incidentManage.query.AccidentReportQuery;
import com.gkhy.safePlatform.incidentManage.query.db.AccidentReportDBQuery;
import com.gkhy.safePlatform.incidentManage.service.AccidentReportService;
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 org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.*;
import java.util.stream.Collectors;
@Service("accidentReportService")
@@ -38,6 +40,12 @@
    @Autowired
    private AccidentReportFileInfoService accidentReportFileInfoService;
    @DubboReference(check = false)
    private AccountDepartmentService accountDepartmentService;
    @Autowired
    private AccidentExpressInfoService accidentExpressInfoService;
    @Override
@@ -54,6 +62,26 @@
        List<AccidentReportInfoPageDO> accidentReportInfoPageDOList = accidentReportInfoService.selectAccidentReportList(page, accidentReportDBQuery);
        List<AccidentReportPageRespDTO> respList = BeanCopyUtils.copyBeanList(accidentReportInfoPageDOList, AccidentReportPageRespDTO.class);
        Map<Long, String> depPool = new HashMap<>();
        respList.forEach(AccidentReportPageRespDTO -> {
            // 设置部门名称
            if (!depPool.containsKey(AccidentReportPageRespDTO.getAccidentDepartmentId())) {
                ResultVO<DepInfoRPCRespDTO> rpcResult = accountDepartmentService.getDepInfoByDepId(AccidentReportPageRespDTO.getAccidentDepartmentId());
                if (rpcResult != null && rpcResult.getCode().equals(ResultCodes.OK.getCode())) {
                    if (rpcResult.getData() != null) {
                        DepInfoRPCRespDTO dep = (DepInfoRPCRespDTO) rpcResult.getData();
                        depPool.put(dep.getDepId(), dep.getDepName());
                    }
                }
            }
            String depName = depPool.get(AccidentReportPageRespDTO.getAccidentDepartmentId());
            AccidentReportPageRespDTO.setDeptName(depName);
        });
        return new SearchResultVO<>(
                true,
@@ -205,10 +233,9 @@
    }
    /**
     * 验证必填项
     *
     * @return
     */
    private void checkRequired(AccidentReportReqDTO AccidentReportReqDTO) {
@@ -216,6 +243,11 @@
        if (AccidentReportReqDTO.getAccidentExpressId() == null ) {
            throw new AccidentException(AccidentResultCodes.ACCIDENT_EXPRESS_NULL);
        }
        AccidentExpressInfoDetailDO accidentExpressInfo = accidentExpressInfoService.selectAccidentExpressById(AccidentReportReqDTO.getAccidentExpressId());
        if (accidentExpressInfo == null) {
            throw new AccidentException(AccidentResultCodes.ACCIDENT_EXPRESS_NOT_EXIST);
        }
        //事故类型
        if (StringUtils.isBlank(AccidentReportReqDTO.getAccidentType())) {
            throw new AccidentException(AccidentResultCodes.REPORT_TYPE_NULL);