Li Jun
2022-04-25 784f9cec56eef3c7ac0ba02de98fdbf341c6a7b3
0428IssueFix
3个文件已修改
44 ■■■■■ 已修改文件
force-app/main/default/classes/PIHelper.cls 24 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/classes/StraightBackAddressController.cls 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/classes/SyncAccountContactToAWS.cls 18 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/classes/PIHelper.cls
@@ -102,16 +102,20 @@
     }
    // Use this log method
    public static void saveTransLog(String module,String awsDataId,String sfId, String transId,String content,String status,String respMsg){
        Transaction_Log__c traLog = new Transaction_Log__c();
        traLog.AWS_Data_Id__c = awsDataId;
        traLog.SFRecordId__c = sfId;
        traLog.Module__c = 'Upsert SF ' + module;
        traLog.TransId__c = transId;
        traLog.Request__c = content;
        traLog.Status__c = status;
        traLog.Response__c = respMsg;
        traLog.Interface_URL__c = traLog.Module__c;
        insert traLog;
        try{
            Transaction_Log__c traLog = new Transaction_Log__c();
            traLog.AWS_Data_Id__c = awsDataId;
            traLog.SFRecordId__c = sfId;
            traLog.Module__c = 'Upsert SF ' + module;
            traLog.TransId__c = transId;
            traLog.Request__c = content;
            traLog.Status__c = status;
            traLog.Response__c = respMsg;
            traLog.Interface_URL__c = traLog.Module__c;
            insert traLog;
        }catch(Exception e){
            system.debug('Exception from insert log:'+e.getMessage());
        }
    }
    //save qianlima log method add sushanhu 20220324
    // model 0 为文件 1为数据
force-app/main/default/classes/StraightBackAddressController.cls
@@ -723,7 +723,7 @@
            savemessage = e.getMessage()+e.getStackTraceString();
            message = '保存失败';
        } finally {
            PIHelper.saveTransLog('StraightBackAddressController',address_id,address_id,address_id, repaire_json ,asset_json,message);
            PIHelper.saveTransLog('StraightBackAddressController',address_id,address_id,address_id, repaire_json ,'success',message);
        }
        return message;
    }
force-app/main/default/classes/SyncAccountContactToAWS.cls
@@ -10,15 +10,19 @@
global class  SyncAccountContactToAWS implements Schedulable,Database.Batchable<SObject>,Database.AllowsCallouts{
    global String query;
    global String scheduleId{set;get;}
    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 order by lastmodifieddate desc';
    }
    global SyncAccountContactToAWS(String query,String scId) {
        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';
        this.scheduleId = scId;
    }
    global Database.QueryLocator start(Database.BatchableContext bc) {
        system.debug('Query by custom soql:'+this.query);
        system.debug('Query by custom soql:'+this.query);
        return Database.getQueryLocator(this.query);
    }
    global void execute(Database.BatchableContext BC, list<Agency_Contact__c> scope) {
@@ -35,7 +39,8 @@
    }
    global void execute(SchedulableContext SC) {
        Id execBTId = Database.executeBatch(new SyncAccountContactToAWS(), 1);
        Id execBTId = Database.executeBatch(new SyncAccountContactToAWS('',SC.getTriggerId()), 1);
        system.debug('Batch Job Id:'+execBTId);
    }
    public static void assignOnceOneMinuteLater() {
@@ -45,12 +50,17 @@
        //parse to cron expression
        String nextFireTime = ss + ' ' + min + ' ' + hour + ' * * ?';
        SyncAccountContactToAWS s = new SyncAccountContactToAWS(); 
        System.schedule('Job Started At ' + String.valueOf(Datetime.now()), nextFireTime, s);
        System.schedule('SyncAccountContactToAWS:' + String.valueOf(Datetime.now()), nextFireTime, s);
    }
    global void finish(Database.BatchableContext BC) {
        system.debug('Finish batch job Id:'+BC.getJobId());
        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);
        system.debug('Finish schedule job Id:'+scheduleId);
        if(scheduleId!=null&&scheduleId!=''){
            system.abortJob(scheduleId);
        }
    }
}