From b9d84568573c9acb1e80bdaa0a6a603e3da9767c Mon Sep 17 00:00:00 2001
From: chenjingwu <chenjingwu@prec-tech.com>
Date: 星期五, 24 五月 2024 11:30:14 +0800
Subject: [PATCH] 1

---
 force-app/main/default/classes/lexSINewQuoteEntryController.cls | 3541 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 3,541 insertions(+), 0 deletions(-)

diff --git a/force-app/main/default/classes/lexSINewQuoteEntryController.cls b/force-app/main/default/classes/lexSINewQuoteEntryController.cls
new file mode 100644
index 0000000..1ee40f9
--- /dev/null
+++ b/force-app/main/default/classes/lexSINewQuoteEntryController.cls
@@ -0,0 +1,3541 @@
+// Author: Fu,Yu
+// Created Date: 2023/08/07
+// Purpose: get page layout and record data
+// Test Class: lexSINewQuoteEntryControllerTest
+public class lexSINewQuoteEntryController {
+  public static Integer quoteEntryMaxLine;
+  public static List<QELine> activities;
+  public static List<QELine> tmpactivities;
+  public static List<QuoteLineItem> CheckItem;
+  public static Boolean WinOrDecideAlert;
+  public static Boolean errorflg;
+  public static String errormessage;
+  public static String errormessagewarn;
+  public static Map<Id, Product2> prd2LatestValMap;
+  public static Boolean productStatusUpdated;
+  public static Opportunity opp;
+  public static Quote quo;
+  public static Boolean enableSales;
+  public static String quoId;
+  public static String oppId;
+  public static Boolean newQuoteFlag;
+  public static Boolean changedAfterPrint;
+  public static string quoteGurantee_Period;
+  public static string quotemultiYearWarranty;
+  public static Pricebook2 standardPricebook;  
+  public static Boolean detail;  
+  public static String selection_hp;
+  public static String  quoIdreturn;
+  public static String  trade;
+  public static String searchMode; 
+  public static Boolean filg;
+  public static Integer flglastbuy;
+  public static String errorProductmodel;
+  public static Boolean SkipQuotefilg;
+  public static Boolean QuoteDecision;
+  //瀛楁鎶ラ敊鏍囪瘑 start
+  public static Boolean dfpp = false;
+  public static Boolean qname = false;
+  public static Boolean qacc = false;
+  public static Boolean qaapc = false;
+  public static Boolean Agency1 = false;
+  public static Boolean nAgency1 = false;
+  public static Boolean oapp = false;
+  public static Boolean noapp = false;
+  public static Boolean Agency2 = false;
+  public static Boolean nAgency2 = false;
+  public static Boolean aapp = false;
+  public static Boolean naapp = false;
+  //瀛楁鎶ラ敊鏍囪瘑 end
+  public static Boolean hongzi = false;
+  public static string agency1Name;
+  @AuraEnabled
+  //鏍规嵁鎶ヤ环Id妫�绱㈡姤浠�
+  public static  Quote selectQuoteById(String quoId){
+      Quote quo = new Quote();
+      
+          if(String.isNotBlank(quoId)){
+              List<Quote> quoList =
+              [ SELECT Id, Name, Cancel_Decide__c, CreatedDate, PriceRefreshDate__c, Quote_Print_Date__c,QuotationChange__c,MainEngineWithoutMonitor__c,Interdepartmental__c,
+                Dealer_Final_Price__c, TotalPrice__c, Estimation_List_Price__c, QuoteNumber,
+                CreatedByid,Queto_Confirm_Date__c,
+                QuoteToName, Quote_Expiration_Date__c, Quote_Comment__c, Stocking_Price__c, Unit_Price__c,
+                Offer_Amount__c, TOTAL__c, Discount__c, Pricing__c, Preferential_Trading_Price__c, Contract__c,
+                Agency1__c, OCM_Agent1_Price__c, Agency1_Profit__c, Agency1_Profit_Rate__c, Print_HP_Name__c,
+                Agency2__c, Agent1_Agent2_Price__c, Agency2_Profit__c, Agency2_Profit_Rate__c, Quote_No__c,
+                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,
+                Preferential_Gurantee_Period__c,LineItemCount 
+                 ,IsQuoteTrial__c,OpportunityId,Opportunity.RecordType.DeveloperName
+                FROM Quote Where Id = :quoId];
+              quo = quoList[0];
+          }
+      
+      return quo;
+  }
+  //妫�绱㈡姤浠疯椤圭洰琛屾暟
+  @AuraEnabled
+  public static  List<Quote> selectQuoteListLineItemCount(String quoId,String oppId,String copyid){
+      List<Quote> quoList = new  List<Quote>();
+      if(String.isBlank(oppId)){
+          if(String.isNotBlank(quoId)){
+              quoList = [select Id, OpportunityId, Opportunity.RecordType.DeveloperName,LineItemCount From Quote Where Id = :quoId];
+          }
+      }else{
+          if(String.isBlank(copyid)){
+              quoList =[select Id, OpportunityId,LineItemCount From Quote Where OpportunityId = :oppId];
+          }
+      }
+      return quoList;
+  }
+  //妫�绱㈡姤浠疯椤圭洰
+  @AuraEnabled
+  public static  String selectQuoteLineItem(String quoId,String copyid){
+      List<QuoteLineItem> items =
+          [Select Id, Asset_Model_No__c, SFDA_Status__c, Product_Sales_Possibility__c,ProductSetName__c,
+           Name__c, BSS_Category__c, Quote.Quote_Print_Date__c,PricebookEntry.Product2.VenderName__c,PricebookEntry.Product2.CanNotCancelledGurantee__c,PricebookEntry.Product2.Is_DangerousChemicals__c,
+           Qty_Unit__c, Cost__c, UnitPrice__c, ListPrice__c, Quantity, TotalPrice__c,
+           PricebookEntry.Product2.SFDA_Status__c, ProductCode__c, Product_Cost__c, Product_ListPrice__c, PricebookEntry.Product2.Sales_Possibility__c, PricebookEntry.Product2.Name,
+           PricebookEntryId, PricebookEntry.Product2Id, UnitPrice_Page__c, PricebookEntry.Product2.Packing_list_manual__c, PricebookEntry.Product2.StorageStatus__c
+           , AgencyUnitPrice__c, AgencySubtotal__c, Present__c
+           , multiYearWarranty__c , If_Cancel_Guarantee__c , GuaranteePeriod__c,
+           ServicePrice__c , GuranteePrice__c, ProductEntend_gurantee_period_all__c,
+           ProductGuranteePrice__c,  GuranteeType__c,
+           warrantyType__c, productServicePrice__c, NoDiscountTotal__c
+           , provistonPeriod__c
+           , PricebookEntry.Product2.Entend_gurantee_period_all__c
+           , PricebookEntry.Product2.Intra_Trade_Gurantee_RMB__c
+           , PricebookEntry.Product2.Intra_Trade_Service_RMB__c
+           , PricebookEntry.Product2.GuranteeType__c
+           , PricebookEntry.Product2.Maintenance_Price_Year__c
+           , Maintenance_Price_Year__c
+           ,PricebookEntry.Product2.Repair_Contract_USD__c
+           ,PricebookEntry.Product2.Intra_Trade_Foreign_RMB__c
+           ,PricebookEntry.Product2.NoDiscount_Foreign__c 
+           ,PricebookEntry.Product2.LastbuyProductFLG__c
+           //chenjingwu DB202308355043 2023.8.25 start
+           ,PricebookEntry.Product2.Category5__c
+           //chenjingwu DB202308355043 2023.8.25 end
+           ,Quote.Opportunity.Trade__c 
+           ,PricebookEntry.Product2.Estimated_ConsumptionDueDate__c
+           //DB202312560765 you 鍚︽湁EndoRapid璧勮川妫�鏌� start 
+           ,PricebookEntry.Product2.IFEndoRapidFlag__c
+           //DB202312560765 you 鍚︽湁EndoRapid璧勮川妫�鏌� end 
+           From QuoteLineItem where Quoteid = :quoId Order by Item_Order__c, Id];
+      activities = new List<QELine>();
+      QELine cle = new QELine();
+      Integer i = 0;
+      if (items.size() > 0) {
+          for (QuoteLineItem olt : items) {
+              i++;
+              cle = new QELine(olt,i, copyid);
+              activities.add(cle);
+          }
+      }
+      return JSON.serialize(activities)+'---'+JSON.serialize(items);
+  }
+  //妫�绱㈢櫥褰曚汉淇℃伅
+  @AuraEnabled
+  public static  User selecUser(){
+      User usobj =new User();
+      List<User> us = new List<User>();
+      String userid = UserInfo.getUserId();
+      if (userid != null) {
+          us = [Select Id,Quote_Correct__c, Quote_Special_Operation__c, Cost_Referable__c, ViewSpecialAgencyAmout__c,ProfileId From User Where Id = :userid];
+          if (us.size() > 0) {
+              usobj = us[0];
+          }
+      }
+      return usobj;
+  }
+  @AuraEnabled
+  public static Boolean getquoDes() {
+    Schema.DescribeSObjectResult quoteDesc = Quote.SObjectType.getDescribe();
+    return quoteDesc.isUpdateable();
+  }
+  @AuraEnabled
+  public static  Boolean QuotCalfagAss(){
+    String ProfileId= UserInfo.getProfileId().subString(0,15);
+    String QuotationCalculationPermission = System.Label.QuotationCalculationPermission;
+      return QuotationCalculationPermission.contains(ProfileId);
+  }
+  //鏍规嵁璇环Id妫�绱㈣浠�
+  @AuraEnabled
+  public static Opportunity selectOpportunityById(String oppId){
+      Opportunity opp = new Opportunity();
+      List<Opportunity> oppList =[SELECT Account.Name,BusinessFileArchived__c, Account.RecordType.DeveloperName,Opportunity_sub_owner__c,
+             CLBIC_Category__c, HP_Name__c, Name, CurrencyIsoCode, Wholesale_Price__c, Department_Name__c,
+             Direct_Separate__c, Trade__c, AccountId, New_Opportunity__c, Estimation_Decision__c, SAP_Send_OK__c, Sales_Root__c,
+             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
+             , Hospital__c, Department_Class__c
+             ,Is_Corrosion__c,
+             If_Need_PriceApply__c
+             ,CelonOpportunity__c 
+             , If_Account_Change__c 
+             ,Configuration_Suggestion__c , Configuration_Suggestion_Feedback__c
+             , Salesdepartment_Owner__c 
+             ,Opportunity_Category__c
+             FROM Opportunity Where Id = :oppId];
+      if (oppList.size() > 0) {
+          opp = oppList[0];
+      }
+      return opp;
+  }
+  // DB202311242191 銆愭姤浠峰崟銆戞姤浠峰崟鍚堝悓閲戦鏇存柊鍜岀敓鎴愭柊鎶ヤ环鍗曡鍒欑‘璁ゅ拰淇敼 fy start
+  //妫�绱㈣浠疯椤圭洰
+  @AuraEnabled
+  public static  String selectOppLItem(String oppId){
+      List<OpportunityLineItem> items = New List<OpportunityLineItem>();
+      items = [Select Id, Asset_Model_No__c, SFDA_Status__c, Name__c, ProductCode__c, PricebookEntry.Product2.StorageStatus__c,
+               Qty_Unit__c, Cost__c, UnitPrice, ListPrice__c, Quantity, BSS_Category__c, TotalPrice,PricebookEntry.Product2.VenderName__c,PricebookEntry.Product2.CanNotCancelledGurantee__c,PricebookEntry.Product2.Is_DangerousChemicals__c,
+               PricebookEntry.Product2.SFDA_Status__c, Product_Cost__c, Product_ListPrice__c, PricebookEntry.Product2.Sales_Possibility__c, PricebookEntry.Product2.Name,
+               PricebookEntryId, PricebookEntry.Product2Id, Opportunity.Trade__c, PricebookEntry.Product2.Intra_Trade_List_RMB__c, PricebookEntry.Product2.Intra_Trade_Cost_RMB__c,
+               PricebookEntry.Product2.Foreign_Trade_List_US__c, PricebookEntry.Product2.Packing_list_manual__c, PricebookEntry.Product2.Foreign_Trade_Cost_US__c, UnitPrice__c, TotalPrice__c
+               , AgencyUnitPrice__c, AgencySubtotal__c, Present__c
+               , multiYearWarranty__c , If_Cancel_Guarantee__c , GuaranteePeriod__c,
+               ServicePrice__c , GuranteePrice__c,
+               ProductEntend_gurantee_period_all__c,
+               ProductGuranteePrice__c, GuranteeType__c,
+               warrantyType__c, productServicePrice__c,
+               NoDiscountTotal__c
+               , provistonPeriod__c
+               , PricebookEntry.Product2.Entend_gurantee_period_all__c
+               , PricebookEntry.Product2.Intra_Trade_Gurantee_RMB__c
+               , PricebookEntry.Product2.Intra_Trade_Service_RMB__c
+               , PricebookEntry.Product2.GuranteeType__c
+               , PricebookEntry.Product2.Maintenance_Price_Year__c
+               , Maintenance_Price_Year__c
+               ,PricebookEntry.Product2.Repair_Contract_USD__c
+               ,PricebookEntry.Product2.Intra_Trade_Foreign_RMB__c
+               ,PricebookEntry.Product2.NoDiscount_Foreign__c
+              ,PricebookEntry.Product2.Estimated_ConsumptionDueDate__c
+              ,PricebookEntry.Product2.Category5__c
+              //DB202312560765 you 鍚︽湁EndoRapid璧勮川妫�鏌� start 
+              ,PricebookEntry.Product2.IFEndoRapidFlag__c
+              //DB202312560765 you 鍚︽湁EndoRapid璧勮川妫�鏌� end 
+               From OpportunityLineItem
+               Where OpportunityId = :oppId Order by Item_Order__c, Id];
+
+      activities = new List<QELine>();
+      QELine cle = new QELine();
+      Integer i = 0;
+      if (items.size() > 0) {
+          for(OpportunityLineItem otlt : items) {
+            i++;
+            QELine c = new QELine(otlt, i);
+            activities.add(c);
+          }
+      }
+      return JSON.serialize(activities);
+  }
+  // DB202311242191 銆愭姤浠峰崟銆戞姤浠峰崟鍚堝悓閲戦鏇存柊鍜岀敓鎴愭柊鎶ヤ环鍗曡鍒欑‘璁ゅ拰淇敼 fy end
+  //妫�绱骇鍝�
+  @AuraEnabled
+  public static  List<Product2> selectProById(String proList){
+    List<String> product2Ids = (List<String>)JSON.deserialize(proList,List<String>.class);
+    List<Product2> plo  =
+    [Select Id, Estimation_Entry_Possibility__c, SFDA_Status__c,Packing_list_manual__c
+        , Intra_Trade_Gurantee_RMB__c,
+        Intra_Trade_Service_RMB__c
+    From Product2 Where Id IN :product2Ids];
+    return plo;
+  }
+  //妫�绱㈠鎴�
+  @AuraEnabled
+  public static  List<Account> selectAccountById(String accountid){
+      List<Account> accs2 = [Select Id, RecordType.DeveloperName, Hospital__c, Agent_Ref__c From Account Where Id = :accountid];
+      List<Account> accs = new List<Account>();
+      if (accs2.size() > 0) {
+          if (accs2[0].RecordType.DeveloperName != 'AgencyContract') {
+          accs = [Select Id, Name, Site, Alias_Name2__c From Account Where Id = :accs2[0].Hospital__c];
+          } else {
+          accs = [Select Id, Name, Site, Alias_Name2__c From Account Where Id = :accs2[0].Agent_Ref__c];
+          }
+      }
+      return accs;
+  }
+  //妫�绱笅鎷夊垪琛ㄥ��
+  @AuraEnabled
+  public static List<Map<String,String>> getPicklistValues(String objstr, String fld ,Boolean ifempty){
+      List<Map<String,String>> options = new List<Map<String,String>>();
+      Map<String,String> space = new Map<String,String>();
+      if(ifempty){
+          space.put('label', '--鏃�--');
+          space.put('value', '');
+          options.add(space);
+      }
+
+      Schema.sObjectType objType = Schema.getGlobalDescribe().get(objstr);
+      Schema.DescribeSObjectResult objDescribe = objType.getDescribe();
+      map<String, Schema.SObjectField> fieldMap = objDescribe.fields.getMap();
+      list<Schema.PicklistEntry> values = fieldMap.get(fld).getDescribe().getPickListValues();
+      system.debug(objstr + '=' + values);
+      for (Schema.PicklistEntry a : values)
+      {
+          if (!a.isActive()) continue;
+          Map<String,String> ses = new Map<String,String>();
+          ses.put('label', a.getLabel());
+          ses.put('value', a.getValue());
+          options.add(ses);
+      }
+      return options;
+  }
+  @AuraEnabled
+  public static Map<String,String> SaveQuote(String activitiesCan,
+                                String CheckItemCan ,
+                                boolean WinOrDecideAlertc,
+                                boolean productStatusUpdatedc,
+                                String oppInfoc,
+                                boolean enableSalesc,
+                                String quoc,
+                                String oppIdc,
+                                String quoIdc,
+                                boolean newQuoteFlagc,
+                                Boolean changedAfterPrintc,
+                                String quoteGurantee_Periodc,
+                                String quotemultiYearWarrantyc,
+                                String selection_hpc,
+                                Boolean SkipQuotefilgc,
+                                Boolean quoteflg,
+                                // DB202311242191 銆愭姤浠峰崟銆戞姤浠峰崟鍚堝悓閲戦鏇存柊鍜岀敓鎴愭柊鎶ヤ环鍗曡鍒欑‘璁ゅ拰淇敼 fy start
+                                String agency1Namec){
+                                // DB202311242191 銆愭姤浠峰崟銆戞姤浠峰崟鍚堝悓閲戦鏇存柊鍜岀敓鎴愭柊鎶ヤ环鍗曡鍒欑‘璁ゅ拰淇敼 fy end
+      errorflg = false;
+      errormessage = null;
+      errormessagewarn = null;
+      oppId = oppIdc;
+      quoId = quoIdc;
+      // DB202311242191 銆愭姤浠峰崟銆戞姤浠峰崟鍚堝悓閲戦鏇存柊鍜岀敓鎴愭柊鎶ヤ环鍗曡鍒欑‘璁ゅ拰淇敼 fy start
+      agency1Name = agency1Namec;
+      // DB202311242191 銆愭姤浠峰崟銆戞姤浠峰崟鍚堝悓閲戦鏇存柊鍜岀敓鎴愭柊鎶ヤ环鍗曡鍒欑‘璁ゅ拰淇敼 fy end
+      System.debug('quoId+'+quoId);
+      WinOrDecideAlert = WinOrDecideAlertc;
+      productStatusUpdated = productStatusUpdatedc;
+      newQuoteFlag  = newQuoteFlagc;
+      changedAfterPrint = changedAfterPrintc;
+      quoteGurantee_Period = quoteGurantee_Periodc;
+      quotemultiYearWarranty = quotemultiYearWarrantyc;
+      selection_hp = selection_hpc;
+      SkipQuotefilg = SkipQuotefilgc;
+      opp = (Opportunity)JSON.deserialize(oppInfoc,Opportunity.class); 
+      quo = (Quote)JSON.deserialize(quoc,Quote.class); 
+      if(String.isNotBlank(activitiesCan)){
+        activities = (List<QELine>)JSON.deserialize(activitiesCan,List<QELine>.class);
+      }else {
+        activities = null;
+      }
+      if(String.isNotBlank(CheckItemCan)){
+        CheckItem = (List<QuoteLineItem>)JSON.deserialize(CheckItemCan,List<QuoteLineItem>.class);
+      }else {
+        CheckItem = null;
+      }
+      enableSales = enableSalesc;
+      // errorMessagechack = null;
+      setOppFromOppInfo();
+      Savepoint sp = Database.setSavepoint();
+      Map<String,String> result = new Map<String,String>();
+      try {
+        //chenjingwu DB202308355043 2023.8.25 start
+        if(quoteflg){
+          // if (opp.If_Need_Authorize__c == true) {
+          //   ID tmpid = opp.Agency2__c == null ? opp.Agency1__c : opp.Agency2__c;
+          //   List<Account> accName = [select name from Account where id = : tmpid];
+          //   if(accName.size()>0){
+          //     if (accName[0].name != opp.Authorized_Finish_Sales__c) {
+          //       errormessage = '璇峰厛鎺堟潈鍚庯紝鍐嶈繘琛屾姤浠疯绠椼��';
+          //       result.put('errormessage', errormessage);
+          //       return result;
+          //     }
+          //   }
+          // }
+          if(checkVirtual('鍖呭惈铏氭嫙浜у搧锛屾棤娉曟姤浠疯绠�')){
+            result.put('errormessage', errormessage);
+            return result;
+          }
+          //chenjingwu DB202308355043 2023.8.25 start
+        }
+        System.debug('suoding1');
+          if (!dataCheck()) { 
+              result.put('errormessage', errormessage);
+              result = resultFlag(result);
+              return result;
+          }
+          System.debug('suoding2');
+          QuoteConfirm(quoId);
+          System.debug('suoding3');
+          if (dataEntry() == false) {
+              result.put('errormessage', errormessage);
+              return result;
+          } else {
+              result.put('success', System.Label.Message_002);
+              if(String.isBlank(quoId)){
+                result.put('quoId',quoIdreturn);
+              }
+              if(String.isNotBlank(quo.Quote_No__c)){
+                result.put('QuoteNo',quo.Quote_No__c);
+              }
+              if(errormessagewarn != null){
+                result.put('warn', errormessagewarn);
+                String act = JSON.serialize(activities);
+                result.put('act', act);
+              }
+              return result;
+          }
+      } catch (DmlException de) {
+          Database.rollback(sp);
+          // errormessage = de.getLineNumber()+'琛�'+de.getDmlMessage(0);
+          errormessage = de.getDmlMessage(0);
+          result.put('errormessage',errormessage);
+          return result; 
+          // system.debug(Logginglevel.ERROR, de.getMessage());
+          // system.debug(Logginglevel.ERROR, de.getStackTraceString());
+      } catch (Exception e) {
+          Database.rollback(sp);
+          // errormessage = e.getLineNumber()+'琛�'+e.getMessage();
+          errormessage = e.getMessage();
+          result.put('errormessage', errormessage);
+          return result;
+          // system.debug(Logginglevel.ERROR, e.getMessage());
+          // system.debug(Logginglevel.ERROR, e.getStackTraceString());
+      }
+  }
+  public static Map<String,String> resultFlag(Map<String,String> result){
+    if(dfpp){
+      result.put('dfpp', 'dfpp');
+    }
+    if(qname){
+      result.put('qname', 'qname');
+    }
+    if(qacc){
+      result.put('qacc', 'qacc');
+    }
+    if(qaapc){
+      result.put('qaapc', 'qaapc');
+    }
+    if(Agency1){
+      result.put('Agency1', 'Agency1');
+    }
+    if(nAgency1){
+      result.put('nAgency1', 'nAgency1');
+    }
+    if(oapp){
+      result.put('oapp', 'oapp');
+    }
+    if(noapp){
+      result.put('noapp', 'noapp');
+    }
+    if(Agency2){
+      result.put('Agency2', 'Agency2');
+    }
+    if(nAgency2){
+      result.put('nAgency2', 'nAgency2');
+    }
+    if(aapp){
+      result.put('aapp', 'aapp');
+    }
+    if(naapp){
+      result.put('naapp', 'naapp');
+    }
+    return result;
+  }
+  @AuraEnabled
+  public static Map<String,String> Print(String activitiesCan,
+                                    String CheckItemCan ,
+                                    boolean WinOrDecideAlertc,
+                                    boolean productStatusUpdatedc,
+                                    String oppInfoc,
+                                    boolean enableSalesc,
+                                    String quoc,
+                                    String oppIdc,
+                                    String quoIdc,
+                                    boolean newQuoteFlagc,
+                                    Boolean changedAfterPrintc,
+                                    String quoteGurantee_Periodc,
+                                    String quotemultiYearWarrantyc,
+                                    String selection_hpc,
+                                    Boolean SkipQuotefilgc,
+                                    Boolean QuoteDecisionc,
+                                    // DB202311242191 銆愭姤浠峰崟銆戞姤浠峰崟鍚堝悓閲戦鏇存柊鍜岀敓鎴愭柊鎶ヤ环鍗曡鍒欑‘璁ゅ拰淇敼 fy start
+                                    String agency1Namec) {
+                                    // DB202311242191 銆愭姤浠峰崟銆戞姤浠峰崟鍚堝悓閲戦鏇存柊鍜岀敓鎴愭柊鎶ヤ环鍗曡鍒欑‘璁ゅ拰淇敼 fy end
+    oppId = oppIdc;
+    quoId = quoIdc;
+    // DB202311242191 銆愭姤浠峰崟銆戞姤浠峰崟鍚堝悓閲戦鏇存柊鍜岀敓鎴愭柊鎶ヤ环鍗曡鍒欑‘璁ゅ拰淇敼 fy start
+    agency1Name = agency1Namec;
+    // DB202311242191 銆愭姤浠峰崟銆戞姤浠峰崟鍚堝悓閲戦鏇存柊鍜岀敓鎴愭柊鎶ヤ环鍗曡鍒欑‘璁ゅ拰淇敼 fy end
+    System.debug('quoId+'+quoId);
+    WinOrDecideAlert = WinOrDecideAlertc;
+    productStatusUpdated = productStatusUpdatedc;
+    newQuoteFlag  = newQuoteFlagc;
+    changedAfterPrint = changedAfterPrintc;
+    quoteGurantee_Period = quoteGurantee_Periodc;
+    quotemultiYearWarranty = quotemultiYearWarrantyc;
+    selection_hp = selection_hpc;
+    SkipQuotefilg = SkipQuotefilgc;
+    opp = (Opportunity)JSON.deserialize(oppInfoc,Opportunity.class); 
+    quo = (Quote)JSON.deserialize(quoc,Quote.class); 
+    if(String.isNotBlank(activitiesCan)){
+      activities = (List<QELine>)JSON.deserialize(activitiesCan,List<QELine>.class);
+    }else {
+      activities = null;
+    }
+    if(String.isNotBlank(CheckItemCan)){
+      CheckItem = (List<QuoteLineItem>)JSON.deserialize(CheckItemCan,List<QuoteLineItem>.class);
+    }else {
+      CheckItem = null;
+    }
+    enableSales = enableSalesc;
+    QuoteDecision = QuoteDecisionc;
+    Savepoint sp = Database.setSavepoint();
+    Map<String,String> result = new Map<String,String>();
+    try {
+      if(checkVirtual('鍖呭惈铏氭嫙浜у搧锛屾棤娉曟墦鍗�')){
+          result.put('errormessage', errormessage);
+          return result;
+      }
+      setOppFromOppInfo();
+      errorflg = false;
+      errormessage = null;
+      errormessagewarn = null;
+      //Decide鍓峯r寰�
+      if (QuoteDecision == true) {
+        //NoSave
+      } else {
+        if (dataCheck() == false ) {
+          result.put('errormessage', errormessage);
+          result = resultFlag(result);
+          return result;
+        }
+
+        if (dataEntry() == false) {
+          result.put('errormessage', errormessage);
+          return result;
+        }
+      }
+      List<Opportunity> opps = new List<Opportunity>();
+      if (String.isBlank(oppId)) {
+      } else {
+        opps = [Select Id
+                From Opportunity Where Id = : oppId];
+        if (opps.size() > 0) {
+          List<Quote> quos = New List<Quote>();
+          //ligthing bug 淇敼 fy start
+          // if (String.isBlank(quoId)) {
+          // } else {
+          //   quos = [Select Id, 
+          //           Quote_Print_Date__c, Quote_Date__c From Quote Where Id = : quoId];
+          if(String.isNotBlank(quoId)||(String.isBlank(quoId) && String.isNotBlank(quoIdreturn))){
+            String quoIds  = String.isNotBlank(quoId) ? quoId : quoIdreturn;
+            quos = [Select Id, 
+                    Quote_Print_Date__c, Quote_Date__c From Quote Where Id = : quoIds];
+          //ligthing bug 淇敼 fy end
+            if (quos.size() > 0) {
+              //浼樻儬鎴愪氦浠�
+              quos[0].Preferential_Trading_Price__c = quo.Preferential_Trading_Price__c;
+              //浼樻儬鎶樻墸
+              quos[0].Discount__c = quo.Discount__c;
+              //浼樻儬浠锋牸
+              quos[0].Pricing__c = quo.Pricing__c;
+              //鍗曚环
+              quos[0].Unit_Price__c = quo.Unit_Price__c;
+              //鎶ヤ环閲戦
+              quos[0].Offer_Amount__c = quo.Offer_Amount__c;
+              //Total
+              quos[0].TOTAL__c = quo.TOTAL__c;
+              //濂戠磩鍐呭
+              quos[0].Contract__c = quo.Contract__c;
+              //澶氬勾淇濅慨 start
+              quos[0].Preferential_Gurantee_Period__c = quo.Preferential_Gurantee_Period__c;
+              //澶氬勾淇濅慨 end
+              if (quos[0].Quote_Date__c == null) {
+                quos[0].Quote_Date__c = date.Today();
+                opps[0].Estimation_Proposal_Date__c = date.Today();
+                StaticParameter.EscapeOppandStaTrigger = true;
+                update opps[0];
+                StaticParameter.EscapeOppandStaTrigger = false;
+              }
+              quos[0].Quote_Print_Date__c = date.Today();
+              ControllerUtil.updQuote(quos[0]);
+            }
+          }
+        }
+      }
+      // pageArrange();
+      result.put('success', System.Label.Message_002);
+      if(String.isBlank(quoId)){
+        result.put('quoId',quoIdreturn);
+      }
+      if(errormessagewarn != null){
+        result.put('warn', errormessagewarn);
+      }
+      return result;
+    } catch (DmlException de) {
+      Database.rollback(sp);
+      errorflg = true;
+      errormessage = de.getDmlMessage(0);   
+      result.put('errormessage', errormessage);
+      return result;
+      // system.debug(Logginglevel.ERROR, de.getMessage());
+      // system.debug(Logginglevel.ERROR, de.getStackTraceString());
+    } catch (Exception e) {
+      Database.rollback(sp);
+      errorflg = true;
+      errormessage = e.getMessage();
+      result.put('errormessage', errormessage);
+      return result;
+      // system.debug(Logginglevel.ERROR, e.getMessage());
+      // system.debug(Logginglevel.ERROR, e.getStackTraceString());
+    }
+  }
+  // opp銇敾闈€伄鍊ゃ倰瑷畾
+  public static  void setOppFromOppInfo() {
+    opp.Agency1__c = quo.Agency1__c;
+    opp.Agency2__c = quo.Agency2__c;
+  }
+  //淇濆瓨chaeck
+  public static Boolean dataCheck() {
+    errorflg = false;
+    errormessage = null;
+    errormessagewarn = null;
+    Boolean error = false;
+    Boolean error1 = false;
+    integer Gcnt = 0;
+    String lines = '';
+    system.debug(oppId+'^^^^^^^'+lines);
+    if(oppId != null){
+        lines = ControllerUtil.setQuote(oppId);
+    }
+    system.debug(oppId+'^^^^^^^'+lines);
+    if(lines!='Fin'){
+        errorMessage = lines;
+    }
+    if (activities == null || activities.size() <= 0) {
+      errorflg = true;
+      errorMessage = '涓嶅厑璁镐繚瀛樼┖鐨勬姤浠峰崟锛岃閫夋嫨浜у搧';
+      return false;
+    }
+    if (WinOrDecideAlert && (!productStatusUpdated)) {
+        errorflg = true;
+        errorMessage = '浜у搧鐘舵�佸彂鐢熷彉鍖栵紝璇锋洿鏂�';
+        return false;
+    }
+    if (!checkSFDAStatus1(false)) {
+        errorflg = true;
+        errormessage = '璇锋洿鏂颁笉鍙攢鍞殑浜у搧銆�';
+        return false;
+    }
+    List<String> product2Ids = new List<String>();
+    if (activities.size() > 0) {
+      for (QELine a : activities) {
+        if (!String.isBlank(a.pageObject.Id__c)) {
+          product2Ids.add(a.pageObject.Id__c);
+        }
+      }
+      Map<String, String> loopMap = new Map<String, String>();
+      if (CheckItem != null) {
+        Gcnt = CheckItem.size();
+        if (CheckItem.size() > 0) {
+          for (QuoteLineItem qli : CheckItem) {
+            loopMap.put(qli.PricebookEntry.Product2Id, qli.SFDA_Status__c);
+          }
+        }
+      }
+      prd2LatestValMap = new Map<Id, Product2>();
+      integer cntPrd2 = 0;
+      for (Product2 prd2 : [Select Id, Estimation_Entry_Possibility__c, SFDA_Status__c, Packing_list_manual__c,LastbuyProductFLG__c
+                            From Product2 Where Id IN :product2Ids]) {
+        cntPrd2 = cntPrd2   +   1;
+        System.debug('prd2.Estimation_Entry_Possibility__c'+prd2.Estimation_Entry_Possibility__c);
+        if (prd2.Estimation_Entry_Possibility__c != '鈼�') {
+          error1 = true;
+        }
+        if (prd2.Estimation_Entry_Possibility__c == 'M') {
+          error1 = false;
+        }
+        if (prd2.SFDA_Status__c != loopMap.get(prd2.Id)) {
+          WinOrDecideAlert    =   true;
+        }
+
+        prd2LatestValMap.put(prd2.Id, prd2);
+      }
+      if (cntPrd2  !=  Gcnt) {
+        WinOrDecideAlert    =   false;
+      }
+
+    }
+    if(ContractAmountLimitJudge()){
+      return false;
+    }
+    if (error1 == true && WinOrDecideAlert == false) {
+      // PageArrange();
+      errorflg = true;
+      errorMessage = System.Label.Error_Message37;
+      return false;
+    }
+
+    if (checkAgentsDeleteFlag() == false) {
+      return false;
+    }
+    if (enableSales == true && opp.Trade__c == '鍐呰部') {
+      //DB202312560765 you 鍚︽湁EndoRapid璧勮川妫�鏌� 20240523 start
+      Integer ERinerr = 0;
+      Integer NoERinerr = 0;
+      Boolean flager =false;
+      //DB202312560765 you 鍚︽湁EndoRapid璧勮川妫�鏌� 20240523 end
+        Map<Id, String> proMap = new Map<Id, String>();
+        if (activities.size() > 0) {
+            for (QELine qli : activities) {
+                if (qli.Asset_Model != null && qli.Asset_Model != '') {
+                    proMap.put(qli.pageObject.Id__c, qli.pageObject.Name__c);
+                }
+                //DB202312560765 you 鍚︽湁EndoRapid璧勮川妫�鏌� 20240523 start
+                if(qli.IFEndoRapidFlag){
+                  ERinerr ++;
+                }  else if(!qli.IFEndoRapidFlag){
+                  NoERinerr++ ;
+            }
+                //DB202312560765 you 鍚︽湁EndoRapid璧勮川妫�鏌� 20240523 end
+            }
+        }
+        if(ERinerr>0 && NoERinerr ==0){//鍏ㄥ寘
+          flager =true;
+        }
+        Map<String, String> chkMap = OpportunityWebService.MapCheckProRegisterDecide(proMap, opp.Agency1__c, '');
+        if ((chkMap.size() > 0 && !flager )  || System.Test.isRunningTest()) {
+            errorflg = true;
+            if (chkMap.containsKey('agency')) {
+              errorflg = true;
+              errormessage = '绗竴缁忛攢鍟嗘病鏈夋湁鏁堢殑鍖荤枟鍣ㄦ缁忚惀璁稿彲璇併��';
+              // return false;
+            }
+            Integer inerr = 0;
+            if (activities.size() > 0) {
+                for (QELine s : activities) {
+                    if (s.Asset_Model != null && s.Asset_Model != '') {
+                        s.haveno_Register = false;
+                        s.wrong_Register = false;
+                        if (chkMap.containsKey(s.pageObject.Id__c)) {
+                            if (chkMap.get(s.pageObject.Id__c) == '1') {
+                                s.haveno_Register = true;
+                                inerr ++;
+                            } else if (chkMap.get(s.pageObject.Id__c) == '2') {
+                                s.wrong_Register = true;
+                                inerr ++;
+                            }
+                        }
+                    }
+                }
+            }
+            if (inerr > 0) {
+                errorflg = true;
+                errormessagewarn = '璇锋鏌ョ孩瀛楀唴瀹癸紙NMPA鐘舵�佺孩瀛楋紝涓嶅彲閿�鍞骇鍝侊紱浜у搧鍚嶇О绾㈠瓧锛岃秴杩囩粡閿�鍟嗙粡钀ヨ寖鍥达級銆�';
+                // errorMessagechack = '璇锋鏌ョ孩瀛楀唴瀹癸紙NMPA鐘舵�佺孩瀛楋紝涓嶅彲閿�鍞骇鍝侊紱浜у搧鍚嶇О绾㈠瓧锛岃秴杩囩粡閿�鍟嗙粡钀ヨ寖鍥达級銆�';
+            }
+        }
+        //DB202312560765 you 鍚︽湁EndoRapid璧勮川妫�鏌� start 
+        Boolean isEndoRapidError = false;
+        if (activities.size() > 0) {
+          for (QELine qli : activities) {
+              if (qli.Asset_Model != null && qli.Asset_Model != '') {
+                  //鍖呮嫭ER浜у搧锛岀湅缁忛攢鍟嗚祫璐�
+                  if(qli.IFEndoRapidFlag){
+                      isEndoRapidError =true;
+                      //qli.wrong_Register = true;
+                  }
+              }
+          }
+        }
+          //褰撻�夋嫨鐨勪骇鍝佸寘鍚獷R浜у搧鏃讹紝楠岃瘉缁忛攢鍟嗘槸鍚︽湁ER璧勮川
+          if(isEndoRapidError){
+            String str = OpportunityWebService.checkEndoRapid(opp.agency1__c);
+            if (str != 'OK') {
+              errorflg = true;
+              errorMessage = str;
+              return false;
+            } 
+          }
+        //DB202312560765 you 鍚︽湁EndoRapid璧勮川妫�鏌� end 
+        // Boolean isDangerError = false;
+        // Boolean isNotDangerError = false;
+        // if (activities.size() > 0) {
+        //     for (QELine qli : activities) {
+        //         if (qli.Asset_Model != null && qli.Asset_Model != '') {
+        //             if (opp.Is_Corrosion__c) {
+        //                 if(!qli.Is_DangerousChemicals){
+        //                     isNotDangerError =true;
+        //                     qli.wrong_Register = true;
+        //                 }
+        //             }else{
+        //                 if(qli.Is_DangerousChemicals){
+        //                     isDangerError =true;
+        //                     qli.wrong_Register = true;
+        //                 }
+        //             }
+        //         }
+        //     }
+        // }
+        // if (opp.Is_Corrosion__c) {
+        //     String str = OpportunityWebService.checkDangerItem(opp.agency1__c);
+        //     if (str != 'OK') {
+        //       errorflg = true;
+        //       errorMessage = str;
+        //       return false;
+        //     } 
+        //     if(isNotDangerError){
+        //         errorflg = true;
+        //         errormessage = '褰撻樋瑗垮澶氭椂锛岃椤圭洰鐨勪骇鍝佸繀椤诲叏閫夋嫨鍗卞寲鍝併��';
+        //         return false;
+        //     }
+        // }else{
+        //     if(isDangerError){
+        //         errorflg = true;
+        //         errormessage = '褰撹浠蜂笉鏄樋瑗垮澶氭椂锛岃椤圭洰鐨勪骇鍝佷笉鑳介�夋嫨鍗卞寲鍝併��';
+        //         return false;
+        //     }
+        // }
+    }
+    detail = false;
+    if ((quo.QuoteName__c == null) || (quo.QuoteName__c == '')) {
+      // quo.QuoteName__c.addError(System.Label.Error_Message3);
+      String label = Schema.SObjectType.Quote.fields.QuoteName__c.label;
+      error = true;
+      qname = true;
+      errormessage = label+':'+System.Label.Error_Message3;
+    }
+    if (quo.Quote_Adjust_Calculate__c == null) {
+      // quo.Quote_Adjust_Calculate__c.addError(System.Label.Error_Message3);
+      String label = Schema.SObjectType.Quote.fields.Quote_Adjust_Calculate__c.label;
+      error = true;
+      qacc = true;
+      errormessage = label+':'+System.Label.Error_Message3;
+    }
+    if (quo.Quote_Adjust_Amount_Page__c == null) {
+      // quo.Quote_Adjust_Amount__c.addError(System.Label.Error_Message3);
+      String label = Schema.SObjectType.Quote.fields.Quote_Adjust_Amount__c.label;
+      error = true;
+      qaapc = true;
+      errormessage = label+':'+System.Label.Error_Message3;
+    }
+    if (quo.Quote_Expiration_Date__c == null) {
+      // quo.Quote_Expiration_Date__c.addError(System.Label.Error_Message3);
+      String label = Schema.SObjectType.Quote.fields.Quote_Expiration_Date__c.label;
+      error = true;
+      errormessage = label+':'+System.Label.Error_Message3;
+    }
+    //decimal temSalesAmount1 = 0; // 2018/09/28 CHAN-B4YAB8 缁忛攢鍟嗗皬璁″悎璁� end
+    system.debug('activities++++----****2'+activities);
+    Decimal initPrice = 0;
+    for (QELine a : activities) {
+      if ((a.Asset_Model != null) && (a.Asset_Model != '')) {
+        if (a.pageObject.Quantity__c == null || a.pageObject.Quantity__c == 0) {
+          // a.pageObject.Quantity__c.addError(System.Label.Error_Message3);
+          String label = Schema.SObjectType.QuoteLineItem.fields.Quantity__c.label;
+          error = true;
+          errormessage = label+':'+System.Label.Error_Message3;
+        }
+        if (a.pageObject.UnitPrice_Page__c == null) {
+          // a.pageObject.UnitPrice__c.addError(System.Label.Error_Message3);
+          String label = Schema.SObjectType.QuoteLineItem.fields.UnitPrice__c.label;
+          error = true;
+          errormessage = label+':'+System.Label.Error_Message3;
+        }
+        if (a.pageObject.AgencyUnitPrice__c == null) {
+          // a.pageObject.AgencyUnitPrice__c.addError(System.Label.Error_Message3);
+          String label = Schema.SObjectType.QuoteLineItem.fields.AgencyUnitPrice__c.label;
+          error = true;
+          errormessage = label+':'+System.Label.Error_Message3;
+        }
+        if (a.pageObject.PricebookEntryId == null) {
+          error = true;
+          errormessage = System.Label.Error_Message27;
+        }
+        detail = true;
+      }
+      if(a.PageObject.UnitPrice_Page__c!=null){
+        initPrice += (a.VenderName=='OSH'?(a.PageObject.UnitPrice_Page__c*0.45):a.PageObject.UnitPrice_Page__c)*(a.PageObject.Quantity__c==null?0:a.PageObject.Quantity__c);
+      }
+    }
+    System.debug('initPrice'+initPrice);
+    if (enableSales == true) {
+      // LHJ Start
+      String profileId = UserInfo.getProfileId();
+      String SI_2M3_ID = System.Label.SI_2M3_ID_15;
+      String SI_2M3_Id_Bulleti = System.Label.SI_2M3_Id_Bulletin;
+      if(!profileId.left(15).equals(SI_2M3_ID)
+      && !profileId.left(15).equals(SI_2M3_Id_Bulleti)) {
+        if (quo.Agency1__c == null) {
+          // quo.Agency1__c.addError(System.Label.Error_Message3);
+          Agency1 = true;
+          String label = Schema.SObjectType.Quote.fields.Agency1__c.label;
+          error = true;
+          if(String.isNotBlank(errormessage)){
+            errormessage +='\n'+ label+':'+System.Label.Error_Message3;
+          }else {
+          errormessage = label+':'+System.Label.Error_Message3;
+          }
+        }
+      }
+      System.debug('SI_2M3_ID'+SI_2M3_ID);
+      System.debug('SI_2M3_Id_Bulleti'+SI_2M3_Id_Bulleti);
+      System.debug('profileId'+profileId);
+      // LHJ End
+      if (quo.OCM_Agent1_Price_Page__c == null) {
+        // quo.OCM_Agent1_Price__c.addError(System.Label.Error_Message3);
+        quo.OCM_Agent1_Price_Page__c = initPrice;
+        // String label = Schema.SObjectType.Quote.fields.OCM_Agent1_Price__c.label;
+        // error = true;
+        // errormessage = label+':'+System.Label.Error_Message3;
+      } else {
+  
+      }
+      System.debug('error'+error);
+      System.debug('errormessage1'+errormessage);
+    } else {
+  
+      if (opp.Agency1__c != null) {
+        // opp.Agency1__c.addError(System.Label.Error_Message30);
+        String label = Schema.SObjectType.Opportunity.fields.Agency1__c.label;
+        error = true;
+        nAgency1 = true;
+        if(String.isNotBlank(errormessage)){
+          errormessage +='\n'+ label+':'+System.Label.Error_Message30;
+        }else {
+          errormessage = label+':'+System.Label.Error_Message30;
+        }
+      }
+      if (quo.OCM_Agent1_Price_Page__c != null) {
+        // quo.OCM_Agent1_Price__c.addError(System.Label.Error_Message30);
+        noapp = true;
+        String label = Schema.SObjectType.Quote.fields.OCM_Agent1_Price__c.label;
+        error = true;
+        errormessage = label+':'+System.Label.Error_Message30;
+      }
+      if (opp.Agency2__c != null) {
+        // opp.Agency2__c.addError(System.Label.Error_Message30);
+        nAgency2 = true;
+        String label = Schema.SObjectType.Opportunity.fields.Agency2__c.label;
+        error = true;
+        errormessage = label+':'+System.Label.Error_Message30;
+      }
+      if (quo.Agent1_Agent2_Price_Page__c != null) {
+        // quo.Agent1_Agent2_Price__c.addError(System.Label.Error_Message30);
+        naapp = true;
+        String label = Schema.SObjectType.Quote.fields.Agent1_Agent2_Price__c.label;
+        error = true;
+        errormessage = label+':'+System.Label.Error_Message30;
+      }
+  
+    }
+    if (quo.Agency1_Profit_Rate__c >= 1000 || quo.Agency1_Profit_Rate__c <= -1000) {
+      error = true;
+      errormessage = System.Label.Error_Message38;
+    }
+    if (quo.Agency2_Profit_Rate__c >= 1000 || quo.Agency2_Profit_Rate__c <= -1000) {
+      error = true;
+      errormessage = System.Label.Error_Message38;
+    }
+    
+    if (error == true) {
+      errorflg = true;
+      return false;
+    }
+    // PageArrange();
+    errorflg = false;
+    errorMessage = null;
+    return true;
+  }
+  // 浜у搧鐘舵�佸垽鏂�
+  public static boolean checkSFDAStatus1(boolean dodecide) {
+    for (QELine a : activities) {
+      if ((a.Asset_Model != null) && (a.Asset_Model != '')) {
+        if (a.pageObject.SFDA_Status__c != '鏈夊姽' &&
+            a.pageObject.SFDA_Status__c != '鏈夊姽锛堝啀鐢宠珛涓級' &&
+            a.pageObject.SFDA_Status__c != '涓嶈' &&
+            a.pageObject.SFDA_Status__c != '澶卞姽锛堟湡闄愬唴鐢熺敚娓堝湪搴蹇滐級' &&
+            // LHJ CBPR 20181221 Start
+            (a.pageObject.SFDA_Status__c != '鏆傚仠鍑哄簱锛堥暱鏈燂級') &&
+            (a.pageObject.SFDA_Status__c != '鏆傚仠鍑哄簱锛堢煭鏈燂級') &&
+            // LHJ CBPR 20181221 End
+            (a.pageObject.SFDA_Status__c != '澶卞姽锛堝啀鐢宠珛涓級' || dodecide != false)
+           ) {
+          return false;
+        }
+      }
+    }
+    return true;
+  }
+  public static boolean ContractAmountLimitJudge(){
+    if(opp.Sales_Root__c =='OCM鐩存帴閿�鍞�'){
+      return false;
+    }
+    Boolean error = false;
+    Double AccrualTotal=0;
+    Double sumContractAmount =0;
+    for(QELine aaa :activities){
+      // 2022-06-14 绱ф�ヤ慨澶� ssm
+      if (String.isBlank(aaa.Asset_Model)) {
+        continue;
+      }
+      if(aaa.pageObject.PricebookEntry.Product2Id!=null){
+        if(aaa.GuranteePrice==null){
+          aaa.GuranteePrice=0;
+        }
+        AccrualTotal += aaa.pageObject.Quantity__c*aaa.GuranteePrice;
+      }
+    }
+    if(quo.MultiYearWarrantyTotalPrice__c==null){
+      quo.MultiYearWarrantyTotalPrice__c=0;
+    }
+    sumContractAmount = AccrualTotal+quo.MultiYearWarrantyTotalPrice__c;
+    if(quo.OCM_Agent1_Price_Page__c<=sumContractAmount){
+      error = true;
+      errorflg = true;
+      errormessage = '棰勬祴閲戦涓鸿礋鏁帮紝璇锋纭~鍐欏悎鍚岄噾棰濄��';
+    }
+    if(quo.multiYearWarranty__c){
+      if(quo.OCM_Agent1_Price_Page__c<=0){
+        error = true;
+        errorflg = true;
+        errormessage = '棰勬祴閲戦涓鸿礋鏁帮紝璇锋纭~鍐欏悎鍚岄噾棰濄��';
+      }
+    }
+    return error;
+  }
+  public static  Boolean checkAgentsDeleteFlag() {
+    // Check Agents
+    List<Id> accIds = new List<Id>();
+    if (opp.Agency1__c != null) {
+      accIds.add(opp.Agency1__c);
+    }
+    if (opp.Agency2__c != null) {
+      accIds.add(opp.Agency2__c);
+    }
+    if (accIds.size() > 0) {
+      List<Account> agentAccs = [SELECT Id, Delete_Flag__c, Is_Active_Formula__c, Sales_Shop_Class__c FROM Account WHERE Id IN :accIds];
+      String activeFormula1 = null, activeFormula2 = null;
+      for (Account local : agentAccs) {
+        if (local.Sales_Shop_Class__c == '鍖荤枟淇悊缁忛攢鍟�') {
+          // PageArrange();
+          errorflg = true;
+          if (local.Id == opp.Agency1__c) {
+            errorMessage = '璇风‘璁ょ涓�缁忛攢鍟嗙殑缁忛攢鍟嗚祫璐�';
+            return false;
+          }
+        }
+        if (local.Id == opp.Agency1__c) {
+          activeFormula1 = local.Is_Active_Formula__c;
+        }
+      }
+      for (Account local : agentAccs) {
+        if (local.Id == opp.Agency2__c) {
+          activeFormula2 = local.Is_Active_Formula__c;
+        }
+      }
+      if (activeFormula1 == '鏃犳晥' && activeFormula2 == '鏃犳晥') {
+        // PageArrange();
+        errorflg = true;
+        errorMessage = System.Label.Agent1_and_Agent2_were_Deleted;
+        return false;
+      } else if (activeFormula1 == '鏃犳晥') {
+        // PageArrange();
+        errorflg = true;
+        errorMessage = System.Label.Agent1_was_Deleted;
+        return false;
+      } else if (activeFormula2 == '鏃犳晥') {
+        // PageArrange();
+        errorflg = true;
+        errorMessage = System.Label.Agent2_was_Deleted;
+        return false;
+      }
+    }
+     // 鍐呰部銇牬鍚圕heck Agency1
+    if (opp.Agency1__c != null && opp.Trade__c == '鍐呰部') {
+      Account acc = [select Sales_Shop_Class__c, Business_Authorization_No__c, Business_Paper_Expiration_Date__c,
+                    Tax_Practice_No__c, Tax_Practice_Expiration_Date__c, Medical_Equipment_Num__c, Is_Active_Formula__c,
+                    Medical_Equipment_Expiration_Date__c from Account where Id = :opp.Agency1__c];
+      //缁忛攢鍟嗗垎绫诲彧鏈夌壒绾︺�佷竴绾ф垨鑰呴泦涓噰璐墠鍙互杩涜鎶ヤ环
+      List<String> salesClazz = new List<String> {'鐗圭磩璨╁2搴楋紙鍖哄煙锛�', '鐗圭磩璨╁2搴楋紙瑁藉搧锛�', '鐗圭磩璨╁2搴楋紙瑁藉搧+鍖哄煙锛�', '涓�绱氳博澹插簵', '闆嗛噰缁忛攢鍟�'};
+      // 鏈夋晥/鏃犳晥锛堝叕寮忥級!= 鏈夋晥
+      if (acc.Is_Active_Formula__c != '鏈夋晥') {
+        // PageArrange();
+        errorflg = true;
+        errorMessage = '璇烽�夋嫨鏈夋晥鐨勭粡閿�鍟�';
+        return false;
+      }
+      else if(!salesClazz.contains(acc.Sales_Shop_Class__c)){
+        // PageArrange();
+        errorflg = true;
+        errorMessage = '缁忛攢鍟�1鐨勭粡閿�鍟嗗垎绫讳负锛氱壒绾︼紝涓�绾э紝闆嗕腑閲囪喘鎵嶅彲浠ユ姤浠�';
+        return false;
+      }else if (!(String.isBlank(acc.Tax_Practice_No__c) == false
+                && (acc.Tax_Practice_Expiration_Date__c == null || acc.Tax_Practice_Expiration_Date__c >= Date.today())
+                && String.isBlank(acc.Medical_Equipment_Num__c) == false
+                && acc.Medical_Equipment_Expiration_Date__c != null && acc.Medical_Equipment_Expiration_Date__c >= Date.today()
+                && String.isBlank(acc.Business_Authorization_No__c) == false
+                && acc.Business_Paper_Expiration_Date__c != null && acc.Business_Paper_Expiration_Date__c >= Date.today())
+              ) {
+        // PageArrange();
+        errorflg = true;
+        errorMessage = '璇风‘璁ょ涓�缁忛攢鍟嗙殑缁忛攢鍟嗚祫璐�';
+        return false;
+      }else {}
+    }
+    return true;
+  }
+  //淇濆瓨閫昏緫
+  public static boolean dataEntry() {
+    system.debug('activities++++----****3'+activities);
+    Boolean ifdecide=checkIsDecide();
+    standardPricebook = ControllerUtil.getStandardPricebook();
+    if(!ifdecide){
+      
+      List<Quote> maxQuote_No = [select Quote_No__c From Quote Where OpportunityId = :oppid and (not Quote_No__c like '%Old') order by Quote_No_last2__c desc NULLS LAST limit 1];
+      String oppNo;
+      Integer l = 1;
+      if (maxQuote_No.size() > 0) {
+        try {
+          oppNo = maxQuote_No[0].Quote_No__c;
+          l = Integer.valueOf(oppNo.substring(oppNo.length() - 2)) + 1;
+        } catch (System.TypeException e) {
+          system.debug('maxQuote_No Error: quote.id=' + maxQuote_No[0].id);
+        }
+      } else {
+        system.debug('first Quote');
+      }
+      oppNo = '00' + String.valueof(l);
+      oppNo = oppNo.substring(oppNo.length() - 2);
+
+      Quote q = New Quote();
+      if (changedAfterPrint) {
+        system.debug('id绌�1锛�');
+        quoId = null;
+        SkipQuotefilg = true;
+      }
+      // if (changedAfterBid) {
+      //   system.debug('id绌�1锛�');
+      //   quoId = null;
+      //   SkipQuotefilg = true;
+      // }
+      // CHAN-AVG3PW 璇环鎶ヤ环鐢婚潰瑙勫垯鍙樻洿
+      // if (quo.CreatedByid !=null && quo.CreatedByid != UserInfo.getUserId() ){
+      //   system.debug('id绌�3锛�');
+      //   quoId = null;
+      //   SkipQuotefilg = true;
+      // }
+      if ((quoteGurantee_Period != null &&
+        !quoteGurantee_Period.equals(quo.Gurantee_Period__c))
+        ||
+        (quotemultiYearWarranty != null &&
+        !quotemultiYearWarranty.equals('' + quo.multiYearWarranty__c))
+        // DB202311242191 銆愭姤浠峰崟銆戞姤浠峰崟鍚堝悓閲戦鏇存柊鍜岀敓鎴愭柊鎶ヤ环鍗曡鍒欑‘璁ゅ拰淇敼 fy start
+        ||
+        (agency1Name !=null &&!agency1Name.equals(quo.Agency1__c)&&quo.IsQuoteTrial__c)
+        // DB202311242191 銆愭姤浠峰崟銆戞姤浠峰崟鍚堝悓閲戦鏇存柊鍜岀敓鎴愭柊鎶ヤ环鍗曡鍒欑‘璁ゅ拰淇敼 fy end
+      ) {
+        system.debug('id绌�8锛�');
+        quoId = null;
+        SkipQuotefilg = true;
+      }
+      if (String.isBlank(quoId)) {
+        system.debug('standardPricebook锛�'+standardPricebook);
+        q = New Quote();
+        q.OpportunityId = oppId;
+        if (detail == true) {
+          if (standardPricebook == null) {
+            errormessage = System.Label.Error_Message27;
+            errorflg = true;
+            return false;
+          } else {
+            q.Pricebook2Id = standardPricebook.Id;
+          }
+        }
+      } else {
+        List<Quote> qs = New List<Quote>();
+        qs = [select Id, OpportunityId, CreatedDate, Pricebook2Id, Name, Estimation_List_Price__c, Dealer_Final_Price__c,QuotationChange__c,MainEngineWithoutMonitor__c,Interdepartmental__c,
+              Stocking_Price__c, Discount_Amount__c, Discount_Amount_Calculate__c, Quote_Adjust_Amount__c, Quote_Adjust_Calculate__c,
+              Agency1__c, OCM_Agent1_Price__c, Agency1_Profit__c, Agency1_Profit_Rate__c, Quote_No__c,
+              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
+              , Preferential_Gurantee_Period__c
+              ,IsQuoteTrial__c 
+              ,HasType2Machine__c //20240416 DB202312560765 you 鏄惁鏈塃ndoRapid璧勮川
+              From Quote Where Id = :quoId];
+        if (qs.size() > 0) {
+          q = qs[0];
+        }
+        if (q.Pricebook2Id == null) {
+          if (detail == true) {
+            if (standardPricebook == null) {
+              errormessage = System.Label.Error_Message27;
+              errorflg = true;
+              return false;
+            } else {
+              q.Pricebook2Id = standardPricebook.Id;
+            }
+          }
+        }
+      }
+      if (String.isBlank(quoId)) {
+        q.Quote_No__c = opp.Opportunity_No__c + '-' + oppNo;
+        q.PriceRefreshDate__c = Date.today();
+      }
+      if (productStatusUpdated) {
+        q.PriceRefreshDate__c = Date.today();
+      }
+      List<String> pIds = new List<String>();
+      system.debug('activities++++----****1'+activities);
+      for (QELine s : activities) {
+        if (String.isBlank(s.pageObject.Id__c) == false) {
+          pIds.add(s.pageObject.Id__c);
+        }
+      }
+      //20240416 DB202312560765 you 鏄惁鏈塃ndoRapid璧勮川 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 鏄惁鏈塃ndoRapid璧勮川 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;
+      q.OCM_Sales_Forecast__c = quo.OCM_Sales_Forecast__c;//棰勬祴閲戦淇敼 fy
+      q.Stocking_Price__c = quo.Stocking_Price__c;
+      q.Quote_Adjust_Amount__c = quo.Quote_Adjust_Amount_Page__c;
+      q.Quote_Adjust_Calculate__c = quo.Quote_Adjust_Calculate__c;
+      q.Discount_Amount__c = quo.Discount_Amount__c;
+      q.Discount_Amount_Calculate__c = quo.Discount_Amount_Calculate__c;
+      q.Agency1__c = opp.Agency1__c;
+      q.OCM_Agent1_Price__c = quo.OCM_Agent1_Price_Page__c;
+      q.Agency1_Profit__c = quo.Agency1_Profit__c;
+      q.AgencyDiscount__c  = quo.AgencyDiscount__c;
+      q.Gurantee_Period__c = quo.Gurantee_Period__c;
+      q.multiYearWarranty__c = quo.multiYearWarranty__c;
+      q.MultiYearWarrantyTotalPrice__c = quo.MultiYearWarrantyTotalPrice__c;
+      q.quoteSavedDate__c = Date.today();
+      q.Agency1_Profit_Rate__c = quo.Agency1_Profit_Rate__c;
+      q.Agency2__c = opp.Agency2__c;
+      q.Agent1_Agent2_Price__c = quo.Agent1_Agent2_Price_Page__c;
+      q.Agency2_Profit__c = quo.Agency2_Profit__c;
+      q.Agency2_Profit_Rate__c = quo.Agency2_Profit_Rate__c;
+      q.Opportunity_sub_owner__c = opp.Opportunity_sub_owner__c;
+      q.Print_HP_Name__c = selection_hp;
+      q.Quote_Expiration_Date__c = quo.Quote_Expiration_Date__c;
+      q.Quote_Comment__c = quo.Quote_Comment__c;
+      q.Installation_location__c = quo.Installation_location__c;
+      q.QuotationChange__c = quo.QuotationChange__c;
+      q.MainEngineWithoutMonitor__c = quo.MainEngineWithoutMonitor__c;
+      q.Interdepartmental__c = quo.Interdepartmental__c;
+      if(!quo.IsQuoteTrial__c){
+        q.IsQuoteTrial__c = quo.IsQuoteTrial__c;
+      }
+      //chenjingwu DB202308355043 2023.8.25 start
+      List<Id> idList = new List<Id>();
+      for (QELine s : activities) {
+        if (String.isNotBlank(s.pageObject.PricebookEntryId)) {
+          idList.add(s.pageObject.PricebookEntryId);
+        }
+      }
+      List<PricebookEntry> pb = [select Id from PricebookEntry where Product2.Category5__c = '铏氭嫙' and Id in: idList];
+      q.Have_Virtual__c = false;
+      if(pb.size() > 0){
+        q.Have_Virtual__c = true;
+      }
+    //chenjingwu DB202308355043 2023.8.25 end
+      if (String.isBlank(quoId)) {
+        insert q;
+        quo.Quote_No__c = q.Quote_No__c;
+        // quo.IsQuoteTrial__c = q.IsQuoteTrial__c;
+        // isQuoteTrialOnInit = q.IsQuoteTrial__c;
+      } else {
+        update q;
+      }
+      List<QuoteLineItem> qlist = New List<QuoteLineItem>();
+      qlist = [Select Id From QuoteLineItem Where QuoteId = :quoId];
+      if (qlist.size() > 0) {
+        delete qlist;
+      }
+      qlist = New List<QuoteLineItem>();
+      List<String> product_lines = new List<String>();
+      Boolean Is_Eng2_Opp = false;
+      Integer i = 1;
+      if (activities.size() > 0) {
+        system.debug('activities++++----****'+activities);
+        for (QELine s : activities) {
+          if (s.Asset_Model != null && s.Asset_Model != '') {
+            if (s.pageObject.PricebookEntryId != null) {
+              QuoteLineItem ql = s.pageObject.clone();
+              ql.Quantity = ql.Quantity__c;
+              ql.UnitPrice = 0;         
+              ql.QuoteId = q.Id;
+              ql.ProductSetName__c = s.Product_Set_Name;
+              ql.Name__c = s.pageObject.Name__c;
+              ql.Cost__c = s.Cost_c;
+              ql.Cost_Subtotal__c = s.Cost_Subtotal_c;
+              // s.pageObject.Cost__c = s.Cost_c;
+              // s.pageObject.Cost_Subtotal__c = s.Cost_Subtotal_c;
+              ql.UnitPrice__c = ql.UnitPrice_Page__c;
+              ql.UnitPrice_Page__c = 0;
+              ql.ListPrice__c = s.ListPrice_Page;
+              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.SFDA_Status__c = prd2LatestValMap.get(s.pageObject.Id__c).SFDA_Status__c;
+              ql.Item_Order__c = i;//棰勬祴閲戦淇敼 fy
+              if (s.pageObject.Subtotal__c != null && quo.OCM_Sales_Forecast__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_Sales_Forecast__c * (s.pageObject.Subtotal__c / quo.QuoteTotal_Page__c);
+                }
+              }
+              qlist.add(ql);
+              product_lines.add(s.pageObject.PricebookEntryId);
+              i++;
+            }
+          }
+        }
+        system.debug('qlist+++---+++'+qlist);
+        insert qlist;
+      }
+      system.debug('鈼嬧棆鈼嬧棆鈼婼ave2鈼嬧棆鈼嬧棆鈼�');
+      List<PricebookEntry> entrys = product_lines!= null && product_lines.size() > 0 ? [select Id from PricebookEntry where Id in :product_lines and Product2.ENG_New__c = 'ENG2'] : null;
+      Is_Eng2_Opp = entrys != null && entrys.size() > 0 ? true : false;
+      Opportunity o = New Opportunity();
+      List<Opportunity> os = New List<Opportunity>();
+      os = [select Id, Estimation_List_Price__c, Dealer_Final_Price__c, Estimation_List_Price_Without_Tax__c,
+            Stock_Submit_Date__c,Stock_Confrim_Date__c,
+            Agency1__c, OCM_Agent1_Price__c, Agency1_Profit__c, Agency1_Profit_Rate__c, Stocking_Price__c,
+            Agency2__c, Agent1_Agent2_Price__c, Agency2_Profit__c, Agency2_Profit_Rate__c, Quote_Update_Sum__c , Hospital__c,Is_Corrosion__c 
+            ,StageName ,OlyNumberHosts__c
+            From Opportunity Where Id = :oppid];
+      if (os.size() > 0) {
+        o = os[0];
+        o.Estimation_List_Price__c = quo.Estimation_List_Price__c;
+        o.Wholesale_Price__c = q.OCM_Sales_Forecast__c;//棰勬祴閲戦淇敼 fy
+        o.Dealer_Final_Price__c = quo.Dealer_Final_Price_Page__c;
+        o.Agency1__c = opp.Agency1__c;
+        o.OCM_Agent1_Price__c = quo.OCM_Agent1_Price_Page__c;
+        o.Agency1_Profit__c = quo.Agency1_Profit__c;
+        o.Agency1_Profit_Rate__c = quo.Agency1_Profit_Rate__c;
+        o.Agency2__c = opp.Agency2__c;
+        o.Agent1_Agent2_Price__c = quo.Agent1_Agent2_Price_Page__c;
+        o.Agency2_Profit__c = quo.Agency2_Profit__c;
+        o.Agency2_Profit_Rate__c = quo.Agency2_Profit_Rate__c;
+        o.Stocking_Price__c = quo.Stocking_Price__c;
+        o.Estimation_No__c = q.Quote_No__c;
+        o.Estimation_Name__c = q.Name;
+        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 鏄惁鏈塃ndoRapid璧勮川
+        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.quoteSavedDate__c = Date.today();
+        // o.OlyNumberHosts__c = 0;
+        // List<String> oppIds = New List<String>();
+        // List<String> product2Ids = New List<String>();
+        // Map<String,Decimal> product2IdsMap = new Map<String,Decimal>();
+        // if (activities.size() > 0) {
+        //   for (QELine a : activities) {
+        //     if(String.isBlank(a.pageObject.Id__c) == false) {
+        //       product2Ids.add(a.pageObject.Id__c);
+        //       product2IdsMap.put(a.pageObject.Id__c,a.pageObject.Quantity__c);
+        //     }
+        //   }
+        //   for (Product2 prod : [Select Id,ProductClass__c From Product2 Where Id IN :product2Ids]) {
+        //     if(o.StageName == '寮曞悎' || o.StageName == '娉ㄦ畫' || o.StageName == '鍑鸿嵎' || o.StageName == '瀹屼簡'){
+        //       if(prod.ProductClass__c == '涓绘満'){
+        //         if(product2IdsMap.containsKey(prod.Id)){
+        //           o.OlyNumberHosts__c += product2IdsMap.get(prod.Id);
+        //           oppIds.add(o.Id);
+        //           ControllerUtil.UpdateBiddingFlag(oppIds);
+        //         }
+        //       }else{
+        //         o.OlyNumberHosts__c += 0;
+        //       }
+        //     }
+        //   }
+        // }
+        if(quoId==null && UserInfo.getProfileId() != System.Label.ProfileId_2S6){
+          o.Stock_Submit_Date__c = null;
+          o.Stock_Confrim_Date__c = null;
+        }
+        if (o.Quote_Update_Sum__c == null) {
+          o.Quote_Update_Sum__c = 1;
+        } else {
+          o.Quote_Update_Sum__c = o.Quote_Update_Sum__c + 1;
+        }
+        o.ENG2_Opp__c = Is_Eng2_Opp;
+        StaticParameter.EscapeOppandStaTrigger = true;
+        update o;
+
+  
+        //OpportunityLineItem--------------------------------------------
+        List<OpportunityLineItem> ols = New List<OpportunityLineItem>();
+        OpportunityLineItem ol = New OpportunityLineItem();
+        ols = [select Id, Quantity from OpportunityLineItem Where OpportunityId = :oppid];
+        if (ols.size() > 0) {
+          ControllerUtil.delOppLine(ols);
+        }
+        i = 1;
+        ols = New List<OpportunityLineItem>();
+        if (activities.size() > 0) {
+          for (QELine s : activities) {
+            if (s.Asset_Model != null && s.Asset_Model != '') {
+              if (s.pageObject.PricebookEntryId != null) {
+                ol = New OpportunityLineItem();
+                ol.OpportunityId = oppid;
+                ol.Id__c = s.pageObject.Id__c;
+                // ol.SFDA_Status__c = s.pageObject.SFDA_Status__c;
+                ol.SFDA_Status__c = prd2LatestValMap.get(s.pageObject.Id__c).SFDA_Status__c;
+                ol.Name__c = s.pageObject.Name__c;
+                ol.ListPrice__c = s.ListPrice_Page;
+                ol.Quantity = s.pageObject.Quantity__c;
+                ol.UnitPrice = 0;
+                ol.UnitPrice__c = s.pageObject.UnitPrice_Page__c;
+                ol.AgencyUnitPrice__c =  s.pageObject.AgencyUnitPrice__c;
+                ol.Present__c =  s.pageObject.Present__c;
+                ol.AgencySubtotal__c =  s.pageObject.AgencySubtotal__c;
+                ol.GuaranteePeriod__c =  s.pageObject.GuaranteePeriod__c;
+                if (opp.CurrencyIsoCode != null ) {
+                  ol.multiYearWarranty__c =  s.pageObject.multiYearWarranty__c;
+                  ol.ServicePrice__c =  s.pageObject.ServicePrice__c;
+                  ol.If_Cancel_Guarantee__c =  s.pageObject.If_Cancel_Guarantee__c;
+                  ol.ProductEntend_gurantee_period_all__c
+                    =  s.pageObject.ProductEntend_gurantee_period_all__c;
+                  ol.GuranteeType__c =  s.pageObject.GuranteeType__c;
+                  ol.NoDiscountTotal__c =  s.pageObject.NoDiscountTotal__c;
+                  ol.warrantyType__c =  s.pageObject.warrantyType__c;
+                  ol.productServicePrice__c =  s.pageObject.productServicePrice__c;
+                  ol.GuranteePrice__c        = s.GuranteePrice;
+                  ol.ProductGuranteePrice__c = s.ProductGuranteePrice;
+                  ol.Maintenance_Price_Year__c = s.Maintenance_Price_Year;
+                  ol.provistonPeriod__c = s.pageObject.provistonPeriod__c;
+                }
+                ol.Qty_Unit__c = s.pageObject.Qty_Unit__c;
+                ol.Cost__c = s.pageObject.Cost__c;
+                ol.BSS_Category__c = s.pageObject.BSS_Category__c;
+                ol.CanNotCancelFlag__c = s.CanNotCancelledGurantee;//棰勬祴閲戦淇敼 fy
+                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);
+                  }
+                }
+                ol.PricebookEntryId = s.pageObject.PricebookEntryId;
+                ol.Item_Order__c = i;
+                ols.add(ol);
+                i++;
+              }
+            }
+          }
+          ControllerUtil.insOppLine(ols);
+        }
+
+      } else {
+        system.debug('*****SystemError OpportunityId is Null*****');
+      }
+      if (String.isBlank(quoId)) {
+        quoIdreturn = q.Id;
+        // newQuoteFlag = false;
+      } 
+    }else{
+      errorflg = true;
+      errormessage = '璇ヨ浠峰凡缁廳ecide锛屼笉鍙啀淇敼';
+      return false;
+    }
+    return true;
+  }
+  //闃叉澶氬紑椤甸潰鍔犻獙璇佹煡璇�
+  private static boolean checkIsDecide() {
+    List<Opportunity> oppsde = [Select Id, Estimation_Decision__c From Opportunity Where Id = : oppId];
+    if (oppsde.size() > 0) {
+      if(oppsde[0].Estimation_Decision__c){
+        return true;
+      }
+    }
+    return false;
+  }
+  //妫�绱㈡柊寤烘姤浠蜂骇鍝�
+  @AuraEnabled
+  public static List<PricebookEntry> serContact(String tradec,String SearchName,String celon){
+      trade = tradec;
+      String x = '脳';
+      String searchSql = 'select Id,Product2Id,Product2.Name,Product2.ProductCode,Product2.StorageStatus__c,Product2.OT_CODE_no_link__c, Product2.Alternative_Products__c, '
+                      + 'Product2.Foreign_Trade_Cost_US__c, Product2.Foreign_Trade_List_US__c, Product2.Intra_Trade_Cost_RMB__c, Product2.Intra_Trade_List_RMB__c, '
+                      + 'Product2.Asset_Model_No__c, Product2.Serial_Lot_No__c, Product2.Sales_Possibility__c, Product2.Estimation_Entry_Possibility__c, '
+                      + 'Product2.SFDA_Status__c, Product2.Qty_Unit__c, Product2.BSSCategory__c, Product2.Asset_loaner_category__c, Product2.Packing_list_manual__c '
+                      + ' ,Product2.Extend_new_product_gurantee_MD__c , Product2.Extend_new_product_gurantee__c , Product2.Entend_gurantee_period_all__c , '
+                      + '  Product2.Intra_Trade_Gurantee_RMB__c  '
+                      + ',Product2.Intra_Trade_Foreign_RMB__c,Product2.NoDiscount_Foreign__c,Product2.Repair_Contract_USD__c '
+                      + ' , 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 '
+                      //chenjingwu DB202308355043 2023.8.25 start
+                      + ' , Product2.Category5__c '
+                      //chenjingwu DB202308355043 2023.8.25 end
+                      //DB202312560765 you 鍚︽湁EndoRapid璧勮川妫�鏌� start 
+                      + ' , Product2.IFEndoRapidFlag__c '
+                      //DB202312560765 you 鍚︽湁EndoRapid璧勮川妫�鏌� end 
+                      + ' , Product2.Estimated_ConsumptionDueDate__c '
+                      + 'FROM PricebookEntry ';
+      String whereStr = 'Where Product2.Asset_Model_No__c != null And Product2.Manual_Entry__c = false And Product2.Estimation_Entry_Possibility__c !=' + '\'' + x + '\' '
+                      + 'AND CurrencyIsoCode =' + '\'' + String.escapeSingleQuotes(trade) + '\' '
+                      + 'AND IsActive = true ';
+      String whereSql = '';
+      if (searchMode == 'CS') {
+          whereSql += 'and Product2.Asset_loaner_category__c = \'涓鸿�楁潗绠$悊\' ';
+      }
+      if (SearchName != null && SearchName != '') {
+          String likename = String.escapeSingleQuotes(SearchName);
+          String prdcd = String.escapeSingleQuotes(SearchName);
+          if (likename.indexOf('*') >= 0) {
+              likename = likename.replace('*', '%');
+          } else {
+              likename = '%' + likename + '%';
+          }
+          whereSql += 'and (Product2.Name Like ' + '\'' + likename + '\' or Product2.ProductCode = ' + '\'' + prdcd + '\' or Product2.Asset_Model_No__c Like ' + '\'' + likename + '\') ';
+      }
+      celon = String.isNotBlank(celon) ? celon : null;
+      whereSql += ' and Product2.Celon_Product__c = :celon ';
+      searchSql = searchSql + whereStr + whereSql;
+      searchSql += ' order by Product2.Asset_Model_No__c Limit 450';
+      List<PricebookEntry> pbes = Database.query(searchSql);
+      return pbes;
+  }
+  //妫�绱骇鍝侀厤濂�
+  @AuraEnabled
+  public static List<Product_Set__c> serSetContact(String SearchName,String SearchCode,String filterName){
+    String searchSql = 'Select id, name, Price__c, Product_Set_CD__c, Quantity__c,Valid_Status__c,Quote_Select_Info__c From Product_Set__c ';
+    String whereStr = 'Where Valid_Status__c = true ';
+    String whereSql = '';
+    if(SearchName != null && SearchName != ''){
+      whereSql += 'and name Like ' + '\'%' + SearchName + '%\' ';
+    }
+    if(filterName != null && filterName != ''){
+      whereSql += 'and Applicable_Department__c =\'' + filterName + '\'';
+    }
+    if(SearchCode != null && SearchCode != ''){
+      whereSql += 'and Product_Set_CD__c like ' + '\'%' + SearchCode + '%\' ';
+    }
+    searchSql = searchSql + whereStr + whereSql;
+    searchSql += ' order by Product_Set_CD__c limit 500';
+    List<Product_Set__c> cl = Database.query(searchSql);
+    return cl;
+  }
+  //浜у搧妫�绱㈤厤濂楄祴鍊�
+  @AuraEnabled
+  public static String setProductEntry(String setProduct_text,
+                                      String activitiesCan,
+                                      String oppInfoc,
+                                      String quoc) {
+    if(String.isNotBlank(activitiesCan)){
+      activities = (List<QELine>)JSON.deserialize(activitiesCan,List<QELine>.class);
+    }else {
+      activities = null;
+    }
+    quo = (Quote)JSON.deserialize(quoc,Quote.class); 
+    opp = (Opportunity)JSON.deserialize(oppInfoc,Opportunity.class); 
+    setOppFromOppInfo();
+    List<String> productIDLIST = new List<String>();
+    if (setProduct_text == null) {
+      // PageArrange();
+      return JSON.serialize(activities);
+    } else {
+      productIDLIST = setProduct_text.split(',');
+    }
+    System.debug('productIDLIST-c++'+productIDLIST);
+    List<Id> productIds = null;
+    //DB202312560765 you 鍚︽湁EndoRapid璧勮川妫�鏌� start  澧炲姞IFEndoRapidFlag__c
+    List<Product_Set_Detail__c> productSetDetails = [SELECT Id, Product__c, Quantity__c, Product_Set__r.Name,Product__r.VenderName__c,Product__r.CanNotCancelledGurantee__c,Product__r.Is_DangerousChemicals__c,Product__r.Estimated_ConsumptionDueDate__c, Product__r.IFEndoRapidFlag__c FROM Product_Set_Detail__c Where Product_Set__c in :productIDLIST];
+    //DB202312560765 you 鍚︽湁EndoRapid璧勮川妫�鏌� end
+    if (productSetDetails.size() == 0) {
+      // PageArrange();
+      return JSON.serialize(activities);
+    } else {
+      productIds = new List<Id>();
+      for (Product_Set_Detail__c local : productSetDetails) {
+        productIds.add(local.Product__c);
+      }
+    }
+    System.debug('productIds++'+productIds);
+    System.debug('activities++'+activities);
+    tmpactivities = activities;
+    activities = new List<QELine>();
+    boolean lineflg = false;
+    Map<Id, Product2> items = new Map<Id, Product2>();
+    List<Product2> products = [select Id, Name, ProductCode,
+                               Foreign_Trade_Cost_US__c, Foreign_Trade_List_US__c, Intra_Trade_Cost_RMB__c, Intra_Trade_List_RMB__c,
+                               Asset_Model_No__c, Sales_Possibility__c, Estimation_Entry_Possibility__c,VenderName__c,
+                               SFDA_Status__c, Qty_Unit__c, BSSCategory__c, Packing_list_manual__c, StorageStatus__c
+                               , Entend_gurantee_period_all__c
+                               , Intra_Trade_Gurantee_RMB__c
+                               , Intra_Trade_Service_RMB__c
+                               , GuranteeType__c
+                               , Maintenance_Price_Year__c
+                               ,CanNotCancelledGurantee__c
+                               ,Is_DangerousChemicals__c
+                               ,Repair_Contract_USD__c
+                               ,LastbuyProductFLG__c
+                               ,Intra_Trade_Foreign_RMB__c
+                               ,NoDiscount_Foreign__c
+                               //chenjingwu DB202308355043 2023.8.25 start
+                               ,Category5__c
+                               //chenjingwu DB202308355043 2023.8.25 end
+                              ,Estimated_ConsumptionDueDate__c
+                              //DB202312560765 you 鍚︽湁EndoRapid璧勮川妫�鏌� start 
+                              ,IFEndoRapidFlag__c
+                              //DB202312560765 you 鍚︽湁EndoRapid璧勮川妫�鏌� end
+                               FROM Product2 Where Id IN :productIds
+                               And Manual_Entry__c = false];
+    for (Product2 product : products) {
+      items.put(product.Id, product);
+    }
+    System.debug('items++'+items);
+    Map<Id, PricebookEntry> entries = new Map<Id, PricebookEntry>();
+    List<PricebookEntry> workEntries = [
+                                         SELECT Id, Product2Id
+                                         FROM PricebookEntry Where Product2Id IN :productIds
+                                         AND CurrencyIsoCode = :(opp.Trade__c == '澶栬部' ? 'USD' : 'CNY')
+                                             AND IsActive = true
+                                       ];
+    for (PricebookEntry workEntry : workEntries) {
+      entries.put(workEntry.Product2Id, workEntry);
+    }
+    System.debug('entries-c++'+entries);
+    Integer i = 1;
+    Integer rightcnt = 0;
+    for (QELine t : tmpactivities) {
+      QELine a = New QELine();
+      a.lineNo = i;
+      System.debug('i-c++'+i);
+        a = t;
+        a.lineNo = i;
+        activities.add(a);
+
+      i++;
+    }
+    if (items.size() > 0) {
+      System.debug('productSetDetails-c++'+productSetDetails);
+      for (Integer l = 0; l < productSetDetails.size(); l++) {
+        Product_Set_Detail__c nowDetail = productSetDetails[l];
+        Product2 prd = items.get(nowDetail.product__c);
+        PricebookEntry pbe = entries.get(nowDetail.product__c);
+        if (pbe == null) {
+        } else {
+          QELine c = null;
+          Integer Quantity_c = nowDetail.Quantity__c > 0 ? Integer.valueOf(nowDetail.Quantity__c) : 1;
+          if (opp.Trade__c == '澶栬部') {
+            if (prd.Foreign_Trade_List_US__c > 0 && prd.Foreign_Trade_Cost_US__c > 0) {
+              c = new QELine(i, prd.Is_DangerousChemicals__c,prd.CanNotCancelledGurantee__c,prd.VenderName__c,
+                            prd.Estimated_ConsumptionDueDate__c,nowDetail.Product_Set__r.Name,
+                            pbe.Id, prd.Asset_Model_No__c, prd.StorageStatus__c,
+                             prd.ProductCode, nowDetail.product__c, prd.SFDA_Status__c,
+                             prd.Sales_Possibility__c, prd.Name, prd.BSSCategory__c,
+                             Quantity_c, prd.Foreign_Trade_List_US__c,
+                             prd.Foreign_Trade_List_US__c, prd.Foreign_Trade_Cost_US__c,
+                             prd.Packing_list_manual__c
+                             , prd.Entend_gurantee_period_all__c
+                             , prd.Intra_Trade_Foreign_RMB__c
+                             , prd.GuranteeType__c
+                             , prd.NoDiscount_Foreign__c, prd.Repair_Contract_USD__c
+                             //chenjingwu DB202308355043 2023.8.25 start
+                             , prd.Category5__c
+                             //chenjingwu DB202308355043 2023.8.25 end
+                             
+                             //DB202312560765 you 鍚︽湁EndoRapid璧勮川妫�鏌� start 
+                             ,prd.IFEndoRapidFlag__c
+                             //DB202312560765 you 鍚︽湁EndoRapid璧勮川妫�鏌� end
+                            );
+            } else {
+              continue;
+            }
+          } else if (opp.Trade__c == '鍐呰部') {
+            if (prd.Intra_Trade_List_RMB__c > 0 && prd.Intra_Trade_Cost_RMB__c > 0) {
+              c = new QELine(i,prd.Is_DangerousChemicals__c,prd.CanNotCancelledGurantee__c,prd.VenderName__c, 
+                            prd.Estimated_ConsumptionDueDate__c,nowDetail.Product_Set__r.Name,
+                            pbe.Id, prd.Asset_Model_No__c, prd.StorageStatus__c,
+                             prd.ProductCode, nowDetail.product__c, prd.SFDA_Status__c,
+                             prd.Sales_Possibility__c, prd.Name, prd.BSSCategory__c,
+                             Quantity_c, prd.Intra_Trade_List_RMB__c,
+                             prd.Intra_Trade_List_RMB__c, prd.Intra_Trade_Cost_RMB__c,
+                             prd.Packing_list_manual__c
+                             , prd.Entend_gurantee_period_all__c
+                             , prd.Intra_Trade_Gurantee_RMB__c
+                             , prd.GuranteeType__c
+                             , prd.Intra_Trade_Service_RMB__c
+                             , prd.Maintenance_Price_Year__c
+                             //chenjingwu DB202308355043 2023.8.25 start
+                             , prd.Category5__c
+                             
+                             //DB202312560765 you 鍚︽湁EndoRapid璧勮川妫�鏌� start 
+                             ,prd.IFEndoRapidFlag__c
+                             //DB202312560765 you 鍚︽湁EndoRapid璧勮川妫�鏌� end
+                            );
+            } else {
+              continue;
+            }
+          } else {
+            continue;
+          }
+          activities.add(c);
+          i++;
+          rightcnt++;
+          lineflg = true;
+        }
+      }
+    }
+    // PageArrange();
+    if (productSetDetails.size() > 0) {
+      errorflg = true;
+      String Message = '';
+      List<String> Nl = new  List<String>();
+      Map<String,String> nameMap = new Map<String,String>();
+      for(Product_Set_Detail__c Psd : productSetDetails){
+          nameMap.put(Psd.Product_Set__r.Name, Psd.Product_Set__r.Name);
+
+      }
+      for(String name : nameMap.keySet()){
+          Message += name+' ';
+      }
+      errormessage = Message + ' 瀵煎叆缁撴潫锛屽鍏� ' + productSetDetails.size() + ' 浠讹紝鎴愬姛' + rightcnt + ' 浠�';
+    }
+    System.debug('activities-to++'+activities);
+    return errormessage + '---' + JSON.serialize(activities);
+  }
+//excelImport
+@AuraEnabled
+public static String excelImport(String excel_text,
+                                String activitiesCan,
+                                String oppInfoc,
+                                String quoc) {
+  
+  if(String.isNotBlank(activitiesCan)){
+      activities = (List<QELine>)JSON.deserialize(activitiesCan,List<QELine>.class);
+  }else {
+      activities = null;
+  }
+  quo = (Quote)JSON.deserialize(quoc,Quote.class); 
+  opp = (Opportunity)JSON.deserialize(oppInfoc,Opportunity.class); 
+  setOppFromOppInfo();
+  errorflg = false;
+  errormessage = '';
+  Integer j = 0;
+  tmpactivities = activities;
+  activities = new List<QELine>();
+  Integer i = 0;
+  Integer xlscnt = 0;
+  Integer rightcnt = 0;
+
+  string[] xlslists = excel_text.split('\n', -1);
+  List<string> xlslist = New list<string>();
+  List<string> codelist = New List<string>();
+  List<Integer> Quantitylist = New List<Integer>();
+  //String str ;
+
+  Map<String, Integer> mp = new Map<String, Integer>();
+  string xlscode;
+  Integer xlsQuantity;
+
+  try {
+    for (string xls : xlslists) {
+      if (xls == null || xls == '') {
+      } else {
+        xlscode = null;
+        xlsQuantity = null;
+        xlslist = xls.split('\t', -1);
+        system.debug('xlslist+++'+xlslist);
+        for (String s : xlslist) {
+          //odd number or even number
+          if (math.mod(i, 2) != 0) {
+            system.debug('xlslist1+++'+s);
+            //odd number
+            if (s == '' || s == null) {
+              errorflg = true;
+              errormessage = System.Label.Error_Message31;
+              activities = tmpactivities;
+              // pageArrange();
+              return errormessage+'---'+JSON.serialize(activities);
+            } else {
+              s = s.trim();
+              xlsQuantity = Integer.valueOf(s);
+              Quantitylist.add(xlsQuantity);
+            }
+          } else {
+            system.debug('xlslist2+++'+s);
+            //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();
+              codelist.add(s);
+              xlscode = s;
+            }
+          }
+          i++;
+        }
+        //mp.put(xlscode, xlsQuantity);
+        xlscnt++;
+      }
+    }
+  } catch (Exception ex) {
+    system.debug('xlslist3+++'+xlscnt);
+    activities = tmpactivities;
+    errorflg = true;
+    errormessage = System.Label.Error_Message31;
+    // pageArrange();
+    return errormessage+'---'+JSON.serialize(activities);
+  }
+
+  system.debug(j);
+  system.debug('xlscnt:::::' + xlscnt);
+
+  if (codelist.size() == 0 || Quantitylist.size() == 0) {
+    activities = tmpactivities;
+    errorflg = true;
+    system.debug('codelist+++'+codelist);
+    system.debug('Quantitylist+++'+Quantitylist);
+    errormessage = System.Label.Error_Message31;
+    // pageArrange();
+    return errormessage+'---'+JSON.serialize(activities);
+  }
+
+
+  i = 1;
+  boolean lineflg = false;
+  for (QELine t : tmpactivities) {
+    QELine a = New QELine();
+      a = t;
+      a.lineNo = i;
+      activities.add(a);
+      i++;
+  }
+  Map<String, Product2> mpProduct2 = new Map<String, Product2>();
+  List<Product2> items = [select Id, Name, ProductCode,
+                          Foreign_Trade_Cost_US__c, Foreign_Trade_List_US__c, Intra_Trade_Cost_RMB__c, Intra_Trade_List_RMB__c,
+                          Asset_Model_No__c, Sales_Possibility__c, Estimation_Entry_Possibility__c,VenderName__c,
+                          SFDA_Status__c, Qty_Unit__c, BSSCategory__c, Packing_list_manual__c, StorageStatus__c
+                          , Entend_gurantee_period_all__c
+                          , Intra_Trade_Gurantee_RMB__c
+                          , Intra_Trade_Service_RMB__c
+                          , GuranteeType__c
+                          ,  Maintenance_Price_Year__c
+                         ,CanNotCancelledGurantee__c
+                         ,Is_DangerousChemicals__c
+                         ,Repair_Contract_USD__c
+                         ,Intra_Trade_Foreign_RMB__c
+                         ,NoDiscount_Foreign__c
+                         //chenjingwu DB202308355043 2023.8.25 start
+                         ,Category5__c
+                         //chenjingwu DB202308355043 2023.8.25 end
+                        ,Estimated_ConsumptionDueDate__c
+                        //DB202312560765 you 鍚︽湁EndoRapid璧勮川妫�鏌� start 
+                        ,IFEndoRapidFlag__c
+                        //DB202312560765 you 鍚︽湁EndoRapid璧勮川妫�鏌� end
+                          FROM Product2 Where ProductCode In :codelist
+                          And Manual_Entry__c = false];
+  for (Product2 prd : items) {
+    system.debug('prd.ProductCode:::::' + prd.ProductCode);
+    mpProduct2.put(prd.ProductCode, prd);
+  }
+  Map<String, PricebookEntry> entries = new Map<String, PricebookEntry>();            // key銇孭roductCode銇с仚銆�
+  List<PricebookEntry> pbes = [
+                                select Id, PricebookEntry.Product2.ProductCode
+                                FROM PricebookEntry Where PricebookEntry.Product2.ProductCode IN :codelist
+                                AND CurrencyIsoCode = :(opp.Trade__c == '澶栬部' ? 'USD' : 'CNY')
+                                    AND IsActive = true];
+  for (PricebookEntry pbe : pbes) {
+    system.debug('pbe.Product2.ProductCode:::::' + pbe.Product2.ProductCode);
+    entries.put(pbe.Product2.ProductCode, pbe);
+  }
+
+  for (Integer l = 0; l < codelist.size(); l++) {
+    system.debug('codelist[l]:::::' + codelist[l]);
+    Product2 prd = mpProduct2.get(codelist[l]);
+    if (prd != null) {
+      PricebookEntry pbe = entries.get(codelist[l]);
+      QELine c = null;
+      if (pbe != null && (opp.Trade__c == '澶栬部' || opp.Trade__c == '鍐呰部')) {
+        if (opp.Trade__c == '澶栬部') {
+          if (prd.Foreign_Trade_List_US__c > 0 && prd.Foreign_Trade_Cost_US__c > 0) {
+            c = new QELine(i,prd.Is_DangerousChemicals__c,prd.CanNotCancelledGurantee__c, prd.VenderName__c,
+                            prd.Estimated_ConsumptionDueDate__c,'',
+                            pbe.Id, prd.Asset_Model_No__c, prd.StorageStatus__c, prd.ProductCode, prd.Id, prd.SFDA_Status__c, prd.Sales_Possibility__c, prd.Name, prd.BSSCategory__c,
+                            Quantitylist[l], prd.Foreign_Trade_List_US__c, prd.Foreign_Trade_List_US__c, prd.Foreign_Trade_Cost_US__c, prd.Packing_list_manual__c
+                           , prd.Entend_gurantee_period_all__c
+                           , prd.Intra_Trade_Foreign_RMB__c
+                           , prd.GuranteeType__c
+                           , prd.NoDiscount_Foreign__c,
+                           prd.Repair_Contract_USD__c
+                           //chenjingwu DB202308355043 2023.8.25 start
+                           , prd.Category5__c
+                           //chenjingwu DB202308355043 2023.8.25 end
+                           
+                           //DB202312560765 you 鍚︽湁EndoRapid璧勮川妫�鏌� start 
+                           ,prd.IFEndoRapidFlag__c
+                           //DB202312560765 you 鍚︽湁EndoRapid璧勮川妫�鏌� end
+                          );
+
+          } else {
+            continue;
+          }
+        } else {
+          if (prd.Intra_Trade_List_RMB__c > 0 && prd.Intra_Trade_Cost_RMB__c > 0) {
+            c = new QELine(i,prd.Is_DangerousChemicals__c,prd.CanNotCancelledGurantee__c,prd.VenderName__c, 
+                          prd.Estimated_ConsumptionDueDate__c,'',
+                          pbe.Id, prd.Asset_Model_No__c, prd.StorageStatus__c, prd.ProductCode, prd.Id, prd.SFDA_Status__c, prd.Sales_Possibility__c, prd.Name, prd.BSSCategory__c,
+                          Quantitylist[l], prd.Intra_Trade_List_RMB__c, prd.Intra_Trade_List_RMB__c, prd.Intra_Trade_Cost_RMB__c, prd.Packing_list_manual__c
+                           , prd.Entend_gurantee_period_all__c
+                           , prd.Intra_Trade_Gurantee_RMB__c
+                           , prd.GuranteeType__c
+                           , prd.Intra_Trade_Service_RMB__c
+                           , prd.Maintenance_Price_Year__c
+                           //chenjingwu DB202308355043 2023.8.25 start
+                           , prd.Category5__c
+                           //chenjingwu DB202308355043 2023.8.25 end
+                           
+                           //DB202312560765 you 鍚︽湁EndoRapid璧勮川妫�鏌� start 
+                           ,prd.IFEndoRapidFlag__c
+                           //DB202312560765 you 鍚︽湁EndoRapid璧勮川妫�鏌� end
+                          );
+
+          } else {
+            continue;
+          }
+        }
+      } else {
+        continue;
+      }
+      activities.add(c);
+      i++;
+      rightcnt++;
+    }
+  }
+  // message銈掑嚭銇�
+  errorflg = true;
+  errormessage = '鏁版嵁瀵煎叆缁撴潫锛屽鍏� ' + codelist.size() + ' 浠讹紝鎴愬姛' + rightcnt + ' 浠�';
+  // pageArrange();
+
+  return errormessage+'---'+JSON.serialize(activities);
+
+}
+@AuraEnabled
+public static Map<String,String> QuoteDecision(String activitiesCan,
+                                                String CheckItemCan ,
+                                                boolean WinOrDecideAlertc,
+                                                boolean productStatusUpdatedc,
+                                                String oppInfoc,
+                                                boolean enableSalesc,
+                                                String quoc,
+                                                String oppIdc,
+                                                String quoIdc,
+                                                boolean newQuoteFlagc,
+                                                Boolean changedAfterPrintc,
+                                                String quoteGurantee_Periodc,
+                                                String quotemultiYearWarrantyc,
+                                                String selection_hpc,
+                                                Boolean SkipQuotefilgc,
+                                                // DB202311242191 銆愭姤浠峰崟銆戞姤浠峰崟鍚堝悓閲戦鏇存柊鍜岀敓鎴愭柊鎶ヤ环鍗曡鍒欑‘璁ゅ拰淇敼 fy start
+                                                String agency1Namec) {
+                                                // DB202311242191 銆愭姤浠峰崟銆戞姤浠峰崟鍚堝悓閲戦鏇存柊鍜岀敓鎴愭柊鎶ヤ环鍗曡鍒欑‘璁ゅ拰淇敼 fy end
+  oppId = oppIdc;
+  quoId = quoIdc;
+  // DB202311242191 銆愭姤浠峰崟銆戞姤浠峰崟鍚堝悓閲戦鏇存柊鍜岀敓鎴愭柊鎶ヤ环鍗曡鍒欑‘璁ゅ拰淇敼 fy start
+  agency1Name = agency1Namec;
+  // DB202311242191 銆愭姤浠峰崟銆戞姤浠峰崟鍚堝悓閲戦鏇存柊鍜岀敓鎴愭柊鎶ヤ环鍗曡鍒欑‘璁ゅ拰淇敼 fy end
+  System.debug('quoId+'+quoId);
+  WinOrDecideAlert = WinOrDecideAlertc;
+  productStatusUpdated = productStatusUpdatedc;
+  newQuoteFlag  = newQuoteFlagc;
+  changedAfterPrint = changedAfterPrintc;
+  quoteGurantee_Period = quoteGurantee_Periodc;
+  quotemultiYearWarranty = quotemultiYearWarrantyc;
+  selection_hp = selection_hpc;
+  SkipQuotefilg = SkipQuotefilgc;
+  opp = (Opportunity)JSON.deserialize(oppInfoc,Opportunity.class); 
+  quo = (Quote)JSON.deserialize(quoc,Quote.class); 
+  if(String.isNotBlank(activitiesCan)){
+    activities = (List<QELine>)JSON.deserialize(activitiesCan,List<QELine>.class);
+  }else {
+      activities = null;
+  }
+  if(String.isNotBlank(CheckItemCan)){
+    CheckItem = (List<QuoteLineItem>)JSON.deserialize(CheckItemCan,List<QuoteLineItem>.class);
+  }else {
+    CheckItem = null;
+  }
+  enableSales = enableSalesc;
+  Savepoint sp = Database.setSavepoint();
+  Map<String,String> result = new Map<String,String>();
+  try {
+    setOppFromOppInfo();
+    errorflg = false;
+    errormessage = null;
+    errormessagewarn = null;
+    //闇�姹傝〃娌¢�氳繃锛屾病鏈夐渶姹傝〃锛氭姤浠蜂笉鑳紻ecide,
+    List<IS_Opportunity_Demand__c> ISOstutas = [SELECT id,Approval_Date__c,Func_SOD_Status__c,Opportunity_ID__r.Stock_Confrim_Date__c from IS_Opportunity_Demand__c WHERE Opportunity_ID__c = :oppid];
+    List<opportunity> oldListCheck = [select Old_Opportunity_ID__c from Opportunity where id =:oppid];
+    integer PassFlg = 0;
+    Integer StockFlg = 0;
+    for(IS_Opportunity_Demand__c iso : ISOstutas){
+        if( iso.Approval_Date__c != null ){
+            PassFlg ++;
+        }
+        if(iso.Opportunity_ID__r.Stock_Confrim_Date__c ==null){
+            StockFlg++;
+        }
+    }
+    if (!(opp.If_Account_Change__c != null ? opp.If_Account_Change__c : false)) {
+      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;
+        }
+      }
+    }
+    //chenjingwu DB202308355043 2023.8.25 start
+    if(checkVirtual('鍖呭惈铏氭嫙浜у搧锛屾棤娉曡繘琛宒ecide')){
+      errorflg = true;
+      result.put('errormessage', errormessage);
+      return result;
+    }
+    //chenjingwu DB202308355043 2023.8.25 end
+    if(PassFlg == 0&&oldListCheck[0].Old_Opportunity_ID__c==null){
+      errorflg = true;
+      errormessage = '娌℃湁鎵瑰噯鐨勯渶姹傝〃锛屼笉鑳紻ecide (From Apex 1120)';
+      result.put('errormessage', errormessage);
+      return result;
+    }
+    if(StockFlg>0){//&&ISOstutas.size()>0
+      errorflg = true;
+      errormessage = '澶囪揣纭鏃ヤ负绌猴紝涓嶅彲浠ecide 鎶ヤ环 (From Apex 1125)';
+      result.put('errormessage', errormessage);
+      return result;
+    }
+    String updateStr = ISO_DemandOperAndDemonsController.SetQuoteDecide(oppid);
+    // if (checkIsQuoteTrial()) {
+    //   errorflg = true;
+    //   result.put('errormessage', errormessage);
+    //   return result;
+    // }
+    if (enableSales == true) {
+      if (dataCheckDecide() == false) {
+        result.put('errormessage', errormessage);
+        result = resultFlag(result);
+        if(hongzi){
+          String act = JSON.serialize(activities);
+          result.put('act', act);
+        }
+      return result;
+      }
+    }
+    if (dataCheck() == false) {
+      result.put('errormessage', errormessage);
+      result = resultFlag(result);
+      return result;
+    }
+    if (dataEntry() == false) {
+      result.put('errormessage', errormessage);
+      return result;
+    }
+    // DB202311242191 銆愭姤浠峰崟銆戞姤浠峰崟鍚堝悓閲戦鏇存柊鍜岀敓鎴愭柊鎶ヤ环鍗曡鍒欑‘璁ゅ拰淇敼 fy start
+    if(String.isBlank(quoId)){
+      result.put('quoId',quoIdreturn);
+    }
+    if(SkipQuotefilg){
+      errorflg = true;
+      errormessage =  '浜у搧閰嶇疆鎴栬�呯粡閿�鍟嗕俊鎭彂鐢熷彉鍖栵紝宸茬粡鐢熸垚鏂扮殑鎶ヤ环鍗曪紝璇烽噸鏂版搷浣滄姤浠疯绠�';
+      quo.IsQuoteTrial__c = false;
+      result.put('errormessage', errormessage);
+      return result;
+    }
+    // if(SkipQuotefilg){
+    //   errorflg = true;
+    //   errormessage =  '浜у搧閰嶇疆鎴栬�呯粡閿�鍟嗕俊鎭彂鐢熷彉鍖栵紝宸茬粡鐢熸垚鏂扮殑鎶ヤ环鍗曪紝璇烽噸鏂版搷浣滄姤浠疯绠�';
+    //   quo.IsQuoteTrial__c = false;
+    //   result.put('errormessage', errormessage);
+    //   return result;
+    // }
+    // DB202311242191 銆愭姤浠峰崟銆戞姤浠峰崟鍚堝悓閲戦鏇存柊鍜岀敓鎴愭柊鎶ヤ环鍗曡鍒欑‘璁ゅ拰淇敼 fy end
+    if (String.isBlank(oppId)) {
+    } else {
+      List<Opportunity> opps = [Select Id, Estimation_Decision__c From Opportunity Where Id = : oppId];
+
+      if (opps.size() > 0) {
+        opps[0].Estimation_Decision__c = true;
+        StaticParameter.EscapeOppandStaTrigger = true;
+        update opps[0];
+        StaticParameter.EscapeOppandStaTrigger = false;
+      }
+      system.debug('quoId+++++'+quoId);
+      Quote q = new Quote();
+      if(String.isBlank(quoId)){
+        q = [select Id from Quote where Id = :quoIdreturn];
+      }else{
+        q = [select Id from Quote where Id = :quoId];
+      }
+      q.Quote_Decision_Date__c = date.Today();
+      update q;
+      result.put('success', System.Label.Message_002);
+      // DB202311242191 銆愭姤浠峰崟銆戞姤浠峰崟鍚堝悓閲戦鏇存柊鍜岀敓鎴愭柊鎶ヤ环鍗曡鍒欑‘璁ゅ拰淇敼 fy start
+      // if(String.isBlank(quoId)){
+      //   result.put('quoId',quoIdreturn);
+      // }
+      // DB202311242191 銆愭姤浠峰崟銆戞姤浠峰崟鍚堝悓閲戦鏇存柊鍜岀敓鎴愭柊鎶ヤ环鍗曡鍒欑‘璁ゅ拰淇敼 fy end
+      if(errormessagewarn != null){
+        result.put('warn', errormessagewarn);
+        String act = JSON.serialize(activities);
+        result.put('act', act);
+      }
+      return result;
+      
+      // pageArrange();
+    }
+  } catch (DmlException de) {
+    Database.rollback(sp);
+    errorflg = true;
+    errormessage = de.getDmlMessage(0);
+    result.put('errormessage', errormessage);
+    return result;
+  } catch (Exception e) {
+    Database.rollback(sp);
+    errorflg = true;
+    errormessage = e.getLineNumber()+':'+e.getMessage();
+    result.put('errormessage', errormessage);
+    return result;
+  }
+
+  return null;
+}
+private static boolean dataCheckDecide() {
+  Boolean error = false;
+  errorflg = false;
+  errormessage = null;
+  errormessagewarn = null;
+  if (quo.Dealer_Final_Price_Page__c == null) {
+    // quo.Dealer_Final_Price__c.addError(System.Label.Error_Message3);
+    String label = Schema.SObjectType.Quote.fields.Dealer_Final_Price__c.label;
+    dfpp = true;
+    error = true;
+    errormessage = label+':'+System.Label.Error_Message3;
+  }
+  if (checkAgentsDeleteFlag() == false) {
+    return false;
+  }
+  if (WinOrDecideAlert && (!productStatusUpdated)) {
+    // PriceStatusUpdate();
+    error = true;
+    errorMessage = '浜у搧鐘舵�佸彂鐢熷彉鍖栵紝璇锋洿鏂�';
+  }
+  if (opp.Agency1__c == null) {
+    // opp.Agency1__c.addError(System.Label.Error_Message3);
+    String label = Schema.SObjectType.Opportunity.fields.Agency1__c.label;
+    error = true;
+    Agency1 = true;
+    errormessage = label+':'+System.Label.Error_Message3;
+  }
+  if (quo.OCM_Agent1_Price_Page__c == null || quo.OCM_Agent1_Price_Page__c == 0) {
+    // quo.OCM_Agent1_Price__c.addError(System.Label.Error_Message3);
+    String label = Schema.SObjectType.Quote.fields.OCM_Agent1_Price__c.label;
+    error = true;
+    oapp = true;
+    errormessage = label+':'+System.Label.Error_Message3;
+  }
+  if (opp.Agency2__c == null && quo.Agent1_Agent2_Price_Page__c != null) {
+    // opp.Agency2__c.addError(System.Label.Error_Message3);
+    String label = Schema.SObjectType.Opportunity.fields.Agency2__c.label;
+    error = true;
+    Agency2 = true;
+    errormessage = label+':'+System.Label.Error_Message3;
+  }
+  if (opp.Agency2__c != null && quo.Agent1_Agent2_Price_Page__c == null) {
+    // quo.Agent1_Agent2_Price__c.addError(System.Label.Error_Message3);
+    String label = Schema.SObjectType.Opportunity.fields.Agent1_Agent2_Price__c.label;
+    error = true;
+    aapp = true;
+    errormessage = label+':'+System.Label.Error_Message3;
+  }
+
+  if (opp.If_Need_Authorize__c == true) {
+    ID tmpid = opp.Agency2__c == null ? opp.Agency1__c : opp.Agency2__c;
+    List<Account> accName = [select name from Account where id = : tmpid];
+    if (accName[0].name != opp.Authorized_Finish_Sales__c) {
+      error = true;
+      errormessage =  '缁忛攢鍟嗘湭鎺堟潈鎴栨巿鏉冩湭瀹屾垚锛岃鍏堟巿鏉冦��' ;
+    }
+  }
+  //wql 鎶ヤ环璇曠畻 鍒ゆ柇鏄惁杩涜杩囨姤浠疯瘯绠� start
+  if(!quo.IsQuoteTrial__c){
+    //娌℃湁鎶ヤ环璇曠畻杩囪繘鍏�
+    error = true;
+    errormessage =  'decide鎶ヤ环杩樻病杩涜鎶ヤ环璇曠畻锛岃鍏堟姤浠疯瘯绠楋紒' ;
+
+  }
+  
+  //wql 鎶ヤ环璇曠畻 鍒ゆ柇鏄惁杩涜杩囨姤浠疯瘯绠� end
+
+
+  //wql 鎶ヤ环璇曠畻 妫�绱績閿�鏀跨瓥鏄惁鏈夋晥 start
+  //1.鑾峰彇鎶ヤ环id
+  //2.鏍规嵁鎶ヤ环id 妫�绱㈠嚭鎵�鏈夋姤浠疯瘯绠楄锛屽苟甯﹀嚭姣忎竴琛岋紝閫夋嫨鐨勬斂绛栫殑鏈夋晥鏈�  3涓〃
+  //3.寰幆閬嶅巻 鏄惁鎵�鏈夐�夋嫨鐨勬斂绛栨湁鏁堟湡閮戒负true 鍙湁鏈変竴涓负false 灏辫繑鍥瀟rue 鐩存帴璺冲嚭寰幆
+  //濡傛灉鎶ヤ环id涓嶄负绌虹殑璇�
+  if(quoId !=null){
+    boolean IsActivePsp = true;
+    String errorPsp ='';
+    //鏍规嵁id 妫�绱� 鎵�鏈夌殑璇曠畻琛屼笂闈㈤�夋嫨鏀跨瓥鐨勬湁鏁堟湡
+    List<PromotionSalesProducts__c> promotionSalesProductsList =[select id,PromotionSales__c,QuantityId__c,PromotionSales__r.name,PromotionSales__r.IsPolicyEffective__c from PromotionSalesProducts__c where QuantityId__c=:  quoId];
+    //濡傛灉鏈夋姤浠疯瘯绠楁暟鎹� 璇存槑閫夋嫨浜嗕績閿�鏀跨瓥
+    if(promotionSalesProductsList.size()>0){
+      for(PromotionSalesProducts__c psp :promotionSalesProductsList){
+        if(psp.PromotionSales__r.IsPolicyEffective__c == '鏃犳晥'){
+            IsActivePsp =false;
+            errorPsp = psp.PromotionSales__r.name;
+            break;
+        }
+      }
+    }
+
+    if(!IsActivePsp){
+      error = true;
+      errormessage =  '鎶ヤ环璇曠畻涓紝閫夋嫨鐨勪績閿�鏀跨瓥:'+errorPsp+',涓嶅湪鏈夋晥鏈熷唴锛岃妫�鏌ワ紒' ;
+    }
+  }
+  if (opp.Trade__c == '鍐呰部') {
+    Map<Id, String> proMap = new Map<Id, String>();
+    //DB202312560765 you 鍚︽湁EndoRapid璧勮川妫�鏌� 20240522 start
+    Integer ERinerr = 0;
+    Integer NoERinerr = 0;
+    Boolean flager =false;
+    //DB202312560765 you 鍚︽湁EndoRapid璧勮川妫�鏌� 20240522 end
+    if (activities.size() > 0) {
+      for (QELine qli : activities) {
+        if (qli.Asset_Model != null && qli.Asset_Model != '') {
+          proMap.put(qli.pageObject.Id__c, qli.PageObject.Name__c);
+        }
+        //DB202312560765 you 鍚︽湁EndoRapid璧勮川妫�鏌� 20240522 start
+        if(qli.IFEndoRapidFlag){
+          ERinerr ++;
+        }  else if(!qli.IFEndoRapidFlag){
+          NoERinerr++ ;
+        }
+        //DB202312560765 you 鍚︽湁EndoRapid璧勮川妫�鏌� 20240522 end
+      }
+    }
+    //DB202312560765 you 鍚︽湁EndoRapid璧勮川妫�鏌� 20240522 start
+    if(ERinerr>0 && NoERinerr ==0){//鍏ㄥ寘
+      flager =true;
+    }
+    //DB202312560765 you 鍚︽湁EndoRapid璧勮川妫�鏌� 20240522 end
+    Map<String, String> chkMap = new Map<String, String>();
+    //DB202312560765 you 鍚︽湁EndoRapid璧勮川妫�鏌� 20240515 start
+    if(!flager){
+    chkMap = OpportunityWebService.MapCheckProRegisterDecide(proMap, opp.Agency1__c, '');
+    }
+    //DB202312560765 you 鍚︽湁EndoRapid璧勮川妫�鏌� 20240515 end
+    if (chkMap.size() > 0   || System.Test.isRunningTest()) {
+      errorflg = true;
+      error = true;
+      if (chkMap.containsKey('agency')) {
+        errormessage = '绗竴缁忛攢鍟嗘病鏈夋湁鏁堢殑鍖荤枟鍣ㄦ缁忚惀璁稿彲璇併��';
+      }
+      Integer inerr = 0;
+      if (activities.size() > 0) {
+        for (QELine s : activities) {
+          if (s.Asset_Model != null && s.Asset_Model != '') {
+            if (chkMap.containsKey(s.PageObject.Id__c)) {
+              if (chkMap.get(s.PageObject.Id__c) == '1') {
+                s.haveno_Register = true;
+                inerr ++;
+              } else if (chkMap.get(s.PageObject.Id__c) == '2') {
+                s.wrong_Register = true;
+                inerr ++;
+              }
+            }
+          }
+        }
+      }
+      if (inerr > 0) {
+        errormessage = '璇锋鏌ョ孩瀛楀唴瀹癸紙NMPA鐘舵�佺孩瀛楋紝涓嶅彲閿�鍞骇鍝侊紱浜у搧鍚嶇О绾㈠瓧锛岃秴杩囩粡閿�鍟嗙粡钀ヨ寖鍥达級銆�';
+        hongzi = true;
+      }
+      return false;
+    }
+     //DB202312560765 you 鍚︽湁EndoRapid璧勮川妫�鏌� start 
+     Boolean isEndoRapidError = false;
+     if (activities.size() > 0) {
+      for (QELine qli : activities) {
+        if (qli.Asset_Model != null && qli.Asset_Model != '') {
+            //鍖呮嫭ER浜у搧锛岀湅缁忛攢鍟嗚祫璐�
+            if(qli.IFEndoRapidFlag){
+              isEndoRapidError =true;
+              //qli.wrong_Register = true;
+            }
+        }
+      }
+    }
+    //褰撻�夋嫨鐨勪骇鍝佸寘鍚獷R浜у搧鏃讹紝楠岃瘉缁忛攢鍟嗘槸鍚︽湁ER璧勮川
+    if(isEndoRapidError){
+      String str = OpportunityWebService.checkEndoRapid(opp.agency1__c);
+      if (str != 'OK') {
+        errorflg = true;
+        errorMessage = str;
+        return false;
+      } 
+    }
+    //DB202312560765 you 鍚︽湁EndoRapid璧勮川妫�鏌� end 
+
+    // Boolean isDangerError = false;
+    // Boolean isNotDangerError = false;
+    // if (activities.size() > 0) {
+    //   for (QELine qli : activities) {
+    //     if (qli.Asset_Model != null && qli.Asset_Model != '') {
+    //         if (opp.Is_Corrosion__c) {
+    //             if(!qli.Is_DangerousChemicals){
+    //               isNotDangerError =true;
+    //               qli.wrong_Register = true;
+    //             }
+
+    //         }else{
+    //           if(qli.Is_DangerousChemicals){
+    //               isDangerError =true;
+    //               qli.wrong_Register = true;
+    //           }
+    //         }
+    //     }
+    //   }
+    // }
+    // if (enableSales == true&&opp.Is_Corrosion__c&&opp.Trade__c == '鍐呰部') {
+    //   String str = OpportunityWebService.checkDangerItem(opp.agency1__c);
+    //   if (str != 'OK') {
+    //     error = true;
+    //     errormessage = str;
+    //   }
+    //   if(isNotDangerError){
+    //     error = true;
+    //     errormessage = '褰撻樋瑗垮澶氭椂锛岃椤圭洰鐨勪骇鍝佸繀椤诲叏閫夋嫨鍗卞寲鍝併��';
+    //   }
+    // }else if(!opp.Is_Corrosion__c){
+    //   if(isDangerError){
+    //     error = true;
+    //     errormessage = '褰撹浠蜂笉鏄樋瑗垮澶氭椂锛岃椤圭洰鐨勪骇鍝佷笉鑳介�夋嫨鍗卞寲鍝併��';
+    //   }
+    // }
+  }
+  if (error == true) {
+    // PageArrange();
+    errorflg = true;
+    return false;
+  } else {
+    return true;
+  }
+}
+private static boolean checkIsQuoteTrial() {
+  Boolean error = false;
+  errorflg = false;
+  errormessage = null;
+  if(opp.If_Need_PriceApply__c){
+    if(!quo.IsQuoteTrial__c){
+      error = true;
+      errormessage =  'decide鎶ヤ环杩樻病杩涜鎶ヤ环璇曠畻锛岃鍏堟姤浠疯瘯绠楋紒' ;   
+    }
+    if(quoId !=null){
+      boolean IsActivePsp = true;
+      String errorPsp ='';
+      List<PromotionSalesProducts__c> promotionSalesProductsList =[select id,PromotionSales__c,QuantityId__c,PromotionSales__r.name,PromotionSales__r.IsPolicyEffective__c,recordTypeName__c from PromotionSalesProducts__c where QuantityId__c=:  quoId];
+      if(promotionSalesProductsList.size()>0){
+        for(PromotionSalesProducts__c psp :promotionSalesProductsList){
+          if(psp.PromotionSales__r.IsPolicyEffective__c == '鏃犳晥'&&psp.recordTypeName__c!='NormalProduct'){
+              IsActivePsp =false;
+              errorPsp = psp.PromotionSales__r.name;
+              break;
+          }
+        }
+      }
+      if(!IsActivePsp){
+        error = true;
+        errormessage =  '鎶ヤ环璇曠畻涓紝閫夋嫨鐨勪績閿�鏀跨瓥:'+errorPsp+',涓嶅湪鏈夋晥鏈熷唴锛岃妫�鏌ワ紒' ;
+      }
+    }
+  }
+  return error;
+}
+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;
+}
+// DB202307431108 鎶ヤ环鍗曘�戠粡閿�鍟�1鍚堝悓閲戦榛樿鍊艰鍒欎慨鏀� fy start
+public static String getValueFromJSONStringPlus(String jsonstring,String key,String key1) {
+  if (String.isNotBlank(jsonstring)) {
+    Map<String, Object> map1 = (Map<String, Object>) JSON.deserializeUntyped(jsonstring);
+    Map<String, Map<String,Object>> mapping = new Map<String, Map<String,Object>>();
+    for (String str : map1.keySet()) {
+      Map<String,Object> mapvalue = (Map<String,Object>) map1.get(str);
+      mapping.put(str, mapvalue);
+    }
+    return mapping.get(key) != null ? (mapping.get(key).get(key1) !=null ? String.valueOf(mapping.get(key).get(key1)) :( mapping.get(key).get('Other') !=null ? String.valueOf(mapping.get(key).get('Other')):null)) : (mapping.get('Default') != null ? (mapping.get('Default').get(key1) !=null ? String.valueOf(mapping.get('Default').get(key1)) : (mapping.get('Default').get('Other') != null ? String.valueOf(mapping.get('Default').get('Other')):null)): null);
+  }
+  return null;
+}
+@AuraEnabled
+public static InitData getModulus(String oppInfoc){
+  opp = (Opportunity)JSON.deserialize(oppInfoc,Opportunity.class); 
+  InitData res = new InitData();
+  String str_rate_hospital = ControllerUtil.getValueFromJSONString(System.Label.Quote_HospitalAmount_Rate, opp.Salesdepartment_Owner__c);
+  String str_rate_agency1 = lexSINewQuoteEntryController.getValueFromJSONStringPlus(System.Label.Quote_Agency1Amount_Rate, opp.Salesdepartment_Owner__c,opp.Opportunity_Category__c);
+  res.rate_hospital = String.isNotBlank(str_rate_hospital) ? Decimal.valueOf(str_rate_hospital) : 1.0;
+  res.rate_agency1 = String.isNotBlank(str_rate_agency1) ? Decimal.valueOf(str_rate_agency1) : 1.0;
+  return res;
+}
+//chenjingwu DB202308355043 2023.8.25 start
+public static Boolean checkVirtual(String message){
+      
+  List<String> idList = new List<String>();
+  for (QELine s : activities) {
+    if (String.isNotBlank(s.Category5) && s.Category5 == '铏氭嫙') {
+      idList.add(s.Category5);
+    }
+    System.debug('Category5+'+s.Category5);
+  }
+  if(idList.size() > 0){
+    errorMessage = message;
+    return true;
+  }
+  return false;
+}
+//chenjingwu DB202308355043 2023.8.25 end
+@AuraEnabled
+public static String submitOppoApplyStock(String oppIdc,String quoIdc){
+  oppId = oppIdc;
+  quoId = quoIdc;
+  id oppIDs = null;
+  if(oppid == null){
+      Quote qupSet = [SELECT Opportunityid from Quote WHERE id =:quoId];
+      oppIDs = qupSet.Opportunityid;
+  }else{
+      oppIDs = oppid;
+  }
+  Opportunity ops = [SELECT   id,Stock_Submit_Date__c,Stock_Confrim_Date__c,Sales_assistant_ID__c,
+                              Stock_Check_Leader__c,Quote_Update_Sum__c,
+                              is_CheckTarget_TF__c  from Opportunity WHERE id =:oppIDs];
+  User ThisAssisUser = [select id,SI_Stock_Checker__c,Salesdepartment__c,Profileid from user where id = :UserInfo.getUserId()];
+  String   ProfileId_IThelp = System.Label.ProfileId_IThelp;
+  System.debug('ProfileId_IThelp'+ProfileId_IThelp);
+  if(ops.Sales_assistant_ID__c!=UserInfo.getUserId().substring(0,15)  && ThisAssisUser.Profileid!=System.Label.ProfileId_SystemAdmin && ThisAssisUser.Profileid!=ProfileId_IThelp){
+      errormessage = 'errorss:鐢宠澶囪揣纭锛岄』鐢辫浠峰姪鐞嗘彁鍑虹敵璇� (From Apex 1043)';
+      return errormessage;
+  }else{
+      if(ThisAssisUser.SI_Stock_Checker__c == null){
+          if(ThisAssisUser.Salesdepartment__c == '5.鍗庝笢'){
+              ThisAssisUser.SI_Stock_Checker__c = System.label.SI_Stock_HD;
+              }else if(ThisAssisUser.Salesdepartment__c == '2.涓滃寳' || ThisAssisUser.Salesdepartment__c == '4.瑗垮崡'){
+                  ThisAssisUser.SI_Stock_Checker__c = System.label.SI_Stock_HDHN;
+                  }else if(ThisAssisUser.Salesdepartment__c == '1.鍗庡寳' || ThisAssisUser.Salesdepartment__c == '6.鍗庡崡'){
+                      ThisAssisUser.SI_Stock_Checker__c = System.label.si_stock_dbhb;
+                  }else if(ThisAssisUser.Salesdepartment__c == '3.瑗垮寳'){
+                      ThisAssisUser.SI_Stock_Checker__c = System.label.SI_Stock_XBXN;
+                  }
+          update ThisAssisUser;
+      }
+      ops.Stock_Submit_Date__c = Date.today();
+      if (ops.Quote_Update_Sum__c == null) {
+          ops.Quote_Update_Sum__c = 1;
+      } else {
+          ops.Quote_Update_Sum__c = ops.Quote_Update_Sum__c + 1;
+      }
+      Savepoint sp = Database.setSavepoint();
+      try{
+          update ops;
+          Approval.ProcessSubmitRequest psr = new Approval.ProcessSubmitRequest();
+          psr.setObjectId(oppIDs);
+          Approval.ProcessResult submitResult = Approval.process(psr);
+          errormessage = '澶囪揣纭鐢宠宸叉彁浜� (From Apex 1000)';
+          return errormessage;
+      }catch (Exception o){
+          Database.rollback(sp);
+          return 'errorss:'+o;
+      }
+  }
+}
+//鎶ヤ环纭
+@AuraEnabled
+public static String QuoteConfirm(String quoid){
+  System.debug('鎶ヤ环纭杩涘叆======');
+  List<Quote> QuoteList = [SELECT id,Queto_Confirm_Date__c,Opportunity.Sales_assistant_ID__c,
+                              CreatedBy.SalesManager__c,CreatedBy.ZongjianApprovalManager__c,
+                              CreatedBy.BuchangApprovalManagerSales__c,OpportunityId,Opportunity.Quote_Update_Sum__c
+                          from Quote WHERE id=:quoid];
+  Map<Id,Opportunity> oppMap = new Map<Id,Opportunity>();
+  for(Quote Qu : QuoteList){
+      Qu.Queto_Confirm_Date__c = Date.today();
+      Qu.OpporsAssistance__c = Qu.Opportunity.Sales_assistant_ID__c;
+      Qu.Manager_Sell__c = Qu.CreatedBy.SalesManager__c;
+      Qu.Minister_Sell__c = Qu.CreatedBy.BuchangApprovalManagerSales__c;
+      Qu.Majordomo_Sell__c =Qu.CreatedBy.ZongjianApprovalManager__c;
+      if (String.isBlank(Qu.OpportunityId) == false) {
+          Opportunity opp = new Opportunity();
+          opp.Id = Qu.OpportunityId;
+          if (Qu.Opportunity.Quote_Update_Sum__c == null) {
+              opp.Quote_Update_Sum__c = 1;
+          } else {
+              opp.Quote_Update_Sum__c = Qu.Opportunity.Quote_Update_Sum__c + 1;
+          }
+          oppMap.put(Qu.id, opp);
+      }
+  }
+  Savepoint Sp = Database.setSavepoint();
+  try{
+      Update QuoteList;
+      Update oppMap.values();
+      return 'success';
+  }catch (Exception o){
+      Database.rollback(Sp);
+      return 'errorss:'+o;
+  }
+}
+public class InitData{
+  @AuraEnabled
+  public Decimal rate_hospital;
+  @AuraEnabled
+  public Decimal rate_agency1;
+}
+  //琛岄」鐩嚜瀹氫箟缁撴瀯
+  //琛岄」鐩師鍊�
+  public class QELinelatestInfo {
+      public String ProductCode { get; set; }
+      public String ProductName { get; set; }
+      public String SFDA_Status { get; set; }
+      public String Sales_Possibility { get; set; }
+      public Decimal ListPrice { get; set; }
+      public Decimal Cost { get; set; }
+      public Integer Specifications {get; set;}
+      public string GuranteeType {get; set;}
+      public Decimal Intra_Trade_Gurantee {get; set;}
+      public Decimal ProductEntend_gurantee_period_all {get; set;}
+      public Decimal Intra_Trade_Service {get; set;}
+      public Decimal Maintenance_Price_Year {get; set;}
+      public Boolean CanNotCancelledGurantee {get; set;}
+      public Boolean Is_DangerousChemicals {get; set;}
+      //DB202312560765 you 鍚︽湁EndoRapid璧勮川妫�鏌� start 
+      public Boolean IFEndoRapidFlag {get; set;}
+      //DB202312560765 you 鍚︽湁EndoRapid璧勮川妫�鏌� end
+  }
+  //琛岄」鐩柊鍊�
+  public class QELine {
+      public Integer lineNo;   
+      public String Asset_Model;
+      public String Sales_Possibility;          
+      public QuoteLineItem pageObject;              
+      public Decimal Cost_c;
+      public Decimal Cost_Subtotal_c;
+      public Decimal ListPrice_Page;
+      public String StorageStatus;
+      public Integer Specifications;
+      public String VenderName;
+      public String Product_Set_Name;
+      public Boolean CanNotCancelledGurantee;
+      public Boolean Is_DangerousChemicals;
+      //DB202312560765 you 鍚︽湁EndoRapid璧勮川妫�鏌� start 
+      public Boolean IFEndoRapidFlag;
+      //DB202312560765 you 鍚︽湁EndoRapid璧勮川妫�鏌� end
+      public QELinelatestInfo latestInfo;
+      public boolean changed_name;
+      public boolean changed_sfda;
+      public boolean changed_list;
+      public boolean changed_cost;
+      public boolean haveno_Register;
+      public boolean wrong_Register;
+      public String Estimated_ConsumptionDueDate;
+      public Decimal GuranteePrice;
+      public Decimal ProductGuranteePrice;
+      public decimal Maintenance_Price_Year;
+      public String Category5;
+      public QELine(){}
+      public QELine(QuoteLineItem qli, Integer i, String copyQuoId) {
+          this.lineNo = i;
+          pageObject = qli.clone();
+          pageObject.Id__c = qli.PricebookEntry.Product2Id;
+          pageObject.Quantity__c = qli.Quantity;
+          if (String.isNotBlank(copyQuoId)) {
+            pageObject.SFDA_Status__c = qli.PricebookEntry.Product2.SFDA_Status__c;
+            pageObject.Name__c = qli.PricebookEntry.Product2.Name;
+          }
+          //chenjingwu DB202308355043 2023.8.25 start
+          Category5 = qli.PricebookEntry.Product2.Category5__c;
+          //chenjingwu DB202308355043 2023.8.25 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;
+          }
+          this.VenderName = qli.PricebookEntry.Product2.VenderName__c;
+          if(qli.PricebookEntry.Product2.Estimated_ConsumptionDueDate__c != null){
+            this.Estimated_ConsumptionDueDate = NFMUtil.formatDate2StrSpo(qli.PricebookEntry.Product2.Estimated_ConsumptionDueDate__c).replaceAll('-','/');
+          }else{
+            this.Estimated_ConsumptionDueDate = '';
+          }
+          if(VenderName==null||VenderName==''){
+              this.VenderName =' 鏃� ';
+          }
+          this.Product_Set_Name = qli.ProductSetName__c;
+          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
+          this.StorageStatus = qli.PricebookEntry.Product2.StorageStatus__c;
+          this.ListPrice_Page = qli.ListPrice__c;
+          this.Cost_c = qli.Cost__c;
+          pageObject.Subtotal__c = qli.TotalPrice__c;
+          pageObject.UnitPrice_Page__c = qli.UnitPrice__c;
+          latestInfo = new QELinelatestInfo();
+          latestInfo.ProductCode = qli.ProductCode__c;
+          latestInfo.ProductName = qli.PricebookEntry.Product2.Name;
+          latestInfo.SFDA_Status = qli.PricebookEntry.Product2.SFDA_Status__c;
+          latestInfo.ProductEntend_gurantee_period_all    =  qli.PricebookEntry.Product2.Entend_gurantee_period_all__c;
+          if(qli.Quote.Opportunity.Trade__c == '鍐呰部'){
+            latestInfo.Intra_Trade_Gurantee             =  qli.PricebookEntry.Product2.Intra_Trade_Gurantee_RMB__c;
+            latestInfo.Intra_Trade_Service             =  qli.PricebookEntry.Product2.Intra_Trade_Service_RMB__c;
+            if(qli.PricebookEntry.Product2.Maintenance_Price_Year__c == null){
+              latestInfo.Maintenance_Price_Year = 0;
+            }else{
+              latestInfo.Maintenance_Price_Year = qli.PricebookEntry.Product2.Maintenance_Price_Year__c;
+            }
+          }else if(qli.Quote.Opportunity.Trade__c == '澶栬部'){
+              latestInfo.Intra_Trade_Gurantee             =  qli.PricebookEntry.Product2.Intra_Trade_Foreign_RMB__c;
+              latestInfo.Intra_Trade_Service              =  qli.PricebookEntry.Product2.NoDiscount_Foreign__c;
+              if(qli.PricebookEntry.Product2.Maintenance_Price_Year__c == null){
+                latestInfo.Maintenance_Price_Year = 0;
+              }else{
+                latestInfo.Maintenance_Price_Year = qli.PricebookEntry.Product2.Repair_Contract_USD__c;
+              }
+          }
+          latestInfo.GuranteeType                         =  qli.PricebookEntry.Product2.GuranteeType__c;
+          latestInfo.CanNotCancelledGurantee  = qli.PricebookEntry.Product2.CanNotCancelledGurantee__c;
+          this.Maintenance_Price_Year                     = qli.Maintenance_Price_Year__c;
+          this.GuranteePrice                              =  qli.GuranteePrice__c;
+          this.ProductGuranteePrice                       =  qli.ProductGuranteePrice__c;
+          latestInfo.Sales_Possibility = qli.PricebookEntry.Product2.Sales_Possibility__c;
+          if (qli.PricebookEntry.Product2.Packing_list_manual__c != null) {
+            latestInfo.Specifications = integer.valueof(qli.PricebookEntry.Product2.Packing_list_manual__c + '');
+          }
+          latestInfo.ListPrice = qli.Product_ListPrice__c;
+          latestInfo.Cost = qli.Product_Cost__c;
+          if (qli.PricebookEntry.Product2.Packing_list_manual__c != null) {
+            this.Specifications = integer.valueof(qli.PricebookEntry.Product2.Packing_list_manual__c + '');
+          }
+          this.changed_name = false;
+          this.changed_sfda = false;
+          this.changed_list = false;
+          this.changed_cost = false;
+          this.haveno_Register = false;
+          this.wrong_Register  = false;
+      }
+      // DB202311242191 銆愭姤浠峰崟銆戞姤浠峰崟鍚堝悓閲戦鏇存柊鍜岀敓鎴愭柊鎶ヤ环鍗曡鍒欑‘璁ゅ拰淇敼 fy start
+      public QELine(OpportunityLineItem oli, Integer i) {
+        pageObject = new QuoteLineItem();
+        pageObject.Quantity__c = oli.Quantity;
+        this.lineNo = i;
+        this.Asset_Model = oli.Asset_Model_No__c;
+        this.Sales_Possibility = oli.PricebookEntry.Product2.Sales_Possibility__c;
+        this.StorageStatus = oli.PricebookEntry.Product2.StorageStatus__c;
+        if (oli.PricebookEntry.Product2.Packing_list_manual__c != null) {
+          this.Specifications = integer.valueof(oli.PricebookEntry.Product2.Packing_list_manual__c + '');
+        }
+        pageObject.Id__c = oli.PricebookEntry.Product2Id;
+        pageObject.UnitPrice_Page__c = oli.UnitPrice__c;
+        pageObject.AgencySubtotal__c = oli.AgencySubtotal__c;
+        pageObject.AgencyUnitPrice__c = oli.AgencyUnitPrice__c;
+        this.VenderName = oli.PricebookEntry.Product2.VenderName__c;
+  
+        //SFDC鍋滄棰勮 lt 20211009  鈶犱笉鑳藉畾涔塪ate鍙橀噺 鍥犱负鍓嶅彴杩斿洖鐨勬槸String鏃ユ湡  鈶″皢util閲岀殑鏂规硶杞负鏃ユ湡鏍煎紡 start
+        if(oli.PricebookEntry.Product2.Estimated_ConsumptionDueDate__c != null){
+          this.Estimated_ConsumptionDueDate = NFMUtil.formatDate2StrSpo(oli.PricebookEntry.Product2.Estimated_ConsumptionDueDate__c).replaceAll('-','/');
+        }else{
+          this.Estimated_ConsumptionDueDate = '';
+        }
+        //SFDC鍋滄棰勮 lt 20211009 end
+  
+        if(VenderName==null||VenderName==''){
+            this.VenderName =' 鏃� ';
+        }else{
+            this.VenderName = oli.PricebookEntry.Product2.VenderName__c;
+        }
+        //CHAN-BKU3XH 妫�鏌ユ槸鍚﹀瓨鍦ㄤ笉鏄悓涓�涓緵閿�鍟嗗悕绉� 绮剧悽鎶�鏈� 2020/02/17 end
+        //涓嶅彲鍙栨秷澶氬勾淇�
+        this.CanNotCancelledGurantee = oli.PricebookEntry.Product2.CanNotCancelledGurantee__c;
+        //闃胯タ璧涘
+        this.Is_DangerousChemicals = oli.PricebookEntry.Product2.Is_DangerousChemicals__c;
+        //DB202312560765 you 鍚︽湁EndoRapid璧勮川妫�鏌� start 
+        this.IFEndoRapidFlag = oli.PricebookEntry.Product2.IFEndoRapidFlag__c;
+        //DB202312560765 you 鍚︽湁EndoRapid璧勮川妫�鏌� end
+        // 澶氬勾淇濅慨 start
+        pageObject.multiYearWarranty__c = oli.multiYearWarranty__c;
+        pageObject.GuaranteePeriod__c = oli.GuaranteePeriod__c;
+        pageObject.ServicePrice__c = oli.ServicePrice__c;
+        pageObject.If_Cancel_Guarantee__c = oli.If_Cancel_Guarantee__c;
+        pageObject.warrantyType__c = oli.warrantyType__c;
+  
+        pageObject.NoDiscountTotal__c = oli.NoDiscountTotal__c;
+        // 璁℃彁閲戦
+        this.GuranteePrice          = oli.GuranteePrice__c;
+        // 缁翠慨鍚堝悓鎶ヤ环
+        this.Maintenance_Price_Year = oli.Maintenance_Price_Year__c;
+        pageObject.provistonPeriod__c = oli.provistonPeriod__c;
+  
+        pageObject.ProductEntend_gurantee_period_all__c =  oli.PricebookEntry.Product2.Entend_gurantee_period_all__c;
+        pageObject.GuranteeType__c = oli.PricebookEntry.Product2.GuranteeType__c;
+        
+        
+        // 澶氬勾淇濅慨 end
+        pageObject.SFDA_Status__c = oli.PricebookEntry.Product2.SFDA_Status__c;
+        //涓嶅彲鍙栨秷澶氬勾淇�
+        //pageObject.CanNotCancelledGurantee__c = oli.PricebookEntry.Product2.CanNotCancelledGurantee__c;
+  
+  
+        pageObject.Name__c = oli.PricebookEntry.Product2.Name;
+  
+        Decimal cost;
+        if (oli.Opportunity.Trade__c == '鍐呰部') {
+          this.ListPrice_Page = oli.PricebookEntry.Product2.Intra_Trade_List_RMB__c;
+          cost = oli.PricebookEntry.Product2.Intra_Trade_Cost_RMB__c;
+          this.ProductGuranteePrice   = oli.PricebookEntry.Product2.Intra_Trade_Gurantee_RMB__c;
+          pageObject.productServicePrice__c = oli.PricebookEntry.Product2.Intra_Trade_Service_RMB__c;
+        } else if (oli.Opportunity.Trade__c == '澶栬部') {
+          this.ListPrice_Page = oli.PricebookEntry.Product2.Foreign_Trade_List_US__c;
+          cost = oli.PricebookEntry.Product2.Foreign_Trade_Cost_US__c;
+          this.ProductGuranteePrice   = oli.PricebookEntry.Product2.Intra_Trade_Foreign_RMB__c;
+          pageObject.productServicePrice__c = oli.PricebookEntry.Product2.NoDiscount_Foreign__c;
+        }
+        if (cost > 0 && oli.Quantity > 0) {
+          this.Cost_Subtotal_c = cost * oli.Quantity;
+        }
+        this.Cost_c = cost;
+        if (oli.UnitPrice__c > 0 && oli.Quantity > 0) {
+          oli.TotalPrice__c = oli.UnitPrice__c * oli.Quantity;
+        }
+  
+        pageObject.BSS_Category__c = oli.BSS_Category__c;
+        pageObject.Subtotal__c = oli.TotalPrice__c;
+        pageObject.PricebookEntryId = oli.PricebookEntryId;
+        latestInfo = New QELinelatestInfo();
+        latestInfo.ProductCode = oli.ProductCode__c;
+        latestInfo.ProductName = oli.PricebookEntry.Product2.Name;
+        latestInfo.SFDA_Status = oli.PricebookEntry.Product2.SFDA_Status__c;
+        latestInfo.Sales_Possibility = oli.PricebookEntry.Product2.Sales_Possibility__c;
+        // 澶氬勾淇濅慨 start
+        //澶栬锤澶氬勾淇� 鍙栦骇鍝佷富鏁版嵁鐨勫璐搁噾棰� 浠ュ強 鎶ヤ环 绮剧悽鎶�鏈� wql 2021/01/04 start 
+        latestInfo.ProductEntend_gurantee_period_all    =  oli.PricebookEntry.Product2.Entend_gurantee_period_all__c;
+        if (oli.Opportunity.Trade__c == '鍐呰部') {
+          latestInfo.Intra_Trade_Gurantee             =  oli.PricebookEntry.Product2.Intra_Trade_Gurantee_RMB__c;
+          latestInfo.Intra_Trade_Service              =  oli.PricebookEntry.Product2.Intra_Trade_Service_RMB__c;
+  
+          // 缁翠慨鍚堝悓鎶ヤ环
+          latestInfo.Maintenance_Price_Year = oli.PricebookEntry.Product2.Maintenance_Price_Year__c;
+        } else if (oli.Opportunity.Trade__c == '澶栬部') {
+          latestInfo.Intra_Trade_Gurantee             =  oli.PricebookEntry.Product2.Intra_Trade_Foreign_RMB__c;
+          latestInfo.Intra_Trade_Service              =  oli.PricebookEntry.Product2.NoDiscount_Foreign__c;
+          
+  
+          // 缁翠慨鍚堝悓鎶ヤ环
+          latestInfo.Maintenance_Price_Year = oli.PricebookEntry.Product2.Repair_Contract_USD__c;
+        }
+        //澶栬锤澶氬勾淇� 鍙栦骇鍝佷富鏁版嵁鐨勫璐搁噾棰� 浠ュ強 鎶ヤ环 绮剧悽鎶�鏈� wql 2021/01/04 end
+          latestInfo.GuranteeType                        =  oli.PricebookEntry.Product2.GuranteeType__c;
+        // 澶氬勾淇濅慨 end
+        if (oli.PricebookEntry.Product2.Packing_list_manual__c != null) {
+          latestInfo.Specifications = integer.valueof(oli.PricebookEntry.Product2.Packing_list_manual__c + '');
+        }
+        latestInfo.ListPrice = oli.Product_ListPrice__c;
+        latestInfo.Cost = oli.Product_Cost__c;
+        //涓嶅彲鍙栨秷澶氬勾淇� 
+        latestInfo.CanNotCancelledGurantee  = oli.PricebookEntry.Product2.CanNotCancelledGurantee__c;
+        this.changed_name = false;
+        this.changed_sfda = false;
+        this.changed_list = false;
+        this.changed_cost = false;
+        this.haveno_Register = false;
+        this.wrong_Register  = false;
+      }
+      // DB202311242191 銆愭姤浠峰崟銆戞姤浠峰崟鍚堝悓閲戦鏇存柊鍜岀敓鎴愭柊鎶ヤ环鍗曡鍒欑‘璁ゅ拰淇敼 fy end
+      public QELine(Integer i,Boolean Is_DangerousChemicals,Boolean CanNotCancelledGurantee,String VenderName,
+                Date Estimated_ConsumptionDueDate,String ProductSetName,
+                String PricebookEntryId,
+                String Asset_Model, String StorageStatus,
+                String ProductCode, String Id_c,
+                String SFDA_Status_c, String Sales_Possibility_c,
+                String Name_c, String BSS_Category_c,
+                Integer Quantity, Decimal ListPrice_c,
+                Decimal UnitPrice_c, Decimal Cost_c,
+                Decimal Packing_list_manual
+                , Decimal Entend_gurantee_period_all
+                , decimal ProductGuranteePrice
+                , string GuranteeType
+                , Decimal productServicePrice
+                , Decimal productMaintenance_Price_Year
+                //chenjingwu DB202308355043 2023.8.25 start
+                ,String Category5
+                //chenjingwu DB202308355043 2023.8.25 end
+                
+                //DB202312560765 you 鍚︽湁EndoRapid璧勮川妫�鏌� start 
+                ,Boolean IFEndoRapidFlag
+                //DB202312560765 you 鍚︽湁EndoRapid璧勮川妫�鏌� end
+               ) {
+          pageObject = New QuoteLineItem();
+          pageObject.Quantity__c = Quantity;
+          this.lineNo = i;
+          this.Asset_Model = Asset_Model;
+          this.Sales_Possibility = Sales_Possibility_c;
+          if(Estimated_ConsumptionDueDate != null){
+            this.Estimated_ConsumptionDueDate = NFMUtil.formatDate2StrSpo(Estimated_ConsumptionDueDate).replaceAll('-','/');
+          }else{
+            this.Estimated_ConsumptionDueDate = '';
+          }
+          this.StorageStatus = StorageStatus;
+          pageObject.Id__c = Id_c;
+          pageObject.SFDA_Status__c = SFDA_Status_c;
+          pageObject.Name__c = Name_c;
+          pageObject.BSS_Category__c = BSS_Category_c;
+          this.ListPrice_Page = ListPrice_c;
+          pageObject.UnitPrice_Page__c = UnitPrice_c;
+          pageObject.Subtotal__c = UnitPrice_c * Quantity;
+          this.Product_Set_Name = ProductSetName;
+          //chenjingwu DB202308355043 2023.8.25 start
+          Category5 = Category5;
+          //chenjingwu DB202308355043 2023.8.25 end
+          if(VenderName==null||VenderName==''){
+              this.VenderName =' 鏃� ';
+          }else{
+              this.VenderName = VenderName;
+          }
+          this.CanNotCancelledGurantee = CanNotCancelledGurantee;
+          this.Is_DangerousChemicals = Is_DangerousChemicals;
+          //DB202312560765 you 鍚︽湁EndoRapid璧勮川妫�鏌� start 
+          this.IFEndoRapidFlag = IFEndoRapidFlag;
+          //DB202312560765 you 鍚︽湁EndoRapid璧勮川妫�鏌� end
+          pageObject.ProductEntend_gurantee_period_all__c = Entend_gurantee_period_all;
+          pageObject.productServicePrice__c               = productServicePrice;
+          pageObject.GuranteeType__c                      = GuranteeType;
+          this.ProductGuranteePrice                       =  ProductGuranteePrice;
+          this.Maintenance_Price_Year                     = productMaintenance_Price_Year;
+          this.Cost_c = Cost_c;
+          this.Cost_Subtotal_c = Cost_c * Quantity;
+          pageObject.PricebookEntryId = PricebookEntryId;
+          latestInfo = New QELinelatestInfo();
+          latestInfo.ProductCode = ProductCode;
+          latestInfo.ProductName = Name_c;
+          latestInfo.SFDA_Status = SFDA_Status_c;
+          latestInfo.Sales_Possibility = Sales_Possibility_c;
+          latestInfo.ListPrice = this.ListPrice_Page;
+          latestInfo.Cost = pageObject.Cost__c;
+          latestInfo.ProductEntend_gurantee_period_all    =  Entend_gurantee_period_all;
+          latestInfo.Intra_Trade_Gurantee             =  ProductGuranteePrice;
+          latestInfo.Intra_Trade_Service              =  productServicePrice;
+          latestInfo.GuranteeType                         =  GuranteeType;
+          latestInfo.Maintenance_Price_Year               =  productMaintenance_Price_Year;
+          latestInfo.CanNotCancelledGurantee = CanNotCancelledGurantee;
+          latestInfo.Is_DangerousChemicals = Is_DangerousChemicals;
+          //DB202312560765 you 鍚︽湁EndoRapid璧勮川妫�鏌� start 
+          latestInfo.IFEndoRapidFlag = IFEndoRapidFlag;
+          //DB202312560765 you 鍚︽湁EndoRapid璧勮川妫�鏌� end
+          if (Packing_list_manual != null) {
+            latestInfo.Specifications = integer.valueof('' + Packing_list_manual);
+          }
+          if (Packing_list_manual != null) {
+            this.Specifications = integer.valueof('' + Packing_list_manual);
+          }
+          this.changed_name = false;
+          this.changed_sfda = false;
+          this.changed_list = false;
+          this.changed_cost = false;
+          this.haveno_Register = false;
+          this.wrong_Register  = false;
+        }
+  }
+  @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++;
+
+  }
+
+}
\ No newline at end of file

--
Gitblit v1.9.1