云
2 天以前 87733eb3623593da247c051593d64b8ff9e1d3a4
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/dal/mysql/pro/batch/MesProBatchMapper.java
@@ -20,6 +20,21 @@
        return selectOne(MesProBatchDO::getCode, code);
    }
    /**
     * 按批次号查询(包含已逻辑删除记录)
     * <p>
     * 批次号存在唯一索引,逻辑删除的记录仍占用码值,校验重复时必须一并纳入。
     */
    @Select("SELECT * FROM mes_pro_batch WHERE code = #{code} LIMIT 1")
    MesProBatchDO selectByCodeIgnoreDeleted(@org.apache.ibatis.annotations.Param("code") String code);
    /**
     * 查询指定年份已使用的最大批次流水号(批次号格式为 4 位年份 + 3 位流水)
     */
    @Select("SELECT COALESCE(MAX(CAST(SUBSTRING(code, 5) AS UNSIGNED)), 0) FROM mes_pro_batch "
            + "WHERE code LIKE CONCAT(#{year}, '%') AND code REGEXP '^[0-9]{7}$'")
    Integer selectMaxCodeSerialByYear(@org.apache.ibatis.annotations.Param("year") String year);
    default MesProBatchDO selectByScanCode(String code) {
        return selectOne(new LambdaQueryWrapperX<MesProBatchDO>().and(q ->
                q.eq(MesProBatchDO::getBusinessCode, code).or().eq(MesProBatchDO::getCode, code)