Thhto
2022-11-17 ea6a4eec81a6a74e214aefc5971d701242c3e7d3
force-app/main/default/classes/NewQuoteIraiController.cls
@@ -6,6 +6,9 @@
    public Id quoId {get;set;}
    public String oppid;
    public String leadid;
    //SWAG-CKDATG【委托】【OBSAP-报价委托】报价委托项目改善1 fy start
    public String tenderid;
    //SWAG-CKDATG【委托】【OBSAP-报价委托】报价委托项目改善1 fy end
    public Boolean productStatusUpdated {get;set;}               // 状態更新、{!$Label.Status_Update} を押下したかどうか
    public Boolean changedAfterPrint {get;set;}                  // true の場合、画面に confirm メッセージが表示します。quoIdを新しいinsert。判定はjsにて実施
@@ -15,7 +18,9 @@
    public String errorProductmodel { get; set; }
    public Boolean is_changed_opp { get; set; }
    //lastbuy  2022/3/10 fy end
    //SWAG-CKDATG 【委托】【OBSAP-报价委托】报价委托项目改善1 start
    public String erroraxsdmodel { get; set; }
    //SWAG-CKDATG 【委托】【OBSAP-报价委托】报价委托项目改善1 end
    public String excel_text {get;set;}
    public Integer select_index {get;set;}                       // excelImport専用ですが、jsにて制御することになるので、TODO katsu 削除予定
    public String Product_text {get;set;}
