From 9ae452e93335a603a4cb22b7314f633c5e0bce25 Mon Sep 17 00:00:00 2001
From: 李彤 <litong@prec-tech.com>
Date: 星期五, 18 十一月 2022 18:08:34 +0800
Subject: [PATCH] 预测改善
---
force-app/main/default/classes/InquiryPredictsDateChangeHandler.cls | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 52 insertions(+), 0 deletions(-)
diff --git a/force-app/main/default/classes/InquiryPredictsDateChangeHandler.cls b/force-app/main/default/classes/InquiryPredictsDateChangeHandler.cls
new file mode 100644
index 0000000..dd34b76
--- /dev/null
+++ b/force-app/main/default/classes/InquiryPredictsDateChangeHandler.cls
@@ -0,0 +1,52 @@
+public with sharing class InquiryPredictsDateChangeHandler extends Oly_TriggerHandler{
+
+ private List<InquiryPredictsDateChange__c> oldList;
+ private List<InquiryPredictsDateChange__c> newList;
+ private Map<Id,InquiryPredictsDateChange__c> oldMap;
+ private Map<Id,InquiryPredictsDateChange__c> newMap;
+
+ public InquiryPredictsDateChangeHandler() {
+ this.oldList = (List<InquiryPredictsDateChange__c>) Trigger.old;
+ this.newList = (List<InquiryPredictsDateChange__c>) Trigger.new;
+ this.oldMap = (Map<Id,InquiryPredictsDateChange__c>) Trigger.oldMap;
+ this.newMap = (Map<Id,InquiryPredictsDateChange__c>) Trigger.newMap;
+ }
+
+ protected override void afterUpdate() {
+ addColumn();
+ }
+
+ //褰撳鎵规祦绋嬭蛋瀹屾椂 鏇存柊 璇环鐩稿叧瀛楁
+ private void addColumn(){
+ List<Opportunity> oppList = new List<Opportunity>();
+ Map<Id,Opportunity> oppMap = new Map<Id,Opportunity>();
+ List<Id> oppIdList = new List<Id>();
+
+ for (InquiryPredictsDateChange__c ipd :newList ) {
+ //鍒ゆ柇鏇存柊鍓嶅悗鐨勭姸鎬佹槸鍚︿笉鍚� 鑻ヤ笉鍚�,鍒欏垽鏂洿鏂板悗鐨勭姸鎬佹槸鍚︿负'宸叉壒鍑�'
+ if ((ipd.Predicted_Date_Status__c != oldMap.get(ipd.Id).Predicted_Date_Status__c) && ipd.Predicted_Date_Status__c == '宸叉壒鍑�' ) {
+ String oppId = ipd.Opportunity__c ;
+ Opportunity opp = new Opportunity();
+
+ opp.Id = oppId;
+ // opp.Close_Forecasted_Assume_Date__c = ipd.Close_Forecasted_Assume_Date__c; //鎷呭綋鏃�
+ opp.Close_Forecasted_Date__c = ipd.Close_Forecasted_Date__c; //KPI鏃�
+ opp.CloseDate = ipd.CloseDate__c; //缁撴潫鏃ユ湡/棰勬祴鍙戣揣鏃�
+ opp.Date_InAdvance_Delay__c = ipd.Date_InAdvance_Delay__c; //鏃ユ湡鎻愬墠/寤跺悗
+ opp.Predicted_date_ChangeReason__c = ipd.Predicted_date_ChangeReason__c; //鏀瑰彉棰勬祴鏃ユ湡鍘熷洜
+ // opp.Opp_New_Mark__c = ipd.Opp_New_Mark__c; //璇环鏂板缓鏍囪
+ opp.Opp_Delay_Mark__c = ipd.Opp_Delay_Mark__c; //璇环寤跺悗鏍囦环
+ opp.ForecastApprovalTime__c = Datetime.now();
+
+ oppList.add(opp);
+
+ }
+ }
+
+ if (oppList.size() > 0) {
+ System.debug('lt123oppList'+oppList);
+ update oppList;
+ }
+ }
+
+}
\ No newline at end of file
--
Gitblit v1.9.1