From 8ec0064cd95292f14027006a8be47c1a71f69af9 Mon Sep 17 00:00:00 2001
From: huang <1532065656@qq.com>
Date: 星期三, 31 十二月 2025 17:02:57 +0800
Subject: [PATCH] 添加查询所有玻璃数据
---
mes-processes/mes-plcSend/src/main/java/com/mes/device/service/impl/GlassInfoServiceImpl.java | 66 +++++++++++++++++++++++++++------
1 files changed, 54 insertions(+), 12 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 3e04c93..0de3ef9 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
@@ -107,9 +107,10 @@
return false;
}
try {
- // 妫�鏌ユ槸鍚﹀凡瀛樺湪
- GlassInfo existing = baseMapper.selectByGlassId(glassInfo.getGlassId());
+ // 鏌ヨ鍖呮嫭閫昏緫鍒犻櫎鐨勮褰�
+ GlassInfo existing = baseMapper.selectByGlassIdIncludingDeleted(glassInfo.getGlassId());
if (existing != null) {
+ // 瀛樺湪鍒欐洿鏂�
glassInfo.setId(existing.getId());
// 淇濈暀鍘熷鍒涘缓淇℃伅
if (glassInfo.getCreatedTime() == null) {
@@ -118,15 +119,42 @@
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);
+
+ if (existing.getIsDeleted() != null && existing.getIsDeleted() != 0) {
+ log.info("鎭㈠閫昏緫鍒犻櫎鐨勭幓鐠冧俊鎭�: glassId={}, id={}", glassInfo.getGlassId(), existing.getId());
+ int updatedRows = baseMapper.restoreAndUpdateById(
+ existing.getId(),
+ glassInfo.getGlassId(),
+ glassInfo.getGlassLength(),
+ glassInfo.getGlassWidth(),
+ glassInfo.getGlassThickness(),
+ glassInfo.getStatus(),
+ glassInfo.getState(),
+ glassInfo.getEngineeringId(),
+ glassInfo.getUpdatedTime() != null ? glassInfo.getUpdatedTime() : new Date(),
+ glassInfo.getUpdatedBy() != null ? glassInfo.getUpdatedBy() : "system"
+ );
+ boolean updated = updatedRows > 0;
+ log.info("鎭㈠閫昏緫鍒犻櫎璁板綍缁撴灉: glassId={}, updatedRows={}, updated={}",
+ glassInfo.getGlassId(), updatedRows, updated);
+ if (!updated) {
+ log.error("鎭㈠閫昏緫鍒犻櫎璁板綍澶辫触锛屽彲鑳藉師鍥狅細鏇存柊鏉′欢涓嶅尮閰嶆垨鏁版嵁寮傚父, glassId={}, id={}",
+ glassInfo.getGlassId(), existing.getId());
+ }
+ return updated;
+ } else {
+ // 姝e父鏇存柊
+ return updateById(glassInfo);
+ }
} else {
+ // 涓嶅瓨鍦ㄥ垯鏂板
Date now = new Date();
if (glassInfo.getCreatedTime() == null) {
glassInfo.setCreatedTime(now);
@@ -139,6 +167,9 @@
}
if (glassInfo.getUpdatedBy() == null) {
glassInfo.setUpdatedBy("system");
+ }
+ if (glassInfo.getIsDeleted() == null) {
+ glassInfo.setIsDeleted(0);
}
return save(glassInfo);
}
@@ -154,10 +185,19 @@
return true;
}
try {
+ int successCount = 0;
+ int failCount = 0;
for (GlassInfo glassInfo : glassInfos) {
- saveOrUpdateGlassInfo(glassInfo);
+ boolean result = saveOrUpdateGlassInfo(glassInfo);
+ if (result) {
+ successCount++;
+ } else {
+ failCount++;
+ log.warn("淇濆瓨鎴栨洿鏂扮幓鐠冧俊鎭け璐�: glassId={}", glassInfo != null ? glassInfo.getGlassId() : "null");
+ }
}
- return true;
+ log.info("鎵归噺淇濆瓨鎴栨洿鏂扮幓鐠冧俊鎭畬鎴�: 鎬绘暟={}, 鎴愬姛={}, 澶辫触={}", glassInfos.size(), successCount, failCount);
+ return failCount == 0;
} catch (Exception e) {
log.error("鎵归噺淇濆瓨鎴栨洿鏂扮幓鐠冧俊鎭け璐�", e);
return false;
@@ -703,8 +743,12 @@
}
if (!glassInfos.isEmpty()) {
- batchSaveOrUpdateGlassInfo(glassInfos);
- log.info("宸蹭繚瀛� {} 鏉$幓鐠冧俊鎭埌鏈湴鏁版嵁搴擄紝宸ョ▼鍙�: {}", glassInfos.size(), engineeringId);
+ boolean success = batchSaveOrUpdateGlassInfo(glassInfos);
+ if (success) {
+ log.info("宸蹭繚瀛� {} 鏉$幓鐠冧俊鎭埌鏈湴鏁版嵁搴擄紝宸ョ▼鍙�: {}", glassInfos.size(), engineeringId);
+ } else {
+ log.error("淇濆瓨鐜荤拑淇℃伅鍒版湰鍦版暟鎹簱澶辫触锛屽伐绋嬪彿: {}, 鎬绘暟: {}", engineeringId, glassInfos.size());
+ }
}
}
@@ -761,14 +805,12 @@
try {
// 鍏堟煡璇㈣鍒犻櫎鐨勬暟閲忥紙鍒犻櫎鍓嶏級
LambdaQueryWrapper<GlassInfo> countWrapper = new LambdaQueryWrapper<>();
- countWrapper.eq(GlassInfo::getEngineeringId, engineeringId.trim())
- .eq(GlassInfo::getIsDeleted, 0); // 鏌ヨ鏈垹闄ょ殑璁板綍
+ countWrapper.eq(GlassInfo::getEngineeringId, engineeringId.trim());
long count = this.count(countWrapper);
// 浣跨敤MyBatis-Plus鐨剅emove鏂规硶锛屼細鏍规嵁@TableLogic鑷姩杩涜閫昏緫鍒犻櫎
LambdaQueryWrapper<GlassInfo> removeWrapper = new LambdaQueryWrapper<>();
- removeWrapper.eq(GlassInfo::getEngineeringId, engineeringId.trim())
- .eq(GlassInfo::getIsDeleted, 0); // 鍙垹闄ゆ湭鍒犻櫎鐨勮褰�
+ removeWrapper.eq(GlassInfo::getEngineeringId, engineeringId.trim());
boolean result = this.remove(removeWrapper);
if (result) {
--
Gitblit v1.8.0