Browse Source

修改bug

brealinxx 5 months ago
parent
commit
d316ef442e

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

@@ -60,13 +60,13 @@ public class EventController {
     @ApiOperation(value = "接收车辆事件")
     public ResponseEntity<Void> receiveCarEvent(@RequestBody(required = false) String eventData) {
         log.info("Received event data: {}", eventData);
-        new Thread(() -> {
+//        new Thread(() -> {
             try {
                 outInRecordUtil.GetVehicleRecordTest(use, faceImportMapper, eventData);
             } catch (SQLException | ParseException e) {
                 log.error("Error processing event data", e);
             }
-        }).start();
+//        }).start();
 
         // 立即返回HTTP 200 OK响应
         return ResponseEntity.ok().build();

+ 31 - 36
src/main/java/com/xjrsoft/module/hikvision/util/OutInRecordUtil.java

@@ -49,11 +49,14 @@ public class OutInRecordUtil {
 
     private void vehicleInsertRecord(Db db, Long carMessageApplyId, String recordTime, int releaseReason, int category, String facePhoto, int status, String planNo, String crossRecordSyscode,
                                      int releaseResult, int releaseWay, int vehicleType, String phone, String name) throws SQLException {
+        String phoneValue = (phone != null && !phone.equals("null")) ? phone : "";
+        String nameValue = (name != null && !name.equals("null")) ? name : "";
+
         String sql = "INSERT INTO car_out_in_record(create_date, car_message_apply_id, record_time, face_photo, status,release_reason, plan_no, " +
                 "cross_record_syscode, release_result, release_way, vehicle_type, phone, name, category,delete_mark,enabled_mark) " +
                 "VALUES(now(), '"  + carMessageApplyId + "', '" +
                 recordTime + "', '" + facePhoto + "', '" + status + "', '" + releaseReason + "', '" + planNo + "', '" +
-                crossRecordSyscode + "', '" + releaseResult + "', '" + releaseWay + "', '" + vehicleType + "', '" + phone + "', '" + name + "', '" + category  +  "',0,1)";
+                crossRecordSyscode + "', '" + releaseResult + "', '" + releaseWay + "', '" + vehicleType + "', '" + phoneValue + "', '" + nameValue + "', '" + category  +  "',0,1)";
         db.execute(sql);
     }
 
@@ -178,7 +181,6 @@ public class OutInRecordUtil {
         return attendanceStatus;
     }
 
-
     String discernStudentStatus(Db use, LocalDateTime recordTime, int status, Long studentUserId) throws SQLException {
         String attendanceStatus = "";
         String dayOfWeek = recordTime.getDayOfWeek().name();
@@ -417,16 +419,7 @@ public class OutInRecordUtil {
             System.out.println(facePicUri + "haha");
 
             String phone = faceImportMapper.GetPhoneNumberByPlanNum(plateNo);
-            if (phone == null){
-                phone = faceImportMapper.GetPhoneNumberByPlanNumView(plateNo);
-                if (phone == null) phone = "";
-            }
-
             String name = faceImportMapper.GetNameByPlanNum(plateNo);
-            if (name == null){
-                name = faceImportMapper.GetNameByPlanNumView(plateNo);
-                if (name == null) name = "";
-            }
 
             if(vehicle_id_list.contains(crossRecordSyscode)) continue;
 
@@ -467,11 +460,23 @@ public class OutInRecordUtil {
 
                 String idNum = null;
                 if (dataObject.has("ExtEventPersonNo")) {
-                    idNum = dataObject.get("ExtEventPersonNo").getAsString();
+                    String idNumStr = dataObject.get("ExtEventPersonNo").getAsString();
+                    if (!idNumStr.isEmpty()) {
+                        idNum = idNumStr;
+                    }
                 }
                 String happenTime = eventObject.get("happenTime").getAsString();
                 String extEventPictureURL = dataObject.get("ExtEventPictureURL").getAsString();
-                int status = eventObject.get("status").getAsInt();
+                int statusInt = dataObject.get("ExtEventInOut").getAsInt();
+                int status = -1;
+                switch (statusInt){
+                    case 0:
+                        status = 1;
+                        break;
+                    case 1:
+                        status = 0;
+                        break;
+                }
                 String eventId = eventObject.get("eventId").getAsString();
                 String recordTimeStr = ChangeTime(happenTime);
 
@@ -520,13 +525,15 @@ public class OutInRecordUtil {
                     Long carId = (carMessageApplyIdStr == null || carMessageApplyIdStr.isEmpty()) ? 0 : Long.parseLong(carMessageApplyIdStr);
                     String eventTime = ChangeTime(dataObject.get("time").getAsString());
 
-                    int releaseWayInt = 0;
-                    int releaseReasonInt = 0;
-                    int releaseResultInt = 0;
+                    int releaseWayInt = -1;
+                    int releaseReasonInt = -1;
+                    int releaseResultInt = -1;
                     JsonObject inResultObject = dataObject.getAsJsonObject("inResult");
-                    if (inResultObject != null) {
-                        JsonObject rlsResultObject = inResultObject.getAsJsonObject("rlsResult");
-                        if (rlsResultObject != null && rlsResultObject.has("releaseWay") && rlsResultObject.has("releaseReason") && rlsResultObject.has("releaseResult")) {
+                    JsonObject outResultObject = dataObject.getAsJsonObject("outResult");
+                    JsonObject inoutResult = (inResultObject != null && !inResultObject.isJsonNull()) ? inResultObject : outResultObject;
+                    if (inoutResult != null) {
+                        JsonObject rlsResultObject = inoutResult.getAsJsonObject("rlsResult");
+                        if (rlsResultObject.has("releaseWay") && rlsResultObject.has("releaseReason") && rlsResultObject.has("releaseResult")) {
                             releaseWayInt = rlsResultObject.get("releaseWay").getAsInt();
                             releaseReasonInt = rlsResultObject.get("releaseReason").getAsInt();
                             releaseResultInt = rlsResultObject.get("releaseResult").getAsInt();
@@ -551,28 +558,16 @@ public class OutInRecordUtil {
                         facePicUri = picUrlObject.get("vehiclePicUrl").getAsString();
                     }
 
-                    int status = eventObject.get("status").getAsInt();
+                    String statusStr = dataObject.get("roadwayName").getAsString();
                     int statusInt = 0;
-                    switch (status){
-                        case 0:
-                            statusInt = 1;
-                            break;
-                        case 1:
-                            statusInt = 0;
-                            break;
+                    if (statusStr.contains("入")) {
+                        statusInt = 0;
+                    } else if (statusStr.contains("出")) {
+                        statusInt = 1;
                     }
 
                     String phone = faceImportMapper.GetPhoneNumberByPlanNum(carNum);
-                    if (phone == null){
-                        phone = faceImportMapper.GetPhoneNumberByPlanNumView(carNum);
-                        if (phone == null) phone = "";
-                    }
-
                     String name = faceImportMapper.GetNameByPlanNum(carNum);
-                    if (name == null){
-                        name = faceImportMapper.GetNameByPlanNumView(carNum);
-                        if (name == null) name = "";
-                    }
 
                     if (vehicle_id_list.contains(eventIndex)) continue;
 

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

@@ -32,9 +32,6 @@ public interface FaceImportMapper {
     String GetPhoneNumberByPlanNum(@Param("id") String id);
     String GetNameByPlanNum(@Param("id") String id);
 
-    String GetPhoneNumberByPlanNumView(@Param("id") String id);
-    String GetNameByPlanNumView(@Param("id") String id);
-
     List<String> GetVisitIdList();
 }
 

+ 6 - 26
src/main/resources/mapper/teacher/TeacherFaceImportMapper.xml

@@ -125,38 +125,18 @@
     </select>
 
     <select id="GetPhoneNumberByPlanNum" resultType="java.lang.String">
-        SELECT c_phone
-        FROM base_car_management
-        where delete_mark = 0
+        SELECT 手机号
+        FROM car_info
         <if test="id != null">
-            and car_no = #{id}
+            where 车牌号码 = #{id}
         </if>
     </select>
 
     <select id="GetNameByPlanNum" resultType="java.lang.String">
-        SELECT c_name
-        FROM base_car_management
-        where delete_mark = 0
-        <if test="id != null">
-            and car_no = #{id}
-        </if>
-    </select>
-
-    <select id="GetPhoneNumberByPlanNumView" resultType="java.lang.String">
-        SELECT phone
-        FROM reservation_school_people
-        where delete_mark = 0
-        <if test="id != null">
-            and plate_number = #{id}
-        </if>
-    </select>
-
-    <select id="GetNameByPlanNumView" resultType="java.lang.String">
-        SELECT name
-        FROM reservation_school_people
-        where delete_mark = 0
+        SELECT 车主姓名
+        FROM car_info
         <if test="id != null">
-            and plate_number = #{id}
+            where 车牌号码 = #{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.GetVisitRecord(use,faceImportMapper);
+        outInRecordUtil.GetVehicleRecord(use,faceImportMapper);
 ////        selecAllPersonById(use);
 //        selectResource(use);
     }