|
@@ -0,0 +1,143 @@
|
|
|
+package com.xjrsoft.module.hikvision.util;
|
|
|
+
|
|
|
+import cn.dev33.satoken.annotation.SaCheckPermission;
|
|
|
+import cn.hutool.db.Db;
|
|
|
+import com.google.gson.Gson;
|
|
|
+import com.google.gson.JsonArray;
|
|
|
+import com.google.gson.JsonElement;
|
|
|
+import com.google.gson.JsonObject;
|
|
|
+import io.swagger.annotations.ApiOperation;
|
|
|
+import lombok.var;
|
|
|
+import org.springframework.web.bind.annotation.GetMapping;
|
|
|
+
|
|
|
+import java.sql.SQLException;
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.Map;
|
|
|
+
|
|
|
+
|
|
|
+public class Teacher_Student_OutIn_RecordUtil {
|
|
|
+// void tearcherInsertRecord(Db db, Long userId, String recordTime, Long facePhoto,int status) throws SQLException {
|
|
|
+//
|
|
|
+// String sql = "INSERT INTO teacher_out_in_record(create_date, ...) " +
|
|
|
+// "VALUES(now(), '" + userId + "', '" + teacherId + "', '" +
|
|
|
+// classId + "', '" + recordTime + "', '" + facePhoto + "', '" + status + "', '" + entry.getValue() + "')";
|
|
|
+// db.execute(sql);
|
|
|
+// }
|
|
|
+
|
|
|
+ public void studentInsertRecord(Db db, Long userId, Long teacherId, Long classId, String recordTime,Long facePhoto, int status) throws SQLException {
|
|
|
+ String sql = "INSERT INTO teacher_out_in_record(create_date, ...) " +
|
|
|
+ "VALUES(now(), '" + userId + "', '" + teacherId + "', '" +
|
|
|
+ classId + "', '" + recordTime + "', '" + facePhoto + "', '" + status + "', '" + "')";
|
|
|
+ db.execute(sql);
|
|
|
+ }
|
|
|
+
|
|
|
+ public void visitInsertRecord(Db db, Long reservation_school_people_id, String recordTime,Long facePhoto, int status) throws SQLException {
|
|
|
+ String sql = "INSERT INTO visitor_out_in_record(create_date, ...) " +
|
|
|
+ "VALUES(now(), '" + reservation_school_people_id + "', '" +
|
|
|
+ recordTime + "', '" + facePhoto + "', '" + status + "', '" + "')";
|
|
|
+ db.execute(sql);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ @GetMapping(value = "/adada")
|
|
|
+ @ApiOperation(value = "新www价项")
|
|
|
+ @SaCheckPermission("evaluateitem:add")
|
|
|
+ public String GetAccessConsole(){
|
|
|
+ ApiUtil apiUtil = new ApiUtil();
|
|
|
+ JsonObject paramJson = new JsonObject();
|
|
|
+ paramJson.addProperty("pageNo", 1);
|
|
|
+ paramJson.addProperty("pageSize", 100);
|
|
|
+
|
|
|
+ Map<String, String> querys = new HashMap<>();
|
|
|
+ querys.put("tagId", "frs");
|
|
|
+
|
|
|
+ String apiPath = "/api/resource/v2/acsDevice/search";
|
|
|
+ String response = apiUtil.doPost(apiPath, String.valueOf(paramJson), querys);
|
|
|
+
|
|
|
+ return GetDoorEvents(response);
|
|
|
+ }
|
|
|
+
|
|
|
+ public String GetDoorEvents(String accessPointResponse){
|
|
|
+ ApiUtil apiUtil = new ApiUtil();
|
|
|
+
|
|
|
+ JsonObject accessPointJson = new Gson().fromJson(accessPointResponse, JsonObject.class);
|
|
|
+ JsonArray dataList = accessPointJson.getAsJsonObject("data").getAsJsonArray("list");
|
|
|
+ String apiPath = "/api/acs/v2/door/events";
|
|
|
+ String response = null;
|
|
|
+ for(JsonElement element : dataList){
|
|
|
+ JsonObject item = element.getAsJsonObject();
|
|
|
+ JsonObject paramJson = new JsonObject();
|
|
|
+ JsonArray doorIndexCodes = new JsonArray();
|
|
|
+ paramJson.addProperty("pageNo", 1);
|
|
|
+ paramJson.addProperty("pageSize", 10);
|
|
|
+ doorIndexCodes.add(item.get("indexCode"));
|
|
|
+ paramJson.add("doorIndexCodes", doorIndexCodes);
|
|
|
+ response = apiUtil.doPost(apiPath, String.valueOf(paramJson), null);
|
|
|
+ // 执行四中人员的导入
|
|
|
+ stProcessRecords(response);
|
|
|
+
|
|
|
+// doorIndexCodes.add(item.get("indexCode").getAsString());
|
|
|
+ System.out.println(response);
|
|
|
+ }
|
|
|
+
|
|
|
+ return response;
|
|
|
+ }
|
|
|
+
|
|
|
+ public void stProcessRecords(String doorEventsResponse) {
|
|
|
+ JsonObject doorEventsJson = new Gson().fromJson(doorEventsResponse, JsonObject.class);
|
|
|
+ JsonArray dataList = doorEventsJson.getAsJsonObject("data").getAsJsonArray("list");
|
|
|
+
|
|
|
+ for (JsonElement element : dataList) {
|
|
|
+ JsonObject item = element.getAsJsonObject();
|
|
|
+ if (item.get("studentId").isJsonNull()) {
|
|
|
+ // 老师记录
|
|
|
+ String personId = item.get("personId").isJsonNull() ? null : item.get("personId").getAsString();
|
|
|
+ int inAndOutType = item.get("inAndOutType").getAsInt();
|
|
|
+
|
|
|
+ } else {
|
|
|
+ // 学生记录
|
|
|
+ String studentId = item.get("studentId").getAsString();
|
|
|
+ String personId = item.get("personId").isJsonNull() ? null : item.get("personId").getAsString();
|
|
|
+ int status = item.get("inAndOutType").getAsInt();
|
|
|
+ String receiveTime = item.get("receiveTime").getAsString();
|
|
|
+
|
|
|
+ // 执行mapper获取例如班主任等数据 然后执行
|
|
|
+// Teacher_Student_OutIn_RecordUtil teacherStudentOutInRecordUtil = new Teacher_Student_OutIn_RecordUtil();
|
|
|
+// teacherStudentOutInRecordUtil.studentInsertRecord(db...);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ void GetVisitRecord(){
|
|
|
+ ApiUtil apiUtil = new ApiUtil();
|
|
|
+ JsonObject paramJson = new JsonObject();
|
|
|
+ paramJson.addProperty("pageNo", 1);
|
|
|
+ paramJson.addProperty("pageSize", 100);
|
|
|
+
|
|
|
+ Map<String, String> querys = new HashMap<>();
|
|
|
+ querys.put("tagId", "frs");
|
|
|
+
|
|
|
+ String apiPath = "/api/visitor/v2/visiting/records\n";
|
|
|
+ String response = apiUtil.doPost(apiPath, String.valueOf(paramJson), querys);
|
|
|
+
|
|
|
+ JsonObject doorEventsJson = new Gson().fromJson(response, JsonObject.class);
|
|
|
+ JsonArray dataList = doorEventsJson.getAsJsonObject("data").getAsJsonArray("list");
|
|
|
+
|
|
|
+ for (JsonElement element : dataList) {
|
|
|
+ JsonObject item = element.getAsJsonObject();
|
|
|
+ if (item.get("orderId").isJsonNull()) {
|
|
|
+ // 访客记录
|
|
|
+ Long orderId = item.get("orderId").getAsLong();
|
|
|
+ String picUri = item.get("picUri").getAsString();
|
|
|
+ String visitStartTime = item.get("visitStartTime").getAsString();
|
|
|
+ // int status?
|
|
|
+
|
|
|
+ // mapper
|
|
|
+
|
|
|
+// Teacher_Student_OutIn_RecordUtil teacherStudentOutInRecordUtil = new Teacher_Student_OutIn_RecordUtil();
|
|
|
+// teacherStudentOutInRecordUtil.visitInsertRecord();db...);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+}
|