From e5e7ddf81d380f7241bcafd15d81c08a25e21b7f Mon Sep 17 00:00:00 2001
From: 张宇恒 <bxyun0@163.com>
Date: 星期四, 28 四月 2022 09:40:04 +0800
Subject: [PATCH] 4_27上线

---
 force-app/main/default/classes/NFM603Controller.cls     |  273 +++++++++++++++++++++++++++++++++++++++++++--
 force-app/main/default/classes/NFM603ControllerTest.cls |   44 ++++++-
 force-app/main/default/classes/RepairHandler.cls        |   24 +++
 force-app/main/default/classes/RepairHandlerTest.cls    |    4 
 4 files changed, 321 insertions(+), 24 deletions(-)

diff --git a/force-app/main/default/classes/NFM603Controller.cls b/force-app/main/default/classes/NFM603Controller.cls
index 2aa5dbe..d819d9c 100644
--- a/force-app/main/default/classes/NFM603Controller.cls
+++ b/force-app/main/default/classes/NFM603Controller.cls
@@ -220,6 +220,7 @@
                 RcSorcDate__c,
                 SorcAcceptDate__c,
                 SorcOgzDate__c,
+                RcOgzDate__c,
                 Returns_Product_waySAP__c,
                 DnNO__c,
                 OgzAcceptDate__c,
@@ -255,6 +256,10 @@
             // 澶囧搧鍑哄�熻褰� 鏌ユ壘澶囧搧鍑哄�熶竴瑙堟槑缁嗙殑 浜у搧鍨嬪彿
             Map < id, List < SparePartsLendingRecord >> rentalMap = getrentalMap(repairIdList);
 
+            String downSDt = '';
+            String downEDt = '';
+            String upSDt = '';
+            String upEDt = '';
 
 
             for (Repair__c repair: repairList) {
@@ -373,13 +378,44 @@
                 info.OgzAcceptDate = NFMUtil.formatDateTime2Str(repair.OgzAcceptDateTime__c);//OGZ鍙楃悊鏃ワ紙灏忕▼搴忥級
                 //update        wangweipeng         2022/02/16           end
 
-                info.SorcOgzDate = NFMUtil.formatDate2StrDateTime(repair.SorcOgzDate__c);
+                // info.SorcOgzDate = NFMUtil.formatDate2StrDateTime(repair.SorcOgzDate__c);RcOgzDate__c
+
+                //update   zhangyuheng    2022/03/07
+                info.SorcOgzDate = NFMUtil.formatDate2StrDateTime(repair.RcOgzDate__c);
 
                 info.cus_dn = repair.DnNO__c;
                 //淇悊澧炲姞OTS杩愬崟鍙峰瓧娈� thh 20220308 start
                 info.OTSRepairOrder = repair.OTSRepairOrder__c;
                 //淇悊澧炲姞OTS杩愬崟鍙峰瓧娈� thh 20220308 end
+
+                //鎶ヤ环鏃ャ�佸垵娆℃姤浠锋棩銆丷C淇悊鍝丷C鍙楃悊鏃ワ紙灏忕▼搴忥級鏃堕棿鍒ゆ柇   zyh  20220315   start
+                downSDt = DownStartDt();
+                downEDt = DownEndDt();
+                upSDt = UpStartDt();
+                upEDt = UpEndDt();
+                //瀹氫箟涓嬬彮鏃堕棿
+                if (String.valueOf(info.FirstQuotationDate) >= String.valueOf(downSDt) && String.valueOf(info.FirstQuotationDate) <= String.valueOf(downEDt)) {
+                    info.FirstQuotationDate = DownDt();//鍒濇鎶ヤ环鏃�
+                }
+                if (String.valueOf(info.RCacceptanceDate) >= String.valueOf(downSDt) && String.valueOf(info.RCacceptanceDate) <= String.valueOf(downEDt)) {
+                    info.RCacceptanceDate = DownDt();//4.淇悊鍝丷C鍙楃悊鏃�
+                }
+                if (String.valueOf(info.quotationDate) >= String.valueOf(downSDt) && String.valueOf(info.quotationDate) <= String.valueOf(downEDt)) {
+                    info.quotationDate = DownDt();//鎶ヤ环鏃�
+                }
+                //瀹氫箟涓婄彮鏃堕棿
+                if (String.valueOf(info.FirstQuotationDate) >= String.valueOf(upSDt) && String.valueOf(info.FirstQuotationDate) <= String.valueOf(upEDt)) {
+                    info.FirstQuotationDate = UpDt();//鍒濇鎶ヤ环鏃�
+                }
+                if (String.valueOf(info.RCacceptanceDate) >= String.valueOf(upSDt) && String.valueOf(info.RCacceptanceDate) <= String.valueOf(upEDt)) {
+                    info.RCacceptanceDate = UpDt();//4.淇悊鍝丷C鍙楃悊鏃�
+                }
+                if (String.valueOf(info.quotationDate) >= String.valueOf(upSDt) && String.valueOf(info.quotationDate) <= String.valueOf(upEDt)) {
+                    info.quotationDate = UpDt();//鎶ヤ环鏃�
+                }
+                //鎶ヤ环鏃ャ�佸垵娆℃姤浠锋棩銆丷C淇悊鍝丷C鍙楃悊鏃ワ紙灏忕▼搴忥級鏃堕棿鍒ゆ柇   zyh  20220315   end
                 repairs.add(info);
+                System.debug('repairs1:' + repairs);
             }
             logstr += '\nend';
             if (repairs.size() > 0) {
@@ -459,7 +495,9 @@
             logstr += ex.getMessage();
             iflog.ErrorLog__c += ex.getMessage() + '\n';
             iflog.ErrorLog__c += ex.getStackTraceString() + '\n';
-            rowDataSFDC = NFMUtil.LogAutoSend(rowDataSFDC, ex, null);
+            if(!Test.isRunningTest()){
+                rowDataSFDC = NFMUtil.LogAutoSend(rowDataSFDC, ex, null);
+            }
         }
         iflog.Log__c = logstr;
         upsert iflog;
