Commit 84e52044ac349d95b21f298d6df8b591e93403ab
1 parent
0a43b0af
Exists in
master
下发权限修改
Showing
11 changed files
with
185 additions
and
48 deletions
Show diff stats
cloud/dahua/src/main/java/com/example/dahua/async/SendUserInfoTask.java
| @@ -4,10 +4,7 @@ package com.example.dahua.async; | @@ -4,10 +4,7 @@ package com.example.dahua.async; | ||
| 4 | 4 | ||
| 5 | import com.alibaba.fastjson.JSON; | 5 | import com.alibaba.fastjson.JSON; |
| 6 | import com.example.dahua.MyTask; | 6 | import com.example.dahua.MyTask; |
| 7 | -import com.example.dahua.bean.AttendanceBean; | ||
| 8 | -import com.example.dahua.bean.SendRecordBean; | ||
| 9 | -import com.example.dahua.bean.TeacherBean; | ||
| 10 | -import com.example.dahua.bean.UserInfoBean; | 7 | +import com.example.dahua.bean.*; |
| 11 | import com.example.dahua.common.Res; | 8 | import com.example.dahua.common.Res; |
| 12 | import com.example.dahua.dao.UserDao; | 9 | import com.example.dahua.dao.UserDao; |
| 13 | import com.example.dahua.enums.*; | 10 | import com.example.dahua.enums.*; |
| @@ -16,10 +13,13 @@ import com.example.dahua.lib.FilePath; | @@ -16,10 +13,13 @@ import com.example.dahua.lib.FilePath; | ||
| 16 | import com.example.dahua.lib.NetSDKLib; | 13 | import com.example.dahua.lib.NetSDKLib; |
| 17 | import com.example.dahua.lib.ToolKits; | 14 | import com.example.dahua.lib.ToolKits; |
| 18 | import com.example.dahua.module.GateModule; | 15 | import com.example.dahua.module.GateModule; |
| 16 | +import com.example.dahua.service.PermissFaceService; | ||
| 19 | import com.example.dahua.utils.FileUtils; | 17 | import com.example.dahua.utils.FileUtils; |
| 20 | import com.example.dahua.utils.HttpUtils; | 18 | import com.example.dahua.utils.HttpUtils; |
| 19 | +import com.example.dahua.utils.JsonUtils; | ||
| 21 | import com.example.dahua.xiananDao.SendRecordDao; | 20 | import com.example.dahua.xiananDao.SendRecordDao; |
| 22 | import com.sun.jna.Memory; | 21 | import com.sun.jna.Memory; |
| 22 | +import io.swagger.models.auth.In; | ||
| 23 | import lombok.extern.slf4j.Slf4j; | 23 | import lombok.extern.slf4j.Slf4j; |
| 24 | import org.springframework.beans.factory.annotation.Autowired; | 24 | import org.springframework.beans.factory.annotation.Autowired; |
| 25 | import org.springframework.http.ResponseEntity; | 25 | import org.springframework.http.ResponseEntity; |
| @@ -44,6 +44,8 @@ public class SendUserInfoTask { | @@ -44,6 +44,8 @@ public class SendUserInfoTask { | ||
| 44 | 44 | ||
| 45 | @Autowired | 45 | @Autowired |
| 46 | SendRecordDao sendRecordDao; | 46 | SendRecordDao sendRecordDao; |
| 47 | + @Autowired | ||
| 48 | + PermissFaceService permissFaceService; | ||
| 47 | 49 | ||
| 48 | /** | 50 | /** |
| 49 | * 下发单个用户人脸任务 | 51 | * 下发单个用户人脸任务 |
| @@ -301,6 +303,7 @@ public class SendUserInfoTask { | @@ -301,6 +303,7 @@ public class SendUserInfoTask { | ||
| 301 | } | 303 | } |
| 302 | } | 304 | } |
| 303 | 305 | ||
| 306 | + | ||
| 304 | /** | 307 | /** |
| 305 | * 下发人脸/卡信息 | 308 | * 下发人脸/卡信息 |
| 306 | * @param attendanceBean | 309 | * @param attendanceBean |
| @@ -323,6 +326,10 @@ public class SendUserInfoTask { | @@ -323,6 +326,10 @@ public class SendUserInfoTask { | ||
| 323 | calendar.add(Calendar.YEAR, 4); | 326 | calendar.add(Calendar.YEAR, 4); |
| 324 | String endTime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(calendar.getTime()); | 327 | String endTime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(calendar.getTime()); |
| 325 | 328 | ||
| 329 | + String studentType = userDao.getStudentType(attendanceBean.getSchool_id(),sendRecordBean.getCustomerid()); | ||
| 330 | + //通道号 | ||
| 331 | + int channel = analysisPermission(Integer.parseInt(attendanceBean.getSchool_id()),studentType); | ||
| 332 | + | ||
| 326 | /** | 333 | /** |
| 327 | * 注:用户下发逻辑 | 334 | * 注:用户下发逻辑 |
| 328 | * 下发时,先从下发记录表:SZ_Student_RecoderNo 获取当前用户下发记录集编号,存在于设备的,新增卡号时返回, | 335 | * 下发时,先从下发记录表:SZ_Student_RecoderNo 获取当前用户下发记录集编号,存在于设备的,新增卡号时返回, |
| @@ -371,7 +378,7 @@ public class SendUserInfoTask { | @@ -371,7 +378,7 @@ public class SendUserInfoTask { | ||
| 371 | if (bCardFlags) { | 378 | if (bCardFlags) { |
| 372 | //修改设备卡信息 | 379 | //修改设备卡信息 |
| 373 | boolean isEditCard = GateModule.modifyCard(Integer.parseInt(recordNo),cardNum, user_id, name, "123456", Res.string().getCardStatusInt(1), | 380 | boolean isEditCard = GateModule.modifyCard(Integer.parseInt(recordNo),cardNum, user_id, name, "123456", Res.string().getCardStatusInt(1), |
| 374 | - Res.string().getCardTypeInt(1), 0, 0, 1, startTime, endTime, loginHandleLong, userType,cardErrNum); | 381 | + Res.string().getCardTypeInt(1), 0, 0, 1, startTime, endTime, loginHandleLong, userType,cardErrNum,channel); |
| 375 | 382 | ||
| 376 | if (isEditCard) { | 383 | if (isEditCard) { |
| 377 | //修改卡成功, 更新下发记录集编号表 | 384 | //修改卡成功, 更新下发记录集编号表 |
| @@ -387,7 +394,7 @@ public class SendUserInfoTask { | @@ -387,7 +394,7 @@ public class SendUserInfoTask { | ||
| 387 | userDao.deleteRecordNo(user_id, Integer.parseInt(recordNo)); | 394 | userDao.deleteRecordNo(user_id, Integer.parseInt(recordNo)); |
| 388 | //重新下发卡号至设备 | 395 | //重新下发卡号至设备 |
| 389 | newRecordNo = GateModule.insertCard(cardNum, user_id, name, "123456", Res.string().getCardStatusInt(1), | 396 | newRecordNo = GateModule.insertCard(cardNum, user_id, name, "123456", Res.string().getCardStatusInt(1), |
| 390 | - Res.string().getCardTypeInt(1), 0, 1, 1, startTime, endTime, loginHandleLong,userType,cardErrNum); | 397 | + Res.string().getCardTypeInt(1), 0, 1, 1, startTime, endTime, loginHandleLong,userType,cardErrNum,channel); |
| 391 | 398 | ||
| 392 | //下发卡至设备,返回值不为-1为下发成功,保存下发记录集编号表 | 399 | //下发卡至设备,返回值不为-1为下发成功,保存下发记录集编号表 |
| 393 | if (newRecordNo != -1) { | 400 | if (newRecordNo != -1) { |
| @@ -401,7 +408,7 @@ public class SendUserInfoTask { | @@ -401,7 +408,7 @@ public class SendUserInfoTask { | ||
| 401 | //新增卡信息, 新增人脸信息至设备 | 408 | //新增卡信息, 新增人脸信息至设备 |
| 402 | newRecordNo = GateModule.insertCard(cardNum, user_id, name, "123456" | 409 | newRecordNo = GateModule.insertCard(cardNum, user_id, name, "123456" |
| 403 | , Res.string().getCardStatusInt(1), Res.string().getCardTypeInt(1), 0, 1 | 410 | , Res.string().getCardStatusInt(1), Res.string().getCardTypeInt(1), 0, 1 |
| 404 | - , 1, startTime, endTime, loginHandleLong,userType,cardErrNum); | 411 | + , 1, startTime, endTime, loginHandleLong,userType,cardErrNum,channel); |
| 405 | 412 | ||
| 406 | //下发卡至设备,返回值不为-1为下发成功,保存下发记录集编号表 | 413 | //下发卡至设备,返回值不为-1为下发成功,保存下发记录集编号表 |
| 407 | if (newRecordNo != -1) { | 414 | if (newRecordNo != -1) { |
| @@ -419,7 +426,7 @@ public class SendUserInfoTask { | @@ -419,7 +426,7 @@ public class SendUserInfoTask { | ||
| 419 | log.info("下发人脸和卡号成功, sendRecordBean: "+ JSON.toJSONString(sendRecordBean)); | 426 | log.info("下发人脸和卡号成功, sendRecordBean: "+ JSON.toJSONString(sendRecordBean)); |
| 420 | 427 | ||
| 421 | //人脸下发成功记录, 先判断是否已经存在了 | 428 | //人脸下发成功记录, 先判断是否已经存在了 |
| 422 | - List<SendRecordBean> sendRecordBeanList = sendRecordDao.getFaceSucceIsexit(sendRecordBean.getDeviceID(), String.valueOf(sendRecordBean.getSchoolId()), sendRecordBean.getCustomerid()); | 429 | + List<SendRecordBean> sendRecordBeanList = sendRecordDao.getFaceSucceIsexit(sendRecordBean.getDeviceID(), String.valueOf(sendRecordBean.getSchoolId()), sendRecordBean.getNum()); |
| 423 | if (sendRecordBeanList.size() > 0) { | 430 | if (sendRecordBeanList.size() > 0) { |
| 424 | //删除重复数据 | 431 | //删除重复数据 |
| 425 | for (int i = 0; i < sendRecordBeanList.size(); i++) { | 432 | for (int i = 0; i < sendRecordBeanList.size(); i++) { |
| @@ -475,6 +482,41 @@ public class SendUserInfoTask { | @@ -475,6 +482,41 @@ public class SendUserInfoTask { | ||
| 475 | } | 482 | } |
| 476 | } | 483 | } |
| 477 | 484 | ||
| 485 | + private static JsonUtils objectMapper = JsonUtils.nonEmptyMapper(); | ||
| 486 | + | ||
| 487 | + /** | ||
| 488 | + * 解析权限模板、获取下发通道号 | ||
| 489 | + * @param schoolId | ||
| 490 | + * @param studentType | ||
| 491 | + * @return | ||
| 492 | + */ | ||
| 493 | + private int analysisPermission(int schoolId, String studentType){ | ||
| 494 | + List<PermissionFaceBean> permissionFaceBeans = permissFaceService.getPermissionList(schoolId); | ||
| 495 | + String channel =""; | ||
| 496 | + if(permissionFaceBeans.size()>0){ | ||
| 497 | + for(PermissionFaceBean permissionFaceBean : permissionFaceBeans){ | ||
| 498 | + String json = permissionFaceBean.getPermissionJson(); | ||
| 499 | + PermissionBean permissionBean = objectMapper.fromJson(json,PermissionBean.class); | ||
| 500 | + //学生考勤类型 1:通校生,2:住校生,3:全部 | ||
| 501 | + String studentTypeStr = permissionBean.getStudentType(); | ||
| 502 | + if(studentTypeStr.indexOf(studentType)!=-1){ | ||
| 503 | + channel= permissionFaceBean.getChannel(); | ||
| 504 | + } | ||
| 505 | + } | ||
| 506 | + } | ||
| 507 | + return Integer.parseInt(channel); | ||
| 508 | + } | ||
| 509 | + | ||
| 510 | + | ||
| 511 | + public static void main(String[] args) { | ||
| 512 | + String json ="{\"studentType\":\"1,2\",\"deviceIds\":[\"aaa\"],\"weekDays\":[{\"weekTimes\":[{\"startTime\":\"12:00\",\"endTime\":\"06:00\"}],\"sex\":\"1,2\",\"weekDay\":\"0,1,2\"}]}"; | ||
| 513 | + PermissionBean permissionBean = objectMapper.fromJson(json,PermissionBean.class); | ||
| 514 | + String studentType = permissionBean.getStudentType(); | ||
| 515 | + if(studentType.indexOf("1")!=-1){ | ||
| 516 | + System.out.println(true); | ||
| 517 | + } | ||
| 518 | + } | ||
| 519 | + | ||
| 478 | /** | 520 | /** |
| 479 | * 解析下发异常信息 | 521 | * 解析下发异常信息 |
| 480 | * @param cardErrNum | 522 | * @param cardErrNum |
| @@ -506,9 +548,6 @@ public class SendUserInfoTask { | @@ -506,9 +548,6 @@ public class SendUserInfoTask { | ||
| 506 | return sb.toString(); | 548 | return sb.toString(); |
| 507 | } | 549 | } |
| 508 | 550 | ||
| 509 | - public static void main(String[] args) { | ||
| 510 | - System.out.println(new SendUserInfoTask().analysisErrorMsg("","")); | ||
| 511 | - } | ||
| 512 | 551 | ||
| 513 | /** | 552 | /** |
| 514 | * 添加人脸下发失败记录 | 553 | * 添加人脸下发失败记录 |
cloud/dahua/src/main/java/com/example/dahua/bean/PermissionBean.java
| @@ -15,6 +15,12 @@ public class PermissionBean implements Serializable { | @@ -15,6 +15,12 @@ public class PermissionBean implements Serializable { | ||
| 15 | @ApiModelProperty("用逗号隔开,1:通校生,2:住校生,3:全部") | 15 | @ApiModelProperty("用逗号隔开,1:通校生,2:住校生,3:全部") |
| 16 | private String studentType; | 16 | private String studentType; |
| 17 | 17 | ||
| 18 | + @ApiModelProperty("权限通道号") | ||
| 19 | + private String channel; | ||
| 20 | + | ||
| 21 | + @ApiModelProperty("权限自定义名成") | ||
| 22 | + private String customName; | ||
| 23 | + | ||
| 18 | public String getStudentType() { | 24 | public String getStudentType() { |
| 19 | return studentType; | 25 | return studentType; |
| 20 | } | 26 | } |
| @@ -38,4 +44,20 @@ public class PermissionBean implements Serializable { | @@ -38,4 +44,20 @@ public class PermissionBean implements Serializable { | ||
| 38 | public void setWeekDays(List<WeekDay> weekDays) { | 44 | public void setWeekDays(List<WeekDay> weekDays) { |
| 39 | this.weekDays = weekDays; | 45 | this.weekDays = weekDays; |
| 40 | } | 46 | } |
| 47 | + | ||
| 48 | + public String getChannel() { | ||
| 49 | + return channel; | ||
| 50 | + } | ||
| 51 | + | ||
| 52 | + public void setChannel(String channel) { | ||
| 53 | + this.channel = channel; | ||
| 54 | + } | ||
| 55 | + | ||
| 56 | + public String getCustomName() { | ||
| 57 | + return customName; | ||
| 58 | + } | ||
| 59 | + | ||
| 60 | + public void setCustomName(String customName) { | ||
| 61 | + this.customName = customName; | ||
| 62 | + } | ||
| 41 | } | 63 | } |
cloud/dahua/src/main/java/com/example/dahua/bean/PermissionFaceBean.java
| @@ -42,6 +42,11 @@ public class PermissionFaceBean implements Serializable { | @@ -42,6 +42,11 @@ public class PermissionFaceBean implements Serializable { | ||
| 42 | @ApiModelProperty(value = "0-新增;1-编辑;2-删除",required = true) | 42 | @ApiModelProperty(value = "0-新增;1-编辑;2-删除",required = true) |
| 43 | private int type; | 43 | private int type; |
| 44 | 44 | ||
| 45 | + @ApiModelProperty("权限通道号") | ||
| 46 | + private String channel; | ||
| 47 | + @ApiModelProperty("权限自定义名成") | ||
| 48 | + private String customName; | ||
| 49 | + | ||
| 45 | public int getType() { | 50 | public int getType() { |
| 46 | return type; | 51 | return type; |
| 47 | } | 52 | } |
| @@ -105,4 +110,20 @@ public class PermissionFaceBean implements Serializable { | @@ -105,4 +110,20 @@ public class PermissionFaceBean implements Serializable { | ||
| 105 | public void setPermissionJson(String permissionJson) { | 110 | public void setPermissionJson(String permissionJson) { |
| 106 | this.permissionJson = permissionJson; | 111 | this.permissionJson = permissionJson; |
| 107 | } | 112 | } |
| 113 | + | ||
| 114 | + public String getChannel() { | ||
| 115 | + return channel; | ||
| 116 | + } | ||
| 117 | + | ||
| 118 | + public void setChannel(String channel) { | ||
| 119 | + this.channel = channel; | ||
| 120 | + } | ||
| 121 | + | ||
| 122 | + public String getCustomName() { | ||
| 123 | + return customName; | ||
| 124 | + } | ||
| 125 | + | ||
| 126 | + public void setCustomName(String customName) { | ||
| 127 | + this.customName = customName; | ||
| 128 | + } | ||
| 108 | } | 129 | } |
cloud/dahua/src/main/java/com/example/dahua/dao/UserDao.java
| @@ -44,6 +44,15 @@ public interface UserDao { | @@ -44,6 +44,15 @@ public interface UserDao { | ||
| 44 | @Select("select top 1 recordNo from SZ_Student_RecoderNo where user_id = #{user_id} and deviceId = #{deviceId}") | 44 | @Select("select top 1 recordNo from SZ_Student_RecoderNo where user_id = #{user_id} and deviceId = #{deviceId}") |
| 45 | String getRecordNo(@Param("user_id") String user_id, @Param("deviceId") String deviceId); | 45 | String getRecordNo(@Param("user_id") String user_id, @Param("deviceId") String deviceId); |
| 46 | 46 | ||
| 47 | + /** | ||
| 48 | + * 获取学生考勤类型 | ||
| 49 | + * @param school_id | ||
| 50 | + * @param customerid | ||
| 51 | + * @return | ||
| 52 | + */ | ||
| 53 | + @Select(" select Top(1)* student_type from SZ_V_School_Student where school_id = #{school_id} and student_id = #{customerid}") | ||
| 54 | + String getStudentType(@Param("school_id") String school_id, @Param("customerid") String customerid); | ||
| 55 | + | ||
| 47 | @Insert("insert into SZ_Student_RecoderNo values(#{user_id},#{recordNo},#{student_name},#{deviceId})") | 56 | @Insert("insert into SZ_Student_RecoderNo values(#{user_id},#{recordNo},#{student_name},#{deviceId})") |
| 48 | int saveRecordNo(@Param("user_id") String user_id, @Param("recordNo") int recordNo, @Param("student_name") String student_name, @Param("deviceId") String deviceId); | 57 | int saveRecordNo(@Param("user_id") String user_id, @Param("recordNo") int recordNo, @Param("student_name") String student_name, @Param("deviceId") String deviceId); |
| 49 | 58 | ||
| @@ -104,7 +113,7 @@ public interface UserDao { | @@ -104,7 +113,7 @@ public interface UserDao { | ||
| 104 | @Select("select StudentId from SS_RoomNumber where Pid in (select id from SS_Room where SchoolId = 479)") | 113 | @Select("select StudentId from SS_RoomNumber where Pid in (select id from SS_Room where SchoolId = 479)") |
| 105 | List<String> getStudentIds(); | 114 | List<String> getStudentIds(); |
| 106 | 115 | ||
| 107 | - @Select("select * from SZ_V_Card where num=#{num}") | 116 | + @Select("select Top(1) * from SZ_V_Card where num=#{num}") |
| 108 | CardBean getCards(@Param("num") String num); | 117 | CardBean getCards(@Param("num") String num); |
| 109 | 118 | ||
| 110 | @Select("select clint_id from SZ_Attendance where school_id = #{schoolId} and (clint_type = 8 or clint_type = 9 or clint_type = 10)") | 119 | @Select("select clint_id from SZ_Attendance where school_id = #{schoolId} and (clint_type = 8 or clint_type = 9 or clint_type = 10)") |
cloud/dahua/src/main/java/com/example/dahua/enums/EnumSzBusinessType.java
| @@ -29,21 +29,22 @@ public interface EnumSzBusinessType { | @@ -29,21 +29,22 @@ public interface EnumSzBusinessType { | ||
| 29 | } | 29 | } |
| 30 | } | 30 | } |
| 31 | 31 | ||
| 32 | -// public enum EnumCardType { | ||
| 33 | -// | ||
| 34 | -// STUDENT(1, "student","学生"), | ||
| 35 | -// TEACHER(2, "teacher","老师"); | ||
| 36 | -//// PARENT(3, "parent","家长"); | ||
| 37 | -// | ||
| 38 | -// public final int code; | ||
| 39 | -// public final String enName; | ||
| 40 | -// public final String cnName; | ||
| 41 | -// | ||
| 42 | -// EnumUserType(int code, String enName,String cnName) { | ||
| 43 | -// this.code = code; | ||
| 44 | -// this.enName = enName; | ||
| 45 | -// this.cnName = cnName; | ||
| 46 | -// } | ||
| 47 | -// } | 32 | + /** |
| 33 | + * 学生出入类型 | ||
| 34 | + */ | ||
| 35 | + public enum EnumStudentType { | ||
| 36 | + | ||
| 37 | + GO_OUT(1, "通校"), | ||
| 38 | + LIVING(2, "住校"), | ||
| 39 | + ALL(3, "全部"); | ||
| 40 | + | ||
| 41 | + public final int code; | ||
| 42 | + public final String name; | ||
| 43 | + | ||
| 44 | + EnumStudentType(int code, String name) { | ||
| 45 | + this.code = code; | ||
| 46 | + this.name = name; | ||
| 47 | + } | ||
| 48 | + } | ||
| 48 | 49 | ||
| 49 | } | 50 | } |
cloud/dahua/src/main/java/com/example/dahua/module/GateModule.java
| @@ -5,6 +5,7 @@ import com.example.dahua.bean.WeekDay; | @@ -5,6 +5,7 @@ import com.example.dahua.bean.WeekDay; | ||
| 5 | import com.example.dahua.bean.WeekTime; | 5 | import com.example.dahua.bean.WeekTime; |
| 6 | import com.example.dahua.enums.EnumSendCardErrorType; | 6 | import com.example.dahua.enums.EnumSendCardErrorType; |
| 7 | import com.example.dahua.enums.EnumSendFaceErrorType; | 7 | import com.example.dahua.enums.EnumSendFaceErrorType; |
| 8 | +import com.example.dahua.enums.EnumSzBusinessType; | ||
| 8 | import com.example.dahua.lib.NetSDKLib; | 9 | import com.example.dahua.lib.NetSDKLib; |
| 9 | import com.example.dahua.lib.NetSDKLib.*; | 10 | import com.example.dahua.lib.NetSDKLib.*; |
| 10 | import com.example.dahua.lib.ToolKits; | 11 | import com.example.dahua.lib.ToolKits; |
| @@ -203,7 +204,7 @@ public class GateModule { | @@ -203,7 +204,7 @@ public class GateModule { | ||
| 203 | public static synchronized int insertCard(String cardNo, String userId, String cardName, String cardPwd, | 204 | public static synchronized int insertCard(String cardNo, String userId, String cardName, String cardPwd, |
| 204 | int cardStatus, int cardType, int useTimes, int isFirstEnter, | 205 | int cardStatus, int cardType, int useTimes, int isFirstEnter, |
| 205 | int isValid, String startValidTime, String endValidTime, LLong lLong, | 206 | int isValid, String startValidTime, String endValidTime, LLong lLong, |
| 206 | - String userType,String cardErrNum) { | 207 | + String userType,String cardErrNum,int channel) { |
| 207 | /** | 208 | /** |
| 208 | * 门禁卡记录集信息 | 209 | * 门禁卡记录集信息 |
| 209 | */ | 210 | */ |
| @@ -230,13 +231,13 @@ public class GateModule { | @@ -230,13 +231,13 @@ public class GateModule { | ||
| 230 | accessCardInfo.sznDoors[0] = 0; | 231 | accessCardInfo.sznDoors[0] = 0; |
| 231 | accessCardInfo.sznDoors[1] = 1; | 232 | accessCardInfo.sznDoors[1] = 1; |
| 232 | accessCardInfo.nTimeSectionNum = 2; // 与门数对应 | 233 | accessCardInfo.nTimeSectionNum = 2; // 与门数对应 |
| 233 | -// if (userType.equals("1")){ | 234 | + if (userType.equals("1")){ |
| 234 | accessCardInfo.sznTimeSectionNo[0] = 255; // 表示第一个门全天有效 | 235 | accessCardInfo.sznTimeSectionNo[0] = 255; // 表示第一个门全天有效 |
| 235 | accessCardInfo.sznTimeSectionNo[1] = 255; // 表示第二个门全天有效 | 236 | accessCardInfo.sznTimeSectionNo[1] = 255; // 表示第二个门全天有效 |
| 236 | -// }else { | ||
| 237 | -// accessCardInfo.sznTimeSectionNo[0] = 120; // 表示第一个门全天有效 | ||
| 238 | -// accessCardInfo.sznTimeSectionNo[1] = 120; // 表示第二个门全天有效 | ||
| 239 | -// } | 237 | + }else { |
| 238 | + accessCardInfo.sznTimeSectionNo[0] = channel; // 表示第一个门全天有效 | ||
| 239 | + accessCardInfo.sznTimeSectionNo[1] = channel; // 表示第二个门全天有效 | ||
| 240 | + } | ||
| 240 | 241 | ||
| 241 | // 卡状态 | 242 | // 卡状态 |
| 242 | accessCardInfo.emStatus = cardStatus; | 243 | accessCardInfo.emStatus = cardStatus; |
| @@ -291,14 +292,13 @@ public class GateModule { | @@ -291,14 +292,13 @@ public class GateModule { | ||
| 291 | log.info("添加卡信息失败,错误信息:{} ,错误码:{} ",ret,number); | 292 | log.info("添加卡信息失败,错误信息:{} ,错误码:{} ",ret,number); |
| 292 | cardErrNum = number; | 293 | cardErrNum = number; |
| 293 | //146用户已存在,21对返回数据的校验出错,1162未知错误 | 294 | //146用户已存在,21对返回数据的校验出错,1162未知错误 |
| 294 | - if(number.equals(EnumSendCardErrorType.CHECK_DATA_ERR_21.code)|| number.equals(EnumSendCardErrorType.EXIST_USER_146.code)|| | ||
| 295 | - number.equals(EnumSendCardErrorType.UNKNOWN_1162.code)) { | 295 | + if(number.equals(EnumSendCardErrorType.CHECK_DATA_ERR_21.code)||number.equals(EnumSendCardErrorType.EXIST_USER_146.code)) { |
| 296 | //用户已存在/返回数据校验出错时,执行删除用户 | 296 | //用户已存在/返回数据校验出错时,执行删除用户 |
| 297 | deleteUser( userId, lLong); | 297 | deleteUser( userId, lLong); |
| 298 | //重新下发卡至设备 | 298 | //重新下发卡至设备 |
| 299 | cardErrNum = ""; | 299 | cardErrNum = ""; |
| 300 | return insertCard(cardNo, userId, cardName, cardPwd, cardStatus, cardType, useTimes, isFirstEnter, | 300 | return insertCard(cardNo, userId, cardName, cardPwd, cardStatus, cardType, useTimes, isFirstEnter, |
| 301 | - isValid, startValidTime, endValidTime, lLong, userType,cardErrNum); | 301 | + isValid, startValidTime, endValidTime, lLong, userType,cardErrNum,channel); |
| 302 | } | 302 | } |
| 303 | //新增卡失败,错误码,返回-1 | 303 | //新增卡失败,错误码,返回-1 |
| 304 | return -1; | 304 | return -1; |
| @@ -414,10 +414,12 @@ public class GateModule { | @@ -414,10 +414,12 @@ public class GateModule { | ||
| 414 | CFG_ACCESS_TIMESCHEDULE_INFO msg = new CFG_ACCESS_TIMESCHEDULE_INFO(); | 414 | CFG_ACCESS_TIMESCHEDULE_INFO msg = new CFG_ACCESS_TIMESCHEDULE_INFO(); |
| 415 | String strCmd = NetSDKLib.CFG_CMD_ACCESSTIMESCHEDULE; | 415 | String strCmd = NetSDKLib.CFG_CMD_ACCESSTIMESCHEDULE; |
| 416 | // 通道号 | 416 | // 通道号 |
| 417 | - int nChannel = 120; | 417 | + int nChannel = Integer.parseInt(permissionBean.getChannel()); |
| 418 | // msg.stuTimeWeekDay[0].stuTimeSection[0].dwRecordMask | 418 | // msg.stuTimeWeekDay[0].stuTimeSection[0].dwRecordMask |
| 419 | - String name = "3"; | 419 | + //自定义名称 |
| 420 | + String name = permissionBean.getCustomName(); | ||
| 420 | System.arraycopy(name.getBytes(), 0, msg.szName, 0, name.getBytes().length); | 421 | System.arraycopy(name.getBytes(), 0, msg.szName, 0, name.getBytes().length); |
| 422 | + //时间段使能开关, 1-true; 0-false | ||
| 421 | msg.bEnable = 1; | 423 | msg.bEnable = 1; |
| 422 | 424 | ||
| 423 | List<WeekDay> weekDays = permissionBean.getWeekDays(); | 425 | List<WeekDay> weekDays = permissionBean.getWeekDays(); |
| @@ -525,10 +527,11 @@ public class GateModule { | @@ -525,10 +527,11 @@ public class GateModule { | ||
| 525 | 527 | ||
| 526 | } | 528 | } |
| 527 | 529 | ||
| 528 | - public static void getAccessTimeSchedule1(LLong lLong) { | 530 | + public static void getAccessTimeSchedule1(LLong lLong,String channel) { |
| 529 | CFG_ACCESS_TIMESCHEDULE_INFO msg = new CFG_ACCESS_TIMESCHEDULE_INFO(); | 531 | CFG_ACCESS_TIMESCHEDULE_INFO msg = new CFG_ACCESS_TIMESCHEDULE_INFO(); |
| 530 | String strCmd = NetSDKLib.CFG_CMD_ACCESSTIMESCHEDULE; | 532 | String strCmd = NetSDKLib.CFG_CMD_ACCESSTIMESCHEDULE; |
| 531 | - int nChannel = 120; // 通道号 | 533 | + // 通道号 |
| 534 | + int nChannel = Integer.parseInt(channel); | ||
| 532 | 535 | ||
| 533 | // 获取 | 536 | // 获取 |
| 534 | if (ToolKits.GetDevConfig(lLong, nChannel, strCmd, msg)) { | 537 | if (ToolKits.GetDevConfig(lLong, nChannel, strCmd, msg)) { |
| @@ -687,7 +690,7 @@ public class GateModule { | @@ -687,7 +690,7 @@ public class GateModule { | ||
| 687 | public static boolean modifyCard(int recordNo, String cardNo, String userId, String cardName, String cardPwd, | 690 | public static boolean modifyCard(int recordNo, String cardNo, String userId, String cardName, String cardPwd, |
| 688 | int cardStatus, int cardType, int useTimes, int isFirstEnter, | 691 | int cardStatus, int cardType, int useTimes, int isFirstEnter, |
| 689 | int isValid, String startValidTime, String endValidTime, LLong lLong, | 692 | int isValid, String startValidTime, String endValidTime, LLong lLong, |
| 690 | - String userType,String cardErrNum) { | 693 | + String userType,String cardErrNum,int channel) { |
| 691 | /** | 694 | /** |
| 692 | * 门禁卡记录集信息 | 695 | * 门禁卡记录集信息 |
| 693 | */ | 696 | */ |
| @@ -715,13 +718,14 @@ public class GateModule { | @@ -715,13 +718,14 @@ public class GateModule { | ||
| 715 | accessCardInfo.nDoorNum = 2; | 718 | accessCardInfo.nDoorNum = 2; |
| 716 | accessCardInfo.sznDoors[0] = 0; | 719 | accessCardInfo.sznDoors[0] = 0; |
| 717 | accessCardInfo.sznDoors[1] = 1; | 720 | accessCardInfo.sznDoors[1] = 1; |
| 718 | - accessCardInfo.nTimeSectionNum = 2; // 与门数对应 | ||
| 719 | - if (userType.equals("1")){ | 721 | + // 有效的的开门时间段数目 ,与设备门数保持一至 |
| 722 | + accessCardInfo.nTimeSectionNum = 2; | ||
| 723 | + if (userType.equals(EnumSzBusinessType.EnumUserType.TEACHER.code)){ | ||
| 720 | accessCardInfo.sznTimeSectionNo[0] = 255; // 表示第一个门全天有效 | 724 | accessCardInfo.sznTimeSectionNo[0] = 255; // 表示第一个门全天有效 |
| 721 | accessCardInfo.sznTimeSectionNo[1] = 255; // 表示第二个门全天有效 | 725 | accessCardInfo.sznTimeSectionNo[1] = 255; // 表示第二个门全天有效 |
| 722 | }else { | 726 | }else { |
| 723 | - accessCardInfo.sznTimeSectionNo[0] = 120; // 表示第一个门全天有效 | ||
| 724 | - accessCardInfo.sznTimeSectionNo[1] = 120; // 表示第二个门全天有效 | 727 | + accessCardInfo.sznTimeSectionNo[0] = channel; // 表示第一个门全天有效 |
| 728 | + accessCardInfo.sznTimeSectionNo[1] = channel; // 表示第二个门全天有效 | ||
| 725 | } | 729 | } |
| 726 | 730 | ||
| 727 | // 卡状态 | 731 | // 卡状态 |
cloud/dahua/src/main/java/com/example/dahua/service/PermissFaceService.java
| @@ -17,4 +17,6 @@ public interface PermissFaceService { | @@ -17,4 +17,6 @@ public interface PermissFaceService { | ||
| 17 | 17 | ||
| 18 | 18 | ||
| 19 | ResponseBean<String> addFace(String imgUrl, String userId); | 19 | ResponseBean<String> addFace(String imgUrl, String userId); |
| 20 | + | ||
| 21 | + public List<PermissionFaceBean> getPermissionList(int schoolId); | ||
| 20 | } | 22 | } |
cloud/dahua/src/main/java/com/example/dahua/service/imp/PermissFaceServiceImp.java
| @@ -41,7 +41,14 @@ public class PermissFaceServiceImp implements PermissFaceService { | @@ -41,7 +41,14 @@ public class PermissFaceServiceImp implements PermissFaceService { | ||
| 41 | 41 | ||
| 42 | int schoolId = permissionFaceBean.getSchoolId(); | 42 | int schoolId = permissionFaceBean.getSchoolId(); |
| 43 | 43 | ||
| 44 | + //编辑设置 | ||
| 44 | PermissionBean permissionBean = permissionFaceBean.getPermissionBean(); | 45 | PermissionBean permissionBean = permissionFaceBean.getPermissionBean(); |
| 46 | + if(!StringUtils.isEmpty(permissionFaceBean.getChannel())){ | ||
| 47 | + permissionBean.setChannel(permissionFaceBean.getChannel()); | ||
| 48 | + } | ||
| 49 | + if(!StringUtils.isEmpty(permissionFaceBean.getCustomName())){ | ||
| 50 | + permissionBean.setChannel(permissionFaceBean.getCustomName()); | ||
| 51 | + } | ||
| 45 | 52 | ||
| 46 | int type = permissionFaceBean.getType(); | 53 | int type = permissionFaceBean.getType(); |
| 47 | if (null != permissionBean) | 54 | if (null != permissionBean) |
| @@ -56,9 +63,19 @@ public class PermissFaceServiceImp implements PermissFaceService { | @@ -56,9 +63,19 @@ public class PermissFaceServiceImp implements PermissFaceService { | ||
| 56 | } | 63 | } |
| 57 | switch (type) { | 64 | switch (type) { |
| 58 | case 0://新增 | 65 | case 0://新增 |
| 66 | + /**通道号**/ | ||
| 67 | + String channel = Rand(); | ||
| 68 | + /**通道自定义名称**/ | ||
| 69 | + String customName = Rand(); | ||
| 70 | + permissionBean.setChannel(channel); | ||
| 71 | + permissionBean.setCustomName(customName); | ||
| 72 | + permissionFaceBean.setChannel(channel); | ||
| 73 | + permissionFaceBean.setCustomName(customName); | ||
| 74 | + | ||
| 59 | permissionFaceDao.addPermissionFace(permissionFaceBean); | 75 | permissionFaceDao.addPermissionFace(permissionFaceBean); |
| 60 | responseBean.setMessage("添加权限模板成功"); | 76 | responseBean.setMessage("添加权限模板成功"); |
| 61 | responseBean.setData(null); | 77 | responseBean.setData(null); |
| 78 | + //下发权限 | ||
| 62 | sendPermiss2Dev(permissionFaceBean); | 79 | sendPermiss2Dev(permissionFaceBean); |
| 63 | responseBean.setStatus(1); | 80 | responseBean.setStatus(1); |
| 64 | break; | 81 | break; |
| @@ -94,6 +111,16 @@ public class PermissFaceServiceImp implements PermissFaceService { | @@ -94,6 +111,16 @@ public class PermissFaceServiceImp implements PermissFaceService { | ||
| 94 | } | 111 | } |
| 95 | 112 | ||
| 96 | /** | 113 | /** |
| 114 | + * 取100以内随机数 | ||
| 115 | + * @return | ||
| 116 | + */ | ||
| 117 | + public static String Rand() { | ||
| 118 | + int rand = (int) (Math.random() * 100000) % 100; | ||
| 119 | + return String.valueOf(rand); | ||
| 120 | + } | ||
| 121 | + | ||
| 122 | + | ||
| 123 | + /** | ||
| 97 | * 下发权限到设备 | 124 | * 下发权限到设备 |
| 98 | * | 125 | * |
| 99 | * @param permissionFaceBean | 126 | * @param permissionFaceBean |
| @@ -140,6 +167,12 @@ public class PermissFaceServiceImp implements PermissFaceService { | @@ -140,6 +167,12 @@ public class PermissFaceServiceImp implements PermissFaceService { | ||
| 140 | } | 167 | } |
| 141 | 168 | ||
| 142 | @Override | 169 | @Override |
| 170 | + public List<PermissionFaceBean> getPermissionList(int schoolId) { | ||
| 171 | + List<PermissionFaceBean> permissionFaceBeans = permissionFaceDao.getPermissFaces(schoolId); | ||
| 172 | + return permissionFaceBeans; | ||
| 173 | + } | ||
| 174 | + | ||
| 175 | + @Override | ||
| 143 | public ResponseBeanList<PermissionFaceBean> getPermissionDetail(int permissionId) { | 176 | public ResponseBeanList<PermissionFaceBean> getPermissionDetail(int permissionId) { |
| 144 | ResponseBeanList responseBeanList = new ResponseBeanList(); | 177 | ResponseBeanList responseBeanList = new ResponseBeanList(); |
| 145 | try { | 178 | try { |
cloud/dahua/src/main/java/com/example/dahua/service/imp/UserServiceImp.java
| @@ -129,7 +129,7 @@ public class UserServiceImp implements UserService { | @@ -129,7 +129,7 @@ public class UserServiceImp implements UserService { | ||
| 129 | NetSDKLib.LLong loginHandleLong = MyTask.lLongMap.get(deviceId); | 129 | NetSDKLib.LLong loginHandleLong = MyTask.lLongMap.get(deviceId); |
| 130 | //下发权限 | 130 | //下发权限 |
| 131 | GateModule.setAccessTimeSchedule(loginHandleLong, permissionBean); | 131 | GateModule.setAccessTimeSchedule(loginHandleLong, permissionBean); |
| 132 | - GateModule.getAccessTimeSchedule1(loginHandleLong); | 132 | + GateModule.getAccessTimeSchedule1(loginHandleLong,permissionBean.getChannel()); |
| 133 | } | 133 | } |
| 134 | 134 | ||
| 135 | 135 |
cloud/dahua/src/main/resources/mapper/PermissionFaceMapper.xml
| @@ -23,7 +23,7 @@ | @@ -23,7 +23,7 @@ | ||
| 23 | 23 | ||
| 24 | <insert id="addPermissionFace" parameterType="com.example.dahua.bean.PermissionFaceBean"> | 24 | <insert id="addPermissionFace" parameterType="com.example.dahua.bean.PermissionFaceBean"> |
| 25 | 25 | ||
| 26 | - insert into PermissionFace values (#{permissionJson},#{schoolId},#{perrmissName},#{createTime},#{updateTime}) | 26 | + insert into PermissionFace values (#{permissionJson},#{schoolId},#{perrmissName},#{createTime},#{updateTime},#{channel},#{customName}) |
| 27 | 27 | ||
| 28 | </insert> | 28 | </insert> |
| 29 | 29 |
cloud/dahua/src/test/java/com/example/dahua/mapper/SearchMapperTest.java
| @@ -5,6 +5,7 @@ import com.example.dahua.Tester; | @@ -5,6 +5,7 @@ import com.example.dahua.Tester; | ||
| 5 | import com.example.dahua.bean.CheckIn; | 5 | import com.example.dahua.bean.CheckIn; |
| 6 | import com.example.dahua.bean.ShortMsg; | 6 | import com.example.dahua.bean.ShortMsg; |
| 7 | import com.example.dahua.dao.UserDao; | 7 | import com.example.dahua.dao.UserDao; |
| 8 | +import com.example.dahua.service.UserService; | ||
| 8 | import com.example.dahua.utils.DateUtils; | 9 | import com.example.dahua.utils.DateUtils; |
| 9 | import com.example.dahua.xiananDao.SearchMapper; | 10 | import com.example.dahua.xiananDao.SearchMapper; |
| 10 | import org.junit.Test; | 11 | import org.junit.Test; |
| @@ -27,6 +28,9 @@ public class SearchMapperTest extends Tester { | @@ -27,6 +28,9 @@ public class SearchMapperTest extends Tester { | ||
| 27 | @Autowired | 28 | @Autowired |
| 28 | private UserDao userDao; | 29 | private UserDao userDao; |
| 29 | 30 | ||
| 31 | + @Autowired | ||
| 32 | + private UserService userService; | ||
| 33 | + | ||
| 30 | @Test | 34 | @Test |
| 31 | public void test(){ | 35 | public void test(){ |
| 32 | //有效刷卡调考勤存储过程 | 36 | //有效刷卡调考勤存储过程 |
| @@ -61,4 +65,6 @@ public class SearchMapperTest extends Tester { | @@ -61,4 +65,6 @@ public class SearchMapperTest extends Tester { | ||
| 61 | // System.out.println(JSON.toJSON(userDao.checkLeave("234232"))); | 65 | // System.out.println(JSON.toJSON(userDao.checkLeave("234232"))); |
| 62 | 66 | ||
| 63 | } | 67 | } |
| 68 | + | ||
| 69 | +// boolean uploadImgAndUserInfo(String file, String schoolId, String studentCode, String clint_type, int userType, String devid); | ||
| 64 | } | 70 | } |