Browse Source

修改bug

brealinxx 5 months ago
parent
commit
98f6045a9a

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

@@ -11,7 +11,9 @@ import com.xjrsoft.module.teacher.mapper.FaceImportMapper;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import java.sql.PreparedStatement;
 import java.sql.SQLException;
+import java.sql.Types;
 import java.text.ParseException;
 import java.text.SimpleDateFormat;
 import java.time.LocalDateTime;
@@ -59,10 +61,29 @@ public class OutInRecordUtil {
 
         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 + "', '" + photoValue + "', '" + status + "', '" + releaseReason + "', '" + planNo + "', '" +
-                crossRecordSyscode + "', '" + releaseResult + "', '" + releaseWay + "', '" + vehicleType + "', '" + phoneValue + "', '" + nameValue + "', '" + category  +  "',0,1)";
-        db.execute(sql);
+                "VALUES(now(), ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, 0, 1)";
+
+        try (PreparedStatement pstmt = db.getConnection().prepareStatement(sql)) {
+            if (carMessageApplyId != 0) {
+                pstmt.setLong(1, carMessageApplyId);
+            } else {
+                pstmt.setNull(1, Types.BIGINT);
+            }
+            pstmt.setString(2, recordTime);
+            pstmt.setString(3, photoValue);
+            pstmt.setInt(4, status);
+            pstmt.setInt(5, releaseReason);
+            pstmt.setString(6, planNo);
+            pstmt.setString(7, crossRecordSyscode);
+            pstmt.setInt(8, releaseResult);
+            pstmt.setInt(9, releaseWay);
+            pstmt.setInt(10, vehicleType);
+            pstmt.setString(11, phoneValue);
+            pstmt.setString(12, nameValue);
+            pstmt.setInt(13, category);
+
+            pstmt.executeUpdate();
+        }
     }
 
     public void GetTeacherAndStudentRecords(Db use, FaceImportMapper faceImportMapper) throws SQLException, ParseException {
@@ -378,7 +399,7 @@ public class OutInRecordUtil {
             JsonObject item = element.getAsJsonObject();
 
             String carMessageApplyIdStr = faceImportMapper.GetCarMessageApplyIdByCarNumber(item.get("plateNo").getAsString().trim());
-            Long carId = (carMessageApplyIdStr == null || carMessageApplyIdStr.isEmpty()) ? null : Long.parseLong(carMessageApplyIdStr);
+            Long carId = (carMessageApplyIdStr == null || carMessageApplyIdStr.isEmpty()) ? 0 : Long.parseLong(carMessageApplyIdStr);
             String category = null;
             int categoryInt = 0;
             if (item.has("carCategory")){
@@ -431,7 +452,6 @@ public class OutInRecordUtil {
             } else {
                 facePicUri = ApiUtil.GetRedirectURL(facePicUriElement.getAsString());
             }
-            System.out.println(facePicUri + "haha");
 
             String phone = faceImportMapper.GetPhoneNumberByPlanNum(plateNo);
             String name = faceImportMapper.GetNameByPlanNum(plateNo);
@@ -537,7 +557,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()) ? null : Long.parseLong(carMessageApplyIdStr);
+                    Long carId = (carMessageApplyIdStr == null || carMessageApplyIdStr.isEmpty()) ? 0 : Long.parseLong(carMessageApplyIdStr);
                     String eventTime = ChangeTime(dataObject.get("time").getAsString());
 
                     int releaseWayInt = -1;

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

@@ -5,7 +5,7 @@ server:
 spring:
   # 环境 dev|pre|prod
   profiles:
-    active: dev
+    active: prod
   # jackson时间格式化
   jackson:
     time-zone: GMT+8

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

@@ -105,7 +105,7 @@ class HikvisionBaseDataTaskTest {
 //        selectCar(use, carTableName);
 
 //        outInRecordUtil.GetVehicleRecord(use,faceImportMapper);
-        outInRecordUtil.GetTeacherAndStudentRecords(use,faceImportMapper);
+        outInRecordUtil.GetVehicleRecord(use,faceImportMapper);
 ////        selecAllPersonById(use);
 //        selectResource(use);
     }