From 8532fb6e9d278f8dbd88e12bbe250c9c0a636556 Mon Sep 17 00:00:00 2001
From: sunxia <sunxia@prec-tech.com>
Date: 星期三, 16 三月 2022 10:29:56 +0800
Subject: [PATCH] obpm新需求修改

---
 force-app/main/default/classes/RentalApplyWebService.cls                    |   26 ++++++++-----
 force-app/main/default/classes/RentalFixtureSetAssignController.cls         |   10 ++++-
 force-app/main/default/classes/EquipmentSetShippmentReceived1Controller.cls |   30 ++++++++++++---
 force-app/main/default/classes/EquipmentSetShippmentReceived2Controller.cls |   14 ++++++-
 4 files changed, 60 insertions(+), 20 deletions(-)

diff --git a/force-app/main/default/classes/EquipmentSetShippmentReceived1Controller.cls b/force-app/main/default/classes/EquipmentSetShippmentReceived1Controller.cls
index ef9ed08..f19bb69 100644
--- a/force-app/main/default/classes/EquipmentSetShippmentReceived1Controller.cls
+++ b/force-app/main/default/classes/EquipmentSetShippmentReceived1Controller.cls
@@ -173,12 +173,22 @@
     // 淇濆瓨鎸夐挳
     public PageReference save() {
 
+        List<String> statusList = System.Label.StatusProcessState.split(',');
+
         //妫�鏌ユ槸鍚﹀彲浠ョ户缁�
-        Rental_Apply__c RaTar = [select Name,Campaign__c,Repair__c,next_action__c,QIS_number__r.ReplaceDeliveryDate__c,demo_purpose2__c,Follow_UP_Opp__r.Shipping_Finished_Day_Func__c,
-                                                Campaign__r.Status,repair__r.Return_Without_Repair_Date__c,Repair__r.Repair_Final_Inspection_Date__c,Repair__r.Repair_Shipped_Date__c,
-                                                Campaign__r.IF_Approved__c,Campaign__r.Meeting_Approved_No__c
-                                            from Rental_Apply__c 
-                                            where id=:Raid];
+        Rental_Apply__c RaTar = [select Name,Campaign__c,
+                                        Repair__c,
+                                        next_action__c,
+                                        QIS_number__r.ReplaceDeliveryDate__c,
+                                        demo_purpose2__c,
+                                        Follow_UP_Opp__r.Shipping_Finished_Day_Func__c,
+                                        Campaign__r.Status,
+                                        repair__r.Return_Without_Repair_Date__c,Repair__r.Repair_Final_Inspection_Date__c,Repair__r.Repair_Shipped_Date__c,
+                                        Campaign__r.IF_Approved__c,
+                                        Campaign__r.Meeting_Approved_No__c,
+                                        Campaign__r.Approved_Status__c      //20220315 sx obpm澶囧搧鍐宠鐘舵�佺浉鍏充慨鏀�
+                                    from Rental_Apply__c 
+                                    where id=:Raid];
 
         if( RaTar.Campaign__r.Status == '鍙栨秷'){
                 ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Error, '瀛︿細宸插彇娑堬紝涓嶈兘缁х画鎿嶄綔浜�'));
@@ -209,10 +219,18 @@
         
         //20220225 sx start obpm 涓嬫灦澧炲姞 鏄惁鐢宠鍐宠鍕剧潃娌℃湁鍐宠缂栧彿涓嶈兘杩涜鎿嶄綔
         else if ( RaTar.Campaign__c!= null && RaTar.Campaign__r.IF_Approved__c && RaTar.Campaign__r.Meeting_Approved_No__c == null){
-            ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Error, '鍗曞彿No.'+ RaTar.Name + '宸茬敵璇峰喅瑁佷絾鍐宠缂栫爜涓虹┖'));
+            ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Error, '宸茬敵璇峰喅瑁佷絾鍐宠缂栫爜涓虹┖'));
+            return null;
         }
         //20220225 sx end 涓嬫灦澧炲姞鍒ゆ柇
 
+        //20220315 sx start obpm obpm澶囧搧鍐宠鐘舵�佺浉鍏充慨鏀�
+        else if ( RaTar.Campaign__c!= null && RaTar.Campaign__r.IF_Approved__c && RaTar.Campaign__r.Meeting_Approved_No__c != null && statusList.contains(RaTar.Campaign__r.Approved_Status__c) ){
+            ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Error, '宸茬敵璇峰喅瑁佷絾鍐宠缂栫爜鐘舵�佷笉绗﹀悎闇�姹�'));
+            return null;
+        }
+        //20220315 sx end obpm obpm澶囧搧鍐宠鐘舵�佺浉鍏充慨鏀�
+
         String userid = Userinfo.getUserId();
         List<Rental_Apply_Equipment_Set_Detail__c> eList = new List<Rental_Apply_Equipment_Set_Detail__c>();
         Map<Id, Boolean> stockDownMap = new Map<Id, Boolean>();
