Compare commits
No commits in common. "main" and "dev_student" have entirely different histories.
main
...
dev_student
|
|
@ -3,8 +3,8 @@ spring:
|
|||
import:
|
||||
# - classpath:nacos.yml
|
||||
# - classpath:sdk.yml
|
||||
# - classpath:nacos-prod.yml
|
||||
# - classpath:sdk-prod.yml
|
||||
- classpath:nacos-prod.yml
|
||||
- classpath:sdk-prod2.yml
|
||||
- classpath:sdk-prod.yml
|
||||
# - classpath:nacos-prod.yml
|
||||
# - classpath:sdk-prod2.yml
|
||||
- classpath:swagger.yml
|
||||
|
|
|
|||
|
|
@ -148,11 +148,11 @@ public class CurriculumUpdateExe {
|
|||
//如果是企业,可以看本企业下所有的,如果是个人,只能看个人的,判断登录的账号是企业主账号还是个人
|
||||
Boolean isCorpAccount = corpInfoRepository.checkCorp();
|
||||
// 企业账户:检查租户ID匹配
|
||||
if ((isCorpAccount||(AuthContext.getRoleIds()!=null && AuthContext.getRoleIds().contains(2008483105201106946L))) && !AuthContext.getTenantId().equals(curriculumDO.getCorpinfoId())) {
|
||||
if ((isCorpAccount||(AuthContext.getRoleIds()!=null && AuthContext.getRoleIds().contains(2008483105201106946L))) && AuthContext.getTenantId().equals(curriculumDO.getCorpinfoId())) {
|
||||
errorList.add(curriculumDO.getCurriculumName()+"课程不是本企业的");
|
||||
}
|
||||
// 个人账户:检查创建者ID匹配
|
||||
if (!isCorpAccount && !curriculumDO.getCreateId().equals(AuthContext.getUserId())) {
|
||||
if (!isCorpAccount && curriculumDO.getCreateId().equals(AuthContext.getUserId())) {
|
||||
|
||||
errorList.add(curriculumDO.getCurriculumName()+"课程不是本人创建的");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -57,16 +57,16 @@ public class StudentSignAddExe {
|
|||
String faceUrl = null;
|
||||
try {
|
||||
faceUrl = Base64Util.getBase64String(studentSignE.getFiles()[0]);
|
||||
log.info("StudentSignAddExe-execute,调用阿里进行人脸识别开始");
|
||||
long startAliTime = System.currentTimeMillis();
|
||||
Boolean environment = false;
|
||||
if (!"https://jpfz.qhdsafety.com/gbsFileTest/".equals(fileUrlConfig.getPrefixUrl())) {
|
||||
log.info("StudentSignAddExe-execute,fileUrlConfig.getPrefixUrl():{}",fileUrlConfig.getPrefixUrl());
|
||||
if(!"https://jpfz.qhdsafety.com/gbsFileTest/".equals(fileUrlConfig.getPrefixUrl())){
|
||||
environment = true;
|
||||
}
|
||||
log.info("StudentSignAddExe-execute,开始进行人脸识别,prefixUrl:{},environment:{}", fileUrlConfig.getPrefixUrl(), environment);
|
||||
long startAliTime = System.currentTimeMillis();
|
||||
studentSignE.compareFace(student.getUserAvatarUrl(), faceUrl, fileUrlConfig.getPrefixUrl(), environment);
|
||||
log.info("StudentSignAddExe-execute,人脸识别结束,耗时:{}", System.currentTimeMillis() - startAliTime);
|
||||
} catch (BizException e) {
|
||||
throw e;
|
||||
|
||||
studentSignE.compareFace(student.getUserAvatarUrl(), faceUrl, fileUrlConfig.getPrefixUrl(),environment);
|
||||
log.info("StudentSignAddExe-execute,调用阿里进行人脸识别结束,耗时:{}",System.currentTimeMillis() - startAliTime);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
|
@ -75,12 +75,7 @@ public class StudentSignAddExe {
|
|||
String fileName = Tools.get32UUID() + studentSignE.getFiles()[0].getOriginalFilename().substring(studentSignE.getFiles()[0].getOriginalFilename().lastIndexOf("."));
|
||||
log.info("StudentSignAddExe-execute,保存人脸图片开始");
|
||||
long l = System.currentTimeMillis();
|
||||
try {
|
||||
studentSignE.setFaceUrl(zcloudImgFilesFacade.saveFile(
|
||||
studentSignE.getFiles()[0].getBytes(), fileName, path, stu.getClassCorpinfoId()));
|
||||
} catch (IOException e) {
|
||||
throw new BizException("保存人脸图片失败");
|
||||
}
|
||||
studentSignE.setFaceUrl(zcloudImgFilesFacade.saveFile( faceUrl,fileName, path));
|
||||
log.info("StudentSignAddExe-execute,保存人脸图片结束,耗时:{}",System.currentTimeMillis() - l);
|
||||
studentSignE.init(stu.getStudentId(), stu.getClassId(), stu.getClassCorpinfoId());
|
||||
boolean res = false;
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
package com.zcloud.edu.dto.training;
|
||||
|
||||
import com.alibaba.cola.dto.Command;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
|
|
@ -30,12 +29,10 @@ public class TrainingUserAddCmd extends Command {
|
|||
|
||||
@ApiModelProperty(value = "有效期开始时间", name = "startTime", required = true)
|
||||
@NotNull(message = "有效期开始时间不能为空")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private LocalDateTime startTime;
|
||||
|
||||
@ApiModelProperty(value = "有效期结束时间", name = "endTime", required = true)
|
||||
@NotNull(message = "有效期结束时间不能为空")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private LocalDateTime endTime;
|
||||
|
||||
@ApiModelProperty(value = "考试状态:1.待考试2:考试通过,3:考试不通过", name = "examineStatus", required = true)
|
||||
|
|
|
|||
|
|
@ -1,170 +1,108 @@
|
|||
package com.zcloud.edu.domain.model.study;
|
||||
|
||||
import com.alibaba.cola.exception.BizException;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.jjb.saas.framework.domain.model.BaseE;
|
||||
import com.zcloud.gbscommon.utils.Base64Util;
|
||||
import com.zcloud.gbscommon.utils.FaceUtil;
|
||||
import com.zcloud.gbscommon.utils.Tools;
|
||||
import lombok.Data;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.OutputStream;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* web-domain
|
||||
*
|
||||
* @Author zhangyue
|
||||
* @Date 2026-01-13 14:18:20
|
||||
*/
|
||||
@Data
|
||||
public class StudentSignE extends BaseE {
|
||||
private Long id;
|
||||
//学员id
|
||||
private String studentId;
|
||||
//业务id
|
||||
private String studentSignId;
|
||||
//班级id
|
||||
private String classId;
|
||||
//用户id
|
||||
private Long userId;
|
||||
//企业id
|
||||
private Long corpinfoId;
|
||||
//签到人脸路径
|
||||
private String faceUrl;
|
||||
//打卡签字路径
|
||||
private String signUrl;
|
||||
//签到类型 1-打卡签到 2-考试签到
|
||||
private Integer type;
|
||||
|
||||
private String phone;
|
||||
private MultipartFile[] files;
|
||||
//环境
|
||||
private String env;
|
||||
//删除标识true false
|
||||
private String deleteEnum;
|
||||
//备注
|
||||
private String remarks;
|
||||
//创建人姓名
|
||||
private String createName;
|
||||
//更新人姓名
|
||||
private String updateName;
|
||||
//租户id
|
||||
private Long tenantId;
|
||||
//单位id
|
||||
private Long orgId;
|
||||
//版本
|
||||
private Integer version;
|
||||
//创建时间
|
||||
private LocalDateTime createTime;
|
||||
//修改时间
|
||||
private LocalDateTime updateTime;
|
||||
//创建人id
|
||||
private Long createId;
|
||||
//修改人id
|
||||
private Long updateId;
|
||||
|
||||
public void compareFace(String templateFaceUrl, String faceUrl, String prefixUrl, Boolean environment) throws Exception {
|
||||
try {
|
||||
String templateFace = Base64Util.urlToBase64(prefixUrl + templateFaceUrl);
|
||||
String compareResultStr;
|
||||
if (environment) {
|
||||
// 正式环境:gbs-face
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put("pic1", templateFace);
|
||||
map.put("pic2", faceUrl);
|
||||
String compareResult = callGbsFaceCompare(JSON.toJSONString(map));
|
||||
compareResultStr = parseGbsFaceConfidence(compareResult);
|
||||
} else {
|
||||
// 测试环境:阿里云
|
||||
compareResultStr = FaceUtil.compareFace(templateFace, faceUrl);
|
||||
}
|
||||
|
||||
if (Double.valueOf(compareResultStr) < 75) {
|
||||
throw new BizException("人脸不匹配");
|
||||
}
|
||||
this.setStudentSignId(Tools.get32UUID());
|
||||
} catch (BizException e) {
|
||||
throw e;
|
||||
} catch (Exception e) {
|
||||
throw new BizException("人脸比对失败: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
private String callGbsFaceCompare(String jsonParam) throws Exception {
|
||||
URL url = new URL("http://192.168.192.201:8971/gbs-face/face/compareFace");
|
||||
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
|
||||
connection.setRequestMethod("POST");
|
||||
connection.setConnectTimeout(15000);
|
||||
connection.setReadTimeout(60000);
|
||||
connection.setDoOutput(true);
|
||||
connection.setDoInput(true);
|
||||
connection.setRequestProperty("Content-Type", "application/json");
|
||||
connection.setRequestProperty("Accept", "application/json");
|
||||
byte[] body = jsonParam.getBytes(StandardCharsets.UTF_8);
|
||||
connection.setFixedLengthStreamingMode(body.length);
|
||||
try (OutputStream os = connection.getOutputStream()) {
|
||||
os.write(body);
|
||||
}
|
||||
int responseCode = connection.getResponseCode();
|
||||
InputStream is = responseCode >= 200 && responseCode < 300
|
||||
? connection.getInputStream() : connection.getErrorStream();
|
||||
if (is == null) {
|
||||
return "";
|
||||
}
|
||||
StringBuilder result = new StringBuilder();
|
||||
try (BufferedReader br = new BufferedReader(new InputStreamReader(is, StandardCharsets.UTF_8))) {
|
||||
String line;
|
||||
while ((line = br.readLine()) != null) {
|
||||
result.append(line);
|
||||
}
|
||||
} finally {
|
||||
connection.disconnect();
|
||||
}
|
||||
return result.toString();
|
||||
}
|
||||
|
||||
private String parseGbsFaceConfidence(String compareResult) {
|
||||
if (compareResult == null || compareResult.trim().isEmpty()) {
|
||||
throw new BizException("人脸比对服务无响应");
|
||||
}
|
||||
JSONObject jsonObject = JSONObject.parseObject(compareResult);
|
||||
if (jsonObject == null) {
|
||||
throw new BizException("人脸比对服务返回异常: " + compareResult);
|
||||
}
|
||||
if ("exception".equals(jsonObject.getString("result"))) {
|
||||
String exceptionMsg = jsonObject.getString("exception");
|
||||
throw new BizException(exceptionMsg != null ? exceptionMsg : "人脸比对服务异常");
|
||||
}
|
||||
JSONObject info = jsonObject.getJSONObject("info");
|
||||
if (info != null && info.getString("confidence") != null) {
|
||||
return info.getString("confidence");
|
||||
}
|
||||
JSONObject data = jsonObject.getJSONObject("data");
|
||||
if (data != null && data.getString("confidence") != null) {
|
||||
return data.getString("confidence");
|
||||
}
|
||||
if (jsonObject.getString("confidence") != null) {
|
||||
return jsonObject.getString("confidence");
|
||||
}
|
||||
throw new BizException("人脸比对服务返回异常: " + compareResult);
|
||||
}
|
||||
|
||||
public void init(String studentId, String classId, long corpinfoId) {
|
||||
this.setStudentId(studentId);
|
||||
this.setClassId(classId);
|
||||
this.setCorpinfoId(corpinfoId);
|
||||
this.setStudentSignId(Tools.get32UUID());
|
||||
}
|
||||
}
|
||||
|
||||
package com.zcloud.edu.domain.model.study;
|
||||
|
||||
import com.alibaba.cola.exception.BizException;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.jjb.saas.framework.domain.model.BaseE;
|
||||
import com.zcloud.gbscommon.utils.Base64Util;
|
||||
import com.zcloud.gbscommon.utils.FaceUtil;
|
||||
import com.zcloud.gbscommon.utils.HttpRequestUtil;
|
||||
import com.zcloud.gbscommon.utils.Tools;
|
||||
import lombok.Data;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* web-domain
|
||||
*
|
||||
* @Author zhangyue
|
||||
* @Date 2026-01-13 14:18:20
|
||||
*/
|
||||
@Data
|
||||
public class StudentSignE extends BaseE {
|
||||
private Long id;
|
||||
//学员id
|
||||
private String studentId;
|
||||
//业务id
|
||||
private String studentSignId;
|
||||
//班级id
|
||||
private String classId;
|
||||
//用户id
|
||||
private Long userId;
|
||||
//企业id
|
||||
private Long corpinfoId;
|
||||
//签到人脸路径
|
||||
private String faceUrl;
|
||||
//打卡签字路径
|
||||
private String signUrl;
|
||||
//签到类型 1-打卡签到 2-考试签到
|
||||
private Integer type;
|
||||
|
||||
private String phone;
|
||||
private MultipartFile[] files;
|
||||
//环境
|
||||
private String env;
|
||||
//删除标识true false
|
||||
private String deleteEnum;
|
||||
//备注
|
||||
private String remarks;
|
||||
//创建人姓名
|
||||
private String createName;
|
||||
//更新人姓名
|
||||
private String updateName;
|
||||
//租户id
|
||||
private Long tenantId;
|
||||
//单位id
|
||||
private Long orgId;
|
||||
//版本
|
||||
private Integer version;
|
||||
//创建时间
|
||||
private LocalDateTime createTime;
|
||||
//修改时间
|
||||
private LocalDateTime updateTime;
|
||||
//创建人id
|
||||
private Long createId;
|
||||
//修改人id
|
||||
private Long updateId;
|
||||
|
||||
public void compareFace(String templateFaceUrl, String faceUrl, String prefixUrl, Boolean environment) throws Exception {
|
||||
try {
|
||||
String templateFace = Base64Util.urlToBase64(prefixUrl + templateFaceUrl);
|
||||
Map<String, Object> map = new HashMap<String, Object>();
|
||||
map.put("pic1", templateFace);
|
||||
map.put("pic2", faceUrl);
|
||||
String jsonParam = JSON.toJSONString(map);
|
||||
String compareResultStr;
|
||||
if (environment) {
|
||||
// 正式环境
|
||||
String compareResult = HttpRequestUtil.doPost("http://192.168.192.201:8971/gbs-face/face/compareFace", jsonParam);
|
||||
JSONObject jsonObject = JSONObject.parseObject(compareResult);
|
||||
jsonObject.getJSONObject("info").getString("confidence");
|
||||
compareResultStr = jsonObject.getJSONObject("info").getString("confidence");
|
||||
} else {
|
||||
// 测试环境
|
||||
compareResultStr = FaceUtil.compareFace(templateFace, faceUrl);
|
||||
}
|
||||
|
||||
if (Double.valueOf(compareResultStr) < 75) {
|
||||
throw new BizException("人脸不匹配");
|
||||
}
|
||||
this.setStudentSignId(Tools.get32UUID());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
throw new BizException("人脸不匹配");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void init(String studentId, String classId, long corpinfoId) {
|
||||
this.setStudentId(studentId);
|
||||
this.setClassId(classId);
|
||||
this.setCorpinfoId(corpinfoId);
|
||||
this.setStudentSignId(Tools.get32UUID());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue