| | |
| | | public final string ApiPrefix{get;private set;} //Add By Li Jun 20220403 |
| | | public Map<string,string> AWSToSobjectEncryptedMap{get;private set;} |
| | | public string AWSToSobjectEncryptedMapJson{get{return JSON.serialize(AWSToSobjectEncryptedMap);}} |
| | | //zhj MEBG新方案改造 2022-11-29 start |
| | | public String staticResourceV2 {get; set;} |
| | | public Boolean isEdit {get; set;} |
| | | //zhj MEBG新方案改造 2022-11-29 end |
| | | |
| | | public RentalApplyController(ApexPages.StandardController controller) { |
| | | ApiPrefix = 'PIBackApi'; |
| | | isNewMode = true; |
| | |
| | | if(obj.Id != null){ |
| | | //更新 |
| | | isNewMode = false; |
| | | Rental_Apply__c rentalApplyData = [select Id,RecordTypeId,AWS_Data_Id__c,Loaner_medical_Staff__c,Loaner_medical_Staff__r.AWS_Data_Id__c from Rental_Apply__c where id =: obj.Id]; |
| | | Rental_Apply__c rentalApplyData = [select Id,RecordTypeId,AWS_Data_Id__c,Loaner_medical_Staff__c,Loaner_medical_Staff__r.AWS_Data_Id__c,status__c,Add_Approval_Status__c from Rental_Apply__c where id =: obj.Id]; |
| | | rtTypeId = rentalApplyData.RecordTypeId; |
| | | //Update record type for Rental Apply by Li Jun 20220419 start |
| | | if(ApexPages.currentPage().getParameters().containskey('RecordType')){ |
| | |
| | | sfIdToAWSIdMap.put(String.valueof(rentalApplyData.Loaner_medical_Staff__r.Id).subString(0,15),rentalApplyData.Loaner_medical_Staff__r.AWS_Data_Id__c); |
| | | } |
| | | contactsInfo = JSON.serialize(sfIdToAWSIdMap); |
| | | |
| | | //zhj MEBG新方案改造 2022-11-29 start |
| | | User loginUser = [Select Id, Name, ProfileId From User where Id = :Userinfo.getUserId()]; |
| | | isEdit = false; |
| | | if(rentalApplyData.status__c != '草案中' |
| | | && rentalApplyData.status__c != '填写完毕' |
| | | && rentalApplyData.status__c != '申请中' |
| | | && rentalApplyData.Add_Approval_Status__c != '草案中' |
| | | && rentalApplyData.Add_Approval_Status__c != '填写完毕' |
| | | && rentalApplyData.Add_Approval_Status__c != '申请中' |
| | | && loginUser.ProfileId != '00e10000000Y3o5' |
| | | && loginUser.ProfileId != '00e10000000xnoT' |
| | | && loginUser.ProfileId != '00e10000000xo1D' |
| | | && loginUser.ProfileId != '00e10000000dEQx'){ |
| | | isEdit = true; |
| | | } |
| | | //zhj MEBG新方案改造 2022-11-29 end |
| | | }else{ |
| | | //新建 |
| | | // Map<string,string> mso = ApexPages.currentPage().getParameters(); |
| | |
| | | obj.put('OwnerId',UserInfo.getUserId()); |
| | | } |
| | | |
| | | if(mso.containsKey('00N10000003Mp2H')){ |
| | | system.debug('00N10000003Mp2H='+mso.get('00N10000003Mp2H')); |
| | | controller.getRecord().put('Status__c',mso.get('00N10000003Mp2H')); |
| | | } |
| | | |
| | | if(mso.containsKey('00N10000007oQKh')){ |
| | | system.debug('00N10000007oQKh='+mso.get('00N10000007oQKh')); |
| | | controller.getRecord().put('Split_Apply_Reason__c',mso.get('00N10000007oQKh')); |
| | | } |
| | | AssignValueFromUrl(mso,controller.getRecord()); |
| | | system.debug('Rental Apply Record Type:'+rtTypeId); |
| | | LayoutDescriberHelper.LayoutWrapper LayoutWrapperValue = LayoutDescriberHelper.describeSectionWithFieldsWrapper(rtTypeId, 'Rental_Apply__c','classic'); |
| | | layoutSections = LayoutWrapperValue.layoutSections; |
| | |
| | | AWSToSobjectEncryptedMap = new Map<String,String>(); |
| | | for (PI_Field_Policy_Detail__c PIDetail : piIntegration.PIDetails) { |
| | | AWSToSobjectEncryptedMap.put(PIDetail.AWS_Field_API__c, PIDetail.SF_Field_API_Name__c); |
| | | } |
| | | //zhj MEBG新方案改造 2022-11-29 start |
| | | staticResourceV2 = JSON.serialize(PIHelper.getPIIntegrationInfo('Rental_Apply__cV2')); |
| | | //zhj MEBG新方案改造 2022-11-29 end |
| | | } |
| | | |
| | | public static void AssignValueFromUrl(Map<string,string> mso, sobject sobj){ |
| | | Map<string,object> temp = new Map<string,object>(); |
| | | Map<string,FieldDefinition> fdm = new Map<string,FieldDefinition>(); |
| | | List<FieldDefinition> fds = [SELECT Id, DurableId, QualifiedApiName, EntityDefinitionId, NamespacePrefix, DeveloperName, MasterLabel, Label FROM FieldDefinition where EntityDefinition.QualifiedApiName = 'Rental_Apply__c']; |
| | | for(FieldDefinition fd : fds){ |
| | | //system.debug(fd.DurableId); |
| | | fdm.put(fd.DurableId.split('\\.')[1],fd); |
| | | } |
| | | |
| | | for(string key : mso.keySet()){ |
| | | string new_key = key; |
| | | system.debug('new_key='+new_key); |
| | | if(new_key.contains('_lkid')){ |
| | | new_key = new_key.replace('_lkid', ''); |
| | | new_key = new_key.substring(2); |
| | | }else{ |
| | | if(temp.containsKey(new_key)){ |
| | | continue; |
| | | } |
| | | } |
| | | |
| | | system.debug('now new_key='+new_key); |
| | | if(fdm.containsKey(new_key)){ |
| | | string val = EncodingUtil.urlDecode(mso.get(key),'UTF-8'); |
| | | if(string.isBlank(val)){ |
| | | val = null; |
| | | } |
| | | temp.put(fdm.get(new_key).QualifiedApiName,val); |
| | | }else{ |
| | | system.debug(key+' is not in fdm'); |
| | | } |
| | | } |
| | | |
| | | for(string key : temp.keySet()){ |
| | | system.debug('assign '+key+'='+temp.get(key)); |
| | | try{ |
| | | sobj.put(key, temp.get(key)); |
| | | }catch(Exception e){ |
| | | system.debug(e.getMessage()); |
| | | system.debug(e.getStackTraceString()); |
| | | } |
| | | } |
| | | } |
| | | |
| | |
| | | system.debug(fieldAPIToTypeMap); |
| | | Map<String,Object> fieldValueMap = (Map<String,Object>)JSON.deserializeUntyped(rentalApplyJson); |
| | | Rental_Apply__c rentalApplyInfo = new Rental_Apply__c(); |
| | | String status = 'success'; |
| | | Response resp = new Response(); |
| | | Savepoint sp = Database.setSavepoint(); |
| | | String rid = ''; |
| | | Boolean isClone = false; |
| | | String awsDataId = ''; |
| | | try{ |
| | | //自定义格式转换 |
| | | for (String fieldAPI: fieldValueMap.keySet()) { |
| | | system.debug('field API'+fieldAPI); |
| | |
| | | } |
| | | |
| | | //2. Save Record Process |
| | | String status = 'success'; |
| | | Response resp = new Response(); |
| | | Savepoint sp = Database.setSavepoint(); |
| | | String rid = ''; |
| | | Boolean isClone = false; |
| | | String awsDataId = ''; |
| | | try{ |
| | | |
| | | |
| | | System.debug('abcde'); |
| | | awsDataId = (String)rentalApplyInfo.get('AWS_Data_Id__c'); |
| | | System.debug('awsDataId = ' + awsDataId); |
| | |
| | | return resp; |
| | | } |
| | | } |
| | | |
| | | public static void improveTestReta(){ |
| | | Integer i = 0; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | i++; |
| | | } |
| | | } |