From 80a3f59e2d3df07805bc67e329300b8de90a5b3a Mon Sep 17 00:00:00 2001
From: buli <137736985@qq.com>
Date: 星期二, 11 七月 2023 14:13:08 +0800
Subject: [PATCH] Merge branch 'LEXCommunityLiJun' into LEXUpgrade2023-Deloitte

---
 force-app/main/default/classes/EquipmentSetShippmentReceived3Controller.cls |  652 ++++++++++++++++++++++++++++++++++++++++------------------
 1 files changed, 449 insertions(+), 203 deletions(-)

diff --git a/force-app/main/default/classes/EquipmentSetShippmentReceived3Controller.cls b/force-app/main/default/classes/EquipmentSetShippmentReceived3Controller.cls
index ae50a30..cb07732 100644
--- a/force-app/main/default/classes/EquipmentSetShippmentReceived3Controller.cls
+++ b/force-app/main/default/classes/EquipmentSetShippmentReceived3Controller.cls
@@ -5,17 +5,17 @@
     public Rental_Apply_Equipment_Set__c es { get; set; }
     public List<EsdInfo> esdList { get; set; }
     public Boolean saveBtnDisabled { get; private set; }
-    public boolean ReturnRefuse {get;private set;}
-    public String ErrorMessage {get; set;}
+    public boolean ReturnRefuse { get; private set; }
+    public String ErrorMessage { get; set; }
     // public String CDSFinished {get;set;}
     // public boolean LostFlg {get;set;}
     public String Step_status { get; private set; }
     public Boolean needCDS { get; private set; }
     public Boolean done_flg { get; set; }
