diff --git a/pusong-modules/pusong-business/src/main/java/com/pusong/business/service/IPsContractInfoService.java b/pusong-modules/pusong-business/src/main/java/com/pusong/business/service/IPsContractInfoService.java index fa94dc1..ea260e4 100644 --- a/pusong-modules/pusong-business/src/main/java/com/pusong/business/service/IPsContractInfoService.java +++ b/pusong-modules/pusong-business/src/main/java/com/pusong/business/service/IPsContractInfoService.java @@ -92,8 +92,9 @@ public interface IPsContractInfoService { * 生成合同pdf * @param add * @param bo + * @param isSave 是否保存数据库 */ - Long makePdf(PsContractInfo add ,PsContractInfoBo bo); + Long makePdf(PsContractInfo add ,PsContractInfoBo bo,boolean isSave); /** * 开发票(开发票操作) diff --git a/pusong-modules/pusong-business/src/main/java/com/pusong/business/service/approver/impl/SignApproverServiceImpl.java b/pusong-modules/pusong-business/src/main/java/com/pusong/business/service/approver/impl/SignApproverServiceImpl.java index 581f3de..a3b0f1d 100644 --- a/pusong-modules/pusong-business/src/main/java/com/pusong/business/service/approver/impl/SignApproverServiceImpl.java +++ b/pusong-modules/pusong-business/src/main/java/com/pusong/business/service/approver/impl/SignApproverServiceImpl.java @@ -74,7 +74,7 @@ public class SignApproverServiceImpl extends ApproverAbstractServiceImpl { info.setSignStatus(CommonStatusEnum.SUCCESS.getCode()); contractInfoService.updateByCode(info); //生成合同 - contractInfoService.makePdf(info,bo); + contractInfoService.makePdf(info,bo,true); } //修改签章状态 diff --git a/pusong-modules/pusong-business/src/main/java/com/pusong/business/service/approver/impl/UpdateContractApproverServiceImpl.java b/pusong-modules/pusong-business/src/main/java/com/pusong/business/service/approver/impl/UpdateContractApproverServiceImpl.java index 2778da6..c3df45d 100644 --- a/pusong-modules/pusong-business/src/main/java/com/pusong/business/service/approver/impl/UpdateContractApproverServiceImpl.java +++ b/pusong-modules/pusong-business/src/main/java/com/pusong/business/service/approver/impl/UpdateContractApproverServiceImpl.java @@ -65,7 +65,7 @@ public class UpdateContractApproverServiceImpl extends ApproverAbstractServiceIm add.setContractStatus(ContractStatusEnum.RETURN.getCode()); contractInfoService.updateByCode(add); //4.生成合同 - contractInfoService.makePdf(add,bo); + contractInfoService.makePdf(add,bo,true); //5.任务状态变为待派单,子任务删除 List task = taskMainMapper.selectList(Wrappers.lambdaQuery().eq(PsTaskMain::getContractCode, psApproverRecord.getContractCode()).eq(PsTaskMain::getDelFlag, 0)); List list = task.stream().map(PsTaskMain::getId).collect(Collectors.toList()); diff --git a/pusong-modules/pusong-business/src/main/java/com/pusong/business/service/impl/PsContractInfoServiceImpl.java b/pusong-modules/pusong-business/src/main/java/com/pusong/business/service/impl/PsContractInfoServiceImpl.java index 4e6816e..4ee6645 100644 --- a/pusong-modules/pusong-business/src/main/java/com/pusong/business/service/impl/PsContractInfoServiceImpl.java +++ b/pusong-modules/pusong-business/src/main/java/com/pusong/business/service/impl/PsContractInfoServiceImpl.java @@ -125,7 +125,7 @@ public class PsContractInfoServiceImpl implements IPsContractInfoService { //4.删除所有服务类型和服务项目,.插入服务类型 businessService.saveList(bo.getBusinessList(),add.getContractCode()); //7.生成合同 - return makePdf(add,bo); + return makePdf(add,bo,true); } /** * 预览合同 @@ -154,7 +154,7 @@ public class PsContractInfoServiceImpl implements IPsContractInfoService { }); BigDecimal sum = bo.getBusinessList().stream().map(PsContractBusinessBo::getBusinessAmount).filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add); add.setContractAmount(sum);//合同总金额 - return makePdf(add,bo); + return makePdf(add,bo,false); } @@ -361,7 +361,7 @@ public class PsContractInfoServiceImpl implements IPsContractInfoService { * @param add * @param bo */ - public Long makePdf(PsContractInfo add ,PsContractInfoBo bo){ + public Long makePdf(PsContractInfo add ,PsContractInfoBo bo,boolean isSave){ Long ossId = null; SysDictData main = dictDataService.selectDict("contract_main", add.getContractMain()); bo.getBusinessList().forEach(item->{ @@ -387,7 +387,7 @@ public class PsContractInfoServiceImpl implements IPsContractInfoService { //是否签章 map.put(PdfGenerator.SIGN,StringUtils.equals(CommonStatusEnum.SUCCESS.getCode(),add.getSignStatus())); - String path = System.getProperty("user.dir")+"/"+bo.getCompanyInfoBo().getCompanyName()+"-"+add.getContractCode()+".pdf"; + String path = System.getProperty("user.dir")+"/"+(StringUtils.isBlank(bo.getCompanyInfoBo().getCompanyName())?"":bo.getCompanyInfoBo().getCompanyName()+"-")+add.getContractCode()+".pdf"; log.info(JSON.toJSONString(map)); // path = "D:/王立帅/临时/output.pdf"; PdfGenerator.makePdf(map, path,TenplateEnum.CONTRACT.getName()); @@ -397,13 +397,16 @@ public class PsContractInfoServiceImpl implements IPsContractInfoService { ossId = sysOssVo.getOssId(); //删除临时的合同文件 if(file.exists())file.delete(); - //更新合同id - PsContractInfo psContractInfo = new PsContractInfo(); - psContractInfo.setContractCode(add.getContractCode()); - psContractInfo.setPdfId(sysOssVo.getOssId()); - this.updateByCode(psContractInfo); - //删除原合同 - if(add.getPdfId() != null)ossService.deleteWithValidByIds(List.of(add.getPdfId()),false); + //是否保存合同信息 + if(isSave){ + //更新合同id + PsContractInfo psContractInfo = new PsContractInfo(); + psContractInfo.setContractCode(add.getContractCode()); + psContractInfo.setPdfId(sysOssVo.getOssId()); + this.updateByCode(psContractInfo); + //删除原合同 + if(add.getPdfId() != null)ossService.deleteWithValidByIds(List.of(add.getPdfId()),false); + } }catch (Exception e){ log.error("生成pdf失败",e); } @@ -521,12 +524,15 @@ public class PsContractInfoServiceImpl implements IPsContractInfoService { //包含最后一天 vo.setPeriod(DateUtils.calWorkDate(payList.get(0).getPayDate(),payList.get(payList.size()-1).getPayDate()) + 1); } - Date date = new Date(); - Date startDate = vo.getFirstApplyDate(); - int year = (date.getYear() - startDate.getYear()); - int month = (date.getMonth() - startDate.getMonth()); - int day = (date.getDate() - startDate.getDate()); - vo.setConTime((year>0?year+"年":"")+(month>0?month+"月":"")+(day>0?day+"天":"") ); + if(vo.getFirstApplyDate() != null){ + Date date = new Date(); + Date startDate = vo.getFirstApplyDate(); + int year = (date.getYear() - startDate.getYear()); + int month = (date.getMonth() - startDate.getMonth()); + int day = (date.getDate() - startDate.getDate()); + vo.setConTime((year>0?year+"年":"")+(month>0?month+"月":"")+(day>0?day+"天":"") ); + } + //todo 签章未通过时查询未通过的原因 return vo; }