Commit d58b4b1e by zhangtw

Merge remote-tracking branch 'origin/master'

parents 89ce3a06 4421478d
...@@ -92,15 +92,15 @@ ...@@ -92,15 +92,15 @@
style="width: 100%" style="width: 100%"
/> />
</el-form-item> </el-form-item>
<el-form-item label="出库类型" prop="orderTypeId"> <el-form-item label="订单类型" prop="orderTypeId">
<el-select <el-select
v-model="queryParams.orderTypeId" v-model="queryParams.orderTypeId"
placeholder="请输入出库类型" placeholder="请输入订单类型"
clearable clearable
style="width: 150px" style="width: 150px"
> >
<el-option <el-option
v-for="dict in dict.type.outbound_order_type" v-for="dict in dict.type.order_type"
:key="dict.value" :key="dict.value"
:label="dict.label" :label="dict.label"
:value="Number(dict.value)" :value="Number(dict.value)"
...@@ -172,16 +172,9 @@ ...@@ -172,16 +172,9 @@
<el-table-column type="selection" width="55" align="center" fixed /> <el-table-column type="selection" width="55" align="center" fixed />
<el-table-column label="出库单号" align="center" prop="orderId" min-width="150" fixed/> <el-table-column label="出库单号" align="center" prop="orderId" min-width="150" fixed/>
<el-table-column label="系统编号" align="center" prop="systemNo" min-width="150" /> <el-table-column label="系统编号" align="center" prop="systemNo" min-width="150" />
<el-table-column label="出库类型" align="center" prop="orderTypeId" min-width="120"> <el-table-column label="订单类型" align="center" prop="orderTypeId" min-width="120">
<template slot-scope="scope"> <template slot-scope="scope">
<dict-tag v-if="dict.type.outbound_order_type" :options="dict.type.outbound_order_type" :value="scope.row.orderTypeId"/> <dict-tag v-if="dict.type.order_type" :options="dict.type.order_type" :value="scope.row.orderTypeId"/>
<span v-else>-</span>
</template>
</el-table-column>
<!-- 新增:订单类型列 -->
<el-table-column label="订单类型" align="center" prop="orderType" min-width="120">
<template slot-scope="scope">
<dict-tag v-if="dict.type.order_type" :options="dict.type.order_type" :value="scope.row.orderType"/>
<span v-else>-</span> <span v-else>-</span>
</template> </template>
</el-table-column> </el-table-column>
...@@ -277,10 +270,10 @@ ...@@ -277,10 +270,10 @@
</el-row> </el-row>
<el-row :gutter="20"> <el-row :gutter="20">
<el-col :span="12"> <el-col :span="12">
<el-form-item label="出库类型" prop="orderTypeId"> <el-form-item label="订单类型" prop="orderTypeId">
<el-select v-model="form.orderTypeId" placeholder="请选择出库类型" :disabled="isViewDetail || formDisabled.orderTypeId" style="width: 100%"> <el-select v-model="form.orderTypeId" placeholder="请选择订单类型" :disabled="isViewDetail || formDisabled.orderTypeId" style="width: 100%">
<el-option <el-option
v-for="item in dict.type.outbound_order_type" v-for="item in dict.type.order_type"
:key="item.value" :key="item.value"
:label="item.label" :label="item.label"
:value="item.value" :value="item.value"
...@@ -290,7 +283,6 @@ ...@@ -290,7 +283,6 @@
</el-select> </el-select>
</el-form-item> </el-form-item>
</el-col> </el-col>
<!-- 新增:订单类型表单项 -->
<el-col :span="12"> <el-col :span="12">
<el-form-item label="仓库" prop="warehouseId"> <el-form-item label="仓库" prop="warehouseId">
<el-input <el-input
...@@ -357,20 +349,7 @@ ...@@ -357,20 +349,7 @@
</el-input> </el-input>
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :span="12"> <!-- 订单类型已合并到出库类型控件(使用 orderTypeId 字段) -->
<el-form-item label="订单类型" prop="orderType">
<el-select v-model="form.orderType" placeholder="请选择订单类型" :disabled="isViewDetail || formDisabled.orderType" style="width: 100%">
<el-option
v-for="item in dict.type.order_type"
:key="item.value"
:label="item.label"
:value="item.value"
>
<span style="margin-left: 8px;">{{ item.label }}</span>
</el-option>
</el-select>
</el-form-item>
</el-col>
</el-row> </el-row>
<el-row :gutter="20"> <el-row :gutter="20">
<el-col :span="12"> <el-col :span="12">
...@@ -598,7 +577,6 @@ export default { ...@@ -598,7 +577,6 @@ export default {
orderId: false, orderId: false,
systemNo: false, systemNo: false,
orderTypeId: false, orderTypeId: false,
orderType: false, // 新增:订单类型禁用控制
batchCode: false, batchCode: false,
warehouseId: false, warehouseId: false,
ownerId: false, ownerId: false,
...@@ -611,7 +589,6 @@ export default { ...@@ -611,7 +589,6 @@ export default {
orderId: null, orderId: null,
systemNo: null, systemNo: null,
orderTypeId: null, orderTypeId: null,
orderType: null, // 新增:订单类型查询参数
batchCode: null, batchCode: null,
warehouseId: null, warehouseId: null,
ownerId: null, ownerId: null,
...@@ -635,14 +612,14 @@ export default { ...@@ -635,14 +612,14 @@ export default {
ownerName: '', ownerName: '',
ownerId: '', // 【新增】补充货主ID字段 ownerId: '', // 【新增】补充货主ID字段
warehouseId: '', // 【新增】补充仓库ID字段 warehouseId: '', // 【新增】补充仓库ID字段
orderType: null, // 新增:订单类型表单字段 orderTypeId: null, // 使用 orderTypeId 表示订单类型
}, },
// 表单校验规则 // 表单校验规则
rules: { rules: {
orderId: [{ required: true, message: '请输入出库单号', trigger: 'blur' }], orderId: [{ required: true, message: '请输入出库单号', trigger: 'blur' }],
warehouseId: [{ required: true, message: '请选择仓库', trigger: 'blur' }], warehouseId: [{ required: true, message: '请选择仓库', trigger: 'blur' }],
inboundDate: [{ required: true, message: '请选择出库日期', trigger: 'change' }], inboundDate: [{ required: true, message: '请选择出库日期', trigger: 'change' }],
orderTypeId: [{ required: true, message: '请选择出库类型', trigger: 'change' }], orderTypeId: [{ required: true, message: '请选择订单类型', trigger: 'change' }],
batchCode: [{ required: true, message: '请选输入批次号', trigger: 'change' }], batchCode: [{ required: true, message: '请选输入批次号', trigger: 'change' }],
}, },
// 货主/仓库选择相关 // 货主/仓库选择相关
...@@ -1173,7 +1150,6 @@ export default { ...@@ -1173,7 +1150,6 @@ export default {
outboundOrderId: null, // 主表ID,由后端生成 outboundOrderId: null, // 主表ID,由后端生成
systemNo: null, systemNo: null,
orderTypeId: null, orderTypeId: null,
orderType: null, // 新增:订单类型重置
batchCode: null, batchCode: null,
warehouseId: null, warehouseId: null,
warehouseName: '', warehouseName: '',
...@@ -1199,7 +1175,6 @@ export default { ...@@ -1199,7 +1175,6 @@ export default {
orderId: false, orderId: false,
systemNo: false, systemNo: false,
orderTypeId: false, orderTypeId: false,
orderType: false, // 新增:订单类型禁用重置
batchCode: false, batchCode: false,
warehouseId: false, warehouseId: false,
ownerId: false, ownerId: false,
...@@ -1235,7 +1210,6 @@ export default { ...@@ -1235,7 +1210,6 @@ export default {
orderId: null, orderId: null,
systemNo: null, systemNo: null,
orderTypeId: null, orderTypeId: null,
orderType: null, // 新增:订单类型重置
batchCode: null, batchCode: null,
warehouseId: null, warehouseId: null,
ownerId: null, ownerId: null,
...@@ -1272,7 +1246,6 @@ export default { ...@@ -1272,7 +1246,6 @@ export default {
orderId: false, orderId: false,
systemNo: false, systemNo: false,
orderTypeId: false, orderTypeId: false,
orderType: false, // 新增:订单类型启用
batchCode: false, batchCode: false,
warehouseId: false, warehouseId: false,
ownerId: false, ownerId: false,
...@@ -1305,7 +1278,7 @@ export default { ...@@ -1305,7 +1278,7 @@ export default {
totalAmount: 0.00, totalAmount: 0.00,
ownerId: response.data.ownerId || '', // 【新增】赋值货主ID ownerId: response.data.ownerId || '', // 【新增】赋值货主ID
warehouseId: response.data.warehouseId || '', // 【新增】赋值仓库ID warehouseId: response.data.warehouseId || '', // 【新增】赋值仓库ID
orderType: response.data.orderType || null, // 新增:订单类型回显 orderTypeId: response.data.orderType || response.data.orderTypeId || null, // 订单类型回显到 orderTypeId
} }
if (response.data && response.data.outboundOrderItemsList && Array.isArray(response.data.outboundOrderItemsList)) { if (response.data && response.data.outboundOrderItemsList && Array.isArray(response.data.outboundOrderItemsList)) {
// 按物料ID分组 + 库存ID去重 // 按物料ID分组 + 库存ID去重
...@@ -1369,7 +1342,6 @@ export default { ...@@ -1369,7 +1342,6 @@ export default {
orderId: true, // 编辑时禁用出货单号修改 orderId: true, // 编辑时禁用出货单号修改
systemNo: true, systemNo: true,
orderTypeId: true, orderTypeId: true,
orderType: true, // 新增:订单类型禁用
batchCode: true, batchCode: true,
warehouseId: true, warehouseId: true,
ownerId: true, ownerId: true,
...@@ -1386,7 +1358,7 @@ export default { ...@@ -1386,7 +1358,7 @@ export default {
totalAmount: 0.00, totalAmount: 0.00,
ownerId: response.data.ownerId || '', // 【新增】赋值货主ID ownerId: response.data.ownerId || '', // 【新增】赋值货主ID
warehouseId: response.data.warehouseId || '', // 【新增】赋值仓库ID warehouseId: response.data.warehouseId || '', // 【新增】赋值仓库ID
orderType: response.data.orderType || null, // 新增:订单类型回显 orderTypeId: response.data.orderType || response.data.orderTypeId || null, // 订单类型回显到 orderTypeId
} }
console.log("this.form",this.form) console.log("this.form",this.form)
if (response.data && response.data.outboundOrderItemsList && Array.isArray(response.data.outboundOrderItemsList)) { if (response.data && response.data.outboundOrderItemsList && Array.isArray(response.data.outboundOrderItemsList)) {
...@@ -1491,7 +1463,7 @@ export default { ...@@ -1491,7 +1463,7 @@ export default {
...this.form, ...this.form,
outboundOrderId: this.form.id, outboundOrderId: this.form.id,
orderId: this.form.orderId, orderId: this.form.orderId,
orderType: this.form.orderType, // 新增:提交订单类型 orderType: this.form.orderTypeId, // 新增:提交订单类型(使用 orderTypeId 字段)
outboundOrderItemsList: uniqueDetails.map(item => { outboundOrderItemsList: uniqueDetails.map(item => {
const { index, materialUuids, warehouseName, locationName, ...rest } = item const { index, materialUuids, warehouseName, locationName, ...rest } = item
return { return {
...@@ -1564,7 +1536,7 @@ export default { ...@@ -1564,7 +1536,7 @@ export default {
const exportParams = { const exportParams = {
...restParams, ...restParams,
outboundOrderId: this.queryParams.orderId, // 映射导出参数 outboundOrderId: this.queryParams.orderId, // 映射导出参数
orderType: this.queryParams.orderType, // 新增:导出订单类型参数 orderType: this.queryParams.orderTypeId, // 新增:导出订单类型参数
// 拆分日期范围 // 拆分日期范围
startDate: dateRange ? dateRange[0] : null, startDate: dateRange ? dateRange[0] : null,
endDate: dateRange ? dateRange[1] : null endDate: dateRange ? dateRange[1] : null
......
...@@ -27,7 +27,8 @@ public class OutboundTemplateVO extends BaseEntity { ...@@ -27,7 +27,8 @@ public class OutboundTemplateVO extends BaseEntity {
@Excel(name = "日期", width = 30, dateFormat = "yyyy-MM-dd") @Excel(name = "日期", width = 30, dateFormat = "yyyy-MM-dd")
private Date inboundDate; private Date inboundDate;
@Excel(name = "出库分类", width = 30,dictType = "outbound_order_type") /** 订单类型 */
@Excel(name = "订单类型")
private String orderTypeId; private String orderTypeId;
/** SAP号 */ /** SAP号 */
...@@ -109,9 +110,6 @@ public class OutboundTemplateVO extends BaseEntity { ...@@ -109,9 +110,6 @@ public class OutboundTemplateVO extends BaseEntity {
@Excel(name = "系统单号") @Excel(name = "系统单号")
private String systemNo; private String systemNo;
/** 订单类型 */
@Excel(name = "订单类型")
private String orderType;
/** 货主ID */ /** 货主ID */
private String ownerId; private String ownerId;
......
...@@ -194,13 +194,21 @@ public class OutboundOrdersServiceImpl implements IOutboundOrdersService { ...@@ -194,13 +194,21 @@ public class OutboundOrdersServiceImpl implements IOutboundOrdersService {
* 核心库存扣减逻辑(确保每个明细仅对应一个库存ID) * 核心库存扣减逻辑(确保每个明细仅对应一个库存ID)
*/ */
private Map<String, List<Map<String, Object>>> deductInventory(List<OutboundOrderItems> outboundOrderItems, String updateUser, Date updateTime) { private Map<String, List<Map<String, Object>>> deductInventory(List<OutboundOrderItems> outboundOrderItems, String updateUser, Date updateTime) {
return deductInventory(outboundOrderItems, updateUser, updateTime, false);
}
/**
* 核心库存扣减逻辑(确保每个明细仅对应一个库存ID)
* 增加参数 ignoreInventoryType:为 true 时在库存分组与扣减时忽略库存类型(用于导入场景)
*/
private Map<String, List<Map<String, Object>>> deductInventory(List<OutboundOrderItems> outboundOrderItems, String updateUser, Date updateTime, boolean ignoreInventoryType) {
if (CollectionUtils.isEmpty(outboundOrderItems)) { if (CollectionUtils.isEmpty(outboundOrderItems)) {
return Collections.emptyMap(); return Collections.emptyMap();
} }
Map<String, List<Map<String, Object>>> deductRecordMap = new HashMap<>(); Map<String, List<Map<String, Object>>> deductRecordMap = new HashMap<>();
Map<String, List<Inventory>> inventoryGroupMap = this.loadInventoryGroupMap(); Map<String, List<Inventory>> inventoryGroupMap = this.loadInventoryGroupMap(ignoreInventoryType);
Map<String, Long> deductQtyMap = this.buildDeductQtyMap(outboundOrderItems); Map<String, Long> deductQtyMap = this.buildDeductQtyMap(outboundOrderItems, ignoreInventoryType);
Map<String, Inventory> toUpdateInventoryMap = new LinkedHashMap<>(); Map<String, Inventory> toUpdateInventoryMap = new LinkedHashMap<>();
for (Map.Entry<String, Long> entry : deductQtyMap.entrySet()) { for (Map.Entry<String, Long> entry : deductQtyMap.entrySet()) {
...@@ -213,7 +221,7 @@ public class OutboundOrdersServiceImpl implements IOutboundOrdersService { ...@@ -213,7 +221,7 @@ public class OutboundOrdersServiceImpl implements IOutboundOrdersService {
String locationId = keyParts.length > 1 ? keyParts[1] : ""; String locationId = keyParts.length > 1 ? keyParts[1] : "";
String inventoryType = keyParts.length > 2 ? keyParts[2] : ""; String inventoryType = keyParts.length > 2 ? keyParts[2] : "";
String itemId = outboundOrderItems.stream() String itemId = outboundOrderItems.stream()
.filter(item -> key.equals(buildDeductKey(item))) .filter(item -> key.equals(buildDeductKey(item, ignoreInventoryType)))
.map(OutboundOrderItems::getId) .map(OutboundOrderItems::getId)
.findFirst() .findFirst()
.orElse(null); .orElse(null);
...@@ -499,6 +507,29 @@ public class OutboundOrdersServiceImpl implements IOutboundOrdersService { ...@@ -499,6 +507,29 @@ public class OutboundOrdersServiceImpl implements IOutboundOrdersService {
} }
/** /**
* 预加载库存分组Map(按维度Key分组)
* 可选是否忽略库存类型(用于导入时不按orderType过滤库存)
*/
private Map<String, List<Inventory>> loadInventoryGroupMap(boolean ignoreInventoryType) {
Inventory query = new Inventory();
query.setInventoryStatus(1L); // 只查可用状态库存
query.setIsUsed(1L); // 只查启用的库存
List<Inventory> allInventory = inventoryMapper.selectInventoryList(query);
Map<String, List<Inventory>> inventoryGroupMap = new LinkedHashMap<>();
for (Inventory inv : allInventory) {
String invTypePart = ignoreInventoryType ? "" : Optional.ofNullable(inv.getInventoryType()).map(String::valueOf).orElse("");
String key = buildInventoryKey(
inv.getMaterialId(),
inv.getLocationId(),
invTypePart
);
inventoryGroupMap.computeIfAbsent(key, k -> new ArrayList<>()).add(inv);
}
return inventoryGroupMap;
}
/**
* 构建扣减数量Map * 构建扣减数量Map
* Key规则:物料ID_库位ID_库存类型 * Key规则:物料ID_库位ID_库存类型
*/ */
...@@ -513,6 +544,20 @@ public class OutboundOrdersServiceImpl implements IOutboundOrdersService { ...@@ -513,6 +544,20 @@ public class OutboundOrdersServiceImpl implements IOutboundOrdersService {
} }
/** /**
* 构建扣减数量Map(可选择是否忽略库存类型)
* Key规则:物料ID_库位ID_库存类型(inventoryType 可为空)
*/
private Map<String, Long> buildDeductQtyMap(List<OutboundOrderItems> items, boolean ignoreInventoryType) {
Map<String, Long> deductQtyMap = new HashMap<>();
for (OutboundOrderItems item : items) {
String key = buildDeductKey(item, ignoreInventoryType);
Long qty = Optional.ofNullable(item.getActualQuantity()).orElse(0L);
deductQtyMap.put(key, deductQtyMap.getOrDefault(key, 0L) + qty);
}
return deductQtyMap;
}
/**
* 构建明细的扣减Key * 构建明细的扣减Key
*/ */
private String buildDeductKey(OutboundOrderItems item) { private String buildDeductKey(OutboundOrderItems item) {
...@@ -524,6 +569,18 @@ public class OutboundOrdersServiceImpl implements IOutboundOrdersService { ...@@ -524,6 +569,18 @@ public class OutboundOrdersServiceImpl implements IOutboundOrdersService {
} }
/** /**
* 构建明细的扣减Key(可选择是否忽略库存类型)
*/
private String buildDeductKey(OutboundOrderItems item, boolean ignoreInventoryType) {
String invType = ignoreInventoryType ? "" : Optional.ofNullable(item.getInventoryType()).map(String::valueOf).orElse("");
return buildInventoryKey(
item.getMaterialId(),
item.getLocationId(),
invType
);
}
/**
* 构建库存Key:物料ID_库位ID_库存类型 * 构建库存Key:物料ID_库位ID_库存类型
*/ */
private String buildInventoryKey(String materialId, String locationId, String inventoryType) { private String buildInventoryKey(String materialId, String locationId, String inventoryType) {
...@@ -839,7 +896,8 @@ public class OutboundOrdersServiceImpl implements IOutboundOrdersService { ...@@ -839,7 +896,8 @@ public class OutboundOrdersServiceImpl implements IOutboundOrdersService {
for (Map.Entry<String, List<OutboundOrderItems>> entry : allItemListMap.entrySet()) { for (Map.Entry<String, List<OutboundOrderItems>> entry : allItemListMap.entrySet()) {
List<OutboundOrderItems> itemList = entry.getValue(); List<OutboundOrderItems> itemList = entry.getValue();
// 执行库存扣减(精准提取被扣减的库存ID) // 执行库存扣减(精准提取被扣减的库存ID)
Map<String, List<Map<String, Object>>> deductRecordMap = deductInventory(itemList, operId, now); // 导入场景:orderType 不参与库存查询,因此传入 ignoreInventoryType = true
Map<String, List<Map<String, Object>>> deductRecordMap = deductInventory(itemList, operId, now, true);
// 处理无库位明细拆分(仅拆分实际被扣减的库存ID) // 处理无库位明细拆分(仅拆分实际被扣减的库存ID)
handleNoLocationItemSplit(itemList, deductRecordMap, operId, now); handleNoLocationItemSplit(itemList, deductRecordMap, operId, now);
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论