From 50ce6a5e5ae7ac6ce3e6281acca9a0db568306e6 Mon Sep 17 00:00:00 2001
From: unknown <sunxia@prec-tech.com>
Date: 星期三, 23 八月 2023 14:54:59 +0800
Subject: [PATCH] Merge branch 'LEX_dev' of http://47.92.229.245:8089/r/lightningupdate into LEX_dev

---
 force-app/main/default/classes/FixtureSetDetailHandler.cls |   29 +++++++++++++++++++++++++++++
 1 files changed, 29 insertions(+), 0 deletions(-)

diff --git a/force-app/main/default/classes/FixtureSetDetailHandler.cls b/force-app/main/default/classes/FixtureSetDetailHandler.cls
index 6ce370b..d5d5ad0 100644
--- a/force-app/main/default/classes/FixtureSetDetailHandler.cls
+++ b/force-app/main/default/classes/FixtureSetDetailHandler.cls
@@ -19,8 +19,37 @@
     }
 
     private void beforeSetValue() {
+        Map<String,Fixture_Set_Detail__c> fsdMap = new Map<String,Fixture_Set_Detail__c>();
         for (Fixture_Set_Detail__c nObj : newList) {
             nObj.Name_CHN_Created__c = nObj.Name_CHN__c;
+            // 20230727 ljh 备品类型I和备品类型II放到保有设备上显示 start
+            if(nObj.Loaner_category__c){
+                fsdMap.put(nObj.Fixture_Model_No_F__c,nObj);
+            }
         }
+        // 20230727 ljh 备品类型I和备品类型II放到保有设备上显示 start
+        if(fsdMap.size() > 0){
+            List<Product2>  Product2List = [SELECT Id,Fixture_Model_No_T__c,Loaner_categoryI__c,Loaner_categoryII__c 
+                                                 FROM Product2 
+                                                WHERE Fixture_Model_No_T__c IN :fsdMap.keySet()];
+            if(Product2List.size() > 0){
+                Map<String,Product2> updateMap = new Map<String,Product2>();
+                for(Product2 pro:Product2List){
+                    Product2 p2 = new Product2();
+                    p2.Id = pro.Id;
+                    p2.Loaner_categoryI__c = fsdMap.get(pro.Fixture_Model_No_T__c).Loaner_categoryI__c;
+                    p2.Loaner_categoryII__c =fsdMap.get(pro.Fixture_Model_No_T__c).Loaner_categoryII__c;
+                    if(((String.isNotBlank(p2.Loaner_categoryI__c) && p2.Loaner_categoryI__c.equals(pro.Loaner_categoryI__c)) || (String.isBlank(p2.Loaner_categoryI__c)&&String.isBlank(pro.Loaner_categoryI__c)))
+                        && ((String.isNotBlank(p2.Loaner_categoryII__c) && p2.Loaner_categoryII__c.equals(pro.Loaner_categoryII__c)) || (String.isBlank(p2.Loaner_categoryII__c)&&String.isBlank(pro.Loaner_categoryII__c)))){
+                        continue;
+                    }
+                    updateMap.put(pro.Id,p2);
+                }
+                if(updateMap.size() > 0){
+                    update updateMap.values();
+                }
+            }
+        }
+        // 20230727 ljh 备品类型I和备品类型II放到保有设备上显示 start
     }
 }
\ No newline at end of file

--
Gitblit v1.9.1