diff --git a/src/main/java/com/gaotao/modules/boxManage/controller/BoxForNotificationController.java b/src/main/java/com/gaotao/modules/boxManage/controller/BoxForNotificationController.java index 61eabbf..9ace40d 100644 --- a/src/main/java/com/gaotao/modules/boxManage/controller/BoxForNotificationController.java +++ b/src/main/java/com/gaotao/modules/boxManage/controller/BoxForNotificationController.java @@ -3,6 +3,7 @@ package com.gaotao.modules.boxManage.controller; import com.gaotao.common.utils.R; import com.gaotao.modules.boxManage.data.SoReceiveBoxRollsData; import com.gaotao.modules.boxManage.data.SoReceiveBoxesData; +import com.gaotao.modules.boxManage.data.SoReceiveCasesData; import com.gaotao.modules.boxManage.service.BoxForNotificationService; import com.gaotao.modules.outboundNotification.entity.vo.OutboundNotificationHeadVo; import org.springframework.beans.factory.annotation.Autowired; @@ -105,4 +106,54 @@ public class BoxForNotificationController { List rows = srmSupplierService.searchRollForOrderNo(data); return R.ok().put("rows", rows); } + + // ===== 盒清单相关接口 ===== + + /** + * 查询盒清单 + * @param data + * @return R + */ + @PostMapping(value="/searchSoReceiveCasesData") + @ResponseBody + public R searchSoReceiveCasesData(@RequestBody SoReceiveCasesData data) { + List rows = srmSupplierService.searchSoReceiveCasesData(data); + return R.ok().put("rows", rows); + } + + /** + * 删除盒清单记录 + * @param data + * @return R + */ + @PostMapping(value="/deleteSoReceiveCasesData") + @ResponseBody + public R deleteSoReceiveCasesData(@RequestBody SoReceiveCasesData data) { + srmSupplierService.deleteSoReceiveCasesData(data); + return R.ok(); + } + + /** + * 校验并扫描卷 + * @param data + * @return R + */ + @PostMapping(value="/validateAndScanCaseRoll") + @ResponseBody + public R validateAndScanCaseRoll(@RequestBody SoReceiveCasesData data) { + SoReceiveCasesData rollInfo = srmSupplierService.validateAndScanCaseRoll(data); + return R.ok().put("rollInfo", rollInfo); + } + + /** + * 保存盒清单列表 + * @param dataList + * @return R + */ + @PostMapping(value="/saveCaseRollList") + @ResponseBody + public R saveCaseRollList(@RequestBody List dataList) { + srmSupplierService.saveCaseRollList(dataList); + return R.ok(); + } } diff --git a/src/main/java/com/gaotao/modules/boxManage/dao/BoxForNotificationMapper.java b/src/main/java/com/gaotao/modules/boxManage/dao/BoxForNotificationMapper.java index 2158be3..852190e 100644 --- a/src/main/java/com/gaotao/modules/boxManage/dao/BoxForNotificationMapper.java +++ b/src/main/java/com/gaotao/modules/boxManage/dao/BoxForNotificationMapper.java @@ -2,6 +2,7 @@ package com.gaotao.modules.boxManage.dao; import com.gaotao.modules.boxManage.data.SoReceiveBoxRollsData; import com.gaotao.modules.boxManage.data.SoReceiveBoxesData; +import com.gaotao.modules.boxManage.data.SoReceiveCasesData; import com.gaotao.modules.inventoryStock.entity.InventoryStock; import com.gaotao.modules.outboundNotification.entity.OutboundNotificationDetailEntity; import com.gaotao.modules.outboundNotification.entity.vo.OutboundNotificationHeadVo; @@ -37,4 +38,11 @@ public interface BoxForNotificationMapper { void updateBoxWareHouse( @Param("site") String site, @Param("buNo") String buNo, @Param("boxNo") String boxNo, @Param("warehouseId") String warehouseId); void deleteBoxRoll( SoReceiveBoxRollsData inData); List searchRollForOrderNo(OutboundNotificationHeadVo inData); + + // 盒清单相关方法 + List searchSoReceiveCasesData(SoReceiveCasesData data); + void deleteSoReceiveCasesData(SoReceiveCasesData data); + SoReceiveCasesData validateCaseRoll(@Param("site") String site, @Param("partNo") String partNo, @Param("rollNo") String rollNo, @Param("casesNo") String casesNo); + void saveSoReceiveCases(SoReceiveCasesData data); + void updateStockParentRollType(@Param("rollNo") String rollNo, @Param("parentRollNo") String parentRollNo, @Param("parentRollType") String parentRollType, @Param("site") String site, @Param("buNo") String buNo); } diff --git a/src/main/java/com/gaotao/modules/boxManage/data/SoReceiveCasesData.java b/src/main/java/com/gaotao/modules/boxManage/data/SoReceiveCasesData.java new file mode 100644 index 0000000..c543022 --- /dev/null +++ b/src/main/java/com/gaotao/modules/boxManage/data/SoReceiveCasesData.java @@ -0,0 +1,28 @@ +package com.gaotao.modules.boxManage.data; + +import com.gaotao.modules.boxManage.entity.SoReceiveCases; +import lombok.Data; +import org.apache.ibatis.type.Alias; + +/** + * 盒清单数据对象 + */ +@Data +@Alias("SoReceiveCasesData") +public class SoReceiveCasesData extends SoReceiveCases { + /** + * 合约号码 + */ + private String batchNo; + + /** + * 库存状态 + */ + private String status; + + /** + * 上级标签类型 + */ + private String parentRollType; +} + diff --git a/src/main/java/com/gaotao/modules/boxManage/entity/SoReceiveCases.java b/src/main/java/com/gaotao/modules/boxManage/entity/SoReceiveCases.java new file mode 100644 index 0000000..167fe78 --- /dev/null +++ b/src/main/java/com/gaotao/modules/boxManage/entity/SoReceiveCases.java @@ -0,0 +1,171 @@ +package com.gaotao.modules.boxManage.entity; + +import com.fasterxml.jackson.annotation.JsonFormat; +import org.springframework.format.annotation.DateTimeFormat; + +import java.util.Date; + +/** + * 盒清单实体类 + * 对应数据库表:so_receive_cases + */ +public class SoReceiveCases { + /** + * 主键,自增ID + */ + private Integer id; + + /** + * 工厂 + */ + private String site; + + /** + * BU + */ + private String buNo; + + /** + * 销售出库单号,关联销售通知主单 + */ + private String notifyNo; + + /** + * 盒标签,标识包装箱或盒的唯一编号 + */ + private String casesNo; + + /** + * 卷标签,标识物料卷的唯一编号 + */ + private String rollNo; + + /** + * 卷数量,表示该盒/该批次中包含的卷数 + */ + private Integer rollQty; + + /** + * 物料编码,对应物料主数据中的编码 + */ + private String partNo; + + /** + * 物料名称,物料的中文名称或描述 + */ + private String partDesc; + + /** + * 记录创建时间,默认为当前系统时间 + */ + @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") + private Date createDate; + + /** + * 创建人,操作员姓名或工号 + */ + private String createBy; + + /** + * 备注信息,用于记录特殊说明或客户要求 + */ + private String remark; + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public String getSite() { + return site; + } + + public void setSite(String site) { + this.site = site; + } + + public String getBuNo() { + return buNo; + } + + public void setBuNo(String buNo) { + this.buNo = buNo; + } + + public String getNotifyNo() { + return notifyNo; + } + + public void setNotifyNo(String notifyNo) { + this.notifyNo = notifyNo; + } + + public String getCasesNo() { + return casesNo; + } + + public void setCasesNo(String casesNo) { + this.casesNo = casesNo; + } + + public String getRollNo() { + return rollNo; + } + + public void setRollNo(String rollNo) { + this.rollNo = rollNo; + } + + public Integer getRollQty() { + return rollQty; + } + + public void setRollQty(Integer rollQty) { + this.rollQty = rollQty; + } + + public String getPartNo() { + return partNo; + } + + public void setPartNo(String partNo) { + this.partNo = partNo; + } + + public String getPartDesc() { + return partDesc; + } + + public void setPartDesc(String partDesc) { + this.partDesc = partDesc; + } + + public Date getCreateDate() { + return createDate; + } + + public void setCreateDate(Date createDate) { + this.createDate = createDate; + } + + public String getCreateBy() { + return createBy; + } + + public void setCreateBy(String createBy) { + this.createBy = createBy; + } + + public String getRemark() { + return remark; + } + + public void setRemark(String remark) { + this.remark = remark; + } +} + diff --git a/src/main/java/com/gaotao/modules/boxManage/service/BoxForNotificationService.java b/src/main/java/com/gaotao/modules/boxManage/service/BoxForNotificationService.java index 424391f..85215c0 100644 --- a/src/main/java/com/gaotao/modules/boxManage/service/BoxForNotificationService.java +++ b/src/main/java/com/gaotao/modules/boxManage/service/BoxForNotificationService.java @@ -2,6 +2,7 @@ package com.gaotao.modules.boxManage.service; import com.gaotao.modules.boxManage.data.SoReceiveBoxRollsData; import com.gaotao.modules.boxManage.data.SoReceiveBoxesData; +import com.gaotao.modules.boxManage.data.SoReceiveCasesData; import com.gaotao.modules.outboundNotification.entity.vo.OutboundNotificationHeadVo; import java.util.List; @@ -23,4 +24,10 @@ public interface BoxForNotificationService { void deleteBoxRoll(SoReceiveBoxRollsData data); List searchRollForOrderNo(OutboundNotificationHeadVo inData); + + // 盒清单相关方法 + List searchSoReceiveCasesData(SoReceiveCasesData data); + void deleteSoReceiveCasesData(SoReceiveCasesData data); + SoReceiveCasesData validateAndScanCaseRoll(SoReceiveCasesData data); + void saveCaseRollList(List dataList); } diff --git a/src/main/java/com/gaotao/modules/boxManage/service/impl/BoxForNotificationServiceImpl.java b/src/main/java/com/gaotao/modules/boxManage/service/impl/BoxForNotificationServiceImpl.java index 2bb3041..3b73d97 100644 --- a/src/main/java/com/gaotao/modules/boxManage/service/impl/BoxForNotificationServiceImpl.java +++ b/src/main/java/com/gaotao/modules/boxManage/service/impl/BoxForNotificationServiceImpl.java @@ -3,6 +3,7 @@ package com.gaotao.modules.boxManage.service.impl; import com.gaotao.modules.boxManage.dao.BoxForNotificationMapper; import com.gaotao.modules.boxManage.data.SoReceiveBoxRollsData; import com.gaotao.modules.boxManage.data.SoReceiveBoxesData; +import com.gaotao.modules.boxManage.data.SoReceiveCasesData; import com.gaotao.modules.boxManage.service.BoxForNotificationService; import com.gaotao.modules.outboundNotification.entity.OutboundNotificationDetailEntity; import com.gaotao.modules.outboundNotification.entity.vo.OutboundNotificationHeadVo; @@ -222,4 +223,116 @@ public class BoxForNotificationServiceImpl implements BoxForNotificationService public List searchRollForOrderNo(OutboundNotificationHeadVo inData) { return boxForNotificationMapper.searchRollForOrderNo(inData); } + + // ===== 盒清单相关方法实现 ===== + @Override + public List searchSoReceiveCasesData(SoReceiveCasesData data) { + return boxForNotificationMapper.searchSoReceiveCasesData(data); + } + + @Override + @Transactional + public void deleteSoReceiveCasesData(SoReceiveCasesData data) { + // 参数校验 + if (data == null || data.getId() == null || data.getSite() == null || data.getBuNo() == null) { + throw new RuntimeException("参数不完整"); + } + + // 删除记录前,需要将对应的库存卷的上级标签恢复为自己的卷号 + SoReceiveCasesData caseData = boxForNotificationMapper.searchSoReceiveCasesData(data).stream() + .filter(item -> item.getId().equals(data.getId())) + .findFirst() + .orElse(null); + + if (caseData != null) { + // 恢复库存的上级标签 + boxForNotificationMapper.updateStockParentRollType( + caseData.getRollNo(), + caseData.getRollNo(), + null, + data.getSite(), + data.getBuNo() + ); + } + + // 删除盒清单记录 + boxForNotificationMapper.deleteSoReceiveCasesData(data); + } + + @Override + @Transactional + public SoReceiveCasesData validateAndScanCaseRoll(SoReceiveCasesData data) { + // 参数校验 + if (data == null || data.getSite() == null || data.getCasesNo() == null + || data.getRollNo() == null || data.getPartNo() == null) { + throw new RuntimeException("参数不完整"); + } + + // 查询卷的信息并进行校验 + SoReceiveCasesData rollInfo = boxForNotificationMapper.validateCaseRoll( + data.getSite(), + data.getPartNo(), + data.getRollNo(), + data.getCasesNo() + ); + + if (rollInfo == null) { + throw new RuntimeException("未找到对应的卷信息,请检查卷标签和物料编码是否正确"); + } + + // 校验1: 检查状态是否为"在库" + if (!"在库".equals(rollInfo.getStatus())) { + throw new RuntimeException("该标签状态不是在库(当前状态:" + rollInfo.getStatus() + "),请检查"); + } + + // 校验2: 检查上级标签类型 + if ("盒标签".equals(rollInfo.getParentRollType()) || "箱标签".equals(rollInfo.getParentRollType())) { + throw new RuntimeException("该标签已经装盒/装箱,不允许重复扫描"); + } + + // 校验3: 检查合约号码 + // 需要查询出库单明细获取合约号进行比对 + List outboundDetails = boxForNotificationMapper.searchOutboundNotificationDetail( + data.getSite(), + data.getBuNo(), + data.getNotifyNo() + ); + + if (outboundDetails == null || outboundDetails.isEmpty()) { + throw new RuntimeException("未找到对应的出库单明细"); + } + + // 检查是否有匹配的合约号(只要有一行的合约号匹配即可) + boolean batchMatched = outboundDetails.stream() + .filter(detail -> detail.getPartNo() != null && detail.getPartNo().equals(data.getPartNo())) + .anyMatch(detail -> detail.getOutBatchNo() != null && detail.getOutBatchNo().equals(rollInfo.getBatchNo())); + + if (!batchMatched) { + throw new RuntimeException("该标签合约号码(" + rollInfo.getBatchNo() + ")不符,请检查"); + } + + // 校验通过,返回卷信息 + return rollInfo; + } + + @Override + @Transactional + public void saveCaseRollList(List dataList) { + if (dataList == null || dataList.isEmpty()) { + throw new RuntimeException("保存数据为空"); + } + + SysUserEntity currentUser = (SysUserEntity) SecurityUtils.getSubject().getPrincipal(); + + for (SoReceiveCasesData data : dataList) { + // 设置创建人 + data.setCreateBy(currentUser.getUsername()); + + // 保存到so_receive_cases表 + boxForNotificationMapper.saveSoReceiveCases(data); + + // 更新inventory_stock表的parent_roll_no为盒标签,parent_roll_type为"盒标签" + boxForNotificationMapper.updateStockParentRollType(data.getRollNo(), data.getCasesNo(), "盒标签", data.getSite(), data.getBuNo()); + } + } } diff --git a/src/main/resources/mapper/boxManage/BoxForNotificationMapper.xml b/src/main/resources/mapper/boxManage/BoxForNotificationMapper.xml index 3da8773..15414a9 100644 --- a/src/main/resources/mapper/boxManage/BoxForNotificationMapper.xml +++ b/src/main/resources/mapper/boxManage/BoxForNotificationMapper.xml @@ -130,4 +130,101 @@ left join inventory_stock c on b.site = c.site and b.final_roll_no = c.roll_no and b.bu_no = c.bu_no where a.site = #{site} and a.order_no = #{orderNo} and a.bu_no = #{buNo} + + + + + + DELETE FROM so_receive_cases + WHERE Id = #{id} + AND site = #{site} + AND bu_no = #{buNo} + + + + + + INSERT INTO so_receive_cases ( + NotifyNo, + cases_no, + roll_no, + roll_qty, + part_no, + part_desc, + create_date, + create_by, + Remark, + site, + bu_no + ) VALUES ( + #{notifyNo}, + #{casesNo}, + #{rollNo}, + #{rollQty}, + #{partNo}, + #{partDesc}, + GETDATE(), + #{createBy}, + #{remark}, + #{site}, + #{buNo} + ) + + + + UPDATE inventory_stock + SET parent_roll_no = #{parentRollNo}, + parent_roll_type = #{parentRollType} + WHERE roll_no = #{rollNo} + AND site = #{site} + AND bu_no = #{buNo} + \ No newline at end of file