Commit ce6969c7e1ccd5b861484e6e8cbc2ab1fc16bccc
1 parent
750f6021
✨ feat(mes): 新增发货通知单状态枚举及相关逻辑优化
新增 MES 发货通知单状态枚举,优化发货通知单的状态管理逻辑,提升代码可读性和维护性。移除不必要的字段,简化请求对象。
Showing
5 changed files
with
61 additions
and
19 deletions
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/wm/salesnotice/vo/MesWmSalesNoticePageReqVO.java
| @@ -5,11 +5,6 @@ import io.swagger.v3.oas.annotations.media.Schema; | @@ -5,11 +5,6 @@ import io.swagger.v3.oas.annotations.media.Schema; | ||
| 5 | import lombok.Data; | 5 | import lombok.Data; |
| 6 | import lombok.EqualsAndHashCode; | 6 | import lombok.EqualsAndHashCode; |
| 7 | import lombok.ToString; | 7 | import lombok.ToString; |
| 8 | -import org.springframework.format.annotation.DateTimeFormat; | ||
| 9 | - | ||
| 10 | -import java.time.LocalDateTime; | ||
| 11 | - | ||
| 12 | -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; | ||
| 13 | 8 | ||
| 14 | @Schema(description = "管理后台 - MES 发货通知单分页 Request VO") | 9 | @Schema(description = "管理后台 - MES 发货通知单分页 Request VO") |
| 15 | @Data | 10 | @Data |
| @@ -29,11 +24,4 @@ public class MesWmSalesNoticePageReqVO extends PageParam { | @@ -29,11 +24,4 @@ public class MesWmSalesNoticePageReqVO extends PageParam { | ||
| 29 | @Schema(description = "客户编号", example = "1") | 24 | @Schema(description = "客户编号", example = "1") |
| 30 | private Long clientId; | 25 | private Long clientId; |
| 31 | 26 | ||
| 32 | - @Schema(description = "发货日期") | ||
| 33 | - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) | ||
| 34 | - private LocalDateTime[] salesDate; | ||
| 35 | - | ||
| 36 | - @Schema(description = "状态", example = "0") | ||
| 37 | - private Integer status; | ||
| 38 | - | ||
| 39 | } | 27 | } |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/dal/dataobject/wm/salesnotice/MesWmSalesNoticeDO.java
| @@ -64,7 +64,7 @@ public class MesWmSalesNoticeDO extends BaseDO { | @@ -64,7 +64,7 @@ public class MesWmSalesNoticeDO extends BaseDO { | ||
| 64 | /** | 64 | /** |
| 65 | * 状态 | 65 | * 状态 |
| 66 | * | 66 | * |
| 67 | - * 0-草稿,1-已提交 | 67 | + * 枚举 {@link cn.iocoder.yudao.module.mes.enums.wm.MesWmSalesNoticeStatusEnum} |
| 68 | */ | 68 | */ |
| 69 | private Integer status; | 69 | private Integer status; |
| 70 | /** | 70 | /** |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/dal/mysql/wm/salesnotice/MesWmSalesNoticeMapper.java
| @@ -21,8 +21,6 @@ public interface MesWmSalesNoticeMapper extends BaseMapperX<MesWmSalesNoticeDO> | @@ -21,8 +21,6 @@ public interface MesWmSalesNoticeMapper extends BaseMapperX<MesWmSalesNoticeDO> | ||
| 21 | .likeIfPresent(MesWmSalesNoticeDO::getNoticeName, reqVO.getNoticeName()) | 21 | .likeIfPresent(MesWmSalesNoticeDO::getNoticeName, reqVO.getNoticeName()) |
| 22 | .likeIfPresent(MesWmSalesNoticeDO::getSalesOrderCode, reqVO.getSalesOrderCode()) | 22 | .likeIfPresent(MesWmSalesNoticeDO::getSalesOrderCode, reqVO.getSalesOrderCode()) |
| 23 | .eqIfPresent(MesWmSalesNoticeDO::getClientId, reqVO.getClientId()) | 23 | .eqIfPresent(MesWmSalesNoticeDO::getClientId, reqVO.getClientId()) |
| 24 | - .betweenIfPresent(MesWmSalesNoticeDO::getSalesDate, reqVO.getSalesDate()) | ||
| 25 | - .eqIfPresent(MesWmSalesNoticeDO::getStatus, reqVO.getStatus()) | ||
| 26 | .orderByDesc(MesWmSalesNoticeDO::getId)); | 24 | .orderByDesc(MesWmSalesNoticeDO::getId)); |
| 27 | } | 25 | } |
| 28 | 26 |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/enums/wm/MesWmSalesNoticeStatusEnum.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.mes.enums.wm; | ||
| 2 | + | ||
| 3 | +import cn.iocoder.yudao.framework.common.core.ArrayValuable; | ||
| 4 | +import cn.iocoder.yudao.module.mes.controller.admin.wm.salesnotice.vo.MesWmSalesNoticeSaveReqVO; | ||
| 5 | +import cn.iocoder.yudao.module.mes.enums.MesOrderStatusConstants; | ||
| 6 | +import cn.iocoder.yudao.module.mes.service.wm.salesnotice.MesWmSalesNoticeService; | ||
| 7 | +import lombok.AllArgsConstructor; | ||
| 8 | +import lombok.Getter; | ||
| 9 | + | ||
| 10 | +import java.util.Arrays; | ||
| 11 | + | ||
| 12 | +/** | ||
| 13 | + * MES 发货通知单状态枚举 | ||
| 14 | + * | ||
| 15 | + * @author 芋道源码 | ||
| 16 | + */ | ||
| 17 | +@Getter | ||
| 18 | +@AllArgsConstructor | ||
| 19 | +public enum MesWmSalesNoticeStatusEnum implements ArrayValuable<Integer> { | ||
| 20 | + | ||
| 21 | + /** | ||
| 22 | + * 草稿 | ||
| 23 | + * | ||
| 24 | + * 对应方法:{@link MesWmSalesNoticeService#createSalesNotice(MesWmSalesNoticeSaveReqVO)} | ||
| 25 | + */ | ||
| 26 | + PREPARE(MesOrderStatusConstants.PREPARE, "草稿"), | ||
| 27 | + /** | ||
| 28 | + * 待出库,对接 wm 模块的 MesWmProductSalesDO 后续流程 | ||
| 29 | + * | ||
| 30 | + * 对应方法:{@link MesWmSalesNoticeService#submitSalesNotice(Long)} | ||
| 31 | + */ | ||
| 32 | + APPROVED(MesOrderStatusConstants.APPROVED, "待出库"), | ||
| 33 | + /** | ||
| 34 | + * 已完成 | ||
| 35 | + */ | ||
| 36 | + // TODO @芋艿:这个待实现; | ||
| 37 | + FINISHED(MesOrderStatusConstants.FINISHED, "已完成"); | ||
| 38 | + | ||
| 39 | + public static final Integer[] ARRAYS = Arrays.stream(values()).map(MesWmSalesNoticeStatusEnum::getStatus).toArray(Integer[]::new); | ||
| 40 | + | ||
| 41 | + /** | ||
| 42 | + * 状态值 | ||
| 43 | + */ | ||
| 44 | + private final Integer status; | ||
| 45 | + /** | ||
| 46 | + * 状态名 | ||
| 47 | + */ | ||
| 48 | + private final String name; | ||
| 49 | + | ||
| 50 | + @Override | ||
| 51 | + public Integer[] array() { | ||
| 52 | + return ARRAYS; | ||
| 53 | + } | ||
| 54 | + | ||
| 55 | +} |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/wm/salesnotice/MesWmSalesNoticeServiceImpl.java
| @@ -21,6 +21,7 @@ import java.util.List; | @@ -21,6 +21,7 @@ import java.util.List; | ||
| 21 | 21 | ||
| 22 | import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; | 22 | import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; |
| 23 | import static cn.iocoder.yudao.module.mes.enums.ErrorCodeConstants.*; | 23 | import static cn.iocoder.yudao.module.mes.enums.ErrorCodeConstants.*; |
| 24 | +import static cn.iocoder.yudao.module.mes.enums.wm.MesWmSalesNoticeStatusEnum.*; | ||
| 24 | 25 | ||
| 25 | /** | 26 | /** |
| 26 | * MES 发货通知单 Service 实现类 | 27 | * MES 发货通知单 Service 实现类 |
| @@ -43,7 +44,7 @@ public class MesWmSalesNoticeServiceImpl implements MesWmSalesNoticeService { | @@ -43,7 +44,7 @@ public class MesWmSalesNoticeServiceImpl implements MesWmSalesNoticeService { | ||
| 43 | 44 | ||
| 44 | // 插入 | 45 | // 插入 |
| 45 | MesWmSalesNoticeDO notice = BeanUtils.toBean(createReqVO, MesWmSalesNoticeDO.class); | 46 | MesWmSalesNoticeDO notice = BeanUtils.toBean(createReqVO, MesWmSalesNoticeDO.class); |
| 46 | - notice.setStatus(0); // 草稿状态 | 47 | + notice.setStatus(PREPARE.getStatus()); // 草稿状态 |
| 47 | salesNoticeMapper.insert(notice); | 48 | salesNoticeMapper.insert(notice); |
| 48 | return notice.getId(); | 49 | return notice.getId(); |
| 49 | } | 50 | } |
| @@ -93,9 +94,9 @@ public class MesWmSalesNoticeServiceImpl implements MesWmSalesNoticeService { | @@ -93,9 +94,9 @@ public class MesWmSalesNoticeServiceImpl implements MesWmSalesNoticeService { | ||
| 93 | throw exception(WM_SALES_NOTICE_LINE_EMPTY); | 94 | throw exception(WM_SALES_NOTICE_LINE_EMPTY); |
| 94 | } | 95 | } |
| 95 | 96 | ||
| 96 | - // 2. 更新状态:草稿 → 已提交 | 97 | + // 2. 更新状态:草稿 → 待出库 |
| 97 | salesNoticeMapper.updateById(new MesWmSalesNoticeDO() | 98 | salesNoticeMapper.updateById(new MesWmSalesNoticeDO() |
| 98 | - .setId(id).setStatus(1)); | 99 | + .setId(id).setStatus(APPROVED.getStatus())); |
| 99 | } | 100 | } |
| 100 | 101 | ||
| 101 | @Override | 102 | @Override |
| @@ -127,7 +128,7 @@ public class MesWmSalesNoticeServiceImpl implements MesWmSalesNoticeService { | @@ -127,7 +128,7 @@ public class MesWmSalesNoticeServiceImpl implements MesWmSalesNoticeService { | ||
| 127 | */ | 128 | */ |
| 128 | private MesWmSalesNoticeDO validateSalesNoticeExistsAndDraft(Long id) { | 129 | private MesWmSalesNoticeDO validateSalesNoticeExistsAndDraft(Long id) { |
| 129 | MesWmSalesNoticeDO notice = validateSalesNoticeExists(id); | 130 | MesWmSalesNoticeDO notice = validateSalesNoticeExists(id); |
| 130 | - if (ObjUtil.notEqual(0, notice.getStatus())) { | 131 | + if (ObjUtil.notEqual(PREPARE.getStatus(), notice.getStatus())) { |
| 131 | throw exception(WM_SALES_NOTICE_STATUS_NOT_ALLOW_DELETE); | 132 | throw exception(WM_SALES_NOTICE_STATUS_NOT_ALLOW_DELETE); |
| 132 | } | 133 | } |
| 133 | return notice; | 134 | return notice; |