Browse Source

盘点+其他功能

dev
常熟吴彦祖 3 weeks ago
parent
commit
6278616baa
  1. 109
      src/main/java/com/gaotao/modules/autoWareHourceHaian/controller/HaiAnIssureNotifyController.java
  2. 24
      src/main/java/com/gaotao/modules/autoWareHourceHaian/entity/HaiAnSOIssueNotifyOrderMaterialListAllocData.java
  3. 55
      src/main/java/com/gaotao/modules/autoWareHourceHaian/entity/dto/HaiAnNoOrderMaterialAllocRequestData.java
  4. 114
      src/main/java/com/gaotao/modules/autoWareHourceHaian/entity/vo/HaiAnSOIssueNotifyOrderMaterialListAlloc.java
  5. 41
      src/main/java/com/gaotao/modules/autoWareHourceHaian/mapper/HaiAnSOIssueNotifyOrderMaterialListAllocMapper.java
  6. 97
      src/main/java/com/gaotao/modules/autoWareHourceHaian/service/HaiAnIssureNotifyService.java
  7. 19
      src/main/java/com/gaotao/modules/autoWareHourceHaian/service/HaiAnSOIssueNotifyOrderMaterialListAllocService.java
  8. 5
      src/main/java/com/gaotao/modules/autoWareHourceHaian/service/impl/HaiAnIssureNotifyServiceImpl.java
  9. 171
      src/main/java/com/gaotao/modules/autoWareHourceHaian/service/impl/HaiAnSOIssueNotifyOrderMaterialListAllocServiceImpl.java
  10. 68
      src/main/resources/mapper/autoWareHourceHaian/HaiAnSOIssueNotifyOrderMaterialListAllocMapper.xml

109
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<HaiAnSOIssueNotifyOrderListData> rows = haiAnIssureNotifyService.haiAnGetNotifyNoDetail(data);
@PostMapping(value = "/getNoOrderMaterialAllocList")
public R getNoOrderMaterialAllocList(@RequestBody HaiAnNoOrderMaterialAllocRequestData data) {
List<HaiAnSOIssueNotifyOrderMaterialListAllocData> 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<HaiAnSOIssueNotifyOrderMaterialListData> 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();
}
}
}

24
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;
}

55
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<HaiAnSOIssueNotifyOrderMaterialListAllocData> allocList;
}

114
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;
}

41
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<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);
}

97
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<HaiAnSOIssueNotifyOrderListData> haiAnGetNotifyNoDetail(HaiAnSOIssueNotifyHeaderData data);
/**
* @author rqrq
* @Description 保存海安工单行返回生成的itemNosubsite缺失时应报错 - 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);
}

19
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<HaiAnSOIssueNotifyOrderMaterialListAllocData> queryAllocList(HaiAnNoOrderMaterialAllocRequestData requestData);
/**
* 全量保存当前物料行分配策略保存前会统一校验排序重建alloc_seq - rqrq
*/
void saveAllocList(HaiAnNoOrderMaterialAllocRequestData requestData);
}

5
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;

171
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<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;
}
}

68
src/main/resources/mapper/autoWareHourceHaian/HaiAnSOIssueNotifyOrderMaterialListAllocMapper.xml

@ -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>
Loading…
Cancel
Save