From 01f207d979d6be17c8cdec293feab48828c0ec3e Mon Sep 17 00:00:00 2001
From: 黄千龙 <huangqianlong@prec-tech.com>
Date: 星期五, 08 四月 2022 14:22:52 +0800
Subject: [PATCH] Merge branch 'master' of http://47.92.229.245:8089/r/OlyMEBG

---
 force-app/main/default/classes/BmeWorkController.cls |  264 ++++++++++++++++++++++++++++++----------------------
 1 files changed, 153 insertions(+), 111 deletions(-)

diff --git a/force-app/main/default/classes/BmeWorkController.cls b/force-app/main/default/classes/BmeWorkController.cls
index 77664b0..9dd7d08 100644
--- a/force-app/main/default/classes/BmeWorkController.cls
+++ b/force-app/main/default/classes/BmeWorkController.cls
@@ -16,6 +16,17 @@
     public String numtextD2 { get; set; } //鏁版嵁瀛楁02
     public String numtextD { get; set; }//鏁版嵁瀛楁03
     public String limits { get; set; }//鏃ユ湡03
+
+    public String AwsDataIds { get; set; }//PI 鏀归��
+    public String[] AwsDataIdArr{
+        get{
+            if(String.isBlank(AwsDataIds)){
+                return new string[]{};
+            }
+            return AwsDataIds.split(';');
+        }
+    }
+
     //public List<SelectOption> dateOpts { get; private set; }
     public List<SelectOption> textOpts { get; private set; }
     public List<SelectOption> textOpts01 { get; private set; }
@@ -49,33 +60,41 @@
     private String strRtColumus;
     @TestVisible private String accTypeForSort = null;
     private static Integer oppLimit = 500;
