From 704265308b1227dbada5a36b2027b588c062ded2 Mon Sep 17 00:00:00 2001
From: 云 <2163098428@qq.com>
Date: 星期一, 12 十月 2026 09:14:37 +0800
Subject: [PATCH] feat(mes): 新增业务码支持并优化追溯查询功能
---
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/dal/mysql/pro/batch/MesProBatchMapper.java | 43 ++++++++++++++++++++++++++++++++++++-------
1 files changed, 36 insertions(+), 7 deletions(-)
diff --git a/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/dal/mysql/pro/batch/MesProBatchMapper.java b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/dal/mysql/pro/batch/MesProBatchMapper.java
index 29ea3a2..4767842 100644
--- a/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/dal/mysql/pro/batch/MesProBatchMapper.java
+++ b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/dal/mysql/pro/batch/MesProBatchMapper.java
@@ -20,13 +20,21 @@
return selectOne(MesProBatchDO::getCode, code);
}
+ default MesProBatchDO selectByScanCode(String code) {
+ return selectOne(new LambdaQueryWrapperX<MesProBatchDO>().and(q ->
+ q.eq(MesProBatchDO::getBusinessCode, code).or().eq(MesProBatchDO::getCode, code)
+ .or().eq(MesProBatchDO::getTempCode, code)));
+ }
+
+ default MesProBatchDO selectByScanCodeForUpdate(String code) {
+ return selectOne(new LambdaQueryWrapperX<MesProBatchDO>().and(q ->
+ q.eq(MesProBatchDO::getBusinessCode, code).or().eq(MesProBatchDO::getCode, code)
+ .or().eq(MesProBatchDO::getTempCode, code)).last("FOR UPDATE"));
+ }
+
default MesProBatchDO selectByTempCode(String tempCode) {
return selectOne(MesProBatchDO::getTempCode, tempCode);
}
-
- /** 鐢熸垚涓存椂鎵规鐮佺敤鐨勫叏灞�搴忓彿锛氳В鏋� temp_code 鐨勬暟瀛楀悗缂�锛屼笉瀛樺湪鍒欒繑鍥� 0 */
- @Select("SELECT IFNULL(MAX(CAST(SUBSTRING(temp_code, 4) AS UNSIGNED)), 0) FROM mes_pro_batch WHERE deleted = 0")
- Integer selectMaxTempCodeSeq();
default Long selectCountByLineId(Long lineId) {
return selectCount(MesProBatchDO::getLineId, lineId);
@@ -39,19 +47,40 @@
int markInbound(@org.apache.ibatis.annotations.Param("id") Long id, @org.apache.ibatis.annotations.Param("eventId") Long eventId,
@org.apache.ibatis.annotations.Param("deviceCode") String deviceCode, @org.apache.ibatis.annotations.Param("lineCode") String lineCode);
+ /** 鎵规鏁存壒鎵爜鍏ュ簱鍥炲啓锛氬叆搴撹鏁扮洿鎺ョ疆涓烘壒娆¤鏁帮紝骞傜瓑锛堝凡鏈夊叆搴撴爣璁扮殑涓嶅啀鏇存柊锛� */
+ @org.apache.ibatis.annotations.Update("UPDATE mes_pro_batch SET inbound_time = NOW(), inbound_event_id = #{eventId}, inbound_line_code = #{lineCode}, inbound_bag_quantity = #{bagQuantity}, update_time = NOW() "
+ + "WHERE id = #{id} AND deleted = 0 AND inbound_event_id IS NULL")
+ int markBatchInbound(@org.apache.ibatis.annotations.Param("id") Long id, @org.apache.ibatis.annotations.Param("eventId") Long eventId,
+ @org.apache.ibatis.annotations.Param("lineCode") String lineCode, @org.apache.ibatis.annotations.Param("bagQuantity") Integer bagQuantity);
+
+ /** 浠ユ湁鏁堣鐮佺殑鍏ュ簱鏍囪涓哄噯锛涙贩鎵�侀噸璇曞拰浣滃簾琚嬩笉褰卞搷瀹屾垚鍒ゆ柇銆傝皟鐢ㄦ柟宸查攣瀹氭壒娆°�� */
+ @org.apache.ibatis.annotations.Update("UPDATE mes_pro_batch SET inbound_time = NOW(), inbound_event_id = #{eventId}, "
+ + "inbound_device_code = #{deviceCode}, inbound_line_code = #{lineCode}, "
+ + "inbound_bag_quantity = (SELECT COUNT(*) FROM mes_pro_bag_code b WHERE b.batch_id = #{id} "
+ + "AND b.deleted = 0 AND b.status <> 30 AND b.inbound_event_id IS NOT NULL), "
+ + "status = CASE WHEN EXISTS (SELECT 1 FROM mes_pro_bag_code b WHERE b.batch_id = #{id} AND b.deleted = 0 AND b.status <> 30) "
+ + "AND NOT EXISTS (SELECT 1 FROM mes_pro_bag_code b WHERE b.batch_id = #{id} AND b.deleted = 0 AND b.status <> 30 AND b.inbound_event_id IS NULL) "
+ + "THEN 30 ELSE status END, update_time = NOW() WHERE id = #{id} AND deleted = 0 AND status <> 40")
+ int refreshInboundProgress(@org.apache.ibatis.annotations.Param("id") Long id, @org.apache.ibatis.annotations.Param("eventId") Long eventId,
+ @org.apache.ibatis.annotations.Param("deviceCode") String deviceCode, @org.apache.ibatis.annotations.Param("lineCode") String lineCode);
+
default PageResult<MesProBatchDO> selectPage(MesProBatchPageReqVO reqVO) {
return selectPage(reqVO, new LambdaQueryWrapperX<MesProBatchDO>()
- .likeIfPresent(MesProBatchDO::getCode, reqVO.getCode())
+ .likeIfPresent(MesProBatchDO::getBusinessCode, reqVO.getBusinessCode())
.likeIfPresent(MesProBatchDO::getTempCode, reqVO.getTempCode())
- .eqIfPresent(MesProBatchDO::getItemId, reqVO.getItemId())
.eqIfPresent(MesProBatchDO::getLineId, reqVO.getLineId())
.likeIfPresent(MesProBatchDO::getLineCode, reqVO.getLineCode())
.likeIfPresent(MesProBatchDO::getLineName, reqVO.getLineName())
+ .likeIfPresent(MesProBatchDO::getProcessingTeam, reqVO.getProcessingTeam())
.eqIfPresent(MesProBatchDO::getOwnerUserId, reqVO.getOwnerUserId())
.eqIfPresent(MesProBatchDO::getStatus, reqVO.getStatus())
.betweenIfPresent(MesProBatchDO::getProduceDate, reqVO.getProduceDate())
.betweenIfPresent(MesProBatchDO::getCreateTime, reqVO.getCreateTime())
- .orderByDesc(MesProBatchDO::getId));
+ .orderByDesc(MesProBatchDO::getId)
+ .and(cn.hutool.core.util.StrUtil.isNotBlank(reqVO.getCode()), q ->
+ q.like(MesProBatchDO::getCode, reqVO.getCode()).or()
+ .like(MesProBatchDO::getBusinessCode, reqVO.getCode()).or()
+ .like(MesProBatchDO::getTempCode, reqVO.getCode())));
}
}
--
Gitblit v1.9.3