global class OPDLendSortCopyToSortBeforeBatch implements Database.Batchable { // SWAG-BYD6DD XHL 2021/02/20 public String query; List oPDPlanIdList = null; global OPDLendSortCopyToSortBeforeBatch() { this.query = query; } global OPDLendSortCopyToSortBeforeBatch(List oPDPlanIdList) { this.oPDPlanIdList = oPDPlanIdList; } global Database.QueryLocator start(Database.BatchableContext bc) { // 20231217 ljh 备品智能化 优化 start // if (oPDPlanIdList <> null) { // return Database.getQueryLocator([SELECT Id, Name, OPDPlan_ImplementDate__c,OPDLendSort__c,OPDLendSortDraft__c,OPDLendSortBefore__c,Status__c FROM OPDPlan__c WHERE (OPDLendSort__c != null OR OPDLendSortDraft__c != null OR OPDLendSortBefore__c != null) AND Status__c = '计划中' AND Id In :oPDPlanIdList]); // } else { // return Database.getQueryLocator([SELECT Id, Name, OPDPlan_ImplementDate__c,OPDLendSort__c,OPDLendSortDraft__c,OPDLendSortBefore__c,Status__c FROM OPDPlan__c WHERE Status__c = '计划中' AND (OPDLendSort__c != null OR OPDLendSortDraft__c != null OR OPDLendSortBefore__c != null)]); // } if (oPDPlanIdList <> null) { return Database.getQueryLocator([SELECT Id, OPDLendSort__c FROM OPDPlan__c WHERE (OPDLendSort__c != null OR OPDLendSortDraft__c != null OR OPDLendSortBefore__c != null) AND Status__c = '计划中' AND Id In :oPDPlanIdList]); } else { return Database.getQueryLocator([SELECT Id, OPDLendSort__c FROM OPDPlan__c WHERE Status__c = '计划中' AND (OPDLendSort__c != null OR OPDLendSortDraft__c != null OR OPDLendSortBefore__c != null)]); } // 20231217 ljh 备品智能化 优化 end } global void execute(Database.BatchableContext BC, List oPDPlanList) { List upOPDList = new List(); for(OPDPlan__c opdp : oPDPlanList) { // 20231217 ljh 备品智能化 不需要清空了 start // opdp.OPDLendSortBefore__c = null;//备品出借优先度(上月)置空 // opdp.OPDLendSortBefore__c = opdp.OPDLendSort__c;//备品出借优先度 赋值给 备品出借优先度(上月) // opdp.OPDLendSort__c = null;//备品出借优先度 置空 // opdp.SortSaveDate__c = null; //20230807 lt DB202308135410 add // opdp.OPDLendSortDraft__c = null;//备品出借优先度草案中 置空 // opdp.SortDate__c = null; //排序日期 置空 OPDPlan__c temp = new OPDPlan__c(); temp.Id = opdp.Id; temp.OPDLendSortBefore__c = opdp.OPDLendSort__c;//备品出借优先度 赋值给 备品出借优先度(上月) temp.Last_Month_Untreated__c = true; // 20231228 dzk 上个月未处理完标识 upOPDList.add(temp); // 20231217 ljh 备品智能化 不需要清空了 end } // 20231217 ljh 备品智能化 优化 start // if (oPDPlanList != null && oPDPlanList.size() > 0) { // update oPDPlanList; // } if (upOPDList != null && upOPDList.size() > 0) { update upOPDList; } // 20231217 ljh 备品智能化 优化 end } global void finish(Database.BatchableContext BC) { } //add by allen 拆分部署ali生产 public void testMock1(){ 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++; } }