jiangping
2024-02-02 f8b1073fbb28d37e08016eed32c682f8c5eae391
server/service/src/main/java/com/doumee/service/business/impl/InsuranceApplyServiceImpl.java
@@ -96,6 +96,9 @@
    @Autowired
    private DuWorktypeMapper duWorktypeMapper;
    @Autowired
    private NoticesMapper noticesMapper;
    @Override
    @Transactional(rollbackFor = {Exception.class,BusinessException.class})
    public Integer back(InsuranceApply insuranceApply) {
@@ -110,6 +113,12 @@
        if(Constants.equalsInteger(model.getStatus(),Constants.InsuranceApplyStatus.UPLOAD_INSURANCE.getKey())){
            throw  new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"对不起,该申请状态已流转,当前不支持该操作~");
        }
        Solutions solutions = solutionsMapper.selectById(model.getSolutionId());
        if(Objects.isNull(solutions)){
            throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"未查询方案信息");
        }
        LoginUserInfo user = (LoginUserInfo) SecurityUtils.getSubject().getPrincipal();
        InsuranceApply update = new InsuranceApply();
        update.setEditDate(new Date());
@@ -120,6 +129,15 @@
        update.setCheckUserId(user.getId());
        update.setId(model.getId());
        insuranceApplyMapper.updateById(update);
        //存储待办信息
        Constants.NoticeObjectType noticeObjectType = Constants.NoticeObjectType.INSURANCE_APPLY;
        //删除其他待办
        noticesMapper.delete(new QueryWrapper<Notices>().lambda().eq(Notices::getObjType,noticeObjectType.getKey()).eq(Notices::getObjId,insuranceApply.getId()));
        Notices notices = new Notices(noticeObjectType,Constants.ONE,insuranceApply.getId(),solutions.getName(),
                model.getCompanyId(), Constants.NoticeType.FOUR);
        noticesMapper.insert(notices);
        Constants.ApplyLogType applyLogType = Constants.ApplyLogType.PLATFORM_RETURN;
        String info =applyLogType.getInfo();
@@ -344,7 +362,10 @@
        if(model == null ||!Constants.equalsInteger(model.getIsdeleted(),Constants.ZERO)){
            throw  new BusinessException(ResponseStatus.DATA_EMPTY);
        }
        Solutions solutions = solutionsMapper.selectById(model.getSolutionId());
        if(Objects.isNull(solutions)){
            throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"未查询方案信息");
        }
        LoginUserInfo user = (LoginUserInfo) SecurityUtils.getSubject().getPrincipal();
        Constants.ApplyLogType applyLogType = null;
        String info = "";
@@ -384,6 +405,7 @@
        update.setEditDate(new Date());
        update.setSignApplyNo(applyNo);
        insuranceApplyMapper.updateById(update);
        return  link;
    }
    public String uploadSignFile(String link){
@@ -418,6 +440,13 @@
        update.setId(model.getId());
        insuranceApplyMapper.updateById(update);
        //存储待办信息
        Constants.NoticeObjectType noticeObjectType = Constants.NoticeObjectType.INSURANCE_APPLY;
        //删除其他待办
        noticesMapper.delete(new QueryWrapper<Notices>().lambda().eq(Notices::getObjType,noticeObjectType.getKey()).eq(Notices::getObjId,model.getId()));
        Notices notices = new Notices(noticeObjectType,Constants.ZERO,model.getId(),model.getSolutionsName(),model.getCompanyId(),Constants.NoticeType.TWO);
        noticesMapper.insert(notices);
        Multifile f = new Multifile();
        f.setIsdeleted(Constants.ZERO);
        f.setCreator(model.getCreator());
@@ -448,6 +477,17 @@
        update.setCheckUserId(model.getCreator());
        update.setId(model.getId());
        applyChangeMapper.updateById(update);
        //存储待办信息
        Constants.NoticeObjectType noticeObjectType = Constants.NoticeObjectType.APPLY_CHANGE;
        if(model.getType().equals(Constants.ONE)){
            noticeObjectType = Constants.NoticeObjectType.CHANGE_FACTORY;
        }
        //删除其他待办
        noticesMapper.delete(new QueryWrapper<Notices>().lambda().eq(Notices::getObjType,noticeObjectType.getKey()).eq(Notices::getObjId,model.getId()));
        Notices notices = new Notices(noticeObjectType,Constants.ONE,model.getId(),model.getSolutionsName(),
                model.getCompanyId(), Constants.NoticeType.TWO);
        noticesMapper.insert(notices);
        Multifile f = new Multifile();
        f.setIsdeleted(Constants.ZERO);
@@ -651,6 +691,11 @@
//        info = info.replace("${param}", update.getCheckInfo());
        ApplyLog log = new ApplyLog(update,applyLogType.getName(),StringUtils.isNotBlank(update.getCheckInfo())?info:"",update.getId(),applyLogType.getKey(),JSONObject.toJSONString(model), JSONObject.toJSONString(update));
        applyLogMapper.insert(log);
        //删除其他待办
        Constants.NoticeObjectType noticeObjectType = Constants.NoticeObjectType.INSURANCE_APPLY;
        noticesMapper.delete(new QueryWrapper<Notices>().lambda().eq(Notices::getObjType,noticeObjectType.getKey()).eq(Notices::getObjId,insuranceApply.getId()));
        return  1;
    }
