高章伟
2023-03-02 e3c02c03dd2de442bbced87236f60a13a1cd154e
force-app/main/default/classes/MaintenanceContractVMPDFController.cls
@@ -8,7 +8,9 @@
    
    private Integer nameMax = 23;
    private Integer commentMax = 5;
    //2021-11-30 fy add LJPH-C8W8FV 置顶 start
    public List<String> TopProductModel =new List<String>();
    //2021-11-30 fy add LJPH-C8W8FV 置顶 end
    private Integer lineNo = 0;
    // 参保价格汇总
    public Decimal benchmark_priceSum { get; private set; }
@@ -22,6 +24,14 @@
    public MaintenanceContractVMPDFController(ApexPages.StandardController controller) {     
    }
 public void init() {
     //2021-11-30 fy add LJPH-C8W8FV 置顶 start
    TopProductModel.add('CF-LV1I');
   TopProductModel.add('CF-LV1L');
   TopProductModel.add('CV-V1');
   TopProductModel.add('GIF-LV1');
    TopProductModel.add('OER-AW');
    TopProductModel.add('OER-A');
    //2021-11-30 fy add LJPH-C8W8FV 置顶 end
        String targetEstimateId = ApexPages.currentPage().getParameters().get('id');
        // 見積情報を取得、必ずあるはず
        // TODO 書き方修正
@@ -42,7 +52,11 @@
                        Submit_quotation_day__c,Maintenance_Contract__r.RecordType.Name,Maintenance_Contract__r.Service_Contract_Staff__r.Name,
                        Maintenance_Contract__r.Contract_create_reason__c,NewEstimation_Amount__c,Maintenance_Contract__r.Estimate_Contract_endDate__c,
                        Print_Simplify__c,New_contract_offer__c,Request_quotation_Amount__c,Service_DiscountPercentage__c,
                        GuidePrice_Up__c,GuidePrice_Down__c,Service_Discount_Price__c,New_Contract_Type_TxT__c
                        GuidePrice_Up__c,GuidePrice_Down__c,Service_Discount_Price__c,New_Contract_Type_TxT__c,
                        //URF限次合同2期 XXF 20220920 start
                        URF_P_MaxRepairCount__c,URF_V_MaxRepairCount__c,URF_Contract__c,
                        URF_P_RepairTime__c,URF_V_RepairTime__c
                        //URF限次合同2期 XXF 20220920 end
                   FROM Maintenance_Contract_Estimate__c WHERE Id = :targetEstimateId]
        ;
        system.debug('维修合同报价:'+mceList+'---'+'维修合同id:'+targetEstimateId);
