|
|
@@ -1,8 +1,12 @@
|
|
|
package com.xjrsoft.module.liteflow.node;
|
|
|
|
|
|
-import cn.hutool.core.convert.Convert;
|
|
|
+import com.google.gson.JsonArray;
|
|
|
+import com.google.gson.JsonObject;
|
|
|
+import com.google.gson.JsonParser;
|
|
|
import com.xjrsoft.XjrSoftApplication;
|
|
|
+import com.xjrsoft.common.mybatis.SqlRunnerAdapter;
|
|
|
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;
|
|
|
@@ -13,7 +17,11 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.boot.test.context.SpringBootTest;
|
|
|
import org.springframework.test.context.junit4.SpringRunner;
|
|
|
|
|
|
-import static org.junit.jupiter.api.Assertions.*;
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.Date;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+
|
|
|
|
|
|
/**
|
|
|
* @author dzx
|
|
|
@@ -32,18 +40,107 @@ class ImportStudentFaceNodeTest {
|
|
|
private FaceImportMapper faceImportMapper;
|
|
|
@Test
|
|
|
void test(){
|
|
|
- Long formId = 1799211798557667328L;
|
|
|
- if (formId != null) {
|
|
|
- String fileUrl = faceImportMapper.GetStudentHikvisionImgById(formId);
|
|
|
+ String sql = "SELECT t1.* FROM xjr_user t1" +
|
|
|
+ " INNER JOIN base_student_school_roll t2 ON t1.id = t2.user_id" +
|
|
|
+ " WHERE t2.archives_status = 'FB2901' and t1.id = 654321987655958";
|
|
|
+ List<Map<String, Object>> list = SqlRunnerAdapter.db().selectList(sql);
|
|
|
+
|
|
|
+ ApiUtil apiUtil = new ApiUtil();
|
|
|
+ JsonParser parser = new JsonParser();
|
|
|
+ for (Map<String, Object> user : list) {
|
|
|
+ long userId = Long.parseLong(user.get("id").toString());
|
|
|
+ sql = "SELECT * FROM stundent_face_process WHERE user_id = " + userId + " AND exam_status = 1 AND STATUS = 1 ORDER BY create_date DESC,modify_date DESC LIMIT 1";
|
|
|
+ Map<String, Object> process = SqlRunnerAdapter.db().selectOne(sql);
|
|
|
+
|
|
|
+ if(process == null || process.isEmpty()){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ long id = Long.parseLong(process.get("id").toString());
|
|
|
+ String fileUrl = faceImportMapper.GetStudentHikvisionImgById(id);
|
|
|
+ // 数据处理
|
|
|
+ StundentFaceProcess dataObj = stundentFaceProcessService.getById(process.get("id").toString());
|
|
|
+ if(dataObj == null){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ 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 result = FaceImportUtil.ImportStudentFace(hikvisionDataMapper.getStudentHikvisionId(dataObj.getUserId()), fileUrl);
|
|
|
+ dataObj.setHikvisionResult(result);
|
|
|
+ dataObj.setModifyDate(new Date());
|
|
|
+ dataObj.setEnabledMark(1);
|
|
|
+ stundentFaceProcessService.updateById(dataObj);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Test
|
|
|
+ void test2(){
|
|
|
+
|
|
|
+ String sql = "SELECT * FROM stundent_face_process WHERE id in (1802917291234996224, 1798295439057399810,1798295434271698945)";
|
|
|
+ List<Map<String, Object>> list = SqlRunnerAdapter.db().selectList(sql);
|
|
|
+
|
|
|
+ ApiUtil apiUtil = new ApiUtil();
|
|
|
+ JsonParser parser = new JsonParser();
|
|
|
+ List<Long> ids = new ArrayList<>();
|
|
|
+ for (Map<String, Object> process : list) {
|
|
|
+ long id = Long.parseLong(process.get("id").toString());
|
|
|
// 数据处理
|
|
|
- StundentFaceProcess dataObj = stundentFaceProcessService.getById(formId);
|
|
|
- dataObj.setStatus(1);
|
|
|
- dataObj.setExamStatus(1);
|
|
|
- String result = FaceImportUtil.ImportStudentFace(hikvisionDataMapper.getStudentHikvisionId(dataObj.getUserId()), fileUrl);
|
|
|
- dataObj.setHikvisionResult(result);
|
|
|
- stundentFaceProcessService.updateById(dataObj);
|
|
|
+ StundentFaceProcess dataObj = stundentFaceProcessService.getById(process.get("id").toString());
|
|
|
|
|
|
+ if(dataObj == null){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
|
|
|
+ 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);
|
|
|
+ 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){
|
|
|
+ ids.add(id);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
+
|
|
|
+ System.out.println("ids.size() ----------> " + ids.size());
|
|
|
}
|
|
|
}
|