From 08a21f49f2eaf9cfc19ceb67b196cc36ba689305 Mon Sep 17 00:00:00 2001
From: buli <137736985@qq.com>
Date: 星期五, 13 五月 2022 20:52:25 +0800
Subject: [PATCH] FIxSWOPageIssue

---
 force-app/main/default/classes/RadiationUtil.cls |   62 +++++++++++++++++++++++++++++--
 1 files changed, 58 insertions(+), 4 deletions(-)

diff --git a/force-app/main/default/classes/RadiationUtil.cls b/force-app/main/default/classes/RadiationUtil.cls
index e39f810..02ebb2f 100644
--- a/force-app/main/default/classes/RadiationUtil.cls
+++ b/force-app/main/default/classes/RadiationUtil.cls
@@ -1,5 +1,9 @@
 global class RadiationUtil {
 
+    public static Boolean oldOrder = false;
+
+    public static BOolean is_oly = false;
+
     public static Boolean EscapeOrderTriggerHandler = true;
     /**
      * [updateRadiationTypeQuantity description]鏇存柊浠g悊鍟嗚瘉鐓ф槑缁嗭紝鏇存柊濂ユ灄宸存柉浠g悊鍟嗙殑璇佺収鏄庣粏
@@ -10,7 +14,8 @@
      */
     public static void updateRadiationTypeQuantity (String Id, String orderFounder, String dealerId, Boolean toloseFlag, String operationType, String operator) {
 
-        String olympusAccountId = System.label.Olympus_Id;
+
+        String olympusAccountId =  System.label.Olympus_Id ;
 
         String orderId = Id;
         //鑾峰彇鍚堝悓鐨勮緪灏勭被鍨嬪拰鏁伴噺
@@ -20,7 +25,9 @@
             //鏌ヤ唬鐞嗗晢鐨勪唬鐞嗗晢璐拱鏄庣粏
             Map<String, PurchaseDetails__c> dealerModelQuantityMap = GetPurchaseDetailsMap(dealerId);
             //鏌ュゥ鏋楀反鏂殑浠g悊鍟嗚喘涔版槑缁�
+            is_oly = true;
             Map<String, PurchaseDetails__c> olympusModelQuantityMap = GetPurchaseDetailsMap(olympusAccountId);
+            is_oly = false;
             // 鏌ユ壘 鍚堝悓鎻愪氦瀵瑰簲鐨勪唬鐞嗗晢璐拱鏄庣粏
             Map<String, PurchaseDetails__c> dealerResult = new Map<String, PurchaseDetails__c>();
             Map<String, PurchaseDetails__c> olympusResult = new Map<String, PurchaseDetails__c>();
@@ -114,7 +121,9 @@
 
                     } else {//澧炲姞宸插敭浜у搧鏁伴噺
                         reportMap.putAll(upsertChangedReport(olympusAccountId, radiationType, operationType, orderId, quantity, operator));
+                        is_oly = true;
                         olympusModelQuantityMap = insertPurchaseDetail(olympusModelQuantityMap, olympusAccountId, radiationType, radiationTypeQuantityMap);
+                        is_oly = false;
                     }
                 } else {//鍑忓幓宸插敭浜у搧鏁伴噺
                     if (toloseFlag) {
@@ -122,7 +131,9 @@
                         olympusResult.get(radiationType).SoldNumber__c -= quantity;
                     } else {//澧炲姞宸插敭浜у搧鏁伴噺
                         reportMap.putAll(upsertChangedReport(olympusAccountId, radiationType, operationType, orderId, quantity, operator));
+                        is_oly = true;
                         olympusModelQuantityMap = insertPurchaseDetail(olympusModelQuantityMap, olympusAccountId, radiationType, radiationTypeQuantityMap);
+                        is_oly = false;
                     }
                     
                 }
@@ -137,7 +148,9 @@
 
                 if ( olympusResult.size() > 0 && olympusResult != null) {
                     upsert olympusResult.values();
+                    is_oly = true;
                     insertReportMap.putAll(insertChangedReport(olympusResult, reportMap));
+                    is_oly = false;
                 }
 
             } else {
@@ -148,7 +161,9 @@
 
                 if ( olympusModelQuantityMap.size() > 0 && olympusModelQuantityMap != null) {
                     upsert olympusModelQuantityMap.values();
+                    is_oly = true;
                     insertReportMap.putAll(insertChangedReport(olympusModelQuantityMap, reportMap));
+                    is_oly = false;
                 }
             }
                 
@@ -158,7 +173,9 @@
             
             Map<String, Integer> radiationMap =  new Map<String, Integer>();
             String accountDealerErrorMessage = updateCertificationDetails(dealerId, orderFounder, radiationMap, true);
+            is_oly = true;
             String olympusDealerErrorMessage = updateCertificationDetails(olympusAccountId, orderFounder, radiationMap, true);
+            is_oly = false;
         }
 
     }
@@ -175,6 +192,7 @@
             String accountId = detail.PurchaseAccount__c;
             //String accountIdafter = accountId.subString(0,15);
             String key = accountId.subString(0, 15) + detail.PurProductModel__c;
+
             if (reportMap.containsKey(key)) {
                 reportMap.get(key).ChangedPurchase__c = detail.Id;
             }
@@ -191,9 +209,11 @@
      * @return              [description]
      */
     public static String updateCertificationDetails( String accountId, String orderFounder, Map<String, Decimal> dataMap, Boolean updateFlag) {
-
+        
         Map<String, CertificationDetails__c> certificationDetailMap = GetAccountCertificationDetail(accountId);
+        
         Map<String, CertificationDetails__c> temporaryCertificationDetailMap = GetAccountCertificationDetail(accountId);
+
         Map<String, PurchaseDetails__c> purchaseDetailMap = GetPurchaseDetailsMap(accountId);
 
         Map<String, CertificationDetails__c> updatecertificationDetailMap = new Map<String, CertificationDetails__c>();
@@ -367,7 +387,19 @@
      */
     public static Map<String, CertificationDetails__c> GetAccountCertificationDetail (String accountId) {
         Map<String, CertificationDetails__c> result = new Map<String, CertificationDetails__c>();
-        List<CertificationDetails__c> certificationDetailsList = [ select Id, Name, ProdustionType__c, 
+        List<CertificationDetails__c> certificationDetailsList = new List<CertificationDetails__c>();
+        if (oldOrder && is_oly) {
+            certificationDetailsList = [ select Id, Name, ProdustionType__c, 
+                                    ProductModelNumber__c, Ceiling80__c, Record80__c, Ceiling90__c, Record90__c , 
+                                    CertificationDetailAccount__c, CertificationDetailAccountName__c,
+                                    LicenseInformation__r.IfQuantityCtrl__c,AccountRecordType__c,Record100__c,
+                                    Ceiling100__c
+                                    from CertificationDetails__c 
+                                    where CertificationDetailAccount__c = :accountId  
+                                        and ActivitieTypes__c = '閿�鍞�' and IsActive__c = false];
+            
+        }else{
+            certificationDetailsList = [ select Id, Name, ProdustionType__c, 
                                     ProductModelNumber__c, Ceiling80__c, Record80__c, Ceiling90__c, Record90__c , 
                                     CertificationDetailAccount__c, CertificationDetailAccountName__c,
                                     LicenseInformation__r.IfQuantityCtrl__c,AccountRecordType__c,Record100__c,
@@ -375,6 +407,8 @@
                                     from CertificationDetails__c 
                                     where CertificationDetailAccount__c = :accountId  
                                         and ActivitieTypes__c = '閿�鍞�' and IsActive__c = true];
+        }
+        
 
         for  (CertificationDetails__c detail : certificationDetailsList) {
             result.put(detail.ProdustionType__c, detail);
@@ -404,6 +438,11 @@
         purchaseDetail.PurProductModel__c = productModel;
         purchaseDetail.PurchaseAccount__c = id;
         purchaseDetail.TakeEffectInYear__c = effectiveYear;
+        if (oldOrder && is_oly) {
+            purchasedetail.company__c = '濂ユ灄宸存柉';
+        }else if(is_oly){
+            purchaseDetail.company__c = '浠櫙閫氬厜瀛︾鎶�';
+        }
 
         for (String model:certificationDetailMap.keySet()) {
             if ('Delta鍜孷anta'.equals(model)) {
@@ -460,10 +499,25 @@
     public static Map<String, PurchaseDetails__c> GetPurchaseDetailsMap( String accountId) {
         String effectiveYear = String.valueOf(Date.today().year());
         Map<String, PurchaseDetails__c> result = new Map<String, PurchaseDetails__c>();
-        List<PurchaseDetails__c> purchaseDetailsList = [select Id, Name, RemainingNumber__c, SoldNumber__c,
+        List<PurchaseDetails__c> purchaseDetailsList = new List<PurchaseDetails__c>();
+        if(is_oly == false){
+            purchaseDetailsList = [select Id, Name, RemainingNumber__c, SoldNumber__c,
                                  PurProductModel__c, PurchaseAccount__c
                                  from PurchaseDetails__c
                                  where TakeEffectInYear__c = :effectiveYear and PurchaseAccount__c = :accountId];
+        }else{
+            if (oldOrder) {
+                purchaseDetailsList = [select Id, Name, RemainingNumber__c, SoldNumber__c,
+                                 PurProductModel__c, PurchaseAccount__c
+                                 from PurchaseDetails__c
+                                 where TakeEffectInYear__c = :effectiveYear and PurchaseAccount__c = :accountId and company__c = '濂ユ灄宸存柉'];
+            }else{
+                purchaseDetailsList = [select Id, Name, RemainingNumber__c, SoldNumber__c,
+                                 PurProductModel__c, PurchaseAccount__c
+                                 from PurchaseDetails__c
+                                 where TakeEffectInYear__c = :effectiveYear and PurchaseAccount__c = :accountId and company__c = '浠櫙閫氬厜瀛︾鎶�'];
+            }
+        }
         if (purchaseDetailsList.size() > 0) {
             for (PurchaseDetails__c purchaseDetail : purchaseDetailsList) {
                 result.put(purchaseDetail.PurProductModel__c, purchaseDetail);

--
Gitblit v1.9.1