Kaynağa Gözat

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

dzx 5 ay önce
ebeveyn
işleme
ec329b8b42

+ 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();

+ 22 - 7
src/main/java/com/xjrsoft/module/hikvision/util/OutInRecordUtil.java

@@ -5,6 +5,7 @@ import com.google.gson.Gson;
 import com.google.gson.JsonArray;
 import com.google.gson.JsonElement;
 import com.google.gson.JsonObject;
+import com.microsoft.schemas.office.office.BulletAttribute;
 import com.xjrsoft.module.attendance.entity.AttendanceRuleDetails;
 import com.xjrsoft.module.teacher.mapper.FaceImportMapper;
 import org.slf4j.Logger;
@@ -25,17 +26,20 @@ public class OutInRecordUtil {
     private static final Logger log = LoggerFactory.getLogger(OutInRecordUtil.class);
 
     private void teacherInsertRecord(Db db, Long userId, String recordTime, String facePhoto, int status, String eventId, String attendanceStatus) throws SQLException {
+        String photoValue = (facePhoto != null && !facePhoto.equals("null")) ? facePhoto : "";
 
         String sql = "INSERT INTO teacher_out_in_record(create_date, user_id, record_time, face_photo, eventId, status,delete_mark,enabled_mark, attendance_status) " +
                 "VALUES(now(), '"  + userId + "', '" + recordTime + "', '" +
-                facePhoto + "', '" + eventId + "', '" +status + "',0,1,'" + attendanceStatus + "')";
+                photoValue + "', '" + eventId + "', '" +status + "',0,1,'" + attendanceStatus + "')";
         db.execute(sql);
     }
 
     private void studentInsertRecord(Db db, Long userId, Long teacherId, Long classId, String facePhoto, String recordTime, int status, String eventId, String attendanceStatus) throws SQLException {
+        String photoValue = (facePhoto != null && !facePhoto.equals("null")) ? facePhoto : "";
+
         String sql = "INSERT INTO student_out_in_record(create_date, user_id, teacher_id, class_id, face_photo, record_time , eventId,status,delete_mark,enabled_mark, attendance_status) " +
                 "VALUES(now(), '" + userId + "', '" + teacherId + "', '" +
-                classId + "', '" + facePhoto + "', '" + recordTime + "', '" + eventId + "', '" + status + "',0,1,'" + attendanceStatus + "')";
+                classId + "', '" + photoValue + "', '" + recordTime + "', '" + eventId + "', '" + status + "',0,1,'" + attendanceStatus + "')";
         db.execute(sql);
     }
 
@@ -51,11 +55,12 @@ public class OutInRecordUtil {
                                      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 photoValue = (facePhoto != null && !facePhoto.equals("null")) ? facePhoto : "";
 
         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 + "', '" +
+                recordTime + "', '" + photoValue + "', '" + status + "', '" + releaseReason + "', '" + planNo + "', '" +
                 crossRecordSyscode + "', '" + releaseResult + "', '" + releaseWay + "', '" + vehicleType + "', '" + phoneValue + "', '" + nameValue + "', '" + category  +  "',0,1)";
         db.execute(sql);
     }
@@ -100,7 +105,17 @@ public class OutInRecordUtil {
             }
             if (personId == null) continue;
 
-            int status = item.get("inAndOutType").getAsInt();
+            int statusInt = item.get("inAndOutType").getAsInt();
+            int status = -1;
+            switch (statusInt){
+                case 0:
+                    status = 1;
+                    break;
+                case 1:
+                    status = 0;
+                    break;
+            }
+
             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();
@@ -121,7 +136,7 @@ public class OutInRecordUtil {
                 LocalDateTime recordTimeDate = LocalDateTime.parse(recordTimeStr, formatter);
                 String attendanceStatus = discernStudentStatus(use, recordTimeDate, status, personId);
                 studentInsertRecord(use, personId, faceImportMapper.GetTeacherIdByPersonId(personId),
-                        faceImportMapper.GetClassIdByPersonId(personId), ApiUtil.GetRedirectURL(uri), recordTimeStr, status,eventId, attendanceStatus);
+                        faceImportMapper.GetClassIdByPersonId(personId), ApiUtil.GetRedirectURL(uri), recordTimeStr, status, eventId, attendanceStatus);
             }
         }
     }
@@ -363,7 +378,7 @@ public class OutInRecordUtil {
             JsonObject item = element.getAsJsonObject();
 
             String carMessageApplyIdStr = faceImportMapper.GetCarMessageApplyIdByCarNumber(item.get("plateNo").getAsString().trim());
-            Long carId = (carMessageApplyIdStr == null || carMessageApplyIdStr.isEmpty()) ? 0 : Long.parseLong(carMessageApplyIdStr);
+            Long carId = (carMessageApplyIdStr == null || carMessageApplyIdStr.isEmpty()) ? null : Long.parseLong(carMessageApplyIdStr);
             String category = null;
             int categoryInt = 0;
             if (item.has("carCategory")){
@@ -522,7 +537,7 @@ public class OutInRecordUtil {
                     String carNum = dataObject.get("plateNo").getAsString().trim();
                     String eventIndex = dataObject.get("eventIndex").getAsString().trim();
                     String carMessageApplyIdStr = faceImportMapper.GetCarMessageApplyIdByCarNumber(carNum);
-                    Long carId = (carMessageApplyIdStr == null || carMessageApplyIdStr.isEmpty()) ? 0 : Long.parseLong(carMessageApplyIdStr);
+                    Long carId = (carMessageApplyIdStr == null || carMessageApplyIdStr.isEmpty()) ? null : Long.parseLong(carMessageApplyIdStr);
                     String eventTime = ChangeTime(dataObject.get("time").getAsString());
 
                     int releaseWayInt = -1;

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

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