Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
J
jilinzhongdianrenqun
概览
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
吴超
jilinzhongdianrenqun
Commits
987884a1
Commit
987884a1
authored
Jan 05, 2026
by
zhangtw
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
入库导入新增按照material_id和areaId分组
库中不存在物料新增逻辑
parent
d459a3be
隐藏空白字符变更
内嵌
并排
正在显示
5 个修改的文件
包含
48 行增加
和
45 行删除
+48
-45
src/main/java/com/scpyun/platform/jilinsscgsdp/service/impl/KeyDmBorrowServiceImpl.java
+4
-4
src/main/java/com/scpyun/platform/jilinsscgsdp/service/impl/KeyDmInboundServiceImpl.java
+9
-2
src/main/java/com/scpyun/platform/jilinsscgsdp/utils/InboundFileListener.java
+19
-21
src/main/resources/mybatis/mappers/standard/jilinsscgsdp/KeyDmBorrowApplicationDao.xml
+2
-2
src/main/resources/mybatis/mappers/standard/jilinsscgsdp/KeyDmInboundRecordDao.xml
+14
-16
没有找到文件。
src/main/java/com/scpyun/platform/jilinsscgsdp/service/impl/KeyDmBorrowServiceImpl.java
View file @
987884a1
...
@@ -35,6 +35,7 @@ public class KeyDmBorrowServiceImpl {
...
@@ -35,6 +35,7 @@ public class KeyDmBorrowServiceImpl {
private
final
String
materialNamespace
=
"com.scpyun.platform.standard.jilinsscgsdp.keyDmMaterialLog."
;
private
final
String
materialNamespace
=
"com.scpyun.platform.standard.jilinsscgsdp.keyDmMaterialLog."
;
private
final
String
userNamespace
=
"com.scpyun.platform.standard.jilinsscgsdp.keyDmUser."
;
private
final
String
userNamespace
=
"com.scpyun.platform.standard.jilinsscgsdp.keyDmUser."
;
private
Map
<
String
,
String
>
userMap
;
private
Map
<
String
,
String
>
userMap
;
private
String
areaId
;
// 把用户的id和名做成字典
// 把用户的id和名做成字典
@PostConstruct
@PostConstruct
public
void
initUserMap
()
{
public
void
initUserMap
()
{
...
@@ -67,13 +68,12 @@ public class KeyDmBorrowServiceImpl {
...
@@ -67,13 +68,12 @@ public class KeyDmBorrowServiceImpl {
public
Page
<
Map
<
String
,
Object
>>
selectPendingList
(
Map
<
String
,
Object
>
map
)
{
public
Page
<
Map
<
String
,
Object
>>
selectPendingList
(
Map
<
String
,
Object
>
map
)
{
if
(
map
==
null
)
map
=
new
HashMap
<>();
if
(
map
==
null
)
map
=
new
HashMap
<>();
Map
<
String
,
Object
>
user
=
(
Map
<
String
,
Object
>)
map
.
get
(
"_user"
);
Map
<
String
,
Object
>
user
=
(
Map
<
String
,
Object
>)
map
.
get
(
"_user"
);
map
.
put
(
"params"
,
user
);
// 获取应用机构代码
if
(
user
!=
null
)
{
if
(
user
!=
null
)
{
Map
<
String
,
String
>
pos
=
DataScopeUtil
.
getPosition
(
user
);
Map
<
String
,
String
>
pos
=
DataScopeUtil
.
getPosition
(
user
);
map
.
put
(
"areaId"
,
pos
.
get
(
"area_id"
)
);
areaId
=
pos
.
get
(
"area_id"
);
map
.
put
(
"parentIds"
,
user
.
get
(
"parent_ids"
)+
","
+
pos
.
get
(
"area_id"
)
);
user
.
put
(
"areaId"
,
areaId
);
}
}
map
.
put
(
"params"
,
user
);
return
commonService
.
findPage
(
namespace
+
"selectPendingList"
,
map
);
return
commonService
.
findPage
(
namespace
+
"selectPendingList"
,
map
);
}
}
...
...
src/main/java/com/scpyun/platform/jilinsscgsdp/service/impl/KeyDmInboundServiceImpl.java
View file @
987884a1
...
@@ -50,7 +50,7 @@ public class KeyDmInboundServiceImpl {
...
@@ -50,7 +50,7 @@ public class KeyDmInboundServiceImpl {
private
final
String
materialNamespace
=
"com.scpyun.platform.standard.jilinsscgsdp.keyDmMaterialLog."
;
private
final
String
materialNamespace
=
"com.scpyun.platform.standard.jilinsscgsdp.keyDmMaterialLog."
;
private
final
String
borrowNamespace
=
"com.scpyun.platform.standard.jilinsscgsdp.keyDmBorrow."
;
private
final
String
borrowNamespace
=
"com.scpyun.platform.standard.jilinsscgsdp.keyDmBorrow."
;
private
final
String
userNamespace
=
"com.scpyun.platform.standard.jilinsscgsdp.keyDmUser."
;
private
final
String
userNamespace
=
"com.scpyun.platform.standard.jilinsscgsdp.keyDmUser."
;
private
String
areaId
;
private
Map
<
String
,
String
>
userMap
;
private
Map
<
String
,
String
>
userMap
;
// 把用户的id和名做成字典
// 把用户的id和名做成字典
@PostConstruct
@PostConstruct
...
@@ -162,7 +162,14 @@ public class KeyDmInboundServiceImpl {
...
@@ -162,7 +162,14 @@ public class KeyDmInboundServiceImpl {
int
aff
=
commonService
.
update
(
namespace
+
"doInbound"
,
map
);
int
aff
=
commonService
.
update
(
namespace
+
"doInbound"
,
map
);
if
(
aff
<
0
)
throw
new
CustomException
(
"入库失败"
);
if
(
aff
<
0
)
throw
new
CustomException
(
"入库失败"
);
Map
<
String
,
Object
>
ret
=
getById
(
map
);
Map
<
String
,
Object
>
ret
=
getById
(
map
);
ret
.
put
(
"_user"
,
map
.
get
(
"_user"
));
Map
<
String
,
Object
>
user
=
(
Map
<
String
,
Object
>)
map
.
get
(
"_user"
);
if
(
user
!=
null
)
{
Map
<
String
,
String
>
pos
=
DataScopeUtil
.
getPosition
(
user
);
areaId
=
pos
.
get
(
"area_id"
);
user
.
put
(
"areaId"
,
areaId
);
}
ret
.
put
(
"_user"
,
user
);
// 更新库存明细:调用 mapper 更新库存和日志(mapper 内实现或逐条处理)
// 更新库存明细:调用 mapper 更新库存和日志(mapper 内实现或逐条处理)
commonService
.
update
(
namespace
+
"updateInventoryByInbound"
,
ret
);
commonService
.
update
(
namespace
+
"updateInventoryByInbound"
,
ret
);
...
...
src/main/java/com/scpyun/platform/jilinsscgsdp/utils/InboundFileListener.java
View file @
987884a1
...
@@ -43,6 +43,7 @@ public class InboundFileListener extends AnalysisEventListener<InboundImp> {
...
@@ -43,6 +43,7 @@ public class InboundFileListener extends AnalysisEventListener<InboundImp> {
if
(
user
!=
null
)
{
if
(
user
!=
null
)
{
Map
<
String
,
String
>
pos
=
DataScopeUtil
.
getPosition
(
user
);
Map
<
String
,
String
>
pos
=
DataScopeUtil
.
getPosition
(
user
);
areaId
=
pos
.
get
(
"area_id"
);
areaId
=
pos
.
get
(
"area_id"
);
user
.
put
(
"areaId"
,
areaId
);
}
}
// 初始化日期格式
// 初始化日期格式
dateFormat
.
setLenient
(
false
);
dateFormat
.
setLenient
(
false
);
...
@@ -291,33 +292,32 @@ public class InboundFileListener extends AnalysisEventListener<InboundImp> {
...
@@ -291,33 +292,32 @@ public class InboundFileListener extends AnalysisEventListener<InboundImp> {
try
{
try
{
// 按物料ID分组汇总数量
// 按物料ID分组汇总数量
Map
<
String
,
BigDecimal
>
materialQuantityMap
=
new
HashMap
<>();
Map
<
String
,
Map
<
String
,
Object
>
>
materialQuantityMap
=
new
HashMap
<>();
for
(
Map
<
String
,
Object
>
detail
:
inboundDetails
)
{
for
(
Map
<
String
,
Object
>
detail
:
inboundDetails
)
{
String
materialId
=
(
String
)
detail
.
get
(
"material_id"
);
String
materialId
=
(
String
)
detail
.
get
(
"material_id"
);
BigDecimal
quantity
=
(
BigDecimal
)
detail
.
get
(
"inbound_quantity"
);
if
(
materialId
!=
null
&&
quantity
!=
null
)
{
if
(
materialId
!=
null
)
{
materialQuantityMap
.
merge
(
materialId
,
quantity
,
BigDecimal:
:
add
);
if
(
materialQuantityMap
.
get
(
materialId
)
==
null
)
{
materialQuantityMap
.
put
(
materialId
,
detail
);
}
else
{
Map
<
String
,
Object
>
tempMap
=
new
HashMap
<>();
tempMap
=
materialQuantityMap
.
get
(
materialId
);
int
materialQuantity
=
(
int
)
tempMap
.
get
(
"inbound_quantity"
);
materialQuantity
+=
(
int
)
detail
.
get
(
"inbound_quantity"
);
detail
.
put
(
"inbound_quantity"
,
materialQuantity
);
materialQuantityMap
.
put
(
materialId
,
detail
);
}
}
}
}
}
// 批量更新
// 批量更新
List
<
Map
<
String
,
Object
>>
updateList
=
new
ArrayList
<>();
List
<
Map
<
String
,
Object
>>
updateList
=
new
ArrayList
<>(
materialQuantityMap
.
values
());
for
(
Map
.
Entry
<
String
,
BigDecimal
>
entry
:
materialQuantityMap
.
entrySet
())
{
Map
<
String
,
Object
>
updateParam
=
new
HashMap
<>();
updateParam
.
put
(
"material_id"
,
entry
.
getKey
());
updateParam
.
put
(
"quantity"
,
entry
.
getValue
());
updateParam
.
put
(
"update_time"
,
new
Date
());
updateParam
.
put
(
"_user"
,
user
);
updateList
.
add
(
updateParam
);
}
if
(!
updateList
.
isEmpty
())
{
if
(!
updateList
.
isEmpty
())
{
Map
<
String
,
Object
>
batchParam
=
new
HashMap
<>();
Map
<
String
,
Object
>
batchParam
=
new
HashMap
<>();
batchParam
.
put
(
"list"
,
updateList
);
batchParam
.
put
(
"list"
,
updateList
);
batchParam
.
put
(
"_user"
,
user
);
batchParam
.
put
(
"_user"
,
user
);
batchParam
.
put
(
"areaId"
,
areaId
);
commonService
.
update
(
namespace
+
"batchUpdateMaterialStock"
,
batchParam
);
commonService
.
update
(
namespace
+
"batchUpdateMaterialStock"
,
batchParam
);
}
}
...
@@ -395,31 +395,29 @@ public class InboundFileListener extends AnalysisEventListener<InboundImp> {
...
@@ -395,31 +395,29 @@ public class InboundFileListener extends AnalysisEventListener<InboundImp> {
detail
.
put
(
"inbound_type"
,
1
);
detail
.
put
(
"inbound_type"
,
1
);
detail
.
put
(
"is_used"
,
1
);
detail
.
put
(
"is_used"
,
1
);
// 转换入库数量
// 转换入库数量
BigDecimal
inboundQuantity
=
BigDecimal
.
ZERO
;
Integer
inboundQuantity
=
0
;
try
{
try
{
if
(
StringUtils
.
isNotEmpty
(
data
.
getInbound_quantity
()))
{
if
(
StringUtils
.
isNotEmpty
(
data
.
getInbound_quantity
()))
{
inboundQuantity
=
new
BigDecimal
(
data
.
getInbound_quantity
().
trim
());
inboundQuantity
=
Integer
.
parseInt
(
data
.
getInbound_quantity
().
trim
());
}
}
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
log
.
warn
(
"数量格式转换失败: {}"
,
data
.
getInbound_quantity
());
log
.
warn
(
"数量格式转换失败: {}"
,
data
.
getInbound_quantity
());
inboundQuantity
=
BigDecimal
.
ZERO
;
}
}
detail
.
put
(
"inbound_quantity"
,
inboundQuantity
);
detail
.
put
(
"inbound_quantity"
,
inboundQuantity
);
// 转换单价
// 转换单价
BigDecimal
unitPrice
=
BigDecimal
.
ZERO
;
Double
unitPrice
=
0.0
;
try
{
try
{
if
(
StringUtils
.
isNotEmpty
(
data
.
getUnit_price
()))
{
if
(
StringUtils
.
isNotEmpty
(
data
.
getUnit_price
()))
{
unitPrice
=
new
BigDecimal
(
data
.
getUnit_price
().
trim
());
unitPrice
=
Double
.
parseDouble
(
data
.
getUnit_price
().
trim
());
}
}
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
log
.
warn
(
"单价格式转换失败: {}"
,
data
.
getUnit_price
());
log
.
warn
(
"单价格式转换失败: {}"
,
data
.
getUnit_price
());
unitPrice
=
BigDecimal
.
ZERO
;
}
}
detail
.
put
(
"unit_price"
,
unitPrice
);
detail
.
put
(
"unit_price"
,
unitPrice
);
// 计算总金额
// 计算总金额
BigDecimal
totalAmount
=
inboundQuantity
.
multiply
(
unitPrice
)
;
Double
totalAmount
=
inboundQuantity
*
unitPrice
;
detail
.
put
(
"total_amount"
,
totalAmount
);
detail
.
put
(
"total_amount"
,
totalAmount
);
// 处理生产日期
// 处理生产日期
...
...
src/main/resources/mybatis/mappers/standard/jilinsscgsdp/KeyDmBorrowApplicationDao.xml
View file @
987884a1
...
@@ -35,8 +35,8 @@
...
@@ -35,8 +35,8 @@
is_used = 1
is_used = 1
AND approval_status = 1
AND approval_status = 1
and approver_id = #{params.params.id}
and approver_id = #{params.params.id}
<if
test=
"params.
areaId != null and params.areaId != ''
"
>
<if
test=
"params.
params.areaId != null
"
>
AND apply_dep_code = #{params.areaId}
AND apply_dep_code = #{params.
params.
areaId}
</if>
</if>
</where>
</where>
ORDER BY submit_time DESC
ORDER BY submit_time DESC
...
...
src/main/resources/mybatis/mappers/standard/jilinsscgsdp/KeyDmInboundRecordDao.xml
View file @
987884a1
...
@@ -134,7 +134,7 @@
...
@@ -134,7 +134,7 @@
#{item.material_code},
#{item.material_code},
#{item.material_name},
#{item.material_name},
#{item.inbound_quantity},
#{item.inbound_quantity},
#{item.available_quantity}
,
0
,
0,
0,
0,
0,
#{item.is_used},
#{item.is_used},
...
@@ -142,8 +142,8 @@
...
@@ -142,8 +142,8 @@
NOW(),
NOW(),
#{_user.id},
#{_user.id},
NOW(),
NOW(),
#{item.order_no}
,
0
,
#{
apply_dep_code
}
#{
_user.areaId
}
)
)
</foreach>
</foreach>
ON DUPLICATE KEY UPDATE
ON DUPLICATE KEY UPDATE
...
@@ -275,21 +275,19 @@
...
@@ -275,21 +275,19 @@
)
)
</foreach>
</foreach>
</insert>
</insert>
<
update
id=
"batchUpdateMaterialStock"
parameterType=
"map"
>
<
insert
id=
"batchUpdateMaterialStock"
parameterType=
"map"
>
UPDATE jl_key_dm_inventory
INSERT INTO jl_key_dm_inventory (id, material_id, material_code, material_name, total_quantity, available_quantity, borrowed_quantity, damaged_quantity, is_used, create_by, create_time, order_no, apply_dep_code)
SET total_quantity = total_quantity + CASE id
VALUES
<foreach
collection=
"list"
item=
"item"
>
<foreach
collection=
"list"
item=
"item"
separator=
","
>
WHEN #{item.material_id} THEN #{item.quantity}
(UUID(), #{item.material_id}, #{item.material_code}, #{item.material_name}, #{item.inbound_quantity},0 ,0, 0, 1, #{_user.id}, NOW(),0, #{_user.areaId})
</foreach>
</foreach>
ELSE 0
ON DUPLICATE KEY UPDATE
END,
total_quantity = total_quantity + VALUES(total_quantity),
borrowed_quantity = borrowed_quantity + VALUES(borrowed_quantity),
damaged_quantity = damaged_quantity + VALUES(damaged_quantity),
update_by = #{_user.id},
update_time = NOW()
update_time = NOW()
WHERE apply_dep_code = #{areaId}
</insert>
AND id IN
<foreach
collection=
"list"
item=
"item"
open=
"("
separator=
","
close=
")"
>
#{item.material_id}
</foreach>
</update>
<insert
id=
"insertInboundMaster"
parameterType=
"map"
>
<insert
id=
"insertInboundMaster"
parameterType=
"map"
>
INSERT INTO jl_key_dm_inbound_record (
INSERT INTO jl_key_dm_inbound_record (
id,
id,
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论