AuditSettingLeftAjax.jsp
8.45 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
<%@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 hasPriv = HrmUserVarify.checkUserRight("FnaBudget:All", user);//预算审批设置
if(hasPriv){
String id = Util.null2String(request.getParameter("id"));
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 guid1 = Util.null2String(request.getParameter("guid1"));
String nameQuery = "";
if(!"".equals(guid1)){
nameQuery = Util.null2String(session.getAttribute("AuditSettingLeft.jsp_nameQuery_"+guid1));
}
if(!"".equals(nameQuery)){//如果是来自于快速查询
int idx = 0;
String sql1 = "select a.id, a.subcompanyname as name, a.showorder, 's' as type, a.canceled \n" +
" from HrmSubCompany a \n" +
" where a.subcompanyname like '%"+StringEscapeUtils.escapeSql(nameQuery)+"%' \n" +
" ORDER BY a.showorder, a.subcompanyname ";
rs1.executeSql(sql1);
while(rs1.next()){
String _id = rs1.getString("id");
String _name = rs1.getString("name");
String _type = rs1.getString("type");
int canceled = Util.getIntValue(rs1.getString("canceled"), 0);
//System.out.println("_id="+_id+";_name="+_name+";_type="+_type+";canceled="+canceled);
if(idx>0){
result.append(",");
}
String workflowid = "";
String workflowname = "";
String sql2 = "select a.workflowid, b.workflowname\n" +
" from BudgetAuditMapping a \n" +
" join workflow_base b on a.workflowid = b.id \n" +
" where a.subcompanyid = "+_id;
rs2.executeSql(sql2);
if(rs2.next()){
workflowid = Util.null2String(rs2.getString("workflowid")).trim();
workflowname = Util.null2String(rs2.getString("workflowname")).trim();
}
result.append("{"+
"id:"+JSONObject.quote(_type+"_"+_id)+","+
"name:"+JSONObject.quote(_name));
result.append(",isParent:false");
result.append(",icon:"+JSONObject.quote("/images/treeimages/Home_wev8.gif"));
result.append(",workflowid:"+JSONObject.quote(workflowid));
result.append(",workflowname:"+JSONObject.quote(workflowname));
result.append("}");
idx++;
}
}else if("".equals(id)){//初始化组织架构树
int idx = 0;
String sql1 = "select '0' as id, companyname as name, 'c' as type from hrmcompany";
rs1.executeSql(sql1);
while(rs1.next()){
String _id = rs1.getString("id");
String _name = rs1.getString("name");
String _type = rs1.getString("type");
if(idx>0){
result.append(",");
}
String workflowid = "";
String workflowname = "";
String sql2 = "select a.workflowid, b.workflowname\n" +
" from BudgetAuditMapping a \n" +
" join workflow_base b on a.workflowid = b.id \n" +
" where a.subcompanyid = "+_id;
rs2.executeSql(sql2);
if(rs2.next()){
workflowid = Util.null2String(rs2.getString("workflowid")).trim();
workflowname = Util.null2String(rs2.getString("workflowname")).trim();
}
result.append("{"+
"id:"+JSONObject.quote(_type+"_"+_id)+","+
"name:"+JSONObject.quote(_name));
result.append(",isParent:true");
result.append(",icon:"+JSONObject.quote("/images/treeimages/global_wev8.gif"));
result.append(",workflowid:"+JSONObject.quote(workflowid));
result.append(",workflowname:"+JSONObject.quote(workflowname));
result.append("}");
idx++;
}
}else{
String idType = id.split("_")[0];
id = id.split("_")[1];
//System.out.println("idType="+idType+";id="+id);
if("c".equalsIgnoreCase(idType)){//展开分部后,显示该目录下的下级组织架构
int idx = 0;
String sql1 = "select a.id, a.subcompanyname as name, a.showorder, 's' as type, a.canceled \n" +
" from HrmSubCompany a \n" +
" where (a.supsubcomid = 0 or a.supsubcomid = '' or a.supsubcomid is null) \n" +
//" and (a.canceled = 'N' or a.canceled = '' or a.canceled is null) \n" +
" ORDER BY a.showorder, a.subcompanyname ";
//System.out.println(sql1);
rs1.executeSql(sql1);
while(rs1.next()){
String _id = rs1.getString("id");
String _name = rs1.getString("name");
String _type = rs1.getString("type");
int canceled = Util.getIntValue(rs1.getString("canceled"), 0);
//System.out.println("_id="+_id+";_name="+_name+";_type="+_type+";canceled="+canceled);
if(idx>0){
result.append(",");
}
String isParent = "false";
String sql2 = "select count(*) cnt from HrmSubCompany a where a.supsubcomid = "+_id;
rs2.executeSql(sql2);
if(rs2.next() && rs2.getInt("cnt") > 0){
isParent = "true";
}
String workflowid = "";
String workflowname = "";
sql2 = "select a.workflowid, b.workflowname\n" +
" from BudgetAuditMapping a \n" +
" join workflow_base b on a.workflowid = b.id \n" +
" where a.subcompanyid = "+_id;
rs2.executeSql(sql2);
if(rs2.next()){
workflowid = Util.null2String(rs2.getString("workflowid")).trim();
workflowname = Util.null2String(rs2.getString("workflowname")).trim();
}
result.append("{"+
"id:"+JSONObject.quote(_type+"_"+_id)+","+
"name:"+JSONObject.quote(_name));
result.append(",isParent:"+isParent);
result.append(",icon:"+JSONObject.quote("/images/treeimages/Home_wev8.gif"));
result.append(",workflowid:"+JSONObject.quote(workflowid));
result.append(",workflowname:"+JSONObject.quote(workflowname));
result.append("}");
idx++;
}
}else if("s".equalsIgnoreCase(idType) && Util.getIntValue(id) > 0){//展开分部后,显示该目录下的下级组织架构
int idx = 0;
String sql1 = "select * from (\n" +
" select a.id, a.subcompanyname as name, a.showorder, 's' as type, a.canceled \n" +
" from HrmSubCompany a \n" +
" where a.supsubcomid = "+Util.getIntValue(id)+" \n" +
//" and (a.canceled = 'N' or a.canceled = '' or a.canceled is null) \n" +
" ) t \n" +
" ORDER BY case when (type='s') then 0 else 1 end, t.showorder, t.name ";
//System.out.println(sql1);
rs1.executeSql(sql1);
while(rs1.next()){
String _id = rs1.getString("id");
String _name = rs1.getString("name");
String _type = rs1.getString("type");
int canceled = Util.getIntValue(rs1.getString("canceled"), 0);
if(idx>0){
result.append(",");
}
result.append("{"+
"id:"+JSONObject.quote(_type+"_"+_id)+","+
"name:"+JSONObject.quote(_name));
String isParent = "false";
String sql2 = "select count(*) cnt from HrmSubCompany a where a.supsubcomid = "+_id;
rs2.executeSql(sql2);
if(rs2.next() && rs2.getInt("cnt") > 0){
isParent = "true";
}
String workflowid = "";
String workflowname = "";
sql2 = "select a.workflowid, b.workflowname\n" +
" from BudgetAuditMapping a \n" +
" join workflow_base b on a.workflowid = b.id \n" +
" where a.subcompanyid = "+_id;
rs2.executeSql(sql2);
if(rs2.next()){
workflowid = Util.null2String(rs2.getString("workflowid")).trim();
workflowname = Util.null2String(rs2.getString("workflowname")).trim();
}
result.append(",isParent:"+isParent);
result.append(",icon:"+JSONObject.quote("/images/treeimages/Home_wev8.gif"));
result.append(",workflowid:"+JSONObject.quote(workflowid));
result.append(",workflowname:"+JSONObject.quote(workflowname));
result.append("}");
idx++;
}
}
}
}
}
//System.out.println("result="+result.toString());
%><%="["+result.toString()+"]" %>