|
@@ -1,38 +1,21 @@
|
|
package com.xjrsoft.module.job;
|
|
package com.xjrsoft.module.job;
|
|
|
|
|
|
-import cn.hutool.core.util.StrUtil;
|
|
|
|
import cn.hutool.extra.spring.SpringUtil;
|
|
import cn.hutool.extra.spring.SpringUtil;
|
|
-import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
|
import com.github.yulichang.wrapper.MPJLambdaWrapper;
|
|
import com.github.yulichang.wrapper.MPJLambdaWrapper;
|
|
-import com.google.gson.JsonArray;
|
|
|
|
-import com.google.gson.JsonElement;
|
|
|
|
import com.google.gson.JsonObject;
|
|
import com.google.gson.JsonObject;
|
|
import com.google.gson.JsonParser;
|
|
import com.google.gson.JsonParser;
|
|
import com.xjrsoft.common.enums.ArchivesStatusEnum;
|
|
import com.xjrsoft.common.enums.ArchivesStatusEnum;
|
|
-import com.xjrsoft.common.mybatis.SqlRunnerAdapter;
|
|
|
|
-import com.xjrsoft.common.utils.SqlRunnerAdapterUtil;
|
|
|
|
import com.xjrsoft.common.utils.VoToColumnUtil;
|
|
import com.xjrsoft.common.utils.VoToColumnUtil;
|
|
-import com.xjrsoft.module.hikvision.entity.HikvisionData;
|
|
|
|
-import com.xjrsoft.module.hikvision.mapper.HikvisionDataMapper;
|
|
|
|
import com.xjrsoft.module.hikvision.util.ApiUtil;
|
|
import com.xjrsoft.module.hikvision.util.ApiUtil;
|
|
-import com.xjrsoft.module.hikvision.util.DataUtil;
|
|
|
|
-import com.xjrsoft.module.organization.entity.User;
|
|
|
|
-import com.xjrsoft.module.organization.service.IUserService;
|
|
|
|
|
|
+import com.xjrsoft.module.personnel.entity.StundentFaceProcess;
|
|
|
|
+import com.xjrsoft.module.personnel.service.IStundentFaceProcessService;
|
|
import com.xjrsoft.module.student.entity.BaseStudentSchoolRoll;
|
|
import com.xjrsoft.module.student.entity.BaseStudentSchoolRoll;
|
|
-import com.xjrsoft.module.student.entity.StudentDropOut;
|
|
|
|
-import com.xjrsoft.module.student.mapper.StudentDropOutMapper;
|
|
|
|
-import com.xjrsoft.module.workflow.entity.WorkflowFormRelation;
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
-import org.camunda.bpm.engine.history.HistoricProcessInstance;
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.scheduling.annotation.Scheduled;
|
|
import org.springframework.scheduling.annotation.Scheduled;
|
|
import org.springframework.stereotype.Component;
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
-import java.util.HashMap;
|
|
|
|
-import java.util.HashSet;
|
|
|
|
import java.util.List;
|
|
import java.util.List;
|
|
-import java.util.Map;
|
|
|
|
-import java.util.Set;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
* @author dzx
|
|
* @author dzx
|
|
@@ -43,11 +26,7 @@ import java.util.Set;
|
|
public class StudentDropOutTask {
|
|
public class StudentDropOutTask {
|
|
|
|
|
|
@Autowired
|
|
@Autowired
|
|
- private HikvisionDataMapper hikvisionDataMapper;
|
|
|
|
-
|
|
|
|
- @Autowired
|
|
|
|
- private IUserService userService;
|
|
|
|
-
|
|
|
|
|
|
+ private IStundentFaceProcessService stundentFaceProcessService;
|
|
|
|
|
|
@Scheduled(cron = "0 */30 * * * ?")
|
|
@Scheduled(cron = "0 */30 * * * ?")
|
|
public void execute() {
|
|
public void execute() {
|
|
@@ -66,49 +45,32 @@ public class StudentDropOutTask {
|
|
}
|
|
}
|
|
log.info("开始推送海康威视基础数据");
|
|
log.info("开始推送海康威视基础数据");
|
|
try {
|
|
try {
|
|
- List<User> list = userService.list(
|
|
|
|
- new MPJLambdaWrapper<User>()
|
|
|
|
- .select(User::getId)
|
|
|
|
- .select(User.class, x -> VoToColumnUtil.fieldsToColumns(User.class).contains(x.getProperty()))
|
|
|
|
- .innerJoin(BaseStudentSchoolRoll.class, BaseStudentSchoolRoll::getUserId, User::getId)
|
|
|
|
|
|
+ List<StundentFaceProcess> list = stundentFaceProcessService.list(
|
|
|
|
+ new MPJLambdaWrapper<StundentFaceProcess>()
|
|
|
|
+ .select(StundentFaceProcess::getId)
|
|
|
|
+ .select(StundentFaceProcess.class, x -> VoToColumnUtil.fieldsToColumns(StundentFaceProcess.class).contains(x.getProperty()))
|
|
|
|
+ .innerJoin(BaseStudentSchoolRoll.class, BaseStudentSchoolRoll::getUserId, StundentFaceProcess::getUserId)
|
|
.ne(BaseStudentSchoolRoll::getArchivesStatus, ArchivesStatusEnum.FB2901)
|
|
.ne(BaseStudentSchoolRoll::getArchivesStatus, ArchivesStatusEnum.FB2901)
|
|
|
|
+ .isNotNull(StundentFaceProcess::getHikvisionResult)
|
|
);
|
|
);
|
|
- for (User user : list) {
|
|
|
|
- //删除海康出入权限
|
|
|
|
- String hikvisionId = hikvisionDataMapper.getStudentHikvisionId(user.getId());
|
|
|
|
- if(StrUtil.isEmpty(hikvisionId)){
|
|
|
|
|
|
+ JsonParser parser = new JsonParser();
|
|
|
|
+ for (StundentFaceProcess user : list) {
|
|
|
|
+ //删除海康人脸
|
|
|
|
+
|
|
|
|
+ JsonObject hikvisionResult = parser.parse(user.getHikvisionResult()).getAsJsonObject();
|
|
|
|
+ if(!hikvisionResult.get("msg").isJsonNull() && !"success".equals(hikvisionResult.get("msg").getAsString())){
|
|
continue;
|
|
continue;
|
|
}
|
|
}
|
|
|
|
+ String faceId = hikvisionResult.get("data").getAsJsonObject().get("faceId").getAsString();
|
|
ApiUtil apiUtil = new ApiUtil();
|
|
ApiUtil apiUtil = new ApiUtil();
|
|
- String apiPath = "/api/pmas/v1/person/batch/delete";
|
|
|
|
|
|
+ String apiPath = "/api/resource/v1/face/single/delete";
|
|
JsonObject paramJson = new JsonObject();
|
|
JsonObject paramJson = new JsonObject();
|
|
- JsonArray personIndexCodes = new JsonArray();
|
|
|
|
- personIndexCodes.add(hikvisionId);
|
|
|
|
- paramJson.add("personIndexCodes", personIndexCodes);
|
|
|
|
|
|
+ paramJson.addProperty("faceId", faceId);
|
|
String doPost = apiUtil.doPost(apiPath, paramJson.toString(), null);
|
|
String doPost = apiUtil.doPost(apiPath, paramJson.toString(), null);
|
|
|
|
|
|
- JsonParser parser = new JsonParser();
|
|
|
|
JsonObject resultJson = parser.parse(doPost).getAsJsonObject();
|
|
JsonObject resultJson = parser.parse(doPost).getAsJsonObject();
|
|
if(resultJson.get("code").getAsInt() == 0){
|
|
if(resultJson.get("code").getAsInt() == 0){
|
|
- JsonArray success = resultJson.get("data").getAsJsonObject().get("success").getAsJsonArray();
|
|
|
|
-
|
|
|
|
- Set<String> valuesSet = new HashSet<>();
|
|
|
|
- String keyToExtract = "indexCode";
|
|
|
|
- // 遍历 JSON 数组并提取指定键的值
|
|
|
|
- for (JsonElement jsonElement : success) {
|
|
|
|
- JsonObject jsonObject = jsonElement.getAsJsonObject();
|
|
|
|
- if (jsonObject.has(keyToExtract)) {
|
|
|
|
- String value = jsonObject.get(keyToExtract).getAsString();
|
|
|
|
- valuesSet.add(value);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- if(valuesSet.contains(hikvisionId)){
|
|
|
|
- hikvisionDataMapper.delete(
|
|
|
|
- new QueryWrapper<HikvisionData>().lambda()
|
|
|
|
- .eq(HikvisionData::getSourceId, user.getId())
|
|
|
|
- .eq(HikvisionData::getHikvisionId, hikvisionId)
|
|
|
|
- );
|
|
|
|
- }
|
|
|
|
|
|
+ stundentFaceProcessService.removeById(user);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|