|
|
@@ -1,13 +1,25 @@
|
|
|
package com.xjrsoft.module.outint.service.impl;
|
|
|
|
|
|
import com.github.yulichang.base.MPJBaseServiceImpl;
|
|
|
+import com.google.gson.JsonArray;
|
|
|
+import com.google.gson.JsonObject;
|
|
|
+import com.google.gson.JsonParser;
|
|
|
+import com.xjrsoft.common.exception.MyException;
|
|
|
+import com.xjrsoft.module.hikvision.util.ApiUtil;
|
|
|
+import com.xjrsoft.module.hikvision.util.OutInRecordUtil;
|
|
|
+import com.xjrsoft.module.outint.dto.SyncHikvsionDataDto;
|
|
|
import com.xjrsoft.module.outint.dto.TeacherOutInRecordDto;
|
|
|
import com.xjrsoft.module.outint.entity.TeacherOutInRecord;
|
|
|
import com.xjrsoft.module.outint.mapper.TeacherOutInRecordMapper;
|
|
|
import com.xjrsoft.module.outint.service.ITeacherOutInRecordService;
|
|
|
+import com.xjrsoft.module.teacher.mapper.FaceImportMapper;
|
|
|
import lombok.AllArgsConstructor;
|
|
|
+import me.zhyd.oauth.log.Log;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
+import java.time.ZoneOffset;
|
|
|
+import java.time.format.DateTimeFormatter;
|
|
|
import java.util.List;
|
|
|
|
|
|
/**
|
|
|
@@ -19,8 +31,44 @@ import java.util.List;
|
|
|
@Service
|
|
|
@AllArgsConstructor
|
|
|
public class TeacherOutInRecordServiceImpl extends MPJBaseServiceImpl<TeacherOutInRecordMapper, TeacherOutInRecord> implements ITeacherOutInRecordService {
|
|
|
+
|
|
|
+ private final FaceImportMapper faceImportMapper;
|
|
|
+
|
|
|
@Override
|
|
|
public List<TeacherOutInRecord> getListByParam(TeacherOutInRecordDto dto) {
|
|
|
return this.baseMapper.getListByParam(dto);
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ public Boolean syncHikvisionData(SyncHikvsionDataDto dto) {
|
|
|
+ try {
|
|
|
+ Integer limit = 1;
|
|
|
+ Integer size = 1000;
|
|
|
+ ApiUtil apiUtil = new ApiUtil();
|
|
|
+ String apiPath = "/api/acs/v2/door/events";
|
|
|
+
|
|
|
+ JsonObject paramJson = new JsonObject();
|
|
|
+ JsonArray eventList = new JsonArray();
|
|
|
+ eventList.add(196893); // 只获取人脸通过的
|
|
|
+ paramJson.addProperty("pageNo", limit);
|
|
|
+ paramJson.addProperty("pageSize", size);
|
|
|
+ paramJson.add("eventTypes", eventList);
|
|
|
+
|
|
|
+ paramJson.addProperty("sort", "eventTime");
|
|
|
+ paramJson.addProperty("order", "desc");
|
|
|
+ paramJson.addProperty("startTime", dto.getStartTime().atOffset(ZoneOffset.ofHours(8)).format(DateTimeFormatter.ISO_OFFSET_DATE_TIME));
|
|
|
+ paramJson.addProperty("endTime", dto.getEndTime().atOffset(ZoneOffset.ofHours(8)).format(DateTimeFormatter.ISO_OFFSET_DATE_TIME));
|
|
|
+
|
|
|
+ String doPost = apiUtil.doPost(apiPath, paramJson.toString(), null);
|
|
|
+ JsonParser parser = new JsonParser();
|
|
|
+ JsonObject data = parser.parse(doPost).getAsJsonObject().get("data").getAsJsonObject();
|
|
|
+ JsonArray list = data.get("list").getAsJsonArray();
|
|
|
+ new OutInRecordUtil().InsertTeacherStudentRecords(list, faceImportMapper);
|
|
|
+ }catch (Exception e){
|
|
|
+ Log.error(e.getMessage(), e);
|
|
|
+ throw new MyException("同步报错,请联系管理员");
|
|
|
+ }
|
|
|
+ return true;
|
|
|
+ }
|
|
|
}
|