diff --git a/src/main/java/com/gaotao/modules/inspection/service/impl/InspectionInboundServiceImpl.java b/src/main/java/com/gaotao/modules/inspection/service/impl/InspectionInboundServiceImpl.java index 2e777ed..ccaeddf 100644 --- a/src/main/java/com/gaotao/modules/inspection/service/impl/InspectionInboundServiceImpl.java +++ b/src/main/java/com/gaotao/modules/inspection/service/impl/InspectionInboundServiceImpl.java @@ -643,7 +643,7 @@ public class InspectionInboundServiceImpl implements InspectionInboundService { String processType = mapTransactionCodeToProcessType(ifsHistory.getTransactionCode()); // 只处理不合格的记录(有退货、报废或换货数量的) - BigDecimal unqualifiedQty = getUnqualifiedQtyFromIfs(ifsHistory); + BigDecimal unqualifiedQty = getUnqualifiedQtyFromIfs(ifsHistory,ifsHistory.getTransactionCode()); if (unqualifiedQty != null && unqualifiedQty.compareTo(BigDecimal.ZERO) > 0) { UnqualifiedInspectionDto dto = new UnqualifiedInspectionDto(); @@ -706,16 +706,16 @@ public class InspectionInboundServiceImpl implements InspectionInboundService { /** * 从IFS历史数据中获取不合格数量 */ - private BigDecimal getUnqualifiedQtyFromIfs(IfsInspectionHistoryDto ifsHistory) { + private BigDecimal getUnqualifiedQtyFromIfs(IfsInspectionHistoryDto ifsHistory,String transactionCode) { BigDecimal qty = BigDecimal.ZERO; // 退货数量 - if (ifsHistory.getSourceQtyReturn() != null && ifsHistory.getSourceQtyReturn() > 0) { + if (transactionCode.equals("RETWORK")&&ifsHistory.getSourceQtyReturn() != null && ifsHistory.getSourceQtyReturn() > 0) { qty = qty.add(BigDecimal.valueOf(ifsHistory.getSourceQtyReturn())); } // 报废数量 - if (ifsHistory.getSourceQtyScrapped() != null && ifsHistory.getSourceQtyScrapped() > 0) { + if (transactionCode.equals("INVSCRAP")&&ifsHistory.getSourceQtyScrapped() != null && ifsHistory.getSourceQtyScrapped() > 0) { qty = qty.add(BigDecimal.valueOf(ifsHistory.getSourceQtyScrapped())); } diff --git a/src/main/java/com/gaotao/modules/warehouse/controller/IfsInventoryInitController.java b/src/main/java/com/gaotao/modules/warehouse/controller/IfsInventoryInitController.java index 94df6f0..2f9cd08 100644 --- a/src/main/java/com/gaotao/modules/warehouse/controller/IfsInventoryInitController.java +++ b/src/main/java/com/gaotao/modules/warehouse/controller/IfsInventoryInitController.java @@ -60,4 +60,19 @@ public class IfsInventoryInitController { return R.error("修改已打印数量失败: " + e.getMessage()); } } + + /** + * 创建其它入库HandlingUnit(inStockFlag='X') + * @param request 创建HU请求 + * @return 创建的HU ID列表 + */ + @PostMapping("/createOtherInboundHandlingUnits") + public R createOtherInboundHandlingUnits(@RequestBody CreateHuRequestDto request) { + try { + List unitIds = ifsInventoryInitService.createOtherInboundHandlingUnits(request); + return R.ok().put("unitIds", unitIds); + } catch (Exception e) { + return R.error("创建其它入库HandlingUnit失败: " + e.getMessage()); + } + } } diff --git a/src/main/java/com/gaotao/modules/warehouse/entity/dto/CreateHuRequestDto.java b/src/main/java/com/gaotao/modules/warehouse/entity/dto/CreateHuRequestDto.java index 01ee9a3..1c4b11a 100644 --- a/src/main/java/com/gaotao/modules/warehouse/entity/dto/CreateHuRequestDto.java +++ b/src/main/java/com/gaotao/modules/warehouse/entity/dto/CreateHuRequestDto.java @@ -2,7 +2,9 @@ package com.gaotao.modules.warehouse.entity.dto; import lombok.Data; +import com.fasterxml.jackson.annotation.JsonFormat; import java.math.BigDecimal; +import java.util.Date; /** * 创建HandlingUnit请求DTO @@ -19,5 +21,13 @@ public class CreateHuRequestDto { private String locationId; // 库位 private BigDecimal perPackageQty; // 单包装数量 private Integer packageCount; // 包装数 - private String umid; + private String umid; // 单位 + + @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8") + private Date manufactureDate; // 生产日期 + + @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8") + private Date expiredDate; // 失效日期 + + private String remark; // 备注 } diff --git a/src/main/java/com/gaotao/modules/warehouse/service/IfsInventoryInitService.java b/src/main/java/com/gaotao/modules/warehouse/service/IfsInventoryInitService.java index 13dfdba..527aa06 100644 --- a/src/main/java/com/gaotao/modules/warehouse/service/IfsInventoryInitService.java +++ b/src/main/java/com/gaotao/modules/warehouse/service/IfsInventoryInitService.java @@ -30,4 +30,11 @@ public interface IfsInventoryInitService { * @param request 修改请求 */ void updatePrintQty(InventoryStock request); + + /** + * 创建其它入库HandlingUnit(inStockFlag='X') + * @param request 创建HU请求 + * @return 创建的HU ID列表 + */ + List createOtherInboundHandlingUnits(CreateHuRequestDto request); } diff --git a/src/main/java/com/gaotao/modules/warehouse/service/impl/IfsInventoryInitServiceImpl.java b/src/main/java/com/gaotao/modules/warehouse/service/impl/IfsInventoryInitServiceImpl.java index 72d9df4..41b2d25 100644 --- a/src/main/java/com/gaotao/modules/warehouse/service/impl/IfsInventoryInitServiceImpl.java +++ b/src/main/java/com/gaotao/modules/warehouse/service/impl/IfsInventoryInitServiceImpl.java @@ -195,4 +195,91 @@ public class IfsInventoryInitServiceImpl implements IfsInventoryInitService { request.getNewPrintQty() ); } + + @Override + @Transactional + public List createOtherInboundHandlingUnits(CreateHuRequestDto request) { + List unitIds = new ArrayList<>(); + + // 根据包装数创建多个HandlingUnit + for (int i = 0; i < request.getPackageCount(); i++) { + // 生成处理单元ID + String unitId = handlingUnitIdGeneratorService.generateUnitId(request.getSite()); + + // 创建HandlingUnit对象 + HandlingUnit handlingUnit = new HandlingUnit(); + handlingUnit.setUnitId(unitId); + handlingUnit.setSite(request.getSite()); + handlingUnit.setUnitType("ROLL"); + handlingUnit.setUnitTypeDb("ROLL"); + handlingUnit.setPartNo(request.getPartNo()); + handlingUnit.setPartDesc(request.getPartDesc()); + handlingUnit.setQty(request.getPerPackageQty()); + handlingUnit.setBatchNo(request.getBatchNo()); + handlingUnit.setLocationId(request.getLocationId()); + handlingUnit.setWarehouseId(request.getWarehouseId()); + handlingUnit.setWdr(request.getWdr()); + handlingUnit.setStatus("ACTIVE"); + handlingUnit.setStatusDb("ACTIVE"); + handlingUnit.setFreezeFlag("N"); + handlingUnit.setMergedFlag("N"); + handlingUnit.setInStockFlag("X"); // 其它入库设置为未入库状态 + handlingUnit.setCreatedDate(new Date()); + handlingUnit.setCreatedBy("SYSTEM"); + handlingUnit.setSourceType("OTHER_INBOUND"); + handlingUnit.setSourceRef("其它入库"); + handlingUnit.setOriginalQty(request.getPerPackageQty()); + handlingUnit.setReceiveDate(new Date()); + + // 根据料号和单位计算长宽 + BigDecimal width = null; + BigDecimal length = null; + + String partNo = request.getPartNo(); + if (partNo != null && partNo.contains("-")) { + // 如果料号带尾缀,比如70001234-0250,那么width就是250 + String[] parts = partNo.split("-"); + String suffix = parts[parts.length - 1]; + try { + int widthVal = Integer.parseInt(suffix); + width = BigDecimal.valueOf(widthVal); + } catch (NumberFormatException e) { + // 默认1000 + } + } + + // length就是数量乘以1000再除以width + if (width!=null && width.compareTo(BigDecimal.ZERO) > 0) { + length = request.getPerPackageQty().multiply(BigDecimal.valueOf(1000)) + .divide(width, 2, java.math.RoundingMode.HALF_UP); + } + + handlingUnit.setWidth(width); + handlingUnit.setLength(length); + + // 设置生产日期和失效日期 + if (request.getManufactureDate() != null) { + handlingUnit.setManufactureDate(request.getManufactureDate()); + } + if (request.getExpiredDate() != null) { + handlingUnit.setExpiredDate(request.getExpiredDate()); + } + + handlingUnit.setUmId(request.getUmid()); + + // 设置备注 + if (request.getRemark() != null && !request.getRemark().trim().isEmpty()) { + handlingUnit.setRemark(request.getRemark()); + } else { + handlingUnit.setRemark("其它入库创建"); + } + + // 保存HandlingUnit + handlingUnitService.save(handlingUnit); + + unitIds.add(unitId); + } + + return unitIds; + } } diff --git a/src/main/resources/mapper/warehouse/WarehouseMapper.xml b/src/main/resources/mapper/warehouse/WarehouseMapper.xml index 2afb77f..4bda71a 100644 --- a/src/main/resources/mapper/warehouse/WarehouseMapper.xml +++ b/src/main/resources/mapper/warehouse/WarehouseMapper.xml @@ -446,7 +446,10 @@ +