| | |
| | | global Integer totalCount = 0; // 总件数 |
| | | global Integer failedCount = 0; |
| | | global Date tdy = Date.today(); |
| | | |
| | | Boolean IsNeedExecute = false; |
| | | |
| | | /** |
| | | * コンスタント |
| | | */ |
| | | global InventoryAutoGiveupBatch() { |
| | | } |
| | | global InventoryAutoGiveupBatch(Boolean NeedExecute) { |
| | | this.IsNeedExecute = NeedExecute; |
| | | } |
| | | |
| | | /** |
| | |
| | | bp3_Setting__c conf = bp3_Setting__c.getOrgDefaults(); |
| | | Date autoGiveupDate30 = Date.today().addDays(-(conf.Auto_GiveUp_Day__c == null ? 30 : Integer.valueOf(conf.Auto_GiveUp_Day__c))); |
| | | Date autoGiveupStartDate = conf.Auto_Giveup_StartDate__c == null ? Date.valueOf('1970-01-01') : conf.Auto_Giveup_StartDate__c; |
| | | return Database.getQueryLocator( |
| | | [SELECT Id, |
| | | LostReport_Detail__c, |
| | | LostReport_Detail__r.LostReport_Status_F__c, |
| | | LostReport_Detail__r.LostReport__c |
| | | FROM Inventory_Detail__c |
| | | WHERE Auto_Lost_item_giveup__c = false |
| | | AND Inventory_Deviation__c < 0 |
| | | AND Internal_Asset_Flg__c = true |
| | | AND Inventory_Time__c != null |
| | | AND Auto_Loaner_Giveup_StartCalculating_Date__c >= :autoGiveupStartDate |
| | | AND Auto_Loaner_Giveup_StartCalculating_Date__c != null |
| | | AND Auto_Loaner_Giveup_StartCalculating_Date__c <= :autoGiveupDate30 |
| | | ORDER BY Id] |
| | | ); |
| | | String query = 'SELECT Id,LostReport_Detail__c,LostReport_Detail__r.LostReport_Status_F__c,LostReport_Detail__r.LostReport__c'; |
| | | query+= ' FROM Inventory_Detail__c'; |
| | | query+= ' WHERE Auto_Lost_item_giveup__c = false AND Inventory_Deviation__c < 0 AND Internal_Asset_Flg__c = true AND Inventory_Time__c != null'; |
| | | query+= ' AND Auto_Loaner_Giveup_StartCalculating_Date__c >= :autoGiveupStartDate AND Auto_Loaner_Giveup_StartCalculating_Date__c != null AND Auto_Loaner_Giveup_StartCalculating_Date__c <= :autoGiveupDate30 ORDER BY Id'; |
| | | if(Test.isRunningTest()){ |
| | | query += ' limit 1'; |
| | | } |
| | | return Database.getQueryLocator(query); |
| | | } |
| | | |
| | | global void execute(Database.BatchableContext BC, List<SObject> ldList) { |
| | |
| | | totalCount, totalCount - failedCount, failedCount); |
| | | } |
| | | be.send(); |
| | | |
| | | //2022/2/21 pk 发货七天还未到货数 start |
| | | if(!Test.isRunningTest() && IsNeedExecute==true){ |
| | | //batch里调用下一个batch时,希望跟原有的Schedule里面传的条数保持一致 |
| | | Id execBTId = Database.executebatch(new Consumable7daysBatch(true),200); |
| | | } |
| | | //2022/2/21 pk 发货七天还未到货数 end |
| | | } |
| | | } |