@@ -675,6 +720,11 @@
            throw  new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"对不起,该申请状态已流转,当前不支持该操作~");
        }
        Solutions solutions = solutionsMapper.selectById(model.getSolutionId());
        if(Objects.isNull(solutions)){
            throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"未查询方案信息");
        }
        Constants.ApplyLogType applyLogType = null;
        LoginUserInfo user = (LoginUserInfo) SecurityUtils.getSubject().getPrincipal();
        InsuranceApply update = new InsuranceApply();
@@ -684,20 +734,30 @@
        update.setCheckInfo(insuranceApply.getCheckInfo());
        update.setCheckUserId(user.getId());
        update.setId(model.getId());
        Constants.NoticeType noticeType = Constants.NoticeType.ONE;
        if(insuranceApply.getDealBackApply() ==1){
            //如果是不通过
            applyLogType = Constants.ApplyLogType.PLATFORM_RETURN ;
            update.setStatus(Constants.InsuranceApplyStatus.PLATFORM_RETURN.getKey());
            noticeType = Constants.NoticeType.FOUR;
        }else{
            applyLogType = Constants.ApplyLogType.PLATFORM_CHECK_PASS;
            update.setStatus(Constants.InsuranceApplyStatus.PLATFORM_CHECK_PASS.getKey());
        }
        insuranceApplyMapper.updateById(update);
        //存储待办信息
        Constants.NoticeObjectType noticeObjectType = Constants.NoticeObjectType.INSURANCE_APPLY;
        //删除其他待办
        noticesMapper.delete(new QueryWrapper<Notices>().lambda().eq(Notices::getObjType,noticeObjectType.getKey()).eq(Notices::getObjId,model.getId()));
        Notices notices = new Notices(noticeObjectType,Constants.ONE,model.getId(),solutions.getName(),model.getCompanyId(),noticeType);
        noticesMapper.insert(notices);
        String info =applyLogType.getInfo();
        info = info.replace("${param}", update.getCheckInfo());
        ApplyLog log = new ApplyLog(update,applyLogType.getName(),info,update.getId(),applyLogType.getKey(),JSONObject.toJSONString(model), JSONObject.toJSONString(update));
        applyLogMapper.insert(log);
        return  1;
    }
@@ -717,6 +777,10 @@
        LoginUserInfo loginUserInfo = (LoginUserInfo) SecurityUtils.getSubject().getPrincipal();
        if(!loginUserInfo.getType().equals(Constants.ONE)){
            throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"用户类型错误:非企业用户无法进行该操作");
        }
        Solutions solutions = solutionsMapper.selectById(insuranceApply.getSolutionId());
        if(Objects.isNull(solutions)){
            throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"未查询到方案信息");
        }
        List<ApplyDetail> applyDetailList = insuranceApply.getApplyDetailList();
        //判断是否存在重复信息
@@ -747,13 +811,22 @@
        //处理下级数据
        this.dealApplyDetailData(insuranceApply,applyDetailList,loginUserInfo,countCyclePriceVO);
        this.dealApplyDetailData(insuranceApply,solutions,applyDetailList,loginUserInfo,countCyclePriceVO);
        InsuranceApply updBean = new InsuranceApply();
        updBean.setId(insuranceApply.getId());
        updBean.setFee(applyDetailList.stream().map(ApplyDetail::getFee).reduce(BigDecimal.ZERO,BigDecimal::add));
        insuranceApplyMapper.updateById(updBean);
        //存储日志数据
        this.saveApplyLog(insuranceApply,insuranceApplyStatus,null);
        //发送待办业务
        //存储待办信息
        Constants.NoticeObjectType noticeObjectType = Constants.NoticeObjectType.INSURANCE_APPLY;
        //删除其他待办
        noticesMapper.delete(new QueryWrapper<Notices>().lambda().eq(Notices::getObjType,noticeObjectType.getKey()).eq(Notices::getObjId,insuranceApply.getId()));
        Notices notices = new Notices(noticeObjectType,Constants.ZERO,insuranceApply.getId(),solutions.getName(),insuranceApply.getCompanyId(),Constants.NoticeType.ZERO);
        noticesMapper.insert(notices);
        return insuranceApply.getId();
    }
