feat: 新增指定发货功能,支持直接出库已入库未发货的SN

cp_1.0.0
kangwenjing 2026-10-26 14:06:56 +08:00
parent 4398d00146
commit 8494a26570
7 changed files with 101 additions and 8 deletions

View File

@ -157,6 +157,8 @@ export default {
tabDataMap: {},
// 各采购单页签是否处于导入态:{ [purchaseNo]: true }
isImportedTabs: {},
// 各采购单页签是否为“指定发货”:{ [purchaseNo]: true }
assignTabs: {},
// 切换页签恢复勾选期间忽略 selection-change
suppressSelectionChange: false,
// 请求序号,避免快速切换页签时旧响应覆盖新页签
@ -392,11 +394,11 @@ export default {
- Number(this.productData.deliveryGenerateQuantity || 0)
- Number(this.productData.deliveryConfirmQuantity || 0);
},
// 所有导入页签的已选行,用于提交 productSnDataList
// 所有导入页签的已选行,用于提交 productSnDataList(指定发货页签不参与,走 assignSnDataList)
getImportedProductSnDataList() {
const list = [];
Object.keys(this.isImportedTabs).forEach(purchaseNo => {
if (!this.isImportedTabs[purchaseNo]) return;
if (!this.isImportedTabs[purchaseNo] || this.assignTabs[purchaseNo]) return;
const rows = this.selectedSnMap[purchaseNo] || {};
Object.keys(rows).forEach(productSn => {
list.push(rows[productSn]);
@ -404,6 +406,21 @@ export default {
});
return list;
},
// 所有指定发货页签的已选行,用于提交 assignSnDataList
getAssignSnDataList() {
const list = [];
Object.keys(this.assignTabs).forEach(purchaseNo => {
if (!this.assignTabs[purchaseNo]) return;
const rows = this.selectedSnMap[purchaseNo] || {};
Object.keys(rows).forEach(productSn => {
list.push({
productSn,
licenseKey: rows[productSn].licenseKey
});
});
});
return list;
},
handleDownloadTemplate() {
exportDownloadTemplateData({
productCode: this.queryParams.productCode,
@ -506,6 +523,7 @@ export default {
}
const purchaseNo = this.activePurchaseNo;
this.$set(this.isImportedTabs, purchaseNo, true);
this.$set(this.assignTabs, purchaseNo, false);
this.$set(this.tabDataMap, purchaseNo, {
rows,
total: rows.length,
@ -549,6 +567,7 @@ export default {
}
this.$set(this.isImportedTabs, purchaseNo, true);
this.$set(this.assignTabs, purchaseNo, true);
this.$set(this.tabDataMap, purchaseNo, {
rows,
total: rows.length,
@ -594,6 +613,7 @@ export default {
outerCode: this.outerData.outerCode,
detailId: this.productData.id,
productSnDataList: this.getImportedProductSnDataList(),
assignSnDataList: this.getAssignSnDataList(),
orderCode: this.queryParams.orderCode,
};
@ -623,6 +643,7 @@ export default {
this.selectedSnMap = {};
this.tabDataMap = {};
this.isImportedTabs = {};
this.assignTabs = {};
this.suppressSelectionChange = false;
this.lastActivePurchaseNo = '';
this.loadedTab = '';

View File

@ -58,7 +58,7 @@ spring:
time-zone: GMT+8
date-format: yyyy-MM-dd HH:mm:ss
profiles:
active: dev
active: prod
# 文件上传
servlet:
multipart:

View File

@ -1,8 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<!-- 日志存放路径 -->
<!-- <property name="log.path" value="/Users/jiliu/WorkSpace/java/RuoYi/logs" />-->
<property name="log.path" value="/Users/kangwenjing/Downloads/project/logs" />
<property name="log.path" value="/Users/jiliu/WorkSpace/java/RuoYi/logs" />
<!-- <property name="log.path" value="/Users/kangwenjing/Downloads/project/logs" />-->
<!-- 日志输出格式 -->
<property name="log.pattern" value="%d{HH:mm:ss.SSS} [%thread] %-5level %logger{20} - [%method,%line] - %msg%n" />

View File

@ -79,6 +79,8 @@ public class InventoryDelivery extends BaseEntity
private String approveStatus;
private List<String> productSnList;
private List<InventoryInfo> productSnDataList;
/** 指定发货的SN明细:SN已存在于库存且未发货,发货时只更新库存为出库,不再生成入库单 */
private List<InventoryInfo> assignSnDataList;

View File

@ -46,6 +46,15 @@ public interface InventoryInfoMapper
*/
public int updateInventoryInfo(InventoryInfo inventoryInfo);
/**
* 指定发货:将已入库且未发货的SN直接更新为出库
* 只更新出库相关字段,保留入库单号、仓库、入库价、应付账单号等原值
*
* @param inventoryInfo 产品库存
* @return 结果
*/
public int updateOutForAssignDelivery(InventoryInfo inventoryInfo);
/**
* 删除产品库存
*

View File

@ -143,7 +143,8 @@ public class InventoryDeliveryServiceImpl implements IInventoryDeliveryService,
List<String> productSnList = inventoryDelivery.getProductSnList();
List<InventoryInfo> productSnDataList = inventoryDelivery.getProductSnDataList();
if (CollUtil.isEmpty(productSnList) && CollUtil.isEmpty(productSnDataList)) {
List<InventoryInfo> assignSnDataList = inventoryDelivery.getAssignSnDataList();
if (CollUtil.isEmpty(productSnList) && CollUtil.isEmpty(productSnDataList) && CollUtil.isEmpty(assignSnDataList)) {
throw new ServiceException("发货清单为空,保存失败");
}
@ -267,7 +268,45 @@ public class InventoryDeliveryServiceImpl implements IInventoryDeliveryService,
BigDecimal bigDecimal = inventoryOuterMapper.selectOutPriceByCode(inventoryDelivery.getOuterCode());
List<OmsInventoryDeliveryDetail> detailList = new ArrayList<>();
if (CollUtil.isEmpty(productSnDataList)) {
// 已由“指定发货/导入”清单处理的SN,用于校验手工勾选的SN是否被遗漏
Set<String> handledSnSet = new HashSet<>();
// ══════════════════════════════════════════════════════
// 指定发货:SN已入库且未发货,直接把库存置为出库
// 不生成入库单/应付单,不增加可用库存;保留入库单号、仓库、入库价、应付账单号等原值
// ══════════════════════════════════════════════════════
if (CollUtil.isNotEmpty(assignSnDataList)) {
List<String> assignSnList = assignSnDataList.stream().map(InventoryInfo::getProductSn).collect(Collectors.toList());
Map<String, InventoryInfo> existingAssignMap = new HashMap<>();
for (InventoryInfo existInfo : inventoryInfoMapper.listByProductSnList(assignSnList)) {
existingAssignMap.put(existInfo.getProductSn(), existInfo);
}
for (InventoryInfo assignInfo : assignSnDataList) {
String productSn = assignInfo.getProductSn();
InventoryInfo existInfo = existingAssignMap.get(productSn);
if (existInfo == null) {
throw new ServiceException(String.format("SN码[%s]在库存中不存在,发货失败", productSn));
}
if (StringUtils.isNotEmpty(existInfo.getOuterCode()) || StringUtils.isNotEmpty(existInfo.getOrderCode())) {
throw new ServiceException(String.format("SN码[%s]已发货或已绑定订单,发货失败", productSn));
}
InventoryInfo updateInfo = new InventoryInfo();
updateInfo.setProductSn(productSn);
updateInfo.setInventoryStatus(InventoryInfo.InventoryStatusEnum.OUTER.getCode());
updateInfo.setOuterCode(inventoryDelivery.getOuterCode());
updateInfo.setOrderCode(inventoryDelivery.getOrderCode());
updateInfo.setOuterPrice(bigDecimal);
updateInfo.setLicenseKey(assignInfo.getLicenseKey());
updateInfo.setUpdateBy(currentUserId);
updateInfo.setUpdateTime(nowDate);
inventoryInfoMapper.updateOutForAssignDelivery(updateInfo);
handledSnSet.add(productSn);
OmsInventoryDeliveryDetail detail = new OmsInventoryDeliveryDetail();
detail.setProductSn(productSn);
detailList.add(detail);
}
}
if (CollUtil.isEmpty(productSnDataList) && CollUtil.isEmpty(assignSnDataList)) {
List<InventoryInfo> inventoryInfoList = productSnList.stream().map(item -> {
InventoryInfo info = new InventoryInfo();
info.setProductSn(item);
@ -287,7 +326,7 @@ public class InventoryDeliveryServiceImpl implements IInventoryDeliveryService,
if (!maintenanceOnly) {
inventoryInfoService.saveBatch(inventoryInfoList);
}
} else {
} else if (CollUtil.isNotEmpty(productSnDataList)) {
Long warehouseId = productSnDataList.get(0).getWarehouseId();
if (warehouseId!=null && !warehouseId.equals(inventoryDelivery.getWarehouseId())){
throw new ServiceException("发货数据仓库与出库单仓库不一致,请确认后重试");
@ -299,12 +338,20 @@ public class InventoryDeliveryServiceImpl implements IInventoryDeliveryService,
inventoryInfo.setUpdateTime(nowDate);
inventoryInfo.setOuterPrice(bigDecimal);
inventoryInfo.setOrderCode(inventoryDelivery.getOrderCode());
handledSnSet.add(inventoryInfo.getProductSn());
OmsInventoryDeliveryDetail detail = new OmsInventoryDeliveryDetail();
detail.setProductSn(inventoryInfo.getProductSn());
detailList.add(detail);
}
omsInventoryInnerService.importByOuter(productSnDataList, inventoryDelivery.getProductCode(), inventoryDelivery.getPurchaseNo(), inventoryDelivery.getItemId());
}
// 指定发货/导入与手工勾选混用时,避免手工勾选的SN被静默丢弃
if ((CollUtil.isNotEmpty(productSnDataList) || CollUtil.isNotEmpty(assignSnDataList)) && CollUtil.isNotEmpty(productSnList)) {
List<String> unhandledSnList = productSnList.stream().filter(item -> !handledSnSet.contains(item)).collect(Collectors.toList());
if (CollUtil.isNotEmpty(unhandledSnList)) {
throw new ServiceException(String.format("SN码%s未参与本次指定发货/导入清单,请确认发货方式后重试", unhandledSnList));
}
}
InventoryOuterDetail inventoryOuterDetail = new InventoryOuterDetail();
inventoryOuterDetail.setId(inventoryDelivery.getDetailId());
inventoryOuterDetail.setWarehouseId(inventoryDelivery.getWarehouseId());

View File

@ -228,6 +228,20 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</trim>
where id = #{id}
</update>
<!-- 指定发货:SN已入库未发货,直接置为出库;只动出库字段,保留入库单号/仓库/入库价/应付账单号 -->
<update id="updateOutForAssignDelivery" parameterType="InventoryInfo">
update oms_inventory_info
set inventory_status = #{inventoryStatus},
outer_code = #{outerCode},
order_code = #{orderCode},
outer_price = #{outerPrice},
update_by = #{updateBy},
update_time = #{updateTime}
<if test="licenseKey != null and licenseKey != ''">
, license_key = #{licenseKey}
</if>
where product_sn = #{productSn}
</update>
<update id="clearOutInfo">
update oms_inventory_info
set inventory_status = 0,outer_code=null