@@ -523,7 +561,7 @@
 
     public static Set < Id > NFM603_Ids = new Set < Id > ();
     // public static Map<Id,Id> rprIdMap = new Map<Id,Id>();
-
+    
     public static void NFM603Trigger(List < Repair__c > newList, Map < Id, Repair__c > newMap, List < Repair__c > oldList, Map < Id, Repair__c > oldMap) {
         List < String > rprIds = new List < String > ();
         Map < Id, Id > rprIdMap = new Map < Id, Id > ();
@@ -548,27 +586,135 @@
                     Repair__c oldrpr = oldMap.get(rpr.Id);
                     // 淇悊鏈夋姤淇瓙鍗曞彿锛屽苟涓� 寰呭彂閫丄WS涓篺alse 鍙戦�佺粰AWS
                     if (String.isNotBlank(rpr.RepairSubOrder__c) && !rpr.AwaitToSendAWS__c) {
-                        if (((rpr.status__c == '0.鐢宠瀹屾瘯' || rpr.status__c == '1.鍙楃悊瀹屾瘯') && (oldrpr.SAP_Transfer_time__c == null && rpr.SAP_Transfer_time__c != null)) || (rpr.Address_type__c == 'X' && (rpr.Address_Type_Index__c != oldrpr.Address_Type_Index__c))) {
+                        if (((rpr.status__c == '0.鐢宠瀹屾瘯' || rpr.status__c == '1.鍙楃悊瀹屾瘯') && (oldrpr.SAP_Transfer_time__c == null && rpr.SAP_Transfer_time__c != null)) || 
+                            (rpr.Address_type__c == 'X' && (rpr.Address_Type_Index__c != oldrpr.Address_Type_Index__c)) || 
+                            //  2022/4/6    zhangyuheng update start
+                            (rpr.OTSRepairOrder__c != oldrpr.OTSRepairOrder__c) || // OTS璁㈠崟鍙锋湁鍊硷紝鍙戦�丄WS
+                            //  2022/4/6    zhangyuheng update end
+                            //  2022/4/7    zhangyuheng update start
+                            (rpr.DeliveryLogisticsNo__c != oldrpr.DeliveryLogisticsNo__c) || // 閫佷慨鐗╂祦鍗曞彿鏈夊�硷紝鍙戦�丄WS
+                            // ((rpr.Discount_Price_formula__c != oldrpr.Discount_Price_formula__c) && rpr.Repair_Firstestimated_Date_formula__c != null) || // 鎶ヤ环閲戦鍙戠敓鏀瑰彉涓斿垵娆℃姤浠锋棩鏈夊�硷紝鍙戦�丄WS
+                            ((rpr.Returns_Product_waySAP__c != oldrpr.Returns_Product_waySAP__c) && rpr.Repair_Shipped_DateTime__c != null) || // 閫佷慨鏂瑰紡鍙戠敓鏀瑰彉涓斿瘎閫佹棩鏈夊�硷紝鍙戦�丄WS
+                            //  2022/4/7    zhangyuheng update end
+                            //  2022/4/18    zhangyuheng update start
+                            (rpr.FSE_ApplyForRepair_time__c != oldrpr.FSE_ApplyForRepair_time__c) ||                   // FSE鐢宠淇悊鏃ュ彂鐢熸敼鍙橈紝鍙戦�丄WS
+                            (rpr.Repair_Ordered_DateTime__c != oldrpr.Repair_Ordered_DateTime__c) ||                   // 4.淇悊鍝丷C鍙楃悊鏃ワ紙灏忕▼搴忥級鍙戠敓鏀瑰彉锛屽彂閫丄WS
+                            (rpr.Repair_Firstestimated_Date__c != oldrpr.Repair_Firstestimated_Date__c) ||             // 鍒濇鎶ヤ环鏃ワ紙涓嶇敤锛夊彂鐢熸敼鍙橈紝鍙戦�丄WS
+                            (rpr.Repair_Shipped_DateTime__c != oldrpr.Repair_Shipped_DateTime__c) ||                   // 11.RC淇悊鍝佽繑閫佹棩锛堝皬绋嬪簭锛夊彂鐢熸敼鍙橈紝鍙戦�丄WS
+                            (rpr.Repair_Final_Inspection_DateTime__c != oldrpr.Repair_Final_Inspection_DateTime__c) || // 10.鏈�缁堟娴嬫棩锛堝皬绋嬪簭锛夊彂鐢熸敼鍙橈紝鍙戦�丄WS
+                            (rpr.Agreed_DateTime__c != oldrpr.Agreed_DateTime__c) ||                                   //7.鐢ㄦ埛鍚屾剰鏃ワ紙灏忕▼搴忥級鍙戠敓鏀瑰彉锛屽彂閫丄WS
+                            (rpr.Agreed_Date__c != oldrpr.Agreed_Date__c) ||                                           // 7.鐢ㄦ埛鍚屾剰鏃ュ彂鐢熸敼鍙橈紝鍙戦�丄WS
+                            (rpr.engineerSendDate__c != oldrpr.engineerSendDate__c)                                    //淇悊鍝佸瘎閫佹棩鍙戠敓鏀瑰彉锛屽彂閫丄WS
+                            //  2022/4/18    zhangyuheng update start
+                            ) {
 
                             if (NFM603Controller.NFM603_Ids.contains(rpr.Id) == false) {
                                 NFM603Controller.NFM603_Ids.add(rpr.Id);
                                 rprIdMap.put(rpr.Id, rpr.Id);
                             }
                         }
-                        // 娴嬭瘯鐜娴嬭瘯鐢紝涓婄嚎鍓嶈娉ㄦ帀
-                        /*if (rpr.Repair_Firstestimated_Date__c != oldrpr.Repair_Firstestimated_Date__c) {
+                        //  2022/4/19    zhangyuheng update start
+                        // 濡傛灉鍚屾湡涓殑淇悊鎶ヤ环锛圧epair_Quotation_Id__c锛変负绌猴紝鍒ゆ柇鍒濇鎶ヤ环鏃ュ拰鎶ヤ环閲戦
+                        if (rpr.Repair_Quotation_Id__c != oldrpr.Repair_Quotation_Id__c) {
                             if (NFM603Controller.NFM603_Ids.contains(rpr.Id) == false) {
                                 NFM603Controller.NFM603_Ids.add(rpr.Id);
-                                // rprIds.add(rpr.Id);
                                 rprIdMap.put(rpr.Id, rpr.Id);
                             }
                         }
-                        if (rpr.Repair_Shipped_Date__c != oldrpr.Repair_Shipped_Date__c) {
-                            if (NFM603Controller.NFM603_Ids.contains(rpr.Id) == false) {
-                                NFM603Controller.NFM603_Ids.add(rpr.Id);
-                                rprIdMap.put(rpr.Id, rpr.Id);
+                        if (rpr.Repair_Quotation_Id__c == null) {
+                            // 濡傛灉鍒濇鎶ヤ环鏃ワ紙涓嶇敤锛夋垨鎶樻墸鍚庨噾棰濓紙涓嶇敤锛夊彂鐢熸敼鍙橈紝鍙戦�丄WS
+                            if (rpr.Discount_Price__c != oldrpr.Discount_Price__c || rpr.Repair_Estimated_Date__c != oldrpr.Repair_Estimated_Date__c) {
+                                if (NFM603Controller.NFM603_Ids.contains(rpr.Id) == false) {
+                                    NFM603Controller.NFM603_Ids.add(rpr.Id);
+                                    rprIdMap.put(rpr.Id, rpr.Id);
+                                }
                             }
-                        }*/
+                        }
+                        // 濡傛灉鍚屾湡涓殑淇悊鎶ヤ环锛圧epair_Quotation_Id__c锛変笉涓虹┖锛屽湪RepairQuoteTrigger.ChangeRepair杩涜鍒ゆ柇瑙﹀彂
+                        //  2022/4/19    zhangyuheng update end
+                        
+                        //  2022/4/6    zhangyuheng update start
+                        //OTS璁㈠崟鍙锋湁鍊硷紝鍙戦�丄WS
+                        // if ((oldrpr.OTSRepairOrder__c == null && String.isNotBlank(rpr.OTSRepairOrder__c)) || rpr.OTSRepairOrder__c != oldrpr.OTSRepairOrder__c) {
+                        //     if (NFM603Controller.NFM603_Ids.contains(rpr.Id) == false) {
+                        //         NFM603Controller.NFM603_Ids.add(rpr.Id);
+                        //         rprIdMap.put(rpr.Id, rpr.Id);
+                        //     }
+                        // }
+                        //  2022/4/6    zhangyuheng update end
+                        //  2022/4/7    zhangyuheng update start
+                        //閫佷慨鐗╂祦鍗曞彿鏈夊�硷紝鍙戦�丄WS
+                        // if ((oldrpr.DeliveryLogisticsNo__c == null && String.isNotBlank(rpr.DeliveryLogisticsNo__c))  || rpr.DeliveryLogisticsNo__c != oldrpr.DeliveryLogisticsNo__c) {
+                        //     if (NFM603Controller.NFM603_Ids.contains(rpr.Id) == false) {
+                        //         NFM603Controller.NFM603_Ids.add(rpr.Id);
+                        //         rprIdMap.put(rpr.Id, rpr.Id);
+                        //     }
+                        // }
+                        //鎶ヤ环閲戦鍙戠敓鏀瑰彉涓斿垵娆℃姤浠锋棩鏈夊�硷紝鍙戦�丄WS
+                        // if ((rpr.Discount_Price_formula__c != oldrpr.Discount_Price_formula__c) && rpr.Repair_Firstestimated_Date_formula__c != null) {
+                        //     if (NFM603Controller.NFM603_Ids.contains(rpr.Id) == false) {
+                        //         NFM603Controller.NFM603_Ids.add(rpr.Id);
+                        //         rprIdMap.put(rpr.Id, rpr.Id);
+                        //     }
+                        // }
+                        // if ((rpr.Returns_Product_waySAP__c != oldrpr.Returns_Product_waySAP__c) && rpr.Repair_Shipped_DateTime__c != null) {
+                        //     if (NFM603Controller.NFM603_Ids.contains(rpr.Id) == false) {
+                        //         NFM603Controller.NFM603_Ids.add(rpr.Id);
+                        //         rprIdMap.put(rpr.Id, rpr.Id);
+                        //     }
+                        // }
+                        //  2022/4/7    zhangyuheng update end
+                        //  2022/4/18    zhangyuheng update start
+                        // FSE鐢宠淇悊鏃ュ彂鐢熸敼鍙橈紝鍙戦�丄WS
+                        // if (rpr.FSE_ApplyForRepair_time__c != oldrpr.FSE_ApplyForRepair_time__c) {
+                        //     if (NFM603Controller.NFM603_Ids.contains(rpr.Id) == false) {
+                        //         NFM603Controller.NFM603_Ids.add(rpr.Id);
+                        //         rprIdMap.put(rpr.Id, rpr.Id);
+                        //     }
+                        // }
+                        // 4.淇悊鍝丷C鍙楃悊鏃ワ紙灏忕▼搴忥級鍙戠敓鏀瑰彉锛屽彂閫丄WS
+                        // if (rpr.Repair_Ordered_DateTime__c != oldrpr.Repair_Ordered_DateTime__c) {
+                        //     if (NFM603Controller.NFM603_Ids.contains(rpr.Id) == false) {
+                        //         NFM603Controller.NFM603_Ids.add(rpr.Id);
+                        //         rprIdMap.put(rpr.Id, rpr.Id);
+                        //     }
+                        // }
+                        // 鍒濇鎶ヤ环鏃ワ紙涓嶇敤锛夊彂鐢熸敼鍙橈紝鍙戦�丄WS
+                        // if (rpr.Repair_Firstestimated_Date__c != oldrpr.Repair_Firstestimated_Date__c) {
+                        //     if (NFM603Controller.NFM603_Ids.contains(rpr.Id) == false) {
+                        //         NFM603Controller.NFM603_Ids.add(rpr.Id);
+                        //         rprIdMap.put(rpr.Id, rpr.Id);
+                        //     }
+                        // }
+                        // 11.RC淇悊鍝佽繑閫佹棩锛堝皬绋嬪簭锛夊彂鐢熸敼鍙橈紝鍙戦�丄WS
+                        // if (rpr.Repair_Shipped_DateTime__c != oldrpr.Repair_Shipped_DateTime__c) {
+                        //     if (NFM603Controller.NFM603_Ids.contains(rpr.Id) == false) {
+                        //         NFM603Controller.NFM603_Ids.add(rpr.Id);
+                        //         rprIdMap.put(rpr.Id, rpr.Id);
+                        //     }
+                        // }
+                        // 10.鏈�缁堟娴嬫棩锛堝皬绋嬪簭锛夊彂鐢熸敼鍙橈紝鍙戦�丄WS
+                        // if (rpr.Repair_Final_Inspection_DateTime__c != oldrpr.Repair_Final_Inspection_DateTime__c) {
+                        //     if (NFM603Controller.NFM603_Ids.contains(rpr.Id) == false) {
+                        //         NFM603Controller.NFM603_Ids.add(rpr.Id);
+                        //         rprIdMap.put(rpr.Id, rpr.Id);
+                        //     }
+                        // }
+                        //  2022/4/18    zhangyuheng update end
+                        // 娴嬭瘯鐜娴嬭瘯鐢紝涓婄嚎鍓嶈娉ㄦ帀
+                        // if (rpr.Repair_Firstestimated_Date__c != oldrpr.Repair_Firstestimated_Date__c) {
+                        //     if (NFM603Controller.NFM603_Ids.contains(rpr.Id) == false) {
+                        //         NFM603Controller.NFM603_Ids.add(rpr.Id);
+                        //         // rprIds.add(rpr.Id);
+                        //         rprIdMap.put(rpr.Id, rpr.Id);
+                        //     }
+                        // }
+                        // if (rpr.Repair_Shipped_Date__c != oldrpr.Repair_Shipped_Date__c) {
+                        //     if (NFM603Controller.NFM603_Ids.contains(rpr.Id) == false) {
+                        //         NFM603Controller.NFM603_Ids.add(rpr.Id);
+                        //         rprIdMap.put(rpr.Id, rpr.Id);
+                        //     }
+                        // }
                         // 娴嬭瘯鐜娴嬭瘯鐢紝涓婄嚎鍓嶈娉ㄦ帀
                     }
 
@@ -582,7 +728,7 @@
                 iflog.Type__c = LOG_TYPE;
                 iflog.Log__c = 'callout start\n';
                 insert iflog;
-                NFM603Controller.callout(iflog.Id, rprIds);
+                NFM603Controller.executefuture(iflog, rprIds);
             }
         } else {
             if (Trigger.isUpdate) {
@@ -596,4 +742,105 @@
             }
         }
     }
