|
@@ -0,0 +1,109 @@
|
|
|
|
+package com.xjrsoft.module.job;
|
|
|
|
+
|
|
|
|
+import cn.hutool.extra.spring.SpringUtil;
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
|
+import com.google.gson.JsonArray;
|
|
|
|
+import com.google.gson.JsonObject;
|
|
|
|
+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.student.entity.StudentLeave;
|
|
|
|
+import com.xjrsoft.module.student.service.IStudentLeaveService;
|
|
|
|
+import com.xjrsoft.module.teacher.entity.WfTeacherleave;
|
|
|
|
+import com.xjrsoft.module.teacher.service.IWfTeacherleaveService;
|
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
+import org.springframework.scheduling.annotation.Scheduled;
|
|
|
|
+import org.springframework.stereotype.Component;
|
|
|
|
+
|
|
|
|
+import java.time.LocalDate;
|
|
|
|
+import java.util.ArrayList;
|
|
|
|
+import java.util.Arrays;
|
|
|
|
+import java.util.Date;
|
|
|
|
+import java.util.HashMap;
|
|
|
|
+import java.util.List;
|
|
|
|
+import java.util.Map;
|
|
|
|
+
|
|
|
|
+/**
|
|
|
|
+ * 请假结束之后,删除下发到海康的一卡通权限
|
|
|
|
+ * @author dzx
|
|
|
|
+ * @date 2024/5/8
|
|
|
|
+ */
|
|
|
|
+@Component
|
|
|
|
+@Slf4j
|
|
|
|
+public class HikvisionLeaveTask {
|
|
|
|
+
|
|
|
|
+ @Autowired
|
|
|
|
+ private IStudentLeaveService studentLeaveService;
|
|
|
|
+
|
|
|
|
+ @Autowired
|
|
|
|
+ private IWfTeacherleaveService teacherleaveService;
|
|
|
|
+
|
|
|
|
+ @Autowired
|
|
|
|
+ private HikvisionDataMapper hikvisionDataMapper;
|
|
|
|
+
|
|
|
|
+ @Scheduled(cron = "0 */15 * * * ?")
|
|
|
|
+ public void execute() {
|
|
|
|
+ doExecute();
|
|
|
|
+ }
|
|
|
|
+ public void doExecute() {
|
|
|
|
+ String active = SpringUtil.getActiveProfile();
|
|
|
|
+ if(!"prod".equals(active)){
|
|
|
|
+ log.info("非正式环境,无法执行数据推送");
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ List<String> sourceIds = new ArrayList<>();
|
|
|
|
+
|
|
|
|
+ List<StudentLeave> studentList = studentLeaveService.list(
|
|
|
|
+ new QueryWrapper<StudentLeave>().lambda()
|
|
|
|
+ .isNotNull(StudentLeave::getHikvisionResult)
|
|
|
|
+ .gt(StudentLeave::getEndDate, LocalDate.now())
|
|
|
|
+ );
|
|
|
|
+ for (StudentLeave studentLeave : studentList) {
|
|
|
|
+ sourceIds.add(studentLeave.getStudentUserId().toString());
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ List<WfTeacherleave> teacherList = teacherleaveService.list(
|
|
|
|
+ new QueryWrapper<WfTeacherleave>().lambda()
|
|
|
|
+ .isNotNull(WfTeacherleave::getHikvisionResult)
|
|
|
|
+ .gt(WfTeacherleave::getLeaveEndTime, new Date())
|
|
|
|
+ );
|
|
|
|
+ for (WfTeacherleave teacherleave : teacherList) {
|
|
|
|
+ String[] split = teacherleave.getUserId().split(",");
|
|
|
|
+ sourceIds.addAll( Arrays.asList(split));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if(sourceIds.isEmpty()){
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ List<HikvisionData> hikvisionData = hikvisionDataMapper.selectList(
|
|
|
|
+ new QueryWrapper<HikvisionData>().lambda()
|
|
|
|
+ .in(HikvisionData::getSourceId, sourceIds)
|
|
|
|
+ );
|
|
|
|
+
|
|
|
|
+ ApiUtil apiUtil = new ApiUtil();
|
|
|
|
+ String apiPath = "/api/acps/v1/auth_config/delete";
|
|
|
|
+
|
|
|
|
+ JsonObject paramJson = new JsonObject();
|
|
|
|
+
|
|
|
|
+ JsonArray personDatas = new JsonArray();
|
|
|
|
+ JsonObject personData = new JsonObject();
|
|
|
|
+
|
|
|
|
+ JsonArray indexCodes = new JsonArray();
|
|
|
|
+ for (HikvisionData el : hikvisionData) {
|
|
|
|
+ indexCodes.add(el.getHikvisionId());
|
|
|
|
+ }
|
|
|
|
+ personData.addProperty("personDataType","personGroup");
|
|
|
|
+ personData.add("indexCodes", indexCodes);
|
|
|
|
+ personDatas.add(personData);
|
|
|
|
+ paramJson.add("personDatas", personDatas);
|
|
|
|
+
|
|
|
|
+ Map<String, String> header = new HashMap<>();
|
|
|
|
+ header.put("tagId", "deltoken");
|
|
|
|
+ //调用接口获取到返回内容,并将其存到数据库中
|
|
|
|
+ String result = apiUtil.doPost(apiPath, paramJson.toString(), null, header);
|
|
|
|
+ System.out.println(result);
|
|
|
|
+ }
|
|
|
|
+}
|