10 changed files with 519 additions and 184 deletions
-
109src/main/java/com/gaotao/modules/autoWareHourceHaian/controller/HaiAnIssureNotifyController.java
-
24src/main/java/com/gaotao/modules/autoWareHourceHaian/entity/HaiAnSOIssueNotifyOrderMaterialListAllocData.java
-
55src/main/java/com/gaotao/modules/autoWareHourceHaian/entity/dto/HaiAnNoOrderMaterialAllocRequestData.java
-
114src/main/java/com/gaotao/modules/autoWareHourceHaian/entity/vo/HaiAnSOIssueNotifyOrderMaterialListAlloc.java
-
41src/main/java/com/gaotao/modules/autoWareHourceHaian/mapper/HaiAnSOIssueNotifyOrderMaterialListAllocMapper.java
-
97src/main/java/com/gaotao/modules/autoWareHourceHaian/service/HaiAnIssureNotifyService.java
-
19src/main/java/com/gaotao/modules/autoWareHourceHaian/service/HaiAnSOIssueNotifyOrderMaterialListAllocService.java
-
5src/main/java/com/gaotao/modules/autoWareHourceHaian/service/impl/HaiAnIssureNotifyServiceImpl.java
-
171src/main/java/com/gaotao/modules/autoWareHourceHaian/service/impl/HaiAnSOIssueNotifyOrderMaterialListAllocServiceImpl.java
-
68src/main/resources/mapper/autoWareHourceHaian/HaiAnSOIssueNotifyOrderMaterialListAllocMapper.xml
@ -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; |
|||
} |
|||
@ -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<HaiAnSOIssueNotifyOrderMaterialListAllocData> allocList; |
|||
} |
|||
@ -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; |
|||
} |
|||
@ -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<HaiAnSOIssueNotifyOrderMaterialListAllocData> 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<HaiAnSOIssueNotifyOrderMaterialListAllocData> rows); |
|||
|
|||
/** |
|||
* 查询当前物料行下一条alloc_seq,保证重建时从1开始连续递增 - rqrq |
|||
*/ |
|||
Integer selectMaxAllocSeq(@Param("site") String site, |
|||
@Param("notifyNo") String notifyNo, |
|||
@Param("itemNo") BigDecimal itemNo, |
|||
@Param("bOMItemNo") String bOMItemNo); |
|||
} |
|||
@ -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<HaiAnSOIssueNotifyOrderListData> haiAnGetNotifyNoDetail(HaiAnSOIssueNotifyHeaderData data); |
|||
|
|||
/** |
|||
* @author rqrq |
|||
* @Description 保存海安工单行;返回生成的itemNo,subsite缺失时应报错 - rqrq |
|||
*/ |
|||
Integer haiAnSaveSOIssueNotifyOrderList(HaiAnSOIssueNotifyOrderList data); |
|||
|
|||
/** |
|||
* @author rqrq |
|||
* @Description 保存海安物料明细;执行先删后存,保存失败时应回滚避免脏数据 - rqrq |
|||
*/ |
|||
void haiAnSaveMaterialDetail(List<HaiAnSOIssueNotifyOrderMaterialListData> 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<HaiAnSOIssueNotifyOrderListData> haiAnGetNotifyNoOrderDetail(HaiAnSOIssueNotifyHeaderData data); |
|||
|
|||
/** |
|||
* @author rqrq |
|||
* @Description 查询海安无单物料明细;返回isInWh与availableQty基础字段供前端编辑回显 - rqrq |
|||
*/ |
|||
List<HaiAnSOIssueNotifyOrderMaterialListData> haiAnGetNoOrderMaterialList(HaiAnSOIssueNotifyOrderMaterialListData data); |
|||
|
|||
/** |
|||
* @author rqrq |
|||
* @Description 保存海安无单物料明细;执行“先删后存”,并在subsite缺失时按父行补齐 - rqrq |
|||
*/ |
|||
void haiAnSaveNoOrderMaterialDetail(List<HaiAnSOIssueNotifyOrderMaterialListData> data); |
|||
|
|||
/** |
|||
* @author rqrq |
|||
* @Description 分页查询海安无单已下达申请单;固定order_type='noorder'并排除UNISSUE - rqrq |
|||
*/ |
|||
PageUtils haiAnSearchNoOrderNotifyHeader(ShipmentIssueDto data); |
|||
|
|||
/** |
|||
* @author rqrq |
|||
* @Description 查询海安无单订单层明细(按header类型过滤);用于无单查看页签联动 - rqrq |
|||
*/ |
|||
List<HaiAnSOIssueNotifyOrderListData> 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<HaiAnSOIssueNotifyOrderMaterialListAllocData> haiAnQueryNoOrderMaterialAllocList(HaiAnNoOrderMaterialAllocRequestData data); |
|||
|
|||
void haiAnSaveNoOrderMaterialAllocList(HaiAnNoOrderMaterialAllocRequestData data); |
|||
} |
|||
@ -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<HaiAnSOIssueNotifyOrderMaterialListAllocData> queryAllocList(HaiAnNoOrderMaterialAllocRequestData requestData); |
|||
|
|||
/** |
|||
* 全量保存当前物料行分配策略,保存前会统一校验、排序、重建alloc_seq - rqrq |
|||
*/ |
|||
void saveAllocList(HaiAnNoOrderMaterialAllocRequestData requestData); |
|||
} |
|||
@ -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<HaiAnSOIssueNotifyOrderMaterialListAllocData> queryAllocList(HaiAnNoOrderMaterialAllocRequestData requestData) { |
|||
validateRequestKey(requestData); |
|||
List<HaiAnSOIssueNotifyOrderMaterialListAllocData> 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<HaiAnSOIssueNotifyOrderMaterialListAllocData> incoming = requestData.getAllocList(); |
|||
if (incoming == null) { |
|||
incoming = new ArrayList<>(); |
|||
} |
|||
List<HaiAnSOIssueNotifyOrderMaterialListAllocData> 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<HaiAnSOIssueNotifyOrderMaterialListData> materialRows = issueNotifyMapper.haiAnGetNoOrderMaterialList(query); |
|||
if (materialRows == null || materialRows.isEmpty()) { |
|||
throw new RuntimeException("当前物料行不存在或已被删除"); |
|||
} |
|||
} |
|||
|
|||
private List<HaiAnSOIssueNotifyOrderMaterialListAllocData> normalizeAllocList(HaiAnNoOrderMaterialAllocRequestData requestData, |
|||
List<HaiAnSOIssueNotifyOrderMaterialListAllocData> incoming) { |
|||
List<HaiAnSOIssueNotifyOrderMaterialListAllocData> labelList = new ArrayList<>(); |
|||
List<HaiAnSOIssueNotifyOrderMaterialListAllocData> 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<HaiAnSOIssueNotifyOrderMaterialListAllocData> 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<HaiAnSOIssueNotifyOrderMaterialListAllocData> 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; |
|||
} |
|||
} |
|||
@ -0,0 +1,68 @@ |
|||
<?xml version="1.0" encoding="UTF-8"?> |
|||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
|||
<mapper namespace="com.gaotao.modules.autoWareHourceHaian.mapper.HaiAnSOIssueNotifyOrderMaterialListAllocMapper"> |
|||
|
|||
<!-- 查询当前物料行全部指定记录,标签优先、批次其次、同类型按alloc_seq升序 - rqrq --> |
|||
<select id="selectAllocList" resultType="HaiAnSOIssueNotifyOrderMaterialListAllocData"> |
|||
SELECT |
|||
site, |
|||
notify_no AS notifyNo, |
|||
item_no AS itemNo, |
|||
BOM_item_no AS bOMItemNo, |
|||
alloc_seq AS allocSeq, |
|||
sub_site AS subSite, |
|||
alloc_type AS allocType, |
|||
batch_no AS batchNo, |
|||
serialNo, |
|||
alloc_qty AS allocQty, |
|||
dest_code AS destCode, |
|||
alloc_status AS allocStatus, |
|||
remark, |
|||
created_by AS createdBy, |
|||
created_time AS createdTime, |
|||
updated_time AS updatedTime |
|||
FROM haian_SOIssueNotifyOrderMaterialList_alloc WITH (NOLOCK) |
|||
WHERE site = #{site} |
|||
AND notify_no = #{notifyNo} |
|||
AND item_no = #{itemNo} |
|||
AND BOM_item_no = #{bOMItemNo} |
|||
ORDER BY CASE WHEN alloc_type = 'LABEL' THEN 0 ELSE 1 END, alloc_seq |
|||
</select> |
|||
|
|||
<!-- 删除当前物料行全部指定记录,保存前先清空旧记录再重建 - rqrq --> |
|||
<delete id="deleteAllocList"> |
|||
DELETE FROM haian_SOIssueNotifyOrderMaterialList_alloc |
|||
WHERE site = #{site} |
|||
AND notify_no = #{notifyNo} |
|||
AND item_no = #{itemNo} |
|||
AND BOM_item_no = #{bOMItemNo} |
|||
</delete> |
|||
|
|||
<!-- 查询当前物料行最大alloc_seq,重建时用于保持连续递增 - rqrq --> |
|||
<select id="selectMaxAllocSeq" resultType="java.lang.Integer"> |
|||
SELECT ISNULL(MAX(alloc_seq), 0) |
|||
FROM haian_SOIssueNotifyOrderMaterialList_alloc WITH (NOLOCK) |
|||
WHERE site = #{site} |
|||
AND notify_no = #{notifyNo} |
|||
AND item_no = #{itemNo} |
|||
AND BOM_item_no = #{bOMItemNo} |
|||
</select> |
|||
|
|||
<!-- 批量保存当前物料行指定记录,所有字段都由服务层规范化后写入 - rqrq --> |
|||
<insert id="insertAllocList"> |
|||
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 |
|||
<foreach collection="rows" item="item" separator=","> |
|||
( |
|||
#{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} |
|||
) |
|||
</foreach> |
|||
</insert> |
|||
|
|||
</mapper> |
|||
Write
Preview
Loading…
Cancel
Save
Reference in new issue