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
0cee0a3f
Commit
0cee0a3f
authored
Dec 15, 2025
by
yubin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修库存 出库单排行榜
parent
7494b209
隐藏空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
75 行增加
和
40 行删除
+75
-40
ruoyi-inventory/src/main/java/com/ruoyi/inventory/service/impl/InventoryServiceImpl.java
+33
-5
ruoyi-inventory/src/main/resources/mapper/inventory/InboundOrdersMapper.xml
+1
-1
ruoyi-inventory/src/main/resources/mapper/inventory/InventoryMapper.xml
+21
-17
ruoyi-inventory/src/main/resources/mapper/inventory/OutboundOrdersMapper.xml
+20
-17
没有找到文件。
ruoyi-inventory/src/main/java/com/ruoyi/inventory/service/impl/InventoryServiceImpl.java
View file @
0cee0a3f
...
@@ -4,11 +4,9 @@ import java.util.*;
...
@@ -4,11 +4,9 @@ import java.util.*;
import
java.util.stream.Collectors
;
import
java.util.stream.Collectors
;
import
com.ruoyi.common.annotation.SerialExecution
;
import
com.ruoyi.common.annotation.SerialExecution
;
import
com.ruoyi.common.exception.ServiceException
;
import
com.ruoyi.common.utils.DateUtils
;
import
com.ruoyi.common.utils.DateUtils
;
import
com.ruoyi.inventory.domain.InboundOrderItems
;
import
com.ruoyi.common.utils.uuid.IdUtils
;
import
com.ruoyi.inventory.domain.OutboundOrderItems
;
import
com.ruoyi.inventory.domain.*
;
import
com.ruoyi.inventory.domain.OutboundOrderLog
;
import
com.ruoyi.inventory.domain.TO.StocktakeItemsTo
;
import
com.ruoyi.inventory.domain.TO.StocktakeItemsTo
;
import
com.ruoyi.inventory.domain.vo.InventoryExceedWarnVO
;
import
com.ruoyi.inventory.domain.vo.InventoryExceedWarnVO
;
import
com.ruoyi.inventory.domain.vo.InventorySummaryVO
;
import
com.ruoyi.inventory.domain.vo.InventorySummaryVO
;
...
@@ -20,7 +18,6 @@ import org.apache.commons.lang3.SystemUtils;
...
@@ -20,7 +18,6 @@ import org.apache.commons.lang3.SystemUtils;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
com.ruoyi.inventory.mapper.InventoryMapper
;
import
com.ruoyi.inventory.mapper.InventoryMapper
;
import
com.ruoyi.inventory.domain.Inventory
;
import
com.ruoyi.inventory.service.IInventoryService
;
import
com.ruoyi.inventory.service.IInventoryService
;
/**
/**
...
@@ -38,6 +35,12 @@ public class InventoryServiceImpl implements IInventoryService
...
@@ -38,6 +35,12 @@ public class InventoryServiceImpl implements IInventoryService
private
OutboundOrderLogMapper
outboundOrderLogMapper
;;
private
OutboundOrderLogMapper
outboundOrderLogMapper
;;
@Autowired
@Autowired
private
OutboundOrderItemsMapper
outboundOrderItemsMapper
;
private
OutboundOrderItemsMapper
outboundOrderItemsMapper
;
@Autowired
private
OutboundOrdersServiceImpl
outboundOrderMapper
;
@Autowired
private
InventoryTransactionsServiceImpl
insertInventoryTransactions
;
/**
/**
...
@@ -146,11 +149,36 @@ public class InventoryServiceImpl implements IInventoryService
...
@@ -146,11 +149,36 @@ public class InventoryServiceImpl implements IInventoryService
OutboundOrderLog
outboundOrderLog
=
outboundOrderLogMapper
.
selectOutboundOrderLogById
(
outboundOrderItem
.
getId
());
OutboundOrderLog
outboundOrderLog
=
outboundOrderLogMapper
.
selectOutboundOrderLogById
(
outboundOrderItem
.
getId
());
Inventory
inventory
=
inventoryMapper
.
selectInventoryById
(
outboundOrderLog
.
getInventoryId
());
Inventory
inventory
=
inventoryMapper
.
selectInventoryById
(
outboundOrderLog
.
getInventoryId
());
String
quantity
=
String
.
valueOf
(
inventory
.
getQuantity
());
inventory
.
setQuantity
(
inventory
.
getQuantity
()-
outboundOrderItem
.
getActualQuantity
());
inventory
.
setQuantity
(
inventory
.
getQuantity
()-
outboundOrderItem
.
getActualQuantity
());
if
(
inventory
.
getQuantity
()==
0
){
if
(
inventory
.
getQuantity
()==
0
){
inventory
.
setInventoryStatus
(
0
l
);
inventory
.
setInventoryStatus
(
0
l
);
}
}
updateInventory
(
inventory
);
updateInventory
(
inventory
);
// 库存操作表插入数据
InventoryTransactions
transactions
=
new
InventoryTransactions
();
transactions
.
setId
(
IdUtils
.
simpleUUID
());
transactions
.
setTransactionType
(
2L
);
// 事务类型-盘点
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
.
getWarehouseId
());
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
());
int
inventoryTransactions
=
insertInventoryTransactions
.
insertInventoryTransactions
(
transactions
);
if
(
inventoryTransactions
<
0
)
{
return
-
1
;
}
}
}
RefreshInventory
(
inventoryIds
);
RefreshInventory
(
inventoryIds
);
}
}
...
...
ruoyi-inventory/src/main/resources/mapper/inventory/InboundOrdersMapper.xml
View file @
0cee0a3f
...
@@ -252,7 +252,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
...
@@ -252,7 +252,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
from materials as m
from materials as m
left join inbound_order_items as ioi
left join inbound_order_items as ioi
on m.id = ioi.material_id
on m.id = ioi.material_id
left join inbound_order as io
left join inbound_order
s
as io
on io.id = ioi.inbound_order_id
on io.id = ioi.inbound_order_id
and io.order_status = 2
and io.order_status = 2
group by m.id, m.material_name
group by m.id, m.material_name
...
...
ruoyi-inventory/src/main/resources/mapper/inventory/InventoryMapper.xml
View file @
0cee0a3f
...
@@ -555,26 +555,29 @@ and inventory_status = '1'
...
@@ -555,26 +555,29 @@ and inventory_status = '1'
<select
id=
"selectInventoryTopTenByAmount"
resultType=
"java.util.Map"
>
<select
id=
"selectInventoryTopTenByAmount"
resultType=
"java.util.Map"
>
select
select
m.material_name as name,
m.material_name as name,
sum(i.quantity)*i.unit_price as value
IFNULL(sum(i.quantity) * IFNULL(i.unit_price, 0), 0) as value
from inventory i
from materials m
left join materials m on i.material_id = m.id
left join inventory i on i.material_id = m.id
where i.is_used = 1 and i.unit_price >0 and i.last_inbound_time
>
= DATE_FORMAT(CURDATE(), '%Y-%m-01')
and i.is_used = 1
and i.last_inbound_time
<
DATE_FORMAT(DATE_ADD(CURDATE(), INTERVAL 1 MONTH), '%Y-%m-01')
and i.unit_price > 0
group by m.material_name
and i.last_inbound_time >= DATE_FORMAT(CURDATE(), '%Y-%m-01')
order by sum(i.quantity)*i.unit_price desc
and i.last_inbound_time
<
DATE_FORMAT(DATE_ADD(CURDATE(), INTERVAL 1 MONTH), '%Y-%m-01')
group by m.id, m.material_name
order by value desc, m.material_name asc
</select>
</select>
<!-- 按数量统计库存前10(含无入库记录的物料) -->
<select
id=
"selectInventoryTopTenByQuantity"
resultType=
"java.util.Map"
>
<select
id=
"selectInventoryTopTenByQuantity"
resultType=
"java.util.Map"
>
select
select
m.material_name as name,
m.material_name as name,
sum(i.quantity) as value
IFNULL(sum(i.quantity), 0) as value
from inventory i
from materials m
left join materials m on i.material_id = m.id
left join inventory i on i.material_id = m.id
where i.is_used = 1 and i.last_inbound_time
>
= DATE_FORMAT(CURDATE(), '%Y-%m-01')
and i.is_used = 1
and i.last_inbound_time
<
DATE_FORMAT(DATE_ADD(CURDATE(), INTERVAL 1 MONTH), '%Y-%m-01')
and i.last_inbound_time >= DATE_FORMAT(CURDATE(), '%Y-%m-01')
group by m.material_name
and i.last_inbound_time
<
DATE_FORMAT(DATE_ADD(CURDATE(), INTERVAL 1 MONTH), '%Y-%m-01')
order by sum(i.quantity) desc
group by m.id, m.material_name
order by value desc, m.material_name asc
</select>
</select>
</mapper>
</mapper>
\ No newline at end of file
ruoyi-inventory/src/main/resources/mapper/inventory/OutboundOrdersMapper.xml
View file @
0cee0a3f
...
@@ -308,29 +308,32 @@
...
@@ -308,29 +308,32 @@
<select
id=
"SelectOutboundOrdersMaterialsTopTenByQuantity"
resultType=
"java.util.Map"
>
<select
id=
"SelectOutboundOrdersMaterialsTopTenByQuantity"
resultType=
"java.util.Map"
>
select
select
m.material_name as name,
m.material_name as name,
sum(ooi.actual_quantity) as value
sum(IFNULL(ooi.actual_quantity, 0)) as value
from outbound_order_items ooi
from materials m
left join materials m on ooi.material_id = m.id
left join outbound_order_items ooi
where ooi.is_used = 1 and ooi.shipped_at
>
= DATE_FORMAT(CURDATE(), '%Y-%m-01')
on ooi.material_id = m.id
and ooi.shipped_at
<
DATE_FORMAT(DATE_ADD(CURDATE(), INTERVAL 1 MONTH), '%Y-%m-01')
and ooi.is_used = 1
group by m.material_name
and ooi.shipped_at >= DATE_FORMAT(CURDATE(), '%Y-%m-01 00:00:00')
order by sum(ooi.actual_quantity) desc
and ooi.shipped_at
<
DATE_FORMAT(DATE_ADD(CURDATE(), INTERVAL 1 MONTH), '%Y-%m-01 00:00:00')
group by m.id, m.material_name
order by value desc
limit 10;
limit 10;
</select>
</select>
<select
id=
"SelectOutboundOrdersMaterialsTopTenByAmount"
resultType=
"java.util.Map"
>
<select
id=
"SelectOutboundOrdersMaterialsTopTenByAmount"
resultType=
"java.util.Map"
>
select
select
m.material_name as name,
m.material_name as name,
sum(ooi.actual_quantity)*ooi.unit_price as value
sum(IFNULL(ooi.actual_quantity, 0) * IFNULL(ooi.unit_price, 0)) as value
from outbound_order_items ooi
from materials m
left join materials m on ooi.material_id = m.id
left join outbound_order_items ooi
where ooi.is_used = 1 and ooi.shipped_at
>
= DATE_FORMAT(CURDATE(), '%Y-%m-01')
on ooi.material_id = m.id
and ooi.shipped_at
<
DATE_FORMAT(DATE_ADD(CURDATE(), INTERVAL 1 MONTH), '%Y-%m-01')
and ooi.is_used = 1
group by m.material_name
and ooi.shipped_at >= DATE_FORMAT(CURDATE(), '%Y-%m-01 00:00:00')
order by sum(ooi.actual_quantity) desc
and ooi.shipped_at
<
DATE_FORMAT(DATE_ADD(CURDATE(), INTERVAL 1 MONTH), '%Y-%m-01 00:00:00')
limit 10;
group by m.id, m.material_name
order by value desc
limit 10;
</select>
</select>
<select
id=
"outboundOrdersCount"
resultType=
"String"
>
<select
id=
"outboundOrdersCount"
resultType=
"String"
>
select count(*) from outbound_orders where is_used = 1 and order_status=2 and inbound_date
>
= DATE_FORMAT(CURDATE(), '%Y-%m-01')
select count(*) from outbound_orders where is_used = 1 and order_status=2 and inbound_date
>
= DATE_FORMAT(CURDATE(), '%Y-%m-01')
and inbound_date
<
DATE_FORMAT(DATE_ADD(CURDATE(), INTERVAL 1 MONTH), '%Y-%m-01')
and inbound_date
<
DATE_FORMAT(DATE_ADD(CURDATE(), INTERVAL 1 MONTH), '%Y-%m-01')
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论