|
|
|
@ -195,4 +195,91 @@ public class IfsInventoryInitServiceImpl implements IfsInventoryInitService { |
|
|
|
request.getNewPrintQty() |
|
|
|
); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
@Transactional |
|
|
|
public List<String> createOtherInboundHandlingUnits(CreateHuRequestDto request) { |
|
|
|
List<String> 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; |
|
|
|
} |
|
|
|
} |