Browse Source

需求优化

chen 1 week ago
parent
commit
b60ab26c59

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

@@ -200,7 +200,13 @@ public class InvoiceController {
         if("1".equals(generateContractVO.getType()) && StringUtils.isBlank(generateContractVO.getIds())){
             return error("请选择需要生成合同的订单");
         }
+        if(StringUtils.isBlank(generateContractVO.getOperateType())){
+            generateContractVO.setOperateType("1");
+        }
         String result = invoiceService.generateContract(generateContractVO);
+        if("2".equals(generateContractVO.getOperateType())){
+            return success(result);
+        }
         return success("操作成功");
     }
 
@@ -249,6 +255,7 @@ public class InvoiceController {
                 }
             }
         }
+
         return success(signingDate);
     }
 

+ 6 - 0
yudao-module-contract/yudao-module-contract-biz/src/main/java/cn/iocoder/yudao/module/contract/controller/admin/invoice/vo/GenerateContractVO.java

@@ -24,4 +24,10 @@ public class GenerateContractVO {
      * 3:批量生成退货协议
      */
     private String signingDate;
+
+    /**
+     * 1:合同生成
+     * 2:合同提前预览
+     */
+    private String operateType;
 }

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

@@ -189,7 +189,7 @@ public class InvoiceContractController {
             return error("合同不存在");
         }
         List<InvoiceDO> invoiceList = invoiceService.list(new LambdaQueryWrapper<InvoiceDO>().eq(InvoiceDO::getContractId,invoiceContract.getId()));
-        invoiceContractService.generateContractFile(invoiceContract,invoiceList);
+        invoiceContractService.generateContractFile(invoiceContract,invoiceList,"1");
         invoiceContractService.updateById(invoiceContract);
         if (!"1".equals(invoiceContract.getStatus())) {
             return error(invoiceContract.getAbnormalCause());

+ 2 - 2
yudao-module-contract/yudao-module-contract-biz/src/main/java/cn/iocoder/yudao/module/contract/dal/mysql/contractTemplate/ContractTemplateMapper.java

@@ -28,6 +28,6 @@ public interface ContractTemplateMapper extends BaseMapperX<ContractTemplateDO>
                 .orderByDesc(ContractTemplateDO::getCreateTime));
     }
 
-    @Select("SELECT count(1)  FROM ct_framework_agreement  WHERE YEAR ( create_time ) = YEAR ( CURDATE( ) );")
-    long countByYear();
+    @Select("SELECT count(1)  FROM ct_framework_agreement  WHERE YEAR ( agreement_start_date ) = YEAR ( #{agreementStartDate} );")
+    long countByYear(String agreementStartDate);
 }

+ 4 - 3
yudao-module-contract/yudao-module-contract-biz/src/main/java/cn/iocoder/yudao/module/contract/service/frameworkAgreement/FrameworkAgreementServiceImpl.java

@@ -83,8 +83,8 @@ public class FrameworkAgreementServiceImpl extends ServiceImpl<FrameworkAgreemen
         frameworkAgreement.setClientName(clientDO.getClientName());
         frameworkAgreement.setClientInfo(JSONObject.toJSONString(clientDO));
         validateUnique(frameworkAgreement.getId(),frameworkAgreement.getClientName(),frameworkAgreement.getAgreementStartDate(),frameworkAgreement.getAgreementEndDate());
-        long count = contractTemplateMapper.countByYear();
-        String contractNo = "KJXY"+DateUtil.format(new Date(),"yyyy")+sequenceCode(10000, count);
+        long count = contractTemplateMapper.countByYear(createReqVO.getAgreementStartDate());
+        String contractNo = "KJ-"+(createReqVO.getAgreementStartDate().substring(2,4))+sequenceCode(10000, count+1);
         if(StringUtils.isBlank(frameworkAgreement.getContractNo())){
             frameworkAgreement.setContractNo(contractNo);
         }
@@ -429,6 +429,7 @@ public class FrameworkAgreementServiceImpl extends ServiceImpl<FrameworkAgreemen
     }
 
     public static void main(String[] args) {
-        System.out.println(sequenceCode(100000, 1L));
+//        System.out.println("2024-11-04".substring(2,4));
+        System.out.println(sequenceCode(10000, 0L));
     }
 }

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

@@ -211,8 +211,14 @@ public class InvoiceServiceImpl extends ServiceImpl<InvoiceMapper, InvoiceDO> im
         }
     }
 
