Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
amos-boot-biz
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
项目统一框架
amos-boot-biz
Commits
c0dc922e
Commit
c0dc922e
authored
Apr 19, 2023
by
chenzhao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
优化消防装备导入过慢
parent
a24ce4a3
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
60 additions
and
27 deletions
+60
-27
StockServiceImpl.java
...om/yeejoin/equipmanage/service/impl/StockServiceImpl.java
+60
-27
No files found.
amos-boot-module/amos-boot-module-biz/amos-boot-module-equip-biz/src/main/java/com/yeejoin/equipmanage/service/impl/StockServiceImpl.java
View file @
c0dc922e
package
com
.
yeejoin
.
equipmanage
.
service
.
impl
;
package
com
.
yeejoin
.
equipmanage
.
service
.
impl
;
import
java.math.BigDecimal
;
import
java.text.SimpleDateFormat
;
import
java.text.SimpleDateFormat
;
import
java.util.*
;
import
java.util.*
;
import
java.util.concurrent.atomic.AtomicReference
;
import
java.util.concurrent.atomic.AtomicReference
;
...
@@ -8,6 +9,7 @@ import java.util.stream.Collectors;
...
@@ -8,6 +9,7 @@ import java.util.stream.Collectors;
import
javax.annotation.Resource
;
import
javax.annotation.Resource
;
import
com.yeejoin.equipmanage.common.utils.*
;
import
com.yeejoin.equipmanage.common.utils.*
;
import
org.apache.commons.lang3.ObjectUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.beans.factory.annotation.Value
;
...
@@ -305,9 +307,8 @@ public class StockServiceImpl extends ServiceImpl<StockMapper, Stock> implements
...
@@ -305,9 +307,8 @@ public class StockServiceImpl extends ServiceImpl<StockMapper, Stock> implements
@Override
@Override
// @Transactional(rollbackFor = Exception.class)
// @Transactional(rollbackFor = Exception.class)
public
Object
uploadListByTemplate
(
List
<
EquipmentDetailDownloadTemplateDto
>
equipmentDetailDownloadVOS
,
ReginParams
reginParams
,
AgencyUserModel
agencyUserModel
)
{
public
Object
uploadListByTemplate
(
List
<
EquipmentDetailDownloadTemplateDto
>
equipmentDetailDownloadVOS
,
ReginParams
reginParams
,
AgencyUserModel
agencyUserModel
)
{
StringBuffer
fireFightSysIdsBuffer
=
new
StringBuffer
();
StringBuffer
fireFightSysIdsBuffer
=
new
StringBuffer
();
Set
<
String
>
bizOrgCodes
=
new
HashSet
<>();
StringBuffer
errBufferName
=
new
StringBuffer
();
StringBuffer
errBufferName
=
new
StringBuffer
();
StringBuffer
erryy
=
new
StringBuffer
();
StringBuffer
erryy
=
new
StringBuffer
();
// StringBuffer errNum="0"; //失败条数
// StringBuffer errNum="0"; //失败条数
...
@@ -491,11 +492,28 @@ public class StockServiceImpl extends ServiceImpl<StockMapper, Stock> implements
...
@@ -491,11 +492,28 @@ public class StockServiceImpl extends ServiceImpl<StockMapper, Stock> implements
// list.add(equipmentSpecific);
// list.add(equipmentSpecific);
// this.equipmentSpecificIndexSave(equipmentDetail, equipmentSpecific);
// this.equipmentSpecificIndexSave(equipmentDetail, equipmentSpecific);
// }
// }
List
<
Equipment
>
equipmentList
;
if
(
redisUtils
.
hasKey
(
"equip_equipDefinitions"
))
{
equipmentList
=
JSONObject
.
parseArray
(
redisUtils
.
get
(
"equip_equipDefinitions"
).
toString
(),
Equipment
.
class
);;
}
else
{
QueryWrapper
<
Equipment
>
equipmentQueryWrapper
=
new
QueryWrapper
<>();
equipmentQueryWrapper
.
isNotNull
(
"id"
);
equipmentList
=
equipmentMapper
.
selectList
(
equipmentQueryWrapper
);
redisUtils
.
set
(
"equip_equipDefinitions"
,
JSONObject
.
toJSONString
(
equipmentList
));
}
List
<
WarehouseStructure
>
warehouseStructures
;
if
(
redisUtils
.
hasKey
(
"equip_warehouseStructures"
))
{
warehouseStructures
=
JSONObject
.
parseArray
(
redisUtils
.
get
(
"equip_warehouseStructures"
).
toString
(),
WarehouseStructure
.
class
);
}
else
{
warehouseStructures
=
warehouseStructureService
.
list
();
redisUtils
.
set
(
"equip_warehouseStructures"
,
JSONObject
.
toJSONString
(
warehouseStructures
));
}
for
(
int
i
=
0
;
i
<
equipmentDetailDownloadVOS
.
size
();
i
++)
{
for
(
int
i
=
0
;
i
<
equipmentDetailDownloadVOS
.
size
();
i
++)
{
try
{
try
{
seveRK
(
equipmentDetailDownloadVOS
.
get
(
i
),
reginParams
,
agencyUserModel
,
seveRK
(
equipmentDetailDownloadVOS
.
get
(
i
),
reginParams
,
agencyUserModel
,
fireFightSysIdsBuffer
,
list
,
errBufferName
,
erryy
,
i
+
1
);
fireFightSysIdsBuffer
,
list
,
errBufferName
,
erryy
,
i
+
1
,
equipmentList
,
warehouseStructures
,
bizOrgCodes
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
e
.
printStackTrace
();
}
}
...
@@ -526,8 +544,18 @@ public class StockServiceImpl extends ServiceImpl<StockMapper, Stock> implements
...
@@ -526,8 +544,18 @@ public class StockServiceImpl extends ServiceImpl<StockMapper, Stock> implements
String
[]
split
=
errBufferName
.
toString
().
split
(
","
);
String
[]
split
=
errBufferName
.
toString
().
split
(
","
);
String
date
=
"上传成功:"
+(
equipmentDetailDownloadVOS
.
size
()-(
split
!=
null
?
split
.
length
:
0
))+
"条---上传失败:"
+(
split
!=
null
?
split
.
length
:
0
)+
"条(失败编号:"
+
errBufferName
+
"详情:"
+
erryy
+
")"
;
String
date
=
"上传成功:"
+(
equipmentDetailDownloadVOS
.
size
()-(
split
!=
null
?
split
.
length
:
0
))+
"条---上传失败:"
+(
split
!=
null
?
split
.
length
:
0
)+
"条(失败编号:"
+
errBufferName
+
"详情:"
+
erryy
+
")"
;
log
.
error
(
date
);
log
.
error
(
date
);
//添加对于成功数据装备类型统计数据的刷新
StockServiceImpl
controllerProxy
=
SpringUtils
.
getBean
(
StockServiceImpl
.
class
);
for
(
String
bizOrgCode
:
bizOrgCodes
)
{
controllerProxy
.
refreshCount
(
bizOrgCode
);
}
return
date
;
return
date
;
}
}
//添加对于成功数据装备类型统计数据的刷新 当所有数据完成时对已成功数据的单位进行最终统计 避免每一次循环带来的线程压力
StockServiceImpl
controllerProxy
=
SpringUtils
.
getBean
(
StockServiceImpl
.
class
);
for
(
String
bizOrgCode
:
bizOrgCodes
)
{
controllerProxy
.
refreshCount
(
bizOrgCode
);
}
String
[]
split
=
errBufferName
.
toString
().
split
(
","
);
String
[]
split
=
errBufferName
.
toString
().
split
(
","
);
String
date
=
""
;
String
date
=
""
;
if
(
split
!=
null
&&
split
.
length
>
0
&&!
""
.
equals
(
split
[
0
])){
if
(
split
!=
null
&&
split
.
length
>
0
&&!
""
.
equals
(
split
[
0
])){
...
@@ -555,8 +583,9 @@ public class StockServiceImpl extends ServiceImpl<StockMapper, Stock> implements
...
@@ -555,8 +583,9 @@ public class StockServiceImpl extends ServiceImpl<StockMapper, Stock> implements
List
<
EquipmentSpecific
>
list
,
List
<
EquipmentSpecific
>
list
,
StringBuffer
errBufferName
,
StringBuffer
errBufferName
,
StringBuffer
erryy
,
StringBuffer
erryy
,
int
rowNum
int
rowNum
,
List
<
Equipment
>
equipmentList
,
List
<
WarehouseStructure
>
warehouseStructures
,
Set
<
String
>
bizOrgCodes
){
){
if
(
StringUtils
.
isEmpty
(
equipmentDetailDownloadVOS
.
getCode
()))
{
if
(
StringUtils
.
isEmpty
(
equipmentDetailDownloadVOS
.
getCode
()))
{
erryy
.
append
(
"第"
+
rowNum
+
"器材编码为空,"
);
erryy
.
append
(
"第"
+
rowNum
+
"器材编码为空,"
);
...
@@ -577,11 +606,13 @@ public class StockServiceImpl extends ServiceImpl<StockMapper, Stock> implements
...
@@ -577,11 +606,13 @@ public class StockServiceImpl extends ServiceImpl<StockMapper, Stock> implements
TransactionStatus
transactionStatus
=
platformTransactionManager
.
getTransaction
(
transactionDefinition
);
TransactionStatus
transactionStatus
=
platformTransactionManager
.
getTransaction
(
transactionDefinition
);
try
{
try
{
//查询装备定义信息
//查询装备定义信息
QueryWrapper
<
Equipment
>
equipmentQueryWrapper
=
new
QueryWrapper
<>();
// equipmentQueryWrapper.lambda().eq(Equipment::getCode, equipmentDetailDownloadVOS.getCode());
equipmentQueryWrapper
.
lambda
().
eq
(
Equipment:
:
getCode
,
equipmentDetailDownloadVOS
.
getCode
());
// Equipment equipment = equipmentMapper.selectOne(equipmentQueryWrapper);
Equipment
equipment
=
equipmentMapper
.
selectOne
(
equipmentQueryWrapper
);
// 此处由于每次导入都需查装备定义导致导入缓慢,所以优化为加入缓存
Equipment
equipment
=
equipmentList
.
stream
().
filter
(
x
->
x
.
getCode
().
equals
(
equipmentDetailDownloadVOS
.
getCode
())).
collect
(
Collectors
.
toList
()).
get
(
0
);
if
(
equipment
==
null
)
{
if
(
equipment
==
null
)
{
erryy
.
append
(
String
.
format
(
"装备(器材)编码[%S]填写错误,请输入正确的装备(器材)编码!"
,
equipmentDetailDownloadVOS
.
getCode
())
+
","
);
erryy
.
append
(
String
.
format
(
"装备(器材)编码[%S]填写错误,请输入正确的装备(器材)编码!"
,
equipmentDetailDownloadVOS
.
getCode
())
+
","
);
throw
new
RuntimeException
(
String
.
format
(
"装备(器材)编码[%S]填写错误,请输入正确的装备(器材)编码!"
,
equipmentDetailDownloadVOS
.
getCode
()));
throw
new
RuntimeException
(
String
.
format
(
"装备(器材)编码[%S]填写错误,请输入正确的装备(器材)编码!"
,
equipmentDetailDownloadVOS
.
getCode
()));
...
@@ -602,15 +633,18 @@ public class StockServiceImpl extends ServiceImpl<StockMapper, Stock> implements
...
@@ -602,15 +633,18 @@ public class StockServiceImpl extends ServiceImpl<StockMapper, Stock> implements
throw
new
RuntimeException
(
String
.
format
(
"物联编码[%S]填写重复,请重新输入!"
,
iotCode
));
throw
new
RuntimeException
(
String
.
format
(
"物联编码[%S]填写重复,请重新输入!"
,
iotCode
));
}
}
if
(
StringUtils
.
isNotEmpty
(
haveUsedIotPrefix
)
&&
Arrays
.
stream
(
haveUsedIotPrefix
.
split
(
","
)).
anyMatch
(
iotCode:
:
startsWith
)){
if
(
StringUtils
.
isNotEmpty
(
haveUsedIotPrefix
)
&&
Arrays
.
stream
(
haveUsedIotPrefix
.
split
(
","
)).
anyMatch
(
iotCode:
:
startsWith
)){
erryy
.
append
(
String
.
format
(
"物联编码[%S]航班
已占用,请重新输入!"
,
iotCode
)+
","
);
erryy
.
append
(
String
.
format
(
"物联编码[%S]
已占用,请重新输入!"
,
iotCode
)+
","
);
throw
new
BadRequest
(
"物联编码航班
已占用"
);
throw
new
BadRequest
(
"物联编码
已占用"
);
}
}
}
}
AtomicReference
<
String
>
fightSysIds
=
new
AtomicReference
<>(
""
);
AtomicReference
<
String
>
fightSysIds
=
new
AtomicReference
<>(
""
);
String
fightingSysCodes
=
equipmentDetailDownloadVOS
.
getFightingSysCodes
();
String
fightingSysCodes
=
equipmentDetailDownloadVOS
.
getFightingSysCodes
();
if
(
StringUtils
.
isNotBlank
(
fightingSysCodes
))
{
if
(
StringUtils
.
isNotBlank
(
fightingSysCodes
))
{
String
[]
idsArr
=
fightingSysCodes
.
split
(
"-"
);
String
[]
codes
=
new
String
[]{};
List
<
FireFightingSystemEntity
>
fightingSystemList
=
fireFightingSystemService
.
getFightingSysByCodes
(
idsArr
);
String
[]
idsArr1
=
fightingSysCodes
.
split
(
"-"
);
String
[]
idsArr2
=
fightingSysCodes
.
split
(
","
);
codes
=
idsArr1
.
length
>=
idsArr2
.
length
?
idsArr1
:
idsArr2
;
List
<
FireFightingSystemEntity
>
fightingSystemList
=
fireFightingSystemService
.
getFightingSysByCodes
(
codes
);
if
(!
fightingSystemList
.
isEmpty
())
{
if
(!
fightingSystemList
.
isEmpty
())
{
fightingSystemList
.
stream
().
forEach
(
x
->
{
fightingSystemList
.
stream
().
forEach
(
x
->
{
String
sysCodes
=
fightSysIds
.
get
();
String
sysCodes
=
fightSysIds
.
get
();
...
@@ -640,9 +674,8 @@ public class StockServiceImpl extends ServiceImpl<StockMapper, Stock> implements
...
@@ -640,9 +674,8 @@ public class StockServiceImpl extends ServiceImpl<StockMapper, Stock> implements
equipmentDetail
.
setName
(
equipmentDetailDownloadVOS
.
getName
());
equipmentDetail
.
setName
(
equipmentDetailDownloadVOS
.
getName
());
equipmentDetail
.
setArea
(
equipmentDetailDownloadVOS
.
getDescription
());
equipmentDetail
.
setArea
(
equipmentDetailDownloadVOS
.
getDescription
());
equipmentDetail
.
setProductionDate
(
equipmentDetailDownloadVOS
.
getProductionDate
());
equipmentDetail
.
setProductionDate
(
equipmentDetailDownloadVOS
.
getProductionDate
());
equipmentDetail
.
setExpiryDate
(
equipmentDetailDownloadVOS
.
getExpiryDate
());
equipmentDetail
.
setDeliveryDate
(
equipmentDetailDownloadVOS
.
getDeliveryDate
());
equipmentDetail
.
setDeliveryDate
(
equipmentDetailDownloadVOS
.
getDeliveryDate
());
equipmentDetail
.
setMaintenanceCycle
(
equipmentDetailDownloadVOS
.
getMaintenanceCycle
(
));
equipmentDetail
.
setMaintenanceCycle
(
ObjectUtils
.
isEmpty
(
equipment
.
getMaintenanceCycle
())
?
null
:
BigDecimal
.
valueOf
(
equipment
.
getMaintenanceCycle
()
));
// 导入新增所属单位
// 导入新增所属单位
...
@@ -675,7 +708,6 @@ public class StockServiceImpl extends ServiceImpl<StockMapper, Stock> implements
...
@@ -675,7 +708,6 @@ public class StockServiceImpl extends ServiceImpl<StockMapper, Stock> implements
equipmentSpecific
.
setTeamId
(
fireTeam
[
1
]);
equipmentSpecific
.
setTeamId
(
fireTeam
[
1
]);
}
}
// 导入新增所属单位
// 导入新增所属单位
if
(
StringUtils
.
isNotBlank
(
equipmentDetailDownloadVOS
.
getCompanyName
()))
{
if
(
StringUtils
.
isNotBlank
(
equipmentDetailDownloadVOS
.
getCompanyName
()))
{
String
[]
company
=
equipmentDetailDownloadVOS
.
getCompanyName
().
split
(
"@"
);
String
[]
company
=
equipmentDetailDownloadVOS
.
getCompanyName
().
split
(
"@"
);
equipmentSpecific
.
setAgencyId
(
company
[
1
]);
equipmentSpecific
.
setAgencyId
(
company
[
1
]);
...
@@ -685,19 +717,19 @@ public class StockServiceImpl extends ServiceImpl<StockMapper, Stock> implements
...
@@ -685,19 +717,19 @@ public class StockServiceImpl extends ServiceImpl<StockMapper, Stock> implements
}
}
if
(
StringUtils
.
isNotBlank
(
equipmentDetailDownloadVOS
.
getSystemName
()))
{
//
if (StringUtils.isNotBlank(equipmentDetailDownloadVOS.getSystemName())) {
String
[]
SystemName
=
equipmentDetailDownloadVOS
.
getSystemName
().
split
(
"@"
);
//
String[] SystemName = equipmentDetailDownloadVOS.getSystemName().split("@");
equipmentSpecific
.
setSystemId
(
SystemName
[
1
]);
//
equipmentSpecific.setSystemId(SystemName[1]);
}
//
}
equipmentSpecificMapper
.
insert
(
equipmentSpecific
);
equipmentSpecificMapper
.
insert
(
equipmentSpecific
);
StockServiceImpl
controllerProxy
=
SpringUtils
.
getBean
(
StockServiceImpl
.
class
);
//添加对于装备类型统计数据的刷新
controllerProxy
.
refreshCount
(
equipmentSpecific
.
getBizOrgCode
());
//位置编码不为空入库
//位置编码不为空入库
if
(
equipmentDetailDownloadVOS
!=
null
&&
equipmentDetailDownloadVOS
.
getWarehouseStructCode
()
!=
null
)
{
if
(
equipmentDetailDownloadVOS
!=
null
&&
equipmentDetailDownloadVOS
.
getWarehouseStructCode
()
!=
null
)
{
QueryWrapper
<
WarehouseStructure
>
warehouseStructureQueryWrapper
=
new
QueryWrapper
<>();
// QueryWrapper<WarehouseStructure> warehouseStructureQueryWrapper = new QueryWrapper<>();
warehouseStructureQueryWrapper
.
lambda
().
eq
(
WarehouseStructure:
:
getCode
,
equipmentDetailDownloadVOS
.
getWarehouseStructCode
());
// warehouseStructureQueryWrapper.lambda().eq(WarehouseStructure::getCode, equipmentDetailDownloadVOS.getWarehouseStructCode());
WarehouseStructure
warehouseStructure
=
warehouseStructureService
.
getOne
(
warehouseStructureQueryWrapper
);
// WarehouseStructure warehouseStructure = warehouseStructureService.getOne(warehouseStructureQueryWrapper);
// 入库位置进行优化
WarehouseStructure
warehouseStructure
=
warehouseStructures
.
stream
().
filter
(
x
->
x
.
getCode
().
equals
(
equipmentDetailDownloadVOS
.
getWarehouseStructCode
())).
collect
(
Collectors
.
toList
()).
get
(
0
);
if
(
warehouseStructure
==
null
)
{
if
(
warehouseStructure
==
null
)
{
erryy
.
append
(
String
.
format
(
"货位编码[%S]填写错误,请输入正确的货位编码!"
,
equipmentDetailDownloadVOS
.
getWarehouseStructCode
())+
","
);
erryy
.
append
(
String
.
format
(
"货位编码[%S]填写错误,请输入正确的货位编码!"
,
equipmentDetailDownloadVOS
.
getWarehouseStructCode
())+
","
);
throw
new
RuntimeException
(
String
.
format
(
"货位编码[%S]填写错误,请输入正确的货位编码!"
,
equipmentDetailDownloadVOS
.
getWarehouseStructCode
()));
throw
new
RuntimeException
(
String
.
format
(
"货位编码[%S]填写错误,请输入正确的货位编码!"
,
equipmentDetailDownloadVOS
.
getWarehouseStructCode
()));
...
@@ -765,6 +797,7 @@ public class StockServiceImpl extends ServiceImpl<StockMapper, Stock> implements
...
@@ -765,6 +797,7 @@ public class StockServiceImpl extends ServiceImpl<StockMapper, Stock> implements
}
}
list
.
add
(
equipmentSpecific
);
list
.
add
(
equipmentSpecific
);
this
.
equipmentSpecificIndexSave
(
equipmentDetail
,
equipmentSpecific
);
this
.
equipmentSpecificIndexSave
(
equipmentDetail
,
equipmentSpecific
);
bizOrgCodes
.
add
(
equipmentSpecific
.
getBizOrgCode
());
platformTransactionManager
.
commit
(
transactionStatus
);
platformTransactionManager
.
commit
(
transactionStatus
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
platformTransactionManager
.
rollback
(
transactionStatus
);
platformTransactionManager
.
rollback
(
transactionStatus
);
...
@@ -780,7 +813,7 @@ public class StockServiceImpl extends ServiceImpl<StockMapper, Stock> implements
...
@@ -780,7 +813,7 @@ public class StockServiceImpl extends ServiceImpl<StockMapper, Stock> implements
//
@Async
@Async
public
void
refreshCount
(
String
bizOrgCode
)
{
public
void
refreshCount
(
String
bizOrgCode
)
{
equipmentSpecificSerivce
.
refreshStaData
();
equipmentSpecificSerivce
.
refreshStaData
();
try
{
try
{
...
...
Write
Preview
Markdown
is supported
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