diff --git a/force-app/main/default/classes/EquipmentSetShippmentReceived2Controller.cls b/force-app/main/default/classes/EquipmentSetShippmentReceived2Controller.cls
index 63fb18a..4454eb8 100644
--- a/force-app/main/default/classes/EquipmentSetShippmentReceived2Controller.cls
+++ b/force-app/main/default/classes/EquipmentSetShippmentReceived2Controller.cls
@@ -199,10 +199,13 @@
     // 淇濆瓨鎸夐挳
     public PageReference save() {
 
+        List<String> statusList = System.Label.StatusProcessState.split(',');
+
         //妫�鏌ユ槸鍚﹀彲浠ョ户缁�
         Rental_Apply__c RaTar = [select Campaign__c,Repair__c,next_action__c,QIS_number__r.ReplaceDeliveryDate__c,demo_purpose2__c,Follow_UP_Opp__r.Shipping_Finished_Day_Func__c,
                                                 Campaign__r.Status,repair__r.Return_Without_Repair_Date__c,Repair__r.Repair_Final_Inspection_Date__c,Repair__r.Repair_Shipped_Date__c,
-                                                Campaign__r.IF_Approved__c, Campaign__r.Meeting_Approved_No__c
+                                                Campaign__r.IF_Approved__c, Campaign__r.Meeting_Approved_No__c,
+                                                Campaign__r.Approved_Status__c      //20220315 sx obpm澶囧搧鍐宠鐘舵�佺浉鍏充慨鏀�
                                             from Rental_Apply__c 
                                             where id=:Raid];
 
@@ -240,6 +243,13 @@
             return null;
         }
         //20220225 sx end 涓嬫灦澧炲姞鍒ゆ柇
+
+        //20220315 sx start obpm澶囧搧鍐宠鐘舵�佺浉鍏充慨鏀�
+        else if ( RaTar.Campaign__c!= null &&  RaTar.Campaign__r.IF_Approved__c && RaTar.Campaign__r.Meeting_Approved_No__c != null && statusList.contains(RaTar.Campaign__r.Approved_Status__c)) {
+            ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Error, '宸茬敵璇峰喅瑁佷絾鍐宠缂栫爜鐘舵�佷笉绗﹀悎闇�姹�'));
+            return null;
+        }
+        //20220315 sx end obpm澶囧搧鍐宠鐘舵�佺浉鍏充慨鏀�
         
         String userid = Userinfo.getUserId();
         List<Rental_Apply_Equipment_Set_Detail__c> eList = new List<Rental_Apply_Equipment_Set_Detail__c>();
@@ -291,7 +301,7 @@
             return null;
         } catch (Exception ex) {
             system.debug('=====' + ex.getMessage());
-            ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Error, ex.getMessage()+'( '+Step_status+' )'));
+            ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Error, ex.getDmlMessage(0)));
             Database.rollback(sp);
             done_flg = false;
             return null;
diff --git a/force-app/main/default/classes/RentalApplyWebService.cls b/force-app/main/default/classes/RentalApplyWebService.cls
index 9bde9c4..0d5bf37 100644
--- a/force-app/main/default/classes/RentalApplyWebService.cls
+++ b/force-app/main/default/classes/RentalApplyWebService.cls
@@ -431,15 +431,15 @@
         }
         //1388 yc 20211021 璺ㄥ尯鍩熷垎閰嶄笉鑳藉嚭搴� end
         // 20220211 ljh add 澶囧搧FY23璇鹃01 start
-        AggregateResult[] resultsRas = [SELECT Rental_Start_Date__c,count(Id) cnt
-                                     FROM Rental_Apply_Equipment_Set__c
-                                     WHERE Rental_Apply__c = :rentalApplyId 
-                                     AND Cancel_Select__c = false
-                                     group by Rental_Start_Date__c];
-        If(resultsRas.size() > 1){
-        	returnStr = '鎵�鏈変竴瑙堝鍝侀璁″嚭璐ф棩搴斾竴鑷达紝涓嶄竴鑷翠笉鑳藉仛鍑哄簱鎸囩ず'; 
-            return returnStr;
-        }
+        // AggregateResult[] resultsRas = [SELECT Rental_Start_Date__c,count(Id) cnt
+        //                              FROM Rental_Apply_Equipment_Set__c
+        //                              WHERE Rental_Apply__c = :rentalApplyId 
+        //                              AND Cancel_Select__c = false
+        //                              group by Rental_Start_Date__c];
+        // If(resultsRas.size() > 1){
+        // 	returnStr = '鎵�鏈変竴瑙堝鍝侀璁″嚭璐ф棩搴斾竴鑷达紝涓嶄竴鑷翠笉鑳藉仛鍑哄簱鎸囩ず'; 
+        //     return returnStr;
+        // }
         // 20220211 ljh add 澶囧搧FY23璇鹃01 end
 
 //bp2        // 澶囧搧鍊熷嚭鍘嗗彶鍙栧緱
