| | |
| | | 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; |
| | |
| | | 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) { |
| | | return selectCount(MesProBagCodeDO::getBatchId, batchId); |
| | | } |
| | |
| | | .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)); |
| | | } |
| | | |
| | | /** |
| | |
| | | } |
| | | |
| | | /** |
| | | * 托盘正式码生成后,回写其下所有袋码的冗余托盘码 |
| | | * |
| | | * @param palletId 托盘编号 |
| | | * @param palletCode 正式托盘码 |
| | | */ |
| | | default void updatePalletCodeByPalletId(Long palletId, String palletCode) { |
| | | update(null, new LambdaUpdateWrapper<MesProBagCodeDO>() |
| | | .set(MesProBagCodeDO::getPalletCode, palletCode) |
| | | .eq(MesProBagCodeDO::getPalletId, palletId)); |
| | | } |
| | | |
| | | /** |
| | | * 批量解绑托盘(置空托盘编号与托盘码) |
| | | * |
| | | * @param ids 袋码编号列表 |
| | |
| | | } |
| | | |
| | | /** |
| | | * 查询批次内袋码最大序号(包含已逻辑删除记录,保证序号不回退、码值唯一) |
| | | * 查询全局最大袋序号(袋序号为全局序号,不区分批次;包含已逻辑删除记录,保证序号不回退) |
| | | * <p> |
| | | * 仅用于为 Redis 序号分配提供基准值,不要在业务中直接用「返回值 + 1」作为起始序号—— |
| | | * 那是先读后写,并发生成会产生重复序号。请使用 |
| | | * {@code MesCodeRedisDAO#allocateBagNoStart(int, Integer)} 原子分配。 |
| | | * |
| | | * @param batchId 批次编号 |
| | | * @return 最大袋序号,无记录返回 0 |
| | | * @return 全局最大袋序号,无记录返回 0 |
| | | */ |
| | | @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 = #{status} AND id IN " + |
| | | "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("status") Integer status); |
| | | @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>() |