|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import cn.hutool.core.util.IdcardUtil; | 
|---|
|  |  |  | import com.alibaba.fastjson.JSONObject; | 
|---|
|  |  |  | import com.baomidou.mybatisplus.extension.api.R; | 
|---|
|  |  |  | import com.doumee.biz.system.SystemDictDataBiz; | 
|---|
|  |  |  | import com.doumee.core.annotation.excel.ExcelExporter; | 
|---|
|  |  |  | import com.doumee.core.constants.ResponseStatus; | 
|---|
|  |  |  | 
|---|
|  |  |  | if(model.getApplyEndTime()== null || model.getStartTime().getTime()>model.getApplyEndTime().getTime() ){ | 
|---|
|  |  |  | throw  new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"对不起,该申请生效周期时间不符合要求,请确认后修改重试~"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | Solutions solutions = solutionsMapper.selectById(model.getSolutionId()); | 
|---|
|  |  |  | if(Objects.isNull(solutions)){ | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"未查询方案信息"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | //计算实际截止时间 | 
|---|
|  |  |  | Date actEndTime = new Date(model.getApplyEndTime().getTime() + (insuranceApply.getStartTime().getTime() - model.getApplyStartTime().getTime())); | 
|---|
|  |  |  | LoginUserInfo user = (LoginUserInfo) SecurityUtils.getSubject().getPrincipal(); | 
|---|
|  |  |  | 
|---|
|  |  |  | if(CollectionUtils.isNotEmpty(applyDetailList)){ | 
|---|
|  |  |  | List<MemberInsurance> memberInsuranceList = new ArrayList<>(); | 
|---|
|  |  |  | for (ApplyDetail applyDetail:applyDetailList) { | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //查询人员信息是否存在相同的方案下是否存在 冲突数据 | 
|---|
|  |  |  | this.checkMemberSolution(solutions.getBaseId(),applyDetail.getIdcardNo(),applyDetail.getMemberName(),update.getStartTime() | 
|---|
|  |  |  | ,update.getEndTime(),insuranceApply.getId()); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | MemberInsurance memberInsurance = new MemberInsurance(applyDetail,user.getId()); | 
|---|
|  |  |  | memberInsurance.setRelationType(Constants.ZERO); | 
|---|
|  |  |  | memberInsuranceList.add(memberInsurance); | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public   void dealSignResult(NotifyDataReq data){ | 
|---|
|  |  |  | public   String dealSignResult(NotifyDataReq data){ | 
|---|
|  |  |  | if(data.getApplyNo() == null ){ | 
|---|
|  |  |  | throw  new BusinessException(ResponseStatus.BAD_REQUEST); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if(Constants.equalsInteger(data.getSignStatus(), Constants.THREE )){ | 
|---|
|  |  |  | if(Constants.equalsInteger(data.getSignStatus(), Constants.THREE ) | 
|---|
|  |  |  | || Constants.equalsInteger(data.getSignStatus(), Constants.TWO )){ | 
|---|
|  |  |  | //如果已保全,可下载签约附件 | 
|---|
|  |  |  | String path = systemDictDataBiz.queryByCode(Constants.OSS,Constants.RESOURCE_PATH).getCode()+ | 
|---|
|  |  |  | systemDictDataBiz.queryByCode(Constants.OSS,Constants.APPLY_FILE).getCode(); | 
|---|
|  |  |  | //直保 投保申请 | 
|---|
|  |  |  | InsuranceApply model = insuranceApplyJoinMapper.selectJoinOne(InsuranceApply.class, | 
|---|
|  |  |  | new MPJLambdaWrapper<InsuranceApply>() | 
|---|
|  |  |  | .selectAll(InsuranceApply.class) | 
|---|
|  |  |  | .selectAs(Solutions::getName,InsuranceApply::getSolutionsName) | 
|---|
|  |  |  | .selectAs(Solutions::getEmail,InsuranceApply::getSolutionEmail) | 
|---|
|  |  |  | .selectAs(Company::getName,InsuranceApply::getCompanyName) | 
|---|
|  |  |  | .leftJoin(Solutions.class,Solutions::getId,InsuranceApply::getSolutionId) | 
|---|
|  |  |  | .leftJoin(Company.class,Company::getId,InsuranceApply::getCompanyId) | 
|---|
|  |  |  | .eq(Solutions::getType,Constants.ZERO) | 
|---|
|  |  |  | .eq(InsuranceApply::getSignApplyNo,data.getApplyNo()) | 
|---|
|  |  |  | .last("limit 1" )); | 
|---|
|  |  |  | if(model != null && Constants.equalsInteger(model.getStatus(),Constants.InsuranceApplyStatus.WAIT_SIGNATURE.getKey())){ | 
|---|
|  |  |  | String r = dealXBTBBiz(path,data,"直保-投保申请签署"); | 
|---|
|  |  |  | if(StringUtils.isNotBlank(r)){ | 
|---|
|  |  |  | return  r; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | r = dealWTBQYQRSBiz(path,data,"委托保-企业方案确认书签署"); | 
|---|
|  |  |  | if(StringUtils.isNotBlank(r)){ | 
|---|
|  |  |  | return  r; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | r = dealWTBQYRYMQDBiz(path,data,"委托保-企业人员名单签署"); | 
|---|
|  |  |  | if(StringUtils.isNotBlank(r)){ | 
|---|
|  |  |  | return  r; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | r = dealWTBTBSQBiz(path,data,"委托保-投保申请书签署"); | 
|---|
|  |  |  | if(StringUtils.isNotBlank(r)){ | 
|---|
|  |  |  | return  r; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | r = dealZBJJBQYBiz(path,data,"直保-加减保企业签署"); | 
|---|
|  |  |  | if(StringUtils.isNotBlank(r)){ | 
|---|
|  |  |  | return  r; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | r = dealWTBJJBQYBiz(path,data,"委托保-加减保企业签署"); | 
|---|
|  |  |  | if(StringUtils.isNotBlank(r)){ | 
|---|
|  |  |  | return  r; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | r = dealHBDSHBiz(path,data,"投保合并单-商户签署签署"); | 
|---|
|  |  |  | if(StringUtils.isNotBlank(r)){ | 
|---|
|  |  |  | return  r; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | r = dealHBCHANGEQYBiz(path,data,"合并加减保/换厂签署"); | 
|---|
|  |  |  | if(StringUtils.isNotBlank(r)){ | 
|---|
|  |  |  | return  r; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return "无处理数据"; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | private String dealHBCHANGEQYBiz(String path, NotifyDataReq data, String title) { | 
|---|
|  |  |  | UnionChange unionChange = unionChangeJoinMapper.selectOne( | 
|---|
|  |  |  | new MPJLambdaWrapper<UnionChange>() | 
|---|
|  |  |  | .selectAll(UnionChange.class) | 
|---|
|  |  |  | .eq(UnionChange::getSignApplyNo,data.getApplyNo()) | 
|---|
|  |  |  | .last(" limit 1 ")); | 
|---|
|  |  |  | if(unionChange == null){ | 
|---|
|  |  |  | return null; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if( Constants.equalsInteger(unionChange.getStatus(),Constants.UnionChangeStatus.MERGE.getKey())){ | 
|---|
|  |  |  | if(Constants.equalsInteger(data.getSignStatus(), Constants.THREE )){ | 
|---|
|  |  |  | //完成签署已完成操作 | 
|---|
|  |  |  | String link = signService.linkFile(data.getApplyNo()); | 
|---|
|  |  |  | String link = signService.linkFile(unionChange.getSignApplyNo()); | 
|---|
|  |  |  | String fileUrl = uploadSignFile(link); | 
|---|
|  |  |  | if(StringUtils.isBlank(fileUrl)){ | 
|---|
|  |  |  | //如果下载失败,清除合同,下次签章重新生成新合同 | 
|---|
|  |  |  | return; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | uploadSignedFileDo(model,fileUrl,path+fileUrl); | 
|---|
|  |  |  | return; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | //委托保 企业方案确认书 | 
|---|
|  |  |  | InsuranceApply modelTBQRS = insuranceApplyJoinMapper.selectJoinOne(InsuranceApply.class, | 
|---|
|  |  |  | new MPJLambdaWrapper<InsuranceApply>() | 
|---|
|  |  |  | .selectAll(InsuranceApply.class) | 
|---|
|  |  |  | .selectAs(Solutions::getName,InsuranceApply::getSolutionsName) | 
|---|
|  |  |  | .selectAs(Solutions::getEmail,InsuranceApply::getSolutionEmail) | 
|---|
|  |  |  | .selectAs(Company::getName,InsuranceApply::getCompanyName) | 
|---|
|  |  |  | .leftJoin(Solutions.class,Solutions::getId,InsuranceApply::getSolutionId) | 
|---|
|  |  |  | .leftJoin(Company.class,Company::getId,InsuranceApply::getCompanyId) | 
|---|
|  |  |  | .eq(Solutions::getType,Constants.ONE) | 
|---|
|  |  |  | .eq(InsuranceApply::getSignQrsNo,data.getApplyNo()) | 
|---|
|  |  |  | .last("limit 1" )); | 
|---|
|  |  |  | if(modelTBQRS != null && Constants.equalsInteger(modelTBQRS.getStatus(),Constants.InsuranceApplyStatus.WTB_UPLOAD.getKey())){ | 
|---|
|  |  |  | //完成签署已完成操作 | 
|---|
|  |  |  | String link = signService.linkFile(data.getApplyNo()); | 
|---|
|  |  |  | String fileUrl = uploadSignFile(link); | 
|---|
|  |  |  | if(StringUtils.isBlank(fileUrl)){ | 
|---|
|  |  |  | //如果下载失败,清除合同,下次签章重新生成新合同 | 
|---|
|  |  |  | return; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | uploadFAQRSSignedFileDo(modelTBQRS,fileUrl,path+fileUrl); | 
|---|
|  |  |  | return; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //委托保 企业签署人员名单 | 
|---|
|  |  |  | InsuranceApply modelMemberList = insuranceApplyJoinMapper.selectJoinOne(InsuranceApply.class, | 
|---|
|  |  |  | new MPJLambdaWrapper<InsuranceApply>() | 
|---|
|  |  |  | .selectAll(InsuranceApply.class) | 
|---|
|  |  |  | .selectAs(Solutions::getName,InsuranceApply::getSolutionsName) | 
|---|
|  |  |  | .selectAs(Solutions::getEmail,InsuranceApply::getSolutionEmail) | 
|---|
|  |  |  | .selectAs(Company::getName,InsuranceApply::getCompanyName) | 
|---|
|  |  |  | .leftJoin(Solutions.class,Solutions::getId,InsuranceApply::getSolutionId) | 
|---|
|  |  |  | .leftJoin(Company.class,Company::getId,InsuranceApply::getCompanyId) | 
|---|
|  |  |  | .eq(Solutions::getType,Constants.ONE) | 
|---|
|  |  |  | .eq(InsuranceApply::getSignMemberListNo,data.getApplyNo()) | 
|---|
|  |  |  | .last("limit 1" )); | 
|---|
|  |  |  | if(modelMemberList != null && Constants.equalsInteger(modelMemberList.getStatus(),Constants.InsuranceApplyStatus.WTB_COMPANY_APPLY_SIGNATURE.getKey())){ | 
|---|
|  |  |  | //完成签署已完成操作 | 
|---|
|  |  |  | String link = signService.linkFile(data.getApplyNo()); | 
|---|
|  |  |  | String fileUrl = uploadSignFile(link); | 
|---|
|  |  |  | if(StringUtils.isBlank(fileUrl)){ | 
|---|
|  |  |  | //如果下载失败,清除合同,下次签章重新生成新合同 | 
|---|
|  |  |  | return; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | uploadApplyMemberListSignedFileDo(modelMemberList,fileUrl,path+fileUrl); | 
|---|
|  |  |  | return; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //委托保 投保申请书签署 | 
|---|
|  |  |  | InsuranceApply modelTBQSQ = insuranceApplyJoinMapper.selectJoinOne(InsuranceApply.class, | 
|---|
|  |  |  | new MPJLambdaWrapper<InsuranceApply>() | 
|---|
|  |  |  | .selectAll(InsuranceApply.class) | 
|---|
|  |  |  | .selectAs(Solutions::getName,InsuranceApply::getSolutionsName) | 
|---|
|  |  |  | .selectAs(Solutions::getEmail,InsuranceApply::getSolutionEmail) | 
|---|
|  |  |  | .selectAs(Company::getName,InsuranceApply::getCompanyName) | 
|---|
|  |  |  | .leftJoin(Solutions.class,Solutions::getId,InsuranceApply::getSolutionId) | 
|---|
|  |  |  | .leftJoin(Company.class,Company::getId,InsuranceApply::getCompanyId) | 
|---|
|  |  |  | .eq(Solutions::getType,Constants.ONE) | 
|---|
|  |  |  | .eq(InsuranceApply::getApplyTbdNo,data.getApplyNo()) | 
|---|
|  |  |  | .last("limit 1" )); | 
|---|
|  |  |  | if(modelTBQRS != null && Constants.equalsInteger(modelTBQSQ.getUnionApplyTbdStatus(),Constants.ONE)){ | 
|---|
|  |  |  | //完成签署已完成操作 | 
|---|
|  |  |  | String link = signService.linkFile(data.getApplyNo()); | 
|---|
|  |  |  | String fileUrl = uploadSignFile(link); | 
|---|
|  |  |  | if(StringUtils.isBlank(fileUrl)){ | 
|---|
|  |  |  | //如果下载失败,清除合同,下次签章重新生成新合同 | 
|---|
|  |  |  | return; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | uploadTBSQSSignedFileDo(modelTBQSQ,fileUrl,path+fileUrl); | 
|---|
|  |  |  | return; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //直保 加减保企业签署 | 
|---|
|  |  |  | ApplyChange applyChange = applyChangeMapper.selectJoinOne(ApplyChange.class, | 
|---|
|  |  |  | new MPJLambdaWrapper<ApplyChange>() | 
|---|
|  |  |  | .selectAll(ApplyChange.class) | 
|---|
|  |  |  | .selectAs(Solutions::getName,InsuranceApply::getSolutionsName) | 
|---|
|  |  |  | .selectAs(Solutions::getEmail,InsuranceApply::getSolutionEmail) | 
|---|
|  |  |  | .selectAs(Solutions::getId,ApplyChange::getSolutionsId) | 
|---|
|  |  |  | .selectAs(Company::getName,InsuranceApply::getCompanyName) | 
|---|
|  |  |  | .selectAs(InsuranceApply::getCompanyId,ApplyChange::getCompanyId) | 
|---|
|  |  |  | .leftJoin(InsuranceApply.class,InsuranceApply::getId,ApplyChange::getApplyId) | 
|---|
|  |  |  | .leftJoin(Solutions.class,Solutions::getId,InsuranceApply::getSolutionId) | 
|---|
|  |  |  | .leftJoin(Company.class,Company::getId,InsuranceApply::getCompanyId) | 
|---|
|  |  |  | .eq(Solutions::getType,Constants.ZERO) | 
|---|
|  |  |  | .eq(ApplyChange::getSignApplyNo,data.getApplyNo()).last("limit 1" )); | 
|---|
|  |  |  | if(applyChange != null &&Constants.equalsInteger(applyChange.getStatus(),Constants.ApplyChangeStatus.UPLOAD.getKey())){ | 
|---|
|  |  |  | String link = signService.linkFile(data.getApplyNo()); | 
|---|
|  |  |  | String fileUrl = uploadSignFile(link); | 
|---|
|  |  |  | if(StringUtils.isBlank(fileUrl)){ | 
|---|
|  |  |  | //如果下载失败,清除合同,下次签章重新生成新合同 | 
|---|
|  |  |  | return; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | uploadChangeSignedFileDo(applyChange,fileUrl,path+fileUrl); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //委托保 加减保企业签署 | 
|---|
|  |  |  | ApplyChange applyChangeMemberList = applyChangeMapper.selectJoinOne(ApplyChange.class, | 
|---|
|  |  |  | new MPJLambdaWrapper<ApplyChange>() | 
|---|
|  |  |  | .selectAll(ApplyChange.class) | 
|---|
|  |  |  | .selectAs(Solutions::getName,InsuranceApply::getSolutionsName) | 
|---|
|  |  |  | .selectAs(Solutions::getEmail,InsuranceApply::getSolutionEmail) | 
|---|
|  |  |  | .selectAs(Solutions::getId,ApplyChange::getSolutionsId) | 
|---|
|  |  |  | .selectAs(Company::getName,InsuranceApply::getCompanyName) | 
|---|
|  |  |  | .selectAs(InsuranceApply::getCompanyId,ApplyChange::getCompanyId) | 
|---|
|  |  |  | .leftJoin(InsuranceApply.class,InsuranceApply::getId,ApplyChange::getApplyId) | 
|---|
|  |  |  | .leftJoin(Solutions.class,Solutions::getId,InsuranceApply::getSolutionId) | 
|---|
|  |  |  | .leftJoin(Company.class,Company::getId,InsuranceApply::getCompanyId) | 
|---|
|  |  |  | .eq(Solutions::getType,Constants.ONE) | 
|---|
|  |  |  | .eq(ApplyChange::getSignMemberListNo,data.getApplyNo()).last("limit 1" )); | 
|---|
|  |  |  | if(applyChangeMemberList != null &&Constants.equalsInteger(applyChangeMemberList.getStatus(),Constants.ApplyChangeStatus.UPLOAD.getKey())){ | 
|---|
|  |  |  | String link = signService.linkFile(data.getApplyNo()); | 
|---|
|  |  |  | String fileUrl = uploadSignFile(link); | 
|---|
|  |  |  | if(StringUtils.isBlank(fileUrl)){ | 
|---|
|  |  |  | //如果下载失败,清除合同,下次签章重新生成新合同 | 
|---|
|  |  |  | return; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | uploadChangeMemberListSignedFileDo(applyChangeMemberList,fileUrl,path+fileUrl); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //投保合并单 商户签署保单 | 
|---|
|  |  |  | UnionApply unionApply = unionApplyJoinMapper.selectOne(new QueryWrapper<UnionApply>() | 
|---|
|  |  |  | .lambda().eq(UnionApply::getSignApplyNo,data.getApplyNo()).last(" limit 1 ")); | 
|---|
|  |  |  | if(unionApply != null &&Constants.equalsInteger(unionApply.getStatus(),Constants.UnionApplyStatus.WAIT_SIGNATURE.getKey())){ | 
|---|
|  |  |  | String link = signService.linkFile(data.getApplyNo()); | 
|---|
|  |  |  | String fileUrl = uploadSignFile(link); | 
|---|
|  |  |  | if(StringUtils.isBlank(fileUrl)){ | 
|---|
|  |  |  | //如果下载失败,清除合同,下次签章重新生成新合同 | 
|---|
|  |  |  | return; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | uploadUnionApplySignedFileDo(unionApply,fileUrl,path+fileUrl); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | *合并加减保换厂 签署业务 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | UnionChange unionChange = unionChangeJoinMapper.selectOne( | 
|---|
|  |  |  | new MPJLambdaWrapper<UnionChange>() | 
|---|
|  |  |  | .selectAll(UnionChange.class) | 
|---|
|  |  |  | .eq(UnionChange::getSignApplyNo,data.getApplyNo()) | 
|---|
|  |  |  | .last(" limit 1 ")); | 
|---|
|  |  |  | if(unionChange != null &&Constants.equalsInteger(unionChange.getStatus(),Constants.UnionChangeStatus.MERGE.getKey())){ | 
|---|
|  |  |  | String link = signService.linkFile(model.getSignApplyNo()); | 
|---|
|  |  |  | String fileUrl = uploadSignFile(link); | 
|---|
|  |  |  | if(StringUtils.isBlank(fileUrl)){ | 
|---|
|  |  |  | //如果下载失败,清除合同,下次签章重新生成新合同 | 
|---|
|  |  |  | return; | 
|---|
|  |  |  | return title+"合同下载失败,等待下次推送处理"; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | uploadUnionChangeSignedFileDo(unionChange,fileUrl,path+fileUrl); | 
|---|
|  |  |  | return title+"状态处理成功"; | 
|---|
|  |  |  | }else{ | 
|---|
|  |  |  | //如果已拒签,清除合同,下次签章重新生成新合同 | 
|---|
|  |  |  | unionChangeJoinMapper.update(null,new UpdateWrapper<UnionChange>().lambda() | 
|---|
|  |  |  | .set(UnionChange::getSignApplyNo,null) | 
|---|
|  |  |  | .eq(UnionChange::getSignApplyNo,data.getApplyNo())); | 
|---|
|  |  |  | return title+"合同拒签处理成功"; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return  title+"状态已流转,不做处理"; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | private String dealHBDSHBiz(String path, NotifyDataReq data, String title) { | 
|---|
|  |  |  | //投保合并单 商户签署保单 | 
|---|
|  |  |  | UnionApply unionApply = unionApplyJoinMapper.selectOne(new QueryWrapper<UnionApply>() | 
|---|
|  |  |  | .lambda().eq(UnionApply::getSignApplyNo,data.getApplyNo()).last(" limit 1 ")); | 
|---|
|  |  |  | if(unionApply == null){ | 
|---|
|  |  |  | return null; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if( Constants.equalsInteger(unionApply.getStatus(),Constants.UnionApplyStatus.WAIT_SIGNATURE.getKey())){ | 
|---|
|  |  |  | if(Constants.equalsInteger(data.getSignStatus(), Constants.THREE )){ | 
|---|
|  |  |  | //完成签署已完成操作 | 
|---|
|  |  |  | String link = signService.linkFile(data.getApplyNo()); | 
|---|
|  |  |  | String fileUrl = uploadSignFile(link); | 
|---|
|  |  |  | if(StringUtils.isBlank(fileUrl)){ | 
|---|
|  |  |  | //如果下载失败,清除合同,下次签章重新生成新合同 | 
|---|
|  |  |  | return title+"合同下载失败,等待下次推送处理"; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | uploadUnionApplySignedFileDo(unionApply,fileUrl,path+fileUrl); | 
|---|
|  |  |  | return title+"状态处理成功"; | 
|---|
|  |  |  | }else{ | 
|---|
|  |  |  | //如果已拒签,清除合同,下次签章重新生成新合同 | 
|---|
|  |  |  | unionApplyJoinMapper.update(null,new UpdateWrapper<UnionApply>().lambda() | 
|---|
|  |  |  | .set(UnionApply::getSignApplyNo,null) | 
|---|
|  |  |  | .eq(UnionApply::getSignApplyNo,data.getApplyNo())); | 
|---|
|  |  |  | return title+"合同拒签处理成功"; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return  title+"状态已流转,不做处理"; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | private String dealWTBJJBQYBiz(String path, NotifyDataReq data, String title) { | 
|---|
|  |  |  | //委托保 加减保企业签署 | 
|---|
|  |  |  | ApplyChange applyChangeMemberList = applyChangeMapper.selectJoinOne(ApplyChange.class, | 
|---|
|  |  |  | new MPJLambdaWrapper<ApplyChange>() | 
|---|
|  |  |  | .selectAll(ApplyChange.class) | 
|---|
|  |  |  | .selectAs(Solutions::getName,InsuranceApply::getSolutionsName) | 
|---|
|  |  |  | .selectAs(Solutions::getEmail,InsuranceApply::getSolutionEmail) | 
|---|
|  |  |  | .selectAs(Solutions::getId,ApplyChange::getSolutionsId) | 
|---|
|  |  |  | .selectAs(Company::getName,InsuranceApply::getCompanyName) | 
|---|
|  |  |  | .selectAs(InsuranceApply::getCompanyId,ApplyChange::getCompanyId) | 
|---|
|  |  |  | .leftJoin(InsuranceApply.class,InsuranceApply::getId,ApplyChange::getApplyId) | 
|---|
|  |  |  | .leftJoin(Solutions.class,Solutions::getId,InsuranceApply::getSolutionId) | 
|---|
|  |  |  | .leftJoin(Company.class,Company::getId,InsuranceApply::getCompanyId) | 
|---|
|  |  |  | .eq(Solutions::getType,Constants.ONE) | 
|---|
|  |  |  | .eq(ApplyChange::getSignMemberListNo,data.getApplyNo()).last("limit 1" )); | 
|---|
|  |  |  | if(applyChangeMemberList == null){ | 
|---|
|  |  |  | return null; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if( Constants.equalsInteger(applyChangeMemberList.getStatus(),Constants.ApplyChangeStatus.UPLOAD.getKey())){ | 
|---|
|  |  |  | if(Constants.equalsInteger(data.getSignStatus(), Constants.THREE )){ | 
|---|
|  |  |  | //完成签署已完成操作 | 
|---|
|  |  |  | String link = signService.linkFile(data.getApplyNo()); | 
|---|
|  |  |  | String fileUrl = uploadSignFile(link); | 
|---|
|  |  |  | if(StringUtils.isBlank(fileUrl)){ | 
|---|
|  |  |  | //如果下载失败,清除合同,下次签章重新生成新合同 | 
|---|
|  |  |  | return title+"合同下载失败,等待下次推送处理"; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | uploadChangeMemberListSignedFileDo(applyChangeMemberList,fileUrl,path+fileUrl); | 
|---|
|  |  |  | return title+"状态处理成功"; | 
|---|
|  |  |  | }else{ | 
|---|
|  |  |  | //如果已拒签,清除合同,下次签章重新生成新合同 | 
|---|
|  |  |  | applyChangeMapper.update(null,new UpdateWrapper<ApplyChange>().lambda() | 
|---|
|  |  |  | .set(ApplyChange::getSignMemberListNo,null) | 
|---|
|  |  |  | .eq(ApplyChange::getSignMemberListNo,data.getApplyNo())); | 
|---|
|  |  |  | return title+"合同拒签处理成功"; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return  title+"状态已流转,不做处理"; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | private String dealZBJJBQYBiz(String path, NotifyDataReq data, String title) { | 
|---|
|  |  |  | //直保 加减保企业签署 | 
|---|
|  |  |  | ApplyChange applyChange = applyChangeMapper.selectJoinOne(ApplyChange.class, | 
|---|
|  |  |  | new MPJLambdaWrapper<ApplyChange>() | 
|---|
|  |  |  | .selectAll(ApplyChange.class) | 
|---|
|  |  |  | .selectAs(Solutions::getName,InsuranceApply::getSolutionsName) | 
|---|
|  |  |  | .selectAs(Solutions::getEmail,InsuranceApply::getSolutionEmail) | 
|---|
|  |  |  | .selectAs(Solutions::getId,ApplyChange::getSolutionsId) | 
|---|
|  |  |  | .selectAs(Company::getName,InsuranceApply::getCompanyName) | 
|---|
|  |  |  | .selectAs(InsuranceApply::getCompanyId,ApplyChange::getCompanyId) | 
|---|
|  |  |  | .leftJoin(InsuranceApply.class,InsuranceApply::getId,ApplyChange::getApplyId) | 
|---|
|  |  |  | .leftJoin(Solutions.class,Solutions::getId,InsuranceApply::getSolutionId) | 
|---|
|  |  |  | .leftJoin(Company.class,Company::getId,InsuranceApply::getCompanyId) | 
|---|
|  |  |  | .eq(Solutions::getType,Constants.ZERO) | 
|---|
|  |  |  | .eq(ApplyChange::getSignApplyNo,data.getApplyNo()).last("limit 1" )); | 
|---|
|  |  |  | if(applyChange == null){ | 
|---|
|  |  |  | return null; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if( Constants.equalsInteger(applyChange.getStatus(),Constants.ApplyChangeStatus.UPLOAD.getKey())){ | 
|---|
|  |  |  | if(Constants.equalsInteger(data.getSignStatus(), Constants.THREE )){ | 
|---|
|  |  |  | //完成签署已完成操作 | 
|---|
|  |  |  | String link = signService.linkFile(data.getApplyNo()); | 
|---|
|  |  |  | String fileUrl = uploadSignFile(link); | 
|---|
|  |  |  | if(StringUtils.isBlank(fileUrl)){ | 
|---|
|  |  |  | //如果下载失败,清除合同,下次签章重新生成新合同 | 
|---|
|  |  |  | return title+"合同下载失败,等待下次推送处理"; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | uploadChangeSignedFileDo(applyChange,fileUrl,path+fileUrl); | 
|---|
|  |  |  | return title+"状态处理成功"; | 
|---|
|  |  |  | }else{ | 
|---|
|  |  |  | //如果已拒签,清除合同,下次签章重新生成新合同 | 
|---|
|  |  |  | applyChangeMapper.update(null,new UpdateWrapper<ApplyChange>().lambda() | 
|---|
|  |  |  | .set(ApplyChange::getSignApplyNo,null) | 
|---|
|  |  |  | .eq(ApplyChange::getSignApplyNo,data.getApplyNo())); | 
|---|
|  |  |  | return title+"合同拒签处理成功"; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | return  title+"状态已流转,不做处理"; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | private String dealWTBTBSQBiz(String path, NotifyDataReq data, String title) { | 
|---|
|  |  |  | //委托保 投保申请书签署 | 
|---|
|  |  |  | InsuranceApply modelTBQSQ = insuranceApplyJoinMapper.selectJoinOne(InsuranceApply.class, | 
|---|
|  |  |  | new MPJLambdaWrapper<InsuranceApply>() | 
|---|
|  |  |  | .selectAll(InsuranceApply.class) | 
|---|
|  |  |  | .selectAs(Solutions::getName,InsuranceApply::getSolutionsName) | 
|---|
|  |  |  | .selectAs(Solutions::getEmail,InsuranceApply::getSolutionEmail) | 
|---|
|  |  |  | .selectAs(Company::getName,InsuranceApply::getCompanyName) | 
|---|
|  |  |  | .leftJoin(Solutions.class,Solutions::getId,InsuranceApply::getSolutionId) | 
|---|
|  |  |  | .leftJoin(Company.class,Company::getId,InsuranceApply::getCompanyId) | 
|---|
|  |  |  | .eq(Solutions::getType,Constants.ONE) | 
|---|
|  |  |  | .eq(InsuranceApply::getApplyTbdNo,data.getApplyNo()) | 
|---|
|  |  |  | .last("limit 1" )); | 
|---|
|  |  |  | if(modelTBQSQ == null){ | 
|---|
|  |  |  | return null; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if( Constants.equalsInteger(modelTBQSQ.getUnionApplyTbdStatus(),Constants.ONE)){ | 
|---|
|  |  |  | if(Constants.equalsInteger(data.getSignStatus(), Constants.THREE )){ | 
|---|
|  |  |  | //完成签署已完成操作 | 
|---|
|  |  |  | String link = signService.linkFile(data.getApplyNo()); | 
|---|
|  |  |  | String fileUrl = uploadSignFile(link); | 
|---|
|  |  |  | if(StringUtils.isBlank(fileUrl)){ | 
|---|
|  |  |  | //如果下载失败,清除合同,下次签章重新生成新合同 | 
|---|
|  |  |  | return title+"合同下载失败,等待下次推送处理"; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | uploadTBSQSSignedFileDo(modelTBQSQ,fileUrl,path+fileUrl); | 
|---|
|  |  |  | return title+"状态处理成功"; | 
|---|
|  |  |  | }else{ | 
|---|
|  |  |  | //如果已拒签,清除合同,下次签章重新生成新合同 | 
|---|
|  |  |  | insuranceApplyJoinMapper.update(null,new UpdateWrapper<InsuranceApply>().lambda() | 
|---|
|  |  |  | .set(InsuranceApply::getApplyTbdNo,null) | 
|---|
|  |  |  | .eq(InsuranceApply::getApplyTbdNo,data.getApplyNo())); | 
|---|
|  |  |  | return title+"合同拒签处理成功"; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return  title+"状态已流转,不做处理"; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | private String dealWTBQYRYMQDBiz(String path, NotifyDataReq data, String title) { | 
|---|
|  |  |  | //委托保 企业签署人员名单 | 
|---|
|  |  |  | InsuranceApply modelMemberList = insuranceApplyJoinMapper.selectJoinOne(InsuranceApply.class, | 
|---|
|  |  |  | new MPJLambdaWrapper<InsuranceApply>() | 
|---|
|  |  |  | .selectAll(InsuranceApply.class) | 
|---|
|  |  |  | .selectAs(Solutions::getName,InsuranceApply::getSolutionsName) | 
|---|
|  |  |  | .selectAs(Solutions::getEmail,InsuranceApply::getSolutionEmail) | 
|---|
|  |  |  | .selectAs(Company::getName,InsuranceApply::getCompanyName) | 
|---|
|  |  |  | .leftJoin(Solutions.class,Solutions::getId,InsuranceApply::getSolutionId) | 
|---|
|  |  |  | .leftJoin(Company.class,Company::getId,InsuranceApply::getCompanyId) | 
|---|
|  |  |  | .eq(Solutions::getType,Constants.ONE) | 
|---|
|  |  |  | .eq(InsuranceApply::getSignMemberListNo,data.getApplyNo()) | 
|---|
|  |  |  | .last("limit 1" )); | 
|---|
|  |  |  | if(modelMemberList == null){ | 
|---|
|  |  |  | return null; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if( Constants.equalsInteger(modelMemberList.getStatus(),Constants.InsuranceApplyStatus.WTB_COMPANY_APPLY_SIGNATURE.getKey())){ | 
|---|
|  |  |  | if(Constants.equalsInteger(data.getSignStatus(), Constants.THREE )){ | 
|---|
|  |  |  | //完成签署已完成操作 | 
|---|
|  |  |  | String link = signService.linkFile(data.getApplyNo()); | 
|---|
|  |  |  | String fileUrl = uploadSignFile(link); | 
|---|
|  |  |  | if(StringUtils.isBlank(fileUrl)){ | 
|---|
|  |  |  | //如果下载失败,清除合同,下次签章重新生成新合同 | 
|---|
|  |  |  | return title+"合同下载失败,等待下次推送处理"; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | uploadApplyMemberListSignedFileDo(modelMemberList,fileUrl,path+fileUrl); | 
|---|
|  |  |  | return title+"状态处理成功"; | 
|---|
|  |  |  | }else{ | 
|---|
|  |  |  | //如果已拒签,清除合同,下次签章重新生成新合同 | 
|---|
|  |  |  | insuranceApplyMapper.update(null,new UpdateWrapper<InsuranceApply>().lambda() | 
|---|
|  |  |  | .set(InsuranceApply::getSignMemberListNo,null) | 
|---|
|  |  |  | .eq(InsuranceApply::getSignMemberListNo,data.getApplyNo())); | 
|---|
|  |  |  | return title+"合同拒签处理成功"; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return  title+"状态已流转,不做处理"; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | private String dealWTBQYQRSBiz(String path, NotifyDataReq data, String title) { | 
|---|
|  |  |  | //委托保 企业方案确认书 | 
|---|
|  |  |  | InsuranceApply modelTBQRS = insuranceApplyJoinMapper.selectJoinOne(InsuranceApply.class, | 
|---|
|  |  |  | new MPJLambdaWrapper<InsuranceApply>() | 
|---|
|  |  |  | .selectAll(InsuranceApply.class) | 
|---|
|  |  |  | .selectAs(Solutions::getName,InsuranceApply::getSolutionsName) | 
|---|
|  |  |  | .selectAs(Solutions::getEmail,InsuranceApply::getSolutionEmail) | 
|---|
|  |  |  | .selectAs(Company::getName,InsuranceApply::getCompanyName) | 
|---|
|  |  |  | .leftJoin(Solutions.class,Solutions::getId,InsuranceApply::getSolutionId) | 
|---|
|  |  |  | .leftJoin(Company.class,Company::getId,InsuranceApply::getCompanyId) | 
|---|
|  |  |  | .eq(Solutions::getType,Constants.ONE) | 
|---|
|  |  |  | .eq(InsuranceApply::getSignQrsNo,data.getApplyNo()) | 
|---|
|  |  |  | .last("limit 1" )); | 
|---|
|  |  |  | if(modelTBQRS == null){ | 
|---|
|  |  |  | return null; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if(  Constants.equalsInteger(modelTBQRS.getStatus(),Constants.InsuranceApplyStatus.WTB_UPLOAD.getKey())){ | 
|---|
|  |  |  | if(Constants.equalsInteger(data.getSignStatus(), Constants.THREE )){ | 
|---|
|  |  |  | //完成签署已完成操作 | 
|---|
|  |  |  | String link = signService.linkFile(data.getApplyNo()); | 
|---|
|  |  |  | String fileUrl = uploadSignFile(link); | 
|---|
|  |  |  | if(StringUtils.isBlank(fileUrl)){ | 
|---|
|  |  |  | //如果下载失败,清除合同,下次签章重新生成新合同 | 
|---|
|  |  |  | return title+"合同下载失败,等待下次推送处理"; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | uploadFAQRSSignedFileDo(modelTBQRS,fileUrl,path+fileUrl); | 
|---|
|  |  |  | return title+"状态处理成功"; | 
|---|
|  |  |  | }else{ | 
|---|
|  |  |  | //如果已拒签,清除合同,下次签章重新生成新合同 | 
|---|
|  |  |  | insuranceApplyMapper.update(null,new UpdateWrapper<InsuranceApply>().lambda() | 
|---|
|  |  |  | .set(InsuranceApply::getSignQrsNo,null) | 
|---|
|  |  |  | .eq(InsuranceApply::getSignQrsNo,data.getApplyNo())); | 
|---|
|  |  |  | return title+"合同拒签处理成功"; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | }else if(Constants.equalsInteger(data.getSignStatus(), Constants.TWO )){ | 
|---|
|  |  |  | //如果已拒签,清除合同,下次签章重新生成新合同 | 
|---|
|  |  |  | insuranceApplyMapper.update(null,new UpdateWrapper<InsuranceApply>().lambda() | 
|---|
|  |  |  | .set(InsuranceApply::getSignApplyNo,null) | 
|---|
|  |  |  | .eq(InsuranceApply::getSignApplyNo,data.getApplyNo())); | 
|---|
|  |  |  | applyChangeMapper.update(null,new UpdateWrapper<ApplyChange>().lambda() | 
|---|
|  |  |  | .set(ApplyChange::getSignApplyNo,null) | 
|---|
|  |  |  | .eq(ApplyChange::getSignApplyNo,data.getApplyNo())); | 
|---|
|  |  |  | insuranceApplyMapper.update(null,new UpdateWrapper<InsuranceApply>().lambda() | 
|---|
|  |  |  | .set(InsuranceApply::getSignQrsNo,null) | 
|---|
|  |  |  | .eq(InsuranceApply::getSignQrsNo,data.getApplyNo())); | 
|---|
|  |  |  | insuranceApplyMapper.update(null,new UpdateWrapper<InsuranceApply>().lambda() | 
|---|
|  |  |  | .set(InsuranceApply::getSignMemberListNo,null) | 
|---|
|  |  |  | .eq(InsuranceApply::getSignMemberListNo,data.getApplyNo())); | 
|---|
|  |  |  | unionApplyJoinMapper.update(null,new UpdateWrapper<UnionApply>().lambda() | 
|---|
|  |  |  | .set(UnionApply::getSignApplyNo,null) | 
|---|
|  |  |  | .eq(UnionApply::getSignApplyNo,data.getApplyNo())); | 
|---|
|  |  |  | applyChangeMapper.update(null,new UpdateWrapper<ApplyChange>().lambda() | 
|---|
|  |  |  | .set(ApplyChange::getSignMemberListNo,null) | 
|---|
|  |  |  | .eq(ApplyChange::getSignMemberListNo,data.getApplyNo())); | 
|---|
|  |  |  | unionChangeJoinMapper.update(null,new UpdateWrapper<UnionChange>().lambda() | 
|---|
|  |  |  | .set(UnionChange::getSignApplyNo,null) | 
|---|
|  |  |  | .eq(UnionChange::getSignApplyNo,data.getApplyNo())); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return  title+"状态已流转,不做处理"; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 投保直保申请签署 | 
|---|
|  |  |  | * @param path | 
|---|
|  |  |  | * @param data | 
|---|
|  |  |  | * @return | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | private String dealXBTBBiz(String path, NotifyDataReq data,String title) { | 
|---|
|  |  |  | InsuranceApply model = insuranceApplyJoinMapper.selectJoinOne(InsuranceApply.class, | 
|---|
|  |  |  | new MPJLambdaWrapper<InsuranceApply>() | 
|---|
|  |  |  | .selectAll(InsuranceApply.class) | 
|---|
|  |  |  | .selectAs(Solutions::getName,InsuranceApply::getSolutionsName) | 
|---|
|  |  |  | .selectAs(Solutions::getEmail,InsuranceApply::getSolutionEmail) | 
|---|
|  |  |  | .selectAs(Company::getName,InsuranceApply::getCompanyName) | 
|---|
|  |  |  | .leftJoin(Solutions.class,Solutions::getId,InsuranceApply::getSolutionId) | 
|---|
|  |  |  | .leftJoin(Company.class,Company::getId,InsuranceApply::getCompanyId) | 
|---|
|  |  |  | .eq(Solutions::getType,Constants.ZERO) | 
|---|
|  |  |  | .eq(InsuranceApply::getSignApplyNo,data.getApplyNo()) | 
|---|
|  |  |  | .last("limit 1" )); | 
|---|
|  |  |  | if(model == null){ | 
|---|
|  |  |  | return null; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if(  Constants.equalsInteger(model.getStatus(),Constants.InsuranceApplyStatus.WAIT_SIGNATURE.getKey())){ | 
|---|
|  |  |  | //完成签署已完成操作 | 
|---|
|  |  |  | if(Constants.equalsInteger(data.getSignStatus(), Constants.THREE )){ | 
|---|
|  |  |  | String link = signService.linkFile(data.getApplyNo()); | 
|---|
|  |  |  | String fileUrl = uploadSignFile(link); | 
|---|
|  |  |  | if(StringUtils.isBlank(fileUrl)){ | 
|---|
|  |  |  | //如果下载失败,清除合同,下次签章重新生成新合同 | 
|---|
|  |  |  | return title + "合同下载失败,等待下次推送处理"; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | uploadSignedFileDo(model,fileUrl,path+fileUrl); | 
|---|
|  |  |  | return title +"状态处理成功"; | 
|---|
|  |  |  | }else{ | 
|---|
|  |  |  | //如果已拒签,清除合同,下次签章重新生成新合同 | 
|---|
|  |  |  | insuranceApplyMapper.update(null,new UpdateWrapper<InsuranceApply>().lambda() | 
|---|
|  |  |  | .set(InsuranceApply::getSignApplyNo,null) | 
|---|
|  |  |  | .eq(InsuranceApply::getSignApplyNo,data.getApplyNo())); | 
|---|
|  |  |  | return title+"合同拒签处理成功"; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return  title+"状态已流转,不做处理"; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | insuranceApply.setEndTime(countCyclePriceVO.getEndDate()); | 
|---|
|  |  |  | insuranceApply.setFinalEndTime(countCyclePriceVO.getEndDate()); | 
|---|
|  |  |  | insuranceApplyMapper.insert(insuranceApply); | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //处理下级数据 | 
|---|
|  |  |  | this.dealApplyDetailData(insuranceApply,solutions,applyDetailList,loginUserInfo,countCyclePriceVO,true); | 
|---|
|  |  |  | InsuranceApply updBean = new InsuranceApply(); | 
|---|
|  |  |  | updBean.setId(insuranceApply.getId()); | 
|---|
|  |  |  | updBean.setFee(applyDetailList.stream().map(ApplyDetail::getFee).reduce(BigDecimal.ZERO,BigDecimal::add)); | 
|---|
|  |  |  | insuranceApplyMapper.updateById(updBean); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //        if(1==1){ | 
|---|
|  |  |  | //            throw new BusinessException(ResponseStatus.NOT_ALLOWED); | 
|---|
|  |  |  | //        } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //存储日志数据 | 
|---|
|  |  |  | Constants.ApplyLogType applyLogType = Constants.ApplyLogType.UPLOAD; | 
|---|
|  |  |  | String info =applyLogType.getInfo(); | 
|---|
|  |  |  | 
|---|
|  |  |  | .apply(" t1.BASE_ID in ( select du.id from dispatch_unit du where du.STATUS = 0 and du.ISDELETED = 0 ) ") | 
|---|
|  |  |  | ); | 
|---|
|  |  |  | if(!CollectionUtils.isNotEmpty(duSolutionList)){ | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"数据异常:保险方案下未查询到派遣单位"); | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"对不起,保险方案下未查询到派遣单位信息,请确保派遣单位和工作配置并审核通过!"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | //查询所有派遣单位下的工种 | 
|---|
|  |  |  | List<Integer> duSolutionIdList = duSolutionList.stream().map(i->i.getId()).collect(Collectors.toList()); | 
|---|
|  |  |  | 
|---|
|  |  |  | .eq(checkNewData,Worktype::getDataType,Constants.TWO) | 
|---|
|  |  |  | .in(DuWorktype::getDuSolutionId,duSolutionIdList)); | 
|---|
|  |  |  | if(!CollectionUtils.isNotEmpty(duWorktypeList)){ | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"数据异常:保险方案下未查询到工种信息"); | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"对不起,保险方案下未查询到工种信息,请确保派遣单位和工作配置并审核通过!"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if(CollectionUtils.isNotEmpty(applyDetailList)){ | 
|---|
|  |  |  | 
|---|
|  |  |  | List<Member> addMemberList = new ArrayList<>(); | 
|---|
|  |  |  | for (int i = 0; i < applyDetailList.size(); i++) { | 
|---|
|  |  |  | ApplyDetail applyDetail = applyDetailList.get(i); | 
|---|
|  |  |  | Member member = new Member(); | 
|---|
|  |  |  | Member member = null; | 
|---|
|  |  |  | if(CollectionUtils.isNotEmpty(memberList)){ | 
|---|
|  |  |  | Optional<Member>  optional = memberList.stream().filter(m->m.getIdcardNo().equals(applyDetail.getIdcardNo())).findFirst(); | 
|---|
|  |  |  | if(optional.isPresent()){ | 
|---|
|  |  |  | 
|---|
|  |  |  | member.setCompanyId(insuranceApply.getCompanyId()); | 
|---|
|  |  |  | member.setSex(Constants.getSexByIdCard(applyDetail.getIdcardNo())); | 
|---|
|  |  |  | if(!IdcardUtil.isValidCard(applyDetail.getIdcardNo())){ | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"投保员工信息身份证信息错误["+member.getName()+"]"); | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"对不起,投保员工【"+member.getName()+"】身份证信息【"+applyDetail.getIdcardNo()+"】错误"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | member.setIdcardNo(applyDetail.getIdcardNo()); | 
|---|
|  |  |  | member.setApplyId(insuranceApply.getId()); | 
|---|
|  |  |  | member.setStartTime(applyDetail.getStartTime()); | 
|---|
|  |  |  | member.setEndTime(applyDetail.getEndTime()); | 
|---|
|  |  |  | //                    member.setStartTime(applyDetail.getStartTime()); | 
|---|
|  |  |  | //                    member.setEndTime(applyDetail.getEndTime()); | 
|---|
|  |  |  | member.setDuId(applyDetail.getDuId()); | 
|---|
|  |  |  | member.setWorktypeId(applyDetail.getWorktypeId()); | 
|---|
|  |  |  | addMemberList.add(member); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | //查询人员信息是否存在相同的方案下是否存在 冲突数据 | 
|---|
|  |  |  | this.checkMemberSolution(solutions.getBaseId(),member.getIdcardNo(),member.getName(),insuranceApply.getStartTime(),insuranceApply.getEndTime(),insuranceApply.getId()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if(CollectionUtils.isNotEmpty(addMemberList)){ | 
|---|
|  |  |  | memberJoinMapper.insertBatchSomeColumn(addMemberList); | 
|---|
|  |  |  | 
|---|
|  |  |  | ||Objects.isNull(applyDetail.getDuId()) | 
|---|
|  |  |  | ||Objects.isNull(applyDetail.getWorktypeId()) | 
|---|
|  |  |  | ){ | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"投保员工信息数据缺失"); | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"对不起,投保员工信息数据缺失,请按照要求填写员工的有效信息!"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | applyDetail.setChangeStatus(Constants.ZERO); | 
|---|
|  |  |  | applyDetail.setCreateDate(new Date()); | 
|---|
|  |  |  | applyDetail.setCreator(loginUserInfo.getId()); | 
|---|
|  |  |  | applyDetail.setIsdeleted(Constants.ZERO); | 
|---|
|  |  |  | 
|---|
|  |  |  | applyDetail.setEndTime(insuranceApply.getApplyEndTime()); | 
|---|
|  |  |  | applyDetail.setSortnum(i); | 
|---|
|  |  |  | applyDetail.setApplyId(insuranceApply.getId()); | 
|---|
|  |  |  | Member member = new Member(); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //根据员工身份证进行判断年龄 | 
|---|
|  |  |  | long age = Constants.getAgeByIdCard(applyDetail.getIdcardNo()); | 
|---|
|  |  |  | if(Objects.isNull(age) | 
|---|
|  |  |  | || age > solutions.getMaxAge() | 
|---|
|  |  |  | || age < solutions.getMinAge()){ | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"【"+applyDetail.getMemberName()+"】员工年龄超出方案配置,方案配置【"+solutions.getMinAge()+" - "+solutions.getMaxAge()+"】!"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | Member member = null; | 
|---|
|  |  |  | if(Objects.isNull(applyDetail.getMemberId())){ | 
|---|
|  |  |  | if(CollectionUtils.isNotEmpty(memberList)){ | 
|---|
|  |  |  | Optional<Member>  optional = memberList.stream().filter(m->m.getIdcardNo().equals(applyDetail.getIdcardNo())).findFirst(); | 
|---|
|  |  |  | 
|---|
|  |  |  | member.setApplyId(insuranceApply.getId()); | 
|---|
|  |  |  | member.setDuId(applyDetail.getDuId()); | 
|---|
|  |  |  | member.setWorktypeId(applyDetail.getWorktypeId()); | 
|---|
|  |  |  | member.setStartTime(applyDetail.getStartTime()); | 
|---|
|  |  |  | member.setEndTime(applyDetail.getEndTime()); | 
|---|
|  |  |  | //                        member.setStartTime(applyDetail.getStartTime()); | 
|---|
|  |  |  | //                        member.setEndTime(applyDetail.getEndTime()); | 
|---|
|  |  |  | memberMapper.updateById(member); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }else{ | 
|---|
|  |  |  | 
|---|
|  |  |  | member.setApplyId(insuranceApply.getId()); | 
|---|
|  |  |  | member.setDuId(applyDetail.getDuId()); | 
|---|
|  |  |  | member.setWorktypeId(applyDetail.getWorktypeId()); | 
|---|
|  |  |  | member.setStartTime(applyDetail.getStartTime()); | 
|---|
|  |  |  | member.setEndTime(applyDetail.getEndTime()); | 
|---|
|  |  |  | //                    member.setStartTime(applyDetail.getStartTime()); | 
|---|
|  |  |  | //                    member.setEndTime(applyDetail.getEndTime()); | 
|---|
|  |  |  | memberMapper.updateById(member); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //根据员工身份证进行判断年龄 | 
|---|
|  |  |  | long age = Constants.getAgeByIdCard(member.getIdcardNo()); | 
|---|
|  |  |  | if(Objects.isNull(age) | 
|---|
|  |  |  | || age > solutions.getMaxAge() | 
|---|
|  |  |  | || age < solutions.getMinAge()){ | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"【"+applyDetail.getMemberName()+"】员工年龄超出方案配置,方案配置【"+solutions.getMinAge()+" - "+solutions.getMaxAge()+"】!"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | applyDetail.setMemberId(member.getId()); | 
|---|
|  |  |  | applyDetail.setIdcardNo(member.getIdcardNo()); | 
|---|
|  |  |  | applyDetail.setSex(member.getSex()); | 
|---|
|  |  |  | 
|---|
|  |  |  | //获取计算总天数 | 
|---|
|  |  |  | Integer maxDays = DateUtil.calculateBetween(applyDetail.getStartTime(),applyDetail.getEndTime(),0); | 
|---|
|  |  |  | if(Constants.equalsInteger(maxDays,0)||Objects.isNull(applyDetail.getFee())){ | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"投保信息异常:总天数与总金额错误"); | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"投保信息异常:投保总天数与总金额错误"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | applyDetail.setPrice( | 
|---|
|  |  |  | applyDetail.getFee().divide(new BigDecimal(maxDays),7,RoundingMode.HALF_UP) | 
|---|
|  |  |  | ); | 
|---|
|  |  |  | //验证派遣单位信息是否存在 | 
|---|
|  |  |  | if(duSolutionList.stream().filter(d->d.getDispatchUnitId().equals(applyDetail.getDuId())).collect(Collectors.toList()).size()<=Constants.ZERO){ | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.DATA_ERRO.getCode(),"【"+applyDetail.getMemberName()+"】员工派遣单位未查询到!"); | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.DATA_ERRO.getCode(),"【"+applyDetail.getMemberName()+applyDetail.getIdcardNo()+"】员工派遣单位未查询到!"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if(duWorktypeList.stream().filter(d->d.getWorkTypeId().equals(applyDetail.getWorktypeId())) | 
|---|
|  |  |  | .collect(Collectors.toList()).size()<=Constants.ZERO){ | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.DATA_ERRO.getCode(),"【"+applyDetail.getMemberName()+"】员工工种信息未查询到!"); | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.DATA_ERRO.getCode(),"【"+applyDetail.getMemberName()+applyDetail.getIdcardNo()+"】员工工种信息未查询到!"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | applyDetailJoinMapper.insertBatchSomeColumn(applyDetailList); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 查询 会员信息在方案下是否存在冲突数据 | 
|---|
|  |  |  | * @param solutionId | 
|---|
|  |  |  | * @param startTime | 
|---|
|  |  |  | * @param endTime | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public void checkMemberSolution(Integer solutionId,String idCode,String memberName,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) | 
|---|
|  |  |  | .leftJoin(InsuranceApply.class,InsuranceApply::getId,ApplyDetail::getApplyId) | 
|---|
|  |  |  | .leftJoin(Solutions.class,Solutions::getId,InsuranceApply::getSolutionId) | 
|---|
|  |  |  | .eq(ApplyDetail::getIdcardNo,idCode) | 
|---|
|  |  |  | .eq(ApplyDetail::getIsdeleted,Constants.ZERO) | 
|---|
|  |  |  | .eq(Solutions::getBaseId,solutionId) | 
|---|
|  |  |  | .ne(Objects.nonNull(applyId),InsuranceApply::getId,applyId) | 
|---|
|  |  |  | .notIn(InsuranceApply::getStatus | 
|---|
|  |  |  | ,Constants.InsuranceApplyStatus.CLOSE.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){ | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if(applyDetailList.size() >Constants.ZERO){ | 
|---|
|  |  |  | ApplyDetail applyDetail = applyDetailList.get(Constants.ZERO); | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"该员工【"+memberName+" "+idCode+"】在该保险方案下已存在投保记录,无法进行该操作"); | 
|---|
|  |  |  | }; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public static void checkStaticMemberSolution(Integer solutionId,String idCode,String memberName,Date startTime, | 
|---|
|  |  |  | Date endTime,ApplyDetailJoinMapper applyDetailJoinMapper){ | 
|---|
|  |  |  | List<ApplyDetail> applyDetailList = new ArrayList<ApplyDetail>(); | 
|---|
|  |  |  | try { | 
|---|
|  |  |  | applyDetailList = applyDetailJoinMapper.selectJoinList(ApplyDetail.class, | 
|---|
|  |  |  | new MPJLambdaWrapper<ApplyDetail>() | 
|---|
|  |  |  | .selectAll(ApplyDetail.class) | 
|---|
|  |  |  | .selectAs(InsuranceApply::getCode,ApplyDetail::getApplyCode) | 
|---|
|  |  |  | .leftJoin(InsuranceApply.class,InsuranceApply::getId,ApplyDetail::getApplyId) | 
|---|
|  |  |  | .leftJoin(Solutions.class,Solutions::getId,InsuranceApply::getSolutionId) | 
|---|
|  |  |  | .eq(ApplyDetail::getIdcardNo,idCode) | 
|---|
|  |  |  | .eq(Solutions::getBaseId,solutionId) | 
|---|
|  |  |  | .eq(ApplyDetail::getIsdeleted,Constants.ZERO) | 
|---|
|  |  |  | .notIn(InsuranceApply::getStatus | 
|---|
|  |  |  | ,Constants.InsuranceApplyStatus.CLOSE.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){ | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if(applyDetailList.size() >Constants.ZERO){ | 
|---|
|  |  |  | ApplyDetail applyDetail = applyDetailList.get(Constants.ZERO); | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"该员工【"+memberName+" "+idCode+"】在该保险方案下已存在投保记录,无法进行该操作"); | 
|---|
|  |  |  | }; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public void deleteById(Integer id) { | 
|---|
|  |  |  | 
|---|
|  |  |  | queryWrapper.selectAs(Solutions::getPrice,InsuranceApply::getPrice); | 
|---|
|  |  |  | 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   ) 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"); | 
|---|
|  |  |  | 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 "); | 
|---|
|  |  |  | 
|---|
|  |  |  | 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 "); | 
|---|
|  |  |  | 
|---|
|  |  |  | .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 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) | 
|---|
|  |  |  | 
|---|
|  |  |  | .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 ) as insureNum") | 
|---|
|  |  |  | .select(" ifnull(( 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() ),0) as guaranteeNum") | 
|---|
|  |  |  | .leftJoin(Solutions.class,Solutions::getId,InsuranceApply::getSolutionId) | 
|---|
|  |  |  | .leftJoin(Company.class,Company::getId,InsuranceApply::getCompanyId) | 
|---|
|  |  |  | .eq(InsuranceApply::getId,model.getId()) | 
|---|
|  |  |  | 
|---|
|  |  |  | .selectAs(DispatchUnit::getName,ApplyDetail::getDuName) | 
|---|
|  |  |  | .leftJoin(Worktype.class,Worktype::getId,ApplyDetail::getWorktypeId) | 
|---|
|  |  |  | .leftJoin(DispatchUnit.class,DispatchUnit::getId,ApplyDetail::getDuId) | 
|---|
|  |  |  | .ge(ApplyDetail::getEndTime,DateUtil.getPlusTime2(new Date())) | 
|---|
|  |  |  | .eq(ApplyDetail::getApplyId,model.getId()); | 
|---|
|  |  |  | //查询明细 | 
|---|
|  |  |  | List<ApplyDetail> detailList =applyDetailJoinMapper.selectJoinList(ApplyDetail.class,wrapper1); | 
|---|
|  |  |  | if(detailList!=null){ | 
|---|
|  |  |  | insuranceApply.setInsureNum(detailList.size()); | 
|---|
|  |  |  | //            insuranceApply.setInsureNum(detailList.size()); | 
|---|
|  |  |  | insuranceApply.setApplyDetailList(detailList); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | insuranceApply.setRemark(model.getRemark()); | 
|---|
|  |  |  | 
|---|
|  |  |  | BigDecimal sumAmount = BigDecimal.ZERO; | 
|---|
|  |  |  | List<ApplyDetail> applyDetailList = applyDetailMapper | 
|---|
|  |  |  | .selectList(new QueryWrapper<ApplyDetail>().lambda() | 
|---|
|  |  |  | .ne(ApplyDetail::getChangeStatus,Constants.TWO) | 
|---|
|  |  |  | .eq(ApplyDetail::getApplyId,insuranceApply.getId())); | 
|---|
|  |  |  | if(CollectionUtils.isNotEmpty(applyDetailList)){ | 
|---|
|  |  |  | for (ApplyDetail applyDetail: applyDetailList) { | 
|---|
|  |  |  | 
|---|
|  |  |  | applyDetail.setCurrentFee(applyDetail.getFee()); | 
|---|
|  |  |  | applyDetailMapper.updateById(applyDetail); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | sumAmount = sumAmount.add(applyDetail.getCurrentFee()); | 
|---|
|  |  |  | if(Constants.equalsInteger(applyDetail.getChangeStatus(),Constants.ZERO) || applyDetail.getEndTime().getTime()>System.currentTimeMillis()){ | 
|---|
|  |  |  | sumAmount = sumAmount.add(applyDetail.getCurrentFee()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | insuranceApply.setCurrentFee(sumAmount); | 
|---|
|  |  |  | insuranceApplyMapper.updateById(insuranceApply); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | //        if(1==1){ | 
|---|
|  |  |  | //            throw new BusinessException(ResponseStatus.NOT_ALLOWED); | 
|---|
|  |  |  | //        } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | .leftJoin(DispatchUnit.class,DispatchUnit::getId,ApplyDetail::getDuId) | 
|---|
|  |  |  | .isNull(ApplyDetail::getFromId) | 
|---|
|  |  |  | .eq(ApplyDetail::getApplyId,model.getId()) | 
|---|
|  |  |  | .orderByAsc(ApplyDetail::getId) | 
|---|
|  |  |  | ); | 
|---|
|  |  |  | model.setApplyDetailList(applyDetailList); | 
|---|
|  |  |  | return model; | 
|---|