Compare commits

..

No commits in common. "main" and "dev_student" have entirely different histories.

6 changed files with 128 additions and 213 deletions

View File

@ -3,8 +3,8 @@ spring:
import: import:
# - classpath:nacos.yml # - classpath:nacos.yml
# - classpath:sdk.yml # - classpath:sdk.yml
# - classpath:nacos-prod.yml
# - classpath:sdk-prod.yml
- classpath:nacos-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 - classpath:swagger.yml

View File

@ -148,11 +148,11 @@ public class CurriculumUpdateExe {
//如果是企业,可以看本企业下所有的,如果是个人,只能看个人的,判断登录的账号是企业主账号还是个人 //如果是企业,可以看本企业下所有的,如果是个人,只能看个人的,判断登录的账号是企业主账号还是个人
Boolean isCorpAccount = corpInfoRepository.checkCorp(); Boolean isCorpAccount = corpInfoRepository.checkCorp();
// 企业账户检查租户ID匹配 // 企业账户检查租户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()+"课程不是本企业的"); errorList.add(curriculumDO.getCurriculumName()+"课程不是本企业的");
} }
// 个人账户检查创建者ID匹配 // 个人账户检查创建者ID匹配
if (!isCorpAccount && !curriculumDO.getCreateId().equals(AuthContext.getUserId())) { if (!isCorpAccount && curriculumDO.getCreateId().equals(AuthContext.getUserId())) {
errorList.add(curriculumDO.getCurriculumName()+"课程不是本人创建的"); errorList.add(curriculumDO.getCurriculumName()+"课程不是本人创建的");
} }

View File

