From d8dc84a3d56df839895f1c417a4d9cbee763d262 Mon Sep 17 00:00:00 2001
From: 高章伟 <gaozhangwei@prec-tech.com>
Date: 星期五, 03 三月 2023 14:50:59 +0800
Subject: [PATCH] gzw 测试环境代码更新

---
 force-app/main/default/classes/OPDSortManageController.cls |   46 ++++++++++++++++++++++++++++++++++++++--------
 1 files changed, 38 insertions(+), 8 deletions(-)

diff --git a/force-app/main/default/classes/OPDSortManageController.cls b/force-app/main/default/classes/OPDSortManageController.cls
index 9e7c9c1..62cb759 100644
--- a/force-app/main/default/classes/OPDSortManageController.cls
+++ b/force-app/main/default/classes/OPDSortManageController.cls
@@ -271,11 +271,23 @@
         soql += 'if_Newest_HaveOpportunity__c,if_HaveOpportunity__c,if_HaveEquipment__c,PlanProdDetail__c,Cnt_Rentals__c,WorkshopPlace__c,Owner.Name,OPDLendSort__c,OPDLendSortDraft__c,OPDPlan_ImplementDate__c,Status__c,IsJump__c,OrderStatusNum__c,JumpCause__c,Campaign__c,AccountType__c,Account_Laboratory__r.Name,IsSaveOrSubmit__c,OPDLendSortBefore__c';
         soql += ' FROM OPDPlan__c where  Status__c = \'璁″垝涓璡' '; // 2020-12-09  mzy  update 淇濆瓨瀹屾垚鍚�,鏈儴缁存寔鍘熺姸 AND  OPDPlanSalesdepartment__c = \''+loginUser.Salesdepartment__c+'\'
         if(dateNow.month() != 12){
-            soql += 'AND CALENDAR_YEAR(OPDPlan_ImplementDate__c)='+year ;
-            soql += 'AND CALENDAR_MONTH(OPDPlan_ImplementDate__c) <='+month ;  //2020-11-16  mzy update 妫�绱㈡湀  淇敼渚嬪,11鍙�11鏈堜互鍓�
+            // 20230119 ljh start
+            // soql += 'AND CALENDAR_YEAR(OPDPlan_ImplementDate__c)='+year ;
+            // soql += 'AND CALENDAR_MONTH(OPDPlan_ImplementDate__c) <='+month ;  //2020-11-16  mzy update 妫�绱㈡湀  淇敼渚嬪,11鍙�11鏈堜互鍓�
+            if(dateNow.month() == 1){
+                Integer tempYear = year -1;
+                soql += 'AND(' ;
+                soql += ' CALENDAR_YEAR(OPDPlan_ImplementDate__c) ='+ tempYear; 
+                soql += ' OR( CALENDAR_YEAR(OPDPlan_ImplementDate__c) ='+year + 'AND CALENDAR_MONTH(OPDPlan_ImplementDate__c) <='+month +')' ;
+                soql += ')';
+            }else{
+                soql += 'AND CALENDAR_YEAR(OPDPlan_ImplementDate__c)='+year ;
+                soql += 'AND CALENDAR_MONTH(OPDPlan_ImplementDate__c) <='+month ;  //2020-11-16  mzy update 妫�绱㈡湀  淇敼渚嬪,11鍙�11鏈堜互鍓�
+            } 
+            // 20230119 ljh end
         }else if(dateNow.month() == 12){
             soql += 'AND(' ;
-            soql += ' CALENDAR_YEAR(OPDPlan_ImplementDate__c) ='+year ;               //2020-11-16  mzy update 妫�绱㈡湀  淇敼渚嬪,11鍙�11鏈堜互鍓�
+            soql += ' CALENDAR_YEAR(OPDPlan_ImplementDate__c) ='+year ;               //2020-11-16  mzy update 妫�绱㈡湀  淇敼渚嬪,11鍙�11鏈堜互鍓� 
             soql += ' OR( CALENDAR_YEAR(OPDPlan_ImplementDate__c) ='+nextyear + 'AND CALENDAR_MONTH(OPDPlan_ImplementDate__c) <='+month +')' ;
             soql += ')';
         }
@@ -558,17 +570,24 @@
         Date dateNow = Date.today();
         this.month = dateNow.month();
         this.year = dateNow.year();
