From 744f42c5496e656a1f9927740a3b37c0b97a6cba Mon Sep 17 00:00:00 2001
From: buli <137736985@qq.com>
Date: 星期五, 14 七月 2023 14:34:12 +0800
Subject: [PATCH] lexcommunityupload0714

---
 force-app/main/default/classes/DealerInquiryModifyStateController.cls | 1315 +++++++++++++++++++++++++++-------------------------------
 1 files changed, 614 insertions(+), 701 deletions(-)

diff --git a/force-app/main/default/classes/DealerInquiryModifyStateController.cls b/force-app/main/default/classes/DealerInquiryModifyStateController.cls
index 2d8fda5..9e6c25c 100644
--- a/force-app/main/default/classes/DealerInquiryModifyStateController.cls
+++ b/force-app/main/default/classes/DealerInquiryModifyStateController.cls
@@ -1,731 +1,644 @@
 public with sharing class DealerInquiryModifyStateController {
-  public List<OpportunityInfo> oppRecords { get; set; }
-  // 銉氥兗銈搞儸銈ゃ偄銈︺儓銇儏鍫便倰鍙栧緱
-  private Map<String, Map<String, String>> editLayoutItemRWMap = new Map<String, Map<String, String>>();
-  // private Map<String, Map<String, String>> editLayoutItemRWMapRt = null;
-  public List<OpportunityInfo> OPPORTList { get; set; }
-  /*****************妞滅储鐢�******************/
+    public List<OpportunityInfo> oppRecords { get; set; }
+    // 銉氥兗銈搞儸銈ゃ偄銈︺儓銇儏鍫便倰鍙栧緱
+    private Map<String, Map<String, String>> editLayoutItemRWMap = New Map<String, Map<String, String>>();
+    // private Map<String, Map<String, String>> editLayoutItemRWMapRt = null;
+    public List<OpportunityInfo> OPPORTList { get; set; }
+    /*****************妞滅储鐢�******************/
 
-  /*******************妫�绱㈠睘鎬у��*******************/
+    /*******************妫�绱㈠睘鎬у��*******************/
 
-  public String accSearch { get; set; } //缁忛攢鍟嗗尰闄�
-  public String aooSearch { get; set; } //鎷呭綋浜�
-  public String numtext1 { get; set; } //鏁版嵁瀛楁01
-  public String numtext { get; set; } //鏁版嵁瀛楁03
-  public String numtext2 { get; set; } //鏁版嵁瀛楁02
-  public String timetext1 { get; set; } //鏃ユ湡01
-  public String timetext2 { get; set; } //鏃ユ湡02
-  public Agency_Opportunity__c tmpAO { get; set; } //妫�绱㈡棩鏈熺敤
-  public Agency_Opportunity__c tmpBO { get; set; } //妫�绱㈡棩鏈熺敤
-  public String limits { get; set; } //鏃ユ湡03
+    public String accSearch { get; set; }//缁忛攢鍟嗗尰闄�
+    public String aooSearch { get; set; }//鎷呭綋浜�
+    public String numtext1 { get; set; } //鏁版嵁瀛楁01
+    public String numtext { get; set; }//鏁版嵁瀛楁03
+    public String numtext2 { get; set; } //鏁版嵁瀛楁02
+    public String timetext1 { get; set; } //鏃ユ湡01
+    public String timetext2 { get; set; } //鏃ユ湡02
+    public Agency_Opportunity__c tmpAO { get; set; } //妫�绱㈡棩鏈熺敤
+    public Agency_Opportunity__c tmpBO { get; set; } //妫�绱㈡棩鏈熺敤
+    public String limits { get; set; }//鏃ユ湡03
 
-  public List<SelectOption> dateOpts { get; private set; }
-  public List<SelectOption> textOpts { get; private set; }
-  public List<SelectOption> timeOpts { get; private set; }
-  public List<SelectOption> equalOpts { get; private set; }
-  public List<SelectOption> timeequalOpts { get; private set; }
-  public List<SelectOption> limitOpts { get; private set; }
+    public List<SelectOption> dateOpts { get; private set; }
+    public List<SelectOption> textOpts { get; private set; }
+    public List<SelectOption> timeOpts { get; private set; }
+    public List<SelectOption> equalOpts { get; private set; }
+    public List<SelectOption> timeequalOpts { get; private set; }
+    public List<SelectOption> limitOpts { get; private set; }
 
-  /*****************鐢婚潰琛ㄧずBean******************/
-  public Integer oppCount { get; set; }
-  public String saveType { get; set; }
+    /*****************鐢婚潰琛ㄧずBean******************/
+    public Integer oppCount { get; set; }
+    public String saveType { get; set; }
 
-  public String sortKey { get; set; }
-  public String preSortKey { get; set; }
-  public Boolean sortOrderAsc { get; set; }
-  public String[] sortOrder { get; set; }
-  public String[] columus = new List<String>{ 'Id' };
-  public String[] selColumus = null;
-  public Set<String> columusSet = new Set<String>{ 'Id' };
+    public String sortKey { get; set; }
+    public String preSortKey { get; set; }
+    public Boolean sortOrderAsc { get; set; }
+    public String[] sortOrder { get; set; }
+    public String[] columus = new String[] {'Id'};
+    public String[] selColumus = null;
+    public Set<String> columusSet = new Set<String> {'Id'};
 
-  // 椤圭洰set 瀛楁鏍囩
-  public List<String> titleLeft { get; private set; }
-  public List<String> titleRight { get; private set; }
-  // 椤圭洰set 瀛楁鍚�
-  public List<List<String>> columnsLeftApi { get; private set; } // 鍙傜収闋呯洰鐢�
-  public List<List<String>> columnsRightApi { get; private set; } // 鍙傜収闋呯洰鐢�
-  public List<String> columnLeftCss { get; private set; } // css 鐢�
-  public List<String> columnRightCss { get; private set; } // css 鐢�
-  public Map<String, String> columnLeftRW { get; private set; } // r,w,wm鐢�
-  public Map<String, String> columnRightRW { get; private set; } // r,w,wm鐢�
-  private String strColumus;
-  private String strRtColumus;
+    // 椤圭洰set 瀛楁鏍囩
+    public List<String> titleLeft { get; private set; }
+    public List<String> titleRight { get; private set; }
+    // 椤圭洰set 瀛楁鍚�
+    public List<List<String>> columnsLeftApi { get; private set; }         // 鍙傜収闋呯洰鐢�
+    public List<List<String>> columnsRightApi { get; private set; }        // 鍙傜収闋呯洰鐢�
+    public List<String> columnLeftCss { get; private set; }               // css 鐢�
+    public List<String> columnRightCss { get; private set; }              // css 鐢�
+    public Map<String, String> columnLeftRW { get; private set; }              // r,w,wm鐢�
+    public Map<String, String> columnRightRW { get; private set; }             // r,w,wm鐢�
+    private String strColumus;
+    private String strRtColumus;
 
-  //add by Link 2023-6-2
-  public String remindMsg { get; set; }
+    //add by Link 2023-6-2
+    public String remindMsg{get;set;}
 
-  @TestVisible
-  private String accTypeForSort = null;
-  private static Integer oppLimit = 500;
+    @TestVisible private String accTypeForSort = null;
+    private static Integer oppLimit = 500;
 
-  public DealerInquiryModifyStateController() {
-    oppRecords = new List<OpportunityInfo>();
+    public DealerInquiryModifyStateController() {
+        oppRecords = new List<OpportunityInfo>();
 
-    //dateOpts = new List<SelectOption>();
-    //dateOpts.add(new SelectOption('', '--鏃�--'));
-    //dateOpts.add(new SelectOption('Registration_Day__c', '鐧诲綍鏃�'));
-    //dateOpts.add(new SelectOption('Ban_On_Use_Date__c', '绂佺敤鏃ユ湡'));
+        //dateOpts = new List<SelectOption>();
+        //dateOpts.add(new SelectOption('', '--鏃�--'));
+        //dateOpts.add(new SelectOption('Registration_Day__c', '鐧诲綍鏃�'));
+        //dateOpts.add(new SelectOption('Ban_On_Use_Date__c', '绂佺敤鏃ユ湡'));
 
-    //鏁版嵁瀛楁涓嬫媺鍒楄〃
-    textOpts = new List<SelectOption>();
-    textOpts.add(new SelectOption('', '--鏃�--'));
-    textOpts.add(
-      new SelectOption('Agency_Opportunity_No__c', '缁忛攢鍟嗚浠风紪鐮�')
-    );
-    textOpts.add(new SelectOption('Agency__r.Name', '缁忛攢鍟�'));
-    textOpts.add(new SelectOption('Agency_Hospital__r.Name', '缁忛攢鍟嗗尰闄�'));
-    textOpts.add(new SelectOption('Department_Cateogy__c', '绉戝鍒嗙被'));
-    textOpts.add(new SelectOption('Change_To_Opportunity_T__c', '璇环鍚嶇О'));
-    // textOpts.add(new SelectOption('Name', '璇环鍚嶇О'));
+        //鏁版嵁瀛楁涓嬫媺鍒楄〃
+        textOpts = new List<SelectOption>();
+        textOpts.add(new SelectOption('', '--鏃�--'));
+        textOpts.add(new SelectOption('Agency_Opportunity_No__c', '缁忛攢鍟嗚浠风紪鐮�'));
+        textOpts.add(new SelectOption('Agency__r.Name', '缁忛攢鍟�'));
+        textOpts.add(new SelectOption('Agency_Hospital__r.Name', '缁忛攢鍟嗗尰闄�'));
+        textOpts.add(new SelectOption('Department_Cateogy__c', '绉戝鍒嗙被'));
+        textOpts.add(new SelectOption('Change_To_Opportunity_T__c', '璇环鍚嶇О'));
+        // textOpts.add(new SelectOption('Name', '璇环鍚嶇О'));
 
-    textOpts.add(new SelectOption('StageName__c', '璇环闃舵'));
-    textOpts.add(new SelectOption('Oly_Inquiry_Status1__c', '鐘舵��1'));
-    //绮剧悽绉戞妧   zxk    2021-08-25   start
-    // textOpts.add(new SelectOption('Oly_Inquiry_Status2__c', '鐘舵��2'));
-    textOpts.add(new SelectOption('Oly_Inquiry_Stage__c', 'Oly璇环闃舵'));
-    //绮剧悽绉戞妧   zxk    2021-08-25   end
-    textOpts.add(new SelectOption('Hospital_City_Master__c', '甯�'));
-
-    // textOpts.add(new SelectOption('Agency_Hospital__r.Hospital__r.Salesdepartment_HP__c', '閿�鍞湰閮�'));
-    // textOpts.add(new SelectOption('Agency_Hospital__r.Hospital__r.State_Master__r.Name', '鐪�'));
-    // textOpts.add(new SelectOption('Agency_Hospital__r.Hospital__r.City_Master__r.Name', '甯�'));
-    //鏃ユ湡瀛楁涓嬫媺鍒楄〃
-    timeOpts = new List<SelectOption>();
-    timeOpts.add(new SelectOption('', '--鏃�--'));
-    timeOpts.add(new SelectOption('Created_Day__c', '鍒涘缓鏃�'));
-    timeOpts.add(new SelectOption('Bid_Planned_Date__c', '棰勬祴鎷涙爣鏃�'));
-    timeOpts.add(new SelectOption('Forecasted_Bid_Date__c', '棰勬祴涓爣鏃�'));
-    timeOpts.add(
-      new SelectOption('Close_Forecasted_Date__c', '棰勬祴涓嶰LY绛剧害鏃�')
-    );
-    timeOpts.add(new SelectOption('Lost_Opportunity_Date__c', '澶卞崟鏃ユ湡'));
-    timeOpts.add(new SelectOption('Deleted_Reason_Date__c', '鍙栨秷鏃ユ湡'));
-    //鏁版嵁瀛楁涓棿杩炴帴绗﹀彿
-    equalOpts = new List<SelectOption>();
-    equalOpts.add(new SelectOption('=', '绛変簬'));
-    equalOpts.add(new SelectOption('<>', '涓嶇瓑浜�'));
-    equalOpts.add(new SelectOption('<', '<'));
-    equalOpts.add(new SelectOption('>', '>'));
-    equalOpts.add(new SelectOption('<=', '<='));
-    equalOpts.add(new SelectOption('>=', '>='));
-    equalOpts.add(new SelectOption('contains', '鍖呭惈'));
-    equalOpts.add(new SelectOption('notcontains', '涓嶅寘鍚�'));
-    equalOpts.add(new SelectOption('starts with', '璧峰瀛楃'));
-    //鏃ユ湡瀛楁杩炴帴绗﹀彿
-    //timeequalOpts = new List<SelectOption>();
-    //timeequalOpts.add(new SelectOption('=', '绛変簬'));
-    //timeequalOpts.add(new SelectOption('<>', '涓嶇瓑浜�'));
-    //timeequalOpts.add(new SelectOption('<', '<'));
-    //timeequalOpts.add(new SelectOption('>', '>'));
-    //timeequalOpts.add(new SelectOption('<=', '<='));
-    //timeequalOpts.add(new SelectOption('>=', '>='));
-    //鏁版嵁鏄剧ず鏉℃暟
-    limitOpts = new List<SelectOption>();
-    limitOpts.add(new SelectOption('10', '10'));
-    limitOpts.add(new SelectOption('20', '20'));
-    limitOpts.add(new SelectOption('50', '50'));
-    limitOpts.add(new SelectOption('100', '100'));
-    limitOpts.add(new SelectOption('200', '200'));
-    limitOpts.add(new SelectOption('1000', '鍏ㄩ儴'));
-    //鏁版嵁鏄剧ず榛樿鏉℃暟
-    limits = '20';
-  }
-
-  public PageReference init() {
-    remindMsg = '';
-    PartnerSoapSforceCom.Soap soap = new PartnerSoapSforceCom.Soap();
-    soap.SessionHeader = new PartnerSoapSforceCom.SessionHeader_element();
-    soap.SessionHeader.sessionId = UserInfo.getSessionId();
-    soap.endpoint_x =
-      URL.getSalesforceBaseUrl().toExternalForm() +
-      '/partner/services/Soap/u/33.0';
-    // soap.endpoint_x = URL.getSalesforceBaseUrl().toExternalForm() + '/services/Soap/u/33.0';
-
-    PartnerSoapSforceCom.DescribeLayoutResult dlr = new PartnerSoapSforceCom.DescribeLayoutResult();
-    if (System.Test.isRunningTest()) {
-      // UnitTest 鐢�
-      // PartnerSoapSforceCom.DescribeLayoutResult dlr = new PartnerSoapSforceCom.DescribeLayoutResult();
-      PartnerSoapSforceCom.RecordTypeMapping rtMap = new PartnerSoapSforceCom.RecordTypeMapping();
-      PartnerSoapSforceCom.DescribeLayout editLayout = new PartnerSoapSforceCom.DescribeLayout();
-      PartnerSoapSforceCom.DescribeLayoutSection editLayoutSection = new PartnerSoapSforceCom.DescribeLayoutSection();
-      PartnerSoapSforceCom.DescribeLayoutRow layoutRow = new PartnerSoapSforceCom.DescribeLayoutRow();
-      PartnerSoapSforceCom.DescribeLayoutItem layoutItem = new PartnerSoapSforceCom.DescribeLayoutItem();
-      PartnerSoapSforceCom.DescribeLayoutComponent layoutComponent = new PartnerSoapSforceCom.DescribeLayoutComponent();
-      dlr.recordTypeMappings = new List<PartnerSoapSforceCom.RecordTypeMapping>();
-      dlr.recordTypeMappings.add(rtMap);
-      rtMap.recordTypeId = 'recordTypeId';
-      dlr.layouts = new List<PartnerSoapSforceCom.DescribeLayout>();
-      dlr.layouts.add(editLayout);
-      editLayout.editLayoutSections = new List<PartnerSoapSforceCom.DescribeLayoutSection>();
-      editLayout.editLayoutSections.add(editLayoutSection);
-      editLayoutSection.layoutRows = new List<PartnerSoapSforceCom.DescribeLayoutRow>();
-      editLayoutSection.layoutRows.add(layoutRow);
-      layoutRow.layoutItems = new List<PartnerSoapSforceCom.DescribeLayoutItem>();
-      layoutRow.layoutItems.add(layoutItem);
-      layoutItem.layoutComponents = new List<PartnerSoapSforceCom.DescribeLayoutComponent>();
-      layoutItem.layoutComponents.add(layoutComponent);
-      // return dlr;
-    } else {
-      dlr = soap.describeLayout('Agency_Opportunity__c', null, null);
-      // dlr  = soap.describeLayout('asdas', null, null);
-    }
-
-    // PartnerSoapSforceCom.DescribeLayoutResult dlr  = soap.describeLayout('Agency_Opportunity__c', null, null);
-    Map<String, PartnerSoapSforceCom.DescribeLayout> layputMap = new Map<String, PartnerSoapSforceCom.DescribeLayout>();
-    for (PartnerSoapSforceCom.DescribeLayout layout : dlr.layouts) {
-      layputMap.put(layout.id, layout);
-    }
-    for (Integer lidx = 0; lidx < dlr.recordTypeMappings.size(); lidx++) {
-      String recordTypeId = dlr.recordTypeMappings[lidx].recordTypeId;
-      Map<String, String> rtnInner = new Map<String, String>();
-      editLayoutItemRWMap.put(recordTypeId, rtnInner);
-      System.debug('recordTypeId=' + recordTypeId);
-      PartnerSoapSforceCom.DescribeLayout layout = layputMap.get(
-        dlr.recordTypeMappings[lidx].layoutId
-      );
-      for (
-        PartnerSoapSforceCom.DescribeLayoutSection section : layout.editLayoutSections
-      ) {
-        for (PartnerSoapSforceCom.DescribeLayoutRow row : section.layoutRows) {
-          for (PartnerSoapSforceCom.DescribeLayoutItem item : row.layoutItems) {
-            if (
-              item.layoutComponents != null &&
-              item.layoutComponents.size() > 0 &&
-              String.isBlank(item.layoutComponents[0].value) == false
-            ) {
-              rtnInner.put(item.layoutComponents[0].value, 'r');
-              if (item.editableForUpdate) {
-                rtnInner.put(item.layoutComponents[0].value, 'w');
-              }
-              if (item.required) {
-                rtnInner.put(item.layoutComponents[0].value, 'wm');
-              }
-            }
-          }
-        }
-      }
-    }
-    // editLayoutItemRWMap = SoapApi.getEditRWByRecordType('Agency_Opportunity__c', null);
-    tmpAO = new Agency_Opportunity__c();
-    tmpBO = new Agency_Opportunity__c();
-    setLayoutRWInfo();
-    searchOppInner();
-    return null;
-  }
-  //鐢ㄤ簬鑾峰彇缁忛攢鍟嗚浠峰瓧娈甸泦鍜岃浠峰瓧娈甸泦浠ュ強鐩稿簲鐨勮鍐欐潈闄�
-  @TestVisible
-  private void setLayoutRWInfo() {
-    if (this.sortOrder == null) {
-      selColumus = new List<String>{};
-      strColumus = '';
-      ID accRecordTypeId = accTypeForSort;
-
-      Map<String, String> DESC_RW = editLayoutItemRWMap.get(
-        '012100000006KW7AAM'
-      );
-      Map<String, Schema.FieldSet> fsMap = Schema.getGlobalDescribe()
-        .get('Agency_Opportunity__c')
-        .getDescribe()
-        .fieldSets.getMap();
-      Schema.FieldSet fs = fsMap.get('DealerInquiryModifyState');
-      List<FieldSetMember> fsmList = fs.getFields();
-      titleLeft = new List<String>();
-      List<String> columnLeft = new List<String>();
-      columnLeftCss = new List<String>();
-      columnsLeftApi = new List<List<String>>();
-      columnLeftRW = new Map<String, String>();
-      for (FieldSetMember fsm : fsmList) {
-        titleLeft.add(fsm.getLabel());
-        columnLeft.add(fsm.getFieldPath());
-        List<String> splitFieldPath = fsm.getFieldPath().split('\\.');
-        columnsLeftApi.add(splitFieldPath);
-        if (DESC_RW == null) {
-          columnLeftRW.put(fsm.getFieldPath(), 'r');
-        } else if (splitFieldPath.size() == 1) {
-          String rw = DESC_RW.get(fsm.getFieldPath());
-          if (rw != null) {
-            columnLeftRW.put(fsm.getFieldPath(), rw);
-          } else {
-            columnLeftRW.put(fsm.getFieldPath(), 'r');
-          }
-        } else {
-          columnLeftRW.put(fsm.getFieldPath(), 'r');
-        }
-      }
-      for (String str : columnLeftRW.keySet()) {
-        System.debug(str + '=+=+=+=+=' + columnLeftRW.get(str));
-      }
-      for (String s : columnLeft) {
-        if (columusSet.contains(s) == false) {
-          columus.add(s);
-          columusSet.add(s);
-        }
-        if (selColumus.contains(s) == false) {
-          selColumus.add(s);
-        }
-        columnLeftCss.add(s.replace('.', '_'));
-      }
-      strRtColumus = '';
-      Schema.FieldSet fsRt = fsMap.get('DealerOpportunity');
-      List<FieldSetMember> fsmListRt = fsRt.getFields();
-      titleRight = new List<String>();
-      List<String> columnRight = new List<String>();
-      columnRightCss = new List<String>();
-      columnsRightApi = new List<List<String>>();
-      columnRightRW = new Map<String, String>();
-
-      for (FieldSetMember fsm : fsmListRt) {
-        titleRight.add(fsm.getLabel());
-        columnRight.add(fsm.getFieldPath());
-        List<String> splitFieldPath = fsm.getFieldPath().split('\\.');
-        columnsRightApi.add(splitFieldPath);
-        if (DESC_RW == null) {
-          columnRightRW.put(fsm.getFieldPath(), 'r');
-        } else if (splitFieldPath.size() == 1) {
-          String rw = DESC_RW.get(fsm.getFieldPath());
-          if (rw != null) {
-            columnRightRW.put(fsm.getFieldPath(), rw);
-          } else {
-            columnRightRW.put(fsm.getFieldPath(), 'r');
-          }
-        } else {
-          columnRightRW.put(fsm.getFieldPath(), 'r');
-        }
-      }
-      for (String s : columnRight) {
-        selColumus.add(s);
-        if (strRtColumus == '') {
-          strRtColumus = s;
-        } else {
-          strRtColumus = strRtColumus + ',' + s;
-        }
-        columnRightCss.add(s.replace('.', '_'));
-      }
-      strColumus = String.join(columus, ',');
-      System.debug('======-======-======strColumus' + strColumus);
-      System.debug('======-======-======strRtColumus' + strRtColumus);
-      this.sortOrderAsc = true;
-      this.sortOrder = new List<String>(selColumus.size());
-      for (Integer i = 0; i < selColumus.size(); i++)
-        this.sortOrder[i] = '銆�';
-    }
-  }
-  //鐢ㄤ簬鎷兼帴SOQL璇彞 鏍规嵁涓嶅悓妫�绱㈡潯浠舵嫾鎺ヤ笉鍚孲OQL璇彞銆�
-  public void searchOppInner() {
-    //SOQL:鎷兼帴妫�绱㈡潯浠朵互鍙婄粡閿�鍟嗚浠风殑SOQL璇彞
-    // List<User> userlist2 = [select id,name from user where Contactid in (select id from Contact)];
-    // String querySoql = '';
-    // Integer queryint = 0;
-    // for(User user : userlist2){
-    //     if(queryint == 0){
-    //         querySoql += '\''+user.Id+'\'';
-    //         queryint++;
-    //     }else{
-    //         querySoql += ',\''+user.Id+'\'';
-    //     }
-
-    // }
-    // System.debug('pppqqq222'+userlist2);
-    // System.debug('pppqqq333'+querySoql);
-    // AND Ownerid in ( '+querySoql+')'
-
-    String soql =
-      'SELECT Change_To_Opportunity__r.Id , Agency_Hospital__r.Name , Product_Category1__r.Name , Product_Category2__r.Name , Product_Category3__r.Name , Agency_Person__r.Name , Agency__r.Name , Change_To_Opportunity__r.Name ,' +
-      strColumus +
-      ',' +
-      strRtColumus +
-      ' FROM Agency_Opportunity__c WHERE recordType.DeveloperName = \'Opportunity\' ';
-    //鏁版嵁瀛楁锛氱粡閿�鍟嗗尰闄�  +SOQL
-    if (!String.isBlank(accSearch)) {
-      accSearch = accSearch.trim();
-      // soql += 'AND Agency__r.Name  '   + '  LIKE  \'%' + accSearch + '%\' ';
-      soql +=
-        'AND Agency_Hospital__r.Name  ' +
-        '  LIKE  \'%' +
-        accSearch +
-        '%\' ';
-    }
-    //鏁版嵁瀛楁锛氭媴褰撲汉  +SOQL
-    if (!String.isBlank(aooSearch)) {
-      String newAooSearch = aooSearch.trim();
-      // soql += 'AND Change_To_Opportunity__r.Owner.Alias = ' + '\'' + newAooSearch + '\'';//Name
-      soql +=
-        'AND Agency_PersonName__c ' +
-        '  LIKE  \'%' +
-        newAooSearch +
-        '%\' ';
-    }
-    //鏁版嵁瀛楁锛�03 鎵嬪姩濉啓椤� 鍑嗗璋冪敤makeTextSql锛�
-    if (!String.isBlank(numtext)) {
-      String newNumtext = numtext.trim();
-      String str = makeTextSql(numtext1, numtext2, newNumtext);
-      soql += str;
-      System.debug('+++++++++++++=============++++++++++++++++++' + soql);
-    }
-    //鐐瑰嚮鎺掑簭
-    // System.debug('==-=-=-=-=-=this.sortKey'+Integer.valueOf(this.sortKey)+'===titleLeft.size'+titleLeft.size()+7);
-    if (String.isBlank(this.sortKey)) {
-      soql +=
-        ' order by LastModifiedDate desc limit ' + Integer.valueOf(limits);
-    } else {
-      if (Integer.valueOf(this.sortKey) <= titleLeft.size() + 7) {
-        soql +=
-          ' order by ' +
-          this.selColumus[Integer.valueOf(this.sortKey)] +
-          ' ' +
-          (this.sortOrderAsc == true ? 'asc nulls first' : 'desc nulls last') +
-          ' limit ' +
-          Integer.valueOf(limits);
-      } else {
-        soql +=
-          ' order by Change_To_Opportunity__r.' +
-          this.selColumus[Integer.valueOf(this.sortKey)] +
-          ' ' +
-          (this.sortOrderAsc == true ? 'asc nulls first' : 'desc nulls last') +
-          ' limit ' +
-          Integer.valueOf(limits);
-      }
-    }
-    system.debug(soql);
-    // List<User> userlist1 = [select id,name from user ];
-    // System.debug('pppqqq111'+userlist1);
-
-    List<Agency_Opportunity__c> InfoList = Database.query(soql);
-    System.debug('+++++++-------------------' + InfoList);
-
-    // List<Agency_Opportunity__c> InfoList = ControllerUtil.DatabaseQuery(soql);
-    // System.debug('InfoList[0].Change_To_Opportunity_T__c'+InfoList[0].Change_To_Opportunity_T__c);
-    for (Agency_Opportunity__c apt : InfoList) {
-      System.debug('pppqqq' + apt.Agency_PersonName__c + '====' + apt.Name);
-    }
-
-    List<OpportunityInfo> oppinfoList = new List<OpportunityInfo>();
-    if (InfoList != null && InfoList.size() > 0) {
-      String str = '';
-      for (Agency_Opportunity__c agc : InfoList) {
-        if (str == '' && agc.Change_To_Opportunity__r.Id != null) {
-          str = '\'' + agc.Change_To_Opportunity__r.Id + '\'';
-        } else if (agc.Change_To_Opportunity__r.Id != null) {
-          str += ',\'' + agc.Change_To_Opportunity__r.Id + '\'';
-        }
-      }
-      for (Agency_Opportunity__c info : InfoList) {
-        oppinfoList.add(new OpportunityInfo(info, info));
-        oppinfoList[oppinfoList.size() - 1].lineNo = oppinfoList.size() - 1;
-      }
-    }
-    oppRecords = oppinfoList.clone();
-    oppCount = oppRecords.size();
-    //鏄剧ず鎻愮ず鎿嶄綔淇℃伅
-    if (String.isBlank(this.saveType) && String.isBlank(this.sortKey)) {
-      ApexPages.addmessage(
-        new ApexPages.message(
-          ApexPages.severity.INFO,
-          '鍙栧緱鏈�杩戠殑 ' + oppCount + ' 鏉℃暟鎹�'
-        )
-      );
-      //add by Link 2023-6-2
-      remindMsg = '鍙栧緱鏈�杩戠殑 ' + oppCount + ' 鏉℃暟鎹�';
-    } else if (!String.isBlank(this.sortKey)) {
-      if (oppCount > oppLimit) {
-        ApexPages.addmessage(
-          new ApexPages.message(
-            ApexPages.severity.INFO,
-            '鏁版嵁瓒呰繃' + oppLimit + '浠讹紝鍙樉绀哄墠' + oppLimit + '浠�'
-          )
-        );
-        //add by Link 2023-6-2
-        remindMsg = '鏁版嵁瓒呰繃' + oppLimit + '浠讹紝鍙樉绀哄墠' + oppLimit + '浠�';
-      } else {
-        ApexPages.addmessage(
-          new ApexPages.message(
-            ApexPages.severity.INFO,
-            '鍏辨湁 ' + oppCount + ' 鏉℃暟鎹�'
-          )
-        );
-        //add by Link 2023-6-2
-        remindMsg = '鍏辨湁 ' + oppCount + ' 鏉℃暟鎹�';
-      }
-    } else {
-      ApexPages.addmessage(
-        new ApexPages.message(
-          ApexPages.severity.INFO,
-          '鍏辨湁 ' + oppCount + ' 鏉℃暟鎹�'
-        )
-      );
-      //add by Link 2023-6-2
-      remindMsg = '鍏辨湁 ' + oppCount + ' 鏉℃暟鎹�';
-    }
-  }
-  //妫�绱㈡潯浠讹細鏁版嵁瀛楁1锛屾暟鎹瓧娈�2锛屾暟鎹瓧娈�3鍧囨弧瓒宠繘鍏ユ鏂规硶 鍒ゆ柇澶氱鎯呭喌
-  private String makeTextSql(
-    String textOpts,
-    String equalOpts,
-    String numtext
-  ) {
-    String soql = '';
-    if (!String.isBlank(textOpts)) {
-      //瀵绘壘妫�绱㈡潯浠跺寘鍚�� 鈥� 绌烘牸鐨勫閲嶆绱㈡潯浠�
-      //system.debug('314-textOpts:'+textOpts);
-      if (
-        (equalOpts == 'contains' || equalOpts == 'notcontains') &&
-        numtext.contains(',')
-      ) {
-        //system.debug('316-equalOpts:'+equalOpts);
-        //system.debug('316-numtext:'+numtext);
-        String[] vals = numtext.split(',');
-        String cSql = '';
-        soql += ' AND (';
-        for (Integer icount = 0; icount < vals.size(); icount++) {
-          //绮剧悽绉戞妧   zxk    2021-08-25   start
-          String val = vals[icount];
-          if (equalOpts == 'contains') {
-            cSql = this.makeTextSqlStr(textOpts, equalOpts, val);
-            soql += cSql;
-
-            if (icount < vals.size() - 1) {
-              soql += ' OR ';
-            }
-          } else if (equalOpts == 'notcontains') {
-            cSql = this.makeTextSqlStr(textOpts, equalOpts, val);
-            soql += cSql;
-            if (icount < vals.size() - 1) {
-              soql += ' AND ';
-            }
-          }
-        }
+        textOpts.add(new SelectOption('StageName__c', '璇环闃舵'));
+        textOpts.add(new SelectOption('Oly_Inquiry_Status1__c', '鐘舵��1'));
+        //绮剧悽绉戞妧   zxk    2021-08-25   start
+        // textOpts.add(new SelectOption('Oly_Inquiry_Status2__c', '鐘舵��2'));
+        textOpts.add(new SelectOption('Oly_Inquiry_Stage__c', 'Oly璇环闃舵'));
         //绮剧悽绉戞妧   zxk    2021-08-25   end
+        textOpts.add(new SelectOption('Hospital_City_Master__c', '甯�'));
+        
+        // textOpts.add(new SelectOption('Agency_Hospital__r.Hospital__r.Salesdepartment_HP__c', '閿�鍞湰閮�'));
+        // textOpts.add(new SelectOption('Agency_Hospital__r.Hospital__r.State_Master__r.Name', '鐪�'));
+        // textOpts.add(new SelectOption('Agency_Hospital__r.Hospital__r.City_Master__r.Name', '甯�'));
+        //鏃ユ湡瀛楁涓嬫媺鍒楄〃
+        timeOpts = new List<SelectOption>();
+        timeOpts.add(new SelectOption('', '--鏃�--'));
+        timeOpts.add(new SelectOption('Created_Day__c', '鍒涘缓鏃�'));
+        timeOpts.add(new SelectOption('Bid_Planned_Date__c', '棰勬祴鎷涙爣鏃�'));
+        timeOpts.add(new SelectOption('Forecasted_Bid_Date__c', '棰勬祴涓爣鏃�'));
+        timeOpts.add(new SelectOption('Close_Forecasted_Date__c', '棰勬祴涓嶰LY绛剧害鏃�'));
+        timeOpts.add(new SelectOption('Lost_Opportunity_Date__c', '澶卞崟鏃ユ湡'));
+        timeOpts.add(new SelectOption('Deleted_Reason_Date__c', '鍙栨秷鏃ユ湡'));
+        //鏁版嵁瀛楁涓棿杩炴帴绗﹀彿
+        equalOpts = new List<SelectOption>();
+        equalOpts.add(new SelectOption('=', '绛変簬'));
+        equalOpts.add(new SelectOption('<>', '涓嶇瓑浜�'));
+        equalOpts.add(new SelectOption('<', '<'));
+        equalOpts.add(new SelectOption('>', '>'));
+        equalOpts.add(new SelectOption('<=', '<='));
+        equalOpts.add(new SelectOption('>=', '>='));
+        equalOpts.add(new SelectOption('contains', '鍖呭惈'));
+        equalOpts.add(new SelectOption('notcontains', '涓嶅寘鍚�'));
+        equalOpts.add(new SelectOption('starts with', '璧峰瀛楃'));
+        //鏃ユ湡瀛楁杩炴帴绗﹀彿
+        //timeequalOpts = new List<SelectOption>();
+        //timeequalOpts.add(new SelectOption('=', '绛変簬'));
+        //timeequalOpts.add(new SelectOption('<>', '涓嶇瓑浜�'));
+        //timeequalOpts.add(new SelectOption('<', '<'));
+        //timeequalOpts.add(new SelectOption('>', '>'));
+        //timeequalOpts.add(new SelectOption('<=', '<='));
+        //timeequalOpts.add(new SelectOption('>=', '>='));
+        //鏁版嵁鏄剧ず鏉℃暟
+        limitOpts = new List<SelectOption>();
+        limitOpts.add(new SelectOption('10', '10'));
+        limitOpts.add(new SelectOption('20', '20'));
+        limitOpts.add(new SelectOption('50', '50'));
+        limitOpts.add(new SelectOption('100', '100'));
+        limitOpts.add(new SelectOption('200', '200'));
+        limitOpts.add(new SelectOption('1000', '鍏ㄩ儴'));
+        //鏁版嵁鏄剧ず榛樿鏉℃暟
+        limits = '20';
+    }
 
-        //     String val = vals[icount];
-        //     cSql = this.makeTextSqlStr(textOpts, equalOpts, val);
-        //     system.debug(cSql);
-        //     soql += cSql;
-        //     if (icount < vals.size() - 1) {
-        //         soql += ' OR ';
+    public PageReference init() {
+        remindMsg = '';
+        PartnerSoapSforceCom.Soap soap = new PartnerSoapSforceCom.Soap();
+        soap.SessionHeader = new PartnerSoapSforceCom.SessionHeader_element();
+        soap.SessionHeader.sessionId = UserInfo.getSessionId();
+        soap.endpoint_x = URL.getSalesforceBaseUrl().toExternalForm() + '/partner/services/Soap/u/33.0';
+        // soap.endpoint_x = URL.getSalesforceBaseUrl().toExternalForm() + '/services/Soap/u/33.0';
+
+        PartnerSoapSforceCom.DescribeLayoutResult dlr = new PartnerSoapSforceCom.DescribeLayoutResult();
+        if (System.Test.isRunningTest()) {
+            // UnitTest 鐢�
+            // PartnerSoapSforceCom.DescribeLayoutResult dlr = new PartnerSoapSforceCom.DescribeLayoutResult();
+            PartnerSoapSforceCom.RecordTypeMapping rtMap = new PartnerSoapSforceCom.RecordTypeMapping();
+            PartnerSoapSforceCom.DescribeLayout editLayout = new PartnerSoapSforceCom.DescribeLayout();
+            PartnerSoapSforceCom.DescribeLayoutSection editLayoutSection = new PartnerSoapSforceCom.DescribeLayoutSection();
+            PartnerSoapSforceCom.DescribeLayoutRow layoutRow = new PartnerSoapSforceCom.DescribeLayoutRow();
+            PartnerSoapSforceCom.DescribeLayoutItem layoutItem = new PartnerSoapSforceCom.DescribeLayoutItem();
+            PartnerSoapSforceCom.DescribeLayoutComponent layoutComponent = new PartnerSoapSforceCom.DescribeLayoutComponent();
+            dlr.recordTypeMappings = new List<PartnerSoapSforceCom.RecordTypeMapping>();
+            dlr.recordTypeMappings.add(rtMap);
+            rtMap.recordTypeId = 'recordTypeId';
+            dlr.layouts = new List<PartnerSoapSforceCom.DescribeLayout>();
+            dlr.layouts.add(editLayout);
+            editLayout.editLayoutSections = new List<PartnerSoapSforceCom.DescribeLayoutSection>();
+            editLayout.editLayoutSections.add(editLayoutSection);
+            editLayoutSection.layoutRows = new List<PartnerSoapSforceCom.DescribeLayoutRow>();
+            editLayoutSection.layoutRows.add(layoutRow);
+            layoutRow.layoutItems = new List<PartnerSoapSforceCom.DescribeLayoutItem>();
+            layoutRow.layoutItems.add(layoutItem);
+            layoutItem.layoutComponents = new List<PartnerSoapSforceCom.DescribeLayoutComponent>();
+            layoutItem.layoutComponents.add(layoutComponent);
+            // return dlr;
+        } else {
+            dlr  = soap.describeLayout('Agency_Opportunity__c', null, null);
+            // dlr  = soap.describeLayout('asdas', null, null);
+        }
+
+        // PartnerSoapSforceCom.DescribeLayoutResult dlr  = soap.describeLayout('Agency_Opportunity__c', null, null);
+        Map<String, PartnerSoapSforceCom.DescribeLayout> layputMap = new Map<String, PartnerSoapSforceCom.DescribeLayout>();
+        for (PartnerSoapSforceCom.DescribeLayout layout : dlr.layouts) {
+            layputMap.put(layout.id, layout);
+        }
+        for (Integer lidx = 0; lidx < dlr.recordTypeMappings.size(); lidx++) {
+            String recordTypeId = dlr.recordTypeMappings[lidx].recordTypeId;
+            Map<String, String> rtnInner = new Map<String, String>();
+            editLayoutItemRWMap.put(recordTypeId, rtnInner);
+            System.debug('recordTypeId=' + recordTypeId);
+            PartnerSoapSforceCom.DescribeLayout layout = layputMap.get(dlr.recordTypeMappings[lidx].layoutId);
+            for (PartnerSoapSforceCom.DescribeLayoutSection section : layout.editLayoutSections) {
+                for (PartnerSoapSforceCom.DescribeLayoutRow row : section.layoutRows) {
+                    for (PartnerSoapSforceCom.DescribeLayoutItem item : row.layoutItems) {
+                        if (item.layoutComponents != null && item.layoutComponents.size() > 0
+                                && String.isBlank(item.layoutComponents[0].value) == false) {
+                            rtnInner.put(item.layoutComponents[0].value, 'r');
+                            if (item.editableForUpdate) {
+                                rtnInner.put(item.layoutComponents[0].value, 'w');
+                            }
+                            if (item.required) {
+                                rtnInner.put(item.layoutComponents[0].value, 'wm');
+                            }
+                        }
+                    }
+                }
+            }
+        }
+        // editLayoutItemRWMap = SoapApi.getEditRWByRecordType('Agency_Opportunity__c', null);
+        tmpAO = new Agency_Opportunity__c();
+        tmpBO = new Agency_Opportunity__c();
+        setLayoutRWInfo();
+        searchOppInner();
+        return null;
+    }
+    //鐢ㄤ簬鑾峰彇缁忛攢鍟嗚浠峰瓧娈甸泦鍜岃浠峰瓧娈甸泦浠ュ強鐩稿簲鐨勮鍐欐潈闄�
+    @TestVisible private void setLayoutRWInfo() {
+        if (this.sortOrder == null) {
+            selColumus = new String[] {};
+            strColumus = '';
+            ID accRecordTypeId = accTypeForSort;
+
+            Map<String, String> DESC_RW = editLayoutItemRWMap.get('012100000006KW7AAM');
+            Map<String, Schema.FieldSet> fsMap = Schema.getGlobalDescribe().get('Agency_Opportunity__c').getDescribe().fieldSets.getMap();
+            Schema.FieldSet fs = fsMap.get('DealerInquiryModifyState');
+            List<FieldSetMember> fsmList = fs.getFields();
+            titleLeft = new List<String>();
+            List<String> columnLeft = new List<String>();
+            columnLeftCss = new List<String>();
+            columnsLeftApi = new List<List<String>>();
+            columnLeftRW = new Map<String, String>();
+            for (FieldSetMember fsm : fsmList) {
+                titleLeft.add(fsm.getLabel());
+                columnLeft.add(fsm.getFieldPath());
+                List<String> splitFieldPath = fsm.getFieldPath().split('\\.');
+                columnsLeftApi.add(splitFieldPath);
+                if (DESC_RW == null) {
+                    columnLeftRW.put(fsm.getFieldPath(), 'r');
+                } else if (splitFieldPath.size() == 1) {
+                    String rw = DESC_RW.get(fsm.getFieldPath());
+                    if (rw != null) {
+                        columnLeftRW.put(fsm.getFieldPath(), rw);
+                    } else {
+                        columnLeftRW.put(fsm.getFieldPath(), 'r');
+                    }
+                } else {
+                    columnLeftRW.put(fsm.getFieldPath(), 'r');
+                }
+            }
+            for (String str : columnLeftRW.keySet()) {
+                System.debug(str + '=+=+=+=+=' + columnLeftRW.get(str));
+            }
+            for (String s : columnLeft) {
+                if (columusSet.contains(s) == false) {
+                    columus.add(s);
+                    columusSet.add(s);
+                }
+                if (selColumus.contains(s) == false) {
+                    selColumus.add(s);
+                }
+                columnLeftCss.add(s.replace('.', '_'));
+            }
+            strRtColumus = '';
+            Schema.FieldSet fsRt = fsMap.get('DealerOpportunity');
+            List<FieldSetMember> fsmListRt = fsRt.getFields();
+            titleRight = new List<String>();
+            List<String> columnRight = new List<String>();
+            columnRightCss = new List<String>();
+            columnsRightApi = new List<List<String>>();
+            columnRightRW = new Map<String, String>();
+
+            for (FieldSetMember fsm : fsmListRt) {
+                titleRight.add(fsm.getLabel());
+                columnRight.add(fsm.getFieldPath());
+                List<String> splitFieldPath = fsm.getFieldPath().split('\\.');
+                columnsRightApi.add(splitFieldPath);
+                if (DESC_RW == null) {
+                    columnRightRW.put(fsm.getFieldPath(), 'r');
+                } else if (splitFieldPath.size() == 1) {
+                    String rw = DESC_RW.get(fsm.getFieldPath());
+                    if (rw != null) {
+                        columnRightRW.put(fsm.getFieldPath(), rw);
+                    } else {
+                        columnRightRW.put(fsm.getFieldPath(), 'r');
+                    }
+                } else {
+                    columnRightRW.put(fsm.getFieldPath(), 'r');
+                }
+            }
+            for (String s : columnRight) {
+                selColumus.add(s);
+                if (strRtColumus == '') {
+                    strRtColumus = s;
+                } else {
+                    strRtColumus = strRtColumus + ',' + s;
+                }
+                columnRightCss.add(s.replace('.', '_'));
+
+            }
+            strColumus = String.join(columus, ',');
+            System.debug('======-======-======strColumus' + strColumus);
+            System.debug('======-======-======strRtColumus' + strRtColumus);
+            this.sortOrderAsc = true;
+            this.sortOrder = new String[selColumus.size()];
+            for (Integer i = 0; i < selColumus.size(); i++) this.sortOrder[i] = '銆�';
+        }
+    }
+    //鐢ㄤ簬鎷兼帴SOQL璇彞 鏍规嵁涓嶅悓妫�绱㈡潯浠舵嫾鎺ヤ笉鍚孲OQL璇彞銆�
+    public void searchOppInner() {
+        //SOQL:鎷兼帴妫�绱㈡潯浠朵互鍙婄粡閿�鍟嗚浠风殑SOQL璇彞
+        // List<User> userlist2 = [select id,name from user where Contactid in (select id from Contact)];
+        // String querySoql = '';
+        // Integer queryint = 0;
+        // for(User user : userlist2){
+        //     if(queryint == 0){
+        //         querySoql += '\''+user.Id+'\'';
+        //         queryint++;
+        //     }else{
+        //         querySoql += ',\''+user.Id+'\'';
         //     }
+
         // }
-        soql += ')';
-      }
-      //瀵绘壘妫�绱㈡潯浠跺寘鍚�橈紝鈥� 閫楀彿鐨勫閲嶆绱㈡潯浠�
-      else if (
-        (equalOpts == '=' || equalOpts == '<>') && numtext.contains(',')
-      ) {
-        String[] vals = numtext.split(',');
-        soql += ' AND ( ';
-        for (Integer icount = 0; icount < vals.size(); icount++) {
-          String val = vals[icount];
-          if (equalOpts == '=') {
-            soql += textOpts + ' = \'' + val + '\'';
-            if (icount < vals.size() - 1) {
-              soql += ' OR ';
-            }
-          } else if (equalOpts == '<>') {
-            soql += textOpts + ' <> \'' + val + '\'';
-            if (icount < vals.size() - 1) {
-              soql += ' AND ';
-            }
-          }
-        }
-        soql += ')';
-      }
-      //妫�绱㈣繛鎺ョ涓哄寘鍚互鍙婁笉鍖呭惈
-      else if (
-        equalOpts.equals('contains') || equalOpts.equals('notcontains')
-      ) {
-        if (equalOpts.equals('contains')) {
-          soql += ' AND ' + textOpts + ' LIKE \'%' + numtext + '%\'';
-        } else if (equalOpts.equals('notcontains')) {
-          soql += ' AND ( NOT ' + textOpts + ' LIKE \'%' + numtext + '%\' ) ';
-        }
-      }
-      //妫�绱㈣繛鎺ョ涓虹瓑浜庝互鍙婁笉绛変簬
-      else if (equalOpts == '=' || equalOpts == '<>') {
-        soql += 'AND ' + textOpts + equalOpts + '\'' + numtext + '\'';
-      }
-      //绮剧悽绉戞妧   zxk    2021-08-25   start
-      //璧峰瀛楃
-      else if (equalOpts == 'starts with' && numtext.contains(' ')) {
-        String[] vals = numtext.split(' ');
-        soql += ' AND ( ';
-        for (Integer icount = 0; icount < vals.size(); icount++) {
-          String val = vals[icount];
-          if (equalOpts == 'starts with') {
-            soql += ' ' + textOpts + '  LIKE  \'%' + val + '%\'';
-            if (icount < vals.size() - 1) {
-              soql += ' OR ';
-            }
-          }
-        }
-        soql += ')';
-      }
-      //绮剧悽绉戞妧   zxk    2021-08-25   end
+        // System.debug('pppqqq222'+userlist2);
+        // System.debug('pppqqq333'+querySoql);
+        // AND Ownerid in ( '+querySoql+')'
 
-      // //璧峰瀛楃
-      // else if (equalOpts == 'starts with'){
-      //     soql += 'AND ' + textOpts + ' LIKE \'' + numtext + '%\'';
-      // }
-      //妫�绱㈣繛鎺ョ鐨勫叾浠栨儏鍐�
-      else {
-        String cSql = this.makeTextSqlStr(textOpts, equalOpts, numtext);
-        if (equalOpts != '<>') {
-          soql += cSql;
+        String soql = 'SELECT Change_To_Opportunity__r.Id , Agency_Hospital__r.Name , Product_Category1__r.Name , Product_Category2__r.Name , Product_Category3__r.Name , Agency_Person__r.Name , Agency__r.Name , Change_To_Opportunity__r.Name ,' +
+                      strColumus + ',' + strRtColumus +
+                      ' FROM Agency_Opportunity__c WHERE recordType.DeveloperName = \'Opportunity\' ';
+        //鏁版嵁瀛楁锛氱粡閿�鍟嗗尰闄�  +SOQL
+        if (!String.isBlank(accSearch)) {
+            accSearch = accSearch.trim();
+            // soql += 'AND Agency__r.Name  '   + '  LIKE  \'%' + accSearch + '%\' ';
+            soql += 'AND Agency_Hospital__r.Name  '   + '  LIKE  \'%' + accSearch + '%\' ';
+        }
+        //鏁版嵁瀛楁锛氭媴褰撲汉  +SOQL
+        if (!String.isBlank(aooSearch)) {
+            String newAooSearch = aooSearch.trim();
+            // soql += 'AND Change_To_Opportunity__r.Owner.Alias = ' + '\'' + newAooSearch + '\'';//Name
+            soql += 'AND Agency_PersonName__c ' + '  LIKE  \'%' + newAooSearch + '%\' ';
+        }
+        //鏁版嵁瀛楁锛�03 鎵嬪姩濉啓椤� 鍑嗗璋冪敤makeTextSql锛�
+        if (!String.isBlank(numtext)) {
+            String newNumtext = numtext.trim();
+            String str = makeTextSql(numtext1,  numtext2,  newNumtext);
+            soql += str;
+            System.debug('+++++++++++++=============++++++++++++++++++' + soql);
+        }
+        //鐐瑰嚮鎺掑簭
+        // System.debug('==-=-=-=-=-=this.sortKey'+Integer.valueOf(this.sortKey)+'===titleLeft.size'+titleLeft.size()+7);
+        if (String.isBlank(this.sortKey)) {
+            soql += ' order by LastModifiedDate desc limit ' + Integer.valueOf(limits);
         } else {
-          soql += ' and (NOT ' + cSql + ') ';
+            if (Integer.valueOf(this.sortKey) <= titleLeft.size() + 7) {
+                soql += ' order by ' + this.selColumus[Integer.valueOf(this.sortKey)] + ' ' + (this.sortOrderAsc == true ? 'asc nulls first' : 'desc nulls last') + ' limit ' + Integer.valueOf(limits);
+            } else {
+                soql += ' order by Change_To_Opportunity__r.' + this.selColumus[Integer.valueOf(this.sortKey)] + ' ' + (this.sortOrderAsc == true ? 'asc nulls first' : 'desc nulls last') + ' limit ' + Integer.valueOf(limits);
+            }
         }
-      }
-    }
-    return soql;
-  }
-  //妫�绱㈡潯浠讹細鏁版嵁瀛楁1锛屾暟鎹瓧娈�2锛屾暟鎹瓧娈�3鍧囨弧瓒筹紝骞朵笖杩涘叆makeTextSql锛堬級涔嬪悗锛屽唴鍚暟鎹瓧娈靛寘鍚绉嶆椂杩涘叆姝ゆ柟娉曘��
-  @TestVisible
-  private String makeTextSqlStr(String textOpts, String equalOpts, String val) {
-    String soql = '';
-    if (!String.isBlank(textOpts)) {
-      String tmpVal = val;
-      if (!String.isBlank(tmpVal)) {
-        if (equalOpts == 'contains' || equalOpts == 'notcontains') {
-          if (equalOpts == 'contains') {
-            soql += ' ' + textOpts + '  LIKE  \'%' + val + '%\'';
-          } else if (equalOpts == 'notcontains') {
-            soql += ' ( NOT ' + textOpts + '  LIKE  \'%' + val + '%\' ) ';
-          }
-        } else if (equalOpts == '=' || equalOpts == '<>') {
-          if (equalOpts == '=') {
-            soql += ' AND ' + textOpts + ' = ' + val;
-          } else if (equalOpts == '<>') {
-            soql += ' AND ' + textOpts + ' <> ' + val;
-          }
+        system.debug(soql);
+        // List<User> userlist1 = [select id,name from user ];
+        // System.debug('pppqqq111'+userlist1);
+
+        List<Agency_Opportunity__c> InfoList = Database.query(soql);
+        System.debug('+++++++-------------------'+InfoList);
+
+        // List<Agency_Opportunity__c> InfoList = ControllerUtil.DatabaseQuery(soql);
+        // System.debug('InfoList[0].Change_To_Opportunity_T__c'+InfoList[0].Change_To_Opportunity_T__c);
+        for (Agency_Opportunity__c apt : InfoList) {
+            System.debug('pppqqq' + apt.Agency_PersonName__c + '====' + apt.Name);
         }
-      } else {
-        soql = ' AND ' + textOpts;
-        if (equalOpts == '=') {
-          soql += ' = ' + tmpVal;
-        } else if (equalOpts == '<>') {
-          soql += ' <> ' + tmpVal;
-        } else if (equalOpts == 'contains') {
-          soql +=
-            ' like \'%' +
-            String.escapeSingleQuotes(tmpVal.replaceAll('%', '\\%')) +
-            '%\'';
-        } else if (equalOpts == 'notcontains') {
-          soql +=
-            ' like \'%' +
-            String.escapeSingleQuotes(tmpVal.replaceAll('%', '\\%')) +
-            '%\'';
-        } else if (equalOpts == 'starts with') {
-          soql +=
-            ' like \'%' +
-            String.escapeSingleQuotes(tmpVal.replaceAll('%', '\\%')) +
-            '%\'';
+
+        List<OpportunityInfo> oppinfoList = new List<OpportunityInfo>();
+        if (InfoList != null && InfoList.size() > 0) {
+            String str = '';
+            for (Agency_Opportunity__c agc : InfoList) {
+                if (str == '' && agc.Change_To_Opportunity__r.Id != null) {
+                    str = '\'' + agc.Change_To_Opportunity__r.Id + '\'';
+                } else if (agc.Change_To_Opportunity__r.Id != null) {
+                    str += ',\'' + agc.Change_To_Opportunity__r.Id + '\'';
+
+                }
+            }
+            for (Agency_Opportunity__c info : InfoList) {
+                oppinfoList.add(new OpportunityInfo(info, info));
+                oppinfoList[oppinfoList.size() - 1].lineNo = oppinfoList.size() - 1;
+            }
+        }
+        oppRecords = oppinfoList.clone();
+        oppCount = oppRecords.size();
+        //鏄剧ず鎻愮ず鎿嶄綔淇℃伅
+        if (String.isBlank(this.saveType) && String.isBlank(this.sortKey)) {
+            ApexPages.addmessage(new ApexPages.message(ApexPages.severity.INFO, '鍙栧緱鏈�杩戠殑 ' + oppCount + ' 鏉℃暟鎹�'));
+            //add by Link 2023-6-2
+            remindMsg = '鍙栧緱鏈�杩戠殑 ' + oppCount + ' 鏉℃暟鎹�';
+        } else if (!String.isBlank(this.sortKey)) {
+            if (oppCount > oppLimit) {
+                ApexPages.addmessage(new ApexPages.message(ApexPages.severity.INFO, '鏁版嵁瓒呰繃' + oppLimit + '浠讹紝鍙樉绀哄墠' + oppLimit + '浠�'));
+                //add by Link 2023-6-2
+                remindMsg = '鏁版嵁瓒呰繃' + oppLimit + '浠讹紝鍙樉绀哄墠' + oppLimit + '浠�';
+            } else {
+                ApexPages.addmessage(new ApexPages.message(ApexPages.severity.INFO, '鍏辨湁 ' + oppCount + ' 鏉℃暟鎹�'));
+                //add by Link 2023-6-2
+                remindMsg = '鍏辨湁 ' + oppCount + ' 鏉℃暟鎹�';
+            }
         } else {
-          soql += ' ' + equalOpts + ' ' + tmpVal;
+            ApexPages.addmessage(new ApexPages.message(ApexPages.severity.INFO, '鍏辨湁 ' + oppCount + ' 鏉℃暟鎹�'));
+            //add by Link 2023-6-2
+            remindMsg = '鍏辨湁 ' + oppCount + ' 鏉℃暟鎹�';
         }
-      }
     }
-    return soql;
-  }
+    //妫�绱㈡潯浠讹細鏁版嵁瀛楁1锛屾暟鎹瓧娈�2锛屾暟鎹瓧娈�3鍧囨弧瓒宠繘鍏ユ鏂规硶 鍒ゆ柇澶氱鎯呭喌
+    private String makeTextSql(String textOpts, String equalOpts, String numtext) {
+        String soql = '';
+        if (!String.isBlank(textOpts)) {
+            //瀵绘壘妫�绱㈡潯浠跺寘鍚�� 鈥� 绌烘牸鐨勫閲嶆绱㈡潯浠�
+            //system.debug('314-textOpts:'+textOpts);
+            if ((equalOpts == 'contains' || equalOpts == 'notcontains') && numtext.contains(',')) {
+                //system.debug('316-equalOpts:'+equalOpts);
+                //system.debug('316-numtext:'+numtext);
+                String[] vals = numtext.split(',');
+                String cSql = '';
+                soql += ' AND (';
+                for (Integer icount = 0; icount < vals.size(); icount++) {
 
-  //妫�绱㈡寜閽細鐐瑰嚮妫�绱㈡寜閽Е鍙戞鏂规硶锛�
-  public PageReference chick() {
-    setLayoutRWInfo();
-    searchOppInner();
-    return null;
-  }
-  //椤甸潰鍐呭鏈変慨鏀规椂锛岄〉闈㈠垽鏂悗浼犲�肩粰changeFlg浠ュ強changeFlgRt灞炴�э紝鐐瑰嚮淇濆瓨鏃惰皟鐢ㄦ鏂规硶锛岃繘琛屼繚瀛樸��
-  public PageReference save() {
-    //system.debug('oppRecords[1].opp:' + oppRecords[1].opp +' oppRecords[1].AgcOpp:' + oppRecords[1].AgcOpp );
-    try {
-      List<Agency_Opportunity__c> updTarget = new List<Agency_Opportunity__c>();
-      // List<Opportunity> updOpps = new List<Opportunity>();
-      for (OpportunityInfo oi : oppRecords) {
-        if (oi.changeFlg == '1') {
-          oi.changeFlg = '0';
-          updTarget.add(oi.AgcOpp);
+                    //绮剧悽绉戞妧   zxk    2021-08-25   start
+                    String val = vals[icount];
+                    if (equalOpts == 'contains') {
+                        cSql = this.makeTextSqlStr(textOpts, equalOpts, val);
+                        soql += cSql;
+
+                        if (icount < vals.size() - 1) {
+                            soql += ' OR ';
+                        }
+                    } else if (equalOpts == 'notcontains') {
+                        cSql = this.makeTextSqlStr(textOpts, equalOpts, val);
+                        soql += cSql;
+                        if (icount < vals.size() - 1) {
+                            soql += ' AND ';
+                        }
+                    }
+
+                }
+                //绮剧悽绉戞妧   zxk    2021-08-25   end
+
+
+                //     String val = vals[icount];
+                //     cSql = this.makeTextSqlStr(textOpts, equalOpts, val);
+                //     system.debug(cSql);
+                //     soql += cSql;
+                //     if (icount < vals.size() - 1) {
+                //         soql += ' OR ';
+                //     }
+                // }
+                soql += ')';
+            }
+            //瀵绘壘妫�绱㈡潯浠跺寘鍚�橈紝鈥� 閫楀彿鐨勫閲嶆绱㈡潯浠�
+            else if ((equalOpts == '=' || equalOpts == '<>') && numtext.contains(',')) {
+                String[] vals = numtext.split(',');
+                soql += ' AND ( ';
+                for (Integer icount = 0; icount < vals.size(); icount++) {
+                    String val = vals[icount];
+                    if (equalOpts == '=') {
+                        soql += textOpts + ' = \'' + val + '\'';
+                        if (icount < vals.size() - 1) {
+                            soql += ' OR ';
+                        }
+                    } else if (equalOpts == '<>') {
+                        soql += textOpts + ' <> \'' + val + '\'';
+                        if (icount < vals.size() - 1) {
+                            soql += ' AND ';
+                        }
+                    }
+                }
+                soql += ')';
+            }
+            //妫�绱㈣繛鎺ョ涓哄寘鍚互鍙婁笉鍖呭惈
+            else if (equalOpts.equals('contains') || equalOpts.equals('notcontains')) {
+                if (equalOpts.equals('contains')) {
+                    soql += ' AND ' + textOpts + ' LIKE \'%' + numtext + '%\'';
+                } else if (equalOpts.equals('notcontains')) {
+                    soql += ' AND ( NOT ' + textOpts + ' LIKE \'%' + numtext + '%\' ) ';
+                }
+            }
+            //妫�绱㈣繛鎺ョ涓虹瓑浜庝互鍙婁笉绛変簬
+            else if (equalOpts == '=' || equalOpts == '<>') {
+                soql += 'AND ' + textOpts + equalOpts + '\'' + numtext + '\'';
+            }
+
+            //绮剧悽绉戞妧   zxk    2021-08-25   start
+            //璧峰瀛楃
+            else if (equalOpts == 'starts with' && numtext.contains(' ')) {
+                String[] vals = numtext.split(' ');
+                soql += ' AND ( ';
+                for (Integer icount = 0; icount < vals.size(); icount++) {
+                    String val = vals[icount];
+                    if (equalOpts == 'starts with') {
+                        soql += ' ' + textOpts + '  LIKE  \'%' + val + '%\'' ;
+                        if (icount < vals.size() - 1) {
+                            soql += ' OR ';
+
+                        }
+                    }
+                }
+                soql += ')';
+
+            }
+            //绮剧悽绉戞妧   zxk    2021-08-25   end
+
+            // //璧峰瀛楃
+            // else if (equalOpts == 'starts with'){
+            //     soql += 'AND ' + textOpts + ' LIKE \'' + numtext + '%\'';
+            // }
+            //妫�绱㈣繛鎺ョ鐨勫叾浠栨儏鍐�
+            else {
+                String cSql = this.makeTextSqlStr(textOpts, equalOpts, numtext);
+                if (equalOpts != '<>') {
+                    soql += cSql;
+                } else {
+                    soql += ' and (NOT ' + cSql + ') ';
+                }
+            }
         }
-        // if (oi.changeFlgRt == '1' && oi.opp.id != null) {
-        //     oi.changeFlgRt = '0';
-        //     updOpps.add(oi.opp);
-        // }
-      }
-      if (updTarget.size() > 0) {
-        system.debug('updTarget.size:' + updTarget.size());
-        update updTarget;
-      }
-      // if (updOpps.size() > 0) {
-      //     update updOpps;
-      // }
-      ApexPages.addmessage(
-        new ApexPages.message(ApexPages.severity.INFO, '淇濆瓨瀹屼簡')
-      );
-      //add by Link 2023-6-2
-      remindMsg = '淇濆瓨瀹屼簡';
-    } catch (Exception e) {
-      //ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Error, '璇风‘瀹氱瀹ゅ垎绫诲拰浜у搧鍖哄垎鐨勫叧绯�'));
+        return soql;
     }
-    if (saveType == '1') {
-      searchOppInner();
-      saveType = '';
-    } else if (saveType == '2') {
-      sortTable();
-      saveType = '';
-    } else {
+    //妫�绱㈡潯浠讹細鏁版嵁瀛楁1锛屾暟鎹瓧娈�2锛屾暟鎹瓧娈�3鍧囨弧瓒筹紝骞朵笖杩涘叆makeTextSql锛堬級涔嬪悗锛屽唴鍚暟鎹瓧娈靛寘鍚绉嶆椂杩涘叆姝ゆ柟娉曘��
+    @TestVisible private String makeTextSqlStr(String textOpts, String equalOpts, String val) {
+        String soql = '';
+        if (!String.isBlank(textOpts)) {
+            String tmpVal = val;
+            if (!String.isBlank(tmpVal)) {
+                if (equalOpts == 'contains' || equalOpts == 'notcontains') {
+                    if (equalOpts == 'contains') {
+                        soql += ' ' + textOpts + '  LIKE  \'%' + val + '%\'' ;
+                    } else if (equalOpts == 'notcontains') {
+                        soql += ' ( NOT ' + textOpts + '  LIKE  \'%' + val + '%\' ) ' ;
+                    }
+                } else if (equalOpts == '=' || equalOpts == '<>') {
+                    if (equalOpts == '=') {
+                        soql += ' AND ' + textOpts + ' = ' + val ;
+                    } else if (equalOpts == '<>') {
+                        soql += ' AND ' + textOpts + ' <> ' + val ;
+                    }
+                }
+            } else {
+                soql = ' AND ' + textOpts;
+                if (equalOpts == '=') {
+                    soql += ' = ' + tmpVal;
+                } else if (equalOpts == '<>') {
+                    soql += ' <> ' + tmpVal;
+                } else if (equalOpts == 'contains') {
+                    soql += ' like \'%' + String.escapeSingleQuotes(tmpVal.replaceAll('%', '\\%')) + '%\'';
+                } else if (equalOpts == 'notcontains') {
+                    soql += ' like \'%' + String.escapeSingleQuotes(tmpVal.replaceAll('%', '\\%')) + '%\'';
+                } else if (equalOpts == 'starts with') {
+                    soql += ' like \'%' + String.escapeSingleQuotes(tmpVal.replaceAll('%', '\\%')) + '%\'';
+                } else {
+                    soql += ' ' + equalOpts + ' ' + tmpVal;
+                }
+            }
+        }
+        return soql;
     }
-    return null;
-  }
-  //鍏ㄩ儴灞曞紑璋冪敤姝ゆ柟娉�
-  public PageReference sortTable() {
-    oppRecords = new List<OpportunityInfo>();
-    if (this.sortKey == this.preSortKey) {
-      if (String.isBlank(this.sortKey) == false) {
-        // 鏂瑰悜銇屽銈忋倠銇伩
-        this.sortOrderAsc = !this.sortOrderAsc;
-        this.sortOrder[Integer.valueOf(this.sortKey)] = (this.sortOrderAsc ==
-          true
-          ? '鈫�'
-          : '鈫�');
-      }
-    } else {
-      this.sortOrderAsc = true;
-      if (String.isBlank(this.preSortKey) == false) {
-        this.sortOrder[Integer.valueOf(this.preSortKey)] = '銆�';
-      }
-      this.sortOrder[Integer.valueOf(this.sortKey)] = (this.sortOrderAsc == true
-        ? '鈫�'
-        : '鈫�');
-    }
-    this.preSortKey = this.sortKey;
 
-    setLayoutRWInfo();
-    searchOppInner();
-    return null;
-  }
-
-  //鑷畾涔夌被OpportunityInfo锛岀敤浜庡垱寤鸿櫄鎷熷瓧娈碉紝鍚堝苟杈撳嚭銆�
-  class OpportunityInfo {
-    // public Opportunity opp { get; set; }
-    public Agency_Opportunity__c opp { get; set; }
-    public Boolean canEdit { get; private set; }
-    public Boolean hasError { get; private set; }
-    public Boolean hasFieldError { get; private set; }
-    public Integer lineNo { get; private set; }
-    public String changeFlg { get; set; }
-    public String changeFlgRt { get; set; }
-    public Boolean ifLock { get; set; }
-    //public String accType { get; private set; }
-    public Agency_Opportunity__c AgcOpp { get; set; }
-    public OpportunityInfo(
-      Agency_Opportunity__c record,
-      Agency_Opportunity__c oppo
-    ) {
-      opp = oppo;
-      canEdit = true;
-      hasError = false;
-      hasFieldError = false;
-      lineNo = 0;
-      changeFlg = '0';
-      changeFlgRt = '0';
-      ifLock = Approval.isLocked(record);
-      AgcOpp = record;
+    //妫�绱㈡寜閽細鐐瑰嚮妫�绱㈡寜閽Е鍙戞鏂规硶锛�
+    public PageReference chick() {
+        setLayoutRWInfo();
+        searchOppInner();
+        return null;
     }
-  }
-}
+    //椤甸潰鍐呭鏈変慨鏀规椂锛岄〉闈㈠垽鏂悗浼犲�肩粰changeFlg浠ュ強changeFlgRt灞炴�э紝鐐瑰嚮淇濆瓨鏃惰皟鐢ㄦ鏂规硶锛岃繘琛屼繚瀛樸��
+    public PageReference save() {
+        //system.debug('oppRecords[1].opp:' + oppRecords[1].opp +' oppRecords[1].AgcOpp:' + oppRecords[1].AgcOpp );
+        try {
+            List<Agency_Opportunity__c> updTarget = new List<Agency_Opportunity__c>();
+            // List<Opportunity> updOpps = new List<Opportunity>();
+            for (OpportunityInfo oi : oppRecords) {
+                if (oi.changeFlg == '1') {
+                    oi.changeFlg = '0';
+                    updTarget.add(oi.AgcOpp);
+
+                }
+                // if (oi.changeFlgRt == '1' && oi.opp.id != null) {
+                //     oi.changeFlgRt = '0';
+                //     updOpps.add(oi.opp);
+                // }
+            }
+            if (updTarget.size() > 0) {
+                system.debug('updTarget.size:' + updTarget.size() );
+                update updTarget;
+            }
+            // if (updOpps.size() > 0) {
+            //     update updOpps;
+            // }
+            ApexPages.addmessage(new ApexPages.message(ApexPages.severity.INFO, '淇濆瓨瀹屼簡'));
+            //add by Link 2023-6-2
+            remindMsg = '淇濆瓨瀹屼簡';
+        } catch (Exception e) {
+            //ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Error, '璇风‘瀹氱瀹ゅ垎绫诲拰浜у搧鍖哄垎鐨勫叧绯�'));
+        }
+        if (saveType == '1') {
+            searchOppInner();
+            saveType = '';
+        } else if (saveType == '2') {
+            sortTable();
+            saveType = '';
+        } else {
+        }
+        return null;
+    }
+    //鍏ㄩ儴灞曞紑璋冪敤姝ゆ柟娉�
+    public PageReference sortTable() {
+        oppRecords = new List<OpportunityInfo>();
+        if (this.sortKey == this.preSortKey) {
+            if (String.isBlank(this.sortKey) == false) {
+                // 鏂瑰悜銇屽銈忋倠銇伩
+                this.sortOrderAsc = !this.sortOrderAsc;
+                this.sortOrder[Integer.valueOf(this.sortKey)] = (this.sortOrderAsc == true ? '鈫�' : '鈫�');
+            }
+        } else {
+            this.sortOrderAsc = true;
+            if (String.isBlank(this.preSortKey) == false) {
+                this.sortOrder[Integer.valueOf(this.preSortKey)] = '銆�';
+            }
+            this.sortOrder[Integer.valueOf(this.sortKey)] = (this.sortOrderAsc == true ? '鈫�' : '鈫�');
+        }
+        this.preSortKey = this.sortKey;
+
+        setLayoutRWInfo();
+        searchOppInner();
+        return null;
+    }
+
+    //鑷畾涔夌被OpportunityInfo锛岀敤浜庡垱寤鸿櫄鎷熷瓧娈碉紝鍚堝苟杈撳嚭銆�
+    class OpportunityInfo {
+        // public Opportunity opp { get; set; }
+        public Agency_Opportunity__c opp { get; set; }
+        public Boolean canEdit { get; private set; }
+        public Boolean hasError { get; private set; }
+        public Boolean hasFieldError { get; private set; }
+        public Integer lineNo { get; private set; }
+        public String changeFlg { get; set; }
+        public String changeFlgRt { get; set; }
+        public Boolean ifLock { get; set; }
+        //public String accType { get; private set; }
+        public Agency_Opportunity__c AgcOpp { get; set; }
+        public OpportunityInfo(Agency_Opportunity__c record, Agency_Opportunity__c oppo) {
+            opp = oppo;
+            canEdit = true;
+            hasError = false;
+            hasFieldError = false;
+            lineNo = 0;
+            changeFlg = '0';
+            changeFlgRt = '0';
+            ifLock = Approval.isLocked(record);
+            AgcOpp = record;
+        }
+    }
+}
\ No newline at end of file

--
Gitblit v1.9.1