Browse Source

需求优化

chen 1 week ago
parent
commit
6aec13fed4
10 changed files with 78 additions and 57 deletions
  1. 4 0
      yudao-module-contract/yudao-module-contract-biz/src/main/java/cn/iocoder/yudao/module/contract/controller/admin/client/vo/ClientRespVO.java
  2. 3 0
      yudao-module-contract/yudao-module-contract-biz/src/main/java/cn/iocoder/yudao/module/contract/controller/admin/client/vo/ClientSaveReqVO.java
  3. 3 38
      yudao-module-contract/yudao-module-contract-biz/src/main/java/cn/iocoder/yudao/module/contract/controller/admin/exportContract/vo/ExportOrderExportVO.java
  4. 5 0
      yudao-module-contract/yudao-module-contract-biz/src/main/java/cn/iocoder/yudao/module/contract/controller/admin/frameworkAgreement/vo/FrameworkAgreementPageReqVO.java
  5. 1 1
      yudao-module-contract/yudao-module-contract-biz/src/main/java/cn/iocoder/yudao/module/contract/controller/admin/invoice/InvoiceController.java
  6. 1 0
      yudao-module-contract/yudao-module-contract-biz/src/main/java/cn/iocoder/yudao/module/contract/dal/mysql/frameworkAgreement/FrameworkAgreementMapper.java
  7. 3 3
      yudao-module-contract/yudao-module-contract-biz/src/main/java/cn/iocoder/yudao/module/contract/dal/mysql/order/OrderMapper.java
  8. 1 1
      yudao-module-contract/yudao-module-contract-biz/src/main/java/cn/iocoder/yudao/module/contract/service/invoice/InvoiceServiceImpl.java
  9. 49 14
      yudao-module-contract/yudao-module-contract-biz/src/main/java/cn/iocoder/yudao/module/contract/service/invoiceContract/InvoiceContractServiceImpl.java
  10. 8 0
      yudao-module-contract/yudao-module-contract-biz/src/main/java/cn/iocoder/yudao/module/contract/webservice/ContractWebService.java

+ 4 - 0
yudao-module-contract/yudao-module-contract-biz/src/main/java/cn/iocoder/yudao/module/contract/controller/admin/client/vo/ClientRespVO.java

@@ -90,4 +90,8 @@ public class ClientRespVO {
      * 快运车站(销售组)
      */
     private String bahne;
+    /**
+     * 信用期
+     */
+    private String zmonth;
 }

+ 3 - 0
yudao-module-contract/yudao-module-contract-biz/src/main/java/cn/iocoder/yudao/module/contract/controller/admin/client/vo/ClientSaveReqVO.java

@@ -69,4 +69,7 @@ public class ClientSaveReqVO {
     @Schema(description = "销售组")
     private String bahne;
 
+    @Schema(description = "信用期")
+    private String zmonth;
+
 }

+ 3 - 38
yudao-module-contract/yudao-module-contract-biz/src/main/java/cn/iocoder/yudao/module/contract/controller/admin/exportContract/vo/ExportOrderExportVO.java

@@ -14,25 +14,6 @@ import java.time.LocalDateTime;
 @ExcelIgnoreUnannotated
 public class ExportOrderExportVO {
 
-    @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "10864")
-    @ExcelProperty("编号")
-    private Long id;
-
-    @Schema(description = "类型编码")
-    @ExcelProperty("类型编码")
-    private String contractTypeCode;
-
-    @Schema(description = "类型名称", example = "李四")
-    @ExcelProperty("类型名称")
-    private String contractTypeName;
-
-    @Schema(description = "模板id", example = "4922")
-    @ExcelProperty("模板id")
-    private Long contractTemplateId;
-
-    @Schema(description = "模板名称", example = "张三")
-    @ExcelProperty("模板名称")
-    private String contractTemplateName;
 
     @Schema(description = "凭证日期")
     @ExcelProperty("凭证日期")
