jiangping
2025-06-10 e6ff15690bf92e4c942f279d95cabe726d3cd56a
server/service/src/main/java/com/doumee/service/business/impl/InsuranceApplyServiceImpl.java
@@ -19,6 +19,7 @@
import com.doumee.dao.business.model.*;
import com.doumee.dao.business.vo.ApplyPowerVO;
import com.doumee.dao.business.vo.CountCyclePriceVO;
import com.doumee.dao.business.vo.dataBoard.InsuranceDataVO;
import com.doumee.dao.system.SystemUserMapper;
import com.doumee.dao.system.model.SystemUser;
import com.doumee.service.business.InsuranceApplyService;
@@ -64,7 +65,6 @@
    private SmsEmailService smsEmailService;
    @Autowired
    private ApplyChangeJoinMapper applyChangeMapper;
    @Autowired
    private SystemDictDataBiz systemDictDataBiz;
    @Autowired
@@ -73,25 +73,20 @@
    private CompanyMapper companyMapper;
    @Autowired
    private MemberInsuranceJoinMapper memberInsuranceJoinMapper;
    @Autowired
    private ApplyDetailMapper applyDetailMapper;
    @Autowired
    private ApplyDetailJoinMapper applyDetailJoinMapper;
    @Autowired
    private ApplyLogMapper applyLogMapper;
    @Autowired
    private SignService signService;
    @Autowired
    private MultifileMapper multifileMapper;
    @Autowired
    private ApplyLogJoinMapper applyLogJoinMapper;
    @Autowired
    private SolutionsMapper solutionsMapper;
    @Autowired
    private MemberMapper memberMapper;
    @Autowired
@@ -106,7 +101,6 @@
    private DuWorkTypeJoinMapper duWorkTypeJoinMapper;
    @Autowired
    private SolutionWorktypeJoinMapper solutionWorktypeJoinMapper;
    @Autowired
    private NoticesMapper noticesMapper;
    @Autowired
@@ -121,7 +115,8 @@
    private SystemUserMapper systemUserMapper;
    @Autowired
    private CompanyDepartmentMapper companyDepartmentMapper;
    @Autowired
    private InsuranceMapper insuranceMapper;
    @Override
    @Transactional(rollbackFor = {Exception.class,BusinessException.class})
@@ -152,7 +147,6 @@
            }
            update.setStatus(Constants.InsuranceApplyStatus.WTB_RETURN.getKey());
        }
        update.setEditDate(new Date());
        update.setEditor(user.getId());
        update.setCheckDate(update.getEditDate());
@@ -160,7 +154,6 @@
        update.setCheckUserId(user.getId());
        update.setId(model.getId());
        insuranceApplyMapper.updateById(update);
        //存储待办信息
        Constants.NoticeObjectType noticeObjectType = Constants.NoticeObjectType.INSURANCE_APPLY;
        //删除其他待办
@@ -170,8 +163,6 @@
        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();
        info = info.replace("${param}", update.getCheckInfo());