@@ -161,13 +166,20 @@
        // 招投标报价委托 2021-06-21 update by gzw start
        // 招投标
        String tenderid = System.currentPageReference().getParameters().get('tenderid');
        //SWAG-CKDATG【委托】【OBSAP-报价委托】报价委托项目改善1 fy start
        // String tenderid = System.currentPageReference().getParameters().get('tenderid');
        tenderid = System.currentPageReference().getParameters().get('tenderid');
        //SWAG-CKDATG【委托】【OBSAP-报价委托】报价委托项目改善1 fy end
        // 招投标报价委托 2021-06-21 update by gzw start
        // 询价id
        oppid = System.currentPageReference().getParameters().get('oppid');
        QuoteIrai__c quoteiraiobj = new QuoteIrai__c();
        if(oppid==null&&tenderid==null&&quoId!=null&&leadid==null&&agencyoppid==null){
        //SWAG-CKDATG【委托】【OBSAP-报价委托】报价委托项目改善1 fy start
        if(oppid==null&&quoId!=null&&leadid==null&&agencyoppid==null){
            // if(oppid==null&&tenderid==null&&quoId!=null&&leadid==null&&agencyoppid==null){
        //SWAG-CKDATG【委托】【OBSAP-报价委托】报价委托项目改善1 fy end
            //XLIU-CFE8M7 【委托】【P-OBSAP】报价委托任务改善 fy  Noteplus__c
            quoteiraiobj = [select id,Note__c,Noteplus__c from QuoteIrai__c where id=:quoId];
            if(quoteiraiobj.Note__c!=null){
@@ -179,6 +191,8 @@
            }
        }
        system.debug('oppid:++++'+oppid);
        system.debug('leadid:++++'+leadid);
        system.debug('tenderid:++++'+tenderid);
        // 报价id
        String oppquoid = System.currentPageReference().getParameters().get('oppquoid');
        //将报价委托的币种与外贸币种一致 防止后续外贸有需要用USD判断显示的地方 精琢技术 wql 2021/01/06 start
@@ -207,7 +221,10 @@
            }
            // 经销商询价报价委托 2020-02-28 update by vivek end
            // 招投标报价委托 2021-06-21 update by gzw start
            if (String.isNotBlank(tenderid)) {
            // SWAG-CKDATG 【委托】【OBSAP-报价委托】报价委托项目改善1 fy start
            // if (String.isNotBlank(tenderid)) {
            if (String.isNotBlank(tenderid)&&String.isBlank(leadid)) {
            // SWAG-CKDATG 【委托】【OBSAP-报价委托】报价委托项目改善1 fy start
                quo.Note__c = Tender_information__c.sObjectType.getDescribe().getLabel() + ':' + baseUrl + '/' + tenderid;
            }
            // 招投标报价委托 2021-06-21 update by gzw end
@@ -405,17 +422,17 @@
            // CHAN-BJQ4VZ 精琢技术 2019/12/11 Start
            //XLIU-CFE8M7 【委托】【P-OBSAP】报价委托任务改善 fy  Noteplus__c
            //SWAG-CF589P【委托】【P:OBSAP】报价委托相关新需求评估 fy Lead__c,Opportunity__c,
            List<QuoteIrai__c> quoList = //obsap 新增经销商1字段 fy satrt Agency1_entrust__c ,
                [ SELECT Id,Name,Cancel_Decide__c,Agency_Hospital_Link__c,CreatedDate, PriceRefreshDate__c,Quote_Print_Date__c,Agency1_entrust__c,
            List<QuoteIrai__c> quoList = //obsap 新增经销商1字段 fy satrt Agency1_entrust__c ,SWAG-CKDATG 【委托】【OBSAP-报价委托】报价委托项目改善1 fy start cancelMultiyearInsurance__c,
                [ SELECT Id,Name,Cancel_Decide__c,Agency_Hospital_Link__c,CreatedDate, PriceRefreshDate__c,Quote_Print_Date__c,Agency1_entrust__c,cancelMultiyearInsurance__c,
                        Quote_Date__c,QuoteToName__c,Quote_Expiration_Date__c,Quote_Comment__c,Tender_information__c,Noteplus__c,Lead__c,Opportunity__c,
                        TOTAL__c,Discount__c,Pricing__c,Preferential_Trading_Price__c,Contract__c,LastIraiUser__c,MultiYearWarrantyTotalPrice__c,QuoteTotal_Page__c,Estimation_List_Price__c,
                        Print_HP_Name__c,Account__c,IraiUser__c,IraiSubject__c,CurrencyIsoCode,IraiName__c,QuoteIrai_Status__c,QuoteProportion__c,Note__c,IraiComment__c
                        FROM QuoteIrai__c Where Id =:quoId];
            // CHAN-BJQ4VZ 精琢技术 2019/12/11 End
            // CHAN-BHNBX6 2019/11/20 START
            List<QuoteIraiLineItem__c> items = //lastbuy  2022/3/10 fy start LastbuyProductFLG__c
            List<QuoteIraiLineItem__c> items = //lastbuy  2022/3/10 fy start LastbuyProductFLG__c //SWAG-CKDATG 【委托】【OBSAP-报价委托】报价委托项目改善1 start Is_DangerousChemicals__c
                [Select Id,Asset_Model_No__c,SFDA_Status__c,Name__c,BSS_Category__c,QuoteIrai__r.Quote_Print_Date__c,
                    Qty_Unit__c,Quantity__c,Product2__r.SFDA_Status__c,ProductCode__c,ListPrice__c,Product2__r.LastbuyProductFLG__c,
                    Qty_Unit__c,Quantity__c,Product2__r.SFDA_Status__c,ProductCode__c,ListPrice__c,Product2__r.LastbuyProductFLG__c,Product2__r.Is_DangerousChemicals__c,
                    Product2__r.Sales_Possibility__c,Product2__r.Name,Product2__c,ServicePrice__c,NoDiscountTotal__c,GuaranteePeriod__c
                    From QuoteIraiLineItem__c where QuoteIrai__c = :quoId Order by Item_Order__c, Id];
            // CHAN-BHNBX6 2019/11/20 END
@@ -499,7 +516,15 @@
            quo.Quote_Expiration_Date__c = Date.today() + 30;
        }
        //--Savebutton
        Save_button=true;
        // SWAG-CKDATG 【委托】【OBSAP-报价委托】报价委托项目改善1 fy start
        this.Save_button=false;
        if(quo.QuoteIrai_Status__c != '草案中'&& String.isNotBlank(quo.QuoteIrai_Status__c)){
            this.Save_button=true;
        }
        // Save_button=true;
        // SWAG-CKDATG 【委托】【OBSAP-报价委托】报价委托项目改善1 fy end
        system.debug('===fff==='+quo.QuoteIrai_Status__c);
        system.debug('===ccc==='+this.Save_button);
        //XLIU-CFE8M7 【委托】【P-OBSAP】报价委托任务改善 fy start
        // if( quo.Note__c!=''){
        if(String.isNotBlank(quo.Note__c)){
@@ -1060,6 +1085,11 @@
            if (!String.isBlank(quo.Agency1_entrust__c)) {
                description += '\r\n' + '第一经销商' + ':' + baseUrl + '/' + quo.Agency1_entrust__c;
            }
            //SWAG-CKDATG【委托】【OBSAP-报价委托】报价委托项目改善1 fy start
            if (!String.isBlank(tenderid)&&!description.contains('招标项目') ) {
                description += '\r\n' + '招标项目' + ':' + baseUrl + '/' + tenderid;
            }
            //SWAG-CKDATG【委托】【OBSAP-报价委托】报价委托项目改善1 fy end
            //obsap 新增经销商1字段 fy end
            // 招投标报价委托 2020-06-21 update by gzw start
            // if (!String.isBlank(quo.Tender_information__c)) {
@@ -1111,6 +1141,14 @@
            if (quo.QuoteProportion__c != null) {
                todoSubject += ', ' + quo.QuoteProportion__c + '%';
            }
            // SWAG-CKDATG 【委托】【OBSAP-报价委托】报价委托项目改善1 fy start
            todoSubject += quo.cancelMultiyearInsurance__c=='不要' ?',取消多年保':',需要多年保';
            // if (quo.cancelMultiyearInsurance__c=='不要') {
            //     todoSubject += ',取消多年保';
            // }else{
            //     todoSubject += ',需要多年保';
            // }
            // SWAG-CKDATG 【委托】【OBSAP-报价委托】报价委托项目改善1 fy end
            // String taskid = '';
            // 改成对多人的
            // if (tasks.size() > 0) {
@@ -1191,8 +1229,8 @@
                // CHAN-BJQ4VZ 精琢技术 2019/12/11 Start
            //XLIU-CFE8M7 【委托】【P-OBSAP】报价委托任务改善 fy  Noteplus__c
            //SWAG-CF589P【委托】【P:OBSAP】报价委托相关新需求评估 fy Lead__c,Opportunity__c,
                quo =[ SELECT Id,Name,Cancel_Decide__c,CreatedDate, PriceRefreshDate__c,Quote_Print_Date__c,//obsap 新增经销商1字段 fy satrt Agency1_entrust__c,
                        Quote_Date__c,QuoteToName__c,Quote_Expiration_Date__c,Quote_Comment__c,Tender_information__c,Agency1_entrust__c,Noteplus__c,Lead__c,Opportunity__c,
                quo =[ SELECT Id,Name,Cancel_Decide__c,CreatedDate, PriceRefreshDate__c,Quote_Print_Date__c,//obsap 新增经销商1字段 fy satrt Agency1_entrust__c,SWAG-CKDATG 【委托】【OBSAP-报价委托】报价委托项目改善1 fy start cancelMultiyearInsurance__c,
                        Quote_Date__c,QuoteToName__c,Quote_Expiration_Date__c,Quote_Comment__c,Tender_information__c,Agency1_entrust__c,Noteplus__c,Lead__c,Opportunity__c,cancelMultiyearInsurance__c,
                        TOTAL__c,Discount__c,Pricing__c,Preferential_Trading_Price__c,Contract__c,LastIraiUser__c,MultiYearWarrantyTotalPrice__c,QuoteTotal_Page__c,Estimation_List_Price__c,
                        Print_HP_Name__c,Account__c,Agency_Hospital_Link__c,IraiUser__c,IraiSubject__c,CurrencyIsoCode,IraiName__c,QuoteIrai_Status__c,QuoteProportion__c,Note__c,IraiComment__c
                        FROM QuoteIrai__c Where Id =:quoId];
@@ -1207,7 +1245,8 @@
            // 招投标报价委托 2020-06-21 update by gzw end
            errorflg = true;
            errorMessage = '邮件发送完成。';
            // SWAG-CKDATG 【委托】【OBSAP-报价委托】报价委托项目改善1 fy start
            this.Save_button=true;
            //XLIU-CHY4KW 20220907 lt start  --- 报价委托发送邮件成功之后 反向更新意向  报价委托字段为1
            Lead lea = new Lead();
            if(String.isNotBlank(leadid)){
@@ -1416,6 +1455,14 @@
        }
      
      //20220310 fy lastbuy end
        //SWAG-CKDATG 【委托】【OBSAP-报价委托】报价委托项目改善1 start
        String resalt = assdproductCheck();
        if(resalt!='OK'){
            errorflg = true;
            errormessage = resalt ;
            return false;
        }
        //SWAG-CKDATG 【委托】【OBSAP-报价委托】报价委托项目改善1 end
        system.debug('○○○○○○○○○○○○Welcome to dataCheck class!!○○○○○○○○○○○○');
        errorflg = false;
        errormessage = null;
@@ -1440,8 +1487,8 @@
            if (error == true){
                if (quoId != null) {
                    Map<String,QuoteIraiLineItem__c> itemmap = new Map<String,QuoteIraiLineItem__c>();
                    for (QuoteIraiLineItem__c item : [//lastbuy  2022/3/10 fy start LastbuyProductFLG__c
                        Select Id,Product2__r.SFDA_Status__c,Product2__r.Name,Product2__c,Product2__r.LastbuyProductFLG__c
                    for (QuoteIraiLineItem__c item : [//lastbuy  2022/3/10 fy start LastbuyProductFLG__c //SWAG-CKDATG 【委托】【OBSAP-报价委托】报价委托项目改善1 start Product2__r.Is_DangerousChemicals__c
                        Select Id,Product2__r.SFDA_Status__c,Product2__r.Name,Product2__c,Product2__r.LastbuyProductFLG__c,Product2__r.Is_DangerousChemicals__c
                        From QuoteIraiLineItem__c where QuoteIrai__c = :quoId Order by Item_Order__c, Id]) {
                        itemmap.put(item.Product2__c,item);
                    }
@@ -1542,10 +1589,10 @@
            q = New QuoteIrai__c();
        }else{
            // CHAN-BJQ4VZ 精琢技术 2019/12/11 Start
            List<QuoteIrai__c> qs = New List<QuoteIrai__c>();//obsap 新增经销商1字段 fy satrt Agency1_entrust__c,
            List<QuoteIrai__c> qs = New List<QuoteIrai__c>();//obsap 新增经销商1字段 fy satrt Agency1_entrust__c,SWAG-CKDATG 【委托】【OBSAP-报价委托】报价委托项目改善1 fy start cancelMultiyearInsurance__c,
            //XLIU-CFE8M7 【委托】【P-OBSAP】报价委托任务改善 fy  Noteplus__c
            //SWAG-CF589P【委托】【P:OBSAP】报价委托相关新需求评估 fy Lead__c,Opportunity__c,
            qs = [select Id,Account__c,Agency_Hospital_Link__c,Name,IraiUser__c,IraiSubject__c,Tender_information__c,Agency1_entrust__c,Noteplus__c,Lead__c,Opportunity__c,
            qs = [select Id,Account__c,Agency_Hospital_Link__c,Name,IraiUser__c,IraiSubject__c,Tender_information__c,Agency1_entrust__c,Noteplus__c,Lead__c,Opportunity__c,cancelMultiyearInsurance__c,
                Preferential_Trading_Price__c,Discount__c,Pricing__c,Unit_Price__c,Offer_Amount__c,TOTAL__c,MultiYearWarrantyTotalPrice__c,QuoteTotal_Page__c,Estimation_List_Price__c,
                Contract__c,Print_HP_Name__c,Quote_Expiration_Date__c,Quote_Comment__c,IraiName__c,QuoteIrai_Status__c,QuoteProportion__c,Note__c,IraiComment__c
                From QuoteIrai__c Where Id =:quoId];
@@ -1574,6 +1621,9 @@
        //obsap 新增经销商1字段 fy staty
        q.Agency1_entrust__c = quo.Agency1_entrust__c;
        //obsap 新增经销商1字段 fy staty
        // SWAG-CKDATG 【委托】【OBSAP-报价委托】报价委托项目改善1 fy start
        q.cancelMultiyearInsurance__c = quo.cancelMultiyearInsurance__c;
        // SWAG-CKDATG 【委托】【OBSAP-报价委托】报价委托项目改善1 fy end
        q.QuoteProportion__c = quo.QuoteProportion__c;
        q.CurrencyIsoCode = quo.CurrencyIsoCode;
        //XLIU-CFE8M7 【委托】【P-OBSAP】报价委托任务改善 fy start
@@ -1609,8 +1659,8 @@
        }
        //XLIU-CFE8M7 【委托】【P-OBSAP】报价委托任务改善 fy  Noteplus__c
        //SWAG-CF589P【委托】【P:OBSAP】报价委托相关新需求评估 fy Lead__c,Opportunity__c,
        quo =[ SELECT Id,Name,Cancel_Decide__c,CreatedDate, PriceRefreshDate__c,Quote_Print_Date__c,//obsap 新增经销商1字段 fy satrt Agency1_entrust__c,
                    Quote_Date__c,QuoteToName__c,Quote_Expiration_Date__c,Quote_Comment__c,Tender_information__c,Agency1_entrust__c,Noteplus__c,Lead__c,Opportunity__c,
        quo =[ SELECT Id,Name,Cancel_Decide__c,CreatedDate, PriceRefreshDate__c,Quote_Print_Date__c,//obsap 新增经销商1字段 fy satrt Agency1_entrust__c,SWAG-CKDATG 【委托】【OBSAP-报价委托】报价委托项目改善1 fy start cancelMultiyearInsurance__c,
                    Quote_Date__c,QuoteToName__c,Quote_Expiration_Date__c,Quote_Comment__c,Tender_information__c,Agency1_entrust__c,Noteplus__c,Lead__c,Opportunity__c,cancelMultiyearInsurance__c,
                    TOTAL__c,Discount__c,Pricing__c,Preferential_Trading_Price__c,Contract__c,LastIraiUser__c,MultiYearWarrantyTotalPrice__c,QuoteTotal_Page__c,Estimation_List_Price__c,
                    Print_HP_Name__c,Account__c,Agency_Hospital_Link__c,IraiUser__c,IraiSubject__c,CurrencyIsoCode,IraiName__c,QuoteIrai_Status__c,QuoteProportion__c,Note__c,IraiComment__c
                    FROM QuoteIrai__c Where Id =:q.Id];
@@ -1785,6 +1835,40 @@
    system.debug('filg====='+filg);
    return filg;
  }
 //SWAG-CKDATG 【委托】【OBSAP-报价委托】报价委托项目改善1 start
  //阿西赛多验证
  public String assdproductCheck(){
    Boolean falg = false;
    String str = 'OK';
    List<Product2> axsdQuoteIItem = new List<Product2>();
    List<Product2> QuoteIItem = new List<Product2>();
    List<Id> Product2List = new List<Id>();
    System.debug('activities111111!!!'+activities);
    for(QELine aaa :activities){
     if(String.isNotBlank(aaa.pageObject.Product2__c)){
        Product2List.add(aaa.pageObject.Product2__c);
     }
    }
    List<Product2> productlist = [select id,Is_DangerousChemicals__c from Product2 where id in:Product2List];
    for(Product2 pro :productlist){
        System.debug('Is_DangerousChemicals__c111111!!!'+pro.Is_DangerousChemicals__c);
        if(pro.Is_DangerousChemicals__c){
            falg = true;
            axsdQuoteIItem.add(pro);
        }else if(!pro.Is_DangerousChemicals__c){
            QuoteIItem.add(pro);
        }
    }
    if(QuoteIItem.size() > 0 && axsdQuoteIItem.size() > 0){
        str = '阿西赛多产品不能和其他产品一起报价';
    }else{
        if(falg){
            str = OpportunityWebService.checkDangerItem(quo.Agency1_entrust__c);
        }
    }
    return str;
  }
  //SWAG-CKDATG 【委托】【OBSAP-报价委托】报价委托项目改善1 end
    // CHAN-BJQ4VZ 精琢技术 2019/12/11 Start
    public class QuoteBean {