From 0fdc2c45a4b4f8199da04611433e93b6d9e969ae Mon Sep 17 00:00:00 2001
From: GWY <guweiyiscp096@foxmail.com>
Date: 星期四, 10 三月 2022 17:49:35 +0800
Subject: [PATCH] 11
---
force-app/main/default/classes/ProRegisterHandler.cls | 29 ++++++++++++++---------------
force-app/main/default/classes/Product2TriggerHandler.cls | 31 +++++++++++++++----------------
2 files changed, 29 insertions(+), 31 deletions(-)
diff --git a/force-app/main/default/classes/ProRegisterHandler.cls b/force-app/main/default/classes/ProRegisterHandler.cls
index 9092f80..4d568fe 100644
--- a/force-app/main/default/classes/ProRegisterHandler.cls
+++ b/force-app/main/default/classes/ProRegisterHandler.cls
@@ -131,6 +131,7 @@
Map<Id,List<String>> pro2Map = new Map<Id,List<String>>();
//瀛樻斁娉ㄥ唽璇佷笂鏈�鍓嶇殑缁存姢鏃�
Map<Id,Date> prSteMap = new Map<Id,Date>();
+ Map<Id,Date> prSte1Map = new Map<Id,Date>();
if (prl1List.size()>0) {
for (Product_Register_Link__c prl: prl1List) {
if (pro2Map.containsKey(prl.Product2__r.Id)) {
@@ -140,7 +141,7 @@
pro2Map.get(prl.Product2__r.Id).add(prl.Product_Register__r.MedPrdClass__c);
}
- if (prl.Product_Register__r.MedPrdClass__c == '1') {
+ if (prl.Product_Register__r.MedPrdClass__c == '1' && prl.Product_Register__r.Stelsedag__c <> null) {
if (prSteMap.containsKey(prl.Product2__r.Id)) {
if (prSteMap.get(prl.Product2__r.Id) > prl.Product_Register__r.Stelsedag__c) {
prSteMap.put(prl.Product2__r.Id,prl.Product_Register__r.Stelsedag__c);
@@ -149,24 +150,21 @@
prSteMap.put(prl.Product2__r.Id,prl.Product_Register__r.Stelsedag__c);
}
}
- }
- for (Product_Register_Link__c prl: prl1List) {
- if (prSteMap.get(prl.Product2__r.Id) == null) {
- if (prSteMap.containsKey(prl.Product2__r.Id) && (prl.Product_Register__r.MedPrdClass__c == '2' || prl.Product_Register__r.MedPrdClass__c == '3')) {
- if (prSteMap.containsKey(prl.Product2__r.Id)) {
- if (prSteMap.get(prl.Product2__r.Id) > prl.Product_Register__r.Stelsedag__c) {
- prSteMap.put(prl.Product2__r.Id,prl.Product_Register__r.Stelsedag__c);
- }
- }else {
- prSteMap.put(prl.Product2__r.Id,prl.Product_Register__r.Stelsedag__c);
+ if ((prl.Product_Register__r.MedPrdClass__c == '2' || prl.Product_Register__r.MedPrdClass__c == '2') && prl.Product_Register__r.Stelsedag__c <> null) {
+ if (prSte1Map.containsKey(prl.Product2__r.Id)) {
+ if (prSte1Map.get(prl.Product2__r.Id) > prl.Product_Register__r.Stelsedag__c) {
+ prSte1Map.put(prl.Product2__r.Id,prl.Product_Register__r.Stelsedag__c);
}
+ }else {
+ prSte1Map.put(prl.Product2__r.Id,prl.Product_Register__r.Stelsedag__c);
}
- }
+ }
}
}
System.debug('pro2Map='+pro2Map);
System.debug('prSteMap='+prSteMap);
+ System.debug('prSte1Map='+prSte1Map);
//浜у搧Id涓庣瓑绾х被鍒�
Map<Id,String> prlMap = new Map<Id,String>();
Map<Id,String> prl1Map = new Map<Id,String>();
@@ -174,11 +172,12 @@
List<ID> pidList = new List<ID>();
if (pro2Map.size()>0) {
for (Product_Register_Link__c pr: prl1List) {
- if (pro2Map.containsKey(pr.Product2__r.Id) && prSteMap.containsKey(pr.Product2__r.Id)) {
+ if (pro2Map.containsKey(pr.Product2__r.Id) && (prSteMap.containsKey(pr.Product2__r.Id) || prSte1Map.containsKey(pr.Product2__r.Id))) {
+ Date stedate = prSteMap.get(pr.Product2__r.Id)==null?prSte1Map.get(pr.Product2__r.Id)==null?null:prSte1Map.get(pr.Product2__r.Id):prSte1Map.get(pr.Product2__r.Id);
pidList.add(pr.Product2__r.Id);
if (pr.Product2__r.demoteer_Sap__c <> null && pr.Product2__r.Diedatvanink__c <> null) {
if (pr.Product_Register__r.Stelsedag__c <> null) {
- if (pr.Product2__r.Diedatvanink__c <= pr.Product_Register__r.Stelsedag__c) {
+ if (pr.Product2__r.Diedatvanink__c <= stedate) {
if (pr.Product2__r.demoteer_Sap__c <= pr.Product_Register__r.ValidTo__c && pr.Product2__r.demoteer_Sap__c >= pr.Product_Register__r.ValidFrom__c
&& pr.Product_Register__r.MedPrdClass__c == '2' || pr.Product_Register__r.MedPrdClass__c == '3') {
if (prlMap.get(pr.Product2__r.Id) == null) {
@@ -207,7 +206,7 @@
prlMap.put(pr.Product2__r.Id, Lins);
}
}
- }else if (pr.Product2__r.Diedatvanink__c > pr.Product_Register__r.Stelsedag__c) {
+ }else if (pr.Product2__r.Diedatvanink__c > stedate) {
if (pr.Product2__r.demoteer_Sap__c <= pr.Product_Register__r.ValidTo__c && pr.Product2__r.demoteer_Sap__c >= pr.Product_Register__r.ValidFrom__c
&& pr.Product_Register__r.MedPrdClass__c == '1') {
if (prl1Map.get(pr.Product2__r.Id) == null) {
diff --git a/force-app/main/default/classes/Product2TriggerHandler.cls b/force-app/main/default/classes/Product2TriggerHandler.cls
index 09d6df6..a429749 100644
--- a/force-app/main/default/classes/Product2TriggerHandler.cls
+++ b/force-app/main/default/classes/Product2TriggerHandler.cls
@@ -63,6 +63,7 @@
Map<Id,List<String>> pro2Map = new Map<Id,List<String>>();
//瀛樻斁娉ㄥ唽璇佷笂鏈�鍓嶇殑缁存姢鏃�,涓�绫昏瘉浼樺厛,鍚﹀垯浜岀被璇併��
Map<Id,Date> prSteMap = new Map<Id,Date>();
+ Map<Id,Date> prSte1Map = new Map<Id,Date>();
if (pro2List.size()>0) {
for (Product_Register_Link__c prl: pro2List) {
if (pro2Map.containsKey(prl.Product2__r.Id)) {
@@ -72,7 +73,7 @@
pro2Map.get(prl.Product2__r.Id).add(prl.Product_Register__r.MedPrdClass__c);
}
- if (prl.Product_Register__r.MedPrdClass__c == '1') {
+ if (prl.Product_Register__r.MedPrdClass__c == '1' && prl.Product_Register__r.Stelsedag__c <> null) {
if (prSteMap.containsKey(prl.Product2__r.Id)) {
if (prSteMap.get(prl.Product2__r.Id) > prl.Product_Register__r.Stelsedag__c) {
prSteMap.put(prl.Product2__r.Id,prl.Product_Register__r.Stelsedag__c);
@@ -81,20 +82,16 @@
prSteMap.put(prl.Product2__r.Id,prl.Product_Register__r.Stelsedag__c);
}
}
- }
- for (Product_Register_Link__c prl: pro2List) {
- if (prSteMap.get(prl.Product2__r.Id) == null) {
- if (prSteMap.containsKey(prl.Product2__r.Id) && (prl.Product_Register__r.MedPrdClass__c == '2' || prl.Product_Register__r.MedPrdClass__c == '3')) {
- if (prSteMap.containsKey(prl.Product2__r.Id) && prl.Product_Register__r.Stelsedag__c != null) {
- if (prSteMap.get(prl.Product2__r.Id) > prl.Product_Register__r.Stelsedag__c) {
- prSteMap.put(prl.Product2__r.Id,prl.Product_Register__r.Stelsedag__c);
- }
- }else {
- prSteMap.put(prl.Product2__r.Id,prl.Product_Register__r.Stelsedag__c);
+ if ((prl.Product_Register__r.MedPrdClass__c == '2' || prl.Product_Register__r.MedPrdClass__c == '2') && prl.Product_Register__r.Stelsedag__c <> null) {
+ if (prSte1Map.containsKey(prl.Product2__r.Id)) {
+ if (prSte1Map.get(prl.Product2__r.Id) > prl.Product_Register__r.Stelsedag__c) {
+ prSte1Map.put(prl.Product2__r.Id,prl.Product_Register__r.Stelsedag__c);
}
+ }else {
+ prSte1Map.put(prl.Product2__r.Id,prl.Product_Register__r.Stelsedag__c);
}
- }
+ }
}
}
@@ -104,14 +101,16 @@
Map<Id,String> prl2Map = new Map<Id,String>();
System.debug('pro2Map='+pro2Map);
System.debug('prSteMap='+prSteMap);
-
+ System.debug('prSte1Map='+prSte1Map);
+
//閫氳繃涓婇潰鐨勫惊鐜紝鎶婂叧绯昏〃杩囪幏鍙栫殑鏁版嵁璇诲嚭鏉ワ紝浼犵粰map
if (pro2Map.size()>0) {
for (Product_Register_Link__c pr: pro2List) {
- if (pro2Map.containsKey(pr.Product2__r.Id) && prSteMap.containsKey(pr.Product2__r.Id)) {
+ if (pro2Map.containsKey(pr.Product2__r.Id) && (prSteMap.containsKey(pr.Product2__r.Id) || prSte1Map.containsKey(pr.Product2__r.Id))) {
+ Date stedate = prSteMap.get(pr.Product2__r.Id)==null?prSte1Map.get(pr.Product2__r.Id)==null?null:prSte1Map.get(pr.Product2__r.Id):prSte1Map.get(pr.Product2__r.Id);
if (newMap.get(pr.Product2__r.Id).demoteer_Sap__c <> null && pr.Product2__r.Diedatvanink__c <> null) {
if (pr.Product_Register__r.Stelsedag__c <> null) {
- if (pr.Product2__r.Diedatvanink__c <= pr.Product_Register__r.Stelsedag__c) {
+ if (pr.Product2__r.Diedatvanink__c <= stedate) {
if (newMap.get(pr.Product2__r.Id).demoteer_Sap__c <= pr.Product_Register__r.ValidTo__c && newMap.get(pr.Product2__r.Id).demoteer_Sap__c >= pr.Product_Register__r.ValidFrom__c
&& pr.Product_Register__r.MedPrdClass__c == '2' || pr.Product_Register__r.MedPrdClass__c == '3') {
System.debug('2');
@@ -142,7 +141,7 @@
prlMap.put(pr.Product2__r.Id, Lins);
}
}
- }else if (pr.Product2__r.Diedatvanink__c > pr.Product_Register__r.Stelsedag__c) {
+ }else if (pr.Product2__r.Diedatvanink__c > stedate) {
if (newMap.get(pr.Product2__r.Id).demoteer_Sap__c <= pr.Product_Register__r.ValidTo__c && newMap.get(pr.Product2__r.Id).demoteer_Sap__c >= pr.Product_Register__r.ValidFrom__c
&& pr.Product_Register__r.MedPrdClass__c == '1') {
if (prl1Map.get(pr.Product2__r.Id) == null) {
--
Gitblit v1.9.1