@@ -76,22 +90,46 @@
        Integer cnt = 1;
        // 最近一期合同结束日
        Date lastDate = null;
        for(Maintenance_Contract_Asset_Estimate__c mcae :
                [SELECT Id, Name, Asset__c,
                        Asset__r.Name, Asset__r.SerialNumber, Asset__r.InstallDate,
                        Product_Manual__c, Product_Manual__r.Maintenance_Price_Month__c, Product_Manual__r.Name, IsNew__c,
                        Maintenance_Price_Month__c, Estimate_List_Price__c,
                        Check_Result__c, Repair_Price__c, Comment__c,Asset__r.CurrentContract_Asset_Price__c,
                        Check_Result_Formula__c,Maintenance_Contract_Estimate__r.Management_Code__c,
                        //消费率  维修合同价格 打印PDF
                        Asset_Consumption_rate__c,Maintenance_Contract_Estimate__r.Maintenance_Contract__r.Contract_Consumption_rate__c,
                        Asset__r.Maintenance_RMB__c,Estimate_Cost__c,Estimate_List_Price_All__c,Adjustment_ratio_Upper__c,Adjustment_ratio_Lower__c,
                        Maintenance_Contract_Estimate__r.Discount_Percentage__c,Asset__r.CurrentContract_F_asset__r.Estimate_Cost_formula__c,
                        Asset__r.CurrentContract_F__r.Maintenance_Contract_No_F__c,Adjustment_Upper_price__c,Adjustment_Lower_price__c,
                        Benchmark_price__c,Asset__r.CurrentContract_F__r.Contract_End_Date__c
                   FROM Maintenance_Contract_Asset_Estimate__c
                  WHERE Maintenance_Contract_Estimate__c = :this.targetObj.estimate.Id
                  ORDER BY Product_Manual__c, Asset__r.SerialNumber, Asset__r.Name, Asset__r.Department_Name__c, Asset__r.InstallDate]) {
        //2021-11-30 fy add LJPH-C8W8FV 置顶 start
        List<Maintenance_Contract_Asset_Estimate__c> mcaeList = [SELECT Id, Name, Asset__c,
        Asset__r.Name, Asset__r.SerialNumber, Asset__r.InstallDate,
        //2021-11-30 fy add LJPH-C8W8FV 置顶 start
        Asset__r.OwnershipMachine_No__c,
        //2021-11-30 fy add LJPH-C8W8FV 置顶 end
        Product_Manual__c, Product_Manual__r.Maintenance_Price_Month__c, Product_Manual__r.Name,
        //2021-11-30 fy add LJPH-C8W8FV 置顶 start
        Product_Manual__r.Asset_Model_No__c,
        //2021-11-30 fy add LJPH-C8W8FV 置顶 end
        IsNew__c,
        Maintenance_Price_Month__c, Estimate_List_Price__c,
        Check_Result__c, Repair_Price__c, Check_Object__c, Comment__c,Asset__r.CurrentContract_Asset_Price__c,
        Check_Result_Formula__c,Maintenance_Contract_Estimate__r.Management_Code__c,
        //消费率  维修合同价格 打印PDF
        Asset_Consumption_rate__c,Maintenance_Contract_Estimate__r.Maintenance_Contract__r.Contract_Consumption_rate__c,
        Asset__r.Maintenance_RMB__c,Estimate_Cost__c,Estimate_List_Price_All__c,Adjustment_ratio_Upper__c,Adjustment_ratio_Lower__c,
        Maintenance_Contract_Estimate__r.Discount_Percentage__c,Asset__r.CurrentContract_F_asset__r.Estimate_Cost_formula__c,
        Asset__r.CurrentContract_F__r.Maintenance_Contract_No_F__c,Adjustment_Upper_price__c,Adjustment_Lower_price__c,
        Benchmark_price__c,Asset__r.CurrentContract_F__r.Contract_End_Date__c
   FROM Maintenance_Contract_Asset_Estimate__c
  WHERE Maintenance_Contract_Estimate__c = :this.targetObj.estimate.Id
  ORDER BY Product_Manual__c, Asset__r.SerialNumber, Asset__r.Name, Asset__r.Department_Name__c, Asset__r.InstallDate];
        List<Maintenance_Contract_Asset_Estimate__c> topAsset =new List<Maintenance_Contract_Asset_Estimate__c>();
        List<Maintenance_Contract_Asset_Estimate__c> otherAsset =new List<Maintenance_Contract_Asset_Estimate__c>();
        for(Maintenance_Contract_Asset_Estimate__c tarAsse : mcaeList){
            system.debug('sss===' + tarAsse.Product_Manual__r.Asset_Model_No__c);
            system.debug('yyy===' + tarAsse.Asset__r.OwnershipMachine_No__c);
            if(TopProductModel.contains(tarAsse.Asset__r.OwnershipMachine_No__c)||TopProductModel.contains(tarAsse.Product_Manual__r.Asset_Model_No__c)){
                topAsset.add(tarAsse);
            }else{
                otherAsset.add(tarAsse);
            }
        }
        topAsset.addAll(otherAsset);
        mcaeList=topAsset;
        //2021-11-30 fy add LJPH-C8W8FV 置顶 end
        for(Maintenance_Contract_Asset_Estimate__c mcae : mcaeList) {
            //for(Integer a=0;a<20;a++){
            //tmpTargetObj.addAssetInfo(mcae);
            //targetObjForSum.addAssetInfo(mcae);
@@ -221,7 +259,6 @@
            }
//            }
        }
        // 新品优惠
        lineNo += 1;
        Boolean rs = tmpTargetObj.addNewDiscountLine(lineNo, targetObjForSum.assetInfoList);
@@ -321,6 +358,7 @@
            estimateendDate = lastDate;
        }
        
    }
    
    /**