From 17ef9dd2ae1d3de83cfa769d02ebe066ffb238dd Mon Sep 17 00:00:00 2001
From: 黄千龙 <huangqianlong@prec-tech.com>
Date: 星期二, 28 三月 2023 14:54:29 +0800
Subject: [PATCH] 上限合同补充

---
 force-app/main/default/classes/NFM103Controller.cls |  300 +++++++++++++++++++++++++++++++++++++++++++++++++++++------
 1 files changed, 269 insertions(+), 31 deletions(-)

diff --git a/force-app/main/default/classes/NFM103Controller.cls b/force-app/main/default/classes/NFM103Controller.cls
index c8e163b..6d8cc69 100644
--- a/force-app/main/default/classes/NFM103Controller.cls
+++ b/force-app/main/default/classes/NFM103Controller.cls
@@ -11,7 +11,7 @@
     public static string ResponseBody;
     public static String SAPRepairNo;
     public class NFM103Response {
-        public RepairRequest_element RepairRequest;
+        // public RepairRequest_element RepairRequest;
         public response[] response;
     }
     public class response {
@@ -103,12 +103,38 @@
         public String ReturnType;//杩斿搧鏂瑰紡
         public String UpdateStatus;//鐩磋繑淇敼鏍囪瘑
         //add by wangweipeng  2021/07/14   end
+        //add pi 鍔犲瘑 sushanhu 20220222 start
+        public String DataId;//AWS瀛樺偍鍑瘉
+        //add pi 鍔犲瘑 sushanhu 20220222 end
+
+        //20220330 lt WLIG-CCT9UG 銆愬鎵樸�戝叧浜庡競鍦哄骞翠繚璁℃彁閲戣皟鏁�  start
+        public String QuotationDate;
+        //20220330 lt WLIG-CCT9UG 銆愬鎵樸�戝叧浜庡競鍦哄骞翠繚璁℃彁閲戣皟鏁�  end
+        //XLIU-CGAD3Z 銆愬鎵樸�戝鍝佺浉鍏冲瓧娈典紶杈撹嚦SAP LY 20220714 start
+        public String BollowDate;          //澶囧搧涓績鍑哄簱鏃�
+        public String IfRentalApply;      //鏄惁鐢宠澶囧搧
+        public String OfferRental;         //鏄惁鎻愪緵澶囧搧(NEW)
+        //XLIU-CGAD3Z 銆愬鎵樸�戝鍝佺浉鍏冲瓧娈典紶杈撹嚦SAP LY 20220714 end
+        //URF闄愭鍚堝悓2鏈� xxf 20220811 start
+        public String Series;
+        //URF闄愭鍚堝悓2鏈� xxf 20220811 end
+
+        //鍐嶆敞鍐屽垎鏋� 闇�姹� 鏂板瀛楁 20220811
+        public String Reanalysis;
+        //DB202211397391鈥滅淮淇濋鍒も�濆拰鈥滅淮淇濋」鐩�濇柊澧炴柟妗� fy start
+        public String MAINITIAL;
+        //DB202211397391鈥滅淮淇濋鍒も�濆拰鈥滅淮淇濋」鐩�濇柊澧炴柟妗� fy end
+        // 涓婇檺鍚堝悓 by20230104 start
+        public String ZFLAG_SX; //鍒拌揪涓婇檺
+        public String ZFLAG_CGSX; //瓒呰繃鍚堝悓涓婇檺
+        // 涓婇檺鍚堝悓 by20230104 end
     }
     ////NFM103淇敼Rest end
 
     // Repair__c銇甀d
     public static Set<Id> NFM103_Ids = new Set<Id>();
     public static String debug_msg = '';
+    public static String rprId = '' ;   //2022-07-14  zyh  add
 
     // on Repair__c (after insert, after update)
     // 鏂拌淇悊銆乷r 鍙椾粯鐢ㄣ伄闋呯洰銈掔法闆嗐仐銇熸檪锛圧epairOrderStatusCode__c = A95鏅傘伄銇� 鍙椾粯鐢ㄣ伄闋呯洰銈掔法闆� 銇с亶銇俱仚锛�
@@ -165,6 +191,28 @@
                             NFM103Controller.debug_msg += 'NFM103_callout_update_' + rpr.Name;
                         }
                     }
