|
@@ -3,7 +3,9 @@ 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.JsonElement;
|
|
|
import com.google.gson.JsonObject;
|
|
|
+import com.google.gson.JsonParser;
|
|
|
import com.xjrsoft.module.hikvision.entity.HikvisionData;
|
|
|
import com.xjrsoft.module.hikvision.mapper.HikvisionDataMapper;
|
|
|
import com.xjrsoft.module.hikvision.util.ApiUtil;
|
|
@@ -100,10 +102,42 @@ public class HikvisionLeaveTask {
|
|
|
personDatas.add(personData);
|
|
|
paramJson.add("personDatas", personDatas);
|
|
|
|
|
|
+ JsonArray resourceInfos = selectResource(apiUtil);
|
|
|
+ paramJson.add("resourceInfos", resourceInfos);
|
|
|
+
|
|
|
Map<String, String> header = new HashMap<>();
|
|
|
- header.put("tagId", "deltoken");
|
|
|
+ header.put("tagId", "studentleave");
|
|
|
//调用接口获取到返回内容,并将其存到数据库中
|
|
|
String result = apiUtil.doPost(apiPath, paramJson.toString(), null, header);
|
|
|
System.out.println(result);
|
|
|
}
|
|
|
+
|
|
|
+ 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;
|
|
|
+ }
|
|
|
}
|