Browse Source

访客导入

brealinxx 1 năm trước cách đây
mục cha
commit
fd60e3e906

+ 5 - 4
src/main/java/com/xjrsoft/module/hikvision/controller/EventController.java

@@ -77,8 +77,9 @@ public class EventController {
         JsonObject paramJson = new JsonObject();
 //*******手动更改****************************************************
 //        eventList.add(196893); //人脸匹配成功
-        eventList.add(771760131); //入场放行事件
-        eventList.add(771760134); //出场放行事件
+//        eventList.add(197151); //人脸匹配失败
+        eventList.add(771760130); //入场放行事件
+        eventList.add(771760133); //出场放行事件
         paramJson.addProperty("eventDest", hikvisionConfig.getCarUrl()); //要修改第二个参数
 //******************************************************************
         paramJson.add("eventTypes", eventList);
@@ -111,8 +112,8 @@ public class EventController {
         JsonArray eventList = new JsonArray();
 //*******手动更改****************************************************
         eventList.add(196893);
-        eventList.add(771760131); //正常过车
-        eventList.add(771760134);
+//        eventList.add(771760131); //正常过车
+//        eventList.add(771760134);
 //******************************************************************
         JsonObject paramJson = new JsonObject();
         paramJson.add("eventTypes", eventList);

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

@@ -67,7 +67,7 @@ public class ApiUtil {
     }
 
     public static String GetRedirectURL(String uri){
-        if (!uri.isEmpty())
+        if (uri != null && !uri.isEmpty())
             return "https://" + ApiUtil.host + "/" + uri;
         else
             return "";

+ 10 - 9
src/main/java/com/xjrsoft/module/hikvision/util/OutInRecordUtil.java

@@ -40,10 +40,10 @@ public class OutInRecordUtil {
     }
 
 
-    public void visitInsertRecord(Db db, Long reservation_school_people_id, String recordTime,String facePhoto, int status) throws SQLException {
-        String sql = "INSERT INTO visitor_out_in_record(create_date, reservation_school_people_id, record_time, face_photo, status,delete_mark,enabled_mark) " +
+    public void visitInsertRecord(Db db, Long reservation_school_people_id, String recordTime,String facePhoto, int status, String eventId) throws SQLException {
+        String sql = "INSERT INTO visitor_out_in_record(create_date, reservation_school_people_id, record_time, face_photo, event_id, status,delete_mark,enabled_mark) " +
                 "VALUES(now(), '"  + reservation_school_people_id + "', '" +
-                 recordTime + "', '" + facePhoto + "', '" + status +  "',0,1)";
+                 recordTime + "', '" + facePhoto + "', '" + eventId + "', '" + status +  "',0,1)";
         db.execute(sql);
     }
 
@@ -295,16 +295,16 @@ public class OutInRecordUtil {
     }
 
     private void InsertVisitRecords(Db use, JsonArray eventsResponse, JsonArray doorEventsResponse,FaceImportMapper faceImportMapper) throws SQLException, ParseException {
-        List<Long> visit_id_list = faceImportMapper.GetReservationSchoolIdList();
 
         for (JsonElement element : eventsResponse) {
+            List<String> visit_id_list = faceImportMapper.GetReservationSchoolIdList();
             JsonObject item = element.getAsJsonObject();
 
-            String picUri = item.get("visitorPhotoUri").isJsonNull() ? null : ApiUtil.GetRedirectURL(item.get("visitorPhotoUri").getAsString());
+            String picUri = item.get("visitorPhotoUri").isJsonNull() ? "" : ApiUtil.GetRedirectURL(item.get("visitorPhotoUri").getAsString());
             String orderId = item.get("orderId").isJsonNull() ? null : item.get("orderId").getAsString();
             String eventTime = item.get("eventTime").isJsonNull() ? null : ChangeTime(item.get("eventTime").getAsString());
-            //todo: reservationSchoolId
-//            Long reservationSchoolId = faceImportMapper.GetReservationSchoolId(orderId) == null ? 1 : faceImportMapper.GetReservationSchoolId(orderId);
+            String reservationSchoolId = faceImportMapper.GetReservationSchoolId(orderId) == null ? "0" : String.valueOf(faceImportMapper.GetReservationSchoolId(orderId));
+            String eventId = item.get("eventId").isJsonNull() ? null : item.get("eventId").getAsString();
 
             int status = -1;
             for (JsonElement e : doorEventsResponse){
@@ -315,8 +315,9 @@ public class OutInRecordUtil {
                 }
             }
 
-            if (visit_id_list.contains(1)) continue;
-            visitInsertRecord(use, Long.parseLong("123"), eventTime, picUri, status);
+            if (visit_id_list.contains(eventId)) continue;
+
+            visitInsertRecord(use, Long.parseLong(reservationSchoolId), eventTime, picUri, status, eventId);
         }
 
     }

+ 5 - 3
src/main/java/com/xjrsoft/module/job/InsertOutInRecordTask.java

@@ -25,7 +25,7 @@ public class InsertOutInRecordTask {
 
     OutInRecordUtil out_in_recordUtil = new OutInRecordUtil();
 
-    @Scheduled(cron = "0 */15 * * * ?")
+    @Scheduled(cron = "*/15 * * * * ?")
     public void RefreshConnectionPool() {
         String active = SpringUtil.getActiveProfile();
         if(!"prod".equals(active)){
@@ -38,9 +38,11 @@ public class InsertOutInRecordTask {
             Db use = Db.use(datasource);
 
             //教师&学生拉取数据
-            out_in_recordUtil.GetTeacherAndStudentRecords(use, faceImportMapper);
+//            out_in_recordUtil.GetTeacherAndStudentRecords(use, faceImportMapper);
             //拉取车辆数据
-            out_in_recordUtil.GetVehicleRecord(use, faceImportMapper);
+//            out_in_recordUtil.GetVehicleRecord(use, faceImportMapper);
+            //拉取访客数据
+            out_in_recordUtil.GetVisitRecord(use, faceImportMapper);
 
             log.info("数据拉取完成");
         } catch (Exception e) {

+ 1 - 1
src/main/java/com/xjrsoft/module/teacher/mapper/FaceImportMapper.java

@@ -23,7 +23,7 @@ public interface FaceImportMapper {
     List<String> GetStudentUrlList();
     List<String> GetTeacherUrlList();
 
-    List<Long> GetReservationSchoolIdList();
+    List<String> GetReservationSchoolIdList();
     Long GetReservationSchoolId(@Param("id") String id);
 
     String GetCarMessageApplyIdByCarNumber(@Param("id") String id);

+ 1 - 1
src/main/resources/application-dev.yml

@@ -146,7 +146,7 @@ xjrsoft:
     appKey: 21350095
     appSecret: LXi9rE2fm8IfRoLnTA2G
     people-url: http://ff.cf.yingcaibx.com/event/receivePeople
-    car-url: http://ff.cf.yingcaibx.com/event/receive
+    car-url: http://ff.cf.yingcaibx.com/event/receiveCar
   keycloak:
     url: http://192.168.0.221:12829/auth/
     realm: test

+ 1 - 1
src/main/resources/application-pre.yml

@@ -130,7 +130,7 @@ xjrsoft:
     appKey: 21350095
     appSecret: LXi9rE2fm8IfRoLnTA2G
     people-url: http://ff.cf.yingcaibx.com/event/receivePeople
-    car-url: http://ff.cf.yingcaibx.com/event/receive
+    car-url: http://ff.cf.yingcaibx.com/event/receiveCar
   keycloak:
     url: http://192.168.0.221:12829/auth/
     realm: test

+ 3 - 3
src/main/resources/mapper/teacher/TeacherFaceImportMapper.xml

@@ -94,8 +94,8 @@
         where t.delete_mark = 0
     </select>
 
-    <select id="GetReservationSchoolIdList" resultType="java.lang.Long">
-        SELECT reservation_school_people_id
+    <select id="GetReservationSchoolIdList" resultType="java.lang.String">
+        SELECT event_id
         FROM visitor_out_in_record
         where delete_mark = 0
     </select>
@@ -105,7 +105,7 @@
         FROM reservation_school_people
         where delete_mark = 0
         <if test="id != null">
-            and registration_result::text LIKE '%"orderId":"' || #{id} || '"%'
+            and JSON_VALUE(registration_result, '$.data.orderId') = #{id};
         </if>
     </select>
 

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

@@ -104,7 +104,7 @@ class HikvisionBaseDataTaskTest {
 //        String carTableName = "car_message_apply";
 //        selectCar(use, carTableName);
 
-        outInRecordUtil.GetTeacherAndStudentRecords(use,faceImportMapper);
+        outInRecordUtil.GetVisitRecord(use,faceImportMapper);
 ////        selecAllPersonById(use);
 //        selectResource(use);
     }