|
@@ -222,8 +222,18 @@ public class InvoiceContractServiceImpl extends ServiceImpl<InvoiceContractMappe
|
|
|
invoiceContract.setClientCode(clientDO.getClientCode());
|
|
|
}
|
|
|
|
|
|
- List<InvoiceDetailsDO> invoiceDetailsList = invoiceDetailsMapper.selectList(new LambdaQueryWrapper<InvoiceDetailsDO>().in(InvoiceDetailsDO::getZskpId, zskpIds));
|
|
|
+ List<InvoiceDetailsDO> invoiceDetailsList = invoiceDetailsMapper.selectList(new LambdaQueryWrapper<InvoiceDetailsDO>().in(InvoiceDetailsDO::getZskpId, zskpIds).ne("F2".equals(contractTemplate.getContractTypeCode()),InvoiceDetailsDO::getSl,""));
|
|
|
Map<String, List<InvoiceDetailsDO>> invoiceDetails = invoiceDetailsList.stream().collect(Collectors.groupingBy(item -> item.getGgxh() + "-" + item.getHsdj()));
|
|
|
+ //借贷项数据
|
|
|
+ Map<String, List<InvoiceDetailsDO>> loanItems = new HashMap<>();
|
|
|
+ if("F2".equals(contractTemplate.getContractTypeCode())){
|
|
|
+ for(InvoiceDO invoiceDO : invoiceList){
|
|
|
+ List<InvoiceDetailsDO> invoiceDetailList = invoiceDetailsMapper.selectList(new LambdaQueryWrapper<InvoiceDetailsDO>().eq(InvoiceDetailsDO::getZskpId, invoiceDO.getZskpId()).eq(InvoiceDetailsDO::getSl,""));
|
|
|
+ if(invoiceDetailList.size()>0){
|
|
|
+ loanItems.put(invoiceDO.getFphm(),invoiceDetailList);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
|
|
|
String frameworkAgreementNo = "";
|
|
@@ -240,27 +250,34 @@ public class InvoiceContractServiceImpl extends ServiceImpl<InvoiceContractMappe
|
|
|
}
|
|
|
invoiceContract.setFrameworkAgreementId(frameworkAgreementId);
|
|
|
|
|
|
- Map<String,Object> param = buildContractParam(invoiceContract,invoiceDetails,company,clientDO,frameworkAgreementNo,invoiceList);
|
|
|
- String htmlContent = contractTemplate.getContractContent();
|
|
|
- htmlContent = htmlInit(htmlContent);
|
|
|
- htmlContent = HtmlToFileConverter.authHtmlToPdf(htmlContent, param);
|
|
|
+ Map<String,Object> param = buildContractParam(invoiceContract,invoiceDetails,company,clientDO,frameworkAgreementNo,invoiceList,loanItems);
|
|
|
+ StringBuilder htmlContent = new StringBuilder(contractTemplate.getContractContent());
|
|
|
+ htmlContent = new StringBuilder(htmlInit(htmlContent.toString()));
|
|
|
+ htmlContent = new StringBuilder(HtmlToFileConverter.authHtmlToPdf(htmlContent.toString(), param));
|
|
|
String fileUrl = null;
|
|
|
if("F2".equals(contractTemplate.getContractTypeCode())){
|
|
|
//销购发票需要拼接附件
|
|
|
List<String> htmlContents = new ArrayList<>();
|
|
|
- htmlContents.add(htmlContent);
|
|
|
+ htmlContents.add(htmlContent.toString());
|
|
|
htmlContents.add(generateAttachmentHtml(template1,param));
|
|
|
- if(false){
|
|
|
- generateAttachmentHtml(template2,param);
|
|
|
+ if(loanItems.size()>0){
|
|
|
+ htmlContents.add(generateAttachmentHtml(template2,param));
|
|
|
}
|
|
|
fileUrl = htmlToFileConverter.htmlToWord(htmlContents,"invoiceContract/"+invoiceContract.getContractNo(),"fpht-");
|
|
|
- htmlContent = StringUtils.join(htmlContents,"<div style='break-after: page;'></div><div class='page-break'>")+"</div>";
|
|
|
+// htmlContent = new StringBuilder();
|
|
|
+ for(int i=0;i<htmlContents.size();i++){
|
|
|
+ if(i>0){
|
|
|
+ String html = htmlContents.get(i);
|
|
|
+ htmlContent.append("<div style='break-after: page;'></div><div class='page-break'>").append(html).append("</div>");
|
|
|
+ }
|
|
|
+ }
|
|
|
+// htmlContent = StringUtils.join(htmlContents,"<div style='break-after: page;'></div><div class='page-break'>")+"</div>";
|
|
|
}else{
|
|
|
- fileUrl = htmlToFileConverter.htmlToWord(htmlContent,"invoiceContract/"+invoiceContract.getContractNo(),"fpht-");
|
|
|
+ fileUrl = htmlToFileConverter.htmlToWord(htmlContent.toString(),"invoiceContract/"+invoiceContract.getContractNo(),"fpht-");
|
|
|
}
|
|
|
|
|
|
invoiceContract.setGeneratedTime(LocalDateTime.now());
|
|
|
- invoiceContract.setContractHtml(htmlContent);
|
|
|
+ invoiceContract.setContractHtml(htmlContent.toString());
|
|
|
invoiceContract.setContractFileUrl(fileUrl);
|
|
|
invoiceContract.setStatus("1");
|
|
|
invoiceContract.setAbnormalCause("");
|
|
@@ -304,7 +321,7 @@ public class InvoiceContractServiceImpl extends ServiceImpl<InvoiceContractMappe
|
|
|
|
|
|
}
|
|
|
|
|
|
- private Map<String, Object> buildContractParam(InvoiceContractDO invoiceContract, Map<String, List<InvoiceDetailsDO>> invoiceDetails, CompanyDO companyDO, ClientDO clientDO,String frameworkAgreementNo,List<InvoiceDO> invoiceList) {
|
|
|
+ private Map<String, Object> buildContractParam(InvoiceContractDO invoiceContract, Map<String, List<InvoiceDetailsDO>> invoiceDetails, CompanyDO companyDO, ClientDO clientDO,String frameworkAgreementNo,List<InvoiceDO> invoiceList,Map<String, List<InvoiceDetailsDO>> loanItems) {
|
|
|
Map<String,Object> param = new HashMap<>();
|
|
|
//订单信息
|
|
|
param.put("购方名称", StringUtils.nvl(invoiceContract.getGfmc(), ""));
|
|
@@ -325,7 +342,7 @@ public class InvoiceContractServiceImpl extends ServiceImpl<InvoiceContractMappe
|
|
|
param.put("组织名称", StringUtils.nvl(invoiceContract.getSellertaxname(), ""));
|
|
|
param.put("组织编码", StringUtils.nvl(invoiceContract.getSellertaxid(), ""));
|
|
|
param.put("框架协议号", StringUtils.nvl(frameworkAgreementNo, ""));
|
|
|
- param.put("付款方式", "000".equals(clientDO.getZmonth())?"款到发货":"货到付款");
|
|
|
+ param.put("付款方式", "0".equals(clientDO.getZmonth())?"款到发货":"货到付款");
|
|
|
param.put("框架协议名", StringUtils.isNotEmpty(frameworkAgreementNo)?"框架协议:":"");
|
|
|
//产品信息
|
|
|
List<Map<String,Object>> details = new ArrayList<>();
|
|
@@ -402,7 +419,7 @@ public class InvoiceContractServiceImpl extends ServiceImpl<InvoiceContractMappe
|
|
|
InvoiceDO invoiceDO = invoiceList.get(i);
|
|
|
Map<String,Object> data = new HashMap<>();
|
|
|
data.put("序号",i+1);
|
|
|
- data.put("明细合同编号", StringUtils.nvl(invoiceDO.getDdh(),""));
|
|
|
+ data.put("明细合同编号", StringUtils.nvl(invoiceContract.getContractNo(),""));
|
|
|
data.put("明细发票号码", StringUtils.nvl(invoiceDO.getFphm(),""));
|
|
|
data.put("明细金额", StringUtils.nvl(MoneyUtil.toSeparator(invoiceDO.getJshj()),""));
|
|
|
data.put("明细开票日期", StringUtils.nvl(invoiceDO.getKprq(),""));
|
|
@@ -410,6 +427,24 @@ public class InvoiceContractServiceImpl extends ServiceImpl<InvoiceContractMappe
|
|
|
}
|
|
|
param.put("invoiceList",invoices);
|
|
|
|
|
|
+ List<Map<String,Object>> loanItem = new ArrayList<>();
|
|
|
+ BigDecimal jeSum = BigDecimal.ZERO;
|
|
|
+ for (String key : loanItems.keySet()) {
|
|
|
+ List<InvoiceDetailsDO> detailsList = loanItems.get(key);
|
|
|
+ Map<String,Object> data = new HashMap<>();
|
|
|
+ for(InvoiceDetailsDO detailsDO : detailsList){
|
|
|
+ if(detailsDO.getHsje()!=null){
|
|
|
+ jeSum = jeSum.add(detailsDO.getHsje());
|
|
|
+ }
|
|
|
+ data.put("借贷项发票号码",key);
|
|
|
+ data.put("借贷项金额",StringUtils.nvl(MoneyUtil.toSeparator(detailsDO.getHsje().toString()),""));
|
|
|
+ data.put("借贷项类型",(detailsDO.getHsje()!=null && detailsDO.getHsje().compareTo(BigDecimal.ZERO) >0)?"补差价":"折扣");
|
|
|
+ loanItem.add(data);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ param.put("loanItem",loanItem);
|
|
|
+ param.put("借贷项总金额",StringUtils.nvl(MoneyUtil.toSeparator(String.valueOf(jeSum)), ""));
|
|
|
+
|
|
|
|
|
|
//产品合计
|
|
|
param.put("数量合计",MoneyUtil.toSeparator(quantityTotal.toString()));
|