Commit 6184590c2aa56b889062229d3000b81fcba002e3

Authored by 徐泉
1 parent 60fd0445
Exists in master

海康大华接口提交

cloud/dahua/src/main/java/com/example/dahua/control/UserControl.java
... ... @@ -190,8 +190,6 @@ public class UserControl {
190 190 }
191 191 }
192 192 }
193   -
194   -
195 193 }
196 194  
197 195  
... ...
cloud/dahua/src/main/java/com/example/dahua/control/UserOperateController.java
... ... @@ -83,4 +83,12 @@ public class UserOperateController {
83 83 public boolean deleteFaceByCard(Integer schoolId,String cardNum,String deviceId) {
84 84 return sendUserInfoTask.deleteFaceByCard(schoolId,cardNum,deviceId);
85 85 }
  86 +
  87 + @ApiOperation(value = "按班级指定下发")
  88 + @RequestMapping(value = "sendFaceByClassId", method = RequestMethod.POST)
  89 + public void exportFace(@RequestParam("schoolId") Integer schoolId,
  90 + @RequestParam(value = "classIds",required = false) String classIds,
  91 + @RequestParam(value = "deviceIds",required = false) String deviceIds){
  92 + userOperateService.sendFaceByClassId(schoolId,classIds,deviceIds);
  93 + }
86 94 }
... ...
cloud/dahua/src/main/java/com/example/dahua/dao/UserDao.java
... ... @@ -17,6 +17,8 @@ public interface UserDao {
17 17 @Select("select school_id from SZ_Attendance where clint_id = #{clint_id} ")
18 18 String getSchoolIdbyClint_id( @Param("clint_id") String clint_id);
19 19  
  20 + @Select("select * from SZ_Attendance where school_id = #{schoolId} and clint_type = 29")
  21 + List<String> selectDeviceBySchoolId(@Param("schoolId") Integer schoolId);
20 22 /**
21 23 * 获取设备出入类型
22 24 * @param clint_id
... ... @@ -269,4 +271,6 @@ public interface UserDao {
269 271 List<AttendanceBean> queryClintList(@Param("schoolId") Integer schoolId,@Param("deviceId")String deviceId);
270 272  
271 273 List<String> queryStudentIdList(@Param("schoolId") Integer schoolId,@Param("roomId")Integer roomId);
  274 +
  275 + List<StudentBean> getStudentByClassId(@Param("schoolId") int schoolId,@Param("classIds") List<Integer> classIds);
272 276 }
... ...
cloud/dahua/src/main/java/com/example/dahua/service/UserOperateService.java
... ... @@ -12,6 +12,13 @@ public interface UserOperateService {
12 12 * 照片下发
13 13 */
14 14 void sendUserFaces(Integer schoolId,Integer userType,String deviceIds,Integer studentType,String sex);
  15 + /**
  16 + * 按班級下發
  17 + * @param schoolId
  18 + * @param classIds
  19 + * @param deviceIds
  20 + */
  21 + void sendFaceByClassId(Integer schoolId,String classIds,String deviceIds);
15 22  
16 23 void test6(Integer schoolId,Integer roomId,Integer type,Integer outof,String intime,String clintId,String startTime,String endTime);
17 24 }
... ...
cloud/dahua/src/main/java/com/example/dahua/service/imp/BaseService.java
... ... @@ -130,4 +130,19 @@ public class BaseService {
130 130 return;
131 131 }
132 132 }
  133 +
  134 + public List<StudentBean> getStudentByClassId(Integer schoolId,String classIds) {
  135 + List<Integer> list = new ArrayList<>();
  136 + if(!StringUtils.isEmpty(classIds)){
  137 + String[] msg = classIds.split(",");
  138 + for(String s : msg){
  139 + list.add(Integer.valueOf(s));
  140 + }
  141 + }
  142 + List<StudentBean> students = userDao.getStudentByClassId(schoolId,list);
  143 + //去重重复数据
  144 + List<StudentBean> studentList = students.stream().collect(Collectors.collectingAndThen(
  145 + Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(StudentBean::getStudent_num))), ArrayList::new));
  146 + return studentList;
  147 + }
133 148 }
... ...
cloud/dahua/src/main/java/com/example/dahua/service/imp/UserOperateServiceImpl.java
... ... @@ -7,6 +7,7 @@ import com.example.dahua.lib.CompressPic;
7 7 import com.example.dahua.lib.FilePath;
8 8 import com.example.dahua.service.UserOperateService;
9 9 import com.example.dahua.utils.DateFormatUtil;
  10 +import com.example.dahua.utils.DateUtils;
10 11 import com.example.dahua.utils.HttpUtils;
11 12 import com.example.dahua.xiananDao.SearchMapper;
12 13 import com.example.dahua.xiananDao.SendRecordDao;
... ... @@ -17,10 +18,8 @@ import org.springframework.util.CollectionUtils;
17 18 import org.springframework.util.StringUtils;
18 19  
19 20 import java.io.File;
20   -import java.util.ArrayList;
21   -import java.util.Arrays;
22   -import java.util.List;
23   -import java.util.UUID;
  21 +import java.util.*;
  22 +import java.util.stream.Collectors;
24 23  
25 24 /**
26 25 * 下发用户信息、人脸、卡、权限接口实现类
... ... @@ -49,27 +48,47 @@ public class UserOperateServiceImpl implements UserOperateService {
49 48 log.error("未选择下发设备");
50 49 return;
51 50 }
52   - //根据类型获取下发用户信息、文件名目录
53   - String typeName="";
54 51 List<StudentBean> studentBeanList = null;
55 52 if(userType.intValue()==2){
56   - typeName= "Student";
57 53 studentBeanList = baseService.getStudentList(schoolId,studentType,sex);
58 54 }else{
59   - typeName= "Teacher";
60 55 studentBeanList = baseService.getTeacherList(schoolId);
61 56 }
62 57 log.info("下发用户总数:"+studentBeanList.size());
  58 + //下發人臉
  59 + sendFace(studentBeanList,deviceList,schoolId,userType);
  60 + }
  61 +
  62 +
  63 + @Override
  64 + public void sendFaceByClassId(Integer schoolId,String classIds,String deviceIds) {
  65 + //下发设备集合
  66 + List<String> deviceList = new ArrayList<>();
  67 + if(StringUtils.isEmpty(deviceIds)){
  68 + deviceList = userDao.selectDeviceBySchoolId(schoolId);
  69 + }else{
  70 + String[] deviceArr = deviceIds.split(",");
  71 + deviceList= new ArrayList<>(Arrays.asList(deviceArr));
  72 + }
  73 + //根据类型获取下发用户信息
  74 + List<StudentBean> studentBeanList = baseService.getStudentByClassId(schoolId,classIds);
  75 + log.info("统计共有下发用户数量:{}",studentBeanList.size());
  76 + //下發人臉
  77 + sendFace(studentBeanList,deviceList,schoolId,2);
  78 + }
  79 +
  80 + private void sendFace(List<StudentBean> studentBeanList,List<String> deviceList,Integer schoolId,Integer userType){
63 81 for(StudentBean studentBean : studentBeanList){
64 82 try{
65 83 String photo= userType.intValue()==1?studentBean.getFace():studentBean.getPhoto();
66   - //以学籍号为名的文件名
67   - String fileName = photo.split(typeName +"/")[1];
68 84 //学籍号
69 85 String studentCode=userType.intValue()==1?studentBean.getNum():studentBean.getStudentcode();
70 86 if (StringUtils.isEmpty(photo) || StringUtils.isEmpty(studentCode)){
71 87 continue;
72 88 }
  89 + //以学籍号为名的文件名
  90 + String fileName = photo.substring(photo.lastIndexOf("/") + 1,photo.length());
  91 + String typeName = userType.intValue() ==1?"Teacher":"Student";
73 92 String filePath="";
74 93 //100服务器人脸照绝对路径
75 94 String path_1 = "E:\\wwwhtdocs\\SmartCampus\\face17e50\\School" + schoolId + "\\" + typeName;
... ... @@ -139,4 +158,21 @@ public class UserOperateServiceImpl implements UserOperateService {
139 158 }
140 159 }
141 160 }
  161 +
  162 + /**
  163 + * 下发时长统计下发截止时间
  164 + * 每条数据执行0.06分钟
  165 + * @param size 文件数
  166 + * @param clientNum 设备数
  167 + * @return
  168 + */
  169 + public String getTime(int size,int clientNum,int timeLength){
  170 + Date date = new Date();
  171 + if(clientNum ==0){
  172 + return DateUtils.date2String(date, DateUtils.format3);
  173 + }
  174 + Date afterDate = DateUtils.getDateByTime(timeLength,date);
  175 + String dateStr = DateUtils.date2String(afterDate,DateUtils.format3);
  176 + return dateStr;
  177 + }
142 178 }
... ...
cloud/dahua/src/main/java/com/example/dahua/utils/DateUtils.java
... ... @@ -2,6 +2,7 @@ package com.example.dahua.utils;
2 2  
3 3 import java.text.ParseException;
4 4 import java.text.SimpleDateFormat;
  5 +import java.util.Calendar;
5 6 import java.util.Date;
6 7  
7 8 /**
... ... @@ -68,4 +69,17 @@ public class DateUtils {
68 69 return difference;
69 70 }
70 71  
  72 + /**
  73 + * 获取N分钟后时间
  74 + * @param length
  75 + * @param date
  76 + * @return
  77 + */
  78 + public static Date getDateByTime(int length, Date date){
  79 + Calendar cal = Calendar.getInstance();
  80 + cal.setTime(date);//设置起时间
  81 + cal.add(Calendar.MINUTE,length);//把日期往后增加
  82 + return cal.getTime();
  83 + }
  84 +
71 85 }
... ...
cloud/dahua/src/main/java/com/example/dahua/utils/HttpUtils.java
... ... @@ -41,7 +41,6 @@ public class HttpUtils {
41 41 }
42 42 String targPath = FilePath.picPathComp + studentCode + ".jpg";
43 43 String url = "http://121.40.109.21:8991/file/uploadImg";
44   - //String url = "http://localhost:8991/file/uploadImg";
45 44 MultiValueMap<String, Object> multivaluedMap = new LinkedMultiValueMap<>();
46 45 HttpHeaders headers = new HttpHeaders();
47 46 RestTemplate restTemplate = new RestTemplate();
... ...
cloud/dahua/src/main/resources/mapper/usermapper.xml
... ... @@ -49,4 +49,15 @@
49 49 and StudentId in (select student_id from SZ_V_School_Student where school_id= #{schoolId}) order by newid()
50 50 </select>
51 51  
  52 + <select id="getStudentByClassId" resultType="com.example.dahua.bean.StudentBean">
  53 + select * from SZ_V_School_Student where school_id = #{schoolId}
  54 + <if test="classIds != null and classIds.size() >0">
  55 + and class_id in
  56 + <foreach item="item" collection="classIds" separator="," open="(" close=")" index="">
  57 + #{item}
  58 + </foreach>
  59 + </if>
  60 + and student_num != '' and photo !=''
  61 + </select>
  62 +
52 63 </mapper>
53 64 \ No newline at end of file
... ...
cloud/haikangface/src/main/java/com/sincere/haikangface/CMSServer.java
... ... @@ -24,13 +24,12 @@ import com.sincere.haikangface.xiananDao.SendRecordDao;
24 24 import com.sun.jna.NativeLong;
25 25 import com.sun.jna.Pointer;
26 26 import lombok.extern.slf4j.Slf4j;
  27 +import org.apache.commons.lang3.StringUtils;
27 28 import org.apache.http.util.TextUtils;
28 29 import org.springframework.beans.factory.annotation.Autowired;
29   -import org.springframework.beans.factory.annotation.Value;
30 30 import org.springframework.boot.ApplicationArguments;
31 31 import org.springframework.boot.ApplicationRunner;
32 32 import org.springframework.stereotype.Component;
33   -import org.springframework.util.StringUtils;
34 33 import org.springframework.web.client.RestTemplate;
35 34  
36 35 import java.io.*;
... ... @@ -386,8 +385,10 @@ public class CMSServer implements ApplicationRunner {
386 385 //人脸记录
387 386 saveFaceRecoder(deviceID, cardNo, time, picDataUrlId, currTemperature,outOrIn);
388 387 //944柯桥实验幼儿园,海康一体机考勤签到
389   - if(Integer.parseInt(schoolId)== 944 && !StringUtils.isEmpty(cardNo) && isNumeric(cardNo)){
390   - kaoQinRecord(outOrIn,cardNo,deviceID,time);
  388 + if(StringUtils.isNotBlank(schoolId)){
  389 + if(Integer.parseInt(schoolId)== 944 && !StringUtils.isEmpty(cardNo) && isNumeric(cardNo)){
  390 + kaoQinRecord(outOrIn,cardNo,deviceID,time);
  391 + }
391 392 }
392 393 break;
393 394 case "0x426"://人证设备在线
... ... @@ -401,16 +402,20 @@ public class CMSServer implements ApplicationRunner {
401 402 log.info("人证比对通过,事件次类型:"+minorType);
402 403 saveFaceRecoder(deviceID, cardNo, time, picDataUrlId, currTemperature,outOrIn);
403 404 //944柯桥实验幼儿园,海康一体机考勤签到
404   - if(Integer.parseInt(schoolId)== 944 && !StringUtils.isEmpty(cardNo)&& isNumeric(cardNo)){
405   - kaoQinRecord(outOrIn,cardNo,deviceID,time);
  405 + if(StringUtils.isNotBlank(schoolId)){
  406 + if(Integer.parseInt(schoolId)== 944 && !StringUtils.isEmpty(cardNo) && isNumeric(cardNo)){
  407 + kaoQinRecord(outOrIn,cardNo,deviceID,time);
  408 + }
406 409 }
407 410 break;
408 411 case "0x6":
409 412 log.info("通过,事件次类型:"+minorType);
410 413 saveFaceRecoder(deviceID, cardNo, time, picDataUrlId, currTemperature,outOrIn);
411 414 //944柯桥实验幼儿园,海康一体机考勤签到
412   - if(Integer.parseInt(schoolId)== 944 && !StringUtils.isEmpty(cardNo) && isNumeric(cardNo)){
413   - kaoQinRecord(outOrIn,cardNo,deviceID,time);
  415 + if(StringUtils.isNotBlank(schoolId)){
  416 + if(Integer.parseInt(schoolId)== 944 && !StringUtils.isEmpty(cardNo) && isNumeric(cardNo)){
  417 + kaoQinRecord(outOrIn,cardNo,deviceID,time);
  418 + }
414 419 }
415 420 break;
416 421 }
... ...
cloud/haikangface/src/main/java/com/sincere/haikangface/control/UserOperateController.java
... ... @@ -123,4 +123,13 @@ public class UserOperateController {
123 123 @RequestParam("faceSrcPath") String faceSrcPath){
124 124 return userOperateService.exportFace(schoolId,userType,deviceIds,faceSrcPath);
125 125 }
  126 +
  127 + @ApiOperation(value = "按班级指定下发")
  128 + @RequestMapping(value = "sendFaceByClassId", method = RequestMethod.POST)
  129 + public Result exportFace(@RequestParam("schoolId") Integer schoolId,
  130 + @RequestParam(value = "classIds",required = false) String classIds,
  131 + @RequestParam(value = "deviceIds",required = false) String deviceIds,
  132 + @RequestParam(value = "isCheck",required = false) Integer isCheck){
  133 + return userOperateService.sendFaceByClassId(schoolId,classIds,deviceIds,isCheck);
  134 + }
126 135 }
... ...
cloud/haikangface/src/main/java/com/sincere/haikangface/dao/DeviceDao.java
... ... @@ -22,7 +22,10 @@ public interface DeviceDao {
22 22 int addDevide(@Param("clint_id") String clint_id, @Param("clint_type") String clint_type, @Param("intime") String intime, @Param("school_id") String school_id,
23 23 @Param("state") String state, @Param("isConnection") String isConnection);
24 24  
25   - @Select("select * from SZ_Attendance where clint_id = #{clint_id}")
  25 + @Select("select * from SZ_Attendance where school_id = #{schoolId} and clint_type = 18")
  26 + List<String> selectDeviceBySchoolId(@Param("schoolId") Integer schoolId);
  27 +
  28 + @Select("select clint_id from SZ_Attendance where clint_id = #{clint_id}")
26 29 AttendanceBean selectDevice(@Param("clint_id") String clint_id);
27 30  
28 31 // @Select("select * from SZ_Attendance where IsKaoqin = #{IsKaoqin}")
... ...
cloud/haikangface/src/main/java/com/sincere/haikangface/dao/UserDao.java
... ... @@ -235,7 +235,6 @@ public interface UserDao {
235 235  
236 236 List<String> getStudentCard(@Param("schoolId") int schoolId , @Param("studentType") int studentType, @Param("sex") List<Integer> sex);
237 237  
238   -
239 238 List<String> getDeviceRoomRelation(@Param("clint_id") String clint_id);
240 239  
241 240 void insertBaiduFaceRecorder(BaiduFaceRecorder baiduFaceRecorder);
... ... @@ -266,6 +265,8 @@ public interface UserDao {
266 265  
267 266 List<StudentBean> getTeacherList(@Param("schoolId") Integer schoolId);
268 267  
  268 + List<StudentBean> getStudentByClassId(@Param("schoolId") int schoolId,@Param("classIds") List<Integer> classIds);
  269 +
269 270 List<String> getDeviceIds(@Param("schoolId") Integer schoolId,@Param("deviceId") String deviceId);
270 271  
271 272 void updateUser(@Param("userId") String userId,@Param("face") String face);
... ...
cloud/haikangface/src/main/java/com/sincere/haikangface/service/UserOperateService.java
... ... @@ -105,4 +105,6 @@ public interface UserOperateService {
105 105 Result insertUpdateCard(String cardNums);
106 106  
107 107 Result exportFace(Integer schoolId,Integer userType,String deviceIds,String faceSrcPath);
  108 +
  109 + Result sendFaceByClassId(Integer schoolId,String classIds,String deviceIds,Integer isCheck);
108 110 }
... ...
cloud/haikangface/src/main/java/com/sincere/haikangface/service/impl/BaseService.java
... ... @@ -12,6 +12,7 @@ import com.sincere.haikangface.enums.EnumSzBusinessType;
12 12 import com.sincere.haikangface.utils.CompressPic;
13 13 import com.sincere.haikangface.utils.DateUtils;
14 14 import com.sincere.haikangface.utils.FileUtils;
  15 +import com.sincere.haikangface.utils.HttpUtil;
15 16 import com.sincere.haikangface.xiananDao.SendRecordDao;
16 17 import lombok.extern.slf4j.Slf4j;
17 18 import org.apache.commons.lang3.StringUtils;
... ... @@ -304,18 +305,15 @@ public class BaseService {
304 305 for(StudentBean studentBean : studentBeanList){
305 306 try{
306 307 String userName= studentBean.getName();
  308 + String userId = studentBean.getUser_id();
307 309 String photo = userType.intValue()==1?studentBean.getFace():studentBean.getPhoto();
308 310 String cardNum =userType.intValue()==1?studentBean.getTeacher_num():studentBean.getStudent_num();
309 311 String typeName=userType.intValue()==1?"Teacher":"Student";
310 312 if (StringUtils.isBlank(photo) || StringUtils.isBlank(cardNum)){
311 313 continue;
312 314 }
313   - String[] fileNameStr = photo.split(typeName +"/");
314   - if(fileNameStr.length==0){
315   - continue;
316   - }
317 315 //以学籍号为名的文件名
318   - String fileName = fileNameStr[1];
  316 + String fileName = photo.substring(photo.lastIndexOf("/") + 1,photo.length());
319 317 //100服务器人脸照绝对路径
320 318 String path_1 = "E:\\wwwhtdocs\\SmartCampus\\face17e50\\School" + schoolId + "\\" + typeName;
321 319 String path_2 = "E:\\wwwhtdocs\\SmartCampus\\face17e5\\School" + schoolId + "\\" + typeName;
... ... @@ -331,7 +329,6 @@ public class BaseService {
331 329 if(photo.indexOf("face17e50")!=-1){
332 330 filePath = path_1 + "\\" + fileName;
333 331 }
334   - log.info("卡号:{},人脸路径:{}, ",cardNum,filePath);
335 332 File file = new File(filePath);//图片
336 333 if(file.exists()){
337 334 String targetPath = FileUtils.picPathComp + file.getName();
... ... @@ -342,14 +339,16 @@ public class BaseService {
342 339 continue;
343 340 }
344 341 for(String sno : deviceIds){
345   - if(cmsServer.getIsDeviceOnline(sno)){
346   - if(!StringUtils.isBlank(cardNum)){
347   - String cardNumLong = Long.parseLong(getCard(cardNum),16) + "";
348   - //下发100海康设备
349   - sendUserAsync.sendStuToHaiKang(file.getAbsolutePath(),targetPath,cardNumLong, startTime, endTime, validTimeEnabled, userName, sno, String.valueOf(userType),schoolId,cardNum);
  342 + if(sendRecordDao.getRecordIsExit(sno,cardNum,userId).size()<1){
  343 + if(cmsServer.getIsDeviceOnline(sno)){
  344 + if(!StringUtils.isBlank(cardNum)){
  345 + String cardNumLong = Long.parseLong(getCard(cardNum),16) + "";
  346 + //下发100海康设备
  347 + sendUserAsync.sendStuToHaiKang(file.getAbsolutePath(),targetPath,cardNumLong, startTime, endTime, validTimeEnabled, userName, sno, String.valueOf(userType),schoolId,cardNum);
  348 + }
  349 + }else{
  350 + log.error("100服务器,设备不在线");
350 351 }
351   - }else{
352   - log.error("100服务器,设备不在线");
353 352 }
354 353 }
355 354 }
... ... @@ -362,7 +361,6 @@ public class BaseService {
362 361  
363 362 protected void sendFaceToDevice253(List<String> deviceIds,List<StudentBean> studentBeanList,Integer schoolId,Integer userType){
364 363 log.info("------------------------开始执行253服务,人脸照下发---------------------");
365   -
366 364 String startTime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date());
367 365 Calendar calendar = Calendar.getInstance();
368 366 calendar.add(Calendar.YEAR, 10);
... ... @@ -372,18 +370,15 @@ public class BaseService {
372 370 for(StudentBean studentBean : studentBeanList){
373 371 try{
374 372 String userName= studentBean.getName();
  373 + String userId = studentBean.getUser_id();
375 374 String photo = userType.intValue()==1?studentBean.getFace():studentBean.getPhoto();
376 375 String cardNum =userType.intValue()==1?studentBean.getTeacher_num():studentBean.getStudent_num();
377 376 String typeName=userType.intValue()==1?"Teacher":"Student";
378 377 if (StringUtils.isBlank(photo) || StringUtils.isBlank(cardNum)){
379 378 continue;
380 379 }
381   - String[] fileNameStr = photo.split(typeName +"/");
382   - if(fileNameStr.length==0){
383   - continue;
384   - }
385 380 //以学籍号为名的文件名
386   - String fileName = fileNameStr[1];
  381 + String fileName = photo.substring(photo.lastIndexOf("/") + 1,photo.length());
387 382 //100服务器人脸照绝对路径
388 383 String path_1 = "E:\\wwwhtdocs\\SmartCampus\\face17e50\\School" + schoolId + "\\" + typeName;
389 384 String path_2 = "E:\\wwwhtdocs\\SmartCampus\\face17e5\\School" + schoolId + "\\" + typeName;
... ... @@ -399,7 +394,6 @@ public class BaseService {
399 394 if(photo.indexOf("face17e50")!=-1){
400 395 filePath = path_1 + "\\" + fileName;
401 396 }
402   - log.info("卡号:{},人脸路径:{}, ",cardNum,filePath);
403 397 File file = new File(filePath);//图片
404 398 if(file.exists()) {
405 399 String targetPath = FileUtils.picPathComp + file.getName();
... ... @@ -410,8 +404,10 @@ public class BaseService {
410 404 continue;
411 405 }
412 406 for (String sno : deviceIds) {
413   - //下发253服务器
414   - sendUserAsync.uploadImgs(targetPath,cardNum, userName, sno, startTime, endTime, validTimeEnabled, String.valueOf(userType),schoolId);
  407 + if(sendRecordDao.getRecordIsExit(sno,cardNum,userId).size()<1){
  408 + //下发253服务器
  409 + sendUserAsync.uploadImgs(targetPath,cardNum, userName, sno, startTime, endTime, validTimeEnabled, String.valueOf(userType),schoolId);
  410 + }
415 411 }
416 412 }
417 413 }catch (Exception e){
... ... @@ -454,6 +450,21 @@ public class BaseService {
454 450 return studentList;
455 451 }
456 452  
  453 + public List<StudentBean> getStudentByClassId(Integer schoolId,String classIds) {
  454 + List<Integer> list = new ArrayList<>();
  455 + if(StringUtils.isNotBlank(classIds)){
  456 + String[] msg = classIds.split(",");
  457 + for(String s : msg){
  458 + list.add(Integer.valueOf(s));
  459 + }
  460 + }
  461 + List<StudentBean> students = userDao.getStudentByClassId(schoolId,list);
  462 + //去重重复数据
  463 + List<StudentBean> studentList = students.stream().collect(Collectors.collectingAndThen(
  464 + Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(StudentBean::getStudent_num))), ArrayList::new));
  465 + return studentList;
  466 + }
  467 +
457 468 /**
458 469 * 获取学校下学生数据
459 470 * @param schoolId
... ...
cloud/haikangface/src/main/java/com/sincere/haikangface/service/impl/UserOperateServiceImpl.java
... ... @@ -26,6 +26,7 @@ import java.io.FileOutputStream;
26 26 import java.io.IOException;
27 27 import java.nio.file.Files;
28 28 import java.util.*;
  29 +import java.util.stream.Collectors;
29 30  
30 31 /**
31 32 * 海康设备用户操作业务实现
... ... @@ -216,7 +217,7 @@ public class UserOperateServiceImpl implements UserOperateService {
216 217 return ResultGenerator.genSuccessResult("文件名为空");
217 218 }
218 219 //以学籍号为名的文件名
219   - String fileName = fileNameStr[1];
  220 + String fileName = photo.substring(photo.lastIndexOf("/") + 1,photo.length());
220 221 //100服务器人脸照绝对路径
221 222 String path_1 = "E:\\wwwhtdocs\\SmartCampus\\face17e50\\School" + schoolId + "\\" + typeName;
222 223 String path_2 = "E:\\wwwhtdocs\\SmartCampus\\face17e5\\School" + schoolId + "\\" + typeName;
... ... @@ -232,8 +233,7 @@ public class UserOperateServiceImpl implements UserOperateService {
232 233 if(photo.indexOf("face17e50")!=-1){
233 234 filePath = path_1 + "\\" + fileName;
234 235 }
235   - log.info("卡号:{},人脸路径:{}, ",cardNum,filePath);
236   - //校验100服务上是否存在此人脸
  236 + //校验100服务文件存储地址上是否存在此人脸
237 237 File file = new File(filePath.trim());//图片
238 238 if (!file.exists()) {
239 239 log.error("文件不存在:" + filePath);
... ... @@ -413,12 +413,8 @@ public class UserOperateServiceImpl implements UserOperateService {
413 413 //不在线,去253服务器上删除
414 414 HttpUtil.deleteCard(deviceId, cardNum);
415 415 }
416   - String[] fileNameStr = photo.split(typeName +"/");
417   - if(fileNameStr.length==0){
418   - continue;
419   - }
420 416 //以学籍号为名的文件名
421   - String fileName = fileNameStr[1];
  417 + String fileName = photo.substring(photo.lastIndexOf("/") + 1,photo.length());
422 418 //100服务器人脸照绝对路径
423 419 String path_1 = "E:\\wwwhtdocs\\SmartCampus\\face17e50\\School" + schoolId + "\\" + typeName;
424 420 String path_2 = "E:\\wwwhtdocs\\SmartCampus\\face17e5\\School" + schoolId + "\\" + typeName;
... ... @@ -433,7 +429,6 @@ public class UserOperateServiceImpl implements UserOperateService {
433 429 if(photo.indexOf("face17e50")!=-1){
434 430 filePath = path_1 + "\\" + fileName;
435 431 }
436   - log.info("卡号:{},人脸路径:{}, ",cardNum,filePath);
437 432 File file = new File(filePath);//图片
438 433 if(file.exists()){
439 434 String targetPath = FileUtils.picPathComp + file.getName();
... ... @@ -572,12 +567,8 @@ public class UserOperateServiceImpl implements UserOperateService {
572 567 continue;
573 568 }
574 569 String typeName= userType.intValue()==1?"Teacher":"Student";
575   - String[] fileNameStr = photo.split(typeName +"/");
576   - if(fileNameStr.length==0){
577   - continue;
578   - }
579 570 //以学籍号为名的文件名
580   - String fileName = fileNameStr[1];
  571 + String fileName = photo.substring(photo.lastIndexOf("/") + 1,photo.length());
581 572 //100服务器人脸照绝对路径
582 573 String path_1 = "E:\\wwwhtdocs\\SmartCampus\\face17e50\\School" + schoolId + "\\" + typeName;
583 574 String path_2 = "E:\\wwwhtdocs\\SmartCampus\\face17e5\\School" + schoolId + "\\" + typeName;
... ... @@ -596,7 +587,6 @@ public class UserOperateServiceImpl implements UserOperateService {
596 587 if(filePath.indexOf("?v=")!=-1){
597 588 filePath = filePath.split("\\?")[0];
598 589 }
599   - log.info("卡号:{},人脸路径:{}",cardNum,filePath);
600 590 File file = new File(filePath);//图片
601 591 if(file.exists()){
602 592 String targetPath = FileUtils.picPathComp + file.getName();
... ... @@ -657,7 +647,6 @@ public class UserOperateServiceImpl implements UserOperateService {
657 647 String fileName = studentCode + ".png";
658 648 //人脸文件路径
659 649 String facePath = path + "\\" +fileName;
660   - log.info("卡号:{}, 人脸路径:{}, ",cardNum,facePath);
661 650 try {
662 651 File absolutePath = new File(facePath);
663 652 FileOutputStream fileOutputStream = new FileOutputStream(absolutePath);
... ... @@ -826,4 +815,59 @@ public class UserOperateServiceImpl implements UserOperateService {
826 815 e.printStackTrace();
827 816 }
828 817 }
  818 +
  819 + @Override
  820 + public Result sendFaceByClassId(Integer schoolId,String classIds,String deviceIds,Integer isCheck) {
  821 + //下发设备集合
  822 + List<String> deviceList = new ArrayList<>();
  823 + if(StringUtils.isBlank(deviceIds)){
  824 + deviceList = deviceDao.selectDeviceBySchoolId(schoolId);
  825 + }else{
  826 + String[] deviceArr = deviceIds.split(",");
  827 + deviceList= new ArrayList<>(Arrays.asList(deviceArr));
  828 + }
  829 + List<StudentBean> resultCard = new ArrayList<>();
  830 + List<String> resultDevices = new ArrayList<>();
  831 + //根据类型获取下发用户信息
  832 + List<StudentBean> studentBeanList = baseService.getStudentByClassId(schoolId,classIds);
  833 + log.info("统计共有下发用户数量:{}",studentBeanList.size());
  834 + if(isCheck !=null){
  835 + for(StudentBean studentBean : studentBeanList){
  836 + String cardNum = studentBean.getStudent_num();
  837 + boolean isOk = true;
  838 + for(String deviceId : deviceList){
  839 + if (cmsServer.getIsDeviceOnline(deviceId)) {
  840 + String cardNo = Long.parseLong(baseService.getCard(cardNum), 16) + "";
  841 + isOk = cmsServer.getFace(deviceId,cardNo,null);
  842 + }else{
  843 + isOk = HttpUtil.deleteCard(deviceId, cardNum);
  844 + }
  845 + if(!isOk){
  846 + resultCard.add(studentBean);
  847 + resultCard.add(studentBean);
  848 + resultDevices.add(deviceId);
  849 + }
  850 + }
  851 + }
  852 + //去重重复数据
  853 + studentBeanList = resultCard.stream().collect(Collectors.collectingAndThen(
  854 + Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(StudentBean::getStudent_num))), ArrayList::new));
  855 + //去重重复数据
  856 + deviceList = resultDevices.stream().distinct().collect(Collectors.toList());
  857 + }
  858 + //发送海康设备:异步执行
  859 + baseService.sendUserFaceByAsyncThread(schoolId,2,studentBeanList,deviceList);
  860 +
  861 + int fileSize = studentBeanList.size();
  862 + int clintNum = deviceList.size();
  863 + //下发所用时长
  864 + int timeLength = new Double(clintNum * fileSize * 0.06).intValue();
  865 + //下发截止时间
  866 + String dateStr = baseService.getTime(fileSize,clintNum,timeLength);
  867 + Map map = new HashMap();
  868 + map.put("timeLength",timeLength);
  869 + map.put("afterDate",dateStr);
  870 + map.put("fileSize",fileSize);
  871 + return ResultGenerator.genSuccessResult(objectMapper.toJson(map));
  872 + }
829 873 }
... ...
cloud/haikangface/src/main/resources/mapper/usermapper.xml
... ... @@ -77,6 +77,17 @@
77 77 and student_num != '' and photo !=''
78 78 </select>
79 79  
  80 + <select id="getStudentByClassId" resultType="com.sincere.haikangface.bean.StudentBean">
  81 + select * from SZ_V_School_Student where school_id = #{schoolId}
  82 + <if test="classIds != null and classIds.size() >0">
  83 + and class_id in
  84 + <foreach item="item" collection="classIds" separator="," open="(" close=")" index="">
  85 + #{item}
  86 + </foreach>
  87 + </if>
  88 + and student_num != '' and photo !=''
  89 + </select>
  90 +
80 91 <select id="getStudentCardGroup" resultType="com.sincere.haikangface.bean.StudentBean">
81 92 select * from SZ_V_School_Student where sex = #{sex} and student_type = #{studentType} and
82 93 class_id in(select DISTINCT ClassId from SZ_OneCardGrouping where Pid = #{groupId} and state = 1)
... ...