pageMultiAjax.jsp
8.53 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
<%@ page language="java" contentType="text/html; charset=UTF-8"%>
<%@ page import="weaver.general.*"%>
<%@ page import="weaver.hrm.*"%>
<%@ page import="java.util.*,java.lang.*"%>
<%@ page import="weaver.systeminfo.*"%>
<%@ page import="net.sf.json.JSONArray"%>
<%@ page import="net.sf.json.JSONObject"%>
<jsp:useBean id="rs" class="weaver.conn.RecordSet" scope="page" />
<jsp:useBean id="hpu" class="weaver.page.PageUtil" scope="page"/>
<%
User user = HrmUserVarify.getUser(request, response);
String src = Util.null2String(request.getParameter("src"));
String ids = Util.null2String(request.getParameter("ids"));
String type = Util.null2String(request.getParameter("type"));
boolean isDetachable=hpu.isDetachable(request);
if (ids.trim().startsWith(",")) {
ids = ids.substring(1);
}
String infoname = Util.null2String(request.getParameter("name"));
//out.println("infoname--"+infoname);
String infodesc = Util.null2String(request.getParameter("desc"));
int subCompanyId = user.getUserSubCompany1();
ArrayList idList = new ArrayList();
ArrayList nameList = new ArrayList();
ArrayList descList = new ArrayList();
String imagefilename = "/images/hdMaintenance_wev8.gif";
String titlename = "";
String sqlWhere="";
String sql = "select id,infoname,infodesc from hpinfo ";
JSONArray jsonArr = new JSONArray();
JSONObject json = new JSONObject();
if (src.equalsIgnoreCase("dest")) {
if ("aft".equals(type)){
if ("sqlserver".equals(rs.getDBType())){
if (user.getUID()==1){ //sysadmin
sqlWhere = " where (creatortype=4 or creatortype=3 and creatorid="+subCompanyId+" ) and subcompanyid!=-1 and infoname != ''";
} else {
sqlWhere = " where (creatortype=3 and creatorid="+subCompanyId+") and subcompanyid!=-1 and infoname != ''";
}
} else {
if (user.getUID()==1){ //sysadmin
sqlWhere = " where (creatortype=4 or creatortype=3 and creatorid="+subCompanyId+" ) and subcompanyid!=-1 and infoname is not null";
} else {
sqlWhere = " where (creatortype=3 and creatorid="+subCompanyId+" ) and subcompanyid!=-1 and infoname is not null";
}
}
//名称过滤
/* if(!"".equals(infoname) && infoname != null){
sqlWhere = sqlWhere + " and infoname like '%"+infoname+"%'";
}
if(!"".equals(infodesc) && infodesc != null){
sqlWhere = sqlWhere + " and infodesc like '%"+infodesc+"%'";
} */
if("".equals(ids)){
ids="''";
}
sqlWhere += " and id in ("+ids+") ";
sql +=sqlWhere+" order by id, subcompanyid ";
rs.execute(sql);
while (rs.next()){
String id = Util.null2String(rs.getString("id"));
String infoname1 = Util.null2String(rs.getString("infoname"));
String infodesc1 = Util.null2String(rs.getString("infodesc"));
JSONObject tmp = new JSONObject();
tmp.put("id", id);
tmp.put("infoname", infoname1);
tmp.put("infodesc", infodesc1);
jsonArr.add(tmp);
}//-------------------------------------
String sqlWhere2="";
if ("sqlserver".equals(rs.getDBType())){
sqlWhere2=" and subcompanyid!=-1 and h1.infoname != ''";
} else {
sqlWhere2=" and subcompanyid!=-1 and h1.infoname is not null";
}
/* if(!"".equals(infoname) && infoname != null){
sqlWhere2 = sqlWhere2 + " and infoname like '%"+infoname+"%'";
}
if(!"".equals(infodesc) && infodesc != null){
sqlWhere2 = sqlWhere2 + " and infodesc like '%"+infodesc+"%'";
} */
sqlWhere2 = sqlWhere2 + " and id in ("+ids+")";
if(subCompanyId==0 && user.getUID()==1&&isDetachable||subCompanyId==0&&!isDetachable){
sql = "select id,infoname,infodesc from hpinfo h1 where 1=1 " + sqlWhere2 + " order by subcompanyid ";
rs.execute(sql);
while (rs.next())
{
String id = Util.null2String(rs.getString("id"));
String infoname1 = Util.null2String(rs.getString("infoname"));
String infodesc1 = Util.null2String(rs.getString("infodesc"));
JSONObject tmp = new JSONObject();
tmp.put("id", id);
tmp.put("infoname", infoname1);
tmp.put("infodesc", infodesc1);
jsonArr.add(tmp);
}
}
}else if ("pre".equals(type)){
titlename = SystemEnv.getHtmlLabelName(23017, user.getLanguage())+":"+SystemEnv.getHtmlLabelName(320, user.getLanguage());
if ("sqlserver".equals(rs.getDBType())){
sqlWhere = " where creatortype=0 and subcompanyid=-1 and infoname != ''";
}else{
sqlWhere = " where creatortype=0 and subcompanyid=-1 and infoname is not null";
}
if("".equals(ids)){
ids="''";
}
sqlWhere += " and id in ("+ids+") ";
sql +=sqlWhere+" order by id,subcompanyid ";
rs.execute(sql);
while (rs.next()){
String id = Util.null2String(rs.getString("id"));
String infoname1 = Util.null2String(rs.getString("infoname"));
String infodesc1 = Util.null2String(rs.getString("infodesc"));
JSONObject tmp = new JSONObject();
tmp.put("id", id);
tmp.put("infoname", infoname1);
tmp.put("infodesc", infodesc1);
jsonArr.add(tmp);
}
}
json.put("mapList", jsonArr.toString());
out.println(json.toString());
return ;
}
if ("aft".equals(type)){
if ("sqlserver".equals(rs.getDBType())){
if (user.getUID()==1){ //sysadmin
sqlWhere = " where (creatortype=4 or creatortype=3 and creatorid="+subCompanyId+" ) and subcompanyid!=-1 and infoname != ''";
} else {
sqlWhere = " where (creatortype=3 and creatorid="+subCompanyId+") and subcompanyid!=-1 and infoname != ''";
}
} else {
if (user.getUID()==1){ //sysadmin
sqlWhere = " where (creatortype=4 or creatortype=3 and creatorid="+subCompanyId+" ) and subcompanyid!=-1 and infoname is not null";
} else {
sqlWhere = " where (creatortype=3 and creatorid="+subCompanyId+" ) and subcompanyid!=-1 and infoname is not null";
}
}
//名称过滤
if(!"".equals(infoname) && infoname != null){
sqlWhere = sqlWhere + " and infoname like '%"+infoname+"%'";
}
if(!"".equals(infodesc) && infodesc != null){
sqlWhere = sqlWhere + " and infodesc like '%"+infodesc+"%'";
}
sql +=sqlWhere+" order by id,subcompanyid ";
rs.execute(sql);
while (rs.next())
{
String id = Util.null2String(rs.getString("id"));
String infoname1 = Util.null2String(rs.getString("infoname"));
String infodesc1 = Util.null2String(rs.getString("infodesc"));
JSONObject tmp = new JSONObject();
tmp.put("id", id);
tmp.put("infoname", infoname1);
tmp.put("infodesc", infodesc1);
jsonArr.add(tmp);
}
//-------------------------------------
String sqlWhere2="";
if ("sqlserver".equals(rs.getDBType())){
sqlWhere2=" and subcompanyid!=-1 and h1.infoname != ''";
} else {
sqlWhere2=" and subcompanyid!=-1 and h1.infoname is not null";
}
//名称过滤
if(!"".equals(infoname) && infoname != null){
sqlWhere2 = sqlWhere2 + " and infoname like '%"+infoname+"%'";
}
if(!"".equals(infodesc) && infodesc != null){
sqlWhere2 = sqlWhere2 + " and infodesc like '%"+infodesc+"%'";
}
// 无功能权限 但有 页面 维护权限
if(subCompanyId==0 && user.getUID()==1&&isDetachable||subCompanyId==0&&!isDetachable){
sql = "select id,infoname,infodesc from hpinfo h1 where 1=1 "+ sqlWhere2 + " order by subcompanyid ";
rs.execute(sql);
while (rs.next()){
String id = Util.null2String(rs.getString("id"));
String infoname1 = Util.null2String(rs.getString("infoname"));
String infodesc1 = Util.null2String(rs.getString("infodesc"));
JSONObject tmp = new JSONObject();
tmp.put("id", id);
tmp.put("infoname", infoname1);
tmp.put("infodesc", infodesc1);
jsonArr.add(tmp);
}
}
}
else if ("pre".equals(type))
{
titlename = SystemEnv.getHtmlLabelName(23017, user.getLanguage())+":"+SystemEnv.getHtmlLabelName(320, user.getLanguage());
if ("sqlserver".equals(rs.getDBType())){
sqlWhere = " where creatortype=0 and subcompanyid=-1 and infoname != ''";
}else{
sqlWhere = " where creatortype=0 and subcompanyid=-1 and infoname is not null";
}
if(!"".equals(infoname) && infoname != null){
sqlWhere = sqlWhere + " and infoname like '%"+infoname+"%'";
}
if(!"".equals(infodesc) && infodesc != null){
sqlWhere = sqlWhere + " and infodesc like '%"+infodesc+"%'";
}
sql +=sqlWhere+" order by id,subcompanyid ";
rs.execute(sql);
while (rs.next())
{
String id = Util.null2String(rs.getString("id"));
String infoname1 = Util.null2String(rs.getString("infoname"));
String infodesc1 = Util.null2String(rs.getString("infodesc"));
JSONObject tmp = new JSONObject();
tmp.put("id", id);
tmp.put("infoname", infoname1);
tmp.put("infodesc", infodesc1);
jsonArr.add(tmp);
}
}
json.put("mapList", jsonArr.toString());
out.println(json.toString());
%>