Quellcode durchsuchen

Merge remote-tracking branch 'origin/dev' into dev

dzx vor 1 Jahr
Ursprung
Commit
0ed648b174

+ 9 - 0
src/main/java/com/xjrsoft/module/hikvision/util/ApiUtil.java

@@ -2,6 +2,7 @@ package com.xjrsoft.module.hikvision.util;
 
 import com.hikvision.artemis.sdk.ArtemisHttpUtil;
 import com.hikvision.artemis.sdk.config.ArtemisConfig;
+import org.apache.http.HttpResponse;
 
 import java.util.HashMap;
 import java.util.Map;
@@ -64,4 +65,12 @@ public class ApiUtil {
     public String doPost(String apiPath, String body, Map<String, String> querys){
         return doPost(apiPath, body, querys, null);
     }
+
+    public static String GetRedirectURL(String uri){
+        if (uri != null)
+            return "https://" + ApiUtil.host + "/" + uri;
+        else
+            return null;
+    }
+
 }

+ 2 - 2
src/main/java/com/xjrsoft/module/hikvision/util/DataUtil.java

@@ -479,8 +479,8 @@ public class DataUtil {
             JsonObject paramJson = new JsonObject();
             paramJson.addProperty("clientId", clientId);
             paramJson.addProperty("plateNo", carMessageApply.getCarNumber());
-            System.out.println(faceImportMapper.GetHikvisonPersonId(carMessageApply.getId().toString()) + "heihei");
-            System.out.println(faceImportMapper.GetHikvisonPersonId(carMessageApply.getId().toString()) + "xixi");
+            System.out.println(faceImportMapper.GetHikvisonPersonId(carMessageApply.getId().toString()));
+            System.out.println(faceImportMapper.GetHikvisonPersonId(carMessageApply.getId().toString()));
             paramJson.addProperty("personId", faceImportMapper.GetHikvisonPersonId(carMessageApply.getId().toString()));
 
             int vehicleTypeNum;

+ 19 - 19
src/main/java/com/xjrsoft/module/hikvision/util/Teacher_Student_OutIn_RecordUtil.java

@@ -5,17 +5,12 @@ import com.google.gson.Gson;
 import com.google.gson.JsonArray;
 import com.google.gson.JsonElement;
 import com.google.gson.JsonObject;
-import com.xjrsoft.common.constant.GlobalConstant;
-import com.xjrsoft.common.utils.DatasourceUtil;
 import com.xjrsoft.module.teacher.mapper.FaceImportMapper;
-import org.springframework.beans.factory.annotation.Autowired;
 
-import javax.sql.DataSource;
 import java.sql.SQLException;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Objects;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.*;
 import java.util.concurrent.atomic.AtomicInteger;
 
 
@@ -43,7 +38,7 @@ public class Teacher_Student_OutIn_RecordUtil {
         db.execute(sql);
     }
 
-    public String GetDoorEvents(Db use, FaceImportMapper faceImportMapper) throws SQLException {
+    public String GetDoorEvents(Db use, FaceImportMapper faceImportMapper) throws SQLException, ParseException {
         ApiUtil apiUtil = new ApiUtil();
 
         String apiPath = "/api/acs/v2/door/events";
@@ -76,8 +71,7 @@ public class Teacher_Student_OutIn_RecordUtil {
     }
 
 
-    public void InsertTeacherStudentRecords(Db use, JsonArray doorEventsResponse, FaceImportMapper faceImportMapper) throws SQLException {
-//        for (JsonElement e : doorEventsResponse){
+    public void InsertTeacherStudentRecords(Db use, JsonArray doorEventsResponse, FaceImportMapper faceImportMapper) throws SQLException, ParseException {
         Teacher_Student_OutIn_RecordUtil teacherStudentOutInRecordUtil = new Teacher_Student_OutIn_RecordUtil();
         List<String> teacherEventIdList = faceImportMapper.GetTeacherUrlList();
         List<String> studentEventIdList = faceImportMapper.GetStudentUrlList();
@@ -94,24 +88,23 @@ public class Teacher_Student_OutIn_RecordUtil {
             if (personId == null) continue;
 
             int status = item.get("inAndOutType").getAsInt();
-            String photo = item.get("picUri").isJsonNull() ? null : item.get("picUri").getAsString();
+            String uri = item.get("picUri").isJsonNull() ? null : item.get("picUri").getAsString();
             String recordTime = item.get("eventTime").isJsonNull() ? null : item.get("eventTime").getAsString();
             String eventId = item.get("eventId").isJsonNull() ? null : item.get("eventId").getAsString();
 
             if (!Objects.equals(faceImportMapper.IsStudentTypeByPersonId(personId), "学生")) {
                 // 老师记录
-                if (teacherEventIdList.contains(item.get("eventId").getAsString())) continue;
-                teacherStudentOutInRecordUtil.teacherInsertRecord(use, personId,recordTime,photo,status,eventId);
+                if (teacherEventIdList.contains(eventId)) continue;
+                teacherStudentOutInRecordUtil.teacherInsertRecord(use, personId, ChangeTime(recordTime), ApiUtil.GetRedirectURL(uri),status,eventId);
             } else {
                 // 学生记录
-                if (studentEventIdList.contains(item.get("eventId").getAsString())) continue;
-                teacherStudentOutInRecordUtil.studentInsertRecord(use, personId, faceImportMapper.GetTeacherIdByPersonId(personId), faceImportMapper.GetClassIdByPersonId(personId), photo, recordTime, status,eventId);
+                if (studentEventIdList.contains(eventId)) continue;
+                teacherStudentOutInRecordUtil.studentInsertRecord(use, personId, faceImportMapper.GetTeacherIdByPersonId(personId),
+                        faceImportMapper.GetClassIdByPersonId(personId), ApiUtil.GetRedirectURL(uri), ChangeTime(recordTime), status,eventId);
             }
         }
-//        }
     }
 
-
     void GetVisitRecord(){
         ApiUtil apiUtil = new ApiUtil();
         JsonObject paramJson = new JsonObject();
@@ -121,7 +114,7 @@ public class Teacher_Student_OutIn_RecordUtil {
         Map<String, String> querys = new HashMap<>();
         querys.put("tagId", "frs");
 
-        String apiPath = "/api/visitor/v2/visiting/records\n";
+        String apiPath = "/api/visitor/v2/visiting/records";
         String response = apiUtil.doPost(apiPath, String.valueOf(paramJson), querys);
 
         JsonObject doorEventsJson = new Gson().fromJson(response, JsonObject.class);
@@ -144,4 +137,11 @@ public class Teacher_Student_OutIn_RecordUtil {
         }
     }
 
+    private String ChangeTime(String recordTime) throws ParseException {
+        SimpleDateFormat isoFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
+        SimpleDateFormat mysqlFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+        Date date = isoFormat.parse(recordTime);
+        return mysqlFormat.format(date);
+    }
+
 }

+ 21 - 51
src/test/java/com/xjrsoft/module/job/HikvisionBaseDataTaskTest.java

@@ -8,6 +8,7 @@ import com.google.gson.JsonParser;
 import com.xjrsoft.XjrSoftApplication;
 import com.xjrsoft.common.constant.GlobalConstant;
 import com.xjrsoft.common.utils.DatasourceUtil;
+import com.xjrsoft.module.evaluate.controller.EvaluateItemController;
 import com.xjrsoft.module.hikvision.entity.HikvisionData;
 import com.xjrsoft.module.hikvision.util.ApiUtil;
 import com.xjrsoft.module.hikvision.util.DataUtil;
@@ -15,8 +16,10 @@ import com.xjrsoft.module.organization.entity.Department;
 import com.xjrsoft.module.schedule.entity.JianyueData;
 import com.xjrsoft.module.teacher.entity.XjrUser;
 import com.xjrsoft.module.teacher.mapper.FaceImportMapper;
+import com.xjrsoft.module.hikvision.util.Teacher_Student_OutIn_RecordUtil;
 import lombok.var;
 import org.junit.jupiter.api.Test;
+import org.junit.platform.commons.logging.LoggerFactory;
 import org.junit.runner.RunWith;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.boot.test.context.SpringBootTest;
@@ -30,6 +33,7 @@ import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
+import java.util.logging.Logger;
 
 /**
  * @author dzx
@@ -41,6 +45,9 @@ class HikvisionBaseDataTaskTest {
     @Autowired
     private FaceImportMapper faceImportMapper;
 
+    @Autowired
+    EvaluateItemController evaluateItemController;
+
     @Test
     void test() throws Exception {
         DataSource datasource = DatasourceUtil.getDataSource(GlobalConstant.DEFAULT_DATASOURCE_KEY);
@@ -65,17 +72,15 @@ class HikvisionBaseDataTaskTest {
             dataMap.put(table, tableData);
         }
         DataUtil dataUtil = new DataUtil();
-
-//        deletePerson();
         String tableName = "xjr_department";
-        Map<String, String> department = dataUtil.insertDepartment(use, tableName, dataMap.get(tableName));
-        if(department.isEmpty() && dataMap.get(tableName) != null){
-            department = dataMap.get(tableName);
-        }
+//        Map<String, String> department = dataUtil.insertDepartment(use, tableName, dataMap.get(tableName));
+//        if(department.isEmpty() && dataMap.get(tableName) != null){
+//            department = dataMap.get(tableName);
+//        }
 //
-        //推送教职工
-        tableName = "base_teacher";
-        dataUtil.insertTeacher(use, tableName, dataMap.get(tableName), department);
+//        //推送教职工
+//        tableName = "base_teacher";
+//        dataUtil.insertTeacher(use, tableName, dataMap.get(tableName), department);
 //
         //推送车辆
 
@@ -83,6 +88,7 @@ class HikvisionBaseDataTaskTest {
 //        Map<String, String> baseClass = dataMap.get(carTableName);
 //        dataUtil.insertCar(use, carTableName,baseClass, faceImportMapper);
 
+
 //        tableName = "base_class";
 //        Map<String, String> baseClass = dataMap.get(tableName);
 //        Map<String, String> classes = dataUtil.insertClass(use, tableName, baseClass);
@@ -100,7 +106,7 @@ class HikvisionBaseDataTaskTest {
 
 
 //        selecAllPersonById(use);
-        selecAllPersonById(use);
+        selectResource(use);
     }
 
     public static void selectCar(Db db, String tableName) throws SQLException {
@@ -248,30 +254,14 @@ class HikvisionBaseDataTaskTest {
 
     void selecAllPersonById(Db db) throws SQLException {
         String apiPath = "/api/resource/v2/person/advance/personList";
+        JsonObject jsonObject = new JsonObject();
+        jsonObject.addProperty("pageNo", 1);
+        jsonObject.addProperty("pageSize", 500);
+        jsonObject.addProperty("personIds", "654321987655613");
 
 
-        Map<Long, String> map = new HashMap<>();
-        map.put(14954817043910L, "肖会春");map.put(14954817552454L, "苏平");map.put(14954818123205L, "刘瑞田");
-        map.put(14954818337094L, "王开兰");map.put(14954818837189L, "龚仁容");map.put(14954819407814L, "张洪梅");
-        map.put(14954819516102L, "袁夕芳");map.put(14954819746757L, "冯加林");map.put(14954820166213L, "张凤琴");
-        map.put(14954820362949L, "周家慧");map.put(14954820552390L, "龙运刚");map.put(14954820751429L, "张怀会");
-        map.put(14954825048006L, "李孝秋");map.put(14954802607430L, "王强");
         ApiUtil apiUtil = new ApiUtil();
-        JsonParser parser = new JsonParser();
-        Map<Long, String> idMap = new HashMap<>();
-        for (Long id : map.keySet()) {
-            JsonObject jsonObject = new JsonObject();
-            jsonObject.addProperty("pageNo", 1);
-            jsonObject.addProperty("pageSize", 500);
-            jsonObject.addProperty("personName", map.get(id));
-            String result = apiUtil.doPost(apiPath, jsonObject.toString(), null, null);
-            JsonObject resultJson = parser.parse(result).getAsJsonObject();
-            JsonObject info = resultJson.get("data").getAsJsonObject().get("list").getAsJsonArray().get(0).getAsJsonObject();
-            String personId = info.get("personId").getAsString();
-            idMap.put(id, personId);
-        }
-        insertRecord(db, "base_teacher",idMap);
-
+        String result = apiUtil.doPost(apiPath, jsonObject.toString(), null, null);
     }
 
     void selecAllPerson(Db db) throws SQLException {
@@ -347,24 +337,4 @@ class HikvisionBaseDataTaskTest {
         System.out.println(result);
     }
 
-    void deletePerson(){
-        String apiPath = "/api/resource/v1/person/batch/delete";
-        Map<Long, String> idMap = new HashMap<>();
-        JsonParser jsonParser = new JsonParser();
-        ApiUtil apiUtil = new ApiUtil();
-        JsonArray dataArray = new JsonArray();
-        dataArray.add("14954805813957");dataArray.add("14954812339909");dataArray.add("14954808977606");
-        dataArray.add("14954812285254");dataArray.add("14954812392774");dataArray.add("14954812448325");
-        dataArray.add("14954804711366");dataArray.add("15331003650245");dataArray.add("14954802607430");
-        dataArray.add("14954807016389");dataArray.add("14954803353286");dataArray.add("14954806910277");
-        dataArray.add("14954807016389");
-
-        JsonObject paramJson = new JsonObject();
-        paramJson.add("personIds", dataArray);
-        Map<String, String> headerMap = new HashMap<>();
-        headerMap.put("tagId", "deleteperson");
-        String result = apiUtil.doPost(apiPath, paramJson.toString(), null, headerMap);
-        System.out.println(result);
-    }
-
 }