fnaTreeBrowserAction.jsp
20.3 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
<%@page import="weaver.fna.maintenance.FnaSystemSetComInfo"%>
<%@page import="weaver.file.FileUpload"%>
<%@page import="org.apache.commons.lang.StringEscapeUtils"%>
<%@page import="org.json.JSONArray"%>
<%@page import="org.json.JSONObject"%>
<%@page import="weaver.fna.general.FnaCommon"%>
<%@page import="weaver.fna.maintenance.BudgetfeeTypeComInfo"%>
<%@ page language="java" contentType="text/html; charset=UTF-8" %>
<%@ page import="weaver.general.*" %>
<%@ page import="java.util.*" %>
<%@ page import="net.sourceforge.pinyin4j.PinyinHelper" %>
<%@ page import="net.sourceforge.pinyin4j.format.HanyuPinyinCaseType" %>
<%@ page import="net.sourceforge.pinyin4j.format.HanyuPinyinOutputFormat" %>
<%@ page import="net.sourceforge.pinyin4j.format.HanyuPinyinToneType" %>
<%@ page import="weaver.hrm.company.DepartmentComInfo" %>
<%@ page import="weaver.hrm.company.SubCompanyComInfo" %>
<%@ page import="weaver.hrm.job.JobTitlesComInfo" %>
<%@ page import="weaver.hrm.resource.ResourceComInfo" %>
<%@ page import="java.io.IOException" %>
<%@ page import="java.io.PrintWriter" %>
<%@ page import="java.net.URLDecoder" %>
<%@ page import="weaver.conn.RecordSet"%>
<%@page import="weaver.hrm.User"%>
<%@page import="weaver.hrm.HrmUserVarify"%>
<%@ page import="com.weaver.formmodel.mobile.manager.MobileUserInit"%>
<%@ page import = "weaver.formmode.tree.*" %>
<jsp:useBean id="rs" class="weaver.conn.RecordSet" scope="page" />
<jsp:useBean id="rs1" class="weaver.conn.RecordSet" scope="page" />
<jsp:useBean id="rs2" class="weaver.conn.RecordSet" scope="page" />
<jsp:useBean id="rs3" class="weaver.conn.RecordSet" scope="page" />
<jsp:useBean id="rs4" class="weaver.conn.RecordSet" scope="page" />
<%
User user = HrmUserVarify.getUser (request , response) ;
JSONObject resultObj = new JSONObject();
if(user == null){
response.sendRedirect("/notice/noright.jsp") ;
return ;
}else{
FnaSystemSetComInfo fnaSystemSetComInfo = new FnaSystemSetComInfo();
FileUpload fu = new FileUpload(request,false);
String action = Util.null2String(fu.getParameter("action"));
int pageNum = Util.getIntValue(fu.getParameter("pageNum"),1);
int pageSize = Util.getIntValue(fu.getParameter("pageSize"),10);
int totalPage = 0;
int enableDispalyAll=Util.getIntValue(fnaSystemSetComInfo.get_enableDispalyAll());
String separator =Util.null2String(fnaSystemSetComInfo.get_separator());
boolean subjectFilter = "1".equals(fnaSystemSetComInfo.get_subjectFilter())?true:false;
int subjectBrowseDefExpanded = Util.getIntValue(fnaSystemSetComInfo.get_subjectBrowseDefExpanded());
boolean showHiddenSubject = "1".equals(fnaSystemSetComInfo.get_showHiddenSubject())?true:false;
int optionalSubject = Util.getIntValue(fnaSystemSetComInfo.get_optionalSubject(), 0);//科目浏览按钮可选科目规则
int userId = 1;
String displayarchive= "0";//是否显示封存科目
if(showHiddenSubject){
displayarchive = "1";
}
int orgType = Util.getIntValue(fu.getParameter("orgType"),-1);
int orgId = Util.getIntValue(fu.getParameter("orgId"),-1);
int orgType2 = Util.getIntValue(fu.getParameter("orgType2"),-1);
int orgId2 = Util.getIntValue(fu.getParameter("orgId2"),-1);
int isFnaSubmitRequest4Mobile = Util.getIntValue(fu.getParameter("isFnaSubmitRequest4Mobile"),-1);
int workflowid = Util.getIntValue(fu.getParameter("fnaworkflowid"),-1);
String fieldid = Util.null2String(fu.getParameter("fnafieldid"));
int billid = Util.getIntValue(fu.getParameter("billid"),-1);
if(!"".equals(fieldid)){
fieldid = fieldid.substring(5).split("_")[0];
}
int isbill = 0;
int formid = 0;
if(workflowid > 0){
String sql = "select * from workflow_base where id = " + workflowid;
rs.executeSql(sql);
if(rs.next()){
isbill = rs.getInt("isbill");
formid = Math.abs(rs.getInt("formid"));
}
}
Map<String, String> dataMap = new HashMap<String, String>();
String fnaWfType = FnaCommon.getFnaWfFieldInfo4Expense(workflowid, dataMap);
BudgetfeeTypeComInfo budgetfeeTypeComInfo = new BudgetfeeTypeComInfo();
//系统表单的科目浏览按钮
if(workflowid!=-1 && "".equals(fieldid) && billid!=-1){
rs.executeSql("select * from workflow_billfield where (fieldname = 'subject' or fieldname = 'feetypeid') and billid = " + billid);
if(rs.next()){
fieldid = rs.getString("id");
}
}
boolean isFnaFeeWfInfo = false;
if(workflowid > 0){
String sql = "select count(*) cnt from fnaFeeWfInfo where workflowid = "+workflowid;
rs2.executeSql(sql);
isFnaFeeWfInfo = (rs2.next() && rs2.getInt("cnt") > 0);
}
//路径设置浏览数据过滤
List<String> subjectList = new ArrayList<String>();
budgetfeeTypeComInfo.getWfBrowdefListByFeelevel(workflowid+"",fieldid+"", BudgetfeeTypeComInfo.FNAFEETYPE_FIELDTYPE+"", subjectList);
boolean subjectWfFilter = true;
if(subjectList.size() == 0){
subjectWfFilter = false;
}
List<String> subjectList_canSelect = new ArrayList<String>();
if(subjectWfFilter){
budgetfeeTypeComInfo.getWfBrowdefListByFeelevel_canSelect(workflowid+"",fieldid+"", BudgetfeeTypeComInfo.FNAFEETYPE_FIELDTYPE+"", subjectList_canSelect);
}
ResourceComInfo rci = new ResourceComInfo();
int sqlCondOrgType4ftRul = orgType;
int sqlCondOrgId4ftRul = orgId;
if(orgType==3){//个人预算
sqlCondOrgType4ftRul = 2;
sqlCondOrgId4ftRul = Util.getIntValue(rci.getDepartmentID(orgId+""));
}
int sqlCondOrgType4ftRul2 = orgType2;
int sqlCondOrgId4ftRul2 = orgId2;
if(orgType2==3){//个人预算
sqlCondOrgType4ftRul2 = 2;
sqlCondOrgId4ftRul2 = Util.getIntValue(rci.getDepartmentID(orgId2+""));
}
if("getTreeData".equals(action)){//获取科目树
String supIdFull = Util.null2String(fu.getParameter("pid"));
String[] supIdFullArray = supIdFull.split("_");
int supId = Util.getIntValue(supIdFullArray[1]);
String selectedids = URLDecoder.decode(Util.null2String(fu.getParameter("selectedIds")), "utf-8");selectedids = "";
JSONArray array = new JSONArray();
try {
String sql1 = "select a.id, a.name, a.feelevel, a.feeperiod, a.Archive, a.isEditFeeType, a.isEditFeeTypeId from FnaBudgetfeeType a "+
" where a.supsubject = "+supId+" "+
" ORDER BY a.feeperiod,a.displayOrder,a.codeName, a.name, a.id ";
rs1.execute(sql1);
while(rs1.next()){
JSONObject json = new JSONObject();
String id = rs1.getString("id");
String name = rs1.getString("name");
int feelevel = Util.getIntValue(rs1.getString("feelevel"));
boolean archive = rs1.getInt("Archive")==1;
int isEditFeeTypeId = Util.getIntValue(rs1.getString("isEditFeeTypeId"));
int isEditFeeType = Util.getIntValue(rs1.getString("isEditFeeType"));
if(archive && !"1".equals(displayarchive)){
continue;
}
//路径设置浏览数据过滤
if(subjectWfFilter && !subjectList.contains(id)){
continue;
}
int canSelect = (isEditFeeTypeId>0)?1:0;
if(subjectWfFilter && !subjectList_canSelect.contains(id)){
canSelect = 0;
}
if(canSelect==1){
//如果是【预算变更流程】或者是系统表单【预算变更申请单】的流程,那么科目只有可编制预算是可以选择的
if("change".equals(fnaWfType) || (isbill == 1 && formid==159)){
if(isEditFeeType!=1){
canSelect = 0;
}
if(isEditFeeTypeId > 0 && Util.getIntValue(id)!=isEditFeeTypeId){
continue;
}
}
}
//过滤科目1
if(isFnaFeeWfInfo && isFnaSubmitRequest4Mobile == 1 && subjectFilter && sqlCondOrgType4ftRul > 0 && sqlCondOrgId4ftRul > 0){
boolean flag = budgetfeeTypeComInfo.checkRuleSetRight(sqlCondOrgType4ftRul, sqlCondOrgId4ftRul, Util.getIntValue(id));
if(!flag){
continue;
}
}
//过滤科目2
if(isFnaFeeWfInfo && isFnaSubmitRequest4Mobile == 1 && subjectFilter && sqlCondOrgType4ftRul2 > 0 && sqlCondOrgId4ftRul2 > 0){
boolean flag = budgetfeeTypeComInfo.checkRuleSetRight(sqlCondOrgType4ftRul2, sqlCondOrgId4ftRul2, Util.getIntValue(id));
if(!flag){
continue;
}
}
String fullName = name;
if(enableDispalyAll==1){
fullName = budgetfeeTypeComInfo.getSubjectFullName(id, separator);
}
String isParent = "true";
if(("change".equals(fnaWfType) || (isbill == 1 && formid==159)) && canSelect==1){
//如果是【预算变更流程】或者是系统表单【预算变更申请单】的流程,且,当前科目可以被选中,则它的下级科目都不能选中,所以,可以认为他没有下级科目
isParent = "false";
}else{
String sql2 = "select count(*) cnt from FnaBudgetfeeType a where a.supsubject = "+Util.getIntValue(id);
rs2.executeSql(sql2);
if(rs2.next() && rs2.getInt("cnt") > 0){
isParent = "true";
if(optionalSubject==1){//1:末級科目(可編制預算的科目或隸屬于某個可編制預算的科目)
canSelect = 0;
}
}else{
isParent = "false";
}
}
int hasChild = "true".equals(isParent)?1:0;
//String icon = "/images/treeimages/home16_wev8.gif";
json.put("id", feelevel+"_"+id);
json.put("name", name);
json.put("hasChild", hasChild);
json.put("lastname", name);
json.put("type", "1");
json.put("canSelect", canSelect);
json.put("fullName", fullName);
array.put(json);
}
resultObj.put("datas", array);
resultObj.put("sel_datas", "["+selectedids+"]");
resultObj.put("isonlyleaf", "0");
resultObj.put("status", "1");
resultObj.put("expanded", subjectBrowseDefExpanded);
} catch (Exception ex) {
ex.printStackTrace();
resultObj.put("status", "0");
resultObj.put("errMsg", ex.getMessage());
}finally{
try{
out.print(resultObj.toString());
out.flush();
}catch(IOException ex){
ex.printStackTrace();
}
}
}else if("getRecentData".equals(action)){//获取最近所选科目
JSONArray array = new JSONArray();
String _spSql = " 1=1 ";
//如果是【预算变更流程】或者是系统表单【预算变更申请单】的流程,那么科目只有可编制预算是可以选择的
if(("change".equals(fnaWfType) || (isbill == 1 && formid==159)) && 1==1){
_spSql = " a.isEditFeeType = 1 ";
}else{
if(optionalSubject==0){//0:可编制预算的科目及下级科目else{
_spSql = " a.isEditFeeType > 0 ";
}else if(optionalSubject==1){//1:末級科目(可編制預算的科目或隸屬于某個可編制預算的科目)
_spSql = " not EXISTS (select 1 from FnaBudgetfeeType a1 where a1.supsubject = a.id) ";
}
}
String sql1 = "select a.feelevel,a.id, a.name, a.codeName, b.orderId, a.feeperiod, a.Archive, a.isEditFeeType, a.isEditFeeTypeId "+
" from FnaBudgetfeeType a "+
" join FnaBudgetfeeTypeUsed b on a.id = b.subjectId "+
" where "+_spSql+" and a.isEditFeeTypeId > 0 "+
" and b.userId = "+userId+" "+
" ORDER BY a.feeperiod, b.orderId desc, a.feelevel, a.displayOrder, a.codeName, a.name, a.id ";
rs1.executeSql(sql1);
int count = 1;
int start = (pageNum - 1) * pageSize + 1;
int end = pageNum * pageSize;
while(rs1.next()){
JSONObject json = new JSONObject();
int feelevel = Util.getIntValue(rs1.getString("feelevel"));
String id = rs1.getString("id");
String name = rs1.getString("name");
boolean archive = rs1.getInt("Archive")==1;
int isEditFeeType = Util.getIntValue(rs1.getString("isEditFeeType"));
if(archive && !"1".equals(displayarchive)){
continue;
}
//路径设置浏览数据过滤
if(subjectWfFilter && !subjectList_canSelect.contains(id)){
continue;
}
//过滤科目1
if(isFnaFeeWfInfo && isFnaSubmitRequest4Mobile == 1 && subjectFilter && sqlCondOrgType4ftRul > 0 && sqlCondOrgId4ftRul > 0){
boolean flag = budgetfeeTypeComInfo.checkRuleSetRight(sqlCondOrgType4ftRul, sqlCondOrgId4ftRul, Util.getIntValue(id));
if(!flag){
continue;
}
}
//过滤科目2
if(isFnaFeeWfInfo && isFnaSubmitRequest4Mobile == 1 && subjectFilter && sqlCondOrgType4ftRul2 > 0 && sqlCondOrgId4ftRul2 > 0){
boolean flag = budgetfeeTypeComInfo.checkRuleSetRight(sqlCondOrgType4ftRul2, sqlCondOrgId4ftRul2, Util.getIntValue(id));
if(!flag){
continue;
}
}
StringBuffer supName = new StringBuffer();//上级所有科目名称
String allSupSubjectids = "";
String sql2 = "select a.allSupSubjectids from fnabudgetfeetype a where a.id = "+id;
rs2.execute(sql2);
while(rs2.next()){
allSupSubjectids = rs2.getString("allSupSubjectids");
}
if(enableDispalyAll!=1){
separator = "-";
}
for(int i = 0;i<allSupSubjectids.split(",").length;i++){
String subjectid = allSupSubjectids.split(",")[i];
if(i< allSupSubjectids.split(",").length - 1){
if(supName.length()>0){
supName.append(separator);
}
supName.append(budgetfeeTypeComInfo.getBudgetfeeTypename(subjectid));
}
}
if(supName.length() == 0){
supName.append("");
}
String fullName = name;
if(enableDispalyAll==1){
fullName = budgetfeeTypeComInfo.getSubjectFullName(id, separator);
}
if(count >= start && count<=end){
json.put("id", feelevel+"_"+id);
json.put("name", name);
json.put("supName", supName.toString());
json.put("fullName", fullName);
array.put(json);
}
count++;
}
resultObj.put("datas", array);
resultObj.put("status", "1");
new BaseBean().writeLog("count", count);
new BaseBean().writeLog("pageSize", pageSize);
resultObj.put("totalPage", (count + pageSize - 2)/pageSize);
out.print(resultObj.toString());
out.flush();
}else if("getSearchData".equals(action)){
JSONArray array = new JSONArray();
String key = Util.null2String(fu.getParameter("key"));
String temp_sel = Util.null2String(fu.getParameter("temp_sel"));
String _spSql = " 1=1 ";
//如果是【预算变更流程】或者是系统表单【预算变更申请单】的流程,那么科目只有可编制预算是可以选择的
if(("change".equals(fnaWfType) || (isbill == 1 && formid==159)) && 1==1){
_spSql = " a.isEditFeeType = 1 ";
}else{
if(optionalSubject==0){//0:可编制预算的科目及下级科目else{
_spSql = " a.isEditFeeType > 0 ";
}else if(optionalSubject==1){//1:末級科目(可編制預算的科目或隸屬于某個可編制預算的科目)
_spSql = " not EXISTS (select 1 from FnaBudgetfeeType a1 where a1.supsubject = a.id) ";
}
}
String sql1 = "select a.id, a.name, a.codeName, a.feelevel, a.feeperiod, a.Archive, a.isEditFeeType, a.isEditFeeTypeId from FnaBudgetfeeType a "+
" where "+_spSql+" and (a.codeName like '%"+StringEscapeUtils.escapeSql(key)+"%' or a.name like '%"+StringEscapeUtils.escapeSql(key)+"%') "+
" and a.isEditFeeTypeId > 0 "+
" ORDER BY a.feelevel, a.displayOrder, a.codeName, a.name, a.id ";
rs1.executeSql(sql1);
int count = 1;
int start = (pageNum - 1) * pageSize + 1;
int end = pageNum * pageSize;
while(rs1.next()){
JSONObject json = new JSONObject();
int feelevel = Util.getIntValue(rs1.getString("feelevel"));
String id = rs1.getString("id");
String name = rs1.getString("name");
boolean archive = rs1.getInt("Archive")==1;
int isEditFeeType = Util.getIntValue(rs1.getString("isEditFeeType"));
if(archive && !"1".equals(displayarchive)){
continue;
}
//路径设置浏览数据过滤
if(subjectWfFilter && !subjectList_canSelect.contains(id)){
continue;
}
//过滤科目1
if(isFnaFeeWfInfo && isFnaSubmitRequest4Mobile == 1 && subjectFilter && sqlCondOrgType4ftRul > 0 && sqlCondOrgId4ftRul > 0){
boolean flag = budgetfeeTypeComInfo.checkRuleSetRight(sqlCondOrgType4ftRul, sqlCondOrgId4ftRul, Util.getIntValue(id));
if(!flag){
continue;
}
}
//过滤科目2
if(isFnaFeeWfInfo && isFnaSubmitRequest4Mobile == 1 && subjectFilter && sqlCondOrgType4ftRul2 > 0 && sqlCondOrgId4ftRul2 > 0){
boolean flag = budgetfeeTypeComInfo.checkRuleSetRight(sqlCondOrgType4ftRul2, sqlCondOrgId4ftRul2, Util.getIntValue(id));
if(!flag){
continue;
}
}
StringBuffer supName = new StringBuffer();//上级所有科目名称
String allSupSubjectids = "";
String sql2 = "select a.allSupSubjectids from fnabudgetfeetype a where a.id = "+id;
rs2.execute(sql2);
while(rs2.next()){
allSupSubjectids = rs2.getString("allSupSubjectids");
}
if(enableDispalyAll!=1){
separator = "-";
}
for(int i = 0;i<allSupSubjectids.split(",").length;i++){
String subjectid = allSupSubjectids.split(",")[i];
if(i< allSupSubjectids.split(",").length - 1){
if(supName.length()>0){
supName.append(separator);
}
supName.append(budgetfeeTypeComInfo.getBudgetfeeTypename(subjectid));
}
}
if(supName.length() == 0){
supName.append("");
}
String fullName = name;
if(enableDispalyAll==1){
fullName = budgetfeeTypeComInfo.getSubjectFullName(id, separator);
}
if(count >= start && count<=end){
json.put("id", feelevel+"_"+id);
json.put("name", name);
json.put("supName", supName.toString());
json.put("fullName", fullName);
array.put(json);
}
count++;
}
resultObj.put("datas", array);
resultObj.put("status", "1");
resultObj.put("totalPage", (count + pageSize - 2)/pageSize);
out.print(resultObj.toString());
out.flush();
}else if("used".equals(action)){
int subjectId = Util.getIntValue(fu.getParameter("subjectId"));
String sql1 = "delete from FnaBudgetfeeTypeUsed where subjectId = "+subjectId+" and userId = "+userId;
rs1.executeSql(sql1);
int idx = 0;
sql1 = "select * from FnaBudgetfeeTypeUsed where userId = "+userId+" order by orderId desc";
rs1.executeSql(sql1);
while(rs1.next()){
int orderId = rs1.getInt("orderId");
idx++;
if(idx >= 20){
String sql2 = "delete from FnaBudgetfeeTypeUsed where orderId <= "+orderId+" and userId = "+userId;
rs2.executeSql(sql2);
break;
}
}
int orderId = 0;
sql1 = "select max(orderId) maxOrderId from FnaBudgetfeeTypeUsed where userId = "+userId+"";
rs1.executeSql(sql1);
while(rs1.next()){
orderId = rs1.getInt("maxOrderId");
}
orderId++;
sql1 = "insert into FnaBudgetfeeTypeUsed (userId, subjectId, orderId) values ("+userId+", "+subjectId+", "+orderId+")";
rs1.executeSql(sql1);
idx = 0;
sql1 = "select * from FnaBudgetfeeTypeUsed where userId = "+userId+" order by orderId asc";
rs1.executeSql(sql1);
while(rs1.next()){
int _subjectId = rs1.getInt("subjectId");
String sql2 = "update FnaBudgetfeeTypeUsed set orderId = "+idx+" where subjectId = "+_subjectId+" and userId = "+userId;
rs2.executeSql(sql2);
idx++;
}
}else if("getFeelevel".equals(action)){
int subjectId = Util.getIntValue(fu.getParameter("subjectId"));
rs.execute("select feelevel from fnabudgetfeetype where id = "+subjectId);
int feelevel = 0;
while(rs.next()){
feelevel = Util.getIntValue(rs.getString("feelevel"));
}
resultObj.put("feelevel", feelevel);
out.print(resultObj.toString());
out.flush();
}
}
%>