Commit 9df247c3254ec2458795cfbe71eff5349e197bf3
1 parent
7fc4b9b6
Exists in
master
大华考勤需求提交
Showing
11 changed files
with
540 additions
and
14 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.bean.CardBean; | |
4 | -import com.example.dahua.bean.DeviceInfoBean; | |
5 | -import com.example.dahua.bean.TeacherBean; | |
6 | -import com.example.dahua.bean.UserInfoBean; | |
3 | +import com.example.dahua.bean.*; | |
4 | +import com.example.dahua.dao.SearchDao; | |
7 | 5 | import com.example.dahua.dao.UserDao; |
8 | 6 | import com.example.dahua.lib.NetSDKLib; |
9 | 7 | import com.example.dahua.lib.ToolKits; |
10 | 8 | import com.example.dahua.lib.Utils; |
11 | 9 | import com.example.dahua.module.AutoRegisterModule; |
10 | +import com.example.dahua.module.FaceRecognitionModule; | |
12 | 11 | import com.example.dahua.module.GateModule; |
13 | 12 | import com.example.dahua.module.LoginModule; |
14 | 13 | import com.example.dahua.service.AttendanceService; |
14 | +import com.example.dahua.utils.DateUtils; | |
15 | +import com.example.dahua.utils.FileUtils; | |
15 | 16 | import com.example.dahua.xiananDao.SendRecordDao; |
16 | 17 | import com.sun.jna.Pointer; |
17 | 18 | import org.springframework.beans.factory.annotation.Autowired; |
... | ... | @@ -58,6 +59,9 @@ public class MyTask implements ApplicationRunner { |
58 | 59 | SendRecordDao sendRecordDao; |
59 | 60 | |
60 | 61 | @Autowired |
62 | + SearchDao searchDao; | |
63 | + | |
64 | + @Autowired | |
61 | 65 | UserDao userDao; |
62 | 66 | |
63 | 67 | public boolean isHasNewDevice = false;//判断是否有新设备上线 |
... | ... | @@ -65,10 +69,15 @@ public class MyTask implements ApplicationRunner { |
65 | 69 | @Override |
66 | 70 | public void run(ApplicationArguments args) throws Exception { |
67 | 71 | // 121.40.109.21 |
72 | + // 打开工程,初始化 | |
73 | + LoginModule.init(disConnect, haveReConnect); | |
74 | + //自注册 | |
75 | + autoRegister(); | |
68 | 76 | |
69 | - LoginModule.init(disConnect, haveReConnect); // 打开工程,初始化 | |
70 | - | |
71 | - autoRegister();//自注册 | |
77 | + /** | |
78 | + * 考勤监听 | |
79 | + */ | |
80 | + kaoQinRecord(); | |
72 | 81 | |
73 | 82 | // System.out.println(" sendRecordDao:"+sendRecordDao.getSenSuccess()); |
74 | 83 | } |
... | ... | @@ -96,6 +105,8 @@ public class MyTask implements ApplicationRunner { |
96 | 105 | if (!StringUtils.isEmpty(deviceId)) { |
97 | 106 | attendanceService.updateConnectStateWithDevid(0, deviceId); |
98 | 107 | GateModule.stopRealLoadPic(lLongMap.get(deviceId)); |
108 | + //人脸识别、人脸检测事件 | |
109 | + FaceRecognitionModule.stopRealLoadPicture(lLongMap.get(deviceId)); | |
99 | 110 | lLongMap.remove(deviceId); |
100 | 111 | // devMap.remove(deviceId); |
101 | 112 | removeDevice(deviceId); |
... | ... | @@ -249,6 +260,22 @@ public class MyTask implements ApplicationRunner { |
249 | 260 | } |
250 | 261 | } |
251 | 262 | |
263 | + /** | |
264 | + * 考勤监听 | |
265 | + */ | |
266 | + public synchronized void kaoQinRecord() { | |
267 | + isHasNewDevice = false; | |
268 | + if (null != deviceInfoBeans && deviceInfoBeans.size() > 0) { | |
269 | + for (DeviceInfoBean dev : | |
270 | + deviceInfoBeans) { | |
271 | + if (lLongMap.get(dev.getDevcieId()).intValue() > 0) { | |
272 | + //人脸识别、人脸检测事件监听 | |
273 | + NetSDKLib.LLong lLong = FaceRecognitionModule.realLoadPicture(0, analyzerCallback); | |
274 | + } | |
275 | + } | |
276 | + } | |
277 | + } | |
278 | + | |
252 | 279 | |
253 | 280 | //智能订阅 |
254 | 281 | private AnalyzerDataCB analyzerCallback = new AnalyzerDataCB(); |
... | ... | @@ -277,11 +304,14 @@ public class MyTask implements ApplicationRunner { |
277 | 304 | if (dwAlarmType == NetSDKLib.EVENT_IVS_ACCESS_CTL) { |
278 | 305 | NetSDKLib.DEV_EVENT_ACCESS_CTL_INFO msg = new NetSDKLib.DEV_EVENT_ACCESS_CTL_INFO(); |
279 | 306 | ToolKits.GetPointerData(pAlarmInfo, msg); |
280 | - System.out.println("sda:" + new String(msg.szCardNo) + " 抓拍照片存储地址:"); | |
307 | + //卡号 | |
308 | + String card = new String(msg.szCardNo).trim(); | |
309 | + System.out.println("sda:" + card + " 抓拍照片存储地址:"); | |
310 | + | |
281 | 311 | try { |
282 | - String card = new String(msg.szCardNo).trim(); | |
283 | 312 | if (!StringUtils.isEmpty(card)) { |
284 | 313 | // 保存图片,获取图片缓存 |
314 | + // 图片服务器路径 | |
285 | 315 | String snapPicPath = path + "\\" + System.currentTimeMillis() + ".png"; // 保存图片地址 |
286 | 316 | byte[] buffer = pBuffer.getByteArray(0, dwBufSize); |
287 | 317 | ByteArrayInputStream byteArrInputGlobal = new ByteArrayInputStream(buffer); |
... | ... | @@ -289,19 +319,32 @@ public class MyTask implements ApplicationRunner { |
289 | 319 | if (gateBufferedImage != null) { |
290 | 320 | ImageIO.write(gateBufferedImage, "png", new File(snapPicPath)); |
291 | 321 | } |
322 | + //卡号取反(大写) | |
292 | 323 | card = cardNo(card); |
293 | - | |
294 | - CardBean cardBean = userDao.getCards(card);//根据卡号获取身份信息 | |
324 | + //根据卡号获取卡身份信息 | |
325 | + CardBean cardBean = userDao.getCards(card); | |
295 | 326 | String time = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()); |
296 | 327 | snapPicPath = snapPicPath.replaceFirst("\\.", "http://121.40.109.21:8991"); |
297 | 328 | snapPicPath = snapPicPath.replace("FaceRecoder", "image"); |
298 | - if (null != cardBean && cardBean.getType() == 0) {//老师 | |
329 | + if (null != cardBean && cardBean.getType() == 0) { | |
330 | + //老师人脸信息,保存人脸记录表 | |
299 | 331 | TeacherBean teacherBean = userDao.getTeacherWithId(cardBean.getUser_id()); |
300 | 332 | sendRecordDao.addFaceRecoder("", teacherBean.getUser_id(), teacherBean.getName(), snapPicPath, 1, time, card,""); |
301 | - } else if (null != cardBean && cardBean.getType() == 2) {//学生 | |
333 | + } else if (null != cardBean && cardBean.getType() == 2) { | |
334 | + //学生人脸信息,保存人脸记录表 | |
302 | 335 | UserInfoBean userInfoBean = userDao.getStudentWithid(cardBean.getUser_id()); |
303 | 336 | sendRecordDao.addFaceRecoder("", userInfoBean.getUser_id(), userInfoBean.getName(), snapPicPath, 1, time, card,""); |
304 | 337 | } |
338 | + | |
339 | + // TODO 考勤记录 | |
340 | + //刷卡结果,1表示成功, 0表示失败 | |
341 | + int status = msg.bStatus; | |
342 | + //门禁事件类型:1进2出 | |
343 | + int eventType = msg.emEventType; | |
344 | + //刷卡时间 | |
345 | + String eventTime = msg.UTC.toStringTime(); | |
346 | + //保存考勤记录 | |
347 | + kaoQinRecord(status,eventType,card,"",eventTime,snapPicPath); | |
305 | 348 | } |
306 | 349 | |
307 | 350 | } catch (IOException e2) { |
... | ... | @@ -321,6 +364,7 @@ public class MyTask implements ApplicationRunner { |
321 | 364 | } |
322 | 365 | } |
323 | 366 | |
367 | + | |
324 | 368 | /** |
325 | 369 | * 卡号两两取反 |
326 | 370 | * |
... | ... | @@ -344,4 +388,84 @@ public class MyTask implements ApplicationRunner { |
344 | 388 | |
345 | 389 | } |
346 | 390 | |
391 | + /** | |
392 | + * 大华设备考勤记录 | |
393 | + * @param status | |
394 | + * @param eventType | |
395 | + * @param cardNo | |
396 | + * @param deviceId | |
397 | + * @param eventTime | |
398 | + * @param imageUrl | |
399 | + */ | |
400 | + public void kaoQinRecord(int status,int eventType,String cardNo,String deviceId,String eventTime,String imageUrl) { | |
401 | + if (status == 1) { | |
402 | + //有效刷卡调考勤存储过程 | |
403 | + CheckIn checkIn = new CheckIn(); | |
404 | + checkIn.setDeviceId(deviceId); | |
405 | + checkIn.setCardNo(cardNo); | |
406 | + checkIn.setFunNo(8); | |
407 | + checkIn.setFlag(eventType == 2 ? 1 : 0); | |
408 | + checkIn.setCheckTime(eventTime); | |
409 | + searchDao.checkIn(checkIn); | |
410 | + if (checkIn.getIsSuccess() == 1) { | |
411 | + //考勤成功 | |
412 | + String content = "考勤成功!,设备:" + deviceId + "卡号:" + cardNo + "方向:" + (eventType == 1 ? "进门" : "出门") + "______" + eventTime; | |
413 | + //记录学生考勤签到记录 | |
414 | + FileUtils.getInstance().writeLogs(content, FileUtils.qiandaoSuccess); | |
415 | + } else { | |
416 | + //考勤失败 | |
417 | + String content = "考勤失败!,设备:" + deviceId + "卡号:" + cardNo + "---" + checkIn.getOut(); | |
418 | + //记录学生考勤签到记录 | |
419 | + FileUtils.getInstance().writeLogs(content, FileUtils.qiandaoErr); | |
420 | + } | |
421 | + } else { | |
422 | + //判断是否请假 | |
423 | + String studentNum = searchDao.checkLeave(cardNo); | |
424 | + if (org.apache.commons.lang.StringUtils.isNotBlank(studentNum)) { | |
425 | + //短信信息 | |
426 | + Message mobileMessage = searchDao.selectByParentMobile(cardNo); | |
427 | + if (mobileMessage.getSchoolId() == 4) { | |
428 | + //才发送短信 | |
429 | + ShortMsg shortMsg = new ShortMsg(); | |
430 | + String tableSuffix = DateUtils.date2String(new Date(), DateUtils.format); | |
431 | + shortMsg.setTableName("smsNew" + tableSuffix); | |
432 | + shortMsg.setSchoolId(mobileMessage.getSchoolId()); | |
433 | + shortMsg.setMobile(mobileMessage.getParentMobile()); | |
434 | + if (eventType == 2) { | |
435 | + //出门 | |
436 | + shortMsg.setMsg(mobileMessage.getName() + "家长您好,你的孩子于" + DateUtils.date2String(new Date(), DateUtils.format2) + "请假后出校,请知晓;"); | |
437 | + } else { | |
438 | + shortMsg.setMsg(mobileMessage.getName() + "家长您好,你的孩子于" + DateUtils.date2String(new Date(), DateUtils.format2) + "请假后进校,请知晓;"); | |
439 | + } | |
440 | + searchDao.insertMessage(shortMsg.getTableName(),shortMsg.getSchoolId()+"",shortMsg.getMobile(),shortMsg.getMsg()); | |
441 | + } | |
442 | + } else { | |
443 | + //若即不成功,也不是请假,则按刷卡异常处理 | |
444 | + User user = searchDao.selectUserByCardNum(cardNo).get(0); | |
445 | + if(user ==null ){ | |
446 | + System.out.println("卡号"+cardNo+"没找到对应学生或老师"); | |
447 | + } | |
448 | + if (deviceId.startsWith("ytj")){ | |
449 | + deviceId = "29"; | |
450 | + }else { | |
451 | + deviceId = "22"; | |
452 | + } | |
453 | + //失败记录 | |
454 | + SendRecordBean sendRecordBean = new SendRecordBean(); | |
455 | + sendRecordBean.setSchoolId(user.getSchoolId()); | |
456 | + sendRecordBean.setSchoolName(userDao.getSchoolName(String.valueOf(user.getSchoolId()))); | |
457 | + sendRecordBean.setTime(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date())); | |
458 | + sendRecordBean.setUserType(2); | |
459 | + sendRecordBean.setNum(cardNo); | |
460 | + sendRecordBean.setName(user.getName()); | |
461 | + sendRecordBean.setImgPath(imageUrl); | |
462 | + sendRecordBean.setCustomerid(String.valueOf(user.getStudentId())); | |
463 | + sendRecordBean.setFailType(8); | |
464 | + sendRecordBean.setFailContent("人脸认证失败"); | |
465 | + sendRecordBean.setDeviceID(deviceId); | |
466 | + sendRecordDao.addFaceFail(sendRecordBean.getCustomerid(), sendRecordBean.getDeviceID(), sendRecordBean.getNum(), sendRecordBean.getName(), sendRecordBean.getTime(), | |
467 | + sendRecordBean.getSchoolName(), sendRecordBean.getImgPath(), sendRecordBean.getSchoolId(), sendRecordBean.getFailContent(), sendRecordBean.getFailType(), sendRecordBean.getUserType(), 22); | |
468 | + } | |
469 | + } | |
470 | + } | |
347 | 471 | } | ... | ... |
cloud/dahua/src/main/java/com/example/dahua/bean/CheckIn.java
0 → 100644
... | ... | @@ -0,0 +1,74 @@ |
1 | +package com.example.dahua.bean; | |
2 | + | |
3 | +/** | |
4 | + * @author chen | |
5 | + * @version 1.0 | |
6 | + * @date 2019/10/30 0030 10:26 | |
7 | + */ | |
8 | +public class CheckIn { | |
9 | + | |
10 | + private String deviceId ; | |
11 | + private String cardNo ; | |
12 | + private int funNo ; | |
13 | + private int flag ; | |
14 | + private String checkTime ; | |
15 | + | |
16 | + private String out; | |
17 | + private int isSuccess ; | |
18 | + | |
19 | + public String getDeviceId() { | |
20 | + return deviceId; | |
21 | + } | |
22 | + | |
23 | + public void setDeviceId(String deviceId) { | |
24 | + this.deviceId = deviceId; | |
25 | + } | |
26 | + | |
27 | + public String getCardNo() { | |
28 | + return cardNo; | |
29 | + } | |
30 | + | |
31 | + public void setCardNo(String cardNo) { | |
32 | + this.cardNo = cardNo; | |
33 | + } | |
34 | + | |
35 | + public int getFlag() { | |
36 | + return flag; | |
37 | + } | |
38 | + | |
39 | + public void setFlag(int flag) { | |
40 | + this.flag = flag; | |
41 | + } | |
42 | + | |
43 | + public String getCheckTime() { | |
44 | + return checkTime; | |
45 | + } | |
46 | + | |
47 | + public void setCheckTime(String checkTime) { | |
48 | + this.checkTime = checkTime; | |
49 | + } | |
50 | + | |
51 | + public String getOut() { | |
52 | + return out; | |
53 | + } | |
54 | + | |
55 | + public void setOut(String out) { | |
56 | + this.out = out; | |
57 | + } | |
58 | + | |
59 | + public int getIsSuccess() { | |
60 | + return isSuccess; | |
61 | + } | |
62 | + | |
63 | + public void setIsSuccess(int isSuccess) { | |
64 | + this.isSuccess = isSuccess; | |
65 | + } | |
66 | + | |
67 | + public int getFunNo() { | |
68 | + return funNo; | |
69 | + } | |
70 | + | |
71 | + public void setFunNo(int funNo) { | |
72 | + this.funNo = funNo; | |
73 | + } | |
74 | +} | ... | ... |
cloud/dahua/src/main/java/com/example/dahua/bean/Message.java
0 → 100644
... | ... | @@ -0,0 +1,31 @@ |
1 | +package com.example.dahua.bean; | |
2 | + | |
3 | +public class Message { | |
4 | + private String name ; | |
5 | + private int schoolId ; | |
6 | + private String parentMobile ; | |
7 | + | |
8 | + public String getName() { | |
9 | + return name; | |
10 | + } | |
11 | + | |
12 | + public void setName(String name) { | |
13 | + this.name = name; | |
14 | + } | |
15 | + | |
16 | + public int getSchoolId() { | |
17 | + return schoolId; | |
18 | + } | |
19 | + | |
20 | + public void setSchoolId(int schoolId) { | |
21 | + this.schoolId = schoolId; | |
22 | + } | |
23 | + | |
24 | + public String getParentMobile() { | |
25 | + return parentMobile; | |
26 | + } | |
27 | + | |
28 | + public void setParentMobile(String parentMobile) { | |
29 | + this.parentMobile = parentMobile; | |
30 | + } | |
31 | +} | ... | ... |
cloud/dahua/src/main/java/com/example/dahua/bean/ShortMsg.java
0 → 100644
... | ... | @@ -0,0 +1,42 @@ |
1 | +package com.example.dahua.bean; | |
2 | + | |
3 | +public class ShortMsg { | |
4 | + | |
5 | + private String tableName ; | |
6 | + | |
7 | + private int schoolId ; | |
8 | + private String mobile ; | |
9 | + private String msg ; | |
10 | + | |
11 | + public String getTableName() { | |
12 | + return tableName; | |
13 | + } | |
14 | + | |
15 | + public void setTableName(String tableName) { | |
16 | + this.tableName = tableName; | |
17 | + } | |
18 | + | |
19 | + public int getSchoolId() { | |
20 | + return schoolId; | |
21 | + } | |
22 | + | |
23 | + public void setSchoolId(int schoolId) { | |
24 | + this.schoolId = schoolId; | |
25 | + } | |
26 | + | |
27 | + public String getMobile() { | |
28 | + return mobile; | |
29 | + } | |
30 | + | |
31 | + public void setMobile(String mobile) { | |
32 | + this.mobile = mobile; | |
33 | + } | |
34 | + | |
35 | + public String getMsg() { | |
36 | + return msg; | |
37 | + } | |
38 | + | |
39 | + public void setMsg(String msg) { | |
40 | + this.msg = msg; | |
41 | + } | |
42 | +} | ... | ... |
cloud/dahua/src/main/java/com/example/dahua/bean/User.java
0 → 100644
... | ... | @@ -0,0 +1,46 @@ |
1 | +package com.example.dahua.bean; | |
2 | + | |
3 | +/** | |
4 | + * @author chen | |
5 | + * @version 1.0 | |
6 | + * @date 2019/10/14 0014 14:41 | |
7 | + */ | |
8 | +public class User { | |
9 | + | |
10 | + private int schoolId; | |
11 | + private int classId ; | |
12 | + private String name ; | |
13 | + private int studentId ; | |
14 | + | |
15 | + public int getSchoolId() { | |
16 | + return schoolId; | |
17 | + } | |
18 | + | |
19 | + public void setSchoolId(int schoolId) { | |
20 | + this.schoolId = schoolId; | |
21 | + } | |
22 | + | |
23 | + public int getClassId() { | |
24 | + return classId; | |
25 | + } | |
26 | + | |
27 | + public void setClassId(int classId) { | |
28 | + this.classId = classId; | |
29 | + } | |
30 | + | |
31 | + public String getName() { | |
32 | + return name; | |
33 | + } | |
34 | + | |
35 | + public void setName(String name) { | |
36 | + this.name = name; | |
37 | + } | |
38 | + | |
39 | + public int getStudentId() { | |
40 | + return studentId; | |
41 | + } | |
42 | + | |
43 | + public void setStudentId(int studentId) { | |
44 | + this.studentId = studentId; | |
45 | + } | |
46 | +} | ... | ... |
cloud/dahua/src/main/java/com/example/dahua/dao/SearchDao.java
0 → 100644
... | ... | @@ -0,0 +1,55 @@ |
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/dbconfig/MessageDataSourceConfig.java
0 → 100644
... | ... | @@ -0,0 +1,43 @@ |
1 | +package com.example.dahua.dbconfig; | |
2 | + | |
3 | +import org.apache.ibatis.session.SqlSessionFactory; | |
4 | +import org.mybatis.spring.SqlSessionFactoryBean; | |
5 | +import org.mybatis.spring.annotation.MapperScan; | |
6 | +import org.springframework.beans.factory.annotation.Qualifier; | |
7 | +import org.springframework.boot.context.properties.ConfigurationProperties; | |
8 | +import org.springframework.boot.jdbc.DataSourceBuilder; | |
9 | +import org.springframework.context.annotation.Bean; | |
10 | +import org.springframework.context.annotation.Configuration; | |
11 | +import org.springframework.context.annotation.Primary; | |
12 | +import org.springframework.core.io.support.PathMatchingResourcePatternResolver; | |
13 | +import org.springframework.jdbc.core.JdbcTemplate; | |
14 | + | |
15 | +import javax.sql.DataSource; | |
16 | + | |
17 | +@Configuration | |
18 | +@MapperScan(basePackages = "com.example.dahua.dao", sqlSessionFactoryRef = "messageSessionFactory") | |
19 | +public class MessageDataSourceConfig { | |
20 | + @Primary | |
21 | + @Bean(name = "messageDataSource") | |
22 | + @ConfigurationProperties("spring.datasource.message") | |
23 | + public DataSource masterDataSource() { | |
24 | + return DataSourceBuilder.create().build(); | |
25 | + } | |
26 | + | |
27 | + @Bean(name = "messageSessionFactory") | |
28 | + public SqlSessionFactory sqlSessionFactory(@Qualifier("messageDataSource") DataSource dataSource) throws Exception { | |
29 | + | |
30 | + SqlSessionFactoryBean sessionFactoryBean = new SqlSessionFactoryBean(); | |
31 | + sessionFactoryBean.setDataSource(dataSource); | |
32 | + sessionFactoryBean.setMapperLocations(new PathMatchingResourcePatternResolver() | |
33 | + .getResources("classpath:mapper/*.xml")); | |
34 | + return sessionFactoryBean.getObject(); | |
35 | + | |
36 | + } | |
37 | + | |
38 | + @Bean | |
39 | + public JdbcTemplate campusJdbcTemplate(@Qualifier("messageDataSource") DataSource dataSource) { | |
40 | + return new JdbcTemplate(dataSource); | |
41 | + } | |
42 | + | |
43 | +} | ... | ... |
cloud/dahua/src/main/java/com/example/dahua/utils/DateUtils.java
0 → 100644
... | ... | @@ -0,0 +1,71 @@ |
1 | +package com.example.dahua.utils; | |
2 | + | |
3 | +import java.text.ParseException; | |
4 | +import java.text.SimpleDateFormat; | |
5 | +import java.util.Date; | |
6 | + | |
7 | +/** | |
8 | + * @author chen | |
9 | + * @version 1.0 | |
10 | + * @date 2019/10/14 0014 14:16 | |
11 | + */ | |
12 | +public class DateUtils { | |
13 | + | |
14 | + public static String format = "yyyy"; | |
15 | + | |
16 | + public static String format1 = "yyyy-MM-dd"; | |
17 | + | |
18 | + public static String format2 = "yyyy-MM-dd HH:mm:ss"; | |
19 | + | |
20 | + public static String format3 = "yyyyMMddHHmm" ; | |
21 | + | |
22 | + public static String format4 = "yyyyMM"; | |
23 | + | |
24 | + public static long getDate(){ | |
25 | + return System.currentTimeMillis(); | |
26 | + } | |
27 | + | |
28 | + public static String date2String(Date date, String format) { | |
29 | + SimpleDateFormat sdf = new SimpleDateFormat(format); | |
30 | + return sdf.format(date); | |
31 | + } | |
32 | + | |
33 | + public static Date string2Date(String date, String format) { | |
34 | + try{ | |
35 | + SimpleDateFormat sdf = new SimpleDateFormat(format); | |
36 | + return sdf.parse(date); | |
37 | + }catch (Exception e){ | |
38 | + | |
39 | + } | |
40 | + return new Date(); | |
41 | + } | |
42 | + | |
43 | + public static Date getToday(){ | |
44 | + return new Date(); | |
45 | + } | |
46 | + | |
47 | + public static String getToday(String format) throws ParseException{ | |
48 | + SimpleDateFormat sdf = new SimpleDateFormat(format); | |
49 | + return sdf.format(new Date()); | |
50 | + } | |
51 | + | |
52 | + public static int getDateDifference(Date date1, Date date2, String timeType) { | |
53 | + int between = (int) (date1.getTime() - date2.getTime()); | |
54 | + int difference = 0; | |
55 | + switch (timeType) { | |
56 | + case "day": | |
57 | + difference = between / (24 * 60 * 60 * 1000); | |
58 | + break; | |
59 | + case "hour": | |
60 | + difference = between / (60 * 60 * 1000); | |
61 | + break; | |
62 | + case "min": | |
63 | + difference = between / (60 * 1000); | |
64 | + break; | |
65 | + case "s": | |
66 | + difference = between / 1000; | |
67 | + } | |
68 | + return difference; | |
69 | + } | |
70 | + | |
71 | +} | ... | ... |
cloud/dahua/src/main/resources/application.yml
... | ... | @@ -27,6 +27,11 @@ spring: |
27 | 27 | # username: SZJXTUSER |
28 | 28 | # password: xst200919 |
29 | 29 | # driver-class-name: com.microsoft.sqlserver.jdbc.SQLServerDriver |
30 | + message: | |
31 | + username: sa | |
32 | + password: qaz!@#0401 | |
33 | + jdbcUrl: jdbc:sqlserver://60.190.202.38:49469;database=XST | |
34 | + driver-class-name: com.microsoft.sqlserver.jdbc.SQLServerDriver | |
30 | 35 | |
31 | 36 | |
32 | 37 | mybatis: | ... | ... |
cloud/dahua/src/main/resources/xiaoanmapper/SearchMapper.xml
0 → 100644
... | ... | @@ -0,0 +1,35 @@ |
1 | +<?xml version="1.0" encoding="UTF-8" ?> | |
2 | +<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" > | |
3 | +<mapper namespace="com.example.dahua.dao.SearchDao" > | |
4 | + | |
5 | + | |
6 | + <resultMap id="resultMap" type="com.example.dahua.bean.CheckIn"> | |
7 | + <result column="arr" property="out" jdbcType="VARCHAR" /> | |
8 | + <result column="iscuccess" property="isSuccess" jdbcType="INTEGER" /> | |
9 | + </resultMap> | |
10 | + <insert id="checkIn" parameterType="com.example.dahua.bean.CheckIn" statementType="CALLABLE" > | |
11 | + {call AttendanceService( | |
12 | + #{deviceId,mode=IN} , #{cardNo,mode=IN} , #{funNo,mode=IN}, #{flag,mode=IN} , #{checkTime,mode=IN}, | |
13 | + #{out,mode=OUT,jdbcType=VARCHAR,resultMap=resultMap},#{isSuccess,mode=OUT,jdbcType=INTEGER,resultMap=resultMap} | |
14 | + )} | |
15 | + </insert> | |
16 | + | |
17 | + <resultMap id="User" type="com.example.dahua.bean.User" > | |
18 | + <result column="school_id" property="schoolId" jdbcType="INTEGER" /> | |
19 | + <result column="class_id" property="classId" jdbcType="INTEGER" /> | |
20 | + <result column="name" property="name" jdbcType="VARCHAR" /> | |
21 | + <result column="student_id" property="studentId" jdbcType="INTEGER" /> | |
22 | + </resultMap> | |
23 | + <select id="selectUserByCardNum" parameterType="java.lang.String" resultMap="User"> | |
24 | + select school_id , class_id ,name ,student_id from | |
25 | + (select top 1 b.school_id, b.class_id, b.name, student_id from SZ_V_Card a | |
26 | + inner join SZ_V_School_Student b on a.user_id = b.student_id | |
27 | + and b.role_state = 1 where a.type = 2 and a.num = #{cardNum} | |
28 | + union | |
29 | + select top 1 b.school_id, 0 as class_id, b.name,b.teacher_id as student_id from SZ_V_Card a | |
30 | + inner join SZ_V_School_Teacher b on a.user_id = b.teacher_id | |
31 | + and b.role_state = 1 where a.type = 0 and a.num = #{cardNum} | |
32 | + ) x | |
33 | + </select> | |
34 | + | |
35 | +</mapper> | |
0 | 36 | \ No newline at end of file | ... | ... |
cloud/pom.xml
... | ... | @@ -31,7 +31,7 @@ |
31 | 31 | <module>common</module> |
32 | 32 | <module>getaway</module> |
33 | 33 | <module>haikang</module> |
34 | - <!-- <module>dahua</module>--> | |
34 | + <module>dahua</module> | |
35 | 35 | <!-- <module>consumer</module>--> |
36 | 36 | <module>haikangface</module> |
37 | 37 | <!-- <module>search_independence</module>--> | ... | ... |