+
+    //鎶ヤ环鏃ャ�佸垵娆℃姤浠锋棩銆丷C淇悊鍝丷C鍙楃悊鏃ワ紙灏忕▼搴忥級鏃堕棿鏂规硶   zyh  20220315   start
+    //涓嬬彮寮�濮嬫椂闂�
+    public static String DownStartDt(){
+        String timenow = Datetime.now().format('yyyyMMddHHmmss');
+        String dt = NFMUtil.formatDate2Str(Date.today());
+        String rtn = null;
+        if (dt == null) {
+            return rtn;
+        }
+        rtn = String.valueOf(dt);
+        rtn = rtn.replaceAll('-', '');
+        if (rtn >= '40001231') {
+            rtn = '99991231';
+        } else if (rtn < '19000101') {
+            rtn = '19000101';
+        }
+        return rtn + '173001';
+    }
+    //涓嬬彮缁撴潫鏃堕棿
+    public static String DownEndDt(){
+        String dt = NFMUtil.formatDate2Str(Date.today());
+        String rtn = null;
+        if (dt == null) {
+            return rtn;
+        }
+        rtn = String.valueOf(dt);
+        rtn = rtn.replaceAll('-', '');
+        if (rtn >= '40001231') {
+            rtn = '99991231';
+        } else if (rtn < '19000101') {
+            rtn = '19000101';
+        }
+        return rtn + '235959';
+    }
+    //涓婄彮寮�濮嬫椂闂�
+    public static String UpStartDt(){
+        String dt = NFMUtil.formatDate2Str(Date.today());
+        String rtn = null;
+        if (dt == null) {
+            return rtn;
+        }
+        rtn = String.valueOf(dt);
+        rtn = rtn.replaceAll('-', '');
+        if (rtn >= '40001231') {
+            rtn = '99991231';
+        } else if (rtn < '19000101') {
+            rtn = '19000101';
+        }
+        return rtn + '000000';
+    }
+    //涓婄彮缁撴潫鏃堕棿
+    public static String UpEndDt(){
+        String dt = NFMUtil.formatDate2Str(Date.today());
+        String rtn = null;
+        if (dt == null) {
+            return rtn;
+        }
+        rtn = String.valueOf(dt);
+        rtn = rtn.replaceAll('-', '');
+        if (rtn >= '40001231') {
+            rtn = '99991231';
+        } else if (rtn < '19000101') {
+            rtn = '19000101';
+        }
+        return rtn + '084459';
+    }
+    //涓婄彮瀹氫箟鏃堕棿
+    public static String UpDt(){
+        String dt = NFMUtil.formatDate2Str(Date.today());
+        String rtn = null;
+        if (dt == null) {
+            return rtn;
+        }
+        rtn = String.valueOf(dt);
+        rtn = rtn.replaceAll('-', '');
+        if (rtn >= '40001231') {
+            rtn = '99991231';
+        } else if (rtn < '19000101') {
+            rtn = '19000101';
+        }
+        return rtn + '090000';
+    }
+    //涓嬬彮瀹氫箟鏃堕棿
+    public static String DownDt(){
+        String dt = NFMUtil.formatDate2Str(Date.today());
+        String rtn = null;
+        if (dt == null) {
+            return rtn;
+        }
+        rtn = String.valueOf(dt);
+        rtn = rtn.replaceAll('-', '');
+        if (rtn >= '40001231') {
+            rtn = '99991231';
+        } else if (rtn < '19000101') {
+            rtn = '19000101';
+        }
+        return rtn + '170000';
+    }
+    //鎶ヤ环鏃ャ�佸垵娆℃姤浠锋棩銆丷C淇悊鍝丷C鍙楃悊鏃ワ紙灏忕▼搴忥級鏃堕棿鏂规硶   zyh  20220315   end
+
 }
