| | |
| | | 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,'; |
| | |
| | | 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 |
| | |
| | | } |
| | | //同步所属的询价(业务机会)的所有人 |
| | | 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; |