From e3c02c03dd2de442bbced87236f60a13a1cd154e Mon Sep 17 00:00:00 2001
From: 高章伟 <gaozhangwei@prec-tech.com>
Date: 星期四, 02 三月 2023 17:51:57 +0800
Subject: [PATCH] gzw 正式环境最新代码更新
---
force-app/main/default/classes/OpportunityAndContactDailyUpdateBatch.cls | 396 +++++++++++++++++++++++++++++++++++++++++++++++++++----
1 files changed, 362 insertions(+), 34 deletions(-)
diff --git a/force-app/main/default/classes/OpportunityAndContactDailyUpdateBatch.cls b/force-app/main/default/classes/OpportunityAndContactDailyUpdateBatch.cls
index b12d6c5..530bac2 100644
--- a/force-app/main/default/classes/OpportunityAndContactDailyUpdateBatch.cls
+++ b/force-app/main/default/classes/OpportunityAndContactDailyUpdateBatch.cls
@@ -59,7 +59,7 @@
system.debug(runTarget);
}
- global Database.QueryLocator start(Database.BatchableContext BC) {
+ global Database.QueryLocator start(Database.BatchableContext BC) {
if (salesdepartment == null || salesdepartment == '') {
query = ' select Id,FSE_Main__c,GI_Main__c,SP_Main__c,GI_Product_Leader__c,GS_Product_Leader__c,GYN_Product_Leader__c,BF_owner__c, ';
query += 'ET_Product_Leader__c,BF_Product_Leader__c,ENT_Product_Leader__c,FSE_GI_Vice_Leader__c,FSE_SP_Vice_Leader__c,GYN_owner__c,';
@@ -69,7 +69,7 @@
query += 'ENT_owner_ID__c,Original_Date_Flag__c,ET_owner__c,URO_owner_ID__c ,URO_Produc_Leader__c,FSE_SP_Main_Leader__c, FSE_GI_Main_Leader__c, ParentId, OwnerId,Energy_LeaderStr__c,FSE_Extend_viceLeaderStr__c,Extend_Leader_Str__c,';
query += 'FSE_Main__r.IsActive ,GI_Main__r.IsActive ,URO_owner_ID__r.IsActive ,ET_owner__r.IsActive ,';
query += 'ENT_owner_ID__r.IsActive ,BF_owner__r.IsActive ,SP_Main__r.IsActive ,GYN_owner__r.IsActive ';
- query += ' from Account where Is_Active__c = \'鏈夊姽\' and RecordType.DeveloperName = \'HP\'';
+ query += ' from Account where Is_Active__c = \'鏈夊姽\' and RecordType.DeveloperName = \'HP\' and Id=\'0011000000V9UKl\'';
if (runTarget != null && runTarget.size() > 0) {
query += ' and id = :runTarget ';
}
@@ -98,7 +98,7 @@
List<Account> deptClassUpdateList = [select Id, RecordType.DeveloperName, Parent.Original_Date_Flag__c, ParentId, Parent.ownerId, Parent.owner.Alias__c, OwnerId from Account where Parent.Is_Active__c = '鏈夊姽' and Parent.RecordType.DeveloperName = 'HP' and Hospital_Department_Class__c = :hpList order by Hospital_Department_Class__c, Account_Sort__c];
List<Account> deptUpdateList = [select Id, RecordType.DeveloperName, Parent.Parent.Original_Date_Flag__c, Parent.owner.Alias__c, Parent.ParentId, Parent.Parent.ownerId, OwnerId from Account where Parent.Parent.Is_Active__c = '鏈夊姽' and Parent.Parent.RecordType.DeveloperName = 'HP' and Hospital__c = :hpList order by Hospital__c, Account_Sort__c];
-
+
AccountDailyUpdateBatch.updateFromHosToContact(deptUpdateList, iflog);
updateFromHosToContact(deptUpdateList, iflog);
//20220415 you SWAG-CBUB2W start
@@ -106,23 +106,44 @@
//20220415 you SWAG-CBUB2W end
//20220509 you SWAG-CBUB2W start
- //updateFromHosToInquiryFormFSEMain(hpList, iflog);
+ updateFromHosToInquiryFormFSEMain(hpList, iflog);
//20220509 you SWAG-CBUB2W end
}
//鍚屾鎵�灞炵殑璇环锛堜笟鍔℃満浼氾級鐨勬墍鏈変汉
public static void updateFromHosToContact(List<Account> deptUpdateList, BatchIF_Log__c iflog) {
- List<Opportunity> updateOpportunityList =
+ List<Opportunity> updateOpportunityList =
[select id, Ownerid, Account.ownerId from Opportunity
where Accountid in:deptUpdateList
and isOwnerDiffWithAccount__c = true
AND owner_not_automatically_update__c = FALSE ];
+ //20220928 you SWAG-CJP7TL start
+ system.debug('deptUpdateList==='+deptUpdateList);
+ Map<Id,String> mapoppid = new Map<Id,String>();
for (Opportunity opp : updateOpportunityList) {
if (opp.Ownerid != opp.Account.ownerId) {
opp.Ownerid = opp.Account.ownerId;
+ mapoppid.put(opp.id,opp.Account.ownerId);
}
}
+ List<Task__c> taskList = [
+ SELECT Id,OpportunityId__c,taskStatus__c
+ FROM task__c
+ WHERE OpportunityId__c in :mapoppid.keySet()
+ AND (RecordType.Name = '涓爣缁撴灉纭' OR RecordType.Name = '澶卞崟鎶ュ憡浠诲姟')
+ AND taskStatus__c = '02 鎺ュ彈'];
+ system.debug(mapoppid.keySet()+'test1-----'+taskList);
+ for(Task__c t: taskList){
+ if(mapoppid.containsKey(t.OpportunityId__c)){
+ t.Ownerid = mapoppid.get(t.OpportunityId__c);
+ t.assignee__c = mapoppid.get(t.OpportunityId__c);
+ }
+
+ }
+
Integer indexCon = 0;
Database.SaveResult[] lsrUpdateCon = Database.update(updateOpportunityList, false);
+ Database.SaveResult[] lsrUpdatetask = Database.update(taskList, false);
+ //20220928 you SWAG-CJP7TL end
for (Database.SaveResult lsrChild : lsrUpdateCon) {
if (!lsrChild.isSuccess()) {
iflog.Is_Error__c = 3;
@@ -139,13 +160,17 @@
//鍚屾鎵�灞炵殑浜у搧鍜ㄨ鍗曠殑鎵�鏈変汉
public static void updateFromHosToInquiryForm(List<Account> deptUpdateList, BatchIF_Log__c iflog) {
List<Inquiry_form__c> updateInquiryFormList =
- [select id, Ownerid,Depart_Owner__c, Hospital_Name__r.ownerId from Inquiry_form__c
+ [select id, Ownerid,Depart_Owner__c,Product_Owner__c, Hospital_Name__r.ownerId from Inquiry_form__c
where Hospital_Name__c in:deptUpdateList
and isOwnerDiffWithAccount__c = true ];
for (Inquiry_form__c ifo : updateInquiryFormList) {
if (ifo.Ownerid != ifo.Hospital_Name__r.ownerId) {
ifo.Depart_Owner__c = ifo.Hospital_Name__r.ownerId;
- ifo.Ownerid = ifo.Hospital_Name__r.ownerId;
+ //20221128 you DB202211530484 褰撳嬀閫� 杞骇鍝佹媴褰撴椂锛屾墍鏈変汉鍙互鎵嬪姩鏇存敼锛屼笉闇�瑕佸悓姝ヨ窡绉戝鎵�鏈変汉涓�鑷�
+ if(ifo.Product_Owner__c == false){
+ ifo.Ownerid = ifo.Hospital_Name__r.ownerId;
+ }
+
}
}
Integer indexCon = 0;
@@ -164,36 +189,37 @@
}
//20220415 you SWAG-CBUB2W end
- ////20220509 you SWAG-CBUB2W start
- // public static void updateFromHosToInquiryFormFSEMain(List<SObject> hpList, BatchIF_Log__c iflog) {
- // List<Inquiry_form__c> updateInquiryFormFSEList =
- // [select id, Ownerid,Hospital_Name__c,Hospital_Name__r.Name, Hospital_Name__r.ownerId,FSE_Owner__c,
- // Hospital_Name__r.Parent.Parent.FSE_GI_Main_Leader__c,Hospital_Name__r.Parent.Parent.FSE_SP_Main_Leader__c from Inquiry_form__c
- // where Hospital__c in:hpList
- // and isFSEDiffWithAccount__c = true ];
- // for (Inquiry_form__c ifo : updateInquiryFormFSEList) {
- // if (String.isNotBlank(ifo.Hospital_Name__r.Name) && (ifo.Hospital_Name__r.Name.contains('娑堝寲') || ifo.Hospital_Name__r.Name.contains('鍛煎惛') || ifo.Hospital_Name__r.Name.contains('ET')) && ifo.FSE_Owner__c != ifo.Hospital_Name__r.Parent.Parent.FSE_GI_Main_Leader__c) {
- // ifo.FSE_Owner__c = ifo.Hospital_Name__r.Parent.Parent.FSE_GI_Main_Leader__c;
+ //20220509 you SWAG-CBUB2W start
+ //FSE涓绘媴褰撳彉鍖�
+ public static void updateFromHosToInquiryFormFSEMain(List<SObject> hpList, BatchIF_Log__c iflog) {
+ List<Inquiry_form__c> updateInquiryFormFSEList =
+ [select id, Ownerid,Hospital_Name__c,Hospital_Name__r.Name, Hospital_Name__r.ownerId,FSE_Owner__c,
+ Hospital_Name__r.Parent.Parent.FSE_GI_Main_Leader__c,Hospital_Name__r.Parent.Parent.FSE_SP_Main_Leader__c from Inquiry_form__c
+ where Hospital__c in:hpList
+ and isFSEDiffWithAccount__c = true ];
+ for (Inquiry_form__c ifo : updateInquiryFormFSEList) {
+ if (String.isNotBlank(ifo.Hospital_Name__r.Name) && (ifo.Hospital_Name__r.Name.contains('娑堝寲') || ifo.Hospital_Name__r.Name.contains('鍛煎惛') || ifo.Hospital_Name__r.Name.contains('ET')) && ifo.FSE_Owner__c != ifo.Hospital_Name__r.Parent.Parent.FSE_GI_Main_Leader__c) {
+ ifo.FSE_Owner__c = ifo.Hospital_Name__r.Parent.Parent.FSE_GI_Main_Leader__c;
- // }
- // if(String.isNotBlank(ifo.Hospital_Name__r.Name) && !ifo.Hospital_Name__r.Name.contains('娑堝寲') && !ifo.Hospital_Name__r.Name.contains('鍛煎惛') && !ifo.Hospital_Name__r.Name.contains('ET') && ifo.FSE_Owner__c != ifo.Hospital_Name__r.Parent.Parent.FSE_SP_Main_Leader__c){
- // ifo.FSE_Owner__c = ifo.Hospital_Name__r.Parent.Parent.FSE_SP_Main_Leader__c;
- // }
- // }
- // Integer indexCon = 0;
- // Database.SaveResult[] lsrUpdateInq = Database.update(updateInquiryFormFSEList, false);
- // for (Database.SaveResult lsrChild : lsrUpdateInq) {
- // if (!lsrChild.isSuccess()) {
- // iflog.Is_Error__c = 3;
- // Database.Error emsg = lsrChild.getErrors()[0];
- // iflog.ErrorLog__c += 'ownerId: ' + updateInquiryFormFSEList.get(indexCon).ownerId + ' \n'
- // + 'InquiryFormID: ' + updateInquiryFormFSEList.get(indexCon).Id + '\n ConLog:' + emsg.getMessage() + '\n';
+ }
+ if(String.isNotBlank(ifo.Hospital_Name__r.Name) && !ifo.Hospital_Name__r.Name.contains('娑堝寲') && !ifo.Hospital_Name__r.Name.contains('鍛煎惛') && !ifo.Hospital_Name__r.Name.contains('ET') && ifo.FSE_Owner__c != ifo.Hospital_Name__r.Parent.Parent.FSE_SP_Main_Leader__c){
+ ifo.FSE_Owner__c = ifo.Hospital_Name__r.Parent.Parent.FSE_SP_Main_Leader__c;
+ }
+ }
+ Integer indexCon = 0;
+ Database.SaveResult[] lsrUpdateInq = Database.update(updateInquiryFormFSEList, false);
+ for (Database.SaveResult lsrChild : lsrUpdateInq) {
+ if (!lsrChild.isSuccess()) {
+ iflog.Is_Error__c = 3;
+ Database.Error emsg = lsrChild.getErrors()[0];
+ iflog.ErrorLog__c += 'ownerId: ' + updateInquiryFormFSEList.get(indexCon).ownerId + ' \n'
+ + 'InquiryFormID: ' + updateInquiryFormFSEList.get(indexCon).Id + '\n ConLog:' + emsg.getMessage() + '\n';
- // }
- // indexCon ++ ;
- // }
+ }
+ indexCon ++ ;
+ }
- //}
+ }
//20220509 you SWAG-CBUB2W end
global void finish(Database.BatchableContext BC) {
system.debug('=====iflog:' + iflog.id);
@@ -229,4 +255,306 @@
//Database.executeBatch(new ConsumablesApplyOrLendBatch(), 50);
//20200819 ljh add end
}
+
+ @TestVisible private static void test() {
+ 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++;
+ 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