查询优化,新增酸连轧页面
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -220,8 +220,8 @@
|
||||
<script>
|
||||
import { getMaterialCoil, mergeMaterialCoil } from '@/api/wms/coil';
|
||||
import { listWarehouse } from '@/api/wms/warehouse';
|
||||
import { listRawMaterial } from '@/api/wms/rawMaterial';
|
||||
import { listProduct } from '@/api/wms/product';
|
||||
import { listRawMaterialWithBom } from '@/api/wms/rawMaterial';
|
||||
import { listProductWithBom } from '@/api/wms/product';
|
||||
import { listPendingAction, completeAction } from '@/api/wms/pendingAction';
|
||||
import CoilSelector from '@/components/CoilSelector';
|
||||
import ActualWarehouseSelect from "@/components/KLPService/ActualWarehouseSelect";
|
||||
@@ -259,12 +259,9 @@ export default {
|
||||
currentSelectIndex: -1,
|
||||
// 库区列表
|
||||
warehouseList: [],
|
||||
// 原材料和产品列表
|
||||
// 原材料和产品列表(实时搜索,不再保存完整备份)
|
||||
rawMaterialList: [],
|
||||
productList: [],
|
||||
// 原始完整列表备份(用于搜索过滤)
|
||||
allRawMaterials: [],
|
||||
allProducts: [],
|
||||
itemSearchLoading: false,
|
||||
// 只读模式
|
||||
readonly: false,
|
||||
@@ -317,8 +314,8 @@ export default {
|
||||
// 加载库区列表
|
||||
await this.loadWarehouses();
|
||||
|
||||
// 🔥 页面加载时直接加载所有原料和产品列表
|
||||
await this.loadAllItems();
|
||||
// 不再一次性加载所有数据,改为实时搜索
|
||||
// await this.loadAllItems();
|
||||
|
||||
// 从路由参数获取coilId、actionId和readonly
|
||||
const coilId = this.$route.query.coilId;
|
||||
@@ -378,15 +375,15 @@ export default {
|
||||
// 清空物品选择
|
||||
this.$set(this.targetCoil, 'itemId', null);
|
||||
|
||||
// 根据材料类型设置物品类型并恢复完整列表
|
||||
// 根据材料类型设置物品类型
|
||||
if (value === '成品') {
|
||||
this.$set(this.targetCoil, 'itemType', 'product');
|
||||
// 恢复完整产品列表
|
||||
this.productList = [...this.allProducts];
|
||||
// 清空列表,等待用户搜索
|
||||
this.productList = [];
|
||||
} else if (value === '原料' || value === '废品') {
|
||||
this.$set(this.targetCoil, 'itemType', 'raw_material');
|
||||
// 恢复完整原料列表
|
||||
this.rawMaterialList = [...this.allRawMaterials];
|
||||
// 清空列表,等待用户搜索
|
||||
this.rawMaterialList = [];
|
||||
}
|
||||
},
|
||||
|
||||
@@ -435,10 +432,7 @@ export default {
|
||||
this.targetCoil.warehouseId = data.warehouseId;
|
||||
this.targetCoil.actualWarehouseId = data.actualWarehouseId;
|
||||
|
||||
// 加载对应的物品列表
|
||||
if (data.itemType) {
|
||||
await this.loadItemList(data.itemType);
|
||||
}
|
||||
// 不再预加载物品列表,改为实时搜索
|
||||
}
|
||||
} catch (error) {
|
||||
this.$message.error('加载钢卷信息失败');
|
||||
@@ -576,113 +570,59 @@ export default {
|
||||
}
|
||||
},
|
||||
|
||||
// 页面加载时一次性加载所有原料和产品列表
|
||||
async loadAllItems() {
|
||||
try {
|
||||
// 同时加载原料和产品
|
||||
const [rawMaterialRes, productRes] = await Promise.all([
|
||||
listRawMaterial({ pageNum: 1, pageSize: 99999, withBom: true }),
|
||||
listProduct({ pageNum: 1, pageSize: 99999, withBom: true })
|
||||
]);
|
||||
// 已移除 loadAllItems,改为实时搜索
|
||||
|
||||
if (rawMaterialRes.code === 200) {
|
||||
this.rawMaterialList = rawMaterialRes.rows || [];
|
||||
this.allRawMaterials = rawMaterialRes.rows || []; // 保存完整备份
|
||||
}
|
||||
// 已移除 loadItemList,改为实时搜索
|
||||
|
||||
if (productRes.code === 200) {
|
||||
this.productList = productRes.rows || [];
|
||||
this.allProducts = productRes.rows || []; // 保存完整备份
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('加载物品列表失败', error);
|
||||
}
|
||||
},
|
||||
|
||||
// 加载物品列表(根据类型)
|
||||
async loadItemList(itemType) {
|
||||
if (!itemType) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
this.itemSearchLoading = true;
|
||||
if (itemType === 'raw_material') {
|
||||
const response = await listRawMaterial({
|
||||
pageNum: 1,
|
||||
pageSize: 100,
|
||||
withBom: true
|
||||
});
|
||||
if (response.code === 200) {
|
||||
this.rawMaterialList = response.rows || [];
|
||||
}
|
||||
} else if (itemType === 'product') {
|
||||
const response = await listProduct({
|
||||
pageNum: 1,
|
||||
pageSize: 100,
|
||||
withBom: true
|
||||
});
|
||||
if (response.code === 200) {
|
||||
this.productList = response.rows || [];
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('merge.vue 加载物品列表失败', error);
|
||||
} finally {
|
||||
this.itemSearchLoading = false;
|
||||
}
|
||||
},
|
||||
|
||||
// 搜索物品(前端过滤,支持名称和规格搜索)
|
||||
// 实时搜索物品(后端搜索)
|
||||
async searchItems(query) {
|
||||
if (!this.targetCoil.itemType) {
|
||||
this.$message.warning('请先选择材料类型');
|
||||
return;
|
||||
}
|
||||
|
||||
// 如果没有输入,恢复完整列表
|
||||
// 如果没有输入,清空列表
|
||||
if (!query || query.trim() === '') {
|
||||
if (this.targetCoil.itemType === 'raw_material') {
|
||||
this.rawMaterialList = [...this.allRawMaterials];
|
||||
this.rawMaterialList = [];
|
||||
} else if (this.targetCoil.itemType === 'product') {
|
||||
this.productList = [...this.allProducts];
|
||||
this.productList = [];
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// 前端过滤:在已加载的数据中搜索
|
||||
const searchQuery = query.toLowerCase().trim();
|
||||
try {
|
||||
this.itemSearchLoading = true;
|
||||
const searchQuery = query.trim();
|
||||
|
||||
if (this.targetCoil.itemType === 'raw_material') {
|
||||
// 从备份列表中过滤原材料
|
||||
this.rawMaterialList = this.allRawMaterials.filter(item => {
|
||||
// 搜索名称
|
||||
const nameMatch = item.rawMaterialName && item.rawMaterialName.toLowerCase().includes(searchQuery);
|
||||
// 搜索规格
|
||||
const specMatch = item.specification && item.specification.toLowerCase().includes(searchQuery);
|
||||
// 搜索 参数 参数
|
||||
const bomMatch = item.bomItems && item.bomItems.some(bom =>
|
||||
(bom.attrKey && bom.attrKey.toLowerCase().includes(searchQuery)) ||
|
||||
(bom.attrValue && bom.attrValue.toLowerCase().includes(searchQuery))
|
||||
);
|
||||
|
||||
return nameMatch || specMatch || bomMatch;
|
||||
});
|
||||
} else if (this.targetCoil.itemType === 'product') {
|
||||
// 从备份列表中过滤产品
|
||||
this.productList = this.allProducts.filter(item => {
|
||||
// 搜索名称
|
||||
const nameMatch = item.productName && item.productName.toLowerCase().includes(searchQuery);
|
||||
// 搜索规格
|
||||
const specMatch = item.specification && item.specification.toLowerCase().includes(searchQuery);
|
||||
// 搜索 参数 参数
|
||||
const bomMatch = item.bomItems && item.bomItems.some(bom =>
|
||||
(bom.attrKey && bom.attrKey.toLowerCase().includes(searchQuery)) ||
|
||||
(bom.attrValue && bom.attrValue.toLowerCase().includes(searchQuery))
|
||||
);
|
||||
|
||||
return nameMatch || specMatch || bomMatch;
|
||||
});
|
||||
if (this.targetCoil.itemType === 'raw_material') {
|
||||
// 后端搜索原材料(支持名称或规格模糊搜索)
|
||||
const response = await listRawMaterialWithBom({
|
||||
pageNum: 1,
|
||||
pageSize: 20,
|
||||
rawMaterialName: searchQuery,
|
||||
specification: searchQuery // 同时传入,后端会使用 OR 条件
|
||||
});
|
||||
if (response.code === 200) {
|
||||
this.rawMaterialList = response.rows || [];
|
||||
}
|
||||
} else if (this.targetCoil.itemType === 'product') {
|
||||
// 后端搜索产品(支持名称或规格模糊搜索)
|
||||
const response = await listProductWithBom({
|
||||
pageNum: 1,
|
||||
pageSize: 20,
|
||||
productName: searchQuery,
|
||||
specification: searchQuery // 同时传入,后端会使用 OR 条件
|
||||
});
|
||||
if (response.code === 200) {
|
||||
this.productList = response.rows || [];
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('搜索物品失败', error);
|
||||
this.$message.error('搜索失败,请重试');
|
||||
} finally {
|
||||
this.itemSearchLoading = false;
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
@@ -200,8 +200,8 @@
|
||||
<script>
|
||||
import { getMaterialCoil, splitMaterialCoil } from '@/api/wms/coil';
|
||||
import { listWarehouse } from '@/api/wms/warehouse';
|
||||
import { listRawMaterial } from '@/api/wms/rawMaterial';
|
||||
import { listProduct } from '@/api/wms/product';
|
||||
import { listRawMaterialWithBom } from '@/api/wms/rawMaterial';
|
||||
import { listProductWithBom } from '@/api/wms/product';
|
||||
import { completeAction } from '@/api/wms/pendingAction';
|
||||
import CoilSelector from '@/components/CoilSelector';
|
||||
import ActualWarehouseSelect from "@/components/KLPService/ActualWarehouseSelect";
|
||||
@@ -249,12 +249,9 @@ export default {
|
||||
coilSelectorVisible: false,
|
||||
// 库区列表
|
||||
warehouseList: [],
|
||||
// 原材料和产品列表
|
||||
// 原材料和产品列表(实时搜索,不再保存完整备份)
|
||||
rawMaterialList: [],
|
||||
productList: [],
|
||||
// 原始完整列表备份(用于搜索过滤)
|
||||
allRawMaterials: [],
|
||||
allProducts: [],
|
||||
itemSearchLoading: false,
|
||||
// 只读模式
|
||||
readonly: false,
|
||||
@@ -268,8 +265,8 @@ export default {
|
||||
// 先加载库区列表
|
||||
await this.loadWarehouses();
|
||||
|
||||
// 🔥 页面加载时直接加载所有原料和产品列表
|
||||
await this.loadAllItems();
|
||||
// 不再一次性加载所有数据,改为实时搜索
|
||||
// await this.loadAllItems();
|
||||
|
||||
// 从路由参数获取coilId、actionId和readonly
|
||||
const coilId = this.$route.query.coilId;
|
||||
@@ -296,15 +293,15 @@ export default {
|
||||
// 清空物品选择
|
||||
this.$set(item, 'itemId', null);
|
||||
|
||||
// 根据材料类型设置物品类型并恢复完整列表
|
||||
// 根据材料类型设置物品类型
|
||||
if (item.materialType === '成品') {
|
||||
this.$set(item, 'itemType', 'product');
|
||||
// 恢复完整产品列表
|
||||
this.productList = [...this.allProducts];
|
||||
// 清空列表,等待用户搜索
|
||||
this.productList = [];
|
||||
} else if (item.materialType === '原料' || item.materialType === '废品') {
|
||||
this.$set(item, 'itemType', 'raw_material');
|
||||
// 恢复完整原料列表
|
||||
this.rawMaterialList = [...this.allRawMaterials];
|
||||
// 清空列表,等待用户搜索
|
||||
this.rawMaterialList = [];
|
||||
}
|
||||
},
|
||||
|
||||
@@ -379,13 +376,12 @@ export default {
|
||||
return displayName;
|
||||
},
|
||||
|
||||
// 物品类型变化
|
||||
handleItemTypeChange(index) {
|
||||
this.splitList[index].itemId = null;
|
||||
this.loadItemListForSplit(this.splitList[index].itemType);
|
||||
},
|
||||
// 物品类型变化(已移除,改为实时搜索)
|
||||
// handleItemTypeChange(index) {
|
||||
// this.splitList[index].itemId = null;
|
||||
// },
|
||||
|
||||
// 搜索子卷物品(前端过滤,支持名称和规格搜索)
|
||||
// 实时搜索子卷物品(后端搜索)
|
||||
async searchItemsForSplit(query, index) {
|
||||
const item = this.splitList[index];
|
||||
|
||||
@@ -395,109 +391,55 @@ export default {
|
||||
return;
|
||||
}
|
||||
|
||||
// 如果没有输入,恢复完整列表
|
||||
// 如果没有输入,清空列表
|
||||
if (!query || query.trim() === '') {
|
||||
if (itemType === 'raw_material') {
|
||||
this.rawMaterialList = [...this.allRawMaterials];
|
||||
this.rawMaterialList = [];
|
||||
} else if (itemType === 'product') {
|
||||
this.productList = [...this.allProducts];
|
||||
this.productList = [];
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// 前端过滤:在已加载的数据中搜索
|
||||
const searchQuery = query.toLowerCase().trim();
|
||||
|
||||
if (itemType === 'raw_material') {
|
||||
// 从备份列表中过滤原材料
|
||||
this.rawMaterialList = this.allRawMaterials.filter(item => {
|
||||
// 搜索名称
|
||||
const nameMatch = item.rawMaterialName && item.rawMaterialName.toLowerCase().includes(searchQuery);
|
||||
// 搜索规格
|
||||
const specMatch = item.specification && item.specification.toLowerCase().includes(searchQuery);
|
||||
// 搜索 参数 参数
|
||||
const bomMatch = item.bomItems && item.bomItems.some(bom =>
|
||||
(bom.attrKey && bom.attrKey.toLowerCase().includes(searchQuery)) ||
|
||||
(bom.attrValue && bom.attrValue.toLowerCase().includes(searchQuery))
|
||||
);
|
||||
|
||||
return nameMatch || specMatch || bomMatch;
|
||||
});
|
||||
} else if (itemType === 'product') {
|
||||
// 从备份列表中过滤产品
|
||||
this.productList = this.allProducts.filter(item => {
|
||||
// 搜索名称
|
||||
const nameMatch = item.productName && item.productName.toLowerCase().includes(searchQuery);
|
||||
// 搜索规格
|
||||
const specMatch = item.specification && item.specification.toLowerCase().includes(searchQuery);
|
||||
// 搜索 参数 参数
|
||||
const bomMatch = item.bomItems && item.bomItems.some(bom =>
|
||||
(bom.attrKey && bom.attrKey.toLowerCase().includes(searchQuery)) ||
|
||||
(bom.attrValue && bom.attrValue.toLowerCase().includes(searchQuery))
|
||||
);
|
||||
|
||||
return nameMatch || specMatch || bomMatch;
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
// 页面加载时一次性加载所有原料和产品列表
|
||||
async loadAllItems() {
|
||||
try {
|
||||
// 同时加载原料和产品
|
||||
const [rawMaterialRes, productRes] = await Promise.all([
|
||||
listRawMaterial({ pageNum: 1, pageSize: 99999, withBom: true }),
|
||||
listProduct({ pageNum: 1, pageSize: 99999, withBom: true })
|
||||
]);
|
||||
|
||||
if (rawMaterialRes.code === 200) {
|
||||
this.rawMaterialList = rawMaterialRes.rows || [];
|
||||
this.allRawMaterials = rawMaterialRes.rows || []; // 保存完整备份
|
||||
}
|
||||
|
||||
if (productRes.code === 200) {
|
||||
this.productList = productRes.rows || [];
|
||||
this.allProducts = productRes.rows || []; // 保存完整备份
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('加载物品列表失败', error);
|
||||
}
|
||||
},
|
||||
|
||||
// 加载子卷物品列表
|
||||
async loadItemListForSplit(itemType) {
|
||||
if (!itemType) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
this.itemSearchLoading = true;
|
||||
const searchQuery = query.trim();
|
||||
|
||||
if (itemType === 'raw_material') {
|
||||
const response = await listRawMaterial({
|
||||
// 后端搜索原材料(支持名称或规格模糊搜索)
|
||||
const response = await listRawMaterialWithBom({
|
||||
pageNum: 1,
|
||||
pageSize: 100,
|
||||
withBom: true
|
||||
pageSize: 20,
|
||||
rawMaterialName: searchQuery,
|
||||
specification: searchQuery // 同时传入,后端会使用 OR 条件
|
||||
});
|
||||
if (response.code === 200) {
|
||||
this.rawMaterialList = response.rows || [];
|
||||
}
|
||||
} else if (itemType === 'product') {
|
||||
const response = await listProduct({
|
||||
// 后端搜索产品(支持名称或规格模糊搜索)
|
||||
const response = await listProductWithBom({
|
||||
pageNum: 1,
|
||||
pageSize: 100,
|
||||
withBom: true
|
||||
pageSize: 20,
|
||||
productName: searchQuery,
|
||||
specification: searchQuery // 同时传入,后端会使用 OR 条件
|
||||
});
|
||||
if (response.code === 200) {
|
||||
this.productList = response.rows || [];
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('split.vue 加载物品列表失败', error);
|
||||
console.error('搜索物品失败', error);
|
||||
this.$message.error('搜索失败,请重试');
|
||||
} finally {
|
||||
this.itemSearchLoading = false;
|
||||
}
|
||||
},
|
||||
|
||||
// 已移除 loadAllItems,改为实时搜索
|
||||
|
||||
// 已移除 loadItemListForSplit,改为实时搜索
|
||||
|
||||
// 显示钢卷选择器
|
||||
showCoilSelector() {
|
||||
this.coilSelectorVisible = true;
|
||||
@@ -717,10 +659,7 @@ export default {
|
||||
// 不复制 itemType 和 itemId,让它们由 materialType 自动决定
|
||||
});
|
||||
|
||||
// 加载物品列表
|
||||
if (this.motherCoil.itemType) {
|
||||
this.loadItemListForSplit(this.motherCoil.itemType);
|
||||
}
|
||||
// 不再预加载物品列表,改为实时搜索
|
||||
|
||||
this.$message.success('已复制到所有子卷');
|
||||
}
|
||||
|
||||
@@ -218,8 +218,8 @@
|
||||
import { getMaterialCoil, updateMaterialCoil, getMaterialCoilTrace } from '@/api/wms/coil';
|
||||
import { completeAction } from '@/api/wms/pendingAction';
|
||||
import { listWarehouse } from '@/api/wms/warehouse';
|
||||
import { listRawMaterial } from '@/api/wms/rawMaterial';
|
||||
import { listProduct } from '@/api/wms/product';
|
||||
import { listRawMaterialWithBom } from '@/api/wms/rawMaterial';
|
||||
import { listProductWithBom } from '@/api/wms/product';
|
||||
import ActualWarehouseSelect from "@/components/KLPService/ActualWarehouseSelect";
|
||||
|
||||
export default {
|
||||
@@ -300,12 +300,9 @@ export default {
|
||||
warehouseList: [],
|
||||
historySteps: [],
|
||||
actionId: null,
|
||||
// 原材料和产品列表
|
||||
// 原材料和产品列表(实时搜索,不再保存完整备份)
|
||||
rawMaterialList: [],
|
||||
productList: [],
|
||||
// 原始完整列表备份(用于搜索过滤)
|
||||
allRawMaterials: [],
|
||||
allProducts: [],
|
||||
itemSearchLoading: false,
|
||||
// 只读模式
|
||||
readonly: false
|
||||
@@ -352,8 +349,8 @@ export default {
|
||||
// 先加载库区列表
|
||||
await this.loadWarehouses();
|
||||
|
||||
// 🔥 页面加载时直接加载所有原料和产品列表
|
||||
await this.loadAllItems();
|
||||
// 不再一次性加载所有数据,改为实时搜索
|
||||
// await this.loadAllItems();
|
||||
|
||||
// 从路由参数获取coilId和actionId
|
||||
const coilId = this.$route.query.coilId;
|
||||
@@ -382,12 +379,12 @@ export default {
|
||||
// 根据材料类型设置物品类型
|
||||
if (value === '成品') {
|
||||
this.$set(this.updateForm, 'itemType', 'product');
|
||||
// 恢复完整产品列表
|
||||
this.productList = [...this.allProducts];
|
||||
// 清空列表,等待用户搜索
|
||||
this.productList = [];
|
||||
} else if (value === '原料' || value === '废品') {
|
||||
this.$set(this.updateForm, 'itemType', 'raw_material');
|
||||
// 恢复完整原料列表
|
||||
this.rawMaterialList = [...this.allRawMaterials];
|
||||
// 清空列表,等待用户搜索
|
||||
this.rawMaterialList = [];
|
||||
}
|
||||
},
|
||||
|
||||
@@ -406,10 +403,7 @@ export default {
|
||||
nextWarehouseName: this.getWarehouseName(data.warehouseId),
|
||||
};
|
||||
|
||||
// 加载对应类型的物品列表
|
||||
if (data.itemType) {
|
||||
await this.loadItemList(data.itemType);
|
||||
}
|
||||
// 不再预加载物品列表,改为实时搜索
|
||||
|
||||
// 加载变更历史
|
||||
this.loadHistory();
|
||||
@@ -492,115 +486,59 @@ export default {
|
||||
}
|
||||
},
|
||||
|
||||
// 页面加载时一次性加载所有原料和产品列表
|
||||
async loadAllItems() {
|
||||
try {
|
||||
// 同时加载原料和产品
|
||||
const [rawMaterialRes, productRes] = await Promise.all([
|
||||
listRawMaterial({ pageNum: 1, pageSize: 99999, withBom: true }),
|
||||
listProduct({ pageNum: 1, pageSize: 99999, withBom: true })
|
||||
]);
|
||||
// 已移除 loadAllItems,改为实时搜索
|
||||
|
||||
if (rawMaterialRes.code === 200) {
|
||||
this.rawMaterialList = rawMaterialRes.rows || [];
|
||||
this.allRawMaterials = rawMaterialRes.rows || []; // 保存完整备份
|
||||
}
|
||||
// 已移除 loadItemList,改为实时搜索
|
||||
|
||||
if (productRes.code === 200) {
|
||||
this.productList = productRes.rows || [];
|
||||
this.allProducts = productRes.rows || []; // 保存完整备份
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('加载物品列表失败', error);
|
||||
}
|
||||
},
|
||||
|
||||
// 加载物品列表(根据类型)
|
||||
async loadItemList(itemType) {
|
||||
if (!itemType) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
this.itemSearchLoading = true;
|
||||
if (itemType === 'raw_material') {
|
||||
// 使用带参数的接口
|
||||
const response = await listRawMaterial({
|
||||
pageNum: 1,
|
||||
pageSize: 100,
|
||||
withBom: true // 请求包含参数信息
|
||||
});
|
||||
if (response.code === 200) {
|
||||
this.rawMaterialList = response.rows || [];
|
||||
}
|
||||
} else if (itemType === 'product') {
|
||||
// 使用带参数的接口
|
||||
const response = await listProduct({
|
||||
pageNum: 1,
|
||||
pageSize: 100,
|
||||
withBom: true // 请求包含参数信息
|
||||
});
|
||||
if (response.code === 200) {
|
||||
this.productList = response.rows || [];
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('加载物品列表失败', error);
|
||||
} finally {
|
||||
this.itemSearchLoading = false;
|
||||
}
|
||||
},
|
||||
|
||||
// 搜索物品(前端过滤,支持名称和规格搜索)
|
||||
// 实时搜索物品(后端搜索)
|
||||
async searchItems(query) {
|
||||
if (!this.updateForm.itemType) {
|
||||
this.$message.warning('请先选择材料类型');
|
||||
return;
|
||||
}
|
||||
|
||||
// 如果没有输入,恢复完整列表
|
||||
// 如果没有输入,清空列表
|
||||
if (!query || query.trim() === '') {
|
||||
if (this.updateForm.itemType === 'raw_material') {
|
||||
this.rawMaterialList = [...this.allRawMaterials];
|
||||
this.rawMaterialList = [];
|
||||
} else if (this.updateForm.itemType === 'product') {
|
||||
this.productList = [...this.allProducts];
|
||||
this.productList = [];
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// 前端过滤:在已加载的数据中搜索
|
||||
const searchQuery = query.toLowerCase().trim();
|
||||
try {
|
||||
this.itemSearchLoading = true;
|
||||
const searchQuery = query.trim();
|
||||
|
||||
if (this.updateForm.itemType === 'raw_material') {
|
||||
// 从备份列表中过滤原材料
|
||||
this.rawMaterialList = this.allRawMaterials.filter(item => {
|
||||
// 搜索名称
|
||||
const nameMatch = item.rawMaterialName && item.rawMaterialName.toLowerCase().includes(searchQuery);
|
||||
// 搜索规格
|
||||
const specMatch = item.specification && item.specification.toLowerCase().includes(searchQuery);
|
||||
// 搜索 参数 参数
|
||||
const bomMatch = item.bomItems && item.bomItems.some(bom =>
|
||||
(bom.attrKey && bom.attrKey.toLowerCase().includes(searchQuery)) ||
|
||||
(bom.attrValue && bom.attrValue.toLowerCase().includes(searchQuery))
|
||||
);
|
||||
|
||||
return nameMatch || specMatch || bomMatch;
|
||||
});
|
||||
} else if (this.updateForm.itemType === 'product') {
|
||||
// 从备份列表中过滤产品
|
||||
this.productList = this.allProducts.filter(item => {
|
||||
// 搜索名称
|
||||
const nameMatch = item.productName && item.productName.toLowerCase().includes(searchQuery);
|
||||
// 搜索规格
|
||||
const specMatch = item.specification && item.specification.toLowerCase().includes(searchQuery);
|
||||
// 搜索 参数 参数
|
||||
const bomMatch = item.bomItems && item.bomItems.some(bom =>
|
||||
(bom.attrKey && bom.attrKey.toLowerCase().includes(searchQuery)) ||
|
||||
(bom.attrValue && bom.attrValue.toLowerCase().includes(searchQuery))
|
||||
);
|
||||
|
||||
return nameMatch || specMatch || bomMatch;
|
||||
});
|
||||
if (this.updateForm.itemType === 'raw_material') {
|
||||
// 后端搜索原材料(支持名称或规格模糊搜索)
|
||||
const response = await listRawMaterialWithBom({
|
||||
pageNum: 1,
|
||||
pageSize: 20,
|
||||
rawMaterialName: searchQuery,
|
||||
specification: searchQuery // 同时传入,后端会使用 OR 条件
|
||||
});
|
||||
if (response.code === 200) {
|
||||
this.rawMaterialList = response.rows || [];
|
||||
}
|
||||
} else if (this.updateForm.itemType === 'product') {
|
||||
// 后端搜索产品(支持名称或规格模糊搜索)
|
||||
const response = await listProductWithBom({
|
||||
pageNum: 1,
|
||||
pageSize: 20,
|
||||
productName: searchQuery,
|
||||
specification: searchQuery // 同时传入,后端会使用 OR 条件
|
||||
});
|
||||
if (response.code === 200) {
|
||||
this.productList = response.rows || [];
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('搜索物品失败', error);
|
||||
this.$message.error('搜索失败,请重试');
|
||||
} finally {
|
||||
this.itemSearchLoading = false;
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
@@ -51,6 +51,10 @@ public class WmsProductController extends BaseController {
|
||||
*/
|
||||
@GetMapping("/listWithBom")
|
||||
public TableDataInfo<WmsProductVo> listWithBom(WmsProductBo bo, PageQuery pageQuery) {
|
||||
// 限制最大 pageSize 为 1000,防止查询过多数据导致性能问题
|
||||
if (pageQuery.getPageSize() != null && pageQuery.getPageSize() > 1000) {
|
||||
pageQuery.setPageSize(1000);
|
||||
}
|
||||
return iWmsProductService.queryPageListWithBom(bo, pageQuery);
|
||||
}
|
||||
|
||||
|
||||
@@ -50,6 +50,10 @@ public class WmsRawMaterialController extends BaseController {
|
||||
*/
|
||||
@GetMapping("/listWithBom")
|
||||
public TableDataInfo<WmsRawMaterialVo> listWithBom(WmsRawMaterialBo bo, PageQuery pageQuery) {
|
||||
// 限制最大 pageSize 为 1000,防止查询过多数据导致性能问题
|
||||
if (pageQuery.getPageSize() != null && pageQuery.getPageSize() > 1000) {
|
||||
pageQuery.setPageSize(1000);
|
||||
}
|
||||
return iWmsRawMaterialService.queryPageListWithBom(bo, pageQuery);
|
||||
}
|
||||
|
||||
|
||||
@@ -211,6 +211,82 @@ public class WmsMaterialCoilVo extends BaseEntity {
|
||||
*/
|
||||
private String packagingRequirement;
|
||||
|
||||
// ========== 联查临时字段(用于优化查询性能,避免单独查询) ==========
|
||||
|
||||
/**
|
||||
* 原材料ID(联查字段)
|
||||
*/
|
||||
private Long rawMaterialId;
|
||||
|
||||
/**
|
||||
* 原材料编号(联查字段)
|
||||
*/
|
||||
private String rawMaterialCode;
|
||||
|
||||
/**
|
||||
* 原材料名称(联查字段)
|
||||
*/
|
||||
private String rawMaterialName;
|
||||
|
||||
/**
|
||||
* 原材料规格(联查字段)
|
||||
*/
|
||||
private String rawMaterialSpecification;
|
||||
|
||||
/**
|
||||
* 原材料钢种(联查字段)
|
||||
*/
|
||||
private String rawMaterialSteelGrade;
|
||||
|
||||
/**
|
||||
* 原材料厚度(联查字段)
|
||||
*/
|
||||
private BigDecimal rawMaterialThickness;
|
||||
|
||||
/**
|
||||
* 原材料宽度(联查字段)
|
||||
*/
|
||||
private BigDecimal rawMaterialWidth;
|
||||
|
||||
/**
|
||||
* 原材料BOM ID(联查字段)
|
||||
*/
|
||||
private Long rawMaterialBomId;
|
||||
|
||||
/**
|
||||
* 产品ID(联查字段)
|
||||
*/
|
||||
private Long productId;
|
||||
|
||||
/**
|
||||
* 产品编号(联查字段)
|
||||
*/
|
||||
private String productCode;
|
||||
|
||||
/**
|
||||
* 产品名称(联查字段)
|
||||
*/
|
||||
private String productName;
|
||||
|
||||
/**
|
||||
* 产品规格(联查字段)
|
||||
*/
|
||||
private String productSpecification;
|
||||
|
||||
/**
|
||||
* 产品厚度(联查字段)
|
||||
*/
|
||||
private BigDecimal productThickness;
|
||||
|
||||
/**
|
||||
* 产品宽度(联查字段)
|
||||
*/
|
||||
private BigDecimal productWidth;
|
||||
|
||||
/**
|
||||
* 产品BOM ID(联查字段)
|
||||
*/
|
||||
private Long productBomId;
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -26,6 +26,7 @@ import com.klp.domain.bo.WmsStockBo;
|
||||
import com.klp.domain.vo.WmsStockVo;
|
||||
import com.klp.mapper.WmsMaterialCoilMapper;
|
||||
import com.klp.mapper.WmsStockMapper;
|
||||
import com.klp.mapper.WmsGenerateRecordMapper;
|
||||
import com.klp.service.IWmsMaterialCoilService;
|
||||
import com.klp.service.IWmsStockService;
|
||||
import com.klp.service.IWmsGenerateRecordService;
|
||||
@@ -61,6 +62,7 @@ public class WmsMaterialCoilServiceImpl implements IWmsMaterialCoilService {
|
||||
private final WmsMaterialCoilMapper baseMapper;
|
||||
private final IWmsStockService stockService;
|
||||
private final IWmsGenerateRecordService generateRecordService;
|
||||
private final WmsGenerateRecordMapper generateRecordMapper;
|
||||
private final IWmsWarehouseService warehouseService;
|
||||
private final IWmsActualWarehouseService actualWarehouseService;
|
||||
private final IWmsRawMaterialService rawMaterialService;
|
||||
@@ -84,7 +86,153 @@ public class WmsMaterialCoilServiceImpl implements IWmsMaterialCoilService {
|
||||
}
|
||||
|
||||
/**
|
||||
* 填充关联对象信息
|
||||
* 批量填充关联对象信息(优化版本,避免N+1查询)
|
||||
*/
|
||||
private void fillRelatedObjectsBatch(List<WmsMaterialCoilVo> voList) {
|
||||
if (voList == null || voList.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// 收集所有需要查询的ID
|
||||
Set<Long> warehouseIds = new HashSet<>();
|
||||
Set<Long> nextWarehouseIds = new HashSet<>();
|
||||
Set<Long> actualWarehouseIds = new HashSet<>();
|
||||
Set<Long> qrcodeRecordIds = new HashSet<>();
|
||||
Set<Long> rawMaterialIds = new HashSet<>();
|
||||
Set<Long> productIds = new HashSet<>();
|
||||
Set<Long> bomIds = new HashSet<>();
|
||||
|
||||
for (WmsMaterialCoilVo vo : voList) {
|
||||
if (vo.getWarehouseId() != null) warehouseIds.add(vo.getWarehouseId());
|
||||
if (vo.getNextWarehouseId() != null) nextWarehouseIds.add(vo.getNextWarehouseId());
|
||||
if (vo.getActualWarehouseId() != null) actualWarehouseIds.add(vo.getActualWarehouseId());
|
||||
if (vo.getQrcodeRecordId() != null) qrcodeRecordIds.add(vo.getQrcodeRecordId());
|
||||
if ("raw_material".equals(vo.getItemType()) && vo.getItemId() != null) {
|
||||
rawMaterialIds.add(vo.getItemId());
|
||||
}
|
||||
if ("product".equals(vo.getItemType()) && vo.getItemId() != null) {
|
||||
productIds.add(vo.getItemId());
|
||||
}
|
||||
}
|
||||
|
||||
// 批量查询库区信息
|
||||
Map<Long, WmsWarehouseVo> warehouseMap = new HashMap<>();
|
||||
if (!warehouseIds.isEmpty()) {
|
||||
for (Long id : warehouseIds) {
|
||||
WmsWarehouseVo warehouse = warehouseService.queryById(id);
|
||||
if (warehouse != null) {
|
||||
warehouseMap.put(id, warehouse);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!nextWarehouseIds.isEmpty()) {
|
||||
for (Long id : nextWarehouseIds) {
|
||||
if (!warehouseMap.containsKey(id)) {
|
||||
WmsWarehouseVo warehouse = warehouseService.queryById(id);
|
||||
if (warehouse != null) {
|
||||
warehouseMap.put(id, warehouse);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 批量查询实际库区信息
|
||||
Map<Long, WmsActualWarehouseVo> actualWarehouseMap = new HashMap<>();
|
||||
if (!actualWarehouseIds.isEmpty()) {
|
||||
for (Long id : actualWarehouseIds) {
|
||||
WmsActualWarehouseVo actualWarehouse = actualWarehouseService.queryById(id);
|
||||
if (actualWarehouse != null) {
|
||||
actualWarehouseMap.put(id, actualWarehouse);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 批量查询二维码信息
|
||||
Map<Long, WmsGenerateRecordVo> qrcodeMap = new HashMap<>();
|
||||
if (!qrcodeRecordIds.isEmpty()) {
|
||||
for (Long id : qrcodeRecordIds) {
|
||||
WmsGenerateRecordVo qrcode = generateRecordService.queryById(id);
|
||||
if (qrcode != null) {
|
||||
qrcodeMap.put(id, qrcode);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 批量查询原材料信息
|
||||
Map<Long, WmsRawMaterialVo> rawMaterialMap = new HashMap<>();
|
||||
if (!rawMaterialIds.isEmpty()) {
|
||||
for (Long id : rawMaterialIds) {
|
||||
WmsRawMaterialVo rawMaterial = rawMaterialService.queryById(id);
|
||||
if (rawMaterial != null) {
|
||||
rawMaterialMap.put(id, rawMaterial);
|
||||
if (rawMaterial.getBomId() != null) {
|
||||
bomIds.add(rawMaterial.getBomId());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 批量查询产品信息
|
||||
Map<Long, WmsProductVo> productMap = new HashMap<>();
|
||||
if (!productIds.isEmpty()) {
|
||||
for (Long id : productIds) {
|
||||
WmsProductVo product = productService.queryById(id);
|
||||
if (product != null) {
|
||||
productMap.put(id, product);
|
||||
if (product.getBomId() != null) {
|
||||
bomIds.add(product.getBomId());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 批量查询BOM信息
|
||||
Map<Long, List<WmsBomItemVo>> bomItemMap = new HashMap<>();
|
||||
if (!bomIds.isEmpty()) {
|
||||
for (Long bomId : bomIds) {
|
||||
WmsBomItemBo bomItemBo = new WmsBomItemBo();
|
||||
bomItemBo.setBomId(bomId);
|
||||
List<WmsBomItemVo> bomItemList = bomItemService.queryList(bomItemBo);
|
||||
if (bomItemList != null && !bomItemList.isEmpty()) {
|
||||
bomItemMap.put(bomId, bomItemList);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 填充到VO对象中
|
||||
for (WmsMaterialCoilVo vo : voList) {
|
||||
if (vo.getWarehouseId() != null && warehouseMap.containsKey(vo.getWarehouseId())) {
|
||||
vo.setWarehouse(warehouseMap.get(vo.getWarehouseId()));
|
||||
}
|
||||
if (vo.getNextWarehouseId() != null && warehouseMap.containsKey(vo.getNextWarehouseId())) {
|
||||
vo.setNextWarehouse(warehouseMap.get(vo.getNextWarehouseId()));
|
||||
}
|
||||
if (vo.getActualWarehouseId() != null && actualWarehouseMap.containsKey(vo.getActualWarehouseId())) {
|
||||
WmsActualWarehouseVo actualWarehouse = actualWarehouseMap.get(vo.getActualWarehouseId());
|
||||
vo.setActualWarehouseName(actualWarehouse.getActualWarehouseName());
|
||||
}
|
||||
if (vo.getQrcodeRecordId() != null && qrcodeMap.containsKey(vo.getQrcodeRecordId())) {
|
||||
vo.setQrcodeRecord(qrcodeMap.get(vo.getQrcodeRecordId()));
|
||||
}
|
||||
if ("raw_material".equals(vo.getItemType()) && vo.getItemId() != null && rawMaterialMap.containsKey(vo.getItemId())) {
|
||||
WmsRawMaterialVo rawMaterial = rawMaterialMap.get(vo.getItemId());
|
||||
vo.setRawMaterial(rawMaterial);
|
||||
if (rawMaterial.getBomId() != null && bomItemMap.containsKey(rawMaterial.getBomId())) {
|
||||
vo.setBomItemList(bomItemMap.get(rawMaterial.getBomId()));
|
||||
}
|
||||
}
|
||||
if ("product".equals(vo.getItemType()) && vo.getItemId() != null && productMap.containsKey(vo.getItemId())) {
|
||||
WmsProductVo product = productMap.get(vo.getItemId());
|
||||
vo.setProduct(product);
|
||||
if (product.getBomId() != null && bomItemMap.containsKey(product.getBomId())) {
|
||||
vo.setBomItemList(bomItemMap.get(product.getBomId()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 填充关联对象信息(单个对象,保留用于兼容性)
|
||||
*/
|
||||
private void fillRelatedObjects(WmsMaterialCoilVo vo) {
|
||||
// 查询所在库区信息
|
||||
@@ -150,9 +298,9 @@ public class WmsMaterialCoilServiceImpl implements IWmsMaterialCoilService {
|
||||
QueryWrapper<WmsMaterialCoil> qw = buildQueryWrapperPlus(bo);
|
||||
Page<WmsMaterialCoilVo> result = baseMapper.selectVoPagePlus(pageQuery.build(), qw);
|
||||
|
||||
// 填充每个记录的产品或原材料对象
|
||||
// 从联查结果中构建产品和原材料对象(避免单独查询)
|
||||
for (WmsMaterialCoilVo vo : result.getRecords()) {
|
||||
fillItemObject(vo);
|
||||
buildItemObjectFromJoin(vo);
|
||||
}
|
||||
|
||||
return TableDataInfo.build(result);
|
||||
@@ -211,16 +359,53 @@ public class WmsMaterialCoilServiceImpl implements IWmsMaterialCoilService {
|
||||
QueryWrapper<WmsMaterialCoil> lqw = buildQueryWrapperPlus(bo);
|
||||
List<WmsMaterialCoilVo> list = baseMapper.selectVoListWithDynamicJoin(lqw);
|
||||
|
||||
// 填充每个记录的产品或原材料对象
|
||||
// 从联查结果中构建产品和原材料对象(避免单独查询)
|
||||
for (WmsMaterialCoilVo vo : list) {
|
||||
fillItemObject(vo);
|
||||
buildItemObjectFromJoin(vo);
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
/**
|
||||
* 填充物品对象(产品或原材料)
|
||||
* 从联查结果中构建物品对象(产品或原材料)
|
||||
* 直接从VO的临时字段中获取数据构建对象,避免单独查询数据库
|
||||
*/
|
||||
private void buildItemObjectFromJoin(WmsMaterialCoilVo vo) {
|
||||
if (vo.getItemId() == null || vo.getItemType() == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
// 构建原材料对象
|
||||
if ("raw_material".equals(vo.getItemType()) && vo.getRawMaterialId() != null) {
|
||||
WmsRawMaterialVo rawMaterial = new WmsRawMaterialVo();
|
||||
rawMaterial.setRawMaterialId(vo.getRawMaterialId());
|
||||
rawMaterial.setRawMaterialCode(vo.getRawMaterialCode());
|
||||
rawMaterial.setRawMaterialName(vo.getRawMaterialName());
|
||||
rawMaterial.setSpecification(vo.getRawMaterialSpecification());
|
||||
rawMaterial.setSteelGrade(vo.getRawMaterialSteelGrade());
|
||||
rawMaterial.setThickness(vo.getRawMaterialThickness());
|
||||
rawMaterial.setWidth(vo.getRawMaterialWidth());
|
||||
rawMaterial.setBomId(vo.getRawMaterialBomId());
|
||||
vo.setRawMaterial(rawMaterial);
|
||||
}
|
||||
|
||||
// 构建产品对象
|
||||
if ("product".equals(vo.getItemType()) && vo.getProductId() != null) {
|
||||
WmsProductVo product = new WmsProductVo();
|
||||
product.setProductId(vo.getProductId());
|
||||
product.setProductCode(vo.getProductCode());
|
||||
product.setProductName(vo.getProductName());
|
||||
product.setSpecification(vo.getProductSpecification());
|
||||
product.setThickness(vo.getProductThickness());
|
||||
product.setWidth(vo.getProductWidth());
|
||||
product.setBomId(vo.getProductBomId());
|
||||
vo.setProduct(product);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 填充物品对象(产品或原材料)- 保留作为备用方法
|
||||
*/
|
||||
private void fillItemObject(WmsMaterialCoilVo vo) {
|
||||
if (vo.getItemId() == null || vo.getItemType() == null) {
|
||||
@@ -1034,7 +1219,7 @@ public class WmsMaterialCoilServiceImpl implements IWmsMaterialCoilService {
|
||||
@Override
|
||||
public Map<String, Object> queryTrace(String enterCoilNo, String currentCoilNo) {
|
||||
try {
|
||||
// 1. 查询所有相关的二维码记录(包括分卷后的独立二维码)
|
||||
// 优化1: 使用LIKE查询替代查询所有记录,大幅提升性能
|
||||
List<WmsGenerateRecordVo> allQrRecords = new ArrayList<>();
|
||||
|
||||
// 首先查询主二维码(以入场钢卷号为序列号的)
|
||||
@@ -1043,14 +1228,21 @@ public class WmsMaterialCoilServiceImpl implements IWmsMaterialCoilService {
|
||||
List<WmsGenerateRecordVo> mainQrRecords = generateRecordService.queryList(qrBo);
|
||||
allQrRecords.addAll(mainQrRecords);
|
||||
|
||||
// 然后查询所有以该入场钢卷号开头的二维码(分卷后的二维码)
|
||||
WmsGenerateRecordBo splitQrBo = new WmsGenerateRecordBo();
|
||||
List<WmsGenerateRecordVo> allRecords = generateRecordService.queryList(splitQrBo);
|
||||
for (WmsGenerateRecordVo record : allRecords) {
|
||||
if (record.getSerialNumber() != null &&
|
||||
record.getSerialNumber().startsWith(enterCoilNo + "-") &&
|
||||
!allQrRecords.contains(record)) {
|
||||
// 优化:使用LIKE查询所有以该入场钢卷号开头的二维码(分卷后的二维码)
|
||||
// 而不是查询所有记录然后在内存中过滤
|
||||
LambdaQueryWrapper<com.klp.domain.WmsGenerateRecord> splitWrapper = Wrappers.lambdaQuery();
|
||||
splitWrapper.like(com.klp.domain.WmsGenerateRecord::getSerialNumber, enterCoilNo + "-");
|
||||
List<WmsGenerateRecordVo> splitRecords = generateRecordMapper.selectVoList(splitWrapper);
|
||||
|
||||
// 去重:使用recordId作为唯一标识
|
||||
Set<Long> existingRecordIds = allQrRecords.stream()
|
||||
.map(WmsGenerateRecordVo::getRecordId)
|
||||
.collect(Collectors.toSet());
|
||||
|
||||
for (WmsGenerateRecordVo record : splitRecords) {
|
||||
if (record.getRecordId() != null && !existingRecordIds.contains(record.getRecordId())) {
|
||||
allQrRecords.add(record);
|
||||
existingRecordIds.add(record.getRecordId());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1058,14 +1250,16 @@ public class WmsMaterialCoilServiceImpl implements IWmsMaterialCoilService {
|
||||
throw new RuntimeException("未找到对应的二维码记录");
|
||||
}
|
||||
|
||||
// 优化2: ObjectMapper在循环外创建,避免重复创建
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
|
||||
// 2. 合并所有二维码的steps信息,去重并重新编号
|
||||
Map<String, Map<String, Object>> uniqueSteps = new HashMap<>(); // 用于去重
|
||||
Set<String> allCoilNos = new HashSet<>();
|
||||
|
||||
for (WmsGenerateRecordVo qrRecord : allQrRecords) {
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
@SuppressWarnings("unchecked")
|
||||
Map<String, Object> contentMap = objectMapper.readValue(qrRecord.getContent(), Map.class);
|
||||
Map<String, Object> contentMap = (Map<String, Object>) objectMapper.readValue(qrRecord.getContent(), Map.class);
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
List<Map<String, Object>> steps = (List<Map<String, Object>>) contentMap.get("steps");
|
||||
@@ -1125,32 +1319,41 @@ public class WmsMaterialCoilServiceImpl implements IWmsMaterialCoilService {
|
||||
.collect(Collectors.toSet());
|
||||
}
|
||||
|
||||
// 优化3: 使用IN查询替代多个OR条件,提升查询性能
|
||||
// 4. 根据提取的钢卷号反向查询数据库
|
||||
List<WmsMaterialCoilVo> result = new ArrayList<>();
|
||||
if (!filteredCoilNos.isEmpty()) {
|
||||
LambdaQueryWrapper<WmsMaterialCoil> lqw = Wrappers.lambdaQuery();
|
||||
lqw.eq(WmsMaterialCoil::getEnterCoilNo, enterCoilNo);
|
||||
|
||||
// 查询包含提取出的钢卷号的记录
|
||||
final Set<String> finalCoilNos = filteredCoilNos;
|
||||
lqw.and(wrapper -> {
|
||||
int count = 0;
|
||||
for (String coilNo : finalCoilNos) {
|
||||
if (count == 0) {
|
||||
wrapper.eq(WmsMaterialCoil::getCurrentCoilNo, coilNo);
|
||||
} else {
|
||||
wrapper.or().eq(WmsMaterialCoil::getCurrentCoilNo, coilNo);
|
||||
}
|
||||
count++;
|
||||
// 优化:使用IN查询替代多个OR条件(当钢卷号数量较少时)
|
||||
// 如果数量太多(>1000),分批查询避免SQL过长
|
||||
List<String> coilNoList = new ArrayList<>(filteredCoilNos);
|
||||
if (coilNoList.size() <= 1000) {
|
||||
lqw.in(WmsMaterialCoil::getCurrentCoilNo, coilNoList);
|
||||
} else {
|
||||
// 分批查询
|
||||
int batchSize = 1000;
|
||||
for (int i = 0; i < coilNoList.size(); i += batchSize) {
|
||||
int end = Math.min(i + batchSize, coilNoList.size());
|
||||
List<String> batch = coilNoList.subList(i, end);
|
||||
LambdaQueryWrapper<WmsMaterialCoil> batchLqw = Wrappers.lambdaQuery();
|
||||
batchLqw.eq(WmsMaterialCoil::getEnterCoilNo, enterCoilNo);
|
||||
batchLqw.in(WmsMaterialCoil::getCurrentCoilNo, batch);
|
||||
batchLqw.orderByAsc(WmsMaterialCoil::getCreateTime);
|
||||
List<WmsMaterialCoilVo> batchResult = baseMapper.selectVoList(batchLqw);
|
||||
result.addAll(batchResult);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
lqw.orderByAsc(WmsMaterialCoil::getCreateTime);
|
||||
result = baseMapper.selectVoList(lqw);
|
||||
if (coilNoList.size() <= 1000) {
|
||||
lqw.orderByAsc(WmsMaterialCoil::getCreateTime);
|
||||
result = baseMapper.selectVoList(lqw);
|
||||
}
|
||||
|
||||
// 填充每个记录的关联对象信息(如库区)
|
||||
for (WmsMaterialCoilVo vo : result) {
|
||||
fillRelatedObjects(vo);
|
||||
// 优化4: 批量填充关联对象,避免N+1查询
|
||||
if (!result.isEmpty()) {
|
||||
fillRelatedObjectsBatch(result);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1161,9 +1364,9 @@ public class WmsMaterialCoilServiceImpl implements IWmsMaterialCoilService {
|
||||
lqw.orderByAsc(WmsMaterialCoil::getCreateTime);
|
||||
result = baseMapper.selectVoList(lqw);
|
||||
|
||||
// 填充每个记录的关联对象信息
|
||||
for (WmsMaterialCoilVo vo : result) {
|
||||
fillRelatedObjects(vo);
|
||||
// 优化:批量填充关联对象
|
||||
if (!result.isEmpty()) {
|
||||
fillRelatedObjectsBatch(result);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -92,7 +92,24 @@ public class WmsProductServiceImpl implements IWmsProductService {
|
||||
Map<String, Object> params = bo.getParams();
|
||||
LambdaQueryWrapper<WmsProduct> lqw = Wrappers.lambdaQuery();
|
||||
lqw.eq(StringUtils.isNotBlank(bo.getProductCode()), WmsProduct::getProductCode, bo.getProductCode());
|
||||
lqw.like(StringUtils.isNotBlank(bo.getProductName()), WmsProduct::getProductName, bo.getProductName());
|
||||
|
||||
// 如果同时传入了名称和规格,且值相同(搜索关键词),使用 OR 条件
|
||||
boolean hasName = StringUtils.isNotBlank(bo.getProductName());
|
||||
boolean hasSpec = StringUtils.isNotBlank(bo.getSpecification());
|
||||
if (hasName && hasSpec && bo.getProductName().equals(bo.getSpecification())) {
|
||||
// 搜索关键词:匹配名称或规格
|
||||
String searchKey = bo.getProductName();
|
||||
lqw.and(wrapper -> wrapper
|
||||
.like(WmsProduct::getProductName, searchKey)
|
||||
.or()
|
||||
.like(WmsProduct::getSpecification, searchKey)
|
||||
);
|
||||
} else {
|
||||
// 分别处理名称和规格
|
||||
lqw.like(hasName, WmsProduct::getProductName, bo.getProductName());
|
||||
lqw.like(hasSpec, WmsProduct::getSpecification, bo.getSpecification());
|
||||
}
|
||||
|
||||
lqw.eq(StringUtils.isNotBlank(bo.getOwner()), WmsProduct::getOwner, bo.getOwner());
|
||||
lqw.eq(bo.getBaseMaterialId() != null, WmsProduct::getBaseMaterialId, bo.getBaseMaterialId());
|
||||
lqw.eq(bo.getSurfaceTreatmentId() != null, WmsProduct::getSurfaceTreatmentId, bo.getSurfaceTreatmentId());
|
||||
@@ -104,8 +121,6 @@ public class WmsProductServiceImpl implements IWmsProductService {
|
||||
lqw.eq(bo.getIsEnabled() != null, WmsProduct::getIsEnabled, bo.getIsEnabled());
|
||||
lqw.eq(bo.getBomId() != null, WmsProduct::getBomId, bo.getBomId());
|
||||
lqw.eq(StringUtils.isNotBlank(bo.getType()), WmsProduct::getType, bo.getType());
|
||||
//规格模糊匹配
|
||||
lqw.like(StringUtils.isNotBlank(bo.getSpecification()), WmsProduct::getSpecification, bo.getSpecification());
|
||||
lqw.eq(StringUtils.isNotBlank(bo.getMaterial()), WmsProduct::getMaterial, bo.getMaterial());
|
||||
lqw.eq(StringUtils.isNotBlank(bo.getSurfaceTreatmentDesc()), WmsProduct::getSurfaceTreatmentDesc, bo.getSurfaceTreatmentDesc());
|
||||
lqw.eq(StringUtils.isNotBlank(bo.getManufacturer()), WmsProduct::getManufacturer, bo.getManufacturer());
|
||||
|
||||
@@ -184,7 +184,24 @@ public class WmsRawMaterialServiceImpl implements IWmsRawMaterialService {
|
||||
Map<String, Object> params = bo.getParams();
|
||||
LambdaQueryWrapper<WmsRawMaterial> lqw = Wrappers.lambdaQuery();
|
||||
lqw.eq(StringUtils.isNotBlank(bo.getRawMaterialCode()), WmsRawMaterial::getRawMaterialCode, bo.getRawMaterialCode());
|
||||
lqw.like(StringUtils.isNotBlank(bo.getRawMaterialName()), WmsRawMaterial::getRawMaterialName, bo.getRawMaterialName());
|
||||
|
||||
// 如果同时传入了名称和规格,且值相同(搜索关键词),使用 OR 条件
|
||||
boolean hasName = StringUtils.isNotBlank(bo.getRawMaterialName());
|
||||
boolean hasSpec = StringUtils.isNotBlank(bo.getSpecification());
|
||||
if (hasName && hasSpec && bo.getRawMaterialName().equals(bo.getSpecification())) {
|
||||
// 搜索关键词:匹配名称或规格
|
||||
String searchKey = bo.getRawMaterialName();
|
||||
lqw.and(wrapper -> wrapper
|
||||
.like(WmsRawMaterial::getRawMaterialName, searchKey)
|
||||
.or()
|
||||
.like(WmsRawMaterial::getSpecification, searchKey)
|
||||
);
|
||||
} else {
|
||||
// 分别处理名称和规格
|
||||
lqw.like(hasName, WmsRawMaterial::getRawMaterialName, bo.getRawMaterialName());
|
||||
lqw.like(hasSpec, WmsRawMaterial::getSpecification, bo.getSpecification());
|
||||
}
|
||||
|
||||
lqw.eq(StringUtils.isNotBlank(bo.getSteelGrade()), WmsRawMaterial::getSteelGrade, bo.getSteelGrade());
|
||||
lqw.eq(StringUtils.isNotBlank(bo.getTargetColdGrade()), WmsRawMaterial::getTargetColdGrade, bo.getTargetColdGrade());
|
||||
lqw.eq(bo.getBaseMaterialId() != null, WmsRawMaterial::getBaseMaterialId, bo.getBaseMaterialId());
|
||||
@@ -206,8 +223,6 @@ public class WmsRawMaterialServiceImpl implements IWmsRawMaterialService {
|
||||
lqw.eq(StringUtils.isNotBlank(bo.getInspectionResult()), WmsRawMaterial::getInspectionResult, bo.getInspectionResult());
|
||||
lqw.eq(bo.getIsEnabled() != null, WmsRawMaterial::getIsEnabled, bo.getIsEnabled());
|
||||
lqw.eq(bo.getBomId() != null, WmsRawMaterial::getBomId, bo.getBomId());
|
||||
//规格模糊匹配
|
||||
lqw.like(StringUtils.isNotBlank(bo.getSpecification()), WmsRawMaterial::getSpecification, bo.getSpecification());
|
||||
lqw.eq(StringUtils.isNotBlank(bo.getMaterial()), WmsRawMaterial::getMaterial, bo.getMaterial());
|
||||
lqw.eq(StringUtils.isNotBlank(bo.getSurfaceTreatmentDesc()), WmsRawMaterial::getSurfaceTreatmentDesc, bo.getSurfaceTreatmentDesc());
|
||||
lqw.eq(StringUtils.isNotBlank(bo.getManufacturer()), WmsRawMaterial::getManufacturer, bo.getManufacturer());
|
||||
|
||||
@@ -94,11 +94,41 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
mc.packaging_requirement,
|
||||
mc.packing_status,
|
||||
w.warehouse_name AS warehouseName,
|
||||
aw.actual_warehouse_name AS actualWarehouseName
|
||||
aw.actual_warehouse_name AS actualWarehouseName,
|
||||
-- 原材料字段
|
||||
rm.raw_material_id AS rawMaterialId,
|
||||
rm.raw_material_code AS rawMaterialCode,
|
||||
rm.raw_material_name AS rawMaterialName,
|
||||
rm.specification AS rawMaterialSpecification,
|
||||
rm.steel_grade AS rawMaterialSteelGrade,
|
||||
rm.thickness AS rawMaterialThickness,
|
||||
rm.width AS rawMaterialWidth,
|
||||
rm.bom_id AS rawMaterialBomId,
|
||||
-- 产品字段
|
||||
p.product_id AS productId,
|
||||
p.product_code AS productCode,
|
||||
p.product_name AS productName,
|
||||
p.specification AS productSpecification,
|
||||
p.thickness AS productThickness,
|
||||
p.width AS productWidth,
|
||||
p.bom_id AS productBomId,
|
||||
-- 物品名称和编号(用于兼容)
|
||||
CASE
|
||||
WHEN mc.item_type = 'raw_material' THEN rm.raw_material_name
|
||||
WHEN mc.item_type = 'product' THEN p.product_name
|
||||
ELSE NULL
|
||||
END as itemName,
|
||||
CASE
|
||||
WHEN mc.item_type = 'raw_material' THEN rm.raw_material_code
|
||||
WHEN mc.item_type = 'product' THEN p.product_code
|
||||
ELSE NULL
|
||||
END as itemCode
|
||||
FROM wms_material_coil mc
|
||||
LEFT JOIN wms_warehouse w ON mc.warehouse_id = w.warehouse_id
|
||||
LEFT JOIN wms_actual_warehouse aw ON mc.actual_warehouse_id = aw.actual_warehouse_id
|
||||
${ew.customSqlSegment}
|
||||
LEFT JOIN wms_warehouse w ON mc.warehouse_id = w.warehouse_id
|
||||
LEFT JOIN wms_actual_warehouse aw ON mc.actual_warehouse_id = aw.actual_warehouse_id
|
||||
LEFT JOIN wms_raw_material rm ON mc.item_type = 'raw_material' AND mc.item_id = rm.raw_material_id
|
||||
LEFT JOIN wms_product p ON mc.item_type = 'product' AND mc.item_id = p.product_id
|
||||
${ew.customSqlSegment}
|
||||
</select>
|
||||
<!-- 查询不同类型的钢卷在不同库区的分布情况 -->
|
||||
<select id="getDistributionByItemType" resultType="java.util.Map">
|
||||
@@ -141,7 +171,25 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<select id="selectVoListWithDynamicJoin" resultType="com.klp.domain.vo.WmsMaterialCoilVo">
|
||||
SELECT mc.*,
|
||||
w.warehouse_name AS warehouseName,
|
||||
aw.warehouse_name AS actualWarehouseName,
|
||||
aw.actual_warehouse_name AS actualWarehouseName,
|
||||
-- 原材料字段
|
||||
rm.raw_material_id AS rawMaterialId,
|
||||
rm.raw_material_code AS rawMaterialCode,
|
||||
rm.raw_material_name AS rawMaterialName,
|
||||
rm.specification AS rawMaterialSpecification,
|
||||
rm.steel_grade AS rawMaterialSteelGrade,
|
||||
rm.thickness AS rawMaterialThickness,
|
||||
rm.width AS rawMaterialWidth,
|
||||
rm.bom_id AS rawMaterialBomId,
|
||||
-- 产品字段
|
||||
p.product_id AS productId,
|
||||
p.product_code AS productCode,
|
||||
p.product_name AS productName,
|
||||
p.specification AS productSpecification,
|
||||
p.thickness AS productThickness,
|
||||
p.width AS productWidth,
|
||||
p.bom_id AS productBomId,
|
||||
-- 物品名称和编号(用于兼容)
|
||||
CASE
|
||||
WHEN mc.item_type = 'raw_material' THEN rm.raw_material_name
|
||||
WHEN mc.item_type = 'product' THEN p.product_name
|
||||
@@ -153,11 +201,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
ELSE NULL
|
||||
END as itemCode
|
||||
FROM wms_material_coil mc
|
||||
LEFT JOIN wms_raw_material rm ON mc.item_type = 'raw_material' AND mc.item_id = rm.raw_material_id
|
||||
LEFT JOIN wms_product p ON mc.item_type = 'product' AND mc.item_id = p.product_id
|
||||
LEFT JOIN wms_warehouse w ON mc.warehouse_id = w.warehouse_id
|
||||
LEFT JOIN wms_actual_warehouse aw ON mc.actual_warehouse_id = aw.actual_warehouse_id
|
||||
${ew.customSqlSegment}
|
||||
LEFT JOIN wms_raw_material rm ON mc.item_type = 'raw_material' AND mc.item_id = rm.raw_material_id
|
||||
LEFT JOIN wms_product p ON mc.item_type = 'product' AND mc.item_id = p.product_id
|
||||
LEFT JOIN wms_warehouse w ON mc.warehouse_id = w.warehouse_id
|
||||
LEFT JOIN wms_actual_warehouse aw ON mc.actual_warehouse_id = aw.actual_warehouse_id
|
||||
${ew.customSqlSegment}
|
||||
</select>
|
||||
<select id="getDistributionByActualWarehouse" resultType="java.util.Map">
|
||||
SELECT
|
||||
|
||||
Reference in New Issue
Block a user