1
chenjingwu
2024-05-24 9caa456d727a48dc4d50ca96cfaa82da2e699890
force-app/main/default/classes/lexNewQuoteEntryController.cls
@@ -2,7 +2,7 @@
// Created Date: 2023/08/07
// Purpose: get page layout and record data
// Test Class: lexNewQuoteEntryControllerTest
public without sharing class lexNewQuoteEntryController{
public class lexNewQuoteEntryController{
  public static Integer quoteEntryMaxLine;
  public static List<QELine> activities;
  public static List<QELine> tmpactivities;
@@ -11,12 +11,6 @@
  public static Boolean errorflg;
  public static String errormessage;
  public static String errormessagewarn;
  //fy DB202312538864 2024.02.02 start
  public static String errormessagelastbuy = '';
  public static List<PreProduct_Storage_List__c> PreProductStorageList = new List<PreProduct_Storage_List__c>();
  public static List<PreProduct_Storage__c> UpdatePreProductStorageList =  new List<PreProduct_Storage__c>();
  // public static Boolean isDecides = false;
  //fy DB202312538864 2024.02.02 end
  public static Map<Id, Product2> prd2LatestValMap;
  public static Boolean productStatusUpdated;
  public static Opportunity opp;
@@ -71,7 +65,7 @@
                Quote_Adjust_Amount__c, Quote_Adjust_Calculate__c, Discount_Amount__c, Discount_Amount_Calculate__c, Installation_location__c,
                QuoteTotal_Page__c, Dealer_Final_Price_Page__c, Quote_Adjust_Amount_Page__c, OCM_Agent1_Price_Page__c, Agent1_Agent2_Price_Page__c
                , AgencyDiscount__c,OCM_Sales_Forecast__c//预测金额修改 fy
                , Gurantee_Period__c , multiYearWarranty__c, MultiYearWarrantyTotalPrice__c,ExtendedWarrantyAmountTotalPrice__c,
                , Gurantee_Period__c , multiYearWarranty__c, MultiYearWarrantyTotalPrice__c,
                Preferential_Gurantee_Period__c,LineItemCount 
                 ,IsQuoteTrial__c,OpportunityId,Opportunity.RecordType.DeveloperName
                FROM Quote Where Id = :quoId];
@@ -120,16 +114,9 @@
           ,PricebookEntry.Product2.Intra_Trade_Foreign_RMB__c
           ,PricebookEntry.Product2.NoDiscount_Foreign__c 
           ,PricebookEntry.Product2.LastbuyProductFLG__c
           //fy DB202312538864 2024.02.02 start
           ,PricebookEntry.Product2.whetherOldCode_PrePro__c
           //fy DB202312538864 2024.02.02 end
           //chenjingwu DB202308355043 2023.8.25 start
           ,PricebookEntry.Product2.Category5__c
           //chenjingwu DB202308355043 2023.8.25 end
           // chenjingwu 3+2保修年限 20240318 start
           ,ExtendedWarrantyPeriod__c
           ,PricebookEntry.Product2.ProductCategory__c
           // chenjingwu 3+2保修年限 20240318 end
           ,Quote.Opportunity.Trade__c 
           ,PricebookEntry.Product2.Estimated_ConsumptionDueDate__c
           //DB202312560765 you 否有EndoRapid资质检查 start 
@@ -183,7 +170,7 @@
             Agency1__c, Agency2__c, Stocking_Price__c, Purchasing_Cost__c, Opportunity_No__c, StageName,
             Agency1__r.Special__c, Agency2__r.Special__c, Account.Parent.Special__c
             , Authorized_DB_No__c, Authorized_Finish_Sales__c, If_Need_Authorize__c
             , Gurantee_Period__c , multiYearWarranty__c, MultiYearWarrantyTotalPrice__c,ExtendedWarrantyAmountTotalPrice__c
             , Gurantee_Period__c , multiYearWarranty__c, MultiYearWarrantyTotalPrice__c
             , Hospital__c, Department_Class__c
             ,Is_Corrosion__c,
             If_Need_PriceApply__c
@@ -191,93 +178,12 @@
             , If_Account_Change__c 
             , Salesdepartment_Owner__c 
             ,Opportunity_Category__c
             //fy DB202312538864 2024.02.02 start
             ,Salesdepartment_SAP__c
             ,OCM_man_province_cus__c
             //fy DB202312538864 2024.02.02 end
             FROM Opportunity Where Id = :oppId];
      if (oppList.size() > 0) {
          opp = oppList[0];
      }
      return opp;
  }
  // chenjingwu 20240409 start
  // @AuraEnabled
  // public static  String addOptions(String str){
  //   List<QELine> lineList = (List<QELine>)JSON.deserialize(str,List<QELine>.class);
  //   List<String> idList = new List<String>();
  //   for(QELine qe: lineList){
  //     idList.add(qe.pageObject.PricebookEntry.Product2Id);
  //   }
  //   Map<String,List<OptionTemplete>> optionMap = new Map<String,List<OptionTemplete>>();
  //   Map<String,Integer> intList = new Map<String,Integer>();
  //   for(AggregateResult  objAgr: [select ProductName__c,COUNT(Id) total from MultiYearWarranty__c where ProductName__c in:idList group by ProductName__c]){
  //     intList.put((String)objAgr.get('ProductName__c'), (Integer)objAgr.get('total'));
  //   }
  //   for(QELine qe: lineList){
  //     List<OptionTemplete> optionTempleteList = new List<OptionTemplete>();
  //     optionTempleteList.add(new OptionTemplete('0年',''));
  //     if(intList.containsKey(qe.pageObject.PricebookEntry.Product2Id) && qe.Learning_CommunityOptions == null){
  //       for(Integer j = 0;j < intList.get(qe.pageObject.PricebookEntry.Product2Id);j++){
  //         optionTempleteList.add(new OptionTemplete((j + 1) + '年',(j + 1) + ''));
  //       }
  //       qe.Learning_CommunityOptions = optionTempleteList;
  //     }else if(!intList.containsKey(qe.pageObject.PricebookEntry.Product2Id) && qe.Learning_CommunityOptions == null){
  //       qe.Learning_CommunityOptions = optionTempleteList;
  //     }
  //   }
  //   return JSON.serialize(lineList);
  // }
  @AuraEnabled
  public static Map<String,Object> addOptions(List<String> idList){
    // Map<String,Integer> intList = new Map<String,Integer>();
    // for(AggregateResult  objAgr: [select ProductName__c,COUNT(Id) total from MultiYearWarranty__c where ProductName__c in:idList group by ProductName__c]){
    //   intList.put((String)objAgr.get('ProductName__c'), (Integer)objAgr.get('total'));
    // }
    // Map<String,List<OptionTemplete>> optionMap = new Map<String,List<OptionTemplete>>();
    // Map<String,Object> allMap = new Map<String,Object>();
    // Map<String,List<MultiYearWarranty__c>> priceMap = new Map<String,List<MultiYearWarranty__c>>();
    // for(String id: idList){
    //   List<OptionTemplete> optionTempleteList = new List<OptionTemplete>();
    //   optionTempleteList.add(new OptionTemplete('0年','0'));
    //   if(intList.containsKey(id)){
    //     for(Integer j = 0;j < intList.get(id);j++){
    //       optionTempleteList.add(new OptionTemplete((j + 1) + '年',(j + 1) + ''));
    //     }
    //     optionMap.put(id,optionTempleteList);
    //   }else {
    //     optionMap.put(id,optionTempleteList);
    //   }
    // }
    // allMap.put('optionMap',optionMap);
    Map<String,Object> allMap = new Map<String,Object>();
    Map<String,List<MultiYearWarranty__c>> priceMap = new Map<String,List<MultiYearWarranty__c>>();
    Map<String,List<OptionTemplete>> optionMap = new Map<String,List<OptionTemplete>>();
    List<MultiYearWarranty__c> muList = [select Id,ProductName__c,MultiOneYearWarrantyPrice__c,AmountWithheld__c,AgeLimit__c from MultiYearWarranty__c where ProductName__c in:idList order by AgeLimit__c];
    for(String id: idList){
      List<MultiYearWarranty__c> muList1 = new List<MultiYearWarranty__c>();
      for(MultiYearWarranty__c mu : muList){
        if(mu.ProductName__c == id){
          muList1.add(mu);
        }
      }
      priceMap.put(id,muList1);
    }
    allMap.put('priceMap',priceMap);
    for(String id: idList){
      List<OptionTemplete> optionTempleteList = new List<OptionTemplete>();
      optionTempleteList.add(new OptionTemplete('0年','0'));
      for(MultiYearWarranty__c mu: priceMap.get(id)){
        optionTempleteList.add(new OptionTemplete(mu.AgeLimit__c + '年',mu.AgeLimit__c + ''));
      }
      optionMap.put(id,optionTempleteList);
    }
    allMap.put('optionMap',optionMap);
    return allMap;
  }
  // chenjingwu 20240409 end
  // DB202311242191 【报价单】报价单合同金额更新和生成新报价单规则确认和修改 fy start
  //检索询价行项目
  @AuraEnabled
