高章伟
2023-03-03 d8dc84a3d56df839895f1c417a4d9cbee763d262
force-app/main/default/classes/RentalFixtureSetAssignController.cls
@@ -77,11 +77,9 @@
    }
    // 20211203 ljh add end
    // 画面里直接可以输入的項目 List
    // 20220211 ljh update FY23课题01 start
    // public override List<String> getWritableColumnFieldList() {
    //     return new List<String>{'Rental_Start_Date__c', 'Rental_End_Date__c'};
    // }
    // 20220211 ljh update FY23课题01 end;
    public override List<String> getWritableColumnFieldList() {
        return new List<String>{'Rental_Start_Date__c', 'Rental_End_Date__c'};
    }
    // getObjName 连 getOriginObjName 的 FK
    public override String getFKColumnField() {
        return null;
@@ -292,13 +290,18 @@
        // updateだけ使用する
        List<Rental_Apply_Equipment_Set__c> mfUpdate = new List<Rental_Apply_Equipment_Set__c>();
        Savepoint sp = Database.setSavepoint();
        List<String> statusList = System.Label.StatusProcessState.split(',');
        try {
            Boolean updRAFlg = false;
            Rental_Apply__c raUpd = [
                    SELECT Id, Shipment_request_Cnt__c,
                           Asset_loaner_start_day__c,
                           Asset_loaner_closed_day__c
                           Asset_loaner_closed_day__c,
                           Campaign__c,
                           Campaign__r.IF_Approved__c,
                           Campaign__r.Meeting_Approved_No__c,
                           Campaign__r.Approved_Status__c   //2022 sx obpm备品决裁状态相关修改
                      FROM Rental_Apply__c
                     WHERE Id = :parentId
                       FOR Update];
@@ -313,6 +316,15 @@
                }
            }
            //20220228 sx obpm修改 是否申请决裁勾着没有决裁编号不能进行操作
            if( raUpd.Campaign__c!= null && raUpd.Campaign__r.IF_Approved__c && raUpd.Campaign__r.Meeting_Approved_No__c == null){
                throw new ControllerUtil.myException('已申请决裁但决裁编码为空');
            }
            //20220315 sx obpm obpm备品决裁状态相关修改 start
            else if( raUpd.Campaign__c!= null && raUpd.Campaign__r.IF_Approved__c && raUpd.Campaign__r.Meeting_Approved_No__c != null && statusList.contains(raUpd.Campaign__r.Approved_Status__c) ){
                throw new ControllerUtil.myException('已申请决裁但决裁状态不符合条件');
            }
            //20220315 sx obpm obpm备品决裁状态相关修改 end
            Integer indexNum = 1;
            // 20210708 ljh SFDC-C47CLV add start
            Set<Id> raeIdset = new Set<Id>();
@@ -324,6 +336,7 @@
                    raeIdset.add(robj.Id);    
                }
            }
            List<Rental_Apply_Equipment_Set__c> raeList = [SELECT Id, Name,Rental_Apply__c,Cancel_Select__c,LastModifiedDate FROM Rental_Apply_Equipment_Set__c where Id in :raeIdset];
            // 20210906  ljh SFDC-C6D9C2 add LastModifiedDate
            for(Rental_Apply_Equipment_Set__c rae:raeList){
@@ -346,6 +359,7 @@
                        hasError = true;
                        throw new ControllerUtil.myException('第' + indexNum +'行数据已被分割申请单,请刷新后重试!');
                    }
                    // 20210708 ljh update end
                    // 20210906  ljh SFDC-C6D9C2 add start
                    // 20210929 ljh SFDC-C6D9C2 注释 恢复改其他方案 start
@@ -887,7 +901,7 @@
                }
            }
        }
        update queueList;
        FixtureUtil.withoutUpdate(queueList);
        List<String> nodusequencekeylist = new List<String>(new Set<String>(sequencekeylist));
        List<Rental_Apply_Sequence__c> updateSequenceList = new List<Rental_Apply_Sequence__c>();
        List<Rental_Apply_Sequence__c> applysequenceList = [SELECT Id,ExternalKey__c,Demo_Purpose2__c,
@@ -926,7 +940,7 @@
                    
                }
            }
            update updateSequenceList;
            FixtureUtil.withoutUpdate(updateSequenceList);
        }
        
    }
@@ -1047,6 +1061,9 @@
                applyObj.campaignType = parentObj.CampaignType__c;
                obj = getdefultInfo(raesd,applyObj,bieCunFangDi);
            }else{
                // Modify by Liu 20220908 Solution本部课题对应 start
                salesdepartments = salesdepartments.replace('16.Solution本部', '16.消化·呼吸领域解决方案本部');
                // Modify by Liu 20220908 Solution本部课题对应 end
                obj = getSpecialInfo(raesd,parentObj,salesdepartments,equipmenttypes);
            }
            System.debug(LoggingLevel.INFO, '*11** index: ' + index);
@@ -1193,9 +1210,11 @@
        updateList.addAll(queueList);
        System.debug(LoggingLevel.INFO, '***old updateList: ' + updateList.size());
        System.debug(LoggingLevel.INFO, '***old updateList.detail: ' + updateList);
        updateList = Batch_QueueAllDetail.getSortDetailList(updateList);
        System.debug(LoggingLevel.INFO, '*** updateList: ' + updateList.size());
        update updateList;
        System.debug(LoggingLevel.INFO, '*** updateList.detail: ' + updateList);
        FixtureUtil.withoutUpdate(updateList);
        
        System.debug(LoggingLevel.INFO, '*** allsequenceList: ' + allsequenceList.size());
        List<Rental_Apply_Sequence__c> oldSequenceList = [SELECT Id,ExternalKey__c,Fixture_Model_No__c FROM Rental_Apply_Sequence__c
@@ -1212,11 +1231,11 @@
        List<Rental_Apply_Sequence__c> olddleteSequenceList = [SELECT Id,ExternalKey__c,Fixture_Model_No__c FROM Rental_Apply_Sequence__c
                                                        WHERE Apply_Set_Detail__c IN:changeddetailIds];
        delete olddleteSequenceList;
        FixtureUtil.withoutDelete(olddleteSequenceList);
        if(updateList.size() + count + oldSequenceList.size() + allsequenceList.size() > 9900){
            throw new ControllerUtil.myException('当前排队数据量过大,请选择单个主体操作');
        }
        insert allsequenceList;
        FixtureUtil.withoutInsert(allsequenceList);
        List<String> newSequenceIds = new List<String>();
        for(Rental_Apply_Sequence__c se:allsequenceList){
            newSequenceIds.add(se.Id);
@@ -1265,7 +1284,7 @@
            throw new ControllerUtil.myException('当前排队数据量过大,请选择单个主体操作');
        }
        System.debug(LoggingLevel.INFO, '*** newSequenceList: ' + newSequenceList);
        upsert newSequenceList;
        FixtureUtil.withoutUpsertObjects(newSequenceList);
    }
@@ -1538,6 +1557,7 @@
        return result;
    }
    public static List<String> transferStringToList(String str){
        // System.debug(LoggingLevel.INFO, '*** str: ' + str);
        List<String> strList = new List<String>();
@@ -1546,6 +1566,11 @@
        }else{
            strList.add(str);
        }
        for(Integer i = strList.size()-1;i >= 0 ; i --){
            if(String.isEmpty(strList.get(i))){
                strList.remove(i);
            }
        }
        return strList;
    }