forked from gzzfw/backEnd/gz-dyh

wangwh
2024-10-08 fb7dcd20fbde955782f33909f1d2d9c39b48afc0
dyh-service/dyh-mediate/src/main/java/cn/huge/module/cases/service/CaseAssistApplyService.java
@@ -3,18 +3,15 @@
import cn.huge.base.common.exception.ServiceException;
import cn.huge.base.common.utils.DateUtils;
import cn.huge.base.common.utils.IdUtils;
import cn.huge.base.common.utils.ObjectUtils;
import cn.huge.module.cases.consts.CaseTaskConsts;
import cn.huge.module.cases.domain.dto.FrontPageListDTO;
import cn.huge.module.cases.domain.po.CaseInfo;
import cn.huge.module.cases.domain.po.CaseInfoUnfold;
import cn.huge.module.cases.domain.po.CaseTask;
import cn.huge.module.cases.domain.po.*;
import cn.huge.module.client.api.impl.CustClientImpl;
import cn.huge.module.client.api.impl.SysClientImpl;
import cn.huge.module.client.api.impl.UtilsClientImpl;
import cn.huge.module.cases.dao.mapper.CaseAssistApplyMapper;
import cn.huge.module.cases.domain.po.CaseAssistApply;
import cn.huge.module.constant.BaseConsts;
import cn.huge.module.cust.constant.UserBaseConsts;
import cn.huge.module.cust.dto.CtUnitDTO;
import cn.huge.module.cust.dto.CtUserDTO;
import cn.huge.module.flow.consts.FlowableConsts;
@@ -37,7 +34,6 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
 * @title: 联合处置申请信息表业务逻辑处理
@@ -67,6 +63,8 @@
    private CaseTaskService caseTaskService;
    @Autowired
    private CaseInfoUnfoldService caseInfoUnfoldService;
    @Autowired
    private CaseAssistInfoService caseAssistInfoService;
    /**
    * 更新对象
@@ -209,8 +207,11 @@
            mapper.updateCaseAssistApply(caseAssistApplyPO);
            // 审核通过,就启动联合处置工作流
            if (AuditBaseConstsEnum.AUDIT_RESULT_1.getIndex().equals(caseAssistApplyPO.getAuditResult())) {
                String[] unitIds = caseAssistApplyPO.getApplyAssistUnitId().split(BaseConsts.COMMA);
                for (String unitId: unitIds) {
                String[] unitIdList = caseAssistApplyPO.getApplyAssistUnitId().split(BaseConsts.COMMA);
                String[] unitNameList = caseAssistApplyPO.getApplyAssistUnitName().split(BaseConsts.COMMA);
                for (int i=0; i<unitIdList.length; i++){
                    String unitId = unitIdList[i];
                    String unitName = unitNameList[i];
                    // 启动联合处置工作流
                    FlowNode dfpFlowNode = flowInfoService.startFlow(FlowableConsts.FLOWABLE_ID_LHCZ, caseAssistApplyPO.getCaseId());
                    // 新建并完成配合部门待分派任务
@@ -229,8 +230,8 @@
                    dfpCaseTask.setCaseTaskType(CaseTaskConsts.CASE_TASK_TYPE_2);
                    // 通过调度的,任务候选执行者类型是上一步骤选择
                    dfpCaseTask.setCandeType(CaseTaskConsts.CANDE_TYPE_1);
                    dfpCaseTask.setCandeUnitId(loginUser.getUnitId());
                    dfpCaseTask.setCandeUnitName(loginUser.getUnitName());
                    dfpCaseTask.setCandeUnitId(unitId);
                    dfpCaseTask.setCandeUnitName(unitName);
                    // 不需要签收
                    dfpCaseTask.setSignStatus(CaseTaskConsts.SIGN_STATUS_0);
                    dfpCaseTask.setStatus(CaseTaskConsts.TASK_STATUS_2);
@@ -283,6 +284,17 @@
                    dslCaseTask.setCreateTime(now);
                    dslCaseTask.setUpdateTime(now);
                    caseTaskService.save(dslCaseTask);
                    // 新增联合处置信息
                    CaseAssistInfo caseAssistInfoPO = new CaseAssistInfo();
                    caseAssistInfoPO.setId(utilsClient.getNewTimeId());
                    caseAssistInfoPO.setCaseId(dslCaseTask.getCaseId());
                    caseAssistInfoPO.setAssistUnitId(unitId);
                    caseAssistInfoPO.setAssistUnitName(unitName);
                    caseAssistInfoPO.setAssistStatus(CaseTaskConsts.ASSIST_STATUS_0);
                    caseAssistInfoPO.setCustId(dslCaseTask.getCustId());
                    caseAssistInfoPO.setCreateTime(now);
                    caseAssistInfoPO.setUpdateTime(now);
                    caseAssistInfoService.save(caseAssistInfoPO);
                }
                // 更新纠纷扩展信息
                CaseInfoUnfold caseInfoUnfoldPO = new CaseInfoUnfold();
@@ -299,26 +311,27 @@
    /**
     * 根据案件编号查询联合处置申请
     * @param caseId 条件
     * @param id 主键编号
     * @return long
     */
    public CaseAssistApply caseAssistApplyByCaseId(String caseId){
    public CaseAssistApply caseAssistApplyById(String id){
        try {
            QueryWrapper<CaseAssistApply> caseAssistApplyQueryWrapper = new QueryWrapper<>();
            caseAssistApplyQueryWrapper.eq("case_id", caseId).eq("apply_status", 0)
                    .orderByDesc("create_time");
            caseAssistApplyQueryWrapper.eq("id", id);
            CaseAssistApply caseAssistApply = mapper.selectOne(caseAssistApplyQueryWrapper);
            Map<String, Object> terms = new HashMap<>();
            terms.put("mainId", caseId);
            terms.put("ownerIds", "'" + caseAssistApply.getId() + "'");
            List<FileIdInfoBaseDTO> fileIdInfoBaseDTOList = sysClient.listIdInfoByOwnerIdList(terms);
            if (CollectionUtils.isNotEmpty(fileIdInfoBaseDTOList)) {
                caseAssistApply.setFileInfoBaseDTOList(fileIdInfoBaseDTOList.get(0).getFileList());
            if(ObjectUtils.isNotEmpty(caseAssistApply)){
                Map<String, Object> terms = new HashMap<>();
                terms.put("mainId", caseAssistApply.getCaseId());
                terms.put("ownerIds", "'" + caseAssistApply.getId() + "'");
                List<FileIdInfoBaseDTO> fileIdInfoBaseDTOList = sysClient.listIdInfoByOwnerIdList(terms);
                if (CollectionUtils.isNotEmpty(fileIdInfoBaseDTOList)) {
                    caseAssistApply.setFileInfoBaseDTOList(fileIdInfoBaseDTOList.get(0).getFileList());
                }
            }
            return caseAssistApply;
        }catch(Exception e ){
            log.error("[CaseAssistApplyService.caseAssistApplyByCaseId]调用失败,异常信息:"+e, e);
            throw new ServiceException("CaseAssistApplyService.caseAssistApplyByCaseId", e);
            log.error("[CaseAssistApplyService.caseAssistApplyById]调用失败,异常信息:"+e, e);
            throw new ServiceException("CaseAssistApplyService.caseAssistApplyById", e);
        }
    }
@@ -349,4 +362,5 @@
    public List<FrontPageListDTO> pageMyTaskAssistReview(PageRequest page, Map<String, Object> terms){
        return mapper.pageMyTaskAssistReview(page, terms);
    }
}