From 6278616baab240f8e9a727c6c98529d106148f6e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B8=B8=E7=86=9F=E5=90=B4=E5=BD=A6=E7=A5=96?= Date: Wed, 2 Sep 2026 18:17:40 +0800 Subject: [PATCH] =?UTF-8?q?=E7=9B=98=E7=82=B9+=E5=85=B6=E4=BB=96=E5=8A=9F?= =?UTF-8?q?=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../HaiAnIssureNotifyController.java | 109 ++--------- ...IssueNotifyOrderMaterialListAllocData.java | 24 +++ .../HaiAnNoOrderMaterialAllocRequestData.java | 55 ++++++ ...AnSOIssueNotifyOrderMaterialListAlloc.java | 114 ++++++++++++ ...sueNotifyOrderMaterialListAllocMapper.java | 41 +++++ .../service/HaiAnIssureNotifyService.java | 97 +--------- ...ueNotifyOrderMaterialListAllocService.java | 19 ++ .../impl/HaiAnIssureNotifyServiceImpl.java | 5 + ...tifyOrderMaterialListAllocServiceImpl.java | 171 ++++++++++++++++++ ...ssueNotifyOrderMaterialListAllocMapper.xml | 68 +++++++ 10 files changed, 519 insertions(+), 184 deletions(-) create mode 100644 src/main/java/com/gaotao/modules/autoWareHourceHaian/entity/HaiAnSOIssueNotifyOrderMaterialListAllocData.java create mode 100644 src/main/java/com/gaotao/modules/autoWareHourceHaian/entity/dto/HaiAnNoOrderMaterialAllocRequestData.java create mode 100644 src/main/java/com/gaotao/modules/autoWareHourceHaian/entity/vo/HaiAnSOIssueNotifyOrderMaterialListAlloc.java create mode 100644 src/main/java/com/gaotao/modules/autoWareHourceHaian/mapper/HaiAnSOIssueNotifyOrderMaterialListAllocMapper.java create mode 100644 src/main/java/com/gaotao/modules/autoWareHourceHaian/service/HaiAnSOIssueNotifyOrderMaterialListAllocService.java create mode 100644 src/main/java/com/gaotao/modules/autoWareHourceHaian/service/impl/HaiAnSOIssueNotifyOrderMaterialListAllocServiceImpl.java create mode 100644 src/main/resources/mapper/autoWareHourceHaian/HaiAnSOIssueNotifyOrderMaterialListAllocMapper.xml diff --git a/src/main/java/com/gaotao/modules/autoWareHourceHaian/controller/HaiAnIssureNotifyController.java b/src/main/java/com/gaotao/modules/autoWareHourceHaian/controller/HaiAnIssureNotifyController.java index 519add53..7a482728 100644 --- a/src/main/java/com/gaotao/modules/autoWareHourceHaian/controller/HaiAnIssureNotifyController.java +++ b/src/main/java/com/gaotao/modules/autoWareHourceHaian/controller/HaiAnIssureNotifyController.java @@ -5,12 +5,15 @@ import com.gaotao.common.utils.PartAttributeUtil; import com.gaotao.common.utils.R; import com.gaotao.modules.autoWareHourceHaian.entity.HaiAnSOIssueNotifyHeaderData; import com.gaotao.modules.autoWareHourceHaian.entity.HaiAnSOIssueNotifyOrderListData; +import com.gaotao.modules.autoWareHourceHaian.entity.HaiAnSOIssueNotifyOrderMaterialListAllocData; import com.gaotao.modules.autoWareHourceHaian.entity.HaiAnSOIssueNotifyOrderMaterialListData; +import com.gaotao.modules.autoWareHourceHaian.entity.dto.HaiAnNoOrderMaterialAllocRequestData; import com.gaotao.modules.autoWareHourceHaian.entity.dto.HaiAnNoOrderNotifyDto; import com.gaotao.modules.autoWareHourceHaian.entity.dto.HaiAnNewSoIssueNotifyDto; import com.gaotao.modules.customer.entity.dto.ShipmentIssueDto; import com.gaotao.modules.autoWareHourceHaian.entity.vo.HaiAnSOIssueNotifyOrderList; import com.gaotao.modules.autoWareHourceHaian.service.HaiAnIssureNotifyService; +import com.gaotao.modules.autoWareHourceHaian.service.HaiAnSOIssueNotifyOrderMaterialListAllocService; import org.apache.commons.lang.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.PostMapping; @@ -32,111 +35,31 @@ public class HaiAnIssureNotifyController { private HaiAnIssureNotifyService haiAnIssureNotifyService; @Autowired - private PartAttributeUtil partAttributeUtil; - - /** - * @author rqrq - * @Description 查询当前用户未下达海安申请单,支持页面初始化加载 - rqrq - */ - @PostMapping(value = "/getUserNotifyNo") - public R haiAnGetUserNotifyNo(@RequestBody HaiAnSOIssueNotifyHeaderData data) { - HaiAnSOIssueNotifyHeaderData row = haiAnIssureNotifyService.haiAnGetUserNotifyNo(data); - return R.ok().put("row", row); - } - - /** - * @author rqrq - * @Description 检查用户是否存在未下达海安shoporder单,避免重复新建 - rqrq - */ - @PostMapping(value = "/checkUserHasUnissueShopOrder") - public R haiAnCheckUserHasUnissueShopOrder(@RequestBody HaiAnSOIssueNotifyHeaderData data) { - HaiAnSOIssueNotifyHeaderData row = haiAnIssureNotifyService.haiAnCheckUserHasUnissueShopOrder(data); - return R.ok().put("row", row); - } + private HaiAnSOIssueNotifyOrderMaterialListAllocService allocService; - /** - * @author rqrq - * @Description 创建海安申请单主记录,保持主单site唯一来源为请求参数 - rqrq - */ - @PostMapping(value = "/createNotify") - public R haiAnCreateNotify(@RequestBody HaiAnSOIssueNotifyHeaderData data) { - haiAnIssureNotifyService.haiAnCreateNotify(data); - return R.ok(); - } + @Autowired + private PartAttributeUtil partAttributeUtil; /** * @author rqrq - * @Description 查询海安申请单工单子明细,子层返回subsite供后续处理 - rqrq + * @Description 查询当前物料行的指定策略,供指定弹窗展示 - rqrq */ - @PostMapping(value = "/getNotifyNoDetail") - public R haiAnGetNotifyNoDetail(@RequestBody HaiAnSOIssueNotifyHeaderData data) { - List rows = haiAnIssureNotifyService.haiAnGetNotifyNoDetail(data); + @PostMapping(value = "/getNoOrderMaterialAllocList") + public R getNoOrderMaterialAllocList(@RequestBody HaiAnNoOrderMaterialAllocRequestData data) { + List rows = allocService.queryAllocList(data); return R.ok().put("rows", rows); } /** * @author rqrq - * @Description 保存单条工单行,补齐海安subsite与默认任务标志字段 - rqrq - */ - @PostMapping(value = "/saveSOIssueNotifyOrderList") - public R haiAnSaveSOIssueNotifyOrderList(@RequestBody HaiAnSOIssueNotifyOrderList data) { - Integer itemNo = haiAnIssureNotifyService.haiAnSaveSOIssueNotifyOrderList(data); - return R.ok().put("itemNo", itemNo); - } - - /** - * @author rqrq - * @Description 保存工单物料明细,执行先删后存保证编辑幂等 - rqrq - */ - @PostMapping(value = "/saveMaterialDetail") - public R haiAnSaveMaterialDetail(@RequestBody List data) { - haiAnIssureNotifyService.haiAnSaveMaterialDetail(data); - return R.ok(); - } - - /** - * @author rqrq - * @Description 删除工单明细时同步删除物料,避免海安子表残留 - rqrq + * @Description 全量保存当前物料行的指定策略,保存前统一规范化顺序并删后重建 - rqrq */ - @PostMapping(value = "/deleteNotifySOS") - public R haiAnDeleteNotifySOS(@RequestBody HaiAnSOIssueNotifyOrderListData data) { - haiAnIssureNotifyService.haiAnDeleteNotifySOS(data); + @PostMapping(value = "/saveNoOrderMaterialAllocList") + public R saveNoOrderMaterialAllocList(@RequestBody HaiAnNoOrderMaterialAllocRequestData data) { + allocService.saveAllocList(data); return R.ok(); } - /** - * @author rqrq - * @Description 下达海安申请单,更新计划发料时间与主状态 - rqrq - */ - @PostMapping(value = "/xiadaNotify") - public R haiAnXiadaNotify(@RequestBody HaiAnSOIssueNotifyHeaderData data) { - haiAnIssureNotifyService.haiAnXiadaNotifyHeader(data); - return R.ok(); - } - - /** - * @author rqrq - * @Description 删除海安申请单时清理父子数据,避免残留脏数据 - rqrq - */ - @PostMapping(value = "/deleteNotify") - public R haiAnDeleteNotify(@RequestBody HaiAnSOIssueNotifyHeaderData data) { - haiAnIssureNotifyService.haiAnDeleteNotifyHeader(data); - return R.ok("删除成功"); - } - - /** - * @author rqrq - * @Description 保存海安新领料模式数据,仅保存申请父子数据并执行删后重存策略 - rqrq - */ - @PostMapping(value = "/saveNewSoIssueNotify") - public R haiAnSaveNewSoIssueNotify(@RequestBody HaiAnNewSoIssueNotifyDto data) { - String result = haiAnIssureNotifyService.haiAnSaveNewSoIssueNotify(data); - if ("200".equals(result)) { - return R.ok("操作成功"); - } - return R.error("操作失败"); - } - /** * @author rqrq * @Description 查询海安无单页面当前用户未下达主单,固定header.order_type=noorder - rqrq @@ -192,7 +115,6 @@ public class HaiAnIssureNotifyController { row.setPartNo(row.getComponentPartNo()); } } - // 调用物料属性工具统一回填isInWh/availableQty,避免页面重复调用多次基础查询 - rqrq partAttributeUtil.fillIsInWh(rows); return R.ok().put("rows", rows); } @@ -266,5 +188,4 @@ public class HaiAnIssureNotifyController { haiAnIssureNotifyService.haiAnCancelNoOrderIssueNotify(data); return R.ok(); } -} - +} \ No newline at end of file diff --git a/src/main/java/com/gaotao/modules/autoWareHourceHaian/entity/HaiAnSOIssueNotifyOrderMaterialListAllocData.java b/src/main/java/com/gaotao/modules/autoWareHourceHaian/entity/HaiAnSOIssueNotifyOrderMaterialListAllocData.java new file mode 100644 index 00000000..1def84b6 --- /dev/null +++ b/src/main/java/com/gaotao/modules/autoWareHourceHaian/entity/HaiAnSOIssueNotifyOrderMaterialListAllocData.java @@ -0,0 +1,24 @@ +package com.gaotao.modules.autoWareHourceHaian.entity; + +import com.gaotao.modules.autoWareHourceHaian.entity.vo.HaiAnSOIssueNotifyOrderMaterialListAlloc; +import lombok.Data; +import org.apache.ibatis.type.Alias; + +/** + * @author rqrq + * @Description 海安无订单物料指定分配业务实体,继承表结构实体并承载页面交互用的展示语义 - rqrq + */ +@Data +@Alias("HaiAnSOIssueNotifyOrderMaterialListAllocData") +public class HaiAnSOIssueNotifyOrderMaterialListAllocData extends HaiAnSOIssueNotifyOrderMaterialListAlloc { + + /** + * 指定类型中文名称,页面仅用于展示标签/批次语义,不入库 - rqrq + */ + private String allocTypeName; + + /** + * 行内显示序号,前端弹窗中用于快速定位当前指定记录,不参与入库 - rqrq + */ + private Integer rowNo; +} \ No newline at end of file diff --git a/src/main/java/com/gaotao/modules/autoWareHourceHaian/entity/dto/HaiAnNoOrderMaterialAllocRequestData.java b/src/main/java/com/gaotao/modules/autoWareHourceHaian/entity/dto/HaiAnNoOrderMaterialAllocRequestData.java new file mode 100644 index 00000000..ff21eb80 --- /dev/null +++ b/src/main/java/com/gaotao/modules/autoWareHourceHaian/entity/dto/HaiAnNoOrderMaterialAllocRequestData.java @@ -0,0 +1,55 @@ +package com.gaotao.modules.autoWareHourceHaian.entity.dto; + +import com.gaotao.modules.autoWareHourceHaian.entity.HaiAnSOIssueNotifyOrderMaterialListAllocData; +import lombok.Data; + +import java.math.BigDecimal; +import java.util.List; + +/** + * @author rqrq + * @Description 海安无单物料指定请求实体,承载当前物料行的查询键与全量指定列表 - rqrq + */ +@Data +public class HaiAnNoOrderMaterialAllocRequestData { + + /** + * 工厂site编码,海安无单页面必须由前端显式传入,后端不得兜底登录态 - rqrq + */ + private String site; + + /** + * 申请单号,对应haian_SOIssueNotifyOrderMaterialList_alloc.notify_no - rqrq + */ + private String notifyNo; + + /** + * 订单层行号,对应haian_SOIssueNotifyOrderMaterialList_alloc.item_no - rqrq + */ + private BigDecimal itemNo; + + /** + * BOM行号,对应haian_SOIssueNotifyOrderMaterialList_alloc.BOM_item_no - rqrq + */ + private String bOMItemNo; + + /** + * 当前物料行的成品料号或申请物料号,页面用于弹窗标题展示,不参与查询主键 - rqrq + */ + private String partNo; + + /** + * 当前物料行的物料描述,页面用于弹窗标题展示,不参与查询主键 - rqrq + */ + private String partDesc; + + /** + * 子站点编码,查询时可用于联动展示,保存时会与明细行保持一致 - rqrq + */ + private String subSite; + + /** + * 当前物料行的全部指定记录,保存时采用全量重存模式;查询时可为空 - rqrq + */ + private List allocList; +} \ No newline at end of file diff --git a/src/main/java/com/gaotao/modules/autoWareHourceHaian/entity/vo/HaiAnSOIssueNotifyOrderMaterialListAlloc.java b/src/main/java/com/gaotao/modules/autoWareHourceHaian/entity/vo/HaiAnSOIssueNotifyOrderMaterialListAlloc.java new file mode 100644 index 00000000..1ea0730f --- /dev/null +++ b/src/main/java/com/gaotao/modules/autoWareHourceHaian/entity/vo/HaiAnSOIssueNotifyOrderMaterialListAlloc.java @@ -0,0 +1,114 @@ +package com.gaotao.modules.autoWareHourceHaian.entity.vo; + +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.Data; + +import java.io.Serializable; +import java.math.BigDecimal; +import java.util.Date; + +/** + * @author rqrq + * @Description 海安无订单物料指定分配层表实体(haian_SOIssueNotifyOrderMaterialList_alloc),字段与数据库表结构一一对应 - rqrq + */ +@Data +@TableName("haian_SOIssueNotifyOrderMaterialList_alloc") +public class HaiAnSOIssueNotifyOrderMaterialListAlloc implements Serializable { + + /** + * 工厂site编码,作为分配策略的工厂隔离主维度,必须与申请单主site一致 - rqrq + */ + @TableField("site") + private String site; + + /** + * 领料申请单号,关联haian_SOIssueNotifyHeader.notify_no,决定当前申请单的分配范围 - rqrq + */ + @TableField("notify_no") + private String notifyNo; + + /** + * 订单层行号,关联haian_SOIssueNotifyOrderList.item_no,用于限定某一行物料 - rqrq + */ + @TableField("item_no") + private BigDecimal itemNo; + + /** + * BOM行号,关联haian_SOIssueNotifyOrderMaterialList.BOM_item_no,避免同一订单行下多物料串用 - rqrq + */ + @TableField("BOM_item_no") + private String bOMItemNo; + + /** + * 分配优先级序号,越小优先级越高;保存时由后端重新规范化,不允许前端自行跳号 - rqrq + */ + @TableField("alloc_seq") + private Integer allocSeq; + + /** + * 子站点编码,对应明细保存时的sub_site,表示该指定记录属于哪个小站点 - rqrq + */ + @TableField("sub_site") + private String subSite; + + /** + * 指定类型,LABEL表示标签指定,BATCH表示批次指定;后续自动匹配按类型优先级消费 - rqrq + */ + @TableField("alloc_type") + private String allocType; + + /** + * 批次号,仅在allocType=BATCH时填写;标签指定时保持为空,避免目标语义混淆 - rqrq + */ + @TableField("batch_no") + private String batchNo; + + /** + * 标签号,仅在allocType=LABEL时填写;批次指定时保持为空,避免目标语义混淆 - rqrq + */ + @TableField("serialNo") + private String serialNo; + + /** + * 指定数量,本条分配策略允许被优先命中的数量,业务单位与申请行保持一致 - rqrq + */ + @TableField("alloc_qty") + private BigDecimal allocQty; + + /** + * 目标库位或目的编码,当前阶段保留扩展字段,默认可为空,后续可支持更细粒度分配目的地 - rqrq + */ + @TableField("dest_code") + private String destCode; + + /** + * 指定状态,NEW表示新建,CONFIRMED表示已确认,CANCELLED表示取消;当前主要用于前端展示与审计 - rqrq + */ + @TableField("alloc_status") + private String allocStatus; + + /** + * 备注信息,记录指定原因或操作说明,便于后续人工复核 - rqrq + */ + @TableField("remark") + private String remark; + + /** + * 创建人账号,写入时用于审计追踪,不影响分配规则计算 - rqrq + */ + @TableField("created_by") + private String createdBy; + + /** + * 创建时间,保存指定记录时由后端统一写入,辅助排障与审计 - rqrq + */ + @TableField("created_time") + private Date createdTime; + + /** + * 更新时间,每次重存时刷新,帮助判断最近一次指定策略变更时点 - rqrq + */ + @TableField("updated_time") + private Date updatedTime; +} \ No newline at end of file diff --git a/src/main/java/com/gaotao/modules/autoWareHourceHaian/mapper/HaiAnSOIssueNotifyOrderMaterialListAllocMapper.java b/src/main/java/com/gaotao/modules/autoWareHourceHaian/mapper/HaiAnSOIssueNotifyOrderMaterialListAllocMapper.java new file mode 100644 index 00000000..a3e1b631 --- /dev/null +++ b/src/main/java/com/gaotao/modules/autoWareHourceHaian/mapper/HaiAnSOIssueNotifyOrderMaterialListAllocMapper.java @@ -0,0 +1,41 @@ +package com.gaotao.modules.autoWareHourceHaian.mapper; + +import com.gaotao.modules.autoWareHourceHaian.entity.HaiAnSOIssueNotifyOrderMaterialListAllocData; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +import java.math.BigDecimal; +import java.util.List; + +@Mapper +public interface HaiAnSOIssueNotifyOrderMaterialListAllocMapper { + + /** + * 查询当前物料行全部指定记录,按标签优先和alloc_seq升序返回 - rqrq + */ + List selectAllocList(@Param("site") String site, + @Param("notifyNo") String notifyNo, + @Param("itemNo") BigDecimal itemNo, + @Param("bOMItemNo") String bOMItemNo); + + /** + * 删除当前物料行全部指定记录,保存前先清空旧数据,避免残留顺序冲突 - rqrq + */ + int deleteAllocList(@Param("site") String site, + @Param("notifyNo") String notifyNo, + @Param("itemNo") BigDecimal itemNo, + @Param("bOMItemNo") String bOMItemNo); + + /** + * 批量保存当前物料行指定记录,后端已完成顺序规范化和字段校验 - rqrq + */ + int insertAllocList(@Param("rows") List rows); + + /** + * 查询当前物料行下一条alloc_seq,保证重建时从1开始连续递增 - rqrq + */ + Integer selectMaxAllocSeq(@Param("site") String site, + @Param("notifyNo") String notifyNo, + @Param("itemNo") BigDecimal itemNo, + @Param("bOMItemNo") String bOMItemNo); +} \ No newline at end of file diff --git a/src/main/java/com/gaotao/modules/autoWareHourceHaian/service/HaiAnIssureNotifyService.java b/src/main/java/com/gaotao/modules/autoWareHourceHaian/service/HaiAnIssureNotifyService.java index bc7f9c31..6cc11256 100644 --- a/src/main/java/com/gaotao/modules/autoWareHourceHaian/service/HaiAnIssureNotifyService.java +++ b/src/main/java/com/gaotao/modules/autoWareHourceHaian/service/HaiAnIssureNotifyService.java @@ -1,148 +1,65 @@ package com.gaotao.modules.autoWareHourceHaian.service; +import com.gaotao.common.utils.PageUtils; import com.gaotao.modules.autoWareHourceHaian.entity.HaiAnSOIssueNotifyHeaderData; import com.gaotao.modules.autoWareHourceHaian.entity.HaiAnSOIssueNotifyOrderListData; +import com.gaotao.modules.autoWareHourceHaian.entity.HaiAnSOIssueNotifyOrderMaterialListAllocData; import com.gaotao.modules.autoWareHourceHaian.entity.HaiAnSOIssueNotifyOrderMaterialListData; +import com.gaotao.modules.autoWareHourceHaian.entity.dto.HaiAnNoOrderMaterialAllocRequestData; import com.gaotao.modules.autoWareHourceHaian.entity.dto.HaiAnNoOrderNotifyDto; import com.gaotao.modules.autoWareHourceHaian.entity.dto.HaiAnNewSoIssueNotifyDto; import com.gaotao.modules.autoWareHourceHaian.entity.vo.HaiAnSOIssueNotifyOrderList; -import com.gaotao.common.utils.PageUtils; import com.gaotao.modules.customer.entity.dto.ShipmentIssueDto; import java.util.List; public interface HaiAnIssureNotifyService { - /** - * @author rqrq - * @Description 查询当前用户未下达海安申请单;入参需包含site与username,若缺失site应抛业务异常 - rqrq - */ HaiAnSOIssueNotifyHeaderData haiAnGetUserNotifyNo(HaiAnSOIssueNotifyHeaderData inData); - /** - * @author rqrq - * @Description 检查用户是否存在未下达海安shoporder单;用于新建前拦截重复单据 - rqrq - */ HaiAnSOIssueNotifyHeaderData haiAnCheckUserHasUnissueShopOrder(HaiAnSOIssueNotifyHeaderData inData); - /** - * @author rqrq - * @Description 创建海安主单;入参site缺失或流水号生成失败时应抛异常并回滚 - rqrq - */ void haiAnCreateNotify(HaiAnSOIssueNotifyHeaderData data); - /** - * @author rqrq - * @Description 查询海安工单行明细;返回行级subsite用于后续子链路处理 - rqrq - */ List haiAnGetNotifyNoDetail(HaiAnSOIssueNotifyHeaderData data); - /** - * @author rqrq - * @Description 保存海安工单行;返回生成的itemNo,subsite缺失时应报错 - rqrq - */ Integer haiAnSaveSOIssueNotifyOrderList(HaiAnSOIssueNotifyOrderList data); - /** - * @author rqrq - * @Description 保存海安物料明细;执行先删后存,保存失败时应回滚避免脏数据 - rqrq - */ void haiAnSaveMaterialDetail(List data); - /** - * @author rqrq - * @Description 删除海安工单行并清理其物料子表;删除失败时应抛异常 - rqrq - */ void haiAnDeleteNotifySOS(HaiAnSOIssueNotifyOrderListData data); - /** - * @author rqrq - * @Description 下达海安申请单;仅更新主单状态与计划时间,主键不存在应报错 - rqrq - */ void haiAnXiadaNotifyHeader(HaiAnSOIssueNotifyHeaderData data); - /** - * @author rqrq - * @Description 删除海安申请单;清理父子层数据,任一步失败应回滚 - rqrq - */ void haiAnDeleteNotifyHeader(HaiAnSOIssueNotifyHeaderData data); - /** - * @author rqrq - * @Description 保存海安新领料模式;仅保存申请父子数据并返回状态码,异常场景返回并抛错 - rqrq - */ String haiAnSaveNewSoIssueNotify(HaiAnNewSoIssueNotifyDto data); - /** - * @author rqrq - * @Description 查询当前用户未下达海安无单申请单;固定筛选header.order_type='noorder'用于无单页面初始化 - rqrq - */ HaiAnSOIssueNotifyHeaderData haiAnGetUserNoOrderNotifyNo(HaiAnSOIssueNotifyHeaderData data); - /** - * @author rqrq - * @Description 创建海安无单申请单头;仅写haian_SOIssueNotifyHeader并强制order_type='noorder' - rqrq - */ void haiAnCreateNoOrderNotify(HaiAnSOIssueNotifyHeaderData data); - /** - * @author rqrq - * @Description 保存海安无单申请父子数据;按subsite拆分父行并写入haian_SOIssueNotifyOrderList/MaterialList - rqrq - */ String haiAnSaveNoOrderNotify(HaiAnNoOrderNotifyDto data); - /** - * @author rqrq - * @Description 查询海安无单申请订单层明细;返回production_area/transport_flag供页面展示 - rqrq - */ List haiAnGetNotifyNoOrderDetail(HaiAnSOIssueNotifyHeaderData data); - /** - * @author rqrq - * @Description 查询海安无单物料明细;返回isInWh与availableQty基础字段供前端编辑回显 - rqrq - */ List haiAnGetNoOrderMaterialList(HaiAnSOIssueNotifyOrderMaterialListData data); - /** - * @author rqrq - * @Description 保存海安无单物料明细;执行“先删后存”,并在subsite缺失时按父行补齐 - rqrq - */ void haiAnSaveNoOrderMaterialDetail(List data); - /** - * @author rqrq - * @Description 分页查询海安无单已下达申请单;固定order_type='noorder'并排除UNISSUE - rqrq - */ PageUtils haiAnSearchNoOrderNotifyHeader(ShipmentIssueDto data); - /** - * @author rqrq - * @Description 查询海安无单订单层明细(按header类型过滤);用于无单查看页签联动 - rqrq - */ List haiAnGetNotifyNoOrderDetailByType(HaiAnSOIssueNotifyOrderList data); - /** - * @author rqrq - * @Description 更新海安无单申请目的地production_area;用于推送前人工修正目标区域 - rqrq - */ void haiAnUpdateProductionArea(HaiAnSOIssueNotifyOrderListData data); - /** - * @author rqrq - * @Description 查询海安无单申请首条订单行关键字段(production_area/order_type),用于推送预览弹窗初始化 - rqrq - */ HaiAnSOIssueNotifyOrderList haiAnGetFirstOrderListDetail(HaiAnSOIssueNotifyOrderListData data); - /** - * @author rqrq - * @Description 检查用户是否存在未下达海安无单申请;用于取消下达前置拦截 - rqrq - */ HaiAnSOIssueNotifyHeaderData haiAnCheckUserHasUnissueNoOrder(HaiAnSOIssueNotifyHeaderData data); - /** - * @author rqrq - * @Description 取消下达海安无单申请;仅允许未推送WCS主单状态回退到UNISSUE - rqrq - */ void haiAnCancelNoOrderIssueNotify(HaiAnSOIssueNotifyHeaderData data); -} + List haiAnQueryNoOrderMaterialAllocList(HaiAnNoOrderMaterialAllocRequestData data); + + void haiAnSaveNoOrderMaterialAllocList(HaiAnNoOrderMaterialAllocRequestData data); +} \ No newline at end of file diff --git a/src/main/java/com/gaotao/modules/autoWareHourceHaian/service/HaiAnSOIssueNotifyOrderMaterialListAllocService.java b/src/main/java/com/gaotao/modules/autoWareHourceHaian/service/HaiAnSOIssueNotifyOrderMaterialListAllocService.java new file mode 100644 index 00000000..860f57eb --- /dev/null +++ b/src/main/java/com/gaotao/modules/autoWareHourceHaian/service/HaiAnSOIssueNotifyOrderMaterialListAllocService.java @@ -0,0 +1,19 @@ +package com.gaotao.modules.autoWareHourceHaian.service; + +import com.gaotao.modules.autoWareHourceHaian.entity.HaiAnSOIssueNotifyOrderMaterialListAllocData; +import com.gaotao.modules.autoWareHourceHaian.entity.dto.HaiAnNoOrderMaterialAllocRequestData; + +import java.util.List; + +public interface HaiAnSOIssueNotifyOrderMaterialListAllocService { + + /** + * 查询当前物料行的分配策略列表,供指定弹窗展示与后续自动匹配读取 - rqrq + */ + List queryAllocList(HaiAnNoOrderMaterialAllocRequestData requestData); + + /** + * 全量保存当前物料行分配策略,保存前会统一校验、排序、重建alloc_seq - rqrq + */ + void saveAllocList(HaiAnNoOrderMaterialAllocRequestData requestData); +} \ No newline at end of file diff --git a/src/main/java/com/gaotao/modules/autoWareHourceHaian/service/impl/HaiAnIssureNotifyServiceImpl.java b/src/main/java/com/gaotao/modules/autoWareHourceHaian/service/impl/HaiAnIssureNotifyServiceImpl.java index ec595657..c5cf64b2 100644 --- a/src/main/java/com/gaotao/modules/autoWareHourceHaian/service/impl/HaiAnIssureNotifyServiceImpl.java +++ b/src/main/java/com/gaotao/modules/autoWareHourceHaian/service/impl/HaiAnIssureNotifyServiceImpl.java @@ -7,6 +7,7 @@ import com.gaotao.modules.api.entity.IfsInventoryPart; import com.gaotao.modules.api.service.IfsApiService; import com.gaotao.modules.autoWareHourceHaian.entity.HaiAnSOIssueNotifyHeaderData; import com.gaotao.modules.autoWareHourceHaian.entity.HaiAnSOIssueNotifyOrderListData; +import com.gaotao.modules.autoWareHourceHaian.entity.HaiAnSOIssueNotifyOrderMaterialListAllocData; import com.gaotao.modules.autoWareHourceHaian.entity.HaiAnSOIssueNotifyOrderMaterialListData; import com.gaotao.modules.autoWareHourceHaian.entity.dto.HaiAnGroupKey; import com.gaotao.modules.autoWareHourceHaian.entity.dto.HaiAnNoOrderNotifyDto; @@ -16,6 +17,7 @@ import com.gaotao.modules.autoWareHourceHaian.entity.vo.HaiAnSOIssueNotifyOrderL import com.gaotao.modules.autoWareHourceHaian.entity.vo.HaiAnSOIssueNotifyOrderMaterialList; import com.gaotao.modules.customer.entity.dto.ShipmentIssueDto; import com.gaotao.modules.autoWareHourceHaian.mapper.HaiAnIssureNotifyMapper; +import com.gaotao.modules.autoWareHourceHaian.mapper.HaiAnSOIssueNotifyOrderMaterialListAllocMapper; import com.gaotao.modules.autoWareHourceHaian.service.HaiAnIssureNotifyService; import com.gaotao.modules.sys.entity.SysUserEntity; import com.gaotao.modules.trans.entity.TransNoControl; @@ -46,6 +48,9 @@ public class HaiAnIssureNotifyServiceImpl implements HaiAnIssureNotifyService { @Autowired private HaiAnIssureNotifyMapper haiAnIssureNotifyMapper; + @Autowired + private HaiAnSOIssueNotifyOrderMaterialListAllocMapper allocMapper; + @Autowired private IfsApiService ifsApiService; diff --git a/src/main/java/com/gaotao/modules/autoWareHourceHaian/service/impl/HaiAnSOIssueNotifyOrderMaterialListAllocServiceImpl.java b/src/main/java/com/gaotao/modules/autoWareHourceHaian/service/impl/HaiAnSOIssueNotifyOrderMaterialListAllocServiceImpl.java new file mode 100644 index 00000000..e3ccd24e --- /dev/null +++ b/src/main/java/com/gaotao/modules/autoWareHourceHaian/service/impl/HaiAnSOIssueNotifyOrderMaterialListAllocServiceImpl.java @@ -0,0 +1,171 @@ +package com.gaotao.modules.autoWareHourceHaian.service.impl; + +import com.gaotao.modules.autoWareHourceHaian.entity.HaiAnSOIssueNotifyOrderMaterialListAllocData; +import com.gaotao.modules.autoWareHourceHaian.entity.HaiAnSOIssueNotifyOrderMaterialListData; +import com.gaotao.modules.autoWareHourceHaian.entity.dto.HaiAnNoOrderMaterialAllocRequestData; +import com.gaotao.modules.autoWareHourceHaian.mapper.HaiAnSOIssueNotifyOrderMaterialListAllocMapper; +import com.gaotao.modules.autoWareHourceHaian.mapper.HaiAnIssureNotifyMapper; +import com.gaotao.modules.autoWareHourceHaian.service.HaiAnSOIssueNotifyOrderMaterialListAllocService; +import org.apache.commons.lang.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.math.BigDecimal; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; +import java.util.Objects; + +/** + * @author rqrq + * @Description 海安无订单物料指定分配服务,负责查询、校验、排序和全量重存 - rqrq + */ +@Service +public class HaiAnSOIssueNotifyOrderMaterialListAllocServiceImpl implements HaiAnSOIssueNotifyOrderMaterialListAllocService { + + @Autowired + private HaiAnSOIssueNotifyOrderMaterialListAllocMapper allocMapper; + + @Autowired + private HaiAnIssureNotifyMapper issueNotifyMapper; + + @Override + public List queryAllocList(HaiAnNoOrderMaterialAllocRequestData requestData) { + validateRequestKey(requestData); + List rows = allocMapper.selectAllocList( + requestData.getSite(), requestData.getNotifyNo(), requestData.getItemNo(), requestData.getBOMItemNo()); + if (rows == null) { + return new ArrayList<>(); + } + for (int i = 0; i < rows.size(); i++) { + HaiAnSOIssueNotifyOrderMaterialListAllocData row = rows.get(i); + row.setRowNo(i + 1); + row.setAllocTypeName(resolveAllocTypeName(row.getAllocType())); + } + return rows; + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void saveAllocList(HaiAnNoOrderMaterialAllocRequestData requestData) { + validateRequestKey(requestData); + validateExistingMaterial(requestData); + List incoming = requestData.getAllocList(); + if (incoming == null) { + incoming = new ArrayList<>(); + } + List normalized = normalizeAllocList(requestData, incoming); + allocMapper.deleteAllocList(requestData.getSite(), requestData.getNotifyNo(), requestData.getItemNo(), requestData.getBOMItemNo()); + if (!normalized.isEmpty()) { + allocMapper.insertAllocList(normalized); + } + } + + private void validateRequestKey(HaiAnNoOrderMaterialAllocRequestData requestData) { + if (requestData == null) { + throw new RuntimeException("分配请求不能为空"); + } + if (!StringUtils.isNotBlank(requestData.getSite())) { + throw new RuntimeException("site不能为空"); + } + if (!StringUtils.isNotBlank(requestData.getNotifyNo())) { + throw new RuntimeException("申请单号不能为空"); + } + if (requestData.getItemNo() == null) { + throw new RuntimeException("订单层行号不能为空"); + } + if (!StringUtils.isNotBlank(requestData.getBOMItemNo())) { + throw new RuntimeException("BOM行号不能为空"); + } + } + + private void validateExistingMaterial(HaiAnNoOrderMaterialAllocRequestData requestData) { + HaiAnSOIssueNotifyOrderMaterialListData query = new HaiAnSOIssueNotifyOrderMaterialListData(); + query.setSite(requestData.getSite()); + query.setNotifyNo(requestData.getNotifyNo()); + query.setItemNo(requestData.getItemNo()); + query.setBOMItemNo(requestData.getBOMItemNo()); + List materialRows = issueNotifyMapper.haiAnGetNoOrderMaterialList(query); + if (materialRows == null || materialRows.isEmpty()) { + throw new RuntimeException("当前物料行不存在或已被删除"); + } + } + + private List normalizeAllocList(HaiAnNoOrderMaterialAllocRequestData requestData, + List incoming) { + List labelList = new ArrayList<>(); + List batchList = new ArrayList<>(); + for (HaiAnSOIssueNotifyOrderMaterialListAllocData row : incoming) { + if (row == null) { + continue; + } + row.setSite(requestData.getSite()); + row.setNotifyNo(requestData.getNotifyNo()); + row.setItemNo(requestData.getItemNo()); + row.setBOMItemNo(requestData.getBOMItemNo()); + row.setSubSite(StringUtils.isNotBlank(row.getSubSite()) ? row.getSubSite() : requestData.getSubSite()); + row.setAllocQty(row.getAllocQty() == null ? BigDecimal.ZERO : row.getAllocQty()); + row.setCreatedBy(StringUtils.isNotBlank(row.getCreatedBy()) ? row.getCreatedBy() : "rqrq"); + row.setCreatedTime(new Date()); + row.setUpdatedTime(new Date()); + if (!StringUtils.isNotBlank(row.getAllocType())) { + throw new RuntimeException("指定类型不能为空"); + } + if (row.getAllocQty().compareTo(BigDecimal.ZERO) <= 0) { + throw new RuntimeException("指定数量必须大于0"); + } + if (StringUtils.equalsIgnoreCase(row.getAllocType(), "LABEL")) { + if (!StringUtils.isNotBlank(row.getSerialNo())) { + throw new RuntimeException("标签指定必须填写标签号"); + } + row.setBatchNo(null); + labelList.add(row); + } else if (StringUtils.equalsIgnoreCase(row.getAllocType(), "BATCH")) { + if (!StringUtils.isNotBlank(row.getBatchNo())) { + throw new RuntimeException("批次指定必须填写批次号"); + } + row.setSerialNo(null); + batchList.add(row); + } else { + throw new RuntimeException("指定类型仅支持LABEL或BATCH"); + } + } + List merged = new ArrayList<>(); + merged.addAll(labelList); + merged.addAll(batchList); + for (int i = 0; i < merged.size(); i++) { + merged.get(i).setAllocSeq(i + 1); + merged.get(i).setAllocStatus(StringUtils.isNotBlank(merged.get(i).getAllocStatus()) ? merged.get(i).getAllocStatus() : "NEW"); + } + validateDuplicateTarget(merged); + return merged; + } + + private void validateDuplicateTarget(List rows) { + for (int i = 0; i < rows.size(); i++) { + HaiAnSOIssueNotifyOrderMaterialListAllocData left = rows.get(i); + for (int j = i + 1; j < rows.size(); j++) { + HaiAnSOIssueNotifyOrderMaterialListAllocData right = rows.get(j); + if (Objects.equals(left.getAllocType(), right.getAllocType())) { + if (StringUtils.equals(left.getAllocType(), "LABEL") && StringUtils.equals(left.getSerialNo(), right.getSerialNo())) { + throw new RuntimeException("同一物料行下标签号不能重复"); + } + if (StringUtils.equals(left.getAllocType(), "BATCH") && StringUtils.equals(left.getBatchNo(), right.getBatchNo())) { + throw new RuntimeException("同一物料行下批次号不能重复"); + } + } + } + } + } + + private String resolveAllocTypeName(String allocType) { + if (StringUtils.equalsIgnoreCase(allocType, "LABEL")) { + return "标签指定"; + } + if (StringUtils.equalsIgnoreCase(allocType, "BATCH")) { + return "批次指定"; + } + return allocType; + } +} \ No newline at end of file diff --git a/src/main/resources/mapper/autoWareHourceHaian/HaiAnSOIssueNotifyOrderMaterialListAllocMapper.xml b/src/main/resources/mapper/autoWareHourceHaian/HaiAnSOIssueNotifyOrderMaterialListAllocMapper.xml new file mode 100644 index 00000000..c9c95344 --- /dev/null +++ b/src/main/resources/mapper/autoWareHourceHaian/HaiAnSOIssueNotifyOrderMaterialListAllocMapper.xml @@ -0,0 +1,68 @@ + + + + + + + + + + DELETE FROM haian_SOIssueNotifyOrderMaterialList_alloc + WHERE site = #{site} + AND notify_no = #{notifyNo} + AND item_no = #{itemNo} + AND BOM_item_no = #{bOMItemNo} + + + + + + + + INSERT INTO haian_SOIssueNotifyOrderMaterialList_alloc ( + site, notify_no, item_no, BOM_item_no, alloc_seq, sub_site, alloc_type, + batch_no, serialNo, alloc_qty, dest_code, alloc_status, remark, + created_by, created_time, updated_time + ) + VALUES + + ( + #{item.site}, #{item.notifyNo}, #{item.itemNo}, #{item.bOMItemNo}, #{item.allocSeq}, #{item.subSite}, #{item.allocType}, + #{item.batchNo}, #{item.serialNo}, #{item.allocQty}, #{item.destCode}, #{item.allocStatus}, #{item.remark}, + #{item.createdBy}, #{item.createdTime}, #{item.updatedTime} + ) + + + + \ No newline at end of file