Commit 49d72e07df4a4c166417608ff5181b88baf2d48f
1 parent
410a48a6
Exists in
master
考勤代码修改
Showing
6 changed files
with
74 additions
and
72 deletions
Show diff stats
cloud/dahua/src/main/java/com/example/dahua/MyTask.java
1 | 1 | package com.example.dahua; |
2 | 2 | |
3 | 3 | import com.example.dahua.bean.*; |
4 | -import com.example.dahua.dao.SearchDao; | |
5 | 4 | import com.example.dahua.dao.UserDao; |
6 | 5 | import com.example.dahua.lib.NetSDKLib; |
7 | 6 | import com.example.dahua.lib.ToolKits; |
8 | 7 | import com.example.dahua.lib.Utils; |
9 | 8 | import com.example.dahua.module.AutoRegisterModule; |
10 | -import com.example.dahua.module.FaceRecognitionModule; | |
11 | 9 | import com.example.dahua.module.GateModule; |
12 | 10 | import com.example.dahua.module.LoginModule; |
13 | 11 | import com.example.dahua.service.AttendanceService; |
14 | 12 | import com.example.dahua.utils.DateUtils; |
15 | 13 | import com.example.dahua.utils.FileUtils; |
14 | +import com.example.dahua.xiananDao.SearchMapper; | |
16 | 15 | import com.example.dahua.xiananDao.SendRecordDao; |
17 | 16 | import com.sun.jna.Pointer; |
17 | +import lombok.extern.slf4j.Slf4j; | |
18 | 18 | import org.springframework.beans.factory.annotation.Autowired; |
19 | 19 | import org.springframework.boot.ApplicationArguments; |
20 | 20 | import org.springframework.boot.ApplicationRunner; |
... | ... | @@ -32,6 +32,7 @@ import java.util.*; |
32 | 32 | import java.util.List; |
33 | 33 | |
34 | 34 | @Component |
35 | +@Slf4j | |
35 | 36 | public class MyTask implements ApplicationRunner { |
36 | 37 | |
37 | 38 | // 主动注册监听回调 |
... | ... | @@ -59,7 +60,7 @@ public class MyTask implements ApplicationRunner { |
59 | 60 | SendRecordDao sendRecordDao; |
60 | 61 | |
61 | 62 | @Autowired |
62 | - SearchDao searchDao; | |
63 | + SearchMapper searchMapper; | |
63 | 64 | |
64 | 65 | @Autowired |
65 | 66 | UserDao userDao; |
... | ... | @@ -390,7 +391,7 @@ public class MyTask implements ApplicationRunner { |
390 | 391 | checkIn.setFunNo(8); |
391 | 392 | checkIn.setFlag(eventType == 2 ? 1 : 0); |
392 | 393 | checkIn.setCheckTime(eventTime); |
393 | - searchDao.checkIn(checkIn); | |
394 | + searchMapper.checkIn(checkIn); | |
394 | 395 | if (checkIn.getIsSuccess() == 1) { |
395 | 396 | //考勤成功 |
396 | 397 | String content = "考勤成功!,设备:" + deviceId + "卡号:" + cardNo + "方向:" + (eventType == 1 ? "进门" : "出门") + "______" + eventTime; |
... | ... | @@ -404,10 +405,10 @@ public class MyTask implements ApplicationRunner { |
404 | 405 | } |
405 | 406 | } else { |
406 | 407 | //判断是否请假 |
407 | - String studentNum = searchDao.checkLeave(cardNo); | |
408 | + String studentNum = userDao.checkLeave(cardNo); | |
408 | 409 | if (org.apache.commons.lang.StringUtils.isNotBlank(studentNum)) { |
409 | 410 | //短信信息 |
410 | - Message mobileMessage = searchDao.selectByParentMobile(cardNo); | |
411 | + Message mobileMessage = userDao.selectByParentMobile(cardNo); | |
411 | 412 | if (mobileMessage.getSchoolId() == 4) { |
412 | 413 | //才发送短信 |
413 | 414 | ShortMsg shortMsg = new ShortMsg(); |
... | ... | @@ -421,18 +422,19 @@ public class MyTask implements ApplicationRunner { |
421 | 422 | } else { |
422 | 423 | shortMsg.setMsg(mobileMessage.getName() + "家长您好,你的孩子于" + DateUtils.date2String(new Date(), DateUtils.format2) + "请假后进校,请知晓;"); |
423 | 424 | } |
424 | - searchDao.insertMessage(shortMsg.getTableName(),shortMsg.getSchoolId()+"",shortMsg.getMobile(),shortMsg.getMsg()); | |
425 | + userDao.insertMessage(shortMsg.getTableName(),shortMsg.getSchoolId()+"",shortMsg.getMobile(),shortMsg.getMsg()); | |
425 | 426 | } |
426 | 427 | } else { |
427 | 428 | //若即不成功,也不是请假,则按刷卡异常处理 |
428 | - User user = searchDao.selectUserByCardNum(cardNo).get(0); | |
429 | + User user = userDao.selectUserByCardNum(cardNo).get(0); | |
429 | 430 | if(user ==null ){ |
430 | 431 | System.out.println("卡号"+cardNo+"没找到对应学生或老师"); |
431 | 432 | } |
433 | + int deviceType; | |
432 | 434 | if (deviceId.startsWith("ytj")){ |
433 | - deviceId = "29"; | |
435 | + deviceType = 29; | |
434 | 436 | }else { |
435 | - deviceId = "22"; | |
437 | + deviceType = 22; | |
436 | 438 | } |
437 | 439 | //失败记录 |
438 | 440 | SendRecordBean sendRecordBean = new SendRecordBean(); |
... | ... | @@ -448,7 +450,7 @@ public class MyTask implements ApplicationRunner { |
448 | 450 | sendRecordBean.setFailContent("人脸认证失败"); |
449 | 451 | sendRecordBean.setDeviceID(deviceId); |
450 | 452 | sendRecordDao.addFaceFail(sendRecordBean.getCustomerid(), sendRecordBean.getDeviceID(), sendRecordBean.getNum(), sendRecordBean.getName(), sendRecordBean.getTime(), |
451 | - sendRecordBean.getSchoolName(), sendRecordBean.getImgPath(), sendRecordBean.getSchoolId(), sendRecordBean.getFailContent(), sendRecordBean.getFailType(), sendRecordBean.getUserType(), 22); | |
453 | + sendRecordBean.getSchoolName(), sendRecordBean.getImgPath(), sendRecordBean.getSchoolId(), sendRecordBean.getFailContent(), sendRecordBean.getFailType(), sendRecordBean.getUserType(), deviceType); | |
452 | 454 | } |
453 | 455 | } |
454 | 456 | } | ... | ... |
cloud/dahua/src/main/java/com/example/dahua/dao/SearchDao.java
... | ... | @@ -1,55 +0,0 @@ |
1 | -package com.example.dahua.dao; | |
2 | - | |
3 | -import com.example.dahua.bean.CheckIn; | |
4 | -import com.example.dahua.bean.Message; | |
5 | -import com.example.dahua.bean.User; | |
6 | -import org.apache.ibatis.annotations.Param; | |
7 | -import org.apache.ibatis.annotations.Select; | |
8 | -import org.springframework.stereotype.Repository; | |
9 | - | |
10 | -import java.util.List; | |
11 | - | |
12 | -@Repository | |
13 | -public interface SearchDao { | |
14 | - /** | |
15 | - * 考勤推送存储过程 | |
16 | - * @param checkIn | |
17 | - * @return | |
18 | - */ | |
19 | - int checkIn(CheckIn checkIn); | |
20 | - | |
21 | - /** | |
22 | - * 获取学生信息 | |
23 | - * @param cardNum | |
24 | - * @return | |
25 | - */ | |
26 | - List<User> selectUserByCardNum(String cardNum); | |
27 | - | |
28 | - /** | |
29 | - * 获取卡号 | |
30 | - * @param cardNo | |
31 | - * @return | |
32 | - */ | |
33 | - @Select("select Top(1) StudentNum from HS_LeaveExaminePassList where StudentNum= #{cardNo} and GETDATE() <![CDATA[ > ]]> LeaveTime and GETDATE() <![CDATA[ < ]]> ReturnTime") | |
34 | - String checkLeave(@Param("cardNo") String cardNo); | |
35 | - | |
36 | - /** | |
37 | - * 获取学生父母电话 | |
38 | - * @param cardNo | |
39 | - * @return | |
40 | - */ | |
41 | - @Select("select school_id , ParentMobile , name from SZ_V_School_Student where student_num = #{cardNo}") | |
42 | - Message selectByParentMobile(@Param("cardNo") String cardNo); | |
43 | - | |
44 | - /** | |
45 | - * 插入短信发送表 | |
46 | - * @param tableName | |
47 | - * @param schoolId | |
48 | - * @param mobile | |
49 | - * @param msg | |
50 | - */ | |
51 | - @Select("insert into ${tableName} (SchoolID,Mobile,Msg,tdtype,Status,IsNeedSend,SendTime,intime) values (#{schoolId},#{mobile},#{msg},1,0,1,GETDATE(),GETDATE())") | |
52 | - void insertMessage(@Param("tableName") String tableName,@Param("schoolId") String schoolId,@Param("mobile") String mobile,@Param("msg") String msg); | |
53 | - | |
54 | - | |
55 | -} |
cloud/dahua/src/main/java/com/example/dahua/dao/UserDao.java
... | ... | @@ -169,4 +169,47 @@ public interface UserDao { |
169 | 169 | " where studentcode = #{studentcode} and school_id = #{school_id}\n" + |
170 | 170 | ")") |
171 | 171 | void updateStu(@Param("studentcode") String studentCode,@Param("httpUrl") String httpUrl,@Param("school_id")String school_id); |
172 | + | |
173 | + /** | |
174 | + * 获取学生信息 | |
175 | + * @param cardNum | |
176 | + * @return | |
177 | + */ | |
178 | + @Select(" select school_id , class_id ,name ,student_id from\n" + | |
179 | + " (select top 1 b.school_id, b.class_id, b.name, student_id from SZ_V_Card a\n" + | |
180 | + " inner join SZ_V_School_Student b on a.user_id = b.student_id\n" + | |
181 | + " and b.role_state = 1 where a.type = 2 and a.num = #{cardNum}\n" + | |
182 | + " union\n" + | |
183 | + " select top 1 b.school_id, 0 as class_id, b.name,b.teacher_id as student_id from SZ_V_Card a\n" + | |
184 | + " inner join SZ_V_School_Teacher b on a.user_id = b.teacher_id\n" + | |
185 | + " and b.role_state = 1 where a.type = 0 and a.num = #{cardNum}\n" + | |
186 | + " ) x ") | |
187 | + List<User> selectUserByCardNum(@Param("studentcode") String cardNum); | |
188 | + | |
189 | + /** | |
190 | + * 获取卡号 | |
191 | + * @param cardNo | |
192 | + * @return | |
193 | + */ | |
194 | + @Select("select Top(1) StudentNum from HS_LeaveExaminePassList where StudentNum= #{cardNo} and GETDATE() <![CDATA[ > ]]> LeaveTime and GETDATE() <![CDATA[ < ]]> ReturnTime") | |
195 | + String checkLeave(@Param("cardNo") String cardNo); | |
196 | + | |
197 | + /** | |
198 | + * 获取学生父母电话 | |
199 | + * @param cardNo | |
200 | + * @return | |
201 | + */ | |
202 | + @Select("select school_id , ParentMobile , name from SZ_V_School_Student where student_num = #{cardNo}") | |
203 | + Message selectByParentMobile(@Param("cardNo") String cardNo); | |
204 | + | |
205 | + /** | |
206 | + * 插入短信发送表 | |
207 | + * @param tableName | |
208 | + * @param schoolId | |
209 | + * @param mobile | |
210 | + * @param msg | |
211 | + */ | |
212 | + @Insert("insert into ${tableName} (SchoolID,Mobile,Msg,tdtype,Status,IsNeedSend,SendTime,intime) values (#{schoolId},#{mobile},#{msg},1,0,1,GETDATE(),GETDATE())") | |
213 | + void insertMessage(@Param("tableName") String tableName, @Param("schoolId") String schoolId, @Param("mobile") String mobile, @Param("msg") String msg); | |
214 | + | |
172 | 215 | } | ... | ... |
cloud/dahua/src/main/java/com/example/dahua/dbconfig/MessageDataSourceConfig.java
... | ... | @@ -10,7 +10,6 @@ import org.springframework.context.annotation.Bean; |
10 | 10 | import org.springframework.context.annotation.Configuration; |
11 | 11 | import org.springframework.context.annotation.Primary; |
12 | 12 | import org.springframework.core.io.support.PathMatchingResourcePatternResolver; |
13 | -import org.springframework.jdbc.core.JdbcTemplate; | |
14 | 13 | |
15 | 14 | import javax.sql.DataSource; |
16 | 15 | |
... | ... | @@ -35,9 +34,4 @@ public class MessageDataSourceConfig { |
35 | 34 | |
36 | 35 | } |
37 | 36 | |
38 | - @Bean | |
39 | - public JdbcTemplate campusJdbcTemplate(@Qualifier("messageDataSource") DataSource dataSource) { | |
40 | - return new JdbcTemplate(dataSource); | |
41 | - } | |
42 | - | |
43 | 37 | } | ... | ... |
cloud/dahua/src/main/java/com/example/dahua/xiananDao/SearchMapper.java
0 → 100644
cloud/dahua/src/main/resources/application.yml
... | ... | @@ -41,8 +41,13 @@ mybatis: |
41 | 41 | xiaoan: |
42 | 42 | type-aliases-package: com.example.dahua.xiananDao |
43 | 43 | mapper-locations: classpath:xiaoanmapper/*.xml |
44 | + message: | |
45 | + type-aliases-package: com.example.dahua.dao | |
46 | + mapper-locations: classpath:mapper/*.xml | |
44 | 47 | config-location: classpath:mybatis-config.xml |
45 | 48 | |
49 | +#logging: | |
50 | +# config: classpath:logback-spring.xml | |
46 | 51 | |
47 | 52 | #haikangpic: E:\wwwhtdocs\HFface\FaceLogs\ |
48 | 53 | ... | ... |