111
tjx
昨天 2c3d8abefd778b7aa9b9ee69ff3fdb02b31f4865
src/test/java/com/gs/dingtalk/DeviceReceivingApplicationTests.java
@@ -9,6 +9,7 @@
import com.gs.dingtalk.service.SimpleExample;
import com.gs.dingtalk.service.VwCjScSjTsBbService;
import com.gs.dingtalk.service.WorkWXService;
import com.gs.dingtalk.service.QwCheckinDayDataService;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
@@ -33,6 +34,9 @@
    @Autowired
    private QwCheckinDataService qwCheckinDataService;
    @Autowired
    private QwCheckinDayDataService qwCheckinDayDataService;
    /**
     * 测试导出生产数据并发送钉钉消息
@@ -280,19 +284,16 @@
                    // 打印异常信息
                    if (data.getExceptionInfos() != null && !data.getExceptionInfos().isEmpty()) {
                        data.getExceptionInfos().forEach(ex -> {
                            String exType = switch (ex.getException()) {
                                case 1 -> "迟到";
                                case 2 -> "早退";
                                case 3 -> "缺卡";
                                case 4 -> "旷工";
                                case 5 -> "地点异常";
                                case 6 -> "设备异常";
                                default -> "未知";
                            };
                            String exType = getExceptionTypeName(ex.getException());
                            System.out.println("      异常: " + exType + ", 次数: " + ex.getCount() + ", 时长(秒): " + ex.getDuration());
                        });
                    }
                });
                // 保存到数据库
                System.out.println("  - 开始保存打卡日报数据到数据库...");
                int insertCount = qwCheckinDayDataService.saveDayDataBatch(dayDataList);
                System.out.println("✓ 保存完成,新增记录数: " + insertCount + ", 更新(已存在): " + (dayDataList.size() - insertCount));
            } else {
                System.out.println("✗ 获取的打卡日报数据为空");
            }
@@ -356,15 +357,7 @@
                    if (data.getExceptionInfos() != null && !data.getExceptionInfos().isEmpty()) {
                        System.out.println("  异常信息:");
                        data.getExceptionInfos().forEach(ex -> {
                            String exType = switch (ex.getException()) {
                                case 1 -> "迟到";
                                case 2 -> "早退";
                                case 3 -> "缺卡";
                                case 4 -> "旷工";
                                case 5 -> "地点异常";
                                case 6 -> "设备异常";
                                default -> "未知";
                            };
                            String exType = getExceptionTypeName(ex.getException());
                            System.out.println("    - " + exType + ": " + ex.getCount() + "次, 时长: " + formatSeconds(ex.getDuration()));
                        });
                    }
@@ -403,4 +396,30 @@
        return sb.toString();
    }
    /**
     * 获取异常类型名称
     * @param exceptionType 异常类型代码:1-迟到;2-早退;3-缺卡;4-旷工;5-地点异常;6-设备异常
     */
    private String getExceptionTypeName(Integer exceptionType) {
        if (exceptionType == null) {
            return "未知";
        }
        switch (exceptionType) {
            case 1:
                return "迟到";
            case 2:
                return "早退";
            case 3:
                return "缺卡";
            case 4:
                return "旷工";
            case 5:
                return "地点异常";
            case 6:
                return "设备异常";
            default:
                return "未知";
        }
    }
}