@@ -225,7 +216,6 @@
                ||StringUtils.isBlank( insuranceApply.getBaoxiandanFile() .getName())){
            throw  new BusinessException(ResponseStatus.BAD_REQUEST);
        }
        InsuranceApply model = insuranceApplyMapper.selectById(insuranceApply.getId());
        if(model == null ||!Constants.equalsInteger(model.getIsdeleted(),Constants.ZERO)){
            throw  new BusinessException(ResponseStatus.DATA_EMPTY);
@@ -320,16 +310,19 @@
        if(CollectionUtils.isNotEmpty(applyDetailList)){
            List<MemberInsurance> memberInsuranceList = new ArrayList<>();
            List<String> idCodeList = new ArrayList<>();
            for (ApplyDetail applyDetail:applyDetailList) {
                idCodeList.add(applyDetail.getIdcardNo());
            }
            List<ApplyDetail> allDetailList =   this.getMemberSolutionList(solutions.getParentId(),idCodeList, update.getStartTime()
                    ,update.getEndTime(),insuranceApply.getId());
            for (ApplyDetail applyDetail:applyDetailList) {
                //查询人员信息是否存在相同的方案下是否存在 冲突数据
                this.checkMemberSolution(solutions.getParentId(),applyDetail.getIdcardNo(),applyDetail.getMemberName(),update.getStartTime()
                        ,update.getEndTime(),insuranceApply.getId());
                this.checkMemberSolution( applyDetail.getIdcardNo(),allDetailList,applyDetail.getMemberName());
                MemberInsurance memberInsurance = new MemberInsurance(applyDetail,user.getId());
                memberInsurance.setRelationType(Constants.ZERO);
                memberInsuranceList.add(memberInsurance);
                memberMapper.update(null,new UpdateWrapper<Member>()
                        .lambda()
                        .set(Member::getStartTime,memberInsurance.getStartTime())
@@ -340,7 +333,7 @@
                );
            }
            memberInsuranceJoinMapper.insertBatchSomeColumn(memberInsuranceList);
            memberInsuranceJoinMapper.insert(memberInsuranceList);
        }
        this.updateApplyCurrentFee(insuranceApply.getId(),null);
@@ -2430,7 +2423,12 @@
            List<Member> memberList = memberMapper.selectList(new QueryWrapper<Member>().lambda()
                    .eq(Member::getCompanyId,insuranceApply.getCompanyId())
                    .eq(Member::getIsdeleted,Constants.ZERO));
            List<String> idCodeList = new ArrayList<>();
            for (ApplyDetail applyDetail:applyDetailList) {
                idCodeList.add(applyDetail.getIdcardNo());
            }
            List<ApplyDetail> allDetailList =   this.getMemberSolutionList(solutions.getParentId(),idCodeList, insuranceApply.getStartTime()
                    ,insuranceApply.getEndTime(),insuranceApply.getId());
            List<Member> addMemberList = new ArrayList<>();
            for (int i = 0; i < applyDetailList.size(); i++) {
                ApplyDetail applyDetail = applyDetailList.get(i);
@@ -2459,10 +2457,11 @@
                    addMemberList.add(member);
                }
                //查询人员信息是否存在相同的方案下是否存在 冲突数据
                this.checkMemberSolution(solutions.getParentId(),member.getIdcardNo(),member.getName(),insuranceApply.getStartTime(),insuranceApply.getEndTime(),insuranceApply.getId());
                this.checkMemberSolution( applyDetail.getIdcardNo(),allDetailList,applyDetail.getMemberName());
//                this.checkMemberSolutionOld(solutions.getParentId(),member.getIdcardNo(),member.getName(),insuranceApply.getStartTime(),insuranceApply.getEndTime(),insuranceApply.getId());
            }
            if(CollectionUtils.isNotEmpty(addMemberList)){
                memberJoinMapper.insertBatchSomeColumn(addMemberList);
                memberJoinMapper.insert(addMemberList);
            }
            memberList.addAll(addMemberList);
            for (int i = 0; i < applyDetailList.size(); i++) {
@@ -2549,19 +2548,29 @@
            }
            Long end = System.currentTimeMillis();
            logger.error("处理单数据结束时间:=========================>"+end +";耗时:====》"+(end-start));
            applyDetailJoinMapper.insertBatchSomeColumn(applyDetailList);
            applyDetailJoinMapper.insert(applyDetailList);
        }
    }
    /**
     * 查询 会员信息在方案下是否存在冲突数据
     * @param startTime
     * @param endTime
     */
    public void checkMemberSolution(String idCode,List<ApplyDetail> allDetailList,String memberName){
        List<ApplyDetail> applyDetailList = getMemberSolutionListByIdcode(idCode,allDetailList);
        if(applyDetailList.size() >Constants.ZERO){
            String companyName = applyDetailList.get(Constants.ZERO).getCompanyName();
            if(StringUtils.isNotBlank(companyName)){
                throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"该员工【"+memberName+" "+idCode+"】已在【"+companyName+"】存在保险,请联系客服确认");
            }else{
                throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"该员工【"+memberName+" "+idCode+"】在该保险方案下已存在投保记录,无法进行该操作");
            }
        };
    }
    @Override
    public void checkMemberSolution(Integer solutionParentId,String idCode,String memberName,Date startTime,Date endTime,Integer applyId){
        List<ApplyDetail> applyDetailList = new ArrayList<ApplyDetail>();
    public void checkMemberSolutionOld(Integer solutionParentId,String idCode, String memberName, Date startTime,Date endTime,Integer applyId){
        List<ApplyDetail> applyDetailList = new ArrayList<>();
        try {
            applyDetailList = applyDetailJoinMapper.selectJoinList(ApplyDetail.class,
                    new MPJLambdaWrapper<ApplyDetail>()
@@ -2599,6 +2608,51 @@
            }
        };
    }
    private List<ApplyDetail> getMemberSolutionListByIdcode(String idCode, List<ApplyDetail> allDetailList) {
        if(allDetailList == null || allDetailList.size()==0){
            return  new ArrayList<>();
        }
        List<ApplyDetail> list = new ArrayList<>();
        for(ApplyDetail d : allDetailList){
            if(StringUtils.equals(d.getIdcardNo(),idCode)){
                list.add(d);
            }
        }
        return list;
    }
    public  List<ApplyDetail>  getMemberSolutionList(Integer solutionParentId,List<String> idCodeList, Date startTime,Date endTime,Integer applyId){
        List<ApplyDetail> applyDetailList = new ArrayList<ApplyDetail>();
        try {
            applyDetailList = applyDetailJoinMapper.selectJoinList(ApplyDetail.class,
                    new MPJLambdaWrapper<ApplyDetail>()
                            .selectAll(ApplyDetail.class)
                            .selectAs(InsuranceApply::getCode,ApplyDetail::getApplyCode)
                            .selectAs(Company::getName,ApplyDetail::getCompanyName)
                            .leftJoin(InsuranceApply.class,InsuranceApply::getId,ApplyDetail::getApplyId)
                            .leftJoin(Solutions.class,Solutions::getId,InsuranceApply::getSolutionId)
                            .leftJoin(Company.class,Company::getId,InsuranceApply::getCompanyId)
                            .in(ApplyDetail::getIdcardNo,idCodeList)
                            .eq(ApplyDetail::getIsdeleted,Constants.ZERO)
                            .eq(Solutions::getParentId,solutionParentId)
                            .ne(Objects.nonNull(applyId),InsuranceApply::getId,applyId)
                            .notIn(InsuranceApply::getStatus
                                    ,Constants.InsuranceApplyStatus.FAIL_RETURN.getKey()
                                    ,Constants.InsuranceApplyStatus.COMPANY_BACK_APPLY_PASS.getKey()
                                    ,Constants.InsuranceApplyStatus.CLOSE.getKey()
                                    ,Constants.InsuranceApplyStatus.WTB_RETURN.getKey()
                                    ,Constants.InsuranceApplyStatus.WTB_CLOSED.getKey() )
                            .apply(" ( " +
                                    " '"+DateUtil.getPlusTime(startTime)+"'  <= t.start_time AND t.start_time < '"+DateUtil.getPlusTime(endTime)+"' " +
                                    " or " +
                                    "  ( '"+DateUtil.getPlusTime(startTime)+"' < t.end_time AND t.end_time < '"+DateUtil.getPlusTime(endTime)+"' )  " +
                                    " or " +
                                    " ( '"+DateUtil.getPlusTime(startTime)+"' > t.start_time AND '"+DateUtil.getPlusTime(endTime)+"' < t.end_time )" +
                                    " ) " ));
        }catch (Exception e){
        }
      return applyDetailList;
    }
    public static void checkStaticMemberSolution(Integer solutionId,Integer memberId,String memberIdCard,String memberName,Date startTime,
@@ -3775,9 +3829,6 @@
        }
        return applyPowerVO;
    }