From 718fcb620fe5cbe868e4ac773bacc4cc14a1f044 Mon Sep 17 00:00:00 2001
From: xuquan <1099815072@qq.com>
Date: Thu, 4 Nov 2021 16:59:29 +0800
Subject: [PATCH] 非空校验代码提交
---
cloud/haikangface/pom.xml | 8 ++++++++
cloud/haikangface/src/main/java/com/sincere/haikangface/service/impl/UserOperateServiceImpl.java | 67 ++++++++++++++++++++++++++++++++++++++-----------------------------
2 files changed, 46 insertions(+), 29 deletions(-)
diff --git a/cloud/haikangface/pom.xml b/cloud/haikangface/pom.xml
index 0358f56..24a2ec3 100644
--- a/cloud/haikangface/pom.xml
+++ b/cloud/haikangface/pom.xml
@@ -181,6 +181,14 @@
+
+
+ org.apache.maven.plugins
+ maven-surefire-plugin
+
+ true
+
+
org.apache.maven.plugins
maven-dependency-plugin
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 326882a..92fcd0d 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
@@ -734,39 +734,48 @@ public class UserOperateServiceImpl implements UserOperateService {
}
List sendFaces = new ArrayList<>();
for (int i = 0; i < imgfiles.length; i++) {
- //人脸照片
- File file = imgfiles[i];
- if(!file.isFile()){
- continue;
- }
- if (file.exists()){
- //原始文件路径
- String srcPath = file.getAbsolutePath();
- //原始文件名
- String fileName = file.getName();
- 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));
+ try{
+ //人脸照片
+ File file = imgfiles[i];
+ if(!file.isFile()){
+ continue;
}
- String typeName = userType.intValue() ==1 ? "Teacher" : "Student";
- String targetPath = "E:\\wwwhtdocs\\SmartCampus\\face17e50\\School" + schoolId + "\\" + typeName;
+ 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);
+ 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);
}
- //savePath
- userDao.updateUser(studentBean.getUser_id(),savePath);
- sendFaces.add(studentBean);
+ file.delete();
+ }catch (Exception e){
+ e.printStackTrace();
+ continue;
}
- file.delete();
}
if(StringUtils.isBlank(deviceIds)){
return ResultGenerator.genFailResult("未选择下发设备");
--
libgit2 0.21.0