Commit 750f6021bee4b0699b25fc21f50c9b792682e6c4

Authored by YunaiV
1 parent e093ce39

✨ feat(mes): 新增发货通知单及相关行功能

添加发货通知单及其行的相关数据结构和逻辑,包括创建、更新、删除和查询功能。此功能将提升销售出库管理的效率,并支持更灵活的发货通知处理。
Showing 19 changed files with 1140 additions and 2 deletions
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/wm/salesnotice/MesWmSalesNoticeController.java 0 → 100644
  1 +package cn.iocoder.yudao.module.mes.controller.admin.wm.salesnotice;
  2 +
  3 +import cn.hutool.core.collection.CollUtil;
  4 +import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog;
  5 +import cn.iocoder.yudao.framework.common.pojo.CommonResult;
  6 +import cn.iocoder.yudao.framework.common.pojo.PageParam;
  7 +import cn.iocoder.yudao.framework.common.pojo.PageResult;
  8 +import cn.iocoder.yudao.framework.common.util.collection.MapUtils;
  9 +import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
  10 +import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
  11 +import cn.iocoder.yudao.module.mes.controller.admin.wm.salesnotice.vo.MesWmSalesNoticePageReqVO;
  12 +import cn.iocoder.yudao.module.mes.controller.admin.wm.salesnotice.vo.MesWmSalesNoticeRespVO;
  13 +import cn.iocoder.yudao.module.mes.controller.admin.wm.salesnotice.vo.MesWmSalesNoticeSaveReqVO;
  14 +import cn.iocoder.yudao.module.mes.dal.dataobject.md.client.MesMdClientDO;
  15 +import cn.iocoder.yudao.module.mes.dal.dataobject.wm.salesnotice.MesWmSalesNoticeDO;
  16 +import cn.iocoder.yudao.module.mes.service.md.client.MesMdClientService;
  17 +import cn.iocoder.yudao.module.mes.service.wm.salesnotice.MesWmSalesNoticeService;
  18 +import io.swagger.v3.oas.annotations.Operation;
  19 +import io.swagger.v3.oas.annotations.Parameter;
  20 +import io.swagger.v3.oas.annotations.tags.Tag;
  21 +import jakarta.annotation.Resource;
  22 +import jakarta.servlet.http.HttpServletResponse;
  23 +import jakarta.validation.Valid;
  24 +import org.springframework.security.access.prepost.PreAuthorize;
  25 +import org.springframework.validation.annotation.Validated;
  26 +import org.springframework.web.bind.annotation.*;
  27 +
  28 +import java.io.IOException;
  29 +import java.util.Collections;
  30 +import java.util.List;
  31 +import java.util.Map;
  32 +
  33 +import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.EXPORT;
  34 +import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
  35 +import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet;
  36 +
  37 +@Tag(name = "管理后台 - MES 发货通知单")
  38 +@RestController
  39 +@RequestMapping("/mes/wm/sales-notice")
  40 +@Validated
  41 +public class MesWmSalesNoticeController {
  42 +
  43 + @Resource
  44 + private MesWmSalesNoticeService salesNoticeService;
  45 +
  46 + @Resource
  47 + private MesMdClientService clientService;
  48 +
  49 + @PostMapping("/create")
  50 + @Operation(summary = "创建发货通知单")
  51 + @PreAuthorize("@ss.hasPermission('mes:wm-sales-notice:create')")
  52 + public CommonResult<Long> createSalesNotice(@Valid @RequestBody MesWmSalesNoticeSaveReqVO createReqVO) {
  53 + return success(salesNoticeService.createSalesNotice(createReqVO));
  54 + }
  55 +
  56 + @PutMapping("/update")
  57 + @Operation(summary = "修改发货通知单")
  58 + @PreAuthorize("@ss.hasPermission('mes:wm-sales-notice:update')")
  59 + public CommonResult<Boolean> updateSalesNotice(@Valid @RequestBody MesWmSalesNoticeSaveReqVO updateReqVO) {
  60 + salesNoticeService.updateSalesNotice(updateReqVO);
  61 + return success(true);
  62 + }
  63 +
  64 + @DeleteMapping("/delete")
  65 + @Operation(summary = "删除发货通知单")
  66 + @Parameter(name = "id", description = "编号", required = true)
  67 + @PreAuthorize("@ss.hasPermission('mes:wm-sales-notice:delete')")
  68 + public CommonResult<Boolean> deleteSalesNotice(@RequestParam("id") Long id) {
  69 + salesNoticeService.deleteSalesNotice(id);
  70 + return success(true);
  71 + }
  72 +
  73 + @GetMapping("/get")
  74 + @Operation(summary = "获得发货通知单")
  75 + @Parameter(name = "id", description = "编号", required = true, example = "1024")
  76 + @PreAuthorize("@ss.hasPermission('mes:wm-sales-notice:query')")
  77 + public CommonResult<MesWmSalesNoticeRespVO> getSalesNotice(@RequestParam("id") Long id) {
  78 + MesWmSalesNoticeDO notice = salesNoticeService.getSalesNotice(id);
  79 + if (notice == null) {
  80 + return success(null);
  81 + }
  82 + return success(buildRespVOList(Collections.singletonList(notice)).get(0));
  83 + }
  84 +
  85 + @GetMapping("/page")
  86 + @Operation(summary = "获得发货通知单分页")
  87 + @PreAuthorize("@ss.hasPermission('mes:wm-sales-notice:query')")
  88 + public CommonResult<PageResult<MesWmSalesNoticeRespVO>> getSalesNoticePage(
  89 + @Valid MesWmSalesNoticePageReqVO pageReqVO) {
  90 + PageResult<MesWmSalesNoticeDO> pageResult = salesNoticeService.getSalesNoticePage(pageReqVO);
  91 + return success(new PageResult<>(buildRespVOList(pageResult.getList()), pageResult.getTotal()));
  92 + }
  93 +
  94 + @GetMapping("/export-excel")
  95 + @Operation(summary = "导出发货通知单 Excel")
  96 + @PreAuthorize("@ss.hasPermission('mes:wm-sales-notice:export')")
  97 + @ApiAccessLog(operateType = EXPORT)
  98 + public void exportSalesNoticeExcel(@Valid MesWmSalesNoticePageReqVO pageReqVO,
  99 + HttpServletResponse response) throws IOException {
  100 + pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
  101 + PageResult<MesWmSalesNoticeDO> pageResult = salesNoticeService.getSalesNoticePage(pageReqVO);
  102 + ExcelUtils.write(response, "发货通知单.xls", "数据", MesWmSalesNoticeRespVO.class,
  103 + buildRespVOList(pageResult.getList()));
  104 + }
  105 +
  106 + @PutMapping("/submit")
  107 + @Operation(summary = "提交发货通知单")
  108 + @Parameter(name = "id", description = "编号", required = true)
  109 + @PreAuthorize("@ss.hasPermission('mes:wm-sales-notice:update')")
  110 + public CommonResult<Boolean> submitSalesNotice(@RequestParam("id") Long id) {
  111 + salesNoticeService.submitSalesNotice(id);
  112 + return success(true);
  113 + }
  114 +
  115 + @GetMapping("/simple-list")
  116 + @Operation(summary = "获得发货通知单精简列表")
  117 + @Parameter(name = "status", description = "状态", example = "1")
  118 + public CommonResult<List<MesWmSalesNoticeRespVO>> getSalesNoticeSimpleList(
  119 + @RequestParam(value = "status", required = false) Integer status) {
  120 + List<MesWmSalesNoticeDO> list = salesNoticeService.getSalesNoticeListByStatus(status);
  121 + return success(buildRespVOList(list));
  122 + }
  123 +
  124 + // ==================== 拼接 VO ====================
  125 +
  126 + private List<MesWmSalesNoticeRespVO> buildRespVOList(List<MesWmSalesNoticeDO> list) {
  127 + if (CollUtil.isEmpty(list)) {
  128 + return Collections.emptyList();
  129 + }
  130 + // 1. 获得关联数据
  131 + Map<Long, MesMdClientDO> clientMap = clientService.getClientMap(
  132 + convertSet(list, MesWmSalesNoticeDO::getClientId));
  133 + // 2. 构建结果
  134 + return BeanUtils.toBean(list, MesWmSalesNoticeRespVO.class, vo -> {
  135 + MapUtils.findAndThen(clientMap, vo.getClientId(), client ->
  136 + vo.setClientCode(client.getCode()).setClientName(client.getName()));
  137 + });
  138 + }
  139 +
  140 +}
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/wm/salesnotice/MesWmSalesNoticeLineController.java 0 → 100644
  1 +package cn.iocoder.yudao.module.mes.controller.admin.wm.salesnotice;
  2 +
  3 +import cn.hutool.core.collection.CollUtil;
  4 +import cn.iocoder.yudao.framework.common.pojo.CommonResult;
  5 +import cn.iocoder.yudao.framework.common.pojo.PageResult;
  6 +import cn.iocoder.yudao.framework.common.util.collection.MapUtils;
  7 +import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
  8 +import cn.iocoder.yudao.module.mes.controller.admin.wm.salesnotice.vo.line.MesWmSalesNoticeLinePageReqVO;
  9 +import cn.iocoder.yudao.module.mes.controller.admin.wm.salesnotice.vo.line.MesWmSalesNoticeLineRespVO;
  10 +import cn.iocoder.yudao.module.mes.controller.admin.wm.salesnotice.vo.line.MesWmSalesNoticeLineSaveReqVO;
  11 +import cn.iocoder.yudao.module.mes.dal.dataobject.md.item.MesMdItemDO;
  12 +import cn.iocoder.yudao.module.mes.dal.dataobject.md.unitmeasure.MesMdUnitMeasureDO;
  13 +import cn.iocoder.yudao.module.mes.dal.dataobject.wm.salesnotice.MesWmSalesNoticeLineDO;
  14 +import cn.iocoder.yudao.module.mes.service.md.item.MesMdItemService;
  15 +import cn.iocoder.yudao.module.mes.service.md.unitmeasure.MesMdUnitMeasureService;
  16 +import cn.iocoder.yudao.module.mes.service.wm.salesnotice.MesWmSalesNoticeLineService;
  17 +import io.swagger.v3.oas.annotations.Operation;
  18 +import io.swagger.v3.oas.annotations.Parameter;
  19 +import io.swagger.v3.oas.annotations.tags.Tag;
  20 +import jakarta.annotation.Resource;
  21 +import jakarta.validation.Valid;
  22 +import org.springframework.security.access.prepost.PreAuthorize;
  23 +import org.springframework.validation.annotation.Validated;
  24 +import org.springframework.web.bind.annotation.*;
  25 +
  26 +import java.util.Collections;
  27 +import java.util.List;
  28 +import java.util.Map;
  29 +
  30 +import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
  31 +import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet;
  32 +
  33 +@Tag(name = "管理后台 - MES 发货通知单行")
  34 +@RestController
  35 +@RequestMapping("/mes/wm/sales-notice-line")
  36 +@Validated
  37 +public class MesWmSalesNoticeLineController {
  38 +
  39 + @Resource
  40 + private MesWmSalesNoticeLineService salesNoticeLineService;
  41 +
  42 + @Resource
  43 + private MesMdItemService itemService;
  44 +
  45 + @Resource
  46 + private MesMdUnitMeasureService unitMeasureService;
  47 +
  48 + @PostMapping("/create")
  49 + @Operation(summary = "创建发货通知单行")
  50 + @PreAuthorize("@ss.hasPermission('mes:wm-sales-notice:create')")
  51 + public CommonResult<Long> createSalesNoticeLine(@Valid @RequestBody MesWmSalesNoticeLineSaveReqVO createReqVO) {
  52 + return success(salesNoticeLineService.createSalesNoticeLine(createReqVO));
  53 + }
  54 +
  55 + @PutMapping("/update")
  56 + @Operation(summary = "修改发货通知单行")
  57 + @PreAuthorize("@ss.hasPermission('mes:wm-sales-notice:update')")
  58 + public CommonResult<Boolean> updateSalesNoticeLine(@Valid @RequestBody MesWmSalesNoticeLineSaveReqVO updateReqVO) {
  59 + salesNoticeLineService.updateSalesNoticeLine(updateReqVO);
  60 + return success(true);
  61 + }
  62 +
  63 + @DeleteMapping("/delete")
  64 + @Operation(summary = "删除发货通知单行")
  65 + @Parameter(name = "id", description = "编号", required = true)
  66 + @PreAuthorize("@ss.hasPermission('mes:wm-sales-notice:delete')")
  67 + public CommonResult<Boolean> deleteSalesNoticeLine(@RequestParam("id") Long id) {
  68 + salesNoticeLineService.deleteSalesNoticeLine(id);
  69 + return success(true);
  70 + }
  71 +
  72 + @GetMapping("/get")
  73 + @Operation(summary = "获得发货通知单行")
  74 + @Parameter(name = "id", description = "编号", required = true, example = "1024")
  75 + @PreAuthorize("@ss.hasPermission('mes:wm-sales-notice:query')")
  76 + public CommonResult<MesWmSalesNoticeLineRespVO> getSalesNoticeLine(@RequestParam("id") Long id) {
  77 + MesWmSalesNoticeLineDO line = salesNoticeLineService.getSalesNoticeLine(id);
  78 + if (line == null) {
  79 + return success(null);
  80 + }
  81 + return success(buildRespVOList(Collections.singletonList(line)).get(0));
  82 + }
  83 +
  84 + @GetMapping("/page")
  85 + @Operation(summary = "获得发货通知单行分页")
  86 + @PreAuthorize("@ss.hasPermission('mes:wm-sales-notice:query')")
  87 + public CommonResult<PageResult<MesWmSalesNoticeLineRespVO>> getSalesNoticeLinePage(
  88 + @Valid MesWmSalesNoticeLinePageReqVO pageReqVO) {
  89 + PageResult<MesWmSalesNoticeLineDO> pageResult = salesNoticeLineService.getSalesNoticeLinePage(pageReqVO);
  90 + return success(new PageResult<>(buildRespVOList(pageResult.getList()), pageResult.getTotal()));
  91 + }
  92 +
  93 + // ==================== 拼接 VO ====================
  94 +
  95 + private List<MesWmSalesNoticeLineRespVO> buildRespVOList(List<MesWmSalesNoticeLineDO> list) {
  96 + if (CollUtil.isEmpty(list)) {
  97 + return Collections.emptyList();
  98 + }
  99 + // 1. 获得关联数据
  100 + Map<Long, MesMdItemDO> itemMap = itemService.getItemMap(
  101 + convertSet(list, MesWmSalesNoticeLineDO::getItemId));
  102 + Map<Long, MesMdUnitMeasureDO> unitMeasureMap = unitMeasureService.getUnitMeasureMap(
  103 + convertSet(itemMap.values(), MesMdItemDO::getUnitMeasureId));
  104 + // 2. 构建结果
  105 + return BeanUtils.toBean(list, MesWmSalesNoticeLineRespVO.class, vo -> {
  106 + MapUtils.findAndThen(itemMap, vo.getItemId(), item -> {
  107 + vo.setItemCode(item.getCode()).setItemName(item.getName()).setSpecification(item.getSpecification());
  108 + MapUtils.findAndThen(unitMeasureMap, item.getUnitMeasureId(),
  109 + unitMeasure -> vo.setUnitMeasureName(unitMeasure.getName()));
  110 + });
  111 + });
  112 + }
  113 +
  114 +}
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/wm/salesnotice/vo/MesWmSalesNoticePageReqVO.java 0 → 100644
  1 +package cn.iocoder.yudao.module.mes.controller.admin.wm.salesnotice.vo;
  2 +
  3 +import cn.iocoder.yudao.framework.common.pojo.PageParam;
  4 +import io.swagger.v3.oas.annotations.media.Schema;
  5 +import lombok.Data;
  6 +import lombok.EqualsAndHashCode;
  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 +
  14 +@Schema(description = "管理后台 - MES 发货通知单分页 Request VO")
  15 +@Data
  16 +@EqualsAndHashCode(callSuper = true)
  17 +@ToString(callSuper = true)
  18 +public class MesWmSalesNoticePageReqVO extends PageParam {
  19 +
  20 + @Schema(description = "通知单编码", example = "SN202603010001")
  21 + private String noticeCode;
  22 +
  23 + @Schema(description = "通知单名称", example = "测试发货通知")
  24 + private String noticeName;
  25 +
  26 + @Schema(description = "销售订单编号", example = "SO202603010001")
  27 + private String salesOrderCode;
  28 +
  29 + @Schema(description = "客户编号", example = "1")
  30 + private Long clientId;
  31 +
  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 +}
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/wm/salesnotice/vo/MesWmSalesNoticeRespVO.java 0 → 100644
  1 +package cn.iocoder.yudao.module.mes.controller.admin.wm.salesnotice.vo;
  2 +
  3 +import cn.idev.excel.annotation.ExcelIgnoreUnannotated;
  4 +import cn.idev.excel.annotation.ExcelProperty;
  5 +import io.swagger.v3.oas.annotations.media.Schema;
  6 +import lombok.Data;
  7 +
  8 +import java.time.LocalDateTime;
  9 +
  10 +@Schema(description = "管理后台 - MES 发货通知单 Response VO")
  11 +@Data
  12 +@ExcelIgnoreUnannotated
  13 +public class MesWmSalesNoticeRespVO {
  14 +
  15 + @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
  16 + @ExcelProperty("编号")
  17 + private Long id;
  18 +
  19 + @Schema(description = "通知单编码", requiredMode = Schema.RequiredMode.REQUIRED, example = "SN202603010001")
  20 + @ExcelProperty("通知单编码")
  21 + private String noticeCode;
  22 +
  23 + @Schema(description = "通知单名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "测试发货通知")
  24 + @ExcelProperty("通知单名称")
  25 + private String noticeName;
  26 +
  27 + @Schema(description = "销售订单编号", example = "SO202603010001")
  28 + @ExcelProperty("销售订单编号")
  29 + private String salesOrderCode;
  30 +
  31 + @Schema(description = "客户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
  32 + private Long clientId;
  33 +
  34 + @Schema(description = "客户编码", example = "C001")
  35 + @ExcelProperty("客户编码")
  36 + private String clientCode;
  37 +
  38 + @Schema(description = "客户名称", example = "某客户")
  39 + @ExcelProperty("客户名称")
  40 + private String clientName;
  41 +
  42 + @Schema(description = "发货日期", requiredMode = Schema.RequiredMode.REQUIRED)
  43 + @ExcelProperty("发货日期")
  44 + private LocalDateTime salesDate;
  45 +
  46 + @Schema(description = "收货人", example = "张三")
  47 + @ExcelProperty("收货人")
  48 + private String recipientName;
  49 +
  50 + @Schema(description = "联系方式", example = "13800138000")
  51 + @ExcelProperty("联系方式")
  52 + private String recipientTelephone;
  53 +
  54 + @Schema(description = "收货地址", example = "北京市朝阳区xxx")
  55 + @ExcelProperty("收货地址")
  56 + private String recipientAddress;
  57 +
  58 + @Schema(description = "状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "0")
  59 + @ExcelProperty("状态")
  60 + private Integer status;
  61 +
  62 + @Schema(description = "备注", example = "备注")
  63 + @ExcelProperty("备注")
  64 + private String remark;
  65 +
  66 + @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
  67 + @ExcelProperty("创建时间")
  68 + private LocalDateTime createTime;
  69 +
  70 +}
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/wm/salesnotice/vo/MesWmSalesNoticeSaveReqVO.java 0 → 100644
  1 +package cn.iocoder.yudao.module.mes.controller.admin.wm.salesnotice.vo;
  2 +
  3 +import io.swagger.v3.oas.annotations.media.Schema;
  4 +import jakarta.validation.constraints.NotEmpty;
  5 +import jakarta.validation.constraints.NotNull;
  6 +import lombok.Data;
  7 +
  8 +import java.time.LocalDateTime;
  9 +
  10 +@Schema(description = "管理后台 - MES 发货通知单新增/修改 Request VO")
  11 +@Data
  12 +public class MesWmSalesNoticeSaveReqVO {
  13 +
  14 + @Schema(description = "编号", example = "1024")
  15 + private Long id;
  16 +
  17 + @Schema(description = "通知单编码", requiredMode = Schema.RequiredMode.REQUIRED, example = "SN202603010001")
  18 + @NotEmpty(message = "通知单编码不能为空")
  19 + private String noticeCode;
  20 +
  21 + @Schema(description = "通知单名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "测试发货通知")
  22 + @NotEmpty(message = "通知单名称不能为空")
  23 + private String noticeName;
  24 +
  25 + @Schema(description = "销售订单编号", example = "SO202603010001")
  26 + private String salesOrderCode;
  27 +
  28 + @Schema(description = "客户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
  29 + @NotNull(message = "客户编号不能为空")
  30 + private Long clientId;
  31 +
  32 + @Schema(description = "发货日期", requiredMode = Schema.RequiredMode.REQUIRED)
  33 + @NotNull(message = "发货日期不能为空")
  34 + private LocalDateTime salesDate;
  35 +
  36 + @Schema(description = "收货人", example = "张三")
  37 + private String recipientName;
  38 +
  39 + @Schema(description = "联系方式", example = "13800138000")
  40 + private String recipientTelephone;
  41 +
  42 + @Schema(description = "收货地址", example = "北京市朝阳区xxx")
  43 + private String recipientAddress;
  44 +
  45 + @Schema(description = "备注", example = "备注")
  46 + private String remark;
  47 +
  48 +}
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/wm/salesnotice/vo/line/MesWmSalesNoticeLinePageReqVO.java 0 → 100644
  1 +package cn.iocoder.yudao.module.mes.controller.admin.wm.salesnotice.vo.line;
  2 +
  3 +import cn.iocoder.yudao.framework.common.pojo.PageParam;
  4 +import io.swagger.v3.oas.annotations.media.Schema;
  5 +import lombok.Data;
  6 +import lombok.EqualsAndHashCode;
  7 +import lombok.ToString;
  8 +
  9 +@Schema(description = "管理后台 - MES 发货通知单行分页 Request VO")
  10 +@Data
  11 +@EqualsAndHashCode(callSuper = true)
  12 +@ToString(callSuper = true)
  13 +public class MesWmSalesNoticeLinePageReqVO extends PageParam {
  14 +
  15 + @Schema(description = "发货通知单编号", example = "1")
  16 + private Long noticeId;
  17 +
  18 +}
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/wm/salesnotice/vo/line/MesWmSalesNoticeLineRespVO.java 0 → 100644
  1 +package cn.iocoder.yudao.module.mes.controller.admin.wm.salesnotice.vo.line;
  2 +
  3 +import io.swagger.v3.oas.annotations.media.Schema;
  4 +import lombok.Data;
  5 +
  6 +import java.math.BigDecimal;
  7 +import java.time.LocalDateTime;
  8 +
  9 +@Schema(description = "管理后台 - MES 发货通知单行 Response VO")
  10 +@Data
  11 +public class MesWmSalesNoticeLineRespVO {
  12 +
  13 + @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
  14 + private Long id;
  15 +
  16 + @Schema(description = "发货通知单编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
  17 + private Long noticeId;
  18 +
  19 + @Schema(description = "物料编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
  20 + private Long itemId;
  21 +
  22 + @Schema(description = "物料编码", example = "M001")
  23 + private String itemCode;
  24 +
  25 + @Schema(description = "物料名称", example = "产品A")
  26 + private String itemName;
  27 +
  28 + @Schema(description = "规格型号", example = "10mm*100mm")
  29 + private String specification;
  30 +
  31 + @Schema(description = "计量单位名称", example = "个")
  32 + private String unitMeasureName;
  33 +
  34 + @Schema(description = "批次编号", example = "1")
  35 + private Long batchId;
  36 +
  37 + @Schema(description = "批次号", example = "BATCH001")
  38 + private String batchCode;
  39 +
  40 + @Schema(description = "发货数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "100.00")
  41 + private BigDecimal quantity;
  42 +
  43 + @Schema(description = "是否检验", requiredMode = Schema.RequiredMode.REQUIRED, example = "true")
  44 + private Boolean oqcCheck;
  45 +
  46 + @Schema(description = "备注", example = "备注")
  47 + private String remark;
  48 +
  49 + @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
  50 + private LocalDateTime createTime;
  51 +
  52 +}
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/wm/salesnotice/vo/line/MesWmSalesNoticeLineSaveReqVO.java 0 → 100644
  1 +package cn.iocoder.yudao.module.mes.controller.admin.wm.salesnotice.vo.line;
  2 +
  3 +import io.swagger.v3.oas.annotations.media.Schema;
  4 +import jakarta.validation.constraints.DecimalMin;
  5 +import jakarta.validation.constraints.NotNull;
  6 +import lombok.Data;
  7 +
  8 +import java.math.BigDecimal;
  9 +
  10 +@Schema(description = "管理后台 - MES 发货通知单行新增/修改 Request VO")
  11 +@Data
  12 +public class MesWmSalesNoticeLineSaveReqVO {
  13 +
  14 + @Schema(description = "编号", example = "1024")
  15 + private Long id;
  16 +
  17 + @Schema(description = "发货通知单编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
  18 + @NotNull(message = "发货通知单编号不能为空")
  19 + private Long noticeId;
  20 +
  21 + @Schema(description = "物料编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
  22 + @NotNull(message = "物料编号不能为空")
  23 + private Long itemId;
  24 +
  25 + @Schema(description = "批次编号", example = "1")
  26 + private Long batchId;
  27 +
  28 + @Schema(description = "批次号", example = "BATCH001")
  29 + private String batchCode;
  30 +
  31 + @Schema(description = "发货数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "100.00")
  32 + @NotNull(message = "发货数量不能为空")
  33 + @DecimalMin(value = "0.01", message = "发货数量必须大于 0")
  34 + private BigDecimal quantity;
  35 +
  36 + @Schema(description = "是否检验", requiredMode = Schema.RequiredMode.REQUIRED, example = "true")
  37 + @NotNull(message = "是否检验不能为空")
  38 + private Boolean oqcCheck;
  39 +
  40 + @Schema(description = "备注", example = "备注")
  41 + private String remark;
  42 +
  43 +}
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/dal/dataobject/wm/salesnotice/MesWmSalesNoticeDO.java 0 → 100644
  1 +package cn.iocoder.yudao.module.mes.dal.dataobject.wm.salesnotice;
  2 +
  3 +import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
  4 +import cn.iocoder.yudao.module.mes.dal.dataobject.md.client.MesMdClientDO;
  5 +import com.baomidou.mybatisplus.annotation.KeySequence;
  6 +import com.baomidou.mybatisplus.annotation.TableId;
  7 +import com.baomidou.mybatisplus.annotation.TableName;
  8 +import lombok.*;
  9 +
  10 +import java.time.LocalDateTime;
  11 +
  12 +/**
  13 + * MES 发货通知单 DO
  14 + */
  15 +@TableName("mes_wm_sales_notice")
  16 +@KeySequence("mes_wm_sales_notice_seq")
  17 +@Data
  18 +@EqualsAndHashCode(callSuper = true)
  19 +@ToString(callSuper = true)
  20 +@Builder
  21 +@NoArgsConstructor
  22 +@AllArgsConstructor
  23 +public class MesWmSalesNoticeDO extends BaseDO {
  24 +
  25 + /**
  26 + * 编号
  27 + */
  28 + @TableId
  29 + private Long id;
  30 + /**
  31 + * 通知单编码
  32 + */
  33 + private String noticeCode;
  34 + /**
  35 + * 通知单名称
  36 + */
  37 + private String noticeName;
  38 + /**
  39 + * 销售订单编号
  40 + */
  41 + private String salesOrderCode;
  42 + /**
  43 + * 客户编号
  44 + *
  45 + * 关联 {@link MesMdClientDO#getId()}
  46 + */
  47 + private Long clientId;
  48 + /**
  49 + * 发货日期
  50 + */
  51 + private LocalDateTime salesDate;
  52 + /**
  53 + * 收货人
  54 + */
  55 + private String recipientName;
  56 + /**
  57 + * 联系方式
  58 + */
  59 + private String recipientTelephone;
  60 + /**
  61 + * 收货地址
  62 + */
  63 + private String recipientAddress;
  64 + /**
  65 + * 状态
  66 + *
  67 + * 0-草稿,1-已提交
  68 + */
  69 + private Integer status;
  70 + /**
  71 + * 备注
  72 + */
  73 + private String remark;
  74 +
  75 +}
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/dal/dataobject/wm/salesnotice/MesWmSalesNoticeLineDO.java 0 → 100644
  1 +package cn.iocoder.yudao.module.mes.dal.dataobject.wm.salesnotice;
  2 +
  3 +import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
  4 +import cn.iocoder.yudao.module.mes.dal.dataobject.md.item.MesMdItemDO;
  5 +import com.baomidou.mybatisplus.annotation.KeySequence;
  6 +import com.baomidou.mybatisplus.annotation.TableId;
  7 +import com.baomidou.mybatisplus.annotation.TableName;
  8 +import lombok.*;
  9 +
  10 +import java.math.BigDecimal;
  11 +
  12 +/**
  13 + * MES 发货通知单行 DO
  14 + */
  15 +@TableName("mes_wm_sales_notice_line")
  16 +@KeySequence("mes_wm_sales_notice_line_seq")
  17 +@Data
  18 +@EqualsAndHashCode(callSuper = true)
  19 +@ToString(callSuper = true)
  20 +@Builder
  21 +@NoArgsConstructor
  22 +@AllArgsConstructor
  23 +public class MesWmSalesNoticeLineDO extends BaseDO {
  24 +
  25 + /**
  26 + * 编号
  27 + */
  28 + @TableId
  29 + private Long id;
  30 + /**
  31 + * 发货通知单编号
  32 + *
  33 + * 关联 {@link MesWmSalesNoticeDO#getId()}
  34 + */
  35 + private Long noticeId;
  36 + /**
  37 + * 物料编号
  38 + *
  39 + * 关联 {@link MesMdItemDO#getId()}
  40 + */
  41 + private Long itemId;
  42 + /**
  43 + * 批次编号
  44 + */
  45 + private Long batchId;
  46 + /**
  47 + * 批次号
  48 + */
  49 + private String batchCode;
  50 + /**
  51 + * 发货数量
  52 + */
  53 + private BigDecimal quantity;
  54 + /**
  55 + * 是否检验
  56 + */
  57 + private Boolean oqcCheck;
  58 + /**
  59 + * 备注
  60 + */
  61 + private String remark;
  62 +
  63 +}
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/dal/mysql/wm/productsales/MesWmProductSalesMapper.java
@@ -21,7 +21,7 @@ public interface MesWmProductSalesMapper extends BaseMapperX&lt;MesWmProductSalesDO @@ -21,7 +21,7 @@ public interface MesWmProductSalesMapper extends BaseMapperX&lt;MesWmProductSalesDO
21 .likeIfPresent(MesWmProductSalesDO::getName, reqVO.getName()) 21 .likeIfPresent(MesWmProductSalesDO::getName, reqVO.getName())
22 .eqIfPresent(MesWmProductSalesDO::getClientId, reqVO.getClientId()) 22 .eqIfPresent(MesWmProductSalesDO::getClientId, reqVO.getClientId())
23 .eqIfPresent(MesWmProductSalesDO::getStatus, reqVO.getStatus()) 23 .eqIfPresent(MesWmProductSalesDO::getStatus, reqVO.getStatus())
24 - .betweenIfPresent(MesWmProductSalesDO::getShipmentDate, reqVO.getShipmentDate()) 24 + .betweenIfPresent(MesWmProductSalesDO::getSalesDate, reqVO.getShipmentDate())
25 .orderByDesc(MesWmProductSalesDO::getId)); 25 .orderByDesc(MesWmProductSalesDO::getId));
26 } 26 }
27 27
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/dal/mysql/wm/salesnotice/MesWmSalesNoticeLineMapper.java 0 → 100644
  1 +package cn.iocoder.yudao.module.mes.dal.mysql.wm.salesnotice;
  2 +
  3 +import cn.iocoder.yudao.framework.common.pojo.PageResult;
  4 +import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
  5 +import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
  6 +import cn.iocoder.yudao.module.mes.controller.admin.wm.salesnotice.vo.line.MesWmSalesNoticeLinePageReqVO;
  7 +import cn.iocoder.yudao.module.mes.dal.dataobject.wm.salesnotice.MesWmSalesNoticeLineDO;
  8 +import org.apache.ibatis.annotations.Mapper;
  9 +
  10 +import java.util.List;
  11 +
  12 +/**
  13 + * MES 发货通知单行 Mapper
  14 + */
  15 +@Mapper
  16 +public interface MesWmSalesNoticeLineMapper extends BaseMapperX<MesWmSalesNoticeLineDO> {
  17 +
  18 + default PageResult<MesWmSalesNoticeLineDO> selectPage(MesWmSalesNoticeLinePageReqVO reqVO) {
  19 + return selectPage(reqVO, new LambdaQueryWrapperX<MesWmSalesNoticeLineDO>()
  20 + .eqIfPresent(MesWmSalesNoticeLineDO::getNoticeId, reqVO.getNoticeId())
  21 + .orderByDesc(MesWmSalesNoticeLineDO::getId));
  22 + }
  23 +
  24 + default List<MesWmSalesNoticeLineDO> selectListByNoticeId(Long noticeId) {
  25 + return selectList(MesWmSalesNoticeLineDO::getNoticeId, noticeId);
  26 + }
  27 +
  28 + default void deleteByNoticeId(Long noticeId) {
  29 + delete(MesWmSalesNoticeLineDO::getNoticeId, noticeId);
  30 + }
  31 +
  32 +}
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/dal/mysql/wm/salesnotice/MesWmSalesNoticeMapper.java 0 → 100644
  1 +package cn.iocoder.yudao.module.mes.dal.mysql.wm.salesnotice;
  2 +
  3 +import cn.iocoder.yudao.framework.common.pojo.PageResult;
  4 +import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
  5 +import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
  6 +import cn.iocoder.yudao.module.mes.controller.admin.wm.salesnotice.vo.MesWmSalesNoticePageReqVO;
  7 +import cn.iocoder.yudao.module.mes.dal.dataobject.wm.salesnotice.MesWmSalesNoticeDO;
  8 +import org.apache.ibatis.annotations.Mapper;
  9 +
  10 +import java.util.List;
  11 +
  12 +/**
  13 + * MES 发货通知单 Mapper
  14 + */
  15 +@Mapper
  16 +public interface MesWmSalesNoticeMapper extends BaseMapperX<MesWmSalesNoticeDO> {
  17 +
  18 + default PageResult<MesWmSalesNoticeDO> selectPage(MesWmSalesNoticePageReqVO reqVO) {
  19 + return selectPage(reqVO, new LambdaQueryWrapperX<MesWmSalesNoticeDO>()
  20 + .likeIfPresent(MesWmSalesNoticeDO::getNoticeCode, reqVO.getNoticeCode())
  21 + .likeIfPresent(MesWmSalesNoticeDO::getNoticeName, reqVO.getNoticeName())
  22 + .likeIfPresent(MesWmSalesNoticeDO::getSalesOrderCode, reqVO.getSalesOrderCode())
  23 + .eqIfPresent(MesWmSalesNoticeDO::getClientId, reqVO.getClientId())
  24 + .betweenIfPresent(MesWmSalesNoticeDO::getSalesDate, reqVO.getSalesDate())
  25 + .eqIfPresent(MesWmSalesNoticeDO::getStatus, reqVO.getStatus())
  26 + .orderByDesc(MesWmSalesNoticeDO::getId));
  27 + }
  28 +
  29 + default MesWmSalesNoticeDO selectByNoticeCode(String noticeCode) {
  30 + return selectOne(MesWmSalesNoticeDO::getNoticeCode, noticeCode);
  31 + }
  32 +
  33 + default List<MesWmSalesNoticeDO> selectListByStatus(Integer status) {
  34 + return selectList(MesWmSalesNoticeDO::getStatus, status);
  35 + }
  36 +
  37 +}
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/enums/ErrorCodeConstants.java
@@ -441,4 +441,12 @@ public interface ErrorCodeConstants { @@ -441,4 +441,12 @@ public interface ErrorCodeConstants {
441 ErrorCode WM_PRODUCT_SALES_DETAIL_NOT_EXISTS = new ErrorCode(1_040_714_011, "销售出库明细不存在"); 441 ErrorCode WM_PRODUCT_SALES_DETAIL_NOT_EXISTS = new ErrorCode(1_040_714_011, "销售出库明细不存在");
442 ErrorCode WM_PRODUCT_SALES_STOCK_INSUFFICIENT = new ErrorCode(1_040_714_012, "库存不足,无法拣货"); 442 ErrorCode WM_PRODUCT_SALES_STOCK_INSUFFICIENT = new ErrorCode(1_040_714_012, "库存不足,无法拣货");
443 443
  444 + // ========== MES 仓库管理-发货通知单(1-040-720-000) ==========
  445 + ErrorCode WM_SALES_NOTICE_NOT_EXISTS = new ErrorCode(1_040_720_000, "发货通知单不存在");
  446 + ErrorCode WM_SALES_NOTICE_CODE_DUPLICATE = new ErrorCode(1_040_720_001, "通知单编号重复");
  447 + ErrorCode WM_SALES_NOTICE_STATUS_NOT_ALLOW_DELETE = new ErrorCode(1_040_720_002, "单据状态不允许删除");
  448 + ErrorCode WM_SALES_NOTICE_STATUS_NOT_ALLOW_UPDATE = new ErrorCode(1_040_720_003, "单据状态不允许修改");
  449 + ErrorCode WM_SALES_NOTICE_LINE_NOT_EXISTS = new ErrorCode(1_040_720_010, "发货通知单行不存在");
  450 + ErrorCode WM_SALES_NOTICE_LINE_EMPTY = new ErrorCode(1_040_720_011, "发货通知单行为空,不能提交");
  451 +
444 } 452 }
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/wm/productsales/MesWmProductSalesLineServiceImpl.java
@@ -47,7 +47,6 @@ public class MesWmProductSalesLineServiceImpl implements MesWmProductSalesLineSe @@ -47,7 +47,6 @@ public class MesWmProductSalesLineServiceImpl implements MesWmProductSalesLineSe
47 47
48 // 新增 48 // 新增
49 MesWmProductSalesLineDO line = BeanUtils.toBean(createReqVO, MesWmProductSalesLineDO.class); 49 MesWmProductSalesLineDO line = BeanUtils.toBean(createReqVO, MesWmProductSalesLineDO.class);
50 - line.setPickedQuantity(BigDecimal.ZERO);  
51 productSalesLineMapper.insert(line); 50 productSalesLineMapper.insert(line);
52 return line.getId(); 51 return line.getId();
53 } 52 }
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/wm/salesnotice/MesWmSalesNoticeLineService.java 0 → 100644
  1 +package cn.iocoder.yudao.module.mes.service.wm.salesnotice;
  2 +
  3 +import cn.iocoder.yudao.framework.common.pojo.PageResult;
  4 +import cn.iocoder.yudao.module.mes.controller.admin.wm.salesnotice.vo.line.MesWmSalesNoticeLinePageReqVO;
  5 +import cn.iocoder.yudao.module.mes.controller.admin.wm.salesnotice.vo.line.MesWmSalesNoticeLineSaveReqVO;
  6 +import cn.iocoder.yudao.module.mes.dal.dataobject.wm.salesnotice.MesWmSalesNoticeLineDO;
  7 +import jakarta.validation.Valid;
  8 +
  9 +import java.util.List;
  10 +
  11 +/**
  12 + * MES 发货通知单行 Service 接口
  13 + */
  14 +public interface MesWmSalesNoticeLineService {
  15 +
  16 + /**
  17 + * 创建发货通知单行
  18 + *
  19 + * @param createReqVO 创建信息
  20 + * @return 编号
  21 + */
  22 + Long createSalesNoticeLine(@Valid MesWmSalesNoticeLineSaveReqVO createReqVO);
  23 +
  24 + /**
  25 + * 修改发货通知单行
  26 + *
  27 + * @param updateReqVO 修改信息
  28 + */
  29 + void updateSalesNoticeLine(@Valid MesWmSalesNoticeLineSaveReqVO updateReqVO);
  30 +
  31 + /**
  32 + * 删除发货通知单行
  33 + *
  34 + * @param id 编号
  35 + */
  36 + void deleteSalesNoticeLine(Long id);
  37 +
  38 + /**
  39 + * 获得发货通知单行
  40 + *
  41 + * @param id 编号
  42 + * @return 发货通知单行
  43 + */
  44 + MesWmSalesNoticeLineDO getSalesNoticeLine(Long id);
  45 +
  46 + /**
  47 + * 获得发货通知单行分页
  48 + *
  49 + * @param pageReqVO 分页参数
  50 + * @return 发货通知单行分页
  51 + */
  52 + PageResult<MesWmSalesNoticeLineDO> getSalesNoticeLinePage(MesWmSalesNoticeLinePageReqVO pageReqVO);
  53 +
  54 + /**
  55 + * 按通知单编号获得行列表
  56 + *
  57 + * @param noticeId 通知单编号
  58 + * @return 行列表
  59 + */
  60 + List<MesWmSalesNoticeLineDO> getSalesNoticeLineListByNoticeId(Long noticeId);
  61 +
  62 + /**
  63 + * 按通知单编号批量删除行
  64 + *
  65 + * @param noticeId 通知单编号
  66 + */
  67 + void deleteSalesNoticeLineByNoticeId(Long noticeId);
  68 +
  69 +}
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/wm/salesnotice/MesWmSalesNoticeLineServiceImpl.java 0 → 100644
  1 +package cn.iocoder.yudao.module.mes.service.wm.salesnotice;
  2 +
  3 +import cn.hutool.core.util.ObjUtil;
  4 +import cn.iocoder.yudao.framework.common.pojo.PageResult;
  5 +import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
  6 +import cn.iocoder.yudao.module.mes.controller.admin.wm.salesnotice.vo.line.MesWmSalesNoticeLinePageReqVO;
  7 +import cn.iocoder.yudao.module.mes.controller.admin.wm.salesnotice.vo.line.MesWmSalesNoticeLineSaveReqVO;
  8 +import cn.iocoder.yudao.module.mes.dal.dataobject.wm.salesnotice.MesWmSalesNoticeDO;
  9 +import cn.iocoder.yudao.module.mes.dal.dataobject.wm.salesnotice.MesWmSalesNoticeLineDO;
  10 +import cn.iocoder.yudao.module.mes.dal.mysql.wm.salesnotice.MesWmSalesNoticeLineMapper;
  11 +import jakarta.annotation.Resource;
  12 +import org.springframework.context.annotation.Lazy;
  13 +import org.springframework.stereotype.Service;
  14 +import org.springframework.validation.annotation.Validated;
  15 +
  16 +import java.util.List;
  17 +
  18 +import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
  19 +import static cn.iocoder.yudao.module.mes.enums.ErrorCodeConstants.*;
  20 +
  21 +/**
  22 + * MES 发货通知单行 Service 实现类
  23 + */
  24 +@Service
  25 +@Validated
  26 +public class MesWmSalesNoticeLineServiceImpl implements MesWmSalesNoticeLineService {
  27 +
  28 + @Resource
  29 + private MesWmSalesNoticeLineMapper salesNoticeLineMapper;
  30 +
  31 + @Resource
  32 + @Lazy
  33 + private MesWmSalesNoticeService salesNoticeService;
  34 +
  35 + @Override
  36 + public Long createSalesNoticeLine(MesWmSalesNoticeLineSaveReqVO createReqVO) {
  37 + // 校验父单据存在且为草稿状态
  38 + validateNoticeStatusDraft(createReqVO.getNoticeId());
  39 +
  40 + // 插入
  41 + MesWmSalesNoticeLineDO line = BeanUtils.toBean(createReqVO, MesWmSalesNoticeLineDO.class);
  42 + salesNoticeLineMapper.insert(line);
  43 + return line.getId();
  44 + }
  45 +
  46 + @Override
  47 + public void updateSalesNoticeLine(MesWmSalesNoticeLineSaveReqVO updateReqVO) {
  48 + // 校验存在
  49 + MesWmSalesNoticeLineDO line = validateSalesNoticeLineExists(updateReqVO.getId());
  50 + // 校验父单据存在且为草稿状态
  51 + validateNoticeStatusDraft(line.getNoticeId());
  52 +
  53 + // 更新
  54 + MesWmSalesNoticeLineDO updateObj = BeanUtils.toBean(updateReqVO, MesWmSalesNoticeLineDO.class);
  55 + salesNoticeLineMapper.updateById(updateObj);
  56 + }
  57 +
  58 + @Override
  59 + public void deleteSalesNoticeLine(Long id) {
  60 + // 校验存在
  61 + validateSalesNoticeLineExists(id);
  62 + // 删除
  63 + salesNoticeLineMapper.deleteById(id);
  64 + }
  65 +
  66 + @Override
  67 + public MesWmSalesNoticeLineDO getSalesNoticeLine(Long id) {
  68 + return salesNoticeLineMapper.selectById(id);
  69 + }
  70 +
  71 + @Override
  72 + public PageResult<MesWmSalesNoticeLineDO> getSalesNoticeLinePage(MesWmSalesNoticeLinePageReqVO pageReqVO) {
  73 + return salesNoticeLineMapper.selectPage(pageReqVO);
  74 + }
  75 +
  76 + @Override
  77 + public List<MesWmSalesNoticeLineDO> getSalesNoticeLineListByNoticeId(Long noticeId) {
  78 + return salesNoticeLineMapper.selectListByNoticeId(noticeId);
  79 + }
  80 +
  81 + @Override
  82 + public void deleteSalesNoticeLineByNoticeId(Long noticeId) {
  83 + salesNoticeLineMapper.deleteByNoticeId(noticeId);
  84 + }
  85 +
  86 + private MesWmSalesNoticeLineDO validateSalesNoticeLineExists(Long id) {
  87 + MesWmSalesNoticeLineDO line = salesNoticeLineMapper.selectById(id);
  88 + if (line == null) {
  89 + throw exception(WM_SALES_NOTICE_LINE_NOT_EXISTS);
  90 + }
  91 + return line;
  92 + }
  93 +
  94 + /**
  95 + * 校验父发货通知单存在且为草稿状态
  96 + */
  97 + private void validateNoticeStatusDraft(Long noticeId) {
  98 + MesWmSalesNoticeDO notice = salesNoticeService.getSalesNotice(noticeId);
  99 + if (notice == null) {
  100 + throw exception(WM_SALES_NOTICE_NOT_EXISTS);
  101 + }
  102 + if (ObjUtil.notEqual(0, notice.getStatus())) {
  103 + throw exception(WM_SALES_NOTICE_STATUS_NOT_ALLOW_UPDATE);
  104 + }
  105 + }
  106 +
  107 +}
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/wm/salesnotice/MesWmSalesNoticeService.java 0 → 100644
  1 +package cn.iocoder.yudao.module.mes.service.wm.salesnotice;
  2 +
  3 +import cn.iocoder.yudao.framework.common.pojo.PageResult;
  4 +import cn.iocoder.yudao.module.mes.controller.admin.wm.salesnotice.vo.MesWmSalesNoticePageReqVO;
  5 +import cn.iocoder.yudao.module.mes.controller.admin.wm.salesnotice.vo.MesWmSalesNoticeSaveReqVO;
  6 +import cn.iocoder.yudao.module.mes.dal.dataobject.wm.salesnotice.MesWmSalesNoticeDO;
  7 +import jakarta.validation.Valid;
  8 +
  9 +import java.util.Collection;
  10 +import java.util.List;
  11 +
  12 +/**
  13 + * MES 发货通知单 Service 接口
  14 + */
  15 +public interface MesWmSalesNoticeService {
  16 +
  17 + /**
  18 + * 创建发货通知单
  19 + *
  20 + * @param createReqVO 创建信息
  21 + * @return 编号
  22 + */
  23 + Long createSalesNotice(@Valid MesWmSalesNoticeSaveReqVO createReqVO);
  24 +
  25 + /**
  26 + * 修改发货通知单
  27 + *
  28 + * @param updateReqVO 修改信息
  29 + */
  30 + void updateSalesNotice(@Valid MesWmSalesNoticeSaveReqVO updateReqVO);
  31 +
  32 + /**
  33 + * 删除发货通知单
  34 + *
  35 + * @param id 编号
  36 + */
  37 + void deleteSalesNotice(Long id);
  38 +
  39 + /**
  40 + * 获得发货通知单
  41 + *
  42 + * @param id 编号
  43 + * @return 发货通知单
  44 + */
  45 + MesWmSalesNoticeDO getSalesNotice(Long id);
  46 +
  47 + /**
  48 + * 获得发货通知单分页
  49 + *
  50 + * @param pageReqVO 分页参数
  51 + * @return 发货通知单分页
  52 + */
  53 + PageResult<MesWmSalesNoticeDO> getSalesNoticePage(MesWmSalesNoticePageReqVO pageReqVO);
  54 +
  55 + /**
  56 + * 提交发货通知单
  57 + *
  58 + * @param id 编号
  59 + */
  60 + void submitSalesNotice(Long id);
  61 +
  62 + /**
  63 + * 获得发货通知单列表
  64 + *
  65 + * @param ids 编号列表
  66 + * @return 发货通知单列表
  67 + */
  68 + List<MesWmSalesNoticeDO> getSalesNoticeList(Collection<Long> ids);
  69 +
  70 + /**
  71 + * 按状态获得发货通知单列表
  72 + *
  73 + * @param status 状态
  74 + * @return 发货通知单列表
  75 + */
  76 + List<MesWmSalesNoticeDO> getSalesNoticeListByStatus(Integer status);
  77 +
  78 +}
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/wm/salesnotice/MesWmSalesNoticeServiceImpl.java 0 → 100644
  1 +package cn.iocoder.yudao.module.mes.service.wm.salesnotice;
  2 +
  3 +import cn.hutool.core.collection.CollUtil;
  4 +import cn.hutool.core.util.ObjUtil;
  5 +import cn.iocoder.yudao.framework.common.pojo.PageResult;
  6 +import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
  7 +import cn.iocoder.yudao.module.mes.controller.admin.wm.salesnotice.vo.MesWmSalesNoticePageReqVO;
  8 +import cn.iocoder.yudao.module.mes.controller.admin.wm.salesnotice.vo.MesWmSalesNoticeSaveReqVO;
  9 +import cn.iocoder.yudao.module.mes.dal.dataobject.wm.salesnotice.MesWmSalesNoticeDO;
  10 +import cn.iocoder.yudao.module.mes.dal.dataobject.wm.salesnotice.MesWmSalesNoticeLineDO;
  11 +import cn.iocoder.yudao.module.mes.dal.mysql.wm.salesnotice.MesWmSalesNoticeMapper;
  12 +import jakarta.annotation.Resource;
  13 +import lombok.extern.slf4j.Slf4j;
  14 +import org.springframework.stereotype.Service;
  15 +import org.springframework.transaction.annotation.Transactional;
  16 +import org.springframework.validation.annotation.Validated;
  17 +
  18 +import java.util.Collection;
  19 +import java.util.Collections;
  20 +import java.util.List;
  21 +
  22 +import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
  23 +import static cn.iocoder.yudao.module.mes.enums.ErrorCodeConstants.*;
  24 +
  25 +/**
  26 + * MES 发货通知单 Service 实现类
  27 + */
  28 +@Service
  29 +@Validated
  30 +@Slf4j
  31 +public class MesWmSalesNoticeServiceImpl implements MesWmSalesNoticeService {
  32 +
  33 + @Resource
  34 + private MesWmSalesNoticeMapper salesNoticeMapper;
  35 +
  36 + @Resource
  37 + private MesWmSalesNoticeLineService salesNoticeLineService;
  38 +
  39 + @Override
  40 + public Long createSalesNotice(MesWmSalesNoticeSaveReqVO createReqVO) {
  41 + // 校验编码唯一
  42 + validateNoticeCodeUnique(null, createReqVO.getNoticeCode());
  43 +
  44 + // 插入
  45 + MesWmSalesNoticeDO notice = BeanUtils.toBean(createReqVO, MesWmSalesNoticeDO.class);
  46 + notice.setStatus(0); // 草稿状态
  47 + salesNoticeMapper.insert(notice);
  48 + return notice.getId();
  49 + }
  50 +
  51 + @Override
  52 + public void updateSalesNotice(MesWmSalesNoticeSaveReqVO updateReqVO) {
  53 + // 校验存在 + 草稿状态
  54 + validateSalesNoticeExistsAndDraft(updateReqVO.getId());
  55 + // 校验编码唯一
  56 + validateNoticeCodeUnique(updateReqVO.getId(), updateReqVO.getNoticeCode());
  57 +
  58 + // 更新
  59 + MesWmSalesNoticeDO updateObj = BeanUtils.toBean(updateReqVO, MesWmSalesNoticeDO.class);
  60 + salesNoticeMapper.updateById(updateObj);
  61 + }
  62 +
  63 + @Override
  64 + @Transactional(rollbackFor = Exception.class)
  65 + public void deleteSalesNotice(Long id) {
  66 + // 校验存在 + 草稿状态
  67 + validateSalesNoticeExistsAndDraft(id);
  68 +
  69 + // 级联删除行
  70 + salesNoticeLineService.deleteSalesNoticeLineByNoticeId(id);
  71 + // 删除
  72 + salesNoticeMapper.deleteById(id);
  73 + }
  74 +
  75 + @Override
  76 + public MesWmSalesNoticeDO getSalesNotice(Long id) {
  77 + return salesNoticeMapper.selectById(id);
  78 + }
  79 +
  80 + @Override
  81 + public PageResult<MesWmSalesNoticeDO> getSalesNoticePage(MesWmSalesNoticePageReqVO pageReqVO) {
  82 + return salesNoticeMapper.selectPage(pageReqVO);
  83 + }
  84 +
  85 + @Override
  86 + @Transactional(rollbackFor = Exception.class)
  87 + public void submitSalesNotice(Long id) {
  88 + // 1.1 校验存在 + 草稿状态
  89 + validateSalesNoticeExistsAndDraft(id);
  90 + // 1.2 检查是否有行项目
  91 + List<MesWmSalesNoticeLineDO> lines = salesNoticeLineService.getSalesNoticeLineListByNoticeId(id);
  92 + if (CollUtil.isEmpty(lines)) {
  93 + throw exception(WM_SALES_NOTICE_LINE_EMPTY);
  94 + }
  95 +
  96 + // 2. 更新状态:草稿 → 已提交
  97 + salesNoticeMapper.updateById(new MesWmSalesNoticeDO()
  98 + .setId(id).setStatus(1));
  99 + }
  100 +
  101 + @Override
  102 + public List<MesWmSalesNoticeDO> getSalesNoticeList(Collection<Long> ids) {
  103 + if (CollUtil.isEmpty(ids)) {
  104 + return Collections.emptyList();
  105 + }
  106 + return salesNoticeMapper.selectByIds(ids);
  107 + }
  108 +
  109 + @Override
  110 + public List<MesWmSalesNoticeDO> getSalesNoticeListByStatus(Integer status) {
  111 + if (status == null) {
  112 + return salesNoticeMapper.selectList();
  113 + }
  114 + return salesNoticeMapper.selectListByStatus(status);
  115 + }
  116 +
  117 + private MesWmSalesNoticeDO validateSalesNoticeExists(Long id) {
  118 + MesWmSalesNoticeDO notice = salesNoticeMapper.selectById(id);
  119 + if (notice == null) {
  120 + throw exception(WM_SALES_NOTICE_NOT_EXISTS);
  121 + }
  122 + return notice;
  123 + }
  124 +
  125 + /**
  126 + * 校验发货通知单存在且为草稿状态
  127 + */
  128 + private MesWmSalesNoticeDO validateSalesNoticeExistsAndDraft(Long id) {
  129 + MesWmSalesNoticeDO notice = validateSalesNoticeExists(id);
  130 + if (ObjUtil.notEqual(0, notice.getStatus())) {
  131 + throw exception(WM_SALES_NOTICE_STATUS_NOT_ALLOW_DELETE);
  132 + }
  133 + return notice;
  134 + }
  135 +
  136 + private void validateNoticeCodeUnique(Long id, String noticeCode) {
  137 + MesWmSalesNoticeDO notice = salesNoticeMapper.selectByNoticeCode(noticeCode);
  138 + if (notice == null) {
  139 + return;
  140 + }
  141 + if (ObjUtil.notEqual(id, notice.getId())) {
  142 + throw exception(WM_SALES_NOTICE_CODE_DUPLICATE);
  143 + }
  144 + }
  145 +
  146 +}