Commit 9bd85b53d9b5ff00e48559f717e33f9ac89eecdf
1 parent
b0adeb36
✨ feat(mes): 添加条码相关组件和逻辑
新增条码格式枚举、条码生成组件及其相关 API,支持条码的创建、查看和配置功能。实现了条码的自动生成逻辑,并优化了条码配置管理界面,提升用户体验。 - 新增 Barcode 组件用于条码展示 - 实现条码生成和下载功能 - 添加条码配置管理功能
Showing
6 changed files
with
32 additions
and
98 deletions
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/dal/mysql/wm/barcode/MesWmBarcodeConfigMapper.java
| @@ -7,8 +7,6 @@ import cn.iocoder.yudao.module.mes.controller.admin.wm.barcode.vo.config.MesWmBa | @@ -7,8 +7,6 @@ import cn.iocoder.yudao.module.mes.controller.admin.wm.barcode.vo.config.MesWmBa | ||
| 7 | import cn.iocoder.yudao.module.mes.dal.dataobject.wm.barcode.MesWmBarcodeConfigDO; | 7 | import cn.iocoder.yudao.module.mes.dal.dataobject.wm.barcode.MesWmBarcodeConfigDO; |
| 8 | import org.apache.ibatis.annotations.Mapper; | 8 | import org.apache.ibatis.annotations.Mapper; |
| 9 | 9 | ||
| 10 | -import java.util.List; | ||
| 11 | - | ||
| 12 | /** | 10 | /** |
| 13 | * MES 条码配置 Mapper | 11 | * MES 条码配置 Mapper |
| 14 | * | 12 | * |
| @@ -31,8 +29,4 @@ public interface MesWmBarcodeConfigMapper extends BaseMapperX<MesWmBarcodeConfig | @@ -31,8 +29,4 @@ public interface MesWmBarcodeConfigMapper extends BaseMapperX<MesWmBarcodeConfig | ||
| 31 | return selectOne(MesWmBarcodeConfigDO::getBizType, bizType); | 29 | return selectOne(MesWmBarcodeConfigDO::getBizType, bizType); |
| 32 | } | 30 | } |
| 33 | 31 | ||
| 34 | - default List<MesWmBarcodeConfigDO> selectListByAutoGenerateFlag(Boolean autoGenerateFlag) { | ||
| 35 | - return selectList(MesWmBarcodeConfigDO::getAutoGenerateFlag, autoGenerateFlag); | ||
| 36 | - } | ||
| 37 | - | ||
| 38 | } | 32 | } |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/framework/barcode/MesWmBarcodeAutoGenerator.java deleted
| 1 | -package cn.iocoder.yudao.module.mes.framework.barcode; | ||
| 2 | - | ||
| 3 | -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; | ||
| 4 | -import cn.iocoder.yudao.module.mes.controller.admin.wm.barcode.vo.MesWmBarcodeSaveReqVO; | ||
| 5 | -import cn.iocoder.yudao.module.mes.dal.dataobject.wm.barcode.MesWmBarcodeConfigDO; | ||
| 6 | -import cn.iocoder.yudao.module.mes.dal.dataobject.wm.barcode.MesWmBarcodeDO; | ||
| 7 | -import cn.iocoder.yudao.module.mes.service.wm.barcode.MesWmBarcodeConfigService; | ||
| 8 | -import cn.iocoder.yudao.module.mes.service.wm.barcode.MesWmBarcodeService; | ||
| 9 | -import jakarta.annotation.Resource; | ||
| 10 | -import lombok.extern.slf4j.Slf4j; | ||
| 11 | -import org.springframework.scheduling.annotation.Async; | ||
| 12 | -import org.springframework.stereotype.Component; | ||
| 13 | - | ||
| 14 | -/** | ||
| 15 | - * MES 条码自动生成器 | ||
| 16 | - * | ||
| 17 | - * @author 芋道源码 | ||
| 18 | - */ | ||
| 19 | -@Component | ||
| 20 | -@Slf4j | ||
| 21 | -public class MesWmBarcodeAutoGenerator { | ||
| 22 | - | ||
| 23 | - @Resource | ||
| 24 | - private MesWmBarcodeConfigService barcodeConfigService; | ||
| 25 | - | ||
| 26 | - @Resource | ||
| 27 | - private MesWmBarcodeService barcodeService; | ||
| 28 | - | ||
| 29 | - // TODO @AI:合并到 MesWmBarcodeServiceImpl 中; | ||
| 30 | - /** | ||
| 31 | - * 自动生成条码 | ||
| 32 | - * | ||
| 33 | - * @param bizType 业务类型 | ||
| 34 | - * @param bizId 业务编号 | ||
| 35 | - * @param bizCode 业务编码 | ||
| 36 | - * @param bizName 业务名称 | ||
| 37 | - */ | ||
| 38 | - @Async | ||
| 39 | - // TODO @AI:就不异步处理了,必要性不大; | ||
| 40 | - public void autoGenerateBarcode(Integer bizType, Long bizId, String bizCode, String bizName) { | ||
| 41 | - // TODO @AI:不要 try catch;;;;必须成功! | ||
| 42 | - try { | ||
| 43 | - // 1.1 检查是否配置自动生成 | ||
| 44 | - MesWmBarcodeConfigDO config = barcodeConfigService.getBarcodeConfigByBizType(bizType); | ||
| 45 | - if (config == null) { | ||
| 46 | - return; | ||
| 47 | - } | ||
| 48 | - // TODO @AI:Boolean.False 去比较;跳过; | ||
| 49 | - if (!config.getAutoGenerateFlag()) { | ||
| 50 | - return; | ||
| 51 | - } | ||
| 52 | - // TODO @AI;CommonStatusEnum.isFalse(config.getStatus()) 去比较;把上面 3 个判断,合并下; | ||
| 53 | - if (!CommonStatusEnum.ENABLE.getStatus().equals(config.getStatus())) { | ||
| 54 | - return; | ||
| 55 | - } | ||
| 56 | - // 1.2 检查是否已存在条码 | ||
| 57 | - MesWmBarcodeDO existBarcode = barcodeService.getBarcodeByBizTypeAndBizId(bizType, bizId); | ||
| 58 | - if (existBarcode != null) { | ||
| 59 | - return; | ||
| 60 | - } | ||
| 61 | - | ||
| 62 | - // 2. 创建条码记录 | ||
| 63 | - MesWmBarcodeSaveReqVO createReqVO = new MesWmBarcodeSaveReqVO() | ||
| 64 | - .setFormat(config.getFormat()).setStatus(CommonStatusEnum.ENABLE.getStatus()) | ||
| 65 | - .setBizType(bizType).setBizId(bizId).setBizCode(bizCode).setBizName(bizName); | ||
| 66 | - Long barcodeId = barcodeService.createBarcode(createReqVO); | ||
| 67 | - // TODO @AI:这里就不打日志了; | ||
| 68 | - log.info("自动生成条码成功 [业务类型={}, 业务ID={}, 条码ID={}]", bizType, bizId, barcodeId); | ||
| 69 | - } catch (Exception e) { | ||
| 70 | - log.error("自动生成条码失败 [业务类型={}, 业务ID={}]", bizType, bizId, e); | ||
| 71 | - } | ||
| 72 | - } | ||
| 73 | - | ||
| 74 | -} |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/wm/barcode/MesWmBarcodeConfigService.java
| @@ -6,8 +6,6 @@ import cn.iocoder.yudao.module.mes.controller.admin.wm.barcode.vo.config.MesWmBa | @@ -6,8 +6,6 @@ import cn.iocoder.yudao.module.mes.controller.admin.wm.barcode.vo.config.MesWmBa | ||
| 6 | import cn.iocoder.yudao.module.mes.dal.dataobject.wm.barcode.MesWmBarcodeConfigDO; | 6 | import cn.iocoder.yudao.module.mes.dal.dataobject.wm.barcode.MesWmBarcodeConfigDO; |
| 7 | import jakarta.validation.Valid; | 7 | import jakarta.validation.Valid; |
| 8 | 8 | ||
| 9 | -import java.util.List; | ||
| 10 | - | ||
| 11 | /** | 9 | /** |
| 12 | * MES 条码配置 Service 接口 | 10 | * MES 条码配置 Service 接口 |
| 13 | * | 11 | * |
| @@ -69,12 +67,4 @@ public interface MesWmBarcodeConfigService { | @@ -69,12 +67,4 @@ public interface MesWmBarcodeConfigService { | ||
| 69 | */ | 67 | */ |
| 70 | MesWmBarcodeConfigDO validateBarcodeConfigByBizType(Integer bizType); | 68 | MesWmBarcodeConfigDO validateBarcodeConfigByBizType(Integer bizType); |
| 71 | 69 | ||
| 72 | - // TODO @AI:是不是删除掉?貌似没用哈。 | ||
| 73 | - /** | ||
| 74 | - * 获取自动生成的条码配置列表 | ||
| 75 | - * | ||
| 76 | - * @return 条码配置列表 | ||
| 77 | - */ | ||
| 78 | - List<MesWmBarcodeConfigDO> getAutoGenerateBarcodeConfigList(); | ||
| 79 | - | ||
| 80 | } | 70 | } |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/wm/barcode/MesWmBarcodeConfigServiceImpl.java
| @@ -11,8 +11,6 @@ import jakarta.annotation.Resource; | @@ -11,8 +11,6 @@ import jakarta.annotation.Resource; | ||
| 11 | import org.springframework.stereotype.Service; | 11 | import org.springframework.stereotype.Service; |
| 12 | import org.springframework.validation.annotation.Validated; | 12 | import org.springframework.validation.annotation.Validated; |
| 13 | 13 | ||
| 14 | -import java.util.List; | ||
| 15 | - | ||
| 16 | import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; | 14 | import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; |
| 17 | import static cn.iocoder.yudao.module.mes.enums.ErrorCodeConstants.*; | 15 | import static cn.iocoder.yudao.module.mes.enums.ErrorCodeConstants.*; |
| 18 | 16 | ||
| @@ -101,10 +99,4 @@ public class MesWmBarcodeConfigServiceImpl implements MesWmBarcodeConfigService | @@ -101,10 +99,4 @@ public class MesWmBarcodeConfigServiceImpl implements MesWmBarcodeConfigService | ||
| 101 | return config; | 99 | return config; |
| 102 | } | 100 | } |
| 103 | 101 | ||
| 104 | - // TODO @AI:getBarcodeConfigListByAutoGenerateFlag,获取自动生成条码的配置列表(Boolean ) | ||
| 105 | - @Override | ||
| 106 | - public List<MesWmBarcodeConfigDO> getAutoGenerateBarcodeConfigList() { | ||
| 107 | - return barcodeConfigMapper.selectListByAutoGenerateFlag(true); | ||
| 108 | - } | ||
| 109 | - | ||
| 110 | } | 102 | } |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/wm/barcode/MesWmBarcodeService.java
| @@ -60,4 +60,14 @@ public interface MesWmBarcodeService { | @@ -60,4 +60,14 @@ public interface MesWmBarcodeService { | ||
| 60 | */ | 60 | */ |
| 61 | MesWmBarcodeDO getBarcodeByBizTypeAndBizId(Integer bizType, Long bizId); | 61 | MesWmBarcodeDO getBarcodeByBizTypeAndBizId(Integer bizType, Long bizId); |
| 62 | 62 | ||
| 63 | + /** | ||
| 64 | + * 自动生成条码 | ||
| 65 | + * | ||
| 66 | + * @param bizType 业务类型 | ||
| 67 | + * @param bizId 业务编号 | ||
| 68 | + * @param bizCode 业务编码 | ||
| 69 | + * @param bizName 业务名称 | ||
| 70 | + */ | ||
| 71 | + void autoGenerateBarcode(Integer bizType, Long bizId, String bizCode, String bizName); | ||
| 72 | + | ||
| 63 | } | 73 | } |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/wm/barcode/MesWmBarcodeServiceImpl.java
| 1 | package cn.iocoder.yudao.module.mes.service.wm.barcode; | 1 | package cn.iocoder.yudao.module.mes.service.wm.barcode; |
| 2 | 2 | ||
| 3 | import cn.hutool.core.util.StrUtil; | 3 | import cn.hutool.core.util.StrUtil; |
| 4 | +import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; | ||
| 4 | import cn.iocoder.yudao.framework.common.pojo.PageResult; | 5 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 5 | import cn.iocoder.yudao.framework.common.util.object.BeanUtils; | 6 | import cn.iocoder.yudao.framework.common.util.object.BeanUtils; |
| 6 | import cn.iocoder.yudao.module.mes.controller.admin.wm.barcode.vo.MesWmBarcodePageReqVO; | 7 | import cn.iocoder.yudao.module.mes.controller.admin.wm.barcode.vo.MesWmBarcodePageReqVO; |
| @@ -97,6 +98,27 @@ public class MesWmBarcodeServiceImpl implements MesWmBarcodeService { | @@ -97,6 +98,27 @@ public class MesWmBarcodeServiceImpl implements MesWmBarcodeService { | ||
| 97 | return barcodeMapper.selectByBizTypeAndBizId(bizType, bizId); | 98 | return barcodeMapper.selectByBizTypeAndBizId(bizType, bizId); |
| 98 | } | 99 | } |
| 99 | 100 | ||
| 101 | + @Override | ||
| 102 | + public void autoGenerateBarcode(Integer bizType, Long bizId, String bizCode, String bizName) { | ||
| 103 | + // 1.1 检查是否配置自动生成 | ||
| 104 | + MesWmBarcodeConfigDO config = barcodeConfigService.getBarcodeConfigByBizType(bizType); | ||
| 105 | + if (config == null || Boolean.FALSE.equals(config.getAutoGenerateFlag()) | ||
| 106 | + || CommonStatusEnum.isDisable(config.getStatus())) { | ||
| 107 | + return; | ||
| 108 | + } | ||
| 109 | + // 1.2 检查是否已存在条码 | ||
| 110 | + MesWmBarcodeDO existBarcode = barcodeMapper.selectByBizTypeAndBizId(bizType, bizId); | ||
| 111 | + if (existBarcode != null) { | ||
| 112 | + return; | ||
| 113 | + } | ||
| 114 | + | ||
| 115 | + // 2. 创建条码记录 | ||
| 116 | + MesWmBarcodeSaveReqVO createReqVO = new MesWmBarcodeSaveReqVO() | ||
| 117 | + .setFormat(config.getFormat()).setStatus(CommonStatusEnum.ENABLE.getStatus()) | ||
| 118 | + .setBizType(bizType).setBizId(bizId).setBizCode(bizCode).setBizName(bizName); | ||
| 119 | + createBarcode(createReqVO); | ||
| 120 | + } | ||
| 121 | + | ||
| 100 | /** | 122 | /** |
| 101 | * 生成条码内容 | 123 | * 生成条码内容 |
| 102 | * | 124 | * |