From ba1c90575c47f9cb5c2ce0a20da90d3b1739b5fa Mon Sep 17 00:00:00 2001
From: buli <137736985@qq.com>
Date: 星期二, 26 四月 2022 11:47:45 +0800
Subject: [PATCH] 0425 Commit
---
force-app/main/default/classes/ProRegisterHandler.cls | 96 ++++++------------------------------------------
1 files changed, 12 insertions(+), 84 deletions(-)
diff --git a/force-app/main/default/classes/ProRegisterHandler.cls b/force-app/main/default/classes/ProRegisterHandler.cls
index 2875d82..f290e50 100644
--- a/force-app/main/default/classes/ProRegisterHandler.cls
+++ b/force-app/main/default/classes/ProRegisterHandler.cls
@@ -98,107 +98,35 @@
if (UpdProMap.keySet().size() > 0) update UpdProMap.values();
}
- //浜у搧闄嶇被,鍙娉ㄥ唽璇佹洿鏂颁簡,灏辨鏌ヤ竴閬嶏紝閲嶆柊缁欎骇鍝佷笂鐨勭瓑绾х被鍒瓧娈佃祴鍊笺��
- //鍙互鎵惧嚭闇�瑕佺殑Id,鐒跺悗璋冪敤鏂规硶銆�
+ //鐢ㄤ簬闄嶇被,浜у搧娉ㄥ唽璇佹洿鏂颁簡,灏辨妸浜у搧娉ㄥ唽璇佷笅鐨勪骇鍝佺殑绛夌骇绫诲埆瀛楁璧嬬┖,瑙﹀彂浜у搧鐨勮Е鍙戝櫒
public static void checkRegistervervaldatum(List<Product_Register__c> newList, Map<Id, Product_Register__c> newMap, List<Product_Register__c> oldList, Map<Id, Product_Register__c> oldMap) {
List<String> prcList = new List<String>();
for (Product_Register__c pr : newList) {
Product_Register__c oldpr = oldMap.get(pr.Id);
- //鏈夋晥鏈熺殑濮嬩笌缁堝彉浜�,灏辨妸杩欎釜浜у搧娉ㄥ唽璇佺殑id鏀惧叆涓�涓狶ist闆嗗悎閲岄潰
- //if (pr.ValidTo__c != oldpr.ValidTo__c || pr.ValidFrom__c != oldpr.ValidFrom__c) {
prcList.add(pr.id);
- //}
}
//鏀惧埌Map閲岋紝鐢ㄤ簬娉ㄥ唽璇佹洿鏂颁骇鍝�
Map<Id,Product2> prt2Map = new Map<Id,Product2>();
//閫氳繃涔嬪墠瀛樺偍鐨処d鐢ㄤ簬鍏崇郴琛ㄧ殑鏌ヨ銆�
List<Product_Register_Link__c> prlList = new List<Product_Register_Link__c>();
- prlList = [select Product2__r.id,Product2__r.demoteer_Sap__c,Product2__r.Diedatvanink__c,Product_Register__r.MedPrdClass__c,Product_Register__r.Stelsedag__c
+ prlList = [select Product2__r.id,Product2__r.demoteer_Sap__c,Product2__r.Diedatvanink__c,Product_Register__r.MedPrdClass__c,Product_Register__r.Stelsedag__c,Product_Register__r.ValidTo__c,Product_Register__r.ValidFrom__c
from Product_Register_Link__c
where Product_Register__r.Id in : prcList];
- //鏍规嵁Id瀛樻斁浜у搧鎵�灞炵殑鎵�鏈夋敞鍐岃瘉涓嬬殑鍣ㄦ鍒嗙被銆�
- Map<Id,List<String>> pro2Map = new Map<Id,List<String>>();
- //瀛樻斁娉ㄥ唽璇佷笂鏈�鍓嶇殑缁存姢鏃�
- Map<Id,Date> prSteMap = new Map<Id,Date>();
- if (prlList.size()>0) {
- for (Product_Register_Link__c prl: prlList) {
- if (pro2Map.containsKey(prl.Product2__r.Id)) {
- pro2Map.get(prl.Product2__r.Id).add(prl.Product_Register__r.MedPrdClass__c);
- }else {
- pro2Map.put(prl.Product2__r.Id, new List<String>());
- pro2Map.get(prl.Product2__r.Id).add(prl.Product_Register__r.MedPrdClass__c);
- }
- if (prSteMap.containsKey(prl.Product2__r.Id)) {
- if (prSteMap.get(prl.Product2__r.Id) > prl.Product_Register__r.Stelsedag__c) {
- prSteMap.remove(prl.Product2__r.Id);
- 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);
- }
- }
+ List<ID> proIdList = new List<ID>();
+ for (Product_Register_Link__c prl: prlList) {
+ proIdList.add(prl.Product2__r.id);
}
- System.debug('pro2Map='+pro2Map);
- System.debug('prSteMap='+prSteMap);
- //浜у搧Id涓庣瓑绾х被鍒�
- Map<Id,String> prlMap = new Map<Id,String>();
- List<ID> pr2Idlsit = new List<ID>();
- if (pro2Map.size()>0 && prSteMap.size()>0) {
- for (Product_Register_Link__c pr: prlList) {
- if (pro2Map.containsKey(pr.Product2__r.Id) && prSteMap.containsKey(pr.Product2__r.Id)) {
- pr2Idlsit.add(pr.Product2__r.Id);
- //鐢熶骇鏃ュぇ浜庣淮鎶ゆ棩,鍏ュ簱鏃ュぇ浜庣淮鎶ゆ棩
- if (pr.Product2__r.demoteer_Sap__c <= prSteMap.get(pr.Product2__r.Id) &&
- pr.Product2__r.Diedatvanink__c <= prSteMap.get(pr.Product2__r.Id)) {
- if (pro2Map.get(pr.Product2__r.Id).contains('1') ||
- pro2Map.get(pr.Product2__r.Id).contains('2') ||
- pro2Map.get(pr.Product2__r.Id).contains('3')) {
- prlMap.put(pr.Product2__r.Id, '浜岀被');
- }else {
- prlMap.put(pr.Product2__r.Id, '闈炵洃绠�');
- }
- }else {
- //鍏ュ簱鏃ュぇ浜庣淮鎶ゆ棩
- if (pr.Product2__r.Diedatvanink__c > prSteMap.get(pr.Product2__r.Id)) {
- //鐢熶骇鏃ュぇ浜庣淮鎶ゆ棩
- if (pr.Product2__r.demoteer_Sap__c > prSteMap.get(pr.Product2__r.Id)) {
- prlMap.put(pr.Product2__r.Id, '涓�绫�');
- }else {
- //鐢熶骇鏃ュ皬浜庣淮鎶ゆ棩
- if (pro2Map.get(pr.Product2__r.Id).contains('1')) {
- prlMap.put(pr.Product2__r.Id, '涓�绫�');
- }else if (!pro2Map.get(pr.Product2__r.Id).contains('1') &&
- (pro2Map.get(pr.Product2__r.Id).contains('2') ||
- pro2Map.get(pr.Product2__r.Id).contains('3'))) {
- prlMap.put(pr.Product2__r.Id, '浜岀被');
- }else {
- prlMap.put(pr.Product2__r.Id, '闈炵洃绠�');
- }
- }
- }
- }
- }
- }
- }
- System.debug('prlMap='+prlMap);
-
+
List<Product2> por2Lsit = new List<Product2>();
//鏌ュ嚭浜у搧鐨刬d鍜岀瓑绾х被鍒殑瀛楁
- por2Lsit = [select Id,Level_Category__c from Product2 where Id in : pr2Idlsit];
- if (por2Lsit.size() > 0) {
- for (Product2 pr2: por2Lsit) {
- if (prlMap.containsKey(pr2.Id)) {
- pr2.Level_Category__c = prlMap.get(pr2.Id);
- prt2Map.put(pr2.Id,pr2);
- }else {
- pr2.Level_Category__c = null;
- prt2Map.put(pr2.Id,pr2);
- }
- }
+ por2Lsit = [select Id,Level_Category__c from Product2 where Id in : proIdList];
+ for (Product2 pro: por2Lsit) {
+ pro.Level_Category__c = null;
+ prt2Map.put(pro.Id, pro);
}
-
- if (prlMap.size() > 0) {
+ System.debug('prt2Map='+prt2Map);
+ if (prt2Map.size() > 0) {
update prt2Map.values();
}
}
--
Gitblit v1.9.1