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
a2bbd1eb
Commit
a2bbd1eb
authored
Jan 12, 2022
by
suhuiguang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1.分类树缓存刷新修改
parent
0912a7f1
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
51 additions
and
22 deletions
+51
-22
CarController.java
...ava/com/yeejoin/equipmanage/controller/CarController.java
+3
-5
ApplicationRunnerImpl.java
...ejoin/equipmanage/service/impl/ApplicationRunnerImpl.java
+18
-1
CarServiceImpl.java
.../com/yeejoin/equipmanage/service/impl/CarServiceImpl.java
+2
-2
EquipmentSpecificSerivceImpl.java
...quipmanage/service/impl/EquipmentSpecificSerivceImpl.java
+1
-1
FireFightingSystemServiceImpl.java
...uipmanage/service/impl/FireFightingSystemServiceImpl.java
+10
-8
SourcesStatisticsImpl.java
...ejoin/equipmanage/service/impl/SourcesStatisticsImpl.java
+17
-5
No files found.
amos-boot-module/amos-boot-module-biz/amos-boot-module-equip-biz/src/main/java/com/yeejoin/equipmanage/controller/CarController.java
View file @
a2bbd1eb
...
...
@@ -240,12 +240,10 @@ public class CarController extends AbstractBaseController {
@Async
public
void
refreshCount
(
String
bizOrgCode
)
{
// 刷新分类数量缓存
iCarService
.
refreshStaData
();
try
{
fireFightingSystemServiceImpl
.
refreshCarTypeAndCount
(
bizOrgCode
);
}
catch
(
Exception
e
)
{
}
// 刷新分类树缓存
fireFightingSystemServiceImpl
.
refreshCarTypeAndCount
(
bizOrgCode
);
}
@Async
public
void
refreshCount
(
List
<
Car
>
list
)
{
...
...
amos-boot-module/amos-boot-module-biz/amos-boot-module-equip-biz/src/main/java/com/yeejoin/equipmanage/service/impl/ApplicationRunnerImpl.java
View file @
a2bbd1eb
package
com
.
yeejoin
.
equipmanage
.
service
.
impl
;
import
com.yeejoin.amos.boot.biz.common.utils.RedisUtils
;
import
com.yeejoin.equipmanage.common.enums.ConfigPageTopicEnum
;
import
com.yeejoin.equipmanage.listener.IntegratePageDataListener
;
import
com.yeejoin.equipmanage.service.IMaintenanceResourceDataService
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.boot.ApplicationArguments
;
import
org.springframework.boot.ApplicationRunner
;
import
org.springframework.stereotype.Component
;
...
...
@@ -29,9 +31,24 @@ public class ApplicationRunnerImpl implements ApplicationRunner {
@Autowired
IntegratePageDataListener
integratePageDataListener
;
@Autowired
RedisUtils
redisUtils
;
@Value
(
"${redis_car_type_count}"
)
private
String
carTypeAndCount
;
@Value
(
"${redis_equip_type_count}"
)
private
String
equipTypeAndCount
;
@Override
public
void
run
(
ApplicationArguments
args
)
throws
Exception
{
// 清空装备分类树缓存
redisUtils
.
getAndDeletePatternKeys
(
carTypeAndCount
+
"*"
);
// 清空车辆分类树缓存
redisUtils
.
getAndDeletePatternKeys
(
equipTypeAndCount
+
"*"
);
// 清空单位分类数量统计缓存
redisUtils
.
getAndDeletePatternKeys
(
SourcesStatisticsImpl
.
PREFIX_CATEGORY_COUNT
+
"*"
);
maintenanceResourceDataService
.
subscribeTopic
();
emqKeeper
.
getMqttClient
().
subscribe
(
ConfigPageTopicEnum
.
INTEGRATE
.
getTopic
(),
2
,
integratePageDataListener
);
emqKeeper
.
getMqttClient
().
subscribe
(
ConfigPageTopicEnum
.
INTEGRATE
.
getTopic
(),
2
,
integratePageDataListener
);
}
}
amos-boot-module/amos-boot-module-biz/amos-boot-module-equip-biz/src/main/java/com/yeejoin/equipmanage/service/impl/CarServiceImpl.java
View file @
a2bbd1eb
...
...
@@ -1620,10 +1620,10 @@ public class CarServiceImpl extends ServiceImpl<CarMapper, Car> implements ICarS
@Override
public
void
refreshStaData
()
{
List
<
Map
<
String
,
Object
>>
result
=
this
.
baseMapper
.
queryCompanyCarStaData
();
result
.
forEach
(
m
->
redisUtils
.
set
((
buildKey
(
m
)),
m
.
get
(
"total"
),
86400
));
result
.
forEach
(
m
->
redisUtils
.
set
((
buildKey
(
m
)),
m
.
get
(
"total"
),
86400
));
}
private
String
buildKey
(
Map
<
String
,
Object
>
row
)
{
return
row
.
get
(
"bizOrgCode"
).
toString
()
+
"_"
+
SourceTypeEnum
.
CAR
.
getCode
()
+
"_"
+
row
.
get
(
"categoryCode"
).
toString
();
return
SourcesStatisticsImpl
.
PREFIX_CATEGORY_COUNT
+
row
.
get
(
"bizOrgCode"
).
toString
()
+
"_"
+
SourceTypeEnum
.
CAR
.
getCode
()
+
"_"
+
row
.
get
(
"categoryCode"
).
toString
();
}
}
amos-boot-module/amos-boot-module-biz/amos-boot-module-equip-biz/src/main/java/com/yeejoin/equipmanage/service/impl/EquipmentSpecificSerivceImpl.java
View file @
a2bbd1eb
...
...
@@ -1595,7 +1595,7 @@ public class EquipmentSpecificSerivceImpl extends ServiceImpl<EquipmentSpecificM
}
private
String
buildKey
(
Map
<
String
,
Object
>
row
)
{
return
row
.
get
(
"bizOrgCode"
).
toString
()
+
"_"
+
SourceTypeEnum
.
EQUIPMENT
.
getCode
()
+
"_"
+
row
.
get
(
"categoryCode"
).
toString
();
return
SourcesStatisticsImpl
.
PREFIX_CATEGORY_COUNT
+
row
.
get
(
"bizOrgCode"
).
toString
()
+
"_"
+
SourceTypeEnum
.
EQUIPMENT
.
getCode
()
+
"_"
+
row
.
get
(
"categoryCode"
).
toString
();
}
}
amos-boot-module/amos-boot-module-biz/amos-boot-module-equip-biz/src/main/java/com/yeejoin/equipmanage/service/impl/FireFightingSystemServiceImpl.java
View file @
a2bbd1eb
...
...
@@ -1010,16 +1010,17 @@ public class FireFightingSystemServiceImpl extends ServiceImpl<FireFightingSyste
return
Collections
.
singletonList
(
parentNode
);
}
public
Object
getEquipmentTypeAndCount
(
String
bizOrgCode
)
throws
Exception
{
@Override
public
Object
getEquipmentTypeAndCount
(
String
bizOrgCode
)
{
if
(
redisUtils
.
hasKey
(
equipTypeAndCount
+
bizOrgCode
))
{
List
<
EquipmentCategory
>
typeList
=
JSONArray
.
parseArray
(
return
JSONArray
.
parseArray
(
JSONArray
.
toJSONString
(
redisUtils
.
get
(
equipTypeAndCount
+
bizOrgCode
)),
EquipmentCategory
.
class
);
return
typeList
;
}
else
{
return
refreshEquipmentTypeAndCount
(
bizOrgCode
);
}
}
public
Object
refreshEquipmentTypeAndCount
(
String
bizOrgCode
)
throws
Exception
{
@Override
public
Object
refreshEquipmentTypeAndCount
(
String
bizOrgCode
)
{
List
<
EquipmentCategory
>
responseList
=
this
.
typeList
();
if
(
responseList
==
null
||
responseList
.
size
()
<
1
)
{
return
null
;
...
...
@@ -1028,21 +1029,22 @@ public class FireFightingSystemServiceImpl extends ServiceImpl<FireFightingSyste
.
filter
(
i
->
!
i
.
getCode
().
startsWith
(
"2"
)
&&
"2"
.
equals
(
i
.
getIndustryCode
()))
.
collect
(
Collectors
.
toList
());
List
<
EquipmentCategory
>
list
=
typeListTree
(
equipmentTypeList
,
bizOrgCode
,
SourceTypeEnum
.
EQUIPMENT
);
redisUtils
.
set
(
equipTypeAndCount
+
bizOrgCode
,
list
);
redisUtils
.
set
(
equipTypeAndCount
+
bizOrgCode
,
list
,
86400
);
return
list
;
}
public
Object
getCarTypeAndCount
(
String
bizOrgCode
)
throws
Exception
{
@Override
public
Object
getCarTypeAndCount
(
String
bizOrgCode
)
{
if
(
redisUtils
.
hasKey
(
carTypeAndCount
+
bizOrgCode
))
{
List
<
EquipmentCategory
>
typeList
=
JSONArray
.
parseArray
(
JSONArray
.
toJSONString
(
redisUtils
.
get
(
carTypeAndCount
+
bizOrgCode
)),
EquipmentCategory
.
class
);
return
typeList
;
}
else
{
return
refreshCarTypeAndCount
(
bizOrgCode
);
}
}
public
Object
refreshCarTypeAndCount
(
String
bizOrgCode
)
throws
Exception
{
@Override
public
Object
refreshCarTypeAndCount
(
String
bizOrgCode
)
{
List
<
EquipmentCategory
>
responseList
=
this
.
typeList
();
if
(
responseList
==
null
||
responseList
.
size
()
<
1
)
{
return
null
;
...
...
amos-boot-module/amos-boot-module-biz/amos-boot-module-equip-biz/src/main/java/com/yeejoin/equipmanage/service/impl/SourcesStatisticsImpl.java
View file @
a2bbd1eb
...
...
@@ -2,8 +2,6 @@ package com.yeejoin.equipmanage.service.impl;
import
com.yeejoin.amos.boot.biz.common.utils.RedisUtils
;
import
com.yeejoin.equipmanage.common.enums.SourceTypeEnum
;
import
com.yeejoin.equipmanage.service.ICarService
;
import
com.yeejoin.equipmanage.service.IEquipmentDetailService
;
import
com.yeejoin.equipmanage.service.ISourceStatistics
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
...
...
@@ -21,12 +19,14 @@ public class SourcesStatisticsImpl implements ISourceStatistics {
@Autowired
private
RedisUtils
redisUtil
;
public
static
String
PREFIX_CATEGORY_COUNT
=
"CATEGORY_COUNT_"
;
@Override
public
int
equipCategoryStatistics
(
String
bizOrgCode
,
SourceTypeEnum
sourceType
,
String
categoryCode
)
{
// 计算处通用code,用来上下级匹配如12001010000->1200101
String
treeCode
=
subStringZero
(
categoryCode
);
Set
<
String
>
keys
=
redisUtil
.
getKeys
(
buildKey
(
bizOrgCode
,
sourceType
.
getCode
(),
treeCode
));
Set
<
String
>
keys
=
redisUtil
.
getKeys
(
build
Patten
Key
(
bizOrgCode
,
sourceType
.
getCode
(),
treeCode
));
if
(
keys
.
size
()
>
0
)
{
//求和
return
this
.
sumNumber
(
keys
);
...
...
@@ -43,10 +43,18 @@ public class SourcesStatisticsImpl implements ISourceStatistics {
}
}
}
return
this
.
sumNumber
(
keys
);
return
this
.
sumNumber
AndInitRedis
(
bizOrgCode
,
sourceType
,
treeCode
,
keys
);
}
}
private
int
sumNumberAndInitRedis
(
String
bizOrgCode
,
SourceTypeEnum
sourceType
,
String
treeCode
,
Set
<
String
>
keys
)
{
int
result
=
this
.
sumNumber
(
keys
);
if
(
result
==
0
){
redisUtil
.
set
(
buildKey
(
bizOrgCode
,
sourceType
.
getCode
(),
treeCode
),
0
,
86400
);
}
return
result
;
}
private
int
sumNumber
(
Set
<
String
>
keys
)
{
return
keys
.
stream
().
filter
(
k
->
redisUtil
.
get
(
k
)
!=
null
).
mapToInt
(
k
->
Integer
.
parseInt
(
redisUtil
.
get
(
k
).
toString
())).
sum
();
}
...
...
@@ -57,7 +65,11 @@ public class SourcesStatisticsImpl implements ISourceStatistics {
return
new
StringBuffer
(
String
.
valueOf
(
noZero
)).
reverse
().
toString
();
}
private
String
buildPattenKey
(
String
bizOrgCode
,
String
sourceType
,
String
treeCode
)
{
return
PREFIX_CATEGORY_COUNT
+
bizOrgCode
+
"*_"
+
sourceType
+
"_"
+
treeCode
+
"*"
;
}
private
String
buildKey
(
String
bizOrgCode
,
String
sourceType
,
String
treeCode
)
{
return
bizOrgCode
+
"*_"
+
sourceType
+
"_"
+
treeCode
+
"*"
;
return
PREFIX_CATEGORY_COUNT
+
bizOrgCode
+
"_"
+
sourceType
+
"_"
+
treeCode
;
}
}
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