From e9e1806b0f4b5bae1fc36204ccc5d6fdad52d66f Mon Sep 17 00:00:00 2001
From: buli <137736985@qq.com>
Date: 星期一, 05 六月 2023 11:22:08 +0800
Subject: [PATCH] Merge branch 'master' into LightningUpgradeProject

---
 force-app/main/default/classes/NFM105Rest.cls |  120 ++++++++++++++++++++++++++++++++++++++++++++++--------------
 1 files changed, 92 insertions(+), 28 deletions(-)

diff --git a/force-app/main/default/classes/NFM105Rest.cls b/force-app/main/default/classes/NFM105Rest.cls
index 56bbb61..6fd096e 100644
--- a/force-app/main/default/classes/NFM105Rest.cls
+++ b/force-app/main/default/classes/NFM105Rest.cls
@@ -62,7 +62,10 @@
 
         BatchIF_Log__c rowData = NFMUtil.saveRowData(Monitoring, 'NFM105', ges.RepairStatusUpdate.GeneralData);
         if (String.isBlank(rowData.Log__c) == false) {
-            executefuture(rowData.Id);
+            //涓婇檺鍚堝悓 LY 20230209 start
+            //executefuture(rowData.Id);
+            main(rowData.Id);
+            //涓婇檺鍚堝悓 LY 20230209 end
         }
 
         // JSON銈掓埢銇�
@@ -162,10 +165,10 @@
                                     , Repair_Quotation_Id__c, NFM105_MessageGroupNumber__c, Repair_List_Price_formula__c
                                     , ReturnType__c, InspectType__c
                                     , Maintenance_Contract__r.URF_Contract__c
-                                    , Maintenance_Contract_Asset_Estimate__r.URF_Series__c // 20220321 ljh 闄愭鍚堝悓寮傚父鏁版嵁
                                     ,Maintenance_Contract__c
                                     ,SerialNumber__c
                                     ,Agreed_Date__c 
+                                    ,Limit_Price__c //涓婇檺鍚堝悓 LY 20230209
                                   from Repair__c
                                   where SAPRepairNo__c in :sapRepairNoList
                                   OR Name in :sfdcRepairNoList]
@@ -593,7 +596,27 @@
                 update astUpdateMap.values();
             }
 
