snihwxf 2 mesi fa
parent
commit
bb408d6a7a

+ 3 - 0
src/test/java/com/xjrsoft/module/job/BaseNewStudentTaskTest.java

@@ -108,6 +108,9 @@ class BaseNewStudentTaskTest {
             plan.setCreateDate(new Date());
             plan.setEnabledMark(EnabledMark.ENABLED.getCode());
             plan.setDeleteMark(DeleteMark.NODELETE.getCode());
+            if(x.get("userdef6")==null){
+                return;
+            }
             if ("1".equals(x.get("userdef6").toString())) {
                 plan.setEnrollType(EnrollTypeEnum.SPRING_ENROLLMENT.getCode());
             } else if ("2".equals(x.get("userdef6").toString())) {

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

@@ -464,6 +464,89 @@ class HikvisionBaseDataTaskTest {
         System.out.println(userInfoMap);
     }
 
+    // 更新海康里有,中间表没的的学生数据
+    @Test
+    void updateHikvisionDataPerson() {
+
+        String tableName = "base_student";
+        List<HikvisionData> studentList = hikvisionDataMapper.selectList(
+                new QueryWrapper<HikvisionData>().lambda().eq(HikvisionData::getTableName, tableName)
+        );
+
+        SimpleDateFormat sdf = new SimpleDateFormat("yyy-MM-dd HH:mm:ss");
+
+        Map<String, String> historyMap = new HashMap<>();
+        for (HikvisionData hikvisionData : studentList) {
+            historyMap.put(hikvisionData.getSourceId(), hikvisionData.getSendData());
+        }
+
+        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" +
+                " 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 t3.is_graduate = 1";
+        List<Map<String, Object>> maps = SqlRunnerAdapter.db().selectList(sql);
+        List<String> userIds = new ArrayList<>();
+        for (Map<String, Object> map : maps) {
+            userIds.add(map.get("id").toString());
+        }
+
+        String instertTableName = "hikvision_data";
+        ApiUtil apiUtil = new ApiUtil();
+        String apiPath = "/api/resource/v2/person/personList";
+        for (int i = 1; i <= 11; i++) {
+
+            JsonObject jsonObject = new JsonObject();
+            jsonObject.addProperty("pageNo", i);
+            jsonObject.addProperty("pageSize", 1000);
+
+            String result = apiUtil.doPost(apiPath, jsonObject.toString(), null, null);
+
+            JsonParser jsonParser = new JsonParser();
+            JsonObject resultJson = jsonParser.parse(result).getAsJsonObject();
+            JsonArray array = resultJson.get("data").getAsJsonObject().get("list").getAsJsonArray();
+
+            List<Entity> insertList = new ArrayList<>();
+            int j=0;
+            for (JsonElement jsonElement : array) {
+                try {
+                    JsonObject element = jsonElement.getAsJsonObject();
+                    String id = element.get("personId").getAsString();
+                    if (!historyMap.containsKey(id) && userIds.contains(id)) {
+
+                        Entity entity = Entity.create(instertTableName);
+                        entity.set("table_name", tableName);
+                        entity.set("create_date", sdf.format(new Date()));
+                        entity.set("source_id", element.get("personId").getAsString());
+                        entity.set("hikvision_id", element.get("personId").getAsString());
+
+                        JsonObject paramJson = new JsonObject();
+                        paramJson.addProperty("personId", id);
+                        paramJson.addProperty("personName", element.get("personName").getAsString());
+                        paramJson.addProperty("orgIndexCode", element.get("orgIndexCode").getAsString());
+                        paramJson.addProperty("phoneNo", element.get("phoneNo").getAsString());
+                        paramJson.addProperty("jobNo", element.get("jobNo").getAsString());
+                        paramJson.addProperty("birthday", element.get("birthday").getAsString());
+                        paramJson.addProperty("personType", element.get("personType").getAsString());
+
+                        entity.set("send_data", paramJson.toString());
+                        insertList.add(entity);
+
+                        System.out.println(j++);
+                    }
+                }catch (Exception ex) {
+                    System.out.println(ex.getMessage());
+                }
+            }
+            if (!insertList.isEmpty()) {
+                SqlRunnerAdapter.db().dynamicInsertBatch(instertTableName, insertList);
+            }
+        }
+
+    }
+
     void selecAllPerson(Db db) throws SQLException {
         String apiPath = "/api/resource/v2/person/personList";
         JsonObject jsonObject = new JsonObject();

+ 2 - 2
src/test/java/com/xjrsoft/module/job/InsertOutInRecordTaskTest.java

@@ -84,7 +84,7 @@ class InsertOutInRecordTaskTest {
     @Test
     void test() throws ParseException {
         //获取时间,并计算出前一天的开始时间和结束时间
-        LocalDateTime now = LocalDateTime.of(2024, 10, 1, 0, 0, 0);
+        LocalDateTime now = LocalDateTime.of(2025, 9, 25, 0, 0, 0);
         for (int i = 0; i < 1; i ++){
             LocalDateTime startDateTime = now.plusDays(i).withHour(0).withMinute(0).withSecond(0).withNano(0);
             LocalDateTime endDateTime = startDateTime.plusDays(i).withHour(23).withMinute(59).withSecond(59);
@@ -102,7 +102,7 @@ class InsertOutInRecordTaskTest {
             //Map<String, String> userIdMap = hikvisionDataService.getUserIdMap();
 
             //教师&学生拉取数据
-            out_in_recordUtil.GetTeacherAndStudentRecords(faceImportMapper, startDateTime, endDateTime);
+//            out_in_recordUtil.GetTeacherAndStudentRecords(faceImportMapper, startDateTime, endDateTime);
             //拉取车辆数据
             out_in_recordUtil.GetVehicleRecord(faceImportMapper, startDateTime, endDateTime);
             //拉取访客数据