+    /**
+     *
+     * @param generateContractVO
+     * @return
+     */
     @Override
     public String generateContract(GenerateContractVO generateContractVO) {
+        String operateType = generateContractVO.getOperateType();
         List<InvoiceDO> list = null;
         String signingDate = "";
         if("1".equals(generateContractVO.getType())) {
@@ -304,19 +310,25 @@ public class InvoiceServiceImpl extends ServiceImpl<InvoiceMapper, InvoiceDO> im
                 invoiceContract.setInvoiceIds(invoiceIds.stream().map(String::valueOf).collect(Collectors.joining(",")));
                 invoiceContract.setGeneratedTime(LocalDateTime.now());
                 invoiceContract.setStatus("0");
-                invoiceContractService.save(invoiceContract);
-                invoiceContractService.generateContractFile(invoiceContract,invoiceList);
-                invoiceContractService.updateById(invoiceContract);
-                for(InvoiceDO invoice : invoiceList){
-                    InvoiceDO invoiceDO = new InvoiceDO();
-                    invoiceDO.setId(invoice.getId());
-                    invoiceDO.setStatus("1");
-                    invoiceDO.setContractNo(invoiceContract.getContractNo());
-                    invoiceDO.setContractId(invoiceContract.getId());
-                    invoiceDO.setContractGeneratedTime(LocalDateTime.now());
-                    updateById(invoiceDO);
+                if("1".equals(operateType)){
+                    invoiceContractService.save(invoiceContract);
+                }
+                invoiceContractService.generateContractFile(invoiceContract,invoiceList,operateType);
+                if("1".equals(operateType)){
+                    invoiceContractService.updateById(invoiceContract);
+                    for(InvoiceDO invoice : invoiceList){
+                        InvoiceDO invoiceDO = new InvoiceDO();
+                        invoiceDO.setId(invoice.getId());
+                        invoiceDO.setStatus("1");
+                        invoiceDO.setContractNo(invoiceContract.getContractNo());
+                        invoiceDO.setContractId(invoiceContract.getId());
+                        invoiceDO.setContractGeneratedTime(LocalDateTime.now());
+                        updateById(invoiceDO);
+                    }
+                    invoiceStatusPush(invoiceList,"1");
+                }else{
+                    return invoiceContract.getContractHtml();
                 }
-                invoiceStatusPush(invoiceList,"1");
             }
         }
 

+ 1 - 1
yudao-module-contract/yudao-module-contract-biz/src/main/java/cn/iocoder/yudao/module/contract/service/invoiceContract/InvoiceContractService.java

@@ -54,7 +54,7 @@ public interface InvoiceContractService extends IService<InvoiceContractDO> {
      */
     PageResult<InvoiceContractDO> getInvoiceContractPage(InvoiceContractPageReqVO pageReqVO);
 
-    void generateContractFile(InvoiceContractDO invoiceContract,List<InvoiceDO> invoiceList);
+    void generateContractFile(InvoiceContractDO invoiceContract,List<InvoiceDO> invoiceList,String type);
 
     void cancellation(InvoiceContractDO invoiceContract,List<InvoiceDO> invoiceList);
 }

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

@@ -125,8 +125,14 @@ public class InvoiceContractServiceImpl extends ServiceImpl<InvoiceContractMappe
         return invoiceContractMapper.selectPage(pageReqVO);
     }
 
+    /**
+     *
+     * @param invoiceContract
+     * @param invoiceList
+     * @param type 1生成合同文件 2生成html
+     */
     @Override
-    public void generateContractFile(InvoiceContractDO invoiceContract,List<InvoiceDO> invoiceList) {
+    public void generateContractFile(InvoiceContractDO invoiceContract,List<InvoiceDO> invoiceList,String type) {
 
         InvoiceDO maxInvoice = invoiceList.stream().max(Comparator.comparing(InvoiceDO::getKprq)).get();
         InvoiceDO minInvoice = invoiceList.stream().min(Comparator.comparing(InvoiceDO::getKprq)).get();
@@ -263,7 +269,9 @@ public class InvoiceContractServiceImpl extends ServiceImpl<InvoiceContractMappe
                 if(loanItems.size()>0){
                     htmlContents.add(generateAttachmentHtml(template2,param));
                 }
-                fileUrl = htmlToFileConverter.htmlToWord(htmlContents,"invoiceContract/"+invoiceContract.getContractNo(),"fpht-");
+                if("1".equals(type)){
+                    fileUrl = htmlToFileConverter.htmlToWord(htmlContents,"invoiceContract/"+invoiceContract.getContractNo(),"fpht-");
+                }
 //                htmlContent = new StringBuilder();
                 for(int i=0;i<htmlContents.size();i++){
                     if(i>0){
@@ -273,7 +281,9 @@ public class InvoiceContractServiceImpl extends ServiceImpl<InvoiceContractMappe
                 }
 //                htmlContent = StringUtils.join(htmlContents,"<div style='break-after: page;'></div><div class='page-break'>")+"</div>";
             }else{
-                fileUrl = htmlToFileConverter.htmlToWord(htmlContent.toString(),"invoiceContract/"+invoiceContract.getContractNo(),"fpht-");
+                if("1".equals(type)) {
+                    fileUrl = htmlToFileConverter.htmlToWord(htmlContent.toString(), "invoiceContract/" + invoiceContract.getContractNo(), "fpht-");
+                }
             }
 
             invoiceContract.setGeneratedTime(LocalDateTime.now());