| | |
| | | this.ih_new = ih; |
| | | } else { |
| | | // emailMessages ihList[0].Name 的状态是 ihList[0].Inventory_Status__c 不能盘点 |
| | | this.emailMessages.add(ihList[0].Name +'的状态是' + ihList[0].Inventory_Status__c + ' ,不能盘点。'); |
| | | this.emailMessages.add(ihList[0].Name +'的状态是' + ihList[0].Inventory_Status__c + ' ,不能盘点Copy。'); |
| | | return Database.getQueryLocator([SELECT Id FROM Asset LIMIT 0]); |
| | | } |
| | | } |
| | |
| | | and Asset_loaner_category__c != '耗材' |
| | | and Internal_asset_location__c = :cunFangDi]; |
| | | if (errorList.size()>0) { |
| | | this.emailMessages.add(ihList[0].Name +' 备品资产中存在未清空的冻结数, 不能盘点。'); |
| | | this.emailMessages.add(ihList[0].Name +' 备品资产中存在未清空的冻结数, 不能盘点Copy。'); |
| | | return Database.getQueryLocator([SELECT Id FROM Asset LIMIT 0]); |
| | | } |
| | | |
| | |
| | | from Inventory_Header_Copy__c where Id = :ih_new.Id]; |
| | | if (ihList.size() == 0 || ihList[0].Inventory_Status__c != '处理中') { |
| | | // emailMessages ihList[0].Name 的状态是 ihList[0].Inventory_Status__c 不能盘点 |
| | | this.emailMessages.add(ihList[0].Name +'的状态是' + ihList[0].Inventory_Status__c + ' ,不能盘点。'); |
| | | this.emailMessages.add(ihList[0].Name +'的状态是' + ihList[0].Inventory_Status__c + ' ,不能盘点Copy。'); |
| | | return; |
| | | } |
| | | Savepoint sp = Database.setSavepoint(); |
| | |
| | | } catch(Exception e) { |
| | | Database.rollback(sp); |
| | | System.debug(LoggingLevel.ERROR, + e.getMessage() + '\n' + e.getStackTraceString()); |
| | | this.emailMessages.add(ihList[0].Name + ' 备品盘点开始处理 Exception:' + e.getMessage() + '\n' + e.getStackTraceString()); |
| | | this.emailMessages.add(ihList[0].Name + ' 备品盘点Copy开始处理 Exception:' + e.getMessage() + '\n' + e.getStackTraceString()); |
| | | } |
| | | executedCount += assetList.size(); |
| | | } |
| | |
| | | try { |
| | | if (this.emailMessages.size() == 0 && totalCount == executedCount) { |
| | | |
| | | text = '备品盘点报告书编号:' + iheader.Name + ' 盘点地点:' + iheader.Internal_asset_location__c + ' 盘点开始日:' + iheader.Inventory_Start_Date__c; |
| | | text = '备品盘点Copy报告书编号:' + iheader.Name + ' 盘点地点:' + iheader.Internal_asset_location__c + ' 盘点开始日:' + iheader.Inventory_Start_Date__c; |
| | | if(cunFangDi == '上海 备品中心'){ |
| | | text += '\n备品盘点batch已结束,请等待耗材盘点batch结束。'; |
| | | text += '\n备品盘点Copy batch已结束,请等待耗材盘点batch结束。'; |
| | | // ConsumInventoryStartAssetSnapshotBatch consumIstarter = new ConsumInventoryStartAssetSnapshotBatch(cunFangDi, iheader); |
| | | // Database.executeBatch(consumIstarter, 100); |
| | | } |
| | | else{ |
| | | iheader.Inventory_Status__c = '盘点中'; |
| | | update iheader; |
| | | text += '\n可以开始备品盘点。'; |
| | | text += '\n可以开始备品盘点Copy。'; |
| | | } |
| | | } else { |
| | | text = '备品盘点报告书编号:' + iheader.Name + ' 盘点地点:' + iheader.Internal_asset_location__c + ' 盘点开始日:' + iheader.Inventory_Start_Date__c; |
| | | text += '\n开始盘点 处理失败。'; |
| | | text = '备品盘点Copy报告书编号:' + iheader.Name + ' 盘点地点:' + iheader.Internal_asset_location__c + ' 盘点开始日:' + iheader.Inventory_Start_Date__c; |
| | | text += '\n开始盘点Copy 处理失败。'; |
| | | // delete iheader; |
| | | } |
| | | } catch (Exception e) { |
| | |
| | | // String InventoryCheck_PIC_email = iheader.InventoryCheck_PIC__r.Email; |
| | | BatchEmailUtil be = new BatchEmailUtil(); |
| | | // String[] toList = new String[]{UserInfo.getUserEmail()}; |
| | | String[] toList = new String[]{'sfdc_lijinhuan@olympus.com.cn'}; |
| | | String title = '开始备品盘点'; |
| | | String toEmal = System.Label.Inventory_Result_Email_To; |
| | | // String[] toList = new String[]{'sfdc_lijinhuan@olympus.com.cn'}; |
| | | String[] toList = new String[]{}; |
| | | toList.add(toEmal); |
| | | String title = '开始备品盘点Copy'; |
| | | String[] ccList = new String[]{}; |
| | | for(String email : System.Label.Inventory_Result_Email.split(',')){ |
| | | for(String email : System.Label.Inventory_Result_Email_Copy.split(',')){ |
| | | ccList.add(email); |
| | | } |
| | | /*system.debug('盘点报告确认人'+InventoryCheck_PIC_email); |
| | |
| | | be.successMail(toList,ccList, title, totalCount, text); |
| | | }else{ |
| | | String emailLabel = 'BatchNotify'; |
| | | for (OrgWideEmailAddress tmpEmailObj : [SELECT Id, Address, DisplayName |
| | | /*for (OrgWideEmailAddress tmpEmailObj : [SELECT Id, Address, DisplayName |
| | | FROM OrgWideEmailAddress |
| | | WHERE DisplayName like :emailLabel]) { |
| | | ccList.add(tmpEmailObj.Address); |
| | | } |
| | | }*/ |
| | | if (totalCount != executedCount) { |
| | | this.emailMessages.add('有一部分Batch没有运行, 请确认系统管理员。'); |
| | | } |