\ No newline at end of file
diff --git a/force-app/main/default/classes/NFM603ControllerTest.cls b/force-app/main/default/classes/NFM603ControllerTest.cls
index 92d2cab..1688f92 100644
--- a/force-app/main/default/classes/NFM603ControllerTest.cls
+++ b/force-app/main/default/classes/NFM603ControllerTest.cls
@@ -74,7 +74,11 @@
         ast = [select Id, Name, Product_Serial_No__c, AccountId, Department_Class__c, Department_Class__r.Management_Code_Auto__c, Hospital__c, Product2Id, Product2.ProductCode, Product2.Repair_Product_Code__c, SerialNumber
                from Asset
                where Id = :ast.Id];
-
+        RepairSubOrder__c subOrder = new RepairSubOrder__c();
+        subOrder.AttachmentDownload__c = true;
+        subOrder.AttachmentLink__c = 'https://albsylfw.s3.cn-northwest-1.amazonaws.com.cn/20211220/14/11/30/lessthan12/5e8cb69e-f935-48f5-825e-b8344d60f6d4.zip';
+        subOrder.AttachmentName__c = '娴嬭瘯闄勪欢涓嬭浇';
+        insert subOrder;
         Repair__c rpr = new Repair__c();
         rpr.PAE_Determine__c = 'PAE' ;   //-- 
         rpr.ifDeadHurt__c = '鏈�';        //-- R1
@@ -83,12 +87,16 @@
         rpr.Account__c             = depart.Id;
         rpr.Department_Class__c    = section.Id;
         rpr.Hospital__c            = company.Id;
+        rpr.DeliveryLogisticsMode__c = '鍏朵粬';
+        rpr.RepairSubOrder__c = subOrder.Id;
         rpr.Delivered_Product__c   = ast.Id;
         rpr.Status__c              = '1.鍙楃悊瀹屾瘯';
+        rpr.SAP_Transfer_time__c = null;
         rpr.Incharge_Staff__c = Userinfo.getUserId();
         rpr.Repair_Detail__c = 'test';
         rpr.GeneratedPDFField__c = null;
         rpr.AsyncData__c    = true;
+        rpr.AwaitToSendAWS__c = false;
         rpr.Complaint_Number__c = null;
         rpr.ReportAdverseEvents__c = '鏈�';
         rpr.ProblemOccurred__c = '鍒拌揣楠屾敹';
@@ -99,6 +107,7 @@
         rpr.Failure_Occurrence_Date__c = Date.today();
         rpr.Repair_Ordered_Date__c = Date.today();
         rpr.Repair_Shipped_Date__c = Date.today();
+        rpr.Repair_Ordered_DateTime__c = Datetime.newInstance(2022,04,13,18,18,18);
         rpr.ReturnType__c = 'A20';
         rpr.AwaitToSendAWS__c = true;
         //rpr.Returns_Product_waySAP__c = '杩旈�佸尰闄�';
