仓码820

This commit is contained in:
王奎兴
2026-08-14 14:36:46 +08:00
parent 208024a6cc
commit 070cdcd5de
16 changed files with 187 additions and 5 deletions
@@ -68,4 +68,9 @@ public class ReservedInventory {
* 验证结果(导入后自动填充,不映射Excel)
*/
private String validationResult;
/**
* WMS物料id(解析预览接口根据货物名称匹配后自动填充,匹配不到为空,不映射Excel)
*/
private Long materialBaseInfoId;
}
@@ -1972,6 +1972,35 @@ public class ReserveStockInOrderApplicationService {
return stockInOrderDomainService.queryNoticePrintDetail(stockInOrderDO);
}
/**
* Excel解析预览:根据货物名称匹配WMS对应物料并填充物料id,
* 匹配不到物料id保持为空,不阻断解析
*/
public void fillMaterialBaseInfoId(List<ReservedInventory> dataList) {
if (dataList == null || dataList.isEmpty()) {
return;
}
// 物料名称匹配结果缓存,避免同名重复查库
Map<String, MaterialBaseInfoPO> materialCache = new HashMap<>();
for (ReservedInventory reservedInventory : dataList) {
String goodsName = reservedInventory.getGoodsName();
if (StringUtils.isBlank(goodsName)) {
continue;
}
MaterialBaseInfoPO materialBaseInfoPO = materialCache.get(goodsName);
if (materialBaseInfoPO == null && !materialCache.containsKey(goodsName)) {
List<MaterialBaseInfoPO> materialBaseInfoPOS = reserveStockInOrderMapper.getByName(goodsName);
if (materialBaseInfoPOS != null && !materialBaseInfoPOS.isEmpty()) {
materialBaseInfoPO = materialBaseInfoPOS.get(0);
}
materialCache.put(goodsName, materialBaseInfoPO);
}
if (materialBaseInfoPO != null) {
reservedInventory.setMaterialBaseInfoId(materialBaseInfoPO.getMaterialBaseInfoId());
}
}
}
public void importInData(List<ReservedInventory> dataList) {
LoginUser loginUser = SecurityUtils.getLoginUser();
ReserveStockInOrderDO reserveStockInOrder = new ReserveStockInOrderDO();
@@ -444,4 +444,9 @@ public class ReserveStockOutOrder extends BaseVOEntity {
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
private Date outboundTime;
@ApiModelProperty("预约业务类型")
private String reserveBusinessType;
@ApiModelProperty("预约业务类型名称")
private String reserveBusinessTypeName;
}
@@ -452,4 +452,8 @@ public class ReserveStockOutOrderPO extends BaseVOEntity {
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
private Date outboundTime;
@ApiModelProperty("预约业务类型")
private String reserveBusinessType;
@ApiModelProperty("预约业务类型名称")
private String reserveBusinessTypeName;
}
@@ -490,4 +490,8 @@ public class ReserveStockOutOrderDO extends BaseVOEntity {
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
private Date outboundTime;
@ApiModelProperty("预约业务类型")
private String reserveBusinessType;
@ApiModelProperty("预约业务类型名称")
private String reserveBusinessTypeName;
}
@@ -479,4 +479,8 @@ public class ReserveStockOutOrderDTO extends ReserveStockOutOrderBaseDTO {
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
private Date outboundTime;
@ApiModelProperty("预约业务类型")
private String reserveBusinessType;
@ApiModelProperty("预约业务类型名称")
private String reserveBusinessTypeName;
}
@@ -1,5 +1,6 @@
package com.mhd.oms.domain.reserveStockOutOrder.repository.vo;
import com.alibaba.excel.annotation.ExcelIgnore;
import com.alibaba.excel.annotation.ExcelProperty;
import com.mhd.oms.domain.reserveStockInOrder.repository.util.StringToBigDecimalConverter;
import com.mhd.oms.domain.reserveStockInOrder.repository.util.StringToDateConverter;
@@ -35,6 +36,15 @@ public class ReservedInventoryOut {
/**
* 验证结果导入后自动填充不映射Excel
* @ExcelIgnore排除在Excel列映射之外避免被自动分配列索引
*/
@ExcelIgnore
private String validationResult;
/**
* WMS库存id解析预览接口根据货物名称查询可用库存后自动填充不映射Excel
* @ExcelIgnoreLong类型字段若被自动映射到非数字列会抛出ExcelDataConvertException
*/
@ExcelIgnore
private Long materialInventoryId;
}
@@ -841,7 +841,7 @@ public class ReserveStockOutOrderApplicationService {
* @description 审核入库单
* @author ZhouGY
* @date 2024/5/21 13:53
* @param stockInOrderDO
* @param stockOutOrderDO
* @return Boolean
*/
public Boolean auditState(ReserveStockOutOrderDO stockOutOrderDO){
@@ -852,7 +852,7 @@ public class ReserveStockOutOrderApplicationService {
* @description 下发入库单
* @author ZhouGY
* @date 2024/5/21 13:53
* @param stockInOrderDO
* @param stockOutOrderDO
* @return Boolean
*/
public Boolean issueOrder(ReserveStockOutOrderDO stockOutOrderDO){
@@ -862,7 +862,7 @@ public class ReserveStockOutOrderApplicationService {
* @description 审核入库单
* @author ZhouGY
* @date 2024/5/21 13:53
* @param stockInOrderDO
* @param stockOutOrderDO
* @return Boolean
*/
public Boolean orderReject(ReserveStockOutOrderDO stockOutOrderDO){
@@ -1355,6 +1355,42 @@ public class ReserveStockOutOrderApplicationService {
return result;
}
/**
* Excel解析预览根据货物名称查询WMS对应物料的库存信息
* 可用数量大于导入数据件数的填充库存id
* 物料不存在无库存或可用数量不足时库存id保持为空不抛异常
*/
public void fillMaterialInventoryId(List<ReservedInventoryOut> dataList) {
if (CollectionUtils.isEmpty(dataList)) {
return;
}
for (ReservedInventoryOut reservedInventory : dataList) {
String goodsName = reservedInventory.getGoodsName();
BigDecimal importQuantity = reservedInventory.getQuantity() == null ? BigDecimal.ZERO : reservedInventory.getQuantity();
// 根据货物名称查询对应物料匹配不到则库存id为空
List<MaterialBaseInfoPO> materialBaseInfoPOS = reserveStockInOrderMapper.getByName(goodsName);
if (materialBaseInfoPOS == null || materialBaseInfoPOS.isEmpty()) {
continue;
}
Long materialBaseInfoId = materialBaseInfoPOS.get(0).getMaterialBaseInfoId();
// 根据物料id查询对应库存无库存则库存id为空
List<ReservationMaterialInventory> reservationMaterialInventories = reservationMaterialInventoryMapper.selectList(
new LambdaQueryWrapper<ReservationMaterialInventory>()
.eq(ReservationMaterialInventory::getMaterialBaseInfoId, materialBaseInfoId));
if (reservationMaterialInventories == null || reservationMaterialInventories.isEmpty()) {
continue;
}
// 取可用数量大于导入数据件数的库存填充库存id都不满足则库存id为空
for (ReservationMaterialInventory inventory : reservationMaterialInventories) {
BigDecimal allocationQuantity = inventory.getAllocationQuantity() == null ? BigDecimal.ZERO : inventory.getAllocationQuantity();
if (allocationQuantity.compareTo(importQuantity) > 0) {
reservedInventory.setMaterialInventoryId(inventory.getMaterialInventoryId());
break;
}
}
}
}
public void importInData(List<ReservedInventoryOut> dataList) {
LoginUser loginUser = SecurityUtils.getLoginUser();
ReserveStockOutOrderDO reserveStockOutOrder = new ReserveStockOutOrderDO();
@@ -296,6 +296,31 @@ public class ReserveStockOutOrderApi extends BaseController {
}
}
/**
* 仅解析Excel文件内容并返回不执行入库
* 同时根据货物名称查询WMS对应物料库存可用数量大于件数的返回库存id匹配不到库存id返回空
*/
@ApiOperation("解析导入Excel(仅解析不入库)")
@PostMapping("/parseExcel")
public ResponseEntity<Map<String, Object>> parseExcel(@RequestParam("file") MultipartFile file) {
List<ReservedInventoryOut> dataList = null;
try {
dataList = ExcelParseUtil.parseExcel(file);
} catch (IOException e) {
throw new RuntimeException(e);
}
// 根据货物名称查询WMS库存并填充库存id匹配不到库存id返回空
stockOutOrderApplicationService.fillMaterialInventoryId(dataList);
Map<String, Object> successResponse = new HashMap<>();
successResponse.put("code", 200);
successResponse.put("message", "Excel解析成功");
successResponse.put("dataCount", dataList.size());
successResponse.put("details", dataList);
return ResponseEntity.ok(successResponse);
}
/**
* 生成出库预约单号
*/
@@ -260,6 +260,52 @@ public class ReserveStockInOrderApi extends BaseController {
}
}
/**
* 仅解析Excel文件内容并返回不执行入库
* 同时根据货物名称匹配WMS物料并返回物料id匹配不到返回空
*/
@ApiOperation("解析导入Excel(仅解析不入库)")
@PostMapping("/parseExcel")
public ResponseEntity<Map<String, Object>> parseExcel(@RequestParam("file") MultipartFile file) {
try {
List<ReservedInventory> dataList = ExcelParseUtil.parseExcel(file);
// 根据货物名称匹配WMS物料并填充物料id匹配不到返回空
stockInOrderApplicationService.fillMaterialBaseInfoId(dataList);
Map<String, Object> successResponse = new HashMap<>();
successResponse.put("code", 200);
successResponse.put("message", "Excel解析成功");
successResponse.put("dataCount", dataList.size());
successResponse.put("details", dataList);
return ResponseEntity.ok(successResponse);
} catch (ValidationException e) {
// 数据验证失败响应
Map<String, Object> errorResponse = new HashMap<>();
errorResponse.put("code", 400);
errorResponse.put("message", "数据验证失败");
errorResponse.put("errorDetails", e.getMessage());
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(errorResponse);
} catch (IOException e) {
// 文件处理失败响应
Map<String, Object> errorResponse = new HashMap<>();
errorResponse.put("code", 500);
errorResponse.put("message", "文件处理失败");
errorResponse.put("errorDetails", e.getMessage());
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(errorResponse);
} catch (Exception e) {
// 其他未知错误响应
Map<String, Object> errorResponse = new HashMap<>();
errorResponse.put("code", 500);
errorResponse.put("message", e.getMessage());
errorResponse.put("errorDetails", e.getMessage());
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(errorResponse);
}
}
/**
* 老系统入库预约单数据导入主表+明细两个Excel文件批量导入按名称匹配基础数据
*/