Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
jinli gu
JSH ERP
Commits
4a51ea98
Commit
4a51ea98
authored
May 13, 2022
by
季圣华
Browse files
优化商品导入,提高速度
parent
7ea99431
Changes
6
Hide whitespace changes
Inline
Side-by-side
jshERP-boot/src/main/java/com/jsh/erp/config/TenantConfig.java
View file @
4a51ea98
...
...
@@ -101,10 +101,10 @@ public class TenantConfig {
/**
* 性能分析拦截器,不建议生产使用
*/
@Bean
public
PerformanceInterceptor
performanceInterceptor
(){
return
new
PerformanceInterceptor
();
}
//
@Bean
//
public PerformanceInterceptor performanceInterceptor(){
//
return new PerformanceInterceptor();
//
}
}
jshERP-boot/src/main/java/com/jsh/erp/controller/MaterialController.java
View file @
4a51ea98
...
...
@@ -325,7 +325,7 @@ public class MaterialController {
StringUtil
.
toNull
(
standard
),
StringUtil
.
toNull
(
model
),
StringUtil
.
toNull
(
color
),
StringUtil
.
toNull
(
weight
),
StringUtil
.
toNull
(
expiryNum
),
StringUtil
.
toNull
(
enableSerialNumber
),
StringUtil
.
toNull
(
enableBatchNumber
),
StringUtil
.
toNull
(
remark
),
StringUtil
.
toNull
(
categoryId
));
String
[]
names
=
{
"条码"
,
"名称"
,
"规格"
,
"型号"
,
"颜色"
,
"类别"
,
"扩展信息"
,
"单位"
,
"基础重量"
,
"保质期"
,
"采购价"
,
"
销
售价"
,
"
零
售价"
,
"最低售价"
,
"备注"
,
"状态"
,
"序列号"
,
"批号"
};
String
[]
names
=
{
"条码"
,
"名称"
,
"规格"
,
"型号"
,
"颜色"
,
"类别"
,
"扩展信息"
,
"单位"
,
"基础重量"
,
"保质期"
,
"采购价"
,
"
零
售价"
,
"
销
售价"
,
"最低售价"
,
"备注"
,
"状态"
,
"序列号"
,
"批号"
};
String
title
=
"商品信息"
;
List
<
String
[]>
objects
=
new
ArrayList
<>();
if
(
null
!=
dataList
)
{
...
...
@@ -342,8 +342,8 @@ public class MaterialController {
objs
[
8
]
=
m
.
getWeight
()
==
null
?
""
:
m
.
getWeight
().
toString
();
objs
[
9
]
=
m
.
getExpiryNum
()
==
null
?
""
:
m
.
getExpiryNum
().
toString
();
objs
[
10
]
=
m
.
getPurchaseDecimal
()
==
null
?
""
:
m
.
getPurchaseDecimal
().
toString
();
objs
[
11
]
=
m
.
get
Wholesale
Decimal
()
==
null
?
""
:
m
.
get
Wholesale
Decimal
().
toString
();
objs
[
12
]
=
m
.
get
Commodity
Decimal
()
==
null
?
""
:
m
.
get
Commodity
Decimal
().
toString
();
objs
[
11
]
=
m
.
get
Commodity
Decimal
()
==
null
?
""
:
m
.
get
Commodity
Decimal
().
toString
();
objs
[
12
]
=
m
.
get
Wholesale
Decimal
()
==
null
?
""
:
m
.
get
Wholesale
Decimal
().
toString
();
objs
[
13
]
=
m
.
getLowDecimal
()
==
null
?
""
:
m
.
getLowDecimal
().
toString
();
objs
[
14
]
=
m
.
getRemark
();
objs
[
15
]
=
m
.
getEnabled
()
?
"启用"
:
"禁用"
;
...
...
jshERP-boot/src/main/java/com/jsh/erp/datasource/mappers/DepotItemMapperEx.java
View file @
4a51ea98
...
...
@@ -154,6 +154,9 @@ public interface DepotItemMapperEx {
@Param
(
"name"
)
String
name
,
@Param
(
"depotId"
)
Long
depotId
,
@Param
(
"barCode"
)
String
barCode
,
@Param
(
"batchNumber"
)
String
batchNumber
);
@Param
(
"batchNumber"
)
String
batchNumber
);
Long
getCountByMaterialAndDepot
(
@Param
(
"mId"
)
Long
mId
,
@Param
(
"depotId"
)
Long
depotId
);
}
jshERP-boot/src/main/java/com/jsh/erp/service/depotItem/DepotItemService.java
View file @
4a51ea98
...
...
@@ -845,4 +845,8 @@ public class DepotItemService {
public
List
<
DepotItemVoBatchNumberList
>
getBatchNumberList
(
String
name
,
Long
depotId
,
String
barCode
,
String
batchNumber
){
return
depotItemMapperEx
.
getBatchNumberList
(
name
,
depotId
,
barCode
,
batchNumber
);
}
public
Long
getCountByMaterialAndDepot
(
Long
mId
,
Long
depotId
)
{
return
depotItemMapperEx
.
getCountByMaterialAndDepot
(
mId
,
depotId
);
}
}
jshERP-boot/src/main/java/com/jsh/erp/service/material/MaterialService.java
View file @
4a51ea98
...
...
@@ -585,9 +585,6 @@ public class MaterialService {
mList
.
add
(
m
);
}
}
logService
.
insertLog
(
"商品"
,
new
StringBuffer
(
BusinessConstants
.
LOG_OPERATION_TYPE_IMPORT
).
append
(
mList
.
size
()).
append
(
BusinessConstants
.
LOG_DATA_UNIT
).
toString
(),
((
ServletRequestAttributes
)
RequestContextHolder
.
getRequestAttributes
()).
getRequest
());
Long
mId
=
0L
;
for
(
MaterialWithInitStock
m:
mList
)
{
//判断该商品是否存在,如果不存在就新增,如果存在就更新
...
...
@@ -596,7 +593,7 @@ public class MaterialService {
if
(
materials
.
size
()<=
0
)
{
materialMapper
.
insertSelective
(
m
);
List
<
Material
>
newList
=
getMaterialListByParam
(
m
.
getName
(),
m
.
getModel
(),
m
.
getColor
(),
m
.
getStandard
(),
m
.
getUnit
(),
m
.
getUnitId
(),
basicBarCode
);
if
(
newList
!=
null
&&
newList
.
size
()>
0
)
{
if
(
newList
.
size
()>
0
)
{
mId
=
newList
.
get
(
0
).
getId
();
}
}
else
{
...
...
@@ -637,19 +634,23 @@ public class MaterialService {
Map
<
Long
,
BigDecimal
>
stockMap
=
m
.
getStockMap
();
Long
depotId
=
null
;
for
(
Depot
depot:
depotList
){
depotId
=
depot
.
getId
();
BigDecimal
stock
=
stockMap
.
get
(
depot
.
getId
());
//初始库存-先清除再插入
MaterialInitialStockExample
example
=
new
MaterialInitialStockExample
();
example
.
createCriteria
().
andMaterialIdEqualTo
(
mId
).
andDepotIdEqualTo
(
depot
.
getId
());
materialInitialStockMapper
.
deleteByExample
(
example
);
if
(
stock
!=
null
&&
stock
.
compareTo
(
BigDecimal
.
ZERO
)!=
0
)
{
depotId
=
depot
.
getId
();
//新增初始库存
insertInitialStockByMaterialAndDepot
(
depotId
,
mId
,
stock
,
null
,
null
);
//更新当前库存
depotItemService
.
updateCurrentStockFun
(
mId
,
depotId
);
}
//新增或更新当前库存
insertOrUpdateCurrentStockByMaterialAndDepot
(
depotId
,
mId
,
stock
);
}
}
logService
.
insertLog
(
"商品"
,
new
StringBuffer
(
BusinessConstants
.
LOG_OPERATION_TYPE_IMPORT
).
append
(
mList
.
size
()).
append
(
BusinessConstants
.
LOG_DATA_UNIT
).
toString
(),
((
ServletRequestAttributes
)
RequestContextHolder
.
getRequestAttributes
()).
getRequest
());
info
.
code
=
200
;
info
.
data
=
"导入成功"
;
}
catch
(
BusinessRunTimeException
e
)
{
...
...
@@ -761,6 +762,19 @@ public class MaterialService {
materialInitialStockMapper
.
insertSelective
(
materialInitialStock
);
//存入初始库存
}
/**
* 删除当前库存
* @param depotId
* @param mId
*/
@Transactional
(
value
=
"transactionManager"
,
rollbackFor
=
Exception
.
class
)
public
void
deleteCurrentStockByMaterialAndDepot
(
Long
depotId
,
Long
mId
){
MaterialCurrentStockExample
example
=
new
MaterialCurrentStockExample
();
example
.
createCriteria
().
andDepotIdEqualTo
(
depotId
).
andMaterialIdEqualTo
(
mId
)
.
andDeleteFlagNotEqualTo
(
BusinessConstants
.
DELETE_FLAG_DELETED
);
materialCurrentStockMapper
.
deleteByExample
(
example
);
}
/**
* 写入当前库存
* @param depotId
...
...
@@ -776,6 +790,25 @@ public class MaterialService {
materialCurrentStockMapper
.
insertSelective
(
materialCurrentStock
);
//存入初始库存
}
/**
* 新增或更新当前库存
* @param depotId
* @param mId
* @param stock
*/
@Transactional
(
value
=
"transactionManager"
,
rollbackFor
=
Exception
.
class
)
public
void
insertOrUpdateCurrentStockByMaterialAndDepot
(
Long
depotId
,
Long
mId
,
BigDecimal
stock
){
Long
billCount
=
depotItemService
.
getCountByMaterialAndDepot
(
mId
,
depotId
);
if
(
billCount
==
0
)
{
deleteCurrentStockByMaterialAndDepot
(
depotId
,
mId
);
if
(
stock
!=
null
&&
stock
.
compareTo
(
BigDecimal
.
ZERO
)!=
0
)
{
insertCurrentStockByMaterialAndDepot
(
depotId
,
mId
,
stock
);
}
}
else
{
depotItemService
.
updateCurrentStockFun
(
mId
,
depotId
);
}
}
public
List
<
MaterialVo4Unit
>
getMaterialEnableSerialNumberList
(
String
q
,
Integer
offset
,
Integer
rows
)
throws
Exception
{
List
<
MaterialVo4Unit
>
list
=
null
;
try
{
...
...
jshERP-boot/src/main/resources/mapper_xml/DepotItemMapperEx.xml
View file @
4a51ea98
...
...
@@ -608,4 +608,10 @@
group by batch_number
order by expiration_date asc
</select>
<select
id=
"getCountByMaterialAndDepot"
resultType=
"java.lang.Long"
>
select count(1) from jsh_depot_item di
where di.material_id=#{mId} and di.depot_id=#{depotId}
and ifnull(di.delete_flag,'0') !='1'
</select>
</mapper>
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment