| | |
| | | } |
| | | protected override void afterInsert() { |
| | | // Check本部是否可以选择 |
| | | checkbenbu(); |
| | | checkbenbu();// 20220909 ljh 恢复代码 |
| | | // 共享设定 |
| | | setShare(); |
| | | |
| | | decryptInsert(newList); |
| | | } |
| | | protected override void beforeUpdate() { |
| | | setManager(); |
| | |
| | | |
| | | protected override void afterUpdate() { |
| | | // Check本部是否可以选择 |
| | | checkbenbu(); |
| | | checkbenbu();// 20220909 ljh 恢复代码 |
| | | cancelRa(); |
| | | // before では数式項目がnullの場合があります |
| | | formulaToTextCheck(); |
| | |
| | | update raesList; |
| | | } |
| | | } |
| | | |
| | | // 20220909 ljh 恢复代码 |
| | | private void checkbenbu() { |
| | | for (Rental_Apply__c nObj : newList) { |
| | | if (nObj.DataMigration_Flag__c == false) { |
| | |
| | | RentalApplyTriggerHandler.doUnlockByFuture(raIdList); |
| | | } |
| | | } |
| | | |
| | | public static void decryptInsert(List<Rental_Apply__c> newList){ |
| | | if(!system.isFuture()){ |
| | | List<Rental_Apply__c> fendanList = new List<Rental_Apply__c>(); |
| | | for(Rental_Apply__c ra : newList){ |
| | | if(ra.Old_Rental_Apply__c != null){ |
| | | fendanList.add(ra); |
| | | } |
| | | } |
| | | |
| | | if(fendanList.size() == 0){ |
| | | system.debug('no need split'); |
| | | return; |
| | | } |
| | | |
| | | decryptInsertFuture(JSON.serialize(fendanList)); |
| | | } |
| | | } |
| | | |
| | | @future(callout=true) |
| | | public static void decryptInsertFuture(string json_list){ |
| | | decryptInsertCore(json_list); |
| | | } |
| | | |
| | | // List<Rental_Apply__c> temps = [select id,AWS_Data_Id__c,name, direct_shippment_address__c, Direct_Shippment_Address_Encrypt__c, Phone_number__c, Phone_Number_Encrypt__c,CreatedDate from Rental_Apply__c where AWS_Data_Id__c != null order by CreatedDate desc limit 2]; |
| | | public static void decryptInsertCore(string json_list){ |
| | | system.debug('enter decryptInsertCore'); |
| | | //调用滨璜接口更新 |
| | | PIHelper.PIIntegration staticResource = PIHelper.getPIIntegrationInfo('Rental_Apply__c'); |
| | | system.debug('staticResource.token='+staticResource.token); |
| | | if(String.isBlank(staticResource.token)){ |
| | | System.debug('获取aws token 失败'); |
| | | return; |
| | | } |
| | | List<Rental_Apply__c> newList = (List<Rental_Apply__c>)Json.deserialize(json_list, List<Rental_Apply__c>.class); |
| | | Map<Id,Rental_Apply__c> newMap = new Map<Id,Rental_Apply__c>(newList); |
| | | List<Map<string,object>> lmso = new List<Map<string,object>>(); |
| | | for(Rental_Apply__c ra : newList){ |
| | | Map<string,object> mso = new Map<string,object>(); |
| | | |
| | | /*if(!string.isBlank(ra.AWS_Data_Id__c)){ |
| | | continue; |
| | | }*/ |
| | | for(PI_Field_Policy_Detail__c detail : staticResource.PIDetails){ |
| | | if(ra.isSet(detail.SF_Field_API_Name__c)){ |
| | | mso.put(detail.AWS_Field_API__c,ra.get(detail.SF_Field_API_Name__c)); |
| | | mso.put(detail.AWS_Encrypted_Field_API__c,ra.get(detail.SF_Field_Encrypted_API__c)); |
| | | } |
| | | } |
| | | mso.put('sfRecordId',ra.Id); |
| | | lmso.add(mso); |
| | | } |
| | | |
| | | if(lmso.size()==0){ |
| | | system.debug('lmso.size()='+lmso.size()); |
| | | return; |
| | | } |
| | | string payload = Json.serialize(lmso); |
| | | system.debug('payload='+payload); |
| | | String awsApi = staticResource.viewUnifiedContactUrl; |
| | | NFMUtil.response response = NFMUtil.sendToPiAWS(payload, awsApi,staticResource.token); |
| | | system.debug(response); |
| | | Map<string,object> res_obj = (Map<string,object>)Json.deserializeUntyped(response.responseBody); |
| | | if(res_obj == null || !res_obj.containsKey('object') ){ |
| | | System.debug('res_obj == null || !res_obj.containsKey(\'object\')'); |
| | | return; |
| | | } |
| | | |
| | | List<object> objList = (List<object>)res_obj.get('object'); |
| | | if(objList == null){ |
| | | System.debug('objList == null'); |
| | | return; |
| | | } |
| | | |
| | | List<Rental_Apply__c> updateList = new List<Rental_Apply__c>(); |
| | | for(object obj : objList){ |
| | | Map<string,object> obj_map = (Map<string,object>)obj; |
| | | string sfRecordId = null; |
| | | string dataId = null; |
| | | if(obj_map.containsKey('sfRecordId')){ |
| | | sfRecordId = string.valueOf(obj_map.get('sfRecordId')); |
| | | }else{ |
| | | system.debug('obj_map.containsKey(\'sfRecordId\')='+obj_map.containsKey('sfRecordId')); |
| | | continue; |
| | | } |
| | | |
| | | if(obj_map.containsKey('dataId')){ |
| | | dataId = string.valueOf(obj_map.get('dataId')); |
| | | }else{ |
| | | system.debug('obj_map.containsKey(\'dataId\')='+obj_map.containsKey('dataId')); |
| | | continue; |
| | | } |
| | | |
| | | |
| | | if(newMap.containsKey(sfRecordId)){ |
| | | Rental_Apply__c ra = newMap.get(sfRecordId); |
| | | ra.AWS_Data_Id__c = dataId; |
| | | updateList.add(ra); |
| | | }else{ |
| | | system.debug('newMap.containsKey('+sfRecordId+')='+newMap.containsKey(sfRecordId)); |
| | | continue; |
| | | } |
| | | } |
| | | |
| | | system.debug('updateList.size='+updateList.size()); |
| | | if(updateList.size()>0){ |
| | | update updateList; |
| | | } |
| | | |
| | | } |
| | | |
| | | @future |
| | | public static void doUnlockByFuture(List<ID> idList) { |