高章伟
2023-03-03 d8dc84a3d56df839895f1c417a4d9cbee763d262
force-app/main/default/classes/OFSInsReportLayoutController.cls
@@ -28,7 +28,7 @@
    private String oldHospital;
    private String oldStatus;
    private Boolean isPDF;
    public Boolean isPDF{get;private set;}
    private Boolean isUpDown;
    private Boolean isSubmit;
    public String alertMessage {
@@ -247,18 +247,23 @@
            oirSettingMap.put(oir.recordType_devName__c, oir);
        }
    }
    public string staticResource { get; private set; }
    //public boolean IsAddmessage { get; private set; }
    /**
    * Visaulforceから呼ばれるコンストラクタ
    */
    public OFSInsReportLayoutController(ApexPages.StandardController controller) {
        staticResource = JSON.serialize(PIHelper.getPIIntegrationInfo('Inspection_Report__c'));
}
    public OFSInsReportLayoutController() {
        countorder = 1;
        nowAssetcount = 1;
        runCount = 0;
        isUpDown = true;
        staticResource = JSON.serialize(PIHelper.getPIIntegrationInfo('Inspection_Report__c'));
    }
    // TODO 全部画面リフレッシュにする
@@ -335,7 +340,7 @@
                pReportId = iis[0].Inspection_ReportId__c;
            }
            List < Inspection_Report__c > queryIrs = [select Id, RecordType.DeveloperName, RecordType.Name, Name, Status__c, Inspection_StartTime__c, Inspection_EndTime__c from Inspection_Report__c where Id = :pReportId];
            List < Inspection_Report__c > queryIrs = [select Id, RecordType.DeveloperName, RecordType.Name, Name, Status__c, Inspection_StartTime__c, Inspection_EndTime__c,AWS_Data_Id__c from Inspection_Report__c where Id = :pReportId];    //zhj 新方案改造 2022-12-05 删除Encrypted__c
            if (queryIrs.size() <= 0) {
                initFlag = false;
                ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR, '无法找到点检报告书'));
@@ -401,7 +406,7 @@
            }
        }
        this.settingSoql = 'select Id, Name, Name_Manual__c, Next_StartHour_Page__c, Next_StartMinute_Page__c, Next_EndHour_Page__c, Next_EndMinute_Page__c '
        this.settingSoql = 'select Id, Name, Name_Manual__c, Next_StartHour_Page__c, Next_StartMinute_Page__c, Next_EndHour_Page__c, Next_EndMinute_Page__c,AWS_Data_Id__c '        //zhj 新方案改造 2022-12-05 删除Encrypted__c
        // fxk 2021/8/4 新加 Start
        + ' , Remarks__c, CleaningFluid__c,SterilizationMethod__c,Disinfectant__c,UsedMachine__c,Used_ET__c ,Mode__c';
        // fxk 2021/8/4 新加 End
@@ -577,13 +582,15 @@
    /**
    * 選択済み/未選択製品の置き換え
    */
    public PageReference exchangeAsset() {
    public void exchangeAsset() {
        isUpDown = false;
        System.debug('exchangeAsset start');
        // 病院変更チェック
        if (!this.checkHpChange()) {
            ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR, '保有设备的医院与点检报告书的医院不符,请点击刷新按钮重新取得保有设备。'));
            return null;
            // return null;
            return;
        }
        Date systemToday = System.today();
        List < AssetInfo > tmpChecked = new List < AssetInfo > ();
