global class Sfdc2PoContactBatch implements Database.Batchable<sObject>, Database.AllowsCallouts {
|
public String query;
|
|
global Sfdc2PoContactBatch() {
|
this.query = query;
|
}
|
|
global Database.QueryLocator start(Database.BatchableContext bc) {
|
// return Database.getQueryLocator([SELECT id, Name, IsFromSPO__c, RecordTypeId, UnifiedI_Contact_ID__c, SendToComPlat__c,MobilePhone
|
// FROM Contact
|
// WHERE Id != null AND RecordTypeId = '01210000000QfWiAAK' AND Account.Is_Active_Formula__c = '有效' AND MobilePhone != '' AND Isactive__c = '有效'
|
// ]);
|
// 发送指定数据
|
// 经销商和医院客户人员数据都需要重新执行 thh 20220411 start
|
return Database.getQueryLocator([SELECT id, Name, IsFromSPO__c, RecordTypeId, UnifiedI_Contact_ID__c, SendToComPlat__c,MobilePhone
|
FROM Contact
|
WHERE Id != null
|
AND (RecordTypeId = '01210000000QfWiAAK' OR RecordTypeId = '01210000000QfWdAAK')
|
AND Account.Is_Active_Formula__c = '有效'
|
AND MobilePhone != ''
|
AND ((Isactive__c = '有效'
|
AND SendToComPlat__c = true) OR SendToComPlat__c = true)
|
]);
|
// 经销商和医院客户人员数据都需要重新执行 thh 20220411 end
|
|
}
|
|
global void execute(Database.BatchableContext BC, list < Contact > senContactList) {
|
// 跳过ContactTriggerHandler,否则会报错 thh 20220411 start
|
Oly_TriggerHandler.bypass('ContactTriggerHandler');
|
// 跳过ContactTriggerHandler,否则会报错 thh 20220411 end
|
List < String > conatctIdList = new List < String > ();
|
for (Contact con: senContactList) {
|
// 医院 客户人员 统一平台编码 发送 PO
|
if ('01210000000QfWdAAK'.equals(con.RecordTypeId) && String.isNotBlank(con.UnifiedI_Contact_ID__c)) {
|
conatctIdList.add(con.Id);
|
}
|
// 经销商 客户人员 手机号码不为空 发送 PO
|
if ('01210000000QfWiAAK'.equals(con.RecordTypeId) && String.isNotBlank(con.MobilePhone)) {
|
conatctIdList.add(con.Id);
|
}
|
|
con.SendToComPlat__c = false;
|
}
|
if (conatctIdList.size() > 0) {
|
NFM606Controller.executeNotFuture(null, conatctIdList);
|
}
|
update senContactList;
|
}
|
|
global void finish(Database.BatchableContext BC) {
|
|
}
|
}
|