高章伟
2022-03-10 1312ba82d4c880bdb5357d28e0d4af5b285f610f
force-app/main/default/classes/ConsumDefaultSelectController.cls
@@ -27,6 +27,7 @@
        myComponentController.columnLeftRW.put('You_Xiao_Ku_Cun_Jia__c', 'r');
        myComponentController.columnLeftRW.put('You_Xiao_Qi_Ku_Cun_Jia__c', 'r');
        myComponentController.columnLeftRW.put('Yi_Guo_Qi_Ku_Cun_Jia__c', 'r');
        myComponentController.columnLeftRW.put('demo_purpose2__c', 'r'); // 20220309 ljh  SFDC-CC73U5 132 动物实验&ET展箱 锁定已过期库存 add start
        return selectedDataSql;
    }
@@ -69,6 +70,7 @@
                , 'Select_Time__c'
                , 'GroupKey_F__c'
                , 'Asset__c'
                , 'demo_purpose2__c' // 20220309 ljh  SFDC-CC73U5 132 动物实验&ET展箱 锁定已过期库存 add start
                , 'Shipment_request_time2__c'
                , 'Consum_Start_Date_After_15_Day__c'
                , 'Consum_Apply_Equipment_Set__r.Model_No__c'
@@ -272,7 +274,10 @@
                    Consum_Apply_Equipment_Set_Detail__c caesd = (Consum_Apply_Equipment_Set_Detail__c)info.sobj;
                    if (caesd.Qu_Xiao_Fen_Pei_Shu_Liang_Jia__c != null
                            && caesd.Qu_Xiao_Fen_Pei_Shu_Liang_Jia__c > 0) {
                        String key = caesd.GroupKey_F__c;
                        // 20220309 ljh  SFDC-CC73U5 132 动物实验&ET展箱 锁定已过期库存 add start
                        // String key = caesd.GroupKey_F__c;
                        String key = caesd.GroupKey_F__c+caesd.Fixture_Model_No__c;
                        // 20220309 ljh  SFDC-CC73U5 132 动物实验&ET展箱 锁定已过期库存 add end
                        System.debug(caesd.Consumable_Guaranteen_end_F__c);
                        System.debug(key);
                        if(caesd.Qu_Xiao_Fen_Pei_Shu_Liang_Jia__c>caesd.Jie_Chu_Fen_Pei_Jia__c){
@@ -317,6 +322,7 @@
            carsdList = [SELECT Id
                        , Select_Time__c
                        , GroupKey_F__c
                        , Fixture_Model_No__c // 20220309 ljh  SFDC-CC73U5 132 动物实验&ET展箱 锁定已过期库存 add
                     FROM Consum_Apply_Equipment_Set_Detail__c
                    WHERE Consum_Apply__c = :parentId
                      AND Cancel_Select__c = False
@@ -324,11 +330,22 @@
                    ORDER BY Degree_Of_Importance__c DESC];
            Map<String, List<Consum_Apply_Equipment_Set_Detail__c>> caesdListMap = new Map<String, List<Consum_Apply_Equipment_Set_Detail__c>>();
            for (Consum_Apply_Equipment_Set_Detail__c caesd : carsdList) {
                if (caesdListMap.containsKey(caesd.GroupKey_F__c) == false) {
                    caesdListMap.put(caesd.GroupKey_F__c, new List<Consum_Apply_Equipment_Set_Detail__c>());
                // 20220309 ljh  SFDC-CC73U5 132 动物实验&ET展箱 锁定已过期库存 add start
                String key = caesd.GroupKey_F__c+caesd.Fixture_Model_No__c;
                // if (caesdListMap.containsKey(caesd.GroupKey_F__c) == false) {
                //     caesdListMap.put(caesd.GroupKey_F__c, new List<Consum_Apply_Equipment_Set_Detail__c>());
                // }
                // System.debug(caesd.GroupKey_F__c);
                // caesdListMap.get(caesd.GroupKey_F__c).add(caesd);
                List<Consum_Apply_Equipment_Set_Detail__c> tempCaesdL;
                if(caesdListMap.containsKey(key)){
                    tempCaesdL = caesdListMap.get(key);
                }else{
                    tempCaesdL = new List<Consum_Apply_Equipment_Set_Detail__c>();
                }
                System.debug(caesd.GroupKey_F__c);
                caesdListMap.get(caesd.GroupKey_F__c).add(caesd);
                tempCaesdL.add(caesd);
                caesdListMap.put(key,tempCaesdL);
                // 20220309 ljh  SFDC-CC73U5 132 动物实验&ET展箱 锁定已过期库存 add end
            }
            System.debug(caesdListMap);
            List<Consum_Apply_Equipment_Set_Detail__c> caesdList = new List<Consum_Apply_Equipment_Set_Detail__c>();
@@ -572,7 +589,7 @@
                final String soqlStr = 'Select {0} {1} ';
                String soql1 = String.format(soqlStr, new String[] {myComponentController.strColumus , selectedDataSql1});
                selectedData = Consum_ApplyUtil.withoutQueryList(soql1);
                System.debug('zheli:'+selectedData.size());
                if (String.isNotBlank(wherStr1) && String.isBlank(wherStr)) {
                    wherStr = wherStr1;
                }
@@ -595,18 +612,23 @@
                Map<String, Consum_Apply_Equipment_Set_Detail__c> keyMap = new Map<String, Consum_Apply_Equipment_Set_Detail__c>();
                Boolean haveChange = false;
                Set<String> modelKeySet = new Set<String>();
                System.debug('zheli598:'+selectedData.size());
                for (SObject sobj : selectedData) {
                    Consum_Apply_Equipment_Set_Detail__c caesdobj = (Consum_Apply_Equipment_Set_Detail__c) sobj;
                    if (caesdobj.Asset__c == null) {
                        continue;
                    }
                    String key = caesdobj.GroupKey_F__c;
                    // 20220309 ljh  SFDC-CC73U5 132 动物实验&ET展箱 锁定已过期库存 add start
                    // String key = caesdobj.GroupKey_F__c;
                    String key = caesdobj.GroupKey_F__c+caesdobj.Fixture_Model_No__c;
                    // 20220309 ljh  SFDC-CC73U5 132 动物实验&ET展箱 锁定已过期库存 add end
                    if (keyMap.containsKey(key)) {
                        Consum_Apply_Equipment_Set_Detail__c caesd = keyMap.get(key);
                        keyMap.get(key).Request_Num_Jia__c ++;
                        if (caesdobj.Select_Time__c != null) {
                            keyMap.get(key).Jie_Chu_Fen_Pei_Jia__c += 1;
                        }
                        System.debug('zheli598:'+selectedData.size());
                        continue;
                    }
                    keyMap.put(key, caesdobj);
@@ -631,6 +653,7 @@
                    //viewList[viewList.size() - 1].additionalInfoMap.put('Substitute_Select_Again__c', String.valueOf(caesdobj.Substitute_Select_Again__c));
                }
            }
            System.debug('zheli634:'+viewList.size());
            if (savetype == '1') {
                ApexPages.addmessage(new ApexPages.message(ApexPages.severity.INFO, '保存成功'));
            }
@@ -667,10 +690,14 @@
                wherStr2 += ' (';
                wherStr += '(Fixture_Model_No_F__c  = \'' + String.escapeSingleQuotes(caesdobj.Consum_Apply_Equipment_Set__r.Model_No__c) + '\'';
                wherStr2 += 'Fixture_Model_No_F__c  = \'' + String.escapeSingleQuotes(caesdobj.Consum_Apply_Equipment_Set__r.Model_No__c) + '\'';
                // 20220309 ljh  SFDC-CC73U5 132 动物实验&ET展箱 锁定已过期库存 add start
                if (parentObj.demo_purpose2__c != '动物实验' 
                    //2021-04-30  mzy 备品课题-1577 start
                    &&parentObj.demo_purpose2__c != 'ET展箱') {
                    //2021-04-30  mzy 备品课题-1577 end
                // if (caesdobj.demo_purpose2__c != '动物实验'
                //     && caesdobj.demo_purpose2__c != 'ET展箱') {
                // 20220309 ljh  SFDC-CC73U5 132 动物实验&ET展箱 锁定已过期库存 add end
                    // Date d1 = caesdobj.Consum_Start_Date_After_15_Day__c == null ? td : caesdobj.Consum_Start_Date_After_15_Day__c;
                    // wherStr += ' AND Consumable_Guaranteen_end__c >= ' + d1.year() + '-' + String.valueOf(d1.month()).leftPad(2,'0') + '-' + String.valueOf(d1.day()).leftPad(2,'0') + ' )';
                    wherStr2 += ' AND (Consumable_Guaranteen_end__c >= ' + td.year() + '-' + String.valueOf(td.month()).leftPad(2,'0') + '-' + String.valueOf(td.day()).leftPad(2,'0');
@@ -693,7 +720,7 @@
        // if (String.isNotBlank(parentObj.Internal_asset_location_F__c)) {
            wherStr += ' AND Internal_asset_location__c = \'上海 备品中心\'';
            wherStr2 += ' AND Internal_asset_location__c = \'上海 备品中心\'';
        // }
        // }
        if (String.isNotBlank(parentObj.Salesdepartment__c)) {
            wherStr += ' AND (Salesdepartment__c = \'' + parentObj.Salesdepartment__c + '\' OR Salesdepartment__c = \'0.备品中心\')';
            wherStr2 += ' AND (Salesdepartment__c = \'' + parentObj.Salesdepartment__c + '\' OR Salesdepartment__c = \'0.备品中心\')';
@@ -753,10 +780,14 @@
                                && (caesdobj.Consumable_Guaranteen_end_F__c == null
                                    // || caesdobj.Consumable_Guaranteen_end_F__c >= fDateMap.get(key)) {
                                    || caesdobj.Consumable_Guaranteen_end_F__c >= d
                                    // 20220309 ljh  SFDC-CC73U5 132 动物实验&ET展箱 锁定已过期库存 add start
                                    || parentObj.demo_purpose2__c == '动物实验'
                                    //2021-04-30  mzy 备品课题-1577 start
                                    || parentObj.demo_purpose2__c == 'ET展箱'
                                    //2021-04-30  mzy 备品课题-1577 end
                                    // || caesdobj.demo_purpose2__c == '动物实验'
                                    // || caesdobj.demo_purpose2__c == 'ET展箱'
                                    // 20220309 ljh  SFDC-CC73U5 132 动物实验&ET展箱 锁定已过期库存 add end
                                   )
                        ) {
                            if (caesdobj.Select_Time__c == null) {
@@ -773,10 +804,14 @@
                                        && (caesdobj.Consumable_Guaranteen_end_F__c == null
                                            // || caesdobj.Consumable_Guaranteen_end_F__c >= fDateMap.get(key)) {
                                            || caesdobj.Consumable_Guaranteen_end_F__c > d
                                            // 20220309 ljh  SFDC-CC73U5 132 动物实验&ET展箱 锁定已过期库存 add start
                                            || parentObj.demo_purpose2__c == '动物实验'
                                            //2021-04-30  mzy 备品课题-1577 start
                                            || parentObj.demo_purpose2__c == 'ET展箱'
                                            //2021-04-30  mzy 备品课题-1577 end
                                            // || caesdobj.demo_purpose2__c == '动物实验'
                                            // || caesdobj.demo_purpose2__c == 'ET展箱'
                                            // 20220309 ljh  SFDC-CC73U5 132 动物实验&ET展箱 锁定已过期库存 add end
                                            )
                                    ) {
                                        caesdobj.Asset__c = assBean.assId;