@@ -812,22 +885,33 @@
        insuranceApply.setEndTime(countCyclePriceVO.getEndDate());
        applyDetailMapper.delete(new QueryWrapper<ApplyDetail>().lambda().eq(ApplyDetail::getApplyId,insuranceApply.getId()));
        Solutions solutions = solutionsMapper.selectById(insuranceApply.getSolutionId());
        if(Objects.isNull(solutions)){
            throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"未查询到方案信息");
        }
        //处理下级数据
        this.dealApplyDetailData(insuranceApply,applyDetailList,loginUserInfo,countCyclePriceVO);
        this.dealApplyDetailData(insuranceApply,solutions,applyDetailList,loginUserInfo,countCyclePriceVO);
        insuranceApply.setFee(applyDetailList.stream().map(ApplyDetail::getFee).reduce(BigDecimal.ZERO,BigDecimal::add));
        insuranceApplyMapper.updateById(insuranceApply);
        //存储日志数据
        this.saveApplyLog(insuranceApply,insuranceApplyStatus,null);
        //存储待办信息
        Constants.NoticeObjectType noticeObjectType = Constants.NoticeObjectType.INSURANCE_APPLY;
        //删除其他待办
        noticesMapper.delete(new QueryWrapper<Notices>().lambda().eq(Notices::getObjType,noticeObjectType.getKey()).eq(Notices::getObjId,insuranceApply.getId()));
        Notices notices = new Notices(noticeObjectType,Constants.ZERO,insuranceApply.getId(),solutions.getName(),insuranceApply.getCompanyId(),Constants.NoticeType.ZERO);
        noticesMapper.insert(notices);
        return insuranceApply.getId();
    }
    public void dealApplyDetailData(InsuranceApply insuranceApply,List<ApplyDetail> applyDetailList,LoginUserInfo loginUserInfo,CountCyclePriceVO  countCyclePriceVO){
        Solutions solutions = solutionsMapper.selectById(insuranceApply.getSolutionId());
        if(Objects.isNull(solutions)){
            throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"未查询到方案信息");
        }
    public void dealApplyDetailData(InsuranceApply insuranceApply,Solutions solutions,List<ApplyDetail> applyDetailList,LoginUserInfo loginUserInfo,CountCyclePriceVO  countCyclePriceVO){
        //查询保险方案下的所有派遣单位
        List<DuSolution>  duSolutionList = duSolutionJoinMapper.selectJoinList(DuSolution.class,new MPJLambdaWrapper<DuSolution>()
                .selectAll(DuSolution.class)
@@ -1047,6 +1131,7 @@
            }else{
                queryWrapper.eq(InsuranceApply::getCompanyId, -1);
            }
            queryWrapper.eq(pageWrap.getModel().getCompanyId()!=null,InsuranceApply::getCompanyId, pageWrap.getModel().getCompanyId());
        }
        if (pageWrap.getModel().getSolutionId() != null) {
            queryWrapper.eq(InsuranceApply::getSolutionId, pageWrap.getModel().getSolutionId());
@@ -1332,8 +1417,14 @@
        if(insuranceApply.getIsdeleted().equals(Constants.ONE)){
            throw new BusinessException(ResponseStatus.DATA_ERRO.getCode(),"数据已删除,无法进行该操作");
        }
        Solutions solutions = solutionsMapper.selectById(insuranceApply.getSolutionId());
        if(Objects.isNull(solutions)){
            throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"未查询到方案信息");
        }
        //-----TODU-------RJ-------完善退回状态分开标记------------------
        Constants.InsuranceApplyStatus insuranceApplyStatus =  Constants.InsuranceApplyStatus.COMPANY_BACK_APPLY_SIGNATURE;
        Constants.NoticeObjectType noticeObjectType = Constants.NoticeObjectType.INSURANCE_APPLY;
        if(insuranceApplyOptDTO.getOptType().equals(Constants.ONE)){
            if(!(insuranceApply.getStatus().equals(Constants.InsuranceApplyStatus.UPLOAD.getKey())
                    ||insuranceApply.getStatus().equals(Constants.InsuranceApplyStatus.WAIT_SIGNATURE.getKey())
@@ -1347,6 +1438,15 @@
            }else  if(insuranceApply.getStatus().equals(Constants.InsuranceApplyStatus.SIGNATURE.getKey())){
                insuranceApplyStatus =  Constants.InsuranceApplyStatus.COMPANY_BACK_APPLY_SIGNATURE;
            }
            //存储待办信息
            //删除其他待办
            noticesMapper.delete(new QueryWrapper<Notices>().lambda().eq(Notices::getObjType,noticeObjectType.getKey()).eq(Notices::getObjId,insuranceApply.getId()));
            Notices notices = new Notices(noticeObjectType,Constants.ONE,insuranceApply.getId(),solutions.getName(),
                    insuranceApply.getCompanyId(), Constants.NoticeType.THREE);
            noticesMapper.insert(notices);
        }else if(insuranceApplyOptDTO.getOptType().equals(Constants.TWO)){
            insuranceApplyStatus =  Constants.InsuranceApplyStatus.CLOSE;
            if(insuranceApply.getStatus().equals(Constants.InsuranceApplyStatus.CLOSE.getKey())){
@@ -1357,6 +1457,8 @@
                    ||insuranceApply.getStatus().equals(Constants.InsuranceApplyStatus.PLATFORM_CHECK_PASS.getKey()))){
                throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"数据状态非可申请退回!");
            }
            //删除其他待办
            noticesMapper.delete(new QueryWrapper<Notices>().lambda().eq(Notices::getObjType,noticeObjectType.getKey()).eq(Notices::getObjId,insuranceApply.getId()));
        }
        insuranceApply.setStatus(insuranceApplyStatus.getKey());
        insuranceApply.setCheckDate(new Date());