From 8badb57ea2c82557850ad5b39281c3e8714eb119 Mon Sep 17 00:00:00 2001
From: liuyan <liuyan@prec-tech.com>
Date: 星期四, 24 十一月 2022 10:08:31 +0800
Subject: [PATCH] 科室信息漏传SPO问题
---
force-app/main/default/classes/OpportunityTrigger.cls | 407 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 405 insertions(+), 2 deletions(-)
diff --git a/force-app/main/default/classes/OpportunityTrigger.cls b/force-app/main/default/classes/OpportunityTrigger.cls
index 15de464..3cfea75 100644
--- a/force-app/main/default/classes/OpportunityTrigger.cls
+++ b/force-app/main/default/classes/OpportunityTrigger.cls
@@ -1,5 +1,7 @@
public without sharing class OpportunityTrigger {
+ public static Boolean isFirst = true;
+
public static void lockOpportunityFile(List<Opportunity> newList, Map<Id, Opportunity> newMap, List<Opportunity> oldList, Map<Id, Opportunity> oldMap) {
List<String> targetIds = new List<String>();
@@ -20,6 +22,7 @@
update ofileList;
}
+
//CHAN-AZJ6JS 杩芥函绯荤粺鏉ョ殑璇环锛屽彇娑圵IN鏃讹紝缁忛攢鍟嗚鍗曡嚜鍔ㄦ敼鍒扳�滈┏鍥炩��
public static void changeConsumableOrderStatus(List<Opportunity> newList, Map<Id, Opportunity> newMap, List<Opportunity> oldList, Map<Id, Opportunity> oldMap) {
@@ -163,10 +166,14 @@
// temptender.IsReactionOpp__c = true;
// tenderMap.put(temptender.id ,temptender );
// }
- // 鍚堝苟鍒ゆ柇鏉′欢
+ // 鍚堝苟鍒ゆ柇鏉′欢
+ //20220803 you 鎷涙爣椤圭洰澧炲姞 鍙栨秷锛屼腑鏍囩粨鏋滄洿鏂扮‘璁ゆ潯浠�
if((op.SAP_Send_OK__c != oldopp.SAP_Send_OK__c) ||
((op.StageName__c.equals('澶卞崟') && !oldopp.StageName__c.equals('澶卞崟')) ||
- (!op.StageName__c.equals('澶卞崟') && oldopp.StageName__c.equals('澶卞崟')))) {
+ (!op.StageName__c.equals('澶卞崟') && oldopp.StageName__c.equals('澶卞崟'))) ||
+ ((op.StageName__c.equals('鍙栨秷') && !oldopp.StageName__c.equals('鍙栨秷')) ||
+ (!op.StageName__c.equals('鍙栨秷') && oldopp.StageName__c.equals('鍙栨秷'))) ||
+ (String.isNotBlank(op.ConfirmationofAward__c) && op.ConfirmationofAward__c!=oldopp.ConfirmationofAward__c)) {
for (Tender_Opportunity_Link__c link : links) {
if (link.Opportunity__c == op.Id) {
Tender_information__c temptender = new Tender_information__c();
@@ -293,5 +300,401 @@
}
}
//LastBuy 棰勭暀浜у搧 lt 20220315 end
+//SWAG-CHL67J 銆愬鎵樸�戙�怓Y23璇环鏀瑰杽銆�-璇环椤甸潰/鎷涙爣椤圭洰澧炲姞缁熻瀛楁 fy start
+// public static void UpdateBidNumber(List<Opportunity> newList, Map<Id, Opportunity> newMap, List<Opportunity> oldList, Map<Id, Opportunity> oldMap){
+// List<Id> OpportunityIdList = new List<Id>();
+// Boolean flag = true;
+// for (Opportunity opp : newList) {
+// OpportunityIdList.add(opp.Id);
+// Opportunity oldopp = oldMap == null? null : oldMap.get(opp.Id);
+// if(oldopp==null){
+// if(opp.NumberOfBids__c!=null||opp.BidWinningNumber__c!=null){
+// flag = true;
+// }
+// }else{
+// if(opp.NumberOfBids__c!=oldopp.NumberOfBids__c||opp.NumberOfBids__c!=oldopp.NumberOfBids__c){
+// flag = true;
+// }
+// }
+// }
+// system.debug('newList+++'+newList);
+// system.debug('oldList+++'+oldList);
+// if(flag){
+// List<Tender_Opportunity_Link__c> TenderOpportunityLinkList = [select Tender_information__c from Tender_Opportunity_Link__c where Opportunity__c in:OpportunityIdList];
+// Set<Id> enderOpportunityId = new Set<Id>();
+// if(TenderOpportunityLinkList.size()>0){
+// for (Tender_Opportunity_Link__c TenderOpportunity : TenderOpportunityLinkList) {
+// enderOpportunityId.add(TenderOpportunity.Tender_information__c);
+// }
+// }
+// system.debug('TenderOpportunityLinkList+++'+TenderOpportunityLinkList);
+// List<Tender_Opportunity_Link__c> TenderOpportunityLinkList2 = [select Tender_information__c,Opportunity__r.NumberOfBids__c,Opportunity__r.BidWinningNumber__c from Tender_Opportunity_Link__c where Tender_information__c in:enderOpportunityId];
+// Map<String,Tender_information__c> TenderinformationMap = new Map<String,Tender_information__c>();
+// system.debug('TenderOpportunityLinkList2+++'+TenderOpportunityLinkList2);
+// if(TenderOpportunityLinkList2.size()>0){
+// for(Tender_Opportunity_Link__c TenderOpportunity2 :TenderOpportunityLinkList2){
+// if(TenderinformationMap.containsKey(TenderOpportunity2.Tender_information__c)){
+// Tender_information__c Tender_informationvalue = new Tender_information__c();
+// Tender_informationvalue = TenderinformationMap.get(TenderOpportunity2.Tender_information__c);
+// Tender_informationvalue.NumberOfBids__c=Tender_informationvalue.NumberOfBids__c+TenderOpportunity2.Opportunity__r.NumberOfBids__c;
+// Tender_informationvalue.BidWinningNumber__c=Tender_informationvalue.BidWinningNumber__c+TenderOpportunity2.Opportunity__r.BidWinningNumber__c;
+// TenderinformationMap.put(TenderOpportunity2.Tender_information__c, Tender_informationvalue);
+// }else{
+// Tender_information__c Tender_informationvalue = new Tender_information__c();
+// Tender_informationvalue.Id=TenderOpportunity2.Tender_information__c;
+// Tender_informationvalue.NumberOfBids__c=TenderOpportunity2.Opportunity__r.NumberOfBids__c;
+// Tender_informationvalue.BidWinningNumber__c=TenderOpportunity2.Opportunity__r.BidWinningNumber__c;
+// TenderinformationMap.put(TenderOpportunity2.Tender_information__c, Tender_informationvalue);
+// }
+// }
+// }
+// List<Tender_information__c> Tender_informationList = new List<Tender_information__c>();
+// for (Tender_information__c value : TenderinformationMap.values()) {
+// Tender_informationList.add(value);
+// }
+// system.debug('Tender_informationList+++'+Tender_informationList);
+// update Tender_informationList;
+// }
+// }
+//SWAG-CHL67J 銆愬鎵樸�戙�怓Y23璇环鏀瑰杽銆�-璇环椤甸潰/鎷涙爣椤圭洰澧炲姞缁熻瀛楁 fy end
+ //add 璇环璺熻繘浠诲姟寮�鍙� - 3.鍒涘缓澶卞崟浠诲姟 sx 20220617 start
+ //璇环涓爣缁撴灉纭绔炰簤瀵规墜涓爣鏃跺疄鏃跺垱寤哄け鍗曚换鍔�
+ public static void createTaskByOppConfirmationofAward(List<Opportunity> newList, Map<Id, Opportunity> newMap, List<Opportunity> oldList, Map<Id, Opportunity> oldMap){
+ if (!isFirst) {
+ return;
+ }
+
+ Set<Id> oppoIds = new Set<Id>();
+ for(Opportunity op : newList){
+ Opportunity oldopp = oldMap.get(op.Id);
+ //璇环涓爣缁撴灉纭绔炰簤瀵规墜涓爣鏃跺疄鏃跺垱寤哄け鍗曚换鍔� 涓� 璇环鐘舵��1绛変簬璇环
+ if (oldopp.ConfirmationofAward__c != '绔炰簤瀵规墜涓爣' && op.ConfirmationofAward__c == '绔炰簤瀵规墜涓爣' && op.StageName__c == '璇环' && op.LeakageNumber__c !=1){
+ oppoIds.add(op.Id);
+ }
+ }
+
+ if (!oppoIds.isEmpty()) {
+ // 鏈夋晥澶卞崟鐘舵�佷竴瑙�
+ List<String> validStatus = new List<String>{'鐢宠涓�', '鎻愪氦', '鎵瑰噯'};
+ // 璇环澶卞崟/鍙栨秷鎶ュ憡鏌ヨ
+ List<Lost_cancel_report__c> lostCancelReportList = [SELECT Id, Opportunity__c from Lost_cancel_report__c WHERE Opportunity__c in :oppoIds and Report_Status__c in: validStatus];
+
+ //<璇环Id, 澶卞崟鎶ュ憡>
+ Map<String, Lost_cancel_report__c> lostCancelReportMap = new Map<String, Lost_cancel_report__c>();
+ for(Lost_cancel_report__c lcr : lostCancelReportList){
+ if (!lostCancelReportMap.isEmpty() && lostCancelReportMap.containsKey(lcr.Opportunity__c)) {
+ // no action
+ } else {
+ lostCancelReportMap.put(lcr.Opportunity__c, lcr);
+ }
+ }
+
+ List<Task__c> insTaskList = new List<Task__c>();
+
+ // 瀹氫箟闇�瑕佹洿鏂扮殑璇环浠诲姟
+ List<Opportunity> updateOpportunity = new List<Opportunity>();
+
+ // 璁板綍绫诲瀷锛氬け鍗曟姤鍛婁换鍔�
+ List<RecordType> recordTypes = [select Id from RecordType where IsActive = true and SobjectType = 'task__c' and DeveloperName = 'LoseListTask'];
+ Id loseListTask_TaskId = recordTypes.get(0).Id;
+ //String taskName = '';
+
+ for(Opportunity opp : newList) {
+ //娌℃湁宸叉彁浜ょ殑澶卞崟鎶ュ憡
+ if(!lostCancelReportMap.containsKey(opp.Id) && oppoIds.contains(opp.Id)) {
+
+ //鍒涘缓澶卞崟浠诲姟鎻愰啋
+ Task__c tempTask = new Task__c();
+ tempTask.RecordTypeId = loseListTask_TaskId;
+ tempTask.taskDifferent__c = '琚姩浠诲姟';
+ tempTask.taskStatus__c = '02 鎺ュ彈'; //浠诲姟鐘舵��2
+ tempTask.assignee__c = opp.OwnerId; //琚垎閰嶈��
+ tempTask.account__c = opp.AccountId;
+ tempTask.Name = '澶卞崟缁撴灉纭锛�' + opp.Opportunity_No__c;
+ tempTask.OwnerId = opp.OwnerId; //鎵�鏈変汉
+ tempTask.OpportunityId__c = opp.Id;
+ tempTask.ConfirmDate__c = Date.today();
+ insTaskList.add(tempTask);
+
+ //鏇存柊璇环 Task_createTime__c
+ Opportunity uopp = new Opportunity();
+ uopp.Id = opp.Id;
+ uopp.LostTask_createTime__c = Date.today();
+ updateOpportunity.add(uopp);
+ }
+ }
+
+ if (!insTaskList.isEmpty()) {
+ insert insTaskList;
+ }
+ if (!updateOpportunity.isEmpty()) {
+ update updateOpportunity;
+ }
+ }
+ isFirst = false;
+ }
+ //add 璇环璺熻繘浠诲姟寮�鍙� - 3.鍒涘缓澶卞崟浠诲姟 sx 20220617 end
+
+
+ //璇环璺熻繘浠诲姟寮�鍙�
+ public static void opportunityTasks(List<Opportunity> newList, Map<Id, Opportunity> newMap, List<Opportunity> oldList, Map<Id, Opportunity> oldMap){
+ Set<Id> oppoIds = new Set<Id>();
+
+ for(Opportunity op : newList){
+ Opportunity oldopp = oldMap.get(op.Id);
+
+ //璇环涓爣缁撴灉纭绔炰簤瀵规墜涓爣鏃跺疄鏃跺垱寤哄け鍗曚换鍔� 涓� 璇环鐘舵��1绛変簬璇环
+ if (oldopp.ConfirmationofAward__c != 'OLY涓爣' && op.ConfirmationofAward__c == 'OLY涓爣' && op.StageName__c == '璇环'){
+ oppoIds.add(op.Id);
+ //纭涓爣缁撴灉鏃堕棿 鍒涘缓浠诲姟鏃堕棿 20220629 sx
+ op.ConfirmationofAward_createTime__c = Date.today();
+ if(op.Task_createTime__c!=null){
+
+ //鏄惁鎸夋椂纭锛�3涓伐浣滄棩鍐呮寜鏃�1锛屼笉鎸夋椂0
+ String inttemp = CalendarUtil.getWorkDayNum(String.valueOf(op.Task_createTime__c), String.valueOf(op.ConfirmationofAward_createTime__c));
+ op.Is_ConfirmationofAward__c = Integer.valueOf(inttemp) > 3 ? 0 : 1;
+ }
+ }
+
+ //20220628浼氳鏂伴渶姹� 瀵规墜涓爣 7.涓爣鏃ユ竻绌�
+ if(oldopp.ConfirmationofAward__c != '绔炰簤瀵规墜涓爣' && op.ConfirmationofAward__c == '绔炰簤瀵规墜涓爣'){
+ op.Closing_Bid_Date__c = null;
+ op.ConfirmationofAward_createTime__c = Date.today();
+ if(op.Task_createTime__c!=null){
+
+ //鏄惁鎸夋椂纭锛�3涓伐浣滄棩鍐呮寜鏃�1锛屼笉鎸夋椂0
+ String inttemp = CalendarUtil.getWorkDayNum(String.valueOf(op.Task_createTime__c), String.valueOf(op.ConfirmationofAward_createTime__c));
+ op.Is_ConfirmationofAward__c = Integer.valueOf(inttemp) > 3 ? 0 : 1;
+ }
+ }
+ }
+
+ if(!oppoIds.isEmpty()){
+
+ list<Tender_Opportunity_Link__c> toppLinkList = [Select Id, Opportunity__c, Tender_information__c,Tender_information__r.ResultDate__c FROM Tender_Opportunity_Link__c WHERE Opportunity__c in :oppoIds];
+ Map<String, Tender_Opportunity_Link__c> toopLinkMap = new Map<String, Tender_Opportunity_Link__c>();
+
+ for(Tender_Opportunity_Link__c tol : toppLinkList){
+ toopLinkMap.put(tol.Opportunity__c, tol);
+ }
+
+ for (String key : toopLinkMap.keySet()) {
+ Opportunity oppoTemp = newMap.get(key);
+
+ //20220628浼氳鏂伴渶姹� OLY涓爣 7.涓爣鏃ワ紙缁撴灉璁板綍鏃ワ級= 鎷涙爣椤圭洰.缁撴灉璁板綍鏃�
+ oppoTemp.Closing_Bid_Date__c = toopLinkMap.get(key).Tender_information__r.ResultDate__c;
+ System.debug('============'+toopLinkMap.get(key).Tender_information__r.ResultDate__c);
+
+
+ //鏄惁鎸夋椂纭锛�3涓伐浣滄棩鍐呮寜鏃�1锛屼笉鎸夋椂0
+ //String inttemp = CalendarUtil.getWorkDayNum(String.valueOf(oppoTemp.Task_createTime__c), String.valueOf(oppoTemp.ConfirmationofAward_createTime__c));
+ //oppoTemp.Is_ConfirmationofAward__c = Integer.valueOf(inttemp) > 3 ? 0 : 1;
+ }
+
+ }
+ Integer i = 0;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+
+ }
}
\ No newline at end of file
--
Gitblit v1.9.1