This commit is contained in:
1073413548 2024-08-21 10:46:55 +08:00
parent 78c917f69e
commit ca43bad3d5
4 changed files with 27 additions and 20 deletions

View File

@ -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);
/**
* 开发票开发票操作

View File

@ -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);
}
//修改签章状态

View File

@ -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<PsTaskMain> task = taskMainMapper.selectList(Wrappers.<PsTaskMain>lambdaQuery().eq(PsTaskMain::getContractCode, psApproverRecord.getContractCode()).eq(PsTaskMain::getDelFlag, 0));
List<Long> list = task.stream().map(PsTaskMain::getId).collect(Collectors.toList());

View File

@ -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;
}