19626
2023-09-09 e14d6d0619330cad423f06493e3aa2371faa2a8f
force-app/main/default/classes/CheckAllOlympusAssetController.cls
@@ -1,7 +1,7 @@
public with sharing class CheckAllOlympusAssetController {
    public static Asset StaticAssetQuertResult;
    // 按钮区域
    public String assertQueryCondition {get; set;}
    public String assertQueryCondition {get; private set;}
    public Boolean allBlueFlag {get; private set;}  // 查看全部保有设备蓝色按钮Flag
    public Boolean consumableBlueFlag {get; private set;}  // 查看在库的保有设备蓝色按钮Flag
    public Boolean lendingBlueFlag {get; private set;}  // 查看出借中保有设备蓝色按钮Flag
@@ -214,27 +214,6 @@
                daysToExpiredOpts.add(new SelectOption('14', '两周内到期'));
            }
            return daysToExpiredOpts;
        }
        set;
    }
     //chenjingwu 2023.8.2
    //设备状态
    public List<SelectOption> assertQueryConditionOpts {
        get {
            if(assertQueryConditionOpts == null){
                assertQueryConditionOpts = new List<SelectOption>();
                assertQueryConditionOpts.add(new SelectOption('all', '--无--'));
                assertQueryConditionOpts.add(new SelectOption('consumable', '有效库存'));
                assertQueryConditionOpts.add(new SelectOption('lending', '借出分配数'));
                assertQueryConditionOpts.add(new SelectOption('repairing', '修理中'));
                assertQueryConditionOpts.add(new SelectOption('scrapping', '待报废'));
                assertQueryConditionOpts.add(new SelectOption('scrapped', '已报废'));
                assertQueryConditionOpts.add(new SelectOption('consumed', '已消耗'));
                assertQueryConditionOpts.add(new SelectOption('soonExpired', '即将到期'));
                assertQueryConditionOpts.add(new SelectOption('expired', '已过期'));
            }
            return assertQueryConditionOpts;
        }
        set;
    }
@@ -1229,7 +1208,9 @@
    public Date stringToDate(String dateStr) {  // Fri Jan 18 00:00:00 GMT 2019
        //System.debug('dateStr=====' + dateStr);
        return Date.valueOf(dateStr);
        dateStr = dateStr.split(' ')[0];
        return Date.valueOf(dateStr.replaceAll('/','-'));
        //String monthStr = dateStr.substring(4,7);
        //Integer dayStr = Integer.ValueOf(dateStr.substring(8,10));
        //Integer yearStr = Integer.ValueOf(dateStr.substring(24,28));
@@ -1290,11 +1271,11 @@
        }
        System.debug('333333');
        // 检索CSV中的ID检索Asset获得List<Asset>
        try {
        // try {
            if (allApiList.contains('Id')) {
                allApiList.remove(0);
            }
            if (importApiList.contains('Id(不可修改)')) {
            if (importApiList.contains('Id')) {
                importApiList.remove(0);
            }
            List<String> notIncludeApiList = new List<String>();
@@ -1328,7 +1309,11 @@
                    if (!queryAssetFieldResult.isCalculated()) {
                        if (queryAssetFieldResult.getType() == Schema.DisplayType.Date) {
                            if (tempCsvBody[i][j+1] != '') {
                                tempAsset.put(importApiList[j], stringToDate(tempCsvBody[i][j+1]));
                                String s = tempCsvBody[i][j+1].substring(0,1);
                                if(s == '2'){
                                    tempAsset.put(importApiList[j], stringToDate(tempCsvBody[i][j+1]));
                                }
                            }
                        } else if (queryAssetFieldResult.getType() == Schema.DisplayType.Boolean) {
                            if (tempCsvBody[i][j+1] != '') {
@@ -1391,11 +1376,11 @@
                ApexPages.Message errorMessage = new ApexPages.Message(ApexPages.severity.INFO, importSuccessfulMsg);
                ApexPages.addMessage(errorMessage);
            }
        } catch (Exception e) {
            System.debug('1234 ' + e);
            ApexPages.Message errorMessage = new ApexPages.Message(ApexPages.severity.ERROR, '导入过程出现错误,导入文件中可能存在Fieldset中不存在的列名,请检查CSV文件。');
            ApexPages.addMessage(errorMessage);
        }
        // } catch (Exception e) {
        //     System.debug('1234 ' + e);
        //     ApexPages.Message errorMessage = new ApexPages.Message(ApexPages.severity.ERROR, '导入过程出现错误,导入文件中可能存在Fieldset中不存在的列名,请检查CSV文件。');
        //     ApexPages.addMessage(errorMessage);
        // }
    }