|
|
@@ -4,6 +4,7 @@ import cn.hutool.core.collection.CollUtil;
|
|
|
import cn.hutool.core.util.IdUtil;
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
@@ -73,6 +74,20 @@ public class RiskInspectionRecordServiceImpl implements IRiskInspectionRecordSer
|
|
|
RiskInspectionTask task = taskMapper.selectById(bo.getTaskId());
|
|
|
Assert.notNull(task, "巡检任务不存在: " + bo.getTaskId());
|
|
|
|
|
|
+ // 1.5 防重复打卡(按 taskId + slot 唯一,每日多时段任务每个 slot 独立)
|
|
|
+ // - 单时段/非每日任务:slot 为空,按 taskId 查
|
|
|
+ // - 每日多时段任务:slot="HH:mm-HH:mm",按 (taskId, slot) 查
|
|
|
+ LambdaQueryWrapper<RiskInspectionRecord> dupLqw = Wrappers.lambdaQuery();
|
|
|
+ dupLqw.eq(RiskInspectionRecord::getTaskId, bo.getTaskId())
|
|
|
+ .eq(StringUtils.isNotBlank(bo.getSlot()), RiskInspectionRecord::getSlot, bo.getSlot());
|
|
|
+ RiskInspectionRecord existing = baseMapper.selectOne(dupLqw);
|
|
|
+ if (existing != null) {
|
|
|
+ String msg = StringUtils.isNotBlank(bo.getSlot())
|
|
|
+ ? "当前时段 [" + bo.getSlot() + "] 已打卡,请勿重复打卡"
|
|
|
+ : "该任务已打卡,请勿重复打卡";
|
|
|
+ throw new ServiceException(msg);
|
|
|
+ }
|
|
|
+
|
|
|
// 2. 扫码打卡:校验二维码(留宽松,空串通过)
|
|
|
if ("SCAN".equalsIgnoreCase(bo.getPunchType())
|
|
|
&& StringUtils.isNotBlank(task.getQrCode())
|