仓码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文件批量导入按名称匹配基础数据
*/
@@ -95,6 +95,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="reservationOrderSource" column="RESERVATION_ORDER_SOURCE" />
<result property="outboundTime" column="OUTBOUND_TIME" />
<result property="businessOrderNo" column="BUSINESS_ORDER_NO" />
<result property="reserveBusinessType" column="RESERVE_BUSINESS_TYPE" />
<result property="reserveBusinessTypeName" column="RESERVE_BUSINESS_TYPE_NAME" />
</resultMap>
@@ -112,7 +114,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
a.COMPLETE_TIME,a.ORDER_DATE,a.TRANSPORT_MODE_CODE,a.TRANSPORT_MODE_NAME,a.SUPERVISION_MODE_CODE,a.SUPERVISION_MODE_NAME,
a.CUSTOMS_INSPECTION_FLAG,a.NEED_DECLARE_FLAG,a.NEED_TRANSPORT_FLAG,a.picture_app,a.reservation_audit_time,a.reservation_audit_name
,a.reservation_audit_id,a.issue_name,a.issue_id,a.issue_time,a.issue_status,a.tms_order_number,
a.DIRECTOR_NAME ,a.DIRECTOR_PHONE,a.DIRECTOR_ID,a.RESERVATION_ORDER_SOURCE,a.OUTBOUND_TIME
a.DIRECTOR_NAME ,a.DIRECTOR_PHONE,a.DIRECTOR_ID,a.RESERVATION_ORDER_SOURCE,a.OUTBOUND_TIME,a.RESERVE_BUSINESS_TYPE,a.RESERVE_BUSINESS_TYPE_NAME
</sql>
@@ -240,4 +240,7 @@ public class MaterialBaseInfo extends BaseVOEntity {
@ApiModelProperty(name = "组织(多个用,分开)")
private String orgId;
@ApiModelProperty(name = "是否正常物料: 0-是 1-否")
private Integer isNormalMaterial;
}
@@ -289,4 +289,7 @@ public class MaterialBaseInfoPO extends BaseVOEntity {
@ApiModelProperty(name = "组织(多个用,分开)")
private String orgId;
@ApiModelProperty(name = "是否正常物料: 0-是 1-否")
private Integer isNormalMaterial;
}
@@ -262,4 +262,7 @@ public class MaterialBaseInfoDO extends BaseVOEntity {
@ApiModelProperty(name = "组织(多个用,分开)")
private String orgId;
@ApiModelProperty(name = "是否正常物料: 0-是 1-否")
private Integer isNormalMaterial;
}
@@ -314,4 +314,6 @@ public class MaterialBaseInfoDTO extends BaseVOEntity {
@ApiModelProperty(name = "组织(多个用,分开)")
private String orgId;
@ApiModelProperty(name = "是否正常物料: 0-是 1-否")
private Integer isNormalMaterial;
}
@@ -68,6 +68,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="insureAmount" column="insure_amount" />
<result property="chargeStandard" column="charge_standard" />
<result property="chargeStandardClass" column="charge_standard_class" />
<result property="isNormalMaterial" column="is_normal_material" />
</resultMap>
@@ -77,7 +78,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
material_shape_name, a.material_size, a.material_length, a.material_width, a.material_height, a.remark, a.nullify, a.create_time, a.create_by, a.create_by_name, a.update_time, a.update_by, a.update_by_name, a.del_flag, a.common,
sku_code, a.unit_price, a.currency, a.origin_country, a.hs_code, a.declaration_unit, a.statutory_unit, a.statutory_second_unit, a.copy_code,
a.push_status,a.push_time,a.push_by,a.goods_type,a.gross_weight,a.push_by_name,a.unit,a.INSURE_AMOUNT,a.CHARGE_STANDARD,
specification_model as specification_model,nvl(b.stock_qty,0) as stock_quantity,c.charge_standard as charge_standard_class
specification_model as specification_model,nvl(b.stock_qty,0) as stock_quantity,c.charge_standard as charge_standard_class,a.is_normal_material
from material_base_info a left join (
select material_base_info_id, sum(INVENTORY_QUANTITY) as stock_qty from MATERIAL_INVENTORY group by material_base_info_id