查询优化,新增酸连轧页面
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -220,8 +220,8 @@
|
|||||||
<script>
|
<script>
|
||||||
import { getMaterialCoil, mergeMaterialCoil } from '@/api/wms/coil';
|
import { getMaterialCoil, mergeMaterialCoil } from '@/api/wms/coil';
|
||||||
import { listWarehouse } from '@/api/wms/warehouse';
|
import { listWarehouse } from '@/api/wms/warehouse';
|
||||||
import { listRawMaterial } from '@/api/wms/rawMaterial';
|
import { listRawMaterialWithBom } from '@/api/wms/rawMaterial';
|
||||||
import { listProduct } from '@/api/wms/product';
|
import { listProductWithBom } from '@/api/wms/product';
|
||||||
import { listPendingAction, completeAction } from '@/api/wms/pendingAction';
|
import { listPendingAction, completeAction } from '@/api/wms/pendingAction';
|
||||||
import CoilSelector from '@/components/CoilSelector';
|
import CoilSelector from '@/components/CoilSelector';
|
||||||
import ActualWarehouseSelect from "@/components/KLPService/ActualWarehouseSelect";
|
import ActualWarehouseSelect from "@/components/KLPService/ActualWarehouseSelect";
|
||||||
@@ -259,12 +259,9 @@ export default {
|
|||||||
currentSelectIndex: -1,
|
currentSelectIndex: -1,
|
||||||
// 库区列表
|
// 库区列表
|
||||||
warehouseList: [],
|
warehouseList: [],
|
||||||
// 原材料和产品列表
|
// 原材料和产品列表(实时搜索,不再保存完整备份)
|
||||||
rawMaterialList: [],
|
rawMaterialList: [],
|
||||||
productList: [],
|
productList: [],
|
||||||
// 原始完整列表备份(用于搜索过滤)
|
|
||||||
allRawMaterials: [],
|
|
||||||
allProducts: [],
|
|
||||||
itemSearchLoading: false,
|
itemSearchLoading: false,
|
||||||
// 只读模式
|
// 只读模式
|
||||||
readonly: false,
|
readonly: false,
|
||||||
@@ -317,8 +314,8 @@ export default {
|
|||||||
// 加载库区列表
|
// 加载库区列表
|
||||||
await this.loadWarehouses();
|
await this.loadWarehouses();
|
||||||
|
|
||||||
// 🔥 页面加载时直接加载所有原料和产品列表
|
// 不再一次性加载所有数据,改为实时搜索
|
||||||
await this.loadAllItems();
|
// await this.loadAllItems();
|
||||||
|
|
||||||
// 从路由参数获取coilId、actionId和readonly
|
// 从路由参数获取coilId、actionId和readonly
|
||||||
const coilId = this.$route.query.coilId;
|
const coilId = this.$route.query.coilId;
|
||||||
@@ -378,15 +375,15 @@ export default {
|
|||||||
// 清空物品选择
|
// 清空物品选择
|
||||||
this.$set(this.targetCoil, 'itemId', null);
|
this.$set(this.targetCoil, 'itemId', null);
|
||||||
|
|
||||||
// 根据材料类型设置物品类型并恢复完整列表
|
// 根据材料类型设置物品类型
|
||||||
if (value === '成品') {
|
if (value === '成品') {
|
||||||
this.$set(this.targetCoil, 'itemType', 'product');
|
this.$set(this.targetCoil, 'itemType', 'product');
|
||||||
// 恢复完整产品列表
|
// 清空列表,等待用户搜索
|
||||||
this.productList = [...this.allProducts];
|
this.productList = [];
|
||||||
} else if (value === '原料' || value === '废品') {
|
} else if (value === '原料' || value === '废品') {
|
||||||
this.$set(this.targetCoil, 'itemType', 'raw_material');
|
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.warehouseId = data.warehouseId;
|
||||||
this.targetCoil.actualWarehouseId = data.actualWarehouseId;
|
this.targetCoil.actualWarehouseId = data.actualWarehouseId;
|
||||||
|
|
||||||
// 加载对应的物品列表
|
// 不再预加载物品列表,改为实时搜索
|
||||||
if (data.itemType) {
|
|
||||||
await this.loadItemList(data.itemType);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
this.$message.error('加载钢卷信息失败');
|
this.$message.error('加载钢卷信息失败');
|
||||||
@@ -576,113 +570,59 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
// 页面加载时一次性加载所有原料和产品列表
|
// 已移除 loadAllItems,改为实时搜索
|
||||||
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) {
|
// 已移除 loadItemList,改为实时搜索
|
||||||
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 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) {
|
async searchItems(query) {
|
||||||
if (!this.targetCoil.itemType) {
|
if (!this.targetCoil.itemType) {
|
||||||
this.$message.warning('请先选择材料类型');
|
this.$message.warning('请先选择材料类型');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 如果没有输入,恢复完整列表
|
// 如果没有输入,清空列表
|
||||||
if (!query || query.trim() === '') {
|
if (!query || query.trim() === '') {
|
||||||
if (this.targetCoil.itemType === 'raw_material') {
|
if (this.targetCoil.itemType === 'raw_material') {
|
||||||
this.rawMaterialList = [...this.allRawMaterials];
|
this.rawMaterialList = [];
|
||||||
} else if (this.targetCoil.itemType === 'product') {
|
} else if (this.targetCoil.itemType === 'product') {
|
||||||
this.productList = [...this.allProducts];
|
this.productList = [];
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 前端过滤:在已加载的数据中搜索
|
try {
|
||||||
const searchQuery = query.toLowerCase().trim();
|
this.itemSearchLoading = true;
|
||||||
|
const searchQuery = query.trim();
|
||||||
|
|
||||||
if (this.targetCoil.itemType === 'raw_material') {
|
if (this.targetCoil.itemType === 'raw_material') {
|
||||||
// 从备份列表中过滤原材料
|
// 后端搜索原材料(支持名称或规格模糊搜索)
|
||||||
this.rawMaterialList = this.allRawMaterials.filter(item => {
|
const response = await listRawMaterialWithBom({
|
||||||
// 搜索名称
|
pageNum: 1,
|
||||||
const nameMatch = item.rawMaterialName && item.rawMaterialName.toLowerCase().includes(searchQuery);
|
pageSize: 20,
|
||||||
// 搜索规格
|
rawMaterialName: searchQuery,
|
||||||
const specMatch = item.specification && item.specification.toLowerCase().includes(searchQuery);
|
specification: searchQuery // 同时传入,后端会使用 OR 条件
|
||||||
// 搜索 参数 参数
|
|
||||||
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 (response.code === 200) {
|
||||||
|
this.rawMaterialList = response.rows || [];
|
||||||
|
}
|
||||||
} else if (this.targetCoil.itemType === 'product') {
|
} else if (this.targetCoil.itemType === 'product') {
|
||||||
// 从备份列表中过滤产品
|
// 后端搜索产品(支持名称或规格模糊搜索)
|
||||||
this.productList = this.allProducts.filter(item => {
|
const response = await listProductWithBom({
|
||||||
// 搜索名称
|
pageNum: 1,
|
||||||
const nameMatch = item.productName && item.productName.toLowerCase().includes(searchQuery);
|
pageSize: 20,
|
||||||
// 搜索规格
|
productName: searchQuery,
|
||||||
const specMatch = item.specification && item.specification.toLowerCase().includes(searchQuery);
|
specification: searchQuery // 同时传入,后端会使用 OR 条件
|
||||||
// 搜索 参数 参数
|
|
||||||
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 (response.code === 200) {
|
||||||
|
this.productList = response.rows || [];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error('搜索物品失败', error);
|
||||||
|
this.$message.error('搜索失败,请重试');
|
||||||
|
} finally {
|
||||||
|
this.itemSearchLoading = false;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
@@ -200,8 +200,8 @@
|
|||||||
<script>
|
<script>
|
||||||
import { getMaterialCoil, splitMaterialCoil } from '@/api/wms/coil';
|
import { getMaterialCoil, splitMaterialCoil } from '@/api/wms/coil';
|
||||||
import { listWarehouse } from '@/api/wms/warehouse';
|
import { listWarehouse } from '@/api/wms/warehouse';
|
||||||
import { listRawMaterial } from '@/api/wms/rawMaterial';
|
import { listRawMaterialWithBom } from '@/api/wms/rawMaterial';
|
||||||
import { listProduct } from '@/api/wms/product';
|
import { listProductWithBom } from '@/api/wms/product';
|
||||||
import { completeAction } from '@/api/wms/pendingAction';
|
import { completeAction } from '@/api/wms/pendingAction';
|
||||||
import CoilSelector from '@/components/CoilSelector';
|
import CoilSelector from '@/components/CoilSelector';
|
||||||
import ActualWarehouseSelect from "@/components/KLPService/ActualWarehouseSelect";
|
import ActualWarehouseSelect from "@/components/KLPService/ActualWarehouseSelect";
|
||||||
@@ -249,12 +249,9 @@ export default {
|
|||||||
coilSelectorVisible: false,
|
coilSelectorVisible: false,
|
||||||
// 库区列表
|
// 库区列表
|
||||||
warehouseList: [],
|
warehouseList: [],
|
||||||
// 原材料和产品列表
|
// 原材料和产品列表(实时搜索,不再保存完整备份)
|
||||||
rawMaterialList: [],
|
rawMaterialList: [],
|
||||||
productList: [],
|
productList: [],
|
||||||
// 原始完整列表备份(用于搜索过滤)
|
|
||||||
allRawMaterials: [],
|
|
||||||
allProducts: [],
|
|
||||||
itemSearchLoading: false,
|
itemSearchLoading: false,
|
||||||
// 只读模式
|
// 只读模式
|
||||||
readonly: false,
|
readonly: false,
|
||||||
@@ -268,8 +265,8 @@ export default {
|
|||||||
// 先加载库区列表
|
// 先加载库区列表
|
||||||
await this.loadWarehouses();
|
await this.loadWarehouses();
|
||||||
|
|
||||||
// 🔥 页面加载时直接加载所有原料和产品列表
|
// 不再一次性加载所有数据,改为实时搜索
|
||||||
await this.loadAllItems();
|
// await this.loadAllItems();
|
||||||
|
|
||||||
// 从路由参数获取coilId、actionId和readonly
|
// 从路由参数获取coilId、actionId和readonly
|
||||||
const coilId = this.$route.query.coilId;
|
const coilId = this.$route.query.coilId;
|
||||||
@@ -296,15 +293,15 @@ export default {
|
|||||||
// 清空物品选择
|
// 清空物品选择
|
||||||
this.$set(item, 'itemId', null);
|
this.$set(item, 'itemId', null);
|
||||||
|
|
||||||
// 根据材料类型设置物品类型并恢复完整列表
|
// 根据材料类型设置物品类型
|
||||||
if (item.materialType === '成品') {
|
if (item.materialType === '成品') {
|
||||||
this.$set(item, 'itemType', 'product');
|
this.$set(item, 'itemType', 'product');
|
||||||
// 恢复完整产品列表
|
// 清空列表,等待用户搜索
|
||||||
this.productList = [...this.allProducts];
|
this.productList = [];
|
||||||
} else if (item.materialType === '原料' || item.materialType === '废品') {
|
} else if (item.materialType === '原料' || item.materialType === '废品') {
|
||||||
this.$set(item, 'itemType', 'raw_material');
|
this.$set(item, 'itemType', 'raw_material');
|
||||||
// 恢复完整原料列表
|
// 清空列表,等待用户搜索
|
||||||
this.rawMaterialList = [...this.allRawMaterials];
|
this.rawMaterialList = [];
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -379,13 +376,12 @@ export default {
|
|||||||
return displayName;
|
return displayName;
|
||||||
},
|
},
|
||||||
|
|
||||||
// 物品类型变化
|
// 物品类型变化(已移除,改为实时搜索)
|
||||||
handleItemTypeChange(index) {
|
// handleItemTypeChange(index) {
|
||||||
this.splitList[index].itemId = null;
|
// this.splitList[index].itemId = null;
|
||||||
this.loadItemListForSplit(this.splitList[index].itemType);
|
// },
|
||||||
},
|
|
||||||
|
|
||||||
// 搜索子卷物品(前端过滤,支持名称和规格搜索)
|
// 实时搜索子卷物品(后端搜索)
|
||||||
async searchItemsForSplit(query, index) {
|
async searchItemsForSplit(query, index) {
|
||||||
const item = this.splitList[index];
|
const item = this.splitList[index];
|
||||||
|
|
||||||
@@ -395,109 +391,55 @@ export default {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 如果没有输入,恢复完整列表
|
// 如果没有输入,清空列表
|
||||||
if (!query || query.trim() === '') {
|
if (!query || query.trim() === '') {
|
||||||
if (itemType === 'raw_material') {
|
if (itemType === 'raw_material') {
|
||||||
this.rawMaterialList = [...this.allRawMaterials];
|
this.rawMaterialList = [];
|
||||||
} else if (itemType === 'product') {
|
} else if (itemType === 'product') {
|
||||||
this.productList = [...this.allProducts];
|
this.productList = [];
|
||||||
}
|
}
|
||||||
return;
|
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 {
|
try {
|
||||||
this.itemSearchLoading = true;
|
this.itemSearchLoading = true;
|
||||||
|
const searchQuery = query.trim();
|
||||||
|
|
||||||
if (itemType === 'raw_material') {
|
if (itemType === 'raw_material') {
|
||||||
const response = await listRawMaterial({
|
// 后端搜索原材料(支持名称或规格模糊搜索)
|
||||||
|
const response = await listRawMaterialWithBom({
|
||||||
pageNum: 1,
|
pageNum: 1,
|
||||||
pageSize: 100,
|
pageSize: 20,
|
||||||
withBom: true
|
rawMaterialName: searchQuery,
|
||||||
|
specification: searchQuery // 同时传入,后端会使用 OR 条件
|
||||||
});
|
});
|
||||||
if (response.code === 200) {
|
if (response.code === 200) {
|
||||||
this.rawMaterialList = response.rows || [];
|
this.rawMaterialList = response.rows || [];
|
||||||
}
|
}
|
||||||
} else if (itemType === 'product') {
|
} else if (itemType === 'product') {
|
||||||
const response = await listProduct({
|
// 后端搜索产品(支持名称或规格模糊搜索)
|
||||||
|
const response = await listProductWithBom({
|
||||||
pageNum: 1,
|
pageNum: 1,
|
||||||
pageSize: 100,
|
pageSize: 20,
|
||||||
withBom: true
|
productName: searchQuery,
|
||||||
|
specification: searchQuery // 同时传入,后端会使用 OR 条件
|
||||||
});
|
});
|
||||||
if (response.code === 200) {
|
if (response.code === 200) {
|
||||||
this.productList = response.rows || [];
|
this.productList = response.rows || [];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('split.vue 加载物品列表失败', error);
|
console.error('搜索物品失败', error);
|
||||||
|
this.$message.error('搜索失败,请重试');
|
||||||
} finally {
|
} finally {
|
||||||
this.itemSearchLoading = false;
|
this.itemSearchLoading = false;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
// 已移除 loadAllItems,改为实时搜索
|
||||||
|
|
||||||
|
// 已移除 loadItemListForSplit,改为实时搜索
|
||||||
|
|
||||||
// 显示钢卷选择器
|
// 显示钢卷选择器
|
||||||
showCoilSelector() {
|
showCoilSelector() {
|
||||||
this.coilSelectorVisible = true;
|
this.coilSelectorVisible = true;
|
||||||
@@ -717,10 +659,7 @@ export default {
|
|||||||
// 不复制 itemType 和 itemId,让它们由 materialType 自动决定
|
// 不复制 itemType 和 itemId,让它们由 materialType 自动决定
|
||||||
});
|
});
|
||||||
|
|
||||||
// 加载物品列表
|
// 不再预加载物品列表,改为实时搜索
|
||||||
if (this.motherCoil.itemType) {
|
|
||||||
this.loadItemListForSplit(this.motherCoil.itemType);
|
|
||||||
}
|
|
||||||
|
|
||||||
this.$message.success('已复制到所有子卷');
|
this.$message.success('已复制到所有子卷');
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -218,8 +218,8 @@
|
|||||||
import { getMaterialCoil, updateMaterialCoil, getMaterialCoilTrace } from '@/api/wms/coil';
|
import { getMaterialCoil, updateMaterialCoil, getMaterialCoilTrace } from '@/api/wms/coil';
|
||||||
import { completeAction } from '@/api/wms/pendingAction';
|
import { completeAction } from '@/api/wms/pendingAction';
|
||||||
import { listWarehouse } from '@/api/wms/warehouse';
|
import { listWarehouse } from '@/api/wms/warehouse';
|
||||||
import { listRawMaterial } from '@/api/wms/rawMaterial';
|
import { listRawMaterialWithBom } from '@/api/wms/rawMaterial';
|
||||||
import { listProduct } from '@/api/wms/product';
|
import { listProductWithBom } from '@/api/wms/product';
|
||||||
import ActualWarehouseSelect from "@/components/KLPService/ActualWarehouseSelect";
|
import ActualWarehouseSelect from "@/components/KLPService/ActualWarehouseSelect";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
@@ -300,12 +300,9 @@ export default {
|
|||||||
warehouseList: [],
|
warehouseList: [],
|
||||||
historySteps: [],
|
historySteps: [],
|
||||||
actionId: null,
|
actionId: null,
|
||||||
// 原材料和产品列表
|
// 原材料和产品列表(实时搜索,不再保存完整备份)
|
||||||
rawMaterialList: [],
|
rawMaterialList: [],
|
||||||
productList: [],
|
productList: [],
|
||||||
// 原始完整列表备份(用于搜索过滤)
|
|
||||||
allRawMaterials: [],
|
|
||||||
allProducts: [],
|
|
||||||
itemSearchLoading: false,
|
itemSearchLoading: false,
|
||||||
// 只读模式
|
// 只读模式
|
||||||
readonly: false
|
readonly: false
|
||||||
@@ -352,8 +349,8 @@ export default {
|
|||||||
// 先加载库区列表
|
// 先加载库区列表
|
||||||
await this.loadWarehouses();
|
await this.loadWarehouses();
|
||||||
|
|
||||||
// 🔥 页面加载时直接加载所有原料和产品列表
|
// 不再一次性加载所有数据,改为实时搜索
|
||||||
await this.loadAllItems();
|
// await this.loadAllItems();
|
||||||
|
|
||||||
// 从路由参数获取coilId和actionId
|
// 从路由参数获取coilId和actionId
|
||||||
const coilId = this.$route.query.coilId;
|
const coilId = this.$route.query.coilId;
|
||||||
@@ -382,12 +379,12 @@ export default {
|
|||||||
// 根据材料类型设置物品类型
|
// 根据材料类型设置物品类型
|
||||||
if (value === '成品') {
|
if (value === '成品') {
|
||||||
this.$set(this.updateForm, 'itemType', 'product');
|
this.$set(this.updateForm, 'itemType', 'product');
|
||||||
// 恢复完整产品列表
|
// 清空列表,等待用户搜索
|
||||||
this.productList = [...this.allProducts];
|
this.productList = [];
|
||||||
} else if (value === '原料' || value === '废品') {
|
} else if (value === '原料' || value === '废品') {
|
||||||
this.$set(this.updateForm, 'itemType', 'raw_material');
|
this.$set(this.updateForm, 'itemType', 'raw_material');
|
||||||
// 恢复完整原料列表
|
// 清空列表,等待用户搜索
|
||||||
this.rawMaterialList = [...this.allRawMaterials];
|
this.rawMaterialList = [];
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -406,10 +403,7 @@ export default {
|
|||||||
nextWarehouseName: this.getWarehouseName(data.warehouseId),
|
nextWarehouseName: this.getWarehouseName(data.warehouseId),
|
||||||
};
|
};
|
||||||
|
|
||||||
// 加载对应类型的物品列表
|
// 不再预加载物品列表,改为实时搜索
|
||||||
if (data.itemType) {
|
|
||||||
await this.loadItemList(data.itemType);
|
|
||||||
}
|
|
||||||
|
|
||||||
// 加载变更历史
|
// 加载变更历史
|
||||||
this.loadHistory();
|
this.loadHistory();
|
||||||
@@ -492,115 +486,59 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
// 页面加载时一次性加载所有原料和产品列表
|
// 已移除 loadAllItems,改为实时搜索
|
||||||
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) {
|
// 已移除 loadItemList,改为实时搜索
|
||||||
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 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) {
|
async searchItems(query) {
|
||||||
if (!this.updateForm.itemType) {
|
if (!this.updateForm.itemType) {
|
||||||
this.$message.warning('请先选择材料类型');
|
this.$message.warning('请先选择材料类型');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 如果没有输入,恢复完整列表
|
// 如果没有输入,清空列表
|
||||||
if (!query || query.trim() === '') {
|
if (!query || query.trim() === '') {
|
||||||
if (this.updateForm.itemType === 'raw_material') {
|
if (this.updateForm.itemType === 'raw_material') {
|
||||||
this.rawMaterialList = [...this.allRawMaterials];
|
this.rawMaterialList = [];
|
||||||
} else if (this.updateForm.itemType === 'product') {
|
} else if (this.updateForm.itemType === 'product') {
|
||||||
this.productList = [...this.allProducts];
|
this.productList = [];
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 前端过滤:在已加载的数据中搜索
|
try {
|
||||||
const searchQuery = query.toLowerCase().trim();
|
this.itemSearchLoading = true;
|
||||||
|
const searchQuery = query.trim();
|
||||||
|
|
||||||
if (this.updateForm.itemType === 'raw_material') {
|
if (this.updateForm.itemType === 'raw_material') {
|
||||||
// 从备份列表中过滤原材料
|
// 后端搜索原材料(支持名称或规格模糊搜索)
|
||||||
this.rawMaterialList = this.allRawMaterials.filter(item => {
|
const response = await listRawMaterialWithBom({
|
||||||
// 搜索名称
|
pageNum: 1,
|
||||||
const nameMatch = item.rawMaterialName && item.rawMaterialName.toLowerCase().includes(searchQuery);
|
pageSize: 20,
|
||||||
// 搜索规格
|
rawMaterialName: searchQuery,
|
||||||
const specMatch = item.specification && item.specification.toLowerCase().includes(searchQuery);
|
specification: searchQuery // 同时传入,后端会使用 OR 条件
|
||||||
// 搜索 参数 参数
|
|
||||||
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 (response.code === 200) {
|
||||||
|
this.rawMaterialList = response.rows || [];
|
||||||
|
}
|
||||||
} else if (this.updateForm.itemType === 'product') {
|
} else if (this.updateForm.itemType === 'product') {
|
||||||
// 从备份列表中过滤产品
|
// 后端搜索产品(支持名称或规格模糊搜索)
|
||||||
this.productList = this.allProducts.filter(item => {
|
const response = await listProductWithBom({
|
||||||
// 搜索名称
|
pageNum: 1,
|
||||||
const nameMatch = item.productName && item.productName.toLowerCase().includes(searchQuery);
|
pageSize: 20,
|
||||||
// 搜索规格
|
productName: searchQuery,
|
||||||
const specMatch = item.specification && item.specification.toLowerCase().includes(searchQuery);
|
specification: searchQuery // 同时传入,后端会使用 OR 条件
|
||||||
// 搜索 参数 参数
|
|
||||||
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 (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")
|
@GetMapping("/listWithBom")
|
||||||
public TableDataInfo<WmsProductVo> listWithBom(WmsProductBo bo, PageQuery pageQuery) {
|
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);
|
return iWmsProductService.queryPageListWithBom(bo, pageQuery);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -50,6 +50,10 @@ public class WmsRawMaterialController extends BaseController {
|
|||||||
*/
|
*/
|
||||||
@GetMapping("/listWithBom")
|
@GetMapping("/listWithBom")
|
||||||
public TableDataInfo<WmsRawMaterialVo> listWithBom(WmsRawMaterialBo bo, PageQuery pageQuery) {
|
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);
|
return iWmsRawMaterialService.queryPageListWithBom(bo, pageQuery);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -211,6 +211,82 @@ public class WmsMaterialCoilVo extends BaseEntity {
|
|||||||
*/
|
*/
|
||||||
private String packagingRequirement;
|
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.domain.vo.WmsStockVo;
|
||||||
import com.klp.mapper.WmsMaterialCoilMapper;
|
import com.klp.mapper.WmsMaterialCoilMapper;
|
||||||
import com.klp.mapper.WmsStockMapper;
|
import com.klp.mapper.WmsStockMapper;
|
||||||
|
import com.klp.mapper.WmsGenerateRecordMapper;
|
||||||
import com.klp.service.IWmsMaterialCoilService;
|
import com.klp.service.IWmsMaterialCoilService;
|
||||||
import com.klp.service.IWmsStockService;
|
import com.klp.service.IWmsStockService;
|
||||||
import com.klp.service.IWmsGenerateRecordService;
|
import com.klp.service.IWmsGenerateRecordService;
|
||||||
@@ -61,6 +62,7 @@ public class WmsMaterialCoilServiceImpl implements IWmsMaterialCoilService {
|
|||||||
private final WmsMaterialCoilMapper baseMapper;
|
private final WmsMaterialCoilMapper baseMapper;
|
||||||
private final IWmsStockService stockService;
|
private final IWmsStockService stockService;
|
||||||
private final IWmsGenerateRecordService generateRecordService;
|
private final IWmsGenerateRecordService generateRecordService;
|
||||||
|
private final WmsGenerateRecordMapper generateRecordMapper;
|
||||||
private final IWmsWarehouseService warehouseService;
|
private final IWmsWarehouseService warehouseService;
|
||||||
private final IWmsActualWarehouseService actualWarehouseService;
|
private final IWmsActualWarehouseService actualWarehouseService;
|
||||||
private final IWmsRawMaterialService rawMaterialService;
|
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) {
|
private void fillRelatedObjects(WmsMaterialCoilVo vo) {
|
||||||
// 查询所在库区信息
|
// 查询所在库区信息
|
||||||
@@ -150,9 +298,9 @@ public class WmsMaterialCoilServiceImpl implements IWmsMaterialCoilService {
|
|||||||
QueryWrapper<WmsMaterialCoil> qw = buildQueryWrapperPlus(bo);
|
QueryWrapper<WmsMaterialCoil> qw = buildQueryWrapperPlus(bo);
|
||||||
Page<WmsMaterialCoilVo> result = baseMapper.selectVoPagePlus(pageQuery.build(), qw);
|
Page<WmsMaterialCoilVo> result = baseMapper.selectVoPagePlus(pageQuery.build(), qw);
|
||||||
|
|
||||||
// 填充每个记录的产品或原材料对象
|
// 从联查结果中构建产品和原材料对象(避免单独查询)
|
||||||
for (WmsMaterialCoilVo vo : result.getRecords()) {
|
for (WmsMaterialCoilVo vo : result.getRecords()) {
|
||||||
fillItemObject(vo);
|
buildItemObjectFromJoin(vo);
|
||||||
}
|
}
|
||||||
|
|
||||||
return TableDataInfo.build(result);
|
return TableDataInfo.build(result);
|
||||||
@@ -211,16 +359,53 @@ public class WmsMaterialCoilServiceImpl implements IWmsMaterialCoilService {
|
|||||||
QueryWrapper<WmsMaterialCoil> lqw = buildQueryWrapperPlus(bo);
|
QueryWrapper<WmsMaterialCoil> lqw = buildQueryWrapperPlus(bo);
|
||||||
List<WmsMaterialCoilVo> list = baseMapper.selectVoListWithDynamicJoin(lqw);
|
List<WmsMaterialCoilVo> list = baseMapper.selectVoListWithDynamicJoin(lqw);
|
||||||
|
|
||||||
// 填充每个记录的产品或原材料对象
|
// 从联查结果中构建产品和原材料对象(避免单独查询)
|
||||||
for (WmsMaterialCoilVo vo : list) {
|
for (WmsMaterialCoilVo vo : list) {
|
||||||
fillItemObject(vo);
|
buildItemObjectFromJoin(vo);
|
||||||
}
|
}
|
||||||
|
|
||||||
return list;
|
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) {
|
private void fillItemObject(WmsMaterialCoilVo vo) {
|
||||||
if (vo.getItemId() == null || vo.getItemType() == null) {
|
if (vo.getItemId() == null || vo.getItemType() == null) {
|
||||||
@@ -1034,7 +1219,7 @@ public class WmsMaterialCoilServiceImpl implements IWmsMaterialCoilService {
|
|||||||
@Override
|
@Override
|
||||||
public Map<String, Object> queryTrace(String enterCoilNo, String currentCoilNo) {
|
public Map<String, Object> queryTrace(String enterCoilNo, String currentCoilNo) {
|
||||||
try {
|
try {
|
||||||
// 1. 查询所有相关的二维码记录(包括分卷后的独立二维码)
|
// 优化1: 使用LIKE查询替代查询所有记录,大幅提升性能
|
||||||
List<WmsGenerateRecordVo> allQrRecords = new ArrayList<>();
|
List<WmsGenerateRecordVo> allQrRecords = new ArrayList<>();
|
||||||
|
|
||||||
// 首先查询主二维码(以入场钢卷号为序列号的)
|
// 首先查询主二维码(以入场钢卷号为序列号的)
|
||||||
@@ -1043,14 +1228,21 @@ public class WmsMaterialCoilServiceImpl implements IWmsMaterialCoilService {
|
|||||||
List<WmsGenerateRecordVo> mainQrRecords = generateRecordService.queryList(qrBo);
|
List<WmsGenerateRecordVo> mainQrRecords = generateRecordService.queryList(qrBo);
|
||||||
allQrRecords.addAll(mainQrRecords);
|
allQrRecords.addAll(mainQrRecords);
|
||||||
|
|
||||||
// 然后查询所有以该入场钢卷号开头的二维码(分卷后的二维码)
|
// 优化:使用LIKE查询所有以该入场钢卷号开头的二维码(分卷后的二维码)
|
||||||
WmsGenerateRecordBo splitQrBo = new WmsGenerateRecordBo();
|
// 而不是查询所有记录然后在内存中过滤
|
||||||
List<WmsGenerateRecordVo> allRecords = generateRecordService.queryList(splitQrBo);
|
LambdaQueryWrapper<com.klp.domain.WmsGenerateRecord> splitWrapper = Wrappers.lambdaQuery();
|
||||||
for (WmsGenerateRecordVo record : allRecords) {
|
splitWrapper.like(com.klp.domain.WmsGenerateRecord::getSerialNumber, enterCoilNo + "-");
|
||||||
if (record.getSerialNumber() != null &&
|
List<WmsGenerateRecordVo> splitRecords = generateRecordMapper.selectVoList(splitWrapper);
|
||||||
record.getSerialNumber().startsWith(enterCoilNo + "-") &&
|
|
||||||
!allQrRecords.contains(record)) {
|
// 去重:使用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);
|
allQrRecords.add(record);
|
||||||
|
existingRecordIds.add(record.getRecordId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1058,14 +1250,16 @@ public class WmsMaterialCoilServiceImpl implements IWmsMaterialCoilService {
|
|||||||
throw new RuntimeException("未找到对应的二维码记录");
|
throw new RuntimeException("未找到对应的二维码记录");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 优化2: ObjectMapper在循环外创建,避免重复创建
|
||||||
|
ObjectMapper objectMapper = new ObjectMapper();
|
||||||
|
|
||||||
// 2. 合并所有二维码的steps信息,去重并重新编号
|
// 2. 合并所有二维码的steps信息,去重并重新编号
|
||||||
Map<String, Map<String, Object>> uniqueSteps = new HashMap<>(); // 用于去重
|
Map<String, Map<String, Object>> uniqueSteps = new HashMap<>(); // 用于去重
|
||||||
Set<String> allCoilNos = new HashSet<>();
|
Set<String> allCoilNos = new HashSet<>();
|
||||||
|
|
||||||
for (WmsGenerateRecordVo qrRecord : allQrRecords) {
|
for (WmsGenerateRecordVo qrRecord : allQrRecords) {
|
||||||
ObjectMapper objectMapper = new ObjectMapper();
|
|
||||||
@SuppressWarnings("unchecked")
|
@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")
|
@SuppressWarnings("unchecked")
|
||||||
List<Map<String, Object>> steps = (List<Map<String, Object>>) contentMap.get("steps");
|
List<Map<String, Object>> steps = (List<Map<String, Object>>) contentMap.get("steps");
|
||||||
@@ -1125,32 +1319,41 @@ public class WmsMaterialCoilServiceImpl implements IWmsMaterialCoilService {
|
|||||||
.collect(Collectors.toSet());
|
.collect(Collectors.toSet());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 优化3: 使用IN查询替代多个OR条件,提升查询性能
|
||||||
// 4. 根据提取的钢卷号反向查询数据库
|
// 4. 根据提取的钢卷号反向查询数据库
|
||||||
List<WmsMaterialCoilVo> result = new ArrayList<>();
|
List<WmsMaterialCoilVo> result = new ArrayList<>();
|
||||||
if (!filteredCoilNos.isEmpty()) {
|
if (!filteredCoilNos.isEmpty()) {
|
||||||
LambdaQueryWrapper<WmsMaterialCoil> lqw = Wrappers.lambdaQuery();
|
LambdaQueryWrapper<WmsMaterialCoil> lqw = Wrappers.lambdaQuery();
|
||||||
lqw.eq(WmsMaterialCoil::getEnterCoilNo, enterCoilNo);
|
lqw.eq(WmsMaterialCoil::getEnterCoilNo, enterCoilNo);
|
||||||
|
|
||||||
// 查询包含提取出的钢卷号的记录
|
// 优化:使用IN查询替代多个OR条件(当钢卷号数量较少时)
|
||||||
final Set<String> finalCoilNos = filteredCoilNos;
|
// 如果数量太多(>1000),分批查询避免SQL过长
|
||||||
lqw.and(wrapper -> {
|
List<String> coilNoList = new ArrayList<>(filteredCoilNos);
|
||||||
int count = 0;
|
if (coilNoList.size() <= 1000) {
|
||||||
for (String coilNo : finalCoilNos) {
|
lqw.in(WmsMaterialCoil::getCurrentCoilNo, coilNoList);
|
||||||
if (count == 0) {
|
|
||||||
wrapper.eq(WmsMaterialCoil::getCurrentCoilNo, coilNo);
|
|
||||||
} else {
|
} else {
|
||||||
wrapper.or().eq(WmsMaterialCoil::getCurrentCoilNo, coilNo);
|
// 分批查询
|
||||||
|
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);
|
||||||
}
|
}
|
||||||
count++;
|
|
||||||
}
|
}
|
||||||
});
|
|
||||||
|
|
||||||
|
if (coilNoList.size() <= 1000) {
|
||||||
lqw.orderByAsc(WmsMaterialCoil::getCreateTime);
|
lqw.orderByAsc(WmsMaterialCoil::getCreateTime);
|
||||||
result = baseMapper.selectVoList(lqw);
|
result = baseMapper.selectVoList(lqw);
|
||||||
|
}
|
||||||
|
|
||||||
// 填充每个记录的关联对象信息(如库区)
|
// 优化4: 批量填充关联对象,避免N+1查询
|
||||||
for (WmsMaterialCoilVo vo : result) {
|
if (!result.isEmpty()) {
|
||||||
fillRelatedObjects(vo);
|
fillRelatedObjectsBatch(result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1161,9 +1364,9 @@ public class WmsMaterialCoilServiceImpl implements IWmsMaterialCoilService {
|
|||||||
lqw.orderByAsc(WmsMaterialCoil::getCreateTime);
|
lqw.orderByAsc(WmsMaterialCoil::getCreateTime);
|
||||||
result = baseMapper.selectVoList(lqw);
|
result = baseMapper.selectVoList(lqw);
|
||||||
|
|
||||||
// 填充每个记录的关联对象信息
|
// 优化:批量填充关联对象
|
||||||
for (WmsMaterialCoilVo vo : result) {
|
if (!result.isEmpty()) {
|
||||||
fillRelatedObjects(vo);
|
fillRelatedObjectsBatch(result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -92,7 +92,24 @@ public class WmsProductServiceImpl implements IWmsProductService {
|
|||||||
Map<String, Object> params = bo.getParams();
|
Map<String, Object> params = bo.getParams();
|
||||||
LambdaQueryWrapper<WmsProduct> lqw = Wrappers.lambdaQuery();
|
LambdaQueryWrapper<WmsProduct> lqw = Wrappers.lambdaQuery();
|
||||||
lqw.eq(StringUtils.isNotBlank(bo.getProductCode()), WmsProduct::getProductCode, bo.getProductCode());
|
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(StringUtils.isNotBlank(bo.getOwner()), WmsProduct::getOwner, bo.getOwner());
|
||||||
lqw.eq(bo.getBaseMaterialId() != null, WmsProduct::getBaseMaterialId, bo.getBaseMaterialId());
|
lqw.eq(bo.getBaseMaterialId() != null, WmsProduct::getBaseMaterialId, bo.getBaseMaterialId());
|
||||||
lqw.eq(bo.getSurfaceTreatmentId() != null, WmsProduct::getSurfaceTreatmentId, bo.getSurfaceTreatmentId());
|
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.getIsEnabled() != null, WmsProduct::getIsEnabled, bo.getIsEnabled());
|
||||||
lqw.eq(bo.getBomId() != null, WmsProduct::getBomId, bo.getBomId());
|
lqw.eq(bo.getBomId() != null, WmsProduct::getBomId, bo.getBomId());
|
||||||
lqw.eq(StringUtils.isNotBlank(bo.getType()), WmsProduct::getType, bo.getType());
|
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.getMaterial()), WmsProduct::getMaterial, bo.getMaterial());
|
||||||
lqw.eq(StringUtils.isNotBlank(bo.getSurfaceTreatmentDesc()), WmsProduct::getSurfaceTreatmentDesc, bo.getSurfaceTreatmentDesc());
|
lqw.eq(StringUtils.isNotBlank(bo.getSurfaceTreatmentDesc()), WmsProduct::getSurfaceTreatmentDesc, bo.getSurfaceTreatmentDesc());
|
||||||
lqw.eq(StringUtils.isNotBlank(bo.getManufacturer()), WmsProduct::getManufacturer, bo.getManufacturer());
|
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();
|
Map<String, Object> params = bo.getParams();
|
||||||
LambdaQueryWrapper<WmsRawMaterial> lqw = Wrappers.lambdaQuery();
|
LambdaQueryWrapper<WmsRawMaterial> lqw = Wrappers.lambdaQuery();
|
||||||
lqw.eq(StringUtils.isNotBlank(bo.getRawMaterialCode()), WmsRawMaterial::getRawMaterialCode, bo.getRawMaterialCode());
|
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.getSteelGrade()), WmsRawMaterial::getSteelGrade, bo.getSteelGrade());
|
||||||
lqw.eq(StringUtils.isNotBlank(bo.getTargetColdGrade()), WmsRawMaterial::getTargetColdGrade, bo.getTargetColdGrade());
|
lqw.eq(StringUtils.isNotBlank(bo.getTargetColdGrade()), WmsRawMaterial::getTargetColdGrade, bo.getTargetColdGrade());
|
||||||
lqw.eq(bo.getBaseMaterialId() != null, WmsRawMaterial::getBaseMaterialId, bo.getBaseMaterialId());
|
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(StringUtils.isNotBlank(bo.getInspectionResult()), WmsRawMaterial::getInspectionResult, bo.getInspectionResult());
|
||||||
lqw.eq(bo.getIsEnabled() != null, WmsRawMaterial::getIsEnabled, bo.getIsEnabled());
|
lqw.eq(bo.getIsEnabled() != null, WmsRawMaterial::getIsEnabled, bo.getIsEnabled());
|
||||||
lqw.eq(bo.getBomId() != null, WmsRawMaterial::getBomId, bo.getBomId());
|
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.getMaterial()), WmsRawMaterial::getMaterial, bo.getMaterial());
|
||||||
lqw.eq(StringUtils.isNotBlank(bo.getSurfaceTreatmentDesc()), WmsRawMaterial::getSurfaceTreatmentDesc, bo.getSurfaceTreatmentDesc());
|
lqw.eq(StringUtils.isNotBlank(bo.getSurfaceTreatmentDesc()), WmsRawMaterial::getSurfaceTreatmentDesc, bo.getSurfaceTreatmentDesc());
|
||||||
lqw.eq(StringUtils.isNotBlank(bo.getManufacturer()), WmsRawMaterial::getManufacturer, bo.getManufacturer());
|
lqw.eq(StringUtils.isNotBlank(bo.getManufacturer()), WmsRawMaterial::getManufacturer, bo.getManufacturer());
|
||||||
|
|||||||
@@ -94,10 +94,40 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
mc.packaging_requirement,
|
mc.packaging_requirement,
|
||||||
mc.packing_status,
|
mc.packing_status,
|
||||||
w.warehouse_name AS warehouseName,
|
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
|
FROM wms_material_coil mc
|
||||||
LEFT JOIN wms_warehouse w ON mc.warehouse_id = w.warehouse_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
|
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}
|
${ew.customSqlSegment}
|
||||||
</select>
|
</select>
|
||||||
<!-- 查询不同类型的钢卷在不同库区的分布情况 -->
|
<!-- 查询不同类型的钢卷在不同库区的分布情况 -->
|
||||||
@@ -141,7 +171,25 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
<select id="selectVoListWithDynamicJoin" resultType="com.klp.domain.vo.WmsMaterialCoilVo">
|
<select id="selectVoListWithDynamicJoin" resultType="com.klp.domain.vo.WmsMaterialCoilVo">
|
||||||
SELECT mc.*,
|
SELECT mc.*,
|
||||||
w.warehouse_name AS warehouseName,
|
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
|
CASE
|
||||||
WHEN mc.item_type = 'raw_material' THEN rm.raw_material_name
|
WHEN mc.item_type = 'raw_material' THEN rm.raw_material_name
|
||||||
WHEN mc.item_type = 'product' THEN p.product_name
|
WHEN mc.item_type = 'product' THEN p.product_name
|
||||||
|
|||||||
Reference in New Issue
Block a user