Prechádzať zdrojové kódy

解决删除学生和教职工人脸后未删除海康人脸信息的问题

dzx 4 mesiacov pred
rodič
commit
32312a61b7

+ 25 - 1
src/main/java/com/xjrsoft/module/personnel/service/impl/StundentFaceProcessServiceImpl.java

@@ -3,7 +3,9 @@ package com.xjrsoft.module.personnel.service.impl;
 import cn.dev33.satoken.stp.StpUtil;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.github.yulichang.base.MPJBaseServiceImpl;
+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;
@@ -39,11 +41,33 @@ public class StundentFaceProcessServiceImpl extends MPJBaseServiceImpl<StundentF
         List<StundentFaceProcess> list = this.baseMapper.selectBatchIds(ids);
         ApiUtil apiUtil = new ApiUtil();
         String apiPath = "/api/resource/v1/face/single/delete";
+        JsonParser parser = new JsonParser();
         for (StundentFaceProcess process : list) {
             String studentHikvisionId = hikvisionDataMapper.getStudentHikvisionId(process.getUserId());
 
+            String apiUrl = "/api/resource/v1/person/condition/personInfo";
+            JsonObject paramsJson = new JsonObject();
+            paramsJson.addProperty("paramName", "personId");
+            JsonArray array = new JsonArray();
+            array.add(studentHikvisionId);
+            paramsJson.add("paramValue", array);
+            String personInfoRes = apiUtil.doPost(apiUrl, paramsJson.toString(), null);
+            String faceId = null;
+            JsonObject personInfoData = parser.parse(personInfoRes).getAsJsonObject();
+            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){
+                        faceId = personPhoto.get(0).getAsJsonObject().get("personPhotoIndexCode").getAsString();
+                    }
+
+                }
+            }
+
             JsonObject paramJson = new JsonObject();
-            paramJson.addProperty("faceId", studentHikvisionId);
+            paramJson.addProperty("faceId", faceId);
 
             String result = apiUtil.doPost(apiPath, paramJson.toString(), null);
             process.setExamStatus(2);

+ 27 - 2
src/main/java/com/xjrsoft/module/personnel/service/impl/TeacherFaceProcessServiceImpl.java

@@ -3,7 +3,9 @@ package com.xjrsoft.module.personnel.service.impl;
 import cn.dev33.satoken.stp.StpUtil;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.github.yulichang.base.MPJBaseServiceImpl;
+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;
@@ -38,11 +40,34 @@ public class TeacherFaceProcessServiceImpl extends MPJBaseServiceImpl<TeacherFac
         List<TeacherFaceProcess> list = this.baseMapper.selectBatchIds(ids);
         ApiUtil apiUtil = new ApiUtil();
         String apiPath = "/api/resource/v1/face/single/delete";
+        JsonParser parser = new JsonParser();
         for (TeacherFaceProcess process : list) {
-            String studentHikvisionId = hikvisionDataMapper.getStudentHikvisionId(process.getUserId());
+            String studentHikvisionId = hikvisionDataMapper.getTeacherHikvisionId(process.getUserId());
+
+            String apiUrl = "/api/resource/v1/person/condition/personInfo";
+            JsonObject paramsJson = new JsonObject();
+            paramsJson.addProperty("paramName", "personId");
+            JsonArray array = new JsonArray();
+            array.add(studentHikvisionId);
+            paramsJson.add("paramValue", array);
+            String personInfoRes = apiUtil.doPost(apiUrl, paramsJson.toString(), null);
+            String faceId = null;
+            JsonObject personInfoData = parser.parse(personInfoRes).getAsJsonObject();
+            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){
+                        faceId = personPhoto.get(0).getAsJsonObject().get("personPhotoIndexCode").getAsString();
+                    }
+
+                }
+            }
+
 
             JsonObject paramJson = new JsonObject();
-            paramJson.addProperty("faceId", studentHikvisionId);
+            paramJson.addProperty("faceId", faceId);
 
             String result = apiUtil.doPost(apiPath, paramJson.toString(), null);
             process.setExamStatus(2);