FnaBudgetLeftFccAjax.jsp
9.25 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
<%@page import="weaver.fna.maintenance.FnaCostCenter"%>
<%@page import="weaver.fna.general.FnaBudgetLeftRuleSet"%><%@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="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" /><%
StringBuffer result = new StringBuffer();
User user = HrmUserVarify.getUser (request , response) ;
if(user == null){
}else{
BaseBean bb = new BaseBean();
int userId = user.getUID();
boolean canView = HrmUserVarify.checkUserRight("BudgetAuthorityRule:readOnly", user);//预算编制只读权限
boolean canEdit = (HrmUserVarify.checkUserRight("FnaBudget:View", user) ||
HrmUserVarify.checkUserRight("FnaBudgetEdit:Edit", user) ||
HrmUserVarify.checkUserRight("BudgetAuthorityRule:edit", user));//财务预算维护、预算编制权限
List<String> allowFccIdEdit_list = new ArrayList<String>();
boolean allowFccIdEdit = FnaBudgetLeftRuleSet.getAllowFccId(user.getUID(), allowFccIdEdit_list);
List<String> allowFccIdTreeView_list_1 = new ArrayList<String>();
if(!allowFccIdEdit && allowFccIdEdit_list.size() > 0){
allowFccIdTreeView_list_1 = FnaBudgetLeftRuleSet.recursiveSuperiorFcc(allowFccIdEdit_list);
}
if(canView || canEdit){
String id = Util.null2String(request.getParameter("id2"));
String name = Util.null2String(request.getParameter("name"));
//String level = Util.null2String(request.getParameter("level"));
String otherParam = Util.null2String(request.getParameter("otherParam"));
//System.out.println("id="+id+";name="+name+";otherParam="+otherParam);
String _searchStr_lowerCase = Util.null2String(request.getParameter("_searchStr_lowerCase"));
List<String> needShowOrgIdWhenCanceled_list = new ArrayList<String>();
rs1.executeQuery("select distinct a.id from FnaBudgetInfo a where a.status <> 0 and a.organizationtype = 18004");
while(rs1.next()){
needShowOrgIdWhenCanceled_list.add(rs1.getString("id"));
}
if(!"".equals(_searchStr_lowerCase)){
List _idList = new ArrayList();
int idx = 0;
String sql1 = "select a.id, a.type, a.name, a.code, a.Archive, a.supFccId from FnaCostCenter a "+
" where "+FnaCostCenter.getDbUserName()+"getFccArchive1(a.id) = 0 "+
" and (a.name like '%"+StringEscapeUtils.escapeSql(_searchStr_lowerCase)+"%' or a.code like '%"+StringEscapeUtils.escapeSql(_searchStr_lowerCase)+"%') "+
" ORDER BY a.type, a.code, a.name, a.id ";
rs1.executeSql(sql1);
while(rs1.next()){
String _id = rs1.getString("id");
int _type = Util.getIntValue(rs1.getString("type"));
String _name = rs1.getString("name");
String _code = rs1.getString("code");
String _supFccId = rs1.getString("supFccId");
int _canceled = Util.getIntValue(rs1.getString("Archive"), 0);
if(!allowFccIdEdit && !allowFccIdTreeView_list_1.contains(_id)){
continue;
}
String _typeName = "fccType";
if(_type == 1){
_typeName = "fcc";
}
String _name1 = _name;
if(_canceled == 1){
if(!needShowOrgIdWhenCanceled_list.contains(_id)){
continue;
}
_name1 += "("+SystemEnv.getHtmlLabelName(22205,user.getLanguage())+")";//已封存
}
if(idx>0){
result.append(",");
}
String icon = "/images/treeimages/home16_wev8.gif";
if(_type == 1){
icon = "/images/treeimages/dept16_wev8.gif";
}
String isParent = "true";
if(_type == 1){
isParent = "false";
}else{
String sql2 = "select count(*) cnt from FnaCostCenter a where a.supFccId = "+Util.getIntValue(_id);
rs2.executeSql(sql2);
if(rs2.next() && rs2.getInt("cnt") > 0){
isParent = "true";
}else{
isParent = "false";
}
}
result.append("{"+
"id:"+JSONObject.quote(_typeName+"_"+_id)+","+
"id2:"+JSONObject.quote(_typeName+"_"+_id)+","+
"name:"+JSONObject.quote(_name1)+","+
"pId:"+JSONObject.quote("fccType"+"_"+_supFccId)+","+
"isParent:"+isParent+""+
//"icon:"+JSONObject.quote(icon)+
"}");
idx++;
_idList.add(_id);
}
for(int i=0;i<_idList.size();i++){
String _subId = (String)_idList.get(i);
sql1 = "WITH allsub(id,name,code,supFccId,type,Archive)\n" +
" as (\n" +
" SELECT id,name,code,supFccId,type,Archive FROM FnaCostCenter where id="+_subId+" \n" +
" UNION ALL SELECT a.id,a.name,a.code,a.supFccId,a.type,a.Archive FROM FnaCostCenter a,allsub b where a.id = b.supFccId \n" +
" ) select * from allsub tb ";
if("oracle".equals(rs1.getDBType())){
sql1 = "select id,name,code,supFccId,type,Archive \n" +
" from FnaCostCenter\n" +
" start with id="+_subId+" \n" +
" connect by prior supFccId = id";
}else if("mysql".equals(rs1.getDBType())){
sql1 = "select DISTINCT tl.lv, t.id,t.name,t.code,t.supFccId,t.type,t.Archive from (\n" +
" select @id idlist, @lv:=@lv+1 lv,\n" +
" (select @id:=group_concat(supFccId separator ',') from FnaCostCenter where find_in_set(id,@id)) sub\n" +
" from FnaCostCenter,(select @id:="+_subId+",@lv:=0) vars\n" +
" where @id is not null) tl,FnaCostCenter t\n" +
" where find_in_set(t.id,tl.idlist) \n" +
" order by tl.lv asc";
}
rs1.executeSql(sql1);
while(rs1.next()){
String _id = rs1.getString("id");
int _type = Util.getIntValue(rs1.getString("type"));
String _name = rs1.getString("name");
String _code = rs1.getString("code");
String _supFccId = rs1.getString("supFccId");
int _canceled = Util.getIntValue(rs1.getString("Archive"), 0);
if(_idList.contains(_id)){
continue;
}
String _typeName = "fccType";
if(_type == 1){
_typeName = "fcc";
}
String _name1 = _name;
if(_canceled == 1){
if(!needShowOrgIdWhenCanceled_list.contains(_id)){
continue;
}
_name1 += "("+SystemEnv.getHtmlLabelName(22205,user.getLanguage())+")";//已封存
}
if(idx>0){
result.append(",");
}
String icon = "/images/treeimages/home16_wev8.gif";
if(_type == 1){
icon = "/images/treeimages/dept16_wev8.gif";
}
String isParent = "true";
if(_type == 1){
isParent = "false";
}else{
String sql2 = "select count(*) cnt from FnaCostCenter a where a.supFccId = "+Util.getIntValue(_id);
rs2.executeSql(sql2);
if(rs2.next() && rs2.getInt("cnt") > 0){
isParent = "true";
}else{
isParent = "false";
}
}
result.append("{"+
"id:"+JSONObject.quote(_typeName+"_"+_id)+","+
"id2:"+JSONObject.quote(_typeName+"_"+_id)+","+
"name:"+JSONObject.quote(_name1)+","+
"pId:"+JSONObject.quote("fccType"+"_"+_supFccId)+","+
"isParent:"+isParent+""+
//"icon:"+JSONObject.quote(icon)+
"}");
idx++;
_idList.add(_id);
}
}
}else{//初始化组织架构树
if("".equals(id)){
id = "0_0";
}
String[] idArray = id.split("_");
int feelevel = Util.getIntValue(idArray[0], -10)+1;
id = idArray[1];
int idx = 0;
String sql1 = "select a.id, a.type, a.name, a.code, a.Archive from FnaCostCenter a "+
" where a.supFccId = "+Util.getIntValue(id)+" "+
" ORDER BY a.type, a.code, a.name, a.id ";
rs1.executeSql(sql1);
while(rs1.next()){
String _id = rs1.getString("id");
int _type = Util.getIntValue(rs1.getString("type"));
String _name = rs1.getString("name");
String _code = rs1.getString("code");
int _canceled = Util.getIntValue(rs1.getString("Archive"), 0);
if(!allowFccIdEdit && !allowFccIdTreeView_list_1.contains(_id)){
//System.out.println("continue2");
continue;
}
String _typeName = "fccType";
if(_type == 1){
_typeName = "fcc";
}
String _name1 = _name;
if(_canceled == 1){
if(!needShowOrgIdWhenCanceled_list.contains(_id)){
continue;
}
_name1 += "("+SystemEnv.getHtmlLabelName(22205,user.getLanguage())+")";//已封存
}
if(idx>0){
result.append(",");
}
String icon = "/images/treeimages/home16_wev8.gif";
if(_type == 1){
icon = "/images/treeimages/dept16_wev8.gif";
}
String isParent = "true";
if(_type == 1){
isParent = "false";
}else{
String sql2 = "select count(*) cnt from FnaCostCenter a where a.supFccId = "+Util.getIntValue(_id);
rs2.executeSql(sql2);
if(rs2.next() && rs2.getInt("cnt") > 0){
isParent = "true";
}else{
isParent = "false";
}
}
result.append("{"+
"id:"+JSONObject.quote(_typeName+"_"+_id)+","+
"id2:"+JSONObject.quote(_typeName+"_"+_id)+","+
"name:"+JSONObject.quote(_name1)+","+
"isParent:"+isParent+""+
//"icon:"+JSONObject.quote(icon)+
"}");
idx++;
}
}
}
}
//System.out.println("result="+result.toString());
%><%="["+result.toString()+"]" %>