@@ -42,10 +23,6 @@ public class ExportOrderExportVO {
     @ExcelProperty("销售凭证")
     private String vbeln;
 
-    @Schema(description = "合同打印模板")
-    @ExcelProperty("合同打印模板")
-    private String htdymb;
-
     @Schema(description = "销售凭证类型")
     @ExcelProperty("销售凭证类型")
     private String auart;
@@ -154,10 +131,6 @@ public class ExportOrderExportVO {
     @ExcelProperty("产品质量")
     private String cpzl;
 
-    @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
-    @ExcelProperty("创建时间")
-    private LocalDateTime createTime;
-
     @Schema(description = "国际贸易条件")
     @ExcelProperty("国际贸易条件")
     private String inco1;
@@ -182,17 +155,9 @@ public class ExportOrderExportVO {
     @ExcelProperty("请求交货日期")
     private String vdatu;
 
-    @Schema(description = "合同id")
-    @ExcelProperty("合同id")
-    private String contractId;
-
-    @Schema(description = "合同号")
-    @ExcelProperty("合同号")
-    private String contractNo;
-
-    @Schema(description = "状态")
-    @ExcelProperty("状态")
-    private String status;
+    @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
+    @ExcelProperty("创建时间")
+    private LocalDateTime createTime;
 
 
 }

+ 5 - 0
yudao-module-contract/yudao-module-contract-biz/src/main/java/cn/iocoder/yudao/module/contract/controller/admin/frameworkAgreement/vo/FrameworkAgreementPageReqVO.java

@@ -34,4 +34,9 @@ public class FrameworkAgreementPageReqVO extends PageParam {
     @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
     private LocalDateTime[] createTime;
 
+
+    @Schema(description = "有效起期")
+    @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
+    private LocalDateTime[] agreementStartDate;
+
 }

+ 1 - 1
yudao-module-contract/yudao-module-contract-biz/src/main/java/cn/iocoder/yudao/module/contract/controller/admin/invoice/InvoiceController.java

@@ -225,7 +225,7 @@ public class InvoiceController {
                 CompanyDO company = companyService.getOne(Wrappers.<CompanyDO>lambdaQuery().eq(CompanyDO::getCompanyName, maxInvoice.getGfmc()));
                 if (!"3".equals(generateContractVO.getType())) {
                     List<String> zskpIds = invoiceList.stream().map(InvoiceDO::getZskpId).collect(Collectors.toList());
-                    List<Map<String, Object>> detailsSumList = invoiceDetailsMapper.selectMaps(Wrappers.<InvoiceDetailsDO>query().select("ggxh, hsdj ,sum(hsje) as hsjeTotal ,sum(sl) as slTotal").in("zskp_id", zskpIds).groupBy("ggxh", "hsdj").having("SUM(hsje) <= 0 or SUM(sl) <= 0"));
+                    List<Map<String, Object>> detailsSumList = invoiceDetailsMapper.selectMaps(Wrappers.<InvoiceDetailsDO>query().select("ggxh, hsdj ,sum(hsje) as hsjeTotal ,sum(sl) as slTotal").ne("sl","").in("zskp_id", zskpIds).groupBy("ggxh", "hsdj").having("SUM(hsje) <= 0 or SUM(sl) <= 0"));
                     if (detailsSumList.size() > 0) {
                         throw new ServiceException(GlobalErrorCodeConstants.INTERNAL_SERVER_ERROR.getCode(), "明细数据存在金额或数量统计为负数");
                     }

+ 1 - 0
yudao-module-contract/yudao-module-contract-biz/src/main/java/cn/iocoder/yudao/module/contract/dal/mysql/frameworkAgreement/FrameworkAgreementMapper.java

@@ -37,6 +37,7 @@ public interface FrameworkAgreementMapper extends BaseMapperX<FrameworkAgreement
                 .selectAll(FrameworkAgreementDO.class)
                 .selectAs(OrderContractDO::getId, FrameworkAgreementRespVO::getOrderContractId)
                 .betweenIfPresent(FrameworkAgreementDO::getCreateTime, reqVO.getCreateTime())
+                .betweenIfPresent(FrameworkAgreementDO::getAgreementStartDate, reqVO.getAgreementStartDate())
                 .like(!ObjectUtils.isEmpty(reqVO.getContractTemplateName()),FrameworkAgreementDO::getContractTemplateName, reqVO.getContractTemplateName())
                 .like(!ObjectUtils.isEmpty(reqVO.getContractNo()),FrameworkAgreementDO::getContractNo, reqVO.getContractNo())
                 .like(!ObjectUtils.isEmpty(reqVO.getClientName()),FrameworkAgreementDO::getClientName, reqVO.getClientName())

+ 3 - 3
yudao-module-contract/yudao-module-contract-biz/src/main/java/cn/iocoder/yudao/module/contract/dal/mysql/order/OrderMapper.java

@@ -80,12 +80,12 @@ public interface OrderMapper extends BaseMapperX<OrderDO> {
                 .le(!ObjectUtils.isEmpty(reqVO.getVbelnEnd()),OrderDO::getVbeln, reqVO.getVbelnEnd())
                 .like(!ObjectUtils.isEmpty(reqVO.getVkorg()),OrderDO::getVkorg, reqVO.getVkorg())
                 .in(!ObjectUtils.isEmpty(reqVO.getZzhtgklxms()),OrderDO::getZzhtgklxms,  !ObjectUtils.isEmpty(reqVO.getZzhtgklxms()) ?reqVO.getZzhtgklxms().split(","): new Object[]{""})
-                .in(!ObjectUtils.isEmpty(reqVO.getPzinfo()),OrderDO::getAuartt,  !ObjectUtils.isEmpty(reqVO.getPzinfo()) ?reqVO.getPzinfo().split(","): new Object[]{""})
+                .in(!ObjectUtils.isEmpty(reqVO.getPzinfo()),OrderDO::getAuart,  !ObjectUtils.isEmpty(reqVO.getPzinfo()) ?reqVO.getPzinfo().split(","): new Object[]{""})
                 .in(!ObjectUtils.isEmpty(reqVO.getBuinfo()),OrderDO::getButxt,  !ObjectUtils.isEmpty(reqVO.getBuinfo()) ?reqVO.getBuinfo().split(","): new Object[]{""})
 //                .in(!ObjectUtils.isEmpty(reqVO.getKuinfo()),OrderDO::getKname,  !ObjectUtils.isEmpty(reqVO.getKuinfo()) ?reqVO.getKuinfo().split(","): new Object[]{""})
 
-                .like(!ObjectUtils.isEmpty(reqVO.getKunnr()) && "1".equals(reqVO.getKunnrType()),OrderDO::getKunnr, reqVO.getKunnr())
-                .in(!ObjectUtils.isEmpty(reqVO.getKunnr()) && "2".equals(reqVO.getKunnrType()),OrderDO::getKunnr, !ObjectUtils.isEmpty(reqVO.getKunnr()) ?reqVO.getKunnr().split(","): new Object[]{""})
+                .and(!ObjectUtils.isEmpty(reqVO.getKunnr()) && "1".equals(reqVO.getKunnrType()),i-> i.like(OrderDO::getKunnr, reqVO.getKunnr()).or().like(OrderDO::getKname, reqVO.getKunnr()))
+                .and(!ObjectUtils.isEmpty(reqVO.getKunnr()) && "2".equals(reqVO.getKunnrType()),i -> i.in(OrderDO::getKunnr, !ObjectUtils.isEmpty(reqVO.getKunnr()) ?reqVO.getKunnr().split(","): new Object[]{""}).or().in(OrderDO::getKname, !ObjectUtils.isEmpty(reqVO.getKunnr()) ?reqVO.getKunnr().split(","): new Object[]{""}))
 
                 .in(!ObjectUtils.isEmpty(reqVO.getVkinfo()),OrderDO::getVkburt,  !ObjectUtils.isEmpty(reqVO.getVkinfo()) ?reqVO.getVkinfo().split(","): new Object[]{""})
                 .and(!ObjectUtils.isEmpty(reqVO.getVkginfo()),i -> i.like(OrderDO::getVkgrp, reqVO.getVkginfo()).or().like(OrderDO::getVkgrpt, reqVO.getVkginfo()))

+ 1 - 1
yudao-module-contract/yudao-module-contract-biz/src/main/java/cn/iocoder/yudao/module/contract/service/invoice/InvoiceServiceImpl.java

@@ -245,7 +245,7 @@ public class InvoiceServiceImpl extends ServiceImpl<InvoiceMapper, InvoiceDO> im
                 List<Long> invoiceIds = invoiceList.stream().map(InvoiceDO::getId).collect(Collectors.toList());
                 if(!"3".equals(generateContractVO.getType())){
                     List<String> zskpIds = invoiceList.stream().map(InvoiceDO::getZskpId).collect(Collectors.toList());
-                    List<Map<String,Object>> detailsSumList = invoiceDetailsMapper.selectMaps(Wrappers.<InvoiceDetailsDO>query().select("ggxh, hsdj ,sum(hsje) as hsjeTotal ,sum(sl) as slTotal").in("zskp_id",zskpIds).groupBy("ggxh","hsdj").having("SUM(hsje) <= 0 or SUM(sl) <= 0"));
+                    List<Map<String,Object>> detailsSumList = invoiceDetailsMapper.selectMaps(Wrappers.<InvoiceDetailsDO>query().select("ggxh, hsdj ,sum(hsje) as hsjeTotal ,sum(sl) as slTotal").ne("sl","").in("zskp_id",zskpIds).groupBy("ggxh","hsdj").having("SUM(hsje) <= 0 or SUM(sl) <= 0"));
                     if(detailsSumList.size()>0){
                         log.info("明细数据存在金额或数量统计为负数:,{}",JSONObject.toJSONString(detailsSumList));
                         if("1".equals(generateContractVO.getType())){

+ 49 - 14
yudao-module-contract/yudao-module-contract-biz/src/main/java/cn/iocoder/yudao/module/contract/service/invoiceContract/InvoiceContractServiceImpl.java

@@ -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()));

+ 8 - 0
yudao-module-contract/yudao-module-contract-biz/src/main/java/cn/iocoder/yudao/module/contract/webservice/ContractWebService.java

@@ -25,6 +25,7 @@ import cn.iocoder.yudao.module.contract.webservice.holders.TABLE_OF_ZSD_JS_009Ho
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.Wrapper;
+import com.baomidou.mybatisplus.core.toolkit.StringUtils;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.stereotype.Component;
@@ -170,6 +171,13 @@ public class ContractWebService {
                 }else{
                     add = add+1;
                 }
+                if(StringUtils.isNotBlank(clientDO.getZmonth())){
+                    if("000".equals(clientDO.getZmonth())){
+                        clientDO.setZmonth("0");
+                    }else{
+                        clientDO.setZmonth(clientDO.getZmonth().replace("000",""));
+                    }
+                }
                 clientService.saveOrUpdate(clientDO);
             }
             return StrUtil.format("同步成功-共{}条,修改{}条,新增{}条。",total,update,add);