From 73aa66976e35252378be3f09be2474193ccd0bf6 Mon Sep 17 00:00:00 2001
From: huang <1532065656@qq.com>
Date: 星期五, 05 十二月 2025 17:15:20 +0800
Subject: [PATCH] 修改任务执行步骤状态完成检验
---
mes-processes/mes-plcSend/src/main/java/com/mes/device/service/impl/GlassInfoServiceImpl.java | 84 ++++++++++++++++++++++++++++++++++++++++++
1 files changed, 84 insertions(+), 0 deletions(-)
diff --git a/mes-processes/mes-plcSend/src/main/java/com/mes/device/service/impl/GlassInfoServiceImpl.java b/mes-processes/mes-plcSend/src/main/java/com/mes/device/service/impl/GlassInfoServiceImpl.java
index 94ed660..5546da4 100644
--- a/mes-processes/mes-plcSend/src/main/java/com/mes/device/service/impl/GlassInfoServiceImpl.java
+++ b/mes-processes/mes-plcSend/src/main/java/com/mes/device/service/impl/GlassInfoServiceImpl.java
@@ -1,14 +1,17 @@
package com.mes.device.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.mes.device.entity.GlassInfo;
import com.mes.device.mapper.DeviceGlassInfoMapper;
import com.mes.device.service.GlassInfoService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
+import org.springframework.util.CollectionUtils;
import java.util.Collections;
+import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -99,8 +102,35 @@
GlassInfo existing = baseMapper.selectByGlassId(glassInfo.getGlassId());
if (existing != null) {
glassInfo.setId(existing.getId());
+ // 淇濈暀鍘熷鍒涘缓淇℃伅
+ if (glassInfo.getCreatedTime() == null) {
+ glassInfo.setCreatedTime(existing.getCreatedTime());
+ }
+ if (glassInfo.getCreatedBy() == null) {
+ glassInfo.setCreatedBy(existing.getCreatedBy());
+ }
+ // 鏇存柊涓哄綋鍓嶆椂闂�
+ if (glassInfo.getUpdatedTime() == null) {
+ glassInfo.setUpdatedTime(new Date());
+ }
+ if (glassInfo.getUpdatedBy() == null) {
+ glassInfo.setUpdatedBy("system");
+ }
return updateById(glassInfo);
} else {
+ Date now = new Date();
+ if (glassInfo.getCreatedTime() == null) {
+ glassInfo.setCreatedTime(now);
+ }
+ if (glassInfo.getUpdatedTime() == null) {
+ glassInfo.setUpdatedTime(now);
+ }
+ if (glassInfo.getCreatedBy() == null) {
+ glassInfo.setCreatedBy("system");
+ }
+ if (glassInfo.getUpdatedBy() == null) {
+ glassInfo.setUpdatedBy("system");
+ }
return save(glassInfo);
}
} catch (Exception e) {
@@ -124,5 +154,59 @@
return false;
}
}
+
+ @Override
+ public List<String> getRecentScannedGlassIds(Integer minutesAgo, Integer maxCount, String workLine) {
+ try {
+ // 榛樿鏌ヨ鏈�杩�2鍒嗛挓鍐呯殑璁板綍锛屾渶澶氳繑鍥�20鏉�
+ int minutes = minutesAgo != null && minutesAgo > 0 ? minutesAgo : 2;
+ int limit = maxCount != null && maxCount > 0 ? maxCount : 20;
+
+ Date timeThreshold = new Date(System.currentTimeMillis() - minutes * 60 * 1000L);
+
+ LambdaQueryWrapper<GlassInfo> wrapper = new LambdaQueryWrapper<>();
+ wrapper.eq(GlassInfo::getStatus, GlassInfo.Status.PENDING)
+ .ge(GlassInfo::getCreatedTime, timeThreshold)
+ .orderByDesc(GlassInfo::getCreatedTime)
+ .last("LIMIT " + limit);
+
+ // 濡傛灉鎸囧畾浜唚orkLine锛屽垯杩囨护description
+ if (workLine != null && !workLine.trim().isEmpty()) {
+ wrapper.like(GlassInfo::getDescription, "workLine=" + workLine);
+ }
+
+ List<GlassInfo> recentGlasses = baseMapper.selectList(wrapper);
+
+ // 鎻愬彇鐜荤拑ID鍒楄〃
+ return recentGlasses.stream()
+ .map(GlassInfo::getGlassId)
+ .filter(id -> id != null && !id.trim().isEmpty())
+ .collect(Collectors.toList());
+
+ } catch (Exception e) {
+ log.error("鏌ヨ鏈�杩戞壂鐮佺殑鐜荤拑ID澶辫触, minutesAgo={}, maxCount={}, workLine={}",
+ minutesAgo, maxCount, workLine, e);
+ return Collections.emptyList();
+ }
+ }
+
+ @Override
+ public boolean updateGlassStatus(List<String> glassIds, String status) {
+ if (CollectionUtils.isEmpty(glassIds) || status == null) {
+ return true;
+ }
+ try {
+ LambdaUpdateWrapper<GlassInfo> wrapper = new LambdaUpdateWrapper<>();
+ wrapper.in(GlassInfo::getGlassId, glassIds);
+ GlassInfo update = new GlassInfo();
+ update.setStatus(status);
+ update.setUpdatedTime(new Date());
+ update.setUpdatedBy("system");
+ return this.update(update, wrapper);
+ } catch (Exception e) {
+ log.error("鎵归噺鏇存柊鐜荤拑鐘舵�佸け璐�, glassIds={}, status={}", glassIds, status, e);
+ return false;
+ }
+ }
}
--
Gitblit v1.8.0