+                    //XLIU-CGAD3Z 銆愬鎵樸�戝鍝佺浉鍏冲瓧娈典紶杈撹嚦SAP LY 20220714 start
+                    if (rpr.SAPRepairNo__c !=null && (oldMap.get(rpr.Id).Bollow_Date__c != rpr.Bollow_Date__c ||oldMap.get(rpr.Id).if_Rental_Apply__c !=rpr.if_Rental_Apply__c || oldMap.get(rpr.Id).Offer_Rental_New__c != rpr.Offer_Rental_New__c)){
+                        if (NFM103Controller.NFM103_Ids.contains(rpr.Id) == false) {
+                            NFM103_Ids.add(rpr.Id);
+                            rprIds.add(rpr.Id);
+                            updMap.put(rpr.Id, new Repair__c(Id = rpr.Id,Address_type__c = 'A'));
+                            NFM103Controller.debug_msg += 'NFM103_callout_update2_' + rpr.Name;
+                        }
+                    }
+                    //XLIU-CGAD3Z 銆愬鎵樸�戝鍝佺浉鍏冲瓧娈典紶杈撹嚦SAP LY 20220714 end
+                    
+                    // 鍒拌揪涓婇檺   淇悊鍗曚慨鏀规椂  涓婇檺鍚堝悓 by20230104 start
+                    if ((rpr.ZFLAG_SX__c == true && oldMap.get(rpr.Id).ZFLAG_SX__c !=rpr.ZFLAG_SX__c && rpr.Agreed_Date__c!=null) ||
+                        (rpr.ZFLAG_SX__c == false && oldMap.get(rpr.Id).ZFLAG_SX__c !=rpr.ZFLAG_SX__c && rpr.Agreed_Date__c==null) ){
+                        if (NFM103Controller.NFM103_Ids.contains(rpr.Id) == false) {
+                            NFM103_Ids.add(rpr.Id);
+                            rprIds.add(rpr.Id);
+                            updMap.put(rpr.Id, new Repair__c(Id = rpr.Id,Address_type__c = 'X'));
+                            NFM103Controller.debug_msg += 'NFM103_callout_update3_' + rpr.Name;
+                        }
+                    }
+                    // 鍒拌揪涓婇檺   淇悊鍗曚慨鏀规椂  涓婇檺鍚堝悓 by20230104 end
 //                    // RepairOrderStatusCode__c = A95 锛堝彇娑堜慨鐞嗗彈鐞嗭級銇檪銇犮亼 鍙椾粯鐢ㄣ伄闋呯洰銈掔法闆嗐仐銇熸檪銆佸啀搴� SAP 銇�佷俊
 //                    // TODO SAP鍋� 鍚屻仒鐣彿銇啀閫併伅銇с亶銈嬨亱锛熴�佷娇銇c仸銇亜銇嬨倐锛侊紒
 //                    else if (NFM103Controller.NFM103_Ids.contains(rpr.Id) == false && rpr.RepairOrderStatusCode__c == 'A95') {
@@ -195,7 +243,18 @@
             insert iflog;
             iflog = [Select Id, Name from BatchIF_Log__c where Id = :iflog.Id];
             System.debug(Logginglevel.DEBUG, 'NFM103_' + iflog.Name + ' start');                  // callout 銇腑 end 銇甽og銈掑嚭銇椼伨銇�
-            NFM103Controller.callout(iflog.Id, rprIds);
+            // 20220902 ljh XLIU-CHSD8G update start
+            // NFM103Controller.callout(iflog.Id, rprIds);
+            String uid = UserInfo.getUserId();
+            String BUid = System.Label.Batch_User_Id;
+            String OLYid = System.Label.OlympusSystem_ID;
+            System.debug('zheli');
+            if (uid.substring(0,15) == BUid.substring(0,15) || uid.substring(0,15) == OLYid.substring(0,15)) {
+                NFM103Controller.calloutNotfuture(iflog.Id, rprIds);
+            }else{
+                NFM103Controller.callout(iflog.Id, rprIds);
+            }
+            // 20220902 ljh XLIU-CHSD8G update end
         }
         System.debug('-----NFM103Trigger end');
     }
