From 2b8e522ec7c38570463a08e04bc1cc264a038e5b Mon Sep 17 00:00:00 2001
From: zm <2369059705qq.com>
Date: 星期一, 17 三月 2025 11:26:39 +0800
Subject: [PATCH] 整体BUG修改

---
 src/main/java/com/product/contract/service/ContractInfoService.java |   79 ++++++++++++++++++++++++++-------------
 1 files changed, 53 insertions(+), 26 deletions(-)

diff --git a/src/main/java/com/product/contract/service/ContractInfoService.java b/src/main/java/com/product/contract/service/ContractInfoService.java
index a74ed68..4fccc04 100644
--- a/src/main/java/com/product/contract/service/ContractInfoService.java
+++ b/src/main/java/com/product/contract/service/ContractInfoService.java
@@ -14,9 +14,12 @@
 import com.product.core.transfer.Transactional;
 import com.product.module.sys.entity.SystemUser;
 import com.product.util.BaseUtil;
+import org.apache.bcel.generic.IF_ACMPEQ;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
 
+import java.time.LocalDate;
+import java.time.format.DateTimeFormatter;
 import java.util.Date;
 
 /**
@@ -127,8 +130,44 @@
     public FieldSetEntity findContractInfo(FieldSetEntity fs) throws BaseException {
     	FieldSetEntity cfs =baseDao.getFieldSetEntity(CmnConst.LX_PROJECT_CONTRACT_INFO,fs.getUUID(),true);
     	DataTableEntity sub=cfs.getSubDataTable("product_project_contract_info_sub");
-    	
+        StringBuilder  filter=new StringBuilder(128);
+        filter.append(" uuid='"+cfs.getValues().get("project_uuid")+"'");
+        DataTableEntity product_project_business = baseDao.listTable("product_project_business",filter.toString(),new Object[]{});
+//        String guarantee_period = product_project_business.getData().get(0).getValues().get("guarantee_period").toString();
+        String guarantee_period = product_project_business.getString(0, "guarantee_period");
+        StringBuilder  dictFilter=new StringBuilder(128);
+        dictFilter.append("dict_name='椤圭洰绠$悊椤圭洰绫诲瀷' and dict_value="+product_project_business.getData().get(0).getValues().get("project_type").toString());
+        DataTableEntity product_sys_dict = baseDao.listTable("product_sys_dict", dictFilter.toString(), new Object[]{});
+       //鍚堝悓鏈夋晥鏈燂細濡傛灉鏄紑鍙戦」鐩�佸疄鏂介」鐩紝浠庨」鐩俊鎭殑璐ㄤ繚鏈熷甫杩囨潵
+        String dict_label = product_sys_dict.getData().get(0).getValues().get("dict_label").toString();
+        if(dict_label.equals("寮�鍙戦」鐩�") ||dict_label.equals("瀹炴柦椤圭洰")){
+            cfs.setValue("guarantee_period",guarantee_period);
+            cfs.setValue("project_type_now",dict_label);
+        }
+       //缁撴潫鏃ユ湡锛� 濡傛灉鏄紑鍙戦」鐩�佸疄鏂介」鐩紝楠屾敹鏃ユ湡+鍚堝悓鏈夋晥鏈燂紝缁存姢鍚堝悓鍒欐槸绛惧畾鏃ユ湡+鍚堝悓鏈夋晥鏈�
+        if(dict_label.equals("寮�鍙戦」鐩�") || dict_label.equals("瀹炴柦椤圭洰")){
+//            String carefully_check = product_project_business.getData().get(0).getValues().get("carefully_check").toString();
+            String carefully_check = product_project_business.getString(0, "carefully_check");
+            if (!StringUtils.isEmpty(carefully_check)){
+                String[] dateTime = carefully_check.split(" ");
+                String time=dateTime[0];
+                String date = getDate(time,guarantee_period);
+                cfs.setValue("end_time",date);
+            }
+        }
         return cfs;
+    }
+
+
+    //鏃ユ湡璁$畻鏂瑰紡
+    public String  getDate(String dateTime,String carefully_time){
+
+        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
+        LocalDate date = LocalDate.parse(dateTime, formatter);
+        // 鍔犱笂鎸囧畾鐨勬湀浠芥暟锛屼緥濡傚姞3涓湀
+        LocalDate newDate = date.plusMonths(Integer.parseInt(carefully_time));
+
+         return  newDate.format(formatter);
     }
 
     /**
@@ -139,28 +178,16 @@
      */
     public FieldSetEntity getContractInfoByName(FieldSetEntity fs) throws BaseException {
         FieldSetEntity fss = baseDao.getFieldSetEntity(CmnConst.LX_PROJECT_CONTRACT_INFO,fs.getUUID(),true);
-        FieldSetEntity fsProject = baseDao.getFieldSetEntity(CmnConst.LX_PROJECT_INFO,fss.getString("project_uuid"),false);
-        DataTableEntity dt = fss.getSubDataTable(CmnConst.LX_PROJECT_CONTRACT_INFO_SUB);
-        FieldSetEntity fsub = null;
-        int invoiced = 0;//宸插紑绁ㄩ噾棰�
-        int payment_received = 0;//宸插洖娆鹃噾棰�
-        if(dt!=null && dt.getRows()>0){
-            for (int i = 0; i < dt.getRows(); i++) {
-                fsub = dt.getFieldSetEntity(i);
-                String invo = fsub.getString("invoiced");
-                String paym = fsub.getString("payment_received");
-                if(BaseUtil.strIsNull(invo)){
-                    invo = "0";
-                }
-                if(BaseUtil.strIsNull(paym)){
-                    paym = "0";
-                }
-                invoiced += Double.parseDouble(invo);
-                payment_received += Double.parseDouble(paym);
-            }
+        FieldSetEntity fsProject = baseDao.getFieldSetEntity(CmnConst.PRODUCT_PROJECT_BUSINESS,fss.getString("project_uuid"),false);
+        FieldSetEntity fsCustomer = baseDao.getFieldSet("product_project_customer", fsProject.getString("customer_name"), false);
+        FieldSetEntity contractName = baseDao.getFieldSetEntityBySQL("SELECT sum(invoice_amount) invoice_amount FROM product_project_contract_invoice_info WHERE contract_invoice_uuid in(SELECT uuid FROM product_project_contract_invoice where contract_name=?)", new String[]{fs.getString("uuid")},false);
+        if (contractName==null||StringUtils.isEmpty(contractName.getString("invoice_amount"))){
+            fss.setValue("invoice_amount",0);
+        }else {
+            fss.setValue("invoice_amount",contractName.getString("invoice_amount"));
         }
-        fss.setValue("invoiced",invoiced);
-        fss.setValue("payment_received",payment_received);
+        fss.setValue("customer_name", fsCustomer.getString("customer_name"));
+        fss.setValue("collection_amount",0);
         fss.setValue("project_num",fsProject.getString("project_num"));
         fss.setValue("project_name",fsProject.getString("project_name"));
         return fss;
@@ -188,7 +215,7 @@
         if(fss!=null){
             fsinvo = baseDao.getFieldSetEntityByFilter(CmnConst.LX_PROJECT_CONTRACT_INVOICE,"contract_name=?",new Object[]{fss.getUUID()},true);
             fspaym = baseDao.getFieldSetEntityByFilter(CmnConst.LX_PROJECT_CONTRACT_PAYMENT,"contract_name=?",new Object[]{fss.getUUID()},true);
-            dtproj = baseDao.listTable(CmnConst.LX_PROJECT_INFO," uuid=? ",new Object[]{fss.getString("project_uuid")});
+            dtproj = baseDao.listTable(CmnConst.PRODUCT_PROJECT_BUSINESS," uuid=? ",new Object[]{fss.getString("project_uuid")});
         }
         DataTableEntity dt = fss.getSubDataTable(CmnConst.LX_PROJECT_CONTRACT_INFO_SUB);
         FieldSetEntity fsub = null;
@@ -235,9 +262,9 @@
             }
         }
         fss.setValue("invoiced",invoiced);//宸插紑绁ㄩ噾棰�
-        fss.setValue("uinvoiced",fss.getInteger("contract_amount")-invoiced);//鏈紑绁ㄩ噾棰�
+        fss.setValue("uinvoiced",fss.getDouble("contract_amount")-invoiced);//鏈紑绁ㄩ噾棰�
         fss.setValue("payment_received",payment_received);//宸插洖娆鹃噾棰�
-        fss.setValue("upayment_received",fss.getInteger("contract_amount")-payment_received);//鏈洖娆鹃噾棰�
+        fss.setValue("upayment_received",fss.getDouble("contract_amount")-payment_received);//鏈洖娆鹃噾棰�
         fss.setValue("project_total",dtproj.getRows());//椤圭洰鏁�
         fss.setValue("projecting",projecting);//鍦ㄥ缓椤圭洰
         fss.setValue("projected",projected);//瀹屾垚椤圭洰
@@ -268,7 +295,7 @@
      */
     public String isAddContract(FieldSetEntity fs) throws BaseException {
         String uuid = fs.getUUID();
-        DataTableEntity dataTableEntity = baseDao.listTable(" SELECT * FROM product_project_contract_info where flow_flag = 2 AND project_uuid = ? ", new String[]{uuid});
+        DataTableEntity dataTableEntity = baseDao.listTable(" SELECT * FROM product_project_contract_info where   project_uuid = ? ", new String[]{uuid});
         if (BaseUtil.dataTableIsEmpty(dataTableEntity)) {
             return "0";
         } else {

--
Gitblit v1.9.2