高章伟
2023-03-03 d8dc84a3d56df839895f1c417a4d9cbee763d262
force-app/main/default/classes/OpportunityPCLController2.cls
@@ -60,6 +60,11 @@
   public List<List<String> > columnsRightApi { get; private set; }        // 参照項目用
   public List<String> columnLeftCss { get; private set; }               // css 用
   public List<String> columnRightCss { get; private set; }              // css 用
   //XLIU-CGF4TA 【委托】 【询价管理改善需求评估】询价中的进口论证判断 fy start
   public List<String> columnRightCsscopy { get; private set; }
   public List<String> titleRightcopy { get; private set; }
   public List<List<String> > columnsRightApicopy { get; private set; }
   //XLIU-CGF4TA 【委托】 【询价管理改善需求评估】询价中的进口论证判断 fy end
   public Map<String, String> columnLeftRW { get; private set; }              // r,w,wm用
   public Map<String, String> columnRightRW { get; private set; }             // r,w,wm用
   public List<String> columnMark { get; private set; }                  // Mark用
@@ -92,7 +97,9 @@
   //【委托】【重要】周会管理表修改  tcm end
   private static Integer oppLimit = 1000;
   private Boolean isForMoneyFlg = false;
   //XLIU-CGF4TA 【委托】 【询价管理改善需求评估】询价中的进口论证判断 fy start
   public Boolean HideForecastOCSMflag { get; set; }
   //XLIU-CGF4TA 【委托】 【询价管理改善需求评估】询价中的进口论证判断 fy end
   public OpportunityPCLController2() {
     //Apexpages.currentPage().getHeaders().put('X-UA-Compatible', 'IE=8');
     DESC_RW = SoapApi.getEditLayoutItemRW('Opportunity', new String[] {'01210000000QekKAAS'}).get('01210000000QekKAAS');
@@ -111,13 +118,13 @@
     dateOpts.add(new SelectOption('  TenderBeginDate__c', '招标日(招标项目)'));
     dateOpts.add(new SelectOption('Closing_Bid_Date_Bid__c', '中标日(招投标)'));
     //【委托】【重要】周会管理表修改  tcm end
     dateOpts.add(new SelectOption('Close_Forecasted_Date__c', '预测OCSM签约日'));
     dateOpts.add(new SelectOption('Close_Forecasted_Date__c', '预测OCSM签约日(KPI)')); //20220506 lt update
  
     //SWAG-C9NC23 【委托】[重要,优先!]周会询价管理表修改   lt   20211217  start
     dateOpts.add(new SelectOption('Close_Forecasted_Assume_Date__c', '预测OCSM签约日(担当)'));
     //SWAG-C9NC23 【委托】[重要,优先!]周会询价管理表修改   lt   20211217  end
  
     dateOpts.add(new SelectOption('CloseDate', '预测发货日'));
     dateOpts.add(new SelectOption('CloseDate', '预测发货日'));  //20220506 lt update
     dateOpts.add( new SelectOption('Created_Day__c', '创建日'));
     dateOpts.add(new SelectOption('Last_Follow_Up_Date__c', '最后跟进日'));//***********************
     // 日付検索に標準のLastModifiedDate(日時項目)は使えない、数式項目を利用
@@ -138,17 +145,27 @@
     dateOpts.add( new SelectOption('Situation_last_update_day__c', '最后更新日-询价跟进情况'));
     dateOpts.add( new SelectOption('Manager_feedback_last_update__c', '最后更新日-经理反馈'));
     dateOpts.add( new SelectOption('Follow_up_plan_last_update__c', '最后更新日-推进计划'));
     //进口论证 fy start
     dateOpts.add( new SelectOption('ImportDemonstration_Filing_date__c', '进口论证申请日'));
     dateOpts.add( new SelectOption('ImportDemonstration_Approval_date__c', '进口论证批准日'));
     dateOpts.add( new SelectOption('ImportDemonstration_Rejection_date__c', '进口论证驳回日'));
     //进口论证 fy end
  
     textOpts = new List<SelectOption>();
     textOpts.add(new SelectOption('','--无--'));
     textOpts.add(new SelectOption('S:Name','询价名称'));
     textOpts.add(new SelectOption('S:Opportunity_No__c',Schema.SObjectType.Opportunity.fields.Opportunity_No__c.label));
     textOpts.add(new SelectOption('S:HP_Name__c','医院名'));
     textOpts.add(new SelectOption('S:Owner_Category__c','课'));// 20220907 XLIU-CHY4JL you
     // TODO xudan 20140626 状态1をチェックボックスに、ここ要らない?
     textOpts.add(new SelectOption('S:Owner.Salesdepartment__c','本部'));
     textOpts.add(new SelectOption('S:Owner.Province__c','省'));
     textOpts.add(new SelectOption('S:Owner.Group__c','组'));
     textOpts.add(new SelectOption('S:StageName__c','状态1'));
     //DB202211286315 【周会-询价管理表】筛选项增加“状态2”  xxf 20221115 start
     textOpts.add(new SelectOption('S:Status_Formula__c','状态2'));
     //DB202211286315 【周会-询价管理表】筛选项增加“状态2”  xxf 20221115 end
     textOpts.add(new SelectOption('S:Owner.Name','担当人'));
     textOpts.add(new SelectOption('S:OCM__c','OCSM分类'));
     textOpts.add(new SelectOption('S:Department_Name__c','科室名'));
@@ -161,6 +178,12 @@
     textOpts.add(new SelectOption('S:Competitor__c','询价等级'));
     //textOpts.add(new SelectOption('S:OPD_SIS_collect_evaluation_sight__r.Name',Schema.SObjectType.Opportunity.fields.OPD_SIS_collect_evaluation_sight__c.label));
     textOpts.add(new SelectOption('S:Forecast_this_month__c','本月预测'));
     //DB202211121149 【周会-询价管理】周会询价表把“资金来源”添加到“数据字段”中进行筛选  xxf 20221109 start
     textOpts.add(new SelectOption('S:Fund_Basis__c','资金来源'));
     //DB202211121149 【周会-询价管理】周会询价表把“资金来源”添加到“数据字段”中进行筛选  xxf 20221109 end
     //进口论证 fy start
     textOpts.add(new SelectOption('t:if_NeedImportDemonstration__c','需要进口论证'));
     //进口论证 fy end
     //textOpts.add(new SelectOption('N:Lapsed_Days__c',Schema.SObjectType.Opportunity.fields.Lapsed_Days__c.label));
     //textOpts.add(new SelectOption('S:Rating01__c','1月末询价状态'));
     //textOpts.add(new SelectOption('S:Rating02__c','2月末询价状态'));
@@ -206,17 +229,20 @@
   }
  
   public PageReference init() {
     System.debug('lt123 --- init start --- : ' + System.currentTimeMillis());
     // xudan 20140626 状态1をチェックボックスに
     onlyOpp = true;
     //【委托】【重要】周会管理表修改  tcm start
     OpptyWait = false;
     //【委托】【重要】周会管理表修改  tcm end
     //20140822 追加 by katsu start
     System.debug('lt123 --- 查user开始 --- : ' + System.currentTimeMillis());
     String uidParam = System.currentPageReference().getParameters().get('uid');
     if (uidParam != null) {
      User u = [select Id, FirstName, LastName from User where Id = :uidParam];
      ownerSearch = u.LastName + ' ' + u.FirstName;
     }
     System.debug('lt123 --- 查user结束 --- : ' + System.currentTimeMillis());
     String hpidParam = System.currentPageReference().getParameters().get('hpid');
     if(hpidParam != null) {
      List<Account> hpAcc = ControllerUtil.selectAccountForTrigger(new String[] {hpidParam});
@@ -224,14 +250,26 @@
        accSearch = hpAcc[0].name;
      }
     }
     System.debug('lt123 --- 调用searchOppSetParam()前 --- : ' + System.currentTimeMillis());
     //20140822 追加 by katsu end
  
     searchOppSetParam();
     System.debug('lt123 --- 调用searchOppSetParam()后,setLayoutRWInfo()前 --- : ' + System.currentTimeMillis());
     setLayoutRWInfo();
     System.debug('lt123 --- 调用setLayoutRWInfo()后 --- : ' + System.currentTimeMillis());
     this.sortOrderAsc = true;
     this.sortOrder = new String[columus.size()];
     for (Integer i = 0; i < columus.size(); i++) this.sortOrder[i] = ' ';
     System.debug('lt123 --- 调用searchOppInner()前 --- : ' + System.currentTimeMillis());
     searchOppInner();
     System.debug('lt123 --- 调用searchOppInner()后 --- : ' + System.currentTimeMillis());
     System.debug('columnMoneyFlgMapvalue:'+columnMoneyFlgMap);
     System.debug('columnMoneyMapvalue:'+columnMoneyMap);
     System.debug('columnRightCss:'+columnRightCss);
     columnRightCsscopy =columnRightCss;
     titleRightcopy = titleRight;
     columnsRightApicopy = columnsRightApi;
     System.debug('lt123 --- init end --- : ' + System.currentTimeMillis());
     return null;
   }
  
@@ -348,6 +386,8 @@
        }
        // 「1月末」を設定したら、12ヶ月分を設定と見なす
        // 設定の順番や、欠番などを考慮せず
      System.debug('splitFieldPath:'+splitFieldPath);
      System.debug('splitFieldPath[0]:'+splitFieldPath[0]);
        if (splitFieldPath.size() == 1 && splitFieldPath[0] == 'Rating01__c') {
         ratingStartIdx = cnt;
        }
@@ -364,10 +404,17 @@
        } else {
         columnRightRW.put(fsm.getFieldPath(), 'r');
        }
        tmpColRight.add(fsm.getFieldPath());
        cnt++;
      }
     //SWAG-CFN8JP 【委托】 【委托】【FY23询价改善】-询价预测时间改善 fy start
     if(columnRightRW.containsKey('Close_Forecasted_Assume_Date__c')){
      columnRightRW.put('Close_Forecasted_Assume_Date__c', 'r');
     }
     if(columnRightRW.containsKey('Close_Forecasted_Date__c')){
      columnRightRW.put('Close_Forecasted_Date__c', 'r');
     }
     //SWAG-CFN8JP 【委托】 【委托】【FY23询价改善】-询价预测时间改善 fy end
      for (String s : tmpColRight) {
        if (columusSet.contains(s) == false) {
         columus.add(s);
@@ -512,32 +559,54 @@
     return null;
   }
  
   //XLIU-CGF4TA 【委托】 【询价管理改善需求评估】询价中的进口论证判断 增加保存的修改,只保存可以修改的字段 start
   private Opportunity makeUpdateOpp(Opportunity oppinline) {
     Opportunity ret = new Opportunity();
     ret.Id = oppinline.Id;
     for (String leftkey : columnLeftRW.keySet()) {
      if (!'r'.equals(columnLeftRW.get(leftkey))) {
        ret.put(leftkey, oppinline.get(leftkey));
      }
     }
     for (String rightkey : columnRightRW.keySet()) {
      if (!'r'.equals(columnRightRW.get(rightkey))) {
        ret.put(rightkey, oppinline.get(rightkey));
      }
     }
     return ret;
   }
   //XLIU-CGF4TA 【委托】 【询价管理改善需求评估】询价中的进口论证判断 增加保存的修改,只保存可以修改的字段 end
   public PageReference save() {
     try {
      List<Opportunity> updOpps = new List<Opportunity>();
  
      List<String> oppidList = new List<String>();
      Map<String, String> oppidMap = new Map<String, String>();
      for (OppInfo oi : oppRecords) {
        if (oi.changeFlg == '1') {
         if (oppidMap.containsKey(oi.rec.Id) == false) {
           oppidList.add(oi.rec.Id);
         }
        }
      }
     // List<String> oppidList = new List<String>();
     // Map<String, String> oppidMap = new Map<String, String>();
     // for (OppInfo oi : oppRecords) {
     //   if (oi.changeFlg == '1') {
     //   if (oppidMap.containsKey(oi.rec.Id) == false) {
     //     oppidList.add(oi.rec.Id);
     //   }
     //   }
     // }
  
      Map<String, Opportunity> oppMap = new Map<String, Opportunity>();
      List<Opportunity> oppList = [select Id, Competitor__c from Opportunity where Id = :oppidList];
      for (Opportunity opp : oppList) {
        oppMap.put(opp.Id, opp);
      }
     // Map<String, Opportunity> oppMap = new Map<String, Opportunity>();
     // List<Opportunity> oppList = [select Id, Competitor__c from Opportunity where Id = :oppidList];
     // for (Opportunity opp : oppList) {
     //   oppMap.put(opp.Id, opp);
     // }
  
      for (OppInfo oi : oppRecords) {
        // 変更チェック
        if (oi.changeFlg == '1') {
         oi.changeFlg = '0';
         oi.rec.Competitor__c = oppMap.get(oi.rec.Id).Competitor__c;
         updOpps.add(oi.rec);
      // oi.rec.Competitor__c = oppMap.get(oi.rec.Id).Competitor__c;
      // updOpps.add(oi.rec);
      Opportunity up_opp = makeUpdateOpp(oi.rec);
      // up_opp.Competitor__c = oppMap.get(oi.rec.Id).Competitor__c;
      System.debug('up_opp: ' + up_opp);
      updOpps.add(up_opp);
        }
      }
  
@@ -555,6 +624,9 @@
      sortTable();
      saveType = '';
     } else {
        //进口论证 fy start
        searchOpp();
        //进口论证 fy end
     }
     return null;
   }
@@ -567,6 +639,29 @@
                     String datefield, Date fromd, Date tod, String txt, String con, String val,
                     String txt2, String con2, String val2,
                     String txt3, String con3, String val3,Boolean OpptyWait) {
     //进口论证 fy start
   //   if(txt=='if_NeedImportDemonstration__c'){
   //    if(val=='是'){
   //       val = 'true';
   //    }else if(val=='否'){
   //       val = 'false';
   //    }
   //   }
   //   if(txt2=='if_NeedImportDemonstration__c'){
   //    if(val2=='是'){
   //       val2 = 'true';
   //    }else if(val2=='否'){
   //       val2 = 'false';
   //    }
   //   }
   //   if(txt3=='if_NeedImportDemonstration__c'){
   //    if(val3=='是'){
   //       val3 = 'true';
   //    }else if(val3=='否'){
   //       val3 = 'false';
   //    }
   //   }
     //进口论证 fy end
     String soql ='';
     if (isforMoneyFlg == false) {
      soql += 'select ' + strColumus + ' from Opportunity where (RecordType.DeveloperName = \'Opportunity\' or RecordType.DeveloperName = \'SI_Oppor\')';
@@ -575,7 +670,7 @@
  + ' Estimation_List_Price__c, Estimation_Id__c, Estimation_No__c, Last_Shipping_Scheduled_Date__c,  Last_Shipping_Date__c,'
  + ' Last_Follow_Up_Date__c, CreatedDate, LastModified_Day__c, Closing_Bid_Date__c, Important_Rroduct_Flg__c,'//Owner.Brief_Name__c,
  + ' Rating01__c, Rating02__c, Rating03__c, Rating04__c, Rating05__c, Rating06__c,'
  + ' Rating07__c, Rating08__c, Rating09__c, Rating10__c, Rating11__c, Rating12__c,'
   + ' Rating07__c, Rating08__c, Rating09__c, Rating10__c, Rating11__c, Rating12__c,Owner_Category__c,'
  + ' HP_Name__c, Sales_incharge__c, Wholesale_Price_F__c, Agency1__c, '//Estimation_List_Price_Formula__c, OCM_Agent1_Price_Formula__c,
  + ' Segment__c, Opp_Code__c, Open_Quotation__c, Competitor__c, Bid_Planned_Date__c,'
  + ' Close_Forecasted_Date__c, CloseDate, Follow_up_comment__c, Department_Name__c,'
@@ -595,7 +690,7 @@
  + ' convertCurrency(Estimation_List_Price__c), Estimation_Id__c, Estimation_No__c, Last_Shipping_Scheduled_Date__c,  Last_Shipping_Date__c,'
  + ' Last_Follow_Up_Date__c, CreatedDate, LastModified_Day__c, Closing_Bid_Date__c, Important_Rroduct_Flg__c,'//Owner.Brief_Name__c,
  + ' Rating01__c, Rating02__c, Rating03__c, Rating04__c, Rating05__c, Rating06__c,'
  + ' Rating07__c, Rating08__c, Rating09__c, Rating10__c, Rating11__c, Rating12__c,'
   + ' Rating07__c, Rating08__c, Rating09__c, Rating10__c, Rating11__c, Rating12__c,Owner_Category__c,'
  + ' HP_Name__c, Sales_incharge__c, convertCurrency(Wholesale_Price_F__c), Agency1__c, '//Estimation_List_Price_Formula__c, OCM_Agent1_Price_Formula__c,
  + ' Segment__c, Opp_Code__c, Open_Quotation__c, Competitor__c, Bid_Planned_Date__c,'
  + ' Close_Forecasted_Date__c, CloseDate, Follow_up_comment__c, Department_Name__c, '
@@ -748,9 +843,42 @@
   private String makeTextSqlStr(String txt1, String con, String val) {
     String soql = '';
     if (!String.isBlank(txt1)) {
//DB202211121149 【周会-询价管理】周会询价表把“资金来源”添加到“数据字段”中进行筛选  xxf 20221109 start
        if (txt1 == 'S:Fund_Basis__c') {
           if(val == '医院资金'){
           val = val.replaceAll('医院资金', '病院資金');
           }
           if(val == '政府拨款'){
           val = val.replaceAll('政府拨款', '政府資金');
           }
           if(val == '国际资金'){
           val = val.replaceAll('国际资金', '国際資金');
           }
           if(val == '银行资金'){
           val = val.replaceAll('银行资金', '銀行資金');
           }
           if(val == '公司/个人投资'){
           val = val.replaceAll('公司/个人投资', '会社/個人資金');
           }
           if(val == '融资租赁'){
           val = val.replaceAll('融资租赁', '融资租赁(リース)');
           }
        }
//DB202211121149 【周会-询价管理】周会询价表把“资金来源”添加到“数据字段”中进行筛选  xxf 20221109 end
      String txt = txt1.substring(2);
      String colType = txt1.substring(0, 2);
      String tmpVal = val;
     //进口论证 fy start
     if(txt=='if_NeedImportDemonstration__c'){
         if(tmpVal=='是'){
            tmpVal = 'true';
         }else if(tmpVal=='否'){
            tmpVal = 'false';
         }else {
            return soql;
         }
     }
     //进口论证 fy end
      // 空白の場合''にする
      if (String.isBlank(tmpVal)) {
        if (con == 'equals') {
@@ -837,7 +965,48 @@
  
     return 'Rating' + rtn + '__c';
   }
   //XLIU-CGF4TA 【委托】 【询价管理改善需求评估】询价中的进口论证判断 fy start
   // public PageReference HideForecastOCSMSigningDate() {
   //   if(HideForecastOCSMflag){
   //     List<String> HidecolumnRightCss = new List<String>();
   //     List<String> HidetitleRight = new List<String>();
   //     List<List<String> > HidecolumnsRightApiList = new List<List<String> >();
   //     for(List<String> colrightapiList: columnsRightApicopy){
   //       List<String> HidecolumnsRightApi = new List<String>();
   //       for(String colrightapi :colrightapiList){
   //         if(colrightapi != 'Close_Forecasted_Date__c'&&colrightapi != 'Close_Forecasted_Assume_Date__c'&&colrightapi != 'CloseDate'){
   //           HidecolumnsRightApi.add(colrightapi);
   //         }
   //       }
   //       if(HidecolumnsRightApi.size()>0){
   //         HidecolumnsRightApiList.add(HidecolumnsRightApi);
   //       }
   //     }
   //     for(String colright: columnRightCsscopy){
   //       if(colright != 'Close_Forecasted_Date__c'&&colright != 'Close_Forecasted_Assume_Date__c'&&colright != 'CloseDate'){
   //         HidecolumnRightCss.add(colright);
   //       }
   //     }
   //     for(String titlr: titleRightcopy){
   //       if(titlr != '预测OCSM签约日(KPI)'&&titlr != '预测OCSM签约日(担当)'&&titlr != '预测发货日'){
   //         HidetitleRight.add(titlr);
   //       }
   //     }
   //     columnsRightApi=HidecolumnsRightApiList;
   //     columnRightCss=HidecolumnRightCss;
   //     titleRight=HidetitleRight;
   //   }else{
   //     system.debug('测试1'+titleRightcopy);
   //     system.debug('测试2'+columnsRightApicopy);
   //     system.debug('测试3'+columnRightCsscopy);
   //     titleRight=titleRightcopy;
   //     columnsRightApi=columnsRightApicopy;
   //     columnRightCss=columnRightCsscopy;
   //   }
  
   //   return null;
   // }
   //SWAG-CGG7UK 【委托】 【询价管理改善需求评估】询价中的进口论证判断 fy end
   class OppInfo {
     public Opportunity rec { get; set; }
     public Boolean canEdit { get; private set; }