From 19ae52ae3e06c44c646ae6b45dc2b0d7f2cead88 Mon Sep 17 00:00:00 2001 From: 李彤 <litong@prec-tech.com> Date: 星期一, 15 五月 2023 18:55:53 +0800 Subject: [PATCH] 招标项目终止 --- force-app/main/default/classes/TenderInformationHandler.cls | 725 ++++++++++++++++++++++++++++++++++++++++++++----------- 1 files changed, 576 insertions(+), 149 deletions(-) diff --git a/force-app/main/default/classes/TenderInformationHandler.cls b/force-app/main/default/classes/TenderInformationHandler.cls index 4f8fe52..1e4df89 100644 --- a/force-app/main/default/classes/TenderInformationHandler.cls +++ b/force-app/main/default/classes/TenderInformationHandler.cls @@ -40,160 +40,319 @@ } protected override void beforeUpdate() { + SetIsReactionOpp(); //lt DB202304062844 20230515 椤圭洰缁堟娴佺▼寮�鍙� add //鍙嶉�昏緫鍒犻櫎 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銆丼P鍔╃悊,琛屾斂绐楀彛,澶囧搧绐楀彛锛屾洿鏂板叡浜紝鍏变韩鍘熷洜涓嶄竴鏍� addShare(); - sednMessage(); + //sednMessage(); 20220729 you 鎷涙爣椤圭洰 鍙栨秷鍙戦�侀偖浠堕�氱煡 // updateTenOwner(); } protected override void afterUpdate() { - addShare(); - sednMessage(); + addShare(); + //sednMessage(); 20220729 you 鎷涙爣椤圭洰 鍙栨秷鍙戦�侀偖浠堕�氱煡 updateWin(); + + // 涓爣浠诲姟 搴熸爣娴佹爣鏃舵竻绌轰腑鏍囨棩 + //20221208 you DB202211594688 + //clearConfirmationofAward(); + + //2022-3-29 yjk SWAG-CCL6R7 + //updateOpportunity();//2022-5-18 yjk XLIU-CEJ38N 娉ㄩ噴鎺� } - public void sednMessage() { - //瑙勫垯鏉′欢 - //ISCHANGED(InfoType__c) && Text(InfoType__c) = '3锛氱粨鏋�' && (Text(IsBid__c) = '鏄�' || ( Text(IsBid__c) = '鍚�' && OpportunityNum__c != null && OpportunityNum__c > 0) ) - // 1锛夋病鏈夊叧鑱旇浠凤紝纭鐩稿叧鎬э紝閭d箞灏卞彂缁橤I鍜孲P鍔╃悊锛� - // 2锛夊叧鑱旇浠峰悗锛岃浠风殑鎵�鏈変汉銆侀」鐩墍鏈変汉锛孏I鍜孲P鍔╃悊锛屾敹閭欢锛� - //鍏宠仈璇环 鍙戠粰璇环鎵�鏈変汉 鎷涙爣椤圭洰鎵�鏈変汉 - //娌℃湁鍏宠仈璇环骞朵笖鍋氫簡鐩稿叧鎬х‘璁� 鍙戠粰鎷涙爣椤圭洰鎵�鏈変汉 - - //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锛氱粨鏋�'))) { - // 濡傛灉鎷涙爣鎵�鏈変汉涓虹郴缁熺鐞嗗憳锛圤lympusSystem锛夋椂闇�瑕佽烦杩� - if (ten.Id != '00510000000gmxH') { - zbIds.add(ten.Id); + //淇敼椤圭洰闃舵锛岀敱 缁撴灉鍙樹负鍏朵粬锛岋紝鐩稿叧浠诲姟鍙栨秷 + public void updateOppotunityBeforeUpdate() { + Set<String> Tenids = new Set<String>();//鎷涙爣椤圭洰id锛屾煡璇ink + Set<String> oppTens = new Set<String>();//鎷涙爣椤圭洰id锛屾煡璇ink + List<String> oppIds = new List<String>();//璇环 + // 鑾峰緱瑕佹洿鏂扮殑璇环 + for (Tender_information__c record: newList) { + //lt 20230425 鎷涙爣缁堟 add || ('鎵瑰噯'.equals(record.TerminateApprovalStatus__c) && !'鎵瑰噯'.equals((oldMap.get(record.Id).TerminateApprovalStatus__c))) + 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))) || ('鎵瑰噯'.equals(record.TerminateApprovalStatus__c) && !'鎵瑰噯'.equals((oldMap.get(record.Id).TerminateApprovalStatus__c)))) { + Tenids.add(record.id); + } + } + Map<String,String> InfoTypeMap = new Map<String,String>(); //鍒ゆ柇鏄惁鏄洜涓轰腑鏍囦慨鏀瑰緱 + Map<String,String> TerminationStateMap = new Map<String,String>(); //lt 20230425 鎷涙爣缁堟 add + if(null!=Tenids && Tenids.size()>0){ + //lt 20230425 鎷涙爣缁堟 add Tender_information__r.TerminateApprovalStatus__c, + List<Tender_Opportunity_Link__c> TenOppLinkList = [select id, Tender_information__c,Tender_information__r.InfoType__c, Tender_information__r.TerminateApprovalStatus__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); + } + //lt DB202304062844 20230515 椤圭洰缁堟娴佺▼寮�鍙� update if(!'3锛氱粨鏋�'.equals(topl.Tender_information__r.InfoType__c)) --- if(!'3锛氱粨鏋�'.equals(NewMap.get(topl.Tender_information__c).InfoType__c)) + if(!'3锛氱粨鏋�'.equals(NewMap.get(topl.Tender_information__c).InfoType__c)){ + InfoTypeMap.put(topl.Opportunity__c,topl.Tender_information__c); + } + //lt 20230425 鎷涙爣缁堟 start + System.debug('---lt123---topl.Tender_information__r.TerminateApprovalStatus__c:'+topl.Tender_information__r.TerminateApprovalStatus__c); + if('鎵瑰噯'.equals(newMap.get(topl.Tender_information__c).TerminateApprovalStatus__c)){ + TerminationStateMap.put(topl.Opportunity__c,topl.Tender_information__c); + } + //lt 20230425 鎷涙爣缁堟 end } } } - 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>()); + if (null!=oppTens && oppTens.size()>0) { + //20221208 you DB202211594688 鏈夌‘璁や换鍔$殑璇环涓嶆竻 + List<Opportunity> opportunities = [select id, Bidding_Project_Name_Bid__c, Opp_Order__c,ConfirmationofAward__c from Opportunity where id in :oppIds]; + //lt 20230425 鎷涙爣缁堟 add Tender_information_Task__r.TerminateApprovalStatus__c 20230510 add and taskStatus__c <> '04 鍙栨秷' + //lt DB202304062844 20230515 椤圭洰缁堟娴佺▼寮�鍙� update taskStatus__c <> '03 瀹屾垚' and taskStatus__c <> '04 鍙栨秷' --- taskStatus__c = '02 鎺ュ彈' + List<task__c> taskList = [select id,taskStatus__c,RecordType.Name,Tender_information_Task__c, + OpportunityId__c,Tender_information_Task__r.TerminateApprovalStatus__c + from task__c + where ((RecordType.Name ='澶卞崟鎶ュ憡浠诲姟' and OpportunityId__c in:oppIds) + or (RecordType.Name ='涓爣缁撴灉纭' and Opp_Tender__c in :oppTens)) + and taskStatus__c = '02 鎺ュ彈']; + for(task__c tsk : taskList){ + System.debug('---lt123---TerminationStateMap:'+TerminationStateMap); + System.debug('---lt123---tsk.Tender_information_Task__r.TerminateApprovalStatus__c:'+tsk.Tender_information_Task__r.TerminateApprovalStatus__c); + //lt DB202304062844 20230515 椤圭洰缁堟娴佺▼寮�鍙� update !='03 瀹屾垚' --- == '02 鎺ュ彈' + if(tsk.RecordType.Name =='澶卞崟鎶ュ憡浠诲姟' && oppIds.contains(tsk.OpportunityId__c) && tsk.taskStatus__c == '02 鎺ュ彈'){ + //涓嶅仛鎿嶄綔 + }else{ + tsk.taskStatus__c = '04 鍙栨秷'; + tsk.cancelDate__c = date.today(); + if(null!=InfoTypeMap && InfoTypeMap.containsKey(tsk.OpportunityId__c)){ + tsk.cancelReasonSelect__c = '淇敼椤圭洰闃舵'; } - 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>(); - - 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 + '宸叉湁涓爣缁撴灉璇风‘璁�'; - - 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); + //lt 20230425 鎷涙爣缁堟 start + else if(null!=TerminationStateMap && TerminationStateMap.containsKey(tsk.OpportunityId__c)){ + tsk.cancelReasonSelect__c = '椤圭洰缁堟'; + } + //lt 20230425 鎷涙爣缁堟 end + else{ + tsk.cancelReasonSelect__c = '娴佹爣/搴熸爣'; } } - - 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() + '鍙戦�佹垚鍔�'); - } + } + update taskList; + //lt DB202304062844 20230515 椤圭洰缁堟娴佺▼寮�鍙� start + // if(taskList.size() > 0){ + if(opportunities.size() > 0){ + for (Opportunity opp : opportunities) { + Boolean upd_flg = null!=TerminationStateMap && TerminationStateMap.containsKey(opp.Id) && opp.ConfirmationofAward__c == '绔炰簤瀵规墜涓爣' ? false : true; + if (!upd_flg) { + continue; + } + for (task__c tlink : taskList) { + if (opp.Id == tlink.OpportunityId__c) { + //lt DB202304062844 20230515 椤圭洰缁堟娴佺▼寮�鍙� update !='03 瀹屾垚' --- == '02 鎺ュ彈' + if(tlink.RecordType.Name =='澶卞崟鎶ュ憡浠诲姟' && tlink.taskStatus__c == '02 鎺ュ彈'){ + upd_flg = false; + break; + //涓嶅仛鎿嶄綔 + // }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; + // //lt DB202304062844 20230515 椤圭洰缁堟娴佺▼寮�鍙� start + // if(tlink.Tender_information_Task__r.TerminateApprovalStatus__c == '鎵瑰噯' && opp.ConfirmationofAward__c == 'OLY涓爣'){ + // opp.Closing_Bid_Date__c = null; + // } + // //lt DB202304062844 20230515 椤圭洰缁堟娴佺▼寮�鍙� end + // //opp.Closing_Bid_Date__c = null; + // //20220718 you 璇环浠诲姟 end } } } + if (upd_flg) { + //lt DB202304062844 20230515 椤圭洰缁堟娴佺▼寮�鍙� start + if(null!=TerminationStateMap && TerminationStateMap.containsKey(opp.Id) && opp.ConfirmationofAward__c == 'OLY涓爣'){ + opp.Closing_Bid_Date__c = null; + } + //lt DB202304062844 20230515 椤圭洰缁堟娴佺▼寮�鍙� end + 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; + } + } + } + //lt DB202304062844 20230515 椤圭洰缁堟娴佺▼寮�鍙� end + StaticParameter.EscapeOppandStaTrigger = true; //lt DB202304062844 20230515 椤圭洰缁堟娴佺▼寮�鍙� 璺宠繃璇环trigger start + update opportunities; + StaticParameter.EscapeOppandStaTrigger = false; //lt DB202304062844 20230515 椤圭洰缁堟娴佺▼寮�鍙� end + } + } + //20220718 you 璇环浠诲姟 end + // 20221027 updateOpportunity() 鍏ㄦ枃鎼滅储杩� 娌℃湁璋冪敤鐨勶紝鏂规硶寮曠敤宸茬粡娉ㄩ噴锛岃鐩栫巼涓嶅鏂规硶浣撲篃娉ㄩ噴锛圫WAG-CKL5UC锛�, + //2022-3-29 yjk SWAG-CCL6R7 + /*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){ + List<Opportunity> oppList = [select id,Closing_Bid_Date__c from Opportunity where Bidding_Project_Name_Bid__c = :newOne.id]; + if(oppList.size() > 0){ + for(Opportunity opp : oppList){ + opp.Closing_Bid_Date__c = newOne.ResultDate__c; + } + update oppList; } } } - } + }*/ + //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锛夋病鏈夊叧鑱旇浠凤紝纭鐩稿叧鎬э紝閭d箞灏卞彂缁橤I鍜孲P鍔╃悊锛� + // // 2锛夊叧鑱旇浠峰悗锛岃浠风殑鎵�鏈変汉銆侀」鐩墍鏈変汉锛孏I鍜孲P鍔╃悊锛屾敹閭欢锛� + // //鍏宠仈璇环 鍙戠粰璇环鎵�鏈変汉 鎷涙爣椤圭洰鎵�鏈変汉 + // //娌℃湁鍏宠仈璇环骞朵笖鍋氫簡鐩稿叧鎬х‘璁� 鍙戠粰鎷涙爣椤圭洰鎵�鏈変汉 + + // //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锛氱粨鏋�'))) { + // // 濡傛灉鎷涙爣鎵�鏈変汉涓虹郴缁熺鐞嗗憳锛圤lympusSystem锛夋椂闇�瑕佽烦杩� + // 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); + + // } + // //鍙栧緱璇环 + // // 鎷涙爣-璇环鍏宠仈淇敼 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>(); + + // 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 + '宸叉湁涓爣缁撴灉璇风‘璁�'; + + // 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); + // } + // } + + // 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() + '鍙戦�佹垚鍔�'); + // } + // } + // } + // } + // } + // } + // } + //} @@ -371,6 +530,12 @@ //鍙栧�奸『搴忔槸锛氭墍鏈変汉锛屼箣鍚庢槸gi鍔╃悊锛屾帴涓嬫潵鏄痵p鍔╃悊锛屾帴涓嬫潵鏄垬鐣ョ瀹ゆ墍鏈変汉 鎵�浠ュ�掔潃鏉� 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 //涓�涓猰ap涓� 閽堝涓�鏉℃嫑鎶曟爣璁″垝鐨勫叡浜� Map<Id, Tender_information__Share> sharemap = new Map<Id, Tender_information__Share>(); //1.鍏堣缃� 鍖婚櫌鎷呭綋鐨勫叡浜� @@ -500,7 +665,7 @@ tenShareList.addAll(sharemap.values()); } - + //鐜板湪鐢ㄧ殑鏄叏鍒犲叏鍔犵殑鏂规硶锛屾病鏈夊啀鍒ゆ柇鏄惁鍙戠敓鏀瑰彉浜� //鍒犻櫎 List<Tender_information__Share> beforeShareList = @@ -517,6 +682,9 @@ } } + /** + * 2022-04-03 澧炲姞鍒ゆ柇 褰撶敤鎴锋棤鏁堟椂涔熻烦杩囪缃� + */ public void AssignValueToAssistant() { //鏍规嵁ocsm绠$悊鐪佺殑鍔╃悊璁剧疆褰撳墠鎷涙姇鏍囬」鐩殑gi/sp鍔╃悊 Map<String, OCM_Management_Province__c> mpMap = new Map<String, OCM_Management_Province__c>(); @@ -524,7 +692,6 @@ 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鍔╃悊 琛屾斂鍔╃悊銆佸鍝佺獥鍙� //鐩存帴璁剧疆 淇℃伅璐熻矗浜�(鍔╃悊) 涓篏I鍔╃悊 for (Tender_information__c info : newList) { @@ -547,26 +714,30 @@ 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 娣诲姞鐨刬f + info.InfoOwner__c = ocm.GI_assistant__c; + } } } // 澧炲姞GI鍔╃悊涓虹┖鏃剁殑澶勭悊锛屾竻绌烘嫑鏍囬」鐩殑GI鍔╃悊鍜屼俊鎭礋璐d汉锛堝姪鐞嗭級 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 娣诲姞鐨刬f + 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; } // @@ -578,14 +749,14 @@ 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; } @@ -594,7 +765,7 @@ 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; } } @@ -606,12 +777,33 @@ || 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 娣诲姞鐨刬f + 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() { @@ -625,44 +817,152 @@ } } } + + 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, '*** cd: ' + cd); + 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>(); + 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璧嬪��: '); + } + + 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 涓爣鏃朵慨鏀瑰叧鑱旇浠风殑鎷涙爣椤圭洰鍚嶅拰涓爣鏃堕棿 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 } // 闇�瑕佽烦杩囪浠穞rigger 闃叉鍑虹幇閲嶅鏇存柊鐨勬儏鍐� StaticParameter.EscapeOpportunityBefUpdTrigger = true; @@ -672,6 +972,7 @@ } } } + /**20220616 SWAG-CFD4SU you if (lostWinIds.size() > 0) { List<Tender_Opportunity_Link__c> links_2 = [SELECT id, @@ -705,6 +1006,23 @@ } } } + **/ + // 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() { @@ -929,7 +1247,6 @@ oppMainMap.put(oppLinks.Tender_information__c, oppLinks.Opportunity__r.OwnerId ); } } - for (Id tenderId : hpTypeToMainMap.keySet()) { for (Tender_information__c info : newList) { // add 銆愬鎵樸�慞-鎷涙爣椤圭洰-鎵嬪姩鍒涘缓鐨勬嫑鏍囬」鐩鍔犲繀濉瓧娈� 2021/11/03 fxk Star @@ -957,13 +1274,33 @@ System.debug('----------9---------' + UpdateTenMap); } } else { - UpdateTenMap.put(tenderId, '00510000000gmxH'); - System.debug('----------10---------' + UpdateTenMap); + // 20220421 SWAG-CC58ME ljh add 鏄惁鐩稿叧锛氭槸锛涘叧鑱斿尰闄�:锛乶ull; 鍏宠仈鎴樼暐绉戝 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 鏄惁鐩稿叧锛氭槸锛涘叧鑱斿尰闄�:锛乶ull; 鍏宠仈鎴樼暐绉戝 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 + 閽堝濡備笅鍦烘櫙鍋氱殑淇敼锛� + 鐩稿叧鎬х‘璁わ細涔嬪悗鎵�鏈変汉鍙栦簡鍖婚櫌+绗竴涓垬鐣ョ瀹ょ殑涓绘媴褰揂锛岀劧鍚庡叧鑱旇浠凤紝璇环鎵�鏈変汉鏄疊锛� + 鎵�鏈変汉鍙栦簡B銆傜劧鍚嶣绂昏亴浜嗭紝杩愯Batch锛屽彉鎴怉锛屽湪鎶夿鍚敤锛屼笉鍙樹細鏉 + */ + // 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); } } } @@ -978,4 +1315,94 @@ } // 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){ + /** + 鏈儴鑷姩鍙樻垚甯傚満浼佸垝鏈儴锛岄」鐩姪鐞嗗拰鎵�鏈変汉閮芥槸甯傚満浼佸垝鏈儴鐨勪汉锛� + 鍙朞CSM绠$悊鐪侀〉闈㈢淮鎶ょ殑甯傚満浼佸垝鏈儴锛屾嫑鏍囬」鐩姪鐞�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; + } + } + } + } + /** + //20221208 you DB202211594688 + // 涓爣浠诲姟 搴熸爣娴佹爣鏃舵竻绌轰腑鏍囨棩 + 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; + } + } + } + } + **/ + + //lt DB202304062844 20230515 椤圭洰缁堟娴佺▼寮�鍙� start subInfoType__c + //濡傛灉椤圭洰闃舵鍙戠敓鍙樺寲 鎴栬�呴樁娈佃ˉ鍏呰鏄庡彂鐢熷彉鍖� 鎴栬�呯粓姝㈠鎵瑰彂鐢熷彉鍖栦笖瀹℃壒閫氳繃 鎶婃嫑鏍囬」鐩笂鐨処sReactionOpp__c璁剧疆涓簍rue + public void SetIsReactionOpp() { + for(Tender_information__c newTen : newList){ + Tender_information__c oldTen = oldMap.get(newTen.Id); + if(newTen.InfoType__c != oldTen.InfoType__c || newTen.subInfoType__c != oldTen.subInfoType__c || (newTen.TerminateApprovalStatus__c != oldTen.TerminateApprovalStatus__c && newTen.TerminateApprovalStatus__c == '鎵瑰噯')){ + newTen.IsReactionOpp__c = true; + } + } + } + //lt DB202304062844 20230515 椤圭洰缁堟娴佺▼寮�鍙� end } \ No newline at end of file -- Gitblit v1.9.1