@@ -230,6 +239,29 @@
 
         Test.stopTest();
     }
+    @isTest
+    static void testCallOut1_2(){
+      List<Repair__c> repairList = [select id,Repair_Ordered_DateTime__c,OTSRepairOrder__c,SAP_Transfer_time__c,Status__c from Repair__c];
+      Test.startTest();
+        List<Id> idList = new List<Id>();
+        for(Repair__c repair : repairList){
+            repair.Repair_Ordered_DateTime__c = Datetime.newInstance(2022,04,13,05,18,18);
+        repair.SAP_Transfer_time__c = Datetime.newInstance(2022,04,13,18,18,18);
+            repair.OTSRepairOrder__c = '123123123';
+          // idList.add(repair.Id);
+        }
+        upsert repairList;
+        for(Repair__c repair : repairList){
+          idList.add(repair.Id);
+        }
+        BatchIF_Log__c iflog = new BatchIF_Log__c();
+        iflog.Log__c = 'test start \n';
+        insert iflog;
+
+        NFM603Controller.executefuture(iflog,idList);
+
+        Test.stopTest();
+    }
 
     // @isTest
     // static void testcallout2(){
@@ -246,11 +278,11 @@
     //     Test.stopTest();
     // }
 
-    @isTest
-    static void testcallout3(){
-      BatchIF_Log__c iflog = [select id from BatchIF_Log__c where Type__c = '603test'];
-        NFM603Controller.ManualExecute(iflog.Id);
-    }
+    // @isTest
+    // static void testcallout3(){
+    //   BatchIF_Log__c iflog = [select id from BatchIF_Log__c where Type__c = '603test' limit 1];
+    //     NFM603Controller.ManualExecute(iflog.Id);
+    // }
 
     @isTest
     static void NFM603BatchTest01(){
diff --git a/force-app/main/default/classes/RepairHandler.cls b/force-app/main/default/classes/RepairHandler.cls
index db18525..083d2ac 100644
--- a/force-app/main/default/classes/RepairHandler.cls
+++ b/force-app/main/default/classes/RepairHandler.cls
@@ -98,9 +98,27 @@
             // 鍖呭惈鎶ヤ慨瀛愬崟鐨勪慨鐞� 淇悊鍗曠姸鎬佺紪鍙峰彉鏇村彂閫丄WS Start
             if (Trigger.isUpdate) {
                 Repair__c oldrpr = oldMap.get(nObj.Id);
-                if (String.isNotBlank(nObj.RepairSubOrder__c) && nObj.RepairOrderStatusCode__c != oldrpr.RepairOrderStatusCode__c) {
-                    nObj.AwaitToSendAWS__c = true;
-                } 
+                // 2022/04/20 zhangyuheng  update start
+                if ((nObj.OTSRepairOrder__c == oldrpr.OTSRepairOrder__c) && // OTS璁㈠崟鍙峰彂鐢熸敼鍙橈紝鍗虫椂鍙戦�丄WS
+                    (nObj.DeliveryLogisticsNo__c == oldrpr.DeliveryLogisticsNo__c) && // 閫佷慨鐗╂祦鍗曞彿鍙戠敓鏀瑰彉锛屽嵆鏃跺彂閫丄WS
+                    (nObj.Returns_Product_waySAP__c == oldrpr.Returns_Product_waySAP__c) && // 閫佷慨鏂瑰紡鍙戠敓鏀瑰彉涓斿瘎閫佹棩鏈夊�硷紝鍗虫椂鍙戦�丄WS
+                    (nObj.FSE_ApplyForRepair_time__c == oldrpr.FSE_ApplyForRepair_time__c) &&                   // FSE鐢宠淇悊鏃ュ彂鐢熸敼鍙橈紝鍗虫椂鍙戦�丄WS
+                    (nObj.Repair_Ordered_DateTime__c == oldrpr.Repair_Ordered_DateTime__c) &&                   // 4.淇悊鍝丷C鍙楃悊鏃ワ紙灏忕▼搴忥級鍙戠敓鏀瑰彉锛屽嵆鏃跺彂閫丄WS
+                    (nObj.Repair_Firstestimated_Date__c == oldrpr.Repair_Firstestimated_Date__c) &&             // 鍒濇鎶ヤ环鏃ワ紙涓嶇敤锛夊彂鐢熸敼鍙橈紝鍗虫椂鍙戦�丄WS
+                    (nObj.Repair_Shipped_DateTime__c == oldrpr.Repair_Shipped_DateTime__c) &&                   // 11.RC淇悊鍝佽繑閫佹棩锛堝皬绋嬪簭锛夊彂鐢熸敼鍙橈紝鍗虫椂鍙戦�丄WS
+                    (nObj.Repair_Final_Inspection_DateTime__c == oldrpr.Repair_Final_Inspection_DateTime__c) && // 10.鏈�缁堟娴嬫棩锛堝皬绋嬪簭锛夊彂鐢熸敼鍙橈紝鍗虫椂鍙戦�丄WS
+                    (nObj.Agreed_DateTime__c == oldrpr.Agreed_DateTime__c) &&                                   //7.鐢ㄦ埛鍚屾剰鏃ワ紙灏忕▼搴忥級鍙戠敓鏀瑰彉锛屽嵆鏃跺彂閫丄WS
+                    (nObj.Agreed_Date__c == oldrpr.Agreed_Date__c) &&                                           // 7.鐢ㄦ埛鍚屾剰鏃ュ彂鐢熸敼鍙橈紝鍗虫椂鍙戦�丄WS
+                    (nObj.engineerSendDate__c == oldrpr.engineerSendDate__c)
+                    ) {
+                    // 2022/04/20 zhangyuheng  update end
+                    if (String.isNotBlank(nObj.RepairSubOrder__c) && nObj.RepairOrderStatusCode__c != oldrpr.RepairOrderStatusCode__c) {
+                        nObj.AwaitToSendAWS__c = true;
+                    } 
+                    // 2022/04/20 zhangyuheng  update start
+                }
+                // 2022/04/20 zhangyuheng  update end
+                
             }
             // 鍖呭惈鎶ヤ慨瀛愬崟鐨勪慨鐞� 淇悊鍗曠姸鎬佺紪鍙峰彉鏇村彂閫丄WS End
             
diff --git a/force-app/main/default/classes/RepairHandlerTest.cls b/force-app/main/default/classes/RepairHandlerTest.cls
index e90d72f..b1d643f 100644
--- a/force-app/main/default/classes/RepairHandlerTest.cls
+++ b/force-app/main/default/classes/RepairHandlerTest.cls
@@ -349,7 +349,7 @@
                 Username = 'Test' + timenow + '@sunbridge.com', IsActive = true, EmailEncodingKey = 'ISO-2022-JP',
                 TimeZoneSidKey = 'Asia/Tokyo', LocaleSidKey = 'ja_JP', LanguageLocaleKey = 'ja',
                 ProfileId = System.Label.ProfileId_SystemAdmin,
-                Dept__c = '鍖荤枟鍗庡寳钀ヤ笟鏈儴', Province__c = '鍖椾含');
+                Dept__c = '鍖荤枟鍗庡寳钀ヤ笟鏈儴', Province__c = '鍖椾含',Employee_No__c = '12345'); // 2022-04-25   zhangyuheng   update  'Employee_No__c = '12345''
 
         List<Profile> p = [Select Id From Profile Where Name = '2S1_閿�鍞尰闄㈡媴褰�'];
         System.assertEquals(p.size(), 1);
@@ -359,7 +359,7 @@
                 Username = 'Test1' + timenow + '@sunbridge.com', IsActive = true, EmailEncodingKey = 'ISO-2022-JP',
                 TimeZoneSidKey = 'Asia/Tokyo', LocaleSidKey = 'ja_JP', LanguageLocaleKey = 'ja',
                 ProfileId = p[0].Id,
-                Dept__c = '鍖荤枟鍗庡寳钀ヤ笟鏈儴', Province__c = '鍖椾含');
+                Dept__c = '鍖荤枟鍗庡寳钀ヤ笟鏈儴', Province__c = '鍖椾含',Employee_No__c = '23456'); // 2022-04-25   zhangyuheng   update  'Employee_No__c = '23456''
         List<User> us = new List<User>();
         us.add(user1);
         us.add(user2);

--
Gitblit v1.9.1