| | |
| | | |
| | | protected override void beforeUpdate() { |
| | | //反逻辑删除 fxk |
| | | changeRelateOppDate(); |
| | | updateTenDel(); |
| | | AssignValueToAssistant(); |
| | | if (!StaticParameter.EscapeOtherUpdateTenOwner) { |
| | | updateTenOwner(); |
| | | } |
| | | |
| | | // 20221011 ljh SWAG-CK28WT start |
| | | updateTenOwnerJC(); |
| | | // 20221011 ljh SWAG-CK28WT end |
| | | //20220804 you 询价任务 |
| | | updateOppotunityBeforeUpdate(); |
| | | |
| | | } |
| | | |
| | | protected override void afterInsert() { |
| | | // 根据上面赋值的GI、SP助理,行政窗口,备品窗口,更新共享,共享原因不一样 |
| | | addShare(); |
| | | sednMessage(); |
| | | //sednMessage(); 20220729 you 招标项目 取消发送邮件通知 |
| | | // updateTenOwner(); |
| | | } |
| | | protected override void afterUpdate() { |
| | | addShare(); |
| | | sednMessage(); |
| | | addShare(); |
| | | //sednMessage(); 20220729 you 招标项目 取消发送邮件通知 |
| | | updateWin(); |
| | | |
| | | // 中标任务 废标流标时清空中标日 |
| | | clearConfirmationofAward(); |
| | | |
| | | //2022-3-29 yjk SWAG-CCL6R7 |
| | | updateOpportunity(); |
| | | //updateOpportunity();//2022-5-18 yjk XLIU-CEJ38N 注释掉 |
| | | } |
| | | |
| | | |
| | | //修改项目阶段,由 结果变为其他,,相关任务取消 |
| | | public void updateOppotunityBeforeUpdate() { |
| | | Set<String> Tenids = new Set<String>();//招标项目id,查询link |
| | | Set<String> oppTens = new Set<String>();//招标项目id,查询link |
| | | List<String> oppIds = new List<String>();//询价 |
| | | // 获得要更新的询价 |
| | | for (Tender_information__c record: newList) { |
| | | if ( ( ('3-5:中标通知'.equals((oldMap.get(record.Id).subInfoType__c)) || '3-6:合同公告'.equals((oldMap.get(record.Id).subInfoType__c)) ) && ('3-1:废标公告'.equals(record.subInfoType__c) || '3-2:流标公告'.equals(record.subInfoType__c) )) || (!'3:结果'.equals(record.InfoType__c) && '3:结果'.equals((oldMap.get(record.Id).InfoType__c)))) { |
| | | Tenids.add(record.id); |
| | | } |
| | | } |
| | | Map<String,String> InfoTypeMap = new Map<String,String>(); //判断是否是因为中标修改得 |
| | | if(null!=Tenids && Tenids.size()>0){ |
| | | |
| | | List<Tender_Opportunity_Link__c> TenOppLinkList = [select id, Tender_information__c,Tender_information__r.InfoType__c, Opportunity__c from Tender_Opportunity_Link__c where Tender_information__c in :Tenids]; |
| | | if(null!=TenOppLinkList && TenOppLinkList.size()>0){ |
| | | for(Tender_Opportunity_Link__c topl :TenOppLinkList){ |
| | | String oppid =String.valueOf(topl.Opportunity__c); |
| | | String tenid =String.valueOf(topl.Tender_information__c); |
| | | oppTens.add(oppid.subString(0,15)+tenid.subString(0,15)); |
| | | if (!oppIds.contains(topl.Opportunity__c)) { |
| | | oppIds.add(topl.Opportunity__c); |
| | | } |
| | | if(!'3:结果'.equals(topl.Tender_information__r.InfoType__c)){ |
| | | InfoTypeMap.put(topl.Opportunity__c,topl.Tender_information__c); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | 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)]; |
| | | 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 = '修改项目阶段'; |
| | | }else{ |
| | | tsk.cancelReasonSelect__c = '流标/废标'; |
| | | } |
| | | } |
| | | update taskList; |
| | | if(taskList.size() > 0){ |
| | | 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 |
| | | } |
| | | } |
| | | } |
| | | } |
| | | update opportunities; |
| | | } |
| | | } |
| | | //20220718 you 询价任务 end |
| | | // 20221027 updateOpportunity() 全文搜索过 没有调用的,方法引用已经注释,覆盖率不够方法体也注释(SWAG-CKL5UC), |
| | | //2022-3-29 yjk SWAG-CCL6R7 |
| | | private void updateOpportunity(){ |
| | | /*private void updateOpportunity(){ |
| | | for(Tender_information__c newOne : newList){ |
| | | Tender_information__c oldOne = oldMap.get(newOne.id); |
| | | if(oldOne.ResultDate__c == null && newOne.ResultDate__c != null){ |
| | |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }*/ |
| | | //20220729 you |
| | | //public void sednMessage() { |
| | | // //规则条件 |
| | | // //ISCHANGED(InfoType__c) && Text(InfoType__c) = '3:结果' && (Text(IsBid__c) = '是' || ( Text(IsBid__c) = '否' && OpportunityNum__c != null && OpportunityNum__c > 0) ) |
| | | // // 1)没有关联询价,确认相关性,那么就发给GI和SP助理; |
| | | // // 2)关联询价后,询价的所有人、项目所有人,GI和SP助理,收邮件; |
| | | // //关联询价 发给询价所有人 招标项目所有人 |
| | | // //没有关联询价并且做了相关性确认 发给招标项目所有人 |
| | | |
| | | public void sednMessage() { |
| | | //规则条件 |
| | | //ISCHANGED(InfoType__c) && Text(InfoType__c) = '3:结果' && (Text(IsBid__c) = '是' || ( Text(IsBid__c) = '否' && OpportunityNum__c != null && OpportunityNum__c > 0) ) |
| | | // 1)没有关联询价,确认相关性,那么就发给GI和SP助理; |
| | | // 2)关联询价后,询价的所有人、项目所有人,GI和SP助理,收邮件; |
| | | //关联询价 发给询价所有人 招标项目所有人 |
| | | //没有关联询价并且做了相关性确认 发给招标项目所有人 |
| | | // //1.判断是否符合大条件 拿到招标id |
| | | // Set<Id> zbIds = new Set<Id>(); |
| | | // //拿到招标id , 招标所有人 GI/SP助理 的邮件地址 |
| | | // Map<Id, Set<String>> zbOppMap = new Map<Id, Set<String>>(); |
| | | // List<Tender_information__c> tlist = new List<Tender_information__c>(); |
| | | |
| | | //1.判断是否符合大条件 拿到招标id |
| | | Set<Id> zbIds = new Set<Id>(); |
| | | //拿到招标id , 招标所有人 GI/SP助理 的邮件地址 |
| | | Map<Id, Set<String>> zbOppMap = new Map<Id, Set<String>>(); |
| | | List<Tender_information__c> tlist = new List<Tender_information__c>(); |
| | | // for (Tender_information__c ten : newList) { |
| | | // // if (ten.InfoType__c == '3:结果' && |
| | | // // (ten.IsBid__c == '是' || (ten.IsBid__c == '否' && ten.OpportunityNum__c != null && ten.OpportunityNum__c > 0)) |
| | | // // && (Trigger.isInsert || (Trigger.isUpdate && oldMap.get(ten.Id).InfoType__c != '3:结果'))) { |
| | | // // zbIds.add(ten.Id); |
| | | // // } |
| | | // // 判断条件修改 |
| | | // if (ten.InfoType__c == '3:结果' && (Trigger.isInsert || (Trigger.isUpdate && oldMap.get(ten.Id).InfoType__c != '3:结果'))) { |
| | | // // 如果招标所有人为系统管理员(OlympusSystem)时需要跳过 |
| | | // if (ten.Ownerid != '00510000000gmxH') { |
| | | // zbIds.add(ten.Id); |
| | | // } |
| | | // } |
| | | // } |
| | | // if (zbIds.size() > 0) { |
| | | // tlist = [select Id, GI_assistant__r.Email, SP_assistant__r.Email, Hospital__r.Name, BudgetAmount__c, Name, department__r.Name, OpenBidingTime__c, Owner.Alias, Owner.Email from Tender_information__c where id in :zbIds]; |
| | | // for (Tender_information__c ten : tlist) { |
| | | // if (!zbOppMap.containsKey(ten.Id)) { |
| | | // zbOppMap.put(ten.Id, new Set<String>()); |
| | | // } |
| | | // zbOppMap.get(ten.Id).add(ten.Owner.Email); |
| | | |
| | | for (Tender_information__c ten : newList) { |
| | | // if (ten.InfoType__c == '3:结果' && |
| | | // (ten.IsBid__c == '是' || (ten.IsBid__c == '否' && ten.OpportunityNum__c != null && ten.OpportunityNum__c > 0)) |
| | | // && (Trigger.isInsert || (Trigger.isUpdate && oldMap.get(ten.Id).InfoType__c != '3:结果'))) { |
| | | // zbIds.add(ten.Id); |
| | | // } |
| | | // 判断条件修改 |
| | | if (ten.InfoType__c == '3:结果' && (Trigger.isInsert || (Trigger.isUpdate && oldMap.get(ten.Id).InfoType__c != '3:结果'))) { |
| | | // 如果招标所有人为系统管理员(OlympusSystem)时需要跳过 |
| | | if (ten.Id != '00510000000gmxH') { |
| | | zbIds.add(ten.Id); |
| | | } |
| | | } |
| | | } |
| | | if (zbIds.size() > 0) { |
| | | tlist = [select Id, GI_assistant__r.Email, SP_assistant__r.Email, Hospital__r.Name, BudgetAmount__c, Name, department__r.Name, OpenBidingTime__c, Owner.Alias, Owner.Email from Tender_information__c where id in :zbIds]; |
| | | for (Tender_information__c ten : tlist) { |
| | | if (!zbOppMap.containsKey(ten.Id)) { |
| | | zbOppMap.put(ten.Id, new Set<String>()); |
| | | } |
| | | zbOppMap.get(ten.Id).add(ten.Owner.Email); |
| | | // } |
| | | // //取得询价 |
| | | // // 招标-询价关联修改 20210817 start |
| | | // // List<Opportunity> oppList = new List<Opportunity>(); |
| | | // // oppList = [select id,Owner.Email,Bidding_Project_Name_Bid__c,Bidding_Project_Name_Bid__r.owner.Email from Opportunity where Bidding_Project_Name_Bid__c in :zbIds]; |
| | | // // if (oppList.size() > 0) { |
| | | // // for (Opportunity opp : oppList) { |
| | | // // // 能走到这说明 询价的所有人、项目所有人 也得发邮件 |
| | | // // if (!zbOppMap.containsKey(opp.Bidding_Project_Name_Bid__c)) { |
| | | // // zbOppMap.put(opp.Bidding_Project_Name_Bid__c, new Set<String>()); |
| | | // // } |
| | | // // zbOppMap.get(opp.Bidding_Project_Name_Bid__c).add(opp.Owner.Email); |
| | | // // // zbOppMap.get(opp.Bidding_Project_Name_Bid__c).add(opp.Bidding_Project_Name_Bid__r.owner.Email); |
| | | // // } |
| | | // // } |
| | | // List<Tender_Opportunity_Link__c> link_list = [select id, Tender_information__c, Opportunity__r.Owner.Email from Tender_Opportunity_Link__c where Tender_information__c in :zbIds]; |
| | | // if (link_list != null && link_list.size() > 0) { |
| | | // for (Tender_Opportunity_Link__c link : link_list) { |
| | | // // 能走到这说明 询价的所有人、项目所有人 也得发邮件 |
| | | // if (!zbOppMap.containsKey(link.Tender_information__c)) { |
| | | // zbOppMap.put(link.Tender_information__c, new Set<String>()); |
| | | // } |
| | | // zbOppMap.get(link.Tender_information__c).add(link.Opportunity__r.Owner.Email); |
| | | // } |
| | | // } |
| | | // // 招标-询价关联修改 20210817 end |
| | | // } |
| | | |
| | | } |
| | | //取得询价 |
| | | // 招标-询价关联修改 20210817 start |
| | | // List<Opportunity> oppList = new List<Opportunity>(); |
| | | // oppList = [select id,Owner.Email,Bidding_Project_Name_Bid__c,Bidding_Project_Name_Bid__r.owner.Email from Opportunity where Bidding_Project_Name_Bid__c in :zbIds]; |
| | | // if (oppList.size() > 0) { |
| | | // for (Opportunity opp : oppList) { |
| | | // // 能走到这说明 询价的所有人、项目所有人 也得发邮件 |
| | | // if (!zbOppMap.containsKey(opp.Bidding_Project_Name_Bid__c)) { |
| | | // zbOppMap.put(opp.Bidding_Project_Name_Bid__c, new Set<String>()); |
| | | // } |
| | | // zbOppMap.get(opp.Bidding_Project_Name_Bid__c).add(opp.Owner.Email); |
| | | // // zbOppMap.get(opp.Bidding_Project_Name_Bid__c).add(opp.Bidding_Project_Name_Bid__r.owner.Email); |
| | | // } |
| | | // } |
| | | List<Tender_Opportunity_Link__c> link_list = [select id, Tender_information__c, Opportunity__r.Owner.Email from Tender_Opportunity_Link__c where Tender_information__c in :zbIds]; |
| | | if (link_list != null && link_list.size() > 0) { |
| | | for (Tender_Opportunity_Link__c link : link_list) { |
| | | // 能走到这说明 询价的所有人、项目所有人 也得发邮件 |
| | | if (!zbOppMap.containsKey(link.Tender_information__c)) { |
| | | zbOppMap.put(link.Tender_information__c, new Set<String>()); |
| | | } |
| | | zbOppMap.get(link.Tender_information__c).add(link.Opportunity__r.Owner.Email); |
| | | } |
| | | } |
| | | // 招标-询价关联修改 20210817 end |
| | | } |
| | | // if (zbOppMap.size() > 0) { |
| | | // if (tlist.size() > 0) { |
| | | // List<Messaging.SingleEmailMessage> sendMails = new List<Messaging.SingleEmailMessage>(); |
| | | |
| | | if (zbOppMap.size() > 0) { |
| | | if (tlist.size() > 0) { |
| | | List<Messaging.SingleEmailMessage> sendMails = new List<Messaging.SingleEmailMessage>(); |
| | | // for (Tender_information__c ten : tlist) { |
| | | // if (zbOppMap.containsKey(ten.Id)) { |
| | | // String body = ''; |
| | | // String title = ''; |
| | | // String BudgetAmount = ten.BudgetAmount__c == null ? '' : ten.BudgetAmount__c + ''; |
| | | // String HospitalName = ten.Hospital__c == null ? '' : ten.Hospital__r.Name; |
| | | // String departmentName = ten.department__c == null ? '' : ten.department__r.Name; |
| | | // String OpenBidingTime = ten.OpenBidingTime__c == null ? '' : ten.OpenBidingTime__c.format(); |
| | | |
| | | for (Tender_information__c ten : tlist) { |
| | | if (zbOppMap.containsKey(ten.Id)) { |
| | | String body = ''; |
| | | String title = ''; |
| | | String BudgetAmount = ten.BudgetAmount__c == null ? '' : ten.BudgetAmount__c + ''; |
| | | String HospitalName = ten.Hospital__c == null ? '' : ten.Hospital__r.Name; |
| | | String departmentName = ten.department__c == null ? '' : ten.department__r.Name; |
| | | String OpenBidingTime = ten.OpenBidingTime__c == null ? '' : ten.OpenBidingTime__c.format(); |
| | | // title = '中标结果:' + ten.Hospital__r.Name + ' 预算金额' + BudgetAmount + '已有中标结果请确认'; |
| | | |
| | | title = '中标结果:' + ten.Hospital__r.Name + ' 预算金额' + BudgetAmount + '已有中标结果请确认'; |
| | | // body += '项目名:' + ten.Name + '<br/>'; |
| | | // body += '预算金额:' + BudgetAmount + '<br/>'; |
| | | // body += '医院:' + HospitalName + '<br/>'; |
| | | // // body += '战略科室:'+departmentName + '<br/>'; |
| | | // body += '中标日:' + OpenBidingTime + '<br/>'; |
| | | // body += '主担当:' + ten.Owner.Alias + '<br/>'; |
| | | // body += '招投标链接: <br/>'; |
| | | // body += '<a href="' + URL.getSalesforceBaseUrl().toExternalForm() + '/' + ten.Id + '">' + URL.getSalesforceBaseUrl().toExternalForm() + '/' + ten.Id + '</a><br/>'; |
| | | // // body += '收件人: '+zbOppMap.get(ten.Id); |
| | | |
| | | body += '项目名:' + ten.Name + '<br/>'; |
| | | body += '预算金额:' + BudgetAmount + '<br/>'; |
| | | body += '医院:' + HospitalName + '<br/>'; |
| | | // body += '战略科室:'+departmentName + '<br/>'; |
| | | body += '中标日:' + OpenBidingTime + '<br/>'; |
| | | body += '主担当:' + ten.Owner.Alias + '<br/>'; |
| | | body += '招投标链接: <br/>'; |
| | | body += '<a href="' + URL.getSalesforceBaseUrl().toExternalForm() + '/' + ten.Id + '">' + URL.getSalesforceBaseUrl().toExternalForm() + '/' + ten.Id + '</a><br/>'; |
| | | // body += '收件人: '+zbOppMap.get(ten.Id); |
| | | // List<String> toMailList = new List<String>(); |
| | | // // List<String> toccList = new List<String>(); |
| | | // // emas.add(UserInfo.getUserEmail()); |
| | | // //收信人 |
| | | // toMailList.addAll(zbOppMap.get(ten.Id)); |
| | | // // if (toMailList.contains(null)) { |
| | | // // toMailList.remove(null); |
| | | // // } |
| | | // // toMailList.add('rentongxiao@prec-tech.com'); |
| | | // //抄送人 |
| | | // // toccList.add('gzw@prec-tech.com'); |
| | | // // toccList.add('rentongxiao@prec-tech.com'); |
| | | // Messaging.SingleEmailMessage messageNEW = new Messaging.SingleEmailMessage(); |
| | | // messageNEW.subject = title; |
| | | // //messageNEW.plainTextBody = body; |
| | | // messageNEW.htmlBody = body; |
| | | // messageNEW.setCharset('UTF-8'); |
| | | // messageNEW.toAddresses = toMailList; |
| | | // // messageNEW.ccAddresses = toccList; |
| | | // sendMails.add(messageNEW); |
| | | // } |
| | | // } |
| | | |
| | | List<String> toMailList = new List<String>(); |
| | | // List<String> toccList = new List<String>(); |
| | | // emas.add(UserInfo.getUserEmail()); |
| | | //收信人 |
| | | toMailList.addAll(zbOppMap.get(ten.Id)); |
| | | // if (toMailList.contains(null)) { |
| | | // toMailList.remove(null); |
| | | // } |
| | | // toMailList.add('rentongxiao@prec-tech.com'); |
| | | //抄送人 |
| | | // toccList.add('gzw@prec-tech.com'); |
| | | // toccList.add('rentongxiao@prec-tech.com'); |
| | | Messaging.SingleEmailMessage messageNEW = new Messaging.SingleEmailMessage(); |
| | | messageNEW.subject = title; |
| | | //messageNEW.plainTextBody = body; |
| | | messageNEW.htmlBody = body; |
| | | messageNEW.setCharset('UTF-8'); |
| | | messageNEW.toAddresses = toMailList; |
| | | // messageNEW.ccAddresses = toccList; |
| | | sendMails.add(messageNEW); |
| | | } |
| | | } |
| | | |
| | | if (sendMails.size() > 0) { |
| | | for (Messaging.SingleEmailMessage mc : sendMails) { |
| | | List<Messaging.SingleEmailMessage> tempsendMails = new List<Messaging.SingleEmailMessage>(); |
| | | tempsendMails.add(mc); |
| | | Messaging.SendEmailResult[] results = null; |
| | | if (!NFMUtil.isSandbox()) { |
| | | results = messaging.sendEmail(tempsendMails); |
| | | } |
| | | if (results != null && results.size() > 0) { |
| | | for (Integer i = 0; i < results.size(); i++) { |
| | | if (results[i].success == false) { |
| | | System.debug('邮件:::' + mc.getSubject() + '发送失败'); |
| | | } else { |
| | | System.debug('邮件:::' + mc.getSubject() + '发送成功'); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | // if (sendMails.size() > 0) { |
| | | // for (Messaging.SingleEmailMessage mc : sendMails) { |
| | | // List<Messaging.SingleEmailMessage> tempsendMails = new List<Messaging.SingleEmailMessage>(); |
| | | // tempsendMails.add(mc); |
| | | // Messaging.SendEmailResult[] results = null; |
| | | // if (!NFMUtil.isSandbox()) { |
| | | // results = messaging.sendEmail(tempsendMails); |
| | | // } |
| | | // if (results != null && results.size() > 0) { |
| | | // for (Integer i = 0; i < results.size(); i++) { |
| | | // if (results[i].success == false) { |
| | | // System.debug('邮件:::' + mc.getSubject() + '发送失败'); |
| | | // } else { |
| | | // System.debug('邮件:::' + mc.getSubject() + '发送成功'); |
| | | // } |
| | | // } |
| | | // } |
| | | // } |
| | | // } |
| | | // } |
| | | // } |
| | | //} |
| | | |
| | | |
| | | |
| | |
| | | //取值顺序是:所有人,之后是gi助理,接下来是sp助理,接下来是战略科室所有人 所以倒着来 |
| | | List<Tender_information__Share> tenShareList = new List<Tender_information__Share>(); |
| | | for (Tender_information__c tenc : newList) { |
| | | // 20221013 ljh SWAG-CK28WT start |
| | | // 集采项目 后续共享不需要,只把原来的共享删除 |
| | | if(tenc.CentralizedProject__c){ |
| | | continue; |
| | | } |
| | | // 20221013 ljh SWAG-CK28WT start |
| | | //一个map为 针对一条招投标计划的共享 |
| | | Map<Id, Tender_information__Share> sharemap = new Map<Id, Tender_information__Share>(); |
| | | //1.先设置 医院担当的共享 |
| | |
| | | tenShareList.addAll(sharemap.values()); |
| | | |
| | | } |
| | | |
| | | |
| | | //现在用的是全删全加的方法,没有再判断是否发生改变了 |
| | | //删除 |
| | | List<Tender_information__Share> beforeShareList = |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 2022-04-03 增加判断 当用户无效时也跳过设置 |
| | | */ |
| | | public void AssignValueToAssistant() { |
| | | //根据ocsm管理省的助理设置当前招投标项目的gi/sp助理 |
| | | Map<String, OCM_Management_Province__c> mpMap = new Map<String, OCM_Management_Province__c>(); |
| | |
| | | for (OCM_Management_Province__c mp : [SELECT id, Name, GI_assistant__c, SP_assistant__c, SP_assistant__r.IsActive, GI_assistant__r.IsActive, Window2__c, Window2__r.IsActive, Admin_assistant3__c, Admin_assistant3__r.IsActive, TenderAssistant1__c, TenderAssistant1__r.IsActive, TenderAssistant2__c, TenderAssistant2__r.IsActive, Window1__c, Window1__r.IsActive FROM OCM_Management_Province__c]) { |
| | | mpMap.put(mp.Name, mp); |
| | | } |
| | | |
| | | //设置GI/SP助理 行政助理、备品窗口 |
| | | //直接设置 信息负责人(助理) 为GI助理 |
| | | for (Tender_information__c info : newList) { |
| | |
| | | info.GI_assistant__c = ocm.GI_assistant__c; |
| | | } |
| | | if (info.InfoOwner__c != ocm.GI_assistant__c) { |
| | | info.InfoOwner__c = ocm.GI_assistant__c; |
| | | if(info.CentralizedProject__c == false){ // 20221012 ljh SWAG-CK28WT 添加的if |
| | | info.InfoOwner__c = ocm.GI_assistant__c; |
| | | } |
| | | } |
| | | } |
| | | // 增加GI助理为空时的处理,清空招标项目的GI助理和信息负责人(助理) 20210813 |
| | | else if (ocm.GI_assistant__c == null) { |
| | | else if (ocm.GI_assistant__c == null || !ocm.GI_assistant__r.IsActive) { |
| | | info.GI_assistant__c = null; |
| | | info.InfoOwner__c = ocm.GI_assistant__c; |
| | | if(info.CentralizedProject__c == false){ // 20221012 ljh SWAG-CK28WT 添加的if |
| | | info.InfoOwner__c = null; |
| | | } |
| | | } |
| | | if (ocm.SP_assistant__r.IsActive && info.SP_assistant__c != ocm.SP_assistant__c) { |
| | | info.SP_assistant__c = ocm.SP_assistant__c; |
| | | } |
| | | // 增加SP助理为空时的处理,清空招标项目的SP助理 20210813 |
| | | else if (ocm.SP_assistant__c == null) { |
| | | else if (ocm.SP_assistant__c == null || !ocm.GI_assistant__r.IsActive) { |
| | | info.SP_assistant__c = null; |
| | | } |
| | | if (ocm.Window2__r.IsActive && info.Window2__c != ocm.Window2__c) { |
| | | info.Window2__c = ocm.Window2__c; |
| | | } |
| | | // 清空行政窗口 20210813 |
| | | else if (ocm.Window2__c == null) { |
| | | else if (ocm.Window2__c == null || !ocm.Window2__r.IsActive) { |
| | | info.Window2__c = null; |
| | | } |
| | | // |
| | |
| | | info.TenderAssistant1__c = ocm.TenderAssistant1__c; |
| | | } |
| | | // 清空招标助理1 20210813 |
| | | else if (ocm.TenderAssistant1__c == null) { |
| | | else if (ocm.TenderAssistant1__c == null || !ocm.TenderAssistant1__r.IsActive) { |
| | | info.TenderAssistant1__c = null; |
| | | } |
| | | if (ocm.TenderAssistant2__r.IsActive && info.TenderAssistant2__c != ocm.TenderAssistant2__c) { |
| | | info.TenderAssistant2__c = ocm.TenderAssistant2__c; |
| | | } |
| | | // 清空招标助理2 20210813 |
| | | else if (ocm.TenderAssistant2__c == null) { |
| | | else if (ocm.TenderAssistant2__c == null || !ocm.TenderAssistant2__r.IsActive) { |
| | | info.TenderAssistant2__c = null; |
| | | } |
| | | |
| | |
| | | info.YingyeWindow__c = ocm.Window1__c; |
| | | } |
| | | // 清空营业窗口 20210813 |
| | | else if (ocm.Window1__c == null) { |
| | | else if (ocm.Window1__c == null || !ocm.Window1__r.IsActive) { |
| | | info.YingyeWindow__c = null; |
| | | } |
| | | } |
| | |
| | | || tenDepartList.contains('01210000000QezoAAC') |
| | | || tenDepartList.contains('01210000000QeztAAC')){ |
| | | System.debug('=====-----'+info.department_selection__c); |
| | | info.InfoOwner__c = info.SP_assistant__c; |
| | | if(info.CentralizedProject__c == false){ // 20221012 ljh SWAG-CK28WT 添加的if |
| | | info.InfoOwner__c = info.SP_assistant__c; |
| | | } |
| | | |
| | | } |
| | | } |
| | | // add 战略科室分类为普外科、泌尿科、妇科、耳鼻喉科时,信息负责人(助理)修改为 SP助理 2021、11、11 fxk end |
| | | // 20221012 ljh SWAG-CK28WT start |
| | | if(info.CentralizedProject__c){ |
| | | // 清除这些人赋值 (就没有权限了) |
| | | info.GI_assistant__c = null; |
| | | info.SP_assistant__c = null; |
| | | info.Window2__c = null; |
| | | info.TenderAssistant1__c = null; |
| | | info.TenderAssistant2__c = null; |
| | | info.YingyeWindow__c = null; |
| | | } |
| | | // 20221012 ljh SWAG-CK28WT end |
| | | } |
| | | // 20221027 ljh SWAG-CKL5UC add start |
| | | // 项目中当结果记录日有值公告记录日为空时,给公告记录日赋值逻辑=结果记录日-15天 |
| | | if(info.ResultDate__c != null && info.publicDate__c == null){ |
| | | info.publicDate__c = info.ResultDate__c.addDays(-15); |
| | | } |
| | | // 20221027 ljh SWAG-CKL5UC add start |
| | | } |
| | | |
| | | } |
| | | // fxk 2021/8/3 反逻辑删除 Star |
| | | private void updateTenDel() { |
| | |
| | | } |
| | | } |
| | | } |
| | | |
| | | private void changeRelateOppDate(){ |
| | | System.debug(LoggingLevel.INFO, '*** 进入方法: '); |
| | | List<String> oldUserOrGroups = new List<String>(); |
| | | 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, '*** tOldMap: ' + tOldMap); |
| | | for(Tender_information__c t:(List<Tender_information__c>) Trigger.new){ |
| | | System.debug(LoggingLevel.INFO, '*** 进入for循环: '); |
| | | System.debug(LoggingLevel.INFO, '*** t: ' + t); |
| | | if(Trigger.isUpdate){ |
| | | if (String.isNotBlank(t.IsRelateProject__c) && t.IsRelateProject__c == '是' && t.relativeTime__c == null && System.Label.ProfileId_2S6.equals(UserInfo.getProfileId())) { |
| | | t.relativeTime__c = Datetime.now(); |
| | | } |
| | | System.debug(LoggingLevel.INFO, '*** tOldMap: ' + tOldMap.get(t.Id).relativeDate__c); |
| | | System.debug(LoggingLevel.INFO, '*** t.relativeDate__c: ' + t.relativeDate__c); |
| | | // if(tOldMap.get(t.Id).relativeDate__c != null && t.relativeDate__c != tOldMap.get(t.Id).relativeDate__c){ |
| | | //lt 20221114 DB202211270805 【紧急】招标项目是否按时关联计算错误 start |
| | | // if(t.relativeDate__c != null && t.relativeDate__c != tOldMap.get(t.Id).relativeDate__c){ |
| | | if(((t.OBSAP_relativeTime__c != null || t.relativeTime_F__c != null) && t.Tender_Olympus__c == null) || (t.relativeDate__c != null && t.relativeDate__c != tOldMap.get(t.Id).relativeDate__c)){ |
| | | //lt 20221114 DB202211270805 【紧急】招标项目是否按时关联计算错误 end |
| | | System.debug(LoggingLevel.INFO, '*** 进入if语句: '); |
| | | String datastr = String.valueOf(t.relativeDate__c); |
| | | cd.add( Date.valueOf(datastr.substring(0,10)) ); |
| | | System.debug(LoggingLevel.INFO, '*** cd: ' + cd); |
| | | } |
| | | } |
| | | } |
| | | 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; |
| | | } |
| | | 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); |
| | | } |
| | | } |
| | | // fxk 2021/8/3 反逻辑删除 end |
| | | // 20210824 中标时修改关联询价的招标项目名和中标时间 |
| | | private void updateWin() { |
| | | List<String> tenderIds = new List<String>(); |
| | | List<String> lostWinIds = new List<String>(); |
| | | // 20221028 ljh SWAG-CKL5UC start |
| | | Map<Id,Tender_information__c> tendMap = New Map<Id,Tender_information__c>(); |
| | | Map<Id,Opportunity> updateOpp = New Map<Id,Opportunity>(); |
| | | // 20221028 ljh SWAG-CKL5UC end |
| | | for (Tender_information__c ten : newList) { |
| | | /** 20220614 SWAG-CFD4SU you 更改,询价优先显示项目阶段最新的招标项目信息 |
| | | if ('3:结果'.equals(ten.InfoType__c) && !'3:结果'.equals((oldMap.get(ten.Id).InfoType__c))) { |
| | | tenderIds.add(ten.Id); |
| | | } else if (!'3:结果'.equals(ten.InfoType__c) && '3:结果'.equals((oldMap.get(ten.Id).InfoType__c))) { |
| | | lostWinIds.add(ten.Id); |
| | | } |
| | | **/ |
| | | //上线处理老数据 |
| | | if((String.isNotBlank(ten.InfoType__c) && ten.InfoType__c != oldMap.get(ten.Id).InfoType__c) || (String.isNotBlank(ten.subInfoType__c) && ten.subInfoType__c != oldMap.get(ten.Id).subInfoType__c) || System.Label.TenderToOpp == '1'){ |
| | | tenderIds.add(ten.Id); |
| | | } |
| | | // 20221028 ljh SWAG-CKL5UC add start |
| | | // 关联询价的 询价页面创建日晚于招标项目公告记录日,漏单数为1 |
| | | // 关联询价的 && 更新有值 |
| | | if(ten.OpportunityNum__c > 0 && Trigger.isUpdate && oldMap.get(ten.Id).publicDate__c == null && ten.publicDate__c != null){ |
| | | tendMap.put(ten.Id, ten); |
| | | } |
| | | // 20221028 ljh SWAG-CKL5UC add end |
| | | |
| | | } |
| | | if (tenderIds.size() > 0) { |
| | | //20220616 SWAG-CFD4SU you 增加order by |
| | | //查询招标项目下所有中间表 |
| | | List<Tender_Opportunity_Link__c> links = |
| | | [SELECT id, |
| | | Tender_information__c, |
| | | Tender_information__r.OpenBidingTime__c, |
| | | Tender_information__r.WinnerAmount__c, |
| | | Tender_information__r.ZhongBiaoUnit1__c, |
| | | Tender_information__r.Tender_Order__c, |
| | | Opportunity__c |
| | | FROM Tender_Opportunity_Link__c |
| | | WHERE Tender_information__c IN :tenderIds |
| | | AND Opportunity__r.Bidding_Project_Name_Bid__c NOT IN :tenderIds]; |
| | | WHERE Tender_information__c IN :tenderIds];// AND Opportunity__r.Bidding_Project_Name_Bid__c NOT IN :tenderIds |
| | | if (links != null && links.size() > 0) { |
| | | List<String> oppIds = new List<String>(); |
| | | for (Tender_Opportunity_Link__c link : links) { |
| | | oppIds.add(link.Opportunity__c); |
| | | } |
| | | if (oppIds.size() > 0) { |
| | | List<Opportunity> opps = [select id, Bidding_Project_Name_Bid__c, Bidding_Project_Name_Bid__r.InfoType__c, Closing_Bid_Date_Bid__c from Opportunity where Id in :oppIds and Bidding_Project_Name_Bid__r.InfoType__c != '3:结果']; |
| | | //查询询价下所有中间表 |
| | | List<Tender_Opportunity_Link__c> links1 = |
| | | [SELECT id, |
| | | Tender_information__c, |
| | | Tender_information__r.OpenBidingTime__c, |
| | | Tender_information__r.WinnerAmount__c, |
| | | Tender_information__r.ZhongBiaoUnit1__c, |
| | | Tender_information__r.Tender_Order__c, |
| | | Tender_information__r.InfoType__c, |
| | | Tender_information__r.subInfoType__c, |
| | | Opportunity__c |
| | | FROM Tender_Opportunity_Link__c |
| | | WHERE Opportunity__c IN :oppIds order by Opportunity__c,Tender_information__r.Tender_Order__c desc, Tender_information__r.relativeTime_F__c desc]; |
| | | List<Opportunity> opps = [select id, Bidding_Project_Name_Bid__c, Bidding_Project_Name_Bid__r.InfoType__c, Closing_Bid_Date_Bid__c,Opp_Order__c from Opportunity where Id in :oppIds];// and Bidding_Project_Name_Bid__r.InfoType__c != '3:结果' |
| | | if (opps != null && opps.size() > 0) { |
| | | for (Opportunity opp : opps) { |
| | | for (Tender_Opportunity_Link__c link : links) { |
| | | if(links1 !=null && links1.size() > 0){ |
| | | for (Tender_Opportunity_Link__c link : links1) { |
| | | if (link.Opportunity__c == opp.Id) { |
| | | opp.Bidding_Project_Name_Bid__c = link.Tender_information__c; |
| | | break; |
| | | //20220616 SWAG-CFD4SU you start 改造,询价实时显示项目阶段最新的招标项目信息 |
| | | if(opp.Opp_Order__c <= link.Tender_information__r.Tender_Order__c){ |
| | | opp.Bidding_Project_Name_Bid__c = link.Tender_information__c; |
| | | break; |
| | | } |
| | | //20220616 SWAG-CFD4SU you end 改造,询价实时显示项目阶段最新的招标项目信息 |
| | | } |
| | | } |
| | | } |
| | | //20220830 you SWAG-CHL67J start |
| | | Integer returncount =0; |
| | | for (Tender_Opportunity_Link__c link : links1) { |
| | | if (link.Opportunity__c == opp.Id) { |
| | | if(String.isNotBlank(link.Tender_information__r.InfoType__c) && link.Tender_information__r.InfoType__c!='1:预告' && String.isNotBlank(link.Tender_information__r.subInfoType__c) && link.Tender_information__r.subInfoType__c!='3-1:废标公告' && link.Tender_information__r.subInfoType__c!='3-2:流标公告'){ |
| | | system.debug('test2进来了'); |
| | | returncount += 1; |
| | | } |
| | | } |
| | | } |
| | | opp.Tender_Number__c =returncount; |
| | | //20220830 you SWAG-CHL67J end |
| | | } |
| | | // 需要跳过询价trigger 防止出现重复更新的情况 |
| | | StaticParameter.EscapeOpportunityBefUpdTrigger = true; |
| | |
| | | } |
| | | } |
| | | } |
| | | /**20220616 SWAG-CFD4SU you |
| | | if (lostWinIds.size() > 0) { |
| | | List<Tender_Opportunity_Link__c> links_2 = |
| | | [SELECT id, |
| | |
| | | } |
| | | } |
| | | } |
| | | **/ |
| | | // 20221028 ljh SWAG-CKL5UC add start |
| | | if(tendMap.size() > 0){ |
| | | List<Tender_Opportunity_Link__c> links = [select id, Opportunity__c, Tender_information__c, Opportunity__r.Created_Day__c ,Opportunity__r.LeakageNumber__c,Opportunity__r.LeadSource from Tender_Opportunity_Link__c where Tender_information__c in :tendMap.keySet()]; |
| | | for(Tender_Opportunity_Link__c lk:links){ |
| | | if(lk.Opportunity__r.Created_Day__c > tendMap.get(lk.Tender_information__c).publicDate__c && lk.Opportunity__r.LeadSource == '招标网'){ |
| | | Opportunity opp = new Opportunity(); |
| | | opp.Id = lk.Opportunity__c; |
| | | opp.LeakageNumber__c = 1; |
| | | updateOpp.put(opp.Id,opp); |
| | | } |
| | | } |
| | | } |
| | | if(updateOpp.size() > 0){ |
| | | update updateOpp.values(); |
| | | } |
| | | // 20221028 ljh SWAG-CKL5UC add end |
| | | } |
| | | |
| | | public void updateTenOwner() { |
| | |
| | | oppMainMap.put(oppLinks.Tender_information__c, oppLinks.Opportunity__r.OwnerId ); |
| | | } |
| | | } |
| | | |
| | | for (Id tenderId : hpTypeToMainMap.keySet()) { |
| | | for (Tender_information__c info : newList) { |
| | | // add 【委托】P-招标项目-手动创建的招标项目增加必填字段 2021/11/03 fxk Star |
| | |
| | | System.debug('----------9---------' + UpdateTenMap); |
| | | } |
| | | } else { |
| | | UpdateTenMap.put(tenderId, '00510000000gmxH'); |
| | | System.debug('----------10---------' + UpdateTenMap); |
| | | // 20220421 SWAG-CC58ME ljh add 是否相关:是;关联医院:!null; 关联战略科室 null; start |
| | | // 是否应标:有值 :所有人:启用 不需要更新 |
| | | // UpdateTenMap.put(tenderId, '00510000000gmxH'); |
| | | // System.debug('----------10---------' + UpdateTenMap); |
| | | if(!(String.isNotBlank(info.IsBid__c) && info.OwnerIsActive__c)){ |
| | | UpdateTenMap.put(tenderId, '00510000000gmxH'); |
| | | System.debug('----------10---------' + UpdateTenMap); |
| | | } |
| | | // 20220421 SWAG-CC58ME ljh add 是否相关:是;关联医院:!null; 关联战略科室 null; end |
| | | } |
| | | } else if ((oldTen.OwnerId != null && oldTen.OwnerId.equals(info.OwnerId)) |
| | | && !hpMainMap.get(tenderId).containskey(info.ownerId)) { |
| | | UpdateTenMap.put(tenderId, oppMainMap.get(tenderId)); |
| | | System.debug('----------11---------' + UpdateTenMap); |
| | | } else { |
| | | /* |
| | | 20220422 SWAG-CC58ME ljh update |
| | | 针对如下场景做的修改: |
| | | 相关性确认:之后所有人取了医院+第一个战略科室的主担当A,然后关联询价,询价所有人是B, |
| | | 所有人取了B。然后B离职了,运行Batch,变成A,在把B启用,不变会来B |
| | | */ |
| | | // 20220422 ljh update start |
| | | System.debug('zheli:'+oppMainMap.get(tenderId)); |
| | | Boolean a = oldTen.OwnerId.equals(info.OwnerId); |
| | | Boolean b = !hpMainMap.get(tenderId).containskey(info.ownerId); |
| | | System.debug('zheli:'+a+b); |
| | | // if ((oldTen.OwnerId != null && oldTen.OwnerId.equals(info.OwnerId)) |
| | | // && !hpMainMap.get(tenderId).containskey(info.ownerId)) { |
| | | // 20220422 ljh update end |
| | | UpdateTenMap.put(tenderId, oppMainMap.get(tenderId)); |
| | | System.debug('----------11---------' + UpdateTenMap); |
| | | } |
| | | } |
| | | } |
| | |
| | | } |
| | | // StaticParameter.EscapeOtherUpdateTenOwner = true; |
| | | } |
| | | /* |
| | | 集采项目导致所有人更新 |
| | | **/ |
| | | // 20221011 ljh SWAG-CK28WT |
| | | public void updateTenOwnerJC() { |
| | | // |
| | | String OCSM_province = '市场企划本部'; |
| | | Id OwnerIdStr; |
| | | List<OCM_Management_Province__c> ompList = [select Id,TenderAssistant1__c,TenderAssistant1__r.IsActive,TenderAssistant2__c from OCM_Management_Province__c where name =:OCSM_province]; |
| | | if(ompList.size() > 0 && ompList[0].TenderAssistant1__r.IsActive){ |
| | | OwnerIdStr = ompList[0].TenderAssistant1__c; |
| | | } |
| | | System.debug('zheli00:'+OwnerIdStr); |
| | | for (Tender_information__c nObj : newList) { |
| | | Tender_information__c oObj = oldMap.get(nObj.Id); |
| | | if (nObj.CentralizedProject__c != oObj.CentralizedProject__c) { |
| | | if(nObj.CentralizedProject__c && OwnerIdStr != null){ |
| | | /** |
| | | 本部自动变成市场企划本部,项目助理和所有人都是市场企划本部的人, |
| | | 取OCSM管理省页面维护的市场企划本部,招标项目助理1, |
| | | */ |
| | | nObj.OwnerId = OwnerIdStr; |
| | | nObj.InfoOwner__c = OwnerIdStr; |
| | | }else if(!nObj.CentralizedProject__c){ |
| | | /** |
| | | 取消勾选后返回营业部门的省和本部, |
| | | 所有人根据关联医院和战略科室取担当的名字。 |
| | | */ |
| | | updateTenOwner(); |
| | | } |
| | | } |
| | | // 如果触发 更新所有人 没有询价则 还是市场企划本部 |
| | | if (!StaticParameter.EscapeOtherUpdateTenOwner) { |
| | | if(nObj.CentralizedProject__c && OwnerIdStr != null && (nObj.OpportunityNum__c == 0 || nObj.OpportunityNum__c == null)){ |
| | | nObj.OwnerId = OwnerIdStr; |
| | | nObj.InfoOwner__c = OwnerIdStr; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | // 中标任务 废标流标时清空中标日 |
| | | public void clearConfirmationofAward() { |
| | | List<String> tenders = new List<String>(); |
| | | String labelTypes = System.Label.ClearConfirmationofAwardTypes; |
| | | List<String> subTypes = labelTypes.split(','); |
| | | for (Tender_information__c tender : this.newList) { |
| | | Tender_information__c old_tender = this.oldMap.get(tender.Id); |
| | | if (subTypes.contains(tender.subInfoType__c) && !tender.subInfoType__c.equals(old_tender.subInfoType__c)) { |
| | | tenders.add(tender.Id); |
| | | } |
| | | } |
| | | if (tenders.size() > 0) { |
| | | List<Tender_Opportunity_Link__c> links = [select Id, Opportunity__c from Tender_Opportunity_Link__c where Tender_information__c in :tenders]; |
| | | if (links != null && links.size() > 0) { |
| | | List<String> oppids = new List<String>(); |
| | | for (Tender_Opportunity_Link__c link : links) { |
| | | oppids.add(link.Opportunity__c); |
| | | } |
| | | // 状态=询价且没有做合同申请的 |
| | | List<Opportunity> opps = [select Id, Closing_Bid_Date__c |
| | | from Opportunity |
| | | where StageName = '引合' |
| | | and IF_Submit__c = false |
| | | and Id in :oppids]; |
| | | if (opps != null && opps.size() > 0) { |
| | | for (Opportunity opp : opps) { |
| | | opp.Closing_Bid_Date__c = null; |
| | | } |
| | | StaticParameter.EscapeOpportunityBefUpdTrigger = true; |
| | | update opps; |
| | | StaticParameter.EscapeOpportunityBefUpdTrigger = false; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |