CommonMultiBrowserAjax.jsp
32.8 KB
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
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
<%@page import="weaver.formmode.browser.FormModeBrowserUtil"%>
<%@ page language="java" contentType="text/html; charset=UTF-8" %>
<%@ page import="com.weaver.formmodel.util.StringHelper"%>
<%@ page import="weaver.servicefiles.DataSourceXML"%>
<%@ page import="net.sf.json.JSONArray"%>
<%@ page import="weaver.general.SplitPageUtil"%>
<%@ page import="java.net.URLDecoder"%>
<%@ page import="weaver.conn.RecordSet"%>
<%@ page import="weaver.systeminfo.SystemEnv"%>
<%@ page import="weaver.hrm.User"%>
<%@ page import="weaver.general.Util" %>
<%@ page import="weaver.general.ComparatorUtil" %>
<%@ page import="java.util.*" %>
<%@ page import="weaver.formmode.virtualform.VirtualFormHandler"%>
<%@ page import="weaver.formmode.service.CommonConstant"%>
<%@ page import="weaver.formmode.customjavacode.CustomJavaCodeRun"%>
<%@ page import="weaver.formmode.service.BrowserInfoService"%>
<%@ page import="weaver.hrm.HrmUserVarify"%>
<%@ page import="weaver.general.SplitPageParaBean"%>
<%@ page import="net.sf.json.JSONObject"%>
<%@ page import="weaver.general.StaticObj" %>
<%@ page import="weaver.interfaces.workflow.browser.Browser" %>
<%@ page import="weaver.interfaces.workflow.browser.BrowserBean" %>
<%@ page import="com.weaver.formmodel.util.StringHelper" %>
<%@page import="weaver.formmode.tree.CustomTreeData"%>
<jsp:useBean id="RecordSet" class="weaver.conn.RecordSet" scope="page" />
<jsp:useBean id="rs" class="weaver.conn.RecordSet" scope="page" />
<jsp:useBean id="rsm" class="weaver.conn.RecordSet" scope="page" />
<jsp:useBean id="FormModeTransMethod" class="weaver.formmode.search.FormModeTransMethod" scope="page"/>
<jsp:useBean id="ModeShareManager" class="weaver.formmode.view.ModeShareManager" scope="page" />
<jsp:useBean id="ModeRightInfo" class="weaver.formmode.setup.ModeRightInfo" scope="page" />
<%
request.setCharacterEncoding("UTF-8");
User user = HrmUserVarify.getUser(request,response);
String istree = Util.null2String(request.getParameter("istree"));//是否树的组合查询
String treeid = Util.null2String(request.getParameter("treeid"));
String treenodeid = Util.null2String(request.getParameter("treenodeid"));
String src = Util.null2String(request.getParameter("src"));
String browsertype = Util.null2String(request.getParameter("browsertype"));
String customid=Util.null2String(request.getParameter("customid"));
//链接地址中sqlwhere
String sqlwhereparam=Util.null2String(request.getParameter("sqlwhere"));
String check_per = Util.null2String(request.getParameter("systemIds")).replace("weaver2017", "+");
int perpage = Util.getIntValue(request.getParameter("pageSize"),10) ;
int pagenum = Util.getIntValue(request.getParameter("currentPage") , 1) ;
if(perpage <1) perpage=10;
String isCustomPageSize = Util.null2String(request.getParameter("isCustomPageSize"));
if("".equals(customid)){
out.println(SystemEnv.getHtmlLabelName(81939,user.getLanguage()));//browser框id不能为空!
return;
}
if(check_per.trim().startsWith(",")){
check_per = check_per.substring(1);
}
//============================================browser框基础数据====================================
boolean issimple=true;
String isbill="1";
int viewtype=0;
int opentype = 0;
String formID="0";
String defaultsql="";
String searchconditiontype = "1";
String javafilename = "";
String showfield="";
String fromSql;
String sqlwhere="";
String formmodeid="0";
String tablename="";
String orderby = "t1.id";
String norightlist = "";
String detailtable = "";
String detailkeyfield = "";
String maintableAlias="t1";
String detailtableAlias="d1";
String detailfieldAlias="d_";
String backfields = " t1.id,t1.formmodeid,t1.modedatacreater,t1.modedatacreatertype,t1.modedatacreatedate,t1.modedatacreatetime ";
rs.execute("select a.defaultsql,a.modeid,a.customname,a.customdesc,a.formid,a.detailtable,a.searchconditiontype,a.javafilename,a.pagenumber,a.norightlist,b.detailkeyfield from mode_custombrowser a left join workflow_bill b on a.formid=b.id where a.id="+customid);
if(rs.next()){
formID=Util.null2String(rs.getString("formid"));
formmodeid=Util.null2String(rs.getString("modeid"));
defaultsql = Util.toScreenToEdit(rs.getString("defaultsql"),user.getLanguage()).trim();
defaultsql = FormModeTransMethod.getDefaultSql(user,defaultsql);
searchconditiontype = Util.null2String(rs.getString("searchconditiontype"));
searchconditiontype = searchconditiontype.equals("") ? "1" : searchconditiontype;
javafilename = Util.null2String(rs.getString("javafilename"));
if(perpage==10&&isCustomPageSize.equals("")){//首次加载或不改变页数
perpage = Util.getIntValue(Util.null2String(rs.getString("pagenumber")),10);
}
norightlist = Util.null2String(rs.getString("norightlist"));
detailtable = Util.null2String(rs.getString("detailtable"));
detailkeyfield = Util.null2String(rs.getString("detailkeyfield"));
}
if(istree.equals("1")){//树组合查询一律当作无权限列表对待
norightlist = "1";
formmodeid = "0";
}
//============================================虚拟表基础数据====================================
String vdatasource = ""; //虚拟表单数据源
String vprimarykey = ""; //虚拟表单主键列名称
String vdatasourceDBtype = ""; //数据库类型
boolean isVirtualForm = VirtualFormHandler.isVirtualForm(formID); //是否是虚拟表单
Map<String, Object> vFormInfo = new HashMap<String, Object>();
if(isVirtualForm){
vFormInfo = VirtualFormHandler.getVFormInfo(formID);
vdatasource = Util.null2String(vFormInfo.get("vdatasource")); //虚拟表单数据源
vprimarykey = Util.null2String(vFormInfo.get("vprimarykey")); //虚拟表单主键列名称
DataSourceXML dataSourceXML = new DataSourceXML();
vdatasourceDBtype = dataSourceXML.getDataSourceDBType(vdatasource);
}else{
vdatasourceDBtype = RecordSet.getDBType();
}
//============================================表单名称====================================
rs.executeSql("select tablename from workflow_bill where id = " + formID);
if (rs.next()){
tablename = rs.getString("tablename");
}
if(isVirtualForm){
tablename= VirtualFormHandler.getRealFromName(tablename);
}
//============================================自定义查询条件====================================
String sqlwhere_con="";
boolean isoracle = vdatasourceDBtype.equals("oracle") ;
boolean ismysql = vdatasourceDBtype.equals("mysql") ;
boolean isdb2 = vdatasourceDBtype.equals("db2") ;
String createrid=Util.null2String(request.getParameter("createrid"));
String creatertype=Util.null2String(request.getParameter("creatertype"));
String fromdate=Util.null2String(request.getParameter("fromdate"));
String todate=Util.null2String(request.getParameter("todate"));
String[] checkcons = request.getParameterValues("check_con");
ArrayList ids = new ArrayList();
ArrayList colnames = new ArrayList();
ArrayList opts = new ArrayList();
ArrayList values = new ArrayList();
ArrayList names = new ArrayList();
ArrayList opt1s = new ArrayList();
ArrayList value1s = new ArrayList();
if(checkcons!=null){
for(int i=0;i<checkcons.length;i++){
String tmpid = ""+checkcons[i];
String tmpcolname = ""+Util.null2String(request.getParameter("con"+tmpid+"_colname"));
String htmltype = ""+Util.null2String(request.getParameter("con"+tmpid+"_htmltype"));
String type = ""+Util.null2String(request.getParameter("con"+tmpid+"_type"));
String tmpopt = ""+Util.null2String(request.getParameter("con"+tmpid+"_opt"));
String tmpvalue = ""+Util.null2String(request.getParameter("con"+tmpid+"_value"));
String tmpname = ""+Util.null2String(request.getParameter("con"+tmpid+"_name"));
String tmpopt1 = ""+Util.null2String(request.getParameter("con"+tmpid+"_opt1"));
String tmpvalue1 = ""+Util.null2String(request.getParameter("con"+tmpid+"_value1"));
String multiselectValue = ""+Util.null2String(request.getParameter("multiselectValue_con"+tmpid+"_value"));
String field_viewtype = ""+Util.null2String(request.getParameter("con"+tmpid+"_viewtype"));
if("".equals(tmpvalue)&&"".equals(tmpvalue1))continue;
String tableAlias = "";
String fieldAlias = "";
tableAlias = maintableAlias+".";
if("1".equals(field_viewtype)){
tableAlias = detailtableAlias+".";
}
tmpvalue = tmpvalue.replace("'", "''");
tmpvalue1 = tmpvalue1.replace("'", "''");
if((htmltype.equals("1")&& type.equals("1"))||htmltype.equals("2")){ //文本框
if(tmpopt.equals("1")) sqlwhere_con+=" and ("+tableAlias+tmpcolname+" ='"+tmpvalue +"' ";
else if(tmpopt.equals("2")) sqlwhere_con+=" and ("+tableAlias+tmpcolname+" <>'"+tmpvalue +"' ";
else if(tmpopt.equals("3")){
ArrayList tempvalues=Util.TokenizerString(Util.StringReplace(tmpvalue," "," ")," ");
sqlwhere_con += " and (";
for(int k=0;k<tempvalues.size();k++){
if(k==0) sqlwhere_con += ""+tableAlias+tmpcolname;
else sqlwhere_con += " or "+tableAlias+tmpcolname;
tmpvalue=Util.StringReplace(Util.StringReplace((String)tempvalues.get(k),"+","%"),"+","%");
if(!isoracle&&!isdb2){
int indx=tmpvalue.indexOf("[");
if(indx<0) indx=tmpvalue.indexOf("]");
if(indx<0){
sqlwhere_con += " like '%"+tmpvalue+"%' ";
}else{
sqlwhere_con += " like '%"+Util.StringReplace(Util.StringReplace(Util.StringReplace(tmpvalue,"/","//"),"[","/["),"]","/]")+"%' ESCAPE '/' ";
}
}else{
sqlwhere_con += " like '%"+tmpvalue+"%' ";
}
}
}else if(tmpopt.equals("4")){
ArrayList tempvalues=Util.TokenizerString(Util.StringReplace(tmpvalue," "," ")," ");
for(int k=0;k<tempvalues.size();k++){
if(k==0) sqlwhere_con += "and ("+tableAlias+tmpcolname;
else sqlwhere_con += " and "+tableAlias+tmpcolname;
tmpvalue=Util.StringReplace(Util.StringReplace((String)tempvalues.get(k),"+","%"),"+","%");
if(!isoracle&&!isdb2){
int indx=tmpvalue.indexOf("[");
if(indx<0) indx=tmpvalue.indexOf("]");
if(indx<0){
sqlwhere_con += " not like '%"+tmpvalue+"%' ";
}else{
sqlwhere_con += " not like '%"+Util.StringReplace(Util.StringReplace(Util.StringReplace(tmpvalue,"/","//"),"[","/["),"]","/]")+"%' ESCAPE '/' ";
}
}else{
sqlwhere_con += " not like '%"+tmpvalue+"%' ";
}
}
}
} else if(htmltype.equals("1")&& !type.equals("1")){ //数字 <!--大于,大于或等于,小于,小于或等于,等于,不等于-->
if(!tmpvalue.equals("")){
if(type.equals("5")){//金额转换
if(rs.getDBType().equals("oracle")){
sqlwhere_con += "and (cast((CASE WHEN ("+tableAlias+tmpcolname+"||'') is null THEN '0' WHEN ("+tableAlias+tmpcolname+"||'') =' ' THEN '0' ELSE Replace(("+tableAlias+tmpcolname+"||''), ',', '') END) as number(30,6))";
}else if(rs.getDBType().equals("mysql")){
sqlwhere_con += "and cast((case when ifnull(("+tableAlias+tmpcolname+" REGEXP '[0-9.,]'),0)=1 then replace("+tableAlias+tmpcolname+",',','') else '0' end) as decimal(30,6) ) ";
}else{//金额千分位是varchar类型
sqlwhere_con += "and (cast((CASE isnumeric ("+tableAlias+tmpcolname+") WHEN 0 THEN '0' WHEN 1 THEN replace("+tableAlias+tmpcolname+",',','') ELSE '0' END) as decimal(30,6))";
}
}else{
sqlwhere_con += "and ("+tableAlias+tmpcolname;
}
if(tmpopt.equals("1")) sqlwhere_con+=" >"+tmpvalue +" ";
if(tmpopt.equals("2")) sqlwhere_con+=" >="+tmpvalue +" ";
if(tmpopt.equals("3")) sqlwhere_con+=" <"+tmpvalue +" ";
if(tmpopt.equals("4")) sqlwhere_con+=" <="+tmpvalue +" ";
if(tmpopt.equals("5")) sqlwhere_con+=" ="+tmpvalue +" ";
if(tmpopt.equals("6")) sqlwhere_con+=" <>"+tmpvalue +" ";
}
if(!tmpvalue1.equals("")){
if(type.equals("5")){//金额转换
if(rs.getDBType().equals("oracle")){
sqlwhere_con += "and cast((CASE WHEN ("+tableAlias+tmpcolname+"||'') is null THEN '0' WHEN ("+tableAlias+tmpcolname+"||'') =' ' THEN '0' ELSE Replace(("+tableAlias+tmpcolname+"||''), ',', '') END) as number(30,6))";
}else if(rs.getDBType().equals("mysql")){
sqlwhere_con += "and cast((case when ifnull(("+tableAlias+tmpcolname+" REGEXP '[0-9.,]'),0)=1 then replace("+tableAlias+tmpcolname+",',','') else '0' end) as decimal(30,6) ) ";
}else{//金额千分位是varchar类型
sqlwhere_con += "and cast((CASE isnumeric ("+tableAlias+tmpcolname+") WHEN 0 THEN '0' WHEN 1 THEN replace("+tableAlias+tmpcolname+",',','') ELSE '0' END) as decimal(30,6))";
}
}else{
sqlwhere_con += " and "+tableAlias+tmpcolname;
}
if(tmpopt1.equals("1")) sqlwhere_con+=" >"+tmpvalue1 +" ";
if(tmpopt1.equals("2")) sqlwhere_con+=" >="+tmpvalue1 +" ";
if(tmpopt1.equals("3")) sqlwhere_con+=" <"+tmpvalue1 +" ";
if(tmpopt1.equals("4")) sqlwhere_con+=" <="+tmpvalue1 +" ";
if(tmpopt1.equals("5")) sqlwhere_con+=" ="+tmpvalue1+" ";
if(tmpopt1.equals("6")) sqlwhere_con+=" <>"+tmpvalue1 +" ";
}
} else if(htmltype.equals("4")){ //check类型 = !=
sqlwhere_con += "and ("+tableAlias+tmpcolname;
if(!tmpvalue.equals("1")) sqlwhere_con+="<>'1' ";
else sqlwhere_con +="='1' ";
} else if(htmltype.equals("5")){ //选择框 = !=
if(!"".equals(multiselectValue)){
sqlwhere_con += "and ( ";
String multiselectSqlwhere_con="";
String[] multiselectValue_tmpvalueArray = multiselectValue.split(",");
for(int n=0;n<multiselectValue_tmpvalueArray.length;n++){
if("".equals(multiselectValue_tmpvalueArray[n])){
continue;
}
multiselectSqlwhere_con+=""+tableAlias+tmpcolname;
if(tmpopt.equals("1"))
multiselectSqlwhere_con+=" ="+multiselectValue_tmpvalueArray[n] +" or ";
if(tmpopt.equals("2"))
multiselectSqlwhere_con+=" <>"+multiselectValue_tmpvalueArray[n] +" or ";
}
if(multiselectSqlwhere_con.length()>0){
multiselectSqlwhere_con = multiselectSqlwhere_con.substring(0,multiselectSqlwhere_con.length()-3);
}
sqlwhere_con+=multiselectSqlwhere_con;
}else{
sqlwhere_con += "and ("+tableAlias+tmpcolname;
if(tmpopt.equals("1")) sqlwhere_con+=" ="+tmpvalue +" ";
if(tmpopt.equals("2")) sqlwhere_con+=" <>"+tmpvalue +" ";
}
}else if(htmltype.equals("8")){ //公共选择项 = !=
sqlwhere_con += "and ("+tableAlias+tmpcolname;
if(tmpopt.equals("1")) sqlwhere_con+=" ="+tmpvalue +" ";
if(tmpopt.equals("2")) sqlwhere_con+=" <>"+tmpvalue +" ";
} else if(htmltype.equals("3") && (type.equals("1")||type.equals("9")||type.equals("4")||type.equals("7")||type.equals("8")||type.equals("16"))){//浏览框单人力资源 条件为多人力 (int not in),条件为多文挡,条件为多部门,条件为多客户,条件为多项目,条件为多请求
sqlwhere_con += "and ("+tableAlias+tmpcolname;
if(tmpopt.equals("1")) sqlwhere_con+=" in ("+tmpvalue +") ";
if(tmpopt.equals("2")) sqlwhere_con+=" not in ("+tmpvalue +") ";
}else if(htmltype.equals("3") && type.equals("24")){//职位的安全级别 > >= = < ! and > >= = < !
if(!tmpvalue.equals("")){
sqlwhere_con += "and ("+tableAlias+tmpcolname;
if(tmpopt.equals("1")) sqlwhere_con+=" >"+tmpvalue +" ";
if(tmpopt.equals("2")) sqlwhere_con+=" >="+tmpvalue +" ";
if(tmpopt.equals("3")) sqlwhere_con+=" <"+tmpvalue +" ";
if(tmpopt.equals("4")) sqlwhere_con+=" <="+tmpvalue +" ";
if(tmpopt.equals("5")) sqlwhere_con+=" ="+tmpvalue +" ";
if(tmpopt.equals("6")) sqlwhere_con+=" <>"+tmpvalue +" ";
}
if(!tmpvalue1.equals("")){
sqlwhere_con += " and "+tableAlias+tmpcolname;
if(tmpopt1.equals("1")) sqlwhere_con+=" >"+tmpvalue1 +" ";
if(tmpopt1.equals("2")) sqlwhere_con+=" >="+tmpvalue1 +" ";
if(tmpopt1.equals("3")) sqlwhere_con+=" <"+tmpvalue1 +" ";
if(tmpopt1.equals("4")) sqlwhere_con+=" <="+tmpvalue1 +" ";
if(tmpopt1.equals("5")) sqlwhere_con+=" ="+tmpvalue1+" ";
if(tmpopt1.equals("6")) sqlwhere_con+=" <>"+tmpvalue1 +" ";
}
}//职位安全级别end
else if(htmltype.equals("3") &&( type.equals("2") || type.equals("19"))){ //日期 > >= = < ! and > >= = < !
if(!tmpvalue.equals("")){
sqlwhere_con += "and ("+tableAlias+tmpcolname;
if(tmpopt.equals("1")) sqlwhere_con+=" >'"+tmpvalue +"' ";
if(tmpopt.equals("2")) sqlwhere_con+=" >='"+tmpvalue +"' ";
if(tmpopt.equals("3")) sqlwhere_con+=" <'"+tmpvalue +"' ";
if(tmpopt.equals("4")) sqlwhere_con+=" <='"+tmpvalue +"' ";
if(tmpopt.equals("5")) sqlwhere_con+=" ='"+tmpvalue +"' ";
if(tmpopt.equals("6")) sqlwhere_con+=" <>'"+tmpvalue +"' ";
}
if(!tmpvalue1.equals("")){
sqlwhere_con += " and "+tableAlias+tmpcolname;
if(tmpopt1.equals("1")) sqlwhere_con+=" >'"+tmpvalue1 +"' ";
if(tmpopt1.equals("2")) sqlwhere_con+=" >='"+tmpvalue1 +"' ";
if(tmpopt1.equals("3")) sqlwhere_con+=" <'"+tmpvalue1 +"' ";
if(tmpopt1.equals("4")) sqlwhere_con+=" <='"+tmpvalue1 +"' ";
if(tmpopt1.equals("5")) sqlwhere_con+=" ='"+tmpvalue1+"' ";
if(tmpopt1.equals("6")) sqlwhere_con+=" <>'"+tmpvalue1 +"' ";
}
}
else if("3".equals(htmltype) && type.equals("141")){
List<String> tmpvalueArray = null;
if(FormModeBrowserUtil.isMultiBrowser(htmltype, type)) {
tmpvalueArray = Util.splitString2List(tmpvalue, "~");
} else {
tmpvalueArray = new ArrayList<String>();
tmpvalueArray.add(tmpvalue);
}
sqlwhere_con += " and ( ";
boolean first = true;
for(String _tmpvalue : tmpvalueArray) {
if(first) {
first = false;
} else {
sqlwhere_con += " and ";
}
if(vdatasourceDBtype.equalsIgnoreCase("oracle") || vdatasourceDBtype.equalsIgnoreCase("db2"))
sqlwhere_con += " "+tableAlias+tmpcolname+" ";
else if(vdatasourceDBtype.equals("mysql"))
sqlwhere_con += " "+tableAlias+tmpcolname+" ";
else
sqlwhere_con += " CONVERT(varchar(max),"+tableAlias+tmpcolname+") ";
if(tmpopt.equals("1")) sqlwhere_con+=" like '%"+_tmpvalue +"%' ";
if(tmpopt.equals("2")) sqlwhere_con+=" not like '%"+_tmpvalue +"%' ";
}
}
else if (htmltype.equals("3") || htmltype.equals("6")){ //其他浏览框
List<String> tmpvalueArray = null;
if(FormModeBrowserUtil.isMultiBrowser(htmltype, type)) {
tmpvalueArray = Util.splitString2List(tmpvalue, ",");
} else {
tmpvalueArray = new ArrayList<String>();
tmpvalueArray.add(tmpvalue);
}
sqlwhere_con += " and ( ";
boolean first = true;
for(String _tmpvalue : tmpvalueArray) {
if(first) {
first = false;
} else {
sqlwhere_con += " and ";
}
if(vdatasourceDBtype.equalsIgnoreCase("oracle") || vdatasourceDBtype.equalsIgnoreCase("db2"))
sqlwhere_con += " ','||"+tableAlias+tmpcolname+"||',' ";
else if(vdatasourceDBtype.equals("mysql"))
sqlwhere_con += " CONCAT(',',"+tableAlias+tmpcolname+",',') ";
else
sqlwhere_con += " ','+CONVERT(varchar(max),"+tableAlias+tmpcolname+")+',' ";
if(tmpopt.equals("1")) sqlwhere_con+=" like '%,"+_tmpvalue +",%' ";
if(tmpopt.equals("2")) sqlwhere_con+=" not like '%,"+_tmpvalue +",%' ";
}
}
if (htmltype.equals("1")|| htmltype.equals("2")||(htmltype.equals("3") && (type.equals("1")||type.equals("9")||type.equals("4")||type.equals("7")||type.equals("8")||type.equals("16")))||(htmltype.equals("3") && type.equals("24"))||(htmltype.equals("3") &&( type.equals("2") || type.equals("19")))) {
if(!tmpvalue.equals("")){
sqlwhere_con +=") ";
}
}else{
sqlwhere_con +=") ";
}
}
}
//============================================需要显示的字段====================================
Map<String,Object> showfieldMap=new LinkedHashMap<String,Object>();
if(isVirtualForm){
backfields = " t1." + vprimarykey + " ";
} else {
rs.executeSql("select * from "+tablename+ " where 1=2 ");
String[] columnName = rs.getColumnName();
boolean hasFormmodeid = false;
for(int i = 0; i<columnName.length;i++) {
if("formmodeid".equalsIgnoreCase(columnName[i])) {
hasFormmodeid = true;
break;
}
}
if(!hasFormmodeid){
backfields = " t1.id ";
}
}
String pkfield = "";
String sql = "select workflow_billfield.id as id,workflow_billfield.fieldname as name,workflow_billfield.fieldlabel as label,workflow_billfield.fielddbtype as dbtype ,workflow_billfield.fieldhtmltype as httype, workflow_billfield.type as type,mode_custombrowserdspfield.showorder,mode_custombrowserdspfield.istitle,mode_custombrowserdspfield.ispk,workflow_billfield.viewtype" +
" from workflow_billfield,mode_custombrowserdspfield,Mode_CustomBrowser where mode_custombrowserdspfield.customid=Mode_CustomBrowser.id and Mode_CustomBrowser.id="+customid+
" and mode_custombrowserdspfield.isshow='1' and workflow_billfield.billid="+formID+" and workflow_billfield.id=mode_custombrowserdspfield.fieldid" +
" union select mode_custombrowserdspfield.fieldid as id,'1' as name,2 as label,'3' as dbtype, '4' as httype,5 as type ,mode_custombrowserdspfield.showorder,mode_custombrowserdspfield.istitle,mode_custombrowserdspfield.ispk,0 as viewtype" +
" from mode_custombrowserdspfield ,Mode_CustomBrowser where mode_custombrowserdspfield.customid=Mode_CustomBrowser.id and Mode_CustomBrowser.id="+customid+
" and mode_custombrowserdspfield.isshow='1' and mode_custombrowserdspfield.fieldid<0" +
" order by istitle desc,showorder asc,id asc";
RecordSet.executeSql(sql);
String showfieldname = "";
String titleviewtype="";
while (RecordSet.next()){
String id=Util.null2String(RecordSet.getString("id"));
if("-1".equals(id)){
showfieldMap.put("modedatacreatedate", "modedatacreatetime");
showfieldname +=",modedatacreatetime";
}else if("-2".equals(id)){
showfieldMap.put("modedatacreater", "modedatacreatertype");
showfieldname +=",modedatacreatertype";
}else{
String name=Util.null2String(RecordSet.getString("name"));
String dbtype=Util.null2String(RecordSet.getString("dbtype"));
String label = RecordSet.getString("label");
String htmltype = RecordSet.getString("httype");
String type = RecordSet.getString("type");
String istitle = RecordSet.getString("istitle");
String hreflink = RecordSet.getString("hreflink");
String ispk = RecordSet.getString("ispk");
int field_viewtype = Util.getIntValue(RecordSet.getString("viewtype"),0);
if("1".equals(ispk)){
pkfield = name;
}
String fieldAlias=name;
String tableAlias=maintableAlias;
if(field_viewtype==1){
tableAlias=detailtableAlias;
fieldAlias=detailfieldAlias+name;
}
if(istitle.equals("1")){
titleviewtype = field_viewtype+"";
}
showfieldname +=","+name;
if(dbtype.toLowerCase().equals("text")){
if(isoracle){
showfield=showfield+","+"to_char("+tableAlias+"."+name+") as "+fieldAlias;
}else if(ismysql){
showfield=showfield+","+"CONCAT("+tableAlias+"."+name+",'') as "+fieldAlias;
}else{
showfield=showfield+","+"convert(varchar(4000),"+tableAlias+"."+name+") as "+fieldAlias;
}
}else{
if((backfields.toUpperCase()+",").indexOf((tableAlias+"."+name).toUpperCase())==-1){
showfield=showfield+","+tableAlias+"."+name+" as "+fieldAlias;
}
}
if(isVirtualForm){
if(formmodeid.equals("0")){
formmodeid = "virtual";
}
}
String para3="column:id+"+id+"+"+htmltype+"+"+type+"+"+user.getLanguage()+"+"+isbill+"+"+dbtype+"+"+istitle+"+"+formmodeid+"+"+formID+"+"+viewtype+"+"+opentype+"+"+customid+"+fromsearchlist"+"+"+hreflink;
showfieldMap.put(fieldAlias,para3);
}
}
showfieldMap.put("hiddenfield","");
List<User> lsUser = ModeRightInfo.getAllUserCountList(user);
backfields=backfields+showfield;
if(isVirtualForm){ //是虚拟表单
fromSql = " from "+tablename+" t1 ";
if(sqlwhere.equals("")){
sqlwhere = " where 1=1";
}
}else if(norightlist.equals("1")){
if(titleviewtype.equals("1")){//标题是明细表中的字段
fromSql = " from "+detailtable+" "+detailtableAlias ;
if(!"".equals(detailtable)){
fromSql+=" inner join "+tablename+" "+maintableAlias+" on t1.id="+detailtableAlias+"."+detailkeyfield+" ";
}
if(formmodeid.equals("")||formmodeid.equals("0")){//浏览框中没有设置模块
sqlwhere = " where 1=1 ";
}else{
sqlwhere = " where t1.formmodeid="+formmodeid+" ";
}
}else{
fromSql = " from "+tablename+" "+maintableAlias ;
if(!"".equals(detailtable)){
fromSql+=" inner join "+detailtable+" "+detailtableAlias+" on t1.id="+detailtableAlias+"."+detailkeyfield+" ";
}
if(formmodeid.equals("")||formmodeid.equals("0")){//浏览框中没有设置模块
sqlwhere = " where 1=1 ";
}else{
sqlwhere = " where t1.formmodeid="+formmodeid+" ";
}
}
}else{
String rightsql = "";
if(formmodeid.equals("")||formmodeid.equals("0")){//浏览框中没有设置模块
String sqlStr1 = "select id,modename from modeinfo where formid="+formID+" order by id";
RecordSet rs1 = new RecordSet();
rs1.executeSql(sqlStr1);
while(rs1.next()){
String mid = rs1.getString("id");
ModeShareManager.setModeId(Util.getIntValue(mid,0));
for(int i=0;i<lsUser.size();i++){
User tempUser = lsUser.get(i);
String tempRightStr = ModeShareManager.getShareDetailTableByUser("formmode",tempUser);
if(rightsql.isEmpty()){
rightsql += tempRightStr;
}else {
rightsql += " union all "+ tempRightStr;
}
}
}
if(!rightsql.isEmpty()){
rightsql = " (SELECT sourceid,MAX(sharelevel) AS sharelevel from ( "+rightsql+" ) temptable group by temptable.sourceid) ";
}
}else{
ModeShareManager.setModeId(Util.getIntValue(formmodeid,0));
for(int i=0;i<lsUser.size();i++){
User tempUser = (User)lsUser.get(i);
String tempRightStr = ModeShareManager.getShareDetailTableByUser("formmode",tempUser);
if(rightsql.isEmpty()){
rightsql += tempRightStr;
}else {
rightsql += " union all "+ tempRightStr;
}
}
if(!rightsql.isEmpty()){
rightsql = " (SELECT sourceid,MAX(sharelevel) AS sharelevel from ( "+rightsql+" ) temptable group by temptable.sourceid) ";
}
}
if(titleviewtype.equals("1")){//标题是明细表中的字段
fromSql = " from "+detailtable+" "+detailtableAlias;
if(!"".equals(detailtable)){
fromSql+=" inner join "+tablename+" "+maintableAlias+" on t1.id="+detailtableAlias+"."+detailkeyfield+" ";
}
}else{
fromSql = " from "+tablename+" t1 ";
if(!"".equals(detailtable)){
fromSql+=" inner join "+detailtable+" "+detailtableAlias+" on t1.id="+detailtableAlias+"."+detailkeyfield+" ";
}
}
fromSql += ","+rightsql+" t2 " ;
if(sqlwhere.equals("")){
sqlwhere = " where t1.id = t2.sourceid";
}else{
sqlwhere += " and t1.id = t2.sourceid";
}
}
if(!"".equals(sqlwhereparam)){
//sqlwhereparam=URLDecoder.decode(sqlwhereparam);
sqlwhere+=" and "+sqlwhereparam.trim();
}
sqlwhere_con=sqlwhere_con.trim();
if(!"".equals(sqlwhere_con)){
if(sqlwhere_con.toLowerCase().trim().startsWith("and ")){
sqlwhere+=" "+sqlwhere_con;
}else{
sqlwhere+=" and "+sqlwhere_con;
}
}
String sqlCondition = "";
if(istree.equals("1")){
String conditionStr = "select datacondition from mode_customtreedetail where mainid="+treeid;
rs.executeSql(conditionStr);
if(rs.next()){
sqlCondition = rs.getString("datacondition");
if(!StringHelper.isEmpty(sqlCondition)){
CustomTreeData customTreeData = new CustomTreeData();
sqlCondition = customTreeData.replaceParam(sqlCondition);
}
}
}else{
if(searchconditiontype.equals("2")){ //java file
if(!javafilename.equals("")){
Map<String, String> sourceCodePackageNameMap = CommonConstant.SOURCECODE_PACKAGENAME_MAP;
String sourceCodePackageName = sourceCodePackageNameMap.get("3");
String classFullName = sourceCodePackageName + "." + javafilename;
Map<String, Object> param = new HashMap<String, Object>();
param.put("user", user);
Object result = CustomJavaCodeRun.run(classFullName, param);
sqlCondition = Util.null2String(result);
}
}else{
sqlCondition = defaultsql;
}
}
if(!sqlCondition.equals("")){
sqlCondition = "(" + sqlCondition + ")";
sqlwhere = sqlwhere + " and "+sqlCondition;
}
String sqlprimarykey = "t1.id";
String pkfieldname = "id";
if(isVirtualForm){ //虚拟表单
sqlprimarykey = "t1." + vprimarykey;
pkfieldname = vprimarykey;
pkfield = vprimarykey;
BrowserInfoService browserInfoService=new BrowserInfoService();
orderby = browserInfoService.getOrderSQL(customid);
if(StringHelper.isEmpty(orderby)){
orderby = "t1." + vprimarykey;
}
} else { //实际表单
BrowserInfoService browserInfoService=new BrowserInfoService();
orderby = browserInfoService.getOrderSQL(customid);
if(titleviewtype.equals("1")){
pkfieldname=detailfieldAlias+"id";
}
if("".equals(pkfield)){
if(titleviewtype.equals("1")){
sqlprimarykey = detailtableAlias+".id";
}else{
sqlprimarykey = "t1.id";
}
}else{
if(titleviewtype.equals("1")){
sqlprimarykey = detailtableAlias+"."+pkfield;
pkfieldname = detailfieldAlias+pkfield;
vprimarykey = pkfieldname;
}else{
sqlprimarykey = "t1."+pkfield;
pkfieldname = pkfield;
vprimarykey = pkfieldname;
}
}
}
backfields+=","+sqlprimarykey+" as hiddenfield ";
String tableAlias=maintableAlias;
if(titleviewtype.equals("1")){
tableAlias=detailtableAlias;
}
if(src.equalsIgnoreCase("dest")){//右侧已选择列表的sql条件
if("".equals(check_per)){
check_per="0";
}
String dbtypeStr = rs.getDBType();
if(isVirtualForm){
dbtypeStr = rs.getDBType(vdatasource);
check_per = check_per.replaceAll(",", "','");
}
if(dbtypeStr.equals("oracle")){//Oracle这里改变in的写法,否则Oracle 10g 版本的数据库会有bug
if(isVirtualForm){
sqlwhere += " and exists (select 1 from "+tablename+" where t1."+vprimarykey+" in ('"+check_per+"')) ";
}else{
if(!"".equals(pkfield)){
check_per = check_per.replaceAll(",", "','");
sqlwhere += " and exists (select 1 from "+tablename+" where "+tableAlias+"."+pkfield+" in ('"+check_per+"')) ";
}else{
sqlwhere += " and exists (select 1 from "+tablename+" where "+tableAlias+".id in ("+check_per+")) ";
}
}
}else{
if(isVirtualForm){
sqlwhere += " and t1."+vprimarykey+" in ('"+check_per+"')";
}else{
if(!"".equals(pkfield)){
check_per = check_per.replaceAll(",", "','");
sqlwhere += " and "+tableAlias+"."+pkfield+" in ('"+check_per+"')";
}else{
sqlwhere += " and "+tableAlias+".id in ("+check_per+")";
}
}
}
}else if(src.equalsIgnoreCase("src")){
//屏蔽已选数据
String excludeId=Util.null2String(request.getParameter("excludeId"));
if(excludeId.length()==0)excludeId=check_per;
if(excludeId.length()>0){
if(isVirtualForm){
sqlwhere += " and t1."+vprimarykey+" not in ("+excludeId+")";
}else{
if(!"".equals(pkfield)){
check_per = check_per.replaceAll(",", "','");
sqlwhere += " and "+tableAlias+"."+pkfield+" not in ('"+excludeId+"')";
}else{
sqlwhere += " and "+tableAlias+".id not in ("+excludeId+")";
}
}
}
}
SplitPageParaBean spp = new SplitPageParaBean();
spp.setBackFields(backfields);
spp.setSqlFrom(fromSql);
spp.setSqlWhere(sqlwhere);
spp.setSqlOrderBy(orderby);
spp.setPrimaryKey(sqlprimarykey);
spp.setPoolname(vdatasource);
spp.setDistinct(false);
spp.setSortWay(spp.DESC);
SplitPageUtil spu = new SplitPageUtil();
spu.setSpp(spp);
int totalPage=0;
if("dest".equalsIgnoreCase(src)){
pagenum=1;
totalPage=1;
rs=spu.getAllRs();
}else if("src".equalsIgnoreCase(src)){
int RecordSetCounts=0;
RecordSetCounts = spu.getRecordCount();
totalPage = RecordSetCounts/perpage;
if(totalPage%perpage>0||totalPage==0){
totalPage++;
}
rs = spu.getCurrentPageRs(pagenum, perpage);
}
JSONArray jsonArr = new JSONArray();
while(rs.next()) {
JSONObject tmp = new JSONObject();
String id = "";
if(!isVirtualForm){
if(!"".equals(pkfield)){
id=rs.getString(vprimarykey);
id = Util.toHtmlForSplitPage(id);
}else{
id=rs.getString("id");
}
}else{
id=rs.getString(vprimarykey);
}
Iterator<Map.Entry<String,Object>> it=showfieldMap.entrySet().iterator();
while(it.hasNext()){
Map.Entry<String,Object> entity=it.next();
String fieldName=entity.getKey();
String paraTwo=Util.null2String(entity.getValue());
String fieldValue=Util.null2String(rs.getString(fieldName));
if(paraTwo.length()>0&&!"".equals(pkfield)){
paraTwo+="+"+pkfield;
if(titleviewtype.equals("1")){
paraTwo+="+"+detailtable;
}
}
if("modedatacreatedate".equals(fieldName)){
fieldValue=FormModeTransMethod.getSearchResultCreateTime(fieldValue,rs.getString(paraTwo));
}else if("modedatacreater".equals(fieldName)){
fieldValue=FormModeTransMethod.getSearchResultName(fieldValue, rs.getString(paraTwo));
}else{
fieldValue = Util.formatMultiLang(fieldValue, user.getLanguage()+"");
if(id.contains("+")){
id = id.replace("+", "{weaver}");
}
fieldValue=FormModeTransMethod.getBrowserOthers(fieldValue, paraTwo.replaceFirst("column:id", id));
}
if(fieldName.equalsIgnoreCase("hiddenfield")){
fieldValue= fieldValue.replace("+", "weaver2017");
}
tmp.put(fieldName,fieldValue);
}
tmp.put("id",id);
jsonArr.add(tmp);
}
if("dest".equalsIgnoreCase(src)&&!check_per.contains("+")){
ComparatorUtil.sortJSONArrayByKeyss(jsonArr,"id",check_per);
}
JSONObject json = new JSONObject();
json.put("currentPage", pagenum);
json.put("totalPage", totalPage);
json.put("mapList",jsonArr.toString());
if(isVirtualForm){
json.put("showfieldname",showfieldname);
json.put("pkfieldname",pkfieldname);
}
out.println(json.toString());
%>