@ -57,16 +57,16 @@ public class StudentSignAddExe {
String faceUrl = null; String faceUrl = null;
try { try {
faceUrl = Base64Util.getBase64String(studentSignE.getFiles()[0]); faceUrl = Base64Util.getBase64String(studentSignE.getFiles()[0]);
log.info("StudentSignAddExe-execute,调用阿里进行人脸识别开始");
long startAliTime = System.currentTimeMillis();
Boolean environment = false; 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; environment = true;
} }
log.info("StudentSignAddExe-execute,开始进行人脸识别,prefixUrl:{},environment:{}", fileUrlConfig.getPrefixUrl(), environment);
long startAliTime = System.currentTimeMillis(); studentSignE.compareFace(student.getUserAvatarUrl(), faceUrl, fileUrlConfig.getPrefixUrl(),environment);
studentSignE.compareFace(student.getUserAvatarUrl(), faceUrl, fileUrlConfig.getPrefixUrl(), environment); log.info("StudentSignAddExe-execute,调用阿里进行人脸识别结束,耗时:{}",System.currentTimeMillis() - startAliTime);
log.info("StudentSignAddExe-execute,人脸识别结束,耗时:{}", System.currentTimeMillis() - startAliTime);
} catch (BizException e) {
throw e;
} catch (Exception e) { } catch (Exception e) {
throw new RuntimeException(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(".")); String fileName = Tools.get32UUID() + studentSignE.getFiles()[0].getOriginalFilename().substring(studentSignE.getFiles()[0].getOriginalFilename().lastIndexOf("."));
log.info("StudentSignAddExe-execute,保存人脸图片开始"); log.info("StudentSignAddExe-execute,保存人脸图片开始");
long l = System.currentTimeMillis(); long l = System.currentTimeMillis();
try { studentSignE.setFaceUrl(zcloudImgFilesFacade.saveFile( faceUrl,fileName, path));
studentSignE.setFaceUrl(zcloudImgFilesFacade.saveFile(
studentSignE.getFiles()[0].getBytes(), fileName, path, stu.getClassCorpinfoId()));
} catch (IOException e) {
throw new BizException("保存人脸图片失败");
}
log.info("StudentSignAddExe-execute,保存人脸图片结束,耗时:{}",System.currentTimeMillis() - l); log.info("StudentSignAddExe-execute,保存人脸图片结束,耗时:{}",System.currentTimeMillis() - l);
studentSignE.init(stu.getStudentId(), stu.getClassId(), stu.getClassCorpinfoId()); studentSignE.init(stu.getStudentId(), stu.getClassId(), stu.getClassCorpinfoId());
boolean res = false; boolean res = false;

View File

@ -1,7 +1,6 @@
package com.zcloud.edu.dto.training; package com.zcloud.edu.dto.training;
import com.alibaba.cola.dto.Command; import com.alibaba.cola.dto.Command;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Data; import lombok.Data;
@ -30,12 +29,10 @@ public class TrainingUserAddCmd extends Command {
@ApiModelProperty(value = "有效期开始时间", name = "startTime", required = true) @ApiModelProperty(value = "有效期开始时间", name = "startTime", required = true)
@NotNull(message = "有效期开始时间不能为空") @NotNull(message = "有效期开始时间不能为空")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private LocalDateTime startTime; private LocalDateTime startTime;
@ApiModelProperty(value = "有效期结束时间", name = "endTime", required = true) @ApiModelProperty(value = "有效期结束时间", name = "endTime", required = true)
@NotNull(message = "有效期结束时间不能为空") @NotNull(message = "有效期结束时间不能为空")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private LocalDateTime endTime; private LocalDateTime endTime;
@ApiModelProperty(value = "考试状态:1.待考试2:考试通过,3:考试不通过", name = "examineStatus", required = true) @ApiModelProperty(value = "考试状态:1.待考试2:考试通过,3:考试不通过", name = "examineStatus", required = true)

View File

@ -6,17 +6,11 @@ import com.alibaba.fastjson.JSONObject;
import com.jjb.saas.framework.domain.model.BaseE; import com.jjb.saas.framework.domain.model.BaseE;
import com.zcloud.gbscommon.utils.Base64Util; import com.zcloud.gbscommon.utils.Base64Util;
import com.zcloud.gbscommon.utils.FaceUtil; import com.zcloud.gbscommon.utils.FaceUtil;
import com.zcloud.gbscommon.utils.HttpRequestUtil;
import com.zcloud.gbscommon.utils.Tools; import com.zcloud.gbscommon.utils.Tools;
import lombok.Data; import lombok.Data;
import org.springframework.web.multipart.MultipartFile; 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.time.LocalDateTime;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
@ -77,16 +71,19 @@ public class StudentSignE extends BaseE {
public void compareFace(String templateFaceUrl, String faceUrl, String prefixUrl, Boolean environment) throws Exception { public void compareFace(String templateFaceUrl, String faceUrl, String prefixUrl, Boolean environment) throws Exception {
try { try {
String templateFace = Base64Util.urlToBase64(prefixUrl + templateFaceUrl); String templateFace = Base64Util.urlToBase64(prefixUrl + templateFaceUrl);
String compareResultStr; Map<String, Object> map = new HashMap<String, Object>();
if (environment) {
// 正式环境gbs-face
Map<String, Object> map = new HashMap<>();
map.put("pic1", templateFace); map.put("pic1", templateFace);
map.put("pic2", faceUrl); map.put("pic2", faceUrl);
String compareResult = callGbsFaceCompare(JSON.toJSONString(map)); String jsonParam = JSON.toJSONString(map);
compareResultStr = parseGbsFaceConfidence(compareResult); 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 { } else {
// 测试环境:阿里云 // 测试环境
compareResultStr = FaceUtil.compareFace(templateFace, faceUrl); compareResultStr = FaceUtil.compareFace(templateFace, faceUrl);
} }
@ -94,70 +91,11 @@ public class StudentSignE extends BaseE {
throw new BizException("人脸不匹配"); throw new BizException("人脸不匹配");
} }
this.setStudentSignId(Tools.get32UUID()); this.setStudentSignId(Tools.get32UUID());
} catch (BizException e) {
throw e;
} catch (Exception e) { } catch (Exception e) {
throw new BizException("人脸比对失败: " + e.getMessage()); e.printStackTrace();
} throw new BizException("人脸不匹配");
} }
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) { public void init(String studentId, String classId, long corpinfoId) {

View File

@ -17,17 +17,13 @@
<select id="listAllByPhones" resultType="com.zcloud.edu.persistence.dataobject.TrainingUserDO"> <select id="listAllByPhones" resultType="com.zcloud.edu.persistence.dataobject.TrainingUserDO">
select select
tu.phone, phone,
tu.start_time, start_time,
tu.end_time, end_time,
case when tu.start_time &lt; now() and tu.end_time > now() then 1 else 0 end stateFlag case when start_time &lt; now() and end_time > now() then 1 else 0 end stateFlag
from training_user tu
inner join (
select phone, max(id) id
from training_user from training_user
<where> <where>
delete_enum = 'false' delete_enum = 'false'
and start_time IS NOT NULL
<if test="params.phones != null"> <if test="params.phones != null">
and phone in and phone in
<foreach item="phone" collection="params.phones" open="(" separator="," close=")"> <foreach item="phone" collection="params.phones" open="(" separator="," close=")">
@ -35,17 +31,6 @@
</foreach> </foreach>
</if> </if>
</where> </where>
group by phone
) latest on latest.id = tu.id
<where>
tu.delete_enum = 'false'
<if test="params.phones != null">
and tu.phone in
<foreach item="phone" collection="params.phones" open="(" separator="," close=")">
#{phone}
</foreach>
</if>
</where>
</select> </select>
<select id="listEduUserPage" resultType="com.zcloud.edu.persistence.dataobject.TrainingUserDO"> <select id="listEduUserPage" resultType="com.zcloud.edu.persistence.dataobject.TrainingUserDO">