dev
zhangyue 2026-03-07 10:05:34 +08:00
parent 63317d726c
commit 42740c78ae
2 changed files with 15 additions and 2 deletions

View File

@ -40,30 +40,41 @@ public class StudentSignAddExe {
@Transactional(rollbackFor = Exception.class)
public StudentSignCO execute(StudentSignAddCmd cmd) {
System.out.println("第一步-----------------------------"+ System.currentTimeMillis());
StudentDO stu = studentRepository.findInfoByStudentId(cmd.getStudentId());
System.out.println("第2步-----------------------------"+ System.currentTimeMillis());
StudentSignE studentSignE = new StudentSignE();
BeanUtils.copyProperties(cmd, studentSignE);
System.out.println("第3步-----------------------------"+ System.currentTimeMillis());
StudentDO student = studentRepository.findFaceUrlByPhone(stu.getPhone());
System.out.println("第4步-----------------------------"+ System.currentTimeMillis());
if (student == null || ObjectUtils.isEmpty(student.getUserAvatarUrl())) {
throw new BizException("您还没有录入人脸");
}
String faceUrl = null;
try {
System.out.println("第5步-----------------------------"+ System.currentTimeMillis());
faceUrl = Base64Util.getBase64String(studentSignE.getFiles()[0]);
System.out.println("第6步-----------------------------"+ System.currentTimeMillis());
studentSignE.compareFace(student.getUserAvatarUrl(), faceUrl, fileUrlConfig.getPrefixUrl());
System.out.println("第10步-----------------------------"+ System.currentTimeMillis());
} catch (Exception e) {
throw new RuntimeException(e);
}
String path = studentSignE.getType() == 1 ? "clockSign" : "examSign";
System.out.println("第11步-----------------------------"+ System.currentTimeMillis());
String fileName = Tools.get32UUID() + studentSignE.getFiles()[0].getOriginalFilename().substring(studentSignE.getFiles()[0].getOriginalFilename().lastIndexOf("."));
System.out.println("第12步-----------------------------"+ System.currentTimeMillis());
studentSignE.setFaceUrl(zcloudImgFilesFacade.saveFile( faceUrl,fileName, path));
System.out.println("第13步-----------------------------"+ System.currentTimeMillis());
studentSignE.init(stu.getStudentId(), stu.getClassId(), stu.getClassCorpinfoId());
boolean res = false;
StudentSignCO studentSignCO = new StudentSignCO();
try {
System.out.println("第14步-----------------------------"+ System.currentTimeMillis());
res = studentSignGateway.add(studentSignE);
System.out.println("第15步-----------------------------"+ System.currentTimeMillis());
BeanUtils.copyProperties(studentSignE, studentSignCO);
} catch (Exception e) {
throw new RuntimeException(e);

View File

@ -65,9 +65,11 @@ public class StudentSignE extends BaseE {
private Long updateId;
public void compareFace(String templateFaceUrl, String faceUrl, String prefixUrl) throws Exception {
System.out.println("第7步-----------------------------"+ System.currentTimeMillis());
String templateFace = Base64Util.urlToBase64(prefixUrl + templateFaceUrl);
System.out.println("第8步-----------------------------"+ System.currentTimeMillis());
String confidence = FaceUtil.compareFace(templateFace, faceUrl);
System.out.println("第9步-----------------------------"+ System.currentTimeMillis());
if (Double.valueOf(confidence) < 75) {
throw new BizException("人脸不匹配");
}