diff --git a/cloud/dahua/src/main/java/com/example/dahua/MyTask.java b/cloud/dahua/src/main/java/com/example/dahua/MyTask.java index d4a3fd7..1cb945e 100644 --- a/cloud/dahua/src/main/java/com/example/dahua/MyTask.java +++ b/cloud/dahua/src/main/java/com/example/dahua/MyTask.java @@ -672,8 +672,8 @@ public class MyTask implements ApplicationRunner { //考勤成功 String content = "考勤成功!,设备:" + deviceId + "卡号:" + cardNo + "方向:" + (eventType == 1 ? "进门" : "出门") + "______" + eventTime; - //开始推送看板 - sendMQMess(deviceId,cardNo,eventType); +// //开始推送看板 +// sendMQMess(deviceId,cardNo,eventType); //记录学生考勤签到记录 FileUtils.getInstance().writeLogs(content, FileUtils.qiandaoSuccess); diff --git a/cloud/dahua/src/main/java/com/example/dahua/mqtt/MqttManager.java b/cloud/dahua/src/main/java/com/example/dahua/mqtt/MqttManager.java index 71a9796..a6a5fb4 100644 --- a/cloud/dahua/src/main/java/com/example/dahua/mqtt/MqttManager.java +++ b/cloud/dahua/src/main/java/com/example/dahua/mqtt/MqttManager.java @@ -21,75 +21,75 @@ public class MqttManager { private static int qosLevel; public void init() { - final String brokerUrl = "tcp://post-cn-4590mq2hr03.mqtt.aliyuncs.com:1883"; - groupId = "GID_HFJSIURFHAQO110"; - topic = "Topic_Quene_Test"; - qosLevel = 1; - final Boolean cleanSession = false; - String clientId = groupId + "@@@9ED96FB6D72C1698"; - accessKey = "UimvLVp0Wj90P88u"; - String secretKey = "TE4rZenITG27tiQqHx9qINjx71Nws7"; - final MemoryPersistence memoryPersistence = new MemoryPersistence(); - if (null == mqttClient) { - try { - mqttClient = new MqttClient(brokerUrl, clientId, memoryPersistence); - } catch (MqttException e) { - e.printStackTrace(); - } - MqttConnectOptions connOpts = new MqttConnectOptions(); - //cal the sign as password,sign=BASE64(MAC.SHA1(groupId,secretKey)) - try { - sign = Tools.macSignature(clientId.split("@@@")[0], secretKey); - } catch (InvalidKeyException e) { - e.printStackTrace(); - } catch (NoSuchAlgorithmException e) { - e.printStackTrace(); - } - connOpts.setUserName(accessKey); - connOpts.setPassword(sign.toCharArray()); - connOpts.setCleanSession(cleanSession); - connOpts.setKeepAliveInterval(90); - connOpts.setAutomaticReconnect(true); - mqttClient.setCallback(new MqttCallbackExtended() { - @Override - public void connectComplete(boolean reconnect, String serverURI) { - System.out.println("connect success"); - } - - @Override - public void connectionLost(Throwable throwable) { - System.out.println("connect lost:" + throwable.toString()); - throwable.printStackTrace(); - init();//初始化 - } - - @Override - public void messageArrived(String s, MqttMessage mqttMessage) throws Exception { - System.out.println("receive msg from topic " + s + " , body is " + new String(mqttMessage.getPayload())); - } - - @Override - public void deliveryComplete(IMqttDeliveryToken iMqttDeliveryToken) { - //this notice make sense when qos >0 -// System.out.println("send msg succeed"); - } - }); - try { - mqttClient.connect(connOpts); - } catch (MqttException e) { - System.out.println("mqtt:" + e.toString()); - e.printStackTrace(); - } - /*while (true){ - sendMessageTest("528C8E6CD4A3C659","zy105387",0); - try { - Thread.sleep(10000); - } catch (InterruptedException e) { - System.out.println("connect success:"+e); - e.printStackTrace(); - } - }*/ - } +// final String brokerUrl = "tcp://post-cn-4590mq2hr03.mqtt.aliyuncs.com:1883"; +// groupId = "GID_HFJSIURFHAQO110"; +// topic = "Topic_Quene_Test"; +// qosLevel = 1; +// final Boolean cleanSession = false; +// String clientId = groupId + "@@@9ED96FB6D72C1698"; +// accessKey = "UimvLVp0Wj90P88u"; +// String secretKey = "TE4rZenITG27tiQqHx9qINjx71Nws7"; +// final MemoryPersistence memoryPersistence = new MemoryPersistence(); +// if (null == mqttClient) { +// try { +// mqttClient = new MqttClient(brokerUrl, clientId, memoryPersistence); +// } catch (MqttException e) { +// e.printStackTrace(); +// } +// MqttConnectOptions connOpts = new MqttConnectOptions(); +// //cal the sign as password,sign=BASE64(MAC.SHA1(groupId,secretKey)) +// try { +// sign = Tools.macSignature(clientId.split("@@@")[0], secretKey); +// } catch (InvalidKeyException e) { +// e.printStackTrace(); +// } catch (NoSuchAlgorithmException e) { +// e.printStackTrace(); +// } +// connOpts.setUserName(accessKey); +// connOpts.setPassword(sign.toCharArray()); +// connOpts.setCleanSession(cleanSession); +// connOpts.setKeepAliveInterval(90); +// connOpts.setAutomaticReconnect(true); +// mqttClient.setCallback(new MqttCallbackExtended() { +// @Override +// public void connectComplete(boolean reconnect, String serverURI) { +// System.out.println("connect success"); +// } +// +// @Override +// public void connectionLost(Throwable throwable) { +// System.out.println("connect lost:" + throwable.toString()); +// throwable.printStackTrace(); +// init();//初始化 +// } +// +// @Override +// public void messageArrived(String s, MqttMessage mqttMessage) throws Exception { +// System.out.println("receive msg from topic " + s + " , body is " + new String(mqttMessage.getPayload())); +// } +// +// @Override +// public void deliveryComplete(IMqttDeliveryToken iMqttDeliveryToken) { +// //this notice make sense when qos >0 +//// System.out.println("send msg succeed"); +// } +// }); +// try { +// mqttClient.connect(connOpts); +// } catch (MqttException e) { +// System.out.println("mqtt:" + e.toString()); +// e.printStackTrace(); +// } +// /*while (true){ +// sendMessageTest("528C8E6CD4A3C659","zy105387",0); +// try { +// Thread.sleep(10000); +// } catch (InterruptedException e) { +// System.out.println("connect success:"+e); +// e.printStackTrace(); +// } +// }*/ +// } } public void sendMq(String deviceId, String cmd) { diff --git a/cloud/haikangface/src/main/java/com/sincere/haikangface/CMSServer.java b/cloud/haikangface/src/main/java/com/sincere/haikangface/CMSServer.java index 01dc82e..9e36247 100644 --- a/cloud/haikangface/src/main/java/com/sincere/haikangface/CMSServer.java +++ b/cloud/haikangface/src/main/java/com/sincere/haikangface/CMSServer.java @@ -245,13 +245,6 @@ public class CMSServer implements ApplicationRunner { } pInBuffer.dwSize = pInBuffer.size(); saveAttendance(deviceId); - /*这里加判断即可,可以通过byDeviceID、sDeviceSerial、sDevName 进行判断 - if(strDevRegInfo.dwDevType == 1) { - pInBuffer.dwAlarmServerType = 3; - } else{ - pInBuffer.dwAlarmServerType = 1; - } - */ byte[] byIP = ip_cloud.getBytes(); System.arraycopy(byIP, 0, pInBuffer.struUDPAlarmSever.szIP, 0, byIP.length); // TODO: 2020/8/27 人脸机类型为0 @@ -1052,7 +1045,7 @@ public class CMSServer implements ApplicationRunner { deviceDao.updateDeviceStatu(1,inTime,deviceId); } else { deviceDao.addDevide(attendanceBean.getClint_id(), attendanceBean.getClint_type(), attendanceBean.getIntime(), - attendanceBean.getSchool_id(), attendanceBean.getState() + "", attendanceBean.getIsConnection() + ""); + attendanceBean.getSchool_id(),attendanceBean.getState() + "", attendanceBean.getIsConnection() + ""); } } } diff --git a/cloud/haikangface/src/main/java/com/sincere/haikangface/async/SendUserAsync.java b/cloud/haikangface/src/main/java/com/sincere/haikangface/async/SendUserAsync.java index 0358918..ec304ac 100644 --- a/cloud/haikangface/src/main/java/com/sincere/haikangface/async/SendUserAsync.java +++ b/cloud/haikangface/src/main/java/com/sincere/haikangface/async/SendUserAsync.java @@ -55,7 +55,8 @@ public class SendUserAsync { * @param deviceId * @param userType */ - public void sendStuToHaiKang(String srcFile, String picUrl, String card, String startTime, String endTime, int validTimeEnabled, String name, String deviceId, String userType,Integer schoolId,String cardNum) { + public void sendStuToHaiKang(String srcFile, String picUrl, String card, String startTime, String endTime, + int validTimeEnabled, String name, String deviceId, String userType,Integer schoolId,String cardNum) { //1、检测图片是否合格 boolean check = true; if (check) {//合格 @@ -70,25 +71,6 @@ public class SendUserAsync { String resultCard = getCard(String.format("%08x", lon)).toUpperCase(); //系统时间 String time = System.currentTimeMillis() + ""; - //1老师;2学生 - if (Integer.parseInt(userType) ==EnumSzBusinessType.EnumUserType.TEACHER.code) { - //根据卡号获取老师信息 - StudentBean studentBean = userDao.getTeacherWithCard(resultCard,schoolId); - if (null == studentBean) { - employeeNo = time.substring(time.length() - 6, time.length()); - } else{ - employeeNo = studentBean.getTeacher_id(); - } - } - if (Integer.parseInt(userType) == EnumSzBusinessType.EnumUserType.STUDENT.code) { - //根据卡号获取学生信息 - StudentBean studentBean = userDao.getStudentWithCard(resultCard,schoolId); - if (null == studentBean) { - employeeNo = time.substring(time.length() - 6, time.length()); - } else{ - employeeNo = studentBean.getStudent_id(); - } - } //设置卡权限计划模板 cmsServer.SetCardWeekPlan(deviceId, card, userType, HKXmlUtils.getInstance().SetCardTemplate(), "设置卡权限计划模板",schoolId,cardNum); //设置卡权限周计划 diff --git a/cloud/haikangface/src/main/java/com/sincere/haikangface/bean/SendRecordBean.java b/cloud/haikangface/src/main/java/com/sincere/haikangface/bean/SendRecordBean.java index 6cde8e2..9ddb9df 100644 --- a/cloud/haikangface/src/main/java/com/sincere/haikangface/bean/SendRecordBean.java +++ b/cloud/haikangface/src/main/java/com/sincere/haikangface/bean/SendRecordBean.java @@ -1,20 +1,24 @@ package com.sincere.haikangface.bean; +import lombok.Data; + import java.io.Serializable; /** * 人脸下发记录 */ +@Data public class SendRecordBean implements Serializable { - private String customerid;//用户编号 private String Num; private String Name; - private int schoolId; + private Integer schoolId; + + private String userId; private String schoolName;//下发结果 @@ -22,117 +26,13 @@ public class SendRecordBean implements Serializable { private String imgPath;//下发的图片路径 - private int userType; + private Integer userType; private String time; private String failContent; private int failType; - - - public String getCustomerid() { - return customerid; - } - - public void setCustomerid(String customerid) { - this.customerid = customerid; - } - - public String getNum() { - return Num; - } - - public void setNum(String num) { - Num = num; - } - - public String getName() { - return Name; - } - - public void setName(String name) { - Name = name; - } - - public int getSchoolId() { - return schoolId; - } - - public void setSchoolId(int schoolId) { - this.schoolId = schoolId; - } - - public String getSchoolName() { - return schoolName; - } - - public void setSchoolName(String schoolName) { - this.schoolName = schoolName; - } - - public String getDeviceID() { - return deviceID; - } - - public void setDeviceID(String deviceID) { - this.deviceID = deviceID; - } - - public String getImgPath() { - return imgPath; - } - - public void setImgPath(String imgPath) { - this.imgPath = imgPath; - } - - public int getUserType() { - return userType; - } - - public void setUserType(int userType) { - this.userType = userType; - } - - public String getTime() { - return time; - } - - public void setTime(String time) { - this.time = time; - } - - public String getFailContent() { - return failContent; - } - - public void setFailContent(String failContent) { - this.failContent = failContent; - } - - public int getFailType() { - return failType; - } - - public void setFailType(int failType) { - this.failType = failType; - } - - @Override - public String toString() { - return "SendRecordBean{" + - "customerid='" + customerid + '\'' + - ", Num='" + Num + '\'' + - ", Name='" + Name + '\'' + - ", schoolId=" + schoolId + - ", schoolName='" + schoolName + '\'' + - ", deviceID='" + deviceID + '\'' + - ", imgPath='" + imgPath + '\'' + - ", userType=" + userType + - ", time='" + time + '\'' + - ", failContent='" + failContent + '\'' + - ", failType=" + failType + - '}'; - } -} + //1成功2失败 + private Integer status; +} \ No newline at end of file diff --git a/cloud/haikangface/src/main/java/com/sincere/haikangface/bean/face/AuthRecordDto.java b/cloud/haikangface/src/main/java/com/sincere/haikangface/bean/face/AuthRecordDto.java index dbbaffc..50c73d2 100644 --- a/cloud/haikangface/src/main/java/com/sincere/haikangface/bean/face/AuthRecordDto.java +++ b/cloud/haikangface/src/main/java/com/sincere/haikangface/bean/face/AuthRecordDto.java @@ -2,6 +2,7 @@ package com.sincere.haikangface.bean.face; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; +import lombok.Data; import java.util.List; @@ -10,6 +11,7 @@ import java.util.List; * @author xuquan * @date 2020/12/16 09:10 */ +@Data @ApiModel public class AuthRecordDto { @@ -27,60 +29,4 @@ public class AuthRecordDto { private List weekDays ; @ApiModelProperty("权限类型1微耕权限2人脸机权限") private Integer authType; - - public Integer getId() { - return id; - } - - public void setId(Integer id) { - this.id = id; - } - - public Integer getType() { - return type; - } - - public void setType(Integer type) { - this.type = type; - } - - public Integer getSchoolId() { - return schoolId; - } - - public void setSchoolId(Integer schoolId) { - this.schoolId = schoolId; - } - - public List getSnList() { - return snList; - } - - public void setSnList(List snList) { - this.snList = snList; - } - - public Integer getStudentType() { - return studentType; - } - - public void setStudentType(Integer studentType) { - this.studentType = studentType; - } - - public List getWeekDays() { - return weekDays; - } - - public void setWeekDays(List weekDays) { - this.weekDays = weekDays; - } - - public Integer getAuthType() { - return authType; - } - - public void setAuthType(Integer authType) { - this.authType = authType; - } } diff --git a/cloud/haikangface/src/main/java/com/sincere/haikangface/bean/face/PermissionBean.java b/cloud/haikangface/src/main/java/com/sincere/haikangface/bean/face/PermissionBean.java index 814474d..21b260c 100644 --- a/cloud/haikangface/src/main/java/com/sincere/haikangface/bean/face/PermissionBean.java +++ b/cloud/haikangface/src/main/java/com/sincere/haikangface/bean/face/PermissionBean.java @@ -1,10 +1,12 @@ package com.sincere.haikangface.bean.face; import io.swagger.annotations.ApiModelProperty; +import lombok.Data; import java.io.Serializable; import java.util.List; +@Data public class PermissionBean implements Serializable { @ApiModelProperty("设备ID,批量用英文逗号,隔开") @@ -21,44 +23,4 @@ public class PermissionBean implements Serializable { @ApiModelProperty("用户ID,批量用英文逗号,隔开") private String userIds; - - public String getUserIds() { - return userIds; - } - - public void setUserIds(String userIds) { - this.userIds = userIds; - } - - public List getDeviceIds() { - return deviceIds; - } - - public void setDeviceIds(List deviceIds) { - this.deviceIds = deviceIds; - } - - public String getSchoolId() { - return schoolId; - } - - public void setSchoolId(String schoolId) { - this.schoolId = schoolId; - } - - public String getUserType() { - return userType; - } - - public void setUserType(String userType) { - this.userType = userType; - } - - public List getWeekDays() { - return weekDays; - } - - public void setWeekDays(List weekDays) { - this.weekDays = weekDays; - } } diff --git a/cloud/haikangface/src/main/java/com/sincere/haikangface/bean/face/SendFaceBean.java b/cloud/haikangface/src/main/java/com/sincere/haikangface/bean/face/SendFaceBean.java index 23d6062..415e66d 100644 --- a/cloud/haikangface/src/main/java/com/sincere/haikangface/bean/face/SendFaceBean.java +++ b/cloud/haikangface/src/main/java/com/sincere/haikangface/bean/face/SendFaceBean.java @@ -1,87 +1,72 @@ package com.sincere.haikangface.bean.face; -public class SendFaceBean { - - private String card; - - private String name; - - private String deviceId; - - private String startTime; +import com.fasterxml.jackson.annotation.JsonIgnore; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import org.apache.commons.lang3.StringUtils; - private String endTime; +import javax.validation.constraints.NotNull; +import java.util.Arrays; +import java.util.List; - private int validTimeEnabled; - - private String userType; +@Data +public class SendFaceBean { - public String getCard() { - return card; - } + @NotNull(message = "学校ID必传") + @ApiModelProperty("学校ID") + private Integer schoolId; - public void setCard(String card) { - this.card = card; - } + @ApiModelProperty("学生类型1老师2学生") + private Integer userType; - public String getName() { - return name; - } + @ApiModelProperty("学生类型1通校2住校3通晚4其他") + private Integer studentType; - public void setName(String name) { - this.name = name; - } + @ApiModelProperty("性别,多个英文逗号隔开") + private String sex; - public String getDeviceId() { - return deviceId; - } + @ApiModelProperty("下发人脸照") + private String photo; - public void setDeviceId(String deviceId) { - this.deviceId = deviceId; - } + @ApiModelProperty("下发班级,多个英文逗号隔开") + private String classIds; - public String getStartTime() { - return startTime; - } + @ApiModelProperty("下发设备,多个英文逗号隔开") + private String deviceIds; - public void setStartTime(String startTime) { - this.startTime = startTime; - } + @ApiModelProperty("下发卡号,多个英文逗号隔开") + private String cardNos; - public String getEndTime() { - return endTime; - } + @ApiModelProperty("是否检验人脸1是2否,默认2") + private Integer isCheck = 2; - public void setEndTime(String endTime) { - this.endTime = endTime; - } + @ApiModelProperty("宿舍分组ID") + private Integer roomId; - public int getValidTimeEnabled() { - return validTimeEnabled; - } + @ApiModelProperty("下发状态") + private Integer status; - public void setValidTimeEnabled(int validTimeEnabled) { - this.validTimeEnabled = validTimeEnabled; + @JsonIgnore + public List getSexList(){ + if(StringUtils.isNotBlank(getSex())) return Arrays.asList(getSex().split(",")); + return null; } - public String getUserType() { - return userType; + @JsonIgnore + public List getClassList(){ + if(StringUtils.isNotBlank(getClassIds())) return Arrays.asList(getClassIds().split(",")); + return null; } - public void setUserType(String userType) { - this.userType = userType; + @JsonIgnore + public List getDeviceList(){ + if(StringUtils.isNotBlank(getDeviceIds())) return Arrays.asList(getDeviceIds().split(",")); + return null; } - @Override - public String toString() { - return "SendFaceBean{" + - "card='" + card + '\'' + - ", name='" + name + '\'' + - ", deviceId='" + deviceId + '\'' + - ", startTime='" + startTime + '\'' + - ", endTime='" + endTime + '\'' + - ", validTimeEnabled=" + validTimeEnabled + - ", userType='" + userType + '\'' + - '}'; + @JsonIgnore + public List getCardList(){ + if(StringUtils.isNotBlank(getCardNos())) return Arrays.asList(getCardNos().split(",")); + return null; } } diff --git a/cloud/haikangface/src/main/java/com/sincere/haikangface/control/UserOperateController.java b/cloud/haikangface/src/main/java/com/sincere/haikangface/control/UserOperateController.java index ce536a1..b6313bb 100644 --- a/cloud/haikangface/src/main/java/com/sincere/haikangface/control/UserOperateController.java +++ b/cloud/haikangface/src/main/java/com/sincere/haikangface/control/UserOperateController.java @@ -4,14 +4,14 @@ import com.sincere.haikangface.bean.Result; import com.sincere.haikangface.bean.ResultGenerator; import com.sincere.haikangface.bean.face.AuthRecordDto; import com.sincere.haikangface.bean.face.DeviceAuthRecord; -import com.sincere.haikangface.bean.face.SendFaceDto; +import com.sincere.haikangface.bean.face.SendFaceBean; import com.sincere.haikangface.dao.UserDao; import com.sincere.haikangface.service.UserOperateService; -import com.sincere.haikangface.utils.JsonUtils; import io.swagger.annotations.ApiOperation; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.MediaType; +import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; import org.springframework.web.multipart.MultipartFile; @@ -65,11 +65,14 @@ public class UserOperateController { return userOperateService.againSendFace(userId,deviceId,userType); } - @ApiOperation(value = "照片下发2.0") - @RequestMapping(value = "sendFaceByThread", method = RequestMethod.POST) - public Result sendFaceByThread(@RequestBody SendFaceDto sendFaceDto, - @RequestParam(value = "groupId",required = false) Integer groupId) { - return userOperateService.sendUserFaceByThread(sendFaceDto,groupId); + @ApiOperation(value = "补发单个人脸至指定设备2.0") + @RequestMapping(value = "againNoSendOneFace", method = RequestMethod.POST) + public Result againNoSendOneFace(@RequestParam(value = "file",required = false) MultipartFile file, + @RequestParam("schoolId") Integer schoolId, + @RequestParam("cardNum") String cardNum, + @RequestParam("userType") Integer userType, + @RequestParam("deviceIds") String deviceIds) { + return userOperateService.againNoSendOneFace(file,schoolId,cardNum,userType,deviceIds); } @ApiOperation(value = "删除下发失败人脸2.0") @@ -80,40 +83,14 @@ public class UserOperateController { @RequestMapping(value = "sendFailFace", method = RequestMethod.POST) @ApiOperation(value = "重新下发失败人脸2.0") - public Result sendFailFace(@RequestParam("schoolId") Integer schoolId) { - return userOperateService.sendFailFace(schoolId); - } - - @RequestMapping(value = "sendFailFace2", method = RequestMethod.POST) - @ApiOperation(value = "重新下发失败人脸2.1") - public Result sendFailFace(@RequestParam("schoolId") Integer schoolId, - @RequestParam(value = "deviceIds",required = false) String deviceIds) { - return userOperateService.sendFailFace2(schoolId,deviceIds); + public Result sendFailFace(@Validated @RequestBody SendFaceBean faceBean) { + return userOperateService.sendFailFace(faceBean); } @ApiOperation(value = "删除指定人脸2.0") @RequestMapping(value = "deleteFace", method = RequestMethod.POST) - public Result deleteFace(@RequestParam("schoolId") Integer schoolId, @RequestParam("cards") String cards, - @RequestParam(value = "deviceIds",required = false) String deviceIds) { - return userOperateService.deleteFace(schoolId,cards,deviceIds); - } - - @ApiOperation(value = "下发未下发的人脸至指定设备2.0") - @RequestMapping(value = "sendFaceForNoSend", method = RequestMethod.POST) - public Result sendFaceForNoSend(@RequestParam("schoolId") Integer schoolId, - @RequestParam("userType") Integer userType, - @RequestParam(value = "studentType",required = false) Integer studentType, - @RequestParam(value = "sex",required = false) String sex, - @RequestParam(value = "deviceIds",required = false) String deviceIds, - @RequestParam(value = "groupId",required = false) Integer groupId) { - return userOperateService.sendFaceForNoSend(schoolId,studentType,sex,userType,deviceIds,groupId); - } - - @ApiOperation(value = "补发单个人脸至指定设备2.0") - @RequestMapping(value = "againNoSendOneFace", method = RequestMethod.POST) - public Result againNoSendOneFace(@RequestParam("file") MultipartFile file,@RequestParam("schoolId") Integer schoolId, - @RequestParam("cardNum") String cardNum,@RequestParam("userType") Integer userType,@RequestParam("deviceIds") String deviceIds) { - return userOperateService.againNoSendOneFace(file,schoolId,cardNum,userType,deviceIds); + public Result deleteFace(@Validated @RequestBody SendFaceBean faceBean) { + return userOperateService.deleteFace(faceBean); } @ApiOperation(value = "捷安成闸机导入") @@ -122,71 +99,36 @@ public class UserOperateController { return userOperateService.insertUpdateCard(cardNums); } - - @ApiOperation(value = "压缩包上传下发") - @RequestMapping(value = "exportFace", method = RequestMethod.POST) - public Result exportFace(@RequestParam("schoolId") Integer schoolId, - @RequestParam("userType") Integer userType, - @RequestParam("deviceIds") String deviceIds, - @RequestParam("faceSrcPath") String faceSrcPath){ - return userOperateService.exportFace(schoolId,userType,deviceIds,faceSrcPath); - } - - @ApiOperation(value = "按班级指定下发") + @ApiOperation(value = "按条件指定下发") @RequestMapping(value = "sendFaceByClassId", method = RequestMethod.POST) - public Result sendFaceByClassId(@RequestParam("schoolId") Integer schoolId, - @RequestParam(value = "classIds",required = false) String classIds, - @RequestParam(value = "deviceIds",required = false) String deviceIds, - @RequestParam(value = "studentType",required = false) Integer studentType, - @RequestParam(value = "sex",required = false) String sex, - @RequestParam(value = "isCheck",required = false) Integer isCheck){ - return userOperateService.sendFaceByClassId(schoolId,classIds,deviceIds,studentType,sex,isCheck); - } - - @ApiOperation(value = "按班级指定下发") - @RequestMapping(value = "sendFaceByKeyword", method = RequestMethod.POST) - public Result sendFaceByKeyword(@RequestParam("schoolId") Integer schoolId, - @RequestParam(value = "deviceIds",required = false) String deviceIds, - @RequestParam(value = "keyword",required = false) String keyword, - @RequestParam(value = "studentType",required = false) Integer studentType, - @RequestParam(value = "sex",required = false) String sex, - @RequestParam(value = "isCheck",required = false) Integer isCheck){ - return userOperateService.sendFaceByKeyword(schoolId,deviceIds,keyword,studentType,sex,isCheck); + public Result sendFaceByClassId(@Validated @RequestBody SendFaceBean faceBean){ + return userOperateService.sendFaceByClassId(faceBean); } - @ApiOperation(value = "指定班级下发未下发人脸") - @RequestMapping(value = "noSendByKeyword", method = RequestMethod.POST) - public Result noSendByKeyword(@RequestParam("schoolId") Integer schoolId, - @RequestParam(value = "keyword",required = false) String keyword, - @RequestParam(value = "deviceIds",required = false) String deviceIds) { - return userOperateService.noSendByKeyword(schoolId,keyword,deviceIds); + @ApiOperation(value = "按条件指定下发未发送") + @RequestMapping(value = "sendNuFaceByClassId", method = RequestMethod.POST) + public Result noSendByKeyword(@Validated @RequestBody SendFaceBean faceBean) { + return userOperateService.sendNuFaceByClassId(faceBean); } - @ApiOperation(value = "根据宿舍分组下发") + @ApiOperation(value = "按宿舍分组下发") @RequestMapping(value = "sendFaceByRoomId", method = RequestMethod.POST) - public Result sendFaceByRoomId(@RequestParam("schoolId") Integer schoolId, - @RequestParam("roomId") Integer roomId, - @RequestParam(value = "deviceIds",required = false) String deviceIds) { - return userOperateService.sendFaceByRoomId(schoolId,roomId,deviceIds); + public Result sendFaceByRoomId(@Validated @RequestBody SendFaceBean faceBean) { + return userOperateService.sendFaceByRoomId(faceBean); } - @ApiOperation(value = "删除指定学校下人脸照片") - @RequestMapping(value = "deleteBySchoolId", method = RequestMethod.POST) - public Result deleteBySchoolId(@RequestParam("schoolId") Integer schoolId, - @RequestParam(value = "deviceIds",required = false) String deviceIds){ - return userOperateService.deleteFaceBySchoolId(schoolId,deviceIds); + @ApiOperation(value = "按条件删除学校下人脸照片") + @RequestMapping(value = "deleteByCondition", method = RequestMethod.POST) + public Result deleteByCondition(@Validated @RequestBody SendFaceBean faceBean){ + return userOperateService.deleteByCondition(faceBean); } - @RequestMapping(value = "checkFaceSend", method = RequestMethod.GET) - public void checkFaceSend(){ - userOperateService.checkFaceSend(); - } - - @ApiOperation(value = "按班级指定下发") - @RequestMapping(value = "replaceFaceByKeyword", method = RequestMethod.POST) - public Result replaceFaceByKeyword(@RequestParam("schoolId") Integer schoolId, - @RequestParam("deviceIds") String deviceIds, - @RequestParam("keyword") String keyword){ - return userOperateService.replaceFaceByKeyword(schoolId,deviceIds,keyword); + @ApiOperation(value = "压缩包上传下发") + @RequestMapping(value = "exportFace", method = RequestMethod.POST) + public Result exportFace(@RequestParam("schoolId") Integer schoolId, + @RequestParam("userType") Integer userType, + @RequestParam("deviceIds") String deviceIds, + @RequestParam("faceSrcPath") String faceSrcPath){ + return userOperateService.exportFace(schoolId,userType,deviceIds,faceSrcPath); } } diff --git a/cloud/haikangface/src/main/java/com/sincere/haikangface/dao/UserDao.java b/cloud/haikangface/src/main/java/com/sincere/haikangface/dao/UserDao.java index 19fbd57..07537fc 100644 --- a/cloud/haikangface/src/main/java/com/sincere/haikangface/dao/UserDao.java +++ b/cloud/haikangface/src/main/java/com/sincere/haikangface/dao/UserDao.java @@ -12,27 +12,6 @@ import java.util.List; @Repository public interface UserDao { - /** - * 没有记录取最新十条下发 - * - * @return - */ - @Select("select top (10) * from HS_StudentUpdateCard order by AddTime desc") - List getStudents(); - - @Select("select student_num,name,studentcode from SZ_V_School_Student where school_id = 479") - List getStu(); - - /** - * 获取所有的学生 - * - * @return - */ - @Select("select * from HS_StudentUpdateCard where ID > #{id} and StudentType = #{StudentType} order by AddTime desc") - List getAllStudents(@Param("id") long id, @Param("StudentType") int StudentType); - @Update("update SZ_V_School_Student set name = #{name} where student_id = #{student_id}") - void updateTest(@Param("student_id") String student_id, @Param("name") String name); - @Select("select Top(1) student_num from SZ_V_School_Student where student_id = #{student_id} and role_state = 1") String getStudent_Num(@Param("student_id") String student_id); @@ -47,153 +26,9 @@ public interface UserDao { @Param("KnowledgeId") String KnowledgeId, @Param("TestId") String TestId, @Param("ChapterId") String ChapterId, @Param("GradeId") String GradeId, @Param("SourceId") String SourceId, @Param("OrderId") String OrderId, @Param("SId") String SId, @Param("StemId") String StemId, @Param("AutomaticCorrection") String AutomaticCorrection, @Param("SchoolId") String SchoolId); - @Select("select * from SZ_User where user_id = #{user_id}") - UserBean getUser(@Param("user_id") String user_id); - @Select("select school_name from SZ_School where school_id = #{schoolid}") String getSchoolName(@Param("schoolid") String schoolid); - @Select("select * from HS_ResFiles where UserId in(select user_id from SZ_V_School_Teacher where school_id = 1021)") - List getFileRes(); - - @Select("select * from HS_ResFiles where UserId = 'zy405704' and id >= 4476 ") - List getFIlesReses(); - - // - @Select("(select Name from HS_ResGrade where SchoolId = 350 and id = #{id})") - String getGradeName(@Param("id") String id); - - // - @Select("select id from HS_ResGrade where SchoolId = 349 and name = #{name}") - String getGradeId(@Param("name") String name); - - @Select("select * from HS_ResGrade where SchoolId = 350") - List getGrades(); - - - @Insert("insert into HS_ResGrade values (#{name},#{addTime},#{status},#{userId},#{schoolId},#{shortName},#{schoolYear},#{year},#{remark},#{isFinish})") - void addGrade(@Param("name") String name, @Param("addTime") String addTime, @Param("status") int status, @Param("userId") String userId, - @Param("schoolId") int schoolId, @Param("shortName") String shortName, @Param("schoolYear") int schoolYear, @Param("year") int year, @Param("remark") String remark, @Param("isFinish") int isFinish); - - // - @Select("select * from HS_ResBook where SchoolId = 350") - List getHSResBook(); - - @Insert(" insert into HS_ResBook values (#{name},#{addTime},#{status},#{userId},#{schoolId},#{press},#{pressTimes},#{price})") - void addHSResBook(@Param("name") String name, @Param("addTime") String addTime, @Param("status") String status, @Param("userId") String userId, @Param("schoolId") String schoolId, @Param("press") String press, - @Param("pressTimes") String pressTimes, @Param("price") String price); - - @Select("select * from SZ_Subject where school_id =350 and Status = 1") - List getSubjects(); - - @Insert("insert into SZ_Subject values(#{school_id},#{subject_name},#{intime},#{subId},#{isElective},#{status},#{typeId},#{maxPerson},#{shortName})") - void addSubjectbean(@Param("school_id") int school_id, @Param("subject_name") String subject_name, @Param("intime") String intime, - @Param("subId") int subId, @Param("isElective") int isElective, @Param("status") int status, @Param("typeId") int typeId, @Param("maxPerson") int maxPerson, @Param("shortName") String shortName); - - @Select("select Top(1)subject_id from SZ_Subject where subject_name = #{subject_name} and school_id = 349") - String getSubjectId(@Param("subject_name") String subject_name); - - @Select("select Top(1) subject_name from SZ_Subject where subject_id = #{subject_id} and school_id = 350") - String getSubjectName(@Param("subject_id") int subject_id); - - @Select("select Top(1) name from HS_ResBook where SchoolId = 350 and id = #{id}") - String getBookName(@Param("id") int bookId); - - @Select("select Top(1) id from HS_ResBook where SchoolId = 349 and name = #{name}") - int getBookId(@Param("name") String bookName); - - @Select("select id from HS_ResBookVersion where SchoolId = #{SchoolId}") - List getbookversionId(@Param("SchoolId") String SchoolId); - - @Select("select * from HS_ResChapter where SchoolId = 350") - List getChapters(); - - // - @Select(" select * from HS_ResBookVersion where SchoolId = 350") - List getResBookVersion(); - - @Insert("insert into HS_ResBookVersion values(#{bookId},#{gradeId},#{subjectId},#{isUse},#{state},#{intime},#{schoolId})") - void addResBookVersion(@Param("bookId") int bookId, @Param("gradeId") int gradeId, @Param("subjectId") int subjectId, @Param("isUse") int isUse, @Param("state") int state, - @Param("intime") String intime, @Param("schoolId") int schoolId); - - @Insert("insert into HS_ResChapter values(#{name},#{subjectId},#{gradeId},#{pid},#{jiaoCaiId},#{bookVersionId},#{sort},#{type},#{addTime},#{status},#{userId},#{schoolId})") - void addChapter(@Param("name") String name, @Param("subjectId") int subjectId, @Param("gradeId") int gradeId, @Param("pid") int pid, @Param("jiaoCaiId") int jiaoCaiId, @Param("bookVersionId") int bookVersionId, - @Param("sort") int sort, @Param("type") int type, @Param("addTime") String addTime, @Param("status") int status, @Param("userId") String userId, @Param("schoolId") int schoolId); - - @Select("Select Top(1)name from HS_ResChapter where id = #{pid} ") - String getChapterName(@Param("pid") int pid); - - @Select(" Select Top(1)id from HS_ResChapter where name=#{name} and SchoolId = 349") - String getChapterId(@Param("name") String name); - - @Update("update HS_ResChapter set Pid = #{pid} where SchoolId = 349 and userId = #{userId} and name = #{name}") - void updateChapter(@Param("userId") String userId, @Param("name") String name, @Param("pid") String chapterId); - - @Select("select id from HS_ResBook where SchoolId = 885 and name =(select name from HS_ResBook where SchoolId = 1021 and Id = #{id})") - String getJiaoCaiId(@Param("id") int id); - - @Select("select id from HS_ResCatalog where SchoolId = 885 and name = #{name}") - String getResCatalog(@Param("name") String name); - - @Select("select name from HS_ResCatalog where SchoolId = 1021 and id = #{id}") - String getResCatalogName(@Param("id") String id); - - @Select("select id from HS_ResType where SchoolId = 885 and name = #{name}") - String getResType(@Param("name") String name); - - @Select("select name from HS_ResType where SchoolId = 1021 and id = #{id}") - String getResTypeName(@Param("id") String id); - - // - @Insert("insert into HS_ResFiles values(#{name},#{catalogId},#{typeId},#{gradeId},#{subjectId},#{jiaoCaiId},#{charpId},#{fileUrl},#{descript},#{keywords}" + - ",#{addTime},#{status},#{userId},#{targetUrl},#{clicks},#{userList},#{isShare},#{charpId1},#{knowledgeId})") - void addFiles(@Param("name") String name, @Param("catalogId") String catalogId, @Param("typeId") int typeId, @Param("gradeId") int gradeId, - @Param("subjectId") int subjectId, @Param("jiaoCaiId") int jiaoCaiId, @Param("charpId") int charpId, @Param("fileUrl") String fileUrl, - @Param("descript") String descript, @Param("keywords") String keywords, @Param("addTime") String addTime, @Param("status") int status, - @Param("userId") String userId, @Param("targetUrl") String targetUrl, @Param("clicks") int clicks, @Param("userList") String userList, @Param("isShare") int isShare, - @Param("charpId1") int charpId1, @Param("knowledgeId") int knowledgeId); - - @Select("select *\n" + - "from SZ_V_School_Student where name = #{name} and school_id = #{school_id}") - List getAllStudentsWithSchoolId(@Param("school_id") String school_id, @Param("name") String name); - - @Select("select * from SZ_V_School_Student where school_id = #{school_id} and student_type = 2") - List getAllStuWithSchoolId(@Param("school_id") String school_id); - - @Select(" select * from SZ_V_School_Student where school_id = 562 and student_num is not null and photo is not null and len(photo)>0") - List getAllStus(); - - @Select("select user_id\n" + - "from SZ_V_School_Student where school_id = 13 and student_type =2 and len(student_num)=0\n") - List getUserids(); - - @Insert("insert into HS_ResRalation (FileId,AddTime,UserId) values (#{FileId},#{AddTime},#{userId})") - void addRelation(@Param("FileId") String id, @Param("AddTime") String time, @Param("userId") String userId); - - @Select("select student_id from SZ_V_School_Student where school_id = #{s} and name = #{name}") - List getStudentIdWidthName(@Param("name") String trim, @Param("s") String s); - - @Insert("insert into Virtual_Card values(#{intCardNum},#{i},#{cardNum})") - void addVirtual_Card(@Param("intCardNum") long intCardNum, @Param("i") int i, @Param("cardNum") String cardNum); - - @Select("select class_id from SZ_V_School_Student where school_id = 479 and student_id = #{customerId} ") - String getClassName(@Param("customerId") String customerId); - - @Select("select clint_id from SZ_Attendance where school_id = #{schoolId} and clint_type=18") - List getDeviceIdsWidthSchoolId(@Param("schoolId") int schoolId); - - - @Select("select StudentId from SS_RoomNumber where Pid in (select id\n" + - " from SS_Room\n" + - " where SchoolId = 479 and SS_Room.Pid =10284 )") - List getStudentIdWithRoom(); - - @Select("select CardNum from Virtual_Card where state =0 and id < 5475 ;") - List getVirCards(); - - @Update("update SZ_V_School_Student set student_num =#{student_num} where school_id = 13 and student_type =2 and len(student_num)=0 and user_id = #{user_id}") - void updateStuCards(@Param("student_num") String card, @Param("user_id") String user_id); - @Select("select Top(1) * from SZ_V_School_Student where studentcode = #{studentcode} and school_id = #{schoolId}") StudentBean getStudentWithstudentcode(@Param("studentcode") String studentcode, @Param("schoolId") String schoolId); @@ -210,18 +45,6 @@ public interface UserDao { void addWGTem(@Param("UserId") String UserId, @Param("StudentId") String StudentId, @Param("Name") String Name, @Param("ClassId") String ClassId, @Param("ClassName") String ClassName, @Param("Temperature") String Temperature, @Param("Type") String Type, @Param("SchoolId") String SchoolId, @Param("Intime") String Intime); - @Select("select student_num from SZ_V_School_Student where school_id = #{schoolId} and student_num<>''") - List getStudentCardsWidthSchoolId(@Param("schoolId") int schoolId); - - @Select("select student_num from SZ_V_School_Teacher where school_id = #{schoolId} and student_num<>''") - List getTeaCardsWidthSchoolId(@Param("schoolId") String schoolId); - - @Select("select Top(1) teacher_num from SZ_V_School_Teacher where user_id = #{userId}") - String getTeaCardWithUserId(@Param("userId") String userId); - - @Select("select Top(1) student_num from SZ_V_School_Student where school_id = #{schoolId} and user_id = #{userId}") - String getStudentCardWithUserId(@Param("schoolId") String schoolId,@Param("userId") String userId); - @Select("select Top(1) studentcode from SZ_V_School_Student where student_num = #{num}") String getStudentCode(@Param("num") String num); @@ -274,14 +97,9 @@ public interface UserDao { @Param("groupId")Integer groupId); List getStudentByClassId(@Param("schoolId") int schoolId, - @Param("classIds") List classIds, - @Param("sexList") List sexList, - @Param("studentType")Integer studentType); - - List getStudentByKeyword(@Param("schoolId") int schoolId, - @Param("keyword") String keyword, - @Param("sexList") List sexList, - @Param("studentType")Integer studentType); + @Param("studentType") Integer studentType, + @Param("classIds") List classIds, + @Param("sexList") List sexList); List getDeviceIds(@Param("schoolId") Integer schoolId,@Param("deviceId") String deviceId); @@ -292,7 +110,7 @@ public interface UserDao { @Select(" select top 1* from SZ_V_School_Student where student_id = #{student_id}") StudentBean getStudentWithid(@Param("student_id") String student_id); - StudentBean getStudentCByUserId(@Param("userId") String userId,@Param("schoolId") Integer schoolId); + StudentBean getStudentByUserId(@Param("userId") String userId,@Param("schoolId") Integer schoolId); StudentBean getTeacherByUserId(@Param("userId") String userId,@Param("schoolId") Integer schoolId); @@ -302,16 +120,11 @@ public interface UserDao { void insertCard(UpdateCardBean bean); - void insertStudent(SaveStudentBak studentBak); - - void updateStudent(@Param("id") Integer id); - - List selectStudentList(); - List getRoomBySchoolId(@Param("schoolId") Integer schoolId,@Param("groupId") Integer groupId); List getStudentByRoomIds(@Param("schoolId") Integer schoolId,@Param("pIdList") List pIdList); + /***找回已毕业的数据***/ List getTestVsByKeyword(@Param("schoolId") int schoolId, @Param("keyword") String keyword, @Param("sexList") List sexList, diff --git a/cloud/haikangface/src/main/java/com/sincere/haikangface/service/UserOperateService.java b/cloud/haikangface/src/main/java/com/sincere/haikangface/service/UserOperateService.java index d07faf1..1cc06a6 100644 --- a/cloud/haikangface/src/main/java/com/sincere/haikangface/service/UserOperateService.java +++ b/cloud/haikangface/src/main/java/com/sincere/haikangface/service/UserOperateService.java @@ -3,7 +3,10 @@ package com.sincere.haikangface.service; import com.sincere.haikangface.bean.Result; import com.sincere.haikangface.bean.face.AuthRecordDto; import com.sincere.haikangface.bean.face.DeviceAuthRecord; +import com.sincere.haikangface.bean.face.SendFaceBean; import com.sincere.haikangface.bean.face.SendFaceDto; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.multipart.MultipartFile; /** @@ -52,13 +55,6 @@ public interface UserOperateService { Result againSendFace(String userId,String deviceId,Integer userType); /** - * 多线程照片下发 - * @param sendFaceDto - * @return - */ - Result sendUserFaceByThread(SendFaceDto sendFaceDto,Integer groupId); - - /** * 删除失败表人脸 * @param schoolId * @return @@ -67,31 +63,15 @@ public interface UserOperateService { /** * 下发失败表人脸 - * @param schoolId * @return */ - Result sendFailFace(Integer schoolId); - - Result sendFailFace2(Integer schoolId,String deviceIds); + Result sendFailFace(SendFaceBean faceBean); /** * 删除指定人脸 - * @param schoolId - * @param cards - * @param deviceIds * @return */ - Result deleteFace(Integer schoolId,String cards,String deviceIds); - - /** - * 下发未下发完的人脸,仅供测试使用 - * @param schoolId - * @param studentType - * @param sex - * @param deviceIds - * @return - */ - Result sendFaceForNoSend(Integer schoolId,Integer studentType,String sex,Integer userType,String deviceIds,Integer groupId); + Result deleteFace(SendFaceBean faceBean); /** * 补发单个人脸至指定设备 @@ -112,57 +92,40 @@ public interface UserOperateService { Result insertUpdateCard(String cardNums); /** - * 压缩包上传下发人脸 - * @param schoolId - * @param userType - * @param deviceIds - * @param faceSrcPath + * + * @param faceBean * @return */ - Result exportFace(Integer schoolId,Integer userType,String deviceIds,String faceSrcPath); + Result sendFaceByClassId(SendFaceBean faceBean); /** - * 按班级下发人脸 - * @param schoolId - * @param classIds - * @param deviceIds - * @param isCheck + * + * @param faceBean * @return */ - Result sendFaceByClassId(Integer schoolId,String classIds,String deviceIds,Integer studentType,String sex,Integer isCheck); + Result sendNuFaceByClassId(SendFaceBean faceBean); /** - * 根据班级新生班级关键字下发 - * @param schoolId - * @param deviceIds - * @param keyword - * @param studentType - * @param sex - * @param isCheck + * 根据寝室号下发人脸 + * @param faceBean * @return */ - Result sendFaceByKeyword(Integer schoolId,String deviceIds,String keyword,Integer studentType,String sex,Integer isCheck); - - Result noSendByKeyword(Integer schoolId,String keyword,String deviceIds); + Result sendFaceByRoomId(SendFaceBean faceBean); /** - * 根据寝室号下发人脸 - * @param schoolId - * @param groupId - * @param deviceIds + * 删除指定学校下的人脸 + * @param faceBean * @return */ - Result sendFaceByRoomId(Integer schoolId,Integer groupId,String deviceIds); + Result deleteByCondition(SendFaceBean faceBean); /** - * 删除指定学校下的人脸 + * 压缩包上传下发人脸 * @param schoolId + * @param userType * @param deviceIds + * @param faceSrcPath * @return */ - Result deleteFaceBySchoolId(Integer schoolId,String deviceIds); - - void checkFaceSend(); - - Result replaceFaceByKeyword(Integer schoolId,String deviceIds,String keyword); + Result exportFace(Integer schoolId,Integer userType,String deviceIds,String faceSrcPath); } diff --git a/cloud/haikangface/src/main/java/com/sincere/haikangface/service/impl/BaseService.java b/cloud/haikangface/src/main/java/com/sincere/haikangface/service/impl/BaseService.java index b3b28d9..3b59696 100644 --- a/cloud/haikangface/src/main/java/com/sincere/haikangface/service/impl/BaseService.java +++ b/cloud/haikangface/src/main/java/com/sincere/haikangface/service/impl/BaseService.java @@ -8,6 +8,7 @@ import com.sincere.haikangface.async.SendUserAsync; import com.sincere.haikangface.bean.AttendanceBean; import com.sincere.haikangface.bean.SendRecordBean; import com.sincere.haikangface.bean.StudentBean; +import com.sincere.haikangface.bean.face.SendFaceBean; import com.sincere.haikangface.dao.DeviceDao; import com.sincere.haikangface.dao.UserDao; import com.sincere.haikangface.enums.EnumSzBusinessType; @@ -23,9 +24,12 @@ import org.springframework.stereotype.Service; import org.springframework.util.CollectionUtils; import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; import java.text.SimpleDateFormat; import java.util.*; import java.util.concurrent.*; +import java.util.function.Function; import java.util.stream.Collectors; /** @@ -276,29 +280,22 @@ public class BaseService { @Async public void sendUserFaceByAsyncThread(Integer schoolId,Integer userType,List studentBeanList,List deviceList){ - List deviceId_100 = new ArrayList<>(); - List deviceId_253 = new ArrayList<>(); + List deviceId100 = new ArrayList<>(); + List deviceId253 = new ArrayList<>(); //过滤设备 for (String sno : deviceList) { //若100服务器有此设备再进行多线程执行下发人脸任务,否则请求253服务执行单个下发人脸 - if (cmsServer.getIsDeviceOnline(sno)) { - deviceId_100.add(sno); - }else{ - deviceId_253.add(sno); - } - } - if(deviceId_100.size()>0){ - //100服务器 - sendFaceToDevice100(deviceId_100,studentBeanList,schoolId,userType); - } - if(deviceId_253.size()>0){ - //253服务器 - sendFaceToDevice253(deviceId_253,studentBeanList,schoolId,userType); + if (cmsServer.getIsDeviceOnline(sno)) deviceId100.add(sno); + else deviceId253.add(sno); } + //100服务器 + sendFaceToDevice100(deviceId100,studentBeanList,schoolId,userType); + //253服务器 + sendFaceToDevice253(deviceId100,studentBeanList,schoolId,userType); } - protected void sendFaceToDevice100(List deviceIds,List studentBeanList,Integer schoolId,Integer userType){ + protected void sendFaceToDevice100(List deviceIds,List studentList,Integer schoolId,Integer userType){ log.info("------------------------开始执行100服务,人脸照下发---------------------"); String startTime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()); Calendar calendar = Calendar.getInstance(); @@ -306,64 +303,41 @@ public class BaseService { String endTime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(calendar.getTime()); //下发标识:详情见枚举 EnumHkOperateType int validTimeEnabled = EnumSzBusinessType.EnumHkOperateType.ADD.code; - for(StudentBean studentBean : studentBeanList){ + studentList.stream().forEach(s->{ try{ - String userName= studentBean.getName(); - String userId = studentBean.getUser_id(); - String photo = userType.intValue()==1?studentBean.getFace():studentBean.getPhoto(); - String cardNum =userType.intValue()==1?studentBean.getTeacher_num():studentBean.getStudent_num(); - String typeName=userType.intValue()==1?"Teacher":"Student"; - if (StringUtils.isBlank(photo) || StringUtils.isBlank(cardNum)){ - continue; - } - //以学籍号为名的文件名 - String fileName = photo.substring(photo.lastIndexOf("/") + 1,photo.length()); - //100服务器人脸照绝对路径 - String path_1 = "E:\\wwwhtdocs\\SmartCampus\\face17e50\\School" + schoolId + "\\" + typeName; - String path_2 = "E:\\wwwhtdocs\\SmartCampus\\face17e5\\School" + schoolId + "\\" + typeName; - String path_3 = "E:\\wwwhtdocs\\SmartCampus\\f0i5l7e5\\"; - String filePath=""; - if(photo.indexOf("f0i5l7e5")!=-1){ - String afterStr = photo.split("f0i5l7e5/")[1].replace("/","\\"); - filePath= path_3 + afterStr; - } - if(photo.indexOf("face17e5")!=-1){ - filePath = path_2 + "\\" + fileName; - } - if(photo.indexOf("face17e50")!=-1){ - filePath = path_1 + "\\" + fileName; + String userName = s.getName(); + String studentNum = s.getStudent_num(); + String filePath = this.checkUserFace(s,userType,schoolId); + if(StringUtils.isBlank(filePath)) return; + File file = new File(filePath); + if(!file.exists()) return; + String targetPath = FileUtils.picPathComp + file.getName(); + try { + CompressPic.CompressPic(file.getAbsolutePath(), targetPath); + } catch (Exception e) { + log.error("压缩图片失败:",e); + return; } - File file = new File(filePath);//图片 - if(file.exists()){ - String targetPath = FileUtils.picPathComp + file.getName(); - try { - CompressPic.CompressPic(file.getAbsolutePath(), targetPath); - } catch (Exception e) { - log.error("压缩图片失败:",e); - continue; - } - for(String sno : deviceIds){ - if(sendRecordDao.getRecordIsExit(sno,cardNum,userId).size()<1){ - if(cmsServer.getIsDeviceOnline(sno)){ - if(!StringUtils.isBlank(cardNum)){ - String cardNumLong = Long.parseLong(getCard(cardNum),16) + ""; - //下发100海康设备 - sendUserAsync.sendStuToHaiKang(file.getAbsolutePath(),targetPath,cardNumLong, startTime, endTime, validTimeEnabled, userName, sno, String.valueOf(userType),schoolId,cardNum); - } - }else{ - log.error("100服务器,设备不在线"); - } + for(String sno : deviceIds){ + if(cmsServer.getIsDeviceOnline(sno)){ + if(!StringUtils.isBlank(s.getStudent_num())){ + String cardNumLong = Long.parseLong(getCard(studentNum),16) + ""; + //下发100海康设备 + sendUserAsync.sendStuToHaiKang(file.getAbsolutePath(),targetPath,cardNumLong, startTime, endTime, + validTimeEnabled, userName, sno, String.valueOf(userType),schoolId,studentNum); } + }else{ + log.error("100服务器,设备不在线"); } } }catch (Exception e){ log.error("人脸下发失败,异常信息:",e); - continue; + return; } - } + }); } - protected void sendFaceToDevice253(List deviceIds,List studentBeanList,Integer schoolId,Integer userType){ + protected void sendFaceToDevice253(List deviceIds,List studentList,Integer schoolId,Integer userType){ log.info("------------------------开始执行253服务,人脸照下发---------------------"); String startTime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()); Calendar calendar = Calendar.getInstance(); @@ -371,73 +345,31 @@ public class BaseService { String endTime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(calendar.getTime()); //下发标识:详情见枚举 EnumHkOperateType int validTimeEnabled = EnumSzBusinessType.EnumHkOperateType.ADD.code; - for(StudentBean studentBean : studentBeanList){ + studentList.stream().forEach(s->{ try{ - String userName= studentBean.getName(); - String userId = studentBean.getUser_id(); - String photo = userType.intValue()==1?studentBean.getFace():studentBean.getPhoto(); - String cardNum =userType.intValue()==1?studentBean.getTeacher_num():studentBean.getStudent_num(); - String typeName=userType.intValue()==1?"Teacher":"Student"; - if (StringUtils.isBlank(photo) || StringUtils.isBlank(cardNum)){ - continue; - } - //以学籍号为名的文件名 - String fileName = photo.substring(photo.lastIndexOf("/") + 1,photo.length()); - //100服务器人脸照绝对路径 - String path_1 = "E:\\wwwhtdocs\\SmartCampus\\face17e50\\School" + schoolId + "\\" + typeName; - String path_2 = "E:\\wwwhtdocs\\SmartCampus\\face17e5\\School" + schoolId + "\\" + typeName; - String path_3 = "E:\\wwwhtdocs\\SmartCampus\\f0i5l7e5\\"; - String filePath=""; - if(photo.indexOf("f0i5l7e5")!=-1){ - String afterStr = photo.split("f0i5l7e5/")[1].replace("/","\\"); - filePath= path_3 + afterStr; - } - if(photo.indexOf("face17e5")!=-1){ - filePath = path_2 + "\\" + fileName; - } - if(photo.indexOf("face17e50")!=-1){ - filePath = path_1 + "\\" + fileName; + String userName = s.getName(); + String studentNum = s.getStudent_num(); + String filePath = this.checkUserFace(s,userType,schoolId); + if(StringUtils.isBlank(filePath)) return; + File file = new File(filePath); + if(!file.exists()) return; + String targetPath = FileUtils.picPathComp + file.getName(); + try { + CompressPic.CompressPic(file.getAbsolutePath(), targetPath); + } catch (Exception e) { + log.error("压缩图片失败:",e); + return; } - File file = new File(filePath);//图片 - if(file.exists()) { - String targetPath = FileUtils.picPathComp + file.getName(); - try { - CompressPic.CompressPic(file.getAbsolutePath(), targetPath); - } catch (Exception e) { - log.error("压缩图片失败:", e); - continue; - } - for (String sno : deviceIds) { - if(sendRecordDao.getRecordIsExit(sno,cardNum,userId).size()<1){ - //下发253服务器 - sendUserAsync.uploadImgs(targetPath,cardNum, userName, sno, startTime, endTime, validTimeEnabled, String.valueOf(userType),schoolId); - } - } + for (String sno : deviceIds) { + //下发253服务器 + sendUserAsync.uploadImgs(targetPath,studentNum, userName, sno, startTime, endTime, validTimeEnabled, + String.valueOf(userType),schoolId); } }catch (Exception e){ - log.error("人脸下发失败"); - e.printStackTrace(); - continue; + log.error("人脸下发失败",e); + return; } - } - } - - - /** - * 获取指定学校下的学生卡信息 - * @param schoolId - * @return - */ - public List getRecordCardBySchoolId(int schoolId) { - List allStudents = new LinkedList<>(); - List students = sendRecordDao.getSendFaceSuccess(schoolId); - allStudents.addAll(students); - List students2 = sendRecordDao.getFaceRecord(schoolId); - allStudents.addAll(students2); - //去重重复数据 - List studentList = allStudents.stream().collect(Collectors.collectingAndThen( - Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(SendRecordBean::getNum))),ArrayList::new)); - return studentList; + }); } /** @@ -480,43 +412,12 @@ public class BaseService { /** * 根据班级ID获取对应班级下的学生数据信息 - * @param schoolId - * @param classIds * @return */ - public List getStudentByClassId(Integer schoolId,String classIds,Integer studentType,String sex) { - List classList = null; - if(StringUtils.isNotBlank(classIds)){ - classList = Arrays.asList(classIds.split(",")) - .stream().map(Integer::parseInt).collect(Collectors.toList()); - } - List sexList = null; - if(StringUtils.isNotBlank(sex)){ - sexList = Arrays.asList(sex.split(",")) - .stream().map(Integer::parseInt).collect(Collectors.toList()); - } - List students = userDao.getStudentByClassId(schoolId,classList,sexList,studentType); - //去重重复数据 - List studentList = students.stream().collect(Collectors.collectingAndThen( - Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(StudentBean::getStudent_num))), ArrayList::new)); - return studentList; - } - - /** - * 根据班级关键字获取学生数据信息 - * @param schoolId - * @param keyword - * @param studentType - * @param sex - * @return - */ - public List getStudentByKeyword(Integer schoolId,String keyword,Integer studentType,String sex) { - List sexList = null; - if(StringUtils.isNotBlank(sex)){ - sexList = Arrays.asList(sex.split(",")) - .stream().map(Integer::parseInt).collect(Collectors.toList()); - } - List students = userDao.getStudentByKeyword(schoolId,keyword,sexList,studentType); + public List getStudentByClassId(SendFaceBean faceBean) { + List classList = faceBean.getClassList(); + List sexList = faceBean.getSexList(); + List students = userDao.getStudentByClassId(faceBean.getSchoolId(),faceBean.getStudentType(),classList,sexList); //去重重复数据 List studentList = students.stream().collect(Collectors.collectingAndThen( Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(StudentBean::getStudent_num))), ArrayList::new)); @@ -555,7 +456,7 @@ public class BaseService { List pIdlIst = rooms.stream().distinct().collect(Collectors.toList()); List studentBeans = userDao.getStudentByRoomIds(schoolId,pIdlIst); //去重重复数据 - List studentList = studentBeans.stream().collect(Collectors.collectingAndThen( + List studentList = studentBeans.parallelStream().collect(Collectors.collectingAndThen( Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(StudentBean::getStudent_num))), ArrayList::new)); return studentList; } @@ -576,34 +477,20 @@ public class BaseService { return teacherist; } - - public void getSuccessList(Integer schoolId,String deviceIds) { - //下发设备集合 - String[] deviceArr = deviceIds.split(","); - List deviceList= new ArrayList<>(Arrays.asList(deviceArr)); - if(deviceList.size()<1){ - return; - } - //启用多线程执行 - CountDownLatch begin = new CountDownLatch(1); - CountDownLatch end = new CountDownLatch(deviceList.size()); - ThreadFactory namedThreadFactory = new ThreadFactoryBuilder().setNameFormat("thread-sendFace-runner-%d").build(); - ExecutorService exe = new ThreadPoolExecutor(8,16,0L, TimeUnit.MILLISECONDS,new LinkedBlockingQueue(),namedThreadFactory); - for(String sno : deviceList){ - exe.execute(new AsyncTask(userDao,sendRecordDao,schoolId,sno,begin,end)); - } - begin.countDown(); - try { - end.await(); - }catch (Exception e){ - log.error("迁移人脸照失败"+e); - e.printStackTrace(); - } - exe.shutdown(); - System.out.println("统计100服务器总共有"+deviceList.size()+"个设备,处理完毕"); + /** + * 获取指定学校下的学生卡信息 + * @return + */ + public List getSendRecordList(SendFaceBean faceBean) { + List students = sendRecordDao.getSendRecordList(faceBean.getSchoolId(),faceBean.getDeviceList(),faceBean.getStatus()); + //去重重复数据 + List studentList = students.stream().collect(Collectors.collectingAndThen( + Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(SendRecordBean::getNum))),ArrayList::new)); + return studentList; } + public void clearStudent(Integer schoolId,String deviceIds) { //下发设备集合 String[] deviceArr = deviceIds.split(","); @@ -637,7 +524,6 @@ public class BaseService { System.out.println("size: " + sendRecordBeans.size()); for(String s : sendRecordBeans){ StudentBean studentBean = userDao.getStudentWithCard(s,schoolId); -// System.out.println(new Gson().toJson(studentBean)); if(studentBean == null){ System.out.println(s); sendRecordDao.deleteRecordByNum(schoolId,s); @@ -676,5 +562,58 @@ public class BaseService { } + public List getDeviceList(String deviceIds,Integer schoolId){ + if(StringUtils.isNotBlank(deviceIds)) return Arrays.asList(deviceIds.split(",")); + return deviceDao.selectDeviceBySchoolId(schoolId); + } + public String checkUserFace(StudentBean studentBean,Integer userType,Integer schoolId){ + String cardNum = userType.intValue()==1 ? studentBean.getTeacher_num():studentBean.getStudent_num(); + String photo = userType.intValue()==1?studentBean.getFace():studentBean.getPhoto(); + if (StringUtils.isBlank(photo) || StringUtils.isBlank(cardNum)) return null; + String typeName= userType.intValue()==1?"Teacher":"Student"; + //以学籍号为名的文件名 + String fileName = photo.substring(photo.lastIndexOf("/") + 1,photo.length()); + //100服务器人脸照绝对路径 + String path_1 = "E:\\wwwhtdocs\\SmartCampus\\face17e50\\School" + schoolId + "\\" + typeName; + String path_2 = "E:\\wwwhtdocs\\SmartCampus\\face17e5\\School" + schoolId + "\\" + typeName; + String path_3 = "E:\\wwwhtdocs\\SmartCampus\\f0i5l7e5\\"; + String filePath=""; + if(photo.indexOf("face17e5")!=-1) filePath = path_2 + "\\" + fileName; + if(photo.indexOf("face17e50")!=-1) filePath = path_1 + "\\" + fileName; + if(filePath.indexOf("?v=")!=-1) filePath = filePath.split("\\?")[0]; + if(photo.indexOf("f0i5l7e5")!=-1){ + String afterStr = photo.split("f0i5l7e5/")[1].replace("/","\\"); + filePath = path_3 + afterStr; + } + return filePath; + } + + public static void copy(String srcPathStr, String desPathStr) { + //获取源文件的名称 + try { + FileInputStream fis = new FileInputStream(srcPathStr);//创建输入流对象 + FileOutputStream fos = new FileOutputStream(desPathStr); //创建输出流对象 + byte datas[] = new byte[1024*8];//创建搬运工具 + int len = 0;//创建长度 + while((len = fis.read(datas))!=-1)//循环读取数据 + { + fos.write(datas,0,len); + } + fis.close();//释放资源 + fis.close();//释放资源 + } + catch (Exception e) + { + e.printStackTrace(); + } + } + + public boolean checkSendRecord(List sendRecords,String sno,Integer schoolId,String cardNum){ + SendRecordBean record = sendRecords.stream().filter(s->Objects.equals(s.getDeviceID(),sno) && + Objects.equals(s.getStatus(),1) && Objects.equals(s.getSchoolId(),schoolId) && + Objects.equals(s.getNum(),cardNum)).findFirst().orElse(null); + if(Objects.nonNull(record)) return true; + return false; + } } diff --git a/cloud/haikangface/src/main/java/com/sincere/haikangface/service/impl/UserOperateServiceImpl.java b/cloud/haikangface/src/main/java/com/sincere/haikangface/service/impl/UserOperateServiceImpl.java index f689d47..1ffcecd 100644 --- a/cloud/haikangface/src/main/java/com/sincere/haikangface/service/impl/UserOperateServiceImpl.java +++ b/cloud/haikangface/src/main/java/com/sincere/haikangface/service/impl/UserOperateServiceImpl.java @@ -6,7 +6,6 @@ import com.sincere.haikangface.CMSServer; import com.sincere.haikangface.async.SendUserAsync; import com.sincere.haikangface.bean.*; import com.sincere.haikangface.bean.face.*; -import com.sincere.haikangface.bean.test.SaveStudentBak; import com.sincere.haikangface.dao.DeviceDao; import com.sincere.haikangface.dao.UserDao; import com.sincere.haikangface.enums.EnumSzBusinessType; @@ -22,11 +21,10 @@ import org.springframework.stereotype.Service; import org.springframework.web.multipart.MultipartFile; import java.io.File; -import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; -import java.text.SimpleDateFormat; import java.util.*; +import java.util.function.Function; import java.util.stream.Collectors; /** @@ -125,16 +123,10 @@ public class UserOperateServiceImpl implements UserOperateService { @Override public Result sendHKAuth(Integer authId) { DeviceAuthRecord record = userDao.getAuthRecord(authId); - if(record ==null){ - log.info("未查询到对应权限ID: {}, 权限计划。",authId); - return ResultGenerator.genFailResult("未查询到对应下发权限计划"); - } - //设备ID - String[] deviceArr = record.getSno().split(","); - List devices= new ArrayList<>(Arrays.asList(deviceArr)); - if(CollectionUtils.isEmpty(devices)){ - return ResultGenerator.genFailResult("未选择权限计划下发设备。"); - } + if(Objects.isNull(record)) return ResultGenerator.genFailResult("未查询到对应下发权限计划"); + + List devices= Arrays.asList(record.getSno().split(",")); + if(CollectionUtils.isEmpty(devices)) return ResultGenerator.genFailResult("未选择权限计划下发设备。"); //学生类型 Integer studentType = record.getStudentType(); //周计划详情 @@ -188,54 +180,28 @@ public class UserOperateServiceImpl implements UserOperateService { } @Override - public Result againSendFace(String userId, String deviceId,Integer userType) { - StudentBean studentBean = null; - String cardNum =""; - String photo =""; - String studentCode = ""; - if(userType.intValue() ==1){ - studentBean = userDao.getTeacherByUserId(userId,null); - cardNum = studentBean.getTeacher_num(); - photo = studentBean.getFace(); - studentCode = studentBean.getNum(); - }else{ - studentBean = userDao.getStudentCByUserId(userId,null); - cardNum = studentBean.getStudent_num(); - photo = studentBean.getPhoto(); - studentCode = studentBean.getStudentCode(); - } - if (studentBean == null) { + public Result againSendFace(String userId, String deviceId, Integer userType) { + StudentBean bean = Objects.equals(userType,EnumSzBusinessType.EnumUserType.STUDENT.code) ? + userDao.getStudentByUserId(userId,null) : userDao.getTeacherByUserId(userId,null); + if (Objects.isNull(bean)) { log.error("下发人脸失败,userId: {},未查询到用户信息", userId); return ResultGenerator.genSuccessResult("未查询到用户信息"); } - Integer schoolId = studentBean.getSchool_id(); - String userName = studentBean.getName(); + String cardNum = Objects.equals(userType,EnumSzBusinessType.EnumUserType.STUDENT.code) ? + bean.getStudent_num() : bean.getTeacher_num(); + String photo = Objects.equals(userType,EnumSzBusinessType.EnumUserType.STUDENT.code) ? + bean.getPhoto() : bean.getFace(); + String studentCode = Objects.equals(userType,EnumSzBusinessType.EnumUserType.STUDENT.code) ? + bean.getStudentCode() : bean.getNum(); + Integer schoolId = bean.getSchool_id(); + String userName = bean.getName(); String typeName = userType.intValue() ==1 ? "Teacher" : "Student"; - String[] fileNameStr =photo.split(typeName +"/"); + String[] fileNameStr = photo.split(typeName +"/"); if(fileNameStr.length==0){ log.error("文件名为空,文件路径 :"+ photo); return ResultGenerator.genSuccessResult("文件名为空"); } - //以学籍号为名的文件名 - String fileName = photo.substring(photo.lastIndexOf("/") + 1,photo.length()); - //100服务器人脸照绝对路径 - String path_1 = "E:\\wwwhtdocs\\SmartCampus\\face17e50\\School" + schoolId + "\\" + typeName; - String path_2 = "E:\\wwwhtdocs\\SmartCampus\\face17e5\\School" + schoolId + "\\" + typeName; - String path_3 = "E:\\wwwhtdocs\\SmartCampus\\f0i5l7e5\\"; - String filePath=""; - if(photo.indexOf("f0i5l7e5")!=-1){ - String afterStr = photo.split("f0i5l7e5/")[1].replace("/","\\"); - filePath= path_3 + afterStr; - } - if(photo.indexOf("face17e5")!=-1){ - filePath = path_2 + "\\" + fileName; - } - if(photo.indexOf("face17e50")!=-1){ - filePath = path_1 + "\\" + fileName; - } - if(filePath.indexOf("?v=")!=-1){ - filePath = filePath.split("\\?")[0]; - } + String filePath = baseService.checkUserFace(bean,userType,schoolId); //校验100服务文件存储地址上是否存在此人脸 File file = new File(filePath.trim());//图片 if (!file.exists()) { @@ -249,6 +215,7 @@ public class UserOperateServiceImpl implements UserOperateService { CompressPic.CompressPic(file.getAbsolutePath(), targetPath); } catch (Exception e) { log.error("压缩图片失败:",e); + return ResultGenerator.genFailResult("重新下发失败"); } } //设备类型 @@ -264,87 +231,19 @@ public class UserOperateServiceImpl implements UserOperateService { } //2.重新下发 boolean isOk = baseService.sendImg(file.getAbsolutePath(), targetPath, deviceId, cardNum, userName, String.valueOf(userType), schoolId); - if (isOk) { - return ResultGenerator.genSuccessResult(); - } else { - return ResultGenerator.genFailResult("重新下发失败"); - } + if (!isOk) return ResultGenerator.genFailResult("重新下发失败"); } //下大华人脸 if(clintType.intValue()== 22 || clintType.intValue()== 29){ //下发单个人脸至大华设备 HttpUtil.uploadDHImgForOne(filePath,schoolId,studentCode,clintType,deviceId); - return ResultGenerator.genSuccessResult(); } return ResultGenerator.genSuccessResult(); } @Override - public Result sendUserFaceByThread(SendFaceDto sendFaceDto,Integer groupId) { - //下发设备集合 - String[] deviceArr = sendFaceDto.getsNos().split(","); - List deviceList= new ArrayList<>(Arrays.asList(deviceArr)); - if(deviceList.size()<1){ - return ResultGenerator.genFailResult("未选择下发设备"); - } - Integer schoolId = sendFaceDto.getSchoolId(); - Integer studentType = sendFaceDto.getStudentType(); - String sex = sendFaceDto.getSex(); - Integer userType = null; - if(sendFaceDto.getType().intValue()==0 || sendFaceDto.getType().intValue()==1){ - userType = 2; - }else{ - userType = 1; - } - //根据类型获取下发用户信息 - List studentBeanList = null; - if (userType == EnumSzBusinessType.EnumUserType.TEACHER.code) { - studentBeanList = baseService.getTeacherList(schoolId); - } - if (userType == EnumSzBusinessType.EnumUserType.STUDENT.code && groupId ==null) { - studentBeanList = baseService.getStudentList(schoolId,studentType,sex); - }else if(userType == EnumSzBusinessType.EnumUserType.STUDENT.code && groupId !=null){ - studentBeanList = baseService.getStudentListByGroup(schoolId,studentType,sex,groupId); - } - log.info("统计共有下发用户数量:{}",studentBeanList.size()); - //设备类型 - Integer clintType = userDao.getClintTypeByDeviceId(deviceList.get(0)); - if(clintType.intValue()== 22 || clintType.intValue()== 29){ - if(groupId ==null){ - //发送大华设备 - HttpUtil.uploadDHImg(String.valueOf(schoolId),userType,sendFaceDto.getsNos(),studentType,sex); - }else{ - Integer finalUserType = userType; - studentBeanList.stream().forEach(s->{ - String userId = s.getUser_id(); - deviceList.stream().forEach(deviceId ->{ - this.againSendFace(userId,deviceId, finalUserType); - }); - }); - } - } - if(clintType.intValue()== 18 || clintType.intValue()== 28){ - //发送海康设备:异步执行 - baseService.sendUserFaceByAsyncThread(schoolId,userType,studentBeanList,deviceList); - } - int fileSize = studentBeanList.size(); - int clintNum = deviceList.size(); - //下发所用时长 - int timeLength = new Double(clintNum * fileSize * 0.06).intValue(); - //下发截止时间 - String dateStr = baseService.getTime(fileSize,clintNum,timeLength); - Map map = new HashMap(); - map.put("timeLength",timeLength); - map.put("afterDate",dateStr); - map.put("fileSize",fileSize); - return ResultGenerator.genSuccessResult(objectMapper.toJson(map)); - } - - @Override public Result deleteFailFace(Integer schoolId) { - if(schoolId ==null){ - return ResultGenerator.genFailResult("删除失败人脸,学校ID不能为空"); - } + if(schoolId ==null) return ResultGenerator.genFailResult("删除失败人脸,学校ID不能为空"); List recordBeanList = sendRecordDao.getFailRecord(schoolId); if(recordBeanList.size()>0){ for(SendRecordBean recordBean : recordBeanList){ @@ -369,7 +268,6 @@ public class UserOperateServiceImpl implements UserOperateService { HttpUtil.deleteDHFace(schoolId,cardNum,deviceId); } //删除成功记录 - sendRecordDao.deleteUserFaceSuccess(schoolId,cardNum,deviceId); sendRecordDao.deleteRecord(schoolId,deviceId,cardNum); }catch (Exception e){ log.error("删除失败人脸失败,异常信息:{}",e); @@ -381,414 +279,163 @@ public class UserOperateServiceImpl implements UserOperateService { } @Override - public Result sendFailFace(Integer schoolId) { - if(schoolId ==null){ - return ResultGenerator.genFailResult("删除失败人脸,学校ID不能为空"); - } - List recordBeanList = sendRecordDao.getFailRecord(schoolId); - if(recordBeanList.size()>0){ - for(SendRecordBean recordBean : recordBeanList){ - try{ - //用户类型1老师2学生 - int userType = recordBean.getUserType(); - //人脸卡号 - String cardNum = recordBean.getNum(); - //设备ID、设备类型 - String deviceId = recordBean.getDeviceID(); - Integer clintType = userDao.getClintTypeByDeviceId(deviceId); - //2.重新下发 - StudentBean studentBean= null; - String typeName =""; - String photo = ""; - if(userType ==1){ - typeName= "Teacher"; - studentBean = userDao.getTeacherWithCard(cardNum,schoolId); - photo=studentBean.getFace(); + public Result sendFailFace(SendFaceBean faceBean) { + List recordList = baseService.getSendRecordList(faceBean); + if(CollectionUtils.isEmpty(recordList)) return ResultGenerator.genSuccessResult(); + recordList.stream().forEach(s->{ + try{ + //用户类型1老师2学生 + Integer userType = s.getUserType(); + String userId = s.getUserId(); + Integer schoolId = s.getSchoolId(); + String deviceId = s.getDeviceID(); + //2.重新下发 + StudentBean bean = Objects.equals(userType,EnumSzBusinessType.EnumUserType.STUDENT.code) ? + userDao.getStudentByUserId(userId,null) : userDao.getTeacherByUserId(userId,null); + String cardNum = Objects.equals(userType,EnumSzBusinessType.EnumUserType.STUDENT.code) ? + bean.getStudent_num() : bean.getTeacher_num(); + String photo = Objects.equals(userType,EnumSzBusinessType.EnumUserType.STUDENT.code) ? + bean.getPhoto() : bean.getFace(); + String studentCode = Objects.equals(userType,EnumSzBusinessType.EnumUserType.STUDENT.code) ? + bean.getStudentCode() : bean.getNum(); + if(Objects.isNull(bean) || StringUtils.isBlank(photo) || StringUtils.isBlank(cardNum)) return; + + String userName= bean.getName(); + String filePath = baseService.checkUserFace(bean,userType,schoolId); + File file = new File(filePath);//图片 + if(file.exists()) return; + Integer clintType = userDao.getClintTypeByDeviceId(deviceId); + //下发海康人脸 + if(clintType.intValue()== 18 || clintType.intValue()== 28){ + //1.先删除人脸 + if (cmsServer.getIsDeviceOnline(deviceId)) { + String cardNo = Long.parseLong(baseService.getCard(cardNum),16) + ""; + cmsServer.deleteFace(deviceId, cardNo,schoolId); }else{ - typeName= "Student"; - studentBean= userDao.getStudentWithCard(cardNum,schoolId); - photo=studentBean.getPhoto(); - } - if(studentBean==null|| StringUtils.isBlank(photo)){ - continue; - } - String userName= studentBean.getName(); - String studentCode = studentBean.getStudentCode(); - String filePath=""; - //下发海康人脸 - if(clintType.intValue()== 18 || clintType.intValue()== 28){ - //1.先删除人脸 - if (cmsServer.getIsDeviceOnline(deviceId)) { - String cardNo = Long.parseLong(baseService.getCard(cardNum),16) + ""; - cmsServer.deleteFace(deviceId, cardNo,schoolId); - }else{ - //不在线,去253服务器上删除 - HttpUtil.deleteCard(deviceId, cardNum); - } - //以学籍号为名的文件名 - String fileName = photo.substring(photo.lastIndexOf("/") + 1,photo.length()); - //100服务器人脸照绝对路径 - String path_1 = "E:\\wwwhtdocs\\SmartCampus\\face17e50\\School" + schoolId + "\\" + typeName; - String path_2 = "E:\\wwwhtdocs\\SmartCampus\\face17e5\\School" + schoolId + "\\" + typeName; - String path_3 = "E:\\wwwhtdocs\\SmartCampus\\f0i5l7e5\\"; - if(photo.indexOf("f0i5l7e5")!=-1){ - String afterStr = photo.split("f0i5l7e5/")[1].replace("/","\\"); - filePath= path_3 + afterStr; - } - if(photo.indexOf("face17e5")!=-1){ - filePath = path_2 + "\\" + fileName; - } - if(photo.indexOf("face17e50")!=-1){ - filePath = path_1 + "\\" + fileName; - } - if(filePath.indexOf("?v=")!=-1){ - filePath = filePath.split("\\?")[0]; - } - File file = new File(filePath);//图片 - if(file.exists()){ - String targetPath = FileUtils.picPathComp + file.getName(); - try { - CompressPic.CompressPic(file.getAbsolutePath(), targetPath); - } catch (Exception e) { - log.error("压缩图片失败:",e); - continue; - } - if(!StringUtils.isBlank(cardNum)) { - baseService.sendImg(file.getAbsolutePath(), targetPath, deviceId, cardNum, userName, String.valueOf(userType), schoolId); - } - } + //不在线,去253服务器上删除 + HttpUtil.deleteCard(deviceId, cardNum); } - //下发大华人脸 - if(clintType.intValue()== 22 || clintType.intValue()== 29){ - HttpUtil.uploadDHImgForOne(filePath,schoolId,studentCode,clintType,deviceId); - } - }catch (Exception e){ - log.error("下发失败表人脸失败,异常信息:{}",e); - continue; + String targetPath = FileUtils.picPathComp + file.getName(); + CompressPic.CompressPic(file.getAbsolutePath(), targetPath); + baseService.sendImg(file.getAbsolutePath(), targetPath, deviceId, cardNum, userName, String.valueOf(userType), schoolId); } - } - } - return ResultGenerator.genSuccessResult(); - } - - - @Override - public Result sendFailFace2(Integer schoolId,String deviceIds) { - if(schoolId ==null){ - return ResultGenerator.genFailResult("删除失败人脸,学校ID不能为空"); - } - List resultList = new ArrayList<>(); - if(StringUtils.isNotBlank(deviceIds)){ - //设备集合 - String[] deviceArr = deviceIds.split(","); - List deviceList= new ArrayList<>(Arrays.asList(deviceArr)); - for(String deviceId : deviceList){ - List recordBeanList = sendRecordDao.getFailRecord2(schoolId,deviceId); - resultList.addAll(recordBeanList); - } - }else{ - List recordBeanList = sendRecordDao.getFailRecord(schoolId); - resultList.addAll(recordBeanList); - } - if(resultList.size()>0){ - for(SendRecordBean recordBean : resultList){ - try{ - //用户类型1老师2学生 - int userType = recordBean.getUserType(); - //人脸卡号 - String cardNum = recordBean.getNum(); - //设备ID、设备类型 - String deviceId = recordBean.getDeviceID(); - Integer clintType = userDao.getClintTypeByDeviceId(deviceId); - //2.重新下发 - StudentBean studentBean= null; - String typeName =""; - String photo = ""; - if(userType ==1){ - typeName= "Teacher"; - studentBean = userDao.getTeacherWithCard(cardNum,schoolId); - photo=studentBean.getFace(); - }else{ - typeName= "Student"; - studentBean= userDao.getStudentWithCard(cardNum,schoolId); - photo=studentBean.getPhoto(); - } - if(studentBean==null|| StringUtils.isBlank(photo)){ - continue; - } - String userName= studentBean.getName(); - String studentCode = studentBean.getStudentCode(); - String filePath=""; - //下发海康人脸 - if(clintType.intValue()== 18 || clintType.intValue()== 28){ - //1.先删除人脸 - if (cmsServer.getIsDeviceOnline(deviceId)) { - String cardNo = Long.parseLong(baseService.getCard(cardNum),16) + ""; - cmsServer.deleteFace(deviceId, cardNo,schoolId); - }else{ - //不在线,去253服务器上删除 - HttpUtil.deleteCard(deviceId, cardNum); - } - //以学籍号为名的文件名 - String fileName = photo.substring(photo.lastIndexOf("/") + 1,photo.length()); - //100服务器人脸照绝对路径 - String path_1 = "E:\\wwwhtdocs\\SmartCampus\\face17e50\\School" + schoolId + "\\" + typeName; - String path_2 = "E:\\wwwhtdocs\\SmartCampus\\face17e5\\School" + schoolId + "\\" + typeName; - String path_3 = "E:\\wwwhtdocs\\SmartCampus\\f0i5l7e5\\"; - if(photo.indexOf("f0i5l7e5")!=-1){ - String afterStr = photo.split("f0i5l7e5/")[1].replace("/","\\"); - filePath= path_3 + afterStr; - } - if(photo.indexOf("face17e5")!=-1){ - filePath = path_2 + "\\" + fileName; - } - if(photo.indexOf("face17e50")!=-1){ - filePath = path_1 + "\\" + fileName; - } - if(filePath.indexOf("?v=")!=-1){ - filePath = filePath.split("\\?")[0]; - } - File file = new File(filePath);//图片 - if(file.exists()){ - String targetPath = FileUtils.picPathComp + file.getName(); - try { - CompressPic.CompressPic(file.getAbsolutePath(), targetPath); - } catch (Exception e) { - log.error("压缩图片失败:",e); - continue; - } - if(!StringUtils.isBlank(cardNum)) { - baseService.sendImg(file.getAbsolutePath(), targetPath, deviceId, cardNum, userName, String.valueOf(userType), schoolId); - } - } - } - //下发大华人脸 - if(clintType.intValue()== 22 || clintType.intValue()== 29){ - HttpUtil.uploadDHImgForOne(filePath,schoolId,studentCode,clintType,deviceId); - } - }catch (Exception e){ - log.error("下发失败表人脸失败,异常信息:{}",e); - continue; + if(clintType.intValue()== 22 || clintType.intValue()== 29){ + HttpUtil.uploadDHImgForOne(filePath,schoolId,studentCode,clintType,deviceId); } + }catch (Exception e){ + log.error("下发失败表人脸失败,异常信息:{}",e); + return; } - } + }); return ResultGenerator.genSuccessResult(); } @Override - public Result deleteFace(Integer schoolId,String cards,String deviceIds) { - if(StringUtils.isBlank(cards)){ - return ResultGenerator.genFailResult("删除人脸卡号为空"); - } - List deviceList = new ArrayList<>(); - if(StringUtils.isBlank(deviceIds)){ - List clintList = userDao.getDeviceIds(schoolId,null); - if(CollectionUtils.isNotEmpty(clintList)){ - deviceList.addAll(clintList); - } - }else{ - //设备集合 - String[] deviceArr = deviceIds.split(","); - deviceList= new ArrayList<>(Arrays.asList(deviceArr)); - } - String[] cardArr = cards.split(","); - List cardList = new ArrayList<>(Arrays.asList(cardArr)); + public Result deleteFace(SendFaceBean faceBean) { + //下发设备集合 + List deviceList = baseService.getDeviceList(faceBean.getDeviceIds(),faceBean.getSchoolId()); + List cardList = faceBean.getCardList(); + if(CollectionUtils.isEmpty(cardList)) return ResultGenerator.genFailResult("删除卡号必传"); for(String card : cardList){ - //未指定设备,删除学校下所有 - if(CollectionUtils.isNotEmpty(deviceList)) { - for (String sno : deviceList) { - try { - //设备类型 - Integer clintType = userDao.getClintTypeByDeviceId(sno); - if (clintType.intValue() == 18 || clintType.intValue() == 28) { - //删除海康设备人脸 - if (cmsServer.getIsDeviceOnline(sno)) { - String cardNo = Long.parseLong(baseService.getCard(card), 16) + ""; - cmsServer.deleteFace(sno, cardNo, schoolId); - } else { - HttpUtil.deleteCard(sno, card); - } - } - if (clintType.intValue() == 22 || clintType.intValue() == 29) { - //删除大华设备人脸 - HttpUtil.deleteDHFace(schoolId, card, sno); + for (String sno : deviceList) { + try { + //设备类型 + Integer clintType = userDao.getClintTypeByDeviceId(sno); + if (clintType.intValue() == 18 || clintType.intValue() == 28) { + //删除海康设备人脸 + if (cmsServer.getIsDeviceOnline(sno)) { + String cardNo = Long.parseLong(baseService.getCard(card), 16) + ""; + cmsServer.deleteFace(sno, cardNo, faceBean.getSchoolId()); + } else { + HttpUtil.deleteCard(sno, card); } - //删除成功记录 - sendRecordDao.deleteUserFaceSuccess(schoolId,card,sno); - sendRecordDao.deleteRecord(schoolId,sno,card); - } catch (Exception e) { - log.error("删除人脸失败,异常信息:{}", e); - continue; } + if (clintType.intValue() == 22 || clintType.intValue() == 29) { + //删除大华设备人脸 + HttpUtil.deleteDHFace(faceBean.getSchoolId(), card, sno); + } + //删除成功记录 + sendRecordDao.deleteRecord(faceBean.getSchoolId(), sno,card); + } catch (Exception e) { + log.error("删除人脸失败,异常信息:{}", e); + continue; } } } return ResultGenerator.genSuccessResult(); } - @Override - public Result sendFaceForNoSend(Integer schoolId,Integer studentType,String sex,Integer userType,String deviceIds,Integer groupId) { - //若未传下发,则下发该学校下所有设备 - //下发设备集合 - List idLists = null; - if(StringUtils.isBlank(deviceIds)){ - idLists = userDao.getDeviceIds(schoolId,null); - }else{ - String[] deviceArr = deviceIds.split(","); - idLists= new ArrayList<>(Arrays.asList(deviceArr)); - } - if(CollectionUtils.isEmpty(idLists)){ - log.warn("该学校下未查询到下发设备"); - return ResultGenerator.genFailResult("该学校下未查询到下发设备"); - } - //下发用户集合 - List list = null; - if (userType == EnumSzBusinessType.EnumUserType.STUDENT.code && groupId ==null) { - list = baseService.getStudentList(schoolId,studentType,sex); - }else if(userType == EnumSzBusinessType.EnumUserType.STUDENT.code && groupId !=null){ - list = baseService.getStudentListByGroup(schoolId,studentType,sex,groupId); - } - if(userType.intValue()==EnumSzBusinessType.EnumUserType.TEACHER.code){ - list = baseService.getTeacherList(schoolId); - } - //异步执行下发 - sendFaceForNoSend(schoolId,userType,list,idLists); - int fileSize = list.size(); - int clintNum = idLists.size(); - //下发所用时长 - int timeLength = new Double(clintNum * fileSize * 0.06).intValue(); - //下发截止时间 - String dateStr = baseService.getTime(fileSize,clintNum,timeLength); - Map map = new HashMap(); - map.put("timeLength",timeLength); - map.put("afterDate",dateStr); - map.put("fileSize",fileSize); - return ResultGenerator.genSuccessResult(objectMapper.toJson(map)); - } - + /** + * 下发未发人脸 + * @param studentList + * @param deviceIds + */ @Async - public void sendFaceForNoSend(Integer schoolId,Integer userType,List studentList,List deviceIds){ - log.info("统计共有:"+studentList.size()+"张卡,"+deviceIds.size()+"台设备." ); - for(StudentBean studentBean : studentList){ + public void sendFaceForNoSend(SendFaceBean faceBean,List studentList,List deviceIds){ + log.info("统计学校共有:"+studentList.size()+"张卡,"+deviceIds.size()+"台设备." ); + List sendRecords = baseService.getSendRecordList(faceBean); + List list = sendRecords.parallelStream() + .collect(Collectors.toMap(t-> Arrays.asList(t.getSchoolId(),t.getNum(),t.getDeviceID()), + Function.identity(),(oldValue, newValue) -> oldValue)) + .values().stream().collect(Collectors.toList()); + studentList.stream().forEach(s->{ + String userName = s.getName(); + String studentCode = s.getStudentCode(); + String studentNum = s.getStudent_num(); + String filePath = baseService.checkUserFace(s, faceBean.getUserType(), faceBean.getSchoolId()); + if(StringUtils.isBlank(filePath)) return; + File file = new File(filePath); + if(!file.exists()) return; + String targetPath = FileUtils.picPathComp + file.getName(); + try { + CompressPic.CompressPic(file.getAbsolutePath(), targetPath); + } catch (Exception e) { + log.error("压缩图片失败:",e); + return; + } for(String sno : deviceIds){ try{ - //卡号 - String cardNum = userType.intValue()==1?studentBean.getTeacher_num():studentBean.getStudent_num(); - //人脸照 - String photo = userType.intValue()==1?studentBean.getFace():studentBean.getPhoto(); - if (StringUtils.isBlank(photo) || StringUtils.isBlank(cardNum)){ - continue; - } - String userName= studentBean.getName(); - String userId = studentBean.getUser_id(); - String studentCode = studentBean.getStudentCode(); - List bean = sendRecordDao.getRecordIsExit(sno,cardNum,userId); - if(CollectionUtils.isNotEmpty(bean)){ - continue; - } - String typeName= userType.intValue()==1?"Teacher":"Student"; - //以学籍号为名的文件名 - String fileName = photo.substring(photo.lastIndexOf("/") + 1,photo.length()); - //100服务器人脸照绝对路径 - String path_1 = "E:\\wwwhtdocs\\SmartCampus\\face17e50\\School" + schoolId + "\\" + typeName; - String path_2 = "E:\\wwwhtdocs\\SmartCampus\\face17e5\\School" + schoolId + "\\" + typeName; - String path_3 = "E:\\wwwhtdocs\\SmartCampus\\f0i5l7e5\\"; - String filePath=""; - if(photo.indexOf("f0i5l7e5")!=-1){ - String afterStr = photo.split("f0i5l7e5/")[1].replace("/","\\"); - filePath= path_3 + afterStr; - } - if(photo.indexOf("face17e5")!=-1){ - filePath = path_2 + "\\" + fileName; - } - if(photo.indexOf("face17e50")!=-1){ - filePath = path_1 + "\\" + fileName; - } - if(filePath.indexOf("?v=")!=-1){ - filePath = filePath.split("\\?")[0]; - } - File file = new File(filePath);//图片 - if(file.exists()){ - String targetPath = FileUtils.picPathComp + file.getName(); - try { - CompressPic.CompressPic(file.getAbsolutePath(), targetPath); - } catch (Exception e) { - log.error("压缩图片失败:",e); - continue; - } - if(!StringUtils.isBlank(cardNum)) { - //设备类型 - Integer clintType = userDao.getClintTypeByDeviceId(sno); - if(clintType.intValue()== 18 || clintType.intValue()== 28){ - baseService.sendImg(file.getAbsolutePath(), targetPath, sno, cardNum, userName, String.valueOf(userType), schoolId); - } - //下大华人脸 - if(clintType.intValue()== 22 || clintType.intValue()== 29){ - //下发单个人脸至大华设备 - HttpUtil.uploadDHImgForOne(filePath,schoolId,studentCode,clintType,sno); - } - } - } + if(baseService.checkSendRecord(list,sno, faceBean.getSchoolId(), studentNum)) continue; + Integer clintType = userDao.getClintTypeByDeviceId(sno); + //大华 + if(clintType.intValue()== 18 || clintType.intValue()== 28) + baseService.sendImg(file.getAbsolutePath(), targetPath, sno, studentNum, userName, + String.valueOf(faceBean.getUserType()), faceBean.getSchoolId()); + //海康 + if(clintType.intValue()== 22 || clintType.intValue()== 29) + HttpUtil.uploadDHImgForOne(filePath, faceBean.getSchoolId(), studentCode,clintType,sno); }catch (Exception e){ log.error("人脸下发失败"); e.printStackTrace(); continue; } } - } + }); } @Override public Result againNoSendOneFace(MultipartFile file, Integer schoolId, String cardNum, Integer userType, String deviceIds) { - if(StringUtils.isBlank(cardNum)){ - return ResultGenerator.genFailResult("卡号为空"); - } - if(StringUtils.isBlank(deviceIds)){ - return ResultGenerator.genFailResult("未指定下发设备"); - } - StudentBean studentBean=null; - if(userType.intValue()==2){ - studentBean= userDao.getStudentWithCard(cardNum,schoolId); - }else{ - studentBean= userDao.getTeacherWithCard(cardNum,schoolId); - } - if(studentBean ==null){ - return ResultGenerator.genFailResult("此卡号未查询到对应学生/老师信息"); - } + if(StringUtils.isBlank(cardNum)) return ResultGenerator.genFailResult("卡号为空"); + if(StringUtils.isBlank(deviceIds)) return ResultGenerator.genFailResult("未指定下发设备"); + StudentBean studentBean = Objects.equals(userType,EnumSzBusinessType.EnumUserType.STUDENT.code) ? + userDao.getStudentWithCard(cardNum,schoolId) : userDao.getTeacherWithCard(cardNum,schoolId); + if(Objects.isNull(studentBean)) return ResultGenerator.genFailResult("此卡号未查询到对应学生/老师信息"); + String userName = studentBean.getName(); - String studentCode = userType.intValue()==1?studentBean.getNum():studentBean.getStudentCode(); + String studentCode = userType.intValue()==1 ? studentBean.getNum(): studentBean.getStudentCode(); String typeName = userType.intValue()==1?"Teacher":"Student"; - //100服务器人脸照绝对路径 - String path = "E:\\wwwhtdocs\\SmartCampus\\face17e5\\School" + schoolId + "\\" + typeName; - if(!new File(path).exists()){ - new File(path).mkdirs(); - } //以学籍号为名的文件名 String fileName = studentCode + ".png"; - //人脸文件路径 - String facePath = path + "\\" +fileName; - try { - File absolutePath = new File(facePath); - FileOutputStream fileOutputStream = new FileOutputStream(absolutePath); - fileOutputStream.write(file.getBytes()); - fileOutputStream.close(); - }catch (IOException e){ - log.error("文件处理异常: ",e); - } -// //在线活体检测 -// String result = HttpUtil.checkFace(facePath); -// if(StringUtils.isBlank(result) || result.equals("false")){ -// log.error("人脸检测不合格!"); -// return ResultGenerator.genFailResult("请添加规范的人脸照片."); -// } + String facePath = ""; + if(file.isEmpty()) facePath = this.getFilePath(schoolId,typeName,fileName,file); + else facePath = baseService.checkUserFace(studentBean,userType,schoolId); String targetPath = FileUtils.picPathComp + file.getName(); try { CompressPic.CompressPic(new File(facePath).getAbsolutePath(), targetPath); } catch (Exception e) { log.error("压缩图片失败: ",e); } - String[] deviceArr = deviceIds.split(","); - List deviceList= new ArrayList<>(Arrays.asList(deviceArr)); + List deviceList= Arrays.asList(deviceIds.split(",")); if(CollectionUtils.isNotEmpty(deviceList)){ for(String deviceId : deviceList) { //获取设备类型 @@ -808,6 +455,24 @@ public class UserOperateServiceImpl implements UserOperateService { return ResultGenerator.genSuccessResult(); } + private String getFilePath(Integer schoolId,String typeName,String fileName,MultipartFile file){ + //100服务器人脸照绝对路径 + String path = "E:\\wwwhtdocs\\SmartCampus\\face17e5\\School" + schoolId + "\\" + typeName; + File saveFile = new File(path); + if(!saveFile.exists()) saveFile.mkdirs(); + //人脸文件路径 + String facePath = path + "\\" + fileName; + try { + File absolutePath = new File(facePath); + FileOutputStream fileOutputStream = new FileOutputStream(absolutePath); + fileOutputStream.write(file.getBytes()); + fileOutputStream.close(); + }catch (IOException e){ + log.error("文件处理异常: ",e); + } + return facePath; + } + @Override public Result insertUpdateCard(String cardNums) { String[] cardArr = cardNums.split(","); @@ -843,78 +508,6 @@ public class UserOperateServiceImpl implements UserOperateService { return new Result(); } - @Override - public Result exportFace(Integer schoolId,Integer userType,String deviceIds,String faceSrcPath) { - File imgPathFile = new File(faceSrcPath);//目录 - File[] imgfiles = imgPathFile.listFiles(); - if(imgfiles.length==0){ - return ResultGenerator.genFailResult("未获取要下发的人脸照片。"); - } - List sendFaces = new ArrayList<>(); - for (int i = 0; i < imgfiles.length; i++) { - try{ - //人脸照片 - File file = imgfiles[i]; - if(!file.isFile()){ - continue; - } - if (file.exists()){ - //原始文件路径 - String srcPath = file.getAbsolutePath(); - //原始文件名 - String fileName = file.getName(); - System.out.println("文件名:"+ fileName+", 学籍号:"+ fileName.split("\\.")[0]); - StudentBean studentBean = new StudentBean(); - if (userType.intValue()==1) { - studentBean = userDao.getTeacherWithstudentcode(fileName.split("\\.")[0],String.valueOf(schoolId)); - }else { - studentBean = userDao.getStudentWithstudentcode(fileName.split("\\.")[0],String.valueOf(schoolId)); - } - if(studentBean == null){ - continue; - } - String typeName = userType.intValue() ==1 ? "Teacher" : "Student"; - String targetPath = "E:\\wwwhtdocs\\SmartCampus\\face17e50\\School" + schoolId + "\\" + typeName; -// //目标路径 - targetPath = targetPath + "\\" + fileName; - //复制文件 - copy(srcPath,targetPath); - String savePath = "http://campus.myjxt.com//face17e50/School"+ schoolId + "/" + typeName + "/" + fileName; - if(userType.intValue() ==1){ - studentBean.setFace(savePath); - }else { - studentBean.setPhoto(savePath); - } - //savePath - userDao.updateUser(studentBean.getUser_id(),savePath); - sendFaces.add(studentBean); - } - file.delete(); - }catch (Exception e){ - e.printStackTrace(); - continue; - } - } - if(StringUtils.isBlank(deviceIds)){ - return ResultGenerator.genFailResult("未选择下发设备"); - } - String[] deviceArr = deviceIds.split(","); - List deviceList = new ArrayList<>(Arrays.asList(deviceArr)); - //异步执行下发 - asyncSendFace(sendFaces,deviceList,schoolId,userType); - int fileSize = sendFaces.size(); - int clintNum = deviceList.size(); - //下发所用时长 - int timeLength = new Double(clintNum * fileSize * 0.06).intValue(); - //下发截止时间 - String dateStr = baseService.getTime(fileSize,clintNum,timeLength); - Map map = new HashMap(); - map.put("timeLength",timeLength); - map.put("afterDate",dateStr); - map.put("fileSize",fileSize); - return ResultGenerator.genSuccessResult(objectMapper.toJson(map)); - } - public void asyncSendFace(List sendFaces,List deviceList,Integer schoolId,Integer userType){ log.info("总共检测到:{},张人脸照片。",sendFaces.size()); //设备类型 @@ -925,103 +518,18 @@ public class UserOperateServiceImpl implements UserOperateService { } } - private static void copy(String srcPathStr, String desPathStr) { - //获取源文件的名称 - try { - FileInputStream fis = new FileInputStream(srcPathStr);//创建输入流对象 - FileOutputStream fos = new FileOutputStream(desPathStr); //创建输出流对象 - byte datas[] = new byte[1024*8];//创建搬运工具 - int len = 0;//创建长度 - while((len = fis.read(datas))!=-1)//循环读取数据 - { - fos.write(datas,0,len); - } - fis.close();//释放资源 - fis.close();//释放资源 - } - catch (Exception e) - { - e.printStackTrace(); - } - } - @Override - public Result sendFaceByClassId(Integer schoolId,String classIds,String deviceIds,Integer studentType,String sex,Integer isCheck) { - //下发设备集合 - List deviceList = null; - if(StringUtils.isBlank(deviceIds)){ - deviceList = deviceDao.selectDeviceBySchoolId(schoolId); - }else{ - deviceList= new ArrayList<>(Arrays.asList(deviceIds.split(","))); - } - List resultCard = new ArrayList<>(); - List resultDevices = new ArrayList<>(); - //根据类型获取下发用户信息 - List studentBeanList = baseService.getStudentByClassId(schoolId,classIds,studentType,sex); - log.info("统计共有下发用户数量:{}",studentBeanList.size()); - if(isCheck !=null){ - for(StudentBean studentBean : studentBeanList){ - String cardNum = studentBean.getStudent_num(); - boolean isOk = true; - for(String deviceId : deviceList){ - if (cmsServer.getIsDeviceOnline(deviceId)) { - String cardNo = Long.parseLong(baseService.getCard(cardNum), 16) + ""; - isOk = cmsServer.getFace(deviceId,cardNo,null); - }else{ - isOk = HttpUtil.getCard(deviceId, cardNum); - } - if(!isOk){ - resultCard.add(studentBean); - resultCard.add(studentBean); - resultDevices.add(deviceId); - } - } - } - //去重重复数据 - studentBeanList = resultCard.stream().collect(Collectors.collectingAndThen( - Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(StudentBean::getStudent_num))), ArrayList::new)); - //去重重复数据 - deviceList = resultDevices.stream().distinct().collect(Collectors.toList()); - } - log.info("统计共有下发用户数量:{}",studentBeanList.size()); - //设备类型 - Integer clintType = userDao.getClintTypeByDeviceId(deviceList.get(0)); - if(clintType.intValue()== 22 || clintType.intValue()== 29){ - //发送大华设备 - HttpUtil.uploadDHImgByClassId(String.valueOf(schoolId),deviceIds,classIds); - } - if(clintType.intValue()== 18 || clintType.intValue()== 28){ - //发送海康设备:异步执行 - baseService.sendUserFaceByAsyncThread(schoolId,2,studentBeanList,deviceList); - } - int fileSize = studentBeanList.size(); - int clintNum = deviceList.size(); - //下发所用时长 - int timeLength = new Double(clintNum * fileSize * 0.06).intValue(); - //下发截止时间 - String dateStr = baseService.getTime(fileSize,clintNum,timeLength); - Map map = new HashMap(); - map.put("timeLength",timeLength); - map.put("afterDate",dateStr); - map.put("fileSize",fileSize); - return ResultGenerator.genSuccessResult(objectMapper.toJson(map)); - } @Override - public Result sendFaceByKeyword(Integer schoolId,String keyword,String deviceIds,Integer studentType,String sex,Integer isCheck) { + public Result sendFaceByClassId(SendFaceBean faceBean) { //下发设备集合 - List deviceList = null; - if(StringUtils.isBlank(deviceIds)){ - deviceList = deviceDao.selectDeviceBySchoolId(schoolId); - }else{ - deviceList= Arrays.asList(deviceIds.split(",")); - } + List deviceList = baseService.getDeviceList(faceBean.getDeviceIds(),faceBean.getSchoolId()); List resultCard = new ArrayList<>(); List resultDevices = new ArrayList<>(); //根据类型获取下发用户信息 - List studentBeanList = baseService.getStudentByKeyword(schoolId,keyword,studentType,sex); + List studentBeanList = baseService.getStudentByClassId(faceBean); log.info("统计共有下发用户数量:{}",studentBeanList.size()); - if(isCheck !=null){ + if(Objects.equals(faceBean.getIsCheck(),1)){ for(StudentBean studentBean : studentBeanList){ String cardNum = studentBean.getStudent_num(); boolean isOk = true; @@ -1041,21 +549,20 @@ public class UserOperateServiceImpl implements UserOperateService { } //去重重复数据 studentBeanList = resultCard.stream().collect(Collectors.collectingAndThen( - Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(StudentBean::getStudent_num))), ArrayList::new)); + Collectors.toCollection(() -> new TreeSet<>(Comparator + .comparing(StudentBean::getStudent_num))), ArrayList::new)); //去重重复数据 deviceList = resultDevices.stream().distinct().collect(Collectors.toList()); } log.info("统计共有下发用户数量:{}",studentBeanList.size()); //设备类型 Integer clintType = userDao.getClintTypeByDeviceId(deviceList.get(0)); - if(clintType.intValue()== 22 || clintType.intValue()== 29){ - //发送大华设备 - HttpUtil.uploadDHImgByClassId(String.valueOf(schoolId),deviceIds,keyword); - } - if(clintType.intValue()== 18 || clintType.intValue()== 28){ - //发送海康设备:异步执行 - baseService.sendUserFaceByAsyncThread(schoolId,2,studentBeanList,deviceList); - } + //发送大华设备 + if(clintType.intValue()== 22 || clintType.intValue()== 29) + HttpUtil.uploadDHImgByClassId(String.valueOf(faceBean.getSchoolId()),faceBean.getDeviceIds(),faceBean.getClassIds()); + //发送海康设备:异步执行 + if(clintType.intValue()== 18 || clintType.intValue()== 28) + baseService.sendUserFaceByAsyncThread(faceBean.getSchoolId(),2,studentBeanList,deviceList); int fileSize = studentBeanList.size(); int clintNum = deviceList.size(); //下发所用时长 @@ -1070,16 +577,15 @@ public class UserOperateServiceImpl implements UserOperateService { } @Override - public Result noSendByKeyword(Integer schoolId,String keyword,String deviceIds) { + public Result sendNuFaceByClassId(SendFaceBean faceBean) { //下发设备集合 - List deviceList = Arrays.asList(deviceIds.split(",")); + List deviceList = baseService.getDeviceList(faceBean.getDeviceIds(),faceBean.getSchoolId()); //根据类型获取下发用户信息 - List studentBeanList = baseService.getStudentByKeyword(schoolId,keyword,null,null); - + List studentBeans = Objects.equals(faceBean.getUserType(),EnumSzBusinessType.EnumUserType.TEACHER.code) ? + baseService.getStudentByClassId(faceBean) : baseService.getTeacherList(faceBean.getSchoolId()); //异步执行下发 - sendFaceForNoSend(schoolId,2,studentBeanList,deviceList); - - int fileSize = studentBeanList.size(); + this.sendFaceForNoSend(faceBean,studentBeans,deviceList); + int fileSize = studentBeans.size(); int clintNum = deviceList.size(); //下发所用时长 int timeLength = new Double(clintNum * fileSize * 0.06).intValue(); @@ -1093,17 +599,11 @@ public class UserOperateServiceImpl implements UserOperateService { } @Override - public Result sendFaceByRoomId(Integer schoolId,Integer roomId,String deviceIds) { + public Result sendFaceByRoomId(SendFaceBean faceBean) { //下发设备集合 - List deviceList = new ArrayList<>(); - if(StringUtils.isBlank(deviceIds)){ - deviceList = deviceDao.selectDeviceBySchoolId(schoolId); - }else{ - String[] deviceArr = deviceIds.split(","); - deviceList= new ArrayList<>(Arrays.asList(deviceArr)); - } + List deviceList = baseService.getDeviceList(faceBean.getDeviceIds(),faceBean.getSchoolId()); //根据类型获取下发用户信息 - List studentBeanList = baseService.getStudentListByRoomId(schoolId,roomId); + List studentBeanList = baseService.getStudentListByRoomId(faceBean.getSchoolId(),faceBean.getRoomId()); log.info("统计共有下发用户数量:{}",studentBeanList.size()); //设备类型 Integer clintType = userDao.getClintTypeByDeviceId(deviceList.get(0)); @@ -1113,7 +613,7 @@ public class UserOperateServiceImpl implements UserOperateService { // } if(clintType.intValue()== 18 || clintType.intValue()== 28){ //发送海康设备:异步执行 - baseService.sendUserFaceByAsyncThread(schoolId,2,studentBeanList,deviceList); + baseService.sendUserFaceByAsyncThread(faceBean.getSchoolId(),faceBean.getUserType(),studentBeanList,deviceList); } int fileSize = studentBeanList.size(); int clintNum = deviceList.size(); @@ -1129,148 +629,82 @@ public class UserOperateServiceImpl implements UserOperateService { } @Override - public Result deleteFaceBySchoolId(Integer schoolId, String deviceIds) { + public Result deleteByCondition(SendFaceBean faceBean) { //下发设备集合 - List deviceList = null; - if(StringUtils.isBlank(deviceIds)){ - deviceList = deviceDao.selectDeviceBySchoolId(schoolId); - }else{ - String[] deviceArr = deviceIds.split(","); - deviceList= new ArrayList<>(Arrays.asList(deviceArr)); - } - List students= baseService.getRecordCardBySchoolId(schoolId.intValue()); - if(!CollectionUtils.isEmpty(students)){ - for(SendRecordBean s : students){ - String cardNum = s.getNum(); - StudentBean studentBean = userDao.getStudentWithCard(cardNum,schoolId.intValue()); - StudentBean teacher = userDao.getTeacherWithCard(cardNum,schoolId.intValue()); - if(studentBean == null && teacher ==null){ - deviceList.stream().forEach(c->{ - boolean isOk = false; - if (cmsServer.getIsDeviceOnline(c)) { - String cardNo = Long.parseLong(baseService.getCard(cardNum), 16) + ""; - isOk = cmsServer.deleteFace(c,cardNo,null); - }else{ - isOk = HttpUtil.deleteCard(c, cardNum); - } - if(isOk){ - //删除成功记录 - sendRecordDao.deleteUserFaceSuccess(schoolId,cardNum,c); - sendRecordDao.deleteRecord(schoolId,c,cardNum); - } - }); - } + List deviceList = baseService.getDeviceList(faceBean.getDeviceIds(),faceBean.getSchoolId()); + //根据类型获取下发用户信息 + List studentBeans = Objects.equals(faceBean.getUserType(),EnumSzBusinessType.EnumUserType.STUDENT.code) ? + baseService.getStudentByClassId(faceBean) : baseService.getTeacherList(faceBean.getSchoolId()); + List students = baseService.getSendRecordList(faceBean); + if(CollectionUtils.isEmpty(students)) return ResultGenerator.genSuccessResult(); + for(SendRecordBean s : students){ + String cardNum = s.getNum(); + StudentBean bean = studentBeans.stream().filter(f->Objects.equals(f.getNum(),cardNum) && + Objects.equals(f.getSchoolId(),faceBean.getSchoolId())).findFirst().orElse(null); + if(Objects.isNull(bean)){ + deviceList.stream().forEach(c->{ + boolean isOk = false; + if (cmsServer.getIsDeviceOnline(c)) { + String cardNo = Long.parseLong(baseService.getCard(cardNum), 16) + ""; + isOk = cmsServer.deleteFace(c,cardNo,null); + }else{ + isOk = HttpUtil.deleteCard(c, cardNum); + } + if(isOk) sendRecordDao.deleteRecord(faceBean.getSchoolId(),c,cardNum); + }); } } return ResultGenerator.genSuccessResult(); } @Override - public void checkFaceSend() { - List saveStudentBaks = userDao.selectStudentList(); - if(!CollectionUtils.isEmpty(saveStudentBaks)) { - saveStudentBaks.stream().forEach(saveStudentBak -> { - try{ - String cardNum = saveStudentBak.getCardNum(); - Integer schoolId = saveStudentBak.getSchoolId(); - String deviceId = saveStudentBak.getClientId(); - StudentBean studentBean = userDao.getStudentWithCard(cardNum, schoolId); - if (studentBean == null) { - return; - } - String photo = studentBean.getPhoto(); - if (StringUtils.isBlank(photo)) { - return; - } - int userType = studentBean.getUserType(); - String userName = studentBean.getName(); - String studentCode = studentBean.getStudentCode(); - String typeName = "Student"; - //以学籍号为名的文件名 - String fileName = photo.substring(photo.lastIndexOf("/") + 1, photo.length()); - //100服务器人脸照绝对路径 - String path_1 = "E:\\wwwhtdocs\\SmartCampus\\face17e50\\School" + schoolId + "\\" + typeName; - String path_2 = "E:\\wwwhtdocs\\SmartCampus\\face17e5\\School" + schoolId + "\\" + typeName; - String path_3 = "E:\\wwwhtdocs\\SmartCampus\\f0i5l7e5\\"; - String filePath = ""; - if (photo.indexOf("f0i5l7e5") != -1) { - String afterStr = photo.split("f0i5l7e5/")[1].replace("/", "\\"); - filePath = path_3 + afterStr; - } - if (photo.indexOf("face17e5") != -1) { - filePath = path_2 + "\\" + fileName; - } - if (photo.indexOf("face17e50") != -1) { - filePath = path_1 + "\\" + fileName; - } - if (filePath.indexOf("?v=") != -1) { - filePath = filePath.split("\\?")[0]; - } - //校验100服务文件存储地址上是否存在此人脸 - File file = new File(filePath.trim());//图片 - if (!file.exists()) { - log.error("文件不存在:" + filePath); - baseService.sendFailRecord(cardNum, filePath, deviceId, "文件不存在", String.valueOf(userType), schoolId); - return; - } - String targetPath = FileUtils.picPathComp + file.getName(); - if (file.exists()) { - try { - CompressPic.CompressPic(file.getAbsolutePath(), targetPath); - } catch (Exception e) { - log.error("压缩图片失败:", e); - } - } - //设备类型 - Integer clintType = userDao.getClintTypeByDeviceId(deviceId); - if (clintType.intValue() == 18 || clintType.intValue() == 28) { -// //1.先删除人脸 -// if (cmsServer.getIsDeviceOnline(deviceId)) { -// String cardNo = Long.parseLong(baseService.getCard(cardNum), 16) + ""; -// cmsServer.deleteFace(deviceId, cardNo, schoolId); -// } else { -// //不在线,去253服务器上删除 -// HttpUtil.deleteCard(deviceId, cardNum); -// } - //2.重新下发 - boolean isOk = baseService.sendImg(file.getAbsolutePath(), targetPath, deviceId, cardNum, userName, String.valueOf(userType), schoolId); - if (isOk) { - userDao.updateStudent(saveStudentBak.getId()); - return; - } else { - } - } - //下大华人脸 - if (clintType.intValue() == 22 || clintType.intValue() == 29) { - //下发单个人脸至大华设备 - HttpUtil.uploadDHImgForOne(filePath, schoolId, studentCode, clintType, deviceId); - return; - } - }catch (Exception e){ - log.error("下发出错"); - return; + public Result exportFace(Integer schoolId,Integer userType,String deviceIds,String faceSrcPath) { + File imgPathFile = new File(faceSrcPath);//目录 + File[] imgfiles = imgPathFile.listFiles(); + if(imgfiles.length==0) return ResultGenerator.genFailResult("未获取要下发的人脸照片。"); + List sendFaces = new ArrayList<>(); + for (int i = 0; i < imgfiles.length; i++) { + try{ + //人脸照片 + File file = imgfiles[i]; + if(!file.isFile())continue; + if(!file.exists()) continue; + //原始文件路径 + String srcPath = file.getAbsolutePath(); + //原始文件名 + String fileName = file.getName(); + System.out.println("文件名:"+ fileName+", 学籍号:"+ fileName.split("\\.")[0]); + StudentBean studentBean = null; + if (userType.intValue()==1) { + studentBean = userDao.getTeacherWithstudentcode(fileName.split("\\.")[0],String.valueOf(schoolId)); + }else { + studentBean = userDao.getStudentWithstudentcode(fileName.split("\\.")[0],String.valueOf(schoolId)); } - }); - } - } - - @Override - public Result replaceFaceByKeyword(Integer schoolId,String deviceIds,String keyword) { - //下发设备集合 - List deviceList = null; - if(StringUtils.isBlank(deviceIds)){ - deviceList = deviceDao.selectDeviceBySchoolId(schoolId); - }else{ - deviceList= Arrays.asList(deviceIds.split(",")); + if(Objects.isNull(studentBean)) continue; + String typeName = userType.intValue() ==1 ? "Teacher" : "Student"; + String targetPath = "E:\\wwwhtdocs\\SmartCampus\\face17e50\\School" + schoolId + "\\" + typeName; + //目标路径 + targetPath = targetPath + "\\" + fileName; + //复制文件 + baseService.copy(srcPath,targetPath); + String savePath = "http://campus.myjxt.com//face17e50/School"+ schoolId + "/" + typeName + "/" + fileName; + if(userType.intValue() ==1) studentBean.setFace(savePath); + else studentBean.setPhoto(savePath); + //savePath + userDao.updateUser(studentBean.getUser_id(),savePath); + sendFaces.add(studentBean); + file.delete(); + }catch (Exception e){ + e.printStackTrace(); + continue; + } } - //根据类型获取下发用户信息 - List studentBeanList = baseService.getReplaceByKeyword(schoolId,keyword); - log.info("统计共有下发用户数量:{}",studentBeanList.size()); - - //发送海康设备:异步执行 - this.deleteReplaceFace(schoolId,studentBeanList,deviceList); - - int fileSize = studentBeanList.size(); + if(StringUtils.isBlank(deviceIds)) return ResultGenerator.genFailResult("未选择下发设备"); + String[] deviceArr = deviceIds.split(","); + List deviceList = new ArrayList<>(Arrays.asList(deviceArr)); + //异步执行下发 + asyncSendFace(sendFaces,deviceList,schoolId,userType); + int fileSize = sendFaces.size(); int clintNum = deviceList.size(); //下发所用时长 int timeLength = new Double(clintNum * fileSize * 0.06).intValue(); @@ -1282,26 +716,4 @@ public class UserOperateServiceImpl implements UserOperateService { map.put("fileSize",fileSize); return ResultGenerator.genSuccessResult(objectMapper.toJson(map)); } - - @Async - public void deleteReplaceFace(Integer schoolId,List studentBeanList,List deviceList){ - //100服务器; - studentBeanList.stream().forEach(s->{ - String cardNum = s.getStudent_num(); - deviceList.stream().forEach(c->{ - boolean isOk = false; - if (cmsServer.getIsDeviceOnline(c)) { - String cardNo = Long.parseLong(baseService.getCard(cardNum), 16) + ""; - isOk = HttpUtil.deleteCard100(c,cardNo); - }else{ - isOk = HttpUtil.deleteCard(c, cardNum); - } - if(isOk){ - //删除成功记录 - sendRecordDao.deleteUserFaceSuccess(schoolId,cardNum,c); - sendRecordDao.deleteRecord(schoolId,c,cardNum); - } - }); - }); - } } diff --git a/cloud/haikangface/src/main/java/com/sincere/haikangface/xiananDao/SendRecordDao.java b/cloud/haikangface/src/main/java/com/sincere/haikangface/xiananDao/SendRecordDao.java index 11253c7..b78f4a1 100644 --- a/cloud/haikangface/src/main/java/com/sincere/haikangface/xiananDao/SendRecordDao.java +++ b/cloud/haikangface/src/main/java/com/sincere/haikangface/xiananDao/SendRecordDao.java @@ -23,32 +23,14 @@ public interface SendRecordDao { @Param("time") String time, @Param("schoolName") String schoolName, @Param("imgPath") String imgPath, @Param("schoolId") int schoolId, @Param("userType") int userType, @Param("deviceType") int deviceType); - @Select("select * from Face_SendSuccess where schoolId = #{schoolId} ") - List getSendFaceSuccess(@Param("schoolId") Integer schoolId); - @Select("select * from Face_SendSuccess where deviceID = #{deviceID} and schoolId = #{schoolId}") List getSenSuccesss(@Param("deviceID") String deviceId, @Param("schoolId") Integer schoolId); - @Select("select a.customerID from [dbo].[WG_SendFail] a inner join DBlan137.smartcampus.dbo.SZ_AttendanceDto b on a.deviceID=b.clint_id and b.isConnection=1 order by createTime desc") - List getWGFail(); - - //获取成功表和失败人脸表中都存在的数据 - @Select("select a.deviceID,a.Num,a.Name from Face_SendFail a inner join Face_SendSuccess b on a.deviceID = b.deviceID where a.schoolId = 1030 and a.num = b.Num") - List getSuccessAndFail(); - @Insert("insert into Face_Recoder values(#{deviceId},#{user_id},#{name},#{imgurl},#{inOrOut},#{time},#{cardNum},#{temp},#{schoolId})") void addFaceRecoder(@Param("deviceId") String deviceId, @Param("user_id") String user_id, @Param("name") String name, @Param("imgurl") String imgurl, @Param("inOrOut") int inOrOut, @Param("time") String time, @Param("cardNum") String cardNum, @Param("temp") String currTemperature,@Param("schoolId") int schoolId); - @Insert("insert into SZ_AttendanceRecordsSS201911 values(#{user_id},#{school_id},#{customerId},#{usertype},#{card_num},#{card_type},#{outof},#{intime},#{cid}," + - "#{func_no},#{head_image},#{classId},#{s},#{attendance_id},#{name},#{mobile},#{class_name},#{sex},#{student_type},#{systime})") - int addAttenRecodrds(@Param("user_id") String user_id, @Param("school_id") String school_id, @Param("customerId") String customerId, - @Param("usertype") String usertype, @Param("card_num") String card_num, @Param("card_type") String card_type, - @Param("outof") String outof, @Param("intime") String intime, @Param("cid") String cid, @Param("func_no") String func_no, - @Param("head_image") String head_image, @Param("classId") String classId, @Param("s") String s, @Param("attendance_id") String attendance_id, - @Param("name") String name, @Param("mobile") String mobile, @Param("class_name") String class_name, @Param("sex") String sex, @Param("student_type") String student_type, @Param("systime") String systime); - @Select("select * from Face_SendSuccess where Num = #{Num} and deviceID = #{deviceID}") List getFaceSendSucess(@Param("Num")String Num,@Param("deviceID")String deviceID); @@ -63,6 +45,9 @@ public interface SendRecordDao { @Select("select * from Face_SendRecord where deviceID = #{deviceID} and Num = #{Num} and userId = #{userId}") List getRecordIsExit(@Param("deviceID") String deviceId, @Param("Num") String cardNum,@Param("userId") String userId); + @Delete("delete Face_SendRecord where deviceID = #{deviceID} and Num = #{Num} and schoolId = #{schoolId}") + void deleteRecord(@Param("schoolId") Integer schoolId,@Param("deviceID") String deviceID,@Param("Num") String Num); + @Insert("insert into Face_SendRecord values(#{deviceID},#{userId},#{num},#{name},#{time},#{schoolName},#{imgPath},#{schoolId},#{failContent},#{failType},#{userType},#{deviceType},#{status},#{channel})") void saveFaceRecord(@Param("userId") String userId, @Param("deviceID") String deviceID, @Param("num") String num, @Param("name") String name, @Param("time") String time, @Param("schoolName") String schoolName, @Param("imgPath") String imgPath, @Param("schoolId") Integer schoolId, @Param("failContent") String failContent, @@ -77,35 +62,18 @@ public interface SendRecordDao { @Select("select * from Face_SendRecord where schoolId = #{schoolId} and status =2") List getFailRecord(@Param("schoolId") Integer schoolId); - @Select("select * from Face_SendRecord where schoolId = #{schoolId} and deviceID = #{deviceId} and status =2") - List getFailRecord2(@Param("schoolId") Integer schoolId,@Param("deviceId") String deviceId); - - @Select("select * from Face_SendRecord where schoolId = #{schoolId}") - List getFaceRecord(@Param("schoolId") Integer schoolId); - - @Delete("delete Face_SendRecord where deviceID = #{deviceID} and Num = #{Num} and schoolId = #{schoolId}") - void deleteRecord(@Param("schoolId") Integer schoolId,@Param("deviceID") String deviceID,@Param("Num") String Num); - @Delete("delete Face_SendRecord where Num = #{Num} and schoolId = #{schoolId}") void deleteRecordByNum(@Param("schoolId") Integer schoolId,@Param("Num") String Num); - @Delete("delete Face_SendSuccess where deviceID = #{deviceID} and Num = #{Num} and schoolId = #{schoolId}") - void deleteUserFaceSuccess(@Param("schoolId") Integer schoolId,@Param("Num") String Num, @Param("deviceID") String deviceID); - - @Delete("delete WG_SendSuccess where deviceID = #{deviceID} and cardNum = #{cardNum} and schoolID = #{schoolID}") - void deleteWGSuccess(@Param("schoolID") Integer schoolId,@Param("cardNum") String cardNum, @Param("deviceID") String deviceId); - - - @Delete("DELETE from SZ_AttendanceRecords202101 where school_id = #{schoolId} and card_Num = #{cardNum} and card_type = #{cardType} and outof=#{outof} and intime > #{startTime} and intime < #{endTime}") - void delete(@Param("schoolId") Integer schoolId,@Param("cardNum") String cardNum,@Param("cardType") Integer cardType,@Param("outof") Integer outof,@Param("startTime") String startTime,@Param("endTime") String endTime); - @Delete("DELETE from SZ_AttendanceRecordsSS202101 where school_id = #{schoolId} and card_Num = #{cardNum} and card_type = #{cardType} and outof=#{outof} and intime > #{startTime} and intime < #{endTime}") void deleteSS(@Param("schoolId") Integer schoolId,@Param("cardNum") String cardNum,@Param("cardType") Integer cardType,@Param("outof") Integer outof,@Param("startTime") String startTime,@Param("endTime") String endTime); - @Select("select DISTINCT num from Face_SendRecord where schoolId = #{schoolId} ") List getFaceRecordList(@Param("schoolId") Integer schoolId); + List getSendRecordList(@Param("schoolId") Integer schoolId, + @Param("deviceList") List deviceList, + @Param("status") Integer status); /** * 考勤推送存储过程 * @param checkIn diff --git a/cloud/haikangface/src/main/resources/mapper/usermapper.xml b/cloud/haikangface/src/main/resources/mapper/usermapper.xml index 7323992..fa50ac3 100644 --- a/cloud/haikangface/src/main/resources/mapper/usermapper.xml +++ b/cloud/haikangface/src/main/resources/mapper/usermapper.xml @@ -86,40 +86,22 @@ - - select Top(1)* from SZ_V_School_Student where student_num = #{card} @@ -177,7 +158,7 @@ - select Top(1) * from SZ_V_School_Student where user_id = #{userId} and school_id = #{schoolId} @@ -191,32 +172,6 @@ - - - - - - - - - - - - - - insert into sz_student_bak values (#{name},#{userId},#{cardNum},#{clientId},#{className},#{status},#{schoolId}) - - - - - - update sz_student_bak set status = 1 where id = #{id} - - diff --git a/cloud/haikangface/src/main/resources/xiaoanmapper/usermapper.xml b/cloud/haikangface/src/main/resources/xiaoanmapper/usermapper.xml index 57bf9a4..579d843 100644 --- a/cloud/haikangface/src/main/resources/xiaoanmapper/usermapper.xml +++ b/cloud/haikangface/src/main/resources/xiaoanmapper/usermapper.xml @@ -13,4 +13,17 @@ #{out,mode=OUT,jdbcType=VARCHAR,resultMap=resultMap},#{isSuccess,mode=OUT,jdbcType=INTEGER,resultMap=resultMap} )} + + diff --git a/cloud/haikangface/src/test/java/com/sincere/haikangface/HaikangfaceApplicationTests.java b/cloud/haikangface/src/test/java/com/sincere/haikangface/HaikangfaceApplicationTests.java index 7946a26..b9f711d 100644 --- a/cloud/haikangface/src/test/java/com/sincere/haikangface/HaikangfaceApplicationTests.java +++ b/cloud/haikangface/src/test/java/com/sincere/haikangface/HaikangfaceApplicationTests.java @@ -103,7 +103,7 @@ public class HaikangfaceApplicationTests { saveStudentBak.setName(name); saveStudentBak.setClassName(className); saveStudentBak.setStatus(2); - userDao.insertStudent(saveStudentBak); +// userDao.insertStudent(saveStudentBak); } } }); diff --git a/cloud/quartz/src/main/java/com/sincere/quartz/datasource/DataSourceConfig.java b/cloud/quartz/src/main/java/com/sincere/quartz/datasource/DataSourceConfig.java index 04884ca..9d9eef9 100644 --- a/cloud/quartz/src/main/java/com/sincere/quartz/datasource/DataSourceConfig.java +++ b/cloud/quartz/src/main/java/com/sincere/quartz/datasource/DataSourceConfig.java @@ -34,12 +34,12 @@ public class DataSourceConfig { public DataSource dataSource3() { return DataSourceBuilder.create().build(); } - - @Bean(name = "update") - @ConfigurationProperties(prefix = "spring.datasource.update") - public DataSource dataSource4() { - return DataSourceBuilder.create().build(); - } +// +// @Bean(name = "update") +// @ConfigurationProperties(prefix = "spring.datasource.update") +// public DataSource dataSource4() { +// return DataSourceBuilder.create().build(); +// } @Bean(name="dynamicDataSource") @Primary //优先使用,多数据源 @@ -48,7 +48,7 @@ public class DataSourceConfig { DataSource master = dataSource1(); DataSource slave = dataSource2(); DataSource yxy = dataSource3(); - DataSource update = dataSource4(); +// DataSource update = dataSource4(); //设置默认数据源 dynamicDataSource.setDefaultTargetDataSource(master); //配置多数据源 @@ -56,7 +56,7 @@ public class DataSourceConfig { map.put(DataSourceType.Master.getName(), master); //key需要跟ThreadLocal中的值对应 map.put(DataSourceType.Slave.getName(), slave); map.put(DataSourceType.Yxy.getName(), yxy); - map.put(DataSourceType.Update.getName(), update); +// map.put(DataSourceType.Update.getName(), update); dynamicDataSource.setTargetDataSources(map); return dynamicDataSource; } diff --git a/cloud/quartz/src/main/java/com/sincere/quartz/job/SyncJob.java b/cloud/quartz/src/main/java/com/sincere/quartz/job/SyncJob.java index bfc2a02..f179004 100644 --- a/cloud/quartz/src/main/java/com/sincere/quartz/job/SyncJob.java +++ b/cloud/quartz/src/main/java/com/sincere/quartz/job/SyncJob.java @@ -23,7 +23,7 @@ public class SyncJob { YXYReadService yxyReadService ; // @Scheduled(cron = "30 1 22 * * ? ") - @Scheduled(fixedDelay = 220 * 60 * 1000) + @Scheduled(fixedDelay = 60 * 60 * 1000) public void Sync(){ //翼校通的同步 之后还有钉钉的同步等等 yxyReadService.sync(); -- libgit2 0.21.0