Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
M
mini-wms
概览
Overview
Details
Activity
Cycle Analytics
版本库
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
问题
0
Issues
0
列表
Board
标记
里程碑
合并请求
0
Merge Requests
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
Snippets
成员
Members
Collapse sidebar
Close sidebar
活动
图像
聊天
创建新问题
作业
提交
Issue Boards
Open sidebar
周海峰
mini-wms
Commits
883b7c52
Commit
883b7c52
authored
Dec 09, 2025
by
chuishuo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
盘点功能。——完成。统计及详情功能。——完成。
parent
c30de553
全部展开
显示空白字符变更
内嵌
并排
正在显示
16 个修改的文件
包含
687 行增加
和
107 行删除
+687
-107
ruoyi-admin-vue/src/api/inventory/stocktakes.js
+23
-3
ruoyi-admin-vue/src/views/inventory/stocktakes/index.vue
+66
-28
ruoyi-admin-vue/src/views/inventory/stocktakes/stocktakeCountTable.vue
+0
-0
ruoyi-admin-vue/src/views/inventory/stocktakes/stocktakeItemsTable.vue
+144
-6
ruoyi-inventory/src/main/java/com/ruoyi/inventory/controller/StocktakesController.java
+33
-11
ruoyi-inventory/src/main/java/com/ruoyi/inventory/domain/StocktakeItems.java
+12
-0
ruoyi-inventory/src/main/java/com/ruoyi/inventory/domain/TO/StocktakesVo.java
+176
-0
ruoyi-inventory/src/main/java/com/ruoyi/inventory/mapper/StocktakeItemsMapper.java
+9
-0
ruoyi-inventory/src/main/java/com/ruoyi/inventory/mapper/StocktakesMapper.java
+11
-1
ruoyi-inventory/src/main/java/com/ruoyi/inventory/service/IStocktakeItemsService.java
+9
-0
ruoyi-inventory/src/main/java/com/ruoyi/inventory/service/IStocktakesService.java
+23
-2
ruoyi-inventory/src/main/java/com/ruoyi/inventory/service/impl/StocktakeItemsServiceImpl.java
+32
-0
ruoyi-inventory/src/main/java/com/ruoyi/inventory/service/impl/StocktakesServiceImpl.java
+46
-6
ruoyi-inventory/src/main/resources/mapper/inventory/InventoryMapper.xml
+2
-2
ruoyi-inventory/src/main/resources/mapper/inventory/StocktakeItemsMapper.xml
+67
-7
ruoyi-inventory/src/main/resources/mapper/inventory/StocktakesMapper.xml
+34
-41
没有找到文件。
ruoyi-admin-vue/src/api/inventory/stocktakes.js
View file @
883b7c52
...
...
@@ -8,12 +8,32 @@ export function listStocktakes(query) {
params
:
query
})
}
// 查询统计
export
function
listStocktakesCount
(
query
)
{
return
request
({
url
:
'/inventory/stocktakes/listCount'
,
method
:
'get'
,
params
:
query
})
}
// 统计详情
export
function
getCountInfo
(
query
)
{
return
request
({
url
:
'/inventory/stocktakes/countInfo'
,
method
:
'get'
,
params
:
query
})
}
// 查询盘点单主详细
export
function
getStocktakes
(
id
)
{
export
function
getStocktakes
(
id
,
operationType
)
{
return
request
({
url
:
'/inventory/stocktakes/'
+
id
,
method
:
'get'
url
:
'/inventory/stocktakes/'
,
method
:
'get'
,
params
:
{
id
:
id
,
operationType
:
operationType
}
})
}
...
...
ruoyi-admin-vue/src/views/inventory/stocktakes/index.vue
View file @
883b7c52
...
...
@@ -10,22 +10,21 @@
@
click=
"handleAdd"
v-hasPermi=
"['inventory:stocktakes:add']"
>
新增
</el-button>
<el-button
type=
"danger"
plain
icon=
"el-icon-delete"
size=
"medium"
:disabled=
"multiple"
@
click=
"handleDelete"
v-hasPermi=
"['inventory:stocktakes:remove']"
>
删除
</el-button
>
<!--
<el-button-->
<!-- type="danger"-->
<!-- plain-->
<!-- icon="el-icon-delete"-->
<!-- size="medium"-->
<!-- :disabled="multiple"-->
<!-- @click="handleDelete"-->
<!-- v-hasPermi="['inventory:stocktakes:remove']"-->
<!-- >删除
</el-button>
--
>
<el-button
type=
"success"
plain
icon=
"el-icon-tickets"
size=
"medium"
:disabled=
"single"
@
click=
"handleConfirm"
@
click=
"handleCount"
v-hasPermi=
"['inventory:stocktakes:count']"
>
处理结果统计
</el-button>
</
template
>
...
...
@@ -80,24 +79,26 @@
<!--
<
el
-
table
-
column
label
=
"排序号"
align
=
"center"
prop
=
"updateUserCode"
/>-->
<
el
-
table
-
column
label
=
"操作"
align
=
"center"
class
-
name
=
"small-padding fixed-width"
>
<
template
slot
-
scope
=
"scope"
>
<!--
<
el
-
button
-->
<!--
size
=
"mini"
-->
<!--
type
=
"text"
-->
<!--
icon
=
"el-icon-edit"
-->
<!--
@
click
=
"handleUpdate(scope.row)"
-->
<!--
v
-
hasPermi
=
"['inventory:stocktakes:edit']"
-->
<!--
>
修改
<
/el-button>--
>
<
el
-
button
size
=
"mini"
type
=
"text"
icon
=
"el-icon-view"
@
click
=
"handleViewInfo(scope.row)"
v
-
hasPermi
=
"['inventory:stocktakes:query']"
>
查看
<
/el-button
>
<
el
-
button
size
=
"mini"
type
=
"text"
icon
=
"el-icon-edit"
@
click
=
"handleCheck(scope.row)"
v
-
if
=
"scope.row.stocktakeStatus === '1'"
v
-
hasPermi
=
"['inventory:stocktakes:check']"
>
盘点
<
/el-button
>
<
el
-
button
size
=
"mini"
type
=
"text"
icon
=
"el-icon-delete"
v
-
if
=
"scope.row.stocktakeStatus === '1'"
@
click
=
"handleDelete(scope.row)"
v
-
hasPermi
=
"['inventory:stocktakes:remove']"
>
删除
<
/el-button
>
...
...
@@ -106,6 +107,7 @@
type
=
"text"
icon
=
"el-icon-circle-check"
@
click
=
"handleConfirm(scope.row)"
v
-
if
=
"scope.row.stocktakeStatus === '2'"
v
-
hasPermi
=
"['inventory:stocktakes:confirm']"
>
盘点确认
<
/el-button
>
<
/template
>
...
...
@@ -199,7 +201,20 @@
/>
<
/el-form
>
<
div
slot
=
"footer"
class
=
"dialog-footer"
>
<
el
-
button
type
=
"primary"
@
click
=
"submitConfirmForm"
>
确
定
<
/el-button
>
<
el
-
button
type
=
"primary"
v
-
if
=
"this.buttonShow"
@
click
=
"submitConfirmForm"
>
确
定
<
/el-button
>
<
el
-
button
@
click
=
"cancelConfirm"
>
取
消
<
/el-button
>
<
/div
>
<
/el-dialog
>
<!--
处理统计弹窗
-->
<
el
-
dialog
:
title
=
"confirmTitle"
:
visible
.
sync
=
"countOpen"
width
=
"1500px"
append
-
to
-
body
>
<
el
-
form
ref
=
"confirmFormRef"
:
model
=
"form"
:
rules
=
"rules"
label
-
width
=
"80px"
>
<!--
引入子表组件(核心:传递数据
+
监听事件)
-->
<
stocktake
-
count
-
table
/>
<
/el-form
>
<
div
slot
=
"footer"
class
=
"dialog-footer"
>
<
el
-
button
@
click
=
"cancelConfirm"
>
取
消
<
/el-button
>
<
/div
>
<
/el-dialog
>
...
...
@@ -208,14 +223,15 @@
<
script
>
import
{
listStocktakes
,
getStocktakes
,
delStocktakes
,
addStocktakes
,
updateStocktakes
}
from
"@/api/inventory/stocktakes"
// 引入子表组件
// 引入子表组件
--盘点
import
stocktakeItemsTable
from
'@/views/inventory/stocktakes/stocktakeItemsTable.vue'
;
// 引入子表组件--统计
import
stocktakeCountTable
from
'@/views/inventory/stocktakes/stocktakeCountTable.vue'
;
export
default
{
name
:
"Stocktakes"
,
dicts
:
[
'stocktake_status'
],
// 注册子组件
components
:
{
stocktakeItemsTable
}
,
components
:
{
stocktakeItemsTable
,
stocktakeCountTable
}
,
data
()
{
return
{
// 遮罩层
...
...
@@ -243,10 +259,12 @@ export default {
// 是否显示弹出层
open
:
false
,
checkOpen
:
false
,
confirmOpen
:
false
,
buttonShow
:
true
,
//是否展示确认按钮
checkOpen
:
false
,
// 盘点弹窗
confirmOpen
:
false
,
// 盘点确认弹窗
checkTitle
:
"库存盘点"
,
confirmTitle
:
"盘点确认"
,
countOpen
:
false
,
// 盘点统计弹窗
// 查询参数
queryParams
:
{
...
...
@@ -358,24 +376,44 @@ export default {
handleCheck
(
row
)
{
this
.
reset
();
const
id
=
row
.
id
||
this
.
ids
getStocktakes
(
id
).
then
(
response
=>
{
getStocktakes
(
id
,
'check'
).
then
(
response
=>
{
this
.
form
=
response
.
data
// 过滤 undefined 行,避免子组件渲染报错
this
.
stocktakeItemsList
=
(
response
.
data
.
stocktakeItemsList
||
[]).
filter
(
item
=>
item
);
this
.
checkOpen
=
true
}
)
}
,
// 盘点确认按钮:打开
确认
弹窗
// 盘点确认按钮:打开弹窗
handleConfirm
(
row
)
{
this
.
reset
();
const
id
=
row
.
id
||
this
.
ids
getStocktakes
(
id
).
then
(
response
=>
{
this
.
confirmTitle
=
'盘点确认'
getStocktakes
(
id
,
'confirm'
).
then
(
response
=>
{
this
.
form
=
response
.
data
// 过滤 undefined 行,避免子组件渲染报错
this
.
stocktakeItemsList
=
(
response
.
data
.
stocktakeItemsList
||
[]).
filter
(
item
=>
item
);
this
.
confirmOpen
=
true
;
}
)
}
,
// 详情按钮:打开弹窗
handleViewInfo
(
row
)
{
this
.
reset
();
const
id
=
row
.
id
||
this
.
ids
this
.
buttonShow
=
false
this
.
confirmTitle
=
'盘点查看'
getStocktakes
(
id
,
'check'
).
then
(
response
=>
{
this
.
form
=
response
.
data
// 过滤 undefined 行,避免子组件渲染报错
this
.
stocktakeItemsList
=
(
response
.
data
.
stocktakeItemsList
||
[]).
filter
(
item
=>
item
);
this
.
confirmOpen
=
true
;
}
)
}
,
/** 处理结果统计按钮操作 */
handleCount
()
{
this
.
reset
()
this
.
countOpen
=
true
this
.
confirmTitle
=
" 处理结果统计"
}
,
/** 子组件字段编辑事件(确保父组件数据同步) */
handleStocktakeItemChange
(
updatedRow
)
{
// 找到更新的行,替换数据(确保引用一致)
...
...
@@ -441,7 +479,7 @@ export default {
// 取消操作
cancelCheck
()
{
this
.
checkOpen
=
false
;
this
.
reset
();
}
,
cancelConfirm
()
{
this
.
confirmOpen
=
false
;
this
.
reset
();
}
,
cancelConfirm
()
{
this
.
confirmOpen
=
false
;
this
.
countOpen
=
false
;
this
.
reset
();
}
,
/** 新增提交按钮 */
submitForm
()
{
...
...
ruoyi-admin-vue/src/views/inventory/stocktakes/stocktakeCountTable.vue
0 → 100644
View file @
883b7c52
差异被折叠。
点击展开。
ruoyi-admin-vue/src/views/inventory/stocktakes/stocktakeItemsTable.vue
View file @
883b7c52
...
...
@@ -21,18 +21,52 @@
/>
</el-form-item>
<el-form-item
label=
"仓库"
prop=
"warehouseId"
>
<el-input
v-model=
"queryWarehouseName"
placeholder=
"请选择仓库"
readonly
@
focus=
"openWarehouseSelector"
:suffix-icon=
"''"
>
<template
v-if=
"queryWarehouseName"
#
suffix
>
<i
class=
"el-icon-circle-close el-input__icon"
style=
"cursor: pointer;"
@
click
.
stop=
"clearQueryWarehouse"
></i>
</
template
>
</el-input>
</el-form-item>
<el-form-item
label=
"库位"
prop=
"locationId"
>
<el-input
v-model=
"queryLocationName"
placeholder=
"请选择库位"
readonly
@
focus=
"openLocationSelector"
:suffix-icon=
"''"
:disabled=
"!searchParams.warehousesCode"
>
<
template
v-if=
"queryLocationName"
#
suffix
>
<i
class=
"el-icon-circle-close el-input__icon"
style=
"cursor: pointer;"
@
click
.
stop=
"clearQueryLocation"
></i>
</
template
>
</el-input>
</el-form-item>
<el-form-item
label=
"仓库"
prop=
"warehouseId"
style=
"display: none;"
>
<common-dict-select
v-model=
"searchParams.warehouseId"
dict-url=
"/inventory/warehouses/getMapList"
value-key=
"warehouses_code"
label-key=
"warehouses_name"
placeholder=
"请选择仓库"
@
change=
"handleWarehouseChange"
@
clear=
"handleWarehouseClear"
@
loaded=
"handleDictLoaded('warehouse', $event)"
/>
</el-form-item>
<el-form-item
label=
"库位"
prop=
"locationId"
>
<el-form-item
label=
"库位"
prop=
"locationId"
style=
"display: none;"
>
<common-dict-select
ref=
"locationSelect"
v-model=
"searchParams.locationId"
...
...
@@ -41,13 +75,23 @@
value-key=
"location_code"
label-key=
"location_name"
placeholder=
"请选择库位"
:disabled="!searchParams.warehouseId"
@change="handleQuery"
@
loaded=
"handleDictLoaded('location', $event)"
/>
</el-form-item>
</page-wrapper-search>
<!-- 仓库选择组件 -->
<WarehouseSelector
v-model=
"warehouseSelectorVisible"
@
selected=
"handleWarehouseSelected"
/>
<!-- 库位选择组件 -->
<LocationSelector
v-model=
"locationSelectorVisible"
:warehousesId=
"currentWarehouseId"
@
selected=
"handleLocationSelected"
/>
<div
class=
"table-container"
>
<el-table
:data=
"filteredItemsList"
:row-class-name=
"setRowIndex"
...
...
@@ -103,6 +147,22 @@
<el-input
type=
"number"
v-model=
"scope.row.varianceQuantity"
placeholder=
"请输入差异数量"
disabled
/>
</
template
>
</el-table-column>
<el-table-column
label=
"单价"
prop=
"unitPrice"
>
<
template
slot-scope=
"scope"
>
<!--
<el-input
v-model=
"scope.row.unitPrice"
placeholder=
"请输入单价"
disabled
/>
-->
<div
class=
"el-input__inner disabled-input"
style=
"padding: 0 15px; height: 32px; line-height: 32px;"
>
{{
formatAmount
(
scope
.
row
.
unitPrice
)
}}
</div>
</
template
>
</el-table-column>
<el-table-column
label=
"差异金额"
prop=
"varianceQuantity"
>
<
template
slot-scope=
"scope"
>
<!--
<el-input
v-model=
"scope.row.varianceAmount"
placeholder=
"请输入差异金额"
disabled
/>
-->
<div
class=
"el-input__inner disabled-input"
style=
"padding: 0 15px; height: 32px; line-height: 32px;"
>
{{
formatAmount
(
scope
.
row
.
varianceQuantity
)
}}
</div>
</
template
>
</el-table-column>
<el-table-column
label=
"是否已调整"
prop=
"adjusted"
v-if=
"isConfirm"
>
<
template
slot-scope=
"scope"
>
<el-input
v-model=
"scope.row.adjusted"
placeholder=
"请输入是否已调整0否1是"
disabled
/>
...
...
@@ -146,9 +206,12 @@
<
script
>
import
{
getDictLabel
}
from
'@/utils/dictUtil'
import
CommonDictSelect
from
'@/components/CommonDictSelect.vue'
import
WarehouseSelector
from
"@/views/compononents/WarehouseSelector.vue"
import
LocationSelector
from
"@/views/compononents/LocationSelector.vue"
export
default
{
name
:
"stocktakeItemsTable"
,
components
:
{
CommonDictSelect
},
// 注册通用字典组件
components
:
{
CommonDictSelect
,
WarehouseSelector
,
LocationSelector
},
// 注册通用字典组件
props
:
{
// 接收父组件传递的子表原始数据(双向绑定)
itemsList
:
{
...
...
@@ -168,8 +231,16 @@ export default {
materialId
:
""
,
batchCode
:
""
,
warehouseId
:
""
,
warehousesCode
:
null
,
locationId
:
""
},
// 仓库选择相关
warehouseSelectorVisible
:
false
,
queryWarehouseName
:
null
,
// 库位选择相关
locationSelectorVisible
:
false
,
queryLocationName
:
null
,
currentWarehouseId
:
""
,
// 存仓库原始ID(0eb22b11...),供库位联动
checkedRows
:
[],
// 子表选中的行
materialDict
:
[],
// 物料字典数组(存储sap_no和name)
warehouseDict
:
[],
// 仓库数组
...
...
@@ -180,6 +251,7 @@ export default {
tableLoading
:
false
}
},
computed
:
{
// 筛选+分页后的表格数据
filteredItemsList
()
{
...
...
@@ -228,18 +300,82 @@ export default {
this
.
searchParams
.
warehouseId
=
warehouseId
this
.
handleQuery
()
},
/** 打开仓库选择器 */
openWarehouseSelector
()
{
this
.
warehouseSelectorVisible
=
true
},
// 仓库清空时触发
handleWarehouseClear
()
{
this
.
searchParams
.
locationId
=
''
this
.
searchParams
.
warehouseId
=
''
this
.
currentWarehouseId
=
''
this
.
handleQuery
()
},
/** 库位选择回调 */
handleLocationSelected
(
location
)
{
if
(
!
location
)
return
this
.
searchParams
.
locationId
=
location
.
locationCode
this
.
queryLocationName
=
location
.
locationName
||
location
.
locationCode
// console.log('selected LocationName', location);
this
.
handleQuery
()
},
/** 仓库选择回调 */
handleWarehouseSelected
(
warehouse
)
{
if
(
!
warehouse
)
return
// 供库位联动:存仓库原始ID(0eb22b11...)
this
.
currentWarehouseId
=
warehouse
.
warehouseId
// 供列表筛选:存仓库编码333(匹配列表里的warehouseId:333
this
.
searchParams
.
warehouseId
=
warehouse
.
warehousesCode
this
.
searchParams
.
warehousesCode
=
warehouse
.
warehousesCode
this
.
queryWarehouseName
=
warehouse
.
warehousesName
||
warehouse
.
warehousesCode
// 仓库选择后,清空库位信息
this
.
queryLocationName
=
null
this
.
searchParams
.
locationId
=
null
this
.
handleQuery
()
// console.log('selected warehouse', warehouse);
},
/** 格式化金额,保留2位小数 */
formatAmount
(
amount
)
{
if
(
amount
===
null
||
amount
===
undefined
||
isNaN
(
amount
))
{
return
'0.00'
}
return
parseFloat
(
amount
).
toFixed
(
2
)
},
// 搜索,补全逻辑(无后端请求,仅重置页码)
handleQuery
()
{
this
.
searchParams
.
pageNum
=
1
;
// 搜索后重置页码
},
/** 清空仓库选择 */
clearQueryWarehouse
()
{
this
.
queryWarehouseName
=
null
this
.
searchParams
.
warehouseId
=
null
this
.
searchParams
.
warehousesCode
=
null
this
.
currentWarehouseId
=
""
// 清空仓库时,同时清空库位
this
.
queryLocationName
=
null
this
.
searchParams
.
locationId
=
null
this
.
handleQuery
()
},
/** 打开库位选择器 */
openLocationSelector
()
{
// console.log('this.currentWarehouseId========',this.currentWarehouseId)
if
(
!
this
.
currentWarehouseId
)
{
this
.
$message
.
warning
(
"请先选择仓库"
)
return
}
this
.
locationSelectorVisible
=
true
},
/** 清空库位选择 */
clearQueryLocation
()
{
this
.
queryLocationName
=
null
this
.
searchParams
.
locationId
=
null
this
.
handleQuery
()
},
// 重置
resetQuery
()
{
this
.
queryWarehouseName
=
null
this
.
queryLocationName
=
null
this
.
currentWarehouseId
=
''
this
.
searchParams
=
{
pageNum
:
1
,
pageSize
:
10
,
...
...
@@ -317,6 +453,8 @@ export default {
const
systemQty
=
Number
(
row
.
systemQuantity
)
||
0
// 计算差异:实际数量 - 系统数量
row
.
varianceQuantity
=
actualQty
-
systemQty
// 计算差异金额:差异数量*单价
row
.
varianceAmount
=
row
.
varianceQuantity
*
row
.
unitPrice
}
// 实时校验调整原因,触发样式更新
this
.
$nextTick
(()
=>
{
...
...
ruoyi-inventory/src/main/java/com/ruoyi/inventory/controller/StocktakesController.java
View file @
883b7c52
...
...
@@ -4,16 +4,10 @@ import java.util.List;
import
javax.servlet.http.HttpServletResponse
;
import
com.ruoyi.inventory.domain.TO.StocktakesTO
;
import
com.ruoyi.inventory.domain.TO.StocktakesVo
;
import
org.springframework.security.access.prepost.PreAuthorize
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.PutMapping
;
import
org.springframework.web.bind.annotation.DeleteMapping
;
import
org.springframework.web.bind.annotation.PathVariable
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
import
org.springframework.web.bind.annotation.*
;
import
com.ruoyi.common.annotation.Log
;
import
com.ruoyi.common.core.controller.BaseController
;
import
com.ruoyi.common.core.domain.AjaxResult
;
...
...
@@ -65,10 +59,11 @@ public class StocktakesController extends BaseController
* 获取库存盘点详细信息
*/
@PreAuthorize
(
"@ss.hasPermi('inventory:stocktakes:query')"
)
@GetMapping
(
value
=
"/{id}"
)
public
AjaxResult
getInfo
(
@PathVariable
(
"id"
)
String
id
)
@GetMapping
(
value
=
"/"
)
public
AjaxResult
getInfo
(
@RequestParam
(
"id"
)
String
id
,
@RequestParam
(
required
=
false
)
String
operationType
)
{
return
success
(
stocktakesService
.
selectStocktakesById
(
id
));
return
success
(
stocktakesService
.
selectStocktakesById
(
id
,
operationType
));
}
/**
...
...
@@ -103,4 +98,31 @@ public class StocktakesController extends BaseController
{
return
toAjax
(
stocktakesService
.
deleteStocktakesByIds
(
ids
));
}
/**
* @description: 查询处理统计
* @author cs
* @date 2025/12/8
* @version 1.0
*/
@GetMapping
(
"/listCount"
)
public
TableDataInfo
listCount
(
StocktakesVo
stocktakes
)
{
startPage
();
List
<
StocktakesVo
>
list
=
stocktakesService
.
selectStocktakesListCount
(
stocktakes
);
return
getDataTable
(
list
);
}
/**
* @description: 查询处理统计-详情
* @author cs
* @date 2025/12/9
* @version 1.0
*/
@GetMapping
(
"/countInfo"
)
public
TableDataInfo
countInfo
(
StocktakesVo
stocktakes
)
{
startPage
();
List
<
StocktakesVo
>
list
=
stocktakesService
.
selectStocktakesCountInfo
(
stocktakes
);
return
getDataTable
(
list
);
}
}
ruoyi-inventory/src/main/java/com/ruoyi/inventory/domain/StocktakeItems.java
View file @
883b7c52
...
...
@@ -124,6 +124,18 @@ public class StocktakeItems extends BaseEntity
@Excel
(
name
=
"排序号"
)
private
String
updateUserCode
;
/** 单价 */
@Excel
(
name
=
"单价"
)
private
double
unitPrice
;
public
double
getUnitPrice
()
{
return
unitPrice
;
}
public
void
setUnitPrice
(
double
unitPrice
)
{
this
.
unitPrice
=
unitPrice
;
}
public
String
getInventoryId
()
{
return
inventoryId
;
}
...
...
ruoyi-inventory/src/main/java/com/ruoyi/inventory/domain/TO/StocktakesVo.java
0 → 100644
View file @
883b7c52
package
com
.
ruoyi
.
inventory
.
domain
.
TO
;
import
com.ruoyi.inventory.domain.Stocktakes
;
import
java.util.Date
;
/**
* 库存盘点对象 stocktakes
*
* @author ruoyi
* @date 2025-12-02
*/
public
class
StocktakesVo
extends
Stocktakes
{
/** 提交按钮类型,check是盘点,confirm 是确认盘点 */
private
String
sapNo
;
private
String
plannedDates
;
private
String
materialId
;
private
String
warehousesName
;
private
String
locationName
;
private
String
warehousesId
;
private
String
locationId
;
private
String
tsCode
;
private
String
hazardName
;
private
String
varianceQuantity
;
private
String
varianceAmount
;
private
String
countQuantity
;
private
String
countAmount
;
// 计划日期数组(接收拆分后的值)
private
String
[]
plannedDateArray
;
// 仓库ID数组
private
String
[]
warehouseIdArray
;
// 库位ID数组
private
String
[]
locationIdArray
;
public
String
[]
getPlannedDateArray
()
{
return
plannedDateArray
;
}
public
void
setPlannedDateArray
(
String
[]
plannedDateArray
)
{
this
.
plannedDateArray
=
plannedDateArray
;
}
public
String
[]
getWarehouseIdArray
()
{
return
warehouseIdArray
;
}
public
void
setWarehouseIdArray
(
String
[]
warehouseIdArray
)
{
this
.
warehouseIdArray
=
warehouseIdArray
;
}
public
String
[]
getLocationIdArray
()
{
return
locationIdArray
;
}
public
void
setLocationIdArray
(
String
[]
locationIdArray
)
{
this
.
locationIdArray
=
locationIdArray
;
}
public
String
getMaterialId
()
{
return
materialId
;
}
public
String
getPlannedDates
()
{
return
plannedDates
;
}
public
void
setPlannedDates
(
String
plannedDates
)
{
this
.
plannedDates
=
plannedDates
;
}
public
String
getLocationId
()
{
return
locationId
;
}
public
void
setLocationId
(
String
locationId
)
{
this
.
locationId
=
locationId
;
}
public
void
setMaterialId
(
String
materialId
)
{
this
.
materialId
=
materialId
;
}
public
String
getSapNo
()
{
return
sapNo
;
}
public
void
setSapNo
(
String
sapNo
)
{
this
.
sapNo
=
sapNo
;
}
public
String
getWarehousesName
()
{
return
warehousesName
;
}
public
void
setWarehousesName
(
String
warehousesName
)
{
this
.
warehousesName
=
warehousesName
;
}
public
String
getLocationName
()
{
return
locationName
;
}
public
void
setLocationName
(
String
locationName
)
{
this
.
locationName
=
locationName
;
}
public
String
getWarehousesId
()
{
return
warehousesId
;
}
public
void
setWarehousesId
(
String
warehousesId
)
{
this
.
warehousesId
=
warehousesId
;
}
public
String
getTsCode
()
{
return
tsCode
;
}
public
void
setTsCode
(
String
tsCode
)
{
this
.
tsCode
=
tsCode
;
}
public
String
getHazardName
()
{
return
hazardName
;
}
public
void
setHazardName
(
String
hazardName
)
{
this
.
hazardName
=
hazardName
;
}
public
String
getVarianceQuantity
()
{
return
varianceQuantity
;
}
public
void
setVarianceQuantity
(
String
varianceQuantity
)
{
this
.
varianceQuantity
=
varianceQuantity
;
}
public
String
getVarianceAmount
()
{
return
varianceAmount
;
}
public
void
setVarianceAmount
(
String
varianceAmount
)
{
this
.
varianceAmount
=
varianceAmount
;
}
public
String
getCountQuantity
()
{
return
countQuantity
;
}
public
void
setCountQuantity
(
String
countQuantity
)
{
this
.
countQuantity
=
countQuantity
;
}
public
String
getCountAmount
()
{
return
countAmount
;
}
public
void
setCountAmount
(
String
countAmount
)
{
this
.
countAmount
=
countAmount
;
}
}
ruoyi-inventory/src/main/java/com/ruoyi/inventory/mapper/StocktakeItemsMapper.java
View file @
883b7c52
package
com
.
ruoyi
.
inventory
.
mapper
;
import
java.util.List
;
import
java.util.Map
;
import
com.ruoyi.inventory.domain.StocktakeItems
;
import
com.ruoyi.inventory.domain.TO.StocktakesVo
;
/**
* 盘点单明细Mapper接口
...
...
@@ -58,4 +61,10 @@ public interface StocktakeItemsMapper
* @return 结果
*/
public
int
deleteStocktakeItemsByIds
(
String
[]
ids
);
// 主表调用获取子表信息
public
List
<
StocktakeItems
>
selectStocktakeItemsByMain
(
Map
<
String
,
Object
>
query
);
// 查询处理统计-详情
public
List
<
StocktakesVo
>
selectStocktakesCountInfo
(
StocktakesVo
stocktakes
);
}
ruoyi-inventory/src/main/java/com/ruoyi/inventory/mapper/StocktakesMapper.java
View file @
883b7c52
package
com
.
ruoyi
.
inventory
.
mapper
;
import
java.util.List
;
import
java.util.Map
;
import
com.ruoyi.inventory.domain.Stocktakes
;
import
com.ruoyi.inventory.domain.StocktakeItems
;
import
com.ruoyi.inventory.domain.TO.StocktakesVo
;
/**
* 盘点单主Mapper接口
...
...
@@ -15,7 +18,6 @@ public interface StocktakesMapper
/**
* 查询盘点单主
*
* @param id 盘点单主主键
* @return 盘点单主
*/
public
Stocktakes
selectStocktakesById
(
String
id
);
...
...
@@ -84,4 +86,12 @@ public interface StocktakesMapper
* @return 结果
*/
public
int
deleteStocktakeItemsByStocktakeId
(
String
id
);
/**
* @description: 查询处理统计
* @author cs
* @date 2025/12/8
* @version 1.0
*/
public
List
<
StocktakesVo
>
selectStocktakesListCount
(
StocktakesVo
stocktakes
);
}
ruoyi-inventory/src/main/java/com/ruoyi/inventory/service/IStocktakeItemsService.java
View file @
883b7c52
package
com
.
ruoyi
.
inventory
.
service
;
import
java.util.List
;
import
java.util.Map
;
import
com.ruoyi.inventory.domain.StocktakeItems
;
import
com.ruoyi.inventory.domain.TO.StocktakesVo
;
/**
* 盘点单明细Service接口
...
...
@@ -19,6 +22,9 @@ public interface IStocktakeItemsService
*/
public
StocktakeItems
selectStocktakeItemsById
(
String
id
);
// 主表调用
public
List
<
StocktakeItems
>
selectStocktakeItemsByMain
(
Map
<
String
,
Object
>
query
);
/**
* 查询盘点单明细列表
*
...
...
@@ -58,4 +64,7 @@ public interface IStocktakeItemsService
* @return 结果
*/
public
int
deleteStocktakeItemsById
(
String
id
);
// 查询处理统计-详情
public
List
<
StocktakesVo
>
selectStocktakesCountInfo
(
StocktakesVo
stocktakes
);
}
ruoyi-inventory/src/main/java/com/ruoyi/inventory/service/IStocktakesService.java
View file @
883b7c52
package
com
.
ruoyi
.
inventory
.
service
;
import
java.util.List
;
import
com.ruoyi.common.core.page.TableDataInfo
;
import
com.ruoyi.inventory.domain.Stocktakes
;
import
com.ruoyi.inventory.domain.TO.StocktakesTO
;
import
com.ruoyi.inventory.domain.TO.StocktakesVo
;
import
org.springframework.web.bind.annotation.GetMapping
;
/**
* 库存盘点Service接口
...
...
@@ -15,10 +19,9 @@ public interface IStocktakesService
/**
* 查询库存盘点
*
* @param id 库存盘点主键
* @return 库存盘点
*/
public
Stocktakes
selectStocktakesById
(
String
id
);
public
Stocktakes
selectStocktakesById
(
String
id
,
String
operationType
);
/**
* 查询库存盘点列表
...
...
@@ -59,4 +62,22 @@ public interface IStocktakesService
* @return 结果
*/
public
int
deleteStocktakesById
(
String
id
);
/**
* @description: 查询处理统计
* @author cs
* @date 2025/12/8
* @version 1.0
*/
public
List
<
StocktakesVo
>
selectStocktakesListCount
(
StocktakesVo
stocktakes
);
/**
* @description: 查询处理统计-详情
* @author cs
* @date 2025/12/9
* @version 1.0
*/
public
List
<
StocktakesVo
>
selectStocktakesCountInfo
(
StocktakesVo
stocktakes
);
}
ruoyi-inventory/src/main/java/com/ruoyi/inventory/service/impl/StocktakeItemsServiceImpl.java
View file @
883b7c52
package
com
.
ruoyi
.
inventory
.
service
.
impl
;
import
java.util.List
;
import
java.util.Map
;
import
com.ruoyi.common.utils.DateUtils
;
import
com.ruoyi.inventory.domain.TO.StocktakesVo
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
com.ruoyi.inventory.mapper.StocktakeItemsMapper
;
...
...
@@ -33,6 +36,15 @@ public class StocktakeItemsServiceImpl implements IStocktakeItemsService
}
/**
* @description: 主表调用获取子表信息
* @author cs
* @date 2025/12/5
* @version 1.0
*/
public
List
<
StocktakeItems
>
selectStocktakeItemsByMain
(
Map
<
String
,
Object
>
query
){
return
stocktakeItemsMapper
.
selectStocktakeItemsByMain
(
query
);
}
/**
* 查询盘点单明细列表
*
* @param stocktakeItems 盘点单明细
...
...
@@ -93,4 +105,24 @@ public class StocktakeItemsServiceImpl implements IStocktakeItemsService
{
return
stocktakeItemsMapper
.
deleteStocktakeItemsById
(
id
);
}
// 查询处理统计-详情
@Override
public
List
<
StocktakesVo
>
selectStocktakesCountInfo
(
StocktakesVo
stocktakes
){
String
plannedDates
=
stocktakes
.
getPlannedDates
();
String
warehousesId
=
stocktakes
.
getWarehousesId
();
String
locationId
=
stocktakes
.
getLocationId
();
if
(
plannedDates
!=
null
&&
!
plannedDates
.
isEmpty
())
{
stocktakes
.
setPlannedDateArray
(
plannedDates
.
split
(
","
));
}
// 2. 拆分仓库ID
if
(
warehousesId
!=
null
&&
!
warehousesId
.
isEmpty
())
{
stocktakes
.
setWarehouseIdArray
(
warehousesId
.
split
(
","
));
}
// 3. 拆分库位ID
if
(
locationId
!=
null
&&
!
locationId
.
isEmpty
())
{
stocktakes
.
setLocationIdArray
(
locationId
.
split
(
","
));
}
return
stocktakeItemsMapper
.
selectStocktakesCountInfo
(
stocktakes
);
}
}
ruoyi-inventory/src/main/java/com/ruoyi/inventory/service/impl/StocktakesServiceImpl.java
View file @
883b7c52
package
com
.
ruoyi
.
inventory
.
service
.
impl
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.*
;
import
com.ruoyi.common.core.domain.model.LoginUser
;
import
com.ruoyi.common.core.page.TableDataInfo
;
import
com.ruoyi.common.utils.DateUtils
;
import
com.ruoyi.common.utils.SecurityUtils
;
import
com.ruoyi.common.utils.uuid.IdUtils
;
import
com.ruoyi.inventory.domain.Inventory
;
import
com.ruoyi.inventory.domain.InventoryTransactions
;
import
com.ruoyi.inventory.domain.TO.StocktakesTO
;
import
com.ruoyi.inventory.domain.TO.StocktakesVo
;
import
com.ruoyi.inventory.mapper.StocktakeItemsMapper
;
import
com.ruoyi.inventory.service.IInventoryService
;
import
com.ruoyi.inventory.service.IInventoryTransactionsService
;
import
com.ruoyi.inventory.service.IStocktakeItemsService
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
java.util.ArrayList
;
import
com.ruoyi.common.utils.StringUtils
;
import
org.springframework.transaction.annotation.Transactional
;
import
com.ruoyi.inventory.domain.StocktakeItems
;
import
com.ruoyi.inventory.mapper.StocktakesMapper
;
import
com.ruoyi.inventory.domain.Stocktakes
;
import
com.ruoyi.inventory.service.IStocktakesService
;
import
org.springframework.web.bind.annotation.GetMapping
;
/**
* 盘点单主Service业务层处理
...
...
@@ -51,9 +53,21 @@ public class StocktakesServiceImpl implements IStocktakesService
* @return 盘点单主
*/
@Override
public
Stocktakes
selectStocktakesById
(
String
id
)
public
Stocktakes
selectStocktakesById
(
String
id
,
String
operationType
)
{
return
stocktakesMapper
.
selectStocktakesById
(
id
);
// 获取主表信息
Stocktakes
stocktakes
=
stocktakesMapper
.
selectStocktakesById
(
id
);
// 获取子表信息
Map
<
String
,
Object
>
query
=
new
HashMap
<>();
query
.
put
(
"stocktake_id"
,
id
);
if
(
"confirm"
.
equals
(
operationType
)){
// 盘点确认时只查看 变更的
query
.
put
(
"adjusted"
,
1
);
}
List
<
StocktakeItems
>
stocktakeItems
=
stocktakeItemsService
.
selectStocktakeItemsByMain
(
query
);
stocktakes
.
setStocktakeItemsList
(
stocktakeItems
);
return
stocktakes
;
}
/**
...
...
@@ -156,9 +170,10 @@ public class StocktakesServiceImpl implements IStocktakesService
Long
actualQuantity
=
stocktakeItems
.
getActualQuantity
();
// 库存表id
String
inventoryId
=
stocktakeItems
.
getInventoryId
();
// 变更前数量 之所以不用库存表中的数量,是因为变更是从盘点计划时开始算的
Long
quantity
=
stocktakeItems
.
getSystemQuantity
();
// 获取库存信息
Inventory
inv
=
inventoryService
.
selectInventoryById
(
inventoryId
);
Long
quantity
=
inv
.
getQuantity
();
// 变更前数量
inv
.
setUpdateTime
(
nowDate
);
//更新时间
inv
.
setUpdateUserCode
(
loginUserId
);
//更新人
inv
.
setQuantity
(
actualQuantity
);
// 更新实际数量
...
...
@@ -260,4 +275,29 @@ public class StocktakesServiceImpl implements IStocktakesService
}
}
}
/**
* @description: 查询处理统计
* @author cs
* @date 2025/12/8
* @version 1.0
*/
@Override
public
List
<
StocktakesVo
>
selectStocktakesListCount
(
StocktakesVo
stocktakes
)
{
List
<
StocktakesVo
>
list
=
stocktakesMapper
.
selectStocktakesListCount
(
stocktakes
);
return
list
;
}
/**
* @description: 查询处理统计-详情
* @author cs
* @date 2025/12/9
* @version 1.0
*/
@Override
public
List
<
StocktakesVo
>
selectStocktakesCountInfo
(
StocktakesVo
stocktakes
)
{
List
<
StocktakesVo
>
list
=
stocktakeItemsService
.
selectStocktakesCountInfo
(
stocktakes
);
return
list
;
}
}
ruoyi-inventory/src/main/resources/mapper/inventory/InventoryMapper.xml
View file @
883b7c52
...
...
@@ -52,7 +52,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result
property=
"adjustedAt"
column=
"adjusted_at"
/>
<result
property=
"startTime"
column=
"start_time"
/>
<result
property=
"endTime"
column=
"end_time"
/>
<result
property=
"inventoryId"
column=
"inventory_id"
/>
</resultMap>
<resultMap
type=
"com.ruoyi.inventory.domain.vo.InventorySummaryVO"
id=
"InventorySummaryResult"
>
...
...
@@ -189,7 +189,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</select>
<select
id=
"selectstocktakeItemsList"
resultMap=
"StocktakeItemsResult"
>
select material_id, batch_id, location_id, warehouse_id, quantity as system_quantity
select
id as inventory_id,
material_id, batch_id, location_id, warehouse_id, quantity as system_quantity
from inventory
where is_used = 1 and inventory_status = 1
order by warehouse_id,location_id,material_id
...
...
ruoyi-inventory/src/main/resources/mapper/inventory/StocktakeItemsMapper.xml
View file @
883b7c52
...
...
@@ -34,10 +34,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result
property=
"updateTime"
column=
"update_time"
/>
<result
property=
"updateUserCode"
column=
"update_user_code"
/>
<result
property=
"inventoryId"
column=
"inventory_id"
/>
<result
property=
"unitPrice"
column=
"unit_price"
/>
</resultMap>
<sql
id=
"selectStocktakeItemsVo"
>
select id, inventory_id, stocktake_id, material_id, batch_code, warehouse_id, location_id, system_quantity, actual_quantity, variance_quantity, variance_amount, stocktake_status, counted_by, counted_at, adjusted, adjustment_reason, adjusted_by, adjusted_at, start_time, end_time, material_range, location_range, remark, is_used, sort_no, create_time, create_user_code, update_time, update_user_code from stocktake_items
select id, inventory_id,
unit_price,
stocktake_id, material_id, batch_code, warehouse_id, location_id, system_quantity, actual_quantity, variance_quantity, variance_amount, stocktake_status, counted_by, counted_at, adjusted, adjustment_reason, adjusted_by, adjusted_at, start_time, end_time, material_range, location_range, remark, is_used, sort_no, create_time, create_user_code, update_time, update_user_code from stocktake_items
</sql>
<select
id=
"selectStocktakeItemsList"
parameterType=
"StocktakeItems"
resultMap=
"StocktakeItemsResult"
>
...
...
@@ -67,6 +68,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if
test=
"sortNo != null "
>
and sort_no = #{sortNo}
</if>
<if
test=
"createUserCode != null and createUserCode != ''"
>
and create_user_code = #{createUserCode}
</if>
<if
test=
"updateUserCode != null and updateUserCode != ''"
>
and update_user_code = #{updateUserCode}
</if>
<if
test=
"unitPrice != null and unitPrice != ''"
>
and unit_price = #{unitPrice}
</if>
</where>
</select>
...
...
@@ -75,6 +77,56 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
where id = #{id}
</select>
<select
id=
"selectStocktakeItemsByMain"
parameterType=
"java.util.Map"
resultMap=
"StocktakeItemsResult"
>
select id, inventory_id,unit_price, stocktake_id, material_id, batch_code, warehouse_id, location_id, system_quantity, actual_quantity, variance_quantity, variance_amount, stocktake_status, counted_by, counted_at, adjusted, adjustment_reason, adjusted_by, adjusted_at, start_time, end_time, material_range, location_range, remark, is_used, sort_no, create_time, create_user_code, update_time, update_user_code
from stocktake_items
where stocktake_id = #{stocktake_id} and is_used = 1
<if
test=
"adjusted != null and adjusted != ''"
>
and adjusted = #{adjusted}
</if>
</select>
<!-- 查询处理统计-详情-->
<select
id=
"selectStocktakesCountInfo"
resultType=
"com.ruoyi.inventory.domain.TO.StocktakesVo"
>
select
st_it.material_id as materialId
,ma.sap_no as sapNo
,date_format(st.planned_date,'%Y%m%d') as plannedDates
,w.warehouses_name as warehousesName
,sl.location_name as locationName
,st_it.warehouse_id as warehousesId
,st_it.location_id as locationID
,ma.ts_code as tsCode
,dict.dict_label as hazardName
,IFNULL(st_it.variance_quantity, '0') as varianceQuantity
,IFNULL(st_it.variance_amount, '0') as varianceAmount
from stocktakes st
left join stocktake_items st_it on st.id = st_it.stocktake_id and st_it.is_used = 1
left join materials ma on st_it.material_id = ma.sap_no and ma.is_used = 1
left join warehouses w on st_it.warehouse_id = w.warehouses_code and w.is_used = 1
left join storage_locations sl on st_it.location_id = sl.location_code and sl.is_used = 1
left join sys_dict_data dict on ma.hazard_id = dict.dict_sort and dict.status =0 and dict.dict_type ='danger_type'
where
st.is_used = 1
<if
test=
"materialId != null "
>
and st_it.material_id = #{materialId}
</if>
<if
test=
"plannedDateArray != null and plannedDateArray.length > 0"
>
and date_format(st.planned_date,'%Y%m%d') in
<foreach
item=
"date"
collection=
"plannedDateArray"
open=
"("
separator=
","
close=
")"
>
#{date}
</foreach>
</if>
<if
test=
"warehouseIdArray != null and warehouseIdArray.length > 0"
>
and st_it.warehouse_id in
<foreach
item=
"warehouse"
collection=
"warehouseIdArray"
open=
"("
separator=
","
close=
")"
>
#{warehouse}
</foreach>
</if>
<if
test=
"locationIdArray != null and locationIdArray.length > 0"
>
and st_it.location_id in
<foreach
item=
"location"
collection=
"locationIdArray"
open=
"("
separator=
","
close=
")"
>
#{location}
</foreach>
</if>
order by st.planned_date
</select>
<insert
id=
"insertStocktakeItems"
parameterType=
"StocktakeItems"
>
insert into stocktake_items
<trim
prefix=
"("
suffix=
")"
suffixOverrides=
","
>
...
...
@@ -107,6 +159,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if
test=
"createUserCode != null"
>
create_user_code,
</if>
<if
test=
"updateTime != null"
>
update_time,
</if>
<if
test=
"updateUserCode != null"
>
update_user_code,
</if>
<if
test=
"unitPrice != null"
>
unit_price,
</if>
</trim>
<trim
prefix=
"values ("
suffix=
")"
suffixOverrides=
","
>
<if
test=
"id != null"
>
#{id},
</if>
...
...
@@ -138,6 +191,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if
test=
"createUserCode != null"
>
#{createUserCode},
</if>
<if
test=
"updateTime != null"
>
#{updateTime},
</if>
<if
test=
"updateUserCode != null"
>
#{updateUserCode},
</if>
<if
test=
"unitPrice != null"
>
#{unitPrice},
</if>
</trim>
</insert>
...
...
@@ -172,18 +226,23 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if
test=
"createUserCode != null"
>
create_user_code = #{createUserCode},
</if>
<if
test=
"updateTime != null"
>
update_time = #{updateTime},
</if>
<if
test=
"updateUserCode != null"
>
update_user_code = #{updateUserCode},
</if>
<if
test=
"unitPrice != null"
>
unit_price = #{unitPrice},
</if>
</trim>
where id = #{id}
</update>
<delete
id=
"deleteStocktakeItemsById"
parameterType=
"String"
>
delete from stocktake_items where id = #{id}
</delete>
<update
id=
"deleteStocktakeItemsById"
parameterType=
"String"
>
update stocktake_items
set is_used = 0
where id = #{id}
</update>
<delete
id=
"deleteStocktakeItemsByIds"
parameterType=
"String"
>
delete from stocktake_items where id in
<update
id=
"deleteStocktakeItemsByIds"
parameterType=
"String"
>
update from stocktake_items
set is_used = 0
where id in
<foreach
item=
"id"
collection=
"array"
open=
"("
separator=
","
close=
")"
>
#{id}
</foreach>
</
dele
te>
</
upda
te>
</mapper>
\ No newline at end of file
ruoyi-inventory/src/main/resources/mapper/inventory/StocktakesMapper.xml
View file @
883b7c52
...
...
@@ -23,41 +23,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result
property=
"updateUserCode"
column=
"update_user_code"
/>
</resultMap>
<resultMap
id=
"StocktakesStocktakeItemsResult"
type=
"Stocktakes"
extends=
"StocktakesResult"
>
<collection
property=
"stocktakeItemsList"
ofType=
"StocktakeItems"
column=
"id"
select=
"selectStocktakeItemsList"
/>
</resultMap>
<resultMap
type=
"StocktakeItems"
id=
"StocktakeItemsResult"
>
<result
property=
"id"
column=
"id"
/>
<result
property=
"stocktakeId"
column=
"stocktake_id"
/>
<result
property=
"inventoryId"
column=
"inventory_id"
/>
<result
property=
"materialId"
column=
"material_id"
/>
<result
property=
"batchCode"
column=
"batch_code"
/>
<result
property=
"warehouseId"
column=
"warehouse_id"
/>
<result
property=
"locationId"
column=
"location_id"
/>
<result
property=
"systemQuantity"
column=
"system_quantity"
/>
<result
property=
"actualQuantity"
column=
"actual_quantity"
/>
<result
property=
"varianceQuantity"
column=
"variance_quantity"
/>
<result
property=
"varianceAmount"
column=
"variance_amount"
/>
<result
property=
"stocktakeStatus"
column=
"stocktake_status"
/>
<result
property=
"countedBy"
column=
"counted_by"
/>
<result
property=
"countedAt"
column=
"counted_at"
/>
<result
property=
"adjusted"
column=
"adjusted"
/>
<result
property=
"adjustmentReason"
column=
"adjustment_reason"
/>
<result
property=
"adjustedBy"
column=
"adjusted_by"
/>
<result
property=
"adjustedAt"
column=
"adjusted_at"
/>
<result
property=
"startTime"
column=
"start_time"
/>
<result
property=
"endTime"
column=
"end_time"
/>
<result
property=
"materialRange"
column=
"material_range"
/>
<result
property=
"locationRange"
column=
"location_range"
/>
<result
property=
"remark"
column=
"remark"
/>
<result
property=
"isUsed"
column=
"is_used"
/>
<result
property=
"sortNo"
column=
"sort_no"
/>
<result
property=
"createTime"
column=
"create_time"
/>
<result
property=
"createUserCode"
column=
"create_user_code"
/>
<result
property=
"updateTime"
column=
"update_time"
/>
<result
property=
"updateUserCode"
column=
"update_user_code"
/>
</resultMap>
<sql
id=
"selectStocktakesVo"
>
select id, stocktake_id, stocktake_type, warehouse_id, stocktake_status, planned_date, material_range, location_range, total_variance_amount, remark, is_used, sort_no, create_time, create_user_code, update_time, update_user_code from stocktakes
...
...
@@ -88,20 +54,47 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
${params.dataScope}
</select>
<select
id=
"selectStocktakesById"
parameterType=
"String"
resultMap=
"Stocktakes
StocktakeItems
Result"
>
<select
id=
"selectStocktakesById"
parameterType=
"String"
resultMap=
"StocktakesResult"
>
select id, stocktake_id, stocktake_type, warehouse_id, stocktake_status, planned_date, material_range, location_range
, total_variance_amount, remark, is_used, sort_no, create_time, create_user_code, update_time, update_user_code
from stocktakes
where id = #{id}
</select>
<select
id=
"selectStocktakeItemsList"
resultMap=
"StocktakeItemsResult"
>
select id, inventory_id, stocktake_id, material_id, batch_code, warehouse_id, location_id, system_quantity, actual_quantity, variance_quantity, variance_amount, stocktake_status, counted_by, counted_at, adjusted, adjustment_reason, adjusted_by, adjusted_at, start_time, end_time, material_range, location_range, remark, is_used, sort_no, create_time, create_user_code, update_time, update_user_code
from stocktake_items
where stocktake_id = #{stocktake_id} and is_used = 1
<!-- 查询处理统计-->
<select
id=
"selectStocktakesListCount"
resultType=
"com.ruoyi.inventory.domain.TO.StocktakesVo"
>
select
st_it.material_id as materialId
,ma.sap_no as sapNo
,GROUP_CONCAT(DISTINCT date_format(st.planned_date,'%Y%m%d') SEPARATOR ',') as plannedDates
,GROUP_CONCAT(DISTINCT w.warehouses_name SEPARATOR ',') as warehousesName
,GROUP_CONCAT(DISTINCT sl.location_name SEPARATOR ',') as locationName
,GROUP_CONCAT(DISTINCT st_it.warehouse_id SEPARATOR ',') as warehousesId
,GROUP_CONCAT(DISTINCT st_it.location_id SEPARATOR ',') as locationId
,ma.ts_code as tsCode
,GROUP_CONCAT(DISTINCT dict.dict_label SEPARATOR ',') as hazardName
,IFNULL(sum(st_it.variance_quantity), '0') as countQuantity
,IFNULL(sum(st_it.variance_amount), '0') as countAmount
from stocktakes st
left join stocktake_items st_it on st.id = st_it.stocktake_id and st_it.is_used = 1
left join materials ma on st_it.material_id = ma.sap_no and ma.is_used = 1
left join warehouses w on st_it.warehouse_id = w.warehouses_code and w.is_used = 1
left join storage_locations sl on st_it.location_id = sl.location_code and sl.is_used = 1
left join sys_dict_data dict on ma.hazard_id = dict.dict_sort and dict.status =0 and dict.dict_type ='danger_type'
where
st.is_used = 1
<if
test=
"materialId != null "
>
and st_it.material_id = #{materialId}
</if>
<if
test=
"params.beginTime != null and params.beginTime != ''"
>
<!-- 开始时间检索 -->
AND date_format(st.planned_date,'%Y%m%d')
>
= date_format(#{params.beginTime},'%Y%m%d')
</if>
<if
test=
"params.endTime != null and params.endTime != ''"
>
<!-- 结束时间检索 -->
AND date_format(st.planned_date,'%Y%m%d')
<
= date_format(#{params.endTime},'%Y%m%d')
</if>
<if
test=
"warehouseId != null "
>
and st_it.warehouse_id = #{warehouseId}
</if>
<if
test=
"locationId != null "
>
and st_it.location_id = #{locationId}
</if>
group by st_it.material_id
</select>
<insert
id=
"insertStocktakes"
parameterType=
"Stocktakes"
>
insert into stocktakes
<trim
prefix=
"("
suffix=
")"
suffixOverrides=
","
>
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论