182d317424bd72a4b3540118e02d63b59e621b72.svn-base
5.44 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
package com.thinkgem.jeesite.modules.reg.web.httprest.utils;
import java.io.InputStreamReader;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Random;
import java.util.UUID;
import java.util.regex.Pattern;
import javax.servlet.http.HttpServletRequest;
import org.json.JSONObject;
import org.json.XML;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.google.common.collect.Lists;
import com.thinkgem.jeesite.common.config.Global;
import com.thinkgem.jeesite.common.utils.DateUtils;
import com.thinkgem.jeesite.common.utils.JsonUtil;
import com.thinkgem.jeesite.common.utils.StringUtils;
import com.thinkgem.jeesite.modules.restQydm.restQydmInterfaceService;
import com.thinkgem.jeesite.modules.sys.utils.DictUtils;
public class DatatypeUtil {
private static Logger logger = LoggerFactory.getLogger(DatatypeUtil.class);
public static Boolean isInteger(String str) {
Pattern pattern = Pattern.compile("^[-\\+]?[\\d]*$");
return pattern.matcher(str).matches();
}
/**
* 请求接受 2018-11-11
*/
public static String reqReceive(HttpServletRequest request) {
// 接收请求
String reqjson = "";
try {
InputStreamReader reader = new InputStreamReader(request.getInputStream(), "utf-8");
char[] buff = new char[20480];
int length = 0;
while ((length = reader.read(buff)) != -1) {
String str = new String(buff, 0, length);
logger.info("接收到{}的字符串信息:{}",length,str);
reqjson += str;
}
// base64 解码
// reqjson = Base64.decodeStr(reqjson,"utf-8");
} catch (Exception e) {
e.printStackTrace();
}
return reqjson;
}
public static Map readXml(String xml_str) {
List<Map> rows = Lists.newArrayList();
JSONObject xml = XML.toJSONObject(xml_str);
Map xml_map = JsonUtil.jsonToMap(xml.toString());
Map root = xml_map.get("Root") == null ? null : (Map) xml_map.get("Root");
return root;
}
public static List<Map> getRows(Map root) {
List<Map> rows = Lists.newArrayList();
Map recordSet = root.get("RecordSet") == null ? null : (Map) root.get("RecordSet");
Object row_obj = recordSet.get("Row");
if (row_obj instanceof Map) {
Map row = (Map) row_obj;
rows.add(row);
} else if (row_obj instanceof List) {
rows = (List) row_obj;
}
return rows;
}
public static Map getHead(Map root) {
return root.get("Head") == null ? null : (Map) root.get("Head");
}
public static Boolean validateSxh(List<Integer> lst) {
Collections.sort(lst);
Integer i = 1;
for (Integer sxh : lst) {
if (!i.equals(sxh)) {
return false;
}
i++;
}
return true;
}
public static Boolean validateGyqk(String gyfs, String gyqk) {
String c_gyqk = DictUtils.getDictLabel(gyfs, "reg_bus_gyfs", "");
System.out.println(c_gyqk + " *** " + gyqk);
return c_gyqk.equals(gyqk);
}
public static Boolean isDate(String str) {
try {
DateUtils.parseDate(str);
} catch (Exception e) {
return false;
}
return true;
}
public static String getYwztMc(String taskey) {
String areaCode = Global.getAreaCode();
String audit = "";
switch (taskey) {
case "reg_start":
audit = "受理";
break;
case "reg_audit":
if ("610702".equals(areaCode) || "610725".equals(areaCode) || "610721".equals(areaCode)
|| "610727".equals(areaCode) || "610728".equals(areaCode)) {
audit = "审核";
} else {
audit = "初审";
}
break;
case "reg_audit2":
if (!"610702".equals(areaCode) && !"610725".equals(areaCode) && !"610721".equals(areaCode)
&& !"610727".equals(areaCode) || "610728".equals(areaCode)) {
audit = "复审";
}
break;
case "reg_audit3":
audit = "核定";
break;
case "reg_audit4":
audit = "登簿";
break;
case "reg_audit5":
audit = "缮证";
break;
case "reg_audit56":
audit = "收费";
break;
case "reg_audit6":
audit = "发证";
break;
case "reg_end":
audit = "归档";
break;
default:
break;
}
return audit;
}
public static String getValueByMap(Map map, String key, String value) {
return map.get(key) == null ? value : map.get(key).toString();
}
public static Boolean isYcslBuss(String djlx) {
switch (djlx) {
case "207":
case "302":
case "402":
case "403":
case "404":
case "416":
case "428":
case "431":
case "213":
case "214":
case "215":
case "316":
case "317":
case "318":
case "433":
case "509":
case "515":
case "606":
case "608":
case "818":
case "505":
case "506":
case "510":
case "511":
case "512":
case "513":
case "607":
case "609":
case "803":
case "804":
case "806":
case "807":
case "809":
case "810":
case "811":
case "812":
case "819":
case "604":
case "1003":
case "1004":
case "703":
case "704":
case "902":
case "903":
case "905":
case "906":
case "907":
case "908":
case "910":
case "912":
case "427":
case "422":
case "432":
return true;
default:
return false;
}
}
public static String randomName(String hz) {
Random r = new Random(99);
String uuid = UUID.randomUUID().toString().replace("-", "").toLowerCase();
int ran1 = r.nextInt(10000);
return uuid+ran1+"."+hz;
}
/**
* 输出异常信息
*
* @param e
* @return
*/
public static String errorTrackSpace(Exception e) {
StringBuffer sb = new StringBuffer();
if (e != null) {
for (StackTraceElement element : e.getStackTrace()) {
sb.append("\r\n\t").append(element);
}
}
return sb.length() == 0 ? null : sb.toString();
}
}