getCustomPageData.jsp
28.9 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
<%@page import="com.api.cube.util.CubeCipherUitl"%>
<%@ page language="java" contentType="text/html; charset=UTF-8" %>
<%@ page import="weaver.general.Util" %>
<%@ page import="net.sf.json.JSONArray" %>
<%@ page import="net.sf.json.JSONObject" %>
<%@ page import="weaver.servicefiles.DataSourceXML" %>
<%@ page import="weaver.formmode.virtualform.VirtualFormHandler" %>
<%@ page import="weaver.systeminfo.SystemEnv" %>
<%@ page import="com.api.formmode.cache.CustomSearchComInfo" %>
<%@ page import="com.api.formmode.cache.ModeFormComInfo" %>
<%@ page import="weaver.hrm.HrmUserVarify" %>
<%@ page import="weaver.hrm.User" %>
<%@ page import="weaver.conn.RecordSet" %>
<%@ page import="com.weaver.formmodel.util.StringHelper" %>
<%@ page import="com.api.cube.constant.SearchConstant" %>
<%@ page import="static com.api.cube.constant.SearchConstant.MAIN_TABLE_ALIAS" %>
<%@ page import="static com.api.cube.constant.SearchConstant.DETAIL_TABLE_ALIAS" %>
<%@ page import="static com.api.cube.constant.SearchConstant.DETAIL_TABLE_ALIAS" %>
<%@ page import="static com.api.cube.constant.SearchConstant.*" %>
<%@ page import="static com.api.cube.constant.SearchConstant.RIGHT_TABLE_ALIAS" %>
<%@ page import="weaver.formmode.setup.ModeRightInfo" %>
<%@ page import="weaver.formmode.view.ModeShareManager" %>
<%@ page import="java.util.*" %>
<%@ page import="com.api.cube.util.CubeSearchTransMethod" %>
<%@ page import="com.engine.cube.biz.CustomPageHelper" %>
<%@ page import="weaver.general.SplitPageParaBean" %>
<%@ page import="weaver.formmode.customjavacode.CustomJavaCodeRun" %>
<%@ page import="weaver.formmode.service.CommonConstant" %>
<%@ page import="com.engine.common.util.ParamUtil" %>
<%@ page import="java.text.SimpleDateFormat" %>
<%@ page import="java.text.ParseException" %>
<jsp:useBean id="rs" class="weaver.conn.RecordSet" scope="page" />
<jsp:useBean id="rs_item" class="weaver.conn.RecordSet" scope="page" />
<jsp:useBean id="rs_titleKey" class="weaver.conn.RecordSet" scope="page" />
<jsp:useBean id="RecordSet" class="weaver.conn.RecordSet" scope="page" />
<%
User user = HrmUserVarify.getUser(request,response);
int customid = Util.getIntValue(request.getParameter("customid"), 0);
String pageno = request.getParameter("pageno");
int viewtype = 0;
String customId = customid+"";
String dataSource ="";
String dataSourceDBType="";
String primaryKey="";
String isbill="1";
int opentype = 0;
String enabled = "0";
JSONArray Optionlist = new JSONArray();
ModeFormComInfo modeFormComInfo = new ModeFormComInfo();
CustomSearchComInfo customSearchComInfo=new CustomSearchComInfo();
int formId = Util.getIntValue(customSearchComInfo.getFormId(customId),0);
int modeId = Util.getIntValue(customSearchComInfo.getModeId(customId),0);
String modeId_ = Util.null2String(customSearchComInfo.getModeId(customId));
boolean noRightList = "1".equals(customSearchComInfo.getNoRightList(customId));
boolean isVirtualForm = "1".equals(modeFormComInfo.getIsVirtualForm(formId+""));
String tableName = modeFormComInfo.getTableName(formId);
String detailTable = getRealDetailTable(customSearchComInfo.getDetailTable(customId),customid);
// int pageNum = Util.getIntValue(customSearchComInfo.getPageNumber(customId));
int pageNum = 20;
String defaulSql = Util.toScreenToEdit(customSearchComInfo.getDefaultSql(customId), user.getLanguage()) ;
String searchconditiontype = customSearchComInfo.getSearchConditionType(customId);
String javafilename = customSearchComInfo.getJavaFileName(customId);
String javafileaddress=customSearchComInfo.getJavaFileAddress(customId);
// 解析链接中 日期排序字段datefield 以及排序方式字段 datefieldorder asc/desc 明细表 datefield 需要拼接 d1.字段名称
String datefield = Util.null2String(request.getParameter("datefield"));
String datefieldorder = "".equals(Util.null2String(request.getParameter("datefieldorder")))?"desc":Util.null2String(request.getParameter("datefieldorder"));
if(isVirtualForm) {
dataSource = modeFormComInfo.getVDataSource(formId+"");
String confirmSql="select id from datasourcesetting where pointid=\'"+dataSource+"\'";
rs.execute(confirmSql);
if(rs.getCounts()>0 ||"$ECOLOGY_SYS_LOCAL_POOLNAME".equals(dataSource)){
DataSourceXML dataSourceXML = new DataSourceXML();
dataSourceDBType = dataSourceXML.getDataSourceDBType(dataSource);
primaryKey = modeFormComInfo.getVPrimaryKey(formId+"");
Map<String, Object> vFormInfo = VirtualFormHandler.getVFormInfo(formId);
String vformtype = Util.null2String(vFormInfo.get("vformtype"));
String vsql = Util.null2String(vFormInfo.get("vsql"));
if("2".equals(vformtype)){
tableName="("+vsql+") ";
}else{
tableName= VirtualFormHandler.getRealFromName(tableName);
}
}else{
JSONObject option=new JSONObject();
option.put("error", SystemEnv.getHtmlLabelName(389199,user.getLanguage()));//数据源不存在
Optionlist.add(option);
out.println(Optionlist.toString());
return;
}
} else {
dataSource = null;
dataSourceDBType = rs.getDBType();
primaryKey = "id";
}
//----------获取查询勾选显示字段Start
String backfields = "";
String sqlPrimaryKey="";
StringBuffer showfield = new StringBuffer();
//判断表单中是否有创建人、创建日期字段。(流程表)
if(isVirtualForm){
rs.executeSql("select * from "+ tableName +" t1 where 1=2",dataSource);
} else{
rs.executeSql("select * from "+tableName+" where 1=2");
}
String colfieldname[] =rs.getColumnName();
String sql = "select b.isorder,b.ColWidth,a.id as id,a.fieldname as name,a.fieldlabel as label"+
",a.fielddbtype as dbtype ,a.fieldhtmltype as httype, a.type as type"+
",b.showorder,b.istitle,b.isstat,b.showmethod, b.isgroup"+
",a.viewtype,a.detailtable,b.ismaplocation,b.shownamelabel,b.editable,b.ALIGNMENT,a.qfws" +
" from workflow_billfield a ,Mode_CustomDspField b"+
" where a.id=b.fieldid and b.customid= ? and b.isshow='1' and a.billid= ? " +
" union all select a.isorder,a.ColWidth,a.fieldid as id,'1' as name,0 as label,'3' as dbtype, '4' as httype,5 as type "+
",a.showorder,a.istitle,a.isstat,a.showmethod, a.isgroup" +
",0 as viewtype,'' as detailtable,a.ismaplocation,a.shownamelabel,a.editable,a.ALIGNMENT,'2' qfws "+
" from Mode_CustomDspField a "+
" where a.customid=? and a.isshow='1' and a.fieldid<0" +
" order by showorder,id asc";
rs.executeQuery(sql, customId, formId, customId);
rs_titleKey.executeQuery(sql, customId, formId, customId);
Set<String> showFieldSet = new HashSet<String>();
List<String>showFieldList = new ArrayList<String>();
List<String>labelName = new ArrayList<String>();
Map<String, Object> labelNameMap = new LinkedHashMap<String, Object>();
String titleKey="";
String titleValue="";
if(rs_titleKey.next()){
titleKey= Util.null2String(rs_titleKey.getString("name"));//取第一个作为标题。
int field_viewtype=rs_titleKey.getInt("viewtype");
if(field_viewtype==1){
titleKey=SearchConstant.DETAIL_FIELD_ALIAS+titleKey;
}
}
rs.writeLog("titleKey:"+titleKey);
while (rs.next()){
if (rs.getInt("id")>0){
String tempname= Util.null2String(rs.getString("name"));
// labelNameMap.put(fieldAlias,label);
String label = Util.null2String(rs.getString("label"));
labelName.add(label);
String dbtype= Util.null2String(rs.getString("dbtype"));
String isgroup = Util.null2String(rs.getString("isgourp"));
String fieldAlias=tempname;
String tableAlias= SearchConstant.MAIN_TABLE_ALIAS;
int field_viewtype=rs.getInt("viewtype");
if(field_viewtype==1){
tableAlias=SearchConstant.DETAIL_TABLE_ALIAS;
fieldAlias=SearchConstant.DETAIL_FIELD_ALIAS+tempname;
}
labelNameMap.put(fieldAlias.toLowerCase(),label);
if(tempname.equalsIgnoreCase(primaryKey)) {
continue;
}
if(dbtype != null && "text".equalsIgnoreCase(dbtype)){
if( "oracle".equals(dataSourceDBType)){
showFieldSet.add(","+"to_char("+tableAlias+"."+tempname+") as "+fieldAlias);
showFieldList.add(","+"to_char("+tableAlias+"."+tempname+") as "+fieldAlias);
}else if("mysql".equals(dataSourceDBType)){
showFieldSet.add(","+"convert("+tableAlias+"."+tempname+",char) as "+fieldAlias);
showFieldList.add(","+"convert("+tableAlias+"."+tempname+",char) as "+fieldAlias);
}else{
showFieldSet.add(","+"convert(varchar(max),"+tableAlias+"."+tempname+") as "+fieldAlias);
showFieldList.add(","+"convert(varchar(max),"+tableAlias+"."+tempname+") as "+fieldAlias);
}
}else{
if(field_viewtype==1){
showFieldSet.add(","+tableAlias+"."+tempname+" as "+fieldAlias);
showFieldList.add(","+tableAlias+"."+tempname+" as "+fieldAlias);
}else{
showFieldSet.add(","+tableAlias+"."+tempname);
showFieldList.add(","+tableAlias+"."+tempname);
}
}
}
}
// for(String field : showFieldSet) {
// showfield.append(field);
// }
for (int i = 0; i <showFieldList.size() ; i++) {
showfield.append(showFieldList.get(i));
}
if(!StringHelper.containsIgnoreCase(colfieldname, "modedatacreater")&&!StringHelper.containsIgnoreCase(colfieldname, "modedatacreatedate")){
showfield.append(",").append(SearchConstant.MAIN_TABLE_ALIAS).append(".").append(primaryKey);
} else {
if(isVirtualForm){
showfield
.append(",")
.append(SearchConstant.MAIN_TABLE_ALIAS).append(".").append(primaryKey);
labelName.add("xn_id");//虚拟表单主键
labelNameMap.put(primaryKey,"虚拟表单主键");
}else{
showfield
.append(",")
.append(SearchConstant.MAIN_TABLE_ALIAS).append(".").append(primaryKey).append(",")
.append(SearchConstant.MAIN_TABLE_ALIAS).append(".").append("formmodeid");
labelName.add("32011");//id
labelName.add("81301");//模块id
labelNameMap.put("id","32011");
labelNameMap.put("formmodeid","81301");
}
}
sqlPrimaryKey = MAIN_TABLE_ALIAS+"."+primaryKey;
if(!StringHelper.isEmpty(detailTable)) {
sqlPrimaryKey+=",d_id";
showfield.append(",").append(SearchConstant.DETAIL_TABLE_ALIAS).append(".id").append(" d_id ");
// labelName.add("d_id");//子表id
// labelNameMap.put("d_id","d_id");
}
labelNameMap.put("modedatacreatedate","722");
backfields = showfield.toString();
backfields = backfields.substring(1,backfields.length());
//----------获取查询勾选显示字段end
StringBuffer sqlFrom = new StringBuffer();
sqlFrom.append(" from ").append(tableName).append(" ").append(MAIN_TABLE_ALIAS);
if(detailTable != null && !"".equals(detailTable)){
sqlFrom.append(" left join ").append(detailTable).append(" ").append(DETAIL_TABLE_ALIAS)
.append(" on ").append(DETAIL_TABLE_ALIAS).append(".").append(DETAIL_MAINID).append(" = ")
.append(MAIN_TABLE_ALIAS).append(".").append(primaryKey);
}
if(!noRightList&&!isVirtualForm){//不是监控、无权限列表、不是虚拟表单
sqlFrom.append(" , ").append(this.getRightSql(user,modeId,formId)).append(" ").append(RIGHT_TABLE_ALIAS);
}
StringBuffer sqlWhere = new StringBuffer();
sqlWhere.append(" where 1=1 ");
if(! isVirtualForm) {
if(modeId > 0) {
sqlWhere.append(" and ").append(MAIN_TABLE_ALIAS).append(".formmodeid = ").append(modeId);
}
if(!noRightList&&!isVirtualForm) {//不是监控、无权限列表、不是虚拟表单
sqlWhere.append(" and ").append(MAIN_TABLE_ALIAS).append(".").append(primaryKey).append(" = ")
.append(RIGHT_TABLE_ALIAS).append(".sourceid");
}
}
defaulSql = CubeSearchTransMethod.INSTANCE.getDefaultSql(user, defaulSql);
//固定查询条件
//替换查询url,request传参字段
if(defaulSql.indexOf("PARM(")>-1){
int beginIndex = defaulSql.indexOf("PARM(");
while(beginIndex>-1){
int endIndex = defaulSql.indexOf(")",beginIndex+5);
int nextIndex = 0;
if(endIndex>-1){
String substring = defaulSql.substring(beginIndex+5, endIndex);
if(request.getParameter(substring)==null){
beginIndex = defaulSql.indexOf("PARM(",endIndex-nextIndex+1);
}else{
String paramvalue = Util.null2String(request.getParameter(substring));
defaulSql = defaulSql.replace("PARM("+substring+")", paramvalue);
if(paramvalue.length()<substring.length()){
nextIndex = substring.length()-paramvalue.length();
}
beginIndex = defaulSql.indexOf("PARM(",endIndex-nextIndex+1);
}
}else{
break;
}
}
}
rs.writeLog("defaulSql="+defaulSql);
if(!StringHelper.isEmpty(defaulSql)) {
sqlWhere.append(" and ").append("("+defaulSql+")").append(" ");
}
if("2".equals(searchconditiontype)) {
if(!javafileaddress.equals("")){
String classFullName =javafileaddress;
Map<String, Object> param = new HashMap<String, Object>();
param.put("user", user);
String javacondition = Util.null2String(CustomJavaCodeRun.run(classFullName, param)).trim();
if(!StringHelper.isEmpty(javacondition)) {
sqlWhere.append(" and ").append(javacondition).append(" ");
}
}else if(!javafilename.equals("")){
Map<String, String> sourceCodePackageNameMap = CommonConstant.SOURCECODE_PACKAGENAME_MAP;
String sourceCodePackageName = sourceCodePackageNameMap.get("2");
String classFullName = sourceCodePackageName + "." + javafilename;
Map<String, Object> param = ParamUtil.request2Map(request);
param.put("user", user);
String javacondition = Util.null2String(CustomJavaCodeRun.run(classFullName, param)).trim();
if(!StringHelper.isEmpty(javacondition)) {
sqlWhere.append(" and ").append(javacondition).append(" ");
}
}
}
rs.writeLog("sqlWhere="+sqlWhere);
//----------获取查询排序字段start
StringBuffer orderby = new StringBuffer();
RecordSet rs_orderby = new RecordSet();
String sql_orderby = " select b.fieldid, a.fieldname, a.viewtype, b.ordertype,a.fielddbtype" +
" from mode_customdspfield b left join workflow_billfield a on a.id = b.fieldid " +
" where b.customid = ? and b.isorder = 1 order by b.ordernum asc ";
rs_orderby.executeQuery(sql_orderby, customId);
while(rs_orderby.next()) {
String fieldid = rs_orderby.getString("fieldid");
String ordertype = rs_orderby.getString("ordertype");
String fieldname = Util.null2String(rs_orderby.getString("fieldname"));
String fielddbtype = Util.null2String(rs_orderby.getString("fielddbtype"));
int viewtype1=rs_orderby.getInt("viewtype");
if("".equals(fieldname)&&!"-1".equals(fieldid)&&!"-2".equals(fieldid))continue;
if("a".equalsIgnoreCase(ordertype)){ //默认升序
ordertype="asc";
}else if ("d".equalsIgnoreCase(ordertype)){ //默认降序
ordertype="desc";
} else {
continue;
}
fieldname = (viewtype1 == 1 ? DETAIL_TABLE_ALIAS:MAIN_TABLE_ALIAS)+"."+fieldname;
if(!"".equals(datefield)&&fieldname.contains(datefield)){//查询勾选了排序字段,且连接拼接了此字段排序,这里剔除,以连接上该字段排序为准
continue;
}
if("sqlserver".equalsIgnoreCase(dataSourceDBType) && "text".equalsIgnoreCase(fielddbtype)) {
fieldname = "convert(varchar, "+fieldname+")";
}
if(fieldid.equals("-1")){
orderby.append(MAIN_TABLE_ALIAS).append(".modedatacreatedate ").append(ordertype).append(",")
.append(MAIN_TABLE_ALIAS).append(".modedatacreatetime ").append(ordertype).append(",");
}else if(fieldid.equals("-2")){
orderby.append(MAIN_TABLE_ALIAS).append(".modedatacreater ").append(ordertype).append(",");
}else{
orderby.append(fieldname).append(" ").append(ordertype).append(",");
}
}
// if(orderby.length()>0) {
// orderby.append(",");
// }
orderby.append(MAIN_TABLE_ALIAS).append(".").append(primaryKey).append(" desc ");
if(!StringHelper.isEmpty(detailTable)) {
orderby.append(",").append(DETAIL_TABLE_ALIAS).append(".id desc ");
}
//--- 解析链接中 日期排序字段datefield 以及排序方式字段 datefieldorder asc/desc
String datefieldStr = "";
String dateStr = "";
//判断是否包含该字段
boolean isContain =false;
if(datefield.contains("d1.")){//明细字段需要在datefield 字段中拼接 d1.字段名称
RecordSet rs1 = new RecordSet();
if(!isVirtualForm){
rs1.executeSql("select * from "+detailTable+" where 1=2");
isContain = StringHelper.containsIgnoreCase(rs1.getColumnName(), datefield.substring(3,datefield.length()));
}
}else{
isContain = StringHelper.containsIgnoreCase(colfieldname, datefield);
}
if(isContain){//包含该排序字段
rs.writeLog("排序字段:"+datefield+" "+datefieldorder);
if(!datefield.contains("d1.")){
datefield = "t1."+datefield;
datefieldStr = datefield.substring(3,datefield.length());//日期字段
if(!backfields.contains(datefield.replace("t1.","").toLowerCase())&&!backfields.contains(datefield.replace("t1.","").toUpperCase())){
backfields=backfields+","+datefield;
}
}else{//明细字段需要在datefield 字段中拼接 d1.字段名称
datefieldStr = datefield.replace("d1.","d_");
if(!backfields.contains(datefield.replace("d1.","").toLowerCase())&&!backfields.contains(datefield.replace("d1.","").toUpperCase())){
backfields=backfields+","+datefield +" as d_"+datefield.replace("d1.","");
}
}
dateStr = datefield+" "+datefieldorder+",";
}
//----------获取查询排序字段end
//------拼接para
Map<String, Object> paraMap = new LinkedHashMap<String, Object>();
RecordSet.executeQuery(sql, customId, formId, customId);
while (RecordSet.next()) {
String fieldid = Util.null2String(RecordSet.getString("id"));
int shownamelabel = Util.getIntValue(RecordSet.getString("shownamelabel"),0);
String hideAttribute = "";
if(RecordSet.getString("id").equals("-1")){
String showmethod = Util.null2o(RecordSet.getString("showmethod"));
String para3="column:modedatacreatetime+"+customid+"+"+showmethod+"+column:"+(isVirtualForm?primaryKey:"id")+"+"+formId;
paraMap.put("modedatacreatetime",para3);
}else if(RecordSet.getString("id").equals("-2")){
// tableString+=" <col width=\""+temocolwidth+"%\" "+hideAttribute+" text=\""+Util.toHtmlForSplitPage(SystemEnv.getHtmlLabelName(shownamelabel,user.getLanguage()))+"\" column=\"modedatacreater\" "+orderkey+" otherpara=\"column:modedatacreatertype\" transmethod=\"weaver.formmode.search.FormModeTransMethod.getSearchResultName\" />";
String para3="column:modedatacreater";
paraMap.put("modedatacreater",para3);
}else if(RecordSet.getString("id").equals("-3")){
// tableString+=" <col width=\""+temocolwidth+"%\" "+hideAttribute+" text=\""+Util.toHtmlForSplitPage(SystemEnv.getHtmlLabelName(shownamelabel,user.getLanguage()))+"\" column=\"id\" "+orderkey+" otherpara=\"column:dataid\" transmethod=\"weaver.formmode.search.FormModeTransMethod.getDataId\" />";
String para3="column:id";
paraMap.put("id",para3);
}else{
String name = RecordSet.getString("name");
String label = RecordSet.getString("label");
if(shownamelabel!=0){
label = shownamelabel+"";
}
String htmltype = RecordSet.getString("httype");
String type = RecordSet.getString("type");
String id = RecordSet.getString("id");
String dbtype=RecordSet.getString("dbtype");
String istitle = RecordSet.getString("istitle");
String showmethod = Util.null2o(RecordSet.getString("showmethod"));
String ismaplocation = Util.getIntValue(RecordSet.getString("ismaplocation"),0)+"";
if(isVirtualForm){
if(modeId_.equals("0")){
modeId_ = "virtual";
}
}
String para3="";
if(viewtype==3){//监控
para3="column:"+(isVirtualForm?primaryKey:"id")+"+"+id+"+"+htmltype+"+"+type+"+"+user.getLanguage()+"+"+isbill+"+"+dbtype+"+"+istitle+"+"+modeId_+"+"+formId+"+"+viewtype+"+"+ismaplocation+"+"+opentype+"+"+customid+"+fromsearchlist"+"+"+showmethod+(detailTable.equals("")?"":("'+column:d_id+"+detailTable+"'"));
}else{
para3="column:"+(isVirtualForm?primaryKey:"id")+"+"+id+"+"+htmltype+"+"+type+"+"+user.getLanguage()+"+"+isbill+"+"+dbtype+"+"+istitle+"+"+modeId_+"+"+formId+"+"+viewtype+"+"+ismaplocation+"+"+opentype+"+"+customid+"+fromsearchlist"+"+"+showmethod+"+"+user.getUID()+"+"+enabled+(detailTable.equals("")?"":("'+column:d_id+"+detailTable+"'"));
}
// label = SystemEnv.getHtmlLabelName(Util.getIntValue(label),user.getLanguage());
// String transmethod = "transmethod=\"weaver.formmode.search.FormModeTransMethod.getOthers\"";
paraMap.put(name,para3);
}
}
rs.writeLog("paraMap:",paraMap);
String fieldname = "";
//String trueSql = "";
//trueSql = "select "+backfields+sqlFrom+sqlWhere+" order by "+orderby;
String orderbyStr = "";
if(!"".equals(dateStr)){
orderbyStr= dateStr+orderby;
}
SplitPageParaBean spp = new SplitPageParaBean();
CustomPageHelper cp = new CustomPageHelper();
String sqlhint = "";
String outfields = "";
String outsqlform = "";
String outsqlwhere= "";
String sqlgroupby= "";
int otype =1;//desc
boolean sqlisdistinct = false;
boolean sqlisprintsql = false;
String params = "";
String pageBySelf = "";
String countColumns = "";
Map<String, Integer> countColumnsDbType = new HashMap<String, Integer>();
String poolname = dataSource;
spp.setSqlhint(sqlhint);
spp.setOutfields(outfields);
spp.setBackFields(backfields);
spp.setSqlFrom(sqlFrom.toString());
spp.setOutsqlform(outsqlform);
spp.setSqlWhere(sqlWhere.toString());
spp.setOutsqlwhere(outsqlwhere);
spp.setSqlGroupBy(sqlgroupby);
spp.setPrimaryKey(MAIN_TABLE_ALIAS+"."+primaryKey);
spp.setSqlOrderBy(orderbyStr);
spp.setSortWay(otype);
spp.setDistinct(sqlisdistinct);
spp.setIsPrintExecuteSql(sqlisprintsql);
spp.setPoolname(poolname);
spp.setCountColumns(countColumns);
spp.setCountColumnsDbType(countColumnsDbType);
spp.setDataSource(dataSource);
spp.setParams(params);
spp.setPageBySelf(pageBySelf);
cp.setSpp(spp);
int pageSize = pageNum; //默认以查询为主
int pageIndex =Util.getIntValue(pageno,0);
List list = new ArrayList();
String dbtype = rs.getDBTypeByPoolName(poolname);
String countSql = cp.getCountSql();
rs.writeLog("countSql="+countSql);
rs.executeSql(countSql,poolname);
int count = 0;
if(rs.next()){
count = rs.getInt(1);
}
if(count>0){
String dbtypeStr = "";
if(dbtype.toLowerCase().indexOf("sqlserver")!=-1){
dbtypeStr = "sqlserver";
}else if(dbtype.toLowerCase().indexOf("db2")!=-1){
dbtypeStr = "db2";
}else if(dbtype.toLowerCase().indexOf("mysql")!=-1){
dbtypeStr = "mysql";
}else{
dbtypeStr = "oracle";
}
cp.setRecordCount(count);
String sql_ = cp.getPageSqlByDBType(pageSize, pageIndex, dbtypeStr);
rs.writeLog("sql_="+sql_);
boolean status=false;
if(dataSource==null){
status=rs.executeSql(sql_);
}else {
status=rs.executeSql(sql_,dataSource);
}
if (!status) {
rs.writeLog("分页部分执行如下SQL语句: \n" + sql + " \n失败,请检查上面的SQL语句.");
}
String vitSql = "select modeid from mode_customsearch where id = ?";
rs_orderby.executeQuery(vitSql,customId);
String virtual_modeid="";
if(rs_orderby.next()){
virtual_modeid = rs_orderby.getString("modeid");
}
String [] cols = rs.getColumnName();
while(rs.next()){
Map<String, Object> Map = new LinkedHashMap<String, Object>();
Map<String, Object> map = new LinkedHashMap<String, Object>();
for(String str :cols) {
str = str.toLowerCase();
if(str.contains("temprownumber")||str.contains("tempcolumn")||str.contains("my_rownum")||str.contains("oracle_rownum")){
continue;
}
int d_id = Util.getIntValue(rs.getString("d_id"),0);
if(d_id==0){
d_id = Util.getIntValue(rs.getString("D_ID"),0);
}
//||sqlPrimaryKey.contains(str)
if(str.equals("id")||str.equals("formmodeid")||str.equals(primaryKey)){
String value=Util.null2String(rs.getString(str));
if(str.equals(primaryKey)&&!str.equals("id")){
String para = Util.null2String(paraMap.get(str)).replace("column:"+primaryKey,rs.getString(primaryKey)).replace("column:d_id",d_id+"");
value=cp.getOthers(value, para);
// if(titleKey.equalsIgnoreCase(str)){
// titleValue = value;
// }
map.put(SystemEnv.getHtmlLabelName(Util.getIntValue(labelNameMap.get(str.toLowerCase()).toString(),0),7),Util.null2String(value));
}else{
map.put(str.toLowerCase(), Util.null2String(value));
}
}else if(str.toLowerCase().contains("d_")){
String value=Util.null2String(rs.getString(str));
if(str.equalsIgnoreCase("d_id")){
map.put(str.toLowerCase(), value);
}else{
String para = Util.null2String(paraMap.get(str.replace("d_",""))).replace("column:"+primaryKey,rs.getString(primaryKey)).replace("column:d_id",d_id+"");
if(!"".equals(para)){
value=cp.getOthers(value, para);
}
// if(titleKey.equalsIgnoreCase(str)){
// titleValue = value;
// }
map.put("("+SystemEnv.getHtmlLabelName(17463,7)+")"+SystemEnv.getHtmlLabelName(Util.getIntValue(labelNameMap.get(str.toLowerCase()).toString(),0),7), Util.null2String(value));
}
}else{
String value=Util.null2String(rs.getString(str));
if(str.equalsIgnoreCase("modedatacreatetime")){
}else if(str.equalsIgnoreCase("modedatacreater")){
}else{
String para = Util.null2String(paraMap.get(str)).replace("column:"+primaryKey,rs.getString(primaryKey)).replace("column:d_id",d_id+"");
if(!"".equals(para)){
value=cp.getOthers(value, para);
}
// if(titleKey.equalsIgnoreCase(str)){
// titleValue = value;
// }
}
map.put(SystemEnv.getHtmlLabelName(Util.getIntValue(labelNameMap.get(str.toLowerCase()).toString(),0),7),Util.null2String(value));
}
}
map.put("isVirtualForm",isVirtualForm);
map.put("formId",formId);
map.put("customid",customid);
String dateTitle = Util.null2String(rs.getString(datefieldStr));
String date = "";
String time ="";
Map<String, String> titleMap = new LinkedHashMap<String, String>();
if(!dateTitle.equals("")){
SimpleDateFormat sdf11 = new SimpleDateFormat("yyyy-MM-dd");
Date d1 = null;
String yy="";
String mmdd="";
try {
d1 = sdf11.parse(dateTitle);
SimpleDateFormat sdf0 = new SimpleDateFormat("yyyy");
SimpleDateFormat sdf1 = new SimpleDateFormat("MM-dd");
yy = sdf0.format(d1);
mmdd = sdf1.format(d1);
} catch (ParseException e) {
e.printStackTrace();
}
date =yy;
time =mmdd;
}
titleMap.put("titleKey",rs.getString(titleKey));
map.put("timeline_date",date);
map.put("timeline_time",time);
Map.put(rs.getString(titleKey),map);
if(isVirtualForm){
map.put("virtual_billid",rs.getString(primaryKey));
map.put("virtual_modeid",virtual_modeid);
}
Optionlist.add(Map);
}
}
//rs.writeLog("Optionlist="+Optionlist.toString());
out.println(CubeCipherUitl.decryptByRegEx(Optionlist.toString()));
%>
<%!
private String getRealDetailTable(String detailTable,int customId ){
RecordSet rs = new RecordSet();
rs.executeQuery("SELECT COUNT(1) cou FROM workflow_billdetailtable WHERE tablename=?",detailTable);
if(rs.next()&&rs.getInt("cou")>0) {
return detailTable ;
}else{
rs.executeUpdate("update mode_customSearch set detailtable='' where id=?",customId);
}
return "";
}
private String getRightSql(User user,int modeId,int formId) {
RecordSet rs = new RecordSet();
ModeRightInfo modeRightInfo = new ModeRightInfo();
ModeShareManager modeShareManager = new ModeShareManager();
List<User> lsUser = modeRightInfo.getAllUserCountList(user);
//未配置模块时重新解析权限
String rightsql = "";
if(modeId == 0){//查询中没有设置模块
String sqlStr1 = "select id,modename from modeinfo where formid=? order by id";
rs.executeQuery(sqlStr1, formId);
while(rs.next()){
String mid = rs.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 {
if (rs.getDBType().equals("mysql")) {//mysql两个大结果集直接union all会报错
rightsql += " union all SELECT sourceid,sharelevel from "+ tempRightStr+" as t"+i;
}else {
rightsql += " union all "+ tempRightStr;
}
}
}
}
}else{
modeShareManager.setModeId(modeId);
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) ";
}
return rightsql;
}
%>