Commit 70c1b5df02fdcd86d5f51095ed1f463a13ffb63d
1 parent
eb6f1ade
Exists in
master
1
Showing
2 changed files
with
130 additions
and
103 deletions
Show diff stats
cloud/zkAttendance/src/main/java/com/sincere/att/Swagger2.java
@@ -19,10 +19,9 @@ public class Swagger2 { | @@ -19,10 +19,9 @@ public class Swagger2 { | ||
19 | public Docket createRestApi() { | 19 | public Docket createRestApi() { |
20 | return new Docket(DocumentationType.SWAGGER_2) | 20 | return new Docket(DocumentationType.SWAGGER_2) |
21 | .apiInfo(apiInfo()) | 21 | .apiInfo(apiInfo()) |
22 | - .enableUrlTemplating(true) | ||
23 | .select() | 22 | .select() |
24 | // 扫描所有有注解的api,用这种方式更灵活 | 23 | // 扫描所有有注解的api,用这种方式更灵活 |
25 | - .apis(RequestHandlerSelectors.withMethodAnnotation(ApiOperation.class)) | 24 | + .apis(RequestHandlerSelectors.basePackage("com.sincere.att.controller")) |
26 | .paths(PathSelectors.any()) | 25 | .paths(PathSelectors.any()) |
27 | .build(); | 26 | .build(); |
28 | 27 |
cloud/zkAttendance/src/main/java/com/sincere/att/controller/AttPushController.java
@@ -14,12 +14,9 @@ import com.sincere.common.dto.smartCampus.SZ_AttendanceDto; | @@ -14,12 +14,9 @@ import com.sincere.common.dto.smartCampus.SZ_AttendanceDto; | ||
14 | import com.sincere.common.dto.xiaoan.FingerDto; | 14 | import com.sincere.common.dto.xiaoan.FingerDto; |
15 | import com.sincere.common.util.DateUtils; | 15 | import com.sincere.common.util.DateUtils; |
16 | import com.sincere.common.util.HttpClientUtils; | 16 | import com.sincere.common.util.HttpClientUtils; |
17 | -import io.swagger.annotations.Api; | ||
18 | -import io.swagger.annotations.ApiOperation; | ||
19 | import org.apache.commons.lang3.StringUtils; | 17 | import org.apache.commons.lang3.StringUtils; |
20 | import org.slf4j.Logger; | 18 | import org.slf4j.Logger; |
21 | import org.springframework.beans.factory.annotation.Autowired; | 19 | import org.springframework.beans.factory.annotation.Autowired; |
22 | -import org.springframework.stereotype.Controller; | ||
23 | import org.springframework.web.bind.annotation.*; | 20 | import org.springframework.web.bind.annotation.*; |
24 | 21 | ||
25 | import javax.servlet.http.HttpServletRequest; | 22 | import javax.servlet.http.HttpServletRequest; |
@@ -35,7 +32,7 @@ import java.util.*; | @@ -35,7 +32,7 @@ import java.util.*; | ||
35 | /** | 32 | /** |
36 | * 所有的设备请求都会在url参数里携带SN,这是设备序列号(serial number的缩写),每个设备唯一标识 | 33 | * 所有的设备请求都会在url参数里携带SN,这是设备序列号(serial number的缩写),每个设备唯一标识 |
37 | */ | 34 | */ |
38 | -@Controller | 35 | +@RestController |
39 | @RequestMapping("/iclock") | 36 | @RequestMapping("/iclock") |
40 | public class AttPushController { | 37 | public class AttPushController { |
41 | private static final Logger Log_orderFail = LoggerUtils.Logger(LogName.orderFail); | 38 | private static final Logger Log_orderFail = LoggerUtils.Logger(LogName.orderFail); |
@@ -43,80 +40,80 @@ public class AttPushController { | @@ -43,80 +40,80 @@ public class AttPushController { | ||
43 | private static final Logger Log_kaoInfo = LoggerUtils.Logger(LogName.kaoInfo); | 40 | private static final Logger Log_kaoInfo = LoggerUtils.Logger(LogName.kaoInfo); |
44 | 41 | ||
45 | private static Map<String, List<String>> cmdMap = new HashMap<>(); | 42 | private static Map<String, List<String>> cmdMap = new HashMap<>(); |
46 | - private static Map<String, Integer> cmdOrderMap = new HashMap<>(); | 43 | + private static Map<String , Integer> cmdOrderMap = new HashMap<>(); |
47 | 44 | ||
48 | - private static String pwd = "22222222-6faf-48uh-a5a9-447ec68bfe2f"; | ||
49 | - private static String account = "yueqingzhijiao"; | 45 | + private static String pwd = "22222222-6faf-48uh-a5a9-447ec68bfe2f" ; |
46 | + private static String account = "yueqingzhijiao" ; | ||
50 | 47 | ||
51 | 48 | ||
52 | @Autowired | 49 | @Autowired |
53 | ScFeign scFeign; | 50 | ScFeign scFeign; |
54 | 51 | ||
55 | @Autowired | 52 | @Autowired |
56 | - XaFeign xaFeign; | 53 | + XaFeign xaFeign ; |
57 | 54 | ||
58 | - @RequestMapping(value = "sendUser/{roomId}", method = RequestMethod.GET) | ||
59 | - public void sendUser(@PathVariable int roomId) { | 55 | + @RequestMapping(value = "sendUser" , method = RequestMethod.GET) |
56 | + public void sendUser(int roomId){ | ||
60 | JSONObject object = new JSONObject(); | 57 | JSONObject object = new JSONObject(); |
61 | - object.put("PageIndex", 1); | ||
62 | - object.put("roomId", roomId); | ||
63 | - object.put("pageSize", 9999); | ||
64 | - JSONObject result = HttpClientUtils.httpPostJson("http://campus.myjxt.com/api/Room/GetListPageRoom", object.toJSONString()); | ||
65 | - JSONArray array = (JSONArray) ((JSONObject) result.get("data")).get("roomList"); | 58 | + object.put("pageIndex",1); |
59 | + object.put("roomId",roomId); | ||
60 | + object.put("pageSize",9999); | ||
61 | + JSONObject result = HttpClientUtils.httpPostJson("http://campus.myjxt.com/api/Room/GetListPageRoom",object.toJSONString()); | ||
62 | + JSONArray array = (JSONArray) ((JSONObject) result.get("data")).get("roomList") ; | ||
66 | List<String> order = new ArrayList<>(); | 63 | List<String> order = new ArrayList<>(); |
67 | List<String> attendanceList = scFeign.selectRoomAttendance(roomId); | 64 | List<String> attendanceList = scFeign.selectRoomAttendance(roomId); |
68 | - for (String attendance : attendanceList) { | ||
69 | - for (int i = 0; i < array.size(); i++) { | 65 | + for(String attendance : attendanceList){ |
66 | + for(int i = 0 ; i < array.size() ; i++){ | ||
70 | JSONObject student = (JSONObject) array.get(i); | 67 | JSONObject student = (JSONObject) array.get(i); |
71 | UserOrderVo vo = new UserOrderVo(); | 68 | UserOrderVo vo = new UserOrderVo(); |
72 | vo.setStudentId((Integer) student.get("studentid")); | 69 | vo.setStudentId((Integer) student.get("studentid")); |
73 | vo.setStudentName((String) student.get("name")); | 70 | vo.setStudentName((String) student.get("name")); |
74 | - int number = 1; | ||
75 | - try { | ||
76 | - number = cmdOrderMap.get(attendance); | ||
77 | - } catch (Exception e) { | 71 | + int number = 1 ; |
72 | + try{ | ||
73 | + number = cmdOrderMap.get(attendance) ; | ||
74 | + }catch (Exception e){ | ||
78 | 75 | ||
79 | } | 76 | } |
80 | vo.setNumber(number); | 77 | vo.setNumber(number); |
81 | - number++; | ||
82 | - cmdOrderMap.put(attendance, number); | ||
83 | - if (vo.getStudentId() != 0) { | 78 | + number++ ; |
79 | + cmdOrderMap.put(attendance,number) ; | ||
80 | + if(vo.getStudentId() != 0){ | ||
84 | order.add(vo.toString()); | 81 | order.add(vo.toString()); |
85 | } | 82 | } |
86 | } | 83 | } |
87 | - cmdMap.put(attendance, order); | 84 | + cmdMap.put(attendance,order); |
88 | } | 85 | } |
89 | } | 86 | } |
90 | 87 | ||
91 | - @RequestMapping(value = "sendFinger/{roomId}", method = RequestMethod.GET) | ||
92 | - public void sendFinger(@PathVariable int roomId) { | 88 | + @RequestMapping(value = "sendFinger" , method = RequestMethod.GET) |
89 | + public void sendFinger(int roomId){ | ||
93 | JSONObject object = new JSONObject(); | 90 | JSONObject object = new JSONObject(); |
94 | - object.put("PageIndex", 1); | ||
95 | - object.put("roomId", roomId); | ||
96 | - object.put("pageSize", 9999); | ||
97 | - JSONObject result = HttpClientUtils.httpPostJson("http://campus.myjxt.com/api/Room/GetListPageRoom", object.toJSONString()); | ||
98 | - JSONArray array = (JSONArray) ((JSONObject) result.get("data")).get("roomList"); | 91 | + object.put("PageIndex",1); |
92 | + object.put("roomId",roomId); | ||
93 | + object.put("pageSize",9999); | ||
94 | + JSONObject result = HttpClientUtils.httpPostJson("http://campus.myjxt.com/api/Room/GetListPageRoom",object.toJSONString()); | ||
95 | + JSONArray array = (JSONArray) ((JSONObject) result.get("data")).get("roomList") ; | ||
99 | List<String> order = new ArrayList<>(); | 96 | List<String> order = new ArrayList<>(); |
100 | List<String> attendanceList = scFeign.selectRoomAttendance(roomId); | 97 | List<String> attendanceList = scFeign.selectRoomAttendance(roomId); |
101 | - for (String attendance : attendanceList) { | ||
102 | - for (int i = 0; i < array.size(); i++) { | 98 | + for(String attendance : attendanceList){ |
99 | + for(int i = 0 ; i < array.size() ; i++){ | ||
103 | JSONObject student = (JSONObject) array.get(i); | 100 | JSONObject student = (JSONObject) array.get(i); |
104 | FingerOrderVo vo = new FingerOrderVo(); | 101 | FingerOrderVo vo = new FingerOrderVo(); |
105 | - int number = 1; | ||
106 | - try { | ||
107 | - number = cmdOrderMap.get(attendance); | ||
108 | - } catch (Exception e) { | 102 | + int number = 1 ; |
103 | + try{ | ||
104 | + number = cmdOrderMap.get(attendance) ; | ||
105 | + }catch (Exception e){ | ||
109 | 106 | ||
110 | } | 107 | } |
111 | vo.setNumber(number); | 108 | vo.setNumber(number); |
112 | - vo.setOrder(xaFeign.selectFinger((Integer) student.get("studentid"))); | ||
113 | - number++; | ||
114 | - cmdOrderMap.put(attendance, number); | ||
115 | - if (StringUtils.isNotBlank(vo.getOrder())) { | 109 | + vo.setOrder(xaFeign.selectFinger((Integer)student.get("studentid"))); |
110 | + number++ ; | ||
111 | + cmdOrderMap.put(attendance,number) ; | ||
112 | + if(StringUtils.isNotBlank(vo.getOrder())){ | ||
116 | order.add(vo.toString()); | 113 | order.add(vo.toString()); |
117 | } | 114 | } |
118 | } | 115 | } |
119 | - cmdMap.put(attendance, order); | 116 | + cmdMap.put(attendance,order); |
120 | } | 117 | } |
121 | } | 118 | } |
122 | 119 | ||
@@ -124,28 +121,29 @@ public class AttPushController { | @@ -124,28 +121,29 @@ public class AttPushController { | ||
124 | * 1,设备通完电以后第一个发送到后台的请求 | 121 | * 1,设备通完电以后第一个发送到后台的请求 |
125 | * 格式为 /iclock/cdata?options=all&language=xxxx&pushver=xxxx | 122 | * 格式为 /iclock/cdata?options=all&language=xxxx&pushver=xxxx |
126 | */ | 123 | */ |
127 | - @RequestMapping(value = "/cdata", params = {"options", "language", "pushver"}, method = RequestMethod.GET) | ||
128 | - public void init(String SN, String options, String language, String pushver, HttpServletRequest request, | ||
129 | - @RequestParam(required = false) String PushOptionsFlag, HttpServletResponse response) { | 124 | + @RequestMapping(value="/cdata",params = {"options","language","pushver"},method = RequestMethod.GET) |
125 | + public void init(String SN, String options, String language, String pushver, HttpServletRequest request , | ||
126 | + @RequestParam(required = false) String PushOptionsFlag, HttpServletResponse response){ | ||
130 | try { | 127 | try { |
131 | - if (cmdMap.get(SN) == null) { | ||
132 | - cmdMap.put(SN, new ArrayList<>()); | ||
133 | - cmdOrderMap.put(SN, 1); | 128 | + if(cmdMap.get(SN) == null){ |
129 | + System.out.println("设备上线:" + SN); | ||
130 | + cmdMap.put(SN,new ArrayList<>()); | ||
131 | + cmdOrderMap.put(SN,1); | ||
134 | } | 132 | } |
135 | - if (scFeign.selectAttendaceWithId(SN) == null) { | 133 | + if(scFeign.selectAttendaceWithId(SN) == null){ |
136 | SZ_AttendanceDto attendanceDto = new SZ_AttendanceDto(); | 134 | SZ_AttendanceDto attendanceDto = new SZ_AttendanceDto(); |
137 | attendanceDto.setClint_id(SN); | 135 | attendanceDto.setClint_id(SN); |
138 | attendanceDto.setClint_type("24"); | 136 | attendanceDto.setClint_type("24"); |
139 | attendanceDto.setIp(request.getRemoteAddr()); | 137 | attendanceDto.setIp(request.getRemoteAddr()); |
140 | attendanceDto.setPort(request.getRemotePort()); | 138 | attendanceDto.setPort(request.getRemotePort()); |
141 | - attendanceDto.setIntime(DateUtils.date2String(new Date(), DateUtils.format2)); | 139 | + attendanceDto.setIntime(DateUtils.date2String(new Date(),DateUtils.format2)); |
142 | attendanceDto.setSchool_id("-1"); | 140 | attendanceDto.setSchool_id("-1"); |
143 | attendanceDto.setState(1); | 141 | attendanceDto.setState(1); |
144 | scFeign.insertAttendance(attendanceDto); | 142 | scFeign.insertAttendance(attendanceDto); |
145 | - } else { | 143 | + }else { |
146 | scFeign.updateAttendance(SN); | 144 | scFeign.updateAttendance(SN); |
147 | } | 145 | } |
148 | - String initOptions = initOptions(SN, PushOptionsFlag); | 146 | + String initOptions = initOptions(SN,PushOptionsFlag); |
149 | response.getWriter().write(initOptions);//返回成功以后设备会发送心跳请求 | 147 | response.getWriter().write(initOptions);//返回成功以后设备会发送心跳请求 |
150 | } catch (IOException e) { | 148 | } catch (IOException e) { |
151 | e.printStackTrace(); | 149 | e.printStackTrace(); |
@@ -156,18 +154,19 @@ public class AttPushController { | @@ -156,18 +154,19 @@ public class AttPushController { | ||
156 | * 2,心跳请求,会从服务器拿到命令返回 给设备 | 154 | * 2,心跳请求,会从服务器拿到命令返回 给设备 |
157 | */ | 155 | */ |
158 | @RequestMapping("/getrequest") | 156 | @RequestMapping("/getrequest") |
159 | - public void heartBeat(String SN, HttpServletResponse response) { | 157 | + public void heartBeat(String SN, HttpServletResponse response){ |
160 | scFeign.updateAttendance(SN); | 158 | scFeign.updateAttendance(SN); |
161 | StringBuffer sb = new StringBuffer("OK"); | 159 | StringBuffer sb = new StringBuffer("OK"); |
162 | - List<String> cmds = cmdMap.get(SN); | ||
163 | - if (cmds == null) {//等于空说明从来没加载过,如果初始化加载过了,此时应该不为Null 只是size为0 | 160 | + List<String> cmds = cmdMap.get(SN); |
161 | + if(cmds==null){//等于空说明从来没加载过,如果初始化加载过了,此时应该不为Null 只是size为0 | ||
162 | + System.out.println("设备上线:" + SN); | ||
164 | cmds = new ArrayList<>(); | 163 | cmds = new ArrayList<>(); |
165 | - cmdMap.put(SN, cmds); | ||
166 | - cmdOrderMap.put(SN, 1); | 164 | + cmdMap.put(SN,cmds); |
165 | + cmdOrderMap.put(SN,1); | ||
167 | } | 166 | } |
168 | - if (cmds != null && cmds.size() > 0) { | ||
169 | - sb.setLength(0);//如果有命令就不返回OK了 | ||
170 | - cmds.stream().forEach(cmd -> sb.append(cmd).append("\r\n\r\n")); | 167 | + if(cmds!=null&&cmds.size()>0){ |
168 | + sb.setLength(0);//如果有命令就不返回OK了 | ||
169 | + cmds.stream().forEach(cmd->sb.append(cmd).append("\r\n\r\n")); | ||
171 | 170 | ||
172 | } | 171 | } |
173 | try { | 172 | try { |
@@ -184,8 +183,8 @@ public class AttPushController { | @@ -184,8 +183,8 @@ public class AttPushController { | ||
184 | * 这个请求,服务器只能返回OK,不可以返回命令 | 183 | * 这个请求,服务器只能返回OK,不可以返回命令 |
185 | */ | 184 | */ |
186 | @RequestMapping("/ping") | 185 | @RequestMapping("/ping") |
187 | - public void ping(HttpServletResponse response) { | ||
188 | - System.out.println("考勤机心跳请求大量进来了......ping" + new SimpleDateFormat("HH:mm:ss").format(new Date())); | 186 | + public void ping(HttpServletResponse response){ |
187 | + System.out.println("考勤机心跳请求大量进来了......ping"+new SimpleDateFormat("HH:mm:ss").format(new Date())); | ||
189 | try { | 188 | try { |
190 | response.getWriter().write("OK"); | 189 | response.getWriter().write("OK"); |
191 | } catch (IOException e) { | 190 | } catch (IOException e) { |
@@ -197,20 +196,20 @@ public class AttPushController { | @@ -197,20 +196,20 @@ public class AttPushController { | ||
197 | * 4,设备端处理完命令以后会发送该请求,告诉服务器命令的处理结果 | 196 | * 4,设备端处理完命令以后会发送该请求,告诉服务器命令的处理结果 |
198 | */ | 197 | */ |
199 | @RequestMapping("/devicecmd") | 198 | @RequestMapping("/devicecmd") |
200 | - public void handleCmd(String SN, @RequestBody String data, HttpServletResponse response) { | 199 | + public void handleCmd(String SN, @RequestBody String data, HttpServletResponse response){ |
201 | //判断data 清空map | 200 | //判断data 清空map |
202 | List<String> cmdList = cmdMap.get(SN); | 201 | List<String> cmdList = cmdMap.get(SN); |
203 | String[] returnList = data.split("\n"); | 202 | String[] returnList = data.split("\n"); |
204 | - if (returnList.length > 0 && cmdList.size() > 0) { | ||
205 | - for (String message : returnList) { | ||
206 | - String number = message.substring(message.indexOf("=") + 1, message.indexOf("&")); | ||
207 | - String result = message.substring(message.indexOf("=", message.indexOf("&")) + 1, message.indexOf("&", message.indexOf("&") + 1)); | ||
208 | - if (result.equals("0")) { | 203 | + if(returnList.length > 0 && cmdList.size() > 0){ |
204 | + for(String message : returnList){ | ||
205 | + String number = message.substring(message.indexOf("=")+1,message.indexOf("&")); | ||
206 | + String result = message.substring(message.indexOf("=",message.indexOf("&"))+1,message.indexOf("&",message.indexOf("&")+1)); | ||
207 | + if(result.equals("0")){ | ||
209 | Iterator<String> it = cmdList.iterator(); | 208 | Iterator<String> it = cmdList.iterator(); |
210 | while (((Iterator) it).hasNext()) { | 209 | while (((Iterator) it).hasNext()) { |
211 | String b = it.next(); | 210 | String b = it.next(); |
212 | - if (b.contains("C:" + number)) { | ||
213 | - Log_orderSuccess.info("指令成功==========" + b); | 211 | + if (b.contains("C:"+number)) { |
212 | + Log_orderSuccess.info("指令成功=========="+b); | ||
214 | it.remove(); | 213 | it.remove(); |
215 | } | 214 | } |
216 | } | 215 | } |
@@ -233,46 +232,50 @@ public class AttPushController { | @@ -233,46 +232,50 @@ public class AttPushController { | ||
233 | request.setCharacterEncoding("gbk"); | 232 | request.setCharacterEncoding("gbk"); |
234 | String data = ""; | 233 | String data = ""; |
235 | ByteArrayOutputStream bos = null; | 234 | ByteArrayOutputStream bos = null; |
236 | - byte[] b = new byte[1024]; | 235 | + byte[] b= new byte[1024]; |
237 | try { | 236 | try { |
238 | InputStream is = request.getInputStream(); | 237 | InputStream is = request.getInputStream(); |
239 | bos = new ByteArrayOutputStream(); | 238 | bos = new ByteArrayOutputStream(); |
240 | int len = 0; | 239 | int len = 0; |
241 | - while ((len = is.read(b)) != -1) { | ||
242 | - bos.write(b, 0, len); | 240 | + while((len=is.read(b))!=-1){ |
241 | + bos.write(b,0,len); | ||
243 | } | 242 | } |
244 | - data = new String(bos.toByteArray(), "gbk"); | 243 | + data = new String(bos.toByteArray(),"gbk"); |
245 | } catch (IOException e) { | 244 | } catch (IOException e) { |
246 | e.printStackTrace(); | 245 | e.printStackTrace(); |
247 | } | 246 | } |
248 | - if ("ATTLOG".equals(table)) { | 247 | + if("ATTLOG".equals(table)){ |
249 | String[] list = data.split("\t"); | 248 | String[] list = data.split("\t"); |
250 | String cardNo = scFeign.selectStudentNumByStudentId(Integer.valueOf(list[0])); | 249 | String cardNo = scFeign.selectStudentNumByStudentId(Integer.valueOf(list[0])); |
251 | - cardNo = new BigInteger(cardNo, 16).toString(); | ||
252 | - //考勤日志 | ||
253 | - SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); | ||
254 | - String info = String.format("<AttendanceInfo submitTime=\"%s\"><Info device=\"%s\" card=\"%s\" operTime=\"%s\" direc=\"%s\"></Info></AttendanceInfo>", | ||
255 | - simpleDateFormat.format(new Date()), SN, cardNo, list[1], "-1"); | ||
256 | - AttendanceInfoBean attendanceInfoBean = new AttendanceInfoBean(); | ||
257 | - attendanceInfoBean.setInfo(info); | ||
258 | - attendanceInfoBean.setIsControl(0); | ||
259 | - attendanceInfoBean.setPwd(pwd); | ||
260 | - attendanceInfoBean.setUsername(account); | 250 | + if(StringUtils.isNotBlank(cardNo)){ |
251 | + String cardNo10 = new BigInteger(cardNo, 16).toString(); | ||
252 | + //考勤日志 | ||
253 | + SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); | ||
254 | + String info = String.format("<AttendanceInfo submitTime=\"%s\"><Info device=\"%s\" card=\"%s\" operTime=\"%s\" direc=\"%s\"></Info></AttendanceInfo>", | ||
255 | + simpleDateFormat.format(new Date()), SN, cardNo10, list[1], "-1"); | ||
256 | + AttendanceInfoBean attendanceInfoBean = new AttendanceInfoBean(); | ||
257 | + attendanceInfoBean.setInfo(info); | ||
258 | + attendanceInfoBean.setIsControl(0); | ||
259 | + attendanceInfoBean.setPwd(pwd); | ||
260 | + attendanceInfoBean.setUsername(account); | ||
261 | 261 | ||
262 | - String jsonResult = JSON.toJSONString(attendanceInfoBean); | ||
263 | - String urlHXY = "http://campus.myjxt.com/api/XiaoAnCommon/SendHXY"; | ||
264 | - JSONObject jsonObject = HttpClientUtils.httpPostJson(urlHXY, jsonResult); | ||
265 | - if ((int) jsonObject.get("status") == 1) { | ||
266 | - Log_kaoInfo.info("出入寝签到成功:" + SN + " 卡号:" + cardNo); | ||
267 | - } else { | ||
268 | - Log_orderFail.info("出入寝签到失败:" + SN + " 卡号:" + cardNo + " result1:" + jsonObject.toJSONString()); | 262 | + String jsonResult = JSON.toJSONString(attendanceInfoBean); |
263 | + String urlHXY = "http://campus.myjxt.com/api/XiaoAnCommon/SendHXY"; | ||
264 | + JSONObject jsonObject = HttpClientUtils.httpPostJson(urlHXY, jsonResult); | ||
265 | + if ((int) jsonObject.get("status") == 1){ | ||
266 | + Log_kaoInfo.info("出入寝签到成功:" + SN + " 卡号:" + cardNo); | ||
267 | + }else { | ||
268 | + Log_orderFail.info("出入寝签到失败:" + SN + " 卡号:" + cardNo + " result1:" + jsonObject.toJSONString()); | ||
269 | + } | ||
270 | + }else { | ||
271 | + System.out.println(cardNo); | ||
269 | } | 272 | } |
270 | } | 273 | } |
271 | - if ("OPERLOG".equals(table)) { | 274 | + if("OPERLOG".equals(table)){ |
272 | //操作日志 | 275 | //操作日志 |
273 | - if (data.substring(0, 3).contains("FP")) { | 276 | + if(data.substring(0,3).contains("FP")){ |
274 | //添加指纹 | 277 | //添加指纹 |
275 | - String studentId = data.substring(data.indexOf("=") + 1, data.indexOf("\t", data.indexOf("="))); | 278 | + String studentId = data.substring(data.indexOf("=")+1,data.indexOf("\t",data.indexOf("="))); |
276 | String order = data.substring(3); | 279 | String order = data.substring(3); |
277 | FingerDto fingerDto = new FingerDto(); | 280 | FingerDto fingerDto = new FingerDto(); |
278 | fingerDto.setOrderMsg(order); | 281 | fingerDto.setOrderMsg(order); |
@@ -288,16 +291,40 @@ public class AttPushController { | @@ -288,16 +291,40 @@ public class AttPushController { | ||
288 | } | 291 | } |
289 | } | 292 | } |
290 | 293 | ||
294 | + public static void main(String[] args){ | ||
295 | + String cardNo = "FF013E0F" ; | ||
296 | + String SN = "A4JS174260624" ; | ||
297 | + String cardNo10 = new BigInteger(cardNo, 16).toString(); | ||
298 | + //考勤日志 | ||
299 | + SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); | ||
300 | + String info = String.format("<AttendanceInfo submitTime=\"%s\"><Info device=\"%s\" card=\"%s\" operTime=\"%s\" direc=\"%s\"></Info></AttendanceInfo>", | ||
301 | + simpleDateFormat.format(new Date()), SN, cardNo10, DateUtils.date2String(new Date(),DateUtils.format2), "-1"); | ||
302 | + AttendanceInfoBean attendanceInfoBean = new AttendanceInfoBean(); | ||
303 | + attendanceInfoBean.setInfo(info); | ||
304 | + attendanceInfoBean.setIsControl(0); | ||
305 | + attendanceInfoBean.setPwd(pwd); | ||
306 | + attendanceInfoBean.setUsername(account); | ||
307 | + | ||
308 | + String jsonResult = JSON.toJSONString(attendanceInfoBean); | ||
309 | + String urlHXY = "http://campus.myjxt.com/api/XiaoAnCommon/SendHXY"; | ||
310 | + JSONObject jsonObject = HttpClientUtils.httpPostJson(urlHXY, jsonResult); | ||
311 | + if ((int) jsonObject.get("status") == 1){ | ||
312 | + Log_kaoInfo.info("出入寝签到成功:" + SN + " 卡号:" + cardNo); | ||
313 | + }else { | ||
314 | + Log_orderFail.info("出入寝签到失败:" + SN + " 卡号:" + cardNo + " result1:" + jsonObject.toJSONString()); | ||
315 | + } | ||
316 | + } | ||
317 | + | ||
318 | + | ||
291 | /** | 319 | /** |
292 | * 设备通电以后连接到服务器,需要返回的初始化参数 | 320 | * 设备通电以后连接到服务器,需要返回的初始化参数 |
293 | - * | ||
294 | * @param sn | 321 | * @param sn |
295 | * @param PushOptionsFlag | 322 | * @param PushOptionsFlag |
296 | * @return | 323 | * @return |
297 | */ | 324 | */ |
298 | - private String initOptions(String sn, String PushOptionsFlag) { | 325 | + private String initOptions(String sn,String PushOptionsFlag) { |
299 | StringBuffer devOptions = new StringBuffer(); | 326 | StringBuffer devOptions = new StringBuffer(); |
300 | - devOptions.append("GET OPTION FROM: " + sn); | 327 | + devOptions.append("GET OPTION FROM: "+sn); |
301 | // + "\nStamp=" + devInfo.devInfoJson.getString("Stamp") | 328 | // + "\nStamp=" + devInfo.devInfoJson.getString("Stamp") |
302 | devOptions.append("\nATTLOGStamp=0"); | 329 | devOptions.append("\nATTLOGStamp=0"); |
303 | devOptions.append("\nOPERLOGStamp=0"); | 330 | devOptions.append("\nOPERLOGStamp=0"); |
@@ -321,8 +348,9 @@ public class AttPushController { | @@ -321,8 +348,9 @@ public class AttPushController { | ||
321 | // 11 工作号码 | 348 | // 11 工作号码 |
322 | // 12 比对照片 | 349 | // 12 比对照片 |
323 | devOptions.append("\nTransFlag=111111111111");// 1-12二进制位 分别代表以上含义 | 350 | devOptions.append("\nTransFlag=111111111111");// 1-12二进制位 分别代表以上含义 |
324 | - System.out.println("PushOptionsFlag=============" + PushOptionsFlag); | ||
325 | - if (PushOptionsFlag != null && PushOptionsFlag.equals("1")) { | 351 | + System.out.println("PushOptionsFlag============="+PushOptionsFlag); |
352 | + if (PushOptionsFlag!=null&&PushOptionsFlag.equals("1")) | ||
353 | + { | ||
326 | // 支持参数单独获取的才要把需要获取的参数回传给设备 modifeid by max 20170926 | 354 | // 支持参数单独获取的才要把需要获取的参数回传给设备 modifeid by max 20170926 |
327 | devOptions.append("\nPushOptions=RegDeviceType,FingerFunOn,FaceFunOn,FPVersion,FaceVersion,NetworkType,HardwareId3,HardwareId5,HardwareId56,LicenseStatus3,LicenseStatus5,LicenseStatus56"); | 355 | devOptions.append("\nPushOptions=RegDeviceType,FingerFunOn,FaceFunOn,FPVersion,FaceVersion,NetworkType,HardwareId3,HardwareId5,HardwareId56,LicenseStatus3,LicenseStatus5,LicenseStatus56"); |
328 | } | 356 | } |