预览合同

This commit is contained in:
1073413548 2024-08-09 15:48:25 +08:00
parent cb62db6484
commit a8ba3a08eb
3 changed files with 48 additions and 13 deletions

View File

@ -51,8 +51,8 @@ public class PsContractInfoController extends BaseController {
@Log(title = "生成合同", businessType = BusinessType.INSERT)
@RepeatSubmit()
@PostMapping("/create")
public R<Void> add(@Validated(AddGroup.class) @RequestBody PsContractInfoBo bo) {
return toAjax(psContractInfoService.createContract(bo,2));
public R<Long> add(@Validated(AddGroup.class) @RequestBody PsContractInfoBo bo) {
return R.ok(psContractInfoService.createContract(bo,2));
}
/**
* 暂存合同
@ -61,10 +61,19 @@ public class PsContractInfoController extends BaseController {
@Log(title = "暂存合同", businessType = BusinessType.INSERT)
@RepeatSubmit()
@PostMapping("/hold")
public R<Void> hold( @RequestBody PsContractInfoBo bo) {
return toAjax(psContractInfoService.createContract(bo,1));
public R<Long> hold( @RequestBody PsContractInfoBo bo) {
return R.ok(psContractInfoService.createContract(bo,1));
}
/**
* 预览合同
*/
@SaCheckPermission("business:customInfo:addContract")
@Log(title = "预览合同", businessType = BusinessType.INSERT)
@RepeatSubmit()
@PostMapping("/preview")
public R<Long> preview( @RequestBody PsContractInfoBo bo) {
return R.ok(psContractInfoService.preview(bo));
}
/**
* 根据客户id查询暂存的合同详情信息
*/

View File

@ -25,7 +25,14 @@ public interface IPsContractInfoService {
* @param type 操作类型 1保存2暂存
* @return 是否新增成功
*/
Boolean createContract(PsContractInfoBo bo,Integer type);
Long createContract(PsContractInfoBo bo,Integer type);
/**
* 预览合同
*
* @param bo 合同信息
* @return 是否新增成功
*/
Long preview(PsContractInfoBo bo);
/**
* 根据客户id查询暂存的合同详情信息

View File

@ -73,9 +73,7 @@ public class PsContractInfoServiceImpl implements IPsContractInfoService {
*/
@Override
@Transactional//开启事务
public Boolean createContract(PsContractInfoBo bo,Integer type) {
public Long createContract(PsContractInfoBo bo,Integer type) {
//1校验
PsContractInfo add = validEntity(bo,UserConstants.YES);
//2.插入公司信息
@ -95,9 +93,27 @@ public class PsContractInfoServiceImpl implements IPsContractInfoService {
baseMapper.insertOrUpdate(add);
//4.删除所有服务类型和服务项目,.插入服务类型
businessService.saveList(bo.getBusinessList(),bo.getContractCode());
return true;
//7.生成合同
return makePdf(add,bo);
}
/**
* 预览合同
*
* @param bo 合同信息
* @return 是否新增成功
*/
public Long preview(PsContractInfoBo bo){
//3.如果已存在合同则进行修改否则新增
PsContractInfo add = new PsContractInfo();
add.setContractCode("0000000000-1");//合同编码
add.setContractName("合同名称");//todo 合同名称
add.setCustomManager(LoginHelper.getUserId());//所属销售经理id
add.setCompanyId(bo.getCompanyInfoBo().getId());//公司id
MapstructUtils.convert(bo, add);
BigDecimal sum = bo.getBusinessList().stream().map(PsContractBusinessBo::getBusinessAmount).reduce(BigDecimal.ZERO, BigDecimal::add);
add.setContractAmount(sum);//合同总金额
return makePdf(add,bo);
}
/**
@ -272,11 +288,12 @@ public class PsContractInfoServiceImpl implements IPsContractInfoService {
return info;
}
/**
* 生成pdf
* 生成合同pdf
* @param add
* @param bo
*/
private void makePdf(PsContractInfo add ,PsContractInfoBo bo){
private Long makePdf(PsContractInfo add ,PsContractInfoBo bo){
Long ossId = null;
try{
//生成合同pdf
PsCustomInfo customer = customInfoService.listById(add.getCustomId());
@ -291,6 +308,7 @@ public class PsContractInfoServiceImpl implements IPsContractInfoService {
File file = new File(path);
//上传到oss服务
SysOssVo sysOssVo = ossService.upload(new File(path));
ossId = sysOssVo.getOssId();
//删除临时的合同文件
if(file.exists())file.delete();
//更新合同id
@ -303,6 +321,7 @@ public class PsContractInfoServiceImpl implements IPsContractInfoService {
}catch (Exception e){
log.error("生成pdf失败",e);
}
return ossId;
}