| | |
| | | import com.doumee.core.utils.Constants; |
| | | import com.doumee.core.utils.DateUtil; |
| | | import com.doumee.core.utils.Utils; |
| | | import com.doumee.core.utils.aliyun.ALiYunUtil; |
| | | import com.doumee.dao.business.*; |
| | | import com.doumee.dao.business.dto.InsuranceApplyOptDTO; |
| | | import com.doumee.dao.business.dto.InsuranceApplyQueryDTO; |
| | |
| | | insuranceApplyMapper.updateById(update); |
| | | return link; |
| | | } |
| | | public String uploadSignFile(String link){ |
| | | try { |
| | | String bucketName = systemDictDataBiz.queryByCode(Constants.OSS,Constants.BUCKETNAME).getCode(); |
| | | String access_id= systemDictDataBiz.queryByCode(Constants.OSS,Constants.ACCESS_ID).getCode(); |
| | | String access_key= systemDictDataBiz.queryByCode(Constants.OSS,Constants.ACCESS_KEY).getCode(); |
| | | String endpoint = systemDictDataBiz.queryByCode(Constants.OSS,Constants.ENDPOINT).getCode(); |
| | | String folder = systemDictDataBiz.queryByCode(Constants.OSS,Constants.APPLY_FILE).getCode(); |
| | | String tempFileName = DateUtil.getNowShortDate() + "/" + UUID.randomUUID().toString() + ".pdf"; |
| | | String key = folder + tempFileName;// 文件名 |
| | | ALiYunUtil obs = new ALiYunUtil(endpoint,access_id, access_key); |
| | | if (obs.uploadOnlineObject(link,bucketName, key,null)) { |
| | | // 移动成功,返回文件名 |
| | | return tempFileName; |
| | | } |
| | | }catch (Exception e){ |
| | | |
| | | } |
| | | return null; |
| | | |
| | | } |
| | | |
| | | |
| | | public Integer uploadSignedFileDo(InsuranceApply model,String fileurl) { |
| | | InsuranceApply update = new InsuranceApply(); |
| | | update.setEditDate(new Date()); |
| | | update.setEditor(model.getCreator()); |
| | | update.setStatus(Constants.InsuranceApplyStatus.UPLOAD_INSURANCE.getKey()); |
| | | update.setCheckDate(update.getEditDate()); |
| | | update.setCheckInfo("企业完成签署"); |
| | | update.setCheckUserId(model.getCreator()); |
| | | update.setId(model.getId()); |
| | | insuranceApplyMapper.updateById(update); |
| | | |
| | | Multifile f = new Multifile(); |
| | | f.setIsdeleted(Constants.ZERO); |
| | | f.setCreator(model.getCreator()); |
| | | f.setObjId(update.getId()); |
| | | f.setCreateDate(update.getEditDate()); |
| | | f.setObjType(Constants.MultiFile.BD_SIGNED_PDF.getKey()); |
| | | f.setType(Constants.TWO); |
| | | f.setFileurl(fileurl); |
| | | f.setName("投保单签约合同.pdf"); |
| | | multifileMapper.insert(f); |
| | | Constants.ApplyLogType applyLogType = Constants.ApplyLogType.SIGNATURE; |
| | | ApplyLog log = new ApplyLog(update,applyLogType.getName(), null,update.getId(),applyLogType.getKey(),JSONObject.toJSONString(model), JSONObject.toJSONString(update)); |
| | | applyLogMapper.insert(log); |
| | | return 1; |
| | | |
| | | } |
| | | public Integer uploadChangeSignedFileDo(ApplyChange model,String fileurl) { |
| | | ApplyChange update = new ApplyChange(); |
| | | update.setEditDate(new Date()); |
| | | update.setEditor(model.getCreator()); |
| | | update.setStatus(Constants.ApplyChangeStatus.SIGNATURE.getKey()); |
| | | update.setCheckDate(update.getEditDate()); |
| | | update.setCheckInfo("企业完成签署"); |
| | | update.setCheckUserId(model.getCreator()); |
| | | update.setId(model.getId()); |
| | | applyChangeMapper.updateById(update); |
| | | |
| | | Multifile f = new Multifile(); |
| | | f.setIsdeleted(Constants.ZERO); |
| | | f.setCreator(model.getCreator()); |
| | | f.setObjId(update.getId()); |
| | | f.setCreateDate(update.getEditDate()); |
| | | f.setObjType(Constants.equalsInteger(Constants.ZERO,model.getType())?Constants.MultiFile.CA_APPLY_JIAJIAN_SIGN.getKey() : Constants.MultiFile.CA_APPLY_CHANGEUNIT_SIGN.getKey()); |
| | | f.setType(Constants.TWO); |
| | | f.setFileurl(fileurl); |
| | | f.setName("签章申请表.pdf"); |
| | | multifileMapper.insert(f); |
| | | Constants.ApplyLogType applyLogType =Constants.equalsInteger(Constants.ZERO,model.getType())? Constants.ApplyLogType.CA_JIAJIAN_APPLY_SIGN: Constants.ApplyLogType.CA_CHANGUNIT_APPLY_SIGN; |
| | | ApplyLog log = new ApplyLog(update,applyLogType.getName(), null,update.getId(),applyLogType.getKey(),JSONObject.toJSONString(model), JSONObject.toJSONString(update)); |
| | | applyLogMapper.insert(log); |
| | | return 1; |
| | | |
| | | } |
| | | @Override |
| | | public void dealWaitSignedData(){ |
| | | List<InsuranceApply> applyList = insuranceApplyMapper.selectList(new QueryWrapper<InsuranceApply>().lambda() |
| | | .eq(InsuranceApply::getStatus,Constants.InsuranceApplyStatus.WAIT_SIGNATURE) |
| | | .isNotNull(InsuranceApply::getSignApplyNo)); |
| | | if(applyList !=null && applyList.size()>0 ){ |
| | | for(InsuranceApply model : applyList){ |
| | | String link = signService.linkFile(model.getSignApplyNo()); |
| | | String fileUrl = uploadSignFile(link); |
| | | if(StringUtils.isBlank(fileUrl)){ |
| | | //如果下载失败,清除合同,下次签章重新生成新合同 |
| | | return; |
| | | } |
| | | uploadSignedFileDo(model,fileUrl); |
| | | return; |
| | | } |
| | | } |
| | | List<ApplyChange> chagneList = applyChangeMapper.selectList(new QueryWrapper<ApplyChange>().lambda() |
| | | .eq(ApplyChange::getStatus,Constants.ApplyChangeStatus.UPLOAD) |
| | | .isNotNull(ApplyChange::getSignApplyNo)); |
| | | if(chagneList !=null && chagneList.size()>0 ){ |
| | | for(ApplyChange model : chagneList){ |
| | | String link = signService.linkFile(model.getSignApplyNo()); |
| | | String fileUrl = uploadSignFile(link); |
| | | if(StringUtils.isBlank(fileUrl)){ |
| | | //如果下载失败,清除合同,下次签章重新生成新合同 |
| | | return; |
| | | } |
| | | uploadChangeSignedFileDo(model,fileUrl); |
| | | return; |
| | | } |
| | | } |
| | | } |
| | | @Override |
| | | public void dealSignResult(NotifyDataReq data){ |
| | | if(data.getApplyNo() == null ){ |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST); |
| | | } |
| | | InsuranceApply model = insuranceApplyMapper.selectOne(new QueryWrapper<InsuranceApply>().lambda().eq(InsuranceApply::getSignApplyNo,data.getApplyNo()).last("limit 1" )); |
| | | if(model != null ){ |
| | | //-----------------TUDO--------完善签约完成业务------ |
| | | |
| | | }else{ |
| | | ApplyChange applyChange = applyChangeMapper.selectOne(new QueryWrapper<ApplyChange>().lambda().eq(ApplyChange::getSignApplyNo,data.getApplyNo()).last("limit 1" )); |
| | | if(applyChange == null){ |
| | | throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"系统未找到匹配合同号!"); |
| | | if(Constants.equalsInteger(data.getSignStatus(), Constants.THREE )){ |
| | | //如果已保全,可下载签约附件 |
| | | InsuranceApply model = insuranceApplyMapper.selectOne(new QueryWrapper<InsuranceApply>().lambda().eq(InsuranceApply::getSignApplyNo,data.getApplyNo()).last("limit 1" )); |
| | | if(model != null && Constants.equalsInteger(model.getStatus(),Constants.InsuranceApplyStatus.COMPANY_BACK_APPLY_WAIT_SIGNATURE.getKey())){ |
| | | //完成签署已完成操作 |
| | | String link = signService.linkFile(data.getApplyNo()); |
| | | String fileUrl = uploadSignFile(link); |
| | | if(StringUtils.isBlank(fileUrl)){ |
| | | //如果下载失败,清除合同,下次签章重新生成新合同 |
| | | return; |
| | | } |
| | | uploadSignedFileDo(model,fileUrl); |
| | | return; |
| | | } |
| | | //-----------------TUDO-------完善签约完成------- |
| | | } |
| | | |
| | | ApplyChange applyChange = applyChangeMapper.selectOne(new QueryWrapper<ApplyChange>().lambda().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); |
| | | } |
| | | }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())); |
| | | } |
| | | |
| | | } |
| | | @Override |
| | |
| | | IPage<InsuranceApply> page = new Page<>(pageWrap.getPage(), pageWrap.getCapacity()); |
| | | MPJLambdaWrapper<InsuranceApply> queryWrapper = new MPJLambdaWrapper<>(); |
| | | Utils.MP.blankToNull(pageWrap.getModel()); |
| | | List<Integer> statusList = Constants.InsuranceApplyStatus.getKesByStatus(pageWrap.getModel().getStatusCollect()); |
| | | queryWrapper.selectAll(InsuranceApply.class); |
| | | queryWrapper.selectAs(Company::getName,InsuranceApply::getCompanyName); |
| | | queryWrapper.selectAs(Solutions::getName,InsuranceApply::getSolutionsName); |
| | | queryWrapper.select(" DATEDIFF( t.END_TIME ,now() ) AS loseEfficacyDays "); |
| | | queryWrapper.select(" ( select count(1) from apply_detail ad where ad.apply_id = t.id ) as insureNum"); |
| | | queryWrapper.select(" ( select sum(td.fee) from taxes ts inner join tax_detial td on ts.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 ts.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 "); |
| | | if(!Objects.isNull(pageWrap.getModel())&&!Objects.isNull(pageWrap.getModel().getType())){ |
| | | 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 "); |
| | | } |
| | | queryWrapper.leftJoin(Solutions.class,Solutions::getId,InsuranceApply::getSolutionId); |
| | | queryWrapper.leftJoin(Company.class,Company::getId,InsuranceApply::getCompanyId); |
| | | queryWrapper.eq(InsuranceApply::getIsdeleted,Constants.ZERO); |
| | | queryWrapper.in(statusList.size()>0,InsuranceApply::getStatus,statusList); |
| | | if(Constants.equalsInteger(pageWrap.getModel().getStatusCollect(),Constants.THREE) ){ |
| | | queryWrapper.eq(InsuranceApply::getStatus,Constants.InsuranceApplyStatus.UPLOAD_INSURANCE.getKey()); |
| | | queryWrapper.lt(InsuranceApply::getEndTime, Utils.Date.getStart(new Date())); |
| | | } |
| | | //企业人员查看本企业数据 |
| | | if(loginUserInfo.getType().equals(Constants.ONE)){ |
| | | queryWrapper.eq(InsuranceApply::getCompanyId, loginUserInfo.getCompanyId()); |
| | |
| | | } |
| | | } |
| | | PageData<InsuranceApply> pageData = PageData.from(insuranceApplyJoinMapper.selectJoinPage(page,InsuranceApply.class, queryWrapper)); |
| | | if(pageData.getRecords()!=null){ |
| | | for (InsuranceApply apply : pageData.getRecords()){ |
| | | apply.setStatusCollect(Constants.InsuranceApplyStatus.getCollectStatus(apply.getStatus())); |
| | | if(Constants.equalsInteger(apply.getStatusCollect(),Constants.InsuranceApplyStatus.UPLOAD_INSURANCE.getKey())){ |
| | | //如果已完成 |
| | | if(apply.getEndTime()==null || System.currentTimeMillis()>apply.getEndTime().getTime()){ |
| | | apply.setStatusCollect(Constants.THREE);//已过期 |
| | | } |
| | | } |
| | | } |
| | | } |
| | | return pageData; |
| | | } |
| | | |