|
|
@@ -3,7 +3,14 @@ package com.xjrsoft.module.teacher.service.impl;
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.github.yulichang.base.MPJBaseServiceImpl;
|
|
|
+import com.google.gson.JsonArray;
|
|
|
+import com.google.gson.JsonElement;
|
|
|
+import com.google.gson.JsonObject;
|
|
|
+import com.google.gson.JsonParser;
|
|
|
import com.xjrsoft.common.enums.LeaveReasonEnum;
|
|
|
+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.teacher.entity.WfHeadTeacherLeave;
|
|
|
import com.xjrsoft.module.teacher.entity.WfTeacherleave;
|
|
|
import com.xjrsoft.module.teacher.mapper.WfTeacherleaveMapper;
|
|
|
@@ -13,11 +20,18 @@ import lombok.AllArgsConstructor;
|
|
|
import lombok.Data;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
-import java.time.*;
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
+import java.time.DayOfWeek;
|
|
|
+import java.time.Instant;
|
|
|
+import java.time.LocalDateTime;
|
|
|
+import java.time.LocalTime;
|
|
|
+import java.time.ZoneId;
|
|
|
import java.time.temporal.ChronoUnit;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.Date;
|
|
|
+import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
|
|
|
/**
|
|
|
* @title: 教职工请假流程
|
|
|
@@ -30,7 +44,7 @@ import java.util.List;
|
|
|
public class WfTeacherleaveServiceImpl extends MPJBaseServiceImpl<WfTeacherleaveMapper, WfTeacherleave> implements IWfTeacherleaveService {
|
|
|
|
|
|
private final IWfHeadTeacherLeaveService wfHeadTeacherLeaveService;
|
|
|
-
|
|
|
+ private final HikvisionDataMapper hikvisionDataMapper;
|
|
|
@Override
|
|
|
public Boolean dataHandle(Long dataId) {
|
|
|
WfTeacherleave wfTeacherleave = this.getById(dataId);
|
|
|
@@ -125,6 +139,79 @@ public class WfTeacherleaveServiceImpl extends MPJBaseServiceImpl<WfTeacherleave
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public Boolean hikvisionLeave(Long id) {
|
|
|
+ WfTeacherleave teacherleave = this.getById(id);
|
|
|
+ //查询学生在海康的id
|
|
|
+ HikvisionData hikvisionData = hikvisionDataMapper.selectOne(
|
|
|
+ new QueryWrapper<HikvisionData>().lambda()
|
|
|
+ .eq(HikvisionData::getSourceId, teacherleave.getUserId())
|
|
|
+ .eq(HikvisionData::getTableName, "base_teacher")
|
|
|
+ );
|
|
|
+ ApiUtil apiUtil = new ApiUtil();
|
|
|
+ String apiPath = "/api/acps/v1/auth_config/add";
|
|
|
+
|
|
|
+ String outputFormat = "yyyy-MM-dd'T'HH:mm:ss+08:00";
|
|
|
+ SimpleDateFormat sdf = new SimpleDateFormat(outputFormat);
|
|
|
+ JsonObject paramJson = new JsonObject();
|
|
|
+
|
|
|
+ paramJson.addProperty("startTime", sdf.format(teacherleave.getLeaveStartTime()));
|
|
|
+ paramJson.addProperty("endTime", sdf.format(teacherleave.getLeaveEndTime()));
|
|
|
+
|
|
|
+ //组装人员数据
|
|
|
+ JsonArray personDatas = new JsonArray();
|
|
|
+ JsonObject personData = new JsonObject();
|
|
|
+ personData.addProperty("personDataType", "person");
|
|
|
+
|
|
|
+ JsonArray indexCodes = new JsonArray();
|
|
|
+ indexCodes.add(hikvisionData.getHikvisionId());
|
|
|
+ personData.add("indexCodes", indexCodes);
|
|
|
+
|
|
|
+ personDatas.add(personData);
|
|
|
+ paramJson.add("personDatas", personDatas);
|
|
|
+
|
|
|
+ JsonArray resourceInfos = selectResource(apiUtil);
|
|
|
+ paramJson.add("resourceInfos", resourceInfos);
|
|
|
+
|
|
|
+ Map<String, String> header = new HashMap<>();
|
|
|
+ header.put("tagId", "studentleave");
|
|
|
+ //调用接口获取到返回内容,并将其存到数据库中
|
|
|
+ String result = apiUtil.doPost(apiPath, paramJson.toString(), null, header);
|
|
|
+ teacherleave.setHikvisionResult(result);
|
|
|
+ this.updateById(teacherleave);
|
|
|
+
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
+ JsonArray selectResource(ApiUtil apiUtil){
|
|
|
+ String apiPath = "/api/irds/v2/resource/resourcesByParams";
|
|
|
+ JsonObject jsonObject = new JsonObject();
|
|
|
+ jsonObject.addProperty("pageNo", 1);
|
|
|
+ jsonObject.addProperty("pageSize", 500);
|
|
|
+ jsonObject.addProperty("resourceType", "door");
|
|
|
+
|
|
|
+ String result = apiUtil.doPost(apiPath, jsonObject.toString(), null, null);
|
|
|
+ JsonParser parser = new JsonParser();
|
|
|
+ JsonObject resultJson = parser.parse(result).getAsJsonObject();
|
|
|
+ JsonArray resourceInfos = new JsonArray();
|
|
|
+
|
|
|
+ if("0".equals(resultJson.get("code").getAsString()) && "success".equals(resultJson.get("msg").getAsString())){
|
|
|
+ JsonArray list = resultJson.get("data").getAsJsonObject().get("list").getAsJsonArray();
|
|
|
+ for (JsonElement jsonElement : list) {
|
|
|
+ JsonObject listOne = jsonElement.getAsJsonObject();
|
|
|
+ JsonObject resourceInfo = new JsonObject();
|
|
|
+ resourceInfo.add("resourceIndexCode", listOne.get("indexCode"));
|
|
|
+ resourceInfo.add("resourceType", listOne.get("resourceType"));
|
|
|
+ JsonArray channelNos = new JsonArray();
|
|
|
+ channelNos.add(listOne.get("channelNo"));
|
|
|
+ resourceInfo.add("channelNos", channelNos);
|
|
|
+ resourceInfos.add(resourceInfo);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return resourceInfos;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 按日分割
|
|
|
*
|