From d81de6b3cc02ce24b4918a1bdef2818c61eb8cce Mon Sep 17 00:00:00 2001
From: puzhibing <393733352@qq.com>
Date: 星期六, 14 三月 2026 23:00:47 +0800
Subject: [PATCH] Merge branch 'master' of http://120.76.84.145:10101/gitblit/r/java/Robotaxi

---
 xp-robotaxi-maintenance-boot/src/main/java/com/xiaopeng/maintenance/service/impl/XpClockInServiceImpl.java |   45 ++++++++++++++++++++++++++-------------------
 1 files changed, 26 insertions(+), 19 deletions(-)

diff --git a/xp-robotaxi-maintenance-boot/src/main/java/com/xiaopeng/maintenance/service/impl/XpClockInServiceImpl.java b/xp-robotaxi-maintenance-boot/src/main/java/com/xiaopeng/maintenance/service/impl/XpClockInServiceImpl.java
index dc64715..54fdd82 100644
--- a/xp-robotaxi-maintenance-boot/src/main/java/com/xiaopeng/maintenance/service/impl/XpClockInServiceImpl.java
+++ b/xp-robotaxi-maintenance-boot/src/main/java/com/xiaopeng/maintenance/service/impl/XpClockInServiceImpl.java
@@ -1,6 +1,7 @@
 package com.xiaopeng.maintenance.service.impl;
 
 import cn.hutool.core.collection.CollUtil;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.baomidou.mybatisplus.extension.conditions.query.QueryChainWrapper;
@@ -103,6 +104,12 @@
     public R<String> clockIn(ClockDTO dto) {
 
         XpCheckLocation xpCheckLocation = xpCheckLocationMapper.selectById(dto.getLocationId());
+        if (null == xpCheckLocation) {
+            return R.fail("打卡地址不存在");
+        }
+        if (xpCheckLocation.getStatus() == 0) {
+            return R.fail("打卡地址已禁用");
+        }
 
         Map<String, Double> distance = GeodesyUtil.getDistance(dto.getUserLon() + "," + dto.getUserLat(), xpCheckLocation.getLocationLon() + "," + xpCheckLocation.getLocationLat());
         if (null != distance) {
@@ -143,6 +150,12 @@
     public R<String> clockOut(ClockDTO dto) {
 
         XpCheckLocation xpCheckLocation = xpCheckLocationMapper.selectById(dto.getLocationId());
+        if (null == xpCheckLocation) {
+            return R.fail("打卡地址不存在");
+        }
+        if (xpCheckLocation.getStatus() == 0) {
+            return R.fail("打卡地址已禁用");
+        }
         Map<String, Double> distance = GeodesyUtil.getDistance(dto.getUserLon() + "," + dto.getUserLat(), xpCheckLocation.getLocationLon() + "," + xpCheckLocation.getLocationLat());
         if (null != distance) {
             Double distance1 = distance.get("WGS84");
@@ -186,10 +199,10 @@
     }
 
     @Override
-    public Boolean checkWorkStatus(Long appUserId) {
+    public Integer checkWorkStatus(Long appUserId) {
         if (appUserId == null) {
             log.warn("检查上班状态失败: appUserId 为空");
-            return false;
+            return 1;
         }
 
         try {
@@ -198,29 +211,23 @@
             LocalDateTime endTime = LocalDateTime.of(LocalDate.now(), LocalTime.MAX);   // 23:59:59
 
             // 2. 查询当天打卡记录
-            List<XpClockIn> records = baseMapper.selectTodayClockInRecords(
-                    appUserId, startTime, endTime
-            );
-
+            XpClockIn xpClockIn = baseMapper.selectOne(new LambdaQueryWrapper<XpClockIn>()
+                    .eq(XpClockIn::getAppUserId, appUserId)
+                    .between(XpClockIn::getClockInTime, startTime, endTime)
+                    .last("limit 1"));
             // 3. 判断上班状态
-            if (records == null || records.isEmpty()) {
-                // 无打卡记录 = 未上班
-                log.debug("用户 {} 今日无打卡记录, workFlag=false", appUserId);
-                return false;
-            } else if (records.size() == 1) {
-                // 1条记录 = 已上班未下班
-                log.debug("用户 {} 今日打卡1次, workFlag=true", appUserId);
-                return true;
+            // 有上班打卡状态,无下班打卡状态
+            if (Objects.isNull(xpClockIn)) {
+                return 1;
+            } else if (Objects.nonNull(xpClockIn.getClockInResult()) && Objects.isNull(xpClockIn.getClockOutResult())) {
+                return 2;
             } else {
-                // 2条及以上记录 = 已下班
-                log.debug("用户 {} 今日打卡{}次, workFlag=false", appUserId, records.size());
-                return false;
+                return 3;
             }
-
         } catch (Exception e) {
             log.error("检查用户上班状态异常, appUserId={}", appUserId, e);
             // 异常情况返回 false
-            return false;
+            return 1;
         }
     }
 

--
Gitblit v1.7.1