Commit f6c2934ebcb6a58efdd2f3a213647c6ba4350c1c
1 parent
8c4743b8
Exists in
master
大华设备对接艺校考勤
Showing
14 changed files
with
456 additions
and
170 deletions
Show diff stats
cloud/dahua/src/main/java/com/example/dahua/MyTask.java
@@ -220,6 +220,9 @@ public class MyTask implements ApplicationRunner { | @@ -220,6 +220,9 @@ public class MyTask implements ApplicationRunner { | ||
220 | String deviceId = ""; | 220 | String deviceId = ""; |
221 | try { | 221 | try { |
222 | deviceId = new String(buffer1, "GBK").trim(); | 222 | deviceId = new String(buffer1, "GBK").trim(); |
223 | + log.info("设备GBK心跳:" + deviceId); | ||
224 | + deviceId = new String(buffer1, "UTF-8").trim(); | ||
225 | + log.info("设备UTF-8心跳:" + deviceId); | ||
223 | } catch (UnsupportedEncodingException e) { | 226 | } catch (UnsupportedEncodingException e) { |
224 | e.printStackTrace(); | 227 | e.printStackTrace(); |
225 | } | 228 | } |
cloud/dahua/src/main/java/com/example/dahua/async/SendUserInfoTask2.java
@@ -25,6 +25,7 @@ import org.springframework.util.StringUtils; | @@ -25,6 +25,7 @@ import org.springframework.util.StringUtils; | ||
25 | 25 | ||
26 | import java.io.File; | 26 | import java.io.File; |
27 | import java.text.SimpleDateFormat; | 27 | import java.text.SimpleDateFormat; |
28 | +import java.util.ArrayList; | ||
28 | import java.util.Calendar; | 29 | import java.util.Calendar; |
29 | import java.util.Date; | 30 | import java.util.Date; |
30 | import java.util.List; | 31 | import java.util.List; |
@@ -183,10 +184,11 @@ public class SendUserInfoTask2 { | @@ -183,10 +184,11 @@ public class SendUserInfoTask2 { | ||
183 | String studentId = userInfoBean.getStudent_id(); | 184 | String studentId = userInfoBean.getStudent_id(); |
184 | //学生卡号 | 185 | //学生卡号 |
185 | String studentNum = userInfoBean.getStudent_num(); | 186 | String studentNum = userInfoBean.getStudent_num(); |
187 | + //班级ID | ||
188 | + String classId = userInfoBean.getClass_id(); | ||
189 | + Integer studentType = userInfoBean.getStudent_type(); | ||
186 | //学生姓名 | 190 | //学生姓名 |
187 | String userName = userInfoBean.getName(); | 191 | String userName = userInfoBean.getName(); |
188 | - //设备类型:默认为大华人脸机 | ||
189 | - int deviceType = EnumDeviceType.DH_FACE.deviceType; | ||
190 | 192 | ||
191 | int userType2 = Integer.parseInt(userType); | 193 | int userType2 = Integer.parseInt(userType); |
192 | //下发记录 | 194 | //下发记录 |
@@ -209,12 +211,21 @@ public class SendUserInfoTask2 { | @@ -209,12 +211,21 @@ public class SendUserInfoTask2 { | ||
209 | String endTime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(calendar.getTime()); | 211 | String endTime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(calendar.getTime()); |
210 | String channel=""; | 212 | String channel=""; |
211 | if(userType2 ==2){ | 213 | if(userType2 ==2){ |
212 | - //根据学生ID\学校ID获取学生类型 | ||
213 | - String studentType = userDao.getStudentType(schoolId,studentId); | ||
214 | - //通道号 | ||
215 | -// String channel = analysisPermission(Integer.parseInt(schoolId),studentType); | ||
216 | - channel = analysisAuthChannel(Integer.parseInt(schoolId),Integer.parseInt(studentType),deviceId); | 214 | + //通道号:先根据学生类型获取,若不存在在根据群组id获取 |
215 | + channel = getAuthChannelByStudentType(Integer.parseInt(schoolId),studentType,deviceId); | ||
216 | + if(StringUtils.isEmpty(channel)){ | ||
217 | + log.error("学生类型【{}】无对应权限通道。",studentType); | ||
218 | + channel = getAuthChannelByClassId(Integer.parseInt(schoolId),Integer.parseInt(classId),deviceId); | ||
219 | + } | ||
220 | + if(StringUtils.isEmpty(channel)){ | ||
221 | + //设备不在线 | ||
222 | + sendRecordBean.setFailType(EnumSendFaceType.AUTH_NOT_SET.code); | ||
223 | + sendRecordBean.setFailContent(EnumSendFaceType.AUTH_NOT_SET.message); | ||
224 | + baseService.sendFailRecord(sendRecordBean,channel); | ||
225 | + return; | ||
226 | + } | ||
217 | } | 227 | } |
228 | + | ||
218 | /** | 229 | /** |
219 | * 下发升级二代接口,动态库libs下win64,更新为官方最新版sdk add by xuquan 2020-11-23 | 230 | * 下发升级二代接口,动态库libs下win64,更新为官方最新版sdk add by xuquan 2020-11-23 |
220 | * 注:用户下发逻辑: | 231 | * 注:用户下发逻辑: |
@@ -234,167 +245,127 @@ public class SendUserInfoTask2 { | @@ -234,167 +245,127 @@ public class SendUserInfoTask2 { | ||
234 | //登录设备 | 245 | //登录设备 |
235 | NetSDKLib.LLong loginHandleLong = MyTask.lLongSendMap.get(attendanceBean.getClint_id()); | 246 | NetSDKLib.LLong loginHandleLong = MyTask.lLongSendMap.get(attendanceBean.getClint_id()); |
236 | log.info("设备ID: {},设备登录句柄: {}",attendanceBean.getClint_id(),loginHandleLong); | 247 | log.info("设备ID: {},设备登录句柄: {}",attendanceBean.getClint_id(),loginHandleLong); |
237 | - | ||
238 | //若设备不在线时,且人脸下发失败表中存在记录,则执行修改下发失败状态为:设备不在线 | 248 | //若设备不在线时,且人脸下发失败表中存在记录,则执行修改下发失败状态为:设备不在线 |
239 | if (loginHandleLong == null) { | 249 | if (loginHandleLong == null) { |
240 | - log.info("设备不在线, 设备ID: {} ",attendanceBean.getClint_id() ); | ||
241 | - FileUtils.getInstance().writeLogs("设备不在线:" + attendanceBean.getClint_id(), FileUtils.devices); | ||
242 | //设备不在线 | 250 | //设备不在线 |
243 | sendRecordBean.setFailType(EnumSendFaceType.NOT_ONLINE_DEVICE.code); | 251 | sendRecordBean.setFailType(EnumSendFaceType.NOT_ONLINE_DEVICE.code); |
244 | sendRecordBean.setFailContent(EnumSendFaceType.NOT_ONLINE_DEVICE.message); | 252 | sendRecordBean.setFailContent(EnumSendFaceType.NOT_ONLINE_DEVICE.message); |
245 | - //判断该学校设备ID对应失败记录是否存在:Face_SendFail | ||
246 | - deviceId = sendRecordDao.getFailIsExit(deviceId, attendanceBean.getSchool_id()); | ||
247 | - if (!StringUtils.isEmpty(deviceId)) { | ||
248 | - sendRecordBean.setFailType(EnumSendFaceType.FACE_AND_CARD_FAIL.code); | ||
249 | - sendRecordBean.setFailContent(EnumSendFaceType.NOT_ONLINE_DEVICE.message); | ||
250 | - baseService.sendFailRecord(sendRecordBean,channel); | ||
251 | - } | 253 | + baseService.sendFailRecord(sendRecordBean,channel); |
254 | + log.info("设备不在线, 设备ID: {} ",attendanceBean.getClint_id() ); | ||
255 | + return; | ||
256 | + } | ||
257 | + | ||
258 | + log.info("=================开始执行下发人脸及卡号任务================="); | ||
259 | + //卡号取反 | ||
260 | + String cardNum =""; | ||
261 | + if(attendanceBean.getClint_id().startsWith("ytj")&&Integer.parseInt(attendanceBean.getSchool_id())!=126 | ||
262 | + &&Integer.parseInt(attendanceBean.getSchool_id())!=393) { | ||
263 | + cardNum = studentNum; | ||
252 | } else { | 264 | } else { |
253 | - log.info("=================开始执行下发人脸及卡号任务================="); | ||
254 | - //卡号取反 | ||
255 | - String cardNum =""; | ||
256 | - if(attendanceBean.getClint_id().startsWith("ytj")&&Integer.parseInt(attendanceBean.getSchool_id())!=126 | ||
257 | - &&Integer.parseInt(attendanceBean.getSchool_id())!=393) { | ||
258 | - cardNum = studentNum; | ||
259 | - } else { | ||
260 | - cardNum = cardNo(studentNum); | ||
261 | - } | ||
262 | - if(attendanceBean.getClint_id().startsWith("ytj")){ | ||
263 | - deviceType= EnumDeviceType.DH_FACE_YTJ.deviceType; | ||
264 | - sendRecordBean.setDeviceType(deviceType); | ||
265 | - } | ||
266 | - try{ | ||
267 | - /** | ||
268 | - * recordNo 不为空存在下发记录集编号,直接修改执行人脸信息(二代升级接口,此处不需要修改用户信息) | ||
269 | - */ | ||
270 | - if (!StringUtils.isEmpty(recordNo)) { | ||
271 | - //修改用户信息 | ||
272 | - bUserFlags = GateModule2.addUser(userId,userName,userType2,"123456",channel,startTime,endTime,loginHandleLong); | ||
273 | - //修改卡 | ||
274 | - bCardFlags = GateModule2.modifyCard(userId,cardNum,loginHandleLong); | ||
275 | - //修改人脸 | ||
276 | - bFaceFalgs = GateModule2.modifyFace(userId,facePath,loginHandleLong); | ||
277 | - if(bFaceFalgs != 0 || bCardFlags !=0){ | ||
278 | - //未知错误、对返回数据校验出错,执行删除用户,重新下发 | ||
279 | - if(bFaceFalgs == EnumSzBusinessType.EnumOperateErrorType.ONE.code || bFaceFalgs == EnumSzBusinessType.EnumOperateErrorType.ERR_21.code|| | ||
280 | - bCardFlags == EnumSzBusinessType.EnumOperateErrorType.ONE.code || bCardFlags == EnumSzBusinessType.EnumOperateErrorType.ERR_21.code){ | ||
281 | - if(GateModule2.deleteUser(userId,loginHandleLong) == 0){ | ||
282 | - bUserFlags = GateModule2.addUser(userId,userName,userType2,"123456",channel,startTime,endTime,loginHandleLong); | ||
283 | - //新增卡 | ||
284 | - bCardFlags = GateModule2.addCard(userId,cardNum,loginHandleLong); | ||
285 | - //新增人脸 | ||
286 | - bFaceFalgs = GateModule2.addFace(userId,facePath,loginHandleLong); | ||
287 | - } | 265 | + cardNum = cardNo(studentNum); |
266 | + } | ||
267 | + //设备类型:默认为大华人脸机 | ||
268 | + int deviceType = EnumDeviceType.DH_FACE.deviceType; | ||
269 | + if(attendanceBean.getClint_id().startsWith("ytj")){ | ||
270 | + deviceType= EnumDeviceType.DH_FACE_YTJ.deviceType; | ||
271 | + sendRecordBean.setDeviceType(deviceType); | ||
272 | + } | ||
273 | + try{ | ||
274 | + /** | ||
275 | + * recordNo 不为空存在下发记录集编号,直接修改执行人脸信息(二代升级接口,此处不需要修改用户信息) | ||
276 | + */ | ||
277 | + if (!StringUtils.isEmpty(recordNo)) { | ||
278 | + //修改用户信息 | ||
279 | + bUserFlags = GateModule2.addUser(userId,userName,userType2,"123456",channel,startTime,endTime,loginHandleLong); | ||
280 | + //修改卡 | ||
281 | + bCardFlags = GateModule2.modifyCard(userId,cardNum,loginHandleLong); | ||
282 | + //修改人脸 | ||
283 | + bFaceFalgs = GateModule2.modifyFace(userId,facePath,loginHandleLong); | ||
284 | + if(bFaceFalgs != 0 || bCardFlags !=0){ | ||
285 | + //未知错误、对返回数据校验出错,执行删除用户,重新下发 | ||
286 | + if(bFaceFalgs == EnumSzBusinessType.EnumOperateErrorType.ONE.code || bFaceFalgs == EnumSzBusinessType.EnumOperateErrorType.ERR_21.code|| | ||
287 | + bCardFlags == EnumSzBusinessType.EnumOperateErrorType.ONE.code || bCardFlags == EnumSzBusinessType.EnumOperateErrorType.ERR_21.code){ | ||
288 | + if(GateModule2.deleteUser(userId,loginHandleLong) == 0){ | ||
289 | + bUserFlags = GateModule2.addUser(userId,userName,userType2,"123456",channel,startTime,endTime,loginHandleLong); | ||
290 | + //新增卡 | ||
291 | + bCardFlags = GateModule2.addCard(userId,cardNum,loginHandleLong); | ||
292 | + //新增人脸 | ||
293 | + bFaceFalgs = GateModule2.addFace(userId,facePath,loginHandleLong); | ||
288 | } | 294 | } |
289 | } | 295 | } |
290 | - } else { | ||
291 | - //新增用户信息 | ||
292 | - bUserFlags = GateModule2.addUser(userId,userName,userType2,"123456",channel,startTime,endTime,loginHandleLong); | ||
293 | - //新增卡 | ||
294 | - bCardFlags = GateModule2.addCard(userId,cardNum,loginHandleLong); | ||
295 | - //新增人脸 | ||
296 | - bFaceFalgs = GateModule2.addFace(userId,facePath,loginHandleLong); | ||
297 | - | ||
298 | - //新增用户、卡、人脸信息都成功,则新增记录集信息,默认为1 | ||
299 | - if (bCardFlags == 0 && bFaceFalgs ==0 && bUserFlags ==0) { | ||
300 | - userDao.saveRecordNo(userId,1, userName, attendanceBean.getClint_id()); | ||
301 | - } | ||
302 | } | 296 | } |
303 | - } catch (RuntimeException e) { | ||
304 | - log.error("下发异常:异常错误信息msg: {}",e); | ||
305 | - continue; | ||
306 | - } | ||
307 | - /** | ||
308 | - * 人脸和卡都下发成功 | ||
309 | - */ | ||
310 | - if (bUserFlags ==0 && bCardFlags ==0 && bFaceFalgs==0) { | ||
311 | - FileUtils.getInstance().writeLogs("下发人脸和卡号成功:" + cardNum + " " + attendanceBean.getClint_id(), FileUtils.sendUserSucTxt); | ||
312 | - log.info("下发人脸和卡号成功, sendRecordBean: "+ JSON.toJSONString(sendRecordBean)); | ||
313 | - //保存成功记录 | ||
314 | - baseService.sendSuccessRecord(sendRecordBean,channel); | ||
315 | - } | ||
316 | - /** | ||
317 | - * 人脸和卡都下发失败 | ||
318 | - */ | ||
319 | - if (bUserFlags !=0 && bFaceFalgs != 0 && bCardFlags !=0) { | ||
320 | - FileUtils.getInstance().writeLogs("下发用户人脸和卡号失败: 卡号:" + cardNum + "用户ID: " + userId + " loginHandleLong: " + loginHandleLong, FileUtils.sendUserErrTxt); | ||
321 | - log.info("下发用户人脸和卡号失败, sendRecordBean: "+ JSON.toJSONString(sendRecordBean)); | ||
322 | - //失败信息 | ||
323 | - String failContent = analysisErrorMsg(bUserFlags,bFaceFalgs,bCardFlags); | ||
324 | - sendRecordBean.setFailType(EnumSendFaceType.FACE_AND_CARD_FAIL.code); | ||
325 | - sendRecordBean.setFailContent(failContent); | ||
326 | - baseService.sendFailRecord(sendRecordBean,channel); | ||
327 | - } | ||
328 | - /** | ||
329 | - * 下发卡号成功,下发人脸失败, | ||
330 | - */ | ||
331 | - if (bUserFlags ==0 && bCardFlags !=0 && bFaceFalgs !=0) { | ||
332 | - FileUtils.getInstance().writeLogs("下发卡号成功,下发人脸失败:" + cardNum + " " + attendanceBean.getClint_id(), FileUtils.sendUserErrTxt); | ||
333 | - log.info("下发卡号成功,下发人脸失败, sendRecordBean: " + JSON.toJSONString(sendRecordBean)); | ||
334 | - //失败信息 | ||
335 | - String failContent = analysisErrorMsg(bUserFlags,bFaceFalgs,bCardFlags); | ||
336 | - sendRecordBean.setFailType(EnumSendFaceType.FACE_FAIL_CARD_SUCCESS.code); | ||
337 | - sendRecordBean.setFailContent(failContent); | ||
338 | - baseService.sendFailRecord(sendRecordBean,channel); | ||
339 | - } | ||
340 | - /** | ||
341 | - * 下发卡号失败,下发人脸成功, | ||
342 | - */ | ||
343 | - if (bUserFlags ==0 && bCardFlags == 0 && bFaceFalgs !=0) { | ||
344 | - FileUtils.getInstance().writeLogs("卡信息已存在,下发人脸成功:" + cardNum + " " + attendanceBean.getClint_id(), FileUtils.sendUserSucTxt); | ||
345 | - //失败信息 | ||
346 | - String failContent = analysisErrorMsg(bUserFlags,bFaceFalgs,bCardFlags); | ||
347 | - sendRecordBean.setFailType(EnumSendFaceType.FACE_SUCCESS_CARD_FAIl.code); | ||
348 | - sendRecordBean.setFailContent(failContent); | ||
349 | - baseService.sendFailRecord(sendRecordBean,channel); | 297 | + } else { |
298 | + //新增用户信息 | ||
299 | + bUserFlags = GateModule2.addUser(userId,userName,userType2,"123456",channel,startTime,endTime,loginHandleLong); | ||
300 | + //新增卡 | ||
301 | + bCardFlags = GateModule2.addCard(userId,cardNum,loginHandleLong); | ||
302 | + //新增人脸 | ||
303 | + bFaceFalgs = GateModule2.addFace(userId,facePath,loginHandleLong); | ||
304 | + | ||
305 | + //新增用户、卡、人脸信息都成功,则新增记录集信息,默认为1 | ||
306 | + if (bCardFlags == 0 && bFaceFalgs ==0 && bUserFlags ==0) { | ||
307 | + userDao.saveRecordNo(userId,1, userName, attendanceBean.getClint_id()); | ||
308 | + } | ||
350 | } | 309 | } |
310 | + } catch (RuntimeException e) { | ||
311 | + log.error("下发异常:异常错误信息msg: {}",e); | ||
312 | + continue; | ||
351 | } | 313 | } |
352 | - } | ||
353 | - | ||
354 | - | ||
355 | - } | ||
356 | - | ||
357 | - private static JsonUtils objectMapper = JsonUtils.nonEmptyMapper(); | ||
358 | - | ||
359 | - /** | ||
360 | - * 解析权限模板、获取下发通道号 | ||
361 | - * @param schoolId | ||
362 | - * @param studentType | ||
363 | - * @return | ||
364 | - */ | ||
365 | - private String analysisPermission(int schoolId, String studentType){ | ||
366 | - if(StringUtils.isEmpty(studentType)){ | ||
367 | - return ""; | ||
368 | - } | ||
369 | - List<PermissionFaceBean> permissionFaceBeans = permissFaceService.getPermissionList(schoolId); | ||
370 | - String channel =""; | ||
371 | - if(permissionFaceBeans.size()>0){ | ||
372 | - for(PermissionFaceBean permissionFaceBean : permissionFaceBeans){ | ||
373 | - String json = permissionFaceBean.getPermissionJson(); | ||
374 | - PermissionBean permissionBean = objectMapper.fromJson(json,PermissionBean.class); | ||
375 | - //学生考勤类型 1:通校生,2:住校生,3:全部 | ||
376 | - String studentTypeStr = permissionBean.getStudentType(); | ||
377 | - if(studentTypeStr.indexOf(studentType)!=-1){ | ||
378 | - channel= permissionFaceBean.getChannel(); | ||
379 | - } | 314 | + /** |
315 | + * 人脸和卡都下发成功 | ||
316 | + */ | ||
317 | + if (bUserFlags ==0 && bCardFlags ==0 && bFaceFalgs==0) { | ||
318 | + FileUtils.getInstance().writeLogs("下发人脸和卡号成功:" + cardNum + " " + attendanceBean.getClint_id(), FileUtils.sendUserSucTxt); | ||
319 | + log.info("下发人脸和卡号成功, sendRecordBean: "+ JSON.toJSONString(sendRecordBean)); | ||
320 | + //保存成功记录 | ||
321 | + baseService.sendSuccessRecord(sendRecordBean,channel); | ||
322 | + } | ||
323 | + /** | ||
324 | + * 人脸和卡都下发失败 | ||
325 | + */ | ||
326 | + if (bUserFlags !=0 && bFaceFalgs != 0 && bCardFlags !=0) { | ||
327 | + FileUtils.getInstance().writeLogs("下发用户人脸和卡号失败: 卡号:" + cardNum + "用户ID: " + userId + " loginHandleLong: " + loginHandleLong, FileUtils.sendUserErrTxt); | ||
328 | + log.info("下发用户人脸和卡号失败, sendRecordBean: "+ JSON.toJSONString(sendRecordBean)); | ||
329 | + //失败信息 | ||
330 | + String failContent = analysisErrorMsg(bUserFlags,bFaceFalgs,bCardFlags); | ||
331 | + sendRecordBean.setFailType(EnumSendFaceType.FACE_AND_CARD_FAIL.code); | ||
332 | + sendRecordBean.setFailContent(failContent); | ||
333 | + baseService.sendFailRecord(sendRecordBean,channel); | ||
334 | + } | ||
335 | + /** | ||
336 | + * 下发卡号成功,下发人脸失败, | ||
337 | + */ | ||
338 | + if (bUserFlags ==0 && bCardFlags !=0 && bFaceFalgs !=0) { | ||
339 | + FileUtils.getInstance().writeLogs("下发卡号成功,下发人脸失败:" + cardNum + " " + attendanceBean.getClint_id(), FileUtils.sendUserErrTxt); | ||
340 | + log.info("下发卡号成功,下发人脸失败, sendRecordBean: " + JSON.toJSONString(sendRecordBean)); | ||
341 | + //失败信息 | ||
342 | + String failContent = analysisErrorMsg(bUserFlags,bFaceFalgs,bCardFlags); | ||
343 | + sendRecordBean.setFailType(EnumSendFaceType.FACE_FAIL_CARD_SUCCESS.code); | ||
344 | + sendRecordBean.setFailContent(failContent); | ||
345 | + baseService.sendFailRecord(sendRecordBean,channel); | ||
380 | } | 346 | } |
381 | - if(StringUtils.isEmpty(channel)){ | ||
382 | - log.warn("未获取到学校权限通道号!"); | ||
383 | - return ""; | 347 | + /** |
348 | + * 下发卡号失败,下发人脸成功, | ||
349 | + */ | ||
350 | + if (bUserFlags ==0 && bCardFlags == 0 && bFaceFalgs !=0) { | ||
351 | + FileUtils.getInstance().writeLogs("卡信息已存在,下发人脸成功:" + cardNum + " " + attendanceBean.getClint_id(), FileUtils.sendUserSucTxt); | ||
352 | + //失败信息 | ||
353 | + String failContent = analysisErrorMsg(bUserFlags,bFaceFalgs,bCardFlags); | ||
354 | + sendRecordBean.setFailType(EnumSendFaceType.FACE_SUCCESS_CARD_FAIl.code); | ||
355 | + sendRecordBean.setFailContent(failContent); | ||
356 | + baseService.sendFailRecord(sendRecordBean,channel); | ||
384 | } | 357 | } |
385 | - return channel; | ||
386 | } | 358 | } |
387 | - return channel; | ||
388 | } | 359 | } |
389 | 360 | ||
390 | /** | 361 | /** |
391 | - * 获取学生时段类型2.0 | 362 | + * 根据学生类型获取学生时段类型 |
392 | * @param schoolId | 363 | * @param schoolId |
393 | * @param studentType | 364 | * @param studentType |
394 | * @param deviceId | 365 | * @param deviceId |
395 | * @return | 366 | * @return |
396 | */ | 367 | */ |
397 | - private String analysisAuthChannel(Integer schoolId,Integer studentType,String deviceId){ | 368 | + private String getAuthChannelByStudentType(Integer schoolId,Integer studentType,String deviceId){ |
398 | if(StringUtils.isEmpty(studentType) || StringUtils.isEmpty(schoolId)){ | 369 | if(StringUtils.isEmpty(studentType) || StringUtils.isEmpty(schoolId)){ |
399 | return ""; | 370 | return ""; |
400 | } | 371 | } |
@@ -407,16 +378,46 @@ public class SendUserInfoTask2 { | @@ -407,16 +378,46 @@ public class SendUserInfoTask2 { | ||
407 | //学生考勤类型 1:通校生,2:住校生,3:全部 | 378 | //学生考勤类型 1:通校生,2:住校生,3:全部 |
408 | Integer sType = authRecord.getStudentType(); | 379 | Integer sType = authRecord.getStudentType(); |
409 | log.info("学生类型:{},设备ID:{}",sType,deviceId); | 380 | log.info("学生类型:{},设备ID:{}",sType,deviceId); |
410 | - if(deviceIds.indexOf(deviceId)!=-1 && (studentType.intValue() == sType.intValue() || sType.intValue() == 3)){ | 381 | + if(deviceIds.indexOf(deviceId)!=-1 && studentType.intValue() == sType.intValue()){ |
411 | channel= authRecord.getShiduan(); | 382 | channel= authRecord.getShiduan(); |
412 | log.info("通道号:"+channel); | 383 | log.info("通道号:"+channel); |
384 | + return channel; | ||
413 | } | 385 | } |
414 | } | 386 | } |
415 | - if(StringUtils.isEmpty(channel)){ | ||
416 | - log.warn("未获取到学校权限通道号!"); | ||
417 | - return ""; | 387 | + } |
388 | + return channel; | ||
389 | + } | ||
390 | + | ||
391 | + /** | ||
392 | + * 根据班级id获取学生时段 | ||
393 | + * @param schoolId | ||
394 | + * @param classId | ||
395 | + * @param deviceId | ||
396 | + * @return | ||
397 | + */ | ||
398 | + private String getAuthChannelByClassId(Integer schoolId,Integer classId,String deviceId){ | ||
399 | + if(StringUtils.isEmpty(classId) || StringUtils.isEmpty(schoolId)) { | ||
400 | + return ""; | ||
401 | + } | ||
402 | + List<Integer> groups = userDao.getGroupByClassId(classId); | ||
403 | + String channel =""; | ||
404 | + if(groups.size()>0){ | ||
405 | + List<DeviceAuthRecord> result = new ArrayList<>(); | ||
406 | + groups.stream().distinct().forEach(s -> { | ||
407 | + List<DeviceAuthRecord> authRecords = userDao.getAuthRecord(schoolId,s); | ||
408 | + result.addAll(authRecords); | ||
409 | + }); | ||
410 | + if(result.size()>0){ | ||
411 | + for(DeviceAuthRecord s : result){ | ||
412 | + String deviceIds = s.getSno(); | ||
413 | + channel= s.getShiduan(); | ||
414 | + log.info("学生类型:{},设备ID:{}",deviceId); | ||
415 | + if(deviceIds.indexOf(deviceId)!=-1 ){ | ||
416 | + log.info("通道号:"+channel); | ||
417 | + return channel; | ||
418 | + } | ||
419 | + } | ||
418 | } | 420 | } |
419 | - return channel; | ||
420 | } | 421 | } |
421 | return channel; | 422 | return channel; |
422 | } | 423 | } |
cloud/dahua/src/main/java/com/example/dahua/bean/UserInfoBean.java
@@ -26,6 +26,8 @@ public class UserInfoBean implements Serializable { | @@ -26,6 +26,8 @@ public class UserInfoBean implements Serializable { | ||
26 | 26 | ||
27 | private String parentMobile; | 27 | private String parentMobile; |
28 | 28 | ||
29 | + private Integer student_type; | ||
30 | + | ||
29 | public String getClass_id() { | 31 | public String getClass_id() { |
30 | return class_id; | 32 | return class_id; |
31 | } | 33 | } |
@@ -114,6 +116,14 @@ public class UserInfoBean implements Serializable { | @@ -114,6 +116,14 @@ public class UserInfoBean implements Serializable { | ||
114 | this.parentMobile = parentMobile; | 116 | this.parentMobile = parentMobile; |
115 | } | 117 | } |
116 | 118 | ||
119 | + public Integer getStudent_type() { | ||
120 | + return student_type; | ||
121 | + } | ||
122 | + | ||
123 | + public void setStudent_type(Integer student_type) { | ||
124 | + this.student_type = student_type; | ||
125 | + } | ||
126 | + | ||
117 | @Override | 127 | @Override |
118 | public String toString() { | 128 | public String toString() { |
119 | return "UserInfoBean{" + | 129 | return "UserInfoBean{" + |
cloud/dahua/src/main/java/com/example/dahua/dao/UserDao.java
@@ -279,4 +279,6 @@ public interface UserDao { | @@ -279,4 +279,6 @@ public interface UserDao { | ||
279 | List<String> queryStudentIdList(@Param("schoolId") Integer schoolId,@Param("roomId")Integer roomId); | 279 | List<String> queryStudentIdList(@Param("schoolId") Integer schoolId,@Param("roomId")Integer roomId); |
280 | 280 | ||
281 | List<StudentBean> getStudentByClassId(@Param("schoolId") int schoolId,@Param("classIds") List<Integer> classIds); | 281 | List<StudentBean> getStudentByClassId(@Param("schoolId") int schoolId,@Param("classIds") List<Integer> classIds); |
282 | + | ||
283 | + List<Integer> getGroupByClassId(@Param("classId") Integer classId); | ||
282 | } | 284 | } |
cloud/dahua/src/main/java/com/example/dahua/enums/EnumSendFaceType.java
@@ -13,7 +13,8 @@ public enum EnumSendFaceType { | @@ -13,7 +13,8 @@ public enum EnumSendFaceType { | ||
13 | FACE_AND_CARD_FAIL(3, "人脸信息、卡信息下发失败"), | 13 | FACE_AND_CARD_FAIL(3, "人脸信息、卡信息下发失败"), |
14 | FACE_FAIL_CARD_SUCCESS(4, "人脸信息下发失败,卡信息下发成功"), | 14 | FACE_FAIL_CARD_SUCCESS(4, "人脸信息下发失败,卡信息下发成功"), |
15 | FACE_SUCCESS_CARD_FAIl(5, "人脸信息下发成功,卡信息下发失败"), | 15 | FACE_SUCCESS_CARD_FAIl(5, "人脸信息下发成功,卡信息下发失败"), |
16 | - TIME_INTERVAL_ERROR(6, "刷卡时段验证错误"); | 16 | + TIME_INTERVAL_ERROR(6, "刷卡时段验证错误"), |
17 | + AUTH_NOT_SET(7, "权限时段未设置"); | ||
17 | 18 | ||
18 | public final int code; | 19 | public final int code; |
19 | public final String message; | 20 | public final String message; |
cloud/dahua/src/main/java/com/example/dahua/module/GateModule2.java
@@ -120,7 +120,7 @@ public class GateModule2 { | @@ -120,7 +120,7 @@ public class GateModule2 { | ||
120 | users[i].nTimeSectionNo[0] = 255; // 表示第一个门全天有效 | 120 | users[i].nTimeSectionNo[0] = 255; // 表示第一个门全天有效 |
121 | users[i].nTimeSectionNo[1] = 255; // 表示第二个门全天有效 | 121 | users[i].nTimeSectionNo[1] = 255; // 表示第二个门全天有效 |
122 | }else { | 122 | }else { |
123 | - //此学校不存在权限设置默认为全天有效 | 123 | + //此学校不存在权限,为老师类型 设置默认为全天有效 |
124 | if(StringUtils.isEmpty(channel)){ | 124 | if(StringUtils.isEmpty(channel)){ |
125 | users[i].nTimeSectionNo[0] = 255; // 表示第一个门全天有效 | 125 | users[i].nTimeSectionNo[0] = 255; // 表示第一个门全天有效 |
126 | users[i].nTimeSectionNo[1] = 255; // 表示第二个门全天有效 | 126 | users[i].nTimeSectionNo[1] = 255; // 表示第二个门全天有效 |
cloud/dahua/src/main/resources/mapper/usermapper.xml
@@ -32,7 +32,7 @@ | @@ -32,7 +32,7 @@ | ||
32 | <select id="getAuthRecord" resultType="com.example.dahua.bean.DeviceAuthRecord"> | 32 | <select id="getAuthRecord" resultType="com.example.dahua.bean.DeviceAuthRecord"> |
33 | select * from AC_DeviceAuthRecord where State = 1 and GrantState = 1 and SchoolId = #{schoolId} | 33 | select * from AC_DeviceAuthRecord where State = 1 and GrantState = 1 and SchoolId = #{schoolId} |
34 | <if test="studentType != null"> | 34 | <if test="studentType != null"> |
35 | - and (StudentType = #{studentType} or StudentType =3) | 35 | + and StudentType = #{studentType} |
36 | </if> | 36 | </if> |
37 | </select> | 37 | </select> |
38 | 38 | ||
@@ -60,4 +60,14 @@ | @@ -60,4 +60,14 @@ | ||
60 | and student_num != '' and photo !='' | 60 | and student_num != '' and photo !='' |
61 | </select> | 61 | </select> |
62 | 62 | ||
63 | + <select id="getGroupByClassId" resultType="java.lang.Integer"> | ||
64 | + SELECT | ||
65 | + Pid | ||
66 | + FROM | ||
67 | + SZ_OneCardGrouping | ||
68 | + WHERE | ||
69 | + ClassId = #{classId} | ||
70 | + AND state = 1 | ||
71 | + </select> | ||
72 | + | ||
63 | </mapper> | 73 | </mapper> |
64 | \ No newline at end of file | 74 | \ No newline at end of file |
cloud/haikangface/src/main/java/com/sincere/haikangface/control/UserOperateController.java
@@ -146,12 +146,9 @@ public class UserOperateController { | @@ -146,12 +146,9 @@ public class UserOperateController { | ||
146 | return userOperateService.deleteFaceBySchoolId(schoolId,deviceIds); | 146 | return userOperateService.deleteFaceBySchoolId(schoolId,deviceIds); |
147 | } | 147 | } |
148 | 148 | ||
149 | - | ||
150 | - public static void main(String[] args) { | ||
151 | - String photo = "http://campus.myjxt.com//f0i5l7e5/0/alluser/20171008/aa26754eb6f24fceb8881d50ee37cdf3.jpg"; | ||
152 | - //以学籍号为名的文件名 | ||
153 | - String fileName = photo.substring(photo.lastIndexOf("/") + 1,photo.length()); | ||
154 | - System.out.println(fileName); | ||
155 | - System.out.println(fileName.split(".")[0]); | 149 | + @ApiOperation(value = "删除指定学校下无效人脸") |
150 | + @RequestMapping(value = "checkFaceSend", method = RequestMethod.GET) | ||
151 | + public void checkFaceSend(){ | ||
152 | + userOperateService.checkFaceSend(); | ||
156 | } | 153 | } |
157 | } | 154 | } |
cloud/haikangface/src/main/java/com/sincere/haikangface/dao/UserDao.java
@@ -2,6 +2,7 @@ package com.sincere.haikangface.dao; | @@ -2,6 +2,7 @@ package com.sincere.haikangface.dao; | ||
2 | 2 | ||
3 | import com.sincere.haikangface.bean.*; | 3 | import com.sincere.haikangface.bean.*; |
4 | import com.sincere.haikangface.bean.face.DeviceAuthRecord; | 4 | import com.sincere.haikangface.bean.face.DeviceAuthRecord; |
5 | +import com.sincere.haikangface.bean.test.SaveStudentBak; | ||
5 | import org.apache.ibatis.annotations.*; | 6 | import org.apache.ibatis.annotations.*; |
6 | import org.springframework.stereotype.Repository; | 7 | import org.springframework.stereotype.Repository; |
7 | 8 | ||
@@ -287,4 +288,10 @@ public interface UserDao { | @@ -287,4 +288,10 @@ public interface UserDao { | ||
287 | StudentBean getTeacherWithCard(@Param("teacher_num") String teacher_num,@Param("schoolId") Integer schoolId); | 288 | StudentBean getTeacherWithCard(@Param("teacher_num") String teacher_num,@Param("schoolId") Integer schoolId); |
288 | 289 | ||
289 | void insertCard(UpdateCardBean bean); | 290 | void insertCard(UpdateCardBean bean); |
291 | + | ||
292 | + void insertStudent(SaveStudentBak studentBak); | ||
293 | + | ||
294 | + void updateStudent(@Param("id") Integer id); | ||
295 | + | ||
296 | + List<SaveStudentBak> selectStudentList(); | ||
290 | } | 297 | } |
cloud/haikangface/src/main/java/com/sincere/haikangface/service/UserOperateService.java
@@ -138,4 +138,6 @@ public interface UserOperateService { | @@ -138,4 +138,6 @@ public interface UserOperateService { | ||
138 | * @return | 138 | * @return |
139 | */ | 139 | */ |
140 | Result deleteFaceBySchoolId(Integer schoolId,String deviceIds); | 140 | Result deleteFaceBySchoolId(Integer schoolId,String deviceIds); |
141 | + | ||
142 | + void checkFaceSend(); | ||
141 | } | 143 | } |
cloud/haikangface/src/main/java/com/sincere/haikangface/service/impl/UserOperateServiceImpl.java
@@ -6,6 +6,7 @@ import com.sincere.haikangface.CMSServer; | @@ -6,6 +6,7 @@ import com.sincere.haikangface.CMSServer; | ||
6 | import com.sincere.haikangface.async.SendUserAsync; | 6 | import com.sincere.haikangface.async.SendUserAsync; |
7 | import com.sincere.haikangface.bean.*; | 7 | import com.sincere.haikangface.bean.*; |
8 | import com.sincere.haikangface.bean.face.*; | 8 | import com.sincere.haikangface.bean.face.*; |
9 | +import com.sincere.haikangface.bean.test.SaveStudentBak; | ||
9 | import com.sincere.haikangface.dao.DeviceDao; | 10 | import com.sincere.haikangface.dao.DeviceDao; |
10 | import com.sincere.haikangface.dao.UserDao; | 11 | import com.sincere.haikangface.dao.UserDao; |
11 | import com.sincere.haikangface.enums.EnumSzBusinessType; | 12 | import com.sincere.haikangface.enums.EnumSzBusinessType; |
@@ -71,13 +72,9 @@ public class UserOperateServiceImpl implements UserOperateService { | @@ -71,13 +72,9 @@ public class UserOperateServiceImpl implements UserOperateService { | ||
71 | String weekDayJson = objectMapper.toJson(weekDay); | 72 | String weekDayJson = objectMapper.toJson(weekDay); |
72 | //设备类型 | 73 | //设备类型 |
73 | Integer deviceType = userDao.getClintTypeByDeviceId(deviceIds.get(0)); | 74 | Integer deviceType = userDao.getClintTypeByDeviceId(deviceIds.get(0)); |
74 | - String deviceStr = ""; | ||
75 | - for (String sn : deviceIds) { | ||
76 | - deviceStr += sn + ","; | ||
77 | - } | ||
78 | Date start = DateUtils.string2Date("2020-01-01", DateUtils.format1); | 75 | Date start = DateUtils.string2Date("2020-01-01", DateUtils.format1); |
79 | Date end = DateUtils.string2Date("2030-01-01", DateUtils.format1); | 76 | Date end = DateUtils.string2Date("2030-01-01", DateUtils.format1); |
80 | - deviceStr = deviceStr.substring(0, deviceStr.length() - 1); | 77 | + String deviceStr = deviceIds.stream().collect(Collectors.joining(",")); |
81 | //保存权限计划 | 78 | //保存权限计划 |
82 | saveDeviceAuth(schoolId, deviceStr, studentType, start, end, weekDayJson, sexStr, type, authType,deviceType); | 79 | saveDeviceAuth(schoolId, deviceStr, studentType, start, end, weekDayJson, sexStr, type, authType,deviceType); |
83 | return true; | 80 | return true; |
@@ -167,7 +164,8 @@ public class UserOperateServiceImpl implements UserOperateService { | @@ -167,7 +164,8 @@ public class UserOperateServiceImpl implements UserOperateService { | ||
167 | dhBean.setWeekDays(weekDayList); | 164 | dhBean.setWeekDays(weekDayList); |
168 | dhBean.setDeviceIds(devices); | 165 | dhBean.setDeviceIds(devices); |
169 | dhBean.setChannel(record.getShiduan()); | 166 | dhBean.setChannel(record.getShiduan()); |
170 | - dhBean.setCustomName(EnumSzBusinessType.EnumStudentType.getByCode(studentType).code+""); | 167 | + EnumSzBusinessType.EnumStudentType enumStudentType = EnumSzBusinessType.EnumStudentType.getByCode(studentType); |
168 | + dhBean.setCustomName(enumStudentType ==null?record.getStudentType()+"": enumStudentType.name); | ||
171 | dhBean.setStudentType(String.valueOf(studentType)); | 169 | dhBean.setStudentType(String.valueOf(studentType)); |
172 | log.info("下发大华权限计划详情:{}", JSON.toJSONString(dhBean)); | 170 | log.info("下发大华权限计划详情:{}", JSON.toJSONString(dhBean)); |
173 | //发送大华设备 | 171 | //发送大华设备 |
@@ -1036,4 +1034,92 @@ public class UserOperateServiceImpl implements UserOperateService { | @@ -1036,4 +1034,92 @@ public class UserOperateServiceImpl implements UserOperateService { | ||
1036 | } | 1034 | } |
1037 | return ResultGenerator.genSuccessResult(); | 1035 | return ResultGenerator.genSuccessResult(); |
1038 | } | 1036 | } |
1037 | + | ||
1038 | + @Override | ||
1039 | + public void checkFaceSend() { | ||
1040 | + List<SaveStudentBak> saveStudentBaks = userDao.selectStudentList(); | ||
1041 | + if(!CollectionUtils.isEmpty(saveStudentBaks)) { | ||
1042 | + saveStudentBaks.stream().forEach(saveStudentBak -> { | ||
1043 | + try{ | ||
1044 | + String cardNum = saveStudentBak.getCardNum(); | ||
1045 | + Integer schoolId = saveStudentBak.getSchoolId(); | ||
1046 | + String deviceId = saveStudentBak.getClientId(); | ||
1047 | + StudentBean studentBean = userDao.getStudentWithCard(cardNum, schoolId); | ||
1048 | + if (studentBean == null) { | ||
1049 | + return; | ||
1050 | + } | ||
1051 | + String photo = studentBean.getPhoto(); | ||
1052 | + if (StringUtils.isBlank(photo)) { | ||
1053 | + return; | ||
1054 | + } | ||
1055 | + int userType = studentBean.getUserType(); | ||
1056 | + String userName = studentBean.getName(); | ||
1057 | + String studentCode = studentBean.getStudentCode(); | ||
1058 | + String typeName = "Student"; | ||
1059 | + //以学籍号为名的文件名 | ||
1060 | + String fileName = photo.substring(photo.lastIndexOf("/") + 1, photo.length()); | ||
1061 | + //100服务器人脸照绝对路径 | ||
1062 | + String path_1 = "E:\\wwwhtdocs\\SmartCampus\\face17e50\\School" + schoolId + "\\" + typeName; | ||
1063 | + String path_2 = "E:\\wwwhtdocs\\SmartCampus\\face17e5\\School" + schoolId + "\\" + typeName; | ||
1064 | + String path_3 = "E:\\wwwhtdocs\\SmartCampus\\f0i5l7e5\\"; | ||
1065 | + String filePath = ""; | ||
1066 | + if (photo.indexOf("f0i5l7e5") != -1) { | ||
1067 | + String afterStr = photo.split("f0i5l7e5/")[1].replace("/", "\\"); | ||
1068 | + filePath = path_3 + afterStr; | ||
1069 | + } | ||
1070 | + if (photo.indexOf("face17e5") != -1) { | ||
1071 | + filePath = path_2 + "\\" + fileName; | ||
1072 | + } | ||
1073 | + if (photo.indexOf("face17e50") != -1) { | ||
1074 | + filePath = path_1 + "\\" + fileName; | ||
1075 | + } | ||
1076 | + if (filePath.indexOf("?v=") != -1) { | ||
1077 | + filePath = filePath.split("\\?")[0]; | ||
1078 | + } | ||
1079 | + //校验100服务文件存储地址上是否存在此人脸 | ||
1080 | + File file = new File(filePath.trim());//图片 | ||
1081 | + if (!file.exists()) { | ||
1082 | + log.error("文件不存在:" + filePath); | ||
1083 | + baseService.sendFailRecord(cardNum, filePath, deviceId, "文件不存在", String.valueOf(userType), schoolId); | ||
1084 | + return; | ||
1085 | + } | ||
1086 | + String targetPath = FileUtils.picPathComp + file.getName(); | ||
1087 | + if (file.exists()) { | ||
1088 | + try { | ||
1089 | + CompressPic.CompressPic(file.getAbsolutePath(), targetPath); | ||
1090 | + } catch (Exception e) { | ||
1091 | + log.error("压缩图片失败:", e); | ||
1092 | + } | ||
1093 | + } | ||
1094 | + //设备类型 | ||
1095 | + Integer clintType = userDao.getClintTypeByDeviceId(deviceId); | ||
1096 | + if (clintType.intValue() == 18 || clintType.intValue() == 28) { | ||
1097 | +// //1.先删除人脸 | ||
1098 | +// if (cmsServer.getIsDeviceOnline(deviceId)) { | ||
1099 | +// String cardNo = Long.parseLong(baseService.getCard(cardNum), 16) + ""; | ||
1100 | +// cmsServer.deleteFace(deviceId, cardNo, schoolId); | ||
1101 | +// } else { | ||
1102 | +// //不在线,去253服务器上删除 | ||
1103 | +// HttpUtil.deleteCard(deviceId, cardNum); | ||
1104 | +// } | ||
1105 | + //2.重新下发 | ||
1106 | + boolean isOk = baseService.sendImg(file.getAbsolutePath(), targetPath, deviceId, cardNum, userName, String.valueOf(userType), schoolId); | ||
1107 | + if (isOk) { | ||
1108 | + return; | ||
1109 | + } else { | ||
1110 | + } | ||
1111 | + } | ||
1112 | + //下大华人脸 | ||
1113 | + if (clintType.intValue() == 22 || clintType.intValue() == 29) { | ||
1114 | + //下发单个人脸至大华设备 | ||
1115 | + HttpUtil.uploadDHImgForOne(filePath, schoolId, studentCode, clintType, deviceId); | ||
1116 | + return; | ||
1117 | + } | ||
1118 | + }catch (Exception e){ | ||
1119 | + log.error("下发出错"); | ||
1120 | + return; | ||
1121 | + } | ||
1122 | + }); | ||
1123 | + } | ||
1124 | + } | ||
1039 | } | 1125 | } |
cloud/haikangface/src/main/java/com/sincere/haikangface/utils/DateUtils.java
@@ -41,6 +41,16 @@ public class DateUtils { | @@ -41,6 +41,16 @@ public class DateUtils { | ||
41 | return new Date(); | 41 | return new Date(); |
42 | } | 42 | } |
43 | 43 | ||
44 | + public static String string2Date2(String date, String format) { | ||
45 | + try{ | ||
46 | + SimpleDateFormat sdf = new SimpleDateFormat(format); | ||
47 | + return String.valueOf(sdf.parse(date).getTime()); | ||
48 | + }catch (Exception e){ | ||
49 | + | ||
50 | + } | ||
51 | + return String.valueOf(new Date().getTime()); | ||
52 | + } | ||
53 | + | ||
44 | public static Date getToday(){ | 54 | public static Date getToday(){ |
45 | return new Date(); | 55 | return new Date(); |
46 | } | 56 | } |
@@ -117,8 +127,11 @@ public class DateUtils { | @@ -117,8 +127,11 @@ public class DateUtils { | ||
117 | 127 | ||
118 | 128 | ||
119 | public static void main(String[] args) { | 129 | public static void main(String[] args) { |
120 | - System.out.println(getDateByTime(3,new Date())); | ||
121 | - System.out.println(date2String(new Date(),format3)); | 130 | +// System.out.println(getDateByTime(3,new Date())); |
131 | +// System.out.println(date2String(new Date(),format3)); | ||
132 | + | ||
133 | + System.out.println(string2Date2("2022-02-23 04:00:00","yyyy-MM-dd HH:mm:ss")); | ||
134 | + System.out.println(string2Date2("2022-02-23 20:00:00","yyyy-MM-dd HH:mm:ss")); | ||
122 | } | 135 | } |
123 | 136 | ||
124 | } | 137 | } |
cloud/haikangface/src/main/resources/mapper/usermapper.xml
@@ -163,4 +163,29 @@ | @@ -163,4 +163,29 @@ | ||
163 | </if> | 163 | </if> |
164 | </select> | 164 | </select> |
165 | 165 | ||
166 | + <resultMap id="BaseResultMap" type="com.sincere.haikangface.bean.test.SaveStudentBak"> | ||
167 | + <!-- | ||
168 | + WARNING - @mbg.generated | ||
169 | + --> | ||
170 | + <id column="id" jdbcType="INTEGER" property="id"/> | ||
171 | + <result column="name" property="name"/> | ||
172 | + <result column="user_id" property="userId"/> | ||
173 | + <result column="card_num" property="cardNum"/> | ||
174 | + <result column="class_name" property="className"/> | ||
175 | + <result column="school_Id" property="schoolId"/> | ||
176 | + <result column="status" property="status"/> | ||
177 | + <result column="client_id" property="clientId"/> | ||
178 | + </resultMap> | ||
179 | + | ||
180 | + <insert id="insertStudent" parameterType="com.sincere.haikangface.bean.test.SaveStudentBak"> | ||
181 | + insert into sz_student_bak values (#{name},#{userId},#{cardNum},#{clientId},#{className},#{status},#{schoolId}) | ||
182 | + </insert> | ||
183 | + | ||
184 | + <select id="selectStudentList" resultMap="BaseResultMap"> | ||
185 | + select * from sz_student_bak where status = 2 | ||
186 | + </select> | ||
187 | + | ||
188 | + <update id="updateStudent" parameterType="java.lang.Integer"> | ||
189 | + update sz_student_bak set status = 1 where id = #{id} | ||
190 | + </update> | ||
166 | </mapper> | 191 | </mapper> |
cloud/haikangface/src/test/java/com/sincere/haikangface/HaikangfaceApplicationTests.java
1 | package com.sincere.haikangface; | 1 | package com.sincere.haikangface; |
2 | 2 | ||
3 | +import com.alibaba.fastjson.JSONObject; | ||
3 | import com.drew.imaging.jpeg.JpegMetadataReader; | 4 | import com.drew.imaging.jpeg.JpegMetadataReader; |
4 | import com.drew.imaging.jpeg.JpegProcessingException; | 5 | import com.drew.imaging.jpeg.JpegProcessingException; |
5 | import com.drew.metadata.Directory; | 6 | import com.drew.metadata.Directory; |
@@ -9,6 +10,7 @@ import com.drew.metadata.exif.ExifDirectory; | @@ -9,6 +10,7 @@ import com.drew.metadata.exif.ExifDirectory; | ||
9 | import com.sincere.haikangface.admindao.ZuoyeAdminDao; | 10 | import com.sincere.haikangface.admindao.ZuoyeAdminDao; |
10 | import com.sincere.haikangface.bean.*; | 11 | import com.sincere.haikangface.bean.*; |
11 | import com.sincere.haikangface.bean.homework.QuestionBean; | 12 | import com.sincere.haikangface.bean.homework.QuestionBean; |
13 | +import com.sincere.haikangface.bean.test.SaveStudentBak; | ||
12 | import com.sincere.haikangface.bean.xiaoan.AttendanceRecordsSS; | 14 | import com.sincere.haikangface.bean.xiaoan.AttendanceRecordsSS; |
13 | import com.sincere.haikangface.bean.xiaoan.CreditCardRecordsSS; | 15 | import com.sincere.haikangface.bean.xiaoan.CreditCardRecordsSS; |
14 | import com.sincere.haikangface.dao.DeviceDao; | 16 | import com.sincere.haikangface.dao.DeviceDao; |
@@ -16,7 +18,9 @@ import com.sincere.haikangface.dao.UserDao; | @@ -16,7 +18,9 @@ import com.sincere.haikangface.dao.UserDao; | ||
16 | import com.sincere.haikangface.dao.ZuoYeDao; | 18 | import com.sincere.haikangface.dao.ZuoYeDao; |
17 | import com.sincere.haikangface.service.impl.BaseService; | 19 | import com.sincere.haikangface.service.impl.BaseService; |
18 | import com.sincere.haikangface.utils.ApiUtil; | 20 | import com.sincere.haikangface.utils.ApiUtil; |
21 | +import com.sincere.haikangface.utils.DateUtils; | ||
19 | import com.sincere.haikangface.xiananDao.SendRecordDao; | 22 | import com.sincere.haikangface.xiananDao.SendRecordDao; |
23 | +import org.apache.commons.lang3.RandomStringUtils; | ||
20 | import org.bouncycastle.asn1.cms.MetaData; | 24 | import org.bouncycastle.asn1.cms.MetaData; |
21 | import org.hibernate.validator.constraints.LuhnCheck; | 25 | import org.hibernate.validator.constraints.LuhnCheck; |
22 | import org.junit.Test; | 26 | import org.junit.Test; |
@@ -74,10 +78,37 @@ public class HaikangfaceApplicationTests { | @@ -74,10 +78,37 @@ public class HaikangfaceApplicationTests { | ||
74 | //艺术 | 78 | //艺术 |
75 | // String deviceIds = "567176463869,567176463898,567176463903,567176463892"; | 79 | // String deviceIds = "567176463869,567176463898,567176463903,567176463892"; |
76 | Integer schoolId = 1066; | 80 | Integer schoolId = 1066; |
77 | -// baseService.clearStudent(schoolId,deviceIds); | 81 | + baseService.clearStudent(schoolId,deviceIds); |
78 | baseService.clearStudent2(schoolId); | 82 | baseService.clearStudent2(schoolId); |
79 | } | 83 | } |
80 | 84 | ||
85 | + @Test | ||
86 | + public void checkFaceSend() { | ||
87 | + String deviceIds = "694642005671,694642215671,687425355671,687425325671,338652895671,687425135671,ytj694642375671,338652415671,687425265671,ytj687425345671,338652515671,694642555671,ytj694642105671,338653105671,ytj687425415671,ytj687425155671,740456495671,694642135671,ytj687425395671,687425225671"; | ||
88 | + //下发设备集合 | ||
89 | + List<String> deviceList= new ArrayList<>(Arrays.asList(deviceIds.split(","))); | ||
90 | + List<StudentBean> studentBeans = userDao.getStudentBySchoolId(865); | ||
91 | + studentBeans.stream().distinct().forEach(studentBean -> { | ||
92 | + String name = studentBean.getName(); | ||
93 | + String userId = studentBean.getUser_id(); | ||
94 | + String cardNum = studentBean.getStudent_num(); | ||
95 | + String className = studentBean.getClass_name(); | ||
96 | + for(String s : deviceList){ | ||
97 | + List<SendRecordBean> sendRecordBeans = sendRecordDao.getRecordIsExit(s,cardNum,userId); | ||
98 | + if(CollectionUtils.isEmpty(sendRecordBeans)){ | ||
99 | + SaveStudentBak saveStudentBak = new SaveStudentBak(); | ||
100 | + saveStudentBak.setCardNum(cardNum); | ||
101 | + saveStudentBak.setClientId(s); | ||
102 | + saveStudentBak.setUserId(userId); | ||
103 | + saveStudentBak.setName(name); | ||
104 | + saveStudentBak.setClassName(className); | ||
105 | + saveStudentBak.setStatus(2); | ||
106 | + userDao.insertStudent(saveStudentBak); | ||
107 | + } | ||
108 | + } | ||
109 | + }); | ||
110 | + } | ||
111 | + | ||
81 | public String splicingZero(String str, int totalLenght) { | 112 | public String splicingZero(String str, int totalLenght) { |
82 | int strLenght = str.length(); | 113 | int strLenght = str.length(); |
83 | String strReturn = str; | 114 | String strReturn = str; |
@@ -137,4 +168,102 @@ public class HaikangfaceApplicationTests { | @@ -137,4 +168,102 @@ public class HaikangfaceApplicationTests { | ||
137 | } | 168 | } |
138 | } | 169 | } |
139 | } | 170 | } |
171 | + | ||
172 | + @Test | ||
173 | + public void test() { | ||
174 | + List<StudentBean> students = userDao.getStudentBySchoolId(12); | ||
175 | + int i = 0; | ||
176 | + for(StudentBean studentBean : students){ | ||
177 | + String time = DateUtils.date2String(new Date(),"yyyyMMddHHmm"); | ||
178 | + String randomString = RandomStringUtils.randomNumeric(4); | ||
179 | + String studentCode = "YX"+time+randomString+".png"; | ||
180 | + String photo = studentBean.getPhoto(); | ||
181 | + System.out.println("源文件:" + photo); | ||
182 | + //以学籍号为名的文件名 | ||
183 | + String fileName = photo.substring(photo.lastIndexOf("/") + 1,photo.length()); | ||
184 | + //100服务器人脸照绝对路径 | ||
185 | + //100服务器人脸照绝对路径 | ||
186 | + String path_1 = "E:\\wwwhtdocs\\SmartCampus\\face17e50\\School12\\Student"; | ||
187 | + String path_2 = "E:\\wwwhtdocs\\SmartCampus\\face17e5\\School12\\Student"; | ||
188 | + String path_3 = "E:\\wwwhtdocs\\SmartCampus\\f0i5l7e5\\"; | ||
189 | + String filePath =""; | ||
190 | + String filePath2 =""; | ||
191 | + if(photo.indexOf("f0i5l7e5")!=-1){ | ||
192 | + String afterStr = photo.split("f0i5l7e5/")[1].replace("/","\\"); | ||
193 | + filePath = path_3 + afterStr; | ||
194 | + filePath2 = path_3 + studentCode; | ||
195 | + } | ||
196 | + if(photo.indexOf("face17e5")!=-1){ | ||
197 | + filePath = path_2 + "\\" + fileName; | ||
198 | + filePath2 = path_2 + "\\" + studentCode; | ||
199 | + } | ||
200 | + if(photo.indexOf("face17e50")!=-1){ | ||
201 | + filePath = path_1 + "\\" + fileName; | ||
202 | + filePath2 = path_1 + "\\" + studentCode; | ||
203 | + } | ||
204 | + if(filePath.indexOf("?v=")!=-1){ | ||
205 | + filePath = filePath.split("\\?")[0]; | ||
206 | + } | ||
207 | + File file = new File(filePath.trim());//图片 | ||
208 | + if (file.exists()) { | ||
209 | + //原始文件路径 | ||
210 | + String srcPath = file.getAbsolutePath(); | ||
211 | + System.out.println("文件名:" + fileName + ", 学籍号:" + fileName.split("\\.")[0]); | ||
212 | + //复制文件 | ||
213 | + copy(srcPath,filePath2); | ||
214 | + String savePath = "http://campus.myjxt.com//" + filePath2; | ||
215 | + studentBean.setPhoto(savePath); | ||
216 | + userDao.updateUser(studentBean.getUser_id(), savePath); | ||
217 | + file.delete(); | ||
218 | + i++; | ||
219 | + } | ||
220 | + if(i==1){ | ||
221 | + System.out.println(filePath); | ||
222 | + return; | ||
223 | + } | ||
224 | + } | ||
225 | + } | ||
226 | + | ||
227 | + public static void copy(String srcPathStr, String desPathStr) { | ||
228 | + //获取源文件的名称 | ||
229 | + try { | ||
230 | + FileInputStream fis = new FileInputStream(srcPathStr);//创建输入流对象 | ||
231 | + FileOutputStream fos = new FileOutputStream(desPathStr); //创建输出流对象 | ||
232 | + byte datas[] = new byte[1024*8];//创建搬运工具 | ||
233 | + int len = 0;//创建长度 | ||
234 | + while((len = fis.read(datas))!=-1)//循环读取数据 | ||
235 | + { | ||
236 | + fos.write(datas,0,len); | ||
237 | + } | ||
238 | + fis.close();//释放资源 | ||
239 | + fis.close();//释放资源 | ||
240 | + } | ||
241 | + catch (Exception e) | ||
242 | + { | ||
243 | + e.printStackTrace(); | ||
244 | + } | ||
245 | + } | ||
246 | + | ||
247 | + | ||
248 | + @Test | ||
249 | + public void send2() { | ||
250 | + try { | ||
251 | + String api = "http://yixiao.198.hmkj.com.cn/index.php/Attend/send"; | ||
252 | + RestTemplate restTemplate = new RestTemplate(); | ||
253 | + MultiValueMap<String, Object> map = new LinkedMultiValueMap<>(); | ||
254 | + map.add("name", "测试"); | ||
255 | + map.add("xuehao", "1122"); | ||
256 | + map.add("time", "2022-02-10 09:09:00"); | ||
257 | + map.add("state", 1); | ||
258 | + HttpHeaders headers = new HttpHeaders(); | ||
259 | + headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED); | ||
260 | + HttpEntity<MultiValueMap<String, Object>> param = new HttpEntity<>(map, headers); | ||
261 | + ResponseEntity<String> response = restTemplate.postForEntity(api, param, String.class); | ||
262 | + String body = response.getBody(); | ||
263 | + System.out.println(body); | ||
264 | + } catch (Exception e) { | ||
265 | + e.printStackTrace(); | ||
266 | + System.out.println("考勤失败"); | ||
267 | + } | ||
268 | + } | ||
140 | } | 269 | } |