|
|
@@ -6,12 +6,14 @@ import cn.hutool.core.bean.BeanUtil;
|
|
|
import cn.hutool.core.util.IdUtil;
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.StringPool;
|
|
|
import com.github.yulichang.toolkit.MPJWrappers;
|
|
|
import com.github.yulichang.wrapper.MPJLambdaWrapper;
|
|
|
import com.google.gson.JsonObject;
|
|
|
+import com.google.gson.JsonParser;
|
|
|
import com.xjrsoft.common.enums.DeleteMark;
|
|
|
import com.xjrsoft.common.model.result.RT;
|
|
|
import com.xjrsoft.common.page.ConventPage;
|
|
|
@@ -182,6 +184,26 @@ public class StundentFaceProcessController {
|
|
|
studentClassMap.put(classVo.getUserId(), classVo);
|
|
|
}
|
|
|
|
|
|
+ List<StundentFaceProcess> faceList = stundentFaceProcessService.list(
|
|
|
+ new QueryWrapper<StundentFaceProcess>().lambda()
|
|
|
+ .eq(StundentFaceProcess::getDeleteMark, DeleteMark.NODELETE.getCode())
|
|
|
+ );
|
|
|
+ Map<Long, StundentFaceProcess> faceMap = new HashMap<>();
|
|
|
+ for (StundentFaceProcess faceProcess : faceList) {
|
|
|
+ faceMap.put(faceProcess.getUserId(), faceProcess);
|
|
|
+ }
|
|
|
+
|
|
|
+ List<FaceManagement> faceManagementList = faceManagementService.list(
|
|
|
+ new QueryWrapper<FaceManagement>().lambda()
|
|
|
+ .eq(FaceManagement::getDeleteMark, DeleteMark.NODELETE.getCode())
|
|
|
+ .eq(FaceManagement::getUserType, 2)
|
|
|
+ );
|
|
|
+ Map<Long, FaceManagement> faceManagementMap = new HashMap<>();
|
|
|
+ for (FaceManagement management : faceManagementList) {
|
|
|
+ faceManagementMap.put(management.getUserId(), management);
|
|
|
+ }
|
|
|
+ JsonParser parser = new JsonParser();
|
|
|
+
|
|
|
ApiUtil apiUtil = new ApiUtil();
|
|
|
Long folderId = IdWorker.getId();
|
|
|
ZipFile zipFile = FileZipUtil.convertToZipFile(file);
|
|
|
@@ -228,52 +250,92 @@ public class StundentFaceProcessController {
|
|
|
fileEntity.setFileType(suffix);
|
|
|
fileService.save(fileEntity);
|
|
|
|
|
|
- long baseFaceId = IdUtil.getSnowflakeNextId();
|
|
|
- FaceManagement baseFace = new FaceManagement();
|
|
|
- baseFace.setId(baseFaceId);
|
|
|
- baseFace.setRegisterBase64(base64String);
|
|
|
- baseFace.setUserId(studentUser.getId());
|
|
|
- baseFace.setSex(studentUser.getGender());
|
|
|
- baseFace.setName(studentUser.getName());
|
|
|
- baseFace.setIdno(studentUser.getCredentialNumber());
|
|
|
- baseFace.setVerifyStatus(1);
|
|
|
- baseFace.setCreateDate(LocalDateTime.now());
|
|
|
- baseFace.setCreateUserId(StpUtil.getLoginIdAsLong());
|
|
|
- baseFace.setDeleteMark(0);
|
|
|
- baseFace.setStatus(1);
|
|
|
- baseFace.setFileId(fileId);
|
|
|
- baseFace.setUserType(2L);
|
|
|
- faceManagementService.save(baseFace);
|
|
|
-
|
|
|
- StudentClassVo classVo = studentClassMap.get(studentUser.getId());
|
|
|
- StundentFaceProcess studentFace = new StundentFaceProcess();
|
|
|
- studentFace.setStatus(1);
|
|
|
- studentFace.setCreateDate(new Date());
|
|
|
- studentFace.setCreateUserId(StpUtil.getLoginIdAsLong());
|
|
|
- studentFace.setDeleteMark(0);
|
|
|
- studentFace.setGender(studentUser.getGender());
|
|
|
- studentFace.setFacePhoto(fileId);
|
|
|
- studentFace.setName(studentUser.getName());
|
|
|
- studentFace.setClassId(classVo.getId());
|
|
|
- studentFace.setClassCn(classVo.getName());
|
|
|
- studentFace.setTeacherId(classVo.getTeacherId());
|
|
|
- studentFace.setIdentityCard(studentUser.getCredentialNumber());
|
|
|
- studentFace.setStatus(1);
|
|
|
- studentFace.setUserId(studentUser.getId());
|
|
|
- studentFace.setExamStatus(1);
|
|
|
-
|
|
|
-
|
|
|
- //将人脸上传海康
|
|
|
- JsonObject paramJson = new JsonObject();
|
|
|
- paramJson.addProperty("personId", studentUser.getId());
|
|
|
- paramJson.addProperty("faceData", base64String);
|
|
|
-
|
|
|
- Map<String, String> querys = new HashMap<>();
|
|
|
- querys.put("tagId", "frs");
|
|
|
-
|
|
|
- String apiPath = "/api/resource/v1/face/single/add";
|
|
|
- String response = apiUtil.doPost(apiPath, String.valueOf(paramJson), querys);
|
|
|
- stundentFaceProcessService.save(studentFace);
|
|
|
+ StundentFaceProcess process = faceMap.get(studentUser.getId());
|
|
|
+ if(process == null){
|
|
|
+ long baseFaceId = IdUtil.getSnowflakeNextId();
|
|
|
+ FaceManagement baseFace = new FaceManagement();
|
|
|
+ baseFace.setId(baseFaceId);
|
|
|
+ baseFace.setRegisterBase64(base64String);
|
|
|
+ baseFace.setUserId(studentUser.getId());
|
|
|
+ baseFace.setSex(studentUser.getGender());
|
|
|
+ baseFace.setName(studentUser.getName());
|
|
|
+ baseFace.setIdno(studentUser.getCredentialNumber());
|
|
|
+ baseFace.setVerifyStatus(1);
|
|
|
+ baseFace.setCreateDate(LocalDateTime.now());
|
|
|
+ baseFace.setCreateUserId(StpUtil.getLoginIdAsLong());
|
|
|
+ baseFace.setDeleteMark(0);
|
|
|
+ baseFace.setStatus(1);
|
|
|
+ baseFace.setFileId(folderId);
|
|
|
+ baseFace.setUserType(2L);
|
|
|
+ faceManagementService.save(baseFace);
|
|
|
+
|
|
|
+ StudentClassVo classVo = studentClassMap.get(studentUser.getId());
|
|
|
+ StundentFaceProcess studentFace = new StundentFaceProcess();
|
|
|
+ studentFace.setStatus(1);
|
|
|
+ studentFace.setCreateDate(new Date());
|
|
|
+ studentFace.setCreateUserId(StpUtil.getLoginIdAsLong());
|
|
|
+ studentFace.setDeleteMark(0);
|
|
|
+ studentFace.setGender(studentUser.getGender());
|
|
|
+ studentFace.setFacePhoto(folderId);
|
|
|
+ studentFace.setName(studentUser.getName());
|
|
|
+ studentFace.setClassId(classVo.getId());
|
|
|
+ studentFace.setClassCn(classVo.getName());
|
|
|
+ studentFace.setTeacherId(classVo.getTeacherId());
|
|
|
+ studentFace.setIdentityCard(studentUser.getCredentialNumber());
|
|
|
+ studentFace.setStatus(1);
|
|
|
+ studentFace.setUserId(studentUser.getId());
|
|
|
+ studentFace.setExamStatus(1);
|
|
|
+
|
|
|
+ //将人脸上传海康
|
|
|
+ JsonObject paramJson = new JsonObject();
|
|
|
+ paramJson.addProperty("personId", studentUser.getId());
|
|
|
+ paramJson.addProperty("faceData", base64String);
|
|
|
+
|
|
|
+ Map<String, String> querys = new HashMap<>();
|
|
|
+ querys.put("tagId", "frs");
|
|
|
+
|
|
|
+ String apiPath = "/api/resource/v1/face/single/add";
|
|
|
+ String response = apiUtil.doPost(apiPath, String.valueOf(paramJson), querys);
|
|
|
+ studentFace.setHikvisionResult(response);
|
|
|
+ stundentFaceProcessService.save(studentFace);
|
|
|
+ }else{
|
|
|
+ process.setStatus(1);
|
|
|
+ process.setExamStatus(1);
|
|
|
+ process.setModifyDate(new Date());
|
|
|
+ process.setModifyUserId(StpUtil.getLoginIdAsLong());
|
|
|
+ process.setDeleteMark(0);
|
|
|
+ process.setFacePhoto(folderId);
|
|
|
+
|
|
|
+ String faceId = null;
|
|
|
+ if(process.getHikvisionResult() == null){
|
|
|
+ JsonObject object = parser.parse(process.getHikvisionResult()).getAsJsonObject();
|
|
|
+ if("0".equals(object.get("code").getAsString()) && "success".equals(object.get("msg").getAsString())){
|
|
|
+ faceId = object.get("data").getAsJsonObject().get("faceId").getAsString();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //更新海康数据
|
|
|
+ JsonObject paramJson = new JsonObject();
|
|
|
+ String apiPath;
|
|
|
+ if(faceId != null){
|
|
|
+ apiPath = "api/resource/v1/face/single/update";
|
|
|
+ paramJson.addProperty("faceId", faceId);
|
|
|
+ paramJson.addProperty("faceData", base64String);
|
|
|
+
|
|
|
+ }else{
|
|
|
+ apiPath = "api/resource/v1/face/single/add";
|
|
|
+ paramJson.addProperty("personId", studentUser.getId());
|
|
|
+ paramJson.addProperty("faceData", base64String);
|
|
|
+ }
|
|
|
+ String result = apiUtil.doPost(apiPath, paramJson.toString(), null);
|
|
|
+ process.setHikvisionResult(result);
|
|
|
+ stundentFaceProcessService.updateById(process);
|
|
|
+
|
|
|
+ FaceManagement faceManagement = faceManagementMap.get(studentUser.getId());
|
|
|
+ faceManagement.setVerifyStatus(2);
|
|
|
+ faceManagement.setRegisterBase64(base64String);
|
|
|
+ faceManagementService.update(faceManagement);
|
|
|
+ }
|
|
|
}
|
|
|
return RT.ok(true);
|
|
|
}
|