|
|
@@ -0,0 +1,96 @@
|
|
|
+package com.xjrsoft.module.job;
|
|
|
+
|
|
|
+import cn.hutool.core.util.StrUtil;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
+import com.google.gson.JsonArray;
|
|
|
+import com.google.gson.JsonObject;
|
|
|
+import com.google.gson.JsonParser;
|
|
|
+import com.xjrsoft.common.enums.DeleteMark;
|
|
|
+import com.xjrsoft.module.hikvision.mapper.HikvisionDataMapper;
|
|
|
+import com.xjrsoft.module.hikvision.util.ApiUtil;
|
|
|
+import com.xjrsoft.module.hikvision.util.FaceImportUtil;
|
|
|
+import com.xjrsoft.module.personnel.entity.StundentFaceProcess;
|
|
|
+import com.xjrsoft.module.personnel.service.IStundentFaceProcessService;
|
|
|
+import com.xjrsoft.module.teacher.mapper.FaceImportMapper;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.scheduling.annotation.Async;
|
|
|
+import org.springframework.scheduling.annotation.Scheduled;
|
|
|
+import org.springframework.stereotype.Component;
|
|
|
+
|
|
|
+import java.util.Date;
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
+/**
|
|
|
+ * 学生人脸定时同步程序
|
|
|
+ */
|
|
|
+@Component
|
|
|
+@Slf4j
|
|
|
+public class StudentFaceTask {
|
|
|
+ @Autowired
|
|
|
+ private IStundentFaceProcessService stundentFaceProcessService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private HikvisionDataMapper hikvisionDataMapper;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private FaceImportMapper faceImportMapper;
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ @Async
|
|
|
+ @Scheduled(cron = "0 */20 * * * ?")
|
|
|
+ public void addSubmitRecord() {
|
|
|
+
|
|
|
+ List<StundentFaceProcess> list = stundentFaceProcessService.list(
|
|
|
+ new QueryWrapper<StundentFaceProcess>().lambda()
|
|
|
+ .eq(StundentFaceProcess::getDeleteMark, DeleteMark.NODELETE.getCode())
|
|
|
+ .eq(StundentFaceProcess::getExamStatus, 1)
|
|
|
+ .like(StundentFaceProcess::getHikvisionResult, "{\"code\":\"0x")
|
|
|
+ );
|
|
|
+ ApiUtil apiUtil = new ApiUtil();
|
|
|
+ JsonParser parser = new JsonParser();
|
|
|
+
|
|
|
+ for (StundentFaceProcess dataObj : list) {
|
|
|
+ String fileUrl = faceImportMapper.GetStudentHikvisionImgById(dataObj.getId());
|
|
|
+
|
|
|
+ String apiUrl = "/api/resource/v1/person/condition/personInfo";
|
|
|
+ JsonObject paramsJson = new JsonObject();
|
|
|
+ paramsJson.addProperty("paramName", "personId");
|
|
|
+ JsonArray array = new JsonArray();
|
|
|
+ String hikvisionId = hikvisionDataMapper.getStudentHikvisionId(dataObj.getUserId());
|
|
|
+ if(hikvisionId == null){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ array.add(hikvisionId);
|
|
|
+ paramsJson.add("paramValue", array);
|
|
|
+ String personInfoRes = apiUtil.doPost(apiUrl, paramsJson.toString(), null);
|
|
|
+ if(personInfoRes == null){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ JsonObject personInfoData = parser.parse(personInfoRes).getAsJsonObject();
|
|
|
+ String faceId = null;
|
|
|
+ if("0".equals(personInfoData.get("code").getAsString()) && "success".equals(personInfoData.get("msg").getAsString())){
|
|
|
+ JsonObject dataJson = personInfoData.get("data").getAsJsonObject();
|
|
|
+ if(dataJson.get("total").getAsInt() > 0){
|
|
|
+ JsonArray personPhoto = dataJson.get("list").getAsJsonArray().get(0)
|
|
|
+ .getAsJsonObject().get("personPhoto").getAsJsonArray();
|
|
|
+ if(personPhoto.size() == 0){
|
|
|
+ dataObj.setStatus(1);
|
|
|
+ dataObj.setExamStatus(1);
|
|
|
+ String studentHikvisionId = hikvisionDataMapper.getStudentHikvisionId(dataObj.getUserId());
|
|
|
+ if(StrUtil.isEmpty(studentHikvisionId)){
|
|
|
+ studentHikvisionId = dataObj.getUserId().toString();
|
|
|
+ }
|
|
|
+ String result = FaceImportUtil.ImportStudentFace(studentHikvisionId, fileUrl);
|
|
|
+ dataObj.setHikvisionResult(result);
|
|
|
+ dataObj.setModifyDate(new Date());
|
|
|
+ dataObj.setEnabledMark(1);
|
|
|
+ stundentFaceProcessService.updateById(dataObj);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+}
|