Commit e130c410da92dec8209ce56dfd8c53452e07db3b
1 parent
9ab51a8c
Exists in
master
大华一体机功能优化
Showing
11 changed files
with
507 additions
and
79 deletions
Show diff stats
cloud/dahua/pom.xml
@@ -192,13 +192,13 @@ | @@ -192,13 +192,13 @@ | ||
192 | <configuration> | 192 | <configuration> |
193 | <includeSystemScope>true</includeSystemScope> | 193 | <includeSystemScope>true</includeSystemScope> |
194 | <layout>ZIP</layout> | 194 | <layout>ZIP</layout> |
195 | - <includes> | ||
196 | - <include> | ||
197 | - <!-- 排除所有Jar --> | ||
198 | - <groupId>nothing</groupId> | ||
199 | - <artifactId>nothing</artifactId> | ||
200 | - </include> | ||
201 | - </includes> | 195 | +<!-- <includes>--> |
196 | +<!-- <include>--> | ||
197 | +<!-- <!– 排除所有Jar –>--> | ||
198 | +<!-- <groupId>nothing</groupId>--> | ||
199 | +<!-- <artifactId>nothing</artifactId>--> | ||
200 | +<!-- </include>--> | ||
201 | +<!-- </includes>--> | ||
202 | </configuration> | 202 | </configuration> |
203 | </plugin> | 203 | </plugin> |
204 | 204 |
cloud/dahua/src/main/java/com/example/dahua/MyTask.java
@@ -110,9 +110,9 @@ public class MyTask implements ApplicationRunner { | @@ -110,9 +110,9 @@ public class MyTask implements ApplicationRunner { | ||
110 | // 通过 CLIENT_SetAutoReconnect 设置该回调函数,当已断线的设备重连成功时,SDK会调用该函数 | 110 | // 通过 CLIENT_SetAutoReconnect 设置该回调函数,当已断线的设备重连成功时,SDK会调用该函数 |
111 | private class HaveReConnect implements NetSDKLib.fHaveReConnect { | 111 | private class HaveReConnect implements NetSDKLib.fHaveReConnect { |
112 | public void invoke(NetSDKLib.LLong m_hLoginHandle, String pchDVRIP, int nDVRPort, Pointer dwUser) { | 112 | public void invoke(NetSDKLib.LLong m_hLoginHandle, String pchDVRIP, int nDVRPort, Pointer dwUser) { |
113 | - System.out.printf("ReConnect Device[%s] Port[%d]\n", pchDVRIP, nDVRPort); | ||
114 | // 重连提示 | 113 | // 重连提示 |
115 | String deviceId = getDeviceId(pchDVRIP, nDVRPort); | 114 | String deviceId = getDeviceId(pchDVRIP, nDVRPort); |
115 | + System.out.printf("ReConnect Device[%s] IP[%S] Port[%d]\n", deviceId,pchDVRIP, nDVRPort); | ||
116 | if (!StringUtils.isEmpty(deviceId)) { | 116 | if (!StringUtils.isEmpty(deviceId)) { |
117 | attendanceService.updateConnectStateWithDevid(1, deviceId); | 117 | attendanceService.updateConnectStateWithDevid(1, deviceId); |
118 | // devMap.put(deviceId,""); | 118 | // devMap.put(deviceId,""); |
@@ -228,7 +228,7 @@ public class MyTask implements ApplicationRunner { | @@ -228,7 +228,7 @@ public class MyTask implements ApplicationRunner { | ||
228 | break; | 228 | break; |
229 | } | 229 | } |
230 | 230 | ||
231 | - return 0; | 231 | + return 1; |
232 | } | 232 | } |
233 | } | 233 | } |
234 | 234 | ||
@@ -240,9 +240,9 @@ public class MyTask implements ApplicationRunner { | @@ -240,9 +240,9 @@ public class MyTask implements ApplicationRunner { | ||
240 | if (lLongMap.get(dev.getDevcieId()).intValue() > 0) { | 240 | if (lLongMap.get(dev.getDevcieId()).intValue() > 0) { |
241 | NetSDKLib.LLong lLong = GateModule.realLoadPic(0, analyzerCallback, lLongMap.get(dev.getDevcieId())); | 241 | NetSDKLib.LLong lLong = GateModule.realLoadPic(0, analyzerCallback, lLongMap.get(dev.getDevcieId())); |
242 | // System.out.println("监听成功:"+dev.getDevcieId()); | 242 | // System.out.println("监听成功:"+dev.getDevcieId()); |
243 | - if (lLong.intValue() != -1) { | ||
244 | - deviceInfoBeans.remove(dev); | ||
245 | - } | 243 | +// if (lLong.intValue() != -1) { |
244 | +// //deviceInfoBeans.remove(dev); | ||
245 | +// } | ||
246 | } | 246 | } |
247 | 247 | ||
248 | } | 248 | } |
@@ -290,14 +290,15 @@ public class MyTask implements ApplicationRunner { | @@ -290,14 +290,15 @@ public class MyTask implements ApplicationRunner { | ||
290 | ImageIO.write(gateBufferedImage, "png", new File(snapPicPath)); | 290 | ImageIO.write(gateBufferedImage, "png", new File(snapPicPath)); |
291 | } | 291 | } |
292 | card = cardNo(card); | 292 | card = cardNo(card); |
293 | + | ||
293 | CardBean cardBean = userDao.getCards(card);//根据卡号获取身份信息 | 294 | CardBean cardBean = userDao.getCards(card);//根据卡号获取身份信息 |
294 | String time = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()); | 295 | String time = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()); |
295 | snapPicPath = snapPicPath.replaceFirst("\\.", "http://121.40.109.21:8991"); | 296 | snapPicPath = snapPicPath.replaceFirst("\\.", "http://121.40.109.21:8991"); |
296 | snapPicPath = snapPicPath.replace("FaceRecoder", "image"); | 297 | snapPicPath = snapPicPath.replace("FaceRecoder", "image"); |
297 | - if (cardBean.getType() == 0) {//老师 | 298 | + if (null != cardBean && cardBean.getType() == 0) {//老师 |
298 | TeacherBean teacherBean = userDao.getTeacherWithId(cardBean.getUser_id()); | 299 | TeacherBean teacherBean = userDao.getTeacherWithId(cardBean.getUser_id()); |
299 | sendRecordDao.addFaceRecoder("", teacherBean.getUser_id(), teacherBean.getName(), snapPicPath, 1, time, card,""); | 300 | sendRecordDao.addFaceRecoder("", teacherBean.getUser_id(), teacherBean.getName(), snapPicPath, 1, time, card,""); |
300 | - } else if (cardBean.getType() == 2) {//学生 | 301 | + } else if (null != cardBean && cardBean.getType() == 2) {//学生 |
301 | UserInfoBean userInfoBean = userDao.getStudentWithid(cardBean.getUser_id()); | 302 | UserInfoBean userInfoBean = userDao.getStudentWithid(cardBean.getUser_id()); |
302 | sendRecordDao.addFaceRecoder("", userInfoBean.getUser_id(), userInfoBean.getName(), snapPicPath, 1, time, card,""); | 303 | sendRecordDao.addFaceRecoder("", userInfoBean.getUser_id(), userInfoBean.getName(), snapPicPath, 1, time, card,""); |
303 | } | 304 | } |
cloud/dahua/src/main/java/com/example/dahua/async/SendUserInfoTask.java
1 | package com.example.dahua.async; | 1 | package com.example.dahua.async; |
2 | 2 | ||
3 | -import com.example.dahua.Gate.Gate; | 3 | +//import com.example.dahua.Gate.Gate; |
4 | import com.example.dahua.MyTask; | 4 | import com.example.dahua.MyTask; |
5 | import com.example.dahua.bean.*; | 5 | import com.example.dahua.bean.*; |
6 | import com.example.dahua.common.Res; | 6 | import com.example.dahua.common.Res; |
@@ -154,7 +154,7 @@ public class SendUserInfoTask { | @@ -154,7 +154,7 @@ public class SendUserInfoTask { | ||
154 | 154 | ||
155 | if (type == 0 || type == 1) {//学生信息或家长信息 | 155 | if (type == 0 || type == 1) {//学生信息或家长信息 |
156 | userInfoBean = userDao.getUserInfo(schoolId, studentCode); | 156 | userInfoBean = userDao.getUserInfo(schoolId, studentCode); |
157 | - HttpUtils.uploadImgs(studentFile, schoolId, studentCode, clint_type, 2); | 157 | + HttpUtils.uploadImgs(studentFile, schoolId, studentCode, clint_type, 2,""); |
158 | } else if (type == 2) {//教师信息 | 158 | } else if (type == 2) {//教师信息 |
159 | TeacherBean teacher = userDao.getTeacher(schoolId, studentCode); | 159 | TeacherBean teacher = userDao.getTeacher(schoolId, studentCode); |
160 | System.out.println("教师信息:" + teacher.toString()); | 160 | System.out.println("教师信息:" + teacher.toString()); |
@@ -166,7 +166,7 @@ public class SendUserInfoTask { | @@ -166,7 +166,7 @@ public class SendUserInfoTask { | ||
166 | userInfoBean.setStudentcode(teacher.getNum()); | 166 | userInfoBean.setStudentcode(teacher.getNum()); |
167 | userInfoBean.setStudent_id(teacher.getTeacher_id()); | 167 | userInfoBean.setStudent_id(teacher.getTeacher_id()); |
168 | } | 168 | } |
169 | - HttpUtils.uploadImgs(studentFile, schoolId, studentCode, clint_type, 1); | 169 | + HttpUtils.uploadImgs(studentFile, schoolId, studentCode, clint_type, 1,""); |
170 | } | 170 | } |
171 | 171 | ||
172 | //判断用户是否存在 | 172 | //判断用户是否存在 |
@@ -282,6 +282,7 @@ public class SendUserInfoTask { | @@ -282,6 +282,7 @@ public class SendUserInfoTask { | ||
282 | } | 282 | } |
283 | 283 | ||
284 | private synchronized void pushCardAndFace(AttendanceBean attendanceBean, String user_id, String student_num, String name, Memory memory, SendRecordBean sendRecordBean,String userType) { | 284 | private synchronized void pushCardAndFace(AttendanceBean attendanceBean, String user_id, String student_num, String name, Memory memory, SendRecordBean sendRecordBean,String userType) { |
285 | + try{ | ||
285 | sendRecordBean.setDeviceID(attendanceBean.getClint_id()); | 286 | sendRecordBean.setDeviceID(attendanceBean.getClint_id()); |
286 | sendRecordBean.setSchoolId(Integer.parseInt(attendanceBean.getSchool_id())); | 287 | sendRecordBean.setSchoolId(Integer.parseInt(attendanceBean.getSchool_id())); |
287 | sendRecordBean.setTime(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date())); | 288 | sendRecordBean.setTime(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date())); |
@@ -297,6 +298,7 @@ public class SendUserInfoTask { | @@ -297,6 +298,7 @@ public class SendUserInfoTask { | ||
297 | // System.out.println("loginHandleLong:" + loginHandleLong + MyTask.lLongMap.toString() + " 设备ID:" + attendanceBean.getClint_id()); | 298 | // System.out.println("loginHandleLong:" + loginHandleLong + MyTask.lLongMap.toString() + " 设备ID:" + attendanceBean.getClint_id()); |
298 | // System.out.println("loginHandleLong:" +loginHandleLong); | 299 | // System.out.println("loginHandleLong:" +loginHandleLong); |
299 | if (loginHandleLong == null) { | 300 | if (loginHandleLong == null) { |
301 | + System.out.println("设备不在线:" + attendanceBean.getClint_id()); | ||
300 | FileUtils.getInstance().writeLogs("设备不在线:" + attendanceBean.getClint_id(), FileUtils.devices); | 302 | FileUtils.getInstance().writeLogs("设备不在线:" + attendanceBean.getClint_id(), FileUtils.devices); |
301 | String deviceId = sendRecordDao.getFailIsExit(attendanceBean.getClint_id(), attendanceBean.getSchool_id()); | 303 | String deviceId = sendRecordDao.getFailIsExit(attendanceBean.getClint_id(), attendanceBean.getSchool_id()); |
302 | sendRecordBean.setFailType(2); | 304 | sendRecordBean.setFailType(2); |
@@ -310,11 +312,30 @@ public class SendUserInfoTask { | @@ -310,11 +312,30 @@ public class SendUserInfoTask { | ||
310 | boolean bFaceFalgs = false; | 312 | boolean bFaceFalgs = false; |
311 | 313 | ||
312 | String cardNum = cardNo(student_num); | 314 | String cardNum = cardNo(student_num); |
315 | +// GateModule.getFace(user_id, loginHandleLong); | ||
316 | +// GateModule.getUser(user_id, loginHandleLong); | ||
317 | +// GateModule.getCard(cardNum, loginHandleLong); | ||
313 | if (bCardFlags != -1) {//修改卡信息 | 318 | if (bCardFlags != -1) {//修改卡信息 |
314 | - GateModule.modifyCard(bCardFlags, cardNum, user_id, name, "123456", Res.string().getCardStatusInt(1), Res.string().getCardTypeInt(1), | ||
315 | - 0, 0, 1, startTime, endTime, loginHandleLong,userType); | ||
316 | - userDao.updateRecordNo(user_id, bCardFlags, attendanceBean.getClint_id()); | ||
317 | - bFaceFalgs = GateModule.modifyFaceInfo(user_id, memory, loginHandleLong); | 319 | + int newRecordNo=0; |
320 | + int bFaceFalgsInt=0; | ||
321 | + bFaceFalgsInt = GateModule.modifyFaceInfo(user_id, memory, loginHandleLong); | ||
322 | + if(bFaceFalgsInt==1) {//1照片修改成功 | ||
323 | + bFaceFalgs=true; | ||
324 | + GateModule.modifyCard(bCardFlags, cardNum, user_id, name, "123456", Res.string().getCardStatusInt(1), Res.string().getCardTypeInt(1), | ||
325 | + 0, 0, 1, startTime, endTime, loginHandleLong, userType); | ||
326 | + userDao.updateRecordNo(user_id, bCardFlags, attendanceBean.getClint_id()); | ||
327 | + } | ||
328 | + else if(bFaceFalgsInt==1029)//1029用户id不存在 | ||
329 | + { | ||
330 | + bCardFlags = GateModule.insertCard(cardNum, user_id, name, "123456" | ||
331 | + , Res.string().getCardStatusInt(1), Res.string().getCardTypeInt(1), 0, 1 | ||
332 | + , 1, startTime, endTime, loginHandleLong,userType); | ||
333 | + | ||
334 | + if (bCardFlags != -1) { | ||
335 | + userDao.updateRecordNo(user_id, bCardFlags, attendanceBean.getClint_id()); | ||
336 | + } | ||
337 | + } | ||
338 | + else{bFaceFalgs=false;} | ||
318 | //卡号添加成功,但是人脸不成功的话,就需要新增人脸 | 339 | //卡号添加成功,但是人脸不成功的话,就需要新增人脸 |
319 | if (!bFaceFalgs) | 340 | if (!bFaceFalgs) |
320 | bFaceFalgs = GateModule.addFaceInfo(user_id, memory, loginHandleLong); | 341 | bFaceFalgs = GateModule.addFaceInfo(user_id, memory, loginHandleLong); |
@@ -389,7 +410,9 @@ public class SendUserInfoTask { | @@ -389,7 +410,9 @@ public class SendUserInfoTask { | ||
389 | System.out.println("卡信息已存在,添加人脸成功-----------\n"); | 410 | System.out.println("卡信息已存在,添加人脸成功-----------\n"); |
390 | } | 411 | } |
391 | } | 412 | } |
392 | - | 413 | + } catch (Exception e) { |
414 | + e.printStackTrace(); | ||
415 | + } | ||
393 | } | 416 | } |
394 | 417 | ||
395 | //人脸发送失败信息添加 | 418 | //人脸发送失败信息添加 |
cloud/dahua/src/main/java/com/example/dahua/common/FunctionList.java
1 | package com.example.dahua.common; | 1 | package com.example.dahua.common; |
2 | 2 | ||
3 | import com.example.dahua.AutoRegister.AutoRegister; | 3 | import com.example.dahua.AutoRegister.AutoRegister; |
4 | -import com.example.dahua.DeviceControl; | ||
5 | -import com.example.dahua.DeviceSearchAndInit; | ||
6 | -import com.example.dahua.FaceRecognition.FaceRecognition; | ||
7 | -import com.example.dahua.Gate.Gate; | 4 | +//import com.example.dahua.DeviceControl; |
5 | +//import com.example.dahua.DeviceSearchAndInit; | ||
6 | +//import com.example.dahua.FaceRecognition.FaceRecognition; | ||
7 | +//import com.example.dahua.Gate.Gate; | ||
8 | 8 | ||
9 | import java.awt.BorderLayout; | 9 | import java.awt.BorderLayout; |
10 | import java.awt.GridLayout; | 10 | import java.awt.GridLayout; |
@@ -88,7 +88,7 @@ public class FunctionList extends JFrame { | @@ -88,7 +88,7 @@ public class FunctionList extends JFrame { | ||
88 | SwingUtilities.invokeLater(new Runnable() { | 88 | SwingUtilities.invokeLater(new Runnable() { |
89 | public void run() { | 89 | public void run() { |
90 | dispose(); | 90 | dispose(); |
91 | - FaceRecognition.main(null); | 91 | +// FaceRecognition.main(null); |
92 | } | 92 | } |
93 | }); | 93 | }); |
94 | } | 94 | } |
@@ -161,7 +161,7 @@ public class FunctionList extends JFrame { | @@ -161,7 +161,7 @@ public class FunctionList extends JFrame { | ||
161 | SwingUtilities.invokeLater(new Runnable() { | 161 | SwingUtilities.invokeLater(new Runnable() { |
162 | public void run() { | 162 | public void run() { |
163 | dispose(); | 163 | dispose(); |
164 | - DeviceSearchAndInit.main(null); | 164 | +// DeviceSearchAndInit.main(null); |
165 | } | 165 | } |
166 | }); | 166 | }); |
167 | } | 167 | } |
@@ -186,7 +186,7 @@ public class FunctionList extends JFrame { | @@ -186,7 +186,7 @@ public class FunctionList extends JFrame { | ||
186 | SwingUtilities.invokeLater(new Runnable() { | 186 | SwingUtilities.invokeLater(new Runnable() { |
187 | public void run() { | 187 | public void run() { |
188 | dispose(); | 188 | dispose(); |
189 | - DeviceControl.main(null); | 189 | +// DeviceControl.main(null); |
190 | } | 190 | } |
191 | }); | 191 | }); |
192 | } | 192 | } |
@@ -235,7 +235,7 @@ public class FunctionList extends JFrame { | @@ -235,7 +235,7 @@ public class FunctionList extends JFrame { | ||
235 | SwingUtilities.invokeLater(new Runnable() { | 235 | SwingUtilities.invokeLater(new Runnable() { |
236 | public void run() { | 236 | public void run() { |
237 | dispose(); | 237 | dispose(); |
238 | - Gate.main(null); | 238 | +// Gate.main(null); |
239 | } | 239 | } |
240 | }); | 240 | }); |
241 | } | 241 | } |
cloud/dahua/src/main/java/com/example/dahua/control/FileControl.java
@@ -2,7 +2,7 @@ package com.example.dahua.control; | @@ -2,7 +2,7 @@ package com.example.dahua.control; | ||
2 | 2 | ||
3 | import com.example.dahua.MyTask; | 3 | import com.example.dahua.MyTask; |
4 | import com.example.dahua.async.SendUserInfoTask; | 4 | import com.example.dahua.async.SendUserInfoTask; |
5 | -import com.example.dahua.attendance.Attendance; | 5 | +//import com.example.dahua.attendance.Attendance; |
6 | import com.example.dahua.bean.AttendanceBean; | 6 | import com.example.dahua.bean.AttendanceBean; |
7 | import com.example.dahua.bean.PermissionBean; | 7 | import com.example.dahua.bean.PermissionBean; |
8 | import com.example.dahua.bean.TeacherBean; | 8 | import com.example.dahua.bean.TeacherBean; |
@@ -17,6 +17,7 @@ import io.swagger.annotations.Api; | @@ -17,6 +17,7 @@ import io.swagger.annotations.Api; | ||
17 | import io.swagger.annotations.ApiOperation; | 17 | import io.swagger.annotations.ApiOperation; |
18 | import org.springframework.beans.factory.annotation.Autowired; | 18 | import org.springframework.beans.factory.annotation.Autowired; |
19 | import org.springframework.http.MediaType; | 19 | import org.springframework.http.MediaType; |
20 | +import org.springframework.util.StringUtils; | ||
20 | import org.springframework.web.bind.annotation.*; | 21 | import org.springframework.web.bind.annotation.*; |
21 | import org.springframework.web.multipart.MultipartFile; | 22 | import org.springframework.web.multipart.MultipartFile; |
22 | 23 | ||
@@ -42,8 +43,9 @@ public class FileControl { | @@ -42,8 +43,9 @@ public class FileControl { | ||
42 | UserDao userDao; | 43 | UserDao userDao; |
43 | 44 | ||
44 | @RequestMapping(method = RequestMethod.POST, value = "uploadImg") | 45 | @RequestMapping(method = RequestMethod.POST, value = "uploadImg") |
45 | - public String uploadImg(@RequestParam("file") MultipartFile file, @RequestParam("schoolId") String schoolId, @RequestParam("studentCode") String studentCode, | ||
46 | - @RequestParam("clint_type") String clint_type, @RequestParam("userType") int userType) { | 46 | + public String uploadImg(@RequestParam("file") MultipartFile file, @RequestParam("schoolId") String schoolId, |
47 | + @RequestParam("studentCode") String studentCode, @RequestParam("clint_type") String clint_type, | ||
48 | + @RequestParam("userType") int userType,@RequestParam(required = false) String deviceId) { | ||
47 | System.out.println("schoolId:" + schoolId + " studentCode:" + studentCode); | 49 | System.out.println("schoolId:" + schoolId + " studentCode:" + studentCode); |
48 | String fileName = file.getOriginalFilename();//文件名 | 50 | String fileName = file.getOriginalFilename();//文件名 |
49 | 51 | ||
@@ -55,7 +57,7 @@ public class FileControl { | @@ -55,7 +57,7 @@ public class FileControl { | ||
55 | 57 | ||
56 | fileOutputStream.write(file.getBytes()); | 58 | fileOutputStream.write(file.getBytes()); |
57 | fileOutputStream.close(); | 59 | fileOutputStream.close(); |
58 | - userService.uploadImgAndUserInfo(dest.getAbsolutePath(), schoolId, studentCode, clint_type, userType, ""); | 60 | + userService.uploadImgAndUserInfo(dest.getAbsolutePath(), schoolId, studentCode, clint_type, userType, StringUtils.isEmpty(deviceId)?"":deviceId); |
59 | return "1"; | 61 | return "1"; |
60 | } catch (FileNotFoundException e) { | 62 | } catch (FileNotFoundException e) { |
61 | e.printStackTrace(); | 63 | e.printStackTrace(); |
cloud/dahua/src/main/java/com/example/dahua/control/UserControl.java
@@ -53,7 +53,7 @@ public class UserControl { | @@ -53,7 +53,7 @@ public class UserControl { | ||
53 | @ApiOperation(value = "上传用户信息") | 53 | @ApiOperation(value = "上传用户信息") |
54 | public boolean uploadImgAndUserInfo(@RequestParam("file") String file, @RequestParam("schoolId") String schoolId, @RequestParam("studentCode") String studentCode, @RequestParam("clint_type") String clint_type) { | 54 | public boolean uploadImgAndUserInfo(@RequestParam("file") String file, @RequestParam("schoolId") String schoolId, @RequestParam("studentCode") String studentCode, @RequestParam("clint_type") String clint_type) { |
55 | // return userService.uploadImgAndUserInfo(file, schoolId, studentCode, clint_type); | 55 | // return userService.uploadImgAndUserInfo(file, schoolId, studentCode, clint_type); |
56 | - return HttpUtils.uploadImgs(new File(file), schoolId, studentCode, clint_type, file.contains("Teacher") ? 1 : 2); | 56 | + return HttpUtils.uploadImgs(new File(file), schoolId, studentCode, clint_type, file.contains("Teacher") ? 1 : 2,""); |
57 | } | 57 | } |
58 | 58 | ||
59 | @RequestMapping(value = "sendPermission", method = RequestMethod.POST) | 59 | @RequestMapping(value = "sendPermission", method = RequestMethod.POST) |
@@ -118,7 +118,7 @@ public class UserControl { | @@ -118,7 +118,7 @@ public class UserControl { | ||
118 | 118 | ||
119 | if (!StringUtils.isEmpty(card)) { | 119 | if (!StringUtils.isEmpty(card)) { |
120 | String clint_type = userDao.getClintType(deviceId); | 120 | String clint_type = userDao.getClintType(deviceId); |
121 | - HttpUtils.uploadImgs(new File(targetPath), schoolId, studentCode, clint_type, Integer.parseInt(userType)); | 121 | + HttpUtils.uploadImgs(new File(targetPath), schoolId, studentCode, clint_type, Integer.parseInt(userType),""); |
122 | } | 122 | } |
123 | 123 | ||
124 | } | 124 | } |
@@ -169,10 +169,10 @@ public class UserControl { | @@ -169,10 +169,10 @@ public class UserControl { | ||
169 | if (sendRecordBean.getUserType() == 1) { | 169 | if (sendRecordBean.getUserType() == 1) { |
170 | studentCode = userDao.getTeaNumWithCard(sendRecordBean.getNum()); | 170 | studentCode = userDao.getTeaNumWithCard(sendRecordBean.getNum()); |
171 | } else if (sendRecordBean.getUserType() == 2) { | 171 | } else if (sendRecordBean.getUserType() == 2) { |
172 | - studentCode = userDao.getStudentCode(sendRecordBean.getNum()); | 172 | + studentCode = userDao.getStudentCode(sendRecordBean.getCustomerid()); |
173 | } | 173 | } |
174 | 174 | ||
175 | - String imgPath = "E:\\wwwhtdocs\\SmartCampus\\face17e50\School" + sendRecordBean.getSchoolId() + "\" + typeName + "\" + studentCode + ".png"; | 175 | + String imgPath = "E:\\wwwhtdocs\\SmartCampus\\face17e5\School" + sendRecordBean.getSchoolId() + "\" + typeName + "\" + studentCode + ".png"; |
176 | File imgFile = new File(imgPath); | 176 | File imgFile = new File(imgPath); |
177 | if (imgFile.exists()) { | 177 | if (imgFile.exists()) { |
178 | String targetPath = "./picPath/comp/" + imgFile.getName(); | 178 | String targetPath = "./picPath/comp/" + imgFile.getName(); |
@@ -183,7 +183,7 @@ public class UserControl { | @@ -183,7 +183,7 @@ public class UserControl { | ||
183 | } | 183 | } |
184 | 184 | ||
185 | String clint_type = userDao.getClintType(sendRecordBean.getDeviceID()); | 185 | String clint_type = userDao.getClintType(sendRecordBean.getDeviceID()); |
186 | - HttpUtils.uploadImgs(new File(targetPath), schoolId, studentCode, clint_type, sendRecordBean.getUserType()); | 186 | + HttpUtils.uploadImgs(new File(targetPath), schoolId, studentCode, clint_type, sendRecordBean.getUserType(),deviceId); |
187 | } else { | 187 | } else { |
188 | System.out.println("文件不存在"); | 188 | System.out.println("文件不存在"); |
189 | } | 189 | } |
@@ -461,7 +461,7 @@ public class UserControl { | @@ -461,7 +461,7 @@ public class UserControl { | ||
461 | public void add2Stuinfo(@RequestParam("schoolid") String schoolId) { | 461 | public void add2Stuinfo(@RequestParam("schoolid") String schoolId) { |
462 | 462 | ||
463 | try { | 463 | try { |
464 | - String path = "E:\\wwwhtdocs\\SmartCampus\\face17e50\School" + schoolId + "\Student"; | 464 | + String path = "E:\\wwwhtdocs\\SmartCampus\\face17e5\School" + schoolId + "\Student"; |
465 | File filePath = new File(path); | 465 | File filePath = new File(path); |
466 | 466 | ||
467 | File[] files = filePath.listFiles(); | 467 | File[] files = filePath.listFiles(); |
cloud/dahua/src/main/java/com/example/dahua/dao/UserDao.java
@@ -41,7 +41,7 @@ public interface UserDao { | @@ -41,7 +41,7 @@ public interface UserDao { | ||
41 | * @param user_id | 41 | * @param user_id |
42 | * @return | 42 | * @return |
43 | */ | 43 | */ |
44 | - @Select("select 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 | @Insert("insert into SZ_Student_RecoderNo values(#{user_id},#{recordNo},#{student_name},#{deviceId})") | 47 | @Insert("insert into SZ_Student_RecoderNo values(#{user_id},#{recordNo},#{student_name},#{deviceId})") |
@@ -140,7 +140,7 @@ public interface UserDao { | @@ -140,7 +140,7 @@ public interface UserDao { | ||
140 | @Select("select top(1) num from SZ_V_School_Teacher where teacher_num=#{num}") | 140 | @Select("select top(1) num from SZ_V_School_Teacher where teacher_num=#{num}") |
141 | String getTeaNumWithCard(@Param("num") String num); | 141 | String getTeaNumWithCard(@Param("num") String num); |
142 | 142 | ||
143 | - @Select("select clint_type from SZ_Attendance where clint_id = #{clint_id}}") | 143 | + @Select("select clint_type from SZ_Attendance where clint_id = #{clint_id}") |
144 | String getClintType(@Param("clint_id") String deviceID); | 144 | String getClintType(@Param("clint_id") String deviceID); |
145 | 145 | ||
146 | @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 ") | 146 | @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 ") |
cloud/dahua/src/main/java/com/example/dahua/lib/CompressPic.java
@@ -24,10 +24,10 @@ public class CompressPic { | @@ -24,10 +24,10 @@ public class CompressPic { | ||
24 | int width = bufferedImage.getWidth(null); | 24 | int width = bufferedImage.getWidth(null); |
25 | int height = bufferedImage.getHeight(null); | 25 | int height = bufferedImage.getHeight(null); |
26 | long fileLength = file.length(); | 26 | long fileLength = file.length(); |
27 | - if ((fileLength / 1024) < 200) { | 27 | + if ((fileLength / 1024) < 100) { |
28 | writeImgToFile(bufferedImage, width, height, targetPath); | 28 | writeImgToFile(bufferedImage, width, height, targetPath); |
29 | } else | 29 | } else |
30 | - while ((fileLength / 1024) >= 200) { | 30 | + while ((fileLength / 1024) >= 100) { |
31 | width = (int) (width * (1 - cutPercent)); | 31 | width = (int) (width * (1 - cutPercent)); |
32 | height = (int) (height * (1 - cutPercent)); | 32 | height = (int) (height * (1 - cutPercent)); |
33 | 33 |
cloud/dahua/src/main/java/com/example/dahua/module/GateModule.java
1 | package com.example.dahua.module; | 1 | package com.example.dahua.module; |
2 | 2 | ||
3 | +import java.awt.image.BufferedImage; | ||
4 | +import java.io.ByteArrayInputStream; | ||
5 | +import java.io.File; | ||
6 | +import java.io.IOException; | ||
3 | import java.io.UnsupportedEncodingException; | 7 | import java.io.UnsupportedEncodingException; |
4 | import java.util.ArrayList; | 8 | import java.util.ArrayList; |
5 | import java.util.HashMap; | 9 | import java.util.HashMap; |
@@ -15,6 +19,8 @@ import com.example.dahua.lib.ToolKits; | @@ -15,6 +19,8 @@ import com.example.dahua.lib.ToolKits; | ||
15 | import com.sun.jna.Memory; | 19 | import com.sun.jna.Memory; |
16 | import com.sun.jna.ptr.IntByReference; | 20 | import com.sun.jna.ptr.IntByReference; |
17 | 21 | ||
22 | +import javax.imageio.ImageIO; | ||
23 | + | ||
18 | 24 | ||
19 | public class GateModule { | 25 | public class GateModule { |
20 | // 查询句柄 | 26 | // 查询句柄 |
@@ -248,7 +254,17 @@ public class GateModule { | @@ -248,7 +254,17 @@ public class GateModule { | ||
248 | accessCardInfo.read(); | 254 | accessCardInfo.read(); |
249 | 255 | ||
250 | if(!bRet) { | 256 | if(!bRet) { |
251 | - System.err.println("添加卡信息失败." + ToolKits.getErrorCodePrint()); | 257 | + //System.err.println("添加卡信息失败." + ToolKits.getErrorCodePrint()); |
258 | + String ret=ToolKits.getErrorCodePrint(); | ||
259 | + System.err.println("添加卡信息失败." + ret); | ||
260 | + String number = ret.substring(ret.indexOf("|") + 1, ret.indexOf(")")); | ||
261 | + if(number.equals("21")||number.equals("146"))//146用户已存在,21对返回数据的校验出错,1162未知错误 number.equals("1162")|| | ||
262 | + { | ||
263 | + deleteUser( userId, lLong); | ||
264 | + return insertCard( cardNo, userId, cardName, cardPwd, | ||
265 | + cardStatus, cardType, useTimes, isFirstEnter, | ||
266 | + isValid, startValidTime, endValidTime, lLong, userType); | ||
267 | + } | ||
252 | return -1; | 268 | return -1; |
253 | } else { | 269 | } else { |
254 | System.out.println("添加卡信息成功,卡信息记录集编号 : " + insert.stuCtrlRecordSetResult.nRecNo); | 270 | System.out.println("添加卡信息成功,卡信息记录集编号 : " + insert.stuCtrlRecordSetResult.nRecNo); |
@@ -387,6 +403,7 @@ public class GateModule { | @@ -387,6 +403,7 @@ public class GateModule { | ||
387 | WeekTime weekTime = weekTimes.get(i); | 403 | WeekTime weekTime = weekTimes.get(i); |
388 | String startTime = weekTime.getStartTime(); | 404 | String startTime = weekTime.getStartTime(); |
389 | String endTime = weekTime.getEndTime(); | 405 | String endTime = weekTime.getEndTime(); |
406 | + msg.stuTimeWeekDay[weekDayIndex].stuTimeSection[i].dwRecordMask=1; | ||
390 | msg.stuTimeWeekDay[weekDayIndex].stuTimeSection[i].nBeginHour = Integer.parseInt(startTime.split(":")[0]); | 407 | msg.stuTimeWeekDay[weekDayIndex].stuTimeSection[i].nBeginHour = Integer.parseInt(startTime.split(":")[0]); |
391 | msg.stuTimeWeekDay[weekDayIndex].stuTimeSection[i].nBeginMin = Integer.parseInt(startTime.split(":")[1]); | 408 | msg.stuTimeWeekDay[weekDayIndex].stuTimeSection[i].nBeginMin = Integer.parseInt(startTime.split(":")[1]); |
392 | msg.stuTimeWeekDay[weekDayIndex].stuTimeSection[i].nBeginSec = 0; | 409 | msg.stuTimeWeekDay[weekDayIndex].stuTimeSection[i].nBeginSec = 0; |
@@ -702,7 +719,16 @@ public class GateModule { | @@ -702,7 +719,16 @@ public class GateModule { | ||
702 | accessCardInfo.read(); | 719 | accessCardInfo.read(); |
703 | 720 | ||
704 | if (!bRet) { | 721 | if (!bRet) { |
705 | - System.err.println("修改卡信息失败." + ToolKits.getErrorCodePrint()); | 722 | + //System.err.println("修改卡信息失败." + ToolKits.getErrorCodePrint()); |
723 | + String ret=ToolKits.getErrorCodePrint(); | ||
724 | + System.err.println("修改卡信息失败." + ret); | ||
725 | + String number = ret.substring(ret.indexOf("|") + 1, ret.indexOf(")")); | ||
726 | + if(number.equals("21")||number.equals("147"))//147用户不存在,21对返回数据的校验出错 | ||
727 | + { | ||
728 | +// newRecordNo= insertCard( cardNo, userId, cardName, cardPwd, | ||
729 | +// cardStatus, cardType, useTimes, isFirstEnter, | ||
730 | +// isValid, startValidTime, endValidTime, lLong, userType); | ||
731 | + } | ||
706 | return false; | 732 | return false; |
707 | } else { | 733 | } else { |
708 | System.out.println("修改卡信息成功 "); | 734 | System.out.println("修改卡信息成功 "); |
@@ -784,6 +810,239 @@ public class GateModule { | @@ -784,6 +810,239 @@ public class GateModule { | ||
784 | return bRet; | 810 | return bRet; |
785 | } | 811 | } |
786 | 812 | ||
813 | + /** | ||
814 | + * 根据用户ID获取用户信息 | ||
815 | + */ | ||
816 | + public static void getUser(String userID,LLong lLong) { | ||
817 | + String[] userIDs = { userID }; | ||
818 | + | ||
819 | + // 获取的用户个数 | ||
820 | + int nMaxNum = userIDs.length; | ||
821 | + | ||
822 | + // /////////////////////////// 以下固定写法 | ||
823 | + // ///////////////////////////////////// | ||
824 | + // 用户操作类型 | ||
825 | + // 获取用户 | ||
826 | + int emtype = NET_EM_ACCESS_CTL_USER_SERVICE.NET_EM_ACCESS_CTL_USER_SERVICE_GET; | ||
827 | + | ||
828 | + /** | ||
829 | + * 用户信息数组 | ||
830 | + */ | ||
831 | + // 先初始化用户信息数组 | ||
832 | + NET_ACCESS_USER_INFO[] users = new NET_ACCESS_USER_INFO[nMaxNum]; | ||
833 | + // 初始化返回的失败信息数组 | ||
834 | + FAIL_CODE[] failCodes = new FAIL_CODE[nMaxNum]; | ||
835 | + | ||
836 | + for (int i = 0; i < nMaxNum; i++) { | ||
837 | + users[i] = new NET_ACCESS_USER_INFO(); | ||
838 | + failCodes[i] = new FAIL_CODE(); | ||
839 | + } | ||
840 | + | ||
841 | + /** | ||
842 | + * 入参 | ||
843 | + */ | ||
844 | + NET_IN_ACCESS_USER_SERVICE_GET stIn = new NET_IN_ACCESS_USER_SERVICE_GET(); | ||
845 | + // 用户ID个数 | ||
846 | + stIn.nUserNum = userIDs.length; | ||
847 | + | ||
848 | + // 用户ID | ||
849 | + for (int i = 0; i < userIDs.length; i++) { | ||
850 | + System.arraycopy(userIDs[i].getBytes(), 0, | ||
851 | + stIn.szUserIDs[i].szUserID, 0, userIDs[i].getBytes().length); | ||
852 | + } | ||
853 | + | ||
854 | + /** | ||
855 | + * 出参 | ||
856 | + */ | ||
857 | + NET_OUT_ACCESS_USER_SERVICE_GET stOut = new NET_OUT_ACCESS_USER_SERVICE_GET(); | ||
858 | + stOut.nMaxRetNum = nMaxNum; | ||
859 | + | ||
860 | + stOut.pUserInfo = new Memory(users[0].size() * nMaxNum); // 申请内存 | ||
861 | + stOut.pUserInfo.clear(users[0].size() * nMaxNum); | ||
862 | + | ||
863 | + stOut.pFailCode = new Memory(failCodes[0].size() * nMaxNum); // 申请内存 | ||
864 | + stOut.pFailCode.clear(failCodes[0].size() * nMaxNum); | ||
865 | + | ||
866 | + ToolKits.SetStructArrToPointerData(users, stOut.pUserInfo); | ||
867 | + ToolKits.SetStructArrToPointerData(failCodes, stOut.pFailCode); | ||
868 | + | ||
869 | + stIn.write(); | ||
870 | + stOut.write(); | ||
871 | + if (LoginModule.netsdk.CLIENT_OperateAccessUserService(lLong, emtype, | ||
872 | + stIn.getPointer(), stOut.getPointer(), 5000)) { | ||
873 | + // 将指针转为具体的信息 | ||
874 | + ToolKits.GetPointerDataToStructArr(stOut.pUserInfo, users); | ||
875 | + ToolKits.GetPointerDataToStructArr(stOut.pFailCode, failCodes); | ||
876 | + | ||
877 | + /** | ||
878 | + * 打印具体的信息 | ||
879 | + */ | ||
880 | + for (int i = 0; i < nMaxNum; i++) { | ||
881 | + try { | ||
882 | + System.out.println("[" + i + "]用户名:" | ||
883 | + + new String(users[i].szName, "GBK").trim()); | ||
884 | + } catch (UnsupportedEncodingException e) { | ||
885 | + e.printStackTrace(); | ||
886 | + } | ||
887 | + System.out.println("[" + i + "]密码:" | ||
888 | + + new String(users[i].szPsw).trim()); | ||
889 | + System.out.println("[" + i + "]查询用户结果:" | ||
890 | + + failCodes[i].nFailCode); | ||
891 | + } | ||
892 | + } else { | ||
893 | + System.err.println("查询卡失败, " + ToolKits.getErrorCodePrint()); | ||
894 | + } | ||
895 | + | ||
896 | + stIn.read(); | ||
897 | + stOut.read(); | ||
898 | + } | ||
899 | + | ||
900 | + /** | ||
901 | + * 根据卡号获取卡信息 | ||
902 | + */ | ||
903 | + public static void getCard(String userID,LLong lLong) { | ||
904 | + String[] cardNOs = { userID }; | ||
905 | + | ||
906 | + // 修改的卡的最大个数 | ||
907 | + int nMaxCount = cardNOs.length; | ||
908 | + | ||
909 | + // 卡片信息 | ||
910 | + NET_ACCESS_CARD_INFO[] cards = new NET_ACCESS_CARD_INFO[nMaxCount]; | ||
911 | + for (int i = 0; i < nMaxCount; i++) { | ||
912 | + cards[i] = new NET_ACCESS_CARD_INFO(); | ||
913 | + } | ||
914 | + | ||
915 | + // | ||
916 | + FAIL_CODE[] failCodes = new FAIL_CODE[nMaxCount]; | ||
917 | + for (int i = 0; i < nMaxCount; i++) { | ||
918 | + failCodes[i] = new FAIL_CODE(); | ||
919 | + } | ||
920 | + | ||
921 | + // 卡操作类型 | ||
922 | + // 获取卡信息 | ||
923 | + int emtype = NET_EM_ACCESS_CTL_CARD_SERVICE.NET_EM_ACCESS_CTL_CARD_SERVICE_GET; | ||
924 | + | ||
925 | + /** | ||
926 | + * 入参 | ||
927 | + */ | ||
928 | + NET_IN_ACCESS_CARD_SERVICE_GET stIn = new NET_IN_ACCESS_CARD_SERVICE_GET(); | ||
929 | + // 卡号数量 | ||
930 | + stIn.nCardNum = cardNOs.length; | ||
931 | + | ||
932 | + for (int i = 0; i < cardNOs.length; i++) { | ||
933 | + // 卡号 | ||
934 | + System.arraycopy(cardNOs[i].getBytes(), 0, | ||
935 | + stIn.szCardNos[i].szCardNo, 0, cardNOs[i].getBytes().length); | ||
936 | + } | ||
937 | + | ||
938 | + /** | ||
939 | + * 出参 | ||
940 | + */ | ||
941 | + NET_OUT_ACCESS_CARD_SERVICE_GET stOut = new NET_OUT_ACCESS_CARD_SERVICE_GET(); | ||
942 | + stOut.nMaxRetNum = nMaxCount; | ||
943 | + | ||
944 | + stOut.pCardInfo = new Memory(cards[0].size() * nMaxCount); | ||
945 | + stOut.pCardInfo.clear(cards[0].size() * nMaxCount); | ||
946 | + | ||
947 | + stOut.pFailCode = new Memory(failCodes[0].size() * nMaxCount); | ||
948 | + stOut.pFailCode.clear(failCodes[0].size() * nMaxCount); | ||
949 | + | ||
950 | + ToolKits.SetStructArrToPointerData(cards, stOut.pCardInfo); | ||
951 | + ToolKits.SetStructArrToPointerData(failCodes, stOut.pFailCode); | ||
952 | + | ||
953 | + stIn.write(); | ||
954 | + stOut.write(); | ||
955 | + if (LoginModule.netsdk.CLIENT_OperateAccessCardService(lLong, emtype, | ||
956 | + stIn.getPointer(), stOut.getPointer(), 5000)) { | ||
957 | + // 将获取到的结果信息转成具体的结构体 | ||
958 | + ToolKits.GetPointerDataToStructArr(stOut.pCardInfo, cards); | ||
959 | + ToolKits.GetPointerDataToStructArr(stOut.pFailCode, failCodes); | ||
960 | + | ||
961 | + // 打印具体信息 | ||
962 | + for (int i = 0; i < nMaxCount; i++) { | ||
963 | + System.out.println("[" + i + "]用户ID : " | ||
964 | + + new String(cards[i].szUserID).trim()); | ||
965 | + System.out.println("[" + i + "]卡号 : " | ||
966 | + + new String(cards[i].szCardNo).trim()); | ||
967 | + System.out.println("[" + i + "]卡类型 : " + cards[i].emType); | ||
968 | + System.out.println("[" + i + "]查询卡结果 : " | ||
969 | + + failCodes[i].nFailCode + "\n"); | ||
970 | + } | ||
971 | + } else { | ||
972 | + System.err.println("查询卡失败, " + ToolKits.getErrorCodePrint()); | ||
973 | + } | ||
974 | + stIn.read(); | ||
975 | + stOut.read(); | ||
976 | + } | ||
977 | + | ||
978 | + /** | ||
979 | + * 删除指定用户ID的用户 | ||
980 | + */ | ||
981 | + public static void deleteUser(String userID,LLong lLong) { | ||
982 | + String[] userIDs = { userID }; | ||
983 | + | ||
984 | + // 删除的用户个数 | ||
985 | + int nMaxNum = userIDs.length; | ||
986 | + | ||
987 | + // /////////////////////////// 以下固定写法 | ||
988 | + // ///////////////////////////////////// | ||
989 | + // 用户操作类型 | ||
990 | + // 删除用户 | ||
991 | + int emtype = NET_EM_ACCESS_CTL_USER_SERVICE.NET_EM_ACCESS_CTL_USER_SERVICE_REMOVE; | ||
992 | + | ||
993 | + // 初始化返回的失败信息数组 | ||
994 | + FAIL_CODE[] failCodes = new FAIL_CODE[nMaxNum]; | ||
995 | + for (int i = 0; i < nMaxNum; i++) { | ||
996 | + failCodes[i] = new FAIL_CODE(); | ||
997 | + } | ||
998 | + | ||
999 | + /** | ||
1000 | + * 入参 | ||
1001 | + */ | ||
1002 | + NET_IN_ACCESS_USER_SERVICE_REMOVE stIn = new NET_IN_ACCESS_USER_SERVICE_REMOVE(); | ||
1003 | + // 用户ID个数 | ||
1004 | + stIn.nUserNum = userIDs.length; | ||
1005 | + | ||
1006 | + // 用户ID | ||
1007 | + for (int i = 0; i < userIDs.length; i++) { | ||
1008 | + System.arraycopy(userIDs[i].getBytes(), 0, | ||
1009 | + stIn.szUserIDs[i].szUserID, 0, userIDs[i].getBytes().length); | ||
1010 | + } | ||
1011 | + | ||
1012 | + /** | ||
1013 | + * 出参 | ||
1014 | + */ | ||
1015 | + NET_OUT_ACCESS_USER_SERVICE_REMOVE stOut = new NET_OUT_ACCESS_USER_SERVICE_REMOVE(); | ||
1016 | + stOut.nMaxRetNum = nMaxNum; | ||
1017 | + | ||
1018 | + stOut.pFailCode = new Memory(failCodes[0].size() * nMaxNum); // 申请内存 | ||
1019 | + stOut.pFailCode.clear(failCodes[0].size() * nMaxNum); | ||
1020 | + | ||
1021 | + ToolKits.SetStructArrToPointerData(failCodes, stOut.pFailCode); | ||
1022 | + | ||
1023 | + stIn.write(); | ||
1024 | + stOut.write(); | ||
1025 | + if (LoginModule.netsdk.CLIENT_OperateAccessUserService(lLong, emtype, | ||
1026 | + stIn.getPointer(), stOut.getPointer(), 5000)) { | ||
1027 | + // 将指针转为具体的信息 | ||
1028 | + ToolKits.GetPointerDataToStructArr(stOut.pFailCode, failCodes); | ||
1029 | + | ||
1030 | + /** | ||
1031 | + * 打印具体的信息 | ||
1032 | + */ | ||
1033 | + for (int i = 0; i < nMaxNum; i++) { | ||
1034 | + System.out.println("[" + i + "]删除用户结果:" | ||
1035 | + + failCodes[i].nFailCode); | ||
1036 | + } | ||
1037 | + } else { | ||
1038 | + //System.err.println("删除用户失败, " + getErrorCode()); | ||
1039 | + System.err.println("删除用户失败, " + ToolKits.getErrorCodePrint()); | ||
1040 | + } | ||
1041 | + | ||
1042 | + stIn.read(); | ||
1043 | + stOut.read(); | ||
1044 | + } | ||
1045 | + | ||
787 | 1046 | ||
788 | ///////////////////////////////// 人脸的增、删、改、清空 /////////////////////////////////////// | 1047 | ///////////////////////////////// 人脸的增、删、改、清空 /////////////////////////////////////// |
789 | 1048 | ||
@@ -867,7 +1126,18 @@ public class GateModule { | @@ -867,7 +1126,18 @@ public class GateModule { | ||
867 | if (bRet) { | 1126 | if (bRet) { |
868 | System.out.println("添加人脸成功!"); | 1127 | System.out.println("添加人脸成功!"); |
869 | } else { | 1128 | } else { |
870 | - System.err.println("添加人脸失败!" + ToolKits.getErrorCodePrint()); | 1129 | +// System.err.println("添加人脸失败!" + ToolKits.getErrorCodePrint()); |
1130 | + String ret=ToolKits.getErrorCodePrint(); | ||
1131 | + System.err.println("添加人脸失败!" + ret); | ||
1132 | + String number = ret.substring(ret.indexOf("|") + 1, ret.indexOf(")")); | ||
1133 | + if(number.equals("1031"))//照片已存在 | ||
1134 | + { | ||
1135 | + return modifyFaceInfo( userId, memory, lLong)==1?true:false; | ||
1136 | + } | ||
1137 | + if(number.equals("1029"))//照片已存在 | ||
1138 | + { | ||
1139 | + return addFaceInfo( userId, memory, lLong); | ||
1140 | + } | ||
871 | return false; | 1141 | return false; |
872 | } | 1142 | } |
873 | 1143 | ||
@@ -914,7 +1184,10 @@ public class GateModule { | @@ -914,7 +1184,10 @@ public class GateModule { | ||
914 | if (bRet) { | 1184 | if (bRet) { |
915 | System.out.println("修改人脸成功!"); | 1185 | System.out.println("修改人脸成功!"); |
916 | } else { | 1186 | } else { |
917 | - System.err.println("修改人脸失败!" + ToolKits.getErrorCodePrint()); | 1187 | +// System.err.println("修改人脸失败!" + ToolKits.getErrorCodePrint()); |
1188 | + String ret=ToolKits.getErrorCodePrint(); | ||
1189 | + System.err.println("修改人脸成功!" + ret); | ||
1190 | + String number = ret.substring(ret.indexOf("|") + 1, ret.indexOf(")")); | ||
918 | return false; | 1191 | return false; |
919 | } | 1192 | } |
920 | 1193 | ||
@@ -922,7 +1195,7 @@ public class GateModule { | @@ -922,7 +1195,7 @@ public class GateModule { | ||
922 | } | 1195 | } |
923 | 1196 | ||
924 | 1197 | ||
925 | - public static boolean modifyFaceInfo(String userId, Memory memory, LLong lLong) { | 1198 | + public static int modifyFaceInfo(String userId, Memory memory, LLong lLong) { |
926 | int emType = EM_FACEINFO_OPREATE_TYPE.EM_FACEINFO_OPREATE_UPDATE; // 修改 | 1199 | int emType = EM_FACEINFO_OPREATE_TYPE.EM_FACEINFO_OPREATE_UPDATE; // 修改 |
927 | 1200 | ||
928 | /** | 1201 | /** |
@@ -955,13 +1228,139 @@ public class GateModule { | @@ -955,13 +1228,139 @@ public class GateModule { | ||
955 | if (bRet) { | 1228 | if (bRet) { |
956 | System.out.println("修改人脸成功!"); | 1229 | System.out.println("修改人脸成功!"); |
957 | } else { | 1230 | } else { |
1231 | +// System.err.println("修改人脸失败!" + ToolKits.getErrorCodePrint()); | ||
1232 | + String ret=ToolKits.getErrorCodePrint(); | ||
1233 | + System.err.println("修改人脸失败!" + ret); | ||
1234 | + String number = ret.substring(ret.indexOf("|") + 1, ret.indexOf(")")); | ||
1235 | + if(number.equals("1029"))//1029用户ID不存在 | ||
1236 | + { | ||
1237 | + //return addFaceInfo(userId, memory, lLong); | ||
1238 | + return Integer.parseInt(number); | ||
1239 | + } | ||
1240 | + return 0; | ||
1241 | + } | ||
1242 | + | ||
1243 | + return 1; | ||
1244 | + } | ||
1245 | + | ||
1246 | + /** | ||
1247 | + * 获取人脸信息 | ||
1248 | + */ | ||
1249 | + public static void getFace(String userId,LLong lLong) { | ||
1250 | + String[] userIDs = { userId }; | ||
1251 | + | ||
1252 | + // 获取人脸的用户最大个数 | ||
1253 | + int nMaxCount = userIDs.length; | ||
1254 | + | ||
1255 | + // ////////////////////// 每个用户的人脸信息初始化 //////////////////////// | ||
1256 | + NET_ACCESS_FACE_INFO[] faces = new NET_ACCESS_FACE_INFO[nMaxCount]; | ||
1257 | + for (int i = 0; i < faces.length; i++) { | ||
1258 | + faces[i] = new NET_ACCESS_FACE_INFO(); | ||
1259 | + | ||
1260 | + // 根据每个用户的人脸图片的实际个数申请内存,最多5张照片 | ||
1261 | + | ||
1262 | + faces[i].nFacePhoto = 1; // 每个用户图片个数 | ||
1263 | + | ||
1264 | + // 对每张照片申请内存 | ||
1265 | + faces[i].nInFacePhotoLen[0] = 200 * 1024; | ||
1266 | + faces[i].pFacePhotos[0].pFacePhoto = new Memory(200 * 1024); // 人脸照片数据,大小不超过200K | ||
1267 | + faces[i].pFacePhotos[0].pFacePhoto.clear(200 * 1024); | ||
1268 | + } | ||
1269 | + | ||
1270 | + // 初始化 | ||
1271 | + FAIL_CODE[] failCodes = new FAIL_CODE[nMaxCount]; | ||
1272 | + for (int i = 0; i < failCodes.length; i++) { | ||
1273 | + failCodes[i] = new FAIL_CODE(); | ||
1274 | + } | ||
1275 | + | ||
1276 | + // 人脸操作类型 | ||
1277 | + // 获取人脸信息 | ||
1278 | + int emtype = NET_EM_ACCESS_CTL_FACE_SERVICE.NET_EM_ACCESS_CTL_FACE_SERVICE_GET; | ||
1279 | + | ||
1280 | + /** | ||
1281 | + * 入参 | ||
1282 | + */ | ||
1283 | + NET_IN_ACCESS_FACE_SERVICE_GET stIn = new NET_IN_ACCESS_FACE_SERVICE_GET(); | ||
1284 | + stIn.nUserNum = nMaxCount; | ||
1285 | + for (int i = 0; i < nMaxCount; i++) { | ||
1286 | + System.arraycopy(userIDs[i].getBytes(), 0, | ||
1287 | + stIn.szUserIDs[i].szUserID, 0, userIDs[i].getBytes().length); | ||
1288 | + } | ||
1289 | + | ||
1290 | + /** | ||
1291 | + * 出参 | ||
1292 | + */ | ||
1293 | + NET_OUT_ACCESS_FACE_SERVICE_GET stOut = new NET_OUT_ACCESS_FACE_SERVICE_GET(); | ||
1294 | + stOut.nMaxRetNum = nMaxCount; | ||
1295 | + | ||
1296 | + stOut.pFaceInfo = new Memory(faces[0].size() * nMaxCount); | ||
1297 | + stOut.pFaceInfo.clear(faces[0].size() * nMaxCount); | ||
1298 | + | ||
1299 | + stOut.pFailCode = new Memory(failCodes[0].size() * nMaxCount); | ||
1300 | + stOut.pFailCode.clear(failCodes[0].size() * nMaxCount); | ||
1301 | + | ||
1302 | + ToolKits.SetStructArrToPointerData(faces, stOut.pFaceInfo); | ||
1303 | + ToolKits.SetStructArrToPointerData(failCodes, stOut.pFailCode); | ||
1304 | + | ||
1305 | + stIn.write(); | ||
1306 | + stOut.write(); | ||
1307 | + if (LoginModule.netsdk.CLIENT_OperateAccessFaceService(lLong, emtype, | ||
1308 | + stIn.getPointer(), stOut.getPointer(), 5000)) { | ||
1309 | + // 将获取到的结果信息转成具体的结构体 | ||
1310 | + ToolKits.GetPointerDataToStructArr(stOut.pFaceInfo, faces); | ||
1311 | + ToolKits.GetPointerDataToStructArr(stOut.pFailCode, failCodes); | ||
1312 | + | ||
1313 | + File path = new File("."); | ||
1314 | + | ||
1315 | + // 打印具体信息 | ||
1316 | + // nMaxCount 几个用户 | ||
1317 | + for (int i = 0; i < nMaxCount; i++) { | ||
1318 | + System.out.println("[" + i + "]用户ID : " | ||
1319 | + + new String(faces[i].szUserID).trim()); | ||
1320 | + | ||
1321 | + // 保存查询到的图片 | ||
1322 | + String savePath = ""; | ||
1323 | + for (int j = 0; j < faces[i].nFacePhoto; j++) { | ||
1324 | + | ||
1325 | + if (faces[i].nFacePhoto == 0 | ||
1326 | + || faces[i].pFacePhotos[j].pFacePhoto == null) { | ||
1327 | + return; | ||
1328 | + } | ||
1329 | + | ||
1330 | + savePath = path.getAbsoluteFile().getParent() + "/" | ||
1331 | + + "qyc" + "_" | ||
1332 | + + new String(faces[i].szUserID).trim() + ".jpg"; | ||
1333 | + System.out.println("路径:" + savePath); | ||
1334 | + // 人脸图片数据 | ||
1335 | + byte[] buffer = faces[i].pFacePhotos[j].pFacePhoto | ||
1336 | + .getByteArray(0, faces[i].nOutFacePhotoLen[j]); | ||
1337 | + | ||
1338 | + ByteArrayInputStream byteInputStream = new ByteArrayInputStream( | ||
1339 | + buffer); | ||
1340 | + try { | ||
1341 | + BufferedImage bufferedImage = ImageIO | ||
1342 | + .read(byteInputStream); | ||
1343 | + if (bufferedImage == null) { | ||
1344 | + return; | ||
1345 | + } | ||
1346 | + ImageIO.write(bufferedImage, "jpg", new File(savePath)); | ||
1347 | + } catch (IOException e) { | ||
1348 | + e.printStackTrace(); | ||
1349 | + } | ||
1350 | + } | ||
1351 | + | ||
1352 | + System.out.println("[" + i + "]获取人脸结果 : " | ||
1353 | + + failCodes[i].nFailCode); | ||
1354 | + } | ||
1355 | + } else { | ||
958 | System.err.println("修改人脸失败!" + ToolKits.getErrorCodePrint()); | 1356 | System.err.println("修改人脸失败!" + ToolKits.getErrorCodePrint()); |
959 | - return false; | ||
960 | } | 1357 | } |
961 | 1358 | ||
962 | - return true; | 1359 | + stIn.read(); |
1360 | + stOut.read(); | ||
963 | } | 1361 | } |
964 | 1362 | ||
1363 | + | ||
965 | /** | 1364 | /** |
966 | * 删除人脸(单个删除) | 1365 | * 删除人脸(单个删除) |
967 | * | 1366 | * |
cloud/dahua/src/main/java/com/example/dahua/service/imp/PermissFaceServiceImp.java
@@ -276,7 +276,7 @@ public class PermissFaceServiceImp implements PermissFaceService { | @@ -276,7 +276,7 @@ public class PermissFaceServiceImp implements PermissFaceService { | ||
276 | 276 | ||
277 | } else if (clintType.equals("22") || clintType.equals("29")) { | 277 | } else if (clintType.equals("22") || clintType.equals("29")) { |
278 | HttpUtils.uploadImgs(saveImgFile, schoolId, studentcode | 278 | HttpUtils.uploadImgs(saveImgFile, schoolId, studentcode |
279 | - , clintType, userType); | 279 | + , clintType, userType,attendanceBean.getClint_id()); |
280 | } | 280 | } |
281 | 281 | ||
282 | } | 282 | } |
cloud/dahua/src/main/java/com/example/dahua/utils/HttpUtils.java
@@ -12,6 +12,7 @@ import org.springframework.http.MediaType; | @@ -12,6 +12,7 @@ import org.springframework.http.MediaType; | ||
12 | import org.springframework.http.ResponseEntity; | 12 | import org.springframework.http.ResponseEntity; |
13 | import org.springframework.util.LinkedMultiValueMap; | 13 | import org.springframework.util.LinkedMultiValueMap; |
14 | import org.springframework.util.MultiValueMap; | 14 | import org.springframework.util.MultiValueMap; |
15 | +import org.springframework.util.StringUtils; | ||
15 | import org.springframework.web.bind.annotation.RequestParam; | 16 | import org.springframework.web.bind.annotation.RequestParam; |
16 | import org.springframework.web.client.RestTemplate; | 17 | import org.springframework.web.client.RestTemplate; |
17 | 18 | ||
@@ -21,7 +22,7 @@ import java.util.Map; | @@ -21,7 +22,7 @@ import java.util.Map; | ||
21 | 22 | ||
22 | public class HttpUtils { | 23 | public class HttpUtils { |
23 | 24 | ||
24 | - public static boolean uploadImgs(File file, String schoolId, String studentCode, String clint_type, int userType) { | 25 | + public static boolean uploadImgs(File file, String schoolId, String studentCode, String clint_type, int userType,String deviceId) { |
25 | 26 | ||
26 | if (!file.exists()) { | 27 | if (!file.exists()) { |
27 | System.out.println("图片不存在"); | 28 | System.out.println("图片不存在"); |
@@ -29,37 +30,39 @@ public class HttpUtils { | @@ -29,37 +30,39 @@ public class HttpUtils { | ||
29 | } | 30 | } |
30 | String targPath = FilePath.picPathComp + studentCode + ".jpg"; | 31 | String targPath = FilePath.picPathComp + studentCode + ".jpg"; |
31 | // String targPath = "C:\\Users\\taohandong\\Desktop\\comp\\"+userInfoBean.getStudentcode()+".jpg"; | 32 | // String targPath = "C:\\Users\\taohandong\\Desktop\\comp\\"+userInfoBean.getStudentcode()+".jpg"; |
32 | - try { | ||
33 | - CompressPic.CompressPic(file.getAbsolutePath(), targPath, studentCode);//压缩后的图片 | ||
34 | - } catch (Exception e) { | ||
35 | - e.printStackTrace(); | ||
36 | - } | ||
37 | String url = "http://121.40.109.21:8991/file/uploadImg"; | 33 | String url = "http://121.40.109.21:8991/file/uploadImg"; |
38 | -// String url = "http://localhost:8991/file/uploadImg"; | ||
39 | - RestTemplate restTemplate = new RestTemplate(); | ||
40 | - | ||
41 | - HttpHeaders headers = new HttpHeaders(); | ||
42 | - | ||
43 | - MediaType mediaType = MediaType.parseMediaType(MediaType.MULTIPART_FORM_DATA_VALUE); | ||
44 | - | ||
45 | - headers.setContentType(mediaType); | ||
46 | - | 34 | + //String url = "http://localhost:8991/file/uploadImg"; |
47 | MultiValueMap<String, Object> multivaluedMap = new LinkedMultiValueMap<>(); | 35 | MultiValueMap<String, Object> multivaluedMap = new LinkedMultiValueMap<>(); |
36 | + HttpHeaders headers = new HttpHeaders(); | ||
37 | + RestTemplate restTemplate = new RestTemplate(); | ||
38 | + HttpEntity<MultiValueMap<String, Object>> httpEntity = null; | ||
39 | + ResponseEntity<String> responseEntity = null; | ||
40 | + try { | ||
41 | + CompressPic.CompressPic(file.getAbsolutePath(), targPath, studentCode);//压缩后的图片 | ||
48 | 42 | ||
49 | - FileSystemResource fileSystemResource = new FileSystemResource(targPath); | ||
50 | - | ||
51 | - multivaluedMap.add("file", fileSystemResource); | ||
52 | - multivaluedMap.add("schoolId", schoolId); | ||
53 | - multivaluedMap.add("studentCode", studentCode); | ||
54 | - multivaluedMap.add("clint_type", clint_type); | ||
55 | - multivaluedMap.add("userType", userType); | ||
56 | - | ||
57 | - HttpEntity<MultiValueMap<String, Object>> httpEntity = new HttpEntity<>(multivaluedMap, headers); | 43 | + MediaType mediaType = MediaType.parseMediaType(MediaType.MULTIPART_FORM_DATA_VALUE); |
58 | 44 | ||
59 | - ResponseEntity<String> responseEntity = restTemplate.postForEntity(url, httpEntity, String.class); | 45 | + headers.setContentType(mediaType); |
60 | 46 | ||
61 | - System.out.println("responseEntity:" + responseEntity.getBody()); | ||
62 | - return responseEntity.getBody().equals("1"); | 47 | + FileSystemResource fileSystemResource = new FileSystemResource(targPath); |
48 | + | ||
49 | + multivaluedMap.add("file", fileSystemResource); | ||
50 | + multivaluedMap.add("schoolId", schoolId); | ||
51 | + multivaluedMap.add("studentCode", studentCode); | ||
52 | + multivaluedMap.add("clint_type", clint_type); | ||
53 | + multivaluedMap.add("userType", userType); | ||
54 | + if(!StringUtils.isEmpty(deviceId)){ | ||
55 | + multivaluedMap.add("deviceId", deviceId); | ||
56 | + } | ||
57 | + httpEntity = new HttpEntity<>(multivaluedMap, headers); | ||
58 | + responseEntity = restTemplate.postForEntity(url, httpEntity, String.class); | ||
59 | + | ||
60 | + System.out.println("responseEntity:" + responseEntity.getBody()); | ||
61 | + return responseEntity.getBody().equals("1"); | ||
62 | + } catch (Exception e) { | ||
63 | + e.printStackTrace(); | ||
64 | + return responseEntity.getBody().equals("0"); | ||
65 | + } | ||
63 | } | 66 | } |
64 | 67 | ||
65 | 68 |