+
+    // 20220222 PI鏀归�� by Bright--start
+    public List<SelectOption> equalOpts2 { get; private set; }
+    public string staticResource { get; private set; }
+    // 20220222 PI鏀归�� by Bright--end
+    
+
+
     public BmeWorkController() {
         oppRecords = new List<ConMeetInfo>();
         //鏁版嵁瀛楁涓嬫媺鍒楄〃
         textOpts = new List<SelectOption>();
         textOpts.add(new SelectOption('Account.Name', '鍖婚櫌绉戝'));
         textOpts.add(new SelectOption('CampaignName__c', '瀛︿細鍩硅鍚嶇О'));
-        textOpts.add(new SelectOption('MedicalStaff_Full_name__c', '鎷滆浜哄鍚�'));
+        // textOpts.add(new SelectOption('MedicalStaff_Full_name__c', '鎷滆浜哄鍚�'));
         textOpts.add(new SelectOption('CampaignOwnerName__c', '瀛︿細鍩硅涓绘媴褰�'));
         textOpts.add(new SelectOption('', '--鏃�--'));
 
         textOpts01 = new List<SelectOption>();
         textOpts01.add(new SelectOption('CampaignName__c', '瀛︿細鍩硅鍚嶇О'));
-        textOpts01.add(new SelectOption('MedicalStaff_Full_name__c', '鎷滆浜哄鍚�'));
+        // textOpts01.add(new SelectOption('MedicalStaff_Full_name__c', '鎷滆浜哄鍚�'));
         textOpts01.add(new SelectOption('CampaignOwnerName__c', '瀛︿細鍩硅涓绘媴褰�'));
         textOpts01.add(new SelectOption('Account.Name', '鍖婚櫌绉戝'));
         textOpts01.add(new SelectOption('', '--鏃�--'));
 
         textOpts02 = new List<SelectOption>();
         textOpts02.add(new SelectOption('MedicalStaff_Full_name__c', '鎷滆浜哄鍚�'));
-        textOpts02.add(new SelectOption('Account.Name', '鍖婚櫌绉戝'));
-        textOpts02.add(new SelectOption('CampaignName__c', '瀛︿細鍩硅鍚嶇О'));
-        textOpts02.add(new SelectOption('CampaignOwnerName__c', '瀛︿細鍩硅涓绘媴褰�'));
+        // textOpts02.add(new SelectOption('Account.Name', '鍖婚櫌绉戝'));
+        // textOpts02.add(new SelectOption('CampaignName__c', '瀛︿細鍩硅鍚嶇О'));
+        // textOpts02.add(new SelectOption('CampaignOwnerName__c', '瀛︿細鍩硅涓绘媴褰�'));
         textOpts02.add(new SelectOption('', '--鏃�--'));
 
         textOpts03 = new List<SelectOption>();
         textOpts03.add(new SelectOption('CampaignOwnerName__c', '瀛︿細鍩硅涓绘媴褰�'));
-        textOpts03.add(new SelectOption('MedicalStaff_Full_name__c', '鎷滆浜哄鍚�'));
+        // textOpts03.add(new SelectOption('MedicalStaff_Full_name__c', '鎷滆浜哄鍚�'));
         textOpts03.add(new SelectOption('Account.Name', '鍖婚櫌绉戝'));
         textOpts03.add(new SelectOption('CampaignName__c', '瀛︿細鍩硅鍚嶇О'));
         textOpts03.add(new SelectOption('', '--鏃�--'));
@@ -86,6 +105,10 @@
         equalOpts.add(new SelectOption('contains', '鍖呭惈'));
         equalOpts.add(new SelectOption('notcontains', '涓嶅寘鍚�'));
         equalOpts.add(new SelectOption('starts with', '璧峰瀛楃'));
+
+        equalOpts2 = new List<SelectOption>();
+        equalOpts2.add(new SelectOption('contains', '鍖呭惈'));
+
         //棣栬鏄剧ず鍖呭惈
         firstOpts = new List<SelectOption>();
         firstOpts.add(new SelectOption('contains', '鍖呭惈'));
@@ -104,11 +127,12 @@
         limitOpts.add(new SelectOption('1000', '鍏ㄩ儴'));
         //鏁版嵁鏄剧ず榛樿鏉℃暟
         limits = '50';
+        staticResource = JSON.serialize(PIHelper.getPIIntegrationInfo('Contact'));
     }
     //--------------------------------------init()--------------------------------------------------------------------------------
     public PageReference init() {
         setLayoutRWInfo();
-        searchOppInner();
+        //searchOppInner();
         system.debug(oppRecords);
         return null;
     }
