高章伟
2023-03-03 d8dc84a3d56df839895f1c417a4d9cbee763d262
force-app/main/default/classes/EventToEventDetailsBatch.cls
@@ -10,19 +10,13 @@
    // 检索所有有任务(包括主动任务,被动任务)没有报告一览的事件,下月的
    global EventToEventDetailsBatch(){
        // this.query = 'select id from Event where task_id__c != \'\' and EventC_ID__c = \'\' and ActivityDate >= '+Date.today().format().ReplaceAll('/', '-')+' and ActivityDate < '+ Date.today().toStartOfMonth().addMonths(2).format().ReplaceAll('/', '-');
        //20210626 zh 任务框架修改  月末生成本月的报告一览 延期、取消的事件不生成报告一览 start
        // this.query = 'select id from Event where task_id__c != \'\' and EventC_ID__c = \'\' and ActivityDate < '+ Date.today().toStartOfMonth().addMonths(2).format().ReplaceAll('/', '-');
        this.query = 'select id from Event where task_id__c != \'\' and EventC_ID__c = \'\' and EventStatus__c not in (\'04 取消\',\'05 延期\',\'06 关闭\',\'07 未执行\') and ActivityDate < '+ Date.today().format().ReplaceAll('/', '-');
        //20210626 zh 任务框架修改  月末生成本月的报告一览 end
        this.query = 'select id from Event where task_id__c != \'\' and EventC_ID__c = \'\' and ActivityDate < '+ Date.today().toStartOfMonth().addMonths(2).format().ReplaceAll('/', '-');
        system.debug('query:'+query);
    }
    // 2021-03-09  mzy  WLIG-BYHD79  SFDC环境batch合并调查  start
    global EventToEventDetailsBatch(Boolean NeedExecute) {
        //20210626 zh 任务框架修改  月末生成本月的报告一览 延期、取消的事件不生成报告一览  start
        // this.query = 'select id from Event where task_id__c != \'\' and EventC_ID__c = \'\' and ActivityDate < '+ Date.today().toStartOfMonth().addMonths(2).format().ReplaceAll('/', '-');
        this.query = 'select id from Event where task_id__c != \'\' and EventC_ID__c = \'\' and EventStatus__c not in (\'04 取消\',\'05 延期\',\'06 关闭\',\'07 未执行\') and ActivityDate < '+ Date.today().format().ReplaceAll('/', '-');
        //20210626 zh 任务框架修改  月末生成本月的报告一览 end
        this.query = 'select id from Event where task_id__c != \'\' and EventC_ID__c = \'\' and ActivityDate < '+ Date.today().toStartOfMonth().addMonths(2).format().ReplaceAll('/', '-');
        this.IsNeedExecute = NeedExecute;
    }
    // 2021-03-09  mzy  WLIG-BYHD79  SFDC环境batch合并调查  end
@@ -61,7 +55,7 @@
        for(Event eve : (List<Event>)scope){
            eventIdSet.add(eve.Id);
        }
        List<Event> calenderList = [select id, ActivityDate, OwnerId, Subject, whatid__c, EventC_ID__c, NextEventC_ID__c, AppCdId__c, SyncCreatedDate__c, Task_ID__c,EventStatus__c,cancelReason__c,cancelReasonOther__c,cancelReasonSelect__c,cancelReasonSelectFSE__c,delayReason__c,delayReasonOther__c,delayReasonSelect__c,delayReasonSelectFSE__c,delayToDate__c,
        List<Event> calenderList = [select id, ActivityDate, OwnerId, Subject, whatid__c, EventC_ID__c, NextEventC_ID__c, AppCdId__c, SyncCreatedDate__c, Task_ID__c,
                                  StartDateTime, DurationInMinutes, Main_Visit_Location__c, Activity_Type2__c, IsScheduled__c, BeforeActivityDate__c,
                                  Visitor1__c, Visitor2__c, Visitor3__c, Visitor4__c, Visitor5__c, Visitor1_ID__c, Visitor2_ID__c, Visitor3_ID__c, Visitor4_ID__c, Visitor5_ID__c,
                                  Purpose_Type__c, Location, Related_Opportunity1__c, Related_Service1__c, Related_Opportunity1_ID__c, Related_Service1_ID__c,
@@ -153,14 +147,6 @@
                            location = e.Location;
                            whatid = e.whatid__c;
                        }
                        //20210527 zh 任务框架修改 start
                        String eventCStatus= '';
                        if ('05 延期'.equals(e.EventStatus__c)) {
                            eventCStatus = '延期';
                        }else if ('04 取消'.equals(e.EventStatus__c)) {
                            eventCStatus = '取消';
                        }
                        //20210527 zh 任务框架修改 end
                        Event__c ec = new Event__c(
                            Subject__c = e.Subject,
                            StartDateTime__c = e.StartDateTime,
@@ -207,19 +193,7 @@
                            Activity_PurposeFSE__c = e.Activity_PurposeFSE__c,
                            Activity_PurposeEscFSE__c = e.Activity_PurposeEscFSE__c,
                            Purpose_TypeFSE__c = e.Purpose_TypeFSE__c,
                            Purpose_TypeEscFSE__c = e.Purpose_TypeEscFSE__c,
                            //20210527 zh 任务框架修改 start
                            eventStatus__c = eventCStatus,
                            delayReason__c = e.delayReason__c,
                            delayReasonOther__c = e.delayReasonOther__c,
                            delayReasonSelect__c = e.delayReasonSelect__c,
                            delayReasonSelectFSE__c = e.delayReasonSelectFSE__c,
                            CancelReason__c = e.cancelReason__c,
                            cancelReasonSelectFSE__c = e.cancelReasonSelectFSE__c,
                            cancelReasonSelect__c = e.cancelReasonSelect__c,
                            cancelReasonOther__c = e.cancelReasonOther__c,
                            delayToDate__c = e.delayToDate__c
                            //20210527 zh 任务框架修改 end
                            Purpose_TypeEscFSE__c = e.Purpose_TypeEscFSE__c
                        );
                        // if(usrJobMap.get(e.OwnerId) != null && usrJobMap.get(e.OwnerId) == '销售服务'){
                        //     ec.Activity_PurposeFSE__c = e.Activity_PurposeFSE__c;