From 80f74bc1dfbf4a6f2fa358efe027590d2cdb5b99 Mon Sep 17 00:00:00 2001
From: GWY <guweiyiscp096@foxmail.com>
Date: 星期二, 19 四月 2022 10:39:16 +0800
Subject: [PATCH] 代理商公共小组,无影响。
---
force-app/main/default/classes/ProRegisterLinkHandler.cls | 269 +++++++++++++++++++----------------------------------
1 files changed, 97 insertions(+), 172 deletions(-)
diff --git a/force-app/main/default/classes/ProRegisterLinkHandler.cls b/force-app/main/default/classes/ProRegisterLinkHandler.cls
index 59e716b..8e0744e 100644
--- a/force-app/main/default/classes/ProRegisterLinkHandler.cls
+++ b/force-app/main/default/classes/ProRegisterLinkHandler.cls
@@ -1,182 +1,107 @@
-public with sharing class ProRegisterLinkHandler extends Oly_TriggerHandler {
- /* 2018-08-31 鏇存柊浜у搧鍐呮渶鏂颁骇鍝佸湪娉ㄥ唽璇�
- 1.鏍规嵁浜у搧-娉ㄥ唽璇佸叧绯绘壘鍑烘墍鏈夊搴旂殑浜у搧
- 2.鏍规嵁浜у搧鎵惧嚭鍏舵墍闇�鏈�鏂颁骇鍝佹敞鍐岃瘉
- */
- private Map<Id, Product_Register_Link__c> newMap;
- private Map<Id, Product_Register_Link__c> oldMap;
- private List<Product_Register_Link__c> newList;
- private List<Product_Register_Link__c> oldList;
+public without sharing class ProRegisterLinkHandler {
+ /* 鏇存柊浜у搧鍐呮渶鏂颁骇鍝佸湪娉ㄥ唽璇�
+ 1.鏍规嵁浜у搧-娉ㄥ唽璇佸叧绯绘壘鍑烘墍鏈夊搴旂殑浜у搧
+ 2.鏍规嵁浜у搧鎵惧嚭鍏舵墍闇�鏈�鏂颁骇鍝佹敞鍐岃瘉
+ */
+ public static void updateProduct(List<Product_Register_Link__c> newList, Map<Id, Product_Register_Link__c> newMap, List<Product_Register_Link__c> oldList, Map<Id, Product_Register_Link__c> oldMap, string HandleType) {
+ // 浜у搧-娉ㄥ唽璇佸叧绯� 涓墍鏈� 浜у搧ID
+ list<ID> Product2_ID_list = new list<ID>();
+ // 鐜版湁浜у搧 map
+ map<ID, Product2> Exist_ProductMap = new map<ID, Product2>();
+ // 闇�瑕佹洿鏂颁骇鍝� list
+ List<Product2> UpdateProductlist = new list<Product2>();
- public ProRegisterLinkHandler() {
- this.newMap = (Map<Id, Product_Register_Link__c>) Trigger.newMap;
- this.oldMap = (Map<Id, Product_Register_Link__c>) Trigger.oldMap;
- this.newList = (List<Product_Register_Link__c>) Trigger.new;
- this.oldList = (List<Product_Register_Link__c>) Trigger.old;
- }
+ List<Product_Register_Link__c> currentList = new List<Product_Register_Link__c>();
- protected override void afterUpdate() {
- updateProduct('1');
- }
+ if ('1'.equals(HandleType)) {
+ currentList = newList;
+ } else {
+ currentList = oldList;
+ }
- protected override void afterInsert() {
- updateProduct('1');
- }
+ for (Product_Register_Link__c PRL : currentList) {
+ Product2_ID_list.add(PRL.Product2__c);
+ }
- protected override void afterDelete() {
- updateProduct('2');
- }
+ Exist_ProductMap = new map<ID, Product2>([select ID, registrationCode__c, clinical_product_code__c from Product2 where id in: Product2_ID_list]);
+ List<Product_Register_Link__c> allPRLList = new List<Product_Register_Link__c>();
+
+ allPRLList = [select Product2__c,
+ Product_Register__c,
+ Product_Register__r.PrdCompanyAddr__c,
+ Product_Register__r.ValidFrom__c,
+ Product_Register__r.ValidTo__c,
+ Product_Register__r.name,
+ Product_Register__r.ValidProductRegister__c,
+ Product_Register__r.ClinicalProductCode__c
+ from Product_Register_Link__c
+ where Product2__c in : Product2_ID_list
+ order by Product2__c,
+ LastModifiedDate desc
+ ];
+
+ String tmpProductID = '';
+ Map<ID, Product2> Upd_ProductMap = new Map<ID, Product2>();
+ Product2 temProduct = new Product2();
+
+ for (String ProId : Product2_ID_list) {
+ temProduct = Exist_ProductMap.get(ProId);
+ Upd_ProductMap.put(ProId, temProduct);
+ }
+
+ for (Product_Register_Link__c temPRL : allPRLList) {
+ if (!tmpProductID.equals(temPRL.Product2__c)) {
+ tmpProductID = temPRL.Product2__c;
+ temProduct = Upd_ProductMap.get(tmpProductID);
+ temProduct.Register_Latest__c = temPRL.Product_Register__c; // 鏈�鏂版敞鍐岃瘉ID
+ temProduct.registrationCode__c = null;
+ temProduct.clinical_product_code__c = null;
+ }
+ //// 濡傛灉娉ㄥ唽璇佺姸鎬佹湁鏁�,璁板綍鏈夋晥娉ㄥ唽璇佸彿
+ if (temPRL.Product_Register__r.ValidProductRegister__c) {
+ if (String.isBlank(temProduct.registrationCode__c)) {
+ temProduct.registrationCode__c = temPRL.Product_Register__r.Name + '\n';
+ } else {
+ if (String.isNotBlank(temPRL.Product_Register__r.Name)) {
+ if (temProduct.registrationCode__c.indexOf(temPRL.Product_Register__r.Name) == -1) {
+ temProduct.registrationCode__c += temPRL.Product_Register__r.Name + '\n';
+ }
+ }
+ }
+ String clinicalCode = temPRL.Product_Register__r.ClinicalProductCode__c;
+ if (String.isBlank(temProduct.clinical_product_code__c)) {
+ temProduct.clinical_product_code__c = clinicalCode;//temPRL.Product_Register__r.ClinicalProductCode__c;
+ } else {
+
+ if (String.isNotBlank(clinicalCode)) {
+
+ Map<String, String> codeMap = new Map<String, String>();
+ for (String code : temProduct.clinical_product_code__c.split('/')) {
+ codeMap.put(code, code);
+ }
+ codeMap.put(clinicalCode, clinicalCode);
+ temProduct.clinical_product_code__c = '';
+ for (String code : codeMap.values()) {
+ if (String.isBlank(temProduct.clinical_product_code__c)) {
+ temProduct.clinical_product_code__c = code;
+ } else {
+ temProduct.clinical_product_code__c += '/' + code;
+ }
+ }
+
+ }
+
+ }
+ }
- // 鏂板缓鍜屾洿鏂颁骇鍝�-娉ㄥ唽璇佸叧绯绘椂浣跨敤
- private void updateProduct(string HandleType) {
+ Upd_ProductMap.put(tmpProductID, temProduct);
+ }
- // 浜у搧-娉ㄥ唽璇佸叧绯� 涓墍鏈� 浜у搧ID
- list<ID> Product2_ID_list = new list<ID>();
- // 鐜版湁浜у搧 map
- map<ID, Product2> Exist_ProductMap = new map<ID, Product2>();
- // 闇�瑕佹洿鏂颁骇鍝� list
- List<Product2> UpdateProductlist = new list<Product2>();
+ if (Upd_ProductMap.keySet().size() > 0) {
+ update Upd_ProductMap.values();
+ }
- List<Product_Register_Link__c> currentList = new List<Product_Register_Link__c>();
+ }
- if ('1'.equals(HandleType)) {
- currentList = newList;
- } else {
- currentList = oldList;
- }
-
- for (Product_Register_Link__c PRL : currentList) {
- Product2_ID_list.add(PRL.Product2__c);
- }
-
- Exist_ProductMap = new map<ID, Product2>([select ID, SFDA_Status__c from Product2 where id in: Product2_ID_list]);
- List<Product_Register_Link__c> allPRLList = new List<Product_Register_Link__c>();
-
- allPRLList = [select Product2__c,
- Product_Register__c,
- Product_Register__r.PrdCompanyAddr__c,
- Product_Register__r.PrdCompanyAddr2__c,
- Product_Register__r.PrdCompanyAddr3__c,
- Product_Register__r.ValidFrom__c,
- Product_Register__r.ValidTo__c,
- Product_Register__r.name,
- Product_Register__r.BusinessScopeKey__c,
- Product_Register__r.RegisterNoStatus__c
- from Product_Register_Link__c
- where Product2__c in : Product2_ID_list
- //and If_Delete__c = false
- order by Product2__c,
- Product_Register__r.RegisterNoStatusCode__c,
- LastModifiedDate desc
- ];
-
- String tmpProductID = '';
- Map<ID, Product2> Upd_ProductMap = new Map<ID, Product2>();
- Product2 temProduct = new Product2();
- String temAllProdStatus = '';
- String temAllProdStatus2 = '';
- String temAllProdStatusAll = '';
- String temAllScopeKey = '';
-
- for (String ProId : Product2_ID_list) {
- temProduct = Exist_ProductMap.get(ProId);
- temProduct.Register_Latest__c = null; // 鏈�鏂版敞鍐岃瘉ID
- temProduct.SFDA_Approbation_No__c = null; // CFDA娉ㄥ唽鍙�
- temProduct.SFDA_Approbated_Date__c = null; // CFDA娉ㄥ唽鏃�
- temProduct.SFDA_Expiration_Date__c = null; // CFDA鏈夋晥鏈熼檺
-
- //if (temProduct.SFDA_Status__c != '涓嶈') {
- //temProduct.ProduceCompany__c = null; // 鐢熶骇浼佷笟
- //}
- temProduct.SFDA_Approbated_Status__c = null; // CFDA娉ㄥ唽璇佺姸鎬�
- temProduct.RegisterNo_ALL__c = null;
- temProduct.RegisterNo_ALL2__c = null;
- // 20190401 CHAN-BAPCE6 LHJ Start
- temProduct.RegScopeKeyAll__c = null;
- // 20190401 CHAN-BAPCE6 LHJ End
-
- Upd_ProductMap.put(ProId, temProduct);
- }
-
- for (Product_Register_Link__c temPRL : allPRLList) {
- if (!tmpProductID.equals(temPRL.Product2__c)) {
- temAllProdStatus = '';
- temAllProdStatus2 = '';
- temAllProdStatusAll = '';
- temAllScopeKey = '';
- tmpProductID = temPRL.Product2__c;
- temProduct = Upd_ProductMap.get(tmpProductID);
- temProduct.Register_Latest__c = temPRL.Product_Register__c; // 鏈�鏂版敞鍐岃瘉ID
- temProduct.SFDA_Approbation_No__c = temPRL.Product_Register__r.name; // CFDA娉ㄥ唽鍙�
- temProduct.SFDA_Approbated_Date__c = temPRL.Product_Register__r.ValidFrom__c; // CFDA娉ㄥ唽鏃�
- temProduct.SFDA_Expiration_Date__c = temPRL.Product_Register__r.ValidTo__c; // CFDA鏈夋晥鏈熼檺
- if(temPRL.Product_Register__r.Name != 'FYL') {
- temProduct.ProduceCompany__c = temPRL.Product_Register__r.PrdCompanyAddr__c; // 鐢熶骇浼佷笟
- //CHAN-C4X63A 銆愬鎵樸�慛FM204瀛楁鈥滅敓浜т紒涓氬湴鍧�鈥濅紭鍖� XHL 20210716 Start
- temProduct.ProduceCompany2__c = temPRL.Product_Register__r.PrdCompanyAddr2__c;
- temProduct.ProduceCompany3__c = temPRL.Product_Register__r.PrdCompanyAddr3__c;
- //CHAN-C4X63A 銆愬鎵樸�慛FM204瀛楁鈥滅敓浜т紒涓氬湴鍧�鈥濅紭鍖� XHL 20210716 End
- }
- temProduct.SFDA_Approbated_Status__c = temPRL.Product_Register__r.RegisterNoStatus__c; // CFDA娉ㄥ唽璇佺姸鎬�;
- }
- //// 濡傛灉娉ㄥ唽璇佺姸鎬佹湁鏁�,璁板綍鏈夋晥娉ㄥ唽璇佸彿
- if (temPRL.Product_Register__r.RegisterNoStatus__c == '鏈夋晥') {
- //temAllProdStatus += ';' + temPRL.Product_Register__r.name;
- String productRegisterName = temPRL.Product_Register__r.Name;
- if (temAllProdStatus.length() + productRegisterName.length() <= 240) {
- if (!temAllProdStatusAll.contains(productRegisterName)) {
- temAllProdStatus += ';' + productRegisterName;
- temAllProdStatusAll += ';' + productRegisterName;
- }
- //temAllProdStatus += ';' + productRegisterName;
- } else {
- if (!temAllProdStatusAll.contains(productRegisterName)) {
- temAllProdStatus2 += ';' + productRegisterName;
- temAllProdStatusAll += ';' + productRegisterName;
- }
- //temAllProdStatus2 += ';' + productRegisterName;
- }
- // 20190401 CHAN-BAPCE6 LHJ Start
- //if (String.isNotBlank(temPRL.Product_Register__r.BusinessScopeKey__c) &&
- // (!temAllScopeKey.contains(temPRL.Product_Register__r.BusinessScopeKey__c))) {
- // temAllScopeKey += ';' + temPRL.Product_Register__r.BusinessScopeKey__c;
- //}
- String businessScopeKey = temPRL.Product_Register__r.BusinessScopeKey__c;
- if (String.isNotBlank(businessScopeKey)) {
- for(String scopeKey:businessScopeKey.split(';')){
- if (!temAllScopeKey.contains(scopeKey)) {
- temAllScopeKey += ';' + scopeKey;
- }
- }
-
-
- }
- // 20190401 CHAN-BAPCE6 LHJ End
- }
- if (temAllProdStatus != '') {
- temProduct.RegisterNo_ALL__c = temAllProdStatus.substring(1, temAllProdStatus.length());
- } else {
- temProduct.RegisterNo_ALL__c = '';
- }
- if (temAllProdStatus2 != '') {
- temProduct.RegisterNo_ALL2__c = temAllProdStatus2.substring(1, temAllProdStatus2.length());
- } else {
- temProduct.RegisterNo_ALL2__c = '';
- }
- // 20190401 CHAN-BAPCE6 LHJ Start
- if (temAllScopeKey != '') {
- temProduct.RegScopeKeyAll__c = temAllScopeKey.substring(1, temAllScopeKey.length());
- } else {
- temProduct.RegScopeKeyAll__c = '';
- }
- // 20190401 CHAN-BAPCE6 LHJ End
-
- Upd_ProductMap.put(tmpProductID, temProduct);
- }
-
- if (Upd_ProductMap.keySet().size() > 0) {
- update Upd_ProductMap.values();
- }
- }
}
\ No newline at end of file
--
Gitblit v1.9.1