-
+            //涓婇檺鍚堝悓 LY 20230131 start 缁翠慨鍚堝悓涓婄殑鍚堝悓鏈熼棿淇悊閲戦姹囨��
+            List<ID> updateMC = new List<ID>();
+            if (rprList.size() > 0 ) {
+                for (Repair__c rc : rprList) {
+                    if (rc.Limit_Price__c) {
+                        //B95-鎶ヤ环鍚屾剰纭銆丅99-鎶ヤ环鍚屾剰纭鍙栨秷銆丄95-鍙栨秷淇悊鍙楃悊銆丄96-鍙栨秷淇悊銆丄99-淇悊鍗曞叧闂� 鏇存柊鍚堝悓鏈熼棿淇悊閲戦
+                        //if (rc.RepairOrderStatusCode__c =='B95' || rc.RepairOrderStatusCode__c =='B99' || rc.RepairOrderStatusCode__c =='A99' || rc.RepairOrderStatusCode__c =='A95' || rc.RepairOrderStatusCode__c =='A96'){
+                        if (rc.Agreed_Date__c != null){
+                            Maintenance_Contract__c mc = new Maintenance_Contract__c();
+                            if (!updateMC.contains(rc.Maintenance_Contract__c)) {
+                                mc.Id = rc.Maintenance_Contract__c;
+                            } 
+                            updateMC.add(mc.Id);
+                        }
+                    }
+                }
+                if (updateMC.size()>0) {
+                    Database.executeBatch(new RollupToMaintenanceContractBatch(updateMC), 1);
+                }
+            }
+            //涓婇檺鍚堝悓 LY 20230131 end
 
             //add by rentx 2021-3-4 start
             /*
@@ -724,43 +747,84 @@
             }*/
             //add by rentx 2021-3-4 end
             if (rprList.size() > 0) {
+                //contractAssetUrfMap<缁翠慨鍚堝悓+淇濇湁璁惧,闄愭绯诲垪>
+                Map<String,String> contractAssetUrfMap = new Map<String,String>();
+                //闄愭鍚堝悓Id闆嗗悎
+                List<Id> contractIds = new List<Id>();
+                //闄愭鍚堝悓涓嬬殑淇悊闆嗗悎
+                List<Repair__c> reList = new List<Repair__c>();
                 // 闄愭鍚堝悓 map
                 Map<String,Map<String,List<Repair__c>>> contractMap = new Map<String,Map<String,List<Repair__c>>>();
                 //缁翠慨鍚堝悓淇濇湁璁惧闆嗗悎
                 List<Maintenance_Contract_Asset__c> maassList = new List<Maintenance_Contract_Asset__c>();
+                // 闇�瑕佹洿鏂扮殑 缁翠慨鍚堝悓鎶ヤ环/淇濇湁璁惧
+                List<Maintenance_Contract_Asset_Estimate__c> updateList = new List<Maintenance_Contract_Asset_Estimate__c>();
                 //鏌ヨ褰撳墠淇悊瀵瑰簲鐨勭淮淇悎鍚屾槸鍚︿负闄愭鍚堝悓 && 澶т慨
                 for (Repair__c rep : rprList) {
-                    if (rep.Maintenance_Contract__c != null && rep.Maintenance_Contract__r.URF_Contract__c == true && (rep.Repair_Rank__c == 'A' || rep.Repair_Rank__c == 'B' || rep.Repair_Rank__c == 'C') && rep.Agreed_Date__c != null) {
-                        List<Repair__c> tempRepL;
-                        Map<String,List<Repair__c>> tempRepM;
-                        if(contractMap.containsKey(rep.Maintenance_Contract__c)){
-                            // 淇濇湁璁惧 鍜� 闄愭绯诲垪
-                            tempRepM = contractMap.get(rep.Maintenance_Contract__c);
-                            if(tempRepM.containsKey(rep.Delivered_Product__c)){
-                                tempRepM.get(rep.Delivered_Product__c).add(rep);
-                            }
-                            if(tempRepM.containsKey(rep.Maintenance_Contract_Asset_Estimate__r.URF_Series__c)){
-                                tempRepM.get(rep.Maintenance_Contract_Asset_Estimate__r.URF_Series__c).add(rep);
-                            }
-                        }else{
-                            tempRepM = new Map<String,List<Repair__c>>();
-                            tempRepL.add(rep); 
-                            tempRepM.put(rep.Delivered_Product__c,tempRepL);
-                            tempRepM.put(rep.Maintenance_Contract_Asset_Estimate__r.URF_Series__c,tempRepL);
-                        }                       
-                        contractMap.put(rep.Maintenance_Contract__c,tempRepM);  
+                    //URF闄愭鍚堝悓2鏈� LY 20220929 start 杩藉姞淇悊鍗曞垹闄ゅ拰鍙栨秷鐨勭姸鎬佹潯浠�
+                    if (rep.Maintenance_Contract__c != null && rep.Maintenance_Contract__r.URF_Contract__c == true && (rep.Repair_Rank__c == 'A' || rep.Repair_Rank__c == 'B' || rep.Repair_Rank__c == 'C') && rep.Agreed_Date__c != null && rep.Status1__c !='0.鍙栨秷' && rep.Status1__c !='0.鍒犻櫎') { 
+                    //URF闄愭鍚堝悓2鏈� LY 20220929 end  
+                        contractIds.add(rep.Maintenance_Contract__c);
                     }
                 }
-                if (contractMap.size() > 0) {
-                    //鏌ヨ褰撳墠闄愭鍚堝悓涓嬬殑鎵�鏈夌淮淇悎鍚屼繚鏈夎澶�
-                    maassList = [SELECT id , Series_RepairCount_F__c
+                //鏌ヨ褰撳墠闄愭鍚堝悓涓嬬殑鎵�鏈夌淮淇悎鍚屼繚鏈夎澶�
+                maassList = [SELECT id , Series_RepairCount_F__c
                                 , Maintenance_Contract_Asset_Estimate__c
                                 , Asset__c
                                 , Maintenance_Contract__c
                                 , URF_Series_F__c
                                 FROM Maintenance_Contract_Asset__c 
-                                WHERE Maintenance_Contract__c in :contractMap.keySet()];
-                    List<Maintenance_Contract_Asset_Estimate__c> updateList = new List<Maintenance_Contract_Asset_Estimate__c>();
+                                WHERE Maintenance_Contract__c in :contractIds];
+                for (Maintenance_Contract_Asset__c maAss : maassList) {
+                    // contractAssetUrfMap<缁翠慨鍚堝悓+淇濇湁璁惧,闄愭绯诲垪>
+                    String keyV = maAss.Maintenance_Contract__c +';'+ maAss.Asset__c;
+                    if (!contractAssetUrfMap.containsKey(keyV) && String.isNotBlank(maAss.URF_Series_F__c)) {
+                        contractAssetUrfMap.put(keyV, maAss.URF_Series_F__c);
+                    }
+                }
+                //鏌ヨ缁翠慨鍚堝悓涓嬬殑鎵�鏈変慨鐞�
+                reList = [select id,Maintenance_Contract__c,Delivered_Product__c,Usage_Ratio_Price_Service__c from Repair__c where (Repair_Rank__c = 'A' OR Repair_Rank__c = 'B' OR Repair_Rank__c = 'C') and Agreed_Date__c <> null and Maintenance_Contract__c in :contractIds ];
+                system.debug('zheli:'+reList.size());
+                for (Repair__c rep : reList) {
+                    List<Repair__c> tempRepL00;
+                    List<Repair__c> tempRepL01;
+                    List<Repair__c> tempRepL02;
+                    List<Repair__c> tempRepL03;
+                    Map<String,List<Repair__c>> tempRepM;
+                    String keyV = rep.Maintenance_Contract__c +';'+rep.Delivered_Product__c;
+                    if(contractMap.containsKey(rep.Maintenance_Contract__c)){
+                        tempRepM = contractMap.get(rep.Maintenance_Contract__c);
+                        // 淇濇湁璁惧 鍜� 闄愭绯诲垪
+                        if(tempRepM.containsKey(rep.Delivered_Product__c)){
+                            tempRepL02 = tempRepM.get(rep.Delivered_Product__c);
+                        }else{
+                            tempRepL02 = new List<Repair__c>();
+                        }
+                        tempRepL02.add(rep);
+                        tempRepM.put(rep.Delivered_Product__c,tempRepL02);
+                        if(contractAssetUrfMap.containsKey(keyV)){
+                            if(tempRepM.containsKey(contractAssetUrfMap.get(keyV))){
+                                tempRepL03 = tempRepM.get(contractAssetUrfMap.get(keyV));
+                            }else{
+                                tempRepL03 = new List<Repair__c>();
+                            }
+                            tempRepL03.add(rep);
+                            tempRepM.put(contractAssetUrfMap.get(keyV),tempRepL03);
+                        }
+                    }else{
+                        tempRepM = new Map<String,List<Repair__c>>();
+                        tempRepL00 = new List<Repair__c>(); 
+                        tempRepL00.add(rep);
+                        tempRepL01 = new List<Repair__c>(); 
+                        tempRepL01.add(rep);            
+                        tempRepM.put(rep.Delivered_Product__c,tempRepL00);
+                        if(contractAssetUrfMap.containsKey(keyV)){
+                            tempRepM.put(contractAssetUrfMap.get(keyV),tempRepL01);
+                        }
+                    }
+                    contractMap.put(rep.Maintenance_Contract__c,tempRepM);  
+                }
+                if (contractMap.size() > 0) {
                     for (Maintenance_Contract_Asset__c maAss : maassList) {
                         // 鍒ゆ柇宸茬淮淇鏁版槸鍚﹀彂鐢熸敼鍙�
                         if (contractMap.get(maAss.Maintenance_Contract__c) != null
@@ -789,7 +853,7 @@
                         }
                     }
                     if (updateList.size() > 0) {
-                        system.debug('zheli:'+updateList);
+                        // system.debug('zheli:'+updateList);
                         update updateList;
                     }
                 }

--
Gitblit v1.9.1