Commit 09102d07086f15c4783f79817baf57128e939682
1 parent
4b0a4282
Exists in
master
修改提交
Showing
5 changed files
with
183 additions
and
2 deletions
Show diff stats
cloud/dahua/src/main/java/com/example/dahua/MyTask.java
... | ... | @@ -478,9 +478,7 @@ public class MyTask implements ApplicationRunner { |
478 | 478 | //刷卡结果,1表示成功, 0表示失败 |
479 | 479 | int status = msg.bStatus; |
480 | 480 | |
481 | - log.info("考勤状态:{},学校:{},设备ID: {},学生信息:{}",status,schoolId,szSn,new Gson().toJson(userInfoBean)); | |
482 | 481 | if(szSn.startsWith("ytj")) { |
483 | - log.info("考勤进来了,学校:{},设备ID: {},学生信息:{}",schoolId,szSn,new Gson().toJson(userInfoBean)); | |
484 | 482 | // 艺校考勤OA |
485 | 483 | if(schoolId == 12 && status ==1){ |
486 | 484 | int intOrOut = eventType ==1? 1 : 2; | ... | ... |
cloud/dahua/src/main/java/com/example/dahua/bean/yx/FaceBean.java
0 → 100644
... | ... | @@ -0,0 +1,105 @@ |
1 | +package com.example.dahua.bean.yx; | |
2 | + | |
3 | +import java.util.Date; | |
4 | + | |
5 | +public class FaceBean { | |
6 | + private String deviceId; | |
7 | + private String userId; | |
8 | + private String Num; | |
9 | + private String Name; | |
10 | + private Date time; | |
11 | + private String schoolName; | |
12 | + private Integer schoolId; | |
13 | + private Integer userType; | |
14 | + private Integer deviceType; | |
15 | + private Integer status; | |
16 | + private Integer channel; | |
17 | + | |
18 | + public String getDeviceId() { | |
19 | + return deviceId; | |
20 | + } | |
21 | + | |
22 | + public void setDeviceId(String deviceId) { | |
23 | + this.deviceId = deviceId; | |
24 | + } | |
25 | + | |
26 | + public String getUserId() { | |
27 | + return userId; | |
28 | + } | |
29 | + | |
30 | + public void setUserId(String userId) { | |
31 | + this.userId = userId; | |
32 | + } | |
33 | + | |
34 | + public String getNum() { | |
35 | + return Num; | |
36 | + } | |
37 | + | |
38 | + public void setNum(String num) { | |
39 | + Num = num; | |
40 | + } | |
41 | + | |
42 | + public String getName() { | |
43 | + return Name; | |
44 | + } | |
45 | + | |
46 | + public void setName(String name) { | |
47 | + Name = name; | |
48 | + } | |
49 | + | |
50 | + public Date getTime() { | |
51 | + return time; | |
52 | + } | |
53 | + | |
54 | + public void setTime(Date time) { | |
55 | + this.time = time; | |
56 | + } | |
57 | + | |
58 | + public String getSchoolName() { | |
59 | + return schoolName; | |
60 | + } | |
61 | + | |
62 | + public void setSchoolName(String schoolName) { | |
63 | + this.schoolName = schoolName; | |
64 | + } | |
65 | + | |
66 | + public Integer getSchoolId() { | |
67 | + return schoolId; | |
68 | + } | |
69 | + | |
70 | + public void setSchoolId(Integer schoolId) { | |
71 | + this.schoolId = schoolId; | |
72 | + } | |
73 | + | |
74 | + public Integer getUserType() { | |
75 | + return userType; | |
76 | + } | |
77 | + | |
78 | + public void setUserType(Integer userType) { | |
79 | + this.userType = userType; | |
80 | + } | |
81 | + | |
82 | + public Integer getDeviceType() { | |
83 | + return deviceType; | |
84 | + } | |
85 | + | |
86 | + public void setDeviceType(Integer deviceType) { | |
87 | + this.deviceType = deviceType; | |
88 | + } | |
89 | + | |
90 | + public Integer getStatus() { | |
91 | + return status; | |
92 | + } | |
93 | + | |
94 | + public void setStatus(Integer status) { | |
95 | + this.status = status; | |
96 | + } | |
97 | + | |
98 | + public Integer getChannel() { | |
99 | + return channel; | |
100 | + } | |
101 | + | |
102 | + public void setChannel(Integer channel) { | |
103 | + this.channel = channel; | |
104 | + } | |
105 | +} | ... | ... |
cloud/dahua/src/main/java/com/example/dahua/xiananDao/SearchMapper.java
1 | 1 | package com.example.dahua.xiananDao; |
2 | 2 | |
3 | 3 | import com.example.dahua.bean.CheckIn; |
4 | +import com.example.dahua.bean.yx.FaceBean; | |
4 | 5 | |
5 | 6 | public interface SearchMapper { |
6 | 7 | /** |
... | ... | @@ -16,4 +17,6 @@ public interface SearchMapper { |
16 | 17 | void insertSS(String user_id,String school_id,String customerId,String card_num,Integer card_type,Integer outof,String intime,String cid,String class_id,String attendance_id, |
17 | 18 | String name,String mobile,String class_name,String sex,String systime); |
18 | 19 | |
20 | + void insertFace(FaceBean faceBean); | |
21 | + | |
19 | 22 | } | ... | ... |
cloud/dahua/src/main/resources/xiaoanmapper/SearchMapper.xml
... | ... | @@ -73,4 +73,8 @@ |
73 | 73 | ) |
74 | 74 | </insert> |
75 | 75 | |
76 | + <insert id="insertFace" parameterType="com.example.dahua.bean.yx.FaceBean"> | |
77 | + insert into Face_SendRecord values (#{deviceId},#{userId},#{Num},#{Name},#{time},#{schoolName},null,#{schoolId},null,null,#{userType},#{deviceType},#{status},#{channel}) | |
78 | + </insert> | |
79 | + | |
76 | 80 | </mapper> |
77 | 81 | \ No newline at end of file | ... | ... |
cloud/dahua/src/test/java/com/example/dahua/DahuaApplicationTests.java
... | ... | @@ -4,10 +4,14 @@ import com.alibaba.fastjson.JSON; |
4 | 4 | |
5 | 5 | import com.example.dahua.async.SendUserInfoTask; |
6 | 6 | import com.example.dahua.bean.*; |
7 | +import com.example.dahua.bean.yx.FaceBean; | |
8 | +import com.example.dahua.bean.yx.ImportStudent; | |
7 | 9 | import com.example.dahua.dao.TestDao; |
8 | 10 | import com.example.dahua.dao.UserDao; |
9 | 11 | import com.example.dahua.mqtt.MqttManager; |
10 | 12 | import com.example.dahua.service.UserService; |
13 | +import com.example.dahua.service.imp.BaseService; | |
14 | +import com.example.dahua.xiananDao.SearchMapper; | |
11 | 15 | import com.example.dahua.xiananDao.SendRecordDao; |
12 | 16 | import org.apache.http.util.TextUtils; |
13 | 17 | import org.junit.Test; |
... | ... | @@ -21,10 +25,13 @@ import org.springframework.http.HttpHeaders; |
21 | 25 | import org.springframework.http.MediaType; |
22 | 26 | import org.springframework.http.ResponseEntity; |
23 | 27 | import org.springframework.test.context.junit4.SpringRunner; |
28 | +import org.springframework.util.StringUtils; | |
24 | 29 | import org.springframework.web.client.RestTemplate; |
25 | 30 | |
31 | +import javax.annotation.Resource; | |
26 | 32 | import java.io.*; |
27 | 33 | import java.util.*; |
34 | +import java.util.stream.Collectors; | |
28 | 35 | |
29 | 36 | @RunWith(SpringRunner.class) |
30 | 37 | @SpringBootTest |
... | ... | @@ -510,4 +517,68 @@ public class DahuaApplicationTests { |
510 | 517 | } |
511 | 518 | } |
512 | 519 | |
520 | + @Resource | |
521 | + private BaseService baseService; | |
522 | + @Resource | |
523 | + private SearchMapper searchMapper; | |
524 | + | |
525 | + @Test | |
526 | + public void test8(){ | |
527 | + //根据类型获取下发用户信息 | |
528 | + String deviceIds = "ytj7locb3apaj33b6a,ytj7locb3apaj412af,ytj7locb3apaj76210,ytj7locb3apajb69c3"; | |
529 | +// String deviceIds = "ytj7locb3apaj8ob3c,ytj7locb3apaj5cao8,ytj7locb3apaj7fc35,ytj7locb3apajdb8f4"; | |
530 | + List<String> deviceList = new ArrayList<>(Arrays.asList(deviceIds.split(","))); | |
531 | + List<ImportStudent> studentBeanList = baseService.getYxStudentList(12,"B幢"); | |
532 | + System.out.println("统计共有下发用户数量:{}"+studentBeanList.size()); | |
533 | + studentBeanList.stream() | |
534 | + .filter(importStudent -> !StringUtils.isEmpty(importStudent.getPhoto())) | |
535 | + .forEach(importStudent -> { | |
536 | + System.out.println(importStudent.getName()); | |
537 | + deviceList.stream().forEach(s -> { | |
538 | + FaceBean faceBean = new FaceBean(); | |
539 | + faceBean.setDeviceId(s); | |
540 | + faceBean.setName(importStudent.getName()); | |
541 | + faceBean.setNum(importStudent.getCardNum()); | |
542 | + faceBean.setUserId(importStudent.getUserId()); | |
543 | + faceBean.setSchoolId(12); | |
544 | + faceBean.setSchoolName("绍兴艺术学校"); | |
545 | + faceBean.setChannel(1); | |
546 | + faceBean.setStatus(1); | |
547 | + faceBean.setDeviceType(29); | |
548 | + faceBean.setTime(new Date()); | |
549 | + searchMapper.insertFace(faceBean); | |
550 | + }); | |
551 | + }); | |
552 | + } | |
553 | + | |
554 | + @Test | |
555 | + public void test9(){ | |
556 | + //根据类型获取下发用户信息 | |
557 | +// String deviceIds = "ytj7locb3apaj33b6a,ytj7locb3apaj412af,ytj7locb3apaj76210,ytj7locb3apajb69c3"; | |
558 | + String deviceIds = "ytj7locb3apaj8ob3c,ytj7locb3apaj5cao8,ytj7locb3apaj7fc35,ytj7locb3apajdb8f4"; | |
559 | + List<String> deviceList = new ArrayList<>(Arrays.asList(deviceIds.split(","))); | |
560 | + List<StudentBean> studentBeanList = baseService.getTeacherList(12); | |
561 | + System.out.println("统计共有下发用户数量: "+studentBeanList.size()); | |
562 | + studentBeanList.stream() | |
563 | + .filter(studentBean -> !StringUtils.isEmpty(studentBean.getFace())) | |
564 | + .forEach(studentBean -> { | |
565 | + System.out.println(studentBean.getName()); | |
566 | + deviceList.stream().forEach(s -> { | |
567 | + FaceBean faceBean = new FaceBean(); | |
568 | + faceBean.setDeviceId(s); | |
569 | + faceBean.setName(studentBean.getName()); | |
570 | + faceBean.setNum(studentBean.getTeacher_num()); | |
571 | + faceBean.setUserId(studentBean.getUser_id()); | |
572 | + faceBean.setSchoolId(12); | |
573 | + faceBean.setSchoolName("绍兴艺术学校"); | |
574 | + faceBean.setChannel(1); | |
575 | + faceBean.setStatus(1); | |
576 | + faceBean.setDeviceType(29); | |
577 | + faceBean.setUserType(1); | |
578 | + faceBean.setTime(new Date()); | |
579 | + searchMapper.insertFace(faceBean); | |
580 | + }); | |
581 | + }); | |
582 | + } | |
583 | + | |
513 | 584 | } | ... | ... |