From 8badb57ea2c82557850ad5b39281c3e8714eb119 Mon Sep 17 00:00:00 2001
From: liuyan <liuyan@prec-tech.com>
Date: 星期四, 24 十一月 2022 10:08:31 +0800
Subject: [PATCH] 科室信息漏传SPO问题
---
force-app/main/default/classes/RentalApplyTriggerHandler.cls | 178 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
1 files changed, 174 insertions(+), 4 deletions(-)
diff --git a/force-app/main/default/classes/RentalApplyTriggerHandler.cls b/force-app/main/default/classes/RentalApplyTriggerHandler.cls
index 871a874..c7d60e2 100644
--- a/force-app/main/default/classes/RentalApplyTriggerHandler.cls
+++ b/force-app/main/default/classes/RentalApplyTriggerHandler.cls
@@ -11,6 +11,7 @@
private List<Rental_Apply__c> oldList;
private static Date td = Date.today();
private static Map<Id, Rental_Apply__c> oldRaMap = new Map<Id, Rental_Apply__c>();
+ public static Boolean isFirst = true;
//update wangweipeng 2021/11/25 start
private static Map<String, String> approver_of_Service_DepartmentMap = new Map<String, String>();
@@ -49,9 +50,11 @@
}
protected override void afterInsert() {
// Check鏈儴鏄惁鍙互閫夋嫨
- checkbenbu();
+ checkbenbu();// 20220909 ljh 鎭㈠浠g爜
// 鍏变韩璁惧畾
setShare();
+
+ decryptInsert(newList);
}
protected override void beforeUpdate() {
setManager();
@@ -64,7 +67,7 @@
protected override void afterUpdate() {
// Check鏈儴鏄惁鍙互閫夋嫨
- checkbenbu();
+ checkbenbu();// 20220909 ljh 鎭㈠浠g爜
cancelRa();
// before 銇с伅鏁板紡闋呯洰銇宯ull銇牬鍚堛亴銇傘倞銇俱仚
formulaToTextCheck();
@@ -75,6 +78,15 @@
// 鍙栨秷鐢宠鍗曠殑瀹℃壒
removedProcessRequest();
+ System.debug('---------------newList--------------' + newList);
+
+ // add by lc 2022/11/15 DB202211029119 start
+ if (isFirst) {
+ // 涓讳粠鐢宠鍗曪紝鍙欢涓诲崟鐨勬儏鍐碉紝璧板崟鐙殑澶勭悊閫昏緫锛屽苟涓斿彧鎵ц涓�娆�
+ synchRentalApplyDataMaster();
+ }
+ // add by lc 2022/11/15 DB202211029119 end
+
synchRentalApplyData2();
// 寤舵湡瀹℃壒鍚庨渶瑕佹洿鏂颁竴瑙�
setAppExtensionRaes();
@@ -82,10 +94,50 @@
setShare();
// 鍔炰簨澶勫垎鍗曠殑瑁呮満纭
setAgencyHPReceived();
-
//鎵归噺瀹℃壒鏃讹紝闇�瑕佹妸涓诲崟鍜屼粠鍗曠殑寤舵湡瀛楁淇℃伅鍚屾
synchRentalApplyData();
}
+
+ // add by lc 2022/11/15 DB202211029119 start
+ // 涓讳粠鐢宠鍗曪紝鍙欢涓诲崟鐨勬儏鍐碉紝璧板崟鐙殑澶勭悊閫昏緫
+ private void synchRentalApplyDataMaster() {
+ List<Rental_Apply_Equipment_Set__c> raesList = new List<Rental_Apply_Equipment_Set__c>();
+ // 鎵瑰噯鍙兘涓�鏉′竴鏉$殑鎵瑰噯
+ for (Rental_Apply__c nObj : newList) {
+ Rental_Apply__c oObj = oldMap.get(nObj.Id);
+
+ if (oObj.ExtensionApprovalTime_Initial__c != nObj.ExtensionApprovalTime_Initial__c
+ && nObj.ExtensionApprovalTime_Initial__c != null && oObj.ExtensionApprovalTime_Initial__c == null
+ && String.isNotBlank(nObj.Extension_Type__c) && nObj.Extension_Type__c == '鎵归噺寤舵湡'
+ && (nObj.demo_purpose2__c == '璇曠敤锛堟棤璇环锛�' || nObj.demo_purpose2__c == '璇曠敤锛堟湁璇环锛�')
+ && String.isBlank(oObj.Extension_Much_ID__c)
+ && String.isBlank(oObj.Root_Rental_Apply__c)) {
+ isFirst = false;
+ List<Rental_Apply__c> checkRentalApply = new List<Rental_Apply__c>();
+ checkRentalApply.add(oObj);
+ try {
+ System.debug('========================checkRentalApply=========================' + checkRentalApply);
+ for (Rental_Apply_Equipment_Set__c raes : getCan_Extend_RequestList(checkRentalApply)) {
+ System.debug('raes.Id=========================' + raes.Id);
+ //鍒ゆ柇鏄鐢宠鍗曟槸鍚﹀瓨鍦� ok骞朵笖鍥炲瘎鏃堕棿涓嶄负绌虹殑涓�瑙堬紝
+ if ((raes.Received_Confirm__c == 'OK' || raes.Received_Confirm__c == '榛樿绛炬敹-OK') && raes.Asset_return_time__c != null) {
+
+ }else{
+ raes.RcUnexpectExpiryDelay__c = raes.Rental_Apply__r.RcUnexpectExpiryDelay__c;
+ raesList.add(raes);
+ }
+ }
+ }
+ catch (Exception e) {
+ nObj.addError(e.getMessage() + ',璇锋搷浣滈┏鍥炪��');
+ }
+ }
+ }
+ if (0 < raesList.size()) {
+ update raesList;
+ }
+ }
+ // add by lc 2022/11/15 DB202211029119 end
private void setAgencyHPReceived() {
Set<Id> raIdSet = new Set<Id>();
@@ -332,8 +384,11 @@
//濡傛灉涓烘壒閲忓欢鏈燂紝閭d箞杩欎釜闆嗗悎閲岄潰浼氬瓨鏀� 鍘熷崟+鍘熷崟涓嬫墍鏈夌殑浠庡崟
//濡傛灉涓轰粠鍗曪紝骞朵笖鐩殑2涓鸿浠凤紝閭d箞浼氬瓨鏀� 褰撳墠浠庡崟鐨勫師鍗�+浠庡崟鍘熷崟涓嬫墍鏈夌殑浠庡崟锛堝寘鎷綋鍓嶄粠鍗曪級
List<Rental_Apply__c> checkRentalApply = new List<Rental_Apply__c>();
+ // 鍙湁浜у搧璇曠敤浼氬瓨鍦ㄦ壒閲忓欢鏈�
if(String.isNotBlank(nObj.Extension_Type__c) && nObj.Extension_Type__c == '鎵归噺寤舵湡'){
+ System.debug('========================1=========================');
if(String.isNotBlank(nObj.Extension_Much_ID__c)){
+ System.debug('========================2=========================');
String parentId = nObj.Id;
parentId = parentId.substring(0,15);
String likeParentId = parentId+'%';
@@ -363,6 +418,7 @@
order by CreatedDate asc];
}
}else{
+ System.debug('========================3=========================');
//濡傛灉寤舵湡鐨勬槸浠庡崟锛岄偅涔堥渶瑕佺壒娈婂鐞�
if(String.isNotBlank(nObj.Root_Rental_Apply__c) && (nObj.demo_purpose2__c == '璇曠敤锛堟棤璇环锛�' || nObj.demo_purpose2__c == '璇曠敤锛堟湁璇环锛�')){
String likeParentId = nObj.Root_Rental_Apply__c+'%';
@@ -395,6 +451,8 @@
}
checkRentalApply.add(oObj);
}
+
+ System.debug('========================checkRentalApply=========================' + checkRentalApply);
for (Rental_Apply_Equipment_Set__c raes : getCan_Extend_RequestList(checkRentalApply)) {
//寤舵湡鎵瑰噯鏃堕棿(鏈�鍒�)鎴栧欢鏈熸壒鍑嗘椂闂�(鏈�缁�) 鍊奸兘鏈夊彉鍔紝閭d箞璇佹槑姝ゆ寤舵湡宸茬粡鎵瑰噯浜嗭紝閭d箞闇�瑕佺粰鐢宠鍗曠殑涓�瑙堣祴鍊�
if (oObj.ExtensionApprovalTime_Initial__c != nObj.ExtensionApprovalTime_Initial__c
@@ -458,7 +516,7 @@
update raesList;
}
}
-
+ // 20220909 ljh 鎭㈠浠g爜
private void checkbenbu() {
for (Rental_Apply__c nObj : newList) {
if (nObj.DataMigration_Flag__c == false) {
@@ -982,6 +1040,116 @@
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) {
@@ -1259,6 +1427,8 @@
}
}
}
+ System.debug('raes==============' + raes);
+ System.debug('raes1==============' + checkCan_Extend_Request(raes, false));
if (checkCan_Extend_Request(raes, false)) {
raesList.add(raes);
}
--
Gitblit v1.9.1