李金换
2022-03-21 ca51336f247021aa79b8863522e15e8dee957e19
盘点Copy邮件标头修改
1个文件已修改
31 ■■■■ 已修改文件
force-app/main/default/classes/InventoryStartAssetSnapshotCopyBatch.cls 31 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/classes/InventoryStartAssetSnapshotCopyBatch.cls
@@ -86,7 +86,7 @@
                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]);
            }
        }
@@ -99,7 +99,7 @@
                             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]);
        }
@@ -211,7 +211,7 @@
                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();
@@ -803,7 +803,7 @@
    } 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();
    }
@@ -814,20 +814,20 @@
        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) {
@@ -882,10 +882,13 @@
        // 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);
@@ -897,11 +900,11 @@
            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没有运行, 请确认系统管理员。');
            }