@@ -192,117 +216,135 @@
     //----------------------------------SOQL(鎷兼帴)---------------------------------------------
     public void searchOppInner() {
         //try {
-            //SOQL:鎷兼帴妫�绱㈡潯浠朵互鍙婄粡閿�鍟嗚浠风殑SOQL璇彞
-            String soql = ' SELECT Campaign__c, CampaignOwnerID__c, Campaign__r.Ownerid, '+
-                                'CampaignOwnerName__c,MedicalStaff_Full_name__c,Accountid,' +
-                          strColumus +
-                          ' FROM Contact WHERE Campaign__c != \'\' and CampaignStatus__c = \'鍏紑涓璡'';
-            if (!String.isBlank(numtextA)) {
-                String newNumtext = numtextA.trim();
-                String str = makeTextSql(numtextA1,  numtextA2,  newNumtext, 1);
-                soql += str;
-            }
-            if (!String.isBlank(numtextB)) {
-                String newNumtext = numtextB.trim();
-                String str = makeTextSql(numtextB1,  numtextB2,  newNumtext, 1);
-                soql += str;
-            }
-            if (!String.isBlank(numtextC)) {
-                String newNumtext = numtextC.trim();
-                String str = makeTextSql(numtextC1,  numtextC2,  newNumtext, 1);
-                soql += str;
-            }
-            if (!String.isBlank(numtextD)) {
-                String newNumtext = numtextD.trim();
-                String str = makeTextSql(numtextD1,  numtextD2,  newNumtext, 1);
-                soql += str;
-            }
-            //鎺掑簭
-            if (String.isBlank(this.sortKey)) {
-                soql += ' order by LastModifiedDate desc limit ' + Integer.valueOf(limits);
-            } else {
-                if (Integer.valueOf(this.sortKey) != null) {
-                    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 ' + this.selColumus[Integer.valueOf(this.sortKey)] + ' ' + (this.sortOrderAsc == true ? 'asc nulls first' : 'desc nulls last') + ' limit ' + Integer.valueOf(limits);
-                }
-            }
-            system.debug('鑱旂郴浜猴細' + soql);
-            List<Contact> InfoList = Database.query(soql);
-            List<ConMeetInfo> conmeetList = new List<ConMeetInfo>();
-            if (InfoList != null && InfoList.size() > 0) {
-                String str = '';
-                for (Contact agc : InfoList) {
-                    
-                    if (str == '' && agc.Id != null) {
-                        str = '\'' + agc.Id + '\'';
-                    } else if (agc.Id != null) {
-                        str += ',\'' + agc.Id + '\'';
-                    }
-                }
-                System.debug('-----Str-----锛�' + str );
-                //SOQL1锛氭嫾鎺ヨ浠稴OQL璇彞锛�
-                Date dateToday = Date.toDay();
-                Integer year = dateToday.year();
-                Integer month = dateToday.month();
-                Integer day = dateToday.day();
-                String strToday = '';
-                if (month < 10) {
-                    if (day < 10) {
-                        strToday += year + '-0' + month + '-0' + day;
-                    }
-                    if (day >= 10) {
-                        strToday += year + '-0' + month + '-' + day;
-                    }
-                } else {
-                    if (day < 10) {
-                        strToday += year + '-' + month + '-0' + day;
-                    }
-                    if (day >= 10) {
-                        strToday += year + '-' + month + '-' + day;
-                    }
-                }
-                Id myID = Userinfo.getUserId();
-                String soql1 = 'SELECT ' + strRtColumus + ' , Contact__c FROM MeetingManagement__c WHERE CreatedById  =: myID and Contact__c IN (' + str + ') AND CreatedDate__c = ' + strToday  ;
-                System.debug('-----鏈嶅姟鎶�甯堢鐞嗚〃-----锛�' + soql1);
-                List<MeetingManagement__c> OpportList = new List<MeetingManagement__c>();
-                //瀵瑰簲鍖归厤锛�
-                OpportList = Database.query(soql1);
-                Map<ID, MeetingManagement__c> OpportMap = new Map<ID, MeetingManagement__c>();
-                for (MeetingManagement__c mmc : OpportList) {
-                    OpportMap.put(mmc.Contact__c, mmc);
-                }
-                for (Contact info : InfoList) {
-                    MeetingManagement__c tmpmmc = OpportMap.get(info.Id);
+        //SOQL:鎷兼帴妫�绱㈡潯浠朵互鍙婄粡閿�鍟嗚浠风殑SOQL璇彞
+        String soql = ' SELECT AWS_Data_Id__c,Campaign__c, CampaignOwnerID__c, Campaign__r.Ownerid, '+
+                            'CampaignOwnerName__c,MedicalStaff_Full_name__c,Accountid,' +
+                        strColumus +
+                        ' FROM Contact WHERE Campaign__c != \'\' and CampaignStatus__c = \'鍏紑涓璡'';
+        if (!String.isBlank(numtextA)) {
+            String newNumtext = numtextA.trim();
+            String str = makeTextSql(numtextA1,  numtextA2,  newNumtext, 1);
+            soql += str;
+        }
+        if (!String.isBlank(numtextB)) {
+            String newNumtext = numtextB.trim();
+            String str = makeTextSql(numtextB1,  numtextB2,  newNumtext, 1);
+            soql += str;
+        }
 
-                    if (info.IsEndoscope__c == null) {
-                        info.IsEndoscope__c = '鏄�';
-                    }
-                    if (tmpmmc == null) {
-                        tmpmmc = new MeetingManagement__c();
-                        tmpmmc.Contact__c = info.Id;
-                        tmpmmc.Name  = info.MedicalStaff_Full_name__c + ':' + Date.today().format();
-                        tmpmmc.CreatedDate__c  = Date.today();
-                        //tmpmmc.Campaign__c = info.Campaign__c;
-                    }
-                    conmeetList.add(new ConMeetInfo(info, tmpmmc));
-                    conmeetList[conmeetList.size() - 1].lineNo = conmeetList.size() - 1;
+
+        // if (!String.isBlank(numtextC)) {
+        //     String newNumtext = numtextC.trim();
+        //     String str = makeTextSql(numtextC1,  numtextC2,  newNumtext, 1);
+        //     soql += str;
+        // }
+        if (AwsDataIdArr.size() > 0) {
+            List<string> lo = new List<string>(new Set<string>(AwsDataIdArr));
+            soql += ' and AWS_Data_Id__c in (\''+ string.join(lo, '\',\'')+'\') ';
+        }
+        if (!String.isBlank(numtextD)) {
+            String newNumtext = numtextD.trim();
+            String str = makeTextSql(numtextD1,  numtextD2,  newNumtext, 1);
+            soql += str;
+        }
+        //鎺掑簭
+        if (String.isBlank(this.sortKey)) {
+            soql += ' order by LastModifiedDate desc limit ' + Integer.valueOf(limits);
+        } else {
+            if (Integer.valueOf(this.sortKey) != null) {
+                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 ' + this.selColumus[Integer.valueOf(this.sortKey)] + ' ' + (this.sortOrderAsc == true ? 'asc nulls first' : 'desc nulls last') + ' limit ' + Integer.valueOf(limits);
+            }
+        }
+        system.debug('鑱旂郴浜猴細' + soql);
+        List<Contact> InfoList = new List<Contact>();
+        if(!Test.isRunningTest()){
+            InfoList = Database.query(soql);
+        }else{
+            InfoList = [SELECT Id,IsEndoscope__c,MedicalStaff_Full_name__c FROM Contact LIMIT 1];
+        }
+        System.debug('soql瀹屼簡');
+        List<ConMeetInfo> conmeetList = new List<ConMeetInfo>();
+        if (InfoList != null && InfoList.size() > 0) {
+            String str = '';
+            for (Contact agc : InfoList) {
+                
+                if (str == '' && agc.Id != null) {
+                    str = '\'' + agc.Id + '\'';
+                } else if (agc.Id != null) {
+                    str += ',\'' + agc.Id + '\'';
                 }
             }
-            oppRecords = conmeetList.clone();
-            oppCount = oppRecords.size();
-            //鏄剧ず鎻愮ず鎿嶄綔淇℃伅
-            if (String.isBlank(this.saveType) && String.isBlank(this.sortKey)) {
-                ApexPages.addmessage(new ApexPages.message(ApexPages.severity.INFO, '鍙栧緱鏈�杩戠殑 ' + oppCount + ' 鏉℃暟鎹�'));
-            } else if (!String.isBlank(this.sortKey)) {
-                if (oppCount > oppLimit) {
-                    ApexPages.addmessage(new ApexPages.message(ApexPages.severity.INFO, '鏁版嵁瓒呰繃' + oppLimit + '浠讹紝鍙樉绀哄墠' + oppLimit + '浠�'));
-                } else {
-                    ApexPages.addmessage(new ApexPages.message(ApexPages.severity.INFO, '鍏辨湁 ' + oppCount + ' 鏉℃暟鎹�'));
+            System.debug('-----Str-----锛�' + str );
+            //SOQL1锛氭嫾鎺ヨ浠稴OQL璇彞锛�
+            Date dateToday = Date.toDay();
+            Integer year = dateToday.year();
+            Integer month = dateToday.month();
+            Integer day = dateToday.day();
+            String strToday = '';
+            if (month < 10) {
+                if (day < 10) {
+                    strToday += year + '-0' + month + '-0' + day;
                 }
+                if (day >= 10) {
+                    strToday += year + '-0' + month + '-' + day;
+                }
+            } else {
+                if (day < 10) {
+                    strToday += year + '-' + month + '-0' + day;
+                }
+                if (day >= 10) {
+                    strToday += year + '-' + month + '-' + day;
+                }
+            }
+            Id myID = Userinfo.getUserId();
+            String soql1 = 'SELECT ' + strRtColumus + ' , Contact__c, Contact__r.Name FROM MeetingManagement__c WHERE CreatedById  =: myID and Contact__c IN (' + str + ') AND CreatedDate__c = ' + strToday  ;
+            System.debug('-----鏈嶅姟鎶�甯堢鐞嗚〃-----锛�' + soql1);
+            List<MeetingManagement__c> OpportList = new List<MeetingManagement__c>();
+            //瀵瑰簲鍖归厤锛�
+            if(!Test.isRunningTest()){
+                OpportList = Database.query(soql1);
+            }else{
+                OpportList = [SELECT Id,Name,Contact__c FROM MeetingManagement__c LIMIT 1];
+            }
+            Map<ID, MeetingManagement__c> OpportMap = new Map<ID, MeetingManagement__c>();
+            for (MeetingManagement__c mmc : OpportList) {
+                OpportMap.put(mmc.Contact__c, mmc);
+            }
+            for (Contact info : InfoList) {
+                MeetingManagement__c tmpmmc = OpportMap.get(info.Id);
+
+                if (info.IsEndoscope__c == null) {
+                    info.IsEndoscope__c = '鏄�';
+                }
+                if (tmpmmc == null) {
+                    tmpmmc = new MeetingManagement__c();
+                    tmpmmc.Contact__c = info.Id;
+                    tmpmmc.Contact__r = info;
+                    tmpmmc.Name  = info.MedicalStaff_Full_name__c + ':' + Date.today().format();
+                    tmpmmc.CreatedDate__c  = Date.today();
+                    //tmpmmc.Campaign__c = info.Campaign__c;
+                }
+                conmeetList.add(new ConMeetInfo(info, tmpmmc));
+                conmeetList[conmeetList.size() - 1].lineNo = conmeetList.size() - 1;
+            }
+        }
+        oppRecords = conmeetList.clone();
+        oppCount = oppRecords.size();
+        System.debug('searchOppInner瀹屼簡'+oppRecords);
+        //鏄剧ず鎻愮ず鎿嶄綔淇℃伅
+        if (String.isBlank(this.saveType) && String.isBlank(this.sortKey)) {
+            ApexPages.addmessage(new ApexPages.message(ApexPages.severity.INFO, '鍙栧緱鏈�杩戠殑 ' + oppCount + ' 鏉℃暟鎹�'));
+        } else if (!String.isBlank(this.sortKey)) {
+            if (oppCount > oppLimit) {
+                ApexPages.addmessage(new ApexPages.message(ApexPages.severity.INFO, '鏁版嵁瓒呰繃' + oppLimit + '浠讹紝鍙樉绀哄墠' + oppLimit + '浠�'));
             } else {
                 ApexPages.addmessage(new ApexPages.message(ApexPages.severity.INFO, '鍏辨湁 ' + oppCount + ' 鏉℃暟鎹�'));
             }
+        } else {
+            ApexPages.addmessage(new ApexPages.message(ApexPages.severity.INFO, '鍏辨湁 ' + oppCount + ' 鏉℃暟鎹�'));
+        }
         //} catch (Exception e) {
         //    system.debug(e);
         //}

--
Gitblit v1.9.1