From 4ca4444ad33a2a1a51f5c06e78ee9365dfb1eed6 Mon Sep 17 00:00:00 2001
From: liu <2021943741@qq.com>
Date: 星期四, 08 十月 2026 17:11:11 +0800
Subject: [PATCH] feat(mes): 种子二维码标签国标四要素合规改造
---
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/dal/mysql/pro/bagcode/MesProBagCodeMapper.java | 115 ++++++++++++++++++++++++++++++++++++++++++++++++++++++---
1 files changed, 109 insertions(+), 6 deletions(-)
diff --git a/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/dal/mysql/pro/bagcode/MesProBagCodeMapper.java b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/dal/mysql/pro/bagcode/MesProBagCodeMapper.java
index ca31481..7024430 100644
--- a/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/dal/mysql/pro/bagcode/MesProBagCodeMapper.java
+++ b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/dal/mysql/pro/bagcode/MesProBagCodeMapper.java
@@ -5,6 +5,7 @@
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.module.mes.controller.admin.pro.bagcode.vo.MesProBagCodePageReqVO;
import cn.iocoder.yudao.module.mes.dal.dataobject.pro.bagcode.MesProBagCodeDO;
+import cn.iocoder.yudao.module.mes.enums.pro.MesProBagCodeStatusEnum;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
@@ -27,6 +28,39 @@
return selectOne(MesProBagCodeDO::getCode, code);
}
+ default MesProBagCodeDO selectByCodeForUpdate(String code) {
+ return selectOne(new LambdaQueryWrapperX<MesProBagCodeDO>()
+ .eq(MesProBagCodeDO::getCode, code).last("FOR UPDATE"));
+ }
+
+ @org.apache.ibatis.annotations.Update("UPDATE mes_pro_bag_code SET inbound_time = NOW(), inbound_event_id = #{eventId}, inbound_device_code = #{deviceCode}, inbound_line_code = #{lineCode}, update_time = NOW() WHERE id = #{id} AND deleted = 0 AND inbound_event_id IS NULL")
+ 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);
+
+ /** 鎵规鏁存壒鍏ュ簱鏃舵壒閲忔爣璁板叾涓嬫湭鍏ュ簱琚嬬爜锛堝箓绛夛級锛屼繚鎸佽鐮佷笌搴撳瓨鐘舵�佷竴鑷� */
+ @Update("UPDATE mes_pro_bag_code SET inbound_time = NOW(), inbound_event_id = #{eventId}, inbound_line_code = #{lineCode}, update_time = NOW() "
+ + "WHERE deleted = 0 AND inbound_event_id IS NULL AND batch_id = #{batchId}")
+ int markInboundByBatchId(@Param("batchId") Long batchId, @Param("eventId") Long eventId,
+ @Param("lineCode") String lineCode);
+
+ /** 鏁存墭鍏ュ簱鏃舵壒閲忔爣璁版墭鐩樹笅鏈叆搴撹鐮侊紙骞傜瓑锛� */
+ @Update("UPDATE mes_pro_bag_code SET inbound_time = NOW(), inbound_event_id = #{eventId}, inbound_line_code = #{lineCode}, update_time = NOW() "
+ + "WHERE deleted = 0 AND inbound_event_id IS NULL AND pallet_id = #{palletId}")
+ int markInboundByPalletId(@Param("palletId") Long palletId, @Param("eventId") Long eventId,
+ @Param("lineCode") String lineCode);
+
+ /**
+ * 鏇存柊琚嬬爜璐ㄦ鐘舵�侊紙绉嶅瓙璐ㄦ鍚堟牸/涓嶅悎鏍兼椂璁板綍璇ヨ缁撴灉锛�
+ *
+ * @param id 琚嬬爜缂栧彿
+ * @param qcStatus 璐ㄦ鐘舵�侊紙瑙� MesProBagCodeQcStatusEnum锛�
+ */
+ default void updateQcStatus(Long id, Integer qcStatus) {
+ update(null, new LambdaUpdateWrapper<MesProBagCodeDO>()
+ .eq(MesProBagCodeDO::getId, id)
+ .set(MesProBagCodeDO::getQcStatus, qcStatus));
+ }
+
default List<MesProBagCodeDO> selectListByUuid(String uuid) {
return selectList(MesProBagCodeDO::getUuid, uuid);
}
@@ -37,6 +71,29 @@
default List<MesProBagCodeDO> selectListByBatchId(Long batchId) {
return selectList(MesProBagCodeDO::getBatchId, batchId);
+ }
+
+ /**
+ * 鏌ヨ鐢熸垚缁勪笅鍙嵃鍒风殑琚嬬爜锛堟帓闄ゅ凡浣滃簾锛夛紝鐢ㄤ簬浜岀淮鐮佹爣绛惧鍑�
+ * <p>
+ * 宸蹭綔搴熻鐮佺殑鏍囩涓嶅緱鍐嶅嵃鍒凤細鍏舵爣绛捐嫢璐村埌浜у搧涓婏紝娑堣垂鑰呮壂鐮佷細琚彁绀恒�岃杩芥函鐮佸凡浣滃簾銆嶏紝
+ * 瀵艰嚧鐪熷搧琚鍒や负鍋囪揣銆�
+ */
+ default List<MesProBagCodeDO> selectPrintableListByUuid(String uuid) {
+ return selectList(new LambdaQueryWrapperX<MesProBagCodeDO>()
+ .eq(MesProBagCodeDO::getUuid, uuid)
+ .ne(MesProBagCodeDO::getStatus, MesProBagCodeStatusEnum.CANCELED.getStatus())
+ .orderByAsc(MesProBagCodeDO::getBagNo));
+ }
+
+ /**
+ * 鏌ヨ鎵规涓嬪彲鍗板埛鐨勮鐮侊紙鎺掗櫎宸蹭綔搴燂級锛岀敤浜庝簩缁寸爜鏍囩瀵煎嚭
+ */
+ default List<MesProBagCodeDO> selectPrintableListByBatchId(Long batchId) {
+ return selectList(new LambdaQueryWrapperX<MesProBagCodeDO>()
+ .eq(MesProBagCodeDO::getBatchId, batchId)
+ .ne(MesProBagCodeDO::getStatus, MesProBagCodeStatusEnum.CANCELED.getStatus())
+ .orderByAsc(MesProBagCodeDO::getBagNo));
}
default Long selectCountByBatchId(Long batchId) {
@@ -58,9 +115,11 @@
.likeIfPresent(MesProBagCodeDO::getBatchCode, reqVO.getBatchCode())
.eqIfPresent(MesProBagCodeDO::getUuid, reqVO.getUuid())
.eqIfPresent(MesProBagCodeDO::getPalletId, reqVO.getPalletId())
+ .eqIfPresent(MesProBagCodeDO::getItemId, reqVO.getItemId())
.eqIfPresent(MesProBagCodeDO::getStatus, reqVO.getStatus())
.betweenIfPresent(MesProBagCodeDO::getCreateTime, reqVO.getCreateTime())
- .orderByAsc(MesProBagCodeDO::getBagNo));
+ .orderByDesc(MesProBagCodeDO::getCreateTime)
+ .orderByDesc(MesProBagCodeDO::getId));
}
/**
@@ -78,6 +137,18 @@
}
/**
+ * 鎵樼洏姝e紡鐮佺敓鎴愬悗锛屽洖鍐欏叾涓嬫墍鏈夎鐮佺殑鍐椾綑鎵樼洏鐮�
+ *
+ * @param palletId 鎵樼洏缂栧彿
+ * @param palletCode 姝e紡鎵樼洏鐮�
+ */
+ default void updatePalletCodeByPalletId(Long palletId, String palletCode) {
+ update(null, new LambdaUpdateWrapper<MesProBagCodeDO>()
+ .set(MesProBagCodeDO::getPalletCode, palletCode)
+ .eq(MesProBagCodeDO::getPalletId, palletId));
+ }
+
+ /**
* 鎵归噺瑙g粦鎵樼洏锛堢疆绌烘墭鐩樼紪鍙蜂笌鎵樼洏鐮侊級
*
* @param ids 琚嬬爜缂栧彿鍒楄〃
@@ -90,13 +161,36 @@
}
/**
- * 鏌ヨ鎵规鍐呰鐮佹渶澶у簭鍙凤紙鍖呭惈宸查�昏緫鍒犻櫎璁板綍锛屼繚璇佸簭鍙蜂笉鍥為��銆佺爜鍊煎敮涓�锛�
+ * 鏌ヨ鍏ㄥ眬鏈�澶ц搴忓彿锛堣搴忓彿涓哄叏灞�搴忓彿锛屼笉鍖哄垎鎵规锛涘寘鍚凡閫昏緫鍒犻櫎璁板綍锛屼繚璇佸簭鍙蜂笉鍥為��锛�
+ * <p>
+ * 浠呯敤浜庝负 Redis 搴忓彿鍒嗛厤鎻愪緵鍩哄噯鍊硷紝涓嶈鍦ㄤ笟鍔′腑鐩存帴鐢ㄣ�岃繑鍥炲�� + 1銆嶄綔涓鸿捣濮嬪簭鍙封�斺��
+ * 閭f槸鍏堣鍚庡啓锛屽苟鍙戠敓鎴愪細浜х敓閲嶅搴忓彿銆傝浣跨敤
+ * {@code MesCodeRedisDAO#allocateBagNoStart(int, Integer)} 鍘熷瓙鍒嗛厤銆�
*
- * @param batchId 鎵规缂栧彿
- * @return 鏈�澶ц搴忓彿锛屾棤璁板綍杩斿洖 0
+ * @return 鍏ㄥ眬鏈�澶ц搴忓彿锛屾棤璁板綍杩斿洖 0
*/
- @Select("SELECT IFNULL(MAX(bag_no), 0) FROM mes_pro_bag_code WHERE batch_id = #{batchId}")
- Integer selectMaxBagNo(@Param("batchId") Long batchId);
+ @Select("SELECT IFNULL(MAX(bag_no), 0) FROM mes_pro_bag_code")
+ Integer selectMaxBagNo();
+
+ @Update("<script>UPDATE mes_pro_bag_code SET batch_id = #{batchId}, batch_code = #{batchCode}, update_time = NOW() " +
+ "WHERE deleted = 0 AND batch_id IS NULL AND status IN " +
+ "<foreach collection='statuses' item='st' open='(' separator=',' close=')'>#{st}</foreach> AND id IN " +
+ "<foreach collection='ids' item='id' open='(' separator=',' close=')'>#{id}</foreach></script>")
+ int bindBatchByIds(@Param("ids") Collection<Long> ids, @Param("batchId") Long batchId,
+ @Param("batchCode") String batchCode, @Param("statuses") Collection<Integer> statuses);
+
+ /** 鏌ヨ鎵樼洏涓嬪皻鏈粦瀹氭壒娆$殑琚嬬爜锛堟墭鐩樼粦瀹氭壒娆℃椂绾ц仈褰曞叆鐢級 */
+ default List<MesProBagCodeDO> selectUnboundListByPalletIds(Collection<Long> palletIds) {
+ return selectList(new LambdaQueryWrapperX<MesProBagCodeDO>()
+ .in(MesProBagCodeDO::getPalletId, palletIds)
+ .isNull(MesProBagCodeDO::getBatchId)
+ .orderByAsc(MesProBagCodeDO::getId));
+ }
+
+ /** 鎵规鍐呮湁鏁堣鐮佺殑鍝佺缂栧彿闆嗗悎锛堝拷鐣ュ巻鍙茬┖鍝佺琚嬬爜锛夛紝鐢ㄤ簬褰曞叆鎵规鏃剁殑鍝佺涓�鑷存�ф牎楠� */
+ @Select("SELECT DISTINCT item_id FROM mes_pro_bag_code " +
+ "WHERE deleted = 0 AND status <> 30 AND batch_id = #{batchId} AND item_id IS NOT NULL")
+ List<Long> selectDistinctItemIdsByBatchId(@Param("batchId") Long batchId);
default List<MesProBagCodeDO> selectListByIdsForUpdate(Collection<Long> ids) {
return selectList(new LambdaQueryWrapperX<MesProBagCodeDO>()
@@ -112,6 +206,15 @@
@Param("toStatus") Integer toStatus, @Param("cancelTime") LocalDateTime cancelTime,
@Param("cancelReason") String cancelReason);
+ @Update("UPDATE mes_pro_bag_code SET sales_id = #{salesId}, outbound_time = #{outboundTime}, update_time = NOW() "
+ + "WHERE id = #{id} AND deleted = 0")
+ void markOutbound(@Param("id") Long id, @Param("salesId") Long salesId,
+ @Param("outboundTime") LocalDateTime outboundTime);
+
+ @Update("UPDATE mes_pro_bag_code SET sales_id = NULL, outbound_time = NULL, update_time = NOW() "
+ + "WHERE id = #{id} AND deleted = 0")
+ void clearOutbound(@Param("id") Long id);
+
@Select("SELECT COUNT(*) FROM mes_pro_bag_code WHERE batch_id = #{batchId} " +
"AND deleted = 0 AND status <> 30")
int selectEffectiveCountByBatchId(@Param("batchId") Long batchId);
--
Gitblit v1.9.3