@@ -307,14 +213,9 @@
               ,PricebookEntry.Product2.NoDiscount_Foreign__c
              ,PricebookEntry.Product2.Estimated_ConsumptionDueDate__c
              ,PricebookEntry.Product2.Category5__c
              // chenjingwu 3+2保修年限 20240318 start
              ,ExtendedWarrantyPeriod__c
              ,SP_Assistant__c
              ,PricebookEntry.Product2.ProductCategory__c
              // chenjingwu 3+2保修年限 20240318 end
              //DB202312560765 you 否有EndoRapid资质检查 start 
              ,PricebookEntry.Product2.IFEndoRapidFlag__c
               //DB202312560765 you 否有EndoRapid资质检查 end
              //DB202312560765 you 否有EndoRapid资质检查 end
               From OpportunityLineItem
               Where OpportunityId = :oppId Order by Item_Order__c, Id];
@@ -473,9 +374,9 @@
          // errormessage = e.getLineNumber()+'行'+e.getMessage();
          errormessage = e.getMessage();
          result.put('errormessage',errormessage);
           system.debug(Logginglevel.ERROR, e.getMessage());
          system.debug(Logginglevel.ERROR, e.getStackTraceString());
          return result;
          // system.debug(Logginglevel.ERROR, e.getMessage());
          // system.debug(Logginglevel.ERROR, e.getStackTraceString());
      }
  }
  public static Map<String,String> resultFlag(Map<String,String> result){
@@ -758,6 +659,24 @@
        Map<String, String> chkMap = OpportunityWebService.MapCheckProRegisterDecide(proMap, opp.Agency1__c, '');
        if (chkMap.size() > 0) {
            errorflg = true;
          //DB202312560765 you 否有EndoRapid资质检查 20240515 增加if条件
          Integer ERinerr = 0;
          Integer NoERinerr = 0;
          Boolean flager =false;
          if (activities.size() > 0) {
            for (QELine qli : activities) {
              if(qli.IFEndoRapidFlag){
                ERinerr ++;
              }  else if(!qli.IFEndoRapidFlag){
                NoERinerr++ ;
              }
            }
          }
          system.debug(ERinerr+'===进来了===='+NoERinerr);
          if(ERinerr>0 && NoERinerr ==0){//全包
            flager =true;
          }
          if(!flager){
            if (chkMap.containsKey('agency')&&!opp.Is_Corrosion__c) {
              errorflg = true;
              errormessage = '第一经销商没有有效的医疗器械经营许可证。';
@@ -787,6 +706,7 @@
                // errorMessagechack = '请检查红字内容(NMPA状态红字,不可销售产品;产品名称红字,超过经销商经营范围)。';
            }
        }
      }
        Boolean isDangerError = false;
        Boolean isNotDangerError = false;
        //DB202312560765 you 否有EndoRapid资质检查 start 
@@ -810,7 +730,7 @@
                    //包括ER产品,看经销商资质
                    if(qli.IFEndoRapidFlag){
                        isEndoRapidError =true;
                        qli.wrong_Register = true;
                      //qli.wrong_Register = true;
                    }
                    //DB202312560765 you 否有EndoRapid资质检查 end 
                }
@@ -974,12 +894,6 @@
      error = true;
      errormessage = System.Label.Error_Message38;
    }
    //fy DB202312538864 2024.02.02 start
    // if(checkLastbuy2(false)){
    if(checkLastbuydecide(false)){
      errormessagewarn = errormessagewarn !=null ? errormessagewarn+'\n'+errormessagelastbuy : errormessagelastbuy;
    }
    //fy DB202312538864 2024.02.02 end
    if (error == true) {
      errorflg = true;
      return false;
@@ -1032,11 +946,7 @@
    if(quo.MultiYearWarrantyTotalPrice__c==null){
      quo.MultiYearWarrantyTotalPrice__c=0;
    }
    if(quo.ExtendedWarrantyAmountTotalPrice__c==null){
      quo.ExtendedWarrantyAmountTotalPrice__c=0;
    }
    sumContractAmount = AccrualTotal+quo.MultiYearWarrantyTotalPrice__c+quo.ExtendedWarrantyAmountTotalPrice__c;
    sumContractAmount = AccrualTotal+quo.MultiYearWarrantyTotalPrice__c;
    if(quo.OCM_Agent1_Price_Page__c<=sumContractAmount){
      error = true;
      errorflg = true;
@@ -1205,9 +1115,10 @@
              Agency2__c, Agent1_Agent2_Price__c, Agency2_Profit__c, Agency2_Profit_Rate__c,
              Preferential_Trading_Price__c, Discount__c, Pricing__c, Unit_Price__c, Offer_Amount__c, TOTAL__c,
              Contract__c, Print_HP_Name__c, Quote_Expiration_Date__c, Quote_Comment__c, OCM_Sales_Forecast__c, Installation_location__c, HasType3Machine__c
              , Gurantee_Period__c , multiYearWarranty__c, MultiYearWarrantyTotalPrice__c,ExtendedWarrantyAmountTotalPrice__c
              , Gurantee_Period__c , multiYearWarranty__c, MultiYearWarrantyTotalPrice__c
              , Preferential_Gurantee_Period__c
              ,IsQuoteTrial__c 
              ,HasType2Machine__c //20240416 DB202312560765 you 是否有EndoRapid资质
              From Quote Where Id = :quoId];
        if (qs.size() > 0) {
          q = qs[0];
@@ -1238,8 +1149,23 @@
          pIds.add(s.pageObject.Id__c);
        }
      }
      List<Product2> pList = [select Id from Product2 where Id in :pids and Category3__c = '主机'];
      if (pList.size() > 0) q.HasType3Machine__c = true;
      //20240416 DB202312560765 you 是否有EndoRapid资质 start
      //List<Product2> pList = [select Id from Product2 where Id in :pids and Category3__c = '主机'];
      //if (pList.size() > 0) q.HasType3Machine__c = true;
      List<Product2> pList = [select Id,Category3__c,Category2__c from Product2 where Id in :pids and (Category3__c = '主机' or Category2__c = '本体')];
      if (pList.size() > 0){
        for(Product2 pp : pList){
          if(String.isNotBlank(pp.Category3__c) && pp.Category3__c=='主机'){
            q.HasType3Machine__c = true;
          }
          if(String.isNotBlank(pp.Category2__c) && pp.Category2__c=='本体'){
            q.HasType2Machine__c = true;
          }
        }
      }
      //20240416 DB202312560765 you 是否有EndoRapid资质 end
      q.Name = quo.QuoteName__c;
      q.Estimation_List_Price__c = quo.Estimation_List_Price__c;
      q.Dealer_Final_Price__c =  quo.Dealer_Final_Price_Page__c;
@@ -1256,7 +1182,6 @@
      q.Gurantee_Period__c = quo.Gurantee_Period__c;
      q.multiYearWarranty__c = quo.multiYearWarranty__c;
      q.MultiYearWarrantyTotalPrice__c = quo.MultiYearWarrantyTotalPrice__c;
      q.ExtendedWarrantyAmountTotalPrice__c = quo.ExtendedWarrantyAmountTotalPrice__c;
      q.quoteSavedDate__c = Date.today();
      q.Agency1_Profit_Rate__c = quo.Agency1_Profit_Rate__c;
      q.Agency2__c = opp.Agency2__c;