-    public String Raid {get;set;}
-    public String ApplyId {get;set;}
-    public String CheckedId {get;set;}
-    public String UnCheckedId {get;set;}
+    public String Raid { get; set; }
+    public String ApplyId { get; set; }
+    public String CheckedId { get; set; }
+    public String UnCheckedId { get; set; }
     private String Id;
 
     public Integer getEsdListSize() {
@@ -23,7 +23,7 @@
     }
 
     public EquipmentSetShippmentReceived3Controller() {
-//        Apexpages.currentPage().getHeaders().put('X-UA-Compatible', 'IE=8');
+        //        Apexpages.currentPage().getHeaders().put('X-UA-Compatible', 'IE=8');
         Id = ApexPages.currentPage().getParameters().get('id');
         if (Step_status == null) {
             Step_status = ApexPages.currentPage().getParameters().get('step');
@@ -32,20 +32,23 @@
     }
 
     public PageReference searchSlip() {
-        Map<String,boolean> esdIdMap = new Map<String,boolean>();
+        Map<String, boolean> esdIdMap = new Map<String, boolean>();
         for (EsdInfo esd : esdList) {
             if (!esd.hasSended)
-            esdIdMap.put(esd.rec.Id, esd.isChecked);
+                esdIdMap.put(esd.rec.Id, esd.isChecked);
         }
 
-        String qryString = 'select Combine_Pack__c, Name, Id, DeliveryCompany_SlipNo__c,DeliveryType__c,Distributor_method__c,DeliveryCompany__c,Wh_Staff__c '
-                + 'from FixtureDeliverySlip__c '
-                + 'where Name =\''+ slip.Name +'\' and DeliveryType__c = \'鍙戣揣\'';
+        String qryString =
+            'select Combine_Pack__c, Name, Id, DeliveryCompany_SlipNo__c,DeliveryType__c,Distributor_method__c,DeliveryCompany__c,Wh_Staff__c ' +
+            'from FixtureDeliverySlip__c ' +
+            'where Name =\'' +
+            slip.Name +
+            '\' and DeliveryType__c = \'鍙戣揣\'';
         if (String.isNotBlank(slip.Distributor_method__c)) {
-            qryString += ' and Distributor_method__c = \''+ slip.Distributor_method__c +'\'';
+            qryString += ' and Distributor_method__c = \'' + slip.Distributor_method__c + '\'';
         }
         if (String.isNotBlank(slip.DeliveryCompany__c)) {
-            qryString += ' and DeliveryCompany__c = \''+ slip.DeliveryCompany__c +'\'';
+            qryString += ' and DeliveryCompany__c = \'' + slip.DeliveryCompany__c + '\'';
         }
         List<FixtureDeliverySlip__c> slipList = Database.query(qryString);
 
@@ -56,15 +59,57 @@
             }
             slip = slipList[0];
 
-            List<Rental_Apply_Equipment_Set_Detail__c> eList = [select Rental_Apply__c, Rental_Apply__r.Shippment_ng_num__c, Rental_Apply__r.Pre_inspection_ng_num__c, SerialNumber_F__c, Rental_Apply_Equipment_Set__r.Inspection_not_finish__c, Fixture_Name_F__c, Rental_Apply_Equipment_Set__r.Fixture_Set__r.Name, Rental_Apply_Equipment_Set__r.Rental_Apply__r.Name, Rental_Apply_Equipment_Set__r.Name, Pre_inspection_time__c, StockDown__c, StockDown_time__c, Id, Name, Asset__c, Asset__r.Name, Asset__r.SerialNumber, Asset__r.Product_Serial_No__c,
-                           Asset__r.Remark__c, Asset__r.ImageAsset__c, Asset__r.ImageSerial__c, Asset__r.ImageAssetUploadedTime__c, Asset__r.ImageSerialUploadedTime__c,
-                           Loaner_CDS_Info__c, Inspection_result__c, Check_lost_Item__c, Pre_disinfection__c, Water_leacage_check__c, Inspection_result_after__c, Arrival_in_wh__c,
-                           Asset__r.Pre_Reserve_RAES_Detail__c, Asset__r.Pre_Reserve_RAES_Detail__r.After_Inspection_time__c,
-                           Inspection_result_after_ng__c, Inspection_result_ng__c, Lost_item_giveup__c, CDS_complete__c, Loaner_accsessary__c
-                      from Rental_Apply_Equipment_Set_Detail__c
-                     where (DeliverySlip__c = :slip.Id or Id in :esdIdMap.keySet())
-                       and Cancel_Select__c = False and Return_DeliverySlip__c = null
-                     order by Rental_Apply_Equipment_Set__r.Rental_Apply__r.Name, Rental_Apply_Equipment_Set__r.Name, Rental_Apply_Equipment_Set__c, Name];
+            List<Rental_Apply_Equipment_Set_Detail__c> eList = [
+                SELECT
+                    Rental_Apply__c,
+                    Rental_Apply__r.Shippment_ng_num__c,
+                    Rental_Apply__r.Pre_inspection_ng_num__c,
+                    SerialNumber_F__c,
+                    Rental_Apply_Equipment_Set__r.Inspection_not_finish__c,
+                    Fixture_Name_F__c,
+                    Rental_Apply_Equipment_Set__r.Fixture_Set__r.Name,
+                    Rental_Apply_Equipment_Set__r.Rental_Apply__r.Name,
+                    Rental_Apply_Equipment_Set__r.Name,
+                    Pre_inspection_time__c,
+                    StockDown__c,
+                    StockDown_time__c,
+                    Id,
+                    Name,
+                    Asset__c,
+                    Asset__r.Name,
+                    Asset__r.SerialNumber,
+                    Asset__r.Product_Serial_No__c,
+                    Asset__r.Remark__c,
+                    Asset__r.ImageAsset__c,
+                    Asset__r.ImageSerial__c,
+                    Asset__r.ImageAssetUploadedTime__c,
+                    Asset__r.ImageSerialUploadedTime__c,
+                    Loaner_CDS_Info__c,
+                    Inspection_result__c,
+                    Check_lost_Item__c,
+                    Pre_disinfection__c,
+                    Water_leacage_check__c,
+                    Inspection_result_after__c,
+                    Arrival_in_wh__c,
+                    Asset__r.Pre_Reserve_RAES_Detail__c,
+                    Asset__r.Pre_Reserve_RAES_Detail__r.After_Inspection_time__c,
+                    Inspection_result_after_ng__c,
+                    Inspection_result_ng__c,
+                    Lost_item_giveup__c,
+                    CDS_complete__c,
+                    Loaner_accsessary__c
+                FROM Rental_Apply_Equipment_Set_Detail__c
+                WHERE
+                    (DeliverySlip__c = :slip.Id
+                    OR Id IN :esdIdMap.keySet())
+                    AND Cancel_Select__c = FALSE
+                    AND Return_DeliverySlip__c = NULL
+                ORDER BY
+                    Rental_Apply_Equipment_Set__r.Rental_Apply__r.Name,
+                    Rental_Apply_Equipment_Set__r.Name,
+                    Rental_Apply_Equipment_Set__c,
+                    Name
+            ];
 
             esdList.clear();
             for (Rental_Apply_Equipment_Set_Detail__c esd : eList) {
@@ -85,11 +130,21 @@
         List<String> ids = ApplyId.split(',');
         Set<String> checkedIds = new Set<String>(CheckedId.split(':'));
         CheckedId = null;
-        List<Rental_Apply_Equipment_Set__c> esList = [select Rental_Apply__r.Name, First_RAESD_Model_No_F__c, First_RAESD__r.SerialNumber_F__c, First_RAESD__r.Loaner_asset_no__c, Rental_Apply__c, Id, RAES_Status__c, Name, Shippment_loaner_time2__c
-                                    from Rental_Apply_Equipment_Set__c
-                                    where (Rental_Apply__r.Name in :ids or Id in :ids)
-                                      AND Cancel_Select__c = False
-                                    order by Rental_Apply__r.Name, Id];
+        List<Rental_Apply_Equipment_Set__c> esList = [
+            SELECT
+                Rental_Apply__r.Name,
+                First_RAESD_Model_No_F__c,
+                First_RAESD__r.SerialNumber_F__c,
+                First_RAESD__r.Loaner_asset_no__c,
+                Rental_Apply__c,
+                Id,
+                RAES_Status__c,
+                Name,
+                Shippment_loaner_time2__c
+            FROM Rental_Apply_Equipment_Set__c
+            WHERE (Rental_Apply__r.Name IN :ids OR Id IN :ids) AND Cancel_Select__c = FALSE
+            ORDER BY Rental_Apply__r.Name, Id
+        ];
         Set<Id> esIds = new Set<Id>();
         Set<Id> esdIds = new Set<Id>();
         Set<Id> applySet = new Set<Id>();
@@ -102,15 +157,55 @@
             esdIds.add(raesd.rec.Id);
         }
         List<Rental_Apply_Equipment_Set_Detail__c> eList = [
-                select Rental_Apply__c, Rental_Apply__r.Shippment_ng_num__c, Rental_Apply__r.Pre_inspection_ng_num__c, SerialNumber_F__c, Rental_Apply_Equipment_Set__r.Inspection_not_finish__c, Fixture_Name_F__c, Rental_Apply_Equipment_Set__r.Fixture_Set__r.Name, Rental_Apply_Equipment_Set__r.Rental_Apply__r.Name, Rental_Apply_Equipment_Set__r.Name, Pre_inspection_time__c, StockDown__c, StockDown_time__c, Id, Name, Asset__c, Asset__r.Name, Asset__r.SerialNumber, Asset__r.Product_Serial_No__c,
-                       Asset__r.Remark__c, Asset__r.ImageAsset__c, Asset__r.ImageSerial__c, Asset__r.ImageAssetUploadedTime__c, Asset__r.ImageSerialUploadedTime__c,
-                       Loaner_CDS_Info__c, Inspection_result__c, Check_lost_Item__c, Pre_disinfection__c, Water_leacage_check__c, Inspection_result_after__c, Arrival_in_wh__c,
-                       Asset__r.Pre_Reserve_RAES_Detail__c, Asset__r.Pre_Reserve_RAES_Detail__r.After_Inspection_time__c,
-                       Inspection_result_after_ng__c, Inspection_result_ng__c, Lost_item_giveup__c, CDS_complete__c, Loaner_accsessary__c
-                  from Rental_Apply_Equipment_Set_Detail__c
-                 where Rental_Apply_Equipment_Set__c in :esIds and DeliverySlip__c = null and Return_DeliverySlip__c = null //and Inspection_result__c <> null and Shipment_request_time2__c <> null
-                   and Cancel_Select__c = False
-                 order by Rental_Apply_Equipment_Set__r.Rental_Apply__r.Name, Rental_Apply_Equipment_Set__r.Name, Rental_Apply_Equipment_Set__c, Name
+            SELECT
+                Rental_Apply__c,
+                Rental_Apply__r.Shippment_ng_num__c,
+                Rental_Apply__r.Pre_inspection_ng_num__c,
+                SerialNumber_F__c,
+                Rental_Apply_Equipment_Set__r.Inspection_not_finish__c,
+                Fixture_Name_F__c,
+                Rental_Apply_Equipment_Set__r.Fixture_Set__r.Name,
+                Rental_Apply_Equipment_Set__r.Rental_Apply__r.Name,
+                Rental_Apply_Equipment_Set__r.Name,
+                Pre_inspection_time__c,
+                StockDown__c,
+                StockDown_time__c,
+                Id,
+                Name,
+                Asset__c,
+                Asset__r.Name,
+                Asset__r.SerialNumber,
+                Asset__r.Product_Serial_No__c,
+                Asset__r.Remark__c,
+                Asset__r.ImageAsset__c,
+                Asset__r.ImageSerial__c,
+                Asset__r.ImageAssetUploadedTime__c,
+                Asset__r.ImageSerialUploadedTime__c,
+                Loaner_CDS_Info__c,
+                Inspection_result__c,
+                Check_lost_Item__c,
+                Pre_disinfection__c,
+                Water_leacage_check__c,
+                Inspection_result_after__c,
+                Arrival_in_wh__c,
+                Asset__r.Pre_Reserve_RAES_Detail__c,
+                Asset__r.Pre_Reserve_RAES_Detail__r.After_Inspection_time__c,
+                Inspection_result_after_ng__c,
+                Inspection_result_ng__c,
+                Lost_item_giveup__c,
+                CDS_complete__c,
+                Loaner_accsessary__c
+            FROM Rental_Apply_Equipment_Set_Detail__c
+            WHERE
+                Rental_Apply_Equipment_Set__c IN :esIds
+                AND DeliverySlip__c = NULL
+                AND Return_DeliverySlip__c = NULL //and Inspection_result__c <> null and Shipment_request_time2__c <> null
+                AND Cancel_Select__c = FALSE
+            ORDER BY
+                Rental_Apply_Equipment_Set__r.Rental_Apply__r.Name,
+                Rental_Apply_Equipment_Set__r.Name,
+                Rental_Apply_Equipment_Set__c,
+                Name
         ];
         //esdList.clear();
         for (Rental_Apply_Equipment_Set_Detail__c esd : eList) {
@@ -123,7 +218,7 @@
         for (EsdInfo raesd : esdList) {
             if (checkedIds.contains(raesd.rec.Rental_Apply_Equipment_Set__c)) {
                 raesd.isChecked = true;
-                system.debug('========4esdList='+JSON.serialize(raesd));
+                system.debug('========4esdList=' + JSON.serialize(raesd));
             }
         }
         return null;
@@ -140,33 +235,43 @@
         ReturnRefuse = true;
         ErrorMessage = '';
         if (Id != null) {
-            system.debug('==================='+Id);
+            system.debug('===================' + Id);
             // 褰撳墠User
             String userid = Userinfo.getUserId();
-            User user = [select Id,Name from User where Id = :userid];
+            User user = [SELECT Id, Name FROM User WHERE Id = :userid];
             List<Rental_Apply_Equipment_Set__c> esList;
             List<String> ids = Id.split(',');
-            esList = [select Rental_Apply__r.Name, First_RAESD_Model_No_F__c, First_RAESD__r.SerialNumber_F__c, First_RAESD__r.Loaner_asset_no__c, Rental_Apply__c, Id, RAES_Status__c, Name, Shippment_loaner_time2__c
-                                        from Rental_Apply_Equipment_Set__c
-                                       where (Rental_Apply__r.Name in :ids or Id in:ids)
-                                         AND Cancel_Select__c = False
-                                       order by Rental_Apply__r.Name, Id];
-         //   if (Step_status == '杩藉姞') {
+            esList = [
+                SELECT
+                    Rental_Apply__r.Name,
+                    First_RAESD_Model_No_F__c,
+                    First_RAESD__r.SerialNumber_F__c,
+                    First_RAESD__r.Loaner_asset_no__c,
+                    Rental_Apply__c,
+                    Id,
+                    RAES_Status__c,
+                    Name,
+                    Shippment_loaner_time2__c
+                FROM Rental_Apply_Equipment_Set__c
+                WHERE (Rental_Apply__r.Name IN :ids OR Id IN :ids) AND Cancel_Select__c = FALSE
+                ORDER BY Rental_Apply__r.Name, Id
+            ];
+            //   if (Step_status == '杩藉姞') {
 
             //} else {
             //  // 澶囧搧set
-         //     esList = [select Rental_Apply__r.Name, First_RAESD_Model_No_F__c, First_RAESD__r.SerialNumber_F__c, First_RAESD__r.Loaner_asset_no__c, Rental_Apply__c, Id, RAES_Status__c, Name, Shippment_loaner_time__c
-         //                                   from Rental_Apply_Equipment_Set__c
-         //                                  where (Rental_Apply__r.Name = :Id or Id = :Id)
-         //                                    AND Cancel_Select__c = False
-         //                                  ];
+            //     esList = [select Rental_Apply__r.Name, First_RAESD_Model_No_F__c, First_RAESD__r.SerialNumber_F__c, First_RAESD__r.Loaner_asset_no__c, Rental_Apply__c, Id, RAES_Status__c, Name, Shippment_loaner_time__c
+            //                                   from Rental_Apply_Equipment_Set__c
+            //                                  where (Rental_Apply__r.Name = :Id or Id = :Id)
+            //                                    AND Cancel_Select__c = False
+            //                                  ];
             //}
 
             //if (Step_status == '鏄庣粏') {
-                slip.Wh_Staff__c = userid;
-                slip.DeliveryType__c = '鍙戣揣';
+            slip.Wh_Staff__c = userid;
+            slip.DeliveryType__c = '鍙戣揣';
             //}
-            //List<Fixture_Set__c> esList = [select Id, Name, CDS_staff__c, Shippment_loaner_time__c, Received_loaner_time__c, 
+            //List<Fixture_Set__c> esList = [select Id, Name, CDS_staff__c, Shippment_loaner_time__c, Received_loaner_time__c,
             //                                       delivery_company__c, Return_to_wh_staff__c, Return_to_wh_staff__r.Name, Fedex_number__c, Distributor_method__c,
             //                                       Return_delivery_company__c,Return_wh_chenk_staff__c, Received_confirmation_staff__c, Received_confirmation_staff__r.Name, Return_Fedex_number__c, Return_Distributor_method__c,
             //                                       Arrival_wh_time2__c, Asset_return_time__c,
@@ -211,21 +316,60 @@
             // system.debug('All::::'+Rac.repair__c);
             //  system.debug('All::::'+Ra_c.RAES_Status__c);
             // 鏈暘鏆備笉涓婄嚎璇ュ姛鑳斤紝鍚敤鍚庝笉鑳藉叆搴撴搷浣滄劅瑙変笉瀵�
-
-
         }
 
         // 澶囧搧set鏄庣粏
         List<Rental_Apply_Equipment_Set_Detail__c> eList = [
-                select Rental_Apply__c, Rental_Apply__r.Shippment_ng_num__c, Rental_Apply__r.Pre_inspection_ng_num__c, SerialNumber_F__c, Rental_Apply_Equipment_Set__r.Inspection_not_finish__c, Fixture_Name_F__c, Rental_Apply_Equipment_Set__r.RAES_Status__c, Rental_Apply_Equipment_Set__r.Fixture_Set__r.Name, Rental_Apply_Equipment_Set__r.Rental_Apply__r.Name, Rental_Apply_Equipment_Set__r.Name, Pre_inspection_time__c, StockDown__c, StockDown_time__c, Id, Name, Asset__c, Asset__r.Name, Asset__r.SerialNumber, Asset__r.Product_Serial_No__c,
-                       Asset__r.Remark__c, Asset__r.ImageAsset__c, Asset__r.ImageSerial__c, Asset__r.ImageAssetUploadedTime__c, Asset__r.ImageSerialUploadedTime__c,
-                       Loaner_CDS_Info__c, Inspection_result__c, Check_lost_Item__c, Pre_disinfection__c, Water_leacage_check__c, Inspection_result_after__c, Arrival_in_wh__c,
-                       Asset__r.Pre_Reserve_RAES_Detail__c, Asset__r.Pre_Reserve_RAES_Detail__r.After_Inspection_time__c,
-                       Inspection_result_after_ng__c, Inspection_result_ng__c, Lost_item_giveup__c, CDS_complete__c, Loaner_accsessary__c
-                  from Rental_Apply_Equipment_Set_Detail__c
-                 where Rental_Apply_Equipment_Set__c in :esIds and DeliverySlip__c = null and Return_DeliverySlip__c = null//and Shipment_request_time__c <> null
-                   and Cancel_Select__c = False
-                 order by Rental_Apply_Equipment_Set__r.Rental_Apply__r.Name, Rental_Apply_Equipment_Set__r.Name, Rental_Apply_Equipment_Set__c, Name
+            SELECT
+                Rental_Apply__c,
+                Rental_Apply__r.Shippment_ng_num__c,
+                Rental_Apply__r.Pre_inspection_ng_num__c,
+                SerialNumber_F__c,
+                Rental_Apply_Equipment_Set__r.Inspection_not_finish__c,
+                Fixture_Name_F__c,
+                Rental_Apply_Equipment_Set__r.RAES_Status__c,
+                Rental_Apply_Equipment_Set__r.Fixture_Set__r.Name,
+                Rental_Apply_Equipment_Set__r.Rental_Apply__r.Name,
+                Rental_Apply_Equipment_Set__r.Name,
+                Pre_inspection_time__c,
+                StockDown__c,
+                StockDown_time__c,
+                Id,
+                Name,
+                Asset__c,
+                Asset__r.Name,
+                Asset__r.SerialNumber,
+                Asset__r.Product_Serial_No__c,
+                Asset__r.Remark__c,
+                Asset__r.ImageAsset__c,
+                Asset__r.ImageSerial__c,
+                Asset__r.ImageAssetUploadedTime__c,
+                Asset__r.ImageSerialUploadedTime__c,
+                Loaner_CDS_Info__c,
+                Inspection_result__c,
+                Check_lost_Item__c,
+                Pre_disinfection__c,
+                Water_leacage_check__c,
+                Inspection_result_after__c,
+                Arrival_in_wh__c,
+                Asset__r.Pre_Reserve_RAES_Detail__c,
+                Asset__r.Pre_Reserve_RAES_Detail__r.After_Inspection_time__c,
+                Inspection_result_after_ng__c,
+                Inspection_result_ng__c,
+                Lost_item_giveup__c,
+                CDS_complete__c,
+                Loaner_accsessary__c
+            FROM Rental_Apply_Equipment_Set_Detail__c
+            WHERE
+                Rental_Apply_Equipment_Set__c IN :esIds
+                AND DeliverySlip__c = NULL
+                AND Return_DeliverySlip__c = NULL //and Shipment_request_time__c <> null
+                AND Cancel_Select__c = FALSE
+            ORDER BY
+                Rental_Apply_Equipment_Set__r.Rental_Apply__r.Name,
+                Rental_Apply_Equipment_Set__r.Name,
+                Rental_Apply_Equipment_Set__c,
+                Name
         ];
         //Set<Id> lockId = new Set<Id>();
         //for (Rental_Apply_Equipment_Set_Detail__c esd : eList) {
@@ -266,8 +410,8 @@
 
     // Step 鍒囥倞鏇裤亪銉溿偪銉炽�佸彂璐у墠-妫�娴�
     public PageReference ShippmentDetail() {
-        system.debug('========cid='+CheckedId);
-        system.debug('========esd='+esdList.size());
+        system.debug('========cid=' + CheckedId);
+        system.debug('========esd=' + esdList.size());
         Step_status = '鏄庣粏';
         //slip.Wh_Staff__c = Userinfo.getUserId();
         //slip.DeliveryType__c = '鍙戣揣';
@@ -288,12 +432,14 @@
                     allcount.put(esd.rec.Rental_Apply__c, Integer.valueOf(esd.rec.Rental_Apply__r.Shippment_ng_num__c));
                 }
             }
-            system.debug('========shipcount='+JSON.serialize(shipcount));
-            system.debug('========shipcount='+JSON.serialize(allcount));
+            system.debug('========shipcount=' + JSON.serialize(shipcount));
+            system.debug('========shipcount=' + JSON.serialize(allcount));
             for (String raid : allcount.keySet()) {
                 if (allcount.get(raid) > shipcount.get(raid).size()) {
                     Step_status = '杩藉姞';
-                    ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Error, '鐢宠鍗曞唴瀛樺湪鏈嬀閫夌殑閰嶅锛岃鍕鹃�夊叏閮ㄩ厤濂楁垨鍒嗗壊鐢宠鍗�!'));
+                    ApexPages.addmessage(
+                        new ApexPages.message(ApexPages.severity.Error, '鐢宠鍗曞唴瀛樺湪鏈嬀閫夌殑閰嶅锛岃鍕鹃�夊叏閮ㄩ厤濂楁垨鍒嗗壊鐢宠鍗�!')
+                    );
                 }
             }
         }
