RequestImportJson.jsp
10.5 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
<%@ page language="java" contentType="text/plain; charset=UTF-8"%>
<%@ page import="weaver.general.Util" %>
<%@ page import="java.util.*" %>
<%@ page import="java.text.SimpleDateFormat"%>
<%@ page import="weaver.hrm.HrmUserVarify" %>
<%@ page import="weaver.hrm.User" %>
<%@page import="weaver.workflow.workflow.WorkflowVersion"%>
<jsp:useBean id="RecordSet" class="weaver.conn.RecordSet" scope="page" />
<%!
public String convertSpecialChar(String str){
str = str.replaceAll("\\\t|\\\r|\\\n|\\\f", "");
str = str.replaceAll("\\\\", "\\\\\\\\");
return str;
}
%>
<%
long start = System.currentTimeMillis();
RecordSet.writeLog("---------------start---------------------");
String f_weaver_belongto_userid=request.getParameter("f_weaver_belongto_userid");
String f_weaver_belongto_usertype=request.getParameter("f_weaver_belongto_usertype");
User user = HrmUserVarify.getUser(request, response, f_weaver_belongto_userid, f_weaver_belongto_usertype) ;
String userID = String.valueOf(user.getUID());
int userid=user.getUID();
String belongtoshow = "";
RecordSet.executeSql("select * from HrmUserSetting where resourceId = "+userID);
if(RecordSet.next()){
belongtoshow = RecordSet.getString("belongtoshow");
}
String userIDAll = String.valueOf(user.getUID());
String Belongtoids =user.getBelongtoids();
int Belongtoid=0;
String[] arr2 = null;
ArrayList<String> userlist = new ArrayList();
userlist.add(userid + "");
if(!"".equals(Belongtoids)){
userIDAll = userID+","+Belongtoids;
arr2 = Belongtoids.split(",");
for(int i=0;i<arr2.length;i++){
Belongtoid = Util.getIntValue(arr2[i]);
userlist.add(Belongtoid + "");
}
}
String importuser=Util.null2String(request.getParameter("importuser"));
//System.out.println("--59-importuser--"+importuser);
//System.out.println("--59-userID--"+userID);
String requestname = Util.null2String(request.getParameter("requestname"));
//System.out.println("requestname = " + requestname);
String creater = Util.null2String(request.getParameter("creater"));
if (creater.equals("")) {
creater = user.getUID() + "";
}
if(!importuser.equals(String.valueOf(user.getUID()))){
creater = importuser;
}
String createdatestart = Util.null2String(request.getParameter("createdatestart"));
String createdateend = Util.null2String(request.getParameter("createdateend"));
if("".equals(createdatestart)){
Calendar calendar = Calendar.getInstance();
calendar.setTime(new Date());
calendar.add(Calendar.YEAR, -1);
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
createdatestart = sdf.format(calendar.getTime());
}
String isrequest = Util.null2String(request.getParameter("isrequest"));
String requestmark = Util.null2String(request.getParameter("requestmark"));
String prjids=Util.null2String(request.getParameter("prjids"));
String crmids=Util.null2String(request.getParameter("crmids"));
String workflowid=Util.null2String(request.getParameter("workflowid"));
String formid=Util.null2String(request.getParameter("formid"));
int isbill=Util.getIntValue(request.getParameter("isbill"),0);
String department =Util.null2String(request.getParameter("department"));
String status = Util.null2String(request.getParameter("status"));
String ismode = Util.null2String(request.getParameter("ismode"));
String sqlwhere = "";
if (isrequest.equals("")) isrequest = "1";
//String userid = ""+user.getUID() ;
String usertype="0";
if(user.getLogintype().equals("2")) usertype="1";
int ishead = 0;
if(!sqlwhere.equals("")) ishead = 1;
if(!requestname.equals("")){
if(ishead==0){
ishead = 1;
sqlwhere += " where t1.requestname like '%" + Util.fromScreen2(requestname,user.getLanguage()) +"%' ";
}
else
sqlwhere += " and t1.requestname like '%" + Util.fromScreen2(requestname,user.getLanguage()) +"%' ";
}
if(!creater.equals("")){
if(ishead==0){
ishead = 1;
sqlwhere += " where t1.creater in (" + creater +") " ;
}
else
sqlwhere += " and t1.creater in (" + creater +") " ;
}
if(!createdatestart.equals("")){
if(ishead==0){
ishead = 1;
sqlwhere += " where t1.createdate >='" + createdatestart +"' " ;
}
else
sqlwhere += " and t1.createdate >='" + createdatestart +"' " ;
}
if(!createdateend.equals("")){
if(ishead==0){
ishead = 1;
sqlwhere += " where t1.createdate <='" + createdateend +"' " ;
}
else
sqlwhere += " and t1.createdate <='" + createdateend +"' " ;
}
if(status.equals("1")){
if(ishead==0){
ishead = 1;
sqlwhere += " where t1.currentnodetype <> 3 " ;
}
else
sqlwhere += " and t1.currentnodetype <> 3 " ;
}
if(status.equals("2")){
if(ishead==0){
ishead = 1;
sqlwhere += " where t1.currentnodetype = 3 " ;
}
else
sqlwhere += " and t1.currentnodetype = 3 " ;
}
if(!formid.equals("")&&!formid.equals("0")){
if(ishead==0){
ishead = 1;
sqlwhere += " where t1.workflowid in (select id from workflow_base where isbill='"+isbill+"' and formid=" + formid +")";
}
else
sqlwhere += " and t1.workflowid in (select id from workflow_base where isbill='"+isbill+"' and formid=" + formid +")";
}
if(!workflowid.equals("")&&!workflowid.equals("0")){
if(ishead==0){
ishead = 1;
sqlwhere += " where t1.workflowid in (" + WorkflowVersion.getAllVersionStringByWFIDs(workflowid)+ ")";
}
else
sqlwhere += " and t1.workflowid in (" + WorkflowVersion.getAllVersionStringByWFIDs(workflowid) + ")";
}
if(!department.equals("")&&!department.equals("0")){
if(ishead==0){
ishead = 1;
sqlwhere += " where t1.creater in (select id from hrmresource where departmentid in ("+department+"))";
}
else
sqlwhere += " and t1.creater in (select id from hrmresource where departmentid in ("+department+"))";
}
if(!prjids.equals("")&&!prjids.equals("0")){
if(ishead==0){
ishead = 1;
if(RecordSet.getDBType().equals("oracle")){
sqlwhere += " where (concat(concat(',' , To_char(t1.prjids)) , ',') LIKE '%,"+prjids+",%') ";
}else if(RecordSet.getDBType().equals("mysql")){
sqlwhere += " where (concat(',' , t1.prjids , ',') LIKE '%,"+prjids+",%') ";
}else{
sqlwhere += " where (',' + CONVERT(varchar,t1.prjids) + ',' LIKE '%,"+prjids+",%') ";
}
}else{
if(RecordSet.getDBType().equals("oracle")){
sqlwhere += " and (concat(concat(',' , To_char(t1.prjids)) , ',') LIKE '%,"+prjids+",%') ";
}else if(RecordSet.getDBType().equals("mysql")){
sqlwhere += " where (concat(',' , t1.prjids , ',') LIKE '%,"+prjids+",%') ";
}else{
sqlwhere += " and (',' + CONVERT(varchar,t1.prjids) + ',' LIKE '%,"+prjids+",%') ";
}
}
}
if(!crmids.equals("")&&!crmids.equals("0")){
if(ishead==0){
ishead = 1;
if(RecordSet.getDBType().equals("oracle")){
sqlwhere += " where (concat(concat(',' , To_char(t1.crmids)) , ',') LIKE '%,"+crmids+",%') ";
}else if(RecordSet.getDBType().equals("mysql")){
sqlwhere += " where (concat(',' , t1.crmids , ',') LIKE '%,"+crmids+",%') ";
}else{
sqlwhere += " where (',' + CONVERT(varchar,t1.crmids) + ',' LIKE '%,"+crmids+",%') ";
}
}else{
if(RecordSet.getDBType().equals("oracle")){
sqlwhere += " and (concat(concat(',' , To_char(t1.crmids)) , ',') LIKE '%,"+crmids+",%') ";
}else if(RecordSet.getDBType().equals("mysql")){
sqlwhere += " and (concat(',' , t1.crmids , ',') LIKE '%,"+crmids+",%') ";
}else{
sqlwhere += " and (',' + CONVERT(varchar,t1.crmids) + ',' LIKE '%,"+crmids+",%') ";
}
}
}
if(!requestmark.equals("")){
if(ishead==0){
ishead = 1;
sqlwhere += " where t1.requestmark like '%" + requestmark +"%' " ;
}
else
sqlwhere += " and t1.requestmark like '%" + requestmark +"%' " ;
}
if (sqlwhere.equals("")){
if("1".equals(belongtoshow)){
sqlwhere = " where t1.requestid <> 0 and t2.requestid = t1.requestid and t1.workflowid=t3.id and and t2.userid in (" +importuser + ") and t2.usertype="+usertype+" and exists(select 1 from workflow_base where id=t1.workflowid and (isvalid='1' or isvalid='3'))" ;
}else{
sqlwhere = " where t1.requestid <> 0 and t2.requestid = t1.requestid and t1.workflowid=t3.id and and t2.userid in (" +userid + ") and t2.usertype="+usertype+" and exists(select 1 from workflow_base where id=t1.workflowid and (isvalid='1' or isvalid='3'))" ;
}
}else{
if("1".equals(belongtoshow)){
sqlwhere += " and t2.requestid = t1.requestid and t1.workflowid=t3.id and t2.userid in (" +importuser + ") and t2.usertype="+usertype+" and exists(select 1 from workflow_base where id=t1.workflowid and (isvalid='1' or isvalid='3')) " ;
}else{
sqlwhere += " and t2.requestid = t1.requestid and t1.workflowid=t3.id and t2.userid in (" +userid + ") and t2.usertype="+usertype+" and exists(select 1 from workflow_base where id=t1.workflowid and (isvalid='1' or isvalid='3')) " ;
}
}
%>
<%
//String backfields = " t4.nodetype,t2.nodeid,t3.formid,t3.isbill,t1.requestid,t1.requestname,t1.creater,t1.createdate,t1.createtime ";
String backfields = " DISTINCT t3.formid,t3.isbill,t1.requestid,t1.requestname,t1.creater,t1.createdate,t1.createtime ";
String fromSql = " workflow_requestbase t1, workFlow_CurrentOperator t2,workflow_base t3,workflow_flownode t4 ";
String tableString = "";
int perpage=10;
String sql="select "+backfields+" from "+fromSql+sqlwhere+" order by t1.createdate desc,t1.createtime desc";
//System.out.println(sql);
RecordSet.writeLog("------------------------------------242line:"+(System.currentTimeMillis() - start));
start = System.currentTimeMillis();
String creatNodeId = "";
RecordSet.executeSql("SELECT nodeid FROM workflow_flownode WHERE workflowid=" + workflowid + " AND nodetype=0");
if (RecordSet.next()) {
creatNodeId = RecordSet.getString("nodeid");
}
RecordSet.writeLog("------------------------------------249line:"+(System.currentTimeMillis() - start));
start = System.currentTimeMillis();
RecordSet.executeSql(sql);
RecordSet.writeLog("------------------------------------252line:"+(System.currentTimeMillis() - start));
start = System.currentTimeMillis();
StringBuilder sb=new StringBuilder("[");
while(RecordSet.next()){
sb.append("{");
sb.append("\"data\":\"").append(RecordSet.getString("requestid")).append("\",");
sb.append("\"isbill\":\"").append(RecordSet.getString("isbill")).append("\",");
sb.append("\"formid\":\"").append(RecordSet.getString("formid")).append("\",");
sb.append("\"nodeid\":\"").append(creatNodeId).append("\",");
sb.append("\"nodetype\":\"0").append("\",");
sb.append("\"value\":\"").append(convertSpecialChar(RecordSet.getString("requestname"))).append("\"},");
}
RecordSet.writeLog("------------------------------------275line:"+(System.currentTimeMillis() - start));
start = System.currentTimeMillis();
String jsonrs;
if(sb.length()>1)
{
jsonrs=sb.substring(0,sb.length()-1)+"]";
}else
{
jsonrs=sb.append("]").toString();
}
//System.out.println(jsonrs);
out.print(jsonrs);
%>