Commit b7125c31aba41ee19a3fce2f643c357e68ea8478
1 parent
38f269ab
Exists in
master
智能校卫:海康、大华人脸机代码提交
Showing
11 changed files
with
151 additions
and
23 deletions
Show diff stats
cloud/dahua/src/main/java/com/example/dahua/bean/WeekTime.java
cloud/dahua/src/main/java/com/example/dahua/control/FileControl.java
| ... | ... | @@ -191,6 +191,12 @@ public class FileControl { |
| 191 | 191 | return clearCard; |
| 192 | 192 | } |
| 193 | 193 | |
| 194 | + @RequestMapping(value = "getUserCard", method = RequestMethod.GET) | |
| 195 | + @ApiOperation(value = "获取卡信息") | |
| 196 | + public void clearFaceInfo(@RequestParam("userId") String userId,@RequestParam("deviceId") String deviceId) { | |
| 197 | + GateModule.getCard(userId, MyTask.lLongSendMap.get(deviceId)); | |
| 198 | + } | |
| 199 | + | |
| 194 | 200 | |
| 195 | 201 | public String cardNo(String cardDex) { |
| 196 | 202 | |
| ... | ... | @@ -209,7 +215,6 @@ public class FileControl { |
| 209 | 215 | |
| 210 | 216 | } |
| 211 | 217 | |
| 212 | - | |
| 213 | 218 | @Autowired |
| 214 | 219 | private DeleteBatchTest deleteBatchTest; |
| 215 | 220 | ... | ... |
cloud/dahua/src/main/java/com/example/dahua/dao/UserDao.java
| ... | ... | @@ -139,7 +139,7 @@ public interface UserDao { |
| 139 | 139 | @Select("select Top(1) PlaceId from XA_PlaceAttendance where KanBanAttendance = #{kanBanDevId}") |
| 140 | 140 | String getPlaceIdWithKanBanDevid(@Param("kanBanDevId") String kanBanDevId); |
| 141 | 141 | |
| 142 | - @Select("select KanBanAttendance from XA_PlaceAttendance where PlaceId = #{PlaceId} and (len(KanBanAttendance)>0 and KanBanAttendance is not null )") | |
| 142 | + @Select("select KanBanAttendance from XA_PlaceAttendance where PlaceId = #{PlaceId} and (len(KanBanAttendance)>0 and KanBanAttendance is not null)") | |
| 143 | 143 | List<String> getKanBanIdWithPlaceId(@Param("PlaceId") String placeId); |
| 144 | 144 | |
| 145 | 145 | @Select("select user_id,studentcode from SZ_V_School_Student where school_id = 27") |
| ... | ... | @@ -269,6 +269,4 @@ public interface UserDao { |
| 269 | 269 | List<AttendanceBean> queryClintList(@Param("schoolId") Integer schoolId,@Param("deviceId")String deviceId); |
| 270 | 270 | |
| 271 | 271 | List<String> queryStudentIdList(@Param("schoolId") Integer schoolId,@Param("roomId")Integer roomId); |
| 272 | - | |
| 273 | - | |
| 274 | 272 | } | ... | ... |
cloud/dahua/src/main/java/com/example/dahua/module/GateModule.java
| ... | ... | @@ -988,8 +988,7 @@ public class GateModule { |
| 988 | 988 | System.out.println("[" + i + "]卡号 : " |
| 989 | 989 | + new String(cards[i].szCardNo).trim()); |
| 990 | 990 | System.out.println("[" + i + "]卡类型 : " + cards[i].emType); |
| 991 | - System.out.println("[" + i + "]查询卡结果 : " | |
| 992 | - + failCodes[i].nFailCode + "\n"); | |
| 991 | + System.out.println("[" + i + "]查询卡结果 : " + failCodes[i].nFailCode + "\n"); | |
| 993 | 992 | } |
| 994 | 993 | } else { |
| 995 | 994 | System.err.println("查询卡失败, " + ToolKits.getErrorCodePrint()); | ... | ... |
cloud/haikangface/src/main/java/com/sincere/haikangface/CMSServer.java
| ... | ... | @@ -7,6 +7,7 @@ import com.sincere.haikangface.bean.AttendanceBean; |
| 7 | 7 | import com.sincere.haikangface.bean.BaiduFaceRecorder; |
| 8 | 8 | import com.sincere.haikangface.bean.StudentBean; |
| 9 | 9 | import com.sincere.haikangface.bean.TeacherBean; |
| 10 | +import com.sincere.haikangface.bean.xiaoan.CheckIn; | |
| 10 | 11 | import com.sincere.haikangface.bean.xiaoan.Face_Recoder; |
| 11 | 12 | import com.sincere.haikangface.dao.DeviceDao; |
| 12 | 13 | import com.sincere.haikangface.dao.UserDao; |
| ... | ... | @@ -17,6 +18,7 @@ import com.sincere.haikangface.mqtt.MqtUtils; |
| 17 | 18 | import com.sincere.haikangface.service.impl.BaseService; |
| 18 | 19 | import com.sincere.haikangface.utils.AlarmUtils; |
| 19 | 20 | import com.sincere.haikangface.utils.HttpUtil; |
| 21 | +import com.sincere.haikangface.utils.JsonUtils; | |
| 20 | 22 | import com.sincere.haikangface.utils.SpringContextHolder; |
| 21 | 23 | import com.sincere.haikangface.xiananDao.SendRecordDao; |
| 22 | 24 | import com.sun.jna.NativeLong; |
| ... | ... | @@ -65,7 +67,7 @@ public class CMSServer implements ApplicationRunner { |
| 65 | 67 | //114.55.30.100 |
| 66 | 68 | //120.26.116.253 |
| 67 | 69 | // private String ip_cloud = "114.55.30.100"; |
| 68 | - private String ip_cloud = "114.55.30.100"; | |
| 70 | + private String ip_cloud = "120.26.116.253"; | |
| 69 | 71 | |
| 70 | 72 | private String ip; |
| 71 | 73 | { |
| ... | ... | @@ -366,6 +368,7 @@ public class CMSServer implements ApplicationRunner { |
| 366 | 368 | pPlateInfo.write(0, pAlarmMsg.pXmlBuf.getByteArray(0, strXMLData.size()), 0, strXMLData.size()); |
| 367 | 369 | strXMLData.read(); |
| 368 | 370 | String strXML = new String(strXMLData.byValue); |
| 371 | +// log.info("strXML: "+strXML); | |
| 369 | 372 | if (null == alarmUtils) { |
| 370 | 373 | log.info("初始化报警工具类"); |
| 371 | 374 | alarmUtils = new AlarmUtils(deviceDao, userDao); |
| ... | ... | @@ -373,10 +376,18 @@ public class CMSServer implements ApplicationRunner { |
| 373 | 376 | @Override |
| 374 | 377 | public void callBack(String minorType, String deviceID, String cardNo, String time, String picDataUrlId, String currTemperature) { |
| 375 | 378 | saveAttendance(deviceID); |
| 379 | + AttendanceBean attendanceBean = deviceDao.selectDevice(deviceID); | |
| 380 | + int outOrIn = attendanceBean.getOutOrIn(); | |
| 381 | + String schoolId = attendanceBean.getSchool_id(); | |
| 376 | 382 | switch (minorType) { |
| 377 | 383 | case "0x4b"://人脸认证通过 |
| 378 | 384 | log.info("人脸验证通过,事件次类型:"+minorType); |
| 379 | - saveFaceRecoder(deviceID, cardNo, time, picDataUrlId, currTemperature); | |
| 385 | + //人脸记录 | |
| 386 | + saveFaceRecoder(deviceID, cardNo, time, picDataUrlId, currTemperature,outOrIn); | |
| 387 | + //944柯桥实验幼儿园,海康一体机考勤签到 | |
| 388 | + if(Integer.parseInt(schoolId)== 944 && !StringUtils.isEmpty(cardNo) && isNumeric(cardNo)){ | |
| 389 | + kaoQinRecord(outOrIn,cardNo,deviceID,time); | |
| 390 | + } | |
| 380 | 391 | break; |
| 381 | 392 | case "0x426"://人证设备在线 |
| 382 | 393 | break; |
| ... | ... | @@ -387,11 +398,19 @@ public class CMSServer implements ApplicationRunner { |
| 387 | 398 | break; |
| 388 | 399 | case "0x69"://人证比对通过 |
| 389 | 400 | log.info("人证比对通过,事件次类型:"+minorType); |
| 390 | - saveFaceRecoder(deviceID, cardNo, time, picDataUrlId, currTemperature); | |
| 401 | + saveFaceRecoder(deviceID, cardNo, time, picDataUrlId, currTemperature,outOrIn); | |
| 402 | + //944柯桥实验幼儿园,海康一体机考勤签到 | |
| 403 | + if(Integer.parseInt(schoolId)== 944 && !StringUtils.isEmpty(cardNo)&& isNumeric(cardNo)){ | |
| 404 | + kaoQinRecord(outOrIn,cardNo,deviceID,time); | |
| 405 | + } | |
| 391 | 406 | break; |
| 392 | 407 | case "0x6": |
| 393 | 408 | log.info("通过,事件次类型:"+minorType); |
| 394 | - saveFaceRecoder(deviceID, cardNo, time, picDataUrlId, currTemperature); | |
| 409 | + saveFaceRecoder(deviceID, cardNo, time, picDataUrlId, currTemperature,outOrIn); | |
| 410 | + //944柯桥实验幼儿园,海康一体机考勤签到 | |
| 411 | + if(Integer.parseInt(schoolId)== 944 && !StringUtils.isEmpty(cardNo) && isNumeric(cardNo)){ | |
| 412 | + kaoQinRecord(outOrIn,cardNo,deviceID,time); | |
| 413 | + } | |
| 395 | 414 | break; |
| 396 | 415 | } |
| 397 | 416 | } |
| ... | ... | @@ -406,6 +425,27 @@ public class CMSServer implements ApplicationRunner { |
| 406 | 425 | } |
| 407 | 426 | } |
| 408 | 427 | |
| 428 | + public void kaoQinRecord(int outOrIn,String cardNo,String deviceId,String eventTime) { | |
| 429 | + BaseService baseService = SpringContextHolder.getBaseService(); | |
| 430 | + //十进制卡转十六进制卡 | |
| 431 | + String card = splicingZero(Long.toHexString(Long.parseLong(cardNo)), 8).toUpperCase(); | |
| 432 | + //卡号逆转 | |
| 433 | + cardNo = baseService.getCard(card); | |
| 434 | + //有效刷卡调考勤存储过程 | |
| 435 | + CheckIn checkIn = new CheckIn(); | |
| 436 | + checkIn.setDeviceId(deviceId); | |
| 437 | + checkIn.setCardNo(cardNo); | |
| 438 | + checkIn.setFunNo(8); | |
| 439 | + checkIn.setFlag(outOrIn == 1 ? 1:0); | |
| 440 | + checkIn.setCheckTime(eventTime); | |
| 441 | + sendRecordDao.checkIn(checkIn); | |
| 442 | + if (checkIn.getIsSuccess() == 1) { | |
| 443 | + log.info("考勤成功: checkIn: {}, 方向:{}", JsonUtils.nonDefaultMapper().toJson(checkIn),outOrIn == 1 ? "门" : "出门"); | |
| 444 | + } else { | |
| 445 | + log.info("考勤失败: checkIn: {}, 方向:{}",JsonUtils.nonDefaultMapper().toJson(checkIn),outOrIn == 1 ? "进门" : "出门"); | |
| 446 | + } | |
| 447 | + } | |
| 448 | + | |
| 409 | 449 | /** |
| 410 | 450 | * 判断设备是否在线 |
| 411 | 451 | * @param deviceId |
| ... | ... | @@ -420,7 +460,7 @@ public class CMSServer implements ApplicationRunner { |
| 420 | 460 | * @param time |
| 421 | 461 | * @param picDataUrlId |
| 422 | 462 | */ |
| 423 | - private void saveFaceRecoder(String deviceID, String cardNo, String time, String picDataUrlId, String currTemperature) { | |
| 463 | + private void saveFaceRecoder(String deviceID, String cardNo, String time, String picDataUrlId, String currTemperature,int OutOrIn) { | |
| 424 | 464 | BaseService baseService = SpringContextHolder.getBaseService(); |
| 425 | 465 | try { |
| 426 | 466 | if (!StringUtils.isEmpty(cardNo) && isNumeric(cardNo)) { |
| ... | ... | @@ -430,7 +470,6 @@ public class CMSServer implements ApplicationRunner { |
| 430 | 470 | //卡号逆转 |
| 431 | 471 | cardNo = baseService.getCard(card); |
| 432 | 472 | StudentBean studentBean = userDao.getStudentWithCard(cardNo,null); |
| 433 | - AttendanceBean attendanceBean = deviceDao.selectDevice(deviceID); | |
| 434 | 473 | if (null != studentBean) { |
| 435 | 474 | String name = studentBean.getName(); |
| 436 | 475 | int schoolId = studentBean.getSchool_id(); |
| ... | ... | @@ -441,7 +480,7 @@ public class CMSServer implements ApplicationRunner { |
| 441 | 480 | face_recoder.setTime(time); |
| 442 | 481 | face_recoder.setName(name); |
| 443 | 482 | face_recoder.setUser_id(studentBean.getUser_id()); |
| 444 | - face_recoder.setInOrOut(attendanceBean.getOutOrIn()); | |
| 483 | + face_recoder.setInOrOut(OutOrIn); | |
| 445 | 484 | String imgUrl = "http://" + ip_cloud + ":8081/kms/services/rest/dataInfoService/downloadFile?id=" + picDataUrlId; |
| 446 | 485 | face_recoder.setImgurl(imgUrl); |
| 447 | 486 | log.info("设备: {},人脸抓怕:学校id: {} ,班级:{} ,用户名:{} ,卡号:{} ,",deviceID,schoolId,className,name,cardNo); | ... | ... |
cloud/haikangface/src/main/java/com/sincere/haikangface/bean/xiaoan/CheckIn.java
0 → 100644
| ... | ... | @@ -0,0 +1,74 @@ |
| 1 | +package com.sincere.haikangface.bean.xiaoan; | |
| 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/haikangface/src/main/java/com/sincere/haikangface/dao/DeviceDao.java
| ... | ... | @@ -6,6 +6,7 @@ import com.sincere.haikangface.bean.AttendanceBean; |
| 6 | 6 | import com.sincere.haikangface.bean.FaceWaterRecoder; |
| 7 | 7 | import com.sincere.haikangface.bean.PlaceAttendance; |
| 8 | 8 | import com.sincere.haikangface.bean.QianDaoManager; |
| 9 | +import com.sincere.haikangface.bean.xiaoan.CheckIn; | |
| 9 | 10 | import org.apache.ibatis.annotations.*; |
| 10 | 11 | import org.springframework.stereotype.Repository; |
| 11 | 12 | |
| ... | ... | @@ -57,5 +58,4 @@ public interface DeviceDao { |
| 57 | 58 | @Select("select * from SZ_Attendance where clint_type = #{clint_type} and school_id = #{school_id}") |
| 58 | 59 | List<AttendanceBean> selectDeviceWithschool_id(@Param("clint_type") String clint_type, @Param("school_id") String school_id); |
| 59 | 60 | |
| 60 | - | |
| 61 | 61 | } | ... | ... |
cloud/haikangface/src/main/java/com/sincere/haikangface/xiananDao/SendRecordDao.java
| ... | ... | @@ -3,6 +3,7 @@ package com.sincere.haikangface.xiananDao; |
| 3 | 3 | import com.sincere.haikangface.bean.AttendanceRecords; |
| 4 | 4 | import com.sincere.haikangface.bean.SendRecordBean; |
| 5 | 5 | import com.sincere.haikangface.bean.xiaoan.AttendanceRecordsSS; |
| 6 | +import com.sincere.haikangface.bean.xiaoan.CheckIn; | |
| 6 | 7 | import com.sincere.haikangface.bean.xiaoan.CreditCardRecordsSS; |
| 7 | 8 | import org.apache.ibatis.annotations.*; |
| 8 | 9 | import org.springframework.stereotype.Repository; |
| ... | ... | @@ -162,4 +163,11 @@ public interface SendRecordDao { |
| 162 | 163 | |
| 163 | 164 | @Select("select top 1000 * from Face_SendFail where schoolId = 865 ") |
| 164 | 165 | List<SendRecordBean> getFaceFailList(); |
| 166 | + | |
| 167 | + /** | |
| 168 | + * 考勤推送存储过程 | |
| 169 | + * @param checkIn | |
| 170 | + * @return | |
| 171 | + */ | |
| 172 | + void checkIn(CheckIn checkIn); | |
| 165 | 173 | } | ... | ... |
cloud/haikangface/src/main/resources/application.yaml
cloud/haikangface/src/main/resources/xiaoanmapper/usermapper.xml
| 1 | 1 | <?xml version="1.0" encoding="UTF-8" ?> |
| 2 | 2 | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" > |
| 3 | -<mapper namespace="com.sincere.haikangface.xiananDao"> | |
| 3 | +<mapper namespace="com.sincere.haikangface.xiananDao.SendRecordDao"> | |
| 4 | 4 | |
| 5 | - <!--<select id="getStudentNum" resultType="String" parameterType="String">--> | |
| 6 | - <!--select student_num--> | |
| 7 | - <!--from SZ_V_School_Student--> | |
| 8 | - <!--where school_id = #{school_id}--> | |
| 9 | - <!--and studentcode = #{studentcode}--> | |
| 10 | - <!--</select>--> | |
| 5 | + <resultMap id="resultMap" type="com.sincere.haikangface.bean.xiaoan.CheckIn"> | |
| 6 | + <result column="arr" property="out" jdbcType="VARCHAR" /> | |
| 7 | + <result column="iscuccess" property="isSuccess" jdbcType="INTEGER" /> | |
| 8 | + </resultMap> | |
| 11 | 9 | |
| 10 | + <insert id="checkIn" parameterType="com.sincere.haikangface.bean.xiaoan.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> | |
| 12 | 16 | </mapper> | ... | ... |
cloud/pom.xml
| ... | ... | @@ -30,7 +30,7 @@ |
| 30 | 30 | <module>autho</module> |
| 31 | 31 | <module>common</module> |
| 32 | 32 | <module>getaway</module> |
| 33 | -<!-- <module>haikang</module>--> | |
| 33 | + <!--<module>haikang</module>--> | |
| 34 | 34 | <module>dahua</module> |
| 35 | 35 | <!-- <module>consumer</module>--> |
| 36 | 36 | <module>haikangface</module> | ... | ... |