+        Integer MonthSearch = Integer.valueOf(OPDMonth);  // 20230120 ljh end
         //2020-12-01  mzy  濡傛灉妫�绱㈢殑鏄�1鏈堝垯妫�绱粖骞翠竴鏁村勾+鏄庡勾1鏈堜唤鐨勬墍鏈塐PD璁″垝 add
         if(this.month==12){
             this.month=1;
             this.nextyear = this.year+1;  // 2020-12-01  mzy  濡傛灉妫�绱㈢殑鏄�1鏈� 鍒欐绱粖骞翠竴鏁村勾+鏄庡勾1鏈堜唤鐨勬墍鏈塐PD璁″垝 update  
         }else{
             this.month +=1;
+            // 20230120 ljh start
+            if(MonthSearch == 2 && dateNow.month() == 1){
+                this.year = dateNow.year() - 1;
+                this.nextyear = dateNow.year();
+            }
+            // 20230120 ljh end
         }
         //System.debug('骞翠唤鏄� : '+this.year);
-        Integer MonthSearch = Integer.valueOf(OPDMonth);
+        // Integer MonthSearch = Integer.valueOf(OPDMonth); // 20230120 ljh end
         if(month != MonthSearch){ 
-            month = MonthSearch;   
+            month = MonthSearch;  
             if (MonthSearch == 1){
               this.nextyear = dateNow.year() + 1;
             }
@@ -581,11 +600,22 @@
         soql +=' FROM OPDPlan__c where Status__c=\'璁″垝涓璡'';  
         // 2020-12-01  mzy  濡傛灉鏄�12鏈堝垯妫�绱粖骞翠竴鏁村勾+鏄庡勾1鏈堜唤鐨勬墍鏈塐PD璁″垝 update start
         if(this.month != 1){
-          soql += ' AND CALENDAR_YEAR(OPDPlan_ImplementDate__c)='+year ;
-          soql += ' AND CALENDAR_MONTH(OPDPlan_ImplementDate__c) <='+month ;   //2020-11-16  mzy update 妫�绱㈡湀  淇敼渚嬪,11鍙�11鏈堜互鍓�
+        // 20230120 ljh start 
+          // soql += ' AND CALENDAR_YEAR(OPDPlan_ImplementDate__c)='+year ;
+          // soql += ' AND CALENDAR_MONTH(OPDPlan_ImplementDate__c) <='+month ;   //2020-11-16  mzy update 妫�绱㈡湀  淇敼渚嬪,11鍙�11鏈堜互鍓�
+            if(this.month == 2){
+                soql += 'AND(' ;
+                soql += ' CALENDAR_YEAR(OPDPlan_ImplementDate__c) ='+year ;           //2020-11-16  mzy update 妫�绱㈡湀  淇敼渚嬪,11鍙�11鏈堜互鍓� 
+                soql += ' OR( CALENDAR_YEAR(OPDPlan_ImplementDate__c) ='+nextyear + ' AND CALENDAR_MONTH(OPDPlan_ImplementDate__c) <='+month +')' ;
+                soql += ')';
+            }else{
+                soql += ' AND CALENDAR_YEAR(OPDPlan_ImplementDate__c)='+year ;
+                soql += ' AND CALENDAR_MONTH(OPDPlan_ImplementDate__c) <='+month ;   //2020-11-16  mzy update 妫�绱㈡湀  淇敼渚嬪,11鍙�11鏈堜互鍓�
+            }
+        // 20230120 ljh end
         }else if(this.month == 1){
           soql += 'AND(' ;
-          soql += ' CALENDAR_YEAR(OPDPlan_ImplementDate__c) ='+year ;           //2020-11-16  mzy update 妫�绱㈡湀  淇敼渚嬪,11鍙�11鏈堜互鍓�
+          soql += ' CALENDAR_YEAR(OPDPlan_ImplementDate__c) ='+year ;           //2020-11-16  mzy update 妫�绱㈡湀  淇敼渚嬪,11鍙�11鏈堜互鍓� 
           soql += ' OR( CALENDAR_YEAR(OPDPlan_ImplementDate__c) ='+nextyear + ' AND CALENDAR_MONTH(OPDPlan_ImplementDate__c) <='+month +')' ;
           soql += ')';
         } 

--
Gitblit v1.9.1