@@ -306,7 +452,7 @@
     // Step 鍒囥倞鏇裤亪銉溿偪銉炽�佸彂璐�-鍙戣揣杩愯緭鍗曞彿 绛�
     public PageReference ShippmentAdd() {
         Step_status = '杩藉姞';
-        system.debug('========2esdList='+JSON.serialize(esdList));
+        system.debug('========2esdList=' + JSON.serialize(esdList));
         //return new PageReference('/apex/EquipmentSetShippmentReceived3?id=' + this.Id + '&step=' + this.Step_status);
         return null;
     }
@@ -334,31 +480,39 @@
 
     // 淇濆瓨鎸夐挳
     public PageReference save() {
-
         List<String> raids = Raid.split(':');
         //妫�鏌ユ槸鍚﹀彲浠ョ户缁�
-        List<Rental_Apply__c> RaTarList = [select Id,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
-                                                ,Campaign__r.IF_Approved__c
-                                                ,Campaign__r.Meeting_Approved_No__c // 20220315 ljh obpm澶囧搧鍐宠鐘舵�佺浉鍏充慨鏀�
-                                                ,Campaign__r.Approved_Status__c     // 20220315 ljh obpm澶囧搧鍐宠鐘舵�佺浉鍏充慨鏀�
-                                                ,repair__r.Return_Without_Repair_Date__c
-                                                ,Repair__r.Repair_Final_Inspection_Date__c
-                                                ,Repair__r.Repair_Shipped_Date__c
-                                            from Rental_Apply__c 
-                                            where id in :raids];//20210602 ljh update 澧炲姞鏌ヨName SFDC-C3LBNL 
+        List<Rental_Apply__c> RaTarList = [
+            SELECT
+                Id,
+                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,
+                Campaign__r.IF_Approved__c,
+                Campaign__r.Meeting_Approved_No__c, // 20220315 ljh obpm澶囧搧鍐宠鐘舵�佺浉鍏充慨鏀�
+                Campaign__r.Approved_Status__c, // 20220315 ljh obpm澶囧搧鍐宠鐘舵�佺浉鍏充慨鏀�
+                repair__r.Return_Without_Repair_Date__c,
+                Repair__r.Repair_Final_Inspection_Date__c,
+                AccDealerBlacklist__c, //璐告槗鍚堣 you
+                //,EquipmentGuaranteeFlg__c//璐告槗鍚堣 you
+                Repair__r.Repair_Shipped_Date__c
+            FROM Rental_Apply__c
+            WHERE id IN :raids
+        ]; //20210602 ljh update 澧炲姞鏌ヨName SFDC-C3LBNL
 
         // add lc 20220927 SFDC-CJ48VE 澶囧搧棰勮鍑哄簱鏃ラ�昏緫璋冩暣 start
         Map<Id, String> rentalApplyNameMap = new Map<Id, String>();
         List<Rental_Apply_Equipment_Set__c> RAESRecords = [
-                SELECT Id,Rental_Apply__c,Rental_Apply__r.Name 
-                FROM Rental_Apply_Equipment_Set__c 
-                WHERE Rental_Apply__c in :raids
-                AND Cancel_Select__c = False
-                AND Rental_Start_Date__c <> :Date.today()
-                ORDER BY Rental_Apply__c];
+            SELECT Id, Rental_Apply__c, Rental_Apply__r.Name
+            FROM Rental_Apply_Equipment_Set__c
+            WHERE Rental_Apply__c IN :raids AND Cancel_Select__c = FALSE AND Rental_Start_Date__c != :Date.today()
+            ORDER BY Rental_Apply__c
+        ];
 
         for (Rental_Apply_Equipment_Set__c RAES : RAESRecords) {
             if (rentalApplyNameMap.isEmpty() || !rentalApplyNameMap.containsKey(RAES.Rental_Apply__c)) {
@@ -374,63 +528,75 @@
         String message2 = '';
         String message3 = '';
         String message = '';
-        String message4 = '';//1822 yc 20211025 宸茶喘寰呰揣鐩殑锛屾柊鍝佸凡鏈夊彂璐ф棩涓嶈兘鍑哄簱
-        String message5 = '';//1822 yc 20211108 绱㈣禂QIS鐩殑锛孮IS宸叉湁鏂板搧鍙戣揣鏃ヤ笉鑳藉嚭搴�
+        String message4 = ''; //1822 yc 20211025 宸茶喘寰呰揣鐩殑锛屾柊鍝佸凡鏈夊彂璐ф棩涓嶈兘鍑哄簱
+        String message5 = ''; //1822 yc 20211108 绱㈣禂QIS鐩殑锛孮IS宸叉湁鏂板搧鍙戣揣鏃ヤ笉鑳藉嚭搴�
         String message6 = '';
-        String message7 = '';// 20220315 ljh obpm澶囧搧鍐宠鐘舵�佺浉鍏充慨鏀� end
-        String message8 = '';//add lc 20220927 SFDC-CJ48VE 澶囧搧棰勮鍑哄簱鏃ラ�昏緫璋冩暣
+        String message7 = ''; // 20220315 ljh obpm澶囧搧鍐宠鐘舵�佺浉鍏充慨鏀� end
+        String message8 = ''; //add lc 20220927 SFDC-CJ48VE 澶囧搧棰勮鍑哄簱鏃ラ�昏緫璋冩暣
+        String message9 = ''; //璐告槗鍚堣 you
         // 瑕佸垽鏂喅瑁佺姸鎬佷笉鑳芥槸鑽夌/椹冲洖/缁堟鐢宠/鍙栨秷/鍒犻櫎
         List<String> statusList = System.Label.StatusProcessState.split(',');
         Map<Id, Rental_Apply__c> RaMap = new Map<Id, Rental_Apply__c>();
         for (Rental_Apply__c RaTar : RaTarList) {
             // 20230215 ljh DB202301265636 瀛︿細鍙栨秷鐢宠涔熸嫤鎴� start
             // if( RaTar.Campaign__r.Status == '鍙栨秷'){
-            if( RaTar.Campaign__r.Status == '鍙栨秷' || RaTar.Campaign__r.Status == '鍙栨秷鐢宠涓�'){
-            // 20230215 ljh DB202301265636 瀛︿細鍙栨秷鐢宠涔熸嫤鎴� end
+            //璐告槗鍚堣 you
+            // && RaTar.EquipmentGuaranteeFlg__c==false
+            if (System.Label.TradeComplianceStatusFlagBP == 'true' && RaTar.AccDealerBlacklist__c == '1') {
+                errorFlag = true;
+                message9 += RaTar.Name + '銆�';
+            } else if (RaTar.Campaign__r.Status == '鍙栨秷' || RaTar.Campaign__r.Status == '鍙栨秷鐢宠涓�') {
+                // 20230215 ljh DB202301265636 瀛︿細鍙栨秷鐢宠涔熸嫤鎴� end
                 // ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Error, '瀛︿細宸插彇娑堬紝涓嶈兘缁х画鎿嶄綔浜�'));
                 // return null;
                 errorFlag = true;
-                message0 += RaTar.Name+'銆�';
-            }else if(RaTar.Repair__r.Repair_Final_Inspection_Date__c!=null){
-                // ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Error, '瀛樺湪淇悊鏈�缁堟娴嬫棩锛屼笉鑳界户缁簡'));        
+                message0 += RaTar.Name + '銆�';
+            } else if (RaTar.Repair__r.Repair_Final_Inspection_Date__c != null) {
+                // ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Error, '瀛樺湪淇悊鏈�缁堟娴嬫棩锛屼笉鑳界户缁簡'));
                 // return null;
                 errorFlag = true;
-                message1 += RaTar.Name+'銆�';
-            }else if(RaTar.repair__r.Return_Without_Repair_Date__c!=null&&RaTar.repair__c!=null ){
-
+                message1 += RaTar.Name + '銆�';
+            } else if (RaTar.repair__r.Return_Without_Repair_Date__c != null && RaTar.repair__c != null) {
                 // ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Error, '鏈慨鐞嗗綊杩樻棩涓嶄负绌猴紝涓嶈兘鍑哄簱'));
                 // return null;
                 errorFlag = true;
-                message2 += RaTar.Name+'銆�';
-            }else if(RaTar.Repair__r.Repair_Shipped_Date__c!=null){
-
+                message2 += RaTar.Name + '銆�';
+            } else if (RaTar.Repair__r.Repair_Shipped_Date__c != null) {
                 // ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Error, '瀛樺湪RC淇悊杩旈�佹棩锛屼笉鑳界户缁簡'));
                 // return null;
                 errorFlag = true;
-                message3 += RaTar.Name+'銆�';
+                message3 += RaTar.Name + '銆�';
             }
             //1822 yc 20211025 宸茶喘寰呰揣鐩殑锛屾柊鍝佸凡鏈夊彂璐ф棩涓嶈兘鍑哄簱 start
-            else if(RaTar.demo_purpose2__c=='宸茶喘寰呰揣' && RaTar.Follow_UP_Opp__r.Shipping_Finished_Day_Func__c!= null){
+            else if (RaTar.demo_purpose2__c == '宸茶喘寰呰揣' && RaTar.Follow_UP_Opp__r.Shipping_Finished_Day_Func__c != null) {
                 errorFlag = true;
-                message4 += RaTar.Name+'銆�';
-            }else if(RaTar.demo_purpose2__c=='绱㈣禂QIS' && RaTar.next_action__c=='鏃犲伩鏇存崲' && RaTar.QIS_number__r.ReplaceDeliveryDate__c!= null){
+                message4 += RaTar.Name + '銆�';
+            } else if (
+                RaTar.demo_purpose2__c == '绱㈣禂QIS' &&
+                RaTar.next_action__c == '鏃犲伩鏇存崲' &&
+                RaTar.QIS_number__r.ReplaceDeliveryDate__c != null
+            ) {
                 errorFlag = true;
-                message5 += RaTar.Name+'銆�';
+                message5 += RaTar.Name + '銆�';
             }
             //1822 yc 20211025 宸茶喘寰呰揣鐩殑锛屾柊鍝佸凡鏈夊彂璐ф棩涓嶈兘鍑哄簱 end
             // 20220315 ljh obpm澶囧搧鍐宠鐘舵�佺浉鍏充慨鏀� start
             // else if (!campMap.isEmpty() && campMap.containsKey(RaTar.Campaign__c) && campMap.get(RaTar.Campaign__c).IF_Approved__c){
-            //     if (String.isBlank(campMap.get(RaTar.Campaign__c).Meeting_Approved_No__c) 
+            //     if (String.isBlank(campMap.get(RaTar.Campaign__c).Meeting_Approved_No__c)
             //         || String.isBlank(campMap.get(RaTar.Campaign__c).Meeting_Approved_No__r.MeetingApprovedNo__c)) {
             //         errorFlag = true;
             //         message6 = RaTar.Name + '銆�';
             //     }
             // }
-            else if(RaTar.Campaign__c!= null &&  RaTar.Campaign__r.IF_Approved__c && RaTar.Campaign__r.Meeting_Approved_No__c == null) {
+            else if (RaTar.Campaign__c != null && RaTar.Campaign__r.IF_Approved__c && RaTar.Campaign__r.Meeting_Approved_No__c == null) {
                 errorFlag = true;
                 message6 += RaTar.Name + '銆�';
-            }
-            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)) {
+            } 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)
+            ) {
                 errorFlag = true;
                 message7 += RaTar.Name + '銆�';
             }
@@ -447,46 +613,50 @@
         }
         // add lc 20220927 SFDC-CJ48VE 澶囧搧棰勮鍑哄簱鏃ラ�昏緫璋冩暣 end
 
-        if(errorFlag){
-            if(String.isNotBlank(message0)){
+        if (errorFlag) {
+            if (String.isNotBlank(message0)) {
                 // 20230215 ljh DB202301265636 瀛︿細鍙栨秷鐢宠涔熸嫤鎴� start
                 // message += '鍗曞彿NO.'+message0.removeEnd('銆�')+'瀛︿細宸插彇娑堬紝涓嶈兘缁х画鎿嶄綔浜�';
-                message += '鍗曞彿NO.'+message0.removeEnd('銆�')+'瀛︿細宸插彇娑堟垨鑰呭彇娑堢敵璇蜂腑锛屼笉鑳界户缁搷浣滀簡';
+                message += '鍗曞彿NO.' + message0.removeEnd('銆�') + '瀛︿細宸插彇娑堟垨鑰呭彇娑堢敵璇蜂腑锛屼笉鑳界户缁搷浣滀簡';
                 // 20230215 ljh DB202301265636 瀛︿細鍙栨秷鐢宠涔熸嫤鎴� start
             }
-            if(String.isNotBlank(message1)){
-                message += '鍗曞彿NO.'+message1.removeEnd('銆�')+'瀛樺湪淇悊鏈�缁堟娴嬫棩锛屼笉鑳界户缁簡';
+            if (String.isNotBlank(message1)) {
+                message += '鍗曞彿NO.' + message1.removeEnd('銆�') + '瀛樺湪淇悊鏈�缁堟娴嬫棩锛屼笉鑳界户缁簡';
             }
-            if(String.isNotBlank(message2)){
-                message += '鍗曞彿NO.'+message2.removeEnd('銆�')+'鏈慨鐞嗗綊杩樻棩涓嶄负绌猴紝涓嶈兘鍑哄簱';     
+            if (String.isNotBlank(message2)) {
+                message += '鍗曞彿NO.' + message2.removeEnd('銆�') + '鏈慨鐞嗗綊杩樻棩涓嶄负绌猴紝涓嶈兘鍑哄簱';
             }
-            if(String.isNotBlank(message3)){
-                message += '鍗曞彿NO.'+message3.removeEnd('銆�')+'瀛樺湪RC淇悊杩旈�佹棩锛屼笉鑳界户缁簡';       
+            if (String.isNotBlank(message3)) {
+                message += '鍗曞彿NO.' + message3.removeEnd('銆�') + '瀛樺湪RC淇悊杩旈�佹棩锛屼笉鑳界户缁簡';
             }
             //1822 yc 20211025 宸茶喘寰呰揣鐩殑锛屾柊鍝佸凡鏈夊彂璐ф棩涓嶈兘鍑哄簱 start
-            if(String.isNotBlank(message4)){
-                message += '鍗曞彿NO.'+message4.removeEnd('銆�')+'宸茶喘寰呰揣鐩殑锛屾柊鍝佸凡鏈夊彂璐ф棩锛屼笉鑳界户缁簡';       
+            if (String.isNotBlank(message4)) {
+                message += '鍗曞彿NO.' + message4.removeEnd('銆�') + '宸茶喘寰呰揣鐩殑锛屾柊鍝佸凡鏈夊彂璐ф棩锛屼笉鑳界户缁簡';
             }
-            if(String.isNotBlank(message5)){
-                message += '鍗曞彿NO.'+message5.removeEnd('銆�')+'绱㈣禂QIS鐩殑锛孮IS宸叉湁鏂板搧鍙戣揣鏃ワ紝涓嶈兘缁х画浜�';       
+            if (String.isNotBlank(message5)) {
+                message += '鍗曞彿NO.' + message5.removeEnd('銆�') + '绱㈣禂QIS鐩殑锛孮IS宸叉湁鏂板搧鍙戣揣鏃ワ紝涓嶈兘缁х画浜�';
             }
             //1822 yc 20211025 宸茶喘寰呰揣鐩殑锛屾柊鍝佸凡鏈夊彂璐ф棩涓嶈兘鍑哄簱 end
-            if(String.isNotBlank(message6)){
-                message += '鍗曞彿No.'+ message6.removeEnd('銆�')+ '宸茬敵璇峰喅瑁佷絾鍐宠缂栫爜涓虹┖';
+            if (String.isNotBlank(message6)) {
+                message += '鍗曞彿No.' + message6.removeEnd('銆�') + '宸茬敵璇峰喅瑁佷絾鍐宠缂栫爜涓虹┖';
             }
             // 20220315 ljh obpm澶囧搧鍐宠鐘舵�佺浉鍏充慨鏀� add start
-            if(String.isNotBlank(message7)){
-                message += '鍗曞彿No.'+ message7.removeEnd('銆�')+ '宸茬敵璇峰喅瑁佷絾鍐宠鐘舵�佷笉绗﹀悎鏉′欢';
+            if (String.isNotBlank(message7)) {
+                message += '鍗曞彿No.' + message7.removeEnd('銆�') + '宸茬敵璇峰喅瑁佷絾鍐宠鐘舵�佷笉绗﹀悎鏉′欢';
             }
             // 20220315 ljh obpm澶囧搧鍐宠鐘舵�佺浉鍏充慨鏀� add end
 
             // add lc 20220927 SFDC-CJ48VE 澶囧搧棰勮鍑哄簱鏃ラ�昏緫璋冩暣 start
-            if(String.isNotBlank(message8)){
-                message += '鍗曞彿No.'+ message8.removeEnd('銆�')+ '鐨勫鍝侀璁″嚭璐ф棩搴旇绛変簬浠婂ぉ锛屽惁鍒欎笉鑳藉彂璐�';
+            if (String.isNotBlank(message8)) {
+                message += '鍗曞彿No.' + message8.removeEnd('銆�') + '鐨勫鍝侀璁″嚭璐ф棩搴旇绛変簬浠婂ぉ锛屽惁鍒欎笉鑳藉彂璐�';
             }
             // add lc 20220927 SFDC-CJ48VE 澶囧搧棰勮鍑哄簱鏃ラ�昏緫璋冩暣 end
 
-            ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Error,message));
+            if (String.isNotBlank(message9)) {
+                message += '鍗曞彿No.' + message9.removeEnd('銆�') + System.Label.IFTradeComplianceAlertBP;
+            }
+
+            ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Error, message));
             return null;
         }
         //20210604 ljh update SFDC-C3LBNL end
@@ -508,21 +678,60 @@
             ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Error, '鏈�夋嫨澶囧搧set锛屼笉鑳藉垱寤哄彂璐у崟'));
             return null;
         }
-        eList = [select Rental_Apply__c, Rental_Apply__r.Shippment_ng_num__c, Rental_Apply__r.Pre_inspection_ng_num__c, Rental_Apply_Equipment_Set__r.Inspection_not_finish__c, Fixture_Name_F__c, Rental_Apply_Equipment_Set__r.Fixture_Set__r.Name, Rental_Apply_Equipment_Set__r.Rental_Apply__r.Name, Rental_Apply_Equipment_Set__r.Name, Pre_inspection_time__c, StockDown__c, StockDown_time__c, Id, Name, Asset__c, Asset__r.Name, Asset__r.SerialNumber, Asset__r.Product_Serial_No__c,
-                           Asset__r.Remark__c, Asset__r.ImageAsset__c, Asset__r.ImageSerial__c, Asset__r.ImageAssetUploadedTime__c, Asset__r.ImageSerialUploadedTime__c,
-                           Loaner_CDS_Info__c, Inspection_result__c, Check_lost_Item__c, Pre_disinfection__c, Water_leacage_check__c, Inspection_result_after__c, Arrival_in_wh__c,
-                           Asset__r.Pre_Reserve_RAES_Detail__c, Asset__r.Pre_Reserve_RAES_Detail__r.After_Inspection_time__c,
-                           Rental_Apply__r.Request_approval_time__c , Add_Request_approval_time__c ,ApplyToShipmentWorkTime__c, //20220309 ljh SFDC-CC6CLJ phase5涓婄嚎璇鹃131 鎻愪氦鐢宠鍒板鍝佸嚭搴撴椂闀� 
-                           Inspection_result_after_ng__c, Inspection_result_ng__c, Lost_item_giveup__c, CDS_complete__c, Loaner_accsessary__c,Key_product__c
-                    from Rental_Apply_Equipment_Set_Detail__c where Id in :eSet for update];
+        eList = [
+            SELECT
+                Rental_Apply__c,
+                Rental_Apply__r.Shippment_ng_num__c,
+                Rental_Apply__r.Pre_inspection_ng_num__c,
+                Rental_Apply_Equipment_Set__r.Inspection_not_finish__c,
+                Fixture_Name_F__c,
+                Rental_Apply_Equipment_Set__r.Fixture_Set__r.Name,
+                Rental_Apply_Equipment_Set__r.Rental_Apply__r.Name,
+                Rental_Apply_Equipment_Set__r.Name,
+                Pre_inspection_time__c,
+                StockDown__c,
+                StockDown_time__c,
+                Id,
+                Name,
+                Asset__c,
+                Asset__r.Name,
+                Asset__r.SerialNumber,
+                Asset__r.Product_Serial_No__c,
+                Asset__r.Remark__c,
+                Asset__r.ImageAsset__c,
+                Asset__r.ImageSerial__c,
+                Asset__r.ImageAssetUploadedTime__c,
+                Asset__r.ImageSerialUploadedTime__c,
+                Loaner_CDS_Info__c,
+                Inspection_result__c,
+                Check_lost_Item__c,
+                Pre_disinfection__c,
+                Water_leacage_check__c,
+                Inspection_result_after__c,
+                Arrival_in_wh__c,
+                Asset__r.Pre_Reserve_RAES_Detail__c,
+                Asset__r.Pre_Reserve_RAES_Detail__r.After_Inspection_time__c,
+                Rental_Apply__r.Request_approval_time__c,
+                Add_Request_approval_time__c,
+                ApplyToShipmentWorkTime__c, //20220309 ljh SFDC-CC6CLJ phase5涓婄嚎璇鹃131 鎻愪氦鐢宠鍒板鍝佸嚭搴撴椂闀�
+                Inspection_result_after_ng__c,
+                Inspection_result_ng__c,
+                Lost_item_giveup__c,
+                CDS_complete__c,
+                Loaner_accsessary__c,
+                Key_product__c
+            FROM Rental_Apply_Equipment_Set_Detail__c
+            WHERE Id IN :eSet
+            FOR UPDATE
+        ];
         Boolean needSaveSet = false;
         Boolean needSaveDetail = false;
         Boolean needDeliverySlip = false;
         //wangweipeng   鏄惁鏄噸鐐逛骇鍝�       2021/08/30        start
-        Map<String,boolean> keyPointProduct = new Map<String,boolean>();
+        Map<String, boolean> keyPointProduct = new Map<String, boolean>();
         //wangweipeng   鏄惁鏄噸鐐逛骇鍝�       2021/08/30        end
         Set<Id> astForLock = new Set<Id>();
-        Map<Datetime, List<Rental_Apply_Equipment_Set_Detail__c>> approvalMap = new Map<Datetime, List<Rental_Apply_Equipment_Set_Detail__c>>();// 20220315 ljh SFDC-CC6CLJ phase5涓婄嚎璇鹃131 鎻愪氦鐢宠鍒板鍝佸嚭搴撴椂闀�
+        Map<Datetime, List<Rental_Apply_Equipment_Set_Detail__c>> approvalMap = new Map<Datetime, List<Rental_Apply_Equipment_Set_Detail__c>>(); // 20220315 ljh SFDC-CC6CLJ phase5涓婄嚎璇鹃131 鎻愪氦鐢宠鍒板鍝佸嚭搴撴椂闀�
         for (Rental_Apply_Equipment_Set_Detail__c esd : eList) {
             if (esd.Inspection_result__c <> null && esd.StockDown__c == false) {
                 ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Error, '澶囧搧set鏈笅鏋讹紝涓嶈兘濉啓鍙戣揣鍓嶆鏌ョ粨鏋�'));
@@ -530,33 +739,37 @@
             }
             //wangweipeng   鏄惁鏄噸鐐逛骇鍝�       2021/08/30        start
             //璁板綍褰撳墠鍊熷嚭澶囧搧鐨勯厤濂楁槑缁嗛噷闈㈡槸鍚︽椂閲嶇偣浜у搧锛屾敞鎰忥細鍙鏈変竴涓槸閲嶇偣浜у搧锛岄偅涔堟鍊熷嚭澶囧搧灏辨槸閲嶇偣浜у搧
-            if(esd.Key_product__c != null && esd.Key_product__c != ''){
-                if(!(keyPointProduct.containsKey(esd.Rental_Apply__c)) || keyPointProduct.get(esd.Rental_Apply__c) == false){
-                    keyPointProduct.put(esd.Rental_Apply__c,true);
+            if (esd.Key_product__c != null && esd.Key_product__c != '') {
+                if (!(keyPointProduct.containsKey(esd.Rental_Apply__c)) || keyPointProduct.get(esd.Rental_Apply__c) == false) {
+                    keyPointProduct.put(esd.Rental_Apply__c, true);
                 }
-            }else{
-                if(keyPointProduct.get(esd.Rental_Apply__c) == null){
-                    keyPointProduct.put(esd.Rental_Apply__c,false);
+            } else {
+                if (keyPointProduct.get(esd.Rental_Apply__c) == null) {
+                    keyPointProduct.put(esd.Rental_Apply__c, false);
                 }
             }
             //wangweipeng   鏄惁鏄噸鐐逛骇鍝�       2021/08/30        end
             astForLock.add(esd.Asset__c);
             // 20220315 ljh SFDC-CC6CLJ phase5涓婄嚎璇鹃131 鎻愪氦鐢宠鍒板鍝佸嚭搴撴椂闀� start
-            Datetime keyDt = esd.Add_Request_approval_time__c != null?esd.Add_Request_approval_time__c:esd.Rental_Apply__r.Request_approval_time__c;
+            Datetime keyDt = esd.Add_Request_approval_time__c != null
+                ? esd.Add_Request_approval_time__c
+                : esd.Rental_Apply__r.Request_approval_time__c;
             List<Rental_Apply_Equipment_Set_Detail__c> tempRaesdL;
-            if(approvalMap.containsKey(keyDt)){
+            if (approvalMap.containsKey(keyDt)) {
                 tempRaesdL = approvalMap.get(keyDt);
-            }else{
+            } else {
                 tempRaesdL = new List<Rental_Apply_Equipment_Set_Detail__c>();
             }
-            tempRaesdL.add(esd);                        
-            approvalMap.put(keyDt,tempRaesdL);
+            tempRaesdL.add(esd);
+            approvalMap.put(keyDt, tempRaesdL);
             // 20220315 ljh SFDC-CC6CLJ phase5涓婄嚎璇鹃131 鎻愪氦鐢宠鍒板鍝佸嚭搴撴椂闀� end
         }
-        List<Asset> astLock = [select Id
-                 from Asset
-                where id in :astForLock
-                  for update];
+        List<Asset> astLock = [
+            SELECT Id
+            FROM Asset
+            WHERE id IN :astForLock
+            FOR UPDATE
+        ];
         if (Step_status == '鏄庣粏') {
             needDeliverySlip = true;
             //if (slip.Id == null) {
@@ -564,18 +777,37 @@
             //    slip.Shippment_loaner_time__c = Datetime.now();
             //}
             if (slip.Id != null) {
-                slip = [select Combine_Pack__c, Name, Id, DeliveryCompany_SlipNo__c,DeliveryType__c,Distributor_method__c,DeliveryCompany__c,Wh_Staff__c 
-                        from FixtureDeliverySlip__c 
-                        where Id =:slip.Id for update];
+                slip = [
+                    SELECT
+                        Combine_Pack__c,
+                        Name,
+                        Id,
+                        DeliveryCompany_SlipNo__c,
+                        DeliveryType__c,
+                        Distributor_method__c,
+                        DeliveryCompany__c,
+                        Wh_Staff__c
+                    FROM FixtureDeliverySlip__c
+                    WHERE Id = :slip.Id
+                    FOR UPDATE
+                ];
             }
             slip.Shippment_loaner_time__c = Datetime.now();
             needSaveDetail = true;
         }
-        List<Rental_Apply__c> raList = [select Id, DeliverySlip__c, Campaign__c 
-                                        , Campaign__r.IF_Approved__c         // 20220315 ljh obpm澶囧搧鍐宠鐘舵�佺浉鍏充慨鏀�
-                                        , Campaign__r.Meeting_Approved_No__r.Name // 20220315 ljh obpm澶囧搧鍐宠鐘舵�佺浉鍏充慨鏀�
-                                        , Campaign__r.Approved_Status__c     // 20220315 ljh obpm澶囧搧鍐宠鐘舵�佺浉鍏充慨鏀�
-                                        from Rental_Apply__c where Id in :raSet];
+        List<Rental_Apply__c> raList = [
+            SELECT
+                Id,
+                DeliverySlip__c,
+                Campaign__c,
+                Campaign__r.IF_Approved__c, // 20220315 ljh obpm澶囧搧鍐宠鐘舵�佺浉鍏充慨鏀�
+                Campaign__r.Meeting_Approved_No__r.Name, // 20220315 ljh obpm澶囧搧鍐宠鐘舵�佺浉鍏充慨鏀�
+                Campaign__r.Approved_Status__c, // 20220315 ljh obpm澶囧搧鍐宠鐘舵�佺浉鍏充慨鏀�
+                Hospital__r.TradeComplianceStatus__c, //璐告槗鍚堣 you
+                Outbound_TradeStatus__c //璐告槗鍚堣 you
+            FROM Rental_Apply__c
+            WHERE Id IN :raSet
+        ];
         Savepoint sp = Database.setSavepoint();
         try {
             //if (needSaveSet) ControllerUtil.upRAdEquipmentSet(es);
@@ -583,34 +815,35 @@
                 FixtureUtil.withoutUpsertObjects(new List<FixtureDeliverySlip__c>{ slip });
                 //ControllerUtil.updRADeliverySlipDetail(slip);
                 // 20220315 ljh SFDC-CC6CLJ phase5涓婄嚎璇鹃131 鎻愪氦鐢宠鍒板鍝佸嚭搴撴椂闀� start
-                map<String,Decimal> ApplyToShipmentMap = new map<String,Decimal>();
-                if(approvalMap.size() > 0 ){
+                map<String, Decimal> ApplyToShipmentMap = new Map<String, Decimal>();
+                if (approvalMap.size() > 0) {
                     // dtList[0] 绗竴涓氨鏄渶灏忔椂闂�
                     List<Datetime> dtList = new List<Datetime>(approvalMap.keySet());
-                    Date startDateSOQL  = date.newinstance(dtList[0].year(), dtList[0].month(), dtList[0].day());
-                    List<OlympusCalendar__c> ocList = [SELECT Id, Date__c,IsWorkDay__c 
-                                     FROM OlympusCalendar__c
-                                    WHERE Date__c >= :startDateSOQL
-                                      AND Date__c <= :Date.today()
-                                    ORDER BY Date__c ASC];
-                    Map<Date,String> ocMap = new Map<Date,String>();
-                    for(OlympusCalendar__c oc:ocList){
+                    Date startDateSOQL = date.newinstance(dtList[0].year(), dtList[0].month(), dtList[0].day());
+                    List<OlympusCalendar__c> ocList = [
+                        SELECT Id, Date__c, IsWorkDay__c
+                        FROM OlympusCalendar__c
+                        WHERE Date__c >= :startDateSOQL AND Date__c <= :Date.today()
+                        ORDER BY Date__c ASC
+                    ];
+                    Map<Date, String> ocMap = new Map<Date, String>();
+                    for (OlympusCalendar__c oc : ocList) {
                         String IsWorkDay = oc.IsWorkDay__c.format();
-                        ocMap.put(oc.Date__c,IsWorkDay);
+                        ocMap.put(oc.Date__c, IsWorkDay);
                     }
-                    for(Datetime dt:dtList){
+                    for (Datetime dt : dtList) {
                         Boolean startFlag = false;
                         Boolean endFlag = false;
                         Datetime startTime = dt;
-                        Date startDate = Date.newInstance(startTime.year(),startTime.month(),startTime.day());
+                        Date startDate = Date.newInstance(startTime.year(), startTime.month(), startTime.day());
                         Datetime endTime = Datetime.now();
                         Date endDate = Date.today();
-                        // 瀹℃壒鏃堕棿鏄潪濂ユ灄宸存柉宸ヤ綔鏃�  
+                        // 瀹℃壒鏃堕棿鏄潪濂ユ灄宸存柉宸ヤ綔鏃�
                         // if(ocList[0].IsWorkDay__c == 0){
-                        if(ocMap.get(startDate) == '0'){
-                            for(OlympusCalendar__c oc:ocList){
-                                if(startDate < oc.Date__c && oc.IsWorkDay__c == 1){
-                                    startTime = Datetime.newInstance(oc.Date__c.year(),oc.Date__c.month(),oc.Date__c.day(),0,0,0);
+                        if (ocMap.get(startDate) == '0') {
+                            for (OlympusCalendar__c oc : ocList) {
+                                if (startDate < oc.Date__c && oc.IsWorkDay__c == 1) {
+                                    startTime = Datetime.newInstance(oc.Date__c.year(), oc.Date__c.month(), oc.Date__c.day(), 0, 0, 0);
                                     startDate = oc.Date__c;
                                     startFlag = true;
                                     break;
@@ -618,10 +851,17 @@
                             }
                         }
                         // 鍙戣揣鏃堕棿鏄潪濂ユ灄宸存柉宸ヤ綔鏃�
-                        if(ocList[ocList.size() - 1].IsWorkDay__c == 0){
-                            for(Integer i = ocList.size() - 1; i >= 0;i--){
-                                if(ocList[i].IsWorkDay__c == 1){
-                                    endTime = Datetime.newInstance(ocList[i].Date__c.addDays(1).year(),ocList[i].Date__c.addDays(1).month(),ocList[i].Date__c.addDays(1).day(),0,0,0);
+                        if (ocList[ocList.size() - 1].IsWorkDay__c == 0) {
+                            for (Integer i = ocList.size() - 1; i >= 0; i--) {
+                                if (ocList[i].IsWorkDay__c == 1) {
+                                    endTime = Datetime.newInstance(
+                                        ocList[i].Date__c.addDays(1).year(),
+                                        ocList[i].Date__c.addDays(1).month(),
+                                        ocList[i].Date__c.addDays(1).day(),
+                                        0,
+                                        0,
+                                        0
+                                    );
                                     endDate = ocList[i].Date__c.addDays(1);
                                     endFlag = true;
                                     break;
@@ -629,26 +869,26 @@
                             }
                         }
                         Decimal timeDifLast;
-                        if(ocList[0].IsWorkDay__c == 0 && ocList[ocList.size() - 1].IsWorkDay__c == 0 && !startFlag && !endFlag){
+                        if (ocList[0].IsWorkDay__c == 0 && ocList[ocList.size() - 1].IsWorkDay__c == 0 && !startFlag && !endFlag) {
                             timeDifLast = 0;
-                        }else{
+                        } else {
                             Long startL = startTime.getTime();
                             Long tendL = endTime.getTime();
-                            Long timeDif = tendL - startL;                            
-                            Decimal time11 = timeDif*1.00;
-                            Decimal time12 = 24*3600*1000*1.00;
-                            timeDifLast = time11/time12;                            
+                            Long timeDif = tendL - startL;
+                            Decimal time11 = timeDif * 1.00;
+                            Decimal time12 = 24 * 3600 * 1000 * 1.00;
+                            timeDifLast = time11 / time12;
                             Integer tempWeek = 0;
-                            for(OlympusCalendar__c oc:ocList){
-                                if(oc.IsWorkDay__c == 0 && startDate < oc.Date__c && oc.Date__c < endDate){
+                            for (OlympusCalendar__c oc : ocList) {
+                                if (oc.IsWorkDay__c == 0 && startDate < oc.Date__c && oc.Date__c < endDate) {
                                     tempWeek++;
                                 }
                             }
                             timeDifLast = timeDifLast - tempWeek;
                         }
                         // dtestLast 鍥涜垗浜斿叆 淇濈暀1浣嶅皬鏁�
-                        for(Rental_Apply_Equipment_Set_Detail__c raesd00:approvalMap.get(dt)){
-                            ApplyToShipmentMap.put(raesd00.Id,timeDifLast.setScale(1));
+                        for (Rental_Apply_Equipment_Set_Detail__c raesd00 : approvalMap.get(dt)) {
+                            ApplyToShipmentMap.put(raesd00.Id, timeDifLast.setScale(1));
                         }
                     }
                 }
@@ -656,7 +896,7 @@
                 for (Rental_Apply_Equipment_Set_Detail__c esd : eList) {
                     esd.DeliverySlip__c = slip.Id;
                     // 20220315 ljh SFDC-CC6CLJ phase5涓婄嚎璇鹃131 鎻愪氦鐢宠鍒板鍝佸嚭搴撴椂闀� start
-                    if(ApplyToShipmentMap.containsKey(esd.Id)){
+                    if (ApplyToShipmentMap.containsKey(esd.Id)) {
                         esd.ApplyToShipmentWorkTime__c = ApplyToShipmentMap.get(esd.Id);
                     }
                     // 20220315 ljh SFDC-CC6CLJ phase5涓婄嚎璇鹃131 鎻愪氦鐢宠鍒板鍝佸嚭搴撴椂闀� end
@@ -667,14 +907,14 @@
                     //wangweipeng   鏄惁鏄噸鐐逛骇鍝�       2021/08/30        start
                     ra.Is_keyPoint_Product__c = keyPointProduct.get(ra.Id);
                     //wangweipeng   鏄惁鏄噸鐐逛骇鍝�       2021/08/30        start
-
+                    ra.Outbound_TradeStatus__c = ra.Hospital__r.TradeComplianceStatus__c; //璐告槗鍚堣 you
                     // 20220315 ljh obpm澶囧搧鍐宠鐘舵�佺浉鍏充慨鏀� update start
                     //20220217 sx add 澶囧搧鍊熷嚭鐢宠-鍐宠鎺у埗 No.4 鍑哄簱鎴愬姛鏃讹紝鎶婃鏃剁偣鐨勫喅瑁佺紪鍙峰拰鍐宠鐘舵�佸啓鍒板喅瑁佺紪鍙凤紙鍑哄簱锛夊拰鍐宠鐘舵�侊紙鍑哄簱锛変笂
                     // if (!campMap.isEmpty() && campMap.containsKey(ra.Campaign__c) && campMap.get(ra.Campaign__c).IF_Approved__c){
                     //     ra.ApprovedNo_Delivery__c = campMap.get(ra.Campaign__c).Meeting_Approved_No__r.MeetingApprovedNo__c;
                     //     ra.Approved_State_Delivery__c = campMap.get(ra.Campaign__c).Meeting_Approved_No__r.ProcessState__c;
                     // }
-                    if (ra.Campaign__c != null&& ra.Campaign__r.IF_Approved__c && ra.Campaign__r.Meeting_Approved_No__r.Name != null){
+                    if (ra.Campaign__c != null && ra.Campaign__r.IF_Approved__c && ra.Campaign__r.Meeting_Approved_No__r.Name != null) {
                         ra.ApprovedNo_Delivery__c = ra.Campaign__r.Meeting_Approved_No__r.Name;
                         ra.Approved_State_Delivery__c = ra.Campaign__r.Approved_Status__c;
                     }
@@ -683,6 +923,9 @@
             }
             //if (needSaveDetail) ControllerUtil.updRAEquipmentSetDetail(eList);
             if (needSaveDetail) {
+                // 澶囧搧浼樺寲杩藉姞 20230518 lc Start
+                RentalApplyEquipmentSetDetailHandler.skipUpdateAgain = true;
+                // 澶囧搧浼樺寲杩藉姞 20230518 lc End
                 FixtureUtil.withoutUpsertObjects(eList);
                 FixtureUtil.withoutUpsertObjects(raList);
             }
@@ -718,7 +961,10 @@
             this.isChecked = checked;
             this.hasSended = false;
 
-            if (rec.Asset__r.Pre_Reserve_RAES_Detail__c != null && rec.Asset__r.Pre_Reserve_RAES_Detail__r.After_Inspection_time__c != null) {
+            if (
+                rec.Asset__r.Pre_Reserve_RAES_Detail__c != null &&
+                rec.Asset__r.Pre_Reserve_RAES_Detail__r.After_Inspection_time__c != null
+            ) {
                 this.quickCheck = Datetime.now() < rec.Asset__r.Pre_Reserve_RAES_Detail__r.After_Inspection_time__c + 30 ? true : false;
             } else {
                 this.quickCheck = false;
@@ -736,4 +982,4 @@
             this(rec, false);
         }
     }
-}
\ No newline at end of file
+}

--
Gitblit v1.9.1