|
@@ -5,12 +5,15 @@ 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;
|
|
|
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;
|
|
@@ -25,17 +28,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);
|
|
|
}
|
|
|
|
|
@@ -49,12 +55,35 @@ 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 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 + "', '" +
|
|
|
- crossRecordSyscode + "', '" + releaseResult + "', '" + releaseWay + "', '" + vehicleType + "', '" + phone + "', '" + name + "', '" + 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 {
|
|
@@ -76,7 +105,7 @@ public class OutInRecordUtil {
|
|
|
|
|
|
JsonObject responseJson = new Gson().fromJson(response, JsonObject.class);
|
|
|
int totalCount = responseJson.getAsJsonObject("data").get("totalPage").getAsInt();
|
|
|
- hasMorePages = pageNo.getAndIncrement() * pageSize < totalCount;
|
|
|
+ hasMorePages = pageNo.getAndIncrement() < totalCount;
|
|
|
}
|
|
|
// Process the records
|
|
|
InsertTeacherStudentRecords(use, responseBuilder, faceImportMapper);
|
|
@@ -97,7 +126,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();
|
|
@@ -118,7 +157,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);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -178,7 +217,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();
|
|
@@ -288,7 +326,7 @@ public class OutInRecordUtil {
|
|
|
|
|
|
JsonObject responseJson = new Gson().fromJson(response, JsonObject.class);
|
|
|
int totalCount = responseJson.getAsJsonObject("data").get("total").getAsInt();
|
|
|
- hasMorePages = pageNo.getAndIncrement() * pageSize < totalCount;
|
|
|
+ hasMorePages = pageNo.getAndIncrement() < totalCount;
|
|
|
}
|
|
|
|
|
|
InsertVisitRecords(use, responseBuilder,responseDoorBuilder,faceImportMapper);
|
|
@@ -414,19 +452,9 @@ public class OutInRecordUtil {
|
|
|
} else {
|
|
|
facePicUri = ApiUtil.GetRedirectURL(facePicUriElement.getAsString());
|
|
|
}
|
|
|
- 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;
|
|
|
|
|
@@ -441,6 +469,8 @@ public class OutInRecordUtil {
|
|
|
JsonObject paramJson = new JsonObject();
|
|
|
paramJson.addProperty("pageNo", pageNo.get());
|
|
|
paramJson.addProperty("pageSize", pageSize);
|
|
|
+ paramJson.addProperty("startTime", "2024-06-01T00:00:00Z");
|
|
|
+ paramJson.addProperty("endTime", "2024-06-12T00:00:00Z");
|
|
|
|
|
|
return apiUtil.doPost(apiPath, String.valueOf(paramJson), null);
|
|
|
}
|
|
@@ -467,11 +497,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 +562,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 +595,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;
|
|
|
|