From d8dc84a3d56df839895f1c417a4d9cbee763d262 Mon Sep 17 00:00:00 2001
From: 高章伟 <gaozhangwei@prec-tech.com>
Date: 星期五, 03 三月 2023 14:50:59 +0800
Subject: [PATCH] gzw 测试环境代码更新

---
 force-app/main/default/classes/NewAndEditBaseController.cls |   61 ++++++++++++++++++++++++++++--
 1 files changed, 57 insertions(+), 4 deletions(-)

diff --git a/force-app/main/default/classes/NewAndEditBaseController.cls b/force-app/main/default/classes/NewAndEditBaseController.cls
index 6474e93..91bbe90 100644
--- a/force-app/main/default/classes/NewAndEditBaseController.cls
+++ b/force-app/main/default/classes/NewAndEditBaseController.cls
@@ -31,7 +31,9 @@
         get{
             Map<string,string> temp = new Map<string,string>();
             temp.putAll(AWSToSobjectNonEncryptedMap);
-            temp.putAll(AWSToSobjectEncryptedMap);
+            //zhj MEBG鏂版柟妗堟敼閫� 2022-11-29 start
+            //temp.putAll(AWSToSobjectEncryptedMap);
+            //zhj MEBG鏂版柟妗堟敼閫� 2022-11-29 end
             return temp;
         }
     }
@@ -198,7 +200,13 @@
         Map<String, Schema.SObjectField> fieldAPIToTypeMap = leadSchema.getDescribe().fields.getMap();
         Map<String,Object> fieldValueMap = (Map<String,Object>)JSON.deserializeUntyped(leadJson);
         
-
+        system.debug('enter Foo');
+        string rtid = null;
+        if (fieldValueMap.containsKey('RecordTypeId')) {
+            rtid = String.valueOf(fieldValueMap.get('RecordTypeId'));
+        }
+        List<string> invalid_fields = GetInvalidFieldFromLayout(rtid,sobjectTypeValue);
+		
         Boolean isClone = false;
         //2. Save Record Process
         String status = 'success';    
@@ -210,6 +218,12 @@
             
             for (String fieldAPI: fieldValueMap.keySet()) {
                 system.debug('field API='+fieldAPI);
+                
+                if(invalid_fields.contains(fieldAPI)){
+                    system.debug(fieldAPI+' is invalid');
+                    continue;
+                }
+                
                 if(!fieldAPIToTypeMap.containskey(fieldAPI)){
                     continue;
                 }
@@ -252,7 +266,7 @@
                 isClone = sobjects.size() == 0;
             }
             System.debug('isNew---------'+isNew);
-            
+                       
             if(isNew || isClone){
                 System.debug('leadInfozhj = ' + leadInfo);
                 if(!Test.isRunningTest()){
@@ -305,11 +319,50 @@
             System.debug('into catch'+e.getMessage());
             Database.rollback(sp);
             resp.status = 'Exception';
-            resp.message = e.getMessage()+e.getStackTraceString();
+            //resp.message = e.getMessage()+e.getStackTraceString();
+            System.debug('閿欒:' + e.getMessage()+e.getStackTraceString());
+            resp.message = e.getMessage();
             PIHelper.saveTransLog(sobjectTypeValue,awsDataId,leadInfo.Id,transId, leadJson ,status,resp.message);
             // PIHelper.saveTransLog(sobjectTypeValue,(String)leadInfo.get('AWS_Data_Id__c'),transId, leadJson,status,e.getStackTraceString());
             return resp;
         }
     }
     
+    public static List<string> GetInvalidFieldFromLayout(string rtid, string sobject_name){
+        List<string> ls = new List<string>();
+        string[] only_type = new string[]{'QIS_Report__c'};
+        if(!only_type.contains(sobject_name)){
+            system.debug('not allow');
+            return ls;
+        }
+        
+        List<Metadata.LayoutSection> sections = MetaDataUtility.GetRecordTypePageLayout(rtid, sobject_name);
+        
+        if (sections == null) {
+            System.debug('sections=null');
+            return ls;
+        }
+        
+        system.debug(Json.serialize(sections));
+        
+        for (Metadata.LayoutSection section : sections) {
+            if (section.layoutColumns != null) {
+                for (Metadata.LayoutColumn layoutColumn : section.layoutColumns) {
+                    if(layoutColumn.layoutItems != null){
+                        for (Metadata.LayoutItem item : layoutColumn.layoutItems) {
+            
+                            System.debug(item);
+                            if(item.field==null)continue;
+                            if (item.behavior == Metadata.UiBehavior.READONLY  ) {
+                                ls.add(item.field);
+                            }
+                        }
+                    }
+                    
+                }
+            }
+            
+        }
+        return ls;
+    }
 }
\ No newline at end of file

--
Gitblit v1.9.1