k94314517
2024-06-20 15ef66d5eb25490cb4684c32598ca25f54cd9c4b
server/service/src/main/java/com/doumee/service/business/impl/InsuranceApplyServiceImpl.java
@@ -308,6 +308,10 @@
        if(CollectionUtils.isNotEmpty(applyDetailList)){
            List<MemberInsurance> memberInsuranceList = new ArrayList<>();
            for (ApplyDetail applyDetail:applyDetailList) {
                //查询人员信息是否存在相同的方案下是否存在 冲突数据
                this.checkMemberSolution(applyDetail.getSolutionId(),applyDetail.getIdcardNo(),applyDetail.getMemberName(),update.getStartTime(),update.getEndTime());
                MemberInsurance memberInsurance = new MemberInsurance(applyDetail,user.getId());
                memberInsurance.setRelationType(Constants.ZERO);
                memberInsuranceList.add(memberInsurance);
@@ -1944,6 +1948,8 @@
                    member.setWorktypeId(applyDetail.getWorktypeId());
                    addMemberList.add(member);
                }
                //查询人员信息是否存在相同的方案下是否存在 冲突数据
                this.checkMemberSolution(solutions.getId(),member.getIdcardNo(),member.getName(),insuranceApply.getStartTime(),insuranceApply.getEndTime());
            }
            if(CollectionUtils.isNotEmpty(addMemberList)){
                memberJoinMapper.insertBatchSomeColumn(addMemberList);
@@ -1959,6 +1965,7 @@
                ){
                    throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"对不起,投保员工信息数据缺失,请按照要求填写员工的有效信息!");
                }
                applyDetail.setChangeStatus(Constants.ZERO);
                applyDetail.setCreateDate(new Date());
                applyDetail.setCreator(loginUserInfo.getId());
                applyDetail.setIsdeleted(Constants.ZERO);
