BudgetfeeTypeBrowserNewTreeAjax.jsp
12.2 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
<%@page import="weaver.fna.maintenance.FnaSystemSetComInfo"%>
<%@page import="weaver.fna.general.FnaCommon"%>
<%@page import="weaver.hrm.resource.ResourceComInfo"%>
<%@page import="weaver.conn.RecordSet"%>
<%@page import="weaver.fna.maintenance.BudgetfeeTypeComInfo"%>
<%@page import="weaver.systeminfo.SystemEnv"%>
<%@page import="weaver.general.BaseBean"%>
<%@page import="org.apache.commons.lang.StringEscapeUtils"%>
<%@page import="org.json.JSONObject"%>
<%@ page language="java" contentType="text/html; charset=UTF-8" %>
<%@ page import="weaver.general.Util" %>
<%@ page import="java.util.*,java.sql.Timestamp" %>
<%@ page import="weaver.general.GCONST" %>
<%@page import="weaver.hrm.HrmUserVarify"%>
<%@page import="weaver.hrm.User"%>
<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" />
<%
StringBuffer result = new StringBuffer();
User user = HrmUserVarify.getUser (request , response) ;
if(user == null){
}else{
FnaSystemSetComInfo fnaSystemSetComInfo = new FnaSystemSetComInfo();
int enableDispalyAll = Util.getIntValue(fnaSystemSetComInfo.get_enableDispalyAll());
String separator = Util.null2String(fnaSystemSetComInfo.get_separator());
boolean subjectFilter = 1==Util.getIntValue(fnaSystemSetComInfo.get_subjectFilter());
int optionalSubject = Util.getIntValue(fnaSystemSetComInfo.get_optionalSubject(), 0);//科目浏览按钮可选科目规则
int userId = user.getUID();
String qryType = Util.null2String(request.getParameter("qryType"));
int filterlevel = Util.getIntValue(request.getParameter("level"),0);
String displayarchive=Util.null2String(request.getParameter("displayarchive"));//是否显示封存科目
String fromWfFnaBudgetChgApply=Util.null2String(request.getParameter("fromWfFnaBudgetChgApply")).trim();//=1:来自系统表单预算变更申请单
int orgType = Util.getIntValue(request.getParameter("orgType"),-1);
int orgId = Util.getIntValue(request.getParameter("orgId"),-1);
int orgType2 = Util.getIntValue(request.getParameter("orgType2"),-1);
int orgId2 = Util.getIntValue(request.getParameter("orgId2"),-1);
int fromFnaRequest = Util.getIntValue(request.getParameter("fromFnaRequest"),-1);
int workflowid = Util.getIntValue(request.getParameter("workflowid"),-1);
int fieldid = Util.getIntValue(request.getParameter("fieldid"),-1);
int billid = Util.getIntValue(request.getParameter("billid"),-1);
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 = rs.getInt("formid");
}
}
Map<String, String> dataMap = new HashMap<String, String>();
String fnaWfType = FnaCommon.getFnaWfFieldInfo4Expense(workflowid, dataMap);
String sqlwhere = Util.null2String(request.getParameter("sqlwhere"));
BudgetfeeTypeComInfo budgetfeeTypeComInfo = new BudgetfeeTypeComInfo();
//系统表单的科目浏览按钮
if(workflowid!=-1 && fieldid==-1 && billid!=-1){
rs.executeSql("select * from workflow_billfield where (fieldname = 'subject' or fieldname = 'feetypeid') and billid = " + billid);
if(rs.next()){
fieldid = rs.getInt("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("0".equals(qryType) || "1".equals(qryType)){//按名称查询科目
String qryName = Util.null2String(request.getParameter("qryName"));
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.isEditFeeTypeId > 0 ";
}else if(optionalSubject==1){//1:末級科目(可編制預算的科目或隸屬于某個可編制預算的科目)
_spSql = " not EXISTS (select 1 from FnaBudgetfeeType a1 where a1.supsubject = a.id) ";
}
}
result.append("{\"dataArray\":[");
int idx = 0;
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(qryName)+"%' or a.name like '%"+StringEscapeUtils.escapeSql(qryName)+"%') "+
" and a.isEditFeeTypeId > 0 "+
" ORDER BY a.feelevel, a.displayOrder, a.codeName, a.name, a.id ";
if("0".equals(qryType)){
sql1 = "select 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);
while(rs1.next()){
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;
}
//如果是【预算变更流程】或者是系统表单【预算变更申请单】的流程,那么科目只有可编制预算是可以选择的
if(("change".equals(fnaWfType) || (isbill == 1 && formId==159)) && isEditFeeType!=1){
continue;
}
//过滤科目1
if(isFnaFeeWfInfo && fromFnaRequest == 1 && subjectFilter && sqlCondOrgType4ftRul > 0 && sqlCondOrgId4ftRul > 0){
boolean flag = budgetfeeTypeComInfo.checkRuleSetRight(sqlCondOrgType4ftRul, sqlCondOrgId4ftRul, Util.getIntValue(id));
if(!flag){
continue;
}
}
//过滤科目2
if(isFnaFeeWfInfo && fromFnaRequest == 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);
}
if(idx>0){
result.append(",");
}
result.append("{"+
"\"id\":"+JSONObject.quote(id)+","+
"\"name\":"+JSONObject.quote(name)+","+
"\"fullName\":"+JSONObject.quote(fullName)+""+
"}");
idx++;
}
result.append("]}");
}else if("2".equals(qryType)){//显示科目树
String supIdFull = Util.null2String(request.getParameter("id"));
if("".equals(supIdFull)){//初始化组织架构树
supIdFull = "0_0";
}
String[] supIdFullArray = supIdFull.split("_");
int supId = Util.getIntValue(supIdFullArray[1]);
result.append("[");
int idx = 0;
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.executeSql(sql1);
while(rs1.next()){
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 && fromFnaRequest == 1 && subjectFilter && sqlCondOrgType4ftRul > 0 && sqlCondOrgId4ftRul > 0){
boolean flag = budgetfeeTypeComInfo.checkRuleSetRight(sqlCondOrgType4ftRul, sqlCondOrgId4ftRul, Util.getIntValue(id));
if(!flag){
continue;
}
}
//过滤科目2
if(isFnaFeeWfInfo && fromFnaRequest == 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";
}
}
//String icon = "/images/treeimages/home16_wev8.gif";
if(idx>0){
result.append(",");
}
result.append("{"+
"\"id\":"+JSONObject.quote(feelevel+"_"+id)+","+
"\"name\":"+JSONObject.quote(name)+","+
"\"isParent\":"+isParent+","+
"\"fullName\":"+JSONObject.quote(fullName)+","+
"\"isEditFeeTypeId\":"+isEditFeeTypeId+","+
"\"canSelect\":"+canSelect+""+
//"\"icon\":"+JSONObject.quote(icon)+
"}");
idx++;
}
result.append("]");
}
}
//System.out.println("result="+result.toString());
%><%=result.toString() %>