|
@@ -4,6 +4,7 @@ import NetSDKDemo.HCNetSDK;
|
|
|
|
|
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
|
|
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
|
|
+import cn.iocoder.yudao.module.infra.api.file.FileApi;
|
|
|
import cn.iocoder.yudao.module.system.controller.admin.studentAttendance.vo.StudentAttendancePageReqVO;
|
|
|
import cn.iocoder.yudao.module.system.controller.admin.studentAttendance.vo.StudentAttendanceSaveReqVO;
|
|
|
import cn.iocoder.yudao.module.system.controller.admin.user.vo.profile.UserProfileUpdatePasswordReqVO;
|
|
@@ -21,6 +22,8 @@ import com.sun.jna.Pointer;
|
|
|
|
|
|
import java.io.*;
|
|
|
import java.nio.ByteBuffer;
|
|
|
+import java.nio.file.Files;
|
|
|
+import java.nio.file.Path;
|
|
|
import java.time.LocalDate;
|
|
|
import java.time.LocalDateTime;
|
|
|
import java.time.format.DateTimeFormatter;
|
|
@@ -53,7 +56,8 @@ public final class EventSearch {
|
|
|
* @throws UnsupportedEncodingException
|
|
|
* @throws InterruptedException
|
|
|
*/
|
|
|
- public static List<Object> searchAllEvent(int lUserID ,AdminUserService adminUserService,StudentAttendanceService studentAttendanceService) throws UnsupportedEncodingException, InterruptedException {
|
|
|
+
|
|
|
+ public static List<Object> searchAllEvent(int lUserID ,AdminUserService adminUserService,StudentAttendanceService studentAttendanceService, FileApi fileApi) throws UnsupportedEncodingException, InterruptedException {
|
|
|
int i = 0; //事件条数
|
|
|
HCNetSDK.NET_DVR_ACS_EVENT_COND struAcsEventCond = new HCNetSDK.NET_DVR_ACS_EVENT_COND();
|
|
|
struAcsEventCond.read();
|
|
@@ -76,8 +80,10 @@ public final class EventSearch {
|
|
|
struAcsEventCond.struEndTime.dwMinute = 59;
|
|
|
struAcsEventCond.struEndTime.dwSecond = 59;
|
|
|
struAcsEventCond.wInductiveEventType = 1;
|
|
|
- struAcsEventCond.byPicEnable = 0; //是否带图片,0-不带图片,1-带图片
|
|
|
+ struAcsEventCond.byPicEnable = 1; //是否带图片,0-不带图片,1-带图片
|
|
|
struAcsEventCond.write();
|
|
|
+
|
|
|
+
|
|
|
Pointer ptrStruEventCond = struAcsEventCond.getPointer();
|
|
|
int m_lSearchEventHandle = AcsService.hCNetSDK.NET_DVR_StartRemoteConfig(lUserID, HCNetSDK.NET_DVR_GET_ACS_EVENT, ptrStruEventCond, struAcsEventCond.size(), null, null);
|
|
|
if (m_lSearchEventHandle<=-1)
|
|
@@ -106,6 +112,7 @@ public final class EventSearch {
|
|
|
System.out.println("获取事件出现异常");
|
|
|
break;
|
|
|
} else if (dwEventSearch == HCNetSDK.NET_SDK_GET_NEXT_STATUS_SUCCESS) {
|
|
|
+ StudentAttendanceDO attendance =new StudentAttendanceDO();
|
|
|
struAcsEventCfg.read();
|
|
|
//获取的事件信息通过struAcsEventCfg结构体进行解析,
|
|
|
//System.out.println(i + "获取事件成功, 报警主类型:" + Integer.toHexString(struAcsEventCfg.dwMajor) + "报警次类型:" + Integer.toHexString(struAcsEventCfg.dwMinor) + "卡号:" + new String(struAcsEventCfg.struAcsEventInfo.byCardNo).trim());
|
|
@@ -122,6 +129,32 @@ public final class EventSearch {
|
|
|
" 时:"+struAcsEventCfg.struTime.dwHour+" 分:"+struAcsEventCfg.struTime.dwMinute+" 秒:"+struAcsEventCfg.struTime.dwSecond);
|
|
|
System.out.println("刷卡信息:"+new String(struAcsEventCfg.struAcsEventInfo.byCardNo));
|
|
|
|
|
|
+
|
|
|
+ //打卡人脸信息
|
|
|
+ String photoUrl = null;
|
|
|
+ if (struAcsEventCfg.dwPicDataLen > 0 || struAcsEventCfg.pPicData != null) {
|
|
|
+ // 用于保存文件的 URL,初始值为 null
|
|
|
+ try {
|
|
|
+ /**
|
|
|
+ * 人脸图片保存路径
|
|
|
+ */
|
|
|
+ ByteBuffer buffers = struAcsEventCfg.pPicData.getByteBuffer(0, struAcsEventCfg.dwPicDataLen);
|
|
|
+ byte[] bytes = new byte[struAcsEventCfg.dwPicDataLen];
|
|
|
+ buffers.rewind();
|
|
|
+ buffers.get(bytes);
|
|
|
+
|
|
|
+ Path tempFilePath = Files.createTempFile("photo", ".jpg");
|
|
|
+
|
|
|
+ Files.write(tempFilePath, bytes);
|
|
|
+
|
|
|
+ photoUrl = fileApi.createFile(Files.readAllBytes(tempFilePath)); // 上传文件并获取 URL
|
|
|
+ } catch (FileNotFoundException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ } catch (IOException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
String clockInTime = (struAcsEventCfg.struTime.dwYear + "-" +
|
|
|
String.format("%02d", struAcsEventCfg.struTime.dwMonth) + "-" +
|
|
|
String.format("%02d", struAcsEventCfg.struTime.dwDay) + " " +
|
|
@@ -141,10 +174,12 @@ public final class EventSearch {
|
|
|
employeeNo = String.valueOf(struAcsEventCfg.struAcsEventInfo.dwEmployeeNo);
|
|
|
}
|
|
|
|
|
|
- StudentAttendanceDO attendance =new StudentAttendanceDO();
|
|
|
attendance.setClockInTime(parsedTime);//打卡时间
|
|
|
attendance.setDate(date);//打卡日期
|
|
|
attendance.setUserNumber(employeeNo);//学号
|
|
|
+ if (photoUrl != null) {
|
|
|
+ attendance.setPhoto(photoUrl); // 只在 photoUrl 不为 null 时设置
|
|
|
+ }
|
|
|
|
|
|
StudentAttendanceDO ST = studentAttendanceService.getStudentAttendanceOne(employeeNo,parsedTime);//获取这个学生对应的这个考勤记录
|
|
|
AdminUserDO user = adminUserService.findUserByUserNumber(employeeNo);//找到这个学生
|
|
@@ -160,6 +195,7 @@ public final class EventSearch {
|
|
|
attendance.setCreateTime(parsedTime);
|
|
|
attendance.setUpdateTime(parsedTime);
|
|
|
//插入考勤表
|
|
|
+ studentAttendance.add(attendance);
|
|
|
studentAttendanceService.createStudentAttendance(BeanUtils.toBean(attendance, StudentAttendanceSaveReqVO.class));
|
|
|
} else {
|
|
|
System.out.println("没有找到该用户" + employeeNo);
|
|
@@ -179,42 +215,18 @@ public final class EventSearch {
|
|
|
if ("1".equals(re.getClockInStatus())) {//找到未打卡的
|
|
|
re.setClockInStatus("0");//变成正常
|
|
|
re.setClockInTime(parsedTime);//更新打卡时间
|
|
|
- attendance.setCreateTime(parsedTime);//更新时间
|
|
|
- attendance.setUpdateTime(parsedTime);
|
|
|
+ re.setCreateTime(parsedTime);//更新时间
|
|
|
+ re.setUpdateTime(parsedTime);
|
|
|
+ if (photoUrl != null) {
|
|
|
+ re.setPhoto(photoUrl); //
|
|
|
+ }
|
|
|
+ studentAttendance.add(re);//测试查询
|
|
|
studentAttendanceService.updateStudentAttendance(BeanUtils.toBean(re, StudentAttendanceSaveReqVO.class));
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- studentAttendance.add(attendance);
|
|
|
-
|
|
|
- //人脸图片保存(没用)
|
|
|
- if (struAcsEventCfg.dwPicDataLen>0 || struAcsEventCfg.pPicData != null )
|
|
|
- {
|
|
|
- FileOutputStream fout;
|
|
|
- try {
|
|
|
- /**
|
|
|
- * 人脸图片保存路径
|
|
|
- */
|
|
|
- String filename = ".\\pic\\"+i+"_event.jpg";
|
|
|
- fout = new FileOutputStream(filename);
|
|
|
- //将字节写入文件
|
|
|
- long offset = 0;
|
|
|
- ByteBuffer buffers = struAcsEventCfg.pPicData.getByteBuffer(offset, struAcsEventCfg.dwPicDataLen);
|
|
|
- byte[] bytes = new byte[struAcsEventCfg.dwPicDataLen];
|
|
|
- buffers.rewind();
|
|
|
- buffers.get(bytes);
|
|
|
- fout.write(bytes);
|
|
|
- fout.close();
|
|
|
- } catch (FileNotFoundException e) {
|
|
|
- // TODO Auto-generated catch block
|
|
|
- e.printStackTrace();
|
|
|
- } catch (IOException e) {
|
|
|
- // TODO Auto-generated catch block
|
|
|
- e.printStackTrace();
|
|
|
- }
|
|
|
- }
|
|
|
i++;
|
|
|
continue;
|
|
|
}
|