| | |
| | | */ |
| | | 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 List<LayoutDescriberHelper.LayoutSection> layoutSections { get; set; } |
| | | public String awsToken { get; set; } |
| | | public static Map<String, Schema.SObjectType> schemaMap = Schema.getGlobalDescribe(); |
| | | public static String sobjectTypeValue = 'Repair__c'; |
| | | public Boolean isNewMode{set;get;} |
| | | public Boolean isNewMode { get; set; } |
| | | public String rtTypeId {get; set;} |
| | | public String AWSDataId{set;get;} |
| | | public String DecryptAWSDataId{set;get;} |
| | | public String ContactAWSDataId{set;get;} |
| | | public List<String> encryptedAPIList{set;get;} |
| | | public String AWSDataId { get; set; } |
| | | public String DecryptAWSDataId { get; set; } |
| | | public String ContactAWSDataId { get; set; } |
| | | public List<String> encryptedAPIList { get; set; } |
| | | public String staticResource {get; set;} |
| | | public String staticResourceContact {get; set;} |
| | | public String staticResourceAddress {get; set;} |
| | | public String requiredFieldAPIListStr {get; set;} |
| | | public String fieldAPIToLabelMapStr {get; set;} |
| | | public String Input_Required_Field_Msg{set;get;} |
| | | public String PIPL_Name_Label{set;get;} |
| | | public String PIPL_Input_Account_Error_Msg{set;get;} |
| | | public String sobjectPrefix{set;get;} |
| | | public String sobjecttypeForFrontEnd{set;get;} |
| | | public String sobjectId{set;get;} |
| | | public String workLocationSelect{set;get;} |
| | | public String RepairSubOrderAWSDataId{set;get;} |
| | | public String staticResourceRepairSubOrder{set;get;} |
| | | public String Input_Required_Field_Msg { get; set; } |
| | | public String PIPL_Name_Label { get; set; } |
| | | public String PIPL_Input_Account_Error_Msg { get; set; } |
| | | public String sobjectPrefix { get; set; } |
| | | public String sobjecttypeForFrontEnd { get; set; } |
| | | public String sobjectId { get; set; } |
| | | public String workLocationSelect { get; set; } |
| | | public String RepairSubOrderAWSDataId { get; set; } |
| | | public String staticResourceRepairSubOrder { get; set; } |
| | | public String VLookUpFieldsJson{get;private set;} |
| | | //zhj MEBG新方案改造 2022-11-29 start |
| | | public String staticResourceV2 {get; set;} |
| | | //zhj MEBG新方案改造 2022-11-29 end |
| | | public NewRepairController(ApexPages.StandardController controller) { |
| | | sobjectId = [SELECT CustomObjectId,CustomObjectName FROM CustomObjectUserLicenseMetrics where CustomObjectName ='Repair' limit 1].CustomObjectId; |
| | | //sobjectId = [SELECT CustomObjectId,CustomObjectName FROM CustomObjectUserLicenseMetrics where CustomObjectName ='Repair' limit 1].CustomObjectId; |
| | | sobjectId = [SELECT id, QualifiedApiName, DurableId, IsCustomizable FROM EntityDefinition WHERE QualifiedApiName = 'Repair__c'] |
| | | .DurableId; |
| | | isNewMode = true; |
| | | Input_Required_Field_Msg = Label.Input_Required_Field_Msg; |
| | | PIPL_Name_Label = Label.PIPL_Name_Label; |
| | |
| | | if(obj.Id != null){ |
| | | //更新 |
| | | isNewMode = false; |
| | | Repair__c repairData = [select Id,RecordTypeId,AWS_Data_Id__c,Address_AWS_Data_Id__c,Contact_AWS_Data_Id__c,Address_Contacts_Encrypt__c,Address_Contacts_Name_Encrypt__c,Address_Telephone_Encrypt__c,Address_ZipCode_Encrypt__c,Detailed_Address_Encrypt__c from Repair__c where id =: obj.Id]; |
| | | Repair__c repairData = [ |
| | | SELECT |
| | | Id, |
| | | RecordTypeId, |
| | | AWS_Data_Id__c, |
| | | Address_AWS_Data_Id__c, |
| | | Contact_AWS_Data_Id__c, |
| | | Address_Contacts_Encrypt__c, |
| | | Address_Contacts_Name_Encrypt__c, |
| | | Address_Telephone_Encrypt__c, |
| | | Address_ZipCode_Encrypt__c, |
| | | Detailed_Address_Encrypt__c |
| | | FROM Repair__c |
| | | WHERE id = :obj.Id |
| | | ]; |
| | | rtTypeId = repairData.RecordTypeId; |
| | | AWSDataId = repairData.AWS_Data_Id__c; |
| | | DecryptAWSDataId = String.valueOf(repairData.Address_AWS_Data_Id__c); |
| | |
| | | // if(mso.containsKey('00N10000006P1dw')){ |
| | | // controller.getRecord().put('PaperRepairRequestNo__c',mso.get('00N10000006P1dw')); |
| | | // } |
| | | |
| | | |
| | | |
| | | // //市场多年保修 有偿/无偿修理00N10000008rG4p |
| | | // if(mso.containsKey('00N10000008rG4p')){ |
| | |
| | | String repairSubOrderId = mso.get('CF00N10000009H1rR_lkid'); |
| | | System.debug('repairSubOrderId = ' + repairSubOrderId); |
| | | //查询AWSDataId |
| | | List<RepairSubOrder__c> rso = [select AWS_Data_Id__c from RepairSubOrder__c where Id=:repairSubOrderId]; |
| | | List<RepairSubOrder__c> rso = [SELECT AWS_Data_Id__c FROM RepairSubOrder__c WHERE Id = :repairSubOrderId]; |
| | | if(rso.size() > 0){ |
| | | RepairSubOrderAWSDataId = rso[0].AWS_Data_Id__c; |
| | | } |
| | |
| | | if (mso.containsKey('retURL')) { |
| | | String RepairId = mso.get('retURL').substring(1); |
| | | System.debug('RepairId = ' + RepairId); |
| | | rc = [select Hospital__c,Department_Class__c,Account__c,Dealer__c,Incharge_Staff_Contact__c,Incharge_Staff__c, RepairSubOrder__c,On_Call_ID__c,QIS_ID__c, InsReport__c,Rental_Apply_Equipment_Set_Detail__c from Repair__c where id =:RepairId ]; |
| | | rc = [ |
| | | SELECT |
| | | Hospital__c, |
| | | Department_Class__c, |
| | | Account__c, |
| | | Dealer__c, |
| | | Incharge_Staff_Contact__c, |
| | | Incharge_Staff__c, |
| | | RepairSubOrder__c, |
| | | On_Call_ID__c, |
| | | QIS_ID__c, |
| | | InsReport__c, |
| | | Rental_Apply_Equipment_Set_Detail__c |
| | | FROM Repair__c |
| | | WHERE id = :RepairId |
| | | ]; |
| | | System.debug('rc = ' + rc); |
| | | if(rc.size() > 0){ |
| | | //医院 |
| | |
| | | //报修子单RepairSubOrder__c |
| | | controller.getRecord().put('RepairSubOrder__c',rc[0].RepairSubOrder__c); |
| | | //查询AWSDataId |
| | | List<RepairSubOrder__c> rso = [select AWS_Data_Id__c from RepairSubOrder__c where Id=:rc[0].RepairSubOrder__c]; |
| | | List<RepairSubOrder__c> rso = [SELECT AWS_Data_Id__c FROM RepairSubOrder__c WHERE Id = :rc[0].RepairSubOrder__c]; |
| | | if(rso.size() > 0){ |
| | | RepairSubOrderAWSDataId = rso[0].AWS_Data_Id__c; |
| | | } |
| | |
| | | //借出备品配套一览明细Rental_Apply_Equipment_Set_Detail__c |
| | | controller.getRecord().put('Rental_Apply_Equipment_Set_Detail__c',rc[0].Rental_Apply_Equipment_Set_Detail__c); |
| | | } |
| | | |
| | | } |
| | | |
| | | rtTypeId = ApexPages.currentPage().getParameters().get('RecordType'); |
| | | if(String.isBlank(rtTypeId)||String.isEmpty(rtTypeId)){ |
| | | List<RecordType> rtList = new List<RecordType>([select Id,DeveloperName from RecordType where SobjectType ='Repair__c' and DeveloperName ='Repair']); |
| | | List<RecordType> rtList = new List<RecordType>( |
| | | [SELECT Id, DeveloperName FROM RecordType WHERE SobjectType = 'Repair__c' AND DeveloperName = 'Repair'] |
| | | ); |
| | | rtTypeId = rtList[0].Id; |
| | | } |
| | | } |
| | | LayoutDescriberHelper.LayoutWrapper LayoutWrapperValue = LayoutDescriberHelper.describeSectionWithFieldsWrapper(rtTypeId, 'Repair__c','classic'); |
| | | 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; |
| | |
| | | } |
| | | |
| | | global class Response{ |
| | | public String recordId{set;get;} |
| | | public String message{set;get;} |
| | | public String status{set;get;} |
| | | public String recordId { get; set; } |
| | | public String message { get; set; } |
| | | public String status { get; set; } |
| | | } |
| | | |
| | | @RemoteAction |
| | |
| | | reps.add(new Repair__c(Id='a0J1m000001QqXk',Encrypt_Update_Flag__c=false)); |
| | | } |
| | | }else{ |
| | | reps = [select id,Encrypt_Update_Flag__c from Repair__c where id =:rid]; |
| | | reps = [SELECT id, Encrypt_Update_Flag__c FROM Repair__c WHERE id = :rid]; |
| | | } |
| | | if(reps.size()==0){ |
| | | r.status = 'failed'; |
| | |
| | | Schema.DisplayType fielddataType = fieldAPIToTypeMap.get(fieldAPI).getDescribe().getType(); |
| | | String fieldValue = String.valueOf(fieldValueMap.get(fieldAPI)); |
| | | if(String.valueOf(fielddataType)=='DATE'){ |
| | | repairInfo.put(fieldAPI,(String.isBlank(fieldValue)||String.isEmpty(fieldValue))? null:Date.valueOf(fieldValue.replace('/', '-'))); |
| | | repairInfo.put( |
| | | fieldAPI, |
| | | (String.isBlank(fieldValue) || String.isEmpty(fieldValue)) ? null : Date.valueOf(fieldValue.replace('/', '-')) |
| | | ); |
| | | }else if(String.valueOf(fielddataType)=='DATETIME'){ |
| | | if(String.isNotBlank(fieldValue)&&fieldValue.contains('T')){ |
| | | fieldValue = fieldValue.replace('T',' '); |
| | |
| | | }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, (String.isBlank(fieldValue)||String.isEmpty(fieldValue))?null:Decimal.valueOf(fieldValue.replace(',', ''))); |
| | | } else if ( |
| | | String.valueOf(fielddataType) == 'PERCENT' || |
| | | String.valueOf(fielddataType) == 'CURRENCY' || |
| | | String.valueOf(fielddataType) == 'Number' || |
| | | String.valueOf(fielddataType) == 'DOUBLE' |
| | | ) { |
| | | repairInfo.put( |
| | | fieldAPI, |
| | | (String.isBlank(fieldValue) || String.isEmpty(fieldValue)) ? null : Decimal.valueOf(fieldValue.replace(',', '')) |
| | | ); |
| | | } else if(String.valueof(fielddataType)=='BOOLEAN'){ |
| | | //check repair check value |
| | | if(fieldAPI == 'Return_Without_Repair__c'&&Boolean.valueof(fieldValueMap.get(fieldAPI))){ |
| | |
| | | System.debug('into update'); |
| | | String awsDataId = (String)repairInfo.get('AWS_Data_Id__c'); |
| | | System.debug('awsDataId = ' + awsDataId); |
| | | Repair__c[] repairs = [select id,Return_Without_Repair_Reason__c,SAP_Transfer_time__c from Repair__c where AWS_Data_Id__c =:awsDataId]; |
| | | Repair__c[] repairs = [ |
| | | SELECT id, Return_Without_Repair_Reason__c, SAP_Transfer_time__c |
| | | FROM Repair__c |
| | | WHERE AWS_Data_Id__c = :awsDataId |
| | | ]; |
| | | if(!updateRepairCheck){ |
| | | repairInfo.put('Return_Without_Repair_Reason__c',repairs[0].Return_Without_Repair_Reason__c); |
| | | } |
| | |
| | | resp.status = status; |
| | | System.debug('resp from sfdx back-end' + resp); |
| | | return resp; |
| | | |
| | | } catch(DmlException e) { |
| | | rid=repairInfo.Id; |
| | | Integer index = 0; |
| | |
| | | Database.rollback(sp); |
| | | resp.status = 'Exception'; |
| | | resp.message ='保存失败,原因:'+ e.getDmlMessage(index); |
| | | PIHelper.saveTransLog(sobjectTypeValue,(String)repairInfo.get('AWS_Data_Id__c'),rid,transId, repairJson ,status,e.getMessage()+e.getStackTraceString()); |
| | | PIHelper.saveTransLog( |
| | | sobjectTypeValue, |
| | | (String) repairInfo.get('AWS_Data_Id__c'), |
| | | rid, |
| | | transId, |
| | | repairJson, |
| | | status, |
| | | e.getMessage() + e.getStackTraceString() |
| | | ); |
| | | return resp; |
| | | |
| | | } catch(Exception e) { |
| | | System.debug('into catch'+e.getMessage()); |
| | | Database.rollback(sp); |
| | | status = 'fail'; |
| | | PIHelper.saveTransLog(sobjectTypeValue,(String)repairInfo.get('AWS_Data_Id__c'),rid,transId, repairJson ,status,e.getMessage()+e.getStackTraceString()); |
| | | PIHelper.saveTransLog( |
| | | sobjectTypeValue, |
| | | (String) repairInfo.get('AWS_Data_Id__c'), |
| | | rid, |
| | | transId, |
| | | repairJson, |
| | | status, |
| | | e.getMessage() + e.getStackTraceString() |
| | | ); |
| | | resp.message = e.getMessage(); |
| | | resp.status = status; |
| | | return resp; |
| | |
| | | |
| | | // 从url参数赋值到当前页面 |
| | | public static void AssignValueFromUrl(Map<string,string> mso, sobject sobj){ |
| | | |
| | | String sobject_name = sobj.getSObjectType().getDescribe().getName(); |
| | | Map<string,object> temp = new Map<string,object>(); |
| | | Map<string,FieldDefinition> fdm = new Map<string,FieldDefinition>(); |
| | | List<FieldDefinition> fds = [SELECT Id, DurableId, QualifiedApiName,ValueTypeId , EntityDefinitionId, NamespacePrefix,EntityDefinition.NamespacePrefix, DeveloperName, MasterLabel, Label FROM FieldDefinition where EntityDefinition.QualifiedApiName = :sobject_name]; |
| | | List<FieldDefinition> fds = [ |
| | | SELECT |
| | | Id, |
| | | DurableId, |
| | | QualifiedApiName, |
| | | ValueTypeId, |
| | | EntityDefinitionId, |
| | | NamespacePrefix, |
| | | EntityDefinition.NamespacePrefix, |
| | | DeveloperName, |
| | | MasterLabel, |
| | | Label |
| | | FROM FieldDefinition |
| | | WHERE EntityDefinition.QualifiedApiName = :sobject_name |
| | | ]; |
| | | for(FieldDefinition fd : fds){ |
| | | //system.debug(fd.DurableId); |
| | | fdm.put(fd.DurableId.split('\\.')[1],fd); |
| | |
| | | system.debug(ee.getStackTraceString()); |
| | | continue; |
| | | } |
| | | |
| | | }else if(type_id == 'id' || type_id == 'string'){ |
| | | val = val_str; |
| | | }else{ |