@@ -2029,6 +2036,75 @@
        }
    }
    /**
     * 查询 会员信息在方案下是否存在冲突数据
     * @param solutionId
     * @param startTime
     * @param endTime
     */
    @Override
    public void checkMemberSolution(Integer solutionId,String idCode,String memberName,Date startTime,Date endTime){
        try {
            List<ApplyDetail> applyDetailList = applyDetailJoinMapper.selectJoinList(ApplyDetail.class,
                    new MPJLambdaWrapper<ApplyDetail>()
                            .selectAll(ApplyDetail.class)
                            .selectAs(InsuranceApply::getCode,ApplyDetail::getApplyCode)
                            .leftJoin(InsuranceApply.class,InsuranceApply::getId,ApplyDetail::getApplyId)
                            .eq(ApplyDetail::getIdcardNo,idCode)
                            .eq(InsuranceApply::getSolutionId,solutionId)
                            .notIn(InsuranceApply::getStatus,Constants.InsuranceApplyStatus.UPLOAD
                                    ,Constants.InsuranceApplyStatus.PLATFORM_RETURN
                                    ,Constants.InsuranceApplyStatus.FAIL_RETURN
                                    ,Constants.InsuranceApplyStatus.CLOSE
                                    ,Constants.InsuranceApplyStatus.WTB_RETURN
                                    ,Constants.InsuranceApplyStatus.WTB_CLOSED )
                            .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 )" +
                                    " ) " ));
            if(applyDetailList.size() >Constants.ZERO){
                ApplyDetail applyDetail = applyDetailList.get(Constants.ZERO);
                throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"该用户【"+memberName+" "+idCode+"】在保单【"+applyDetail.getApplyCode()+"】下已存在与本次提报冲突的日期");
            };
        }catch (Exception e){
        }
    }
    public static void checkStaticMemberSolution(Integer solutionId,String idCode,String memberName,Date startTime,Date endTime,ApplyDetailJoinMapper applyDetailJoinMapper){
        try {
            List<ApplyDetail> applyDetailList = applyDetailJoinMapper.selectJoinList(ApplyDetail.class,
                    new MPJLambdaWrapper<ApplyDetail>()
                            .selectAll(ApplyDetail.class)
                            .selectAs(InsuranceApply::getCode,ApplyDetail::getApplyCode)
                            .leftJoin(InsuranceApply.class,InsuranceApply::getId,ApplyDetail::getApplyId)
                            .eq(ApplyDetail::getIdcardNo,idCode)
                            .eq(InsuranceApply::getSolutionId,solutionId)
                            .notIn(InsuranceApply::getStatus,Constants.InsuranceApplyStatus.UPLOAD
                                    ,Constants.InsuranceApplyStatus.PLATFORM_RETURN
                                    ,Constants.InsuranceApplyStatus.FAIL_RETURN
                                    ,Constants.InsuranceApplyStatus.CLOSE
                                    ,Constants.InsuranceApplyStatus.WTB_RETURN
                                    ,Constants.InsuranceApplyStatus.WTB_CLOSED )
                            .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 )" +
                                    " ) " ));
            if(applyDetailList.size() >Constants.ZERO){
                ApplyDetail applyDetail = applyDetailList.get(Constants.ZERO);
                throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"该用户【"+memberName+" "+idCode+"】在保单【"+applyDetail.getApplyCode()+"】下已存在与本次提报冲突的日期");
            };
        }catch (Exception e){
        }
    }
    @Override
    public void deleteById(Integer id) {
@@ -2124,7 +2200,7 @@
        queryWrapper.selectAs(Solutions::getTimeUnit,InsuranceApply::getTimeUnit);
        queryWrapper.select(" DATEDIFF( t.END_TIME ,now()  ) AS loseEfficacyDays  ");
        queryWrapper.select(" ( select count(DISTINCT(ad.MEMBER_ID)) from apply_detail ad  where ad.apply_id = t.id   ) as insureNum");
        queryWrapper.select(" ( select count(DISTINCT(ad.MEMBER_ID)) from apply_detail ad  where ad.apply_id = t.id and ad.END_TIME > now() ) as guaranteeNum");
        queryWrapper.select(" ( select count(DISTINCT(ad.MEMBER_ID)) from apply_detail ad inner join insurance_apply a on ad.apply_id = a.id  and a.status in ( 5 , 27 )  where ad.apply_id = t.id and ad.END_TIME > now() ) as guaranteeNum");
        if(!Objects.isNull(pageWrap.getModel())&&!Objects.isNull(pageWrap.getModel().getType())){
            queryWrapper.select(" ifnull(( select sum(td.fee) from taxes ts inner join tax_detial td on td.TAX_ID = ts.id  where ts.status != 2 and td.INSURANCE_APPLY_ID = t.id ),0) as taxesMoney");
            queryWrapper.select(" ( select td.CREATE_DATE from taxes ts inner join tax_detial td on td.TAX_ID = ts.id  where ts.status = 1 and td.INSURANCE_APPLY_ID = t.id order by td.CREATE_DATE desc limit 1 ) as taxesLast ");
@@ -2251,6 +2327,7 @@
        queryWrapper.selectAs(Solutions::getName,InsuranceApply::getSolutionsName);
        queryWrapper.selectAs(Solutions::getType,InsuranceApply::getSolutionType);
        queryWrapper.select(" ( select count(DISTINCT(ad.MEMBER_ID)) from apply_detail ad  where ad.apply_id = t.id ) as insureNum");
        queryWrapper.select(" ( select count(DISTINCT(ad.MEMBER_ID)) from apply_detail ad inner join insurance_apply a on ad.apply_id = a.id  and a.status in ( 5 , 27 )  where ad.apply_id = t.id and ad.END_TIME > now() ) as guaranteeNum");
        queryWrapper.select(" ( select max(ac.APPLY_START_TIME) from apply_change ac  where ac.apply_id = t.id and ac.status = 2 ) as lastChangeDate");
        queryWrapper.select(" ( select sum(td.fee) from taxes ts inner join tax_detial td on td.TAX_ID = ts.id  where ts.status != 2 and td.INSURANCE_APPLY_ID = t.id ) as taxesMoney ");
        queryWrapper.select(" ( select td.CREATE_DATE from taxes ts inner join tax_detial td on td.TAX_ID = ts.id  where ts.status != 2 and td.INSURANCE_APPLY_ID = t.id order by td.CREATE_DATE desc limit 1 ) as taxesLast ");
@@ -2396,7 +2473,7 @@
                .selectAs(Company::getName,InsuranceApply::getCompanyName)
                .select(" ( select max(ac.APPLY_START_TIME) from apply_change ac  where ac.apply_id = t.id and ac.status = 2 ) as lastChangeDate")
                .select(" ( select count(DISTINCT(ad.MEMBER_ID)) from apply_detail ad  where ad.apply_id = t.id ) as insureNum")
                .select(" ( select count(DISTINCT(ad.MEMBER_ID)) from apply_detail ad  where ad.apply_id = t.id and ad.END_TIME > now() ) as guaranteeNum")
                .select(" ( select count(DISTINCT(ad.MEMBER_ID)) from apply_detail ad inner join insurance_apply a on ad.apply_id = a.id  and a.status in ( 5 , 27 )  where ad.apply_id = t.id and ad.END_TIME > now() ) as guaranteeNum")
                .select(" t3.name as shopName")
                .leftJoin(Solutions.class,Solutions::getId,InsuranceApply::getSolutionId)
                .leftJoin(Company.class,Company::getId,InsuranceApply::getCompanyId)
@@ -2520,7 +2597,7 @@
                .selectAs(Solutions::getName,InsuranceApply::getSolutionsName)
                .selectAs(Solutions::getType,InsuranceApply::getSolutionType)
                .selectAs(Company::getName,InsuranceApply::getCompanyName)
                .select(" ( select count(DISTINCT(ad.MEMBER_ID)) from apply_detail ad  where ad.apply_id = t.id and ad.END_TIME > now() ) as guaranteeNum")
                .select(" ( select count(DISTINCT(ad.MEMBER_ID)) from apply_detail ad inner join insurance_apply a on ad.apply_id = a.id  and a.status in ( 5 , 27 )  where ad.apply_id = t.id and ad.END_TIME > now() ) as guaranteeNum")
                .leftJoin(Solutions.class,Solutions::getId,InsuranceApply::getSolutionId)
                .leftJoin(Company.class,Company::getId,InsuranceApply::getCompanyId)
                .eq(InsuranceApply::getId,model.getId())
@@ -2713,6 +2790,7 @@
                BigDecimal sumAmount = BigDecimal.ZERO;
                List<ApplyDetail> applyDetailList = applyDetailMapper
                        .selectList(new QueryWrapper<ApplyDetail>().lambda()
                                .eq(ApplyDetail::getChangeStatus,Constants.ZERO)
                                .eq(ApplyDetail::getApplyId,insuranceApply.getId()));
                if(CollectionUtils.isNotEmpty(applyDetailList)){
                    for (ApplyDetail applyDetail: applyDetailList) {