Li Jun
2022-03-31 1b8c8764c39fc546ca1b85ff1810ae51be74331c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
public without sharing class LeadIntentionController {
        public List<PCLInfo> pclInfos { get; set; }
    
    /*****************検索用******************/
    
    //检索日期
    public Contact con1 { get; set; }
    public Contact con2 { get; set; }
    
    //检索 两个页面上方的字段
    public String accSearch { get; set; }
    public String ownerSearch { get; set; }
    
    public List<SelectOption> dateOpts { get; private set; }
    public List<SelectOption> textOpts { get; private set; }
    public List<SelectOption> equalOpts { get; private set; }
    public List<SelectOption> textOpts2 { get; private set; }
    public List<SelectOption> equalOpts2 { get; private set; }
    public List<SelectOption> textOpts3 { get; private set; }
    public List<SelectOption> equalOpts3 { get; private set; }
    public List<SelectOption> limitOpts { get; private set; }
 
    //原因选项
    public List<SelectOption> reasonOpts { get; private set; }
 
    // public String dateField { get; set; }
    
    public String text { get; set; }
    public String condition { get; set; }
    public String value { get; set; }
    
    public String text2 { get; set; }
    public String condition2 { get; set; }
    public String value2 { get; set; }
    
    public String text3 { get; set; }
    public String condition3 { get; set; }
    public String value3 { get; set; }
    
    public Boolean onlyOpp { get; set; }
    
    public String limits { get; set; }
 
    //原因选项
    public String reasons { get;set; }
    public String inquiryformId { get;set; }
    public String reason { get;set; }
    public String opp_ID { get;set; }
    // public String Opp_Name_Search_Id { get;set; }
    public String batchReason { get;set; }
 
    //状态未跟进
    public String   leadStatus { get; set; }
    //战略科室有效
    public String   isActiveFormula { get; set; }
    
    /*****************画面表示Bean******************/
    public Integer pclCount { 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 String[]{'Contact_Name__c', 'Hospital_Name__c', 'Department_Class__c', 'Company__c', 'Status__c'
                                          ,'Request1__c', 'Inquiry_No__c', 'Phone__c', 'Email__c', 'Cancel_Reason__c'
                                          ,'Opp_Name_Search__c', 'Opportunity_Division__c', 'LeadSource__c', 'Campaign__c'
                                          ,'Urgent__c', 'Request_Detail__c','Contact_Id__c','Hospital_ID__c','Department_ID__c','Opp_Name_Search_ID__c'
                                          ,'Campaign_ID__c','Id','Name','Family_Name__c','Last_Name__c','Reasons_options__c','Product1__c'
                                          };
    private String soqlWithoutSort = null;
    private String soqlForMoneyWithoutSort = null;
 
    private static Integer searchLimit = 1000;
    public String staticResource {get; set;}
    public String awsDataIds {get; set;}
    public LeadIntentionController() {
 
        pclInfos = new List<PCLInfo>();
 
        con1 = new Contact();
        con2 = new Contact();
 
        dateOpts = new List<SelectOption>();
 
        textOpts = new List<SelectOption>();
        textOpts.add(new SelectOption('','--无--'));
        textOpts.add(new SelectOption('S:Name', Schema.SObjectType.Inquiry_form__c.fields.Name.label));
        textOpts.add(new SelectOption('S:Hospital_Name__r.Name', Schema.SObjectType.Inquiry_form__c.fields.Hospital_Name__c.label));
        textOpts.add(new SelectOption('S:Department_Class__r.Name', Schema.SObjectType.Inquiry_form__c.fields.Department_Class__c.label));
        textOpts.add(new SelectOption('S:Status__c', Schema.SObjectType.Inquiry_form__c.fields.Status__c.label));
        textOpts.add(new SelectOption('S:Request1__c', Schema.SObjectType.Inquiry_form__c.fields.Request1__c.label));
        textOpts.add(new SelectOption('S:Product1__c', Schema.SObjectType.Inquiry_form__c.fields.Product1__c.label));
        textOpts.add(new SelectOption('S:Phone__c', Schema.SObjectType.Inquiry_form__c.fields.Phone__c.label));
        textOpts.add(new SelectOption('S:Email__c', Schema.SObjectType.Inquiry_form__c.fields.Email__c.label));
        textOpts.add(new SelectOption('S:Cancel_Reason__c', Schema.SObjectType.Inquiry_form__c.fields.Cancel_Reason__c.label));
        textOpts.add(new SelectOption('S:Opp_Name_Search__r.Name', Schema.SObjectType.Inquiry_form__c.fields.Opp_Name_Search__c.label));
        textOpts.add(new SelectOption('S:Opportunity_Division__c', Schema.SObjectType.Inquiry_form__c.fields.Opportunity_Division__c.label));
        textOpts.add(new SelectOption('S:LeadSource__c', Schema.SObjectType.Inquiry_form__c.fields.LeadSource__c.label));
        textOpts.add(new SelectOption('S:Campaign__r.Name', Schema.SObjectType.Inquiry_form__c.fields.Campaign__c.label));
        textOpts.add(new SelectOption('S:Request_Detail__c', Schema.SObjectType.Inquiry_form__c.fields.Request_Detail__c.label));
 
        textOpts2 = textOpts;
        textOpts3 = textOpts;
 
        equalOpts = new List<SelectOption>();
        equalOpts.add(new SelectOption('equals','等于'));
        equalOpts.add(new SelectOption('notequals','不等于'));
        equalOpts.add(new SelectOption('contains','包含'));
        equalOpts.add(new SelectOption('notcontains','不包含'));
        equalOpts.add(new SelectOption('starts with','起始字符'));
        
        equalOpts2 = equalOpts;
        equalOpts3 = equalOpts;
 
        limitOpts = new List<SelectOption>();
        // limitOpts.add(new SelectOption('5','5'));
        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('500','500'));
        limitOpts.add(new SelectOption('' + (searchLimit + 1), '全部'));
        
        limits = '50';
 
        reasonOpts = new List<SelectOption>();
        reasonOpts.add(new SelectOption('已经有询价','已经有询价'));
        reasonOpts.add(new SelectOption('客户不需要','客户不需要'));
        reasonOpts.add(new SelectOption('客户不存在','客户不存在'));
        
 
        reasons = '原因选项';
 
        leadStatus = '未跟进';
 
        isActiveFormula = '有效';
 
        staticResource = JSON.serialize(PIHelper.getPIIntegrationInfo('Inquiry_form__c')); 
    }
 
    public PageReference init() {
        system.debug('test:12345');
        onlyOpp = false;
        String uidParam = System.currentPageReference().getParameters().get('uid');
        if (uidParam != null){
            User u = [select Id, FirstName, LastName from User where Id = :uidParam];
            ownerSearch = u.LastName + ' ' + u.FirstName;
        }
        String hpidParam = System.currentPageReference().getParameters().get('hpid');
        if(hpidParam != null){
            List<Account> hpAcc = ControllerUtil.selectAccountForTrigger(new String[] {hpidParam});
            if (hpAcc.size() > 0) {
                accSearch = hpAcc[0].name;
            }
        }
        soqlWithoutSort = this.makeSoql(false, accSearch, ownerSearch,
                                     text, condition, value, text2, condition2, value2, text3, condition3, value3);
        String soql = soqlWithoutSort + ' order by  CreatedDate  desc limit ' + Integer.valueOf(limits);
        
        soqlForMoneyWithoutSort = this.makeSoql(true, accSearch, ownerSearch,
                                    text, condition, value, text2, condition2, value2, text3, condition3, value3);
        String soqlForMoney = soqlForMoneyWithoutSort + ' order by  CreatedDate   desc limit ' + Integer.valueOf(System.Label.TotalLimit);
        System.debug('soqlWithoutSort:' + soqlWithoutSort);
        system.debug('aaaaaaaaaa'+soql);
        system.debug('bbbbbbb:'+soqlForMoney);
        List<Inquiry_form__c> queryList = Database.query(soql);
        List<Inquiry_form__c> queryListForMoney = Database.query(soqlForMoney);
        system.debug('ppppppppp:'+queryList);
        system.debug('ooooooooo:'+queryListForMoney);
        system.debug('ppppppppp的size():'+queryList.size());
        system.debug('ooooooooo的size():'+queryListForMoney.size());
        this.makeOppRecordsForView(queryList, queryListForMoney);
        
        this.sortKey = '0';
        this.preSortKey = '0';
        this.sortOrderAsc = true;
        this.sortOrder = new String[columus.size()];
        for (Integer i = 0; i < columus.size(); i++) this.sortOrder[i] = ' ';
        
        System.debug('最后取得:'+pclInfos.size());
        pclCount = pclInfos.size();
        ApexPages.addmessage(new ApexPages.message(ApexPages.severity.INFO, '取得最近的 ' + pclCount + ' 条数据'));
 
        List<String> a = new List<String>();
        for(Inquiry_form__c ifc : queryList){
            a.add(ifc.AWS_Data_Id__c);
        }
        awsDataIds = JSON.serialize(a);
        return null;
    }
 
    public PageReference searchOpp() {
        pclInfos = new List<PCLInfo>();
        
        String soql = this.makeSoql(false, accSearch, ownerSearch, text, condition, value, text2, condition2, value2, text3, condition3, value3)+ ' order by     CreatedDate desc limit ' + Integer.valueOf(limits);
        // soql += ' order by Name limit ' + Integer.valueOf(limits);
        
        String soqlForMoney = this.makeSoql(true, accSearch, ownerSearch, text, condition, value, text2, condition2, value2, text3, condition3, value3)+ ' order by   CreatedDate desc limit ' + Integer.valueOf(System.Label.TotalLimit);
        // soqlForMoney += ' order by Name limit ' + Integer.valueOf(System.Label.TotalLimit);
        this.sortOrder[0] = '↑';
        
        system.debug('soql:'+soql);
        system.debug('soqlForMoney:'+soqlForMoney);
        List<Inquiry_form__c> queryList = Database.query(soql);
        List<Inquiry_form__c> queryListForMoney = Database.query(soqlForMoney);
        
        this.makeOppRecordsForView(queryList, queryListForMoney);
        
        pclCount = pclInfos.size();
        if (pclCount > searchLimit) {
            ApexPages.addmessage(new ApexPages.message(ApexPages.severity.INFO, 'The search returned more than the maximum number of rows (' + searchLimit + ')'));
        } else {
            ApexPages.addmessage(new ApexPages.message(ApexPages.severity.INFO, '共有 ' + pclCount + ' 条数据'));
        }
        return null;
    }
 
    public PageReference sortTable() {
        pclInfos = new List<PCLInfo>();
        
        if (this.sortKey == this.preSortKey) {
            this.sortOrderAsc = !this.sortOrderAsc;
            this.sortOrder[Integer.valueOf(this.sortKey)] = (this.sortOrderAsc == true ? '↑' : '↓');
        } else {
            this.sortOrderAsc = true;
            this.sortOrder[Integer.valueOf(this.preSortKey)] = ' ';
            this.sortOrder[Integer.valueOf(this.sortKey)] = (this.sortOrderAsc == true ? '↑' : '↓');
        }
 
        system.debug(this.sortKey);
        this.preSortKey = this.sortKey;
        
        String soql = soqlWithoutSort
                + ' order by ' + this.columus[Integer.valueOf(this.sortKey)] + ' ' + (this.sortOrderAsc == true ? 'asc nulls first' : 'desc nulls last') + ' limit ' + Integer.valueOf(limits);
system.debug('sort:::::'+ soql);
        List<Inquiry_form__c> queryList = Database.query(soql);
        String soqlForMoney = soqlForMoneyWithoutSort 
                + ' order by ' + this.columus[Integer.valueOf(this.sortKey)] + ' ' + (this.sortOrderAsc == true ? 'asc nulls first' : 'desc nulls last')+ ' limit ' + Integer.valueOf(System.Label.TotalLimit) ;
system.debug('sort:::::'+ soqlForMoney);
        List<Inquiry_form__c> queryListForMoney = Database.query(soqlForMoney);
        
        
        this.makeOppRecordsForView(queryList, queryListForMoney);
        pclCount = pclInfos.size();
        if (pclCount > searchLimit) {
            ApexPages.addmessage(new ApexPages.message(ApexPages.severity.INFO, 'The search returned more than the maximum number of rows (' + searchLimit + ')'));
        } else {
            ApexPages.addmessage(new ApexPages.message(ApexPages.severity.INFO, '共有 ' + pclCount + ' 条数据'));
        }
        return null;
    }
    //修改询问单状态为不要 并保存原因
    public PageReference   saveInquiryform() {
        //ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Error, '66666666666___'+ Id));
        system.debug('aaaaaaaaa'+inquiryformId+'bbbbbbbb'+reason);
        if (String.isNotBlank(inquiryformId)){
            List<Inquiry_form__c> updateInquiryform = new List<Inquiry_form__c>();
            Inquiry_form__c inquiryForm = new Inquiry_form__c();
            inquiryForm.Id = inquiryformId;
            inquiryForm.Status__c = '02.不需要';
            //不需要的时候 的确认日期
            system.debug('ccccccc:'+opp_ID);
            inquiryForm.Confirmation_Date__c = Date.toDay();
            inquiryForm.Reasons_options__c = reason;
            inquiryForm.Cancel_Reason__c = reason;
            if(reason == '已经有询价'){
                inquiryForm.Opp_Name_Search__c = opp_ID;
            }
            updateInquiryform.add(inquiryForm);
 
            if (updateInquiryform.size() > 0) {
                update updateInquiryform;
                // ApexPages.addmessage(new ApexPages.message(ApexPages.severity.INFO, '询问单状态更新完毕,已保存,请手动刷新页面。'));
            }
            inquiryformId = '';
        }
        
         return loadPage(); 
    }
 
     public PageReference loadPage() {
        PageReference ref = new PageReference('/apex/LeadIntention');
        ref.setRedirect(true);
        return ref;
    }
    //批量更新 询问单状态
    public PageReference   saveInquiryOpts() {
            //ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Error, '66666666666___'+ Id));
 
        try {
            system.debug('ccccccc'+batchReason);
        List<Inquiry_form__c> updSAs = new List<Inquiry_form__c>();
            
            for (PCLInfo oi : pclInfos) {
                  system.debug('输出的值为:'+oi.reasonFlg);  
                if (oi.reasonFlg == '1') {
                    oi.reasonFlg = '0';
                    oi.rec.Status__c = '02.不需要';
                    oi.rec.Reasons_options__c=batchReason;
                    oi.rec.Cancel_Reason__c = batchReason;
                    oi.rec.Confirmation_Date__c = Date.toDay();
                    updSAs.add(oi.rec); 
                    system.debug('更新的字段为:'+oi.rec);
                }
                 
            }
            system.debug(updSAs); 
        if (updSAs.size() > 0) update updSAs;
            ApexPages.addmessage(new ApexPages.message(ApexPages.severity.INFO, 'Save Completed'));
        }catch (Exception ex) {
            ApexPages.addMessages(ex);
            return null;
        } 
            
           return null; 
        }
       
    public PageReference save() {
        try {
 
            List<Inquiry_form__c> updSAs = new List<Inquiry_form__c>();
            system.debug('输出的值为:'+pclInfos);
            for (PCLInfo oi : pclInfos) {
                if (oi.changeFlg == '1') {
                    oi.changeFlg = '0';
                    updSAs.add(oi.rec);
                    system.debug('更新的字段为:'+oi.rec);
                }
 
                 
            }
 
            if (updSAs.size() > 0) update updSAs;
            ApexPages.addmessage(new ApexPages.message(ApexPages.severity.INFO, 'Save Completed'));
        } catch (Exception ex) {
            ApexPages.addMessages(ex);
            return null;
        }
        
        if (saveType == '1') {
            searchOpp();
            saveType = '';
        } else if (saveType == '2') {
            sortTable();
            saveType = '';
        } else {  
        }
        return null;
    }
 
    public PageReference cancel() {
        return new PageReference('/home/home.jsp');
    }
 
    private String makeSoql(Boolean isforMoneyFlg, String accStr, String ownerStr, //String dept, String rank, Boolean consumable,
                            String txt, String con, String val,
                            String txt2, String con2, String val2,
                            String txt3, String con3, String val3) {
        String soql ='';
            soql += 'select Id, Contact_Name__c, Hospital_Name__r.Name, Department_Class__c, Company__c, Request1__c,'
                + ' Inquiry_No__c, Phone__c, Email__c, Cancel_Reason__c,Status__c,'
                + ' Opp_Name_Search__c, Opportunity_Division__c, LeadSource__c, Campaign__c,'
                + ' Urgent__c, Request_Detail__c ,Contact_Id__c,Hospital_ID__c,Department_ID__c,Opp_Name_Search_ID__c,'
                + 'Campaign_ID__c,Last_Name__c,Family_Name__c,Name,Reasons_options__c,'
                + 'Product1__c,Confirmation_Date__c,AWS_Data_Id__c'
                //,Lead_link__c
                + ' from Inquiry_form__c where Id != null ';
                //2021-11-24  mzy  共通平台项目-首页修改  start
                //只查询所有人是当前用户的产品咨询单
                //+ ' And OwnerId = \''+UserInfo.getUserId()+'\''
                //2021-11-24  mzy  共通平台项目-首页修改  end
 
        //状态只显示未跟进
        if (!String.isBlank(leadStatus)) {
            String[] vals = leadStatus.split(' ');
                    for (String v : vals) {
                        soql += ' and Status__c = \'' + v + '\'' ;
            } 
        }
        if(!String.isBlank(isActiveFormula)){
            String[] vals = isActiveFormula.split(' ');
                    for (String v : vals) {
                        soql += ' and Department_Class__r.Is_Active_Formula__c = \'' + v + '\'' ;
            } 
        }
        if (!String.isBlank(accStr)) {
            String[] vals = accStr.split(' ');
            for (String v : vals) {
                soql += ' and Hospital_Name__r.Name like \'%' + v + '%\'';
            }
        }
        if (!String.isBlank(ownerStr)) {
            String[] vals = ownerStr.split(' ');
            for (String v : vals) {
                soql += ' and Name like \'%' + v + '%\'';
            }
        }
        
        soql += this.makeTextSql(txt, con, val);
        soql += this.makeTextSql(txt2, con2, val2);
        soql += this.makeTextSql(txt3, con3, val3);
        
        system.debug('sssssss:'+soql);
        return soql;
    }
 
    private void makeOppRecordsForView(List<Inquiry_form__c> queryList, List<Inquiry_form__c> queryListForMoney) {
        Savepoint sp = Database.setSavepoint();
        Database.SaveResult[] results = Database.update(queryList, false);
        Database.rollback(sp);
        system.debug('llllllllll:'+queryListForMoney.size());
        for (Integer i = 0; i < queryListForMoney.size(); i++) {
            system.debug('vvvvvvvvvv:'+queryList);
            if(i<queryList.size()){
                if (i == searchLimit + 1) {
                    continue;
                }
                pclInfos.add(new PCLInfo(queryList[i]));
                pclInfos[pclInfos.size() - 1].lineNo = pclInfos.size() - 1;
                //拼接 复选框的id值
                pclInfos[pclInfos.size() - 1].chk = 'chk'+ pclInfos[pclInfos.size() - 1].lineNo;
                if (!results[i].isSuccess()) {
                    pclInfos[pclInfos.size() - 1].canEdit = false;
                    if (results[i].getErrors()[0].getStatusCode() != null) {
                        if (String.valueOf(results[i].getErrors()[0].getStatusCode()) == 'INSUFFICIENT_ACCESS_OR_READONLY') {
                            pclInfos[pclInfos.size() - 1].hasError = true;
                        } else {
                            pclInfos[pclInfos.size() - 1].hasFieldError = true;
                        }
                    }
                }
            }
  
        }
    }
 
private String makeTextSql(String txt1, String con, String val) {
    system.debug('第一个参数:'+txt1+'第二个参数:'+con+'第三个参数:'+val);
        String soql = '';
        if (!String.isBlank(txt1)) {
            if ((con == 'contains' || con == 'notcontains') && val.contains(' ')) {
                String[] vals = val.split(' ');
                String cSql = '';
                for (String v : vals) {
                    cSql += this.makeTextSqlStr(txt1, con, v);
                }
                if (con == 'contains') {
                    soql += cSql;
                } else {
                    cSql = cSql.replaceAll(' and ', ') and (NOT ');
                    soql += cSql.substring(1) + ') ';
                }
            } else if ((con == 'equals' || con == 'notequals') && val.contains(',')) {
                String[] vals = val.split(',');
                if (vals.size() > 0) {
                    String txt = txt1.substring(2);  
                    soql += ' and ( ';
                    for (String v : vals) {
                        if (con == 'equals') {
                            soql += txt + ' = \'' + v + '\' or ';
                            system.debug('wwwwwwwwwwww :'+soql);
                        } else {
                            // notequals
                            soql += txt + ' <> \'' + v + '\' and ';
                        }
                    }
                    soql = soql.substring(0, soql.length() - 4);
                    soql += ')';
                }
            } else {
                String cSql = this.makeTextSqlStr(txt1, con, val);
                if (con != 'notcontains') {
                    soql += this.makeTextSqlStr(txt1, con, val);
                } else {
                    // notcontains
                    cSql = cSql.substring(5);    
                    soql += ' and (NOT ' + cSql + ') ';
                }
            }
        }
        return soql;
    }
    private String makeTextSqlStr(String txt1, String con, String val) {
        String soql = '';
        system.debug('第一个参数:'+txt1+'第二个参数:'+con+'第三个参数:'+val);
        if (!String.isBlank(txt1)) {
            String txt = txt1.substring(2);
            String colType = txt1.substring(0, 2);
            String tmpVal = val;
            if (String.isBlank(tmpVal)) {
                if (con == 'equals') {
                    soql += ' and ' + txt + ' = null';
                } else if (con == 'notequals') {
                    soql += ' and ' + txt + ' <> null';
                } else {
                }
            } else {
                soql += ' and ' + txt;
                if (con == 'equals') {
                    if (colType == 'S:') {
                        soql += ' = \'' + tmpVal + '\'';
                    } else {
                        soql += ' = ' + tmpVal + ' ';
                    }
                } else if (con == 'notequals') {
                    if (colType == 'S:') {
                        soql += ' <> \'' + tmpVal + '\'';
                    } else {
                        soql += ' <> ' + tmpVal + ' ';
                    }
                } else if (con == 'contains' || con == 'notcontains') {
                    soql += ' like \'%' + tmpVal + '%\'';
                } else if (con == 'starts with') {
                    soql += ' like \'' + tmpVal + '%\'';
                } else {
                    if (colType == 'S:') {
                        soql += ' ' + con + '\'' + tmpVal + '\'';
                    } else {
                        soql += ' ' + con + ' ' + tmpVal + ' ';
                    }
                }
            }
        }
        return soql;
    }
 
     class PCLInfo {
        public Inquiry_form__c rec { 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 reasonFlg { get; set; }
        //复选框id值
        public String chk { get;set; }
        
        public PCLInfo(Inquiry_form__c record) {
            rec = record;
            canEdit = true;
            hasError = false;
            hasFieldError = false;
            lineNo = 0;
            changeFlg = '0';
            reasonFlg = '0';
            chk = 'chk'+lineNo;
        }
 
    }
 
}