@@ -595,24 +602,27 @@
            } else {
                if (ass.rec_checkBox_c) {
                    tmpChecked.add(ass);
                    system.debug('=====uncheck SerialNumber1:' + ass.rec.SerialNumber);
                } else {
                    tmpUnChecked.add(ass);
                }
            }
        }
        system.debug('=====unCheckedInfoList:' + unCheckedInfoList.size());
        for (AssetInfo Ai: unCheckedInfoList) {
            if (Ai.rec_checkBox_c) {
                system.debug('=====uncheck SerialNumber1:' + Ai.rec.SerialNumber);
            }
        }
        for (List < AssetInfo > Li: unCheckedInfoListForThousend) {
            for (AssetInfo Ai: Li) {
                if (Ai.rec_checkBox_c) {
                    system.debug('=====uncheck SerialNumber2:' + Ai.rec.SerialNumber);
                }
            }
        }
        // for (AssetInfo Ai: unCheckedInfoList) {
        //     if (Ai.rec_checkBox_c) {
        //         ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR, '+++++++++++++++: ' + Ai.rec.SerialNumber));
        //         system.debug('=====uncheck SerialNumber1:' + Ai.rec.SerialNumber);
        //     }
        // }
        // for (List < AssetInfo > Li: unCheckedInfoListForThousend) {
        //     for (AssetInfo Ai: Li) {
        //         if (Ai.rec_checkBox_c) {
        //             ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR, '---------------: ' + Ai.rec.SerialNumber));
        //             system.debug('=====uncheck SerialNumber2:' + Ai.rec.SerialNumber);
        //         }
        //     }
        // }
        if (ThousandFLG > 0) {
            this.unCheckedInfoList.clear();
            for (List < AssetInfo > Li: unCheckedInfoListForThousend) {
@@ -629,13 +639,15 @@
                tmpUnChecked.add(ass);
            }
        }
        for (List < AssetInfo > Li: unCheckedInfoListForThousend) {
            for (AssetInfo Ai: Li) {
                if (Ai.rec_checkBox_c) {
                    system.debug('=====uncheck SerialNumber4:' + Ai.rec.SerialNumber);
                }
            }
        }
        // for (List < AssetInfo > Li: unCheckedInfoListForThousend) {
        //     for (AssetInfo Ai: Li) {
        //         if (Ai.rec_checkBox_c) {
        //             ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR, '4444444444444444 ' + Ai.rec.SerialNumber));
        //             system.debug('=====uncheck SerialNumber4:' + Ai.rec.SerialNumber);
        //         }
        //     }
        // }
        // return null;
        this.checkedInfoList = new List < AssetInfo > ();
        for (AssetInfo ass: tmpChecked) {
            ass.lineNo = this.checkedInfoList.size();
@@ -673,7 +685,7 @@
            unCheckedInfoListForThousend.add(bufflist);
        }
        getAssetFromHp();
        return null;
        // return null;
    }
    public PageReference showPDF() {
@@ -785,14 +797,19 @@
            // }
        }
        if (isError) {
            system.debug('795'+ir.AWS_Data_Id__c);
            return null;
        }
        system.debug('798'+ir.AWS_Data_Id__c);
        //add by rentx 20210630
        if (timeCheck() != true) {
            system.debug('800');
            return null;
        }
        system.debug('804');
        if (isPDF) {
            ir.Status__c = 'PDF';
        }
@@ -801,6 +818,7 @@
            ir.Status__c = '填写完毕';
        }
        system.debug('813');
        Savepoint sp = Database.setSavepoint();
        try {
            // 部长经理总监
@@ -815,9 +833,11 @@
            OFSInsReportAssetHistoryController.upsertInspection_Report(ir);
        } catch(Exception e) {
            clearIrId(sp, e, isIrNew);
            system.debug('829');
            return null;
        }
        system.debug('832');
        // 日報からくる場合、保存時、EventCに書き戻す
        if (String.isBlank(pEventCId) == false) {
            try {
@@ -825,10 +845,11 @@
                update ec;
            } catch(Exception e) {
                clearIrId(sp, e, isIrNew);
                system.debug('840');
                return null;
            }
        }
        system.debug('844');
        //List<Inspection_Item__c> toUpsertAhs = new List<Inspection_Item__c>();
        List < Inspection_Item__c > toDeleteAhs = new List < Inspection_Item__c > ();
        List < Inspection_Item__c > manualDeleteAhs = new List < Inspection_Item__c > ();
