MutiKLGBrowserAjax.jsp
5.87 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
<%@page import="bsh.StringUtil"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"%>
<%@ page import="java.util.*"%>
<%@ page import="weaver.hrm.*"%>
<%@ page import="weaver.general.*"%>
<%@ page import="net.sf.json.JSONArray"%>
<%@ page import="net.sf.json.JSONObject"%>
<jsp:useBean id="ResourceComInfo" class="weaver.hrm.resource.ResourceComInfo" scope="page"/>
<jsp:useBean id="CustomerInfoComInfo" class="weaver.crm.Maint.CustomerInfoComInfo" scope="page" />
<jsp:useBean id="rs" class="weaver.conn.RecordSet" scope="page" />
<%
User user = HrmUserVarify.getUser(request, response);
//处理类型
String src = Util.null2String(request.getParameter("src"));
//获取知识点id
String klgIds = Util.null2String(request
.getParameter("systemIds"));
if (klgIds.trim().startsWith(",")) {
klgIds = klgIds.substring(1);
}
//如果是展示数据
if (src.equalsIgnoreCase("dest")) {
JSONArray jsonArr = new JSONArray();
JSONArray jsonArr_tmp = new JSONArray();
JSONObject json = new JSONObject();
if (!klgIds.equals("")) {
String sql = "select * from KT_Knowledge where id in ("
+ klgIds + ")";
rs.executeSql(sql);
while (rs.next()) {
JSONObject tmp = new JSONObject();
String usertype = rs.getString("usertype");
tmp.put("id", rs.getString("id"));
tmp.put("name", rs.getString("name"));
//tmp.put("mainid",MainCategoryComInfo.getMainCategoryname(rs.getString("maincategory")));
String createrid = rs.getString("createrId");
tmp.put("createrid", (usertype.equals("1") ? Util.toScreen(
ResourceComInfo.getResourcename(createrid),
user.getLanguage()) : Util.toScreen(
CustomerInfoComInfo
.getCustomerInfoname(createrid), user
.getLanguage())));
tmp.put("updateDate", rs.getString("updateDate"));
jsonArr_tmp.add(tmp);
}
String[] documentidArr = Util.TokenizerString2(klgIds,
",");
for (int i = 0; i < documentidArr.length; i++) {
for (int j = 0; j < jsonArr_tmp.size(); j++) {
JSONObject tmp = (JSONObject) jsonArr_tmp.get(j);
if (tmp.get("id").equals(documentidArr[i])) {
jsonArr.add(tmp);
}
}
}
}
json.put("currentPage", 1);
json.put("totalPage", 1);
json.put("mapList", jsonArr.toString());
out.println(json.toString());
return;
}
/*************************-- 数据源查询 --*************************/
String para = Util.fromScreen3(request.getParameter("resourceids"), user.getLanguage());
String name = Util.null2String(request.getParameter("name"));
String createrId = Util.null2String(request.getParameter("createrId"));
String sqlWhere = " where deleted=0 ";
String orderby = " order by id asc";
if (!name.equals("")) {
sqlWhere += " and name like '%" + Util.fromScreen2(name, 7) + "%'";
}
if (!createrId.equals("")) {
sqlWhere += " and createrId in (" + Util.fromScreen2(createrId, 7) + ")";
}
if (!klgIds.equals("")) {
sqlWhere += " and id not in (" + klgIds + ")";
}
String check_per = Util.fromScreen3(request.getParameter("parm"), user.getLanguage());
String resourceids ="";
String resourcenames ="";
if (!check_per.equals("")) {
String strtmp = "select id,name from KT_Knowledge where id in ("+check_per+")";
rs.executeSql(strtmp);
Hashtable ht = new Hashtable();
while(rs.next()){
ht.put( Util.null2String(rs.getString("id")), Util.null2String(rs.getString("name")));
}
try{
StringTokenizer st = new StringTokenizer(check_per,",");
while(st.hasMoreTokens()){
String s = st.nextToken().trim();
if(ht.containsKey(s)){
resourceids +=","+s;
resourcenames += ","+ht.get(s).toString();
}
}
}catch(Exception e){
resourceids ="";
resourcenames ="";
}
}
//System.out.println("resourceids:"+resourceids);
int pagenum = Util.getIntValue(request.getParameter("pagenum"), 1);
int perpage = 50;
rs.executeSql("Select count(id) RecordSetCounts from KT_Knowledge " + sqlWhere);
boolean hasNextPage = false;
int RecordSetCounts = 0;
if (rs.next()) {
RecordSetCounts = rs.getInt(1);
}
if (RecordSetCounts > pagenum * perpage) {
hasNextPage = true;
}
String sqltemp="";
if(rs.getDBType().equals("oracle")){
sqltemp = "select id,name,createrId,updateDate from KT_Knowledge "
+ sqlWhere
+ " and rownum< "
+ (RecordSetCounts - (pagenum - 1) * perpage + 1)
+ orderby;
} else if (rs.getDBType().equals("db2")) {
sqltemp = "select id,name,createrId,updateDate from KT_Knowledge "
+ sqlWhere
+ orderby
+ " fetch first "
+ (RecordSetCounts - (pagenum - 1) * perpage + 1)
+ " rows only";
} else {
sqltemp = "select top "
+ (RecordSetCounts - (pagenum - 1) * perpage)
+ " id,name,createrId,updateDate from KT_Knowledge"
+ sqlWhere + orderby;
}
rs.executeSql(sqltemp);
int i = 0;
JSONArray jsonArr = new JSONArray();
JSONObject json = new JSONObject();
while (rs.next()) {
JSONObject tmp = new JSONObject();
tmp.put("id", Util.null2String(rs.getString("id")));
tmp.put("name", Util.null2String(rs.getString("name")));
//tmp.put("mainid",MainCategoryComInfo.getMainCategoryname(mainid));
tmp.put("createrid", Util.toScreen(ResourceComInfo.getResourcename(Util.null2String(rs.getString("createrid"))), user.getLanguage()));
tmp.put("updateDate", Util.null2String(rs.getString("updateDate")));
jsonArr.add(tmp);
}
json.put("currentPage", pagenum);
json.put("totalPage", RecordSetCounts);
json.put("mapList", jsonArr.toString());
json.put("sqlWhere", sqlWhere);
out.println(json.toString());
%>