高章伟
2022-03-10 1312ba82d4c880bdb5357d28e0d4af5b285f610f
force-app/main/default/classes/NewQuoteIraiController.cls
@@ -8,6 +8,12 @@
    public Boolean productStatusUpdated {get;set;}               // 状態更新、{!$Label.Status_Update} を押下したかどうか
    public Boolean changedAfterPrint {get;set;}                  // true の場合、画面に confirm メッセージが表示します。quoIdを新しいinsert。判定はjsにて実施
    //lastbuy  2022/3/10 fy start
    public Boolean filg { get; set; }
    public Integer flglastbuy { get; set; }
    public String errorProductmodel { get; set; }
    //lastbuy  2022/3/10 fy end
    public String excel_text {get;set;}
    public Integer select_index {get;set;}                       // excelImport専用ですが、jsにて制御することになるので、TODO katsu 削除予定
    public String Product_text {get;set;}
@@ -1160,6 +1166,23 @@
    }
    public boolean dataCheck(){
         //20220310 fy lastbuy start
      if(!ReservedProductVerification()){
        if(flglastbuy==1){
          errorflg = true;
          errormessage =  '预留产品表中没有录入该报价的预留产品' ;
          return false;
        }else if(flglastbuy==2){
          errorflg = true;
          errormessage =  errorProductmodel+'产品数量不可超过产品预留数量' ;
          return false;
        }else if(flglastbuy==3){
          errorflg = true;
          errormessage =  '预留产品'+errorProductmodel+'未录入预留产品表';
          return false;
        }
      }
      //20220310 fy lastbuy end
        system.debug('○○○○○○○○○○○○Welcome to dataCheck class!!○○○○○○○○○○○○');
        errorflg = false;
        errormessage = null;
@@ -1399,6 +1422,92 @@
        return true;
    }
     //lastbuy  2022/3/10 fy start
  public boolean ReservedProductVerification() {
    filg=true;
    Map<string,QuoteIraiLineItem__c> quotlinitMap = new Map<string,QuoteIraiLineItem__c>();
    List<Id> lastProductFLGListId = new List<Id>();
    List<QuoteIraiLineItem__c> lastProductFLGList = new List<QuoteIraiLineItem__c>();
    List<QuoteIraiLineItem__c> act = new List<QuoteIraiLineItem__c>();
    List<QuoteIraiLineItem__c> act2 = new List<QuoteIraiLineItem__c>();
    for(QELine aaa :activities){
      if(aaa.pageObject.Product2__c!=null&&aaa.pageObject.Quantity__c!=null){
        act.add(aaa.pageObject);
      }
    }
    act2=act.deepClone();
    Map<String,QuoteIraiLineItem__c> map1 = new Map<String,QuoteIraiLineItem__c>();
    System.debug('activities1111111111112为所当为多多!!!'+activities);
    integer i =0;
    for(QuoteIraiLineItem__c pspsc :act2){
      if(pspsc.Product2__c!=null&&pspsc.Quantity__c!=null){
        if(map1.containsKey(pspsc.Product2__c)){
            QuoteIraiLineItem__c quoteLine = map1.get(pspsc.Product2__c);
          quoteLine.Quantity__c =quoteLine.Quantity__c+pspsc.Quantity__c;
          map1.put(pspsc.Product2__c,quoteLine);
          System.debug('2222222!!!'+quoteLine);
        }else{
          map1.put(pspsc.Product2__c,pspsc);
        }
        System.debug('5555555!!!'+pspsc);
        System.debug('34499879!!!'+activities);
      }
    }
    System.debug('3434343!!!'+activities);
    System.debug('5656565!!!'+map1);
    for (QuoteIraiLineItem__c value : map1.values()) {
      if(value.Product2__r.LastbuyProductFLG__c){
        lastProductFLGListId.add(value.Product2__c);
        quotlinitMap.put(value.Product2__c,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(QuoteIraiLineItem__c lastbuypr :lastProductFLGList){
            Decimal quoteLItemNum=0;
            if(LastbuyObjMap.containsKey(lastbuypr.Product2__c)){
                quoteLItemNum=LastbuyObjMap.get(lastbuypr.Product2__c).LastbuyQuantity__c;
                System.debug('quoteLItemNum!!!'+quoteLItemNum);
                System.debug('lastbuypr.pageObject.Quantity__c+++!!!'+lastbuypr.Quantity__c);
                if(lastbuypr.Quantity__c>quoteLItemNum){
                  errorProductmodel=lastbuypr.Asset_Model_No__c;
                  flglastbuy=2;
                  filg=false;
                  break;
                }
            }else{
              errorProductmodel=lastbuypr.Asset_Model_No__c;
              flglastbuy=3;
              filg=false;
              break;
            }
          }
        }
    }
    system.debug('filg====='+filg);
    return filg;
  }
    // CHAN-BJQ4VZ 精琢技术 2019/12/11 Start
    public class QuoteBean {
    // 产品标准定价总额