indexTreeLeftXML.jsp
5.86 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
<%@ page language="java" contentType="text/html; charset=UTF-8" %>
<%@ page import="weaver.systeminfo.SystemEnv" %>
<%@ page import="weaver.hrm.HrmUserVarify" %>
<%@ page import="weaver.hrm.User" %>
<%@ page import="weaver.general.Util" %>
<%@ page import="net.sf.json.*"%>
<%@ page import="weaver.common.util.xtree.TreeNode" %>
<%@page import="java.net.URLDecoder"%>
<%@page import="java.util.Map"%>
<%@page import="java.util.HashMap"%>
<%@page import="weaver.hrm.job.JobTitlesTempletComInfo"%>
<%@page import="weaver.hrm.job.JobActivitiesComInfo"%>
<jsp:useBean id="JobGroupsComInfo" class="weaver.hrm.job.JobGroupsComInfo" scope="page" /><jsp:useBean id="JobActivitiesComInfo" class="weaver.hrm.job.JobActivitiesComInfo" scope="page" /><jsp:useBean id="JobTitlesTempletComInfo" class="weaver.hrm.job.JobTitlesTempletComInfo" scope="page" />
<%!
private boolean hasChild(String id, String cmd) throws Exception {
boolean hasChild = false;
if(cmd.equals("jobgroup")){
weaver.hrm.job.JobActivitiesComInfo JobActivitiesComInfo = new weaver.hrm.job.JobActivitiesComInfo();
JobActivitiesComInfo.setTofirstRow();
while(JobActivitiesComInfo.next()){
if(JobActivitiesComInfo.getJobgroupid().equals(id)){
hasChild = true;
break;
}
}
}else if(cmd.equals("jobactivites")){
weaver.hrm.job.JobTitlesTempletComInfo JobTitlesTempletComInfo = new weaver.hrm.job.JobTitlesTempletComInfo();
JobTitlesTempletComInfo.setTofirstRow();
while(JobTitlesTempletComInfo.next()){
if(JobTitlesTempletComInfo.getJobactivityid().equals(id)){
hasChild = true;
break;
}
}
}
return hasChild;
}
private Map getTree3(String condition) throws Exception {
Map tree3 = new HashMap();
//第三级
JobTitlesTempletComInfo templet = new JobTitlesTempletComInfo();
templet.setTofirstRow();
while(templet.next()){
String curjobactiviteid = templet.getJobactivityid();
String name=templet.getJobTitlesmark();
String id = templet.getJobTitlesid();
if(!name.contains(condition)){
continue;
}
tree3.put(curjobactiviteid,curjobactiviteid);
}
return tree3;
}
private Map getTree2(String condition) throws Exception {
Map tree2 = new HashMap();
//第二级
JobActivitiesComInfo activities = new JobActivitiesComInfo();
activities.setTofirstRow();
while(activities.next()){
String curgroupid = activities.getJobgroupid();
String name=activities.getJobActivitiesname();
String id = activities.getJobActivitiesid();
if(!name.contains(condition)){
continue;
}
tree2.put(curgroupid,curgroupid);
}
return tree2;
}
%>
<%
response.setHeader("cache-control", "no-cache");
response.setHeader("pragma", "no-cache");
response.setHeader("expires", "Mon 1 Jan 1990 00:00:00 GMT");
User user = HrmUserVarify.getUser(request,response);
if(user == null) return ;
String condition=Util.null2String(request.getParameter("condition"));
condition = condition==null?"":URLDecoder.decode(condition,"UTF-8");
System.out.println("前台传过来的参数:" + condition);//输出结果:来自前台我不是乱码
String jobgroup=Util.null2String(request.getParameter("jobgroup"));
if(jobgroup.equals("0")) jobgroup="";
String jobactivite=Util.null2String(request.getParameter("jobactivite"));
if(jobactivite.equals("0")) jobactivite="";
%>
<%
TreeNode envelope=new TreeNode();
envelope.setTitle("envelope");
StringBuffer treeStr = new StringBuffer();
JSONArray jObject = null;
Map tree3 = new HashMap();
Map tree2 = new HashMap();
Map tree1 = new HashMap();
if(!"".equals(jobactivite)){
//第三级
JobTitlesTempletComInfo.setTofirstRow();
while(JobTitlesTempletComInfo.next()){
treeStr = new StringBuffer();
String curjobactiviteid = JobTitlesTempletComInfo.getJobactivityid();
if(!curjobactiviteid.equals(jobactivite))continue;
String name=JobTitlesTempletComInfo.getJobTitlesmark();
String id = JobTitlesTempletComInfo.getJobTitlesid();
if(!name.contains(condition)){
continue;
}
tree3.put(curjobactiviteid,curjobactiviteid);
TreeNode node=new TreeNode();
node.setTitle(name);
node.setValue(id);
node.setNodeId("jobtitlestemplet_"+id);
node.setHref("javascript:onClickJobGroup(" + id + ")");
node.setTarget("_self");
envelope.addTreeNode(node);
}
}else if(!"".equals(jobgroup)){
//第二级
JobActivitiesComInfo.setTofirstRow();
while(JobActivitiesComInfo.next()){
treeStr = new StringBuffer();
String curgroupid = JobActivitiesComInfo.getJobgroupid();
if(!curgroupid.equals(jobgroup))continue;
String name=JobActivitiesComInfo.getJobActivitiesname();
String id = JobActivitiesComInfo.getJobActivitiesid();
if(!name.contains(condition)){
if(tree3.isEmpty()){
tree3 = getTree3(condition);
}
if(tree3.get(id) == null){
continue;
}
}
tree2.put(curgroupid,curgroupid);
TreeNode node=new TreeNode();
node.setTitle(name);
node.setValue(id);
node.setNodeId("jobactivities_"+id);
node.setHref("javascript:onClickJobGroup(" + id + ")");
node.setTarget("_self");
if (hasChild(id, "jobactivites")) {
node.setNodeXmlSrc("indexTreeLeftXML.jsp?jobactivite=" + id);
}
envelope.addTreeNode(node);
}
}else if("".equals(jobgroup)){
JobGroupsComInfo.setTofirstRow();
while(JobGroupsComInfo.next()){
String name=JobGroupsComInfo.getJobGroupsname();
String id = JobGroupsComInfo.getJobGroupsid();
if(!name.contains(condition)){
if(tree2.get(id) == null){
continue;
}
}
tree1.put(id,id);
TreeNode node=new TreeNode();
node.setTitle(name);
node.setValue(id);
node.setNodeId("jobgroup_"+id);
node.setHref("javascript:onClickJobGroup(" + id + ")");
node.setTarget("_self");
if (hasChild(id, "jobgroup")) {
node.setNodeXmlSrc("indexTreeLeftXML.jsp?jobgroup=" + id);
}
envelope.addTreeNode(node);
}
}
if(tree3.isEmpty() && tree2.isEmpty() && tree1.isEmpty()){
}else{
weaver.common.util.string.StringUtil.parseXml(out, envelope);
}
%>