Commit 623099fe3b1eefc4c587adbb1038f01e833caba4
1 parent
c28016fb
Exists in
master
大华设备对接艺校考勤
Showing
7 changed files
with
278 additions
and
63 deletions
Show diff stats
cloud/dahua/src/main/java/com/example/dahua/MyTask.java
1 | package com.example.dahua; | 1 | package com.example.dahua; |
2 | 2 | ||
3 | +import com.alibaba.fastjson.JSON; | ||
4 | +import com.alibaba.fastjson.JSONObject; | ||
3 | import com.example.dahua.bean.*; | 5 | import com.example.dahua.bean.*; |
4 | import com.example.dahua.dao.UserDao; | 6 | import com.example.dahua.dao.UserDao; |
5 | import com.example.dahua.enums.EnumDeviceType; | 7 | import com.example.dahua.enums.EnumDeviceType; |
@@ -25,8 +27,15 @@ import lombok.extern.slf4j.Slf4j; | @@ -25,8 +27,15 @@ import lombok.extern.slf4j.Slf4j; | ||
25 | import org.springframework.beans.factory.annotation.Autowired; | 27 | import org.springframework.beans.factory.annotation.Autowired; |
26 | import org.springframework.boot.ApplicationArguments; | 28 | import org.springframework.boot.ApplicationArguments; |
27 | import org.springframework.boot.ApplicationRunner; | 29 | import org.springframework.boot.ApplicationRunner; |
30 | +import org.springframework.http.HttpEntity; | ||
31 | +import org.springframework.http.HttpHeaders; | ||
32 | +import org.springframework.http.MediaType; | ||
33 | +import org.springframework.http.ResponseEntity; | ||
28 | import org.springframework.stereotype.Component; | 34 | import org.springframework.stereotype.Component; |
35 | +import org.springframework.util.LinkedMultiValueMap; | ||
36 | +import org.springframework.util.MultiValueMap; | ||
29 | import org.springframework.util.StringUtils; | 37 | import org.springframework.util.StringUtils; |
38 | +import org.springframework.web.client.RestTemplate; | ||
30 | 39 | ||
31 | import javax.annotation.PostConstruct; | 40 | import javax.annotation.PostConstruct; |
32 | import javax.imageio.ImageIO; | 41 | import javax.imageio.ImageIO; |
@@ -38,6 +47,7 @@ import java.io.UnsupportedEncodingException; | @@ -38,6 +47,7 @@ import java.io.UnsupportedEncodingException; | ||
38 | import java.text.SimpleDateFormat; | 47 | import java.text.SimpleDateFormat; |
39 | import java.util.*; | 48 | import java.util.*; |
40 | import java.util.concurrent.CopyOnWriteArrayList; | 49 | import java.util.concurrent.CopyOnWriteArrayList; |
50 | +import java.util.stream.Collectors; | ||
41 | 51 | ||
42 | @Component | 52 | @Component |
43 | @Slf4j | 53 | @Slf4j |
@@ -388,7 +398,6 @@ public class MyTask implements ApplicationRunner { | @@ -388,7 +398,6 @@ public class MyTask implements ApplicationRunner { | ||
388 | if (lAnalyzerHandle.longValue() == 0 || pAlarmInfo == null) { | 398 | if (lAnalyzerHandle.longValue() == 0 || pAlarmInfo == null) { |
389 | return -1; | 399 | return -1; |
390 | } | 400 | } |
391 | - | ||
392 | byte[] bufferBytes = new byte[dwBufSize]; | 401 | byte[] bufferBytes = new byte[dwBufSize]; |
393 | pBuffer.read(0, bufferBytes, 0, dwBufSize); | 402 | pBuffer.read(0, bufferBytes, 0, dwBufSize); |
394 | File path = new File(".\\FaceRecoder"); | 403 | File path = new File(".\\FaceRecoder"); |
@@ -399,14 +408,6 @@ public class MyTask implements ApplicationRunner { | @@ -399,14 +408,6 @@ public class MyTask implements ApplicationRunner { | ||
399 | CDevInfo data = new CDevInfo(); | 408 | CDevInfo data = new CDevInfo(); |
400 | ToolKits.GetPointerData(dwUser, data); | 409 | ToolKits.GetPointerData(dwUser, data); |
401 | String szSn = new String(data.szSN).trim(); | 410 | String szSn = new String(data.szSN).trim(); |
402 | -// if(dwAlarmType == NetSDKLib.EVENT_IVS_FACERECOGNITION){ | ||
403 | -//// ToolKits.GetPointerData(pAlarmInfo, msg); | ||
404 | -//// //卡号 | ||
405 | -//// String card = new String(msg.szCardNo).trim(); | ||
406 | -//// //开门用户 | ||
407 | -//// String userId = new String(msg.szUID).trim(); | ||
408 | -//// log.info("你来了。。。。"); | ||
409 | -// } | ||
410 | ///< 门禁事件 | 411 | ///< 门禁事件 |
411 | if (dwAlarmType == NetSDKLib.EVENT_IVS_ACCESS_CTL) { | 412 | if (dwAlarmType == NetSDKLib.EVENT_IVS_ACCESS_CTL) { |
412 | NetSDKLib.DEV_EVENT_ACCESS_CTL_INFO msg = new NetSDKLib.DEV_EVENT_ACCESS_CTL_INFO(); | 413 | NetSDKLib.DEV_EVENT_ACCESS_CTL_INFO msg = new NetSDKLib.DEV_EVENT_ACCESS_CTL_INFO(); |
@@ -423,66 +424,70 @@ public class MyTask implements ApplicationRunner { | @@ -423,66 +424,70 @@ public class MyTask implements ApplicationRunner { | ||
423 | saveAttendanceService(szSn,"",0,1); | 424 | saveAttendanceService(szSn,"",0,1); |
424 | try { | 425 | try { |
425 | if (!StringUtils.isEmpty(card)) { | 426 | if (!StringUtils.isEmpty(card)) { |
426 | - // 保存图片,获取图片缓存 | ||
427 | - // 图片服务器路径 | ||
428 | - String snapPicPath = path + "\\" + System.currentTimeMillis() + ".png"; | 427 | + //根据卡号获取卡身份信息 |
428 | + CardBean cardBean = myTaskUtil.userDao.getCards(card); | ||
429 | + if(cardBean ==null){ | ||
430 | + card = cardNo(card); | ||
431 | + cardBean = myTaskUtil.userDao.getCards(card); | ||
432 | + } | ||
433 | + if(cardBean ==null){ | ||
434 | + return -1; | ||
435 | + } | ||
436 | + | ||
437 | + // 缓存抓拍人脸 | ||
438 | + String fileName = StringUtils.isEmpty(userId)? card + ".png" : userId + ".png"; | ||
439 | + String snapPicPath = path + "\\" + fileName; | ||
429 | byte[] buffer = pBuffer.getByteArray(0, dwBufSize); | 440 | byte[] buffer = pBuffer.getByteArray(0, dwBufSize); |
430 | ByteArrayInputStream byteArrInputGlobal = new ByteArrayInputStream(buffer); | 441 | ByteArrayInputStream byteArrInputGlobal = new ByteArrayInputStream(buffer); |
431 | gateBufferedImage = ImageIO.read(byteArrInputGlobal); | 442 | gateBufferedImage = ImageIO.read(byteArrInputGlobal); |
432 | if (gateBufferedImage != null) { | 443 | if (gateBufferedImage != null) { |
433 | ImageIO.write(gateBufferedImage, "png", new File(snapPicPath)); | 444 | ImageIO.write(gateBufferedImage, "png", new File(snapPicPath)); |
434 | } | 445 | } |
435 | - int schoolId=0; | ||
436 | - int outOrIn =0; | ||
437 | - AttendanceBean attendanceBean = myTaskUtil.userDao.getTypeByClint_id(szSn); | ||
438 | - if(attendanceBean !=null){ | ||
439 | - if(org.apache.commons.lang.StringUtils.isNotBlank(attendanceBean.getSchool_id())){ | ||
440 | - schoolId=Integer.parseInt(attendanceBean.getSchool_id()); | ||
441 | - outOrIn= StringUtils.isEmpty(attendanceBean.getOutOrIn())?0:Integer.parseInt(attendanceBean.getOutOrIn()); | ||
442 | - } | ||
443 | - } | ||
444 | - /** | ||
445 | - * 卡号取反(大写) | ||
446 | - * 注:若设备为一体机、且非"126上虞城东小学、393上虞实验中学"学校,卡则取反 | ||
447 | - */ | ||
448 | - if(szSn.startsWith("ytj")&&schoolId!=126&&schoolId!=393){ | ||
449 | - card = card; | ||
450 | - } else{ | ||
451 | - card = cardNo(card); | ||
452 | - } | ||
453 | - //根据卡号获取卡身份信息 | ||
454 | - CardBean cardBean = myTaskUtil.userDao.getCards(card); | ||
455 | - String time = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()); | ||
456 | snapPicPath = snapPicPath.replaceFirst("\\.", "http://121.40.109.21:8991"); | 446 | snapPicPath = snapPicPath.replaceFirst("\\.", "http://121.40.109.21:8991"); |
457 | snapPicPath = snapPicPath.replace("FaceRecoder", "image"); | 447 | snapPicPath = snapPicPath.replace("FaceRecoder", "image"); |
458 | - if (null != cardBean && cardBean.getType() == 0) { | ||
459 | - //老师人脸信息,保存人脸记录表 | ||
460 | - TeacherBean teacherBean = myTaskUtil.userDao.getTeacherWithId(cardBean.getUser_id()); | ||
461 | - myTaskUtil.sendRecordDao.addFaceRecoder(szSn, teacherBean.getUser_id(), teacherBean.getName(), snapPicPath,outOrIn, | ||
462 | - time, card,messageCode ==20?EnumSendFaceType.TIME_INTERVAL_ERROR.message:""); | ||
463 | - } else if (null != cardBean && cardBean.getType() == 2) { | ||
464 | - //学生人脸信息,保存人脸记录表 | ||
465 | - UserInfoBean userInfoBean = myTaskUtil.userDao.getStudentWithid(cardBean.getUser_id()); | ||
466 | - myTaskUtil.sendRecordDao.addFaceRecoder(szSn, userInfoBean.getUser_id(), userInfoBean.getName(), snapPicPath,outOrIn, | ||
467 | - time, card,messageCode ==20?EnumSendFaceType.TIME_INTERVAL_ERROR.message:""); | ||
468 | - } | ||
469 | - if(szSn.startsWith("ytj")) { | ||
470 | - //门禁进出类型:1进0出 | ||
471 | - int eventType = EnumSzBusinessType.EnumDeviceInAndOut.INT.code; | ||
472 | - if(StringUtils.isEmpty(attendanceBean.getOutOrIn())){ | ||
473 | - eventType = EnumSzBusinessType.EnumDeviceInAndOut.INT.code; | ||
474 | - } | ||
475 | - if(Integer.parseInt(attendanceBean.getOutOrIn()) != EnumSzBusinessType.EnumDeviceInAndOut.INT.code){ | ||
476 | - eventType = EnumSzBusinessType.EnumDeviceInAndOut.OUT.code; | 448 | + //关联设备信息 |
449 | + AttendanceBean attendanceBean = myTaskUtil.userDao.getTypeByClint_id(szSn); | ||
450 | + if(attendanceBean !=null){ | ||
451 | + if(StringUtils.isEmpty(attendanceBean.getSchool_id())){ | ||
452 | + int schoolId = Integer.parseInt(attendanceBean.getSchool_id()); | ||
453 | + //门禁进出类型:1进0出 | ||
454 | + int eventType = 0; | ||
455 | + if(StringUtils.isEmpty(attendanceBean.getOutOrIn())){ | ||
456 | + eventType = EnumSzBusinessType.EnumDeviceInAndOut.OUT.code; | ||
457 | + }else{ | ||
458 | + eventType = Integer.parseInt(attendanceBean.getOutOrIn()); | ||
459 | + } | ||
460 | + //刷卡时间 | ||
461 | + String eventTime = DateUtils.date2String(new Date(), DateUtils.format2); | ||
462 | + //老师 | ||
463 | + if (cardBean.getType() == 0) { | ||
464 | + //老师人脸信息,保存人脸记录表 | ||
465 | + TeacherBean teacherBean = myTaskUtil.userDao.getTeacherWithId(cardBean.getUser_id()); | ||
466 | + myTaskUtil.sendRecordDao.addFaceRecoder(szSn, teacherBean.getUser_id(), teacherBean.getName(), snapPicPath,eventType, | ||
467 | + eventTime, card,messageCode ==20?EnumSendFaceType.TIME_INTERVAL_ERROR.message:""); | ||
468 | + } | ||
469 | + UserInfoBean userInfoBean = null; | ||
470 | + if (cardBean.getType() == 2) { | ||
471 | + //学生人脸信息,保存人脸记录表 | ||
472 | + userInfoBean = myTaskUtil.userDao.getStudentWithid(cardBean.getUser_id()); | ||
473 | + myTaskUtil.sendRecordDao.addFaceRecoder(szSn, userInfoBean.getUser_id(), userInfoBean.getName(), snapPicPath,eventType, | ||
474 | + eventTime, card,messageCode ==20?EnumSendFaceType.TIME_INTERVAL_ERROR.message:""); | ||
475 | + } | ||
476 | + | ||
477 | + // TODO 考勤记录 | ||
478 | + //刷卡结果,1表示成功, 0表示失败 | ||
479 | + int status = msg.bStatus; | ||
480 | + | ||
481 | + if(szSn.startsWith("ytj")) { | ||
482 | + //保存考勤记录 | ||
483 | + kaoQinRecord(status, eventType, card, szSn, eventTime,lAnalyzerHandle); | ||
484 | + // 艺校考勤 | ||
485 | + if(schoolId ==12 && status ==1){ | ||
486 | + int intOrOut = eventType ==1? 1 : 2; | ||
487 | + sendRecordToSXYX(userInfoBean.getName(),userInfoBean.getUser_id(),intOrOut,eventTime); | ||
488 | + } | ||
489 | + } | ||
477 | } | 490 | } |
478 | - // TODO 考勤记录 | ||
479 | - //刷卡结果,1表示成功, 0表示失败 | ||
480 | - int status = msg.bStatus; | ||
481 | - //刷卡时间 | ||
482 | - String eventTime = DateUtils.date2String(new Date(), DateUtils.format2); | ||
483 | - | ||
484 | - //保存考勤记录 | ||
485 | - kaoQinRecord(status, eventType, card, szSn, eventTime,lAnalyzerHandle); | ||
486 | } | 491 | } |
487 | } | 492 | } |
488 | } catch (IOException e2) { | 493 | } catch (IOException e2) { |
@@ -765,6 +770,25 @@ public class MyTask implements ApplicationRunner { | @@ -765,6 +770,25 @@ public class MyTask implements ApplicationRunner { | ||
765 | return true; | 770 | return true; |
766 | } | 771 | } |
767 | 772 | ||
773 | + public static void sendRecordToSXYX(String name,String userId,int intOrOut,String eventTime) { | ||
774 | + try { | ||
775 | + String api = "http://yixiao.198.hmkj.com.cn/index.php/Attend/send"; | ||
776 | + RestTemplate restTemplate = new RestTemplate(); | ||
777 | + MultiValueMap<String, Object> map = new LinkedMultiValueMap<>(); | ||
778 | + map.add("name", name); | ||
779 | + map.add("xuehao", userId); | ||
780 | + map.add("time", eventTime); | ||
781 | + map.add("state", intOrOut); | ||
782 | + HttpHeaders headers = new HttpHeaders(); | ||
783 | + headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED); | ||
784 | + HttpEntity<MultiValueMap<String, Object>> param = new HttpEntity<>(map, headers); | ||
785 | + ResponseEntity<String> response = restTemplate.postForEntity(api, param, String.class); | ||
786 | + String body = response.getBody(); | ||
787 | + System.out.println(body); | ||
788 | + } catch (Exception e) { | ||
789 | + sendRecordToSXYX(name,userId,intOrOut,eventTime); | ||
790 | + } | ||
791 | + } | ||
768 | } | 792 | } |
769 | 793 | ||
770 | 794 |
cloud/dahua/src/main/java/com/example/dahua/control/UserControl.java
@@ -2,9 +2,10 @@ package com.example.dahua.control; | @@ -2,9 +2,10 @@ 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.bean.PermissionBean; | ||
6 | -import com.example.dahua.bean.SendRecordBean; | ||
7 | -import com.example.dahua.bean.StudentBean; | 5 | +import com.example.dahua.bean.*; |
6 | +import com.example.dahua.bean.yx.Result; | ||
7 | +import com.example.dahua.bean.yx.ResultGenerator; | ||
8 | +import com.example.dahua.bean.yx.StudentInfo; | ||
8 | import com.example.dahua.dao.UserDao; | 9 | import com.example.dahua.dao.UserDao; |
9 | import com.example.dahua.enums.EnumSzBusinessType; | 10 | import com.example.dahua.enums.EnumSzBusinessType; |
10 | import com.example.dahua.lib.CompressPic; | 11 | import com.example.dahua.lib.CompressPic; |
@@ -13,6 +14,7 @@ import com.example.dahua.service.UserService; | @@ -13,6 +14,7 @@ import com.example.dahua.service.UserService; | ||
13 | import com.example.dahua.service.imp.BaseService; | 14 | import com.example.dahua.service.imp.BaseService; |
14 | import com.example.dahua.utils.*; | 15 | import com.example.dahua.utils.*; |
15 | import com.example.dahua.xiananDao.SendRecordDao; | 16 | import com.example.dahua.xiananDao.SendRecordDao; |
17 | +import com.google.gson.Gson; | ||
16 | import io.swagger.annotations.Api; | 18 | import io.swagger.annotations.Api; |
17 | import io.swagger.annotations.ApiImplicitParam; | 19 | import io.swagger.annotations.ApiImplicitParam; |
18 | import io.swagger.annotations.ApiImplicitParams; | 20 | import io.swagger.annotations.ApiImplicitParams; |
@@ -21,7 +23,13 @@ import lombok.extern.slf4j.Slf4j; | @@ -21,7 +23,13 @@ import lombok.extern.slf4j.Slf4j; | ||
21 | import org.json.JSONException; | 23 | import org.json.JSONException; |
22 | import org.json.JSONObject; | 24 | import org.json.JSONObject; |
23 | import org.springframework.beans.factory.annotation.Autowired; | 25 | import org.springframework.beans.factory.annotation.Autowired; |
26 | +import org.springframework.http.HttpEntity; | ||
27 | +import org.springframework.http.HttpHeaders; | ||
24 | import org.springframework.http.MediaType; | 28 | import org.springframework.http.MediaType; |
29 | +import org.springframework.http.ResponseEntity; | ||
30 | +import org.springframework.util.CollectionUtils; | ||
31 | +import org.springframework.util.LinkedMultiValueMap; | ||
32 | +import org.springframework.util.MultiValueMap; | ||
25 | import org.springframework.util.StringUtils; | 33 | import org.springframework.util.StringUtils; |
26 | import org.springframework.web.bind.annotation.*; | 34 | import org.springframework.web.bind.annotation.*; |
27 | import org.springframework.web.client.RestTemplate; | 35 | import org.springframework.web.client.RestTemplate; |
@@ -455,4 +463,63 @@ public class UserControl { | @@ -455,4 +463,63 @@ public class UserControl { | ||
455 | } | 463 | } |
456 | } | 464 | } |
457 | 465 | ||
466 | + @RequestMapping(value = "getStudent", method = RequestMethod.GET) | ||
467 | + @ApiOperation("艺校对账查询") | ||
468 | + @ResponseBody | ||
469 | + public Result queryStudent(@RequestHeader("code") String code) { | ||
470 | + if(StringUtils.isEmpty(code) || !code.equals("sxyx")){ | ||
471 | + return ResultGenerator.genFailResult("请求标识匹配错误"); | ||
472 | + } | ||
473 | + List<UserInfoBean> students = userService.getStudent(12); | ||
474 | + if(CollectionUtils.isEmpty(students)){ | ||
475 | + return ResultGenerator.genSuccessResult(); | ||
476 | + } | ||
477 | + StudentInfo info = new StudentInfo(); | ||
478 | + List<StudentInfo.Student> studentList = new ArrayList<>(); | ||
479 | + students.stream().distinct().forEach(s->{ | ||
480 | + StudentInfo.Student student = new StudentInfo.Student(); | ||
481 | + student.setUserName(s.getName()); | ||
482 | + student.setStudentCode(s.getUser_id()); | ||
483 | + studentList.add(student); | ||
484 | + }); | ||
485 | + info.setTotal(students.size()); | ||
486 | + info.setStudentList(studentList); | ||
487 | + return ResultGenerator.genSuccessResult(new Gson().toJson(info)); | ||
488 | + } | ||
489 | + | ||
490 | + @RequestMapping(value = "syncStudent", method = RequestMethod.GET) | ||
491 | + @ApiOperation("艺校对账新增") | ||
492 | + @ResponseBody | ||
493 | + public Result syncStudent(@RequestParam("userId") String userId) { | ||
494 | + if(StringUtils.isEmpty(userId)){ | ||
495 | + return ResultGenerator.genFailResult("参数为空"); | ||
496 | + } | ||
497 | + UserInfoBean student = userService.getStudentByUserId(userId); | ||
498 | + if(student ==null){ | ||
499 | + return ResultGenerator.genFailResult("此学生不存在"); | ||
500 | + } | ||
501 | + sendRecordToSXYX(student.getName(),userId); | ||
502 | + return ResultGenerator.genSuccessResult(); | ||
503 | + } | ||
504 | + | ||
505 | + public static String sendRecordToSXYX(String name,String userId) { | ||
506 | + String result = ""; | ||
507 | + try { | ||
508 | + String api = "http://yixiao.198.hmkj.com.cn/index.php/Attend/student"; | ||
509 | + RestTemplate restTemplate = new RestTemplate(); | ||
510 | + MultiValueMap<String, Object> map = new LinkedMultiValueMap<>(); | ||
511 | + map.add("name", name); | ||
512 | + map.add("xuehao", userId); | ||
513 | + HttpHeaders headers = new HttpHeaders(); | ||
514 | + headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED); | ||
515 | + HttpEntity<MultiValueMap<String, Object>> param = new HttpEntity<>(map, headers); | ||
516 | + ResponseEntity<String> response = restTemplate.postForEntity(api, param, String.class); | ||
517 | + result = response.getBody(); | ||
518 | + System.out.println(result); | ||
519 | + } catch (Exception e) { | ||
520 | + sendRecordToSXYX(name,userId); | ||
521 | + } | ||
522 | + return result; | ||
523 | + } | ||
524 | + | ||
458 | } | 525 | } |
cloud/dahua/src/main/java/com/example/dahua/control/sxyx/SxyxOaControl.java
0 → 100644
@@ -0,0 +1,95 @@ | @@ -0,0 +1,95 @@ | ||
1 | +package com.example.dahua.control.sxyx; | ||
2 | + | ||
3 | +import com.example.dahua.bean.UserInfoBean; | ||
4 | +import com.example.dahua.bean.yx.Result; | ||
5 | +import com.example.dahua.bean.yx.ResultGenerator; | ||
6 | +import com.example.dahua.bean.yx.StudentInfo; | ||
7 | +import com.example.dahua.service.UserService; | ||
8 | +import com.google.gson.Gson; | ||
9 | +import io.swagger.annotations.Api; | ||
10 | +import io.swagger.annotations.ApiOperation; | ||
11 | +import lombok.extern.slf4j.Slf4j; | ||
12 | +import org.springframework.beans.factory.annotation.Autowired; | ||
13 | +import org.springframework.http.HttpEntity; | ||
14 | +import org.springframework.http.HttpHeaders; | ||
15 | +import org.springframework.http.MediaType; | ||
16 | +import org.springframework.http.ResponseEntity; | ||
17 | +import org.springframework.util.CollectionUtils; | ||
18 | +import org.springframework.util.LinkedMultiValueMap; | ||
19 | +import org.springframework.util.MultiValueMap; | ||
20 | +import org.springframework.util.StringUtils; | ||
21 | +import org.springframework.web.bind.annotation.*; | ||
22 | +import org.springframework.web.client.RestTemplate; | ||
23 | + | ||
24 | +import java.util.ArrayList; | ||
25 | +import java.util.List; | ||
26 | + | ||
27 | +@Slf4j | ||
28 | +@RestController | ||
29 | +@Api(tags = "绍兴艺校对外接口") | ||
30 | +@RequestMapping("/sxyx/student") | ||
31 | +public class SxyxOaControl { | ||
32 | + | ||
33 | + @Autowired | ||
34 | + UserService userService; | ||
35 | + | ||
36 | + @RequestMapping(value = "/getStudent", method = RequestMethod.GET) | ||
37 | + @ApiOperation("艺校对账查询") | ||
38 | + @ResponseBody | ||
39 | + public Result queryStudent(@RequestHeader("code") String code) { | ||
40 | + if(StringUtils.isEmpty(code) || !code.equals("sxyx")){ | ||
41 | + return ResultGenerator.genFailResult("请求标识匹配错误"); | ||
42 | + } | ||
43 | + List<UserInfoBean> students = userService.getStudent(12); | ||
44 | + if(CollectionUtils.isEmpty(students)){ | ||
45 | + return ResultGenerator.genSuccessResult(); | ||
46 | + } | ||
47 | + StudentInfo info = new StudentInfo(); | ||
48 | + List<StudentInfo.Student> studentList = new ArrayList<>(); | ||
49 | + students.stream().distinct().forEach(s->{ | ||
50 | + StudentInfo.Student student = new StudentInfo.Student(); | ||
51 | + student.setUserName(s.getName()); | ||
52 | + student.setStudentCode(s.getUser_id()); | ||
53 | + studentList.add(student); | ||
54 | + }); | ||
55 | + info.setTotal(students.size()); | ||
56 | + info.setStudentList(studentList); | ||
57 | + return ResultGenerator.genSuccessResult(new Gson().toJson(info)); | ||
58 | + } | ||
59 | + | ||
60 | + @RequestMapping(value = "/syncStudent", method = RequestMethod.GET) | ||
61 | + @ApiOperation("艺校对账新增") | ||
62 | + @ResponseBody | ||
63 | + public Result syncStudent(@RequestParam("userId") String userId) { | ||
64 | + if(StringUtils.isEmpty(userId)){ | ||
65 | + return ResultGenerator.genFailResult("参数为空"); | ||
66 | + } | ||
67 | + UserInfoBean student = userService.getStudentByUserId(userId); | ||
68 | + if(student ==null){ | ||
69 | + return ResultGenerator.genFailResult("此学生不存在"); | ||
70 | + } | ||
71 | + sendRecordToSXYX(student.getName(),userId); | ||
72 | + return ResultGenerator.genSuccessResult(); | ||
73 | + } | ||
74 | + | ||
75 | + public static String sendRecordToSXYX(String name,String userId) { | ||
76 | + String result = ""; | ||
77 | + try { | ||
78 | + String api = "http://yixiao.198.hmkj.com.cn/index.php/Attend/student"; | ||
79 | + RestTemplate restTemplate = new RestTemplate(); | ||
80 | + MultiValueMap<String, Object> map = new LinkedMultiValueMap<>(); | ||
81 | + map.add("name", name); | ||
82 | + map.add("xuehao", userId); | ||
83 | + HttpHeaders headers = new HttpHeaders(); | ||
84 | + headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED); | ||
85 | + HttpEntity<MultiValueMap<String, Object>> param = new HttpEntity<>(map, headers); | ||
86 | + ResponseEntity<String> response = restTemplate.postForEntity(api, param, String.class); | ||
87 | + result = response.getBody(); | ||
88 | + System.out.println(result); | ||
89 | + } catch (Exception e) { | ||
90 | + sendRecordToSXYX(name,userId); | ||
91 | + } | ||
92 | + return result; | ||
93 | + } | ||
94 | + | ||
95 | +} |
cloud/dahua/src/main/java/com/example/dahua/dao/UserDao.java
@@ -94,12 +94,18 @@ public interface UserDao { | @@ -94,12 +94,18 @@ public interface UserDao { | ||
94 | @Select(" select top 1* from SZ_V_School_Student where student_id = #{student_id}") | 94 | @Select(" select top 1* from SZ_V_School_Student where student_id = #{student_id}") |
95 | UserInfoBean getStudentWithid(@Param("student_id") String student_id); | 95 | UserInfoBean getStudentWithid(@Param("student_id") String student_id); |
96 | 96 | ||
97 | + @Select(" select top 1* from SZ_V_School_Student where user_id = #{userId}") | ||
98 | + UserInfoBean getStudentByUserId(@Param("userId") String userId); | ||
99 | + | ||
97 | @Select(" select * from SZ_V_School_Student where student_num = #{student_num} and name = #{name}") | 100 | @Select(" select * from SZ_V_School_Student where student_num = #{student_num} and name = #{name}") |
98 | UserInfoBean getStudent(@Param("student_num") String student_num, @Param("name") String name); | 101 | UserInfoBean getStudent(@Param("student_num") String student_num, @Param("name") String name); |
99 | 102 | ||
100 | @Select(" select * from SZ_V_School_Student where school_id = #{school_id} and sex = #{sex} and student_type = #{student_type}") | 103 | @Select(" select * from SZ_V_School_Student where school_id = #{school_id} and sex = #{sex} and student_type = #{student_type}") |
101 | List<UserInfoBean> getStudentWithSchoolId(@Param("school_id") String school_id, @Param("sex") String sex, @Param("student_type") String student_type); | 104 | List<UserInfoBean> getStudentWithSchoolId(@Param("school_id") String school_id, @Param("sex") String sex, @Param("student_type") String student_type); |
102 | 105 | ||
106 | + @Select(" select * from SZ_V_School_Student where school_id = #{school_id}") | ||
107 | + List<UserInfoBean> getStudentBySchoolId(@Param("school_id") Integer school_id); | ||
108 | + | ||
103 | @Select("select * from SZ_V_School_Student where school_id = 479 and student_type = 2") | 109 | @Select("select * from SZ_V_School_Student where school_id = 479 and student_type = 2") |
104 | List<UserInfoBean> getUsers(); | 110 | List<UserInfoBean> getUsers(); |
105 | 111 |
cloud/dahua/src/main/java/com/example/dahua/service/UserService.java
@@ -67,4 +67,8 @@ public interface UserService { | @@ -67,4 +67,8 @@ public interface UserService { | ||
67 | * @param url | 67 | * @param url |
68 | */ | 68 | */ |
69 | void test(String url); | 69 | void test(String url); |
70 | + | ||
71 | + List<UserInfoBean> getStudent(Integer schoolId); | ||
72 | + | ||
73 | + UserInfoBean getStudentByUserId(String userId); | ||
70 | } | 74 | } |
cloud/dahua/src/main/java/com/example/dahua/service/imp/UserServiceImp.java
@@ -182,4 +182,14 @@ public class UserServiceImp implements UserService { | @@ -182,4 +182,14 @@ public class UserServiceImp implements UserService { | ||
182 | } | 182 | } |
183 | } | 183 | } |
184 | } | 184 | } |
185 | + | ||
186 | + @Override | ||
187 | + public List<UserInfoBean> getStudent(Integer schoolId) { | ||
188 | + return userDao.getStudentBySchoolId(schoolId); | ||
189 | + } | ||
190 | + | ||
191 | + @Override | ||
192 | + public UserInfoBean getStudentByUserId(String userId) { | ||
193 | + return userDao.getStudentByUserId(userId); | ||
194 | + } | ||
185 | } | 195 | } |
cloud/haikangface/src/main/java/com/sincere/haikangface/control/UserOperateController.java
@@ -145,4 +145,13 @@ public class UserOperateController { | @@ -145,4 +145,13 @@ public class UserOperateController { | ||
145 | @RequestParam(value = "deviceIds",required = false) String deviceIds){ | 145 | @RequestParam(value = "deviceIds",required = false) String deviceIds){ |
146 | return userOperateService.deleteFaceBySchoolId(schoolId,deviceIds); | 146 | return userOperateService.deleteFaceBySchoolId(schoolId,deviceIds); |
147 | } | 147 | } |
148 | + | ||
149 | + | ||
150 | + public static void main(String[] args) { | ||
151 | + String photo = "http://campus.myjxt.com//f0i5l7e5/0/alluser/20171008/aa26754eb6f24fceb8881d50ee37cdf3.jpg"; | ||
152 | + //以学籍号为名的文件名 | ||
153 | + String fileName = photo.substring(photo.lastIndexOf("/") + 1,photo.length()); | ||
154 | + System.out.println(fileName); | ||
155 | + System.out.println(fileName.split(".")[0]); | ||
156 | + } | ||
148 | } | 157 | } |