@@ -1159,7 +1159,10 @@
 //    }
     // 鍒嗛厤楠岃瘉
     Webservice static String AssignBtn(String Rid){
-        List<Rental_Apply__c> raList = [select demo_purpose2__c,next_action__c,QIS_number__r.ReplaceDeliveryDate__c,Follow_UP_Opp__r.Shipping_Finished_Day_Func__c,repair__r.Repair_Final_Inspection_Date__c,repair__r.Return_Without_Repair_Date__c,Campaign__c,Campaign__r.Status,Repair__r.Repair_Shipped_Date__c,Campaign__r.IF_Approved__c,Campaign__r.Meeting_Approved_No__c   from Rental_Apply__c where id = :Rid];
+
+        List<String> statusList = System.Label.StatusProcessState.split(',');
+
+        List<Rental_Apply__c> raList = [select demo_purpose2__c,next_action__c,QIS_number__r.ReplaceDeliveryDate__c,Follow_UP_Opp__r.Shipping_Finished_Day_Func__c,repair__r.Repair_Final_Inspection_Date__c,repair__r.Return_Without_Repair_Date__c,Campaign__c,Campaign__r.Status,Repair__r.Repair_Shipped_Date__c,Campaign__r.IF_Approved__c,Campaign__r.Meeting_Approved_No__c,Campaign__r.Approved_Status__c   from Rental_Apply__c where id = :Rid];
         // 20210803 ljh  SFDC-C5HDC7 add 鏌ヨ娣诲姞 Campaign__c,Campaign__r.Status,Repair__r.Repair_Shipped_Date__c 
         if(raList.size()>0){
             Rental_Apply__c Ra = raList[0];
@@ -1184,6 +1187,9 @@
            else if(Ra.Campaign__r.IF_Approved__c && Ra.Campaign__r.Meeting_Approved_No__c == null){
                 return '宸茬敵璇峰喅瑁佷絾鍐宠缂栫爜涓虹┖';
            }//20220301 sx obpm淇敼
+           else if(Ra.Campaign__r.IF_Approved__c && Ra.Campaign__r.Meeting_Approved_No__c != null && statusList.contains(Ra.Campaign__r.Approved_Status__c)){
+                return '宸茬敵璇峰喅瑁佷絾鍐宠缂栫爜鐘舵�佷笉绗﹀悎闇�姹�';
+           }//20220315 sx obpm澶囧搧鍐宠鐘舵�佺浉鍏充慨鏀�
            else{
                 return 'Fin';
             } 
diff --git a/force-app/main/default/classes/RentalFixtureSetAssignController.cls b/force-app/main/default/classes/RentalFixtureSetAssignController.cls
index 85dabea..dd42ffe 100644
--- a/force-app/main/default/classes/RentalFixtureSetAssignController.cls
+++ b/force-app/main/default/classes/RentalFixtureSetAssignController.cls
@@ -290,6 +290,7 @@
         // update銇犮亼浣跨敤銇欍倠
         List<Rental_Apply_Equipment_Set__c> mfUpdate = new List<Rental_Apply_Equipment_Set__c>();
         Savepoint sp = Database.setSavepoint();
+        List<String> statusList = System.Label.StatusProcessState.split(',');
 
         try {
             Boolean updRAFlg = false;
@@ -299,7 +300,8 @@
                            Asset_loaner_closed_day__c,
                            Campaign__c,
                            Campaign__r.IF_Approved__c,
-                           Campaign__r.Meeting_Approved_No__c
+                           Campaign__r.Meeting_Approved_No__c,
+                           Campaign__r.Approved_Status__c   //2022 sx obpm澶囧搧鍐宠鐘舵�佺浉鍏充慨鏀�
                       FROM Rental_Apply__c
                      WHERE Id = :parentId
                        FOR Update];
@@ -318,7 +320,11 @@
             if( raUpd.Campaign__c!= null && raUpd.Campaign__r.IF_Approved__c && raUpd.Campaign__r.Meeting_Approved_No__c == null){
                 throw new ControllerUtil.myException('宸茬敵璇峰喅瑁佷絾鍐宠缂栫爜涓虹┖');
             }
-
+            //20220315 sx obpm obpm澶囧搧鍐宠鐘舵�佺浉鍏充慨鏀� start
+            else if( raUpd.Campaign__c!= null && raUpd.Campaign__r.IF_Approved__c && raUpd.Campaign__r.Meeting_Approved_No__c != null && statusList.contains(raUpd.Campaign__r.Approved_Status__c) ){
+                throw new ControllerUtil.myException('宸茬敵璇峰喅瑁佷絾鍐宠缂栫爜鐘舵�佷笉绗﹀悎闇�姹�');
+            }
+            //20220315 sx obpm obpm澶囧搧鍐宠鐘舵�佺浉鍏充慨鏀� end
             Integer indexNum = 1;
             // 20210708 ljh SFDC-C47CLV add start
             Set<Id> raeIdset = new Set<Id>();

--
Gitblit v1.9.1