@@ -1320,17 +1245,11 @@
              ql.UnitPrice__c = ql.UnitPrice_Page__c;
              ql.UnitPrice_Page__c = 0;
              ql.ListPrice__c = s.ListPrice_Page;
              ql.ExtendedWarrantyAmount__c = s.exPrice;
              ql.GuranteePrice__c        = s.GuranteePrice;
              ql.ProductGuranteePrice__c = s.ProductGuranteePrice;
              ql.Maintenance_Price_Year__c = s.Maintenance_Price_Year;
              ql.CanNotCancelFlag__c = s.CanNotCancelledGurantee;
              ql.Item_Order__c = i;//预测金额修改 fy
              // chenjingwu 3+2多年保 20240403 start
              if(s.Learning_Community != null && s.Learning_Community != '' && s.Learning_Community?.isNumeric() == true){
                ql.ExtendedWarrantyPeriod__c = Integer.valueof(s.Learning_Community);
              }
              // chenjingwu 3+2多年保 20240403 end
              if (s.pageObject.Subtotal__c != null && quo.OCM_Agent1_Price_Page__c != null && quo.QuoteTotal_Page__c != null) {
                if (s.pageObject.Subtotal__c > 0 && quo.QuoteTotal_Page__c > 0) {//预测金额修改 fy
                  ql.OCM_Sales_Forecast__c =  quo.OCM_Agent1_Price_Page__c * (s.pageObject.Subtotal__c / quo.QuoteTotal_Page__c);
@@ -1374,11 +1293,12 @@
        o.Estimation_Id__c = q.Id;
        o.Installation_location__c = q.Installation_location__c;
        o.HasType3Machine__c = q.HasType3Machine__c;
        o.HasType2Machine__c = q.HasType2Machine__c;//20240416 DB202312560765 you 是否有EndoRapid资质
        o.AgencyDiscount__c  = quo.AgencyDiscount__c;
        o.Gurantee_Period__c              = quo.Gurantee_Period__c ;
        o.multiYearWarranty__c            = quo.multiYearWarranty__c ;
        o.MultiYearWarrantyTotalPrice__c  = quo.MultiYearWarrantyTotalPrice__c ;
        o.ExtendedWarrantyAmountTotalPrice__c = quo.ExtendedWarrantyAmountTotalPrice__c;
        o.quoteSavedDate__c = Date.today();
        o.OlyNumberHosts__c = 0;
        List<String> oppIds = New List<String>();
@@ -1429,9 +1349,6 @@
            if (s.Asset_Model != null && s.Asset_Model != '') {
              if (s.pageObject.PricebookEntryId != null) {
                ol = New OpportunityLineItem();
                // chenjingwu Sp主机类型 20240318 start
                ol.SP_Assistant__c = s.SPAssistant;
                // chenjingwu Sp主机类型 20240318 end
                ol.OpportunityId = oppid;
                ol.Id__c = s.pageObject.Id__c;
                ol.SFDA_Status__c = s.pageObject.SFDA_Status__c;
@@ -1463,11 +1380,6 @@
                ol.Cost__c = s.pageObject.Cost__c;
                ol.BSS_Category__c = s.pageObject.BSS_Category__c;
                ol.CanNotCancelFlag__c = s.CanNotCancelledGurantee;//预测金额修改 fy
                // chenjingwu 3+2多年保 20240403 start
                if(s.Learning_Community != null && s.Learning_Community != '' && s.Learning_Community?.isNumeric() == true){
                  ol.ExtendedWarrantyPeriod__c        = integer.valueof(s.Learning_Community);
                }
                // chenjingwu 3+2多年保 20240403 end
                if (s.pageObject.Subtotal__c != null && o.Wholesale_Price__c != null && quo.QuoteTotal_Page__c != null) {
                  if (s.pageObject.Subtotal__c > 0 && quo.QuoteTotal_Page__c > 0) {//预测金额修改 fy
                    ol.OCM_Sales_Forecast__c =  o.Wholesale_Price__c * (s.pageObject.Subtotal__c / quo.QuoteTotal_Page__c);
@@ -1522,16 +1434,9 @@
                      + ' , Product2.Intra_Trade_Service_RMB__c,Product2.CanNotCancelledGurantee__c,Product2.Is_DangerousChemicals__c '
                      + ' , Product2.GuranteeType__c , product2.VenderName__c , product2.Maintenance_Price_Year__c '
                      + ' , Product2.suitDepartment__c '
                      //fy DB202312538864 2024.02.02 start
                      + ' , Product2.LastbuyProductFLG__c '
                      + ' , Product2.whetherOldCode_PrePro__c '
                      //fy DB202312538864 2024.02.02 end
                      //chenjingwu DB202308355043 2023.8.25 start
                      + ' , Product2.Category5__c '
                      //chenjingwu DB202308355043 2023.8.25 end
                      //chenjingwu 20240319 start
                      + ' , Product2.ProductCategory__c '
                      //chenjingwu 20240319  end
                      + ' , Product2.Estimated_ConsumptionDueDate__c '
                      //DB202312560765 you 否有EndoRapid资质检查 start 
                      + ' , Product2.IFEndoRapidFlag__c '
@@ -1639,17 +1544,11 @@
                               ,Is_DangerousChemicals__c
                               ,Repair_Contract_USD__c
                               ,LastbuyProductFLG__c
                               //fy DB202312538864 2024.02.02 start
                               ,whetherOldCode_PrePro__c
                               //fy DB202312538864 2024.02.02 end
                               ,Intra_Trade_Foreign_RMB__c
                               ,NoDiscount_Foreign__c
                               //chenjingwu DB202308355043 2023.8.25 start
                               ,Category5__c
                               //chenjingwu DB202308355043 2023.8.25 end
                                //chenjingwu 20240411 start
                               ,ProductCategory__c
                             //chenjingwu 20240411 end
                              ,Estimated_ConsumptionDueDate__c
                              //DB202312560765 you 否有EndoRapid资质检查 start 
                              ,IFEndoRapidFlag__c
@@ -1677,9 +1576,9 @@
      QELine a = New QELine();
      a.lineNo = i;
      System.debug('i-c++'+i);
      a = t;
      a.lineNo = i;
      activities.add(a);
        a = t;
        a.lineNo = i;
        activities.add(a);
      i++;
    }
@@ -1710,14 +1609,7 @@
                             //chenjingwu DB202308355043 2023.8.25 start
                             , prd.Category5__c
                             //chenjingwu DB202308355043 2023.8.25 end
                             //chenjingwu 20240411 start
                             , 0
                             ,prd.ProductCategory__c
                             //chenjingwu 20240411 end
                             //fy DB202312538864 2024.02.02 start
                            ,prd.LastbuyProductFLG__c
                            ,prd.whetherOldCode_PrePro__c
                            //fy DB202312538864 2024.02.02 end
                            //DB202312560765 you 否有EndoRapid资质检查 start 
                            ,prd.IFEndoRapidFlag__c
                            //DB202312560765 you 否有EndoRapid资质检查 end
@@ -1743,14 +1635,7 @@
                             //chenjingwu DB202308355043 2023.8.25 start
                             , prd.Category5__c
                             //chenjingwu DB202308355043 2023.8.25 end
                             //chenjingwu 20240411 start
                             , 0
                             ,prd.ProductCategory__c
                             //chenjingwu 20240411 end
                             //fy DB202312538864 2024.02.02 start
                            ,prd.LastbuyProductFLG__c
                            ,prd.whetherOldCode_PrePro__c
                            //fy DB202312538864 2024.02.02 end
                             //DB202312560765 you 否有EndoRapid资质检查 start 
                             ,prd.IFEndoRapidFlag__c
                            //DB202312560765 you 否有EndoRapid资质检查 end
@@ -1804,10 +1689,6 @@
    List<string> xlslist = New list<string>();
    List<string> codelist = New List<string>();
    List<Integer> Quantitylist = New List<Integer>();
    // chenjingwu 20240411 start
    List<Integer> exYearList = New List<Integer>();
    Integer xlsExYear;
    // chenjingwu 20240411 end
    //String str ;
    Map<String, Integer> mp = new Map<String, Integer>();
@@ -1824,8 +1705,7 @@
          system.debug('xlslist+++'+xlslist);
          for (String s : xlslist) {
            //odd number or even number
            // chenjingwu 20240411 start
            if (math.mod(i, 3) == 1) {
            if (math.mod(i, 2) != 0) {
              system.debug('xlslist1+++'+s);
              //odd number
              if (s == '' || s == null) {
@@ -1839,7 +1719,7 @@
                xlsQuantity = Integer.valueOf(s);
                Quantitylist.add(xlsQuantity);
              }
            } else if(math.mod(i, 3) == 0){
            } else {
              system.debug('xlslist2+++'+s);
              //even number
              if (s == '' || s == null) {
@@ -1853,20 +1733,6 @@
                codelist.add(s);
                xlscode = s;
              }
            }else if(math.mod(i, 3) == 2){
              //even number
              if (s == '' || s == null) {
                errorflg = true;
                errormessage = System.Label.Error_Message31;
                activities = tmpactivities;
                // pageArrange();
                return errormessage+'---'+JSON.serialize(activities);
              } else {
                s = s.trim();
                xlsExYear = Integer.valueOf(s);
                exYearList.add(xlsExYear);
              }
              // chenjingwu 20240411 end
            }
            i++;
          }
@@ -1885,9 +1751,8 @@
    system.debug(j);
    system.debug('xlscnt:::::' + xlscnt);
    // chenjingwu 20240411 start
    if (codelist.size() == 0 || Quantitylist.size() == 0 || exYearList.size() == 0) {
      // chenjingwu 20240411 end
    if (codelist.size() == 0 || Quantitylist.size() == 0) {
      activities = tmpactivities;
      errorflg = true;
      system.debug('codelist+++'+codelist);
@@ -1916,10 +1781,6 @@
                            , Entend_gurantee_period_all__c
                            , Intra_Trade_Gurantee_RMB__c
                            , Intra_Trade_Service_RMB__c
                            //fy DB202312538864 2024.02.02 start
                            ,LastbuyProductFLG__c
                            ,whetherOldCode_PrePro__c
                            //fy DB202312538864 2024.02.02 end
                            , GuranteeType__c
                            ,  Maintenance_Price_Year__c
                          ,CanNotCancelledGurantee__c
@@ -1930,9 +1791,6 @@
                          //chenjingwu DB202308355043 2023.8.25 start
                          ,Category5__c
                          //chenjingwu DB202308355043 2023.8.25 end
                          //chenjingwu 20240411 start
                          ,ProductCategory__c
                          //chenjingwu 20240411 end
                          ,Estimated_ConsumptionDueDate__c
                          //DB202312560765 you 否有EndoRapid资质检查 start 
                          ,IFEndoRapidFlag__c
@@ -1976,14 +1834,7 @@
                            //chenjingwu DB202308355043 2023.8.25 start
                            , prd.Category5__c
                            //chenjingwu DB202308355043 2023.8.25 end
                            //chenjingwu  20240411 start
                            , exYearList[l]
                            ,prd.ProductCategory__c
                            //chenjingwu  20240411 end
                            //fy DB202312538864 2024.02.02 start
                            ,prd.LastbuyProductFLG__c
                            ,prd.whetherOldCode_PrePro__c
                            //fy DB202312538864 2024.02.02 end
                            //DB202312560765 you 否有EndoRapid资质检查 start 
                            ,prd.IFEndoRapidFlag__c
                            //DB202312560765 you 否有EndoRapid资质检查 end
@@ -2006,14 +1857,7 @@
                            //chenjingwu DB202308355043 2023.8.25 start
                            , prd.Category5__c
                            //chenjingwu DB202308355043 2023.8.25 end
                            //chenjingwu  20240411 start
                            , exYearList[l]
                            , prd.ProductCategory__c
                            //chenjingwu  20240411 end
                            //fy DB202312538864 2024.02.02 start
                            ,prd.LastbuyProductFLG__c
                            ,prd.whetherOldCode_PrePro__c
                            //fy DB202312538864 2024.02.02 end
                            //DB202312560765 you 否有EndoRapid资质检查 start 
                            ,prd.IFEndoRapidFlag__c
                            //DB202312560765 you 否有EndoRapid资质检查 end
@@ -2064,9 +1908,6 @@
    // DB202311242191 【报价单】报价单合同金额更新和生成新报价单规则确认和修改 fy start
    agency1Name = agency1Namec;
    // DB202311242191 【报价单】报价单合同金额更新和生成新报价单规则确认和修改 fy end
    //fy DB202312538864 2024.02.02 start
    // isDecides = true;
    //fy DB202312538864 2024.02.02 end
    System.debug('quoId+'+quoId);
    WinOrDecideAlert = WinOrDecideAlertc;
    productStatusUpdated = productStatusUpdatedc;
@@ -2097,30 +1938,24 @@
      errormessage = null;
      errormessagewarn = null;
      if (!(opp.If_Account_Change__c != null ? opp.If_Account_Change__c : false)) {
        //fy DB202312538864 2024.02.02 start
        // if(!ReservedProductVerification()){
        //   if(flglastbuy==1){
        //     errorflg = true;
        //     errormessage =  '预留产品表中没有该询价,请通过本部窗口联系营业管理课' ;
        //     result.put('errormessage', errormessage);
        //     return result;
        //   }else if(flglastbuy==2){
        //     errorflg = true;
        //     errormessage =  errorProductmodel+'产品数量不可超过产品预留数量' ;
        //     result.put('errormessage', errormessage);
        //     return result;
        //   }else if(flglastbuy==3){
        //     errorflg = true;
        //     errormessage =  '预留产品'+errorProductmodel+'未录入预留产品表';
        //     result.put('errormessage', errormessage);
        //     return result;
        //   }
        // }
        if(checkLastbuydecide(true)){
          result.put('errormessage', errormessagelastbuy);
          return result;
        if(!ReservedProductVerification()){
          if(flglastbuy==1){
            errorflg = true;
            errormessage =  '预留产品表中没有该询价,请通过本部窗口联系营业管理课' ;
            result.put('errormessage', errormessage);
            return result;
          }else if(flglastbuy==2){
            errorflg = true;
            errormessage =  errorProductmodel+'产品数量不可超过产品预留数量' ;
            result.put('errormessage', errormessage);
            return result;
          }else if(flglastbuy==3){
            errorflg = true;
            errormessage =  '预留产品'+errorProductmodel+'未录入预留产品表';
            result.put('errormessage', errormessage);
            return result;
          }
        }
        //fy DB202312538864 2024.02.02 end
      }
      //chenjingwu DB202308355043 2023.8.25 start
      if(checkVirtual('包含虚拟产品,无法进行decide')){
@@ -2161,16 +1996,6 @@
        result.put('errormessage', errormessage);
        return result;
      }
      //fy DB202312538864 2024.02.02 start
      if(PreProductStorageList.size()>0){
        insert PreProductStorageList;
      }
      // if(UpdatePreProductStorageList.size()>0){
      //   update UpdatePreProductStorageList;
      // }
      System.debug('PreProductStorageListf56522!!!'+PreProductStorageList);
      System.debug('UpdatePreProductStorageListdf22565!!!'+UpdatePreProductStorageList);
      //fy DB202312538864 2024.02.02 end
      // DB202311242191 【报价单】报价单合同金额更新和生成新报价单规则确认和修改 fy start
      if(String.isBlank(quoId)){
        result.put('quoId',quoIdreturn);
@@ -2299,9 +2124,28 @@
        }
      }
      Map<String, String> chkMap = new Map<String, String>();
      if(!opp.Is_Corrosion__c){
    //DB202312560765 you 否有EndoRapid资质检查 20240515 start
    Integer ERinerr = 0;
    Integer NoERinerr = 0;
    Boolean flager =false;
    if (activities.size() > 0) {
      for (QELine qli : activities) {
        if(qli.IFEndoRapidFlag){
          ERinerr ++;
        }  else if(!qli.IFEndoRapidFlag){
          NoERinerr++ ;
        }
      }
    }
    system.debug(ERinerr+'===进来了===='+NoERinerr);
    if(ERinerr>0 && NoERinerr ==0){//全包
      flager =true;
    }
    if(!opp.Is_Corrosion__c && !flager){
        chkMap = OpportunityWebService.MapCheckProRegisterDecide(proMap, opp.Agency1__c, '');
      }
    //DB202312560765 you 否有EndoRapid资质检查 20240515 end
      System.debug('chkMap++'+chkMap);
      if (chkMap.size() > 0) {
        errorflg = true;
@@ -2355,7 +2199,7 @@
              //包括ER产品,看经销商资质
              if(qli.IFEndoRapidFlag){
                isEndoRapidError =true;
                qli.wrong_Register = true;
              //qli.wrong_Register = true;
              }
              //DB202312560765 you 否有EndoRapid资质检查 end 
          }
@@ -2388,7 +2232,7 @@
        } 
      }
      //DB202312560765 you 否有EndoRapid资质检查 end 
    }
  }
    if (error == true) {
      // PageArrange();
      errorflg = true;
@@ -2429,87 +2273,87 @@
    return error;
  }
  //lastbuy检查
  // public static boolean ReservedProductVerification() {
  //   filg=true;
  //   Map<string,QuoteLineItem> quotlinitMap = new Map<string,QuoteLineItem>();
  //   List<Id> lastProductFLGListId = new List<Id>();
  //   List<QuoteLineItem> lastProductFLGList = new List<QuoteLineItem>();
  //   List<QuoteLineItem> act = new List<QuoteLineItem>();
  //   List<QuoteLineItem> act2 = new List<QuoteLineItem>();
  //   for(QELine aaa :activities){
  //     if(aaa.pageObject.PricebookEntry.Product2Id!=null){
  //       act.add(aaa.pageObject);
  //     }
  //   }
  //   act2=act.deepClone();
  //   Map<String,QuoteLineItem> map1 = new Map<String,QuoteLineItem>();
  //   System.debug('activities1111111111112为所当为多多!!!'+activities);
  //   integer i =0;
  //   for(QuoteLineItem pspsc :act2){
  //     if(pspsc.PricebookEntry.Product2Id!=null){
  //       if(map1.containsKey(pspsc.PricebookEntry.Product2Id)){
  //         QuoteLineItem quoteLine = map1.get(pspsc.PricebookEntry.Product2Id);
  //         quoteLine.Quantity__c =quoteLine.Quantity__c+pspsc.Quantity__c;
  //         map1.put(pspsc.PricebookEntry.Product2Id,quoteLine);
  //       }else{
  //         map1.put(pspsc.PricebookEntry.Product2Id,pspsc);
  //       }
  //       System.debug('34499879!!!'+activities);
  //     }
  //   }
  //   System.debug('3434343!!!'+activities);
  //   System.debug('5656565!!!'+map1);
  //   for (QuoteLineItem value : map1.values()) {
  //     if(value.PricebookEntry.Product2.LastbuyProductFLG__c){
  //       lastProductFLGListId.add(value.PricebookEntry.Product2Id);
  //       quotlinitMap.put(value.PricebookEntry.Product2Id,value);
  //       lastProductFLGList.add(value);
  //     }
  //   }
  //   System.debug('activities++++!!!'+activities);
  //   System.debug('activities!!!'+map1.values());
  //   System.debug('oppId!!!'+oppId);
  //   System.debug('lastProductFLGList!!!'+lastProductFLGListId);
  //   if(lastProductFLGListId!=null&&lastProductFLGListId.size()!=0){
  //       List<LastbuyProduct__c> LastbuyObjList=[select id,LastbuyQuantity__c,InquiryCode__c,ProductName__c,effectiveFLG__c from LastbuyProduct__c where InquiryCode__c= : oppId and ProductName__c in :lastProductFLGListId and effectiveFLG__c = true];
  //       Map<string,LastbuyProduct__c> LastbuyObjMap = new Map<string,LastbuyProduct__c>();
  //       System.debug('LastbuyObjList+++++!!!'+LastbuyObjList);
  //       if(LastbuyObjList!=null&&LastbuyObjList.size()!=0){
  //         for(LastbuyProduct__c lastbuypr :LastbuyObjList){
  //           LastbuyObjMap.put(lastbuypr.ProductName__c,lastbuypr);
  //         }
  //       }else{
  //         flglastbuy=1;
  //         filg=false;
  //         return filg;
  //       }
  //       System.debug('LastbuyObjMap!!!'+LastbuyObjMap);
  //       System.debug('lastProductFLGList+++++++!!!'+lastProductFLGList);
  //       if(lastProductFLGList!=null&&lastProductFLGList.size()!=0){
  //         for(QuoteLineItem lastbuypr :lastProductFLGList){
  //           Decimal quoteLItemNum=0;
  //           if(LastbuyObjMap.containsKey(lastbuypr.PricebookEntry.Product2Id)){
  //               quoteLItemNum=LastbuyObjMap.get(lastbuypr.PricebookEntry.Product2Id).LastbuyQuantity__c;
  //               System.debug('quoteLItemNum!!!'+quoteLItemNum);
  //               System.debug('lastbuypr.pageObject.Quantity__c+++!!!'+lastbuypr.Quantity__c);
  //               if(lastbuypr.Quantity__c>quoteLItemNum){
  //                 errorProductmodel=lastbuypr.Asset_Model_No__c;
  //                 flglastbuy=2;
  //                 filg=false;
  //                 break;
  //               }
  //           }else{
  //             errorProductmodel=lastbuypr.Asset_Model_No__c;
  //             flglastbuy=3;
  //             filg=false;
  //             break;
  //           }
  //         }
  //       }
  //   }
  //   system.debug('filg====='+filg);
  //   return filg;
  // }
  public static boolean ReservedProductVerification() {
    filg=true;
    Map<string,QuoteLineItem> quotlinitMap = new Map<string,QuoteLineItem>();
    List<Id> lastProductFLGListId = new List<Id>();
    List<QuoteLineItem> lastProductFLGList = new List<QuoteLineItem>();
    List<QuoteLineItem> act = new List<QuoteLineItem>();
    List<QuoteLineItem> act2 = new List<QuoteLineItem>();
    for(QELine aaa :activities){
      if(aaa.pageObject.PricebookEntry.Product2Id!=null){
        act.add(aaa.pageObject);
      }
    }
    act2=act.deepClone();
    Map<String,QuoteLineItem> map1 = new Map<String,QuoteLineItem>();
    System.debug('activities1111111111112为所当为多多!!!'+activities);
    integer i =0;
    for(QuoteLineItem pspsc :act2){
      if(pspsc.PricebookEntry.Product2Id!=null){
        if(map1.containsKey(pspsc.PricebookEntry.Product2Id)){
          QuoteLineItem quoteLine = map1.get(pspsc.PricebookEntry.Product2Id);
          quoteLine.Quantity__c =quoteLine.Quantity__c+pspsc.Quantity__c;
          map1.put(pspsc.PricebookEntry.Product2Id,quoteLine);
        }else{
          map1.put(pspsc.PricebookEntry.Product2Id,pspsc);
        }
        System.debug('34499879!!!'+activities);
      }
    }
    System.debug('3434343!!!'+activities);
    System.debug('5656565!!!'+map1);
    for (QuoteLineItem value : map1.values()) {
      if(value.PricebookEntry.Product2.LastbuyProductFLG__c){
        lastProductFLGListId.add(value.PricebookEntry.Product2Id);
        quotlinitMap.put(value.PricebookEntry.Product2Id,value);
        lastProductFLGList.add(value);
      }
    }
    System.debug('activities++++!!!'+activities);
    System.debug('activities!!!'+map1.values());
    System.debug('oppId!!!'+oppId);
    System.debug('lastProductFLGList!!!'+lastProductFLGListId);
    if(lastProductFLGListId!=null&&lastProductFLGListId.size()!=0){
        List<LastbuyProduct__c> LastbuyObjList=[select id,LastbuyQuantity__c,InquiryCode__c,ProductName__c,effectiveFLG__c from LastbuyProduct__c where InquiryCode__c= : oppId and ProductName__c in :lastProductFLGListId and effectiveFLG__c = true];
        Map<string,LastbuyProduct__c> LastbuyObjMap = new Map<string,LastbuyProduct__c>();
        System.debug('LastbuyObjList+++++!!!'+LastbuyObjList);
        if(LastbuyObjList!=null&&LastbuyObjList.size()!=0){
          for(LastbuyProduct__c lastbuypr :LastbuyObjList){
            LastbuyObjMap.put(lastbuypr.ProductName__c,lastbuypr);
          }
        }else{
          flglastbuy=1;
          filg=false;
          return filg;
        }
        System.debug('LastbuyObjMap!!!'+LastbuyObjMap);
        System.debug('lastProductFLGList+++++++!!!'+lastProductFLGList);
        if(lastProductFLGList!=null&&lastProductFLGList.size()!=0){
          for(QuoteLineItem lastbuypr :lastProductFLGList){
            Decimal quoteLItemNum=0;
            if(LastbuyObjMap.containsKey(lastbuypr.PricebookEntry.Product2Id)){
                quoteLItemNum=LastbuyObjMap.get(lastbuypr.PricebookEntry.Product2Id).LastbuyQuantity__c;
                System.debug('quoteLItemNum!!!'+quoteLItemNum);
                System.debug('lastbuypr.pageObject.Quantity__c+++!!!'+lastbuypr.Quantity__c);
                if(lastbuypr.Quantity__c>quoteLItemNum){
                  errorProductmodel=lastbuypr.Asset_Model_No__c;
                  flglastbuy=2;
                  filg=false;
                  break;
                }
            }else{
              errorProductmodel=lastbuypr.Asset_Model_No__c;
              flglastbuy=3;
              filg=false;
              break;
            }
          }
        }
    }
    system.debug('filg====='+filg);
    return filg;
  }
  // CHAN-AVG3PW 询价报价画面规则变更
  // 报价创建日超过三个月时,如产品停产或CFDA失效,不可以保存,提示“请更新停止销售的产品”
  //             做DECIDE时,如产品停产或CFDA失效,不可以保存,提示“请更新停止销售的产品”
@@ -2569,322 +2413,11 @@
    return false;
  }
  //chenjingwu DB202308355043 2023.8.25 end
  //fy DB202312538864 2024.02.02 start
  //产品预留check
  // public static Boolean checkLastbuy2(Boolean isDecide){
  //   if(isDecides){
  //     return false;
  //   }
  //   Boolean lastcheck = false;
  //   Map<string,QuoteLineItem> quotlinitMap = new Map<string,QuoteLineItem>();
  //   List<Id> lastProductFLGListId = new List<Id>();
  //   List<QuoteLineItem> lastProductFLGList = new List<QuoteLineItem>();
  //   List<QuoteLineItem> act = new List<QuoteLineItem>();
  //   List<QuoteLineItem> act2 = new List<QuoteLineItem>();
  //   // PreProductStorageList = new List<PreProduct_Storage_List__c>();
  //   // UpdatePreProductStorageList = new List<PreProduct_Storage__c>();
  //   for(QELine aaa :activities){
  //     if(aaa.pageObject.PricebookEntry.Product2Id!=null){
  //       act.add(aaa.pageObject);
  //     }
  //   }
  //   act2=act.deepClone();
  //   Map<String,QuoteLineItem> map1 = new Map<String,QuoteLineItem>();
  //   System.debug('activitiesss!!!'+activities);
  //   //*****合并产品重复的报价行项目****
  //   for(QuoteLineItem pspsc :act2){
  //     if(pspsc.PricebookEntry.Product2Id!=null){
  //       if(map1.containsKey(pspsc.PricebookEntry.Product2Id)){
  //         QuoteLineItem quoteLine = map1.get(pspsc.PricebookEntry.Product2Id);
  //         quoteLine.Quantity__c =quoteLine.Quantity__c+pspsc.Quantity__c;
  //         map1.put(pspsc.PricebookEntry.Product2Id,quoteLine);
  //       }else{
  //         map1.put(pspsc.PricebookEntry.Product2Id,pspsc);
  //       }
  //       System.debug('3449987sdf9!!!'+pspsc.PricebookEntry);
  //     }
  //   }
  //   System.debug('3434sdf343!!!'+activities);
  //   System.debug('5656sdf565!!!'+map1);
  //   for (QuoteLineItem value : map1.values()) {
  //     if(value.PricebookEntry.Product2.LastbuyProductFLG__c){
  //       lastProductFLGListId.add(value.PricebookEntry.Product2Id);
  //       quotlinitMap.put(value.PricebookEntry.Product2Id,value);
  //       lastProductFLGList.add(value);
  //     }
  //     System.debug('3434sdf343!!!'+value.PricebookEntry.Product2);
  //   }
  //   System.debug('opp5656sdf565!!!'+opp);
  //   //*****合并产品重复的报价****
  //   if(lastProductFLGListId!=null&&lastProductFLGListId.size()!=0){
  //     // 锁定行前查询数据
  //     List<PreProduct_Storage__c> lockedPreProductStorage = [SELECT Id,Name,Storage_Number__c,LeftNumber__c,Used_Number__c,Department__c,Province__c,RecordType.Name,Field1__c FROM PreProduct_Storage__c WHERE ifValid__c = true and Field1__c in:lastProductFLGListId FOR UPDATE];
  //     // 执行需要锁定行的其他操作
  //     if(lockedPreProductStorage!=null&&lockedPreProductStorage.size()!=0){
  //       System.debug('3434slockedPreProductStoragedf343!!!'+lockedPreProductStorage);
  //       for (PreProduct_Storage__c preProductStorage : lockedPreProductStorage) {
  //         System.debug('34preProductStorage3!!!'+preProductStorage);
  //         Decimal pronumber = map1.get(preProductStorage.Field1__c).Quantity__c;
  //         if(preProductStorage.RecordType.Name == '整机'
  //           && opp.Salesdepartment_SAP__c == preProductStorage.Department__c ){
  //           if(preProductStorage.LeftNumber__c < pronumber){
  //             errormessagelastbuy = String.isNotBlank(errormessagelastbuy)? errormessagelastbuy+';'+'\n': errormessagelastbuy;
  //             errormessagelastbuy += '产品 '+ map1.get(preProductStorage.Field1__c).Asset_Model_No__c+' 已经超出剩余预留数量,剩余数量是'+preProductStorage.LeftNumber__c;
  //             lastcheck = true;
  //           }
  //           // else if(isDecide){
  //           //   // preProductStorage.LeftNumber__c -= pronumber;
  //           //   // preProductStorage.Used_Number__c += pronumber;
  //           //   PreProduct_Storage_List__c PreProductStorageObj = new PreProduct_Storage_List__c();
  //           //   PreProductStorageObj.PreProduct_Storage__c = preProductStorage.Id;
  //           //   PreProductStorageObj.Modify_Number__c = pronumber;
  //           //   PreProductStorageObj.AddReduceNumber__c = -pronumber;
  //           //   PreProductStorageObj.Modified_Time__c = Datetime.now();
  //           //   PreProductStorageObj.Change_Type__c = '支出';
  //           //   PreProductStorageObj.Opportunity__c = opp.Id;
  //           //   UpdatePreProductStorageList.add(preProductStorage);
  //           //   PreProductStorageList.add(PreProductStorageObj);
  //           // }
  //         }else if(preProductStorage.RecordType.Name == '耗材'
  //           && opp.OCM_man_province_cus__c == preProductStorage.Province__c){
  //           if(preProductStorage.LeftNumber__c < pronumber){
  //             errormessagelastbuy = String.isNotBlank(errormessagelastbuy)? errormessagelastbuy+';'+'\n': errormessagelastbuy;
  //             errormessagelastbuy += '产品 '+ map1.get(preProductStorage.Field1__c).Asset_Model_No__c+' 已经超出剩余预留数量,剩余数量是'+preProductStorage.LeftNumber__c;
  //             lastcheck = true;
  //           }
  //           // else if(isDecide){
  //           //   // preProductStorage.LeftNumber__c -= pronumber;
  //           //   // preProductStorage.Used_Number__c += pronumber;
  //           //   PreProduct_Storage_List__c PreProductStorageObj = new PreProduct_Storage_List__c();
  //           //   PreProductStorageObj.PreProduct_Storage__c = preProductStorage.Id;
  //           //   PreProductStorageObj.Modify_Number__c = pronumber;
  //           //   PreProductStorageObj.AddReduceNumber__c = -pronumber;
  //           //   PreProductStorageObj.Modified_Time__c = Datetime.now();
  //           //   PreProductStorageObj.Change_Type__c = '支出';
  //           //   PreProductStorageObj.Opportunity__c = opp.Id;
  //           //   UpdatePreProductStorageList.add(preProductStorage);
  //           //   PreProductStorageList.add(PreProductStorageObj);
  //           // }
  //         }
  //         System.debug('34errormessagelastbuy3!!!'+errormessagelastbuy);
  //       }
  //     }
  //   }
  //   System.debug('PreProductStorageListf565!!!'+PreProductStorageList);
  //   System.debug('UpdatePreProductStorageListdf565!!!'+UpdatePreProductStorageList);
  //   System.debug('lastcheck!!!++'+lastcheck);
  //   return lastcheck;
  // }
  //产品预留check
  public static Boolean checkLastbuydecide(Boolean isDecide){
    Boolean lastcheck = false;
    Map<string,QuoteLineItem> quotlinitMap = new Map<string,QuoteLineItem>();
    List<Id> lastProductFLGListId = new List<Id>();
    List<Id> NewcodeListId = new List<Id>();
    // List<Id> lastNewcodeListId = new List<Id>();
    List<QuoteLineItem> lastProductFLGList = new List<QuoteLineItem>();
    List<QuoteLineItem> act = new List<QuoteLineItem>();
    List<QuoteLineItem> act2 = new List<QuoteLineItem>();
    // PreProductStorageList = new List<PreProduct_Storage_List__c>();
    // UpdatePreProductStorageList = new List<PreProduct_Storage__c>();
    for(QELine aaa :activities){
      if(aaa.pageObject.PricebookEntry.Product2Id!=null){
        act.add(aaa.pageObject);
      }
    }
    act2=act.deepClone();
    Map<String,QuoteLineItem> map1 = new Map<String,QuoteLineItem>();
    System.debug('activitiessws!!!'+activities);
    //*****合并产品重复的报价行项目****
    for(QuoteLineItem pspsc :act2){
      if(pspsc.PricebookEntry.Product2Id!=null){
        if(map1.containsKey(pspsc.PricebookEntry.Product2Id)){
          QuoteLineItem quoteLine = map1.get(pspsc.PricebookEntry.Product2Id);
          quoteLine.Quantity__c =quoteLine.Quantity__c+pspsc.Quantity__c;
          map1.put(pspsc.PricebookEntry.Product2Id,quoteLine);
        }else{
          map1.put(pspsc.PricebookEntry.Product2Id,pspsc);
        }
        System.debug('3449987wsdf9!!!'+activities);
      }
    }
    System.debug('3434sdf3w43!!!'+activities);
    System.debug('5656sdf5w65!!!'+map1);
    for (QuoteLineItem value : map1.values()) {
      //检索是否有旧code的产品id
      if(value.PricebookEntry.Product2.whetherOldCode_PrePro__c){
        NewcodeListId.add(value.PricebookEntry.Product2Id);
      }
      if(value.PricebookEntry.Product2.LastbuyProductFLG__c){
        lastProductFLGListId.add(value.PricebookEntry.Product2Id);
        quotlinitMap.put(value.PricebookEntry.Product2Id,value);
        lastProductFLGList.add(value);
      }
    }
    System.debug('5656sdfaa5w65!!!'+NewcodeListId);
    List<Product2> prd2List = new List<Product2>();
    Map<String,String> prd2Map = new Map<String,String>();
    Map<String,PreProduct_Storage__c> prd2ppsMap = new Map<String,PreProduct_Storage__c>();
    // List<PreProduct_Storage__c> ProductStorageList = new List<PreProduct_Storage__c>();
    if(NewcodeListId.size() > 0){
      prd2List = [Select Id,Correspond_Code__c From Product2 Where Correspond_Code__c In:NewcodeListId];
      for(Product2 prd2 : prd2List){
        lastProductFLGListId.add(prd2.Id);
        prd2Map.put(prd2.Correspond_Code__c, prd2.Id);
      }
    }
    System.debug('opp5656sdf565!!!'+opp);
    //*****合并产品重复的报价****
    if(lastProductFLGListId!=null&&lastProductFLGListId.size()!=0){
      // 锁定行前查询数据
      List<PreProduct_Storage__c> lockedPreProductStorage = [SELECT Id,Name,Storage_Number__c,LeftNumber__c,Department__c,Province__c,RecordType.Name,Field1__c
      FROM PreProduct_Storage__c WHERE ifValid__c = true and Field1__c in:lastProductFLGListId
      and ((RecordType.Name = '整机' and Department__c =:opp.Salesdepartment_SAP__c)
        or (RecordType.Name = '耗材' and Province__c =:opp.OCM_man_province_cus__c) ) FOR UPDATE];
      // 执行需要锁定行的其他操作
      System.debug('opp5656sdf56aa5!!!>>'+lockedPreProductStorage);
      if(lockedPreProductStorage!=null&&lockedPreProductStorage.size()!=0){
        for (PreProduct_Storage__c preProductStorage : lockedPreProductStorage) {
            prd2ppsMap.put(preProductStorage.Field1__c,preProductStorage);
        }
        for (QuoteLineItem value2 : map1.values()) {
          if(prd2ppsMap.containsKey(value2.PricebookEntry.Product2Id) || value2.PricebookEntry.Product2.whetherOldCode_PrePro__c){
            //有预留的产品
            PreProduct_Storage__c preProductStorage2 = prd2ppsMap.get(value2.PricebookEntry.Product2Id);
            //有旧code的产品
            PreProduct_Storage__c oldcodeps = prd2ppsMap.get(prd2Map.get(value2.PricebookEntry.Product2Id));
            System.debug('oldcodeps!!!>>'+oldcodeps);
            System.debug('preProductStorage2!!!>>'+preProductStorage2);
            if(oldcodeps != null){
              System.debug('value2!!!>>'+value2);
              if((oldcodeps.RecordType.Name == '整机' && opp.Salesdepartment_SAP__c == oldcodeps.Department__c)
              ||(oldcodeps.RecordType.Name == '耗材' && opp.OCM_man_province_cus__c == oldcodeps.Province__c) ){
                if(oldcodeps.LeftNumber__c < value2.Quantity__c
                &&(preProductStorage2 != null && preProductStorage2.LeftNumber__c < (value2.Quantity__c-oldcodeps.LeftNumber__c))){
                  Decimal TotalRemainingQuantity = preProductStorage2.LeftNumber__c + oldcodeps.LeftNumber__c;
                  errormessagelastbuy = String.isNotBlank(errormessagelastbuy)? errormessagelastbuy+';'+'\n': errormessagelastbuy;
                  errormessagelastbuy += '产品 '+ value2.Asset_Model_No__c+' 已经超出剩余预留数量,剩余数量是'+TotalRemainingQuantity;
                  lastcheck = true;
                }else if(isDecide){
                  if(oldcodeps.LeftNumber__c < value2.Quantity__c
                  &&(preProductStorage2 != null && preProductStorage2.LeftNumber__c > (value2.Quantity__c-oldcodeps.LeftNumber__c))){
                    Decimal couchuNumber = value2.Quantity__c-oldcodeps.LeftNumber__c;
                    PreProduct_Storage_List__c PreProductStorageObj = new PreProduct_Storage_List__c();
                    PreProductStorageObj.PreProduct_Storage__c = oldcodeps.Id;
                    PreProductStorageObj.Modify_Number__c = oldcodeps.LeftNumber__c;
                    PreProductStorageObj.AddReduceNumber__c = -oldcodeps.LeftNumber__c;
                    PreProductStorageObj.Modified_Time__c = Datetime.now();
                    PreProductStorageObj.Change_Type__c = '支出';
                    PreProductStorageObj.Opportunity__c = opp.Id;
                    PreProductStorageList.add(PreProductStorageObj);
                    PreProduct_Storage_List__c PreProductStorageObj1 = new PreProduct_Storage_List__c();
                    PreProductStorageObj1.PreProduct_Storage__c = preProductStorage2.Id;
                    PreProductStorageObj1.Modify_Number__c = couchuNumber;
                    PreProductStorageObj1.AddReduceNumber__c = -couchuNumber;
                    PreProductStorageObj1.Modified_Time__c = Datetime.now();
                    PreProductStorageObj1.Change_Type__c = '支出';
                    PreProductStorageObj1.Opportunity__c = opp.Id;
                    PreProductStorageList.add(PreProductStorageObj1);
                  }else if(oldcodeps.LeftNumber__c < value2.Quantity__c && preProductStorage2 == null){
                    if(oldcodeps.LeftNumber__c != 0){
                      PreProduct_Storage_List__c PreProductStorageObj = new PreProduct_Storage_List__c();
                      PreProductStorageObj.PreProduct_Storage__c = oldcodeps.Id;
                      PreProductStorageObj.Modify_Number__c = oldcodeps.LeftNumber__c;
                      PreProductStorageObj.AddReduceNumber__c = -oldcodeps.LeftNumber__c;
                      PreProductStorageObj.Modified_Time__c = Datetime.now();
                      PreProductStorageObj.Change_Type__c = '支出';
                      PreProductStorageObj.Opportunity__c = opp.Id;
                      PreProductStorageList.add(PreProductStorageObj);
                    }
                  }else{
                    PreProduct_Storage_List__c PreProductStorageObj = new PreProduct_Storage_List__c();
                    PreProductStorageObj.PreProduct_Storage__c = oldcodeps.Id;
                    PreProductStorageObj.Modify_Number__c = value2.Quantity__c;
                    PreProductStorageObj.AddReduceNumber__c = -value2.Quantity__c;
                    PreProductStorageObj.Modified_Time__c = Datetime.now();
                    PreProductStorageObj.Change_Type__c = '支出';
                    PreProductStorageObj.Opportunity__c = opp.Id;
                    PreProductStorageList.add(PreProductStorageObj);
                  }
                }
              }
            }else{
              if(preProductStorage2.RecordType.Name == '整机'
              && opp.Salesdepartment_SAP__c == preProductStorage2.Department__c ){
                if(preProductStorage2.LeftNumber__c < value2.Quantity__c){
                  errormessagelastbuy = String.isNotBlank(errormessagelastbuy)? errormessagelastbuy+';'+'\n': errormessagelastbuy;
                  errormessagelastbuy += '产品 '+ map1.get(preProductStorage2.Field1__c).Asset_Model_No__c+' 已经超出剩余预留数量,剩余数量是'+preProductStorage2.LeftNumber__c;
                  lastcheck = true;
                }else if(isDecide){
                  PreProduct_Storage_List__c PreProductStorageObj = new PreProduct_Storage_List__c();
                  PreProductStorageObj.PreProduct_Storage__c = preProductStorage2.Id;
                  PreProductStorageObj.Modify_Number__c = value2.Quantity__c;
                  PreProductStorageObj.AddReduceNumber__c = -value2.Quantity__c;
                  PreProductStorageObj.Modified_Time__c = Datetime.now();
                  PreProductStorageObj.Change_Type__c = '支出';
                  PreProductStorageObj.Opportunity__c = opp.Id;
                  PreProductStorageList.add(PreProductStorageObj);
                }
              }else if(preProductStorage2.RecordType.Name == '耗材'
                && opp.OCM_man_province_cus__c == preProductStorage2.Province__c){
                if(preProductStorage2.LeftNumber__c < value2.Quantity__c){
                  errormessagelastbuy = String.isNotBlank(errormessagelastbuy)? errormessagelastbuy+';'+'\n': errormessagelastbuy;
                  errormessagelastbuy += '产品 '+ map1.get(preProductStorage2.Field1__c).Asset_Model_No__c+' 已经超出剩余预留数量,剩余数量是'+preProductStorage2.LeftNumber__c;
                  lastcheck = true;
                }else if(isDecide){
                  PreProduct_Storage_List__c PreProductStorageObj = new PreProduct_Storage_List__c();
                  PreProductStorageObj.PreProduct_Storage__c = preProductStorage2.Id;
                  PreProductStorageObj.Modify_Number__c = value2.Quantity__c;
                  PreProductStorageObj.AddReduceNumber__c = -value2.Quantity__c;
                  PreProductStorageObj.Modified_Time__c = Datetime.now();
                  PreProductStorageObj.Change_Type__c = '支出';
                  PreProductStorageObj.Opportunity__c = opp.Id;
                  PreProductStorageList.add(PreProductStorageObj);
                }
              }
            }
          }
        }
      }
    }
    System.debug('PreProductStorageListf565!!!'+PreProductStorageList);
    System.debug('UpdatePreProductStorageListdf565!!!'+UpdatePreProductStorageList);
    System.debug('lastcheck!!!>>'+lastcheck);
    return lastcheck;
  }
  //fy DB202312538864 2024.02.02 end
  public class InitData{
    @AuraEnabled
    public Decimal rate_hospital;
    @AuraEnabled
    public Decimal rate_agency1;
  }
  // public class WarrantyPeriod{
  //   @AuraEnabled
  //   public List<OptionTemplete> lcListOptions;
  //   @AuraEnabled
  //   public String Learning_Community;
  //   public WarrantyPeriod(List<OptionTemplete> options,String value){
  //     this.lcListOptions = options;
  //     this.Learning_Community = value;
  //   }
  // }
  public class OptionTemplete{
    @AuraEnabled
    public String label;
    @AuraEnabled
    public String value;
    public OptionTemplete(String label,String value){
      this.label = label;
      this.value = value;
    }
  }
  //行项目自定义结构
  //行项目原值
@@ -2936,24 +2469,6 @@
      public Decimal ProductGuranteePrice;
      public decimal Maintenance_Price_Year;
      public String Category5;
      // chenjingwu sp主机类型 20240318 start
      public String SPAssistant;
      public Boolean SPAssistantFlag;
      public String ProductCategory;
      // chenjingwu sp主机类型 20240318 end
      // chenjingwu 3+2多年保 20240401 start
      public String Learning_Community;
      public String Learning_CommunityCopy;
      public Decimal exPrice;
      public Decimal exPriceCopy;
      // public List<Map<String, String>> Learning_CommunityOptions = new List<Map<String, String>>();
      public List<OptionTemplete> Learning_CommunityOptions;
      public List<MultiYearWarranty__c> multiYearWarrantyList;
      // chenjingwu 3+2多年保 20240401 end
      //fy DB202312538864 2024.02.02 start
      public Boolean lastbuyProductFLGc;
      public Boolean whetherOldCode_PreProc;
      //fy DB202312538864 2024.02.02 end
      public QELine(){}
      public QELine(QuoteLineItem qli, Integer i, String copyQuoId) {
          this.lineNo = i;
@@ -2967,46 +2482,6 @@
          //chenjingwu DB202308355043 2023.8.25 start
          Category5 = qli.PricebookEntry.Product2.Category5__c;
          //chenjingwu DB202308355043 2023.8.25 end
          // chenjingwu SP主机类型 20240318 start
          this.ProductCategory = qli.PricebookEntry.Product2.ProductCategory__c;
          if(qli.PricebookEntry.Product2.ProductCategory__c == 'SP主机'){
            this.SPAssistantFlag = true;
          }
          // chenjingwu SP主机类型 20240318 end
          // chenjingwu 3+2多年保 20240401 start
          if(qli.ExtendedWarrantyPeriod__c != null && qli.ExtendedWarrantyPeriod__c != 0){
            this.Learning_Community = String.valueof(qli.ExtendedWarrantyPeriod__c);
          }
          this.multiYearWarrantyList = [select Id,MultiOneYearWarrantyPrice__c,AmountWithheld__c,AgeLimit__c from MultiYearWarranty__c where ProductName__c =: qli.PricebookEntry.Product2Id order by AgeLimit__c];
          Integer period = this.multiYearWarrantyList.size();
          if(qli.ExtendedWarrantyPeriod__c != null && qli.ExtendedWarrantyPeriod__c != 0){
            for(MultiYearWarranty__c mu: this.multiYearWarrantyList){
              if(mu.AgeLimit__c == qli.ExtendedWarrantyPeriod__c){
                this.exPrice = mu.MultiOneYearWarrantyPrice__c;
              }
            }
          }else{
              this.Learning_Community = 0 + '';
              this.exPrice = 0;
          }
          List<OptionTemplete> optionTempleteList = new List<OptionTemplete>();
            optionTempleteList.add(new OptionTemplete('0年','0'));
          if(period > 0){
            for(MultiYearWarranty__c mu: this.multiYearWarrantyList){
              optionTempleteList.add(new OptionTemplete(mu.AgeLimit__c + '年',mu.AgeLimit__c + ''));
            }
            // for(Integer j = 0;j < period;j++){
            //   optionTempleteList.add(new OptionTemplete((j + 1) + '年',(j + 1) + ''));
            // }
          }
          this.Learning_CommunityOptions = optionTempleteList;
          if(qli.ExtendedWarrantyPeriod__c == null && this.Learning_CommunityOptions.size() > 1){
            this.Learning_Community = this.multiYearWarrantyList.get(this.multiYearWarrantyList.size() - 1).AgeLimit__c + '';
            this.exPrice = this.multiYearWarrantyList.get(this.multiYearWarrantyList.size() - 1).MultiOneYearWarrantyPrice__c;
          }
          // this.ExtendedWarrantyPeriod = new WarrantyPeriod(optionTempleteList,'');
          // chenjingwu 3+2多年保 20240401 end
          this.Asset_Model = qli.Asset_Model_No__c;
          if (qli.Cost__c > 0 && qli.Quantity > 0) {
            this.Cost_Subtotal_c = qli.Cost__c * qli.Quantity;
@@ -3020,12 +2495,9 @@
          if(VenderName==null||VenderName==''){
              this.VenderName =' 无 ';
          }
          //fy DB202312538864 2024.02.02 start
          lastbuyProductFLGc = qli.PricebookEntry.Product2.LastbuyProductFLG__c;
          whetherOldCode_PreProc = qli.PricebookEntry.Product2.whetherOldCode_PrePro__c;
          //fy DB202312538864 2024.02.02 end
          this.CanNotCancelledGurantee = qli.PricebookEntry.Product2.CanNotCancelledGurantee__c;
          this.Is_DangerousChemicals = qli.PricebookEntry.Product2.Is_DangerousChemicals__c;
          //DB202312560765 you 否有EndoRapid资质检查 start 
          this.IFEndoRapidFlag = qli.PricebookEntry.Product2.IFEndoRapidFlag__c;
          //DB202312560765 you 否有EndoRapid资质检查 end
@@ -3088,15 +2560,6 @@
        if (oli.PricebookEntry.Product2.Packing_list_manual__c != null) {
          this.Specifications = integer.valueof(oli.PricebookEntry.Product2.Packing_list_manual__c + '');
        }
        // chenjingwu SP主机类型 20240318 start
        if(oli.SP_Assistant__c != null || oli.PricebookEntry.Product2.ProductCategory__c == 'SP主机'){
          this.SPAssistant = oli.SP_Assistant__c;
          this.SPAssistantFlag = true;
        }
        if(oli.ExtendedWarrantyPeriod__c != null && oli.ExtendedWarrantyPeriod__c != 0){
          this.Learning_Community = String.valueof(oli.ExtendedWarrantyPeriod__c);
        }
        // chenjingwu SP主机类型 20240318 end
        pageObject.Id__c = oli.PricebookEntry.Product2Id;
        pageObject.UnitPrice_Page__c = oli.UnitPrice__c;
        pageObject.AgencySubtotal__c = oli.AgencySubtotal__c;
@@ -3231,24 +2694,13 @@
                //chenjingwu DB202308355043 2023.8.25 start
                ,String Category5
                //chenjingwu DB202308355043 2023.8.25 end
                //chenjingwu  20240411 start
                , Integer exYear
                ,String ProductCategory
                //chenjingwu  20240411 end
                //fy DB202312538864 2024.02.02 start
                ,Boolean lastbuyProductFLG
                ,Boolean whetherOldCode_PrePro
                //fy DB202312538864 2024.02.02 end
                //DB202312560765 you 否有EndoRapid资质检查 start 
                ,Boolean IFEndoRapidFlag
                //DB202312560765 you 否有EndoRapid资质检查 end
               ) {
          pageObject = New QuoteLineItem();
          pageObject.Quantity__c = Quantity;
          //chenjingwu  20240411 start
          this.Learning_Community = String.valueof(exYear);
          this.ProductCategory = ProductCategory;
          //chenjingwu  20240411 end
          this.lineNo = i;
          this.Asset_Model = Asset_Model;
          this.Sales_Possibility = Sales_Possibility_c;
@@ -3262,10 +2714,6 @@
          pageObject.SFDA_Status__c = SFDA_Status_c;
          pageObject.Name__c = Name_c;
          pageObject.BSS_Category__c = BSS_Category_c;
          //fy DB202312538864 2024.02.02 start
          lastbuyProductFLGc = lastbuyProductFLG;
          whetherOldCode_PreProc = whetherOldCode_PrePro;
          //fy DB202312538864 2024.02.02 end
          this.ListPrice_Page = ListPrice_c;
          pageObject.UnitPrice_Page__c = UnitPrice_c;
          pageObject.Subtotal__c = UnitPrice_c * Quantity;
@@ -3322,5 +2770,579 @@
        }
  }
  @TestVisible private static void test() {
    Integer i = 0;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
      i++;
}
  }
}