@@ -208,6 +267,10 @@
      */
     @future (callout = true)
     public static void callout(String iflog_Id, List<Id> repairIds) {
+       calloutNotfuture(iflog_Id, repairIds);
+    }
+    //20220902 ljh 鏂板锛堝鍒讹級鏂规硶  XLIU-CHSD8G 
+    public static void calloutNotfuture(String iflog_Id, List<Id> repairIds) {
 
         if (repairIds == null || repairIds.size() == 0) {
             return;
@@ -283,7 +346,7 @@
             List<Repair__c> recptList = [select
                                          Id, Name, Workshop__c, SalesOfficeCode__c,
                                          Repair_Detail__c, RepairSource__c, On_site_repair__c, PaperRepairRequestNo__c,
-                                         Failure_Occurrence_Date__c,Failure_Occurrence_Date2__c, On_Site_Repair_Order_Date__c, Send_To_RC_Date__c,
+                                         Failure_Occurrence_Date__c, On_Site_Repair_Order_Date__c, Send_To_RC_Date__c,
                                          Hospital__r.Management_Code__c, Account__r.Management_Code__c, Dealer__r.Management_Code__c,
                                          Incharge_Staff__r.alias, Incharge_Staff_Email__c, Incharge_Staff_Contact__c, Incharge_Staff_Contact__r.Name, CreatedBy.Alias, CreatedBy.Email,
                                          Delivered_Product__r.Product2.Asset_Model_No__c, Delivered_Product__r.SerialNumber, Delivered_Product__r.LastSFDCRepairNo__c,
@@ -327,7 +390,36 @@
                                          ,Returns_Product_way__c    //杩斿搧鏂瑰紡
                                          ,FSE_ApplyForRepair_time__c    //鐢宠淇悊鏃堕棿
                                          //add by wangweipeng  2021/07/14   start
-                                         
+                                         ,AWS_Data_Id__c //add by sushanhu AWSDateID for PIPL
+                                         //20220330 lt WLIG-CCT9UG 銆愬鎵樸�戝叧浜庡競鍦哄骞翠繚璁℃彁閲戣皟鏁�  start
+                                         ,Delivered_Product__r.Backorder__r.Opportunity__r.SAP_Send_OK_Date__c
+                                         //20220330 lt WLIG-CCT9UG 銆愬鎵樸�戝叧浜庡競鍦哄骞翠繚璁℃彁閲戣皟鏁�  end
+                                         //XLIU-CEX8A6 涓枃鏍囩瀵煎叆-SFDC浼犺緭鍨嬪彿淇敼锛堜紭鍏堝搴旓級 20220602 LY Start
+                                         ,Delivered_Product__r.Product2.Chinese_Labels__c
+                                         //XLIU-CEX8A6 涓枃鏍囩瀵煎叆-SFDC浼犺緭鍨嬪彿淇敼锛堜紭鍏堝搴旓級 20220602 LY End
+                                         //XLIU-CGAD3Z 銆愬鎵樸�戝鍝佺浉鍏冲瓧娈典紶杈撹嚦SAP LY 20220714 start
+                                         ,Bollow_Date__c       //澶囧搧涓績鍑哄簱鏃�
+                                         ,if_Rental_Apply__c   //鏄惁鐢宠澶囧搧
+                                         ,Offer_Rental_New__c  //鏄惁鎻愪緵澶囧搧(NEW)
+                                         //XLIU-CGAD3Z 銆愬鎵樸�戝鍝佺浉鍏冲瓧娈典紶杈撹嚦SAP LY 20220714 end
+                                         //URF闄愭鍚堝悓2鏈� xxf 20220811 start
+                                         ,Delivered_Product__r.Product2.ProductURF__c
+                                         ,Delivered_Product__r.Product2.ProductURF__r.URFLimitSerial__c
+                                         ,URF_Reapir__c
+                                         ,Maintenance_Contract__r.URF_Contract__c
+                                         //URF闄愭鍚堝悓2鏈� xxf 20220811 end
+                                         //DB202211397391鈥滅淮淇濋鍒も�濆拰鈥滅淮淇濋」鐩�濇柊澧炴柟妗� fy start
+                                         ,MAINITIAL__c
+                                         //DB202211397391鈥滅淮淇濋鍒も�濆拰鈥滅淮淇濋」鐩�濇柊澧炴柟妗� fy end
+                                         // 涓婇檺鍚堝悓 by20230104 start
+                                         ,Maintenance_Contract__r.Limit_Price_Amount__c
+                                         ,Maintenance_Contract__r.Sum_repair_price_new__c
+                                         ,Repair_Quotation_Id__r.Usage_Ratio_Price__c
+                                         ,Maintenance_Contract__r.Remaining_Amount__c
+                                         ,Maintenance_Contract__r.Limit_Price__c
+                                         ,ZFLAG_CGSX__c
+                                         ,ZFLAG_SX__c
+                                         // 涓婇檺鍚堝悓 by20230104 end
                                          from Repair__c where Id IN :repairIds];          // 鍓婇櫎銉囥兗銈裤倰妞滅储銇椼仾銇勩伅銇氥�丄ll ROWS 銇勩倝銇亜銇仛
             System.debug(Logginglevel.DEBUG, 'NFM103_ recptList.size()=' + recptList.size());
 
@@ -349,9 +441,17 @@
                 element.DepartmentNo              = rpr.Account__r.Management_Code__c;
                 element.SAPAgentNo                = rpr.Dealer__r.Management_Code__c;
                 element.RepairOTCode              = rpr.Delivered_Product__r.Product2.ProductCode;
+                
                 //LJPH-C7Z8AP LY Start
-                element.RepairModel               = rpr.Delivered_Product__r.Product2.Asset_Model_No__c;
-                // LJPH-C9SB9C LHJ 鐗规畩瀵瑰簲 Start
+                //element.RepairModel               = rpr.Delivered_Product__r.Product2.Asset_Model_No__c;
+                //LJPH-C9SB9C LHJ 鐗规畩瀵瑰簲 Start
+                //XLIU-CEX8A6 涓枃鏍囩瀵煎叆-SFDC浼犺緭鍨嬪彿淇敼锛堜紭鍏堝搴旓級 20220602 LY Start
+                if (String.isBlank(rpr.Delivered_Product__r.Product2.Chinese_Labels__c)) {
+                    element.RepairModel               = rpr.Delivered_Product__r.Product2.Asset_Model_No__c;
+                } else {
+                    element.RepairModel               = rpr.Delivered_Product__r.Product2.Chinese_Labels__c;
+                }
+                //XLIU-CEX8A6 涓枃鏍囩瀵煎叆-SFDC浼犺緭鍨嬪彿淇敼锛堜紭鍏堝搴旓級 20220602 LY End
                 if (element.RepairModel == 'G400') {
                     element.RepairModel = '777000';
                 } else if (element.RepairModel == 'EU-ME2(KEYBOARD)') {
@@ -380,6 +480,11 @@
                 element.FSEReceiveDate            = NFMUtil.formatDate2Str(rpr.On_Site_Repair_Order_Date__c);   // TODO 蹇呴爤銇с伅銇亜銇戙仼銆佷慨鐞嗗彈浠樺緦鍏ュ姏銇椼仧銈夈仼銇嗐倓銇c仸SAP銇�併倠锛�
                 element.FSEDeliverDate            = NFMUtil.formatDate2Str(rpr.Send_To_RC_Date__c);             // TODO 蹇呴爤銇с伅銇亜銇戙仼銆佷慨鐞嗗彈浠樺緦鍏ュ姏銇椼仧銈夈仼銇嗐倓銇c仸SAP銇�併倠锛�
                 element.TradeType                 = NFMUtil.getMapValue(transferMap, 'Trade__c', rpr.Delivered_Product__r.Backorder__r.Opportunity__r.Trade__c, iflog);
+
+                //20220330 lt WLIG-CCT9UG 銆愬鎵樸�戝叧浜庡競鍦哄骞翠繚璁℃彁閲戣皟鏁�  start
+                element.QuotationDate = rpr.Delivered_Product__r.SerMarGuranteeType__c != '甯傚満澶氬勾淇濅慨'  ? '' : NFMUtil.formatDateTime2StrSprit2(rpr.Delivered_Product__r.Backorder__r.Opportunity__r.SAP_Send_OK_Date__c).replaceAll('/', '');
+                //20220330 lt WLIG-CCT9UG 銆愬鎵樸�戝叧浜庡競鍦哄骞翠繚璁℃彁閲戣皟鏁�  end
+
                 // 澶氬勾淇濅慨 LHJ Start
                 element.RepairCostType            = rpr.Delivered_Product__r.SerMarGuranteeType__c != '甯傚満澶氬勾淇濅慨'  ? '' : rpr.RepairCostType__c;
                 element.RepairTypeQIS             = rpr.RepairType_QIS__c;
@@ -399,6 +504,10 @@
                 element.RecordPersonEmail         = rpr.CreatedBy.Email;
                 element.RepairContractObject      = '';
                 element.RepairContractNumber      = '';
+                // 涓婇檺鍚堝悓 by20230201 LY start
+                element.ZFLAG_SX = '';
+                element.ZFLAG_CGSX = '';
+                // 涓婇檺鍚堝悓 by20230201 LY end
                 /*// Gzw 20201216 NFM103浼燬AP鐨勬椂鍊欙紝闇�瑕佷紶FSE淇悊鐢宠鏃剁殑缁翠慨鍚堝悓淇℃伅 start
                 // if (rpr.Maintenance_Contract__c != null && rpr.Maintenance_Contract__r.Status__c == '濂戠磩') {
                 if (rpr.Maintenance_Contract__c != null && rpr.FSE_ApplyForRepair_Day__c != null
@@ -409,14 +518,32 @@
                 }*/
                 // 2021-01-07  mzy  update  澶氬勾淇濅慨澶栬锤NFM103鎺ュ彛淇敼  start
                 String tradeType = rpr.Delivered_Product__r.Backorder__r.Opportunity__r.Trade__c;
+
                 String NewProductGuaranteeObject = rpr.NewProductGuaranteeObject__c == null ? '':  rpr.NewProductGuaranteeObject__c;
 
 
                 // 缁翠慨鍚堝悓
                 if (rpr.Maintenance_Contract__c != null && rpr.FSE_ApplyForRepair_Day__c != null
                         && rpr.FSE_ApplyForRepair_Day__c >= rpr.Contract_Start_Date__c && rpr.FSE_ApplyForRepair_Day__c <= rpr.Contract_End_Date__c) {
-                    element.RepairContractObject  = 'X';
-                    element.RepairContractNumber  = rpr.Maintenance_Contract__r.Maintenance_Contract_No__c;
+                    // 涓婇檺鍚堝悓 by20230201 LY start 濡傛灉鏄笂闄愬悎鍚屾墠鍘诲垽鏂槸鍚︹�滆秴杩囧悎鍚屼笂闄愨�濆拰鈥滃埌杈句笂闄愨�濇爣璇�
+                    if (rpr.Maintenance_Contract__r.Limit_Price__c == true){
+                        
+                        if (rpr.ZFLAG_CGSX__c == true) { // 鈥滆秴杩囧悎鍚屼笂闄愨�濅负true锛屼笉浼犲悎鍚屼俊鎭紝ZFLAG_CGSX浼燳
+                            element.ZFLAG_CGSX = 'X';
+                        }else if (rpr.ZFLAG_SX__c == true) { //鈥滃埌杈句笂闄愨�濅负true锛屼紶鍚堝悓淇℃伅锛孼FLAG_SX浼燳
+                            element.ZFLAG_SX = 'X';
+                            element.RepairContractObject  = 'X';
+                            element.RepairContractNumber  = rpr.Maintenance_Contract__r.Maintenance_Contract_No__c;
+                        }else { //娌¤秴杩囧悎鍚屼笂闄愪篃娌¤揪鍒颁笂闄� 浼犲悎鍚屼俊鎭� ZFLAG_CGSX浼犵┖ ZFLAG_SX浼犵┖
+                            element.RepairContractObject  = 'X';
+                            element.RepairContractNumber  = rpr.Maintenance_Contract__r.Maintenance_Contract_No__c;
+                        }
+                    }else { //涓嶆槸涓婇檺鍚堝悓 浼犲悎鍚屼俊鎭�
+                        element.RepairContractObject  = 'X';
+                        element.RepairContractNumber  = rpr.Maintenance_Contract__r.Maintenance_Contract_No__c;
+                    }
+                    // 涓婇檺鍚堝悓 by20230201 LY end
+                    
                 } else {
                     if (!String.isBlank(tradeType) && tradeType.equals('澶栬部')) {
                         // 澶氬勾淇濆璐告湇鍔″骞翠繚 (鐢熸垚铏氭嫙缁翠慨鍚堝悓鍙�) 鍜� 澶氬勾淇濆璐稿競鍦哄骞翠繚 (鐢熸垚铏氭嫙缁翠慨鍚堝悓鍙�)
@@ -472,7 +599,33 @@
                  element.Postal                     = rpr.address_ZipCode__c;    //閭紪
                  element.ReturnType                 = NFMUtil.getMapValue(ReturnsProductWayMap,'Returns_Product_way__c', rpr.Returns_Product_way__c, iflog);//杩斿搧鏂瑰紡
                  element.UpdateStatus               = rpr.Address_type__c;    //鐢宠淇悊鏃堕棿
-                 //add by wangweipeng  2021/07/14   start
+                 //add by wangweipeng  2021/07/14   end
+                 //add pi 瀵嗘枃 sushanhu 20220222 start
+                 element.DataId                     =rpr.AWS_Data_Id__c;//aws瀛樺偍鍑瘉
+                 //add pi 瀵嗘枃 sushanhu 20220222 end
+                 //XLIU-CGAD3Z 銆愬鎵樸�戝鍝佺浉鍏冲瓧娈典紶杈撹嚦SAP LY 20220714 start
+                 element.BollowDate                =NFMUtil.formatDate2Str(rpr.Bollow_Date__c);       //澶囧搧涓績鍑哄簱鏃�
+                 element.IfRentalApply             =rpr.if_Rental_Apply__c ? 'X':'';   //鏄惁鐢宠澶囧搧 
+                 element.OfferRental               =rpr.Offer_Rental_New__c ? 'X':'';  //鏄惁鎻愪緵澶囧搧锛圢EW锛�
+                 //XLIU-CGAD3Z 銆愬鎵樸�戝鍝佺浉鍏冲瓧娈典紶杈撹嚦SAP LY 20220714 end
+                 //DB202211397391鈥滅淮淇濋鍒も�濆拰鈥滅淮淇濋」鐩�濇柊澧炴柟妗� fy start
+                 element.MAINITIAL               =rpr.MAINITIAL__c ? 'X':''; 
+                 //DB202211397391鈥滅淮淇濋鍒も�濆拰鈥滅淮淇濋」鐩�濇柊澧炴柟妗� fy end
+                 //URF闄愭鍚堝悓2鏈� xxf 20220811 start
+                 if (!String.isBlank(rpr.Maintenance_Contract__c)){
+                    if (rpr.Maintenance_Contract__r.URF_Contract__c == true && rpr.Delivered_Product__r.Product2.ProductURF__c !=null) {
+                        element.Series                 =rpr.Delivered_Product__r.Product2.ProductURF__r.URFLimitSerial__c =='URF-P'?'P':'V';   //闄愭鍚堝悓绯诲垪 
+                     }else{
+                        element.Series                 =null;
+                     }
+                 }
+                 
+                 //URF闄愭鍚堝悓2鏈� xxf 20220811 end
+                 rprId = rpr.Id;   //2022-07-14  zyh  add
+
+                 //鍐嶆敞鍐屽垎鏋� 闇�姹� 鏂板瀛楁 20220811 sx start
+                 element.Reanalysis                = null;
+                 //鍐嶆敞鍐屽垎鏋� 闇�姹� 鏂板瀛楁 20220811 sx end
             }
 
             if (repairRequest.GeneralData.size() > 0) {
@@ -502,14 +655,27 @@
                 // NFM103淇敼Rest end
                 execute(rowData, iflog);
             }
-            logstr += '\nStatus:' + status;
+            logstr += '\nStatus:' + status ;
             // WLIG-BXQBH6 start 淇濆瓨鍥炲鍐呭
             logstr += '\nResponse:' + responseBody;
+            System.debug('SAPRepairNo2:' + SAPRepairNo);
             if(string.isNotEmpty(SAPRepairNo)){
+                System.debug('SAPRepairNo3:' + SAPRepairNo);
                 Repair__c rpr = new repair__c(id = repairIds[0], SAPRepairNo__c = SAPRepairNo);
+                System.debug('rpr1:' + rpr);
                 update rpr;
             }
             // WLIG-BXQBH6 end 淇濆瓨鍥炲鍐呭
+            //澶囧搧鐩稿叧瀛楁浼犺緭鑷砈AP LY 20220908 start
+            List <Repair__c> rprflag = new List <Repair__c>();
+            for (Id idflag :repairIds){
+                Repair__c rprnew = new repair__c();
+                rprnew.id = idflag;
+                rprnew.Address_type__c = '';
+                rprflag.add(rprnew);
+            }
+            update rprflag;
+            //澶囧搧鐩稿叧瀛楁浼犺緭鑷砈AP LY 20220908 end
             logstr += '\nend';
         } catch (Exception ex) {
             // 銈ㄣ儵銉笺亴鐧虹敓銇椼仧鍫村悎
@@ -556,6 +722,11 @@
             logstr = iflog.Log__c;
         }
         try {
+            // if (rowData.retry_cnt__c >= 1) {
+            // }else {
+            //     List<BatchIF_Log__c> logList = [Select Id, Name, Log__c, ErrorLog__c from BatchIF_Log__c where Id = :rowData.Id];
+            //     BatchIF_Log__c log1 = logList[9];
+            // }  //2022-07-18   zyh 娉ㄩ噴
             // NFM103淇敼Rest start
             // Nfm103Sync.HTTPS_Port stub = new Nfm103Sync.HTTPS_Port();
             // stub.timeout_x = 100000; // timeout in milliseconds
@@ -571,23 +742,74 @@
             // NFM103淇敼Rest end
 
             // WLIG-BXQBH6 start
-            NFMUtil.response response =
-                NFMUtil.sendToSapStatusAndBody(rowDataStr, NFMUtil.NFM103_ENDPOINT);
+            // NFMUtil.response response =
+            //     NFMUtil.sendToSapStatusAndBody(rowDataStr, NFMUtil.NFM103_ENDPOINT);
+                //update to aws 20220222 sushanhu start for PIPL
+            PIHelper.PIIntegration NFM103AWS =PIHelper.getPIIntegrationInfo('NFM103');
+            NFMUtil.response response =     NFMUtil.sendToPiAWS(rowDataStr, NFM103AWS.newUrl,NFM103AWS.token);
+                //update to aws 20220222 sushanhu end for PIPL
             status = response.status;
-            ResponseBody = response.responseBody;
-            NFM103Response NFM103Response = new NFM103Response();
+            system.debug('AWS Response status:'+status);
+             system.System.debug('NGM103 AWS result--'+ response.ResponseBody);
+             ResponseBody = response.responseBody;
+            //update to aws 20220302 sushanhu start for PIPL
+            if ('200'.equals(status)) {
+                Map<String, Object> results = (Map<String, Object>)JSON.deserializeUntyped(ResponseBody);
+                NFM103Response NFM103Response = new NFM103Response();
             system.debug(ResponseBody);
             if (string.isNotEmpty(ResponseBody)) {
                 NFM103Response =
                     (NFM103Response) JSON.deserializeStrict(ResponseBody, NFM103Response.class);
             }
+            System.debug('NFM103Response.SAPRepairNo:' + NFM103Response.response[0].LOG.SAPRepairNo);
             if (NFM103Response.response != null &&
                     NFM103Response.response.size() > 0 &&
                     NFM103Response.response[0].LOG != null &&
                     string.isNotEmpty(NFM103Response.response[0].LOG.SAPRepairNo)) {
-                SAPRepairNo = NFM103Response.response[0].LOG.SAPRepairNo;
+                    SAPRepairNo = NFM103Response.response[0].LOG.SAPRepairNo;
 
             }
+            System.debug('SAPRepairNo1===:' + SAPRepairNo);
+            //2022-07-14  zyh  add   start
+            // if (rowData.retry_cnt__c != 2) {
+            //     String srn = NFM103Response.Response[9].LOG.SAPRepairNo;
+            // }
+            String repairNo1 = nfm103.RepairRequest.GeneralData[0].SFDCRepairNo;
+            System.debug('repairNo1--------------------1:' + repairNo1);
+
+            List<Repair__c> repairList = [SELECT Id From Repair__c Where Name = :repairNo1];
+            if(string.isNotEmpty(SAPRepairNo)){
+                System.debug('SAPRepairNo3-1:' + SAPRepairNo);
+                System.debug('rprId--------------------1:' + rprId);
+                Repair__c rpr = new repair__c(id = repairList[0].Id, SAPRepairNo__c = SAPRepairNo);
+                System.debug('rpr1-1:' + rpr);
+                update rpr;
+            }
+            //2022-07-14  zyh  add   end
+            rowData.retry_cnt__c = 0;
+            //add           wangweipeng                       2022/02/18               start
+            //濡傛灉涓簍rue锛岃瘉鏄庢槸閲嶆柊鍙戦�佺殑鎺ュ彛锛岄渶瑕佹妸鏃ュ織璁板綍涓�
+            if(needUpdateIflog){
+                logstr += 'Status:' + status;
+                logstr += '\nResponse:' + ResponseBody;
+                logstr += '\nend';
+            }
+            //add           wangweipeng                       2022/02/18               start
+            } else {
+                if (rowData.retry_cnt__c == null) rowData.retry_cnt__c = 0;
+                if (rowData.retry_cnt__c < batch_retry_max_cnt) {
+                    rowData.retry_cnt__c++;
+                    LogAutoSendSchedule.assignOneMinute();
+                }
+                if (rowData.retry_cnt__c >= batch_retry_max_cnt) {
+                    rowData.ErrorLog__c = 'status:' + ResponseBody +
+                                          '\n閿欒娆℃暟宸茬粡瓒呰繃鑷姩閫佷俊璁惧畾鐨勬渶澶ф鏁帮紝璇锋墜鍔ㄩ�佷俊';
+                }
+            }
+            // Map<String, Object> results = (Map<String, Object>)JSON.deserializeUntyped(ResponseBody);
+           
+            //update to aws 20220302 sushanhu end for PIPL
+            
             // 鍘熶唬鐮侊細
             // NFM103淇敼Rest start
             //status =
@@ -597,28 +819,44 @@
             //  WLIG-BXQBH6 end
 
             // 鍘熷墖闈炲悓鏈熴仹銇欍伄銇с�乴ogs銈掔⒑瑾嶃仚銈嬪繀瑕併亴銇亜銇с仐銈囥亞銆�
-            if (status == 'OK') {
-                rowData.retry_cnt__c = 0;
-            } else {
-                if (rowData.retry_cnt__c == null) rowData.retry_cnt__c = 0;
-                if (rowData.retry_cnt__c < batch_retry_max_cnt) {
-                    rowData.retry_cnt__c++;
-                    LogAutoSendSchedule.assignOneMinute();
-                }
-                if (rowData.retry_cnt__c >= batch_retry_max_cnt) {
-                    rowData.ErrorLog__c = 'status:' + status +
-                                          '\n閿欒娆℃暟宸茬粡瓒呰繃鑷姩閫佷俊璁惧畾鐨勬渶澶ф鏁帮紝璇锋墜鍔ㄩ�佷俊';
-                }
-            }
+            // if (status == 'OK') {
+            //     rowData.retry_cnt__c = 0;
+            //     //add           wangweipeng                       2022/02/18               start
+            //     //濡傛灉涓簍rue锛岃瘉鏄庢槸閲嶆柊鍙戦�佺殑鎺ュ彛锛岄渶瑕佹妸鏃ュ織璁板綍涓�
+            //     if(needUpdateIflog){
+            //         logstr += 'Status:' + status;
+            //         logstr += '\nResponse:' + responseBody;
+            //         logstr += '\nend';
+            //     }
+            //     //add           wangweipeng                       2022/02/18               start
+            // } else {
+            //     if (rowData.retry_cnt__c == null) rowData.retry_cnt__c = 0;
+            //     if (rowData.retry_cnt__c < batch_retry_max_cnt) {
+            //         rowData.retry_cnt__c++;
+            //         LogAutoSendSchedule.assignOneMinute();
+            //     }
+            //     if (rowData.retry_cnt__c >= batch_retry_max_cnt) {
+            //         rowData.ErrorLog__c = 'status:' + status +
+            //                               '\n閿欒娆℃暟宸茬粡瓒呰繃鑷姩閫佷俊璁惧畾鐨勬渶澶ф鏁帮紝璇锋墜鍔ㄩ�佷俊';
+            //     }
+            // }
         } catch (Exception ex) {
             // TODO IOException
             // 銈ㄣ儵銉笺亴鐧虹敓銇椼仧鍫村悎
             System.debug(Logginglevel.ERROR, 'NFM103_' + iflog.Name + ':' + ex.getMessage());
             System.debug(Logginglevel.ERROR, 'NFM103_' + iflog.Name + ':' + ex.getStackTraceString());
-            logstr += ex.getMessage();
-            iflog.ErrorLog__c += ex.getMessage() + '\n';
-            iflog.ErrorLog__c += ex.getStackTraceString() + '\n';
+            //NFM105瑙﹀彂103鎺ュ彛 20230303 LY start
+            // Callout from triggers are currently not supported.
+            System.debug('NFM201jiekou'+ex.getMessage());
+            if (!String.valueOf(ex.getMessage()).contains('Callout from triggers')) {
 
+                logstr += ex.getMessage();
+                iflog.ErrorLog__c += ex.getMessage() + '\n';
+                iflog.ErrorLog__c += ex.getStackTraceString() + '\n';
+            }
+                System.debug('鏍囪0--------------------1:' + rowData.retry_cnt__c);
+
+            //NFM105瑙﹀彂103鎺ュ彛 20230303 LY end
             //---Gaozw---add
             if (rowData.retry_cnt__c == null) rowData.retry_cnt__c = 0;
             if (rowData.retry_cnt__c < batch_retry_max_cnt) {

--
Gitblit v1.9.1