buli
2023-07-14 36d15f189de2e83ce2576715dac30c3c260388dd
force-app/main/default/classes/DealerInquiryModifyStateController.cls
@@ -1,23 +1,38 @@
public with sharing class DealerInquiryModifyStateController {
    public List<OpportunityInfo> oppRecords { get; set; }
    // ページレイアウトの情報を取得
<<<<<<< HEAD
    private Map<String, Map<String, String>> editLayoutItemRWMap = new Map<String, Map<String, String>>();
=======
    private Map<String, Map<String, String>> editLayoutItemRWMap = New Map<String, Map<String, String>>();
>>>>>>> LEXCommunityLiJun
    // private Map<String, Map<String, String>> editLayoutItemRWMapRt = null;
    public List<OpportunityInfo> OPPORTList { get; set; }
    /*****************検索用******************/
    /*******************检索属性值*******************/
<<<<<<< HEAD
    public String accSearch { get; set; } //经销商医院
    public String aooSearch { get; set; } //担当人
    public String numtext1 { get; set; } //数据字段01
    public String numtext { 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
>>>>>>> LEXCommunityLiJun
    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; } //检索日期用
<<<<<<< HEAD
    public String limits { get; set; } //日期03
=======
    public String limits { get; set; }//日期03
>>>>>>> LEXCommunityLiJun
    public List<SelectOption> dateOpts { get; private set; }
    public List<SelectOption> textOpts { get; private set; }
@@ -34,27 +49,49 @@
    public String preSortKey { get; set; }
    public Boolean sortOrderAsc { get; set; }
    public String[] sortOrder { get; set; }
<<<<<<< HEAD
    public String[] columus = new List<String>{ 'Id' };
    public String[] selColumus = null;
    public Set<String> columusSet = new Set<String>{ 'Id' };
=======
    public String[] columus = new String[] {'Id'};
    public String[] selColumus = null;
    public Set<String> columusSet = new Set<String> {'Id'};
>>>>>>> LEXCommunityLiJun
    // 项目set 字段标签
    public List<String> titleLeft { get; private set; }
    public List<String> titleRight { get; private set; }
    // 项目set 字段名
<<<<<<< HEAD
    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用
=======
    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用
>>>>>>> LEXCommunityLiJun
    private String strColumus;
    private String strRtColumus;
    //add by Link 2023-6-2
<<<<<<< HEAD
    public String remindMsg { get; set; }
    @TestVisible
    private String accTypeForSort = null;
=======
    public String remindMsg{get;set;}
    @TestVisible private String accTypeForSort = null;
>>>>>>> LEXCommunityLiJun
    private static Integer oppLimit = 500;
    public DealerInquiryModifyStateController() {
@@ -82,6 +119,52 @@
        textOpts.add(new SelectOption('Oly_Inquiry_Stage__c', 'Oly询价阶段'));
        //精琢科技   zxk    2021-08-25   end
        textOpts.add(new SelectOption('Hospital_City_Master__c', '市'));
<<<<<<< HEAD
        // 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', '预测与OLY签约日'));
        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';
    }
=======
        
        // 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', '省'));
@@ -126,6 +209,7 @@
        limits = '20';
    }
>>>>>>> LEXCommunityLiJun
    public PageReference init() {
        remindMsg = '';
        PartnerSoapSforceCom.Soap soap = new PartnerSoapSforceCom.Soap();
@@ -159,7 +243,11 @@
            layoutItem.layoutComponents.add(layoutComponent);
            // return dlr;
        } else {
<<<<<<< HEAD
            dlr = soap.describeLayout('Agency_Opportunity__c', null, null);
=======
            dlr  = soap.describeLayout('Agency_Opportunity__c', null, null);
>>>>>>> LEXCommunityLiJun
            // dlr  = soap.describeLayout('asdas', null, null);
        }
