Commit c7cf6243 by yubin

组件双击 去选框 弹窗修改高度 物料根据库存排序反显 列表id修改

parent 278338ea
...@@ -55,7 +55,8 @@ ...@@ -55,7 +55,8 @@
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button> <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
</el-form-item> </el-form-item>
</el-form> </el-form>
<div class="table-container" style="flex: 1; min-height: 400px; max-height: 600px; overflow: auto; margin: 10px 0;">
<!-- 物料表格(恢复所有字段显示) --> <!-- 物料表格(恢复所有字段显示) -->
<el-table <el-table
ref="materialTable" ref="materialTable"
...@@ -66,12 +67,15 @@ ...@@ -66,12 +67,15 @@
:row-key="row => row.id" :row-key="row => row.id"
@row-click="handleRowClick" @row-click="handleRowClick"
:select-on-indeterminate="false" :select-on-indeterminate="false"
@select="handleTableSelect" @select="handleTableSelect"
@row-dblclick="handleRowDblClick"
> >
<!-- 单选模式下隐藏选择框 -->
<el-table-column <el-table-column
type="selection" type="selection"
width="55" width="55"
align="center" align="center"
v-if="multiple"
/> />
<el-table-column type="index" label="序号" align="center"/> <el-table-column type="index" label="序号" align="center"/>
<el-table-column label="SAP物料号" align="center" prop="sapNo" /> <el-table-column label="SAP物料号" align="center" prop="sapNo" />
...@@ -79,7 +83,7 @@ ...@@ -79,7 +83,7 @@
<el-table-column label="TS Code" align="center" prop="tsCode" /> <el-table-column label="TS Code" align="center" prop="tsCode" />
<el-table-column label="物料分类" align="center" prop="categoryCode"> <el-table-column label="物料分类" align="center" prop="categoryCode">
<template slot-scope="scope"> <template slot-scope="scope">
{{ scope.row.displayCategory || categoryMap[scope.row.categoryCode] || scope.row.categoryCode || '-' }} {{ scope.row.displayCategory }}
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="规格型号" align="center" prop="specification" /> <el-table-column label="规格型号" align="center" prop="specification" />
...@@ -92,7 +96,8 @@ ...@@ -92,7 +96,8 @@
</template> </template>
</el-table-column> </el-table-column>
</el-table> </el-table>
</div>
<!-- 分页 --> <!-- 分页 -->
<pagination <pagination
v-show="total>0" v-show="total>0"
...@@ -221,6 +226,55 @@ export default { ...@@ -221,6 +226,55 @@ export default {
this.getList() this.getList()
}, },
methods: { methods: {
// 新增:双击行事件处理
handleRowDblClick(row) {
if (this.isSelecting || !this.$refs.materialTable) return
this.isSelecting = true
try {
// 单选模式下双击直接选择并关闭组件
if (!this.multiple) {
// 选中当前行
this.$refs.materialTable.clearSelection()
this.$refs.materialTable.toggleRowSelection(row, true)
this.singleSelectedId = row.id
this.selectedRows = [row]
// 构造返回数据
const selectedData = {
id: row.id,
sapNo: row.sapNo,
materialName: row.materialName,
tsCode: row.tsCode,
categoryCode: row.categoryCode,
categoryName: this.categoryMap[row.categoryCode] || row.categoryCode,
specification: row.specification,
materialUnit: row.materialUnit,
isBatchManaged: row.isBatchManaged
}
// 触发事件
this.$emit('input', row.id)
this.$emit('change', selectedData)
this.$emit('selection-change', {
materialIds: [row.id],
materials: [selectedData],
names: [row.materialName],
categoryIds: [row.categoryCode || '']
})
// 触发关闭事件(需要父组件监听此事件并关闭弹窗)
this.$emit('confirm', selectedData)
this.$emit('close')
} else {
// 多选模式下双击仅切换选择状态
this.$refs.materialTable.toggleRowSelection(row)
}
} finally {
this.isSelecting = false
}
},
// 恢复分类列表加载(分类名称映射) // 恢复分类列表加载(分类名称映射)
async getCategoryList() { async getCategoryList() {
try { try {
...@@ -246,6 +300,7 @@ export default { ...@@ -246,6 +300,7 @@ export default {
console.error('获取分类列表失败:', error) console.error('获取分类列表失败:', error)
} }
}, },
handleValueChange(val) { handleValueChange(val) {
if (this.isSelecting) return if (this.isSelecting) return
...@@ -276,6 +331,7 @@ export default { ...@@ -276,6 +331,7 @@ export default {
this.handleValueSync() this.handleValueSync()
} }
}, },
async getCategoryTreeData() { async getCategoryTreeData() {
this.loadingTree = true this.loadingTree = true
try { try {
...@@ -291,6 +347,7 @@ export default { ...@@ -291,6 +347,7 @@ export default {
this.loadingTree = false this.loadingTree = false
} }
}, },
buildTreeData(list, parentId = null) { buildTreeData(list, parentId = null) {
return list return list
.filter(item => parentId === null .filter(item => parentId === null
...@@ -306,6 +363,7 @@ export default { ...@@ -306,6 +363,7 @@ export default {
: undefined : undefined
})) }))
}, },
buildCategoryCodeToSidMap(treeData) { buildCategoryCodeToSidMap(treeData) {
treeData.forEach(node => { treeData.forEach(node => {
if (node.categoryCode) { if (node.categoryCode) {
...@@ -320,6 +378,7 @@ export default { ...@@ -320,6 +378,7 @@ export default {
} }
}) })
}, },
selectCategoryNodes(categoryCodes) { selectCategoryNodes(categoryCodes) {
if (!this.$refs.treeComponent || !this.$refs.treeComponent.$refs.tree) return if (!this.$refs.treeComponent || !this.$refs.treeComponent.$refs.tree) return
const tree = this.$refs.treeComponent.$refs.tree const tree = this.$refs.treeComponent.$refs.tree
...@@ -334,6 +393,7 @@ export default { ...@@ -334,6 +393,7 @@ export default {
} }
}) })
}, },
handleTreeClick(data) { handleTreeClick(data) {
this.currentNodeId = data.sid this.currentNodeId = data.sid
this.queryParams.categoryCode = data.categoryCode this.queryParams.categoryCode = data.categoryCode
...@@ -341,13 +401,14 @@ export default { ...@@ -341,13 +401,14 @@ export default {
this.queryParams.pageNum = 1 this.queryParams.pageNum = 1
this.getList() this.getList()
}, },
getList() { getList() {
this.loading = true this.loading = true
listMaterials(this.queryParams).then(response => { listMaterials(this.queryParams).then(response => {
// 恢复所有字段映射(显示用) // 恢复所有字段映射(显示用)
this.materialsList = (response.rows || []).filter(item => item.isUsed !== 0 && item.isUsed !== '0').map(item => ({ this.materialsList = (response.rows || []).filter(item => item.isUsed !== 0 && item.isUsed !== '0').map(item => ({
...item, ...item,
displayCategory: this.categoryMap[item.categoryCode] || `${item.categoryCode}(未匹配分类)` displayCategory: this.categoryMap[item.categoryCode] || '未匹配分类'
})) }))
this.total = response.total || 0 this.total = response.total || 0
this.$nextTick(() => { this.$nextTick(() => {
...@@ -361,6 +422,7 @@ export default { ...@@ -361,6 +422,7 @@ export default {
this.loading = false this.loading = false
}) })
}, },
handleQuery() { handleQuery() {
// 恢复分类名称查询逻辑 // 恢复分类名称查询逻辑
const inputName = this.queryParams.categoryNameInput const inputName = this.queryParams.categoryNameInput
...@@ -380,6 +442,7 @@ export default { ...@@ -380,6 +442,7 @@ export default {
this.queryParams.pageNum = 1 this.queryParams.pageNum = 1
this.getList() this.getList()
}, },
resetQuery() { resetQuery() {
// 恢复所有查询参数重置 // 恢复所有查询参数重置
this.queryParams = { this.queryParams = {
...@@ -399,6 +462,7 @@ export default { ...@@ -399,6 +462,7 @@ export default {
this.clearSelection() this.clearSelection()
this.getList() this.getList()
}, },
// 核心:基于 ID 的选择事件(保留所有字段返回) // 核心:基于 ID 的选择事件(保留所有字段返回)
handleSelectionChange(selection) { handleSelectionChange(selection) {
if (this.isSelecting || !this.$refs.materialTable) return if (this.isSelecting || !this.$refs.materialTable) return
...@@ -454,6 +518,7 @@ export default { ...@@ -454,6 +518,7 @@ export default {
this.isSelecting = false this.isSelecting = false
} }
}, },
// 单选模式下的选择事件(纯 ID 逻辑,保留字段返回) // 单选模式下的选择事件(纯 ID 逻辑,保留字段返回)
handleTableSelect(selection, row) { handleTableSelect(selection, row) {
if (this.isSelecting || this.multiple) return if (this.isSelecting || this.multiple) return
...@@ -502,6 +567,7 @@ export default { ...@@ -502,6 +567,7 @@ export default {
this.isSelecting = false this.isSelecting = false
} }
}, },
// 行点击事件(纯 ID 逻辑,保留字段返回) // 行点击事件(纯 ID 逻辑,保留字段返回)
handleRowClick(row) { handleRowClick(row) {
if (this.isSelecting || !this.$refs.materialTable) return if (this.isSelecting || !this.$refs.materialTable) return
...@@ -555,6 +621,7 @@ export default { ...@@ -555,6 +621,7 @@ export default {
this.isSelecting = false this.isSelecting = false
} }
}, },
// 清空选择(纯 ID 逻辑) // 清空选择(纯 ID 逻辑)
clearSelection() { clearSelection() {
if (this.isSelecting || !this.$refs.materialTable) return if (this.isSelecting || !this.$refs.materialTable) return
...@@ -576,6 +643,7 @@ export default { ...@@ -576,6 +643,7 @@ export default {
this.isSelecting = false this.isSelecting = false
} }
}, },
// 核心:基于 ID 的反显逻辑(保留所有字段显示) // 核心:基于 ID 的反显逻辑(保留所有字段显示)
handleValueSync(isRetry = false) { handleValueSync(isRetry = false) {
if (this.loading || this.isSelecting || !this.$refs.materialTable) return if (this.loading || this.isSelecting || !this.$refs.materialTable) return
...@@ -646,6 +714,7 @@ export default { ...@@ -646,6 +714,7 @@ export default {
this.isRetrySync = false this.isRetrySync = false
} }
}, },
// 外部设置选中 ID 的方法 // 外部设置选中 ID 的方法
setSelectedIds(ids) { setSelectedIds(ids) {
if (this.isSelecting) return if (this.isSelecting) return
...@@ -665,6 +734,7 @@ export default { ...@@ -665,6 +734,7 @@ export default {
this.isSelecting = false this.isSelecting = false
} }
}, },
// 获取选中物料(返回完整字段,核心为ID) // 获取选中物料(返回完整字段,核心为ID)
getSelectedMaterials() { getSelectedMaterials() {
if (this.multiple) { if (this.multiple) {
...@@ -693,6 +763,7 @@ export default { ...@@ -693,6 +763,7 @@ export default {
} : null } : null
} }
}, },
// 单选模式下设置选中 ID // 单选模式下设置选中 ID
setSingleSelection(id) { setSingleSelection(id) {
if (this.isSelecting || this.multiple) return if (this.isSelecting || this.multiple) return
...@@ -758,9 +829,17 @@ export default { ...@@ -758,9 +829,17 @@ export default {
} }
/deep/ .el-table--enable-row-hover .el-table__body tr:hover>td { /deep/ .el-table--enable-row-hover .el-table__body tr:hover>td {
background-color: #f5f7fa; background-color: #f5f7fa;
cursor: pointer; /* 新增:鼠标悬停显示指针 */
} }
/deep/ .el-table__fixed-right, /deep/ .el-table__fixed-right,
/deep/ .el-table__fixed-left { /deep/ .el-table__fixed-left {
pointer-events: auto !important; pointer-events: auto !important;
} }
/* 单选模式下表格行样式优化 */
/deep/ .el-table__body tr.el-table__row--striped td {
background-color: #fafafa;
}
/deep/ .el-table__body tr.current-row td {
background-color: #e8f4fd !important;
}
</style> </style>
\ No newline at end of file
...@@ -71,7 +71,7 @@ ...@@ -71,7 +71,7 @@
@keyup.enter.native="handleQuery" @keyup.enter.native="handleQuery"
/> />
</el-form-item> </el-form-item>
<el-form-item label="仓库" prop="warehouseId"> <!-- <el-form-item label="仓库" prop="warehouseId">
<el-input <el-input
v-model="queryWarehouseName" v-model="queryWarehouseName"
placeholder="请选择仓库" placeholder="请选择仓库"
...@@ -89,7 +89,7 @@ ...@@ -89,7 +89,7 @@
></i> ></i>
</template> </template>
</el-input> </el-input>
</el-form-item> </el-form-item> -->
<el-form-item label="层" prop="layerCode"> <el-form-item label="层" prop="layerCode">
<el-input <el-input
v-model="queryParams.layerCode" v-model="queryParams.layerCode"
...@@ -230,11 +230,11 @@ ...@@ -230,11 +230,11 @@
<el-table-column type="selection" width="55" align="center" fixed /> <el-table-column type="selection" width="55" align="center" fixed />
<el-table-column label="库位编码" align="center" prop="locationCode" width="120" fixed /> <el-table-column label="库位编码" align="center" prop="locationCode" width="120" fixed />
<el-table-column label="库位名称" align="center" prop="locationName" width="150" /> <el-table-column label="库位名称" align="center" prop="locationName" width="150" />
<el-table-column label="仓库" align="center" prop="warehousesName" width="180"> <!-- <el-table-column label="仓库" align="center" prop="warehousesName" width="180">
<template slot-scope="scope"> <template slot-scope="scope">
{{ scope.row.warehousesName }} {{ scope.row.warehousesName }}
</template> </template>
</el-table-column> </el-table-column> -->
<el-table-column label="库位类型" align="center" prop="locationType" width="100"> <el-table-column label="库位类型" align="center" prop="locationType" width="100">
<template slot-scope="scope"> <template slot-scope="scope">
<dict-tag :options="dict.type.location_type" :value="scope.row.locationType"/> <dict-tag :options="dict.type.location_type" :value="scope.row.locationType"/>
...@@ -357,7 +357,7 @@ ...@@ -357,7 +357,7 @@
</el-form-item> </el-form-item>
</el-col> </el-col>
</el-row> </el-row>
<el-form-item label="仓库" prop="warehouseId"> <!-- <el-form-item label="仓库" prop="warehouseId">
<el-input <el-input
v-model="form.warehouseName" v-model="form.warehouseName"
placeholder="请选择仓库" placeholder="请选择仓库"
...@@ -375,7 +375,7 @@ ...@@ -375,7 +375,7 @@
></i> ></i>
</template> </template>
</el-input> </el-input>
</el-form-item> </el-form-item> -->
<el-row :gutter="20"> <el-row :gutter="20">
<el-col :span="12"> <el-col :span="12">
<el-form-item label="库位类型" prop="locationType"> <el-form-item label="库位类型" prop="locationType">
...@@ -583,10 +583,10 @@ ...@@ -583,10 +583,10 @@
/> />
<!-- 仓库选择器组件 --> <!-- 仓库选择器组件 -->
<WarehouseSelector <!-- <WarehouseSelector
v-model="warehouseSelectorVisible" v-model="warehouseSelectorVisible"
@selected="handleWarehouseSelected" @selected="handleWarehouseSelected"
/> /> -->
</div> </div>
</template> </template>
...@@ -594,7 +594,7 @@ ...@@ -594,7 +594,7 @@
import { listLocations, getLocations, delLocations, addLocations, updateLocations } from "@/api/inventory/locations" import { listLocations, getLocations, delLocations, addLocations, updateLocations } from "@/api/inventory/locations"
import { listWarehouses } from "@/api/inventory/warehouses" import { listWarehouses } from "@/api/inventory/warehouses"
import materialsSeletor from "../../../components/materialsSeletor.vue" import materialsSeletor from "../../../components/materialsSeletor.vue"
import WarehouseSelector from "@/views/compononents/WarehouseSelector.vue" // import WarehouseSelector from "@/views/compononents/WarehouseSelector.vue"
import ImportExcel from "@/components/ImportExcel/index" import ImportExcel from "@/components/ImportExcel/index"
import { listMaterials } from "@/api/inventory/materials" import { listMaterials } from "@/api/inventory/materials"
...@@ -670,9 +670,9 @@ export default { ...@@ -670,9 +670,9 @@ export default {
{ required: true, message: '库位名称不能为空', trigger: 'blur' }, { required: true, message: '库位名称不能为空', trigger: 'blur' },
{ min: 1, max: 100, message: '库位名称长度不能超过100个字符', trigger: 'blur' } { min: 1, max: 100, message: '库位名称长度不能超过100个字符', trigger: 'blur' }
], ],
warehouseId: [ // warehouseId: [
{ required: true, message: '仓库不能为空', trigger: 'change' } // { required: true, message: '仓库不能为空', trigger: 'change' }
], // ],
locationType: [ locationType: [
{ required: true, message: '库位类型不能为空', trigger: 'change' } { required: true, message: '库位类型不能为空', trigger: 'change' }
], ],
......
...@@ -49,15 +49,12 @@ ...@@ -49,15 +49,12 @@
<div style="height: 70vh; overflow: auto; padding: 0 10px;"> <div style="height: 70vh; overflow: auto; padding: 0 10px;">
<MaterialSelector <MaterialSelector
ref="materialsSeletor" ref="materialsSeletor"
@selection-change="handleMaterialSelectionChange" @selection-change="confirmMaterialSelect"
:selected-material-codes="form.materialUuids ? [form.materialUuids] : []" :selected-material-codes="form.materialUuids ? [form.materialUuids] : []"
:multiple="false" :multiple="false"
/> />
</div> </div>
<div slot="footer" class="dialog-footer">
<el-button @click.native="openMaterialSelector = false">取消</el-button>
<el-button type="primary" @click.native="confirmMaterialSelect">确认选择</el-button>
</div>
</el-dialog> </el-dialog>
<!-- 库存信息列表 --> <!-- 库存信息列表 -->
...@@ -335,7 +332,8 @@ export default { ...@@ -335,7 +332,8 @@ export default {
selectedMaterialId: '', selectedMaterialId: '',
selectedMaterialInfo: null, selectedMaterialInfo: null,
currentSelectedRowId: null, currentSelectedRowId: null,
isInitEcho: false isInitEcho: false,
openMaterialSelector: false, // 确保初始为关闭状态
}; };
}, },
computed: { computed: {
...@@ -798,53 +796,50 @@ handleSubmit() { ...@@ -798,53 +796,50 @@ handleSubmit() {
} }
}, },
// 修复:增强校验逻辑,增加组件存在性检查和异步同步 // 修复:增强校验逻辑,增加组件存在性检查和异步同步
confirmMaterialSelect() { confirmMaterialSelect() {
// 1. 检查选择器组件是否存在 // 标记为“用户主动操作”
if (!this.$refs.materialsSeletor) { this.isUserInitiatedSelect = true;
this.$message.error('物料选择器组件加载失败,请重试');
return;
}
// 2. 异步等待组件数据同步(避免取值过早) // 1. 检查选择器组件是否存在
this.$nextTick(() => { if (!this.$refs.materialsSeletor) {
// 3. 强制触发选中数据同步 this.$message.error('物料选择器组件加载失败,请重试');
const selector = this.$refs.materialsSeletor; return;
let selectedData = []; }
// 兼容组件的多种取值方式
if (selector.getSelectedMaterials) {
selectedData = selector.getSelectedMaterials();
} else if (selector.selectedList) {
selectedData = selector.selectedList;
} else if (selector.value) {
selectedData = selector.value;
}
// 触发数据同步(覆盖事件未触发的场景)
this.handleMaterialSelectionChange(selectedData);
// 4. 增强空值校验 // 2. 异步等待组件数据同步(避免取值过早)
if (!this.selectedMaterialInfo || !this.selectedMaterialId) { this.$nextTick(() => {
this.$message.warning('请选择物料后再确认'); // 3. 强制触发选中数据同步
return; const selector = this.$refs.materialsSeletor;
} let selectedData = [];
// 兼容组件的多种取值方式
if (selector.getSelectedMaterials) {
selectedData = selector.getSelectedMaterials();
} else if (selector.selectedList) {
selectedData = selector.selectedList;
} else if (selector.value) {
selectedData = selector.value;
}
// 触发数据同步(覆盖事件未触发的场景)
this.handleMaterialSelectionChange(selectedData);
// 5. 容错处理:确保物料ID有效
const materialId = this.selectedMaterialInfo.id || this.selectedMaterialInfo.materialId || this.selectedMaterialInfo.uuid || '';
if (!materialId) {
this.$message.error('选中的物料缺少有效ID,请重新选择');
return;
}
// 6. 赋值并关闭弹窗 // 5. 容错处理:确保物料ID有效
this.$set(this.form, 'materialId', materialId); const materialId = this.selectedMaterialInfo.id || this.selectedMaterialInfo.materialId || this.selectedMaterialInfo.uuid || '';
this.$set(this.form, 'materialUuids', materialId);
this.openMaterialSelector = false;
// 7. 查询库存并校验字段 // 6. 赋值并关闭弹窗
this.handleMaterialIdChange(); this.$set(this.form, 'materialId', materialId);
this.$nextTick(() => { this.$set(this.form, 'materialUuids', materialId);
this.$refs.detailForm?.validateField('materialId'); this.openMaterialSelector = false;
});
}); // 7. 查询库存并校验字段
this.handleMaterialIdChange();
this.$nextTick(() => {
this.$refs.detailForm?.validateField('materialId');
});
// 重置标记
this.isUserInitiatedSelect = false;
});
} }
}, },
beforeDestroy() { beforeDestroy() {
......
...@@ -13,7 +13,7 @@ spring: ...@@ -13,7 +13,7 @@ spring:
#username: root # 数据库用户名 #username: root # 数据库用户名
#password: 'Aa123456' #password: 'Aa123456'
#測試 #測試
url: jdbc:mysql://demo.docmis.cn:23500/inventory_manager?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&useSSL=false url: jdbc:mysql://demo.docmis.cn:23500/inventory_manager?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&useSSL=false&allowMultiQueries=true
username: root username: root
password: '!QAZ2wsx#EDC2022' password: '!QAZ2wsx#EDC2022'
# 从库数据源 # 从库数据源
......
...@@ -7,6 +7,6 @@ public class WarehouseConfig { ...@@ -7,6 +7,6 @@ public class WarehouseConfig {
/** /**
* 默认出库仓库ID(核心默认值) * 默认出库仓库ID(核心默认值)
*/ */
public static final String DEFAULT_WAREHOUSE_ID = "572ba484-199c-45d9-9735-610928ed5c70"; public static final String DEFAULT_WAREHOUSE_ID = "local";
} }
\ No newline at end of file
...@@ -117,7 +117,7 @@ public class OutboundOrderItems extends BaseEntity ...@@ -117,7 +117,7 @@ public class OutboundOrderItems extends BaseEntity
@Excel(name = "排序号") @Excel(name = "排序号")
private String updateUserCode; private String updateUserCode;
private String InventoryType; private int InventoryType;
} }
\ No newline at end of file
...@@ -74,5 +74,11 @@ public interface OutboundOrderItemsMapper ...@@ -74,5 +74,11 @@ public interface OutboundOrderItemsMapper
public int batchInsertOutboundOrderItems(List<OutboundOrderItems> inboundOrderItems); public int batchInsertOutboundOrderItems(List<OutboundOrderItems> inboundOrderItems);
public int batchUpdateOutboundOrderItems(List<OutboundOrderItems> inboundOrderItems);
int batchDeleteOutboundOrderItems(String[] ids);
public int deleteOutboundOrderItemsByOrderId(String orderId);
} }
...@@ -156,34 +156,46 @@ public class InventoryServiceImpl implements IInventoryService ...@@ -156,34 +156,46 @@ public class InventoryServiceImpl implements IInventoryService
} }
updateInventory(inventory); updateInventory(inventory);
// 库存操作表插入数据 createInventoryOutboundLog(inventory,outboundOrderItem,Long.valueOf(quantity),SystemUtils.getUserName(),new Date());
InventoryTransactions transactions = new InventoryTransactions();
transactions.setId(IdUtils.simpleUUID());
transactions.setTransactionType(2L);// 事务类型-出库
transactions.setBatchCode(outboundOrderItem.getBatchCode());
transactions.setUnitPrice(String.valueOf(outboundOrderItem.getUnitPrice()));
transactions.setInventoryId(inventory.getId()); // 库存表Id
transactions.setReferenceId(outboundOrderItem.getOutboundOrderId()); //关联单号,相当于主记录-盘点主表
transactions.setReferenceItemId(outboundOrderItem.getId()); // 盘点子表id
transactions.setMaterialId(outboundOrderItem.getMaterialId());
transactions.setWarehouseId(outboundOrderItem.getWarehouseId());
transactions.setLocationId(outboundOrderItem.getLocationId());
OutboundOrders outboundOrders = outboundOrderMapper.selectOutboundOrdersById(outboundOrderItem.getOutboundOrderId());
transactions.setOwnerId(outboundOrders.getOwnerId());
transactions.setQuantityBefore(Long.valueOf(quantity));// 变更前数量
transactions.setQuantityAfter(inventory.getQuantity());// 变更后数量
transactions.setQuantityChange(outboundOrderItem.getActualQuantity());
Date nowDate = new Date();
transactions.setTransactionTime(nowDate);
transactions.setOperatedBy(SystemUtils.getUserName());
insertInventoryTransactions.insertInventoryTransactions(transactions);
} }
RefreshInventory(inventoryIds); RefreshInventory(inventoryIds);
} }
return 1; return 1;
} }
private void createInventoryOutboundLog(Inventory inventory, OutboundOrderItems outboundOrderItem,
Long deductQty, String updateUser, Date updateTime) {
InventoryTransactions transactions = new InventoryTransactions();
transactions.setId(IdUtils.simpleUUID()); // 确保IdUtils工具类存在,若无则替换为UUID.randomUUID().toString()
transactions.setTransactionType(2L); // 事务类型-出库
transactions.setBatchCode(outboundOrderItem.getBatchCode());
transactions.setUnitPrice(String.valueOf(outboundOrderItem.getUnitPrice()));
transactions.setInventoryId(inventory.getId()); // 库存表Id
transactions.setReferenceId(outboundOrderItem.getOutboundOrderId()); // 关联出库单主表ID
transactions.setReferenceItemId(outboundOrderItem.getId()); // 关联出库单明细ID
transactions.setMaterialId(outboundOrderItem.getMaterialId());
transactions.setWarehouseId(outboundOrderItem.getWarehouseId());
transactions.setLocationId(outboundOrderItem.getLocationId());
// 补充货主ID(从出库单主表查询)
OutboundOrders outboundOrders = outboundOrderMapper.selectOutboundOrdersById(outboundOrderItem.getOutboundOrderId());
if (outboundOrders != null) {
transactions.setOwnerId(outboundOrders.getOwnerId());
}
// 变更前后数量
Long beforeQty = Optional.ofNullable(inventory.getQuantity()).orElse(0L) + deductQty; // 扣减前数量 = 扣减后 + 扣减量
transactions.setQuantityBefore(beforeQty);
transactions.setQuantityAfter(inventory.getQuantity()); // 扣减后数量
transactions.setQuantityChange(deductQty); // 变更量(出库为正数)
transactions.setTransactionTime(updateTime);
transactions.setOperatedBy(updateUser);
// 插入日志
insertInventoryTransactions.insertInventoryTransactions(transactions);
}
@SerialExecution(group = "inventoryRefresh", fair = true) @SerialExecution(group = "inventoryRefresh", fair = true)
@Override @Override
public boolean inventoryLockValidation(List<OutboundOrderItems> outboundOrderItems) public boolean inventoryLockValidation(List<OutboundOrderItems> outboundOrderItems)
......
...@@ -128,6 +128,7 @@ public class StorageLocationsServiceImpl implements IStorageLocationsService ...@@ -128,6 +128,7 @@ public class StorageLocationsServiceImpl implements IStorageLocationsService
storageLocations.setId(LocationsID); storageLocations.setId(LocationsID);
storageLocations.setCreateTime(DateUtils.getNowDate()); storageLocations.setCreateTime(DateUtils.getNowDate());
storageLocations.setCreateUserCode(String.valueOf(SecurityUtils.getUserId())); storageLocations.setCreateUserCode(String.valueOf(SecurityUtils.getUserId()));
storageLocations.setWarehousesId(WarehouseConfig.DEFAULT_WAREHOUSE_ID);
storageLocationsCategory.setLocationCode(LocationsID); storageLocationsCategory.setLocationCode(LocationsID);
......
...@@ -586,4 +586,17 @@ and inventory_status = '1' ...@@ -586,4 +586,17 @@ and inventory_status = '1'
group by m.id, m.material_name group by m.id, m.material_name
order by value desc, m.material_name asc order by value desc, m.material_name asc
</select> </select>
<update id="batchUpdateInventory">
<foreach collection="list" item="item" separator=";">
UPDATE inventory
<set>
quantity = #{item.quantity},
inventory_status = #{item.inventoryStatus},
update_user_code = #{item.updateBy},
update_time = #{item.updateTime}
</set>
WHERE id = #{item.id}
</foreach>
</update>
</mapper> </mapper>
\ No newline at end of file
...@@ -367,6 +367,9 @@ ...@@ -367,6 +367,9 @@
</foreach> </foreach>
</update> </update>
<delete id="deleteOutboundOrderItemsByOrderId" parameterType="String">
delete from outbound_order_items where outbound_order_id = #{orderId}
</delete>
<!-- 单条删除:逻辑删除 --> <!-- 单条删除:逻辑删除 -->
<update id="deleteOutboundOrderItemsById" parameterType="String"> <update id="deleteOutboundOrderItemsById" parameterType="String">
update outbound_order_items update outbound_order_items
...@@ -432,4 +435,39 @@ ...@@ -432,4 +435,39 @@
) )
</foreach> </foreach>
</insert> </insert>
<update id="batchUpdateOutboundOrderItems" parameterType="java.util.List">
<foreach collection="list" item="item" separator=";">
UPDATE outbound_order_items
SET
inventory_id = <if test="item.inventoryId != null">#{item.inventoryId}</if><if test="item.inventoryId == null">null</if>,
material_id = <if test="item.materialId != null">#{item.materialId}</if><if test="item.materialId == null">null</if>,
batch_code = <if test="item.batchCode != null">#{item.batchCode}</if><if test="item.batchCode == null">null</if>,
warehouse_id = <if test="item.warehouseId != null">#{item.warehouseId}</if><if test="item.warehouseId == null">null</if>,
location_id = <if test="item.locationId != null">#{item.locationId}</if><if test="item.locationId == null">null</if>,
unit_price = <if test="item.unitPrice != null">#{item.unitPrice}</if><if test="item.unitPrice == null">null</if>,
planned_quantity = <if test="item.plannedQuantity != null">#{item.plannedQuantity}</if><if test="item.plannedQuantity == null">null</if>,
actual_quantity = <if test="item.actualQuantity != null">#{item.actualQuantity}</if><if test="item.actualQuantity == null">null</if>,
divisor = <if test="item.divisor != null">#{item.divisor}</if><if test="item.divisor == null">null</if>,
label_color = <if test="item.labelColor != null">#{item.labelColor}</if><if test="item.labelColor == null">null</if>,
voucher_number = <if test="item.voucherNumber != null">#{item.voucherNumber}</if><if test="item.voucherNumber == null">null</if>,
item_status = <if test="item.itemStatus != null">#{item.itemStatus}</if><if test="item.itemStatus == null">null</if>,
shipped_at = <if test="item.shippedAt != null">#{item.shippedAt}</if><if test="item.shippedAt == null">null</if>,
shipped_by = <if test="item.shippedBy != null">#{item.shippedBy}</if><if test="item.shippedBy == null">null</if>,
remark = <if test="item.remark != null">#{item.remark}</if><if test="item.remark == null">null</if>,
is_used = <if test="item.isUsed != null">#{item.isUsed}</if><if test="item.isUsed == null">1</if>,
sort_no = <if test="item.sortNo != null">#{item.sortNo}</if><if test="item.sortNo == null">null</if>,
update_time = <if test="item.updateTime != null">#{item.updateTime}</if><if test="item.updateTime == null">NOW()</if>,
update_user_code = <if test="item.updateUserCode != null">#{item.updateUserCode}</if><if test="item.updateUserCode == null">null</if>
WHERE id = #{item.id}
</foreach>
</update>
<delete id="batchDeleteOutboundOrderItems">
DELETE FROM outbound_order_items
WHERE id IN
<foreach collection="array" item="id" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
</mapper> </mapper>
\ No newline at end of file
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论