生成合同

This commit is contained in:
1073413548 2024-08-09 16:41:27 +08:00
parent a8ba3a08eb
commit 6121032236
5 changed files with 27 additions and 10 deletions

View File

@ -57,6 +57,10 @@
<version>5.2.0</version> <version>5.2.0</version>
</dependency> </dependency>
<!--pdf所需pom end--> <!--pdf所需pom end-->
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
</dependency>
</dependencies> </dependencies>
</project> </project>

View File

@ -87,7 +87,15 @@ public class PsContractInfoServiceImpl implements IPsContractInfoService {
} }
add.setCompanyId(bo.getCompanyInfoBo().getId());//公司id add.setCompanyId(bo.getCompanyInfoBo().getId());//公司id
MapstructUtils.convert(bo, add); MapstructUtils.convert(bo, add);
BigDecimal sum = bo.getBusinessList().stream().map(PsContractBusinessBo::getBusinessAmount).reduce(BigDecimal.ZERO, BigDecimal::add); bo.getBusinessList().forEach(item->{
BigDecimal mony = BigDecimal.ZERO;
if(CollectionUtils.isNotEmpty(item.getDetailBos())){
mony = item.getDetailBos().stream().map(PsContractBusinessDetailBo::getAmount).filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add);
}
item.setBusinessAmount(mony);
});
BigDecimal sum = bo.getBusinessList().stream().map(PsContractBusinessBo::getBusinessAmount).filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add);
add.setContractAmount(sum);//合同总金额 add.setContractAmount(sum);//合同总金额
add.setContractStatus(type == 1?ContractStatusEnum.INIT.getCode():ContractStatusEnum.CREATE.getCode());//合同状态 add.setContractStatus(type == 1?ContractStatusEnum.INIT.getCode():ContractStatusEnum.CREATE.getCode());//合同状态
baseMapper.insertOrUpdate(add); baseMapper.insertOrUpdate(add);
@ -110,7 +118,7 @@ public class PsContractInfoServiceImpl implements IPsContractInfoService {
add.setCustomManager(LoginHelper.getUserId());//所属销售经理id add.setCustomManager(LoginHelper.getUserId());//所属销售经理id
add.setCompanyId(bo.getCompanyInfoBo().getId());//公司id add.setCompanyId(bo.getCompanyInfoBo().getId());//公司id
MapstructUtils.convert(bo, add); MapstructUtils.convert(bo, add);
BigDecimal sum = bo.getBusinessList().stream().map(PsContractBusinessBo::getBusinessAmount).reduce(BigDecimal.ZERO, BigDecimal::add); BigDecimal sum = bo.getBusinessList().stream().map(PsContractBusinessBo::getBusinessAmount).filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add);
add.setContractAmount(sum);//合同总金额 add.setContractAmount(sum);//合同总金额
return makePdf(add,bo); return makePdf(add,bo);
} }
@ -209,7 +217,7 @@ public class PsContractInfoServiceImpl implements IPsContractInfoService {
//3.插入公司信息 //3.插入公司信息
companyInfoService.saveBo(bo.getCompanyInfoBo()); companyInfoService.saveBo(bo.getCompanyInfoBo());
//4.装填合同信息 //4.装填合同信息
BigDecimal sum = bo.getBusinessList().stream().map(PsContractBusinessBo::getBusinessAmount).reduce(BigDecimal.ZERO, BigDecimal::add); BigDecimal sum = bo.getBusinessList().stream().map(PsContractBusinessBo::getBusinessAmount).filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add);
bo.setContractAmount(sum);//合同总金额 bo.setContractAmount(sum);//合同总金额
//5.删除所有服务类型和服务项目,.插入服务类型 //5.删除所有服务类型和服务项目,.插入服务类型
businessService.saveList(bo.getBusinessList(),bo.getContractCode()); businessService.saveList(bo.getBusinessList(),bo.getContractCode());
@ -266,7 +274,7 @@ public class PsContractInfoServiceImpl implements IPsContractInfoService {
PsContractInfoVo infoVo = this.queryContractByCode(contractCode); PsContractInfoVo infoVo = this.queryContractByCode(contractCode);
//查询是否有审批中的退款信息 //查询是否有审批中的退款信息
List<PsContractPayVo> payList = contractPayService.queryListByContractCode(contractCode,null,PayStatusEnum.PAYING); List<PsContractPayVo> payList = contractPayService.queryListByContractCode(contractCode,null,PayStatusEnum.PAYING);
BigDecimal pay = payList.stream().map(PsContractPayVo::getMoney).reduce(BigDecimal.ZERO, BigDecimal::add); BigDecimal pay = payList.stream().map(PsContractPayVo::getMoney).filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add);
//有未完成的退款合同列表状态更新为处理中并显示在已完成回款列表重新生成任务 //有未完成的退款合同列表状态更新为处理中并显示在已完成回款列表重新生成任务
if(infoVo.getPayMoney().subtract(pay).compareTo(BigDecimal.ZERO) > 0){ if(infoVo.getPayMoney().subtract(pay).compareTo(BigDecimal.ZERO) > 0){
info.setContractStatus(ContractStatusEnum.EXECUTION.getCode()); info.setContractStatus(ContractStatusEnum.EXECUTION.getCode());
@ -303,6 +311,7 @@ public class PsContractInfoServiceImpl implements IPsContractInfoService {
map.put("company",bo.getCompanyInfoBo()); map.put("company",bo.getCompanyInfoBo());
map.put("customer",customer); map.put("customer",customer);
String path = System.getProperty("user.dir")+"test.pdf"; String path = System.getProperty("user.dir")+"test.pdf";
log.info(JSON.toJSONString(map));
// path = "D:/王立帅/临时/output.pdf"; // path = "D:/王立帅/临时/output.pdf";
PdfGenerator.makePdf(map, path,TenplateEnum.CONTRACT.getName()); PdfGenerator.makePdf(map, path,TenplateEnum.CONTRACT.getName());
File file = new File(path); File file = new File(path);
@ -352,10 +361,10 @@ public class PsContractInfoServiceImpl implements IPsContractInfoService {
vo.setContractPayVoList(payList); vo.setContractPayVoList(payList);
//退款金额 //退款金额
vo.setReturnMoney(payList.stream().filter(item->StringUtils.equals(item.getBusinessType(), PayBuinessStatusEnum.RETURN.getCode())) vo.setReturnMoney(payList.stream().filter(item->StringUtils.equals(item.getBusinessType(), PayBuinessStatusEnum.RETURN.getCode()))
.map(PsContractPayVo::getMoney).reduce(BigDecimal.ZERO, BigDecimal::add)); .map(PsContractPayVo::getMoney).filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add));
//收款金额 //收款金额
BigDecimal netPay = payList.stream().filter(item -> StringUtils.equals(item.getBusinessType(), PayBuinessStatusEnum.PAY.getCode())) BigDecimal netPay = payList.stream().filter(item -> StringUtils.equals(item.getBusinessType(), PayBuinessStatusEnum.PAY.getCode()))
.map(PsContractPayVo::getMoney).reduce(BigDecimal.ZERO, BigDecimal::add); .map(PsContractPayVo::getMoney).filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add);
BigDecimal pay = netPay.subtract(vo.getReturnMoney()); BigDecimal pay = netPay.subtract(vo.getReturnMoney());
//已付金额(收款-退款) //已付金额(收款-退款)
vo.setPayMoney(pay.compareTo(BigDecimal.ZERO)>=0?pay:BigDecimal.ZERO); vo.setPayMoney(pay.compareTo(BigDecimal.ZERO)>=0?pay:BigDecimal.ZERO);

View File

@ -146,7 +146,7 @@ public class PsCustomInfoServiceImpl implements IPsCustomInfoService {
info.setPsCompanyInfoVos(id_companyMap.get(info.getId())); info.setPsCompanyInfoVos(id_companyMap.get(info.getId()));
//报价金额 //报价金额
if(CollectionUtils.isNotEmpty(info.getPsCustomPriceVo())){ if(CollectionUtils.isNotEmpty(info.getPsCustomPriceVo())){
info.setPrice(info.getPsCustomPriceVo().stream().map(PsCustomPriceVo::getServicePrice).reduce(BigDecimal.ZERO, BigDecimal::add)); info.setPrice(info.getPsCustomPriceVo().stream().map(PsCustomPriceVo::getServicePrice).filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add));
} }
//最新的回访信息 //最新的回访信息
if(CollectionUtils.isNotEmpty(info.getPsCustomCallbackVo())){ if(CollectionUtils.isNotEmpty(info.getPsCustomCallbackVo())){

View File

@ -6,8 +6,8 @@ import ${import};
import ${packageName}.domain.${ClassName}; import ${packageName}.domain.${ClassName};
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
import com.alibaba.excel.annotation.ExcelProperty; import com.alibaba.excel.annotation.ExcelProperty;
import annotation.com.pusong.common.excel.ExcelDictFormat; import com.pusong.common.excel.annotation.ExcelDictFormat;
import convert.com.pusong.common.excel.ExcelDictConvert; import com.pusong.common.excel.convert.ExcelDictConvert;
import io.github.linpeilie.annotations.AutoMapper; import io.github.linpeilie.annotations.AutoMapper;
import lombok.Data; import lombok.Data;

View File

@ -29,6 +29,8 @@ import com.pusong.system.domain.vo.SysOssVo;
import com.pusong.system.mapper.SysOssMapper; import com.pusong.system.mapper.SysOssMapper;
import com.pusong.system.service.ISysOssService; import com.pusong.system.service.ISysOssService;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cache.annotation.Cacheable; import org.springframework.cache.annotation.Cacheable;
import org.springframework.http.MediaType; import org.springframework.http.MediaType;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@ -50,6 +52,7 @@ import java.util.Map;
@Service @Service
public class SysOssServiceImpl implements ISysOssService, OssService { public class SysOssServiceImpl implements ISysOssService, OssService {
private static final Logger log = LoggerFactory.getLogger(SysOssServiceImpl.class);
private final SysOssMapper baseMapper; private final SysOssMapper baseMapper;
/** /**
@ -195,7 +198,8 @@ public class SysOssServiceImpl implements ISysOssService, OssService {
try { try {
uploadResult = storage.uploadSuffix(file.getBytes(), suffix); uploadResult = storage.uploadSuffix(file.getBytes(), suffix);
} catch (IOException e) { } catch (IOException e) {
throw new ServiceException(e.getMessage()); log.error("文件上传失败",e);
throw new ServiceException("文件上传失败,请联系管理员");
} }
// 保存文件信息 // 保存文件信息
return buildResultEntity(originalfileName, suffix, storage.getConfigKey(), uploadResult); return buildResultEntity(originalfileName, suffix, storage.getConfigKey(), uploadResult);