@@ -868,14 +889,17 @@
        // SWAG-AREBA8 end
        toDeleteAhs = [select Id, AssetId__c from Inspection_Item__c where AssetId__c in :unCheckedAssetIds and Inspection_ReportId__c = :ir.Id];
        system.debug('884');
        try {
            if (manualDeleteAhs.size() > 0) toDeleteAhs.addAll(manualDeleteAhs);
            OFSInsReportAssetHistoryController.deleteInspection_Item(ir, toDeleteAhs);
        } catch(Exception e) {
            clearIrId(sp, e, isIrNew);
            system.debug('890');
            return null;
        }
        system.debug('894');
        try {
            //OFSInsReportAssetHistoryController.upsertInspection_Item(ir, toUpsertAhs);
            OFSInsReportAssetHistoryController.upsertInspection_Item(ir, new List < Inspection_Item__c > (toUpsertAhsMap.keySet()));
@@ -884,9 +908,11 @@
            for (Inspection_Item__c ah: toUpsertAhsMap.keySet()) {
                if (toUpsertAhsMap.get(ah).isNew == true) ah.Id = null;
            }
            system.debug('903');
            return null;
        }
        system.debug('905');
        saveOK = true;
        this.init();
        return null;
@@ -896,6 +922,7 @@
        if (isIrNew) ir.Id = null;
        Database.rollback(sp);
        ApexPages.addMessages(e);
        //IsAddmessage = true;
    }
    private Boolean checkHpChange() {
@@ -1151,10 +1178,11 @@
    }
    // 检索按钮
    public PageReference searchBtn() {
    public void searchBtn() {
        countorder = 1;
        //验证
        assetSerialNumberList.clear();
        // assetSerialNumberList.clear();
        // this.unCheckedInfoList.clear();
        getAssetSerialNumber();
        List < Asset > assetconfimList = getAssetconfim(text1, cond1, val1);
        // 获取assets
@@ -1166,20 +1194,21 @@
        text1ForSort = text1;
        cond1ForSort = cond1;
        val1ForSort = val1;
        system.debug('=====unCheckedInfoList:' + unCheckedInfoList.size());
        for (AssetInfo Ai: unCheckedInfoList) {
            if (Ai.rec_checkBox_c) {
                system.debug('=====uncheck SerialNumber1:' + Ai.rec.SerialNumber);
            }
        }
        for (List < AssetInfo > Li: unCheckedInfoListForThousend) {
            for (AssetInfo Ai: Li) {
                if (Ai.rec_checkBox_c) {
                    system.debug('=====uncheck SerialNumber2:' + Ai.rec.SerialNumber);
                }
            }
        }
        return null;
        // system.debug('=====unCheckedInfoList:' + unCheckedInfoList.size());
        // for (AssetInfo Ai: unCheckedInfoList) {
        //     if (Ai.rec_checkBox_c) {
        //         system.debug('=====uncheck SerialNumber1:' + Ai.rec.SerialNumber);
        //     }
        // }
        // for (List < AssetInfo > Li: unCheckedInfoListForThousend) {
        //     for (AssetInfo Ai: Li) {
        //         if (Ai.rec_checkBox_c) {
        //             system.debug('=====uncheck SerialNumber2:' + Ai.rec.SerialNumber);
        //         }
        //     }
        // }
        // ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR, '77777777777777777:' + unCheckedInfoList.size()));
        // return null;
    }
    // 明细排序
    public void sortTable() {
@@ -1281,7 +1310,7 @@
            soql += ' AND Status = \'使用中\'';
        }
        // fxk 2021/8/4 新加 Start
        soql += ' and (Asset.CurrentContract_F__r.Status__c != \'契約\' or (Asset.CurrentContract_F__r.Status__c = \'契約\' and Asset.CurrentContract_F_asset__r.Check_object__c = false) or Asset.CurrentContract_F__c = null) ';
        soql += ' and (Asset.CurrentContract_F__c = \'a0H100000156VLH\' OR  Asset.CurrentContract_F__r.Status__c != \'契約\' or (Asset.CurrentContract_F__r.Status__c = \'契約\' and Asset.CurrentContract_F_asset__r.Check_object__c = false) or (Asset.CurrentContract_F__r.Status__c = \'契約\' and Asset.CurrentContract_F__r.Effective_Status__c = \'无效\') or Asset.CurrentContract_F__c = null) ';
        // fxk 2021/8/4 新加 End
        if (assetSerialNumberList.size() > 0) {
            soql += ' AND SerialNumber not in ' + sqlTail;
@@ -1473,6 +1502,7 @@
            }
        }
        // 显示数据条数信息
        //if (overLimit) {
        //    ApexPages.addmessage(new ApexPages.message(ApexPages.severity.INFO, '数据超过' + Select_Limit + '条,只显示前' + Select_Limit + '条'));