Li Jun
2022-03-24 f127c76b19f5316032d4bed127a1dde710c48d74
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);