Commit a949f8e829108ff717b085f428143fc96bbcf917
Exists in
master
Merge branch 'master' of http://git.shunzhi.net/taohd/mycloud
Showing
2 changed files
with
24 additions
and
8 deletions
Show diff stats
cloud/dahua/src/main/java/com/example/dahua/MyTask.java
| 1 | 1 | package com.example.dahua; |
| 2 | 2 | |
| 3 | +import com.example.dahua.async.MyScheduledTask; | |
| 3 | 4 | import com.example.dahua.bean.*; |
| 4 | 5 | import com.example.dahua.dao.UserDao; |
| 5 | 6 | import com.example.dahua.enums.EnumSendFaceType; |
| ... | ... | @@ -10,6 +11,7 @@ import com.example.dahua.lib.Utils; |
| 10 | 11 | import com.example.dahua.module.AutoRegisterModule; |
| 11 | 12 | import com.example.dahua.module.GateModule; |
| 12 | 13 | import com.example.dahua.module.LoginModule; |
| 14 | +import com.example.dahua.mqtt.MqttManager; | |
| 13 | 15 | import com.example.dahua.service.AttendanceService; |
| 14 | 16 | import com.example.dahua.utils.DateUtils; |
| 15 | 17 | import com.example.dahua.utils.FileUtils; |
| ... | ... | @@ -71,6 +73,9 @@ public class MyTask implements ApplicationRunner { |
| 71 | 73 | |
| 72 | 74 | public boolean isHasNewDevice = false;//判断是否有新设备上线 |
| 73 | 75 | |
| 76 | + @Autowired | |
| 77 | + private MyScheduledTask myScheduledTask; | |
| 78 | + | |
| 74 | 79 | @Override |
| 75 | 80 | public void run(ApplicationArguments args) throws Exception { |
| 76 | 81 | // 121.40.109.21 |
| ... | ... | @@ -318,7 +323,8 @@ public class MyTask implements ApplicationRunner { |
| 318 | 323 | ImageIO.write(gateBufferedImage, "png", new File(snapPicPath)); |
| 319 | 324 | } |
| 320 | 325 | log.info("设备ID: {},卡号: {},抓拍照片存储地址:{}" ,szSn,card,snapPicPath); |
| 321 | - if(isMatch(REGEX_POSITIVE_Symbol, szSn)){//验证设备id是否存在特殊字符 | |
| 326 | + //验证设备id是否存在特殊字符 | |
| 327 | + if(isMatch(REGEX_POSITIVE_Symbol, szSn)){ | |
| 322 | 328 | log.info("—设备ID异常: {},卡号: {}",szSn,card); |
| 323 | 329 | return 0; |
| 324 | 330 | } |
| ... | ... | @@ -327,12 +333,13 @@ public class MyTask implements ApplicationRunner { |
| 327 | 333 | if(org.apache.commons.lang.StringUtils.isNotBlank(schoolIdStr)){ |
| 328 | 334 | schoolId=Integer.parseInt(schoolIdStr); |
| 329 | 335 | } |
| 330 | - //卡号取反(大写) | |
| 331 | - //if(!szSn.startsWith("ytj")||(szSn.startsWith("ytj")&&schoolId==126&&schoolId==393)){ | |
| 336 | + /** | |
| 337 | + * 卡号取反(大写) | |
| 338 | + * 注:若设备为一体机、且非"126上虞城东小学、393上虞实验中学"学校,卡则取反 | |
| 339 | + */ | |
| 332 | 340 | if(szSn.startsWith("ytj")&&schoolId!=126&&schoolId!=393){ |
| 333 | 341 | card = card; |
| 334 | - } | |
| 335 | - else{ | |
| 342 | + } else{ | |
| 336 | 343 | card = cardNo(card); |
| 337 | 344 | } |
| 338 | 345 | //根据卡号获取卡身份信息 |
| ... | ... | @@ -353,10 +360,10 @@ public class MyTask implements ApplicationRunner { |
| 353 | 360 | } |
| 354 | 361 | |
| 355 | 362 | if(szSn.startsWith("ytj")) { |
| 356 | - | |
| 357 | 363 | // TODO 考勤记录 |
| 358 | 364 | //刷卡结果,1表示成功, 0表示失败 |
| 359 | 365 | int status = msg.bStatus; |
| 366 | + | |
| 360 | 367 | //门禁事件类型:1进2出 |
| 361 | 368 | int eventType = msg.emEventType; |
| 362 | 369 | //刷卡时间 |
| ... | ... | @@ -418,6 +425,7 @@ public class MyTask implements ApplicationRunner { |
| 418 | 425 | return isNum.matches(); |
| 419 | 426 | } |
| 420 | 427 | |
| 428 | + private static MqttManager mqttManager; | |
| 421 | 429 | /** |
| 422 | 430 | * 大华设备考勤记录 |
| 423 | 431 | * @param status |
| ... | ... | @@ -440,6 +448,14 @@ public class MyTask implements ApplicationRunner { |
| 440 | 448 | if (checkIn.getIsSuccess() == 1) { |
| 441 | 449 | //考勤成功 |
| 442 | 450 | String content = "考勤成功!,设备:" + deviceId + "卡号:" + cardNo + "方向:" + (eventType == 1 ? "进门" : "出门") + "______" + eventTime; |
| 451 | + | |
| 452 | + //一体机设备,抓拍到人脸,将人脸发送数据看板 | |
| 453 | + if(null == mqttManager){ | |
| 454 | + mqttManager = new MqttManager(); | |
| 455 | + mqttManager.init(); | |
| 456 | + } | |
| 457 | + myScheduledTask.sendMQMess(content); | |
| 458 | + | |
| 443 | 459 | //记录学生考勤签到记录 |
| 444 | 460 | FileUtils.getInstance().writeLogs(content, FileUtils.qiandaoSuccess); |
| 445 | 461 | } else { |
| ... | ... | @@ -473,7 +489,7 @@ public class MyTask implements ApplicationRunner { |
| 473 | 489 | //若即不成功,也不是请假,则按刷卡异常处理 |
| 474 | 490 | List<User> users = userDao.selectUserByCardNum(cardNo); |
| 475 | 491 | if(users.size()<1){ |
| 476 | - log.warn("考勤记录:卡号: {}没找到对应学生或老师,考勤时间: {}",cardNo,DateUtils.date2String(new Date(), DateUtils.format2)); | |
| 492 | + log.warn("考勤记录:卡号: {},没找到对应学生或老师,考勤时间: {}",cardNo,DateUtils.date2String(new Date(), DateUtils.format2)); | |
| 477 | 493 | return; |
| 478 | 494 | } |
| 479 | 495 | User user = users.get(0); | ... | ... |
cloud/dahua/src/main/java/com/example/dahua/async/MyScheduledTask.java
| ... | ... | @@ -235,7 +235,7 @@ public class MyScheduledTask { |
| 235 | 235 | |
| 236 | 236 | } |
| 237 | 237 | |
| 238 | - private void sendMQMess(String content) { | |
| 238 | + public void sendMQMess(String content) { | |
| 239 | 239 | String cardNum = content.substring(content.indexOf("卡号") + 3, content.indexOf("卡号") + 11); |
| 240 | 240 | |
| 241 | 241 | // System.out.println("cardNum:" + cardNum); | ... | ... |