高章伟
2023-03-03 d8dc84a3d56df839895f1c417a4d9cbee763d262
force-app/main/default/classes/TenderInformationHandler.cls
@@ -67,7 +67,8 @@
        updateWin();
        // 中标任务 废标流标时清空中标日
        clearConfirmationofAward();
        //20221208 you DB202211594688
        //clearConfirmationofAward();
        //2022-3-29 yjk SWAG-CCL6R7
        //updateOpportunity();//2022-5-18 yjk XLIU-CEJ38N 注释掉 
@@ -103,15 +104,20 @@
            }
        }
        if (null!=oppTens && oppTens.size()>0) {
          List<Opportunity> opportunities = [select id, Bidding_Project_Name_Bid__c, TenderBeginDate_Text__c,Opp_Order__c from Opportunity where id in :oppIds];
           List<task__c> taskList = [select id,taskStatus__c,Tender_information_Task__c,OpportunityId__c from task__c where (RecordType.Name ='失单报告任务' and OpportunityId__c in:oppIds) or (RecordType.Name ='中标结果确认' and Opp_Tender__c in :oppTens)];
            //20221208 you DB202211594688 有确认任务的询价不清
          List<Opportunity> opportunities = [select id, Bidding_Project_Name_Bid__c, Opp_Order__c from Opportunity where id in :oppIds];
           List<task__c> taskList = [select id,taskStatus__c,RecordType.Name,Tender_information_Task__c,OpportunityId__c from task__c where ((RecordType.Name ='失单报告任务' and OpportunityId__c in:oppIds) or (RecordType.Name ='中标结果确认' and Opp_Tender__c in :oppTens)) and taskStatus__c <> '03 完成'];
            for(task__c tsk : taskList){
                tsk.taskStatus__c = '04 取消';
                tsk.cancelDate__c = date.today();
                if(null!=InfoTypeMap && InfoTypeMap.containsKey(tsk.OpportunityId__c)){
                   tsk.cancelReasonSelect__c = '修改项目阶段';
                if(tsk.RecordType.Name =='失单报告任务' && oppIds.contains(tsk.OpportunityId__c) && tsk.taskStatus__c !='03 完成'){
                  //不做操作
                }else{
                   tsk.cancelReasonSelect__c = '流标/废标';
                    tsk.taskStatus__c = '04 取消';
                    tsk.cancelDate__c = date.today();
                    if(null!=InfoTypeMap && InfoTypeMap.containsKey(tsk.OpportunityId__c)){
                       tsk.cancelReasonSelect__c = '修改项目阶段';
                    }else{
                       tsk.cancelReasonSelect__c = '流标/废标';
                    }
                }
            }
             update taskList;
@@ -119,15 +125,19 @@
                for (task__c tlink : taskList) {
                    for (Opportunity opp : opportunities) {
                        if (opp.Id == tlink.OpportunityId__c) {
                           //20220718 you 询价任务 start
                            opp.ConfirmationofAward__c = null;
                            opp.Task_createTime__c = null;
                            opp.ConfirmationofAward_createTime__c =null;
                            opp.LostTask_comfirmTime__c =null;
                            opp.Is_ConfirmationofAward__c =null;
                            opp.LostTask_createTime__c =null;
                            opp.Closing_Bid_Date__c = null;
                            //20220718 you 询价任务 end
                            if(tlink.RecordType.Name =='失单报告任务' && tlink.taskStatus__c !='03 完成'){
                              //不做操作
                            }else{
                               //20220718 you 询价任务 start
                                opp.ConfirmationofAward__c = null;
                                opp.Task_createTime__c = null;
                                opp.ConfirmationofAward_createTime__c =null;
                                opp.LostTask_comfirmTime__c =null;
                                opp.Is_ConfirmationofAward__c =null;
                                opp.LostTask_createTime__c =null;
                                //opp.Closing_Bid_Date__c = null;
                                //20220718 you 询价任务 end
                            }
                       }  
                    }
                }
@@ -758,6 +768,7 @@
        Map<Id,Tender_information__c> tOldMap = (Map<Id,Tender_information__c>) Trigger.oldMap;
        Map<Id,Tender_information__c> tNewMap = (Map<Id,Tender_information__c>) Trigger.newMap;
        List<Date> cd = new List<Date>();
        System.debug(LoggingLevel.INFO, '*** cd: ' + cd);
        System.debug(LoggingLevel.INFO, '*** tOldMap: ' + tOldMap);
        for(Tender_information__c t:(List<Tender_information__c>) Trigger.new){
            System.debug(LoggingLevel.INFO, '*** 进入for循环: ');
@@ -781,20 +792,31 @@
            }
        }
        Map<Date,String> lm = new Map<Date,String>();
        for(OlympusCalendar__c oc:[SELECT Id,Date__c FROM OlympusCalendar__c WHERE Date__c IN:cd]){
            lm.put(oc.Date__c,oc.Id);
            System.debug(LoggingLevel.INFO, '*** map赋值: ');
        }
        for(Tender_information__c l:(List<Tender_information__c>) Trigger.new){
            if (l.relativeDate__c == null) {
                continue;
        if(cd.size() > 0){
            for(OlympusCalendar__c oc:[SELECT Id,Date__c FROM OlympusCalendar__c WHERE Date__c IN:cd]){
                lm.put(oc.Date__c,oc.Id);
                System.debug(LoggingLevel.INFO, '*** map赋值: ');
            }
            String datastr = String.valueOf(l.relativeDate__c);
            String dt = lm.get(Date.valueOf(datastr.substring(0,10)));
            l.Tender_Olympus__c = dt;
            System.debug(LoggingLevel.INFO, '*** l.Tender_Olympus__c: '+ l.Tender_Olympus__c);
            for(Tender_information__c l:(List<Tender_information__c>) Trigger.new){
                //lt 20221114 DB202211270805 【紧急】招标项目是否按时关联计算错误 start
                // if (l.relativeDate__c == null) {
                //     continue;
                // }
                if (l.relativeDate__c == null && l.OBSAP_relativeTime__c == null) {
                    continue;
                }
                Datetime relativetime = l.OBSAP_relativeTime__c != null ? l.OBSAP_relativeTime__c : l.relativeTime__c;
                // String datastr = String.valueOf(l.relativeDate__c);
                String datastr = String.valueOf(relativetime);
                //lt 20221114 DB202211270805 【紧急】招标项目是否按时关联计算错误 end
                String dt = lm.get(Date.valueOf(datastr.substring(0,10)));
                System.debug(LoggingLevel.INFO, '*** dt: '+ dt);
                l.Tender_Olympus__c = dt;
                System.debug(LoggingLevel.INFO, '*** l.Tender_Olympus__c: '+ l.Tender_Olympus__c);
            }
        }
    }
// fxk 2021/8/3 反逻辑删除 end
// 20210824 中标时修改关联询价的招标项目名和中标时间
@@ -1277,6 +1299,8 @@
            }
        }
    }
    /**
    //20221208 you DB202211594688
    // 中标任务 废标流标时清空中标日
    public void clearConfirmationofAward() {
        List<String> tenders = new List<String>();
@@ -1312,4 +1336,5 @@
            }
        }
    }
    **/
}