| | |
| | | this.oldList = (List < Contact > ) Trigger.old; |
| | | } |
| | | protected override void beforeInsert() { |
| | | if(Test.isRunningTest()||UserInfo.getUserId()!=System.Label.ByPassTrigger){ //Add by Li Jun for PIPL 20220331 |
| | | mobileNumberVerification(); |
| | | } |
| | | } |
| | | |
| | | protected override void afterInsert() { |
| | |
| | | // ) |
| | | ) |
| | | ) { |
| | | Agency_Contact__c acObj = new Agency_Contact__c(Agency_ID__c = '000000000000000', Contact__c = nObj.Id, ContactId18__c = nObj.Id, Agency_Hospital__c = null, Name = nObj.LastName + ((String.isBlank(nObj.FirstName) == false) ? ' ' + nObj.FirstName : ''), Department_Class__c = nObj.Strategic_dept_Class__c, Type__c = nObj.Type__c, Doctor_Division1__c = nObj.Doctor_Division1__c); |
| | | //Agency_Contact__c acObj = new Agency_Contact__c(Agency_ID__c = '000000000000000', Contact__c = nObj.Id, ContactId18__c = nObj.Id, Agency_Hospital__c = null, Name = nObj.LastName + ((String.isBlank(nObj.FirstName) == false) ? ' ' + nObj.FirstName : ''), Department_Class__c = nObj.Strategic_dept_Class__c, Type__c = nObj.Type__c, Doctor_Division1__c = nObj.Doctor_Division1__c); |
| | | Agency_Contact__c acObj = new Agency_Contact__c( |
| | | Agency_ID__c = '000000000000000', |
| | | Contact__c = nObj.Id, |
| | | ContactId18__c = nObj.Id, |
| | | Agency_Hospital__c = null, |
| | | Name = nObj.LastName, |
| | | Name_Encrypted__c = nObj.LastName_Encrypted__c, |
| | | Department_Class__c = nObj.Strategic_dept_Class__c, |
| | | Type__c = nObj.Type__c, |
| | | Type_Encrypted__c = nObj.Type_Encrypted__c, |
| | | Doctor_Division1__c = nObj.Doctor_Division1__c, |
| | | Doctor_Division1_Encrypted__c = nObj.Doctor_Division1_Encrypted__c |
| | | ); |
| | | targetContactMap.put(nObj.Id, acObj); |
| | | } |
| | | } |
| | | } |
| | | if (targetContactMap.size() > 0) { |
| | | upsert targetContactMap.values() ContactId18__c; |
| | | List<Agency_Contact__c> temp = targetContactMap.values(); |
| | | upsert temp ContactId18__c; |
| | | system.debug('temp='+temp); |
| | | EncryptInsert(temp); |
| | | } |
| | | } |
| | | |
| | | static void EncryptInsert(List<Agency_Contact__c> aclist){ |
| | | if(!(system.isFuture() || system.isBatch())){ |
| | | AwsServiceTool2.EncryptPushFuture(Json.serialize(aclist), 'Agency_Contact__c'); |
| | | }else{ |
| | | //Add By Li Jun for sync agency contact to aws 20220424 start |
| | | if(!Test.isRunningTest()){ |
| | | SyncAccountContactToAWS.assignOnceOneMinuteLater(); |
| | | } |
| | | //Add By Li Jun for sync agency contact to aws 20220424 end |
| | | } |
| | | } |
| | | |
| | |
| | | } |
| | | } |
| | | } |
| | | |
| | | public static Map<Id,Id> NFM606_IdMap = new Map<Id,Id>(); |
| | | // 606接口调用问题修复 thh 20220330 start |
| | | private void sendToComPlat() { |
| | |
| | | ID DoctorRecordTypeId = Schema.SObjectType.Contact.getRecordTypeInfosByDeveloperName().get('Doctor').getRecordTypeId(); |
| | | ID AgencyRecordTypeId = Schema.SObjectType.Contact.getRecordTypeInfosByDeveloperName().get('Agency').getRecordTypeId(); |
| | | //获取客户人员的记录类型ID thh 20220330 end |
| | | System.debug('local.UnifiedI_Contact_ID__c1:' + local.UnifiedI_Contact_ID__c); |
| | | System.debug('local.MobilePhone1:' + local.MobilePhone); |
| | | if (!local.IsFromSPO__c && !InternalStaffRecordTypeId.equals(local.RecordTypeId)) { |
| | | |
| | | // 医院 客户人员 统一平台编码有值 发送 PO |
| | | if (DoctorRecordTypeId.equals(local.RecordTypeId) && String.isNotBlank(local.UnifiedI_Contact_ID__c)) { |
| | | if (!NFM606_IdMap.containsKey(local.Id)) { |
| | |
| | | public static Contact contact1 = new Contact(); |
| | | public static Contact contact2 = new Contact(); |
| | | |
| | | @Testsetup |
| | | static void setup(){ |
| | | TestDataUtility.CreatePIPolicyConfiguration('Agency_Contact__c'); |
| | | |
| | | } |
| | | @isTest static void test_method_one() { |
| | | List<RecordType> HPrectCo = [select Id, Name, DeveloperName from RecordType where IsActive = true and SobjectType = 'Account' and DeveloperName = 'HP']; |
| | | List<RecordType> GIrectCo = [select Id, Name, DeveloperName from RecordType where IsActive = true and SobjectType = 'Account' and DeveloperName = 'Department_Class_GI']; |
| | | List<RecordType> DoctorrectCo = [select Id, Name, DeveloperName from RecordType where IsActive = true and SobjectType = 'Contact' and DeveloperName = 'Doctor']; |
| | | if (HPrectCo.size() == 0) { |
| | | throw new ControllerUtil.myException('not found HP recordtype'); |
| | | } |
| | | if (GIrectCo.size() == 0) { |
| | | throw new ControllerUtil.myException('not found Department_Class_GI recordtype'); |
| | | } |
| | | if (DoctorrectCo.size() == 0) { |
| | | throw new ControllerUtil.myException('not found Doctor recordtype'); |
| | | } |
| | | // 取引先 |
| | | account1.Name = 'test1医院'; |
| | | account1.RecordTypeId = '01210000000QemG'; |
| | | // account1.RecordTypeId = '01210000000QemG'; |
| | | account1.RecordTypeId = HPrectCo[0].Id; |
| | | insert account1; |
| | | |
| | | // 取引先責任者 |
| | | contact1.AccountId = account1.Id; |
| | | contact1.FirstName = '責任者'; |
| | | contact1.LastName = 'test1医院'; |
| | | Account dept = [select Id from Account where RecordTypeId = '01210000000QemL']; |
| | | Account dept = [select Id from Account where RecordTypeId =: GIrectCo[0].Id]; |
| | | contact1.Strategic_dept_Class__c = dept.Id; |
| | | contact1.MobilePhone = '13409507069'; |
| | | contact1.RecordTypeId = '01210000000QfWdAAK'; |
| | | // contact1.RecordTypeId = '01210000000QfWdAAK'; |
| | | contact1.RecordTypeId = DoctorrectCo[0].Id; |
| | | contact1.UnifiedI_Contact_ID__c = '100000'; |
| | | insert contact1; |
| | | MeetingManagement__c a = |
| | |
| | | } |
| | | @isTest |
| | | static void test_method_two(){ |
| | | List<RecordType> AgencyrectCo1 = [select Id, Name, DeveloperName from RecordType where IsActive = true and SobjectType = 'Account' and DeveloperName = 'Agency']; |
| | | if (AgencyrectCo1.size() == 0) { |
| | | throw new ControllerUtil.myException('not found AccountAgency recordtype'); |
| | | } |
| | | List<RecordType> AgencyrectCo2 = [select Id, Name, DeveloperName from RecordType where IsActive = true and SobjectType = 'Contact' and DeveloperName = 'Agency']; |
| | | if (AgencyrectCo2.size() == 0) { |
| | | throw new ControllerUtil.myException('not found ContactAgency recordtype'); |
| | | } |
| | | account2.Name = 'test2 经销商'; |
| | | account2.RecordTypeId = '01210000000Qem1'; |
| | | // account2.RecordTypeId = '01210000000Qem1'; |
| | | account2.RecordTypeId = AgencyrectCo1[0].Id; |
| | | insert account2; |
| | | |
| | | contact2.FirstName = 'test'; |
| | | contact2.LastName = 'Data'; |
| | | contact2.RecordTypeId = '01210000000QfWi'; |
| | | // contact2.RecordTypeId = '01210000000QfWi'; |
| | | contact2.RecordTypeId = AgencyrectCo2[0].Id; |
| | | contact2.AccountId = account2.Id; |
| | | contact2.Agency_User__c = true; |
| | | contact2.MobilePhone = '18999999999'; |
| | |
| | | Contact contact3 = new Contact(); |
| | | contact3.FirstName = 'test'; |
| | | contact3.LastName = 'Data'; |
| | | contact3.RecordTypeId = '01210000000QfWi'; |
| | | // contact3.RecordTypeId = '01210000000QfWi'; |
| | | contact3.RecordTypeId = AgencyrectCo2[0].Id; |
| | | contact3.AccountId = account2.Id; |
| | | // contact3.Agency_User__c = true; |
| | | contact3.Ignore_Same_Name__c = true; |
| | |
| | | |
| | | global Database.QueryLocator start(Database.BatchableContext bc) { |
| | | |
| | | return Database.getQueryLocator([select Id, NFM624_Secondary_processing__c from BatchIF_Log__c where NFM624_Secondary_processing__c = false AND Type__C = 'NFM624' AND RowDataFlg__c = true AND retry_cnt__c < 3]); |
| | | return Database.getQueryLocator([select Id, NFM624_Secondary_processing__c from BatchIF_Log__c where NFM624_Secondary_processing__c = false AND Type__C = 'NFM624' AND RowDataFlg__c = true AND retry_cnt__c < 3 AND Is_Error__c != 1]); |
| | | } |
| | | |
| | | global void execute(Database.BatchableContext BC, list<BatchIF_Log__c> scope) { |
| | |
| | | // if(updateprocessingList.size()>0){ |
| | | // update updateprocessingList; |
| | | // } |
| | | if(!Test.isRunningTest()){ |
| | | Id execBTId = Database.executeBatch(new NFM601Batch(), 200); |
| | | } |
| | | } |
| | | } |
| | |
| | | |
| | | // Map<String,String> RecordTypeMap = new Map<String,String>(); |
| | | // RecordTypeMap.put('','') |
| | | //List<RecordType> rectDpt = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and DeveloperName IN ('Department_OTH','Department_GI', 'Department_BF','Department_GYN','Department_GS','Department_URO','Department_ENT','Department_Class_ET') order by DeveloperName desc]; |
| | | Map < string, string > RecordTypeMap = new Map < string, string > (); //存放记录类型Id |
| | | //for(ID temp : rectDpt){ |
| | | // |
| | | //} |
| | | RecordTypeMap.put('呼吸科', '01210000000QfmR'); |
| | | RecordTypeMap.put('其他', '01210000000Qfmb'); |
| | | RecordTypeMap.put('妇科', '01210000000QfmM'); |
| | |
| | | List < String > ManagementList = new List < String > (); //医院、科室平台编码List |
| | | List < String > StateList = new List < String > (); |
| | | List < String > CityList = new List < String > (); |
| | | List < String > NameList = new List < String >(); |
| | | try { //根据传过来的管理编码查询如果可以查询得到结果则更新,查询不到则新增 |
| | | List < Gedata > newGeDataList = new List < Gedata > (); |
| | | for (Gedata gedata: GeDataList) { |
| | | //for test |
| | | gedata.AgentFlag=false; |
| | | // string dataComplete = verify(gedata); |
| | | string dataComplete =null; |
| | | // test end for pi |
| | | string dataComplete = verify(gedata); |
| | | |
| | | if (!String.isBlank(dataComplete)) { |
| | | logstr += dataComplete; |
| | | rowData.Is_Error__c = 1; |
| | | rowData.retry_cnt__c = 0; |
| | | continue; |
| | | } |
| | | if (!gedata.AgentFlag) { |
| | |
| | | } |
| | | if (string.isnotblank(gedata.PersonManagementCode)) { |
| | | PersonManagementCodeList.add(gedata.PersonManagementCode); |
| | | } |
| | | if(String.isnotBlank(gedata.NameEncrypted)){ |
| | | NameList.add(gedata.NameEncrypted); |
| | | } |
| | | newGeDataList.add(gedata); |
| | | System.debug('ManagementList'+ManagementList); |
| | |
| | | AccountId |
| | | from Contact |
| | | where CManageCode__c IN: PersonManagementCodeList |
| | | OR Account.Parent_PlatformCode__c IN: ManagementList |
| | | OR Account.Parent_Management_Code__c IN: SFDCCodeList]; //根据人员管理编码检索联系人 |
| | | OR (Account.Parent_PlatformCode__c IN: ManagementList AND LastName_Encrypted__c IN:NameList) |
| | | OR (Account.Parent_Management_Code__c IN: SFDCCodeList AND LastName_Encrypted__c IN:NameList ) |
| | | ORDER BY MobilePhone ASC,CManageCode__c ASC]; //根据人员管理编码检索联系人 |
| | | Map < String, Contact > peopleMap = new Map < String, Contact > (); //联系人 |
| | | system.debug('peopleList '+peopleList); |
| | | for (Contact ct: peopleList) { |
| | | if (string.isnotblank(ct.Account.parent.Name)) { |
| | | Map < String, Contact > snameMap = new Map < String, Contact > (); |
| | | string namekey = ct.Account.Name + ' ' + ct.LastName_Encrypted__c; |
| | | string namekey = ct.Account.Name + ' ' + ct.LastName_Encrypted__c.trim(); |
| | | string nameKey2 = ct.Account.Management_Code__c + ' ' + ct.LastName_Encrypted__c.trim(); |
| | | // snameMap.put(namekey,ct); |
| | | if (nameMap.containsKey(ct.Account.parent.Name)) { |
| | | snameMap = nameMap.get(ct.Account.parent.Name); |
| | | } |
| | | snameMap.put(namekey, ct); |
| | | snameMap.put(ct.LastName_Encrypted__c, ct); |
| | | snameMap.put(nameKey2,ct); |
| | | snameMap.put(ct.LastName_Encrypted__c.trim(), ct); |
| | | nameMap.put(ct.Account.parent.Name, snameMap); |
| | | system.debug('snameMap'+snameMap); |
| | | } |
| | |
| | | logstr += gedata.DepartmentName; |
| | | |
| | | |
| | | string comefrom = gedata.RegSource == '1' ? '智慧医疗' : '服务客户端'; //平台来源 |
| | | string comefrom = gedata.RegSource == '1' ? '智慧医疗' : (gedata.RegSource == '2' ? '服务客户端' :'医拓网'); //平台来源 |
| | | |
| | | //新建医院 |
| | | Account hp = new Account(); |
| | | |
| | | //新建联系人 |
| | | Contact ct = new Contact(); |
| | | if(gedata.AgentFlag){ |
| | | //ct.FirstName = ''; 2022-4-7 yjk 注释掉 |
| | | ct.UnifiedI_Contact_ID__c = gedata.ContactId; //统一平台Id |
| | | ct.ServicePlatformCode__c = gedata.ServiceUserId; //服务平台用户Id |
| | | //ct.CManageCode__c = gedata.PersonManagementCode;//人员管理编码 |
| | | }else{ |
| | | ct.LastName = gedata.Name; |
| | | ct.FirstName = ''; |
| | | ct.Type__c = gedata.Type; |
| | |
| | | ct.AWS_Data_Id__c =gedata.DataId;//add 20220215 aws存储凭证 |
| | | ct.MobilePhone_Encrypted__c =gedata.MobileEncrypted;//add 20220215 手机密文 |
| | | ct.LastName_Encrypted__c =gedata.NameEncrypted;//add 20220215 姓名密文 |
| | | } |
| | | |
| | | |
| | | String personCode = gedata.PersonManagementCode; |
| | | |
| | |
| | | if (gedata.AgentFlag == true) { |
| | | //更新经销商联系人 |
| | | if (!peopleMap.containsKey(personCode)) { |
| | | rowData.Is_Error__c = 1; |
| | | logstr += 'error:人员管理编码 [PersonManagementCode] 对应的联系人不存在,此条数据跳过'; |
| | | continue; |
| | | } |
| | |
| | | if ('有效'.equals(hospital.Is_Active_Formula__c)) { |
| | | string DepartmentCode = string.isNotBlank(gedata.RelatedDepartment) ? gedata.RelatedDepartment : gedata.DepartmentManagementCode2; |
| | | string DepartmentClasskey = gedata.AccountName + ' ' + gedata.DepartmentClass; |
| | | system.debug('DepartmentClasskey------->'+DepartmentClasskey); |
| | | //科室存在 |
| | | if (AccountMap.containsKey(DepartmentCode)) { |
| | | //人员管理编码存在 |
| | |
| | | upsertContactList.add(ct); |
| | | } else { //联系人不存在 2 完成 |
| | | system.debug('2逻辑 有医院 有科室 有人员管理编码但查找无此人 动作:报错'); |
| | | rowData.Is_Error__c = 1; |
| | | logstr += 'error:人员管理编码 [PersonManagementCode] 对应的联系人不存在,此条数据跳过'; |
| | | continue; |
| | | } |
| | | } else { //人员管理编码不存在 |
| | | //搜索人名/且在当前战略科室科室下 |
| | | System.debug('人员管理编码不存在'); |
| | | string namekey = gedata.NameEncrypted; |
| | | string namekey = gedata.RelatedDepartment + ' ' + gedata.NameEncrypted; |
| | | system.debug('DepartmentClasskey = '+DepartmentClasskey); |
| | | system.debug('nameMap22222222 '+nameMap); |
| | | if (nameMap.containskey(DepartmentClasskey)) { // 6 完成 更新操作 |
| | |
| | | if (sMap.containsKey(namekey)) { |
| | | system.debug('Id赋值'+sMap); |
| | | ct.id = sMap.get(namekey).id; |
| | | } else if(sMap.containsKey(gedata.NameEncrypted)){ |
| | | ct.id = sMap.get(gedata.NameEncrypted).id; |
| | | } else { // 7 完成 |
| | | system.debug('7逻辑 无人员管理编码 有医院 有科室 人名查找无 动作:新建联系人 '); |
| | | } |
| | |
| | | //upsertContactList.add(ct); |
| | | } else { //人员管理编码查找无值 4 完成 |
| | | system.debug('4逻辑'); |
| | | rowData.Is_Error__c = 1; |
| | | logstr += 'error:人员管理编码 [PersonManagementCode] 对应的联系人不存在,此条数据跳过'; |
| | | continue; |
| | | } |
| | |
| | | system.debug('8逻辑'); |
| | | system.debug('该联系人存在'); |
| | | ct.id = sMap.get(namekey).id; |
| | | upsertAccountList.add(dpt); |
| | | //upsertAccountList.add(dpt);//可以注释 |
| | | upsertContactList.add(ct); |
| | | // if(sMap.containsKey(gedata.Name)){ |
| | | // ct.Id = sMap.get(gedata.Name).Id; |
| | |
| | | } |
| | | } |
| | | }else if('无效'.equals(hospital.Is_Active_Formula__c)){ |
| | | rowData.Is_Error__c = 1; |
| | | logstr += 'error:该医院无效,此条数据跳过'; |
| | | continue; |
| | | }else{ |
| | |
| | | |
| | | private static String verify(GeData gda) { |
| | | String result = ''; |
| | | if (gda.AgentFlag) { |
| | | if (string.isblank(gda.ContactId)) { |
| | | result += 'DataError: ContactId 统一平台ID为空\n'; |
| | | } |
| | | if (string.isblank(gda.PersonManagementCode)) { |
| | | result += 'DataError:PersonManagementCode 人员管理编码为空\n'; |
| | | } |
| | | if (string.isblank(gda.ServiceUserId)) { |
| | | result += 'ServiceUserId 服务平台用户Id为空\n'; |
| | | } |
| | | }else{ |
| | | if (string.isblank(gda.ContactId)) { |
| | | result += 'DataError: ContactId 统一平台ID为空\n'; |
| | | } |
| | |
| | | if (string.isblank(gda.Name)) { |
| | | result += 'DataError:姓名为空\n'; |
| | | } |
| | | if (string.isblank(gda.NameEncrypted)) { |
| | | result += 'DataError:姓名密文为空\n'; |
| | | } |
| | | if (string.isblank(gda.Mobile)) { |
| | | result += 'DataError:手机号为空\n'; |
| | | } |
| | | if (string.isblank(gda.MobileEncrypted)) { |
| | | result += 'DataError:手机号密文为空\n'; |
| | | } |
| | | if (string.isblank(gda.RegSource)) { |
| | | result += 'DataError:注册平台来源为空\n'; |
| | | }if (string.isblank(gda.DataId)) { |
| | | result += 'DataError:AWS加密凭据为空\n'; |
| | | } |
| | | if (gda.AgentFlag) { |
| | | if (string.isblank(gda.PersonManagementCode)) { |
| | | result += 'DataError:PersonManagementCode 人员管理编码为空\n'; |
| | | } |
| | | } else { |
| | | // if (string.isnotblank(gda.PersonManagementCode) && string.isBlank(gda.RelatedHospital)) { |
| | | // result += 'DataError: 关联医院编码为空\n'; |
| | | // } |
| | | if(string.isBlank(gda.RelatedDepartment) && String.isBlank(gda.ApproverID)){ |
| | | result += 'DataError: 在关联SFDC科室[RelatedDepartment]为空时,审核人员员工编码[ApproverID]必填\n'; |
| | | if(string.isBlank(gda.RelatedHospital) && String.isBlank(gda.HospitalManagementCode2) && String.isBlank(gda.ApproverID)){ |
| | | result += 'DataError: 新建医院时,审核人员员工编码[ApproverID]必填\n'; |
| | | } |
| | | if (string.isblank(gda.HospitalManagementCode2)) { |
| | | result += 'DataError:医院平台编码为空\n'; |
| | |
| | | * 04/22/2022 - Bubba Li - Initial Code. |
| | | * |
| | | * */ |
| | | global class SyncAccountContactToAWS implements Database.Batchable<SObject>,Database.AllowsCallouts{ |
| | | global class SyncAccountContactToAWS implements Schedulable,Database.Batchable<SObject>,Database.AllowsCallouts{ |
| | | |
| | | global String query; |
| | | |
| | | global SyncAccountContactToAWS(String query) { |
| | | this.query = query; |
| | | } |
| | | global SyncAccountContactToAWS() { |
| | | this.query = 'SELECT id,Doctor_Division1__c,Doctor_Division1_Encrypted__c,Name,Name_Encrypted__c,Type__c,Type_Encrypted__c,AWS_Data_Id__c,Contact__c, Contact__r.Doctor_Division1_Encrypted__c,Contact__r.LastName_Encrypted__c, Contact__r.Type_Encrypted__c FROM Agency_Contact__c WHERE AWS_Data_Id__c =\'\' And Contact__c != null'; |
| | | this.query = 'SELECT id,Doctor_Division1__c,Doctor_Division1_Encrypted__c,Name,Name_Encrypted__c,Type__c,Type_Encrypted__c,AWS_Data_Id__c,Contact__c, Contact__r.Doctor_Division1_Encrypted__c,Contact__r.LastName_Encrypted__c, Contact__r.Type_Encrypted__c FROM Agency_Contact__c WHERE AWS_Data_Id__c =\'\' And Contact__c != null order by lastmodifieddate desc'; |
| | | } |
| | | global Database.QueryLocator start(Database.BatchableContext bc) { |
| | | system.debug('Query by custom soql:'+this.query); |
| | |
| | | global void execute(Database.BatchableContext BC, list<Agency_Contact__c> scope) { |
| | | if(scope!=null && scope.size()>0){ |
| | | for(Agency_Contact__c aContact:scope){ |
| | | aContact.Doctor_Division1_Encrypted__c = aContact.Contact__r.Doctor_Division1_Encrypted__c; |
| | | aContact.Name_Encrypted__c = aContact.Contact__r.LastName_Encrypted__c; |
| | | aContact.Type_Encrypted__c = aContact.Contact__r.Type_Encrypted__c; |
| | | aContact.Doctor_Division1_Encrypted__c = aContact.Contact__c!=null&&aContact.Contact__r.Doctor_Division1_Encrypted__c!=''?aContact.Contact__r.Doctor_Division1_Encrypted__c:''; |
| | | aContact.Name_Encrypted__c = aContact.Contact__c!=null&&aContact.Contact__r.LastName_Encrypted__c!=''?aContact.Contact__r.LastName_Encrypted__c:''; |
| | | aContact.Type_Encrypted__c = aContact.Contact__c!=null&&aContact.Contact__r.Type_Encrypted__c!=''?aContact.Contact__r.Type_Encrypted__c:''; |
| | | aContact.AWS_Data_Id__c = ''; |
| | | } |
| | | system.debug('Agency Contact Info to AWS:'+JSON.serialize(scope)); |
| | |
| | | } |
| | | } |
| | | |
| | | global void finish(Database.BatchableContext BC) { |
| | | global void execute(SchedulableContext SC) { |
| | | Id execBTId = Database.executeBatch(new SyncAccountContactToAWS(), 1); |
| | | } |
| | | |
| | | public static void assignOnceOneMinuteLater() { |
| | | String hour = String.valueOf(Datetime.now().hour()); |
| | | String min = String.valueOf(Datetime.now().minute() + 1); |
| | | String ss = String.valueOf(Datetime.now().second()); |
| | | //parse to cron expression |
| | | String nextFireTime = ss + ' ' + min + ' ' + hour + ' * * ?'; |
| | | SyncAccountContactToAWS s = new SyncAccountContactToAWS(); |
| | | System.schedule('Job Started At ' + String.valueOf(Datetime.now()), nextFireTime, s); |
| | | } |
| | | |
| | | global void finish(Database.BatchableContext BC) { |
| | | AsyncApexJob a = [SELECT Id, Status, NumberOfErrors, JobItemsProcessed, TotalJobItems, CreatedBy.Email FROM AsyncApexJob WHERE Id = :BC.getJobId()]; |
| | | //then use the active job id and abort it |
| | | system.abortJob(a.id); |
| | | } |
| | | } |
New file |
| | |
| | | @isTest |
| | | public class SyncAccountContactToAWSTest { |
| | | class HttpMock implements HttpCalloutMock{ |
| | | |
| | | public HTTPResponse respond(HTTPRequest request) { |
| | | // 创建一个假的回应 |
| | | System.debug('------------------------------------------------------'); |
| | | HttpResponse response = new HttpResponse(); |
| | | string body = ''; |
| | | system.debug(request.getEndpoint()); |
| | | if(request.getEndpoint().contains('token')){ |
| | | system.debug('url=token'); |
| | | response.setHeader('Content-Type', 'application/json'); |
| | | body='{ "message": "", "object": "freqfewqfewewfewfew", "status": "", "success": true, "timestamp": 0, "txId": "" }'; |
| | | } else if(request.getEndpoint().contains('insert')){ |
| | | system.debug('url=Insert'); |
| | | response.setHeader('Content-Type', 'application/json'); |
| | | body='{ "message": "", "object": [ { "dataId": "123456", "directShippmentAddress": "", "directShippmentAddressEncrypt": "", "isDelete": 0, "phoneNumber": "", "phoneNumberEncrypt": "", "sfRecordId": "a2R1m0000007BPD" } ], "status": "", "success": true, "timestamp": 0, "txId": "" }'; |
| | | } else if(request.getEndpoint().contains('update')){ |
| | | system.debug('url=update'); |
| | | response.setHeader('Content-Type', 'application/json'); |
| | | body='{ "message": "", "object": [ { "dataId": "123456", "directShippmentAddress": "", "directShippmentAddressEncrypt": "", "isDelete": 0, "phoneNumber": "", "phoneNumberEncrypt": "", "sfRecordId": "a2R1m0000007BPD" } ], "status": "", "success": true, "timestamp": 0, "txId": "" }'; |
| | | } else{} |
| | | |
| | | response.setBody(body); |
| | | response.setStatus('OK'); |
| | | response.setStatusCode(200); |
| | | return response; |
| | | // } |
| | | } |
| | | } |
| | | @isTest |
| | | static void startTest() { |
| | | TestDataUtility.CreatePIPolicyConfigurations(new string[]{'Agency_Contact__c','Contact'}); |
| | | Test.setMock(HttpCalloutMock.class, new HttpMock()); |
| | | List<Agency_Contact__c> lra = new List<Agency_Contact__c>(); |
| | | lra.add(new Agency_Contact__c(AWS_Data_Id__c='Test AWS')); |
| | | insert lra; |
| | | System.Test.startTest(); |
| | | try{ |
| | | //String soql = 'SELECT id,Doctor_Division1__c,Doctor_Division1_Encrypted__c,Name,Name_Encrypted__c,Type__c,Type_Encrypted__c,AWS_Data_Id__c,Contact__c, Contact__r.Doctor_Division1_Encrypted__c,Contact__r.LastName_Encrypted__c, Contact__r.Type_Encrypted__c FROM Agency_Contact__c WHERE id=\'a2R10000001cfatEAA\' And AWS_Data_Id__c =\'\' And Contact__c != null'; |
| | | String soql = 'SELECT id,Doctor_Division1__c,Doctor_Division1_Encrypted__c,Name,Name_Encrypted__c,Type__c,Type_Encrypted__c,AWS_Data_Id__c,Contact__c, Contact__r.Doctor_Division1_Encrypted__c,Contact__r.LastName_Encrypted__c, Contact__r.Type_Encrypted__c FROM Agency_Contact__c WHERE AWS_Data_Id__c =\'Test AWS\''; |
| | | SyncAccountContactToAWS contactBatch = new SyncAccountContactToAWS(soql); |
| | | Id execBTId = Database.executeBatch(contactBatch,1); |
| | | }catch(Exception e){ |
| | | system.debug('Exception from sync aws batch:'+ e.getMessage()); |
| | | } |
| | | try{ |
| | | SyncAccountContactToAWS.assignOnceOneMinuteLater(); |
| | | }catch(Exception e){ |
| | | system.debug('Exception from sync aws scheduler:'+ e.getMessage()); |
| | | } |
| | | System.Test.stopTest(); |
| | | } |
| | | |
| | | // static testMethod void testExecute() { |
| | | // // This test runs a scheduled job at midnight Sept. 3rd. 2022 |
| | | // String CRON_EXP = '0 0 0 3 9 ? 2022'; |
| | | // String soql = 'SELECT id,Doctor_Division1__c,Doctor_Division1_Encrypted__c,Name,Name_Encrypted__c,Type__c,Type_Encrypted__c,AWS_Data_Id__c,Contact__c, Contact__r.Doctor_Division1_Encrypted__c,Contact__r.LastName_Encrypted__c, Contact__r.Type_Encrypted__c FROM Agency_Contact__c WHERE id=\'a2R10000001cfatEAA\' And AWS_Data_Id__c =\'\' And Contact__c != null'; |
| | | |
| | | // System.Test.startTest(); |
| | | // // Schedule the test job |
| | | // String jobId = system.schedule('SyncAccountContactToAWSTest', CRON_EXP, new SyncAccountContactToAWS(soql)); |
| | | // // Get the information from the CronTrigger API object |
| | | // CronTrigger ct = [SELECT Id, CronExpression, TimesTriggered, NextFireTime FROM CronTrigger WHERE id = :jobId]; |
| | | // // Verify the expressions are the same |
| | | // System.assertEquals(CRON_EXP, ct.CronExpression); |
| | | // // Verify the job has not run |
| | | // System.assertEquals(0, ct.TimesTriggered); |
| | | // // Verify the next time the job will run |
| | | // System.assertEquals('2022-09-03 00:00:00', String.valueOf(ct.NextFireTime)); |
| | | // System.Test.StopTest(); |
| | | // } |
| | | |
| | | } |
New file |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | <ApexClass xmlns="http://soap.sforce.com/2006/04/metadata"> |
| | | <apiVersion>54.0</apiVersion> |
| | | <status>Active</status> |
| | | </ApexClass> |
| | |
| | | <apex:stylesheet value="{!URLFOR($Resource.ConsumTrialPageCss)}"/> |
| | | <apex:includeScript value="{!URLFOR($Resource.ReceivingNotePageJS)}"/> |
| | | <apex:includeScript value="{!URLFOR($Resource.CommonUtilJs)}"/> |
| | | <apex:includeScript value="{! URLFOR($Resource.AWSService, 'AWSService.js') }"/> |
| | | <apex:form id="allForm"> |
| | | <style> |
| | | table.headTable td { |
| | |
| | | <script type="text/javascript"> |
| | | var heightAjustment = 120; |
| | | var widthAjustment = 30; |
| | | var staticResource = JSON.parse('{!staticResource}'); |
| | | |
| | | // 适用按钮 |
| | | function applyJs() { |
| | |
| | | } |
| | | } |
| | | |
| | | //2022 02 24 张华建 display PI Data start |
| | | var rowBList; |
| | | var TrialUser = {}; |
| | | var ids = []; |
| | | |
| | | queryUser(); |
| | | |
| | | function q1(){ |
| | | var p = new Promise(function(resolve, reject){ |
| | | rowBList = JSON.parse('{!rowListString}') |
| | | var x = 0; |
| | | var y = 0; |
| | | let searchCallBack = function searchCallBack(result){ |
| | | let contacts = result.object; |
| | | if(contacts == null){ |
| | | return; |
| | | } |
| | | let temp = {} |
| | | temp.trialUser = contacts.trialUser; |
| | | TrialUser[contacts.dataId] = temp; |
| | | x++; |
| | | }; |
| | | for(var i=0;i<rowBList.length;i++){ |
| | | if(rowBList[i].AWSDataId ){ |
| | | y++; |
| | | ids.push(rowBList[i].AWSDataId + '_' + rowBList[i].Id); |
| | | AWSService.query(staticResource.queryUrl,rowBList[i].AWSDataId,searchCallBack,staticResource.token); |
| | | } |
| | | } |
| | | var id = setInterval(function(){ |
| | | if(x == y){ |
| | | console.log('success') |
| | | resolve('success'); |
| | | clearInterval(id); |
| | | } |
| | | },500); |
| | | }); |
| | | return p; |
| | | } |
| | | |
| | | function q2(value){ |
| | | var p = new Promise(function(resolve, reject){ |
| | | console.log('进入q2'+value) |
| | | for(var i=0;i<ids.length;i++){ |
| | | console.log('i = '+i); |
| | | document.getElementById(ids[i]).children[0].children[0].innerText = TrialUser[ids[i].substring(0,18)].trialUser; |
| | | console.log('i = '+i); |
| | | } |
| | | }); |
| | | } |
| | | |
| | | function queryUser(){ |
| | | unblockUI() |
| | | rowBList = JSON.parse('{!rowListString}') |
| | | console.log('pageB.fixMode = '+'{!pageB.fixMode}') |
| | | if('{!pageB.fixMode}' == 'true'){ |
| | | q1().then(function(data){ |
| | | return q2(data); |
| | | }) |
| | | unblockUI(); |
| | | }else{ |
| | | blockme(); |
| | | console.log(rowBList) |
| | | let searchCallBack = function searchCallBack(result){ |
| | | let contacts = result.object; |
| | | if(contacts == null){ |
| | | return; |
| | | } |
| | | let temp = {} |
| | | temp.trialUser = contacts.trialUser; |
| | | TrialUser[contacts.dataId] = temp; |
| | | }; |
| | | for(var i=0;i<rowBList.length;i++){ |
| | | ids.push(rowBList[i].AWSDataId + '_' + rowBList[i].Id); |
| | | AWSService.query(staticResource.queryUrl,rowBList[i].AWSDataId,searchCallBack,staticResource.token); |
| | | } |
| | | unblockUI(); |
| | | } |
| | | } |
| | | |
| | | function showPIDiv(awsDataId){ |
| | | if(awsDataId.length == 0){ |
| | | return |
| | | } |
| | | if(TrialUser[awsDataId.substring(0,18)] == null){ |
| | | return |
| | | } |
| | | console.log('awsDataId Value:'+awsDataId); |
| | | let parentNode = document.getElementById(awsDataId); |
| | | let createDiv = document.createElement("div"); |
| | | createDiv.id = awsDataId+"_PI"; |
| | | let piInformation = TrialUser[awsDataId.substring(0,18)].trialUser |
| | | //let piInformation = 'Name:'+contact['943114607025717249'].lastName +'\n' +'Phone:'+contact['943114607025717249'].phone |
| | | createDiv.innerText = piInformation; |
| | | let x=window.event.x; |
| | | let y=window.event.y; |
| | | createDiv.style.left=x; |
| | | createDiv.style.top=y; |
| | | createDiv.style.background="#dddddd"; |
| | | createDiv.style.position = "absolute"; |
| | | parentNode.appendChild(createDiv); |
| | | parentNode.style.position = "relative"; |
| | | } |
| | | |
| | | function hidePIDiv(awsDataId){ |
| | | if(awsDataId.length == 0){ |
| | | return |
| | | } |
| | | if(TrialUser[awsDataId.substring(0,18)] == null){ |
| | | return |
| | | } |
| | | document.getElementById(awsDataId+'_PI').remove(); |
| | | } |
| | | |
| | | function q3(){ |
| | | var p = new Promise(function(resolve, reject){ |
| | | console.log('saveRecordJS') |
| | | |
| | | var a = 0; |
| | | var b = 0; |
| | | let newCallBack = function newCallBack(result,indexNumber){ |
| | | |
| | | console.log('result = '+JSON.stringify(result)) |
| | | //赋值dataId和trialUser |
| | | document.getElementById('allPage:allForm:dataBlock:dataline_R_aws:'+indexNumber+':EditAWSDataId').value = result.object[0].dataId; |
| | | document.getElementById('allPage:allForm:dataBlock:dataline_R:'+indexNumber+':inputField:6:inputField').value = result.object[0].trialUser; |
| | | let transParameters = { |
| | | txId: result.txId, |
| | | isSuccess: 1 |
| | | }; |
| | | let confirmCallBack = function confirmCallBack(result){ |
| | | console.log('confirmCallBack = '+JSON.stringify(result)) |
| | | } |
| | | b++; |
| | | AWSService.confirmTrans(staticResource.transactionUrl,JSON.stringify(transParameters),confirmCallBack,staticResource.token) |
| | | }; |
| | | for(var i=0;i<rowBList.length;i++){ |
| | | if(document.getElementById('allPage:allForm:dataBlock:dataline_L:'+i+':rowCheck').checked == true){ |
| | | a++; |
| | | } |
| | | } |
| | | debugger |
| | | for(var i=0;i<rowBList.length;i++){ |
| | | if(document.getElementById('allPage:allForm:dataBlock:dataline_L:'+i+':rowCheck').checked == true){ |
| | | //加密试用者 |
| | | var trialUser = document.getElementById('allPage:allForm:dataBlock:dataline_R:'+i+':inputField:6:j_id86').children[0].children[0].value |
| | | let consumApplyPayloadList = []; |
| | | let consumApplyPIData = new Object(); |
| | | consumApplyPIData.trialUser = trialUser; |
| | | consumApplyPIData.sfRecordId = ''; |
| | | consumApplyPayloadList.push(consumApplyPIData); |
| | | AWSService.postConsumTrial(staticResource.newUrl,i,JSON.stringify(consumApplyPayloadList),newCallBack,staticResource.token); |
| | | } |
| | | } |
| | | var id = setInterval(function(){ |
| | | if(a == b){ |
| | | console.log('a==b success') |
| | | resolve('success'); |
| | | clearInterval(id); |
| | | } |
| | | },500); |
| | | }); |
| | | return p; |
| | | } |
| | | |
| | | function q4(){ |
| | | debugger |
| | | saveRecord(); |
| | | } |
| | | function saveRecordJS(){ |
| | | if('{!pageB.fixMode}' != 'true'){ |
| | | return |
| | | } |
| | | // q3().then(function(data){ |
| | | // return q4(data); |
| | | // }) |
| | | saveRecord(); |
| | | unblockUI(); |
| | | } |
| | | //2022 02 24 张华建 display PI Data end |
| | | |
| | | </script> |
| | | <apex:pageMessages /> |
| | | <apex:actionFunction name="saveRecord" action="{!saveRecord}" oncomplete="unblockUI();refopener();" rerender="allForm"/> |
| | |
| | | <apex:commandButton value="适用" rendered="{!canEdit}" onclick="applyJs();return false;"/> |
| | | </span> |
| | | <span style="margin-left: 10px;"> |
| | | <apex:commandButton value="保存" onclick="blockme(); saveRecord(); return false;" rendered="{!canEdit}" reRender="allForm"/> |
| | | <apex:commandButton value="保存" onclick="blockme(); saveRecordJS(); return false;" rendered="{!canEdit}" reRender="allForm"/> |
| | | </span> |
| | | </td> |
| | | </tr> |
| | |
| | | </apex:repeat> |
| | | </table> |
| | | </div> |
| | | <apex:repeat id="dataline_R_aws" value="{!pageB.rowBList}" var="var"> |
| | | <apex:inputHidden value="{!var.rnd.AWS_Data_Id__c}" id="EditAWSDataId"/> |
| | | </apex:repeat> |
| | | <div id="in_Div" style="overflow:auto;"> |
| | | <table class="list" style="border-bottom-width: 0px; font-size:11px; border-spacing:0;" border="" id="tableData"> |
| | | <apex:variable value="{!0}" var="Cnt_R" /> |
| | |
| | | <tr id="tableData_R_{!Cnt_R}" class="dataRow" onmouseover="if (window.hiOn){hiOn(this);} " onmouseout="if (window.hiOff){hiOff(this);} " onblur="if (window.hiOff){hiOff(this);}" onfocus="if (window.hiOn){hiOn(this);}" > |
| | | <apex:variable value="{!0}" var="Col_R" /> |
| | | <apex:repeat value="{!inputFieldList}" var="info" id="inputField" > |
| | | <td class="dataCellBorder1 intf {!info.value} col_{!info.value}" style="{!IF(info.value=='RAESD_Status__c' && var.rnd[info.value]=='申请者收货NG','background-color: #009DDC','')}"> |
| | | <td class="dataCellBorder1 intf {!info.value} col_{!info.value}" style="{!IF(info.value=='RAESD_Status__c' && var.rnd[info.value]=='申请者收货NG','background-color: #009DDC','')}" id="{! IF(info.value=='Trial_User__c',var.rnd.AWS_Data_Id__c+'_'+var.rnd.Id,info.value)}" onmouseover="showPIDiv('{! IF(info.value=='Trial_User__c',var.rnd.AWS_Data_Id__c+'_'+var.rnd.Id,'')}')" onmouseout="hidePIDiv('{! IF(info.value=='Trial_User__c',var.rnd.AWS_Data_Id__c+'_'+var.rnd.Id,'')}')"> |
| | | |
| | | <apex:outputPanel rendered="{!((contains(var.canChangeField, info.value) || var.canChangeField == '') && pageB.fixMode == true && var.canChange == true)}"> |
| | | <apex:inputField id="inputField" value="{!var.rnd[info.value]}" onchange="setChangeFlg('{!var.lineNo-1}');changeEditable('{!var.lineNo-1}');" rendered="{!info.value != 'Asset_loaner_category__c' || var.haveAsset}" /> |
| | | |