From f127c76b19f5316032d4bed127a1dde710c48d74 Mon Sep 17 00:00:00 2001
From: Li Jun <buli@deloitte.com.cn>
Date: 星期四, 24 三月 2022 10:10:36 +0800
Subject: [PATCH] PIPLFunctionFixBug0324

---
 force-app/main/default/classes/NewRepairController.cls |   31 ++++++++++++++++++++++++++++++-
 1 files changed, 30 insertions(+), 1 deletions(-)

diff --git a/force-app/main/default/classes/NewRepairController.cls b/force-app/main/default/classes/NewRepairController.cls
index e0391de..aae5173 100644
--- a/force-app/main/default/classes/NewRepairController.cls
+++ b/force-app/main/default/classes/NewRepairController.cls
@@ -4,6 +4,7 @@
  *@Date: 2022-03-10 10:26:47
 */
 global without sharing class NewRepairController {
+    public String layoutSectionsStr {get; set;}//for dynamic add readonly attribute
     public List <LayoutDescriberHelper.LayoutSection > layoutSections{set;get;}
     public String awsToken{set;get;}
     public static Map<String, Schema.SObjectType> schemaMap = Schema.getGlobalDescribe();
@@ -55,6 +56,7 @@
         }
         LayoutDescriberHelper.LayoutWrapper LayoutWrapperValue = LayoutDescriberHelper.describeSectionWithFieldsWrapper(rtTypeId, 'Repair__c','classic');
         layoutSections = LayoutWrapperValue.layoutSections;
+        layoutSectionsStr = JSON.serialize(layoutSections); //for dynamic add readonly attribute
         List<String> requiredFieldAPIList = LayoutWrapperValue.requiredFieldAPIList;
         Map<String,String> fieldAPIToLabelMap = LayoutWrapperValue.fieldAPIToLabelMap;
         requiredFieldAPIListStr = JSON.serialize(requiredFieldAPIList);
@@ -98,7 +100,14 @@
                 if(String.isNotBlank(dt)&&dt.contains('T')){
                     dt = dt.replace('T',' ');
                     repairInfo.put(fieldAPI, Datetime.valueOfGmt(dt));
-                }             
+                }else if(String.isNotBlank(dt))  {
+                    dt = dt.replace('/', '-') + ':00';
+                    System.debug('dt = ' + dt);
+                    repairInfo.put(fieldAPI, Datetime.valueOf(dt));
+                }else{
+                    repairInfo.put(fieldAPI, null);
+                }
+                
             }else if(String.valueOf(fielddataType)=='PERCENT'||String.valueOf(fielddataType)=='CURRENCY'||String.valueOf(fielddataType)=='Number'||String.valueOf(fielddataType)=='DOUBLE' ){
                 repairInfo.put(fieldAPI, Decimal.valueOf(String.valueOf(fieldValueMap.get(fieldAPI))));
             } else if(String.valueof(fielddataType)=='BOOLEAN'){
@@ -135,6 +144,26 @@
             System.debug('resp from sfdx back-end' + resp);
             return resp;
 
+        } catch(DmlException e) {
+            rid=repairInfo.Id;
+            Integer index = 0;
+            System.debug(e.getNumDml());
+            System.debug(e.getDmlFields(index));
+            System.debug(e.getDmlId(index));
+            System.debug(e.getDmlIndex(index));
+            System.debug(e.getDmlMessage(index));
+            System.debug(e.getDmlStatusCode(index));
+            System.debug(e.getDmlType(index));
+			system.debug(e.getMessage());
+            system.debug(e.getStackTraceString());
+
+            System.debug('into catch'+e.getMessage());
+            Database.rollback(sp);
+            resp.status = 'Exception';
+            resp.message ='淇濆瓨澶辫触锛屽師鍥�:'+ e.getDmlMessage(index);
+            PIHelper.saveTransLog(sobjectTypeValue,rid,transId, (String)repairInfo.get('AWS_Data_Id__c'),repairJson ,status,'');
+            return resp;
+            
         } catch(Exception e) {
             System.debug('into catch'+e.getMessage());
             Database.rollback(sp);

--
Gitblit v1.9.1