|
@@ -17,6 +17,7 @@ import java.net.http.HttpResponse;
|
|
import java.nio.charset.StandardCharsets;
|
|
import java.nio.charset.StandardCharsets;
|
|
import java.time.LocalDateTime;
|
|
import java.time.LocalDateTime;
|
|
import java.time.LocalTime;
|
|
import java.time.LocalTime;
|
|
|
|
+import java.time.ZoneId;
|
|
import java.util.*;
|
|
import java.util.*;
|
|
|
|
|
|
import static com.alibaba.dashscope.utils.JsonUtils.gson;
|
|
import static com.alibaba.dashscope.utils.JsonUtils.gson;
|
|
@@ -160,24 +161,30 @@ public class HikiotTool {
|
|
* @Description 新增/修改人员
|
|
* @Description 新增/修改人员
|
|
* @Date 9:35 2025/8/15
|
|
* @Date 9:35 2025/8/15
|
|
**/
|
|
**/
|
|
- public static String addUser() throws IOException, InterruptedException {
|
|
|
|
|
|
+ public static String addUser(Date inputDate,String deviceSerial,String name,String employeeNo) throws IOException, InterruptedException {
|
|
|
|
+ LocalDateTime now = inputDate.toInstant()
|
|
|
|
+ .atZone(ZoneId.systemDefault())
|
|
|
|
+ .toLocalDateTime();
|
|
|
|
+ LocalDateTime startOfDay = now.with(LocalTime.MIN); // 00:00
|
|
|
|
+ LocalDateTime endOfDay = now.with(LocalTime.MAX);
|
|
AddUserRequestDTO addUserRequestDTO = new AddUserRequestDTO();
|
|
AddUserRequestDTO addUserRequestDTO = new AddUserRequestDTO();
|
|
List<AddUserRequestDTO.DoorRightPlan> doorRightPlans = new ArrayList<>();
|
|
List<AddUserRequestDTO.DoorRightPlan> doorRightPlans = new ArrayList<>();
|
|
AddUserRequestDTO.DoorRightPlan doorRightPlan = new AddUserRequestDTO.DoorRightPlan();
|
|
AddUserRequestDTO.DoorRightPlan doorRightPlan = new AddUserRequestDTO.DoorRightPlan();
|
|
doorRightPlan.setDoorNo(1);
|
|
doorRightPlan.setDoorNo(1);
|
|
doorRightPlan.setPlanTemplateId(Collections.singletonList(1));
|
|
doorRightPlan.setPlanTemplateId(Collections.singletonList(1));
|
|
doorRightPlans.add(doorRightPlan);
|
|
doorRightPlans.add(doorRightPlan);
|
|
- addUserRequestDTO.setDeviceSerial("FX0889961");
|
|
|
|
|
|
+ addUserRequestDTO.setDeviceSerial(deviceSerial);
|
|
addUserRequestDTO.setPayload(new AddUserRequestDTO.Payload()
|
|
addUserRequestDTO.setPayload(new AddUserRequestDTO.Payload()
|
|
.setUserInfo(new AddUserRequestDTO.UserInfo()
|
|
.setUserInfo(new AddUserRequestDTO.UserInfo()
|
|
.setUserType(VISITOR)
|
|
.setUserType(VISITOR)
|
|
- .setEmployeeNo("00wm")
|
|
|
|
- .setName("王明")
|
|
|
|
|
|
+ .setEmployeeNo(employeeNo)
|
|
|
|
+ .setName(name)
|
|
.setDoorRightPlan(doorRightPlans)
|
|
.setDoorRightPlan(doorRightPlans)
|
|
.setDoorRight(Collections.singletonList(1))
|
|
.setDoorRight(Collections.singletonList(1))
|
|
- .setPermanentValid(true).setMaxOpenDoorTime(255)
|
|
|
|
- .setEnableBeginTime(LocalDateTimeUtil.format(LocalDateTime.now().with(LocalTime.MIN), "yyyy-MM-dd'T'HH:mm:ss"))
|
|
|
|
- .setEnableEndTime("2025-12-31T23:59:59")));
|
|
|
|
|
|
+ .setPermanentValid(false)
|
|
|
|
+ .setMaxOpenDoorTime(255)
|
|
|
|
+ .setEnableBeginTime(LocalDateTimeUtil.format(startOfDay, "yyyy-MM-dd'T'HH:mm:ss"))
|
|
|
|
+ .setEnableEndTime(LocalDateTimeUtil.format(endOfDay, "yyyy-MM-dd'T'HH:mm:ss"))));
|
|
return sendPostRequest(ADD_USER_URL, gson.toJson(addUserRequestDTO),setHeaders());
|
|
return sendPostRequest(ADD_USER_URL, gson.toJson(addUserRequestDTO),setHeaders());
|
|
}
|
|
}
|
|
|
|
|
|
@@ -186,10 +193,10 @@ public class HikiotTool {
|
|
* @Description 设备添加
|
|
* @Description 设备添加
|
|
* @Date 10:47 2025/8/15
|
|
* @Date 10:47 2025/8/15
|
|
**/
|
|
**/
|
|
- public static String addDevice() throws IOException, InterruptedException {
|
|
|
|
|
|
+ public static String addDevice(String deviceSerial,String validateCode) throws IOException, InterruptedException {
|
|
Map<String, String> device = new HashMap<>();
|
|
Map<String, String> device = new HashMap<>();
|
|
- device.put("deviceSerial", "FX0889961");
|
|
|
|
- device.put("validateCode", "zswl8812");
|
|
|
|
|
|
+ device.put("deviceSerial", deviceSerial);
|
|
|
|
+ device.put("validateCode", validateCode);
|
|
device.put("addMethod", "DeviceToken");
|
|
device.put("addMethod", "DeviceToken");
|
|
device.put("qrCode", "");
|
|
device.put("qrCode", "");
|
|
return sendPostRequest(ADD_DEVICE_URL, gson.toJson(device),setHeaders());
|
|
return sendPostRequest(ADD_DEVICE_URL, gson.toJson(device),setHeaders());
|
|
@@ -235,12 +242,13 @@ public class HikiotTool {
|
|
* @Description 新增/修改人脸
|
|
* @Description 新增/修改人脸
|
|
* @Date 14:28 2025/8/15
|
|
* @Date 14:28 2025/8/15
|
|
**/
|
|
**/
|
|
- public static String addFace() throws IOException, InterruptedException {
|
|
|
|
|
|
+ public static String addFace(String deviceSerial,String employeeNo,String url) throws IOException, InterruptedException {
|
|
AddFaceRequestDTO addFaceRequestDTO = new AddFaceRequestDTO();
|
|
AddFaceRequestDTO addFaceRequestDTO = new AddFaceRequestDTO();
|
|
- addFaceRequestDTO.setDeviceSerial("FX0889961");
|
|
|
|
|
|
+ addFaceRequestDTO.setDeviceSerial(deviceSerial);
|
|
addFaceRequestDTO.setPayload(new AddFaceRequestDTO.Payload()
|
|
addFaceRequestDTO.setPayload(new AddFaceRequestDTO.Payload()
|
|
- .setFaceInfo(new AddFaceRequestDTO.Payload.FaceInfo().setEmployeeNo("00wm")
|
|
|
|
- .setFaceURL("https://dst-health.oss-cn-chengdu.aliyuncs.com/20250818/0e6f578209ba4eb995a73c6130ba9836.jpg")));
|
|
|
|
|
|
+ .setFaceInfo(new AddFaceRequestDTO.Payload.FaceInfo()
|
|
|
|
+ .setEmployeeNo(employeeNo)
|
|
|
|
+ .setFaceURL(url)));
|
|
return sendPostRequest(ADD_FACE_URL, gson.toJson(addFaceRequestDTO),setHeaders());
|
|
return sendPostRequest(ADD_FACE_URL, gson.toJson(addFaceRequestDTO),setHeaders());
|
|
}
|
|
}
|
|
|
|
|
|
@@ -261,11 +269,11 @@ public class HikiotTool {
|
|
* @Description 配置人员周计划
|
|
* @Description 配置人员周计划
|
|
* @Date 16:12 2025/8/15
|
|
* @Date 16:12 2025/8/15
|
|
**/
|
|
**/
|
|
- public static String addUserWeekPlan() throws IOException, InterruptedException {
|
|
|
|
|
|
+ public static String addUserWeekPlan(String deviceSerial) throws IOException, InterruptedException {
|
|
AddUserWeekPlanDTO dto = new AddUserWeekPlanDTO();
|
|
AddUserWeekPlanDTO dto = new AddUserWeekPlanDTO();
|
|
|
|
|
|
// 基础配置
|
|
// 基础配置
|
|
- dto.setDeviceSerial("FX0889961");
|
|
|
|
|
|
+ dto.setDeviceSerial(deviceSerial);
|
|
|
|
|
|
// 初始化payload
|
|
// 初始化payload
|
|
AddUserWeekPlanDTO.Payload payload = new AddUserWeekPlanDTO.Payload();
|
|
AddUserWeekPlanDTO.Payload payload = new AddUserWeekPlanDTO.Payload();
|
|
@@ -315,9 +323,9 @@ public class HikiotTool {
|
|
* @Description 配置人员计划模板
|
|
* @Description 配置人员计划模板
|
|
* @Date 17:09 2025/8/15
|
|
* @Date 17:09 2025/8/15
|
|
**/
|
|
**/
|
|
- public static String addUserPlanTemplate() throws IOException, InterruptedException {
|
|
|
|
|
|
+ public static String addUserPlanTemplate(String deviceSerial) throws IOException, InterruptedException {
|
|
String addUserPlanTemplate = "{\n" +
|
|
String addUserPlanTemplate = "{\n" +
|
|
- " \"deviceSerial\": \"FX0889961\",\n" +
|
|
|
|
|
|
+ " \"deviceSerial\": \"" + deviceSerial +"\",\n" +
|
|
" \"payload\": {\n" +
|
|
" \"payload\": {\n" +
|
|
" \"userPlanTemplate\": {\n" +
|
|
" \"userPlanTemplate\": {\n" +
|
|
" \"doorPlanTemplateId\": 1,\n" +
|
|
" \"doorPlanTemplateId\": 1,\n" +
|
|
@@ -429,7 +437,7 @@ public class HikiotTool {
|
|
}
|
|
}
|
|
|
|
|
|
public static void main(String[] args) throws IOException, InterruptedException {
|
|
public static void main(String[] args) throws IOException, InterruptedException {
|
|
- addUser();
|
|
|
|
|
|
+// addUser();
|
|
// addUserPlanTemplate();
|
|
// addUserPlanTemplate();
|
|
// addFace();
|
|
// addFace();
|
|
// addUserWeekPlan();
|
|
// addUserWeekPlan();
|