Area_json.jsp
6.39 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
<%@ page import="weaver.general.Util" %>
<%@ page import="weaver.hrm.*" %>
<%@ page import="net.sf.json.*"%>
<%@ page language="java" contentType="text/html; charset=UTF-8" %>
<%@page import="java.util.ArrayList"%>
<%@page import="weaver.hrm.country.CountryComInfo"%>
<%@page import="weaver.hrm.province.ProvinceComInfo"%>
<%@page import="weaver.hrm.city.CityComInfo"%>
<%@page import="weaver.hrm.city.CitytwoComInfo"%>
<%@page import="java.util.Map"%>
<%@page import="java.util.HashMap"%>
<%@page import="weaver.systeminfo.SystemEnv"%>
<%!
public ArrayList getCountryTreeList() throws Exception {
ArrayList list = new ArrayList();
CountryComInfo rs = new CountryComInfo();
rs.setTofirstRow();
while (rs.next()) {
String id = rs.getCountryid();
String name = rs.getCountryname();
if(Util.null2String(rs.getCountryiscanceled()).equals("1")){
continue;
}
Map map = new HashMap();
map.put("id",id);
map.put("name",name);
map.put("type","country");
list.add(map);
}
return list;
}
public ArrayList getProvinceTreeList(String subId) throws Exception {
ArrayList list = new ArrayList();
ProvinceComInfo rs = new ProvinceComInfo();
rs.setTofirstRow();
while (rs.next()) {
if (rs.getProvincecountryid().equals(subId) && !"1".equals(rs.getProvinceiscanceled())){
String id = rs.getProvinceid();
String name = rs.getProvincename();
Map map = new HashMap();
map.put("id",id);
map.put("name",name);
map.put("type","province");
list.add(map);
}
}
return list;
}
public ArrayList getCityTreeList(String subId) throws Exception {
ArrayList list = new ArrayList();
CityComInfo rs = new CityComInfo();
rs.setTofirstRow();
while (rs.next()) {
if (rs.getCityprovinceid().equals(subId) && !"1".equals(rs.getCitycanceled())){
String id = rs.getCityid();
String name = rs.getCityname();
Map map = new HashMap();
map.put("id",id);
map.put("name",name);
map.put("type","city");
list.add(map);
}
}
return list;
}
public ArrayList getCityTwoTreeList(String subId) throws Exception {
ArrayList list = new ArrayList();
CitytwoComInfo rs = new CitytwoComInfo();
rs.setTofirstRow();
while (rs.next()) {
if (rs.getCitypid().equals(subId) && !"1".equals(rs.getCitycanceled())){
String id = rs.getCityid();
String name = rs.getCityname();
Map map = new HashMap();
map.put("id",id);
map.put("name",name);
map.put("type","citytwo");
list.add(map);
}
}
return list;
}
/**
* 指定节点下是否有子节点
* @param type com:分部;dept:部门
* @param id 节点id
* @return boolean
* @throws Exception
*/
private int hasChild(String type, String id) throws Exception {
int hasChild = 0;
if (type.equals("country")) {
ProvinceComInfo rs = new ProvinceComInfo();
rs.setTofirstRow();
while (rs.next()) {
if (rs.getProvincecountryid().equals(id) && !"1".equals(rs.getProvinceiscanceled()))
hasChild++;
}
} else if (type.equals("province")) {
CityComInfo rs = new CityComInfo();
rs.setTofirstRow();
while (rs.next()) {
if ( rs.getCityprovinceid().equals(id) && !"1".equals(rs.getCitycanceled()))
hasChild++;
}
}else if (type.equals("city")) {
CitytwoComInfo rs = new CitytwoComInfo();
rs.setTofirstRow();
while (rs.next()) {
if ( rs.getCitypid().equals(id) && !"1".equals(rs.getCitycanceled()))
hasChild++;
}
}
return hasChild;
}
%>
<%
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 id=Util.null2String(request.getParameter("id"));
String type=Util.null2String(request.getParameter("type"));
String opt=Util.null2String(request.getParameter("opt"));
ArrayList selectList = new ArrayList();
JSONArray jObject = null;
if(opt.equals("findSubid")){
CountryComInfo counrs = new CountryComInfo();
ProvinceComInfo provincers = new ProvinceComInfo();
if(type.equals("province")){
String countryId = provincers.getProvincecountryid(id);
Map map = new HashMap();
map.put("id",countryId);
map.put("name",counrs.getCountryname(countryId));
map.put("type","country");
selectList.add(map);
}else if(type.equals("city")){
CityComInfo rs = new CityComInfo();
String countryId = rs.getCitycountryid(id);
Map map = new HashMap();
map.put("id",countryId);
map.put("name",counrs.getCountryname(countryId));
map.put("type","country");
selectList.add(map);
Map map2 = new HashMap();
String provinceid = rs.getCityprovinceid(id);
map2.put("id",provinceid);
map2.put("name",provincers.getProvincename(provinceid));
map2.put("type","province");
selectList.add(map2);
}else if(type.equals("citytwo")){
CitytwoComInfo rs = new CitytwoComInfo();
String citypid=rs.getCitypid(id);
CityComInfo rs1 = new CityComInfo();
String countryId = rs1.getCitycountryid(citypid);
Map map = new HashMap();
map.put("id",countryId);
map.put("name",counrs.getCountryname(countryId));
map.put("type","country");
selectList.add(map);
Map map2 = new HashMap();
String provinceid = rs1.getCityprovinceid(citypid);
map2.put("id",provinceid);
map2.put("name",provincers.getProvincename(provinceid));
map2.put("type","province");
selectList.add(map2);
Map map3 = new HashMap();
map3.put("id",citypid);
map3.put("name",rs1.getCityname(citypid));
map3.put("type","city");
selectList.add(map3);
}
jObject = JSONArray.fromObject(selectList);
out.println(jObject.toString());
}else if("getTitle".equals(opt)){
Map map = new HashMap();
map.put("countryName",SystemEnv.getHtmlLabelName(377,user.getLanguage()));
map.put("provinceName",SystemEnv.getHtmlLabelName(800,user.getLanguage()));
map.put("cityName",SystemEnv.getHtmlLabelName(493,user.getLanguage()));
map.put("district",SystemEnv.getHtmlLabelName(81764,user.getLanguage()));
selectList.add(map);
jObject = JSONArray.fromObject(selectList);
out.println(jObject.toString());
}else{
if(id.equals("")){
//初始化
selectList=getCountryTreeList();
}else if(type.equals("country")){
selectList=getProvinceTreeList(id);
}else if(type.equals("province")){
selectList=getCityTreeList(id);
}else if(type.equals("city")){
selectList=getCityTwoTreeList(id);
}
jObject = JSONArray.fromObject(selectList);
out.println(jObject.toString());
}
%>