diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/pom.xml b/xinnengyuan/ruoyi-modules/ruoyi-system/pom.xml
index 19bd2db8..476ccc33 100644
--- a/xinnengyuan/ruoyi-modules/ruoyi-system/pom.xml
+++ b/xinnengyuan/ruoyi-modules/ruoyi-system/pom.xml
@@ -280,6 +280,13 @@
netty-all
+
+
+ commons-codec
+ commons-codec
+ 1.15
+
+
diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/project/controller/BusAttendanceDeviceController.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/project/controller/BusAttendanceDeviceController.java
index 3e30f9ad..3fb101df 100644
--- a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/project/controller/BusAttendanceDeviceController.java
+++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/project/controller/BusAttendanceDeviceController.java
@@ -3,10 +3,12 @@ package org.dromara.project.controller;
import cn.dev33.satoken.annotation.SaIgnore;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.codec.binary.Base64;
import org.dromara.common.core.domain.R;
import org.dromara.common.web.core.BaseController;
import org.dromara.project.domain.BusAttendanceMachine;
import org.dromara.project.domain.dto.attendance.*;
+import org.dromara.project.domain.vo.attendance.DeviceResult;
import org.dromara.project.service.IBusAttendanceMachineService;
import org.dromara.project.service.IBusAttendanceService;
import org.springframework.mock.web.MockMultipartFile;
@@ -17,7 +19,7 @@ import org.springframework.web.multipart.MultipartFile;
import java.io.IOException;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
-import java.util.Base64;
+
/**
* 考勤
@@ -34,15 +36,15 @@ public class BusAttendanceDeviceController extends BaseController {
private final IBusAttendanceService busAttendanceService;
- private final IBusAttendanceMachineService busAttendanceMachineService;
+ private final IBusAttendanceMachineService busAttendanceMachineService;
@PostMapping("/api/v1/record/face")
@SaIgnore
- public R punchCardByFace(@RequestBody DeviceDto dto) {
+ public DeviceResult punchCardByFace(@RequestBody DeviceDto dto) {
//打印接收数据
log.info("接收数据:{}", dto);
if (dto.getLogs().isEmpty()) {
- return R.fail("没有数据");
+ return new DeviceResult(500, "没有数据");
}
Log first = dto.getLogs().getFirst();
@@ -53,7 +55,7 @@ public class BusAttendanceDeviceController extends BaseController {
.last("limit 1")
.one();
if (one == null || one.getProjectId() == null) {
- return R.fail("考勤机不存在或未关联项目");
+ return new DeviceResult(500, "考勤机不存在或未关联项目");
}
String recogTime = first.getRecog_time();
@@ -74,14 +76,14 @@ public class BusAttendanceDeviceController extends BaseController {
// 假设first.getImage()返回base64字符串,且你有一个文件名
MultipartFile file = convert(first.getPhoto(), "face.jpg");
log.info("开始打卡");
- return R.ok(busAttendanceService.punchCardByFace(file, req));
+ busAttendanceService.punchCardByFace(file, req);
+ return new DeviceResult(0, "打卡成功");
} catch (IOException e) {
- return R.fail("文件转换失败");
+ return new DeviceResult(500, "文件转换失败");
}
}
-
public static MultipartFile convert(String base64String, String fileName) throws IOException {
// 先进行URL解码(如果是URL编码过的数据)
try {
@@ -96,23 +98,11 @@ public class BusAttendanceDeviceController extends BaseController {
}
// 解码base64字符串
- byte[] decodedBytes = Base64.getDecoder().decode(base64String);
+ byte[] decodedBytes = Base64.decodeBase64(base64String);
// 创建MultipartFile对象
return new MockMultipartFile(fileName, fileName, "image/jpeg", decodedBytes);
}
-
-
-
-
-
-
-
-
-
-
-
-
}
diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/project/domain/vo/attendance/DeviceResult.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/project/domain/vo/attendance/DeviceResult.java
new file mode 100644
index 00000000..aaac1f8d
--- /dev/null
+++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/project/domain/vo/attendance/DeviceResult.java
@@ -0,0 +1,16 @@
+package org.dromara.project.domain.vo.attendance;
+
+
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+@Data
+@AllArgsConstructor
+@NoArgsConstructor
+public class DeviceResult {
+
+ private Integer Result;
+
+ private String Msg;
+}