| | |
| | | // Check本部是否可以选择 |
| | | // checkbenbu(); |
| | | setRental_Apply_Consum_ApplyId(); |
| | | decryptInsert(newList);//Dennis updated for pi |
| | | } |
| | | protected override void beforeUpdate() { |
| | | checkOneConsumApplyForQIS(); |
| | |
| | | update raess; |
| | | } |
| | | } |
| | | //Dennis updated for pi start |
| | | public static void decryptInsert(List<Consum_Apply__c> newList){ |
| | | if(!system.isFuture()){ |
| | | List<Consum_Apply__c> fendanList = new List<Consum_Apply__c>(); |
| | | for(Consum_Apply__c ra : newList){ |
| | | if(ra.Old_Consum_Apply__c != null){ |
| | | fendanList.add(ra); |
| | | } |
| | | } |
| | | |
| | | if(fendanList.size() == 0){ |
| | | system.debug('no need split'); |
| | | return; |
| | | } |
| | | |
| | | //zhj MEBG新方案改造 2022-12-01 start |
| | | //decryptInsertFuture(JSON.serialize(fendanList)); |
| | | Map<String,PIHelper.PIIntegration> staticResource = new Map<String,PIHelper.PIIntegration>(); |
| | | staticResource.put('Consum_Apply__c',PIHelper.getPIIntegrationInfo('Consum_Apply__c')); |
| | | Map<String, Map<String, PI_Field_Policy_Detail__c>> mmsp = new Map<String, Map<String,PI_Field_Policy_Detail__c>>(); |
| | | for (String key : staticResource.keySet()) { |
| | | mmsp.put(key, new Map<String,PI_Field_Policy_Detail__c>()); |
| | | for (PI_Field_Policy_Detail__c detail : staticResource.get(key).PIDetails) { |
| | | mmsp.get(key).put(detail.SF_Field_API_Name__c, detail); |
| | | } |
| | | } |
| | | System.debug('mmsp = ' + mmsp); |
| | | |
| | | |
| | | List<AWSServiceTool2V2.EncryptPushRequestBody> EncryptPushList = new List<AWSServiceTool2V2.EncryptPushRequestBody>(); |
| | | for(Consum_Apply__c ac : fendanList){ |
| | | Consum_Apply__c oldAc = [select id,AWS_Data_Id__c from Consum_Apply__c where id=:ac.Old_Consum_Apply__c]; |
| | | AWSServiceTool2V2.EncryptPushRequestBody EncryptPush = new AWSServiceTool2V2.EncryptPushRequestBody(); |
| | | EncryptPush.dataId = ac.AWS_Data_Id__c != null ?ac.AWS_Data_Id__c:''; |
| | | EncryptPush.sfRecordId = ac.Id; |
| | | EncryptPush.fieldsMapping = new Map<String, List<AWSServiceTool2V2.EncryptPushRes>>(); |
| | | List<AWSServiceTool2V2.EncryptPushRes> resList = new List<AWSServiceTool2V2.EncryptPushRes>(); |
| | | AWSServiceTool2V2.EncryptPushRes res= new AWSServiceTool2V2.EncryptPushRes(); |
| | | res.isQueryDb = true; |
| | | res.value = ''; |
| | | res.table = staticResource.get('Consum_Apply__c').awsTableName; |
| | | //res.dataId = ac.Old_Consum_Apply__r.AWS_Data_Id__c; |
| | | res.dataId = oldAc.AWS_Data_Id__c; |
| | | res.field = mmsp.get('Consum_Apply__c').get('direct_shippment_address__c').AWS_Field_API__c; |
| | | resList.add(res); |
| | | |
| | | List<AWSServiceTool2V2.EncryptPushRes> resList2 = new List<AWSServiceTool2V2.EncryptPushRes>(); |
| | | AWSServiceTool2V2.EncryptPushRes res2= new AWSServiceTool2V2.EncryptPushRes(); |
| | | res2.isQueryDb = true; |
| | | res2.value = ''; |
| | | res2.table = staticResource.get('Consum_Apply__c').awsTableName; |
| | | //res2.dataId = ac.Old_Consum_Apply__r.AWS_Data_Id__c; |
| | | res2.dataId = oldAc.AWS_Data_Id__c; |
| | | res2.field = mmsp.get('Consum_Apply__c').get('Phone_number__c').AWS_Field_API__c; |
| | | resList2.add(res2); |
| | | |
| | | EncryptPush.fieldsMapping.put(mmsp.get('Consum_Apply__c').get('direct_shippment_address__c').AWS_Field_API__c, resList); |
| | | EncryptPush.fieldsMapping.put(mmsp.get('Consum_Apply__c').get('Phone_number__c').AWS_Field_API__c, resList2); |
| | | EncryptPushList.add(EncryptPush); |
| | | } |
| | | System.debug('EncryptPushListdataId = ' + JSON.serialize(EncryptPushList[0].dataId)); |
| | | System.debug('EncryptPushListsfRecordId = ' + JSON.serialize(EncryptPushList[0].sfRecordId)); |
| | | System.debug('EncryptPushListfieldsMapping = ' + JSON.serialize(EncryptPushList[0].fieldsMapping)); |
| | | System.debug('EncryptPushList = ' + JSON.serialize(EncryptPushList)); |
| | | AwsServiceTool2V2.EncryptPushFutureV2(Json.serialize(EncryptPushList),Json.serialize(fendanList), 'Consum_Apply__c'); |
| | | //zhj MEBG新方案改造 2022-12-01 end |
| | | } |
| | | } |
| | | |
| | | @future(callout=true) |
| | | public static void decryptInsertFuture(string json_list){ |
| | | decryptInsertCore(json_list); |
| | | } |
| | | |
| | | // List<Consum_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 Consum_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('Consum_Apply__c'); |
| | | system.debug('staticResource.token='+staticResource.token); |
| | | if(String.isBlank(staticResource.token)){ |
| | | System.debug('获取aws token 失败'); |
| | | return; |
| | | } |
| | | List<Consum_Apply__c> newList = (List<Consum_Apply__c>)Json.deserialize(json_list, List<Consum_Apply__c>.class); |
| | | Map<Id,Consum_Apply__c> newMap = new Map<Id,Consum_Apply__c>(newList); |
| | | List<Map<string,object>> lmso = new List<Map<string,object>>(); |
| | | for(Consum_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<Consum_Apply__c> updateList = new List<Consum_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)){ |
| | | Consum_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; |
| | | } |
| | | |
| | | } |
| | | //Dennis updated for pi end |
| | | |
| | | // From ConsumApplyApprovalProcess.trigger TODO test |
| | | private void approvalCheck() { |
| | |
| | | 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++; |
| | | 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++; |
| | | 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++; |
| | | 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++; |
| | | 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++; |
| | | } |
| | | } |