@@ -177,8 +265,16 @@
            for (PartnerSoapSforceCom.DescribeLayoutSection section : layout.editLayoutSections) {
                for (PartnerSoapSforceCom.DescribeLayoutRow row : section.layoutRows) {
                    for (PartnerSoapSforceCom.DescribeLayoutItem item : row.layoutItems) {
<<<<<<< HEAD
                        if (
                            item.layoutComponents != null &&
                            item.layoutComponents.size() > 0 &&
                            String.isBlank(item.layoutComponents[0].value) == false
                        ) {
=======
                        if (item.layoutComponents != null && item.layoutComponents.size() > 0
                                && String.isBlank(item.layoutComponents[0].value) == false) {
>>>>>>> LEXCommunityLiJun
                            rtnInner.put(item.layoutComponents[0].value, 'r');
                            if (item.editableForUpdate) {
                                rtnInner.put(item.layoutComponents[0].value, 'w');
@@ -199,9 +295,16 @@
        return null;
    }
    //用于获取经销商询价字段集和询价字段集以及相应的读写权限
<<<<<<< HEAD
    @TestVisible
    private void setLayoutRWInfo() {
        if (this.sortOrder == null) {
            selColumus = new List<String>{};
=======
    @TestVisible private void setLayoutRWInfo() {
        if (this.sortOrder == null) {
            selColumus = new String[] {};
>>>>>>> LEXCommunityLiJun
            strColumus = '';
            ID accRecordTypeId = accTypeForSort;
@@ -280,14 +383,23 @@
                    strRtColumus = strRtColumus + ',' + s;
                }
                columnRightCss.add(s.replace('.', '_'));
<<<<<<< HEAD
=======
>>>>>>> LEXCommunityLiJun
            }
            strColumus = String.join(columus, ',');
            System.debug('======-======-======strColumus' + strColumus);
            System.debug('======-======-======strRtColumus' + strRtColumus);
            this.sortOrderAsc = true;
<<<<<<< HEAD
            this.sortOrder = new List<String>(selColumus.size());
            for (Integer i = 0; i < selColumus.size(); i++)
                this.sortOrder[i] = ' ';
=======
            this.sortOrder = new String[selColumus.size()];
            for (Integer i = 0; i < selColumus.size(); i++) this.sortOrder[i] = ' ';
>>>>>>> LEXCommunityLiJun
        }
    }
    //用于拼接SOQL语句 根据不同检索条件拼接不同SOQL语句。
@@ -309,14 +421,27 @@
        // System.debug('pppqqq333'+querySoql);
        // AND Ownerid in ( '+querySoql+')'
<<<<<<< HEAD
        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\' ';
=======
        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\' ';
>>>>>>> LEXCommunityLiJun
        //数据字段:经销商医院  +SOQL
        if (!String.isBlank(accSearch)) {
            accSearch = accSearch.trim();
            // soql += 'AND Agency__r.Name  '   + '  LIKE  \'%' + accSearch + '%\' ';
<<<<<<< HEAD
            soql += 'AND Agency_Hospital__r.Name  ' + '  LIKE  \'%' + accSearch + '%\' ';
=======
            soql += 'AND Agency_Hospital__r.Name  '   + '  LIKE  \'%' + accSearch + '%\' ';
>>>>>>> LEXCommunityLiJun
        }
        //数据字段:担当人  +SOQL
        if (!String.isBlank(aooSearch)) {
@@ -327,7 +452,11 @@
        //数据字段:03 手动填写项 准备调用makeTextSql;
        if (!String.isBlank(numtext)) {
            String newNumtext = numtext.trim();
<<<<<<< HEAD
            String str = makeTextSql(numtext1, numtext2, newNumtext);
=======
            String str = makeTextSql(numtext1,  numtext2,  newNumtext);
>>>>>>> LEXCommunityLiJun
            soql += str;
            System.debug('+++++++++++++=============++++++++++++++++++' + soql);
        }
@@ -337,9 +466,27 @@
            soql += ' order by LastModifiedDate desc limit ' + Integer.valueOf(limits);
        } else {
            if (Integer.valueOf(this.sortKey) <= titleLeft.size() + 7) {
<<<<<<< HEAD
                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);
=======
                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);
>>>>>>> LEXCommunityLiJun
            }
        }
        system.debug(soql);
@@ -347,7 +494,11 @@
        // System.debug('pppqqq111'+userlist1);
        List<Agency_Opportunity__c> InfoList = Database.query(soql);
<<<<<<< HEAD
        System.debug('+++++++-------------------' + InfoList);
=======
        System.debug('+++++++-------------------'+InfoList);
>>>>>>> LEXCommunityLiJun
        // List<Agency_Opportunity__c> InfoList = ControllerUtil.DatabaseQuery(soql);
        // System.debug('InfoList[0].Change_To_Opportunity_T__c'+InfoList[0].Change_To_Opportunity_T__c);
@@ -363,7 +514,10 @@
                    str = '\'' + agc.Change_To_Opportunity__r.Id + '\'';
                } else if (agc.Change_To_Opportunity__r.Id != null) {
                    str += ',\'' + agc.Change_To_Opportunity__r.Id + '\'';
<<<<<<< HEAD
=======
>>>>>>> LEXCommunityLiJun
                }
            }
            for (Agency_Opportunity__c info : InfoList) {
@@ -380,7 +534,13 @@
            remindMsg = '取得最近的 ' + oppCount + ' 条数据';
        } else if (!String.isBlank(this.sortKey)) {
            if (oppCount > oppLimit) {
<<<<<<< HEAD
                ApexPages.addmessage(
                    new ApexPages.message(ApexPages.severity.INFO, '数据超过' + oppLimit + '件,只显示前' + oppLimit + '件')
                );
=======
                ApexPages.addmessage(new ApexPages.message(ApexPages.severity.INFO, '数据超过' + oppLimit + '件,只显示前' + oppLimit + '件'));
>>>>>>> LEXCommunityLiJun
                //add by Link 2023-6-2
                remindMsg = '数据超过' + oppLimit + '件,只显示前' + oppLimit + '件';
            } else {
@@ -407,6 +567,14 @@
                String cSql = '';
                soql += ' AND (';
                for (Integer icount = 0; icount < vals.size(); icount++) {
<<<<<<< HEAD
                    //精琢科技   zxk    2021-08-25   start
                    String val = vals[icount];
                    if (equalOpts == 'contains') {
                        cSql = this.makeTextSqlStr(textOpts, equalOpts, val);
                        soql += cSql;
=======
                    //精琢科技   zxk    2021-08-25   start
                    String val = vals[icount];
@@ -414,6 +582,7 @@
                        cSql = this.makeTextSqlStr(textOpts, equalOpts, val);
                        soql += cSql;
>>>>>>> LEXCommunityLiJun
                        if (icount < vals.size() - 1) {
                            soql += ' OR ';
                        }
@@ -424,11 +593,17 @@
                            soql += ' AND ';
                        }
                    }
<<<<<<< HEAD
                }
                //精琢科技   zxk    2021-08-25   end
=======
                }
                //精琢科技   zxk    2021-08-25   end
>>>>>>> LEXCommunityLiJun
                //     String val = vals[icount];
                //     cSql = this.makeTextSqlStr(textOpts, equalOpts, val);
                //     system.debug(cSql);
@@ -471,7 +646,10 @@
            else if (equalOpts == '=' || equalOpts == '<>') {
                soql += 'AND ' + textOpts + equalOpts + '\'' + numtext + '\'';
            }
<<<<<<< HEAD
=======
>>>>>>> LEXCommunityLiJun
            //精琢科技   zxk    2021-08-25   start
            //起始字符
            else if (equalOpts == 'starts with' && numtext.contains(' ')) {
@@ -480,15 +658,24 @@
                for (Integer icount = 0; icount < vals.size(); icount++) {
                    String val = vals[icount];
                    if (equalOpts == 'starts with') {
<<<<<<< HEAD
                        soql += ' ' + textOpts + '  LIKE  \'%' + val + '%\'';
                        if (icount < vals.size() - 1) {
                            soql += ' OR ';
=======
                        soql += ' ' + textOpts + '  LIKE  \'%' + val + '%\'' ;
                        if (icount < vals.size() - 1) {
                            soql += ' OR ';
>>>>>>> LEXCommunityLiJun
                        }
                    }
                }
                soql += ')';
<<<<<<< HEAD
=======
>>>>>>> LEXCommunityLiJun
            }
            //精琢科技   zxk    2021-08-25   end
@@ -509,13 +696,29 @@
        return soql;
    }
    //检索条件:数据字段1,数据字段2,数据字段3均满足,并且进入makeTextSql()之后,内含数据字段包含多种时进入此方法。
<<<<<<< HEAD
    @TestVisible
    private String makeTextSqlStr(String textOpts, String equalOpts, String val) {
=======
    @TestVisible private String makeTextSqlStr(String textOpts, String equalOpts, String val) {
>>>>>>> LEXCommunityLiJun
        String soql = '';
        if (!String.isBlank(textOpts)) {
            String tmpVal = val;
            if (!String.isBlank(tmpVal)) {
                if (equalOpts == 'contains' || equalOpts == 'notcontains') {
                    if (equalOpts == 'contains') {
<<<<<<< HEAD
                        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;
=======
                        soql += ' ' + textOpts + '  LIKE  \'%' + val + '%\'' ;
                    } else if (equalOpts == 'notcontains') {
                        soql += ' ( NOT ' + textOpts + '  LIKE  \'%' + val + '%\' ) ' ;
@@ -525,6 +728,7 @@
                        soql += ' AND ' + textOpts + ' = ' + val ;
                    } else if (equalOpts == '<>') {
                        soql += ' AND ' + textOpts + ' <> ' + val ;
>>>>>>> LEXCommunityLiJun
                    }
                }
            } else {
@@ -552,6 +756,97 @@
        setLayoutRWInfo();
        searchOppInner();
        return null;
<<<<<<< HEAD
    }
    //页面内容有修改时,页面判断后传值给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;
        }
    }
}
=======
    }
    //页面内容有修改时,页面判断后传值给changeFlg以及changeFlgRt属性,点击保存时调用此方法,进行保存。
    public PageReference save() {
@@ -641,4 +936,5 @@
            AgcOpp = record;
        }
    }
}
}
>>>>>>> LEXCommunityLiJun