Explorar el Código

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

dzx hace 5 meses
padre
commit
bc212d8592

+ 6 - 3
src/main/java/com/xjrsoft/module/hikvision/controller/EventController.java

@@ -208,9 +208,12 @@ public class EventController {
         ApiUtil apiUtil = new ApiUtil();
         JsonArray eventList = new JsonArray();
 //*******手动更改****************************************************
-//        eventList.add(196893);
-        eventList.add(771760130);
-        eventList.add(771760133);
+        eventList.add(196893);
+//        eventList.add(197151);
+        eventList.add(1392513025); //访客登记
+        eventList.add(1392513026); //访客签离
+//        eventList.add(771760130);
+//        eventList.add(771760133);
 //******************************************************************
         JsonObject paramJson = new JsonObject();
         paramJson.add("eventTypes", eventList);

+ 4 - 1
src/main/java/com/xjrsoft/module/hikvision/util/OutInRecordUtil.java

@@ -489,8 +489,11 @@ public class OutInRecordUtil {
         ApiUtil apiUtil = new ApiUtil();
         String apiPath = "/api/acs/v2/door/events";
         JsonObject paramJson = new JsonObject();
+        JsonArray eventList = new JsonArray();
+        eventList.add(196893);
         paramJson.addProperty("pageNo", pageNo.get());
         paramJson.addProperty("pageSize", pageSize);
+        paramJson.add("eventTypes", eventList);
 
         return apiUtil.doPost(apiPath, String.valueOf(paramJson), null);
     }
@@ -616,7 +619,7 @@ public class OutInRecordUtil {
                     }
 
                     String statusStr = dataObject.get("roadwayName").getAsString();
-                    int statusInt = 0;
+                    int statusInt = 1;
                     if (statusStr.contains("入")) {
                         statusInt = 0;
                     } else if (statusStr.contains("出")) {

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

@@ -83,29 +83,29 @@ class HikvisionBaseDataTaskTest {
 
     @Test
     void test() throws Exception {
-        String sql = "SELECT distinct table_name FROM hikvision_data WHERE 1 = 1";
-        List<Map<String, Object>> maps = SqlRunnerAdapter.db().selectList(sql, HikvisionData.class);
-        Set<String> tables = new HashSet<>();
-        for (Map<String, Object> map : maps) {
-            String[] strings = SqlRunnerAdapterUtil.convertMapToStringArray(map);
-            tables.add(strings[0]);
-        }
-        sql = "SELECT * FROM hikvision_data WHERE 0 = 0";
-        List<Map<String, Object>> list = SqlRunnerAdapter.db().selectList(sql, HikvisionData.class);
-        Map<String, Map<String, String>> dataMap = new HashMap<>();
-        for (String table : tables) {
-            Map<String, String> tableData = new HashMap<>();
-            for (Map<String, Object> hikvision : list) {
-
-                if(!table.equals(hikvision.get("table_name").toString())){
-                    continue;
-                }
-                tableData.put(hikvision.get("source_id").toString(), hikvision.get("hikvision_id").toString());
-            }
-            dataMap.put(table, tableData);
-        }
+//        DataSource datasource = DatasourceUtil.getDataSource(GlobalConstant.DEFAULT_DATASOURCE_KEY);
+//        Db use = Db.use(datasource);
+//        String sql = "SELECT distinct table_name FROM hikvision_data WHERE 1 = 1";
+//        List<JianyueData> query = use.query(sql, JianyueData.class);
+//        Set<String> tables = new HashSet<>();
+//        for (JianyueData jianyueData : query) {
+//            tables.add(jianyueData.getTableName());
+//        }
+//        sql = "SELECT * FROM hikvision_data WHERE 0 = 0";
+//        List<HikvisionData> list = use.query(sql, HikvisionData.class);
+//        Map<String, Map<String, String>> dataMap = new HashMap<>();
+//        for (String table : tables) {
+//            Map<String, String> tableData = new HashMap<>();
+//            for (HikvisionData hikvisiondata : list) {
+//                if(!table.equals(hikvisiondata.getTableName())){
+//                    continue;
+//                }
+//                tableData.put(hikvisiondata.getSourceId(), hikvisiondata.getHikvisionId());
+//            }
+//            dataMap.put(table, tableData);
+//        }
 //        DataUtil dataUtil = new DataUtil();
-        String tableName = "xjr_department";
+//        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);
@@ -127,9 +127,9 @@ class HikvisionBaseDataTaskTest {
 //        Map<String, String> classes = dataUtil.insertClass(use, tableName, baseClass);
 
 
-        tableName = "base_student";
-        Map<String, String> baseStudent = dataMap.get(tableName);
-        Map<String, String> student = insertStudentOne(tableName, baseStudent);
+//        tableName = "base_student";
+//        Map<String, String> baseStudent = dataMap.get(tableName);
+//        Map<String, String> student = dataUtil.insertStudentOne(use, tableName, baseStudent);
 
 //        selectOrg(use, "base_class");
 
@@ -170,18 +170,20 @@ class HikvisionBaseDataTaskTest {
         db.executeBatch(sqls);
     }
 
-    public Map<String, String> insertStudentOne(String tableName, Map<String, String> tableData) throws Exception {
-        String sql = "SELECT t1.id,t1.name,CONCAT(t3.id,'-',replace(t4.name,'级',''),'-',t3.class_type,'-',t2.stduy_status) as orgIndexCode," +
-                " t1.user_name,t1.gender,DATE_FORMAT(t1.birth_date, '%Y-%m-%d') as birthday,t1.mobile,t1.email,t1.credential_type,t1.credential_number FROM xjr_user t1" +
+    public Map<String, String> insertStudentOne(Db db, String tableName, Map<String, String> tableData) throws Exception {
+        String sql = "SELECT t1.id,t1.name,CONCAT(t3.id,'-',t4.name,'-',t3.class_type,'-',t2.stduy_status)," +
+                " t1.user_name,t1.gender,DATE_FORMAT(t1.birth_date, '%Y-%m-%d'),t1.mobile,t1.email,t1.credential_type,t1.credential_number FROM xjr_user t1" +
                 " INNER JOIN base_student_school_roll t2 ON t1.id = t2.user_id" +
                 " INNER JOIN base_class t3 ON t2.class_id = t3.id" +
                 " INNER JOIN base_grade t4 ON t3.grade_id = t4.id" +
                 " WHERE t1.delete_mark = 0 AND t2.delete_mark = 0" +
                 " AND t3.class_type IS NOT NULL" +
-                " AND t1.name IN ('白江龙')";
-        List<Map<String, Object>> list = SqlRunnerAdapter.db().selectList(sql, String[].class);
+                " AND t1.id NOT IN (SELECT source_id FROM hikvision_data WHERE table_name = 'base_student'\n" +
+                ") AND t4.name NOT IN ('2021级','2020级')";
+        List<String[]> list = db.query(sql, String[].class);
         Map<Integer, String> clientMap = new HashMap<>();
 
+        String apiPath = "/api/resource/v2/person/single/add";
         Map<String, String> idMap = new HashMap<>();
         JsonParser jsonParser = new JsonParser();
         ApiUtil apiUtil = new ApiUtil();
@@ -189,21 +191,22 @@ class HikvisionBaseDataTaskTest {
         header.put("tagId", "insert_student");
 
         for(int i = 0; i < list.size(); i ++){
-            Map<String, Object> objectMap = list.get(i);
-            String apiPath = "/api/resource/v2/person/single/add";
-
+            String[] el = list.get(i);
+            if(tableData != null && tableData.containsKey(el[0])){
+                continue;
+            }
             JsonObject paramJson = new JsonObject();
             paramJson.addProperty("clientId", i);
-            paramJson.addProperty("personId", objectMap.get("id").toString());
-            paramJson.addProperty("personName", objectMap.get("name").toString());
-            paramJson.addProperty("orgIndexCode", objectMap.get("orgIndexCode").toString());
-            paramJson.addProperty("phoneNo", objectMap.get("mobile").toString());
-            paramJson.addProperty("jobNo", objectMap.get("user_name").toString());
-            paramJson.addProperty("birthday", objectMap.get("birthday").toString());
+            paramJson.addProperty("personId", el[0]);
+            paramJson.addProperty("personName", el[1]);
+            paramJson.addProperty("orgIndexCode", el[2]);
+            paramJson.addProperty("phoneNo", el[6]);
+            paramJson.addProperty("jobNo", el[3]);
+            paramJson.addProperty("birthday", el[5]);
             paramJson.addProperty("personType", 2);
 
             int gender;
-            switch (objectMap.get("gender").toString()) {
+            switch (el[4]) {
                 case "SB10001":
                     gender = 1;
                     break;
@@ -216,21 +219,18 @@ class HikvisionBaseDataTaskTest {
             }
             paramJson.addProperty("gender", gender);
 
-            if(tableData != null && tableData.containsKey(objectMap.get("id").toString())){
-                apiPath = "/api/resource/v1/person/single/update";
-                String doPost = apiUtil.doPost(apiPath, paramJson.toString(), null, header);
-                continue;
-            }
-
-            clientMap.put(i, objectMap.get("id").toString());
+            clientMap.put(i, el[0]);
+            System.out.println("请求参数:" + paramJson.toString());
             String result = apiUtil.doPost(apiPath, paramJson.toString(), null, header);
+            System.out.println("返回结果:" + result);
             JsonElement parse = jsonParser.parse(result);
             JsonObject resultJson = parse.getAsJsonObject();
             if("0".equals(resultJson.get("code").getAsString()) && "success".equals(resultJson.get("msg").getAsString())){
                 JsonObject array = resultJson.get("data").getAsJsonObject();
-                idMap.put(objectMap.get("id").toString(), array.get("personId").getAsString());
+                idMap.put(el[0], array.get("personId").getAsString());
             }
         }
+        insertRecord(db, tableName, idMap);
         //插入记录表
         return idMap;
     }