From 3d2b122faed2614a9b03468034b6c58e6b45a68e Mon Sep 17 00:00:00 2001 From: 2821744554@qq.com <2821744554@qq.com> Date: Mon, 28 Sep 2020 13:40:03 +0800 Subject: [PATCH] 人脸抓拍机实现 --- cloud/dahua/ReadMe.md | 30 ++++++++++++++++++++++++++++++ cloud/dahua/src/main/java/com/example/dahua/MyTask.java | 16 ++++++++++------ cloud/dahua/src/main/java/com/example/dahua/async/MyScheduledTask.java | 8 ++++---- cloud/dahua/src/main/java/com/example/dahua/async/SendUserInfoTask.java | 11 ++++------- cloud/dahua/src/main/java/com/example/dahua/bean/StudentBean.java | 54 +++++++++++++++++++++++++++++++++++++++++++++++++++++- cloud/dahua/src/main/java/com/example/dahua/control/FileControl.java | 4 ++-- cloud/dahua/src/main/java/com/example/dahua/control/UserControl.java | 174 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++---------------- cloud/dahua/src/main/java/com/example/dahua/dao/UserDao.java | 29 +++++++++++++++++++++++++++-- cloud/dahua/src/main/java/com/example/dahua/module/GateModule.java | 42 +++++++++++++++++++++++++++--------------- cloud/dahua/src/main/java/com/example/dahua/service/imp/PermissFaceServiceImp.java | 47 ++++++++++++++++++++++++++++++++++++++++++----- cloud/dahua/src/main/java/com/example/dahua/service/imp/UserServiceImp.java | 8 +++++++- cloud/dahua/src/main/java/com/example/dahua/utils/BaiduUtils.java | 2 +- cloud/dahua/src/main/java/com/example/dahua/xiananDao/SendRecordDao.java | 10 ++++++---- cloud/dahua/src/test/java/com/example/dahua/DahuaApplicationTests.java | 44 +++++++------------------------------------- cloud/fIle-center/ReadMe.md | 13 +++++++++++++ cloud/fIle-center/src/main/java/com/sincere/file/control/FileControl.java | 4 ++-- cloud/fIle-center/src/main/java/com/sincere/file/service/impl/AliyunOssServiceImpl.java | 4 ++-- cloud/haikangface/ReadMe.md | 38 ++++++++++++++++++++++++++++++++++++++ cloud/haikangface/src/main/java/com/sincere/haikangface/CMSServer.java | 106 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++---------------------------------------------- cloud/haikangface/src/main/java/com/sincere/haikangface/Test.java | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ cloud/haikangface/src/main/java/com/sincere/haikangface/control/FileControl.java | 6 +++--- cloud/haikangface/src/main/java/com/sincere/haikangface/control/UserControl.java | 151 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++------------- cloud/haikangface/src/main/java/com/sincere/haikangface/dao/UserDao.java | 10 +++++++++- cloud/haikangface/src/main/java/com/sincere/haikangface/utils/AlarmUtils.java | 10 ++++++++-- cloud/haikangface/src/main/java/com/sincere/haikangface/xiananDao/SendRecordDao.java | 9 +++++++-- cloud/mypulsar/src/main/java/com/example/mypulsar/MyRunnerableInt.java | 2 +- cloud/mypulsar/src/test/java/com/example/mypulsar/MypulsarApplicationTests.java | 8 +++----- cloud/pom.xml | 2 +- cloud/quartz/src/main/java/com/sincere/quartz/job/SyncJob.java | 58 +++++++++++++++++++++++++++++----------------------------- cloud/zkAttendance/pom.xml | 10 +++++++++- cloud/zkAttendance/src/main/java/com/sincere/att/AttApplication.java | 2 ++ cloud/zkAttendance/src/main/java/com/sincere/att/Swagger2.java | 1 - cloud/zkAttendance/src/main/java/com/sincere/att/controller/AttPushController.java | 252 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++------------------------------------------------------------------------------------------------------------- cloud/zkAttendance/src/main/resources/application.yaml | 3 ++- 34 files changed, 896 insertions(+), 320 deletions(-) create mode 100644 cloud/dahua/ReadMe.md create mode 100644 cloud/fIle-center/ReadMe.md create mode 100644 cloud/haikangface/ReadMe.md create mode 100644 cloud/haikangface/src/main/java/com/sincere/haikangface/Test.java diff --git a/cloud/dahua/ReadMe.md b/cloud/dahua/ReadMe.md new file mode 100644 index 0000000..81fff26 --- /dev/null +++ b/cloud/dahua/ReadMe.md @@ -0,0 +1,30 @@ +#**服务运行的环境** +##一、运行需要的基本环境库 + 在包路径下有个libs文件,该文件下有个win64文件夹,里面存放了核心的库文件; + +##二、服务运行的核心库 + 在com.example.dahua.lib下有个NetSDKLib实现类,里面封装了各种核心的方法,只需要知道调用就行; + com.example.dahua.module下的类是人脸设备方法的实现,可直接调用,基本上用的是GateModule类; + +##三、下发人员信息流程 + 在mytask类中 有个设备自注册服务在autoRegister()方法中,会在ServiceCB回调接口中响应设备的注册信息, + 注册上来的设备都会存在内存中,通过deviceInfoBeans存储; + 人脸和卡号下发都是通过GateModule类中的响应方法下发; + +##四、下发人脸和权限的API接口 + 由于之前图片传的是本地的绝对路径,所以在100服务器上部署了一个接口服务,对应的接口控制器为UserControl, + UserControl内部有逻辑处理,大华因为可以远程控制设备的注册ip和端口号,所以设备都注册在了21服务器上,做 + 人脸下发的操作都在FileControl中; + +##五、部署到不同服务器中需要注意什么? + 大华的不用修改什么,只需要注意服务器内存就行; + +##六、UserControl的主要接口方法 + sendPermission():下发权限,这个是在最新的人脸一体机和教师点名中使用方式上会用到,注册上来的人脸机设备id会以ytj开头,注意如果出现人脸和权限都下发了的情况还是提示没有权限,那就再发一遍权限,有些机型需要先发人脸再发权限; + sendToKB():人脸抓拍机会把抓到的人脸信息推送到数据看板,这个用来做测试用; + uploadImgAndUserInfo():单个下发人脸的接口 + imgsSend():下发学校下所有人脸给指定设备; + checkFace():在线活体检测; + +##七、配置信息修改 + application.yaml,该文件下包含了数据库配置、注册中心、数据库文件映射等信息,端口号、服务名也都是在这里修改; \ No newline at end of file diff --git a/cloud/dahua/src/main/java/com/example/dahua/MyTask.java b/cloud/dahua/src/main/java/com/example/dahua/MyTask.java index 2261be1..171dc03 100644 --- a/cloud/dahua/src/main/java/com/example/dahua/MyTask.java +++ b/cloud/dahua/src/main/java/com/example/dahua/MyTask.java @@ -66,9 +66,9 @@ public class MyTask implements ApplicationRunner { public void run(ApplicationArguments args) throws Exception { // 121.40.109.21 -// LoginModule.init(disConnect, haveReConnect); // 打开工程,初始化 + LoginModule.init(disConnect, haveReConnect); // 打开工程,初始化 -// autoRegister();//自注册 + autoRegister();//自注册 // System.out.println(" sendRecordDao:"+sendRecordDao.getSenSuccess()); } @@ -205,7 +205,11 @@ public class MyTask implements ApplicationRunner { lLongMap.put(deviceId, loginHandleLong); isHasNewDevice = true; String inTime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()); - int index = attendanceService.insert(deviceId, "22", pIp, wPort + "", inTime, "-1", "1"); + if (deviceId.startsWith("ytj")){ + attendanceService.insert(deviceId, "29", pIp, wPort + "", inTime, "-1", "1"); + }else { + attendanceService.insert(deviceId, "22", pIp, wPort + "", inTime, "-1", "1"); + } DeviceInfoBean deviceInfoBean = new DeviceInfoBean(); deviceInfoBean.setDevcieId(deviceId); deviceInfoBean.setDeviceIp(pIp); @@ -232,9 +236,9 @@ public class MyTask implements ApplicationRunner { if (null != deviceInfoBeans && deviceInfoBeans.size() > 0) { for (DeviceInfoBean dev : deviceInfoBeans) { -// FileUtils.getInstance().writeLogs(dev.getDevcieId() + "------" + lLongMap.get(dev.getDevcieId()), FileUtils.device_login); if (lLongMap.get(dev.getDevcieId()).intValue() > 0) { NetSDKLib.LLong lLong = GateModule.realLoadPic(0, analyzerCallback, lLongMap.get(dev.getDevcieId())); +// System.out.println("监听成功:"+dev.getDevcieId()); if (lLong.intValue() != -1) { deviceInfoBeans.remove(dev); } @@ -291,10 +295,10 @@ public class MyTask implements ApplicationRunner { snapPicPath = snapPicPath.replace("FaceRecoder", "image"); if (cardBean.getType() == 0) {//老师 TeacherBean teacherBean = userDao.getTeacherWithId(cardBean.getUser_id()); - sendRecordDao.addFaceRecoder("", teacherBean.getUser_id(), teacherBean.getName(), snapPicPath, 1, time, card); + sendRecordDao.addFaceRecoder("", teacherBean.getUser_id(), teacherBean.getName(), snapPicPath, 1, time, card,""); } else if (cardBean.getType() == 2) {//学生 UserInfoBean userInfoBean = userDao.getStudentWithid(cardBean.getUser_id()); - sendRecordDao.addFaceRecoder("", userInfoBean.getUser_id(), userInfoBean.getName(), snapPicPath, 1, time, card); + sendRecordDao.addFaceRecoder("", userInfoBean.getUser_id(), userInfoBean.getName(), snapPicPath, 1, time, card,""); } } diff --git a/cloud/dahua/src/main/java/com/example/dahua/async/MyScheduledTask.java b/cloud/dahua/src/main/java/com/example/dahua/async/MyScheduledTask.java index 4473484..96b2ecf 100644 --- a/cloud/dahua/src/main/java/com/example/dahua/async/MyScheduledTask.java +++ b/cloud/dahua/src/main/java/com/example/dahua/async/MyScheduledTask.java @@ -63,9 +63,9 @@ public class MyScheduledTask { private String imgFilPath = "C:\\EhomePicServer";//抓拍图片路径 - // @Scheduled(fixedRate = 5000) + @Scheduled(fixedRate = 5000) private void sendErrorInfo() throws InterruptedException { - System.out.println("---------------------------sendErrorInfo:"); +// System.out.println("---------------------------sendErrorInfo:"); // System.out.println("定时任务执行中...."); deleteFaceImg(); @@ -76,13 +76,13 @@ public class MyScheduledTask { SimpleDateFormat simpleDateFormat = new SimpleDateFormat("HH"); int hour = Integer.parseInt(simpleDateFormat.format(new Date())); - if (hour >= 9 && hour < 11) { + /* if (hour >= 9 && hour < 11) { dealData(); } else if (hour >= 13 && hour < 14) { dealData(); } else if (hour >= 20 || hour < 5) { dealData(); - } + }*/ if (myTasks.isHasNewDevice) myTasks.reloadPic(); diff --git a/cloud/dahua/src/main/java/com/example/dahua/async/SendUserInfoTask.java b/cloud/dahua/src/main/java/com/example/dahua/async/SendUserInfoTask.java index 774ebca..b0b3539 100644 --- a/cloud/dahua/src/main/java/com/example/dahua/async/SendUserInfoTask.java +++ b/cloud/dahua/src/main/java/com/example/dahua/async/SendUserInfoTask.java @@ -267,23 +267,21 @@ public class SendUserInfoTask { Memory memory = null;//图片缓存 try { String targPath = FilePath.picPathComp + userInfoBean.getStudentcode() + ".jpg"; -// String targPath = "C:\\Users\\taohandong\\Desktop\\comp\\"+userInfoBean.getStudentcode()+".jpg"; if (new File(picSrc).exists()) CompressPic.CompressPic(picSrc, targPath, userInfoBean.getStudentcode());//压缩后的图片 memory = ToolKits.readPictureFile(targPath); sendRecordBean.setImgPath(picSrc); -// System.out.println("下发学生信息:" + "targPath:" + new File(targPath).exists() + targPath + " userInfoBean:" + userInfoBean); } catch (Exception e) { e.printStackTrace(); } for (AttendanceBean attendanceBean : attendanceBeans) { - pushCardAndFace(attendanceBean, userInfoBean.getUser_id(), userInfoBean.getStudent_num(), userInfoBean.getName(), memory, sendRecordBean); + pushCardAndFace(attendanceBean, userInfoBean.getUser_id(), userInfoBean.getStudent_num(), userInfoBean.getName(), memory, sendRecordBean,userType); } } - private synchronized void pushCardAndFace(AttendanceBean attendanceBean, String user_id, String student_num, String name, Memory memory, SendRecordBean sendRecordBean) { + private synchronized void pushCardAndFace(AttendanceBean attendanceBean, String user_id, String student_num, String name, Memory memory, SendRecordBean sendRecordBean,String userType) { sendRecordBean.setDeviceID(attendanceBean.getClint_id()); sendRecordBean.setSchoolId(Integer.parseInt(attendanceBean.getSchool_id())); sendRecordBean.setTime(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date())); @@ -299,7 +297,6 @@ public class SendUserInfoTask { // System.out.println("loginHandleLong:" + loginHandleLong + MyTask.lLongMap.toString() + " 设备ID:" + attendanceBean.getClint_id()); // System.out.println("loginHandleLong:" +loginHandleLong); if (loginHandleLong == null) { - FileUtils.getInstance().writeLogs("设备不在线:" + attendanceBean.getClint_id(), FileUtils.devices); String deviceId = sendRecordDao.getFailIsExit(attendanceBean.getClint_id(), attendanceBean.getSchool_id()); sendRecordBean.setFailType(2); @@ -315,7 +312,7 @@ public class SendUserInfoTask { String cardNum = cardNo(student_num); if (bCardFlags != -1) {//修改卡信息 GateModule.modifyCard(bCardFlags, cardNum, user_id, name, "123456", Res.string().getCardStatusInt(1), Res.string().getCardTypeInt(1), - 0, 0, 1, startTime, endTime, loginHandleLong); + 0, 0, 1, startTime, endTime, loginHandleLong,userType); userDao.updateRecordNo(user_id, bCardFlags, attendanceBean.getClint_id()); bFaceFalgs = GateModule.modifyFaceInfo(user_id, memory, loginHandleLong); //卡号添加成功,但是人脸不成功的话,就需要新增人脸 @@ -326,7 +323,7 @@ public class SendUserInfoTask { bCardFlags = GateModule.insertCard(cardNum, user_id, name, "123456" , Res.string().getCardStatusInt(1), Res.string().getCardTypeInt(1), 0, 1 - , 1, startTime, endTime, loginHandleLong); + , 1, startTime, endTime, loginHandleLong,userType); if (bCardFlags != -1) { int index = userDao.saveRecordNo(user_id, bCardFlags, name, attendanceBean.getClint_id());//存储记录集编号 diff --git a/cloud/dahua/src/main/java/com/example/dahua/bean/StudentBean.java b/cloud/dahua/src/main/java/com/example/dahua/bean/StudentBean.java index 7bde583..4db2885 100644 --- a/cloud/dahua/src/main/java/com/example/dahua/bean/StudentBean.java +++ b/cloud/dahua/src/main/java/com/example/dahua/bean/StudentBean.java @@ -13,6 +13,8 @@ public class StudentBean implements Serializable { private int StudentType; + private String teacher_num; + private int UserType; private String Name; @@ -21,6 +23,12 @@ public class StudentBean implements Serializable { private String ClassName; + private String class_id; + + private String class_name; + + private String student_type; + private String OldCard; private String Card; @@ -49,6 +57,24 @@ public class StudentBean implements Serializable { private String studentcode; + private String num; + + public String getNum() { + return num; + } + + public void setNum(String num) { + this.num = num; + } + + public String getTeacher_num() { + return teacher_num; + } + + public void setTeacher_num(String teacher_num) { + this.teacher_num = teacher_num; + } + public String getUser_id() { return user_id; } @@ -225,6 +251,30 @@ public class StudentBean implements Serializable { this.student_id = student_id; } + public String getClass_id() { + return class_id; + } + + public void setClass_id(String class_id) { + this.class_id = class_id; + } + + public String getClass_name() { + return class_name; + } + + public void setClass_name(String class_name) { + this.class_name = class_name; + } + + public String getStudent_type() { + return student_type; + } + + public void setStudent_type(String student_type) { + this.student_type = student_type; + } + @Override public String toString() { return "StudentBean{" + @@ -236,6 +286,9 @@ public class StudentBean implements Serializable { ", Name='" + Name + '\'' + ", ClassId=" + ClassId + ", ClassName='" + ClassName + '\'' + + ", class_id='" + class_id + '\'' + + ", class_name='" + class_name + '\'' + + ", student_type='" + student_type + '\'' + ", OldCard='" + OldCard + '\'' + ", Card='" + Card + '\'' + ", SchoolId=" + SchoolId + @@ -245,7 +298,6 @@ public class StudentBean implements Serializable { ", AddTime=" + AddTime + ", Sex=" + Sex + ", Face='" + Face + '\'' + -// ", StudentCode='" + StudentCode + '\'' + ", student_num='" + student_num + '\'' + ", student_id='" + student_id + '\'' + ", user_id='" + user_id + '\'' + diff --git a/cloud/dahua/src/main/java/com/example/dahua/control/FileControl.java b/cloud/dahua/src/main/java/com/example/dahua/control/FileControl.java index 3615b39..60769a6 100644 --- a/cloud/dahua/src/main/java/com/example/dahua/control/FileControl.java +++ b/cloud/dahua/src/main/java/com/example/dahua/control/FileControl.java @@ -126,7 +126,7 @@ public class FileControl { @ApiOperation(value = "下发卡信息") public int addCard(@RequestParam("schoolId") String schoolId, @RequestParam("targPath") String targPath) { - File file = new File(targPath); + /*File file = new File(targPath); File[] files = file.listFiles(); @@ -148,7 +148,7 @@ public class FileControl { } - } + }*/ return 1; diff --git a/cloud/dahua/src/main/java/com/example/dahua/control/UserControl.java b/cloud/dahua/src/main/java/com/example/dahua/control/UserControl.java index e9ba77f..269fcc2 100644 --- a/cloud/dahua/src/main/java/com/example/dahua/control/UserControl.java +++ b/cloud/dahua/src/main/java/com/example/dahua/control/UserControl.java @@ -1,37 +1,28 @@ package com.example.dahua.control; import com.example.dahua.MyTask; -import com.example.dahua.async.ImageUtils; import com.example.dahua.async.SendUserInfoTask; import com.example.dahua.bean.PermissionBean; -import com.example.dahua.bean.UserAndPermission; +import com.example.dahua.bean.SendRecordBean; +import com.example.dahua.bean.StudentBean; +import com.example.dahua.dao.UserDao; import com.example.dahua.lib.CompressPic; import com.example.dahua.service.UserService; import com.example.dahua.utils.*; +import com.example.dahua.xiananDao.SendRecordDao; import io.swagger.annotations.Api; import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParams; import io.swagger.annotations.ApiOperation; -import org.json.JSONArray; import org.json.JSONException; import org.json.JSONObject; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.http.HttpEntity; -import org.springframework.http.HttpHeaders; import org.springframework.http.MediaType; -import org.springframework.http.ResponseEntity; -import org.springframework.util.LinkedMultiValueMap; -import org.springframework.util.MultiValueMap; import org.springframework.util.StringUtils; import org.springframework.web.bind.annotation.*; import org.springframework.web.client.RestTemplate; -import org.springframework.web.multipart.MultipartFile; -import javax.imageio.stream.FileImageInputStream; import java.io.*; -import java.net.HttpURLConnection; -import java.net.URL; import java.util.*; /** @@ -51,6 +42,12 @@ public class UserControl { @Autowired MyTask myTasks; + @Autowired + SendRecordDao sendRecordDao; + + @Autowired + UserDao userDao; + @RequestMapping(value = "uploadImgAndUserInfo", method = RequestMethod.GET) @ApiOperation(value = "上传用户信息") @@ -72,6 +69,130 @@ public class UserControl { return true; } + @RequestMapping(value = "sendFaces", method = RequestMethod.GET) + @ApiOperation(value = "下发学校下所有人脸给指定设备", notes = "下发所有人脸给指定设备") + public void sendFaces(@RequestParam("deviceIds") String deviceIds, @RequestParam("schoolId") String schoolId, @RequestParam("userType") String userType) { + + String typeName = userType.equals("1") ? "Teacher" : "Student"; + + String imgPath = "E:\\wwwhtdocs\\SmartCampus\\face17e5\\School" + schoolId + "\\" + typeName; + + File imgPathFile = new File(imgPath);//目录 + + String[] deviceIdsStr = deviceIds.split(","); + + + if (imgPathFile.exists()) { + File[] imgfiles = imgPathFile.listFiles(); + if (null != imgfiles) { + + for (int i = 0; i < imgfiles.length; i++) { + File file = imgfiles[i];//图片 + String targetPath = "./picPath/comp/" + file.getName(); + try { + CompressPic.CompressPic(file.getAbsolutePath(), targetPath, ""); + } catch (Exception e) { + e.printStackTrace(); + } + if (file.exists()) + for (int j = 0; j < deviceIdsStr.length; j++) { + String deviceId = deviceIdsStr[j]; + + StudentBean studentBean = null; + String card = "", name = "", studentCode = ""; + if (userType.equals("1")) { + studentBean = userDao.getTeacherWithstudentcode(file.getName().split("\\.")[0], schoolId); + if (null != studentBean) { + card = studentBean.getTeacher_num(); + name = studentBean.getName(); + studentCode = studentBean.getNum(); + } + } else if (userType.equals("2")) { + studentBean = userDao.getStudentWithstudentcode(file.getName().split("\\.")[0], schoolId); + if (null != studentBean) { + card = studentBean.getStudent_num(); + name = studentBean.getName(); + studentCode = studentBean.getStudentcode(); + } + } + + if (!StringUtils.isEmpty(card)) { + String clint_type = userDao.getClintType(deviceId); + HttpUtils.uploadImgs(new File(targetPath), schoolId, studentCode, clint_type, Integer.parseInt(userType)); + } + + } + + } + + } + } + + } + + @RequestMapping(value = "sendErrorFaces", method = RequestMethod.GET) + @ApiOperation(value = "下发失败的人脸", notes = "下发失败的人脸") + public void sendErrorFaces(@RequestParam("schoolId") String schoolId, @RequestParam("deviceid") String deviceid,@RequestParam("userType")int userType) { + + if (!StringUtils.isEmpty(deviceid)) { + senErrorFace(deviceid, schoolId, userType); + } else { + List deviceIds = sendRecordDao.getDeviceIds(schoolId); + + if (null != deviceIds) { + for (int j = 0; j < deviceIds.size(); j++) { + String deviceId = deviceIds.get(j); + senErrorFace(deviceId, schoolId,userType); + } + } + } + + + } + + + private void senErrorFace(String deviceId, String schoolId, int userType) { + List sendRecordBeans = sendRecordDao.getSendFailWithDevId(deviceId); + if (null != sendRecordBeans) { + + for (int i = 0; i < sendRecordBeans.size(); i++) { + + SendRecordBean sendRecordBean = sendRecordBeans.get(i); + String typeName = ""; + if (userType==0){ + typeName = sendRecordBean.getUserType() == 1 ? "Teacher" : "Student"; + }else { + typeName = userType == 1 ? "Teacher" : "Student"; + } + String studentCode = ""; + + if (sendRecordBean.getUserType() == 1) { + studentCode = userDao.getTeaNumWithCard(sendRecordBean.getNum()); + } else if (sendRecordBean.getUserType() == 2) { + studentCode = userDao.getStudentCode(sendRecordBean.getNum()); + } + + String imgPath = "E:\\wwwhtdocs\\SmartCampus\\face17e50\\School" + sendRecordBean.getSchoolId() + "\\" + typeName + "\\" + studentCode + ".png"; + File imgFile = new File(imgPath); + if (imgFile.exists()) { + String targetPath = "./picPath/comp/" + imgFile.getName(); + try { + CompressPic.CompressPic(imgFile.getAbsolutePath(), targetPath, ""); + } catch (Exception e) { + e.printStackTrace(); + } + + String clint_type = userDao.getClintType(sendRecordBean.getDeviceID()); + HttpUtils.uploadImgs(new File(targetPath), schoolId, studentCode, clint_type, sendRecordBean.getUserType()); + } else { + System.out.println("文件不存在"); + } + } + + } + } + + @RequestMapping(value = "sendSingle", method = RequestMethod.GET) @ApiOperation(value = "单张卡下发") public String sendSIngle(@RequestParam("SchoolId") String SchoolId, @RequestParam("Card") String Card) { @@ -123,11 +244,11 @@ public class UserControl { String userCode = file.getName().split("\\.")[0]; - String schoolId = ""; + String schoolId = "864"; - if (httpurl.contains("Student")) { + if (httpurl.contains("Student")&&!httpurl.startsWith("http")) { schoolId = httpurl.substring(httpurl.indexOf("School") + 6, httpurl.indexOf("\\Student")); - } else if (httpurl.contains("Teacher")) { + } else if (httpurl.contains("Teacher")&&!httpurl.startsWith("http")) { schoolId = httpurl.substring(httpurl.indexOf("School") + 6, httpurl.indexOf("\\Teacher")); } System.out.println("choolId:" + schoolId + "userCode:" + userCode); @@ -143,6 +264,27 @@ public class UserControl { } + @RequestMapping(value = "jpg2png", method = RequestMethod.GET) + @ApiOperation("jpg图片转png") + public boolean jpg2png(@RequestParam("path") String path) { + + File file = new File(path); + if (file.exists()) { + + File[] files = file.listFiles(); + + for (int i = 0; i < files.length; i++) { + File filePath = files[i]; + BaiduUtils.getBaiduUtils().checkImg(filePath.getAbsolutePath()); + } + + } + + return true; + + } + + /*@RequestMapping(value = "tranpic", method = RequestMethod.GET) diff --git a/cloud/dahua/src/main/java/com/example/dahua/dao/UserDao.java b/cloud/dahua/src/main/java/com/example/dahua/dao/UserDao.java index 287408a..522a5a1 100644 --- a/cloud/dahua/src/main/java/com/example/dahua/dao/UserDao.java +++ b/cloud/dahua/src/main/java/com/example/dahua/dao/UserDao.java @@ -129,12 +129,37 @@ public interface UserDao { void getUserWidthUserId(@Param("userId") String userId); @Select("select * from SZ_V_School_Student where user_id = #{userId}") - List getStudentWithUserId(@Param("userId")String userId); + List getStudentWithUserId(@Param("userId") String userId); @Select("select * from SZ_V_School_Teacher where user_id = #{userId}") - List getTeaWithUserId(@Param("userId")String userId); + List getTeaWithUserId(@Param("userId") String userId); @Select("select Top(1) user_id from SZ_V_School_Student where studentcode = #{studentcode}") String getStuWithCode(@Param("studentcode") String code); + @Select("select top(1) num from SZ_V_School_Teacher where teacher_num=#{num}") + String getTeaNumWithCard(@Param("num") String num); + + @Select("select clint_type from SZ_Attendance where clint_id = #{clint_id}}") + String getClintType(@Param("clint_id") String deviceID); + + @Select("select v.* from SZ_Student as s inner join SZ_V_School_Student as v on s.student_id = v.student_id where s.intime>'2020-09-01' and school_id = 654 order by student_id desc ") + List getStus(); + + @Insert("insert into HS_StudentUpdateCard(UserId,CustomerId,StudentType,UserType,Name,ClassId,ClassName,Card,SchoolId,IsNew,UpdateType,AddTime,Sex,StudentCode,mobile) values (" + + "#{UserId},#{CustomerId},#{StudentType},#{UserType},#{Name},#{ClassId},#{ClassName},#{Card},#{SchoolId},#{IsNew},#{UpdateType},#{AddTime},#{Sex},#{StudentCode},#{mobile})") + void insertUpdateCard(@Param("UserId")String UserId,@Param("CustomerId")String CustomerId,@Param("StudentType")String StudentType,@Param("UserType")String UserType, + @Param("Name")String Name,@Param("ClassId")String ClassId,@Param("ClassName")String ClassName,@Param("Card")String Card,@Param("SchoolId")String SchoolId, + @Param("IsNew")String IsNew,@Param("UpdateType")String UpdateType,@Param("AddTime")String AddTime,@Param("Sex")String Sex,@Param("StudentCode")String StudentCode, + @Param("mobile")String mobile); + + @Select("select Top(1)*\n" + + "from SZ_V_School_Teacher\n" + + "where num = #{num} and school_id = #{schoolId}") + StudentBean getTeacherWithstudentcode(@Param("num") String num, @Param("schoolId") String schoolId); + + @Select("select Top(1)*\n" + + "from SZ_V_School_Student\n" + + "where studentcode = #{studentcode} and school_id = #{schoolId}") + StudentBean getStudentWithstudentcode(@Param("studentcode") String studentcode, @Param("schoolId") String schoolId); } diff --git a/cloud/dahua/src/main/java/com/example/dahua/module/GateModule.java b/cloud/dahua/src/main/java/com/example/dahua/module/GateModule.java index 59ffd72..839a215 100644 --- a/cloud/dahua/src/main/java/com/example/dahua/module/GateModule.java +++ b/cloud/dahua/src/main/java/com/example/dahua/module/GateModule.java @@ -165,7 +165,7 @@ public class GateModule { public static synchronized int insertCard(String cardNo, String userId, String cardName, String cardPwd, int cardStatus, int cardType, int useTimes, int isFirstEnter, - int isValid, String startValidTime, String endValidTime, LLong lLong) { + int isValid, String startValidTime, String endValidTime, LLong lLong,String userType) { /** * 门禁卡记录集信息 */ @@ -192,8 +192,13 @@ public class GateModule { accessCardInfo.sznDoors[0] = 0; accessCardInfo.sznDoors[1] = 1; accessCardInfo.nTimeSectionNum = 2; // 与门数对应 - accessCardInfo.sznTimeSectionNo[0] = 120; // 表示第一个门全天有效 - accessCardInfo.sznTimeSectionNo[1] = 120; // 表示第二个门全天有效 + if (userType.equals("1")){ + accessCardInfo.sznTimeSectionNo[0] = 255; // 表示第一个门全天有效 + accessCardInfo.sznTimeSectionNo[1] = 255; // 表示第二个门全天有效 + }else { + accessCardInfo.sznTimeSectionNo[0] = 120; // 表示第一个门全天有效 + accessCardInfo.sznTimeSectionNo[1] = 120; // 表示第二个门全天有效 + } // 卡状态 accessCardInfo.emStatus = cardStatus; @@ -380,17 +385,19 @@ public class GateModule { // 获取 if (ToolKits.GetDevConfig(lLong, nChannel, strCmd, msg)) { - System.out.println("Enable:" + msg.bEnable); - try { - System.out.println("自定义名称:" + new String(msg.szName, "utf-8").trim()); - } catch (UnsupportedEncodingException e) { - e.printStackTrace(); - } +// System.out.println("Enable:" + msg.bEnable); +// try { +// System.out.println("自定义名称:" + new String(msg.szName, "utf-8").trim()); +// } catch (UnsupportedEncodingException e) { +// e.printStackTrace(); +// } for (int i = 0; i < 7; i++) { - for (int j = 0; j < 4; j++) { - System.out.println("dwRecordMask:" + msg.stuTimeWeekDay[i].stuTimeSection[j].dwRecordMask); + for (int j = 0; j < 3; j++) { +// System.out.println("dwRecordMask:" + msg.stuTimeWeekDay[i].stuTimeSection[j]); System.out.println(msg.stuTimeWeekDay[i].stuTimeSection[j].startTime() + "-" + - msg.stuTimeWeekDay[i].stuTimeSection[j].endTime() + "\n"); + msg.stuTimeWeekDay[i].stuTimeSection[j].endTime()); + System.out.println("--------------------------------------------"); + } } // 设置 @@ -514,7 +521,7 @@ public class GateModule { public static boolean modifyCard(int recordNo, String cardNo, String userId, String cardName, String cardPwd, int cardStatus, int cardType, int useTimes, int isFirstEnter, - int isValid, String startValidTime, String endValidTime, LLong lLong) { + int isValid, String startValidTime, String endValidTime, LLong lLong,String userType) { /** * 门禁卡记录集信息 */ @@ -543,8 +550,13 @@ public class GateModule { accessCardInfo.sznDoors[0] = 0; accessCardInfo.sznDoors[1] = 1; accessCardInfo.nTimeSectionNum = 2; // 与门数对应 - accessCardInfo.sznTimeSectionNo[0] = 120; // 表示第一个门全天有效 - accessCardInfo.sznTimeSectionNo[1] = 120; // 表示第二个门全天有效 + if (userType.equals("1")){ + accessCardInfo.sznTimeSectionNo[0] = 255; // 表示第一个门全天有效 + accessCardInfo.sznTimeSectionNo[1] = 255; // 表示第二个门全天有效 + }else { + accessCardInfo.sznTimeSectionNo[0] = 120; // 表示第一个门全天有效 + accessCardInfo.sznTimeSectionNo[1] = 120; // 表示第二个门全天有效 + } // 卡状态 accessCardInfo.emStatus = cardStatus; diff --git a/cloud/dahua/src/main/java/com/example/dahua/service/imp/PermissFaceServiceImp.java b/cloud/dahua/src/main/java/com/example/dahua/service/imp/PermissFaceServiceImp.java index 00b3ae7..e91777d 100644 --- a/cloud/dahua/src/main/java/com/example/dahua/service/imp/PermissFaceServiceImp.java +++ b/cloud/dahua/src/main/java/com/example/dahua/service/imp/PermissFaceServiceImp.java @@ -16,9 +16,7 @@ import org.springframework.stereotype.Service; import org.springframework.util.StringUtils; import org.springframework.web.client.RestTemplate; -import java.io.File; -import java.io.FileOutputStream; -import java.io.IOException; +import java.io.*; import java.net.URI; import java.net.URISyntaxException; import java.util.List; @@ -187,18 +185,30 @@ public class PermissFaceServiceImp implements PermissFaceService { for (int i = 0; i < studentBeans.size(); i++) { StudentBean studentBean = studentBeans.get(i); int schoolId = studentBean.getSchool_id(); + String imgPath = "E:\\wwwhtdocs\\SmartCampus\\face17e50\\School" + schoolId + "\\Student" + "\\" + studentBean.getStudentcode() + ".png"; + File stuFile = new File(imgPath); + if (!stuFile.exists())stuFile.createNewFile(); + + copy(saveImgFile.getAbsolutePath(),imgPath); + uploadImgs(saveImgFile, schoolId + "", studentBean.getStudentcode(), 2, studentBean.getCard(), studentBean.getName()); } } else { List teacherBeans = userDao.getTeaWithUserId(userId); -log.error("教师下发"); + log.error("教师下发"); if (null != teacherBeans && teacherBeans.size() > 0) { for (int i = 0; i < teacherBeans.size(); i++) { TeacherBean teacherBean = teacherBeans.get(i); String schoolId = teacherBean.getSchool_id(); + + String imgPath = "E:\\wwwhtdocs\\SmartCampus\\face17e50\\School" + schoolId + "\\Teacher" + "\\" + teacherBean.getNum() + ".png"; + File stuFile = new File(imgPath); + if (!stuFile.exists())stuFile.createNewFile(); + copy(saveImgFile.getAbsolutePath(),imgPath); + uploadImgs(saveImgFile, schoolId, teacherBean.getNum(), 1, teacherBean.getTeacher_num(), teacherBean.getName()); } @@ -225,6 +235,33 @@ log.error("教师下发"); return responseBean; } + + private void copy(String src,String target){ + + try { + FileInputStream fileInputStream = new FileInputStream(src); + FileOutputStream fileOutputStream = new FileOutputStream(target); + + byte[] bytes = new byte[1024]; + int length = -1; + while ((length=fileInputStream.read(bytes))!=0){ + + fileOutputStream.write(bytes,0,length); + + } + + fileInputStream.close(); + fileOutputStream.close(); + + } catch (FileNotFoundException e) { + e.printStackTrace(); + } catch (IOException e) { + e.printStackTrace(); + } + + } + + private void uploadImgs(File saveImgFile, String schoolId, String studentcode, int userType, String card, String name) { List attendanceBeanList = userDao.getAllDevices(schoolId + ""); if (null != attendanceBeanList && attendanceBeanList.size() > 0) @@ -233,7 +270,7 @@ log.error("教师下发"); String clintType = attendanceBean.getClint_type(); //根据设备类型上传人脸 - log.error("设备:{}",clintType); + log.error("设备:{}", clintType); if (clintType.equals("18") || clintType.equals("28")) { HttpUtils.uploadImg2HK(saveImgFile.getAbsolutePath(), card, name, attendanceBean.getClint_id(), String.valueOf(userType)); diff --git a/cloud/dahua/src/main/java/com/example/dahua/service/imp/UserServiceImp.java b/cloud/dahua/src/main/java/com/example/dahua/service/imp/UserServiceImp.java index 07cbc10..ee8689e 100644 --- a/cloud/dahua/src/main/java/com/example/dahua/service/imp/UserServiceImp.java +++ b/cloud/dahua/src/main/java/com/example/dahua/service/imp/UserServiceImp.java @@ -29,7 +29,11 @@ public class UserServiceImp implements UserService { if (!StringUtils.isEmpty(devid)) return userDao.getAttendanceBeanWithId(schoolId, clint_type, devid); - return userDao.getAttendanceBeans(schoolId, clint_type); + List attendanceBeanList = userDao.getAttendanceBeans(schoolId, clint_type); + + if (attendanceBeanList.size()==0)attendanceBeanList = userDao.getAttendanceBeans(schoolId,"29"); + + return attendanceBeanList; } @Override @@ -49,7 +53,9 @@ public class UserServiceImp implements UserService { @Override public boolean uploadImgAndUserInfo(String file, String schoolId, String studentCode, String clint_type, int userType, String devid) { List attendanceBeans = getAttendanceBeans(schoolId, clint_type, devid);//获取学校下的大华设备 + System.out.println("设备数量:" + attendanceBeans.size()); + UserInfoBean userInfoBean = null; try { if (userType == 2) { diff --git a/cloud/dahua/src/main/java/com/example/dahua/utils/BaiduUtils.java b/cloud/dahua/src/main/java/com/example/dahua/utils/BaiduUtils.java index ff08ebc..c4b3809 100644 --- a/cloud/dahua/src/main/java/com/example/dahua/utils/BaiduUtils.java +++ b/cloud/dahua/src/main/java/com/example/dahua/utils/BaiduUtils.java @@ -101,8 +101,8 @@ public class BaiduUtils { } } catch (Exception e) { e.printStackTrace(); + return false; } - return true; } /** diff --git a/cloud/dahua/src/main/java/com/example/dahua/xiananDao/SendRecordDao.java b/cloud/dahua/src/main/java/com/example/dahua/xiananDao/SendRecordDao.java index 0cb62a6..768d8be 100644 --- a/cloud/dahua/src/main/java/com/example/dahua/xiananDao/SendRecordDao.java +++ b/cloud/dahua/src/main/java/com/example/dahua/xiananDao/SendRecordDao.java @@ -75,14 +75,16 @@ public interface SendRecordDao { @Select("select * from Face_SendFail where schoolId = #{schoolId} and userType = #{userType} and deviceID = #{deviceID}") List getFaceFails(@Param("userType") int userType, @Param("schoolId") int schoolId, @Param("deviceID") String deviceID); - @Insert("insert into Face_Recoder values(#{deviceId},#{user_id},#{name},#{imgurl},#{inOrOut},#{time},#{cardNum})") + @Insert("insert into Face_Recoder values(#{deviceId},#{user_id},#{name},#{imgurl},#{inOrOut},#{time},#{cardNum},#{temp})") void addFaceRecoder(@Param("deviceId") String deviceId, @Param("user_id") String user_id, @Param("name") String name, @Param("imgurl") String imgurl, @Param("inOrOut") int inOrOut, @Param("time") String time, - @Param("cardNum") String cardNum); + @Param("cardNum") String cardNum,@Param("temp")String temp); + @Select("select DISTINCT deviceID from Face_SendFail where schoolId = #{schoolId} ") + List getDeviceIds(@Param("schoolId") String schoolId); - @Select("select stu.studentcode from DBLan137.smartcampus.dbo.SZ_V_School_Student as stu where stu.student_num in (select distinct NUM from Face_SendFail where schoolId = 1037 and time > '2020-04-13' and userType = 2)") - List getStudentCode(); + @Select("select * from Face_SendFail where deviceID = #{deviceID}") + List getSendFailWithDevId(@Param("deviceID") String deviceId); } diff --git a/cloud/dahua/src/test/java/com/example/dahua/DahuaApplicationTests.java b/cloud/dahua/src/test/java/com/example/dahua/DahuaApplicationTests.java index 7bb3d31..ef2058d 100644 --- a/cloud/dahua/src/test/java/com/example/dahua/DahuaApplicationTests.java +++ b/cloud/dahua/src/test/java/com/example/dahua/DahuaApplicationTests.java @@ -479,47 +479,17 @@ public class DahuaApplicationTests { @Test public void test1() { -// List list = userDao.getStudentUserIdsWith(); -// -// for (int i = 0; i < list.size(); i++) { -// StudentBean studentBean = list.get(i); -// } -// -// System.out.println("list:" + list.toString()); - -// List attendanceBeanList = userDao.getAttendanceBeans("479","4"); -// -// for (int i = 0; i < attendanceBeanList.size(); i++) { -// AttendanceBean attendanceBean = attendanceBeanList.get(i); -// -// -// } - - File file = new File("D:\\新七年级\\名字.txt"); - - try { - FileReader fileReader = new FileReader(file); - BufferedReader bufferedReader = new BufferedReader(fileReader); - List userInfoBeans = userDao.getStuUserInfos(); - String content = null; - while ((content = bufferedReader.readLine()) != null) { - - for (int i = 0; i < userInfoBeans.size(); i++) { - UserInfoBean userInfoBean = userInfoBeans.get(i); - if (content.equals(userInfoBean.getName())){ - System.out.println(userInfoBean.getStudentcode()+"\t"); - } - } + List studentBeans = userDao.getStus(); + for (int i = 0; i < studentBeans.size(); i++) { + StudentBean studentBean = studentBeans.get(i); + System.out.println("studentBean:"+studentBean.toString()); - } + userDao.insertUpdateCard(studentBean.getUser_id(),studentBean.getStudent_id(),studentBean.getStudent_type()+"","2", + studentBean.getName(),studentBean.getClass_id()+"",studentBean.getClass_name(),studentBean.getStudent_num(),studentBean.getSchool_id()+"", + "1","1","2020-09-23 11:40:00",studentBean.getSex()+"",studentBean.getStudentcode(),""); - } catch (FileNotFoundException e) { - e.printStackTrace(); - } catch (IOException e) { - e.printStackTrace(); } - } diff --git a/cloud/fIle-center/ReadMe.md b/cloud/fIle-center/ReadMe.md new file mode 100644 index 0000000..86286bf --- /dev/null +++ b/cloud/fIle-center/ReadMe.md @@ -0,0 +1,13 @@ +#文件管理服务 +##配置信息 + application.yml配置文件中配置了OSS的各种属性,如果要修改的话,可直接在这里修改; + +##实现的接口 + fileUpload1:上传文件,重名的会覆盖; + fileUpload:上传文件,重名的会在后面加1; +##配置类 + AliyunOSSConfig类,初始化的时候会调用配置文件中的信息; + AllowOriginFilter:做跨域处理; + +##业务处理类: + service文件下,类名后面以service结尾的就是抽象方法,以Imp结尾的就是对抽象方法的实现类,做业务处理; \ No newline at end of file diff --git a/cloud/fIle-center/src/main/java/com/sincere/file/control/FileControl.java b/cloud/fIle-center/src/main/java/com/sincere/file/control/FileControl.java index b682706..3340e08 100644 --- a/cloud/fIle-center/src/main/java/com/sincere/file/control/FileControl.java +++ b/cloud/fIle-center/src/main/java/com/sincere/file/control/FileControl.java @@ -80,7 +80,7 @@ public class FileControl { } - @RequestMapping(value = "getWord", method = RequestMethod.GET) + /*@RequestMapping(value = "getWord", method = RequestMethod.GET) @ApiOperation("获取21世纪题目") @ApiImplicitParams( {@ApiImplicitParam(name = "url", value = "链接")} @@ -106,7 +106,7 @@ public class FileControl { return fileService.uploadLocalFile(new File(wordPath), "test"); - } + }*/ } diff --git a/cloud/fIle-center/src/main/java/com/sincere/file/service/impl/AliyunOssServiceImpl.java b/cloud/fIle-center/src/main/java/com/sincere/file/service/impl/AliyunOssServiceImpl.java index abded0f..dfe3cea 100644 --- a/cloud/fIle-center/src/main/java/com/sincere/file/service/impl/AliyunOssServiceImpl.java +++ b/cloud/fIle-center/src/main/java/com/sincere/file/service/impl/AliyunOssServiceImpl.java @@ -43,8 +43,8 @@ public class AliyunOssServiceImpl extends AbstractFileService { @Override protected void uploadFile(MultipartFile file, FileInfo fileInfo, String filePath) throws Exception { -// String fileName = UUID.randomUUID().toString()+"."+fileInfo.getName().split("\\.")[1]; - String fileName = fileInfo.getName(); + String fileName = UUID.randomUUID().toString()+"."+fileInfo.getName().split("\\.")[1]; +// String fileName = fileInfo.getName(); String keyObjectName = filePath + "/" + fileName; // boolean isExist = ossClient.doesObjectExist(bucketName, keyObjectName); diff --git a/cloud/haikangface/ReadMe.md b/cloud/haikangface/ReadMe.md new file mode 100644 index 0000000..a064211 --- /dev/null +++ b/cloud/haikangface/ReadMe.md @@ -0,0 +1,38 @@ +#**服务运行的环境** +##一、运行需要的基本环境库 + 在C盘放了一个lib文件夹,里面放了服务运行的基础库,每台有海康服务的服务器上都有这个文件; + +##二、服务运行的核心库 + 和人脸机直接通信的服务功能全在CMSServer类里面,run方法是服务在运行的时候,会自动执行注册服务、图片服务、报警服务的初始化, + 分别对应initCMS()、initSS()、initAlarm(),里面的方法不用做修改; + CMS(注册服务):设备注册该服务的IP和端口,在FRegisterCallBack注册回调接口中接收注册信息,并响应报警服务器和图片服务器的ip和端口; + HCEHomeSS(图片服务):createImgPath()方法生成图片服务路径,生成后可以下发给人脸机使用; + initAlarm(报警服务):EHomeMsgCallBack回调方法会监听设备的各种报警信息,目前主要是对人脸识别成功做了记录,其余的方法可以参考PDF文件或者AlarmUtil类; + +##三、下发人员信息流程 + CMSServer方法封装了下发的方法,只需要调用就行,xml的字段和格式不需要去改变; + 直接调用createImgPath() 方法,里面执行了人脸图片路径生成和下发对应卡号的操作; + +##四、下发人脸和权限的API接口 + 由于之前图片传的是本地的绝对路径,所以在100服务器上部署了一个接口服务,对应的接口控制器为UserControl, + UserControl内部有逻辑处理,如果人脸机注册在100服务器上,就会直接对人脸机做下发人脸、报警信息处理等操作, + 如果没有注册在100服务器上,内部会调用api接口访问253上的接口,253上的服务会对注册的人脸机做响应操作,调用的 + 控制器对应FileControl,这些控制器都在这同一个服务中; + 下发权限:默认会发全天的权限; + +##五、部署到不同服务器中需要注意什么? + 唯一要注意的就是修改CMSServer服务中的ip_cloud值,改成对应服务的公网ip; + +##六、UserControl的主要接口方法 + sendPermiss():下发权限,这个是在最新的人脸一体机和教师点名中使用方式上会用到,注册上来的人脸机设备id会以ytj开头,注意如果出现人脸和权限都下发了的情况还是提示没有权限,那就再发一遍权限,有些机型需要先发人脸再发权限; + sendUsersAndPermiss():教师点名中用到了这个方法; + sendToKB():人脸抓拍机会把抓到的人脸信息推送到数据看板,这个用来做测试用; + sendCardAndImg1():单个下发人脸的接口 + sendFaces():下发学校下所有人脸给指定设备; + sendErrorFaces():下发失败的人脸; + sendFaceNotExits():下发学校下还没有下发的人脸给指定设备; + sendFaceToDevices():下发单个用户给指定设备 + deleteCard():删除人脸 + +##七、配置信息修改 + application.yaml,该文件下包含了数据库配置、注册中心、数据库文件映射等信息,端口号、服务名也都是在这里修改; \ No newline at end of file diff --git a/cloud/haikangface/src/main/java/com/sincere/haikangface/CMSServer.java b/cloud/haikangface/src/main/java/com/sincere/haikangface/CMSServer.java index 3d4e7ef..6208173 100644 --- a/cloud/haikangface/src/main/java/com/sincere/haikangface/CMSServer.java +++ b/cloud/haikangface/src/main/java/com/sincere/haikangface/CMSServer.java @@ -4,7 +4,6 @@ import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import com.sincere.haikangface.bean.*; -import com.sincere.haikangface.bean.face.BaiduUserInfoBean; import com.sincere.haikangface.bean.xiaoan.Face_Recoder; import com.sincere.haikangface.dao.DeviceDao; import com.sincere.haikangface.dao.UserDao; @@ -12,7 +11,6 @@ import com.sincere.haikangface.haikanglibs.HCEHomeAlarm; import com.sincere.haikangface.haikanglibs.HCEHomeCMS; import com.sincere.haikangface.haikanglibs.HCEHomeSS; import com.sincere.haikangface.mqtt.MqtUtils; -import com.sincere.haikangface.mqtt.MqttManager; import com.sincere.haikangface.utils.*; import com.sincere.haikangface.xiananDao.SendRecordDao; import com.sun.jna.NativeLong; @@ -38,13 +36,8 @@ import java.io.*; import java.net.InetAddress; import java.net.UnknownHostException; import java.nio.ByteBuffer; -import java.text.DecimalFormat; -import java.text.ParseException; import java.text.SimpleDateFormat; -import java.util.Date; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import java.util.*; import java.util.regex.Pattern; @Component @@ -318,23 +311,19 @@ public class CMSServer implements ApplicationRunner { public class PSS_Storage_Callback implements HCEHomeSS.EHomeSSStorageCallBack { public boolean invoke(NativeLong iHandle, String pFileName, Pointer pFileBuf, int dwFileLen, Pointer pFilePath, Pointer pUser) { -// log.error("图片进来:{}", pFileName); String strPath = "C://EhomePicServer/"; -// System.out.println("pFileName:" + pFileName); FileUtils.getInstance().writeLogs("文件名:" + pFileName, FileUtils.fileName); + + String isQJFileName = pFileName;//用来判断是否是枪机 + pFileName = pFileName.replace("_", ""); - boolean isZhuaPai = false; - if (pFileName.contains("-")) {//人脸抓拍机抓拍到的图片 - if (!ip.contains("172.16")) - strPath = "E://wwwhtdocs//SmartCampus//face17e5//School16//Student//";//测试服务器 - pFileName = pFileName.split("T")[0] + ".jpg"; - isZhuaPai = true; - } + + if (pFileName.contains("T"))pFileName=pFileName.split("T")[0]+".jpg"; + + FileUtils.getInstance().writeLogs("文件名pFileName:" + pFileName, FileUtils.fileName); String strFilePath = strPath + pFileName; //保存抓拍到的人脸图片,比对通过后的图片资源 - -// System.out.println("文件保存回调函数:" + strFilePath); //若此目录不存在,则创建之 File myPath = new File(strPath); if (!myPath.exists()) { @@ -363,9 +352,16 @@ public class CMSServer implements ApplicationRunner { buffers.get(bytes); fout.write(bytes); fout.close(); + if (isQJFileName.contains("T")) {//人脸抓拍机抓拍到的图片 + String deviceId = ""; + int start = isQJFileName.indexOf("01_") + 3; + int end = isQJFileName.lastIndexOf("_01"); + if (start < end) { + deviceId = isQJFileName.substring(start, end); + } + sendToKB(strFilePathFile, deviceId); + } -// if (ip_cloud.equals(ip_cloudQJ)) - sendToKB(strFilePathFile); } catch (FileNotFoundException e) { // TODO Auto-generated catch block @@ -378,9 +374,9 @@ public class CMSServer implements ApplicationRunner { pFilePath.write(0, strFilePath.getBytes(), 0, strFilePath.getBytes().length); - if (isZhuaPai) { +// if (isZhuaPai) { // MqtUtils.getInstance().sendMsg("http://campus.myjxt.com//face17e5/School16/Student/" + pFileName); - } +// } return true; } @@ -393,11 +389,13 @@ public class CMSServer implements ApplicationRunner { * * @param strFilePathFile */ - public void sendToKB(File strFilePathFile) { + public void sendToKB(File strFilePathFile, String deviceId) { try { + String schoolId = userDao.getSchoolIdWithDevId(deviceId); + log.error("开始识别....."); - String url = "http://120.26.116.253:9214/baiduapi/search/16"; + String url = "http://120.26.116.253:9214/baiduapi/search/" + schoolId; RestTemplate restTemplate = new RestTemplate(); @@ -415,7 +413,7 @@ public class CMSServer implements ApplicationRunner { JSONObject jsonObject = JSON.parseObject(responseEntity.getBody()); String face = jsonObject.getString("data"); - if (face.startsWith("face")||face.startsWith("pic")) return; + if (face.startsWith("face") || face.startsWith("pic")) return; JSONObject data = jsonObject.getJSONObject("data"); String error_msg = data.getString("error_msg"); @@ -441,11 +439,11 @@ public class CMSServer implements ApplicationRunner { String time = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()); BaiduFaceRecorder baiduFaceRecorder = new BaiduFaceRecorder(); baiduFaceRecorder.setName(teacherBean.getName()); - baiduFaceRecorder.setScore(sc+""); + baiduFaceRecorder.setScore(sc + ""); baiduFaceRecorder.setTime(time); baiduFaceRecorder.setUserImgUrl(teacherBean.getFace()); - baiduFaceRecorder.setUploadImgUrl(strFilePathFile.getAbsolutePath().contains(date)? - "http://" + ip_cloud + ":8081/kms/services/rest/dataInfoService/downloadFile?id="+strFilePathFile.getName().substring(0,strFilePathFile.getName().indexOf(date)):strFilePathFile.getAbsolutePath()); + baiduFaceRecorder.setUploadImgUrl(strFilePathFile.getAbsolutePath().contains(date) ? + "http://" + ip_cloud + ":8081/kms/services/rest/dataInfoService/downloadFile?id=" + strFilePathFile.getName().substring(0, strFilePathFile.getName().indexOf(date)) : strFilePathFile.getAbsolutePath()); baiduFaceRecorder.setUserId(user_id); userDao.insertBaiduFaceRecorder(baiduFaceRecorder); @@ -455,26 +453,26 @@ public class CMSServer implements ApplicationRunner { if (userMap.containsKey(user_id)) { long value = userMap.get(user_id); - if ((System.currentTimeMillis() - value) / 1000 > 6) { + if ((System.currentTimeMillis() - value) / 1000 > 60) { userMap.put(user_id, System.currentTimeMillis()); - MqtUtils.getInstance().sendMsg("09EA8EB5142F2964", 1, teacherBean.toString()); + send2DeviceIds(schoolId, teacherBean); log.error("发送成功....."); } } else { userMap.put(user_id, System.currentTimeMillis()); - MqtUtils.getInstance().sendMsg("09EA8EB5142F2964", 1, teacherBean.toString()); + send2DeviceIds(schoolId, teacherBean); log.error("发送成功....."); } // strFilePathFile.deleteOnExit(); } else { System.out.println("用户身份信息不存在"); - sendNoPersonImg(strFilePathFile); + sendNoPersonImg(strFilePathFile,schoolId); } } else { System.out.println("用户身份信息不存在" + score); - sendNoPersonImg(strFilePathFile); + sendNoPersonImg(strFilePathFile,schoolId); } } @@ -490,12 +488,29 @@ public class CMSServer implements ApplicationRunner { } - private void sendNoPersonImg(File strFilePathFile) { + private void send2DeviceIds(String schoolId, TeacherBean teacherBean) { + + List deviceIds = userDao.getKBDevices(schoolId); + if (deviceIds != null) + for (int i = 0; i < deviceIds.size(); i++) { + String deviceId = deviceIds.get(i); + if (!StringUtils.isEmpty(deviceId)) + MqtUtils.getInstance().sendMsg(deviceId, 1, teacherBean.toString()); + } + + } + + private void sendNoPersonImg(File strFilePathFile, String schoolId) { + List deviceIds = userDao.getKBDevices(schoolId); String imgName = strFilePathFile.getName(); String date = new SimpleDateFormat("yyyy-MM-dd").format(new Date()); if (imgName.contains(date)) { String imgId = imgName.substring(0, imgName.indexOf(date)); - MqtUtils.getInstance().sendMsg("09EA8EB5142F2964", 2, "http://" + ip_cloud + ":8081/kms/services/rest/dataInfoService/downloadFile?id=" + imgId); + for (int i = 0; i < deviceIds.size(); i++) { + String deviceId = deviceIds.get(i); + if (!StringUtils.isEmpty(deviceId)) + MqtUtils.getInstance().sendMsg(deviceId, 2, "http://" + ip_cloud + ":8081/kms/services/rest/dataInfoService/downloadFile?id=" + imgId); + } } } @@ -568,7 +583,7 @@ public class CMSServer implements ApplicationRunner { // System.out.println(strXML); // log.error("报警监听:{}", strXML); if (null == alarmUtils) { - alarmUtils = new AlarmUtils(deviceDao,userDao); + alarmUtils = new AlarmUtils(deviceDao, userDao); alarmUtils.setCallBack(new AlarmUtils.AlarmCallBack() { @Override public void callBack(String minorType, String deviceID, String cardNo, String time, String picDataUrlId, String currTemperature) { @@ -578,7 +593,6 @@ public class CMSServer implements ApplicationRunner { saveFaceRecoder(deviceID, cardNo, time, picDataUrlId, currTemperature); break; case "0x426"://人证设备在线 - break; case "0x427"://人证设备离线 map.remove(deviceID); @@ -639,10 +653,10 @@ public class CMSServer implements ApplicationRunner { if (!TextUtils.isEmpty(currTemperature)) {//只有有温度的才存记录 userDao.addWGTem(studentBean.getUser_id(), studentBean.getStudent_id(), studentBean.getName(), studentBean.getClass_id() + "", studentBean.getClass_name(), currTemperature, studentBean.getStudent_type() + "", studentBean.getSchool_id() + "", time); - - sendRecordDao.addFaceRecoder(face_recoder.getDeviceId(), face_recoder.getUser_id(), face_recoder.getName(), - face_recoder.getImgurl(), face_recoder.getInOrOut(), face_recoder.getTime(), face_recoder.getCardNum(), currTemperature); } + //记录签到成功的流水 + sendRecordDao.addFaceRecoder(face_recoder.getDeviceId(), face_recoder.getUser_id(), face_recoder.getName(), + face_recoder.getImgurl(), face_recoder.getInOrOut(), face_recoder.getTime(), face_recoder.getCardNum(), currTemperature); } else { //教师点名 isTeacher(cardNo, deviceID); @@ -673,7 +687,7 @@ public class CMSServer implements ApplicationRunner { public void isTeacher(String cardNo, String deviceID) { List devLists = userDao.getDeviceRoomRelation(deviceID); - log.error("cardNo:{},devLists{}", cardNo, devLists); +// log.error("cardNo:{},devLists{}", cardNo, devLists); if (null != devLists && devLists.size() > 0) { @@ -813,7 +827,7 @@ public class CMSServer implements ApplicationRunner { "\r\n" + "\r\n" + ""; - System.out.println("strConfigXMLCard:" + strConfigXMLCard + name + nameAfter); +// System.out.println("strConfigXMLCard:" + strConfigXMLCard + name + nameAfter); byte[] nameBeforBy = null; byte[] resultBy = null; try { @@ -861,10 +875,10 @@ public class CMSServer implements ApplicationRunner { int iErr = hCEhomeCMS.NET_ECMS_GetLastError(); if (validTimeEnabled == 0) System.err.println("删除卡号失败,错误号:" + iErr + "card:" + card); else System.err.println("下发卡号失败,错误号:" + iErr + "card:" + card); - if (iErr == 10) map.remove(deviceId); +// if (iErr == 10) map.remove(deviceId); } else { if (validTimeEnabled == 0) System.out.println("删除卡号成功"); - else System.out.println("下发卡号成功"); + else System.out.println("下发卡号成功:"+name); } } @@ -1015,7 +1029,7 @@ public class CMSServer implements ApplicationRunner { } else { stringXMLOut.read(); String strOutXML = new String(stringXMLOut.byString).trim(); - System.out.println(content + "成功:" + strOutXML); + System.out.println(content + "成功:" + card); } } return false; diff --git a/cloud/haikangface/src/main/java/com/sincere/haikangface/Test.java b/cloud/haikangface/src/main/java/com/sincere/haikangface/Test.java new file mode 100644 index 0000000..25f7645 --- /dev/null +++ b/cloud/haikangface/src/main/java/com/sincere/haikangface/Test.java @@ -0,0 +1,48 @@ +package com.sincere.haikangface; + +import java.io.File; +import java.io.IOException; + +public class Test { + + public static void main(String[] args){ + String strPath = "C://EhomePicServer/"; + String img = "5EA6FC3BC6C6285812F92A68CB43F4F52020-09-27T16:01:59A08:00_01_qj111111_01.jpg"; + String isQJFileName = img;//用来判断是否是枪机 + + img = img.split("T")[0]; +// img = img.substring(img.indexOf("01_")+3,img.lastIndexOf("_01")); + String strFilePath = strPath + img; + //保存抓拍到的人脸图片,比对通过后的图片资源 + //若此目录不存在,则创建之 + File myPath = new File(strPath); + if (!myPath.exists()) { + myPath.mkdir(); + System.out.println("创建文件夹路径为:" + strPath); + } + + File strFilePathFile = new File(strFilePath); + System.out.println("strFilePath:" + strFilePath); + if (!strFilePathFile.exists()) { + try { + strFilePathFile.createNewFile(); + } catch (IOException e) { + e.printStackTrace(); + } + } + + if (img.contains("T")) {//人脸抓拍机抓拍到的图片 + String deviceId = ""; + int start = img.indexOf("01_") + 3; + int end = img.lastIndexOf("_01"); + if (start < end) { + deviceId = img.substring(start, end); + } + System.out.println("deviceId:"+deviceId+"isQJFileName:"+isQJFileName.replace("_","")); + } + + + + } + +} diff --git a/cloud/haikangface/src/main/java/com/sincere/haikangface/control/FileControl.java b/cloud/haikangface/src/main/java/com/sincere/haikangface/control/FileControl.java index ca5bc12..c95ea8d 100644 --- a/cloud/haikangface/src/main/java/com/sincere/haikangface/control/FileControl.java +++ b/cloud/haikangface/src/main/java/com/sincere/haikangface/control/FileControl.java @@ -83,15 +83,15 @@ public class FileControl { long time = System.currentTimeMillis(); // if (filePath.contains(".jpg")) filePath = filePath.replace(".jpg", ".png"); if (new File(filePath.trim()).exists()) { - String targetPath = FileUtils.picPathComp + new File(filePath).getName().replace(".png", ".jpg"); + String targetPath = FileUtils.picPathComp + new File(filePath).getName(); try { CompressPic.CompressPic(filePath, targetPath); } catch (Exception e) { e.printStackTrace(); } - File targetFile = new File(targetPath); - System.out.println("targetPath:" + targetFile.exists() + targetFile.getAbsolutePath()); +// File targetFile = new File(targetPath); +// System.out.println("targetPath:" + targetFile.exists() + targetFile.getAbsolutePath()); try { int isPiliang = 0;//0:批量,1:单张 if (filePath.contains("face17e50")) {//批量发送 diff --git a/cloud/haikangface/src/main/java/com/sincere/haikangface/control/UserControl.java b/cloud/haikangface/src/main/java/com/sincere/haikangface/control/UserControl.java index 6964459..0d58207 100644 --- a/cloud/haikangface/src/main/java/com/sincere/haikangface/control/UserControl.java +++ b/cloud/haikangface/src/main/java/com/sincere/haikangface/control/UserControl.java @@ -3,13 +3,10 @@ package com.sincere.haikangface.control; //import com.sincere.common.dto.smartCampus.SZ_AttendanceDto; import com.alibaba.fastjson.JSON; -import com.sincere.haikangface.bean.Images2Ddevices; +import com.sincere.haikangface.bean.*; //import com.sincere.haikangface.utils.BaiduApiUtiols; import com.sincere.haikangface.CMSServer; import com.sincere.haikangface.async.SendUserAsync; -import com.sincere.haikangface.bean.StudentBean; -import com.sincere.haikangface.bean.StudentInfo; -import com.sincere.haikangface.bean.TeacherBean; import com.sincere.haikangface.bean.face.PermissionBean; import com.sincere.haikangface.bean.face.UserAndPermission; import com.sincere.haikangface.dao.UserDao; @@ -21,22 +18,17 @@ import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParams; import io.swagger.annotations.ApiOperation; import lombok.extern.slf4j.Slf4j; -import org.apache.poi.util.StringUtil; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.MediaType; import org.springframework.util.StringUtils; import org.springframework.web.bind.annotation.*; -import org.springframework.web.client.RestTemplate; import org.springframework.web.multipart.MultipartFile; import java.io.*; import java.text.SimpleDateFormat; -import java.util.ArrayList; -import java.util.Calendar; -import java.util.Date; -import java.util.List; +import java.util.*; @RestController @RequestMapping(value = "/facereco/*", produces = MediaType.APPLICATION_JSON_UTF8_VALUE) @@ -67,7 +59,7 @@ public class UserControl { @ApiOperation("下发权限给设备") public boolean sendPermiss(@RequestBody PermissionBean permissionBean) { log.error("permissionBean:{}", JSON.toJSONString(permissionBean)); - FileUtils.getInstance().writeLogs("传入权限模板:"+JSON.toJSONString(permissionBean),"设置权限内容.txt"); + FileUtils.getInstance().writeLogs("传入权限模板:" + JSON.toJSONString(permissionBean), "设置权限内容.txt"); if (!StringUtils.isEmpty(permissionBean.getDeviceIds())) { // List cardNumList = userDao.getStudentCardsWidthSchoolId(permissionBean.getSchoolId()); return sendUserAsync.sendPermiss(permissionBean, 0); @@ -100,9 +92,9 @@ public class UserControl { @RequestMapping(value = "sendToKB", method = RequestMethod.GET) @ApiOperation("发送数据到看板") - public void sendToKB(@RequestParam("filePath") String filePath) { + public void sendToKB(@RequestParam("filePath") String filePath, @RequestParam("deviceid") String deviceid) { try { - cmsServer.sendToKB(new File(filePath)); + cmsServer.sendToKB(new File(filePath), deviceid); } catch (Exception e) { e.printStackTrace(); } @@ -313,6 +305,139 @@ public class UserControl { } + + @RequestMapping(value = "sendErrorFaces", method = RequestMethod.GET) + @ApiOperation(value = "下发失败的人脸", notes = "下发失败的人脸") + @ApiImplicitParams({ + @ApiImplicitParam(name = "deviceid", required = false), + @ApiImplicitParam(name = "userType", required = false), + @ApiImplicitParam(name = "schoolId", required = true) + }) + public void sendErrorFaces(String schoolId, String deviceid, String userType) { + + System.out.println("schoolId:" + schoolId + "---deviceid:" + deviceid + "---userType:" + userType); + if (StringUtils.isEmpty(userType)) userType = "0";//不传的话就默认失败表中的类型 + if (!StringUtils.isEmpty(deviceid)) { + sendFace(deviceid, Integer.parseInt(userType)); + } else { + List deviceIds = sendRecordDao.getDeviceIds(schoolId); + + if (null != deviceIds) { + for (int j = 0; j < deviceIds.size(); j++) { + String deviceId = deviceIds.get(j); + sendFace(deviceId, Integer.parseInt(userType)); + } + } + } + + + } + + + private void sendFace(String deviceId, int userType) { + + List sendRecordBeans = sendRecordDao.getSendFailWithDevId(deviceId); + if (null != sendRecordBeans) { + + for (int i = 0; i < sendRecordBeans.size(); i++) { + + SendRecordBean sendRecordBean = sendRecordBeans.get(i); + String typeName = ""; + if (userType == 0) { + typeName = sendRecordBean.getUserType() == 1 ? "Teacher" : "Student"; + } else { + typeName = userType == 1 ? "Teacher" : "Student"; + } + String studentCode = ""; + + if (sendRecordBean.getUserType() == 1) { + studentCode = userDao.getTeaNumWithCard(sendRecordBean.getNum()); + } else if (sendRecordBean.getUserType() == 2) { + studentCode = userDao.getStudentCode(sendRecordBean.getNum()); + } + + String imgPath = "E:\\wwwhtdocs\\SmartCampus\\face17e50\\School" + sendRecordBean.getSchoolId() + "\\" + typeName + "\\" + studentCode + ".png"; + File imgFile = new File(imgPath); + if (imgFile.exists()) { + String targetPath = FileUtils.picPathComp + imgFile.getName(); + try { + CompressPic.CompressPic(imgFile.getAbsolutePath(), targetPath); + } catch (Exception e) { + e.printStackTrace(); + } + sendImg(imgPath, targetPath, sendRecordBean.getDeviceID(), sendRecordBean.getNum(), sendRecordBean.getName(), sendRecordBean.getUserType() + ""); + } else { + System.out.println("文件不存在"); + } + } + + } + + } + + + @RequestMapping(value = "sendFaceNotExits", method = RequestMethod.GET) + @ApiOperation(value = "下发学校下还没有下发的人脸给指定设备", notes = "下发学校下还没有下发的人脸给指定设备") + public void sendFaceNotExits(@RequestParam("deviceIds") String deviceIds, @RequestParam("schoolId") String schoolId, @RequestParam("userType") String userType) { + + String typeName = userType.equals("1") ? "Teacher" : "Student"; + + String imgPath = "E:\\wwwhtdocs\\SmartCampus\\face17e50\\School" + schoolId + "\\" + typeName; + + File imgPathFile = new File(imgPath);//目录 + + String[] deviceIdsStr = deviceIds.split(","); + + + if (imgPathFile.exists()) { + File[] imgfiles = imgPathFile.listFiles(); + if (null != imgfiles) { + + for (int i = 0; i < imgfiles.length; i++) { + File file = imgfiles[i];//图片 + String targetPath = FileUtils.picPathComp + file.getName(); + try { + CompressPic.CompressPic(file.getAbsolutePath(), targetPath); + } catch (Exception e) { + e.printStackTrace(); + } + if (file.exists()) + for (int j = 0; j < deviceIdsStr.length; j++) { + String deviceId = deviceIdsStr[j]; + + StudentBean studentBean = null; + String card = "", name = ""; + if (userType.equals("1")) { + studentBean = userDao.getTeacherWithstudentcode(file.getName().split("\\.")[0], schoolId); + if (null != studentBean) { + card = studentBean.getTeacher_num(); + name = studentBean.getName(); + } + } else if (userType.equals("2")) { + studentBean = userDao.getStudentWithstudentcode(file.getName().split("\\.")[0], schoolId); + if (null != studentBean) { + card = studentBean.getStudent_num(); + name = studentBean.getName(); + } + } + + if (!StringUtils.isEmpty(card)) { + List sendRecordBeans = sendRecordDao.getFaceSendSucess(card, deviceId); + if (sendRecordBeans == null || sendRecordBeans.size() == 0) + sendImg(file.getAbsolutePath(), targetPath, deviceId, card, name, userType); + else System.out.println("人脸已经下发"); + } + + } + + } + + } + } + + } + + @RequestMapping(value = "sendFaceToDevices", method = RequestMethod.GET) @ApiOperation(value = "下发单个用户给指定设备", notes = "下发单个用户给指定设备") @ApiImplicitParams({@ApiImplicitParam(name = "deviceIds", value = "设备id用逗号,拼接"), diff --git a/cloud/haikangface/src/main/java/com/sincere/haikangface/dao/UserDao.java b/cloud/haikangface/src/main/java/com/sincere/haikangface/dao/UserDao.java index ab2628b..37463ca 100644 --- a/cloud/haikangface/src/main/java/com/sincere/haikangface/dao/UserDao.java +++ b/cloud/haikangface/src/main/java/com/sincere/haikangface/dao/UserDao.java @@ -216,7 +216,7 @@ public interface UserDao { "where num = #{num} and school_id = #{schoolId}") StudentBean getTeacherWithstudentcode(@Param("num") String num, @Param("schoolId") String schoolId); - @Select("select school_id from SZ_Attendance where clint_id = #{devId}") + @Select("select top(1) school_id from SZ_Attendance where clint_id = #{devId}") String getSchoolIdWithDevId(@Param("devId") String devId); @Insert("insert into CW_StuTemperatureReocrd values (#{UserId},#{StudentId},#{Name},#{ClassId},#{ClassName},#{Temperature},#{Type},#{SchoolId},#{Intime})") @@ -236,6 +236,9 @@ public interface UserDao { @Select("select student_num from SZ_V_School_Student where user_id = #{userId}") String getStudentCardWithUserId(@Param("userId") String userId); + @Select("select Top(1) studentcode from SZ_V_School_Student where student_num = #{num}") + String getStudentCode(@Param("num") String num); + @Select("select Top(1) * from SZ_V_School_Teacher where user_id = #{userId} and teacher_num<>''") TeacherBean getTeacherWithUserId(@Param("userId") String userId); @@ -250,4 +253,9 @@ public interface UserDao { void insertBaiduFaceRecorder(BaiduFaceRecorder baiduFaceRecorder); + @Select("select top(1) num from SZ_V_School_Teacher where teacher_num=#{num}") + String getTeaNumWithCard(@Param("num") String num); + + @Select("select clint_id from SZ_Attendance where clint_type in(8,9,10) and school_id = #{schoolId}") + List getKBDevices(@Param("schoolId") String schoolId); } diff --git a/cloud/haikangface/src/main/java/com/sincere/haikangface/utils/AlarmUtils.java b/cloud/haikangface/src/main/java/com/sincere/haikangface/utils/AlarmUtils.java index 3df3b0d..2fc1847 100644 --- a/cloud/haikangface/src/main/java/com/sincere/haikangface/utils/AlarmUtils.java +++ b/cloud/haikangface/src/main/java/com/sincere/haikangface/utils/AlarmUtils.java @@ -46,19 +46,19 @@ public class AlarmUtils { } public void deleAlarm(String strXML) { - System.out.println("人脸抓拍机:" + strXML); +// System.out.println("人脸抓拍机:" + strXML); if (strXML.contains("FACESNAPREPORT")) {//人脸抓拍机器 // System.out.println("人脸抓拍机:" + strXML); BaiduFaceRecorder baiduFaceRecorder = new BaiduFaceRecorder(); baiduFaceRecorder.setUploadImgUrl(strXML); baiduFaceRecorder.setTime(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date())); - userDao.insertBaiduFaceRecorder(baiduFaceRecorder); String deviceId = strXML.substring(strXML.indexOf("DeviceID"),strXML.lastIndexOf("DeviceID")).trim(); deviceId = deviceId.replace("DeviceID>",""); deviceId = deviceId.replace(" getFaceSendSucess(); + @Select("select * from Face_SendSuccess where Num = #{Num} and deviceID = #{deviceID}") + List getFaceSendSucess(@Param("Num")String Num,@Param("deviceID")String deviceID); + @Select("select * from Face_SendFail where deviceID = #{deviceID}") + List getSendFailWithDevId(@Param("deviceID") String deviceId); + + @Select("select DISTINCT deviceID from Face_SendFail where schoolId = #{schoolId} ") + List getDeviceIds(@Param("schoolId") String schoolId); } diff --git a/cloud/mypulsar/src/main/java/com/example/mypulsar/MyRunnerableInt.java b/cloud/mypulsar/src/main/java/com/example/mypulsar/MyRunnerableInt.java index de4e90d..608a9e4 100644 --- a/cloud/mypulsar/src/main/java/com/example/mypulsar/MyRunnerableInt.java +++ b/cloud/mypulsar/src/main/java/com/example/mypulsar/MyRunnerableInt.java @@ -40,7 +40,7 @@ public class MyRunnerableInt implements ApplicationRunner { @Override public void run(ApplicationArguments args) throws Exception { -// initMqConsumer(); + initMqConsumer(); } /** diff --git a/cloud/mypulsar/src/test/java/com/example/mypulsar/MypulsarApplicationTests.java b/cloud/mypulsar/src/test/java/com/example/mypulsar/MypulsarApplicationTests.java index e86a863..98d077c 100644 --- a/cloud/mypulsar/src/test/java/com/example/mypulsar/MypulsarApplicationTests.java +++ b/cloud/mypulsar/src/test/java/com/example/mypulsar/MypulsarApplicationTests.java @@ -85,7 +85,7 @@ public class MypulsarApplicationTests { } - private String closeModel = "{\"mode\":\"0\",\"power\":\"0\",\"remote_id\":\"%s\",\"remote_index\":\"11272\",\"temp\":\"26\",\"wind\":\"0\"}"; + private String closeModel = "{\"mode\":\"0\",\"power\":\"1\",\"remote_id\":\"%s\",\"remote_index\":\"11272\",\"temp\":\"26\",\"wind\":\"0\"}"; private void closeAllDevice() { @@ -96,11 +96,9 @@ public class MypulsarApplicationTests { String deviceId = deviceIds.get(i).getClint_id(); String conValue = getRemoteId(deviceDao.getConBeValue(deviceId)); String devName = deviceIds.get(i).getName(); -// System.out.println("closeModel:" + closeModel); String con = String.format(closeModel, conValue); -// System.out.println("con:" + con); - - HttpUtil.addAirCode(con, deviceId, devName); +// if (deviceId.equals("22000203ecfabcace679")) + HttpUtil.addAirCode(con, deviceId, devName); } diff --git a/cloud/pom.xml b/cloud/pom.xml index 496db1e..5543063 100644 --- a/cloud/pom.xml +++ b/cloud/pom.xml @@ -41,7 +41,7 @@ quartz - + zkAttendance user_search fIle-center RibbonConsume diff --git a/cloud/quartz/src/main/java/com/sincere/quartz/job/SyncJob.java b/cloud/quartz/src/main/java/com/sincere/quartz/job/SyncJob.java index 48520d5..78c11d3 100644 --- a/cloud/quartz/src/main/java/com/sincere/quartz/job/SyncJob.java +++ b/cloud/quartz/src/main/java/com/sincere/quartz/job/SyncJob.java @@ -1,29 +1,29 @@ -//package com.sincere.quartz.job; -// -//import com.sincere.quartz.third.yixueyun.YXYReadService; -//import com.sincere.quartz.third.yixueyun.YXYWriteService; -//import org.springframework.beans.factory.annotation.Autowired; -//import org.springframework.scheduling.annotation.Scheduled; -//import org.springframework.stereotype.Service; -// -///** -// * @author chen -// * @version 1.0 -// * @date 2019/12/24 0024 10:54 -// */ -//@Service -//public class SyncJob { -// -// @Autowired -// YXYWriteService yxyWriteService ; -// -// @Autowired -// YXYReadService yxyReadService ; -// -// @Scheduled(cron = "30 1 22 * * ? ") -// public void Sync(){ -// //翼校通的同步 之后还有钉钉的同步等等 -// yxyReadService.sync(); -// yxyWriteService.sync(); -// } -//} +package com.sincere.quartz.job; + +import com.sincere.quartz.third.yixueyun.YXYReadService; +import com.sincere.quartz.third.yixueyun.YXYWriteService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.scheduling.annotation.Scheduled; +import org.springframework.stereotype.Service; + +/** + * @author chen + * @version 1.0 + * @date 2019/12/24 0024 10:54 + */ +@Service +public class SyncJob { + + @Autowired + YXYWriteService yxyWriteService ; + + @Autowired + YXYReadService yxyReadService ; + + @Scheduled(cron = "30 1 22 * * ? ") + public void Sync(){ + //翼校通的同步 之后还有钉钉的同步等等 + yxyReadService.sync(); + yxyWriteService.sync(); + } +} diff --git a/cloud/zkAttendance/pom.xml b/cloud/zkAttendance/pom.xml index 29e9e74..a1d0ac4 100644 --- a/cloud/zkAttendance/pom.xml +++ b/cloud/zkAttendance/pom.xml @@ -37,6 +37,14 @@ commons-lang3 3.3.2 + + org.springframework.boot + spring-boot-starter-web + + + + + @@ -75,7 +83,7 @@ - com.sincere.quartz.QuartzApplication + com.sincere.att.AttApplication true lib/ diff --git a/cloud/zkAttendance/src/main/java/com/sincere/att/AttApplication.java b/cloud/zkAttendance/src/main/java/com/sincere/att/AttApplication.java index 9084059..f9d17df 100644 --- a/cloud/zkAttendance/src/main/java/com/sincere/att/AttApplication.java +++ b/cloud/zkAttendance/src/main/java/com/sincere/att/AttApplication.java @@ -4,6 +4,7 @@ import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.cloud.netflix.eureka.EnableEurekaClient; import org.springframework.cloud.openfeign.EnableFeignClients; +import org.springframework.context.annotation.Configuration; /** * @author chen @@ -13,6 +14,7 @@ import org.springframework.cloud.openfeign.EnableFeignClients; @EnableFeignClients(basePackages = "com.sincere.att.feign") @EnableEurekaClient @SpringBootApplication +@Configuration public class AttApplication { // public static void main(String[] args) { diff --git a/cloud/zkAttendance/src/main/java/com/sincere/att/Swagger2.java b/cloud/zkAttendance/src/main/java/com/sincere/att/Swagger2.java index 1767fc3..2ee683c 100644 --- a/cloud/zkAttendance/src/main/java/com/sincere/att/Swagger2.java +++ b/cloud/zkAttendance/src/main/java/com/sincere/att/Swagger2.java @@ -1,6 +1,5 @@ package com.sincere.att; -import io.swagger.annotations.ApiOperation; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import springfox.documentation.builders.ApiInfoBuilder; diff --git a/cloud/zkAttendance/src/main/java/com/sincere/att/controller/AttPushController.java b/cloud/zkAttendance/src/main/java/com/sincere/att/controller/AttPushController.java index 6e330c0..9e5cbb6 100644 --- a/cloud/zkAttendance/src/main/java/com/sincere/att/controller/AttPushController.java +++ b/cloud/zkAttendance/src/main/java/com/sincere/att/controller/AttPushController.java @@ -40,80 +40,86 @@ public class AttPushController { private static final Logger Log_kaoInfo = LoggerUtils.Logger(LogName.kaoInfo); private static Map> cmdMap = new HashMap<>(); - private static Map cmdOrderMap = new HashMap<>(); + private static Map cmdOrderMap = new HashMap<>(); - private static String pwd = "22222222-6faf-48uh-a5a9-447ec68bfe2f" ; - private static String account = "yueqingzhijiao" ; + private static String pwd = "22222222-6faf-48uh-a5a9-447ec68bfe2f"; + private static String account = "yueqingzhijiao"; @Autowired ScFeign scFeign; @Autowired - XaFeign xaFeign ; + XaFeign xaFeign; - @RequestMapping(value = "sendUser" , method = RequestMethod.GET) - public void sendUser(int roomId){ + @RequestMapping(value = "sendUser", method = RequestMethod.GET) + public void sendUser(int roomId) { JSONObject object = new JSONObject(); - object.put("pageIndex",1); - object.put("roomId",roomId); - object.put("pageSize",9999); - JSONObject result = HttpClientUtils.httpPostJson("http://campus.myjxt.com/api/Room/GetListPageRoom",object.toJSONString()); - JSONArray array = (JSONArray) ((JSONObject) result.get("data")).get("roomList") ; - List order = new ArrayList<>(); + object.put("pageIndex", 1); + object.put("roomId", roomId); + object.put("pageSize", 9999); + JSONObject result = HttpClientUtils.httpPostJson("http://campus.myjxt.com/api/Room/GetListPageRoom", object.toJSONString()); + JSONArray array = (JSONArray) ((JSONObject) result.get("data")).get("roomList"); List attendanceList = scFeign.selectRoomAttendance(roomId); - for(String attendance : attendanceList){ - for(int i = 0 ; i < array.size() ; i++){ + System.out.println("设备数量:" + JSONObject.toJSONString(attendanceList)); + for (String attendance : attendanceList) { + List order = new ArrayList<>(); + for (int i = 0; i < array.size(); i++) { JSONObject student = (JSONObject) array.get(i); UserOrderVo vo = new UserOrderVo(); vo.setStudentId((Integer) student.get("studentid")); vo.setStudentName((String) student.get("name")); - int number = 1 ; - try{ - number = cmdOrderMap.get(attendance) ; - }catch (Exception e){ + int number = 1; + try { + number = cmdOrderMap.get(attendance); + } catch (Exception e) { } vo.setNumber(number); - number++ ; - cmdOrderMap.put(attendance,number) ; - if(vo.getStudentId() != 0){ - order.add(vo.toString()); + number++; + cmdOrderMap.put(attendance, number); + if (vo.getStudentId() != 0) { +// if (vo.getStudentId() == 72196){ + //todo:测试专用 + if (!order.contains(vo.toString())){ + order.add(vo.toString()); + } +// } } } - cmdMap.put(attendance,order); + cmdMap.put(attendance, order); } } - @RequestMapping(value = "sendFinger" , method = RequestMethod.GET) - public void sendFinger(int roomId){ + @RequestMapping(value = "sendFinger", method = RequestMethod.GET) + public void sendFinger(int roomId) { JSONObject object = new JSONObject(); - object.put("PageIndex",1); - object.put("roomId",roomId); - object.put("pageSize",9999); - JSONObject result = HttpClientUtils.httpPostJson("http://campus.myjxt.com/api/Room/GetListPageRoom",object.toJSONString()); - JSONArray array = (JSONArray) ((JSONObject) result.get("data")).get("roomList") ; - List order = new ArrayList<>(); + object.put("PageIndex", 1); + object.put("roomId", roomId); + object.put("pageSize", 9999); + JSONObject result = HttpClientUtils.httpPostJson("http://campus.myjxt.com/api/Room/GetListPageRoom", object.toJSONString()); + JSONArray array = (JSONArray) ((JSONObject) result.get("data")).get("roomList"); List attendanceList = scFeign.selectRoomAttendance(roomId); - for(String attendance : attendanceList){ - for(int i = 0 ; i < array.size() ; i++){ + for (String attendance : attendanceList) { + List order = new ArrayList<>(); + for (int i = 0; i < array.size(); i++) { JSONObject student = (JSONObject) array.get(i); FingerOrderVo vo = new FingerOrderVo(); - int number = 1 ; - try{ - number = cmdOrderMap.get(attendance) ; - }catch (Exception e){ + int number = 1; + try { + number = cmdOrderMap.get(attendance); + } catch (Exception e) { } vo.setNumber(number); - vo.setOrder(xaFeign.selectFinger((Integer)student.get("studentid"))); - number++ ; - cmdOrderMap.put(attendance,number) ; - if(StringUtils.isNotBlank(vo.getOrder())){ + vo.setOrder(xaFeign.selectFinger((Integer) student.get("studentid"))); + number++; + cmdOrderMap.put(attendance, number); + if (StringUtils.isNotBlank(vo.getOrder())) { order.add(vo.toString()); } } - cmdMap.put(attendance,order); + cmdMap.put(attendance, order); } } @@ -121,29 +127,29 @@ public class AttPushController { * 1,设备通完电以后第一个发送到后台的请求 * 格式为 /iclock/cdata?options=all&language=xxxx&pushver=xxxx */ - @RequestMapping(value="/cdata",params = {"options","language","pushver"},method = RequestMethod.GET) - public void init(String SN, String options, String language, String pushver, HttpServletRequest request , - @RequestParam(required = false) String PushOptionsFlag, HttpServletResponse response){ + @RequestMapping(value = "/cdata", params = {"options", "language", "pushver"}, method = RequestMethod.GET) + public void init(String SN, String options, String language, String pushver, HttpServletRequest request, + @RequestParam(required = false) String PushOptionsFlag, HttpServletResponse response) { try { - if(cmdMap.get(SN) == null){ + if (cmdMap.get(SN) == null) { System.out.println("设备上线:" + SN); - cmdMap.put(SN,new ArrayList<>()); - cmdOrderMap.put(SN,1); + cmdMap.put(SN, new ArrayList<>()); + cmdOrderMap.put(SN, 1); } - if(scFeign.selectAttendaceWithId(SN) == null){ + if (scFeign.selectAttendaceWithId(SN) == null) { SZ_AttendanceDto attendanceDto = new SZ_AttendanceDto(); attendanceDto.setClint_id(SN); attendanceDto.setClint_type("24"); attendanceDto.setIp(request.getRemoteAddr()); attendanceDto.setPort(request.getRemotePort()); - attendanceDto.setIntime(DateUtils.date2String(new Date(),DateUtils.format2)); + attendanceDto.setIntime(DateUtils.date2String(new Date(), DateUtils.format2)); attendanceDto.setSchool_id("-1"); attendanceDto.setState(1); scFeign.insertAttendance(attendanceDto); - }else { + } else { scFeign.updateAttendance(SN); } - String initOptions = initOptions(SN,PushOptionsFlag); + String initOptions = initOptions(SN, PushOptionsFlag); response.getWriter().write(initOptions);//返回成功以后设备会发送心跳请求 } catch (IOException e) { e.printStackTrace(); @@ -154,19 +160,19 @@ public class AttPushController { * 2,心跳请求,会从服务器拿到命令返回 给设备 */ @RequestMapping("/getrequest") - public void heartBeat(String SN, HttpServletResponse response){ + public void heartBeat(String SN, HttpServletResponse response) { scFeign.updateAttendance(SN); StringBuffer sb = new StringBuffer("OK"); - List cmds = cmdMap.get(SN); - if(cmds==null){//等于空说明从来没加载过,如果初始化加载过了,此时应该不为Null 只是size为0 + List cmds = cmdMap.get(SN); + if (cmds == null) {//等于空说明从来没加载过,如果初始化加载过了,此时应该不为Null 只是size为0 System.out.println("设备上线:" + SN); cmds = new ArrayList<>(); - cmdMap.put(SN,cmds); - cmdOrderMap.put(SN,1); + cmdMap.put(SN, cmds); + cmdOrderMap.put(SN, 1); } - if(cmds!=null&&cmds.size()>0){ - sb.setLength(0);//如果有命令就不返回OK了 - cmds.stream().forEach(cmd->sb.append(cmd).append("\r\n\r\n")); + if (cmds != null && cmds.size() > 0) { + sb.setLength(0);//如果有命令就不返回OK了 + cmds.stream().forEach(cmd -> sb.append(cmd).append("\r\n\r\n")); } try { @@ -183,8 +189,8 @@ public class AttPushController { * 这个请求,服务器只能返回OK,不可以返回命令 */ @RequestMapping("/ping") - public void ping(HttpServletResponse response){ - System.out.println("考勤机心跳请求大量进来了......ping"+new SimpleDateFormat("HH:mm:ss").format(new Date())); + public void ping(HttpServletResponse response) { + System.out.println("考勤机心跳请求大量进来了......ping" + new SimpleDateFormat("HH:mm:ss").format(new Date())); try { response.getWriter().write("OK"); } catch (IOException e) { @@ -196,20 +202,35 @@ public class AttPushController { * 4,设备端处理完命令以后会发送该请求,告诉服务器命令的处理结果 */ @RequestMapping("/devicecmd") - public void handleCmd(String SN, @RequestBody String data, HttpServletResponse response){ + public void handleCmd(String SN, @RequestBody String data, HttpServletResponse response) { //判断data 清空map List cmdList = cmdMap.get(SN); + System.out.println("----请求设备:" + SN+"ssssss:"+(cmdList==null?"false":"true")); String[] returnList = data.split("\n"); - if(returnList.length > 0 && cmdList.size() > 0){ - for(String message : returnList){ - String number = message.substring(message.indexOf("=")+1,message.indexOf("&")); - String result = message.substring(message.indexOf("=",message.indexOf("&"))+1,message.indexOf("&",message.indexOf("&")+1)); - if(result.equals("0")){ + if (returnList.length > 0 && cmdList.size() > 0) { + for (String message : returnList) { + String number = message.substring(message.indexOf("=") + 1, message.indexOf("&")); + String result = message.substring(message.indexOf("=", message.indexOf("&")) + 1, message.indexOf("&", message.indexOf("&") + 1)); + if (result.equals("0")) { + /*for (int i = 0; i < cmdList.size(); i++) { + + String b = cmdList.get(i); +// if (null==b)System.out.println("内容为空:"+i); +// else System.out.println("内容为:"+b+"----number:"+number); + if (b.contains("C:"+number)) { + Log_orderSuccess.info("指令成功=========="+b); + } + + } + cmdList.clear();*/ Iterator it = cmdList.iterator(); while (((Iterator) it).hasNext()) { String b = it.next(); - if (b.contains("C:"+number)) { - Log_orderSuccess.info("指令成功=========="+b); +// if (b.contains("72196")) +// System.out.println("下发指令==========" + b + "----设备id:" + SN); + if (b.contains("C:" + number)) { + Log_orderSuccess.info("指令成功==========" + b); + System.out.println( "----设备id:" + SN+"======指令成功==========" + b); it.remove(); } } @@ -232,22 +253,22 @@ public class AttPushController { request.setCharacterEncoding("gbk"); String data = ""; ByteArrayOutputStream bos = null; - byte[] b= new byte[1024]; + byte[] b = new byte[1024]; try { InputStream is = request.getInputStream(); bos = new ByteArrayOutputStream(); int len = 0; - while((len=is.read(b))!=-1){ - bos.write(b,0,len); + while ((len = is.read(b)) != -1) { + bos.write(b, 0, len); } - data = new String(bos.toByteArray(),"gbk"); + data = new String(bos.toByteArray(), "gbk"); } catch (IOException e) { e.printStackTrace(); } - if("ATTLOG".equals(table)){ + if ("ATTLOG".equals(table)) { String[] list = data.split("\t"); String cardNo = scFeign.selectStudentNumByStudentId(Integer.valueOf(list[0])); - if(StringUtils.isNotBlank(cardNo)){ + if (StringUtils.isNotBlank(cardNo)) { String cardNo10 = new BigInteger(cardNo, 16).toString(); //考勤日志 SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); @@ -262,20 +283,20 @@ public class AttPushController { String jsonResult = JSON.toJSONString(attendanceInfoBean); String urlHXY = "http://campus.myjxt.com/api/XiaoAnCommon/SendHXY"; JSONObject jsonObject = HttpClientUtils.httpPostJson(urlHXY, jsonResult); - if ((int) jsonObject.get("status") == 1){ + if ((int) jsonObject.get("status") == 1) { Log_kaoInfo.info("出入寝签到成功:" + SN + " 卡号:" + cardNo); - }else { + } else { Log_orderFail.info("出入寝签到失败:" + SN + " 卡号:" + cardNo + " result1:" + jsonObject.toJSONString()); } - }else { + } else { System.out.println(cardNo); } } - if("OPERLOG".equals(table)){ + if ("OPERLOG".equals(table)) { //操作日志 - if(data.substring(0,3).contains("FP")){ + if (data.substring(0, 3).contains("FP")) { //添加指纹 - String studentId = data.substring(data.indexOf("=")+1,data.indexOf("\t",data.indexOf("="))); + String studentId = data.substring(data.indexOf("=") + 1, data.indexOf("\t", data.indexOf("="))); String order = data.substring(3); FingerDto fingerDto = new FingerDto(); fingerDto.setOrderMsg(order); @@ -291,40 +312,54 @@ public class AttPushController { } } - public static void main(String[] args){ - String cardNo = "FF013E0F" ; - String SN = "A4JS174260624" ; - String cardNo10 = new BigInteger(cardNo, 16).toString(); - //考勤日志 - SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); - String info = String.format("", - simpleDateFormat.format(new Date()), SN, cardNo10, DateUtils.date2String(new Date(),DateUtils.format2), "-1"); - AttendanceInfoBean attendanceInfoBean = new AttendanceInfoBean(); - attendanceInfoBean.setInfo(info); - attendanceInfoBean.setIsControl(0); - attendanceInfoBean.setPwd(pwd); - attendanceInfoBean.setUsername(account); + public static void main(String[] args) { + /*JSONObject object = new JSONObject(); + object.put("pageIndex",1); + object.put("roomId","13299"); + object.put("pageSize",9999); + JSONObject result = HttpClientUtils.httpPostJson("http://campus.myjxt.com/api/Room/GetListPageRoom",object.toJSONString()); + JSONObject data = result.getJSONObject("data"); + JSONArray roomList = data.getJSONArray("roomList"); + for (int i = 0; i < roomList.size(); i++) { + String name = roomList.getJSONObject(i).getString("name"); + String studentId = roomList.getJSONObject(i).getString("studentid"); + System.out.println(name+","+studentId); + }*/ - String jsonResult = JSON.toJSONString(attendanceInfoBean); - String urlHXY = "http://campus.myjxt.com/api/XiaoAnCommon/SendHXY"; - JSONObject jsonObject = HttpClientUtils.httpPostJson(urlHXY, jsonResult); - if ((int) jsonObject.get("status") == 1){ - Log_kaoInfo.info("出入寝签到成功:" + SN + " 卡号:" + cardNo); - }else { - Log_orderFail.info("出入寝签到失败:" + SN + " 卡号:" + cardNo + " result1:" + jsonObject.toJSONString()); - } - } + String cardNo = "FF013E0F"; + String SN = "A4JS174260624"; + String cardNo10 = new BigInteger(cardNo, 16).toString(); + //考勤日志 + SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + String info = String.format("", + simpleDateFormat.format(new Date()), SN, cardNo10, DateUtils.date2String(new Date(), DateUtils.format2), "-1"); + AttendanceInfoBean attendanceInfoBean = new AttendanceInfoBean(); + attendanceInfoBean.setInfo(info); + attendanceInfoBean.setIsControl(0); + attendanceInfoBean.setPwd(pwd); + attendanceInfoBean.setUsername(account); + + String jsonResult = JSON.toJSONString(attendanceInfoBean); + String urlHXY = "http://campus.myjxt.com/api/XiaoAnCommon/SendHXY"; + JSONObject jsonObject = HttpClientUtils.httpPostJson(urlHXY, jsonResult); + if ((int) jsonObject.get("status") == 1) { + Log_kaoInfo.info("出入寝签到成功:" + SN + " 卡号:" + cardNo); + } else { + Log_orderFail.info("出入寝签到失败:" + SN + " 卡号:" + cardNo + " result1:" + jsonObject.toJSONString()); + } + } /** * 设备通电以后连接到服务器,需要返回的初始化参数 + * * @param sn * @param PushOptionsFlag * @return */ - private String initOptions(String sn,String PushOptionsFlag) { + private String initOptions(String sn, String PushOptionsFlag) { StringBuffer devOptions = new StringBuffer(); - devOptions.append("GET OPTION FROM: "+sn); + devOptions.append("GET OPTION FROM: " + sn); // + "\nStamp=" + devInfo.devInfoJson.getString("Stamp") devOptions.append("\nATTLOGStamp=0"); devOptions.append("\nOPERLOGStamp=0"); @@ -348,9 +383,8 @@ public class AttPushController { // 11 工作号码 // 12 比对照片 devOptions.append("\nTransFlag=111111111111");// 1-12二进制位 分别代表以上含义 - System.out.println("PushOptionsFlag============="+PushOptionsFlag); - if (PushOptionsFlag!=null&&PushOptionsFlag.equals("1")) - { + System.out.println("PushOptionsFlag=============" + PushOptionsFlag); + if (PushOptionsFlag != null && PushOptionsFlag.equals("1")) { // 支持参数单独获取的才要把需要获取的参数回传给设备 modifeid by max 20170926 devOptions.append("\nPushOptions=RegDeviceType,FingerFunOn,FaceFunOn,FPVersion,FaceVersion,NetworkType,HardwareId3,HardwareId5,HardwareId56,LicenseStatus3,LicenseStatus5,LicenseStatus56"); } diff --git a/cloud/zkAttendance/src/main/resources/application.yaml b/cloud/zkAttendance/src/main/resources/application.yaml index 72638f5..a229f3b 100644 --- a/cloud/zkAttendance/src/main/resources/application.yaml +++ b/cloud/zkAttendance/src/main/resources/application.yaml @@ -12,5 +12,6 @@ eureka: lease-renewal-interval-in-seconds: 10 client: service-url: - defaultZone: http://localhost:8761/eureka/,http://localhost:8762/eureka/ +# defaultZone: http://localhost:8761/eureka/,http://localhost:8762/eureka/ + defaultZone: http://121.40.109.21:8761/eureka/,http://121.40.109.21:8762/eureka/ -- libgit2 0.21.0