|
@@ -5,17 +5,12 @@ import com.google.gson.Gson;
|
|
|
import com.google.gson.JsonArray;
|
|
|
import com.google.gson.JsonElement;
|
|
|
import com.google.gson.JsonObject;
|
|
|
-import com.xjrsoft.common.constant.GlobalConstant;
|
|
|
-import com.xjrsoft.common.utils.DatasourceUtil;
|
|
|
import com.xjrsoft.module.teacher.mapper.FaceImportMapper;
|
|
|
-import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
|
-import javax.sql.DataSource;
|
|
|
import java.sql.SQLException;
|
|
|
-import java.util.HashMap;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
-import java.util.Objects;
|
|
|
+import java.text.ParseException;
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
+import java.util.*;
|
|
|
import java.util.concurrent.atomic.AtomicInteger;
|
|
|
|
|
|
|
|
@@ -43,7 +38,7 @@ public class Teacher_Student_OutIn_RecordUtil {
|
|
|
db.execute(sql);
|
|
|
}
|
|
|
|
|
|
- public String GetDoorEvents(Db use, FaceImportMapper faceImportMapper) throws SQLException {
|
|
|
+ public String GetDoorEvents(Db use, FaceImportMapper faceImportMapper) throws SQLException, ParseException {
|
|
|
ApiUtil apiUtil = new ApiUtil();
|
|
|
|
|
|
String apiPath = "/api/acs/v2/door/events";
|
|
@@ -76,8 +71,7 @@ public class Teacher_Student_OutIn_RecordUtil {
|
|
|
}
|
|
|
|
|
|
|
|
|
- public void InsertTeacherStudentRecords(Db use, JsonArray doorEventsResponse, FaceImportMapper faceImportMapper) throws SQLException {
|
|
|
-// for (JsonElement e : doorEventsResponse){
|
|
|
+ public void InsertTeacherStudentRecords(Db use, JsonArray doorEventsResponse, FaceImportMapper faceImportMapper) throws SQLException, ParseException {
|
|
|
Teacher_Student_OutIn_RecordUtil teacherStudentOutInRecordUtil = new Teacher_Student_OutIn_RecordUtil();
|
|
|
List<String> teacherEventIdList = faceImportMapper.GetTeacherUrlList();
|
|
|
List<String> studentEventIdList = faceImportMapper.GetStudentUrlList();
|
|
@@ -94,24 +88,23 @@ public class Teacher_Student_OutIn_RecordUtil {
|
|
|
if (personId == null) continue;
|
|
|
|
|
|
int status = item.get("inAndOutType").getAsInt();
|
|
|
- String photo = item.get("picUri").isJsonNull() ? null : item.get("picUri").getAsString();
|
|
|
+ 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();
|
|
|
|
|
|
if (!Objects.equals(faceImportMapper.IsStudentTypeByPersonId(personId), "学生")) {
|
|
|
// 老师记录
|
|
|
- if (teacherEventIdList.contains(item.get("eventId").getAsString())) continue;
|
|
|
- teacherStudentOutInRecordUtil.teacherInsertRecord(use, personId,recordTime,photo,status,eventId);
|
|
|
+ if (teacherEventIdList.contains(eventId)) continue;
|
|
|
+ teacherStudentOutInRecordUtil.teacherInsertRecord(use, personId, ChangeTime(recordTime), ApiUtil.GetRedirectURL(uri),status,eventId);
|
|
|
} else {
|
|
|
// 学生记录
|
|
|
- if (studentEventIdList.contains(item.get("eventId").getAsString())) continue;
|
|
|
- teacherStudentOutInRecordUtil.studentInsertRecord(use, personId, faceImportMapper.GetTeacherIdByPersonId(personId), faceImportMapper.GetClassIdByPersonId(personId), photo, recordTime, status,eventId);
|
|
|
+ if (studentEventIdList.contains(eventId)) continue;
|
|
|
+ teacherStudentOutInRecordUtil.studentInsertRecord(use, personId, faceImportMapper.GetTeacherIdByPersonId(personId),
|
|
|
+ faceImportMapper.GetClassIdByPersonId(personId), ApiUtil.GetRedirectURL(uri), ChangeTime(recordTime), status,eventId);
|
|
|
}
|
|
|
}
|
|
|
-// }
|
|
|
}
|
|
|
|
|
|
-
|
|
|
void GetVisitRecord(){
|
|
|
ApiUtil apiUtil = new ApiUtil();
|
|
|
JsonObject paramJson = new JsonObject();
|
|
@@ -121,7 +114,7 @@ public class Teacher_Student_OutIn_RecordUtil {
|
|
|
Map<String, String> querys = new HashMap<>();
|
|
|
querys.put("tagId", "frs");
|
|
|
|
|
|
- String apiPath = "/api/visitor/v2/visiting/records\n";
|
|
|
+ String apiPath = "/api/visitor/v2/visiting/records";
|
|
|
String response = apiUtil.doPost(apiPath, String.valueOf(paramJson), querys);
|
|
|
|
|
|
JsonObject doorEventsJson = new Gson().fromJson(response, JsonObject.class);
|
|
@@ -144,4 +137,11 @@ public class Teacher_Student_OutIn_RecordUtil {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ private String ChangeTime(String recordTime) throws ParseException {
|
|
|
+ SimpleDateFormat isoFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
|
|
|
+ SimpleDateFormat mysqlFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
+ Date date = isoFormat.parse(recordTime);
|
|
|
+ return mysqlFormat.format(date);
|
|
|
+ }
|
|
|
+
|
|
|
}
|