|
@@ -6,6 +6,7 @@ import cn.com.qmth.examcloud.tool.service.CommonService;
|
|
import cn.com.qmth.examcloud.tool.service.TaskService;
|
|
import cn.com.qmth.examcloud.tool.service.TaskService;
|
|
import cn.com.qmth.examcloud.tool.service.export_student_photo.vo.StudentVO;
|
|
import cn.com.qmth.examcloud.tool.service.export_student_photo.vo.StudentVO;
|
|
import cn.com.qmth.examcloud.tool.utils.FileHelper;
|
|
import cn.com.qmth.examcloud.tool.utils.FileHelper;
|
|
|
|
+import cn.com.qmth.examcloud.tool.utils.FssHelper;
|
|
import cn.com.qmth.examcloud.tool.utils.HttpHelper;
|
|
import cn.com.qmth.examcloud.tool.utils.HttpHelper;
|
|
import cn.com.qmth.examcloud.tool.utils.JsonMapper;
|
|
import cn.com.qmth.examcloud.tool.utils.JsonMapper;
|
|
import cn.com.qmth.examcloud.tool.vo.PageInfo;
|
|
import cn.com.qmth.examcloud.tool.vo.PageInfo;
|
|
@@ -58,8 +59,7 @@ public class ExportStudentPhotoTask implements TaskService {
|
|
JsonMapper jsonMapper = new JsonMapper();
|
|
JsonMapper jsonMapper = new JsonMapper();
|
|
long pageNo = 0, pageSize = 100, finishedCount = 0, noPhotoCount = 0;
|
|
long pageNo = 0, pageSize = 100, finishedCount = 0, noPhotoCount = 0;
|
|
|
|
|
|
- final String url = loginUser.getServerUrl()
|
|
|
|
- + "/api/ecs_core/student/studentPage/%s/%s?rootOrgId=%s&hasPhoto=TRUE";
|
|
|
|
|
|
+ final String url = loginUser.getServerUrl() + "/api/ecs_core/student/studentPage/%s/%s?rootOrgId=%s&hasPhoto=TRUE";
|
|
|
|
|
|
List<StudentVO> hasPhotoStudents = new ArrayList<>();
|
|
List<StudentVO> hasPhotoStudents = new ArrayList<>();
|
|
while (true) {
|
|
while (true) {
|
|
@@ -76,7 +76,6 @@ public class ExportStudentPhotoTask implements TaskService {
|
|
continue;
|
|
continue;
|
|
}
|
|
}
|
|
|
|
|
|
- student.setPhotoPath(this.fixPhotoUrl(student.getPhotoPath()));
|
|
|
|
hasPhotoStudents.add(student);
|
|
hasPhotoStudents.add(student);
|
|
}
|
|
}
|
|
|
|
|
|
@@ -92,9 +91,9 @@ public class ExportStudentPhotoTask implements TaskService {
|
|
|
|
|
|
private List<StudentVO> loadStudentFromExcel(String dataFilePath) {
|
|
private List<StudentVO> loadStudentFromExcel(String dataFilePath) {
|
|
/*
|
|
/*
|
|
- select stu.id, stu.root_org_id 学校ID, stu.name 学生姓名, stu.identity_number 身份证号, sc.student_code 学号, stu.photo_path 照片
|
|
|
|
- from ec_b_student stu left join ec_b_student_code sc on sc.student_id = stu.id
|
|
|
|
- where stu.root_org_id = 0 and stu.photo_path is not null;
|
|
|
|
|
|
+ select stu.id, stu.root_org_id 学校ID, stu.name 学生姓名, stu.identity_number 身份证号,
|
|
|
|
+ (select GROUP_CONCAT(DISTINCT sc.student_code) from ec_b_student_code sc where sc.student_id = stu.id)学号,stu.photo_path 照片
|
|
|
|
+ from ec_b_student stu where stu.root_org_id = 0 and stu.photo_path is not null;
|
|
*/
|
|
*/
|
|
List<StudentVO> list = new ArrayList<>();
|
|
List<StudentVO> list = new ArrayList<>();
|
|
try {
|
|
try {
|
|
@@ -123,15 +122,13 @@ public class ExportStudentPhotoTask implements TaskService {
|
|
continue;
|
|
continue;
|
|
}
|
|
}
|
|
|
|
|
|
- student.setPhotoPath(this.fixPhotoUrl(student.getPhotoPath()));
|
|
|
|
-
|
|
|
|
if (StringUtils.isNotBlank(student.getStudentCodesStr())) {
|
|
if (StringUtils.isNotBlank(student.getStudentCodesStr())) {
|
|
- student.setStudentCodeList(Lists.newArrayList(student.getStudentCodesStr()));
|
|
|
|
|
|
+ student.setStudentCodeList(Lists.newArrayList(student.getStudentCodesStr().split(",")));
|
|
}
|
|
}
|
|
hasPhotoStudents.add(student);
|
|
hasPhotoStudents.add(student);
|
|
}
|
|
}
|
|
|
|
|
|
- log.info("总数:{} 已获取学生数:{} 无底照学生数:{}", list.size(), hasPhotoStudents.size(), noPhotoCount);
|
|
|
|
|
|
+ log.info("总数:{} 有底照学生数:{} 无底照学生数:{}", list.size(), hasPhotoStudents.size(), noPhotoCount);
|
|
return hasPhotoStudents;
|
|
return hasPhotoStudents;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -141,44 +138,38 @@ public class ExportStudentPhotoTask implements TaskService {
|
|
if (fileNameByStudentCode) {
|
|
if (fileNameByStudentCode) {
|
|
if (CollectionUtils.isNotEmpty(student.getStudentCodeList())) {
|
|
if (CollectionUtils.isNotEmpty(student.getStudentCodeList())) {
|
|
if (student.getStudentCodeList().size() > 1) {
|
|
if (student.getStudentCodeList().size() > 1) {
|
|
- log.warn("identityNumber:{} 多个学号!", student.getIdentityNumber());
|
|
|
|
|
|
+ log.warn("identityNumber:{} 多个学号!{}", student.getIdentityNumber(), student.getStudentCodesStr());
|
|
}
|
|
}
|
|
for (String studentCode : student.getStudentCodeList()) {
|
|
for (String studentCode : student.getStudentCodeList()) {
|
|
- String photoPath = String.format("%s/%s/%s%s", exportDir, student.getRootOrgId(), studentCode, photoSuffix);
|
|
|
|
- this.downloadPhoto(student.getPhotoPath(), photoPath);
|
|
|
|
|
|
+ String savePhotoPath = String.format("%s/%s/%s%s", exportDir, student.getRootOrgId(), studentCode, photoSuffix);
|
|
|
|
+ this.downloadPhoto(student.getPhotoPath(), savePhotoPath);
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
log.warn("identityNumber:{} 无学号!", student.getIdentityNumber());
|
|
log.warn("identityNumber:{} 无学号!", student.getIdentityNumber());
|
|
- String photoPath = String.format("%s/%s/%s%s", exportDir, student.getRootOrgId(), student.getIdentityNumber(), photoSuffix);
|
|
|
|
- this.downloadPhoto(student.getPhotoPath(), photoPath);
|
|
|
|
|
|
+ String savePhotoPath = String.format("%s/%s/%s%s", exportDir, student.getRootOrgId(), student.getIdentityNumber(), photoSuffix);
|
|
|
|
+ this.downloadPhoto(student.getPhotoPath(), savePhotoPath);
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
- String photoPath = String.format("%s/%s/%s%s", exportDir, student.getRootOrgId(), student.getIdentityNumber(), photoSuffix);
|
|
|
|
- this.downloadPhoto(student.getPhotoPath(), photoPath);
|
|
|
|
|
|
+ String savePhotoPath = String.format("%s/%s/%s%s", exportDir, student.getRootOrgId(), student.getIdentityNumber(), photoSuffix);
|
|
|
|
+ this.downloadPhoto(student.getPhotoPath(), savePhotoPath);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
private void downloadPhoto(String photoUrl, String photoPath) {
|
|
private void downloadPhoto(String photoUrl, String photoPath) {
|
|
|
|
+ String urlPrefix = "https://ecs-test-static.qmth.com.cn";
|
|
|
|
+ photoUrl = FssHelper.finalFileUrl(photoUrl, urlPrefix);
|
|
|
|
+
|
|
if (new File(photoPath).exists()) {
|
|
if (new File(photoPath).exists()) {
|
|
- log.info("【已下载】 photoUrl:{} photoPath:{}", photoUrl, photoPath);
|
|
|
|
|
|
+ log.info("【已下载】 {} {}", photoPath, photoUrl);
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
|
|
|
|
try {
|
|
try {
|
|
FileHelper.saveImageToFile(photoUrl, photoPath);
|
|
FileHelper.saveImageToFile(photoUrl, photoPath);
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
- log.error("【错误】 photoUrl:{} photoPath:{} err:{}", photoUrl, photoPath, e.getMessage());
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- public String fixPhotoUrl(String url) {
|
|
|
|
- if (StringUtils.isEmpty(url)) {
|
|
|
|
- return "";
|
|
|
|
|
|
+ log.error("【错误】 {} err:{}", photoPath, e.getMessage());
|
|
}
|
|
}
|
|
-
|
|
|
|
- // ecs-static-upyun.qmth.com.cn 去掉 -upyun
|
|
|
|
- return url.replace("-upyun.qmth.com.cn", ".qmth.com.cn");
|
|
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
}
|