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
18fb01a2
Commit
18fb01a2
authored
Sep 27, 2023
by
caotao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
优化大屏缓存数据逻辑
parent
7b8750f9
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
62 additions
and
61 deletions
+62
-61
StationCacheInfoDto.java
...n/amos/boot/module/jxiop/biz/dto/StationCacheInfoDto.java
+1
-0
StationCacheDataInit.java
.../boot/module/jxiop/biz/initdata/StationCacheDataInit.java
+31
-30
CommonServiceImpl.java
...boot/module/jxiop/biz/service/impl/CommonServiceImpl.java
+29
-31
StationCacheInfoDto.java
...n/amos/boot/module/jxiop/biz/dto/StationCacheInfoDto.java
+1
-0
No files found.
amos-boot-system-jxiop/amos-boot-module-jxiop-bigscreen-biz/src/main/java/com/yeejoin/amos/boot/module/jxiop/biz/dto/StationCacheInfoDto.java
View file @
18fb01a2
...
@@ -6,6 +6,7 @@ import java.io.Serializable;
...
@@ -6,6 +6,7 @@ import java.io.Serializable;
@Data
@Data
public
class
StationCacheInfoDto
implements
Serializable
{
public
class
StationCacheInfoDto
implements
Serializable
{
private
static
final
long
serialVersionUID
=
1L
;
//场站id
//场站id
private
String
stationId
;
private
String
stationId
;
//场站名称
//场站名称
...
...
amos-boot-system-jxiop/amos-boot-module-jxiop-bigscreen-biz/src/main/java/com/yeejoin/amos/boot/module/jxiop/biz/initdata/StationCacheDataInit.java
View file @
18fb01a2
...
@@ -12,61 +12,62 @@ import com.yeejoin.amos.boot.module.jxiop.biz.dto.QueryDto;
...
@@ -12,61 +12,62 @@ import com.yeejoin.amos.boot.module.jxiop.biz.dto.QueryDto;
import
com.yeejoin.amos.boot.module.jxiop.biz.dto.StationCacheInfoDto
;
import
com.yeejoin.amos.boot.module.jxiop.biz.dto.StationCacheInfoDto
;
import
com.yeejoin.amos.boot.module.jxiop.biz.mapper2.SjglZsjZsbtzMapper
;
import
com.yeejoin.amos.boot.module.jxiop.biz.mapper2.SjglZsjZsbtzMapper
;
import
com.yeejoin.amos.boot.module.jxiop.biz.service.impl.CommonServiceImpl
;
import
com.yeejoin.amos.boot.module.jxiop.biz.service.impl.CommonServiceImpl
;
import
lombok.extern.slf4j.Slf4j
;
import
org.slf4j.Logger
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.boot.CommandLineRunner
;
import
org.springframework.boot.CommandLineRunner
;
import
org.springframework.data.redis.core.RedisTemplate
;
import
org.springframework.data.redis.core.RedisTemplate
;
import
org.springframework.stereotype.Component
;
import
org.springframework.stereotype.Component
;
import
javax.annotation.Resource
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.List
;
import
java.util.stream.Collectors
;
import
java.util.stream.Collectors
;
@Slf4j
@Component
@Component
public
class
StationCacheDataInit
implements
CommandLineRunner
{
public
class
StationCacheDataInit
implements
CommandLineRunner
{
@Autowired
private
StationBasicMapper
stationBasicMapper
;
@Autowired
private
RegionMapper
regionMapper
;
@Autowired
private
MapRegionMapper
mapRegionMapper
;
@Autowired
private
SjglZsjZsbtzMapper
sjglZsjZsbtzMapper
;
@Autowired
private
CommonServiceImpl
commonServiceImpl
;
@Autowired
private
RedisTemplate
redisTemplate
;
Logger
logger
=
LoggerFactory
.
getLogger
(
StationCacheDataInit
.
class
);
Logger
logger
=
LoggerFactory
.
getLogger
(
StationCacheDataInit
.
class
);
@Resource
private
StationBasicMapper
stationBasicMapper
;
@Resource
private
RegionMapper
regionMapper
;
@Resource
private
MapRegionMapper
mapRegionMapper
;
@Resource
private
SjglZsjZsbtzMapper
sjglZsjZsbtzMapper
;
@Resource
private
CommonServiceImpl
commonServiceImpl
;
@Resource
private
RedisTemplate
redisTemplate
;
public
void
run
(
String
...
args
)
throws
Exception
{
public
void
run
(
String
...
args
)
throws
Exception
{
log
.
info
(
"-------------------------------------开始缓存场站基础数据----------------------------
"
);
redisTemplate
.
delete
(
"station_info_cache_bigscreen
"
);
List
<
StationCacheInfoDto
>
stationCacheInfoDtos
=
new
ArrayList
<>();
List
<
StationCacheInfoDto
>
stationCacheInfoDtos
=
new
ArrayList
<>();
redisTemplate
.
delete
(
"station_info_cache"
);
List
<
Region
>
regionList
=
regionMapper
.
selectList
(
new
QueryWrapper
<
Region
>().
eq
(
"LEVEL"
,
1
));
List
<
Region
>
regionList
=
regionMapper
.
selectList
(
new
QueryWrapper
<
Region
>().
eq
(
"LEVEL"
,
1
));
List
<
MapRegion
>
mapRegionList
=
mapRegionMapper
.
selectList
(
new
QueryWrapper
<
MapRegion
>().
isNotNull
(
"name"
));
List
<
MapRegion
>
mapRegionList
=
mapRegionMapper
.
selectList
(
new
QueryWrapper
<
MapRegion
>().
isNotNull
(
"name"
));
List
<
StationBasic
>
stationBasicList
=
stationBasicMapper
.
selectList
(
new
QueryWrapper
<
StationBasic
>().
isNotNull
(
"belong_area"
).
isNotNull
(
"fan_gateway_id"
));
List
<
StationBasic
>
stationBasicList
=
stationBasicMapper
.
selectList
(
new
QueryWrapper
<
StationBasic
>().
isNotNull
(
"belong_area"
).
isNotNull
(
"fan_gateway_id"
));
stationBasicList
.
forEach
(
stationBasic
->
{
stationBasicList
.
forEach
(
stationBasic
->
{
StationCacheInfoDto
stationCacheInfoDto
=
new
StationCacheInfoDto
();
StationCacheInfoDto
stationCacheInfoDto
=
new
StationCacheInfoDto
();
stationCacheInfoDto
.
setStationId
(
stationBasic
.
getSequenceNbr
().
toString
());
stationCacheInfoDto
.
setStationId
(
stationBasic
.
getSequenceNbr
().
toString
());
stationCacheInfoDto
.
setStationName
(
stationBasic
.
getStationName
());
stationCacheInfoDto
.
setStationName
(
stationBasic
.
getStationName
());
stationCacheInfoDto
.
setStationType
(
stationBasic
.
getStationType
());
stationCacheInfoDto
.
setStationType
(
stationBasic
.
getStationType
());
stationCacheInfoDto
.
setBelongProvince
(
regionList
.
stream
().
filter
(
region
->
region
.
getRegionCode
().
toString
().
equals
(
stationBasic
.
getBelongArea
().
replace
(
"["
,
""
).
split
(
","
)[
0
])).
map
(
region
->
region
.
getRegionName
()).
collect
(
Collectors
.
toList
()).
get
(
0
));
stationCacheInfoDto
.
setBelongProvince
(
regionList
.
stream
().
filter
(
region
->
region
.
getRegionCode
().
toString
().
equals
(
stationBasic
.
getBelongArea
().
replace
(
"["
,
""
).
split
(
","
)[
0
])).
map
(
region
->
region
.
getRegionName
()).
collect
(
Collectors
.
toList
()).
get
(
0
));
stationCacheInfoDto
.
setBelongArea
(
mapRegionList
.
stream
().
filter
(
mapRegion
->
mapRegion
.
getProvince
().
contains
(
stationCacheInfoDto
.
getBelongProvince
().
substring
(
0
,
2
))||
mapRegion
.
getProvince
().
contains
(
stationCacheInfoDto
.
getBelongProvince
().
substring
(
0
,
3
))).
map
(
mapRegion
->
mapRegion
.
getName
()).
collect
(
Collectors
.
toList
()).
get
(
0
));
stationCacheInfoDto
.
setBelongArea
(
mapRegionList
.
stream
().
filter
(
mapRegion
->
mapRegion
.
getProvince
().
contains
(
stationCacheInfoDto
.
getBelongProvince
().
substring
(
0
,
2
))
||
mapRegion
.
getProvince
().
contains
(
stationCacheInfoDto
.
getBelongProvince
().
substring
(
0
,
3
))).
map
(
mapRegion
->
mapRegion
.
getName
()).
collect
(
Collectors
.
toList
()).
get
(
0
));
stationCacheInfoDto
.
setAreaCode
(
mapRegionList
.
stream
().
filter
(
mapRegion
->
mapRegion
.
getProvince
().
contains
(
stationCacheInfoDto
.
getBelongProvince
().
substring
(
0
,
2
))||
mapRegion
.
getProvince
().
contains
(
stationCacheInfoDto
.
getBelongProvince
().
substring
(
0
,
3
))).
map
(
mapRegion
->
mapRegion
.
getAreaCode
()).
collect
(
Collectors
.
toList
()).
get
(
0
));
stationCacheInfoDto
.
setInstalledCapacity
(
String
.
format
(
"%.2f"
,
sjglZsjZsbtzMapper
.
getStationCapactityByStationWerks
(
stationBasic
.
getStationNumber
())));
stationCacheInfoDto
.
setInstalledCapacity
(
String
.
format
(
"%.2f"
,
sjglZsjZsbtzMapper
.
getStationCapactityByStationWerks
(
stationBasic
.
getStationNumber
())));
try
{
List
<
QueryDto
>
queryDtoList
=
new
ArrayList
<>();
List
<
QueryDto
>
queryDtoList
=
new
ArrayList
<>();
queryDtoList
.
add
(
new
QueryDto
(
"gatewayId"
,
stationBasic
.
getFanGatewayId
()));
queryDtoList
.
add
(
new
QueryDto
(
"gatewayId"
,
stationBasic
.
getFanGatewayId
()));
queryDtoList
.
add
(
new
QueryDto
(
"equipmentIndexName.keyword"
,
"有功功率"
));
queryDtoList
.
add
(
new
QueryDto
(
"equipmentIndexName.keyword"
,
"有功功率"
));
if
(!
stationBasic
.
getStationType
().
equals
(
"FDZ"
)){
if
(!
stationBasic
.
getStationType
().
equals
(
"FDZ"
))
{
queryDtoList
.
add
(
new
QueryDto
(
"frontModule"
,
"逆变器"
));
queryDtoList
.
add
(
new
QueryDto
(
"frontModule"
,
"逆变器"
));
}
stationCacheInfoDto
.
setEquipmentNumbers
(
commonServiceImpl
.
getCount
(
queryDtoList
,
"equipmentNumber.Keyword"
,
ESEquipments
.
class
).
toString
());
}
catch
(
Exception
exception
)
{
logger
.
info
(
"--------------------查询ES错误---------------------------"
);
}
}
stationCacheInfoDto
.
setEquipmentNumbers
(
commonServiceImpl
.
getCount
(
queryDtoList
,
"equipmentNumber.Keyword"
,
ESEquipments
.
class
).
toString
());
stationCacheInfoDto
.
setFanGatewayId
(
stationBasic
.
getFanGatewayId
());
stationCacheInfoDto
.
setFanGatewayId
(
stationBasic
.
getFanGatewayId
());
stationCacheInfoDto
.
setBoosterGatewayId
(
stationBasic
.
getBoosterGatewayId
());
stationCacheInfoDto
.
setBoosterGatewayId
(
stationBasic
.
getBoosterGatewayId
());
stationCacheInfoDtos
.
add
(
stationCacheInfoDto
);
stationCacheInfoDtos
.
add
(
stationCacheInfoDto
);
});
});
redisTemplate
.
opsForList
().
leftPushAll
(
"station_info_cache"
,
stationCacheInfoDtos
);
redisTemplate
.
opsForList
().
leftPushAll
(
"station_info_cache_bigscreen"
,
stationCacheInfoDtos
);
log
.
info
(
"-------------------------------------结束缓存场站基础数据----------------------------"
);
}
}
}
}
amos-boot-system-jxiop/amos-boot-module-jxiop-bigscreen-biz/src/main/java/com/yeejoin/amos/boot/module/jxiop/biz/service/impl/CommonServiceImpl.java
View file @
18fb01a2
...
@@ -163,41 +163,39 @@ public class CommonServiceImpl {
...
@@ -163,41 +163,39 @@ public class CommonServiceImpl {
return
socialContributionDtoPage
;
return
socialContributionDtoPage
;
}
}
public
List
<
StationCacheInfoDto
>
getListStationCacheInfoDto
()
{
public
List
<
StationCacheInfoDto
>
getListStationCacheInfoDto
()
{
List
<
StationCacheInfoDto
>
stationCacheInfoDto
List
=
redisTemplate
.
opsForList
().
range
(
"station_info_cache"
,
0
,-
1
);
List
<
StationCacheInfoDto
>
stationCacheInfoDto
s
=
new
ArrayList
<>(
);
if
(
ObjectUtils
.
isEmpty
(
stationCacheInfoDtoList
)){
stationCacheInfoDtos
=
redisTemplate
.
opsForList
().
range
(
"station_info_cache_bigscreen"
,
0
,
-
1
);
try
{
if
(
ObjectUtils
.
isEmpty
(
stationCacheInfoDtos
))
{
List
<
StationCacheInfoDto
>
stationCacheInfoDtos
=
new
ArrayList
<>(
);
List
<
Region
>
regionList
=
regionMapper
.
selectList
(
new
QueryWrapper
<
Region
>().
eq
(
"LEVEL"
,
1
)
);
List
<
Region
>
regionList
=
regionMapper
.
selectList
(
new
QueryWrapper
<
Region
>().
eq
(
"LEVEL"
,
1
));
List
<
MapRegion
>
mapRegionList
=
mapRegionMapper
.
selectList
(
new
QueryWrapper
<
MapRegion
>().
isNotNull
(
"name"
));
List
<
MapRegion
>
mapRegionList
=
mapRegionMapper
.
selectList
(
new
QueryWrapper
<
MapRegion
>().
isNotNull
(
"name
"
));
List
<
StationBasic
>
stationBasicList
=
stationBasicMapper
.
selectList
(
new
QueryWrapper
<
StationBasic
>().
isNotNull
(
"belong_area"
).
isNotNull
(
"fan_gateway_id
"
));
List
<
StationBasic
>
stationBasicList
=
stationBasicMapper
.
selectList
(
new
QueryWrapper
<
StationBasic
>().
isNotNull
(
"belong_area"
).
isNotNull
(
"fan_gateway_id"
));
for
(
int
i
=
0
;
i
<
stationBasicList
.
size
();
i
++)
{
stationBasicList
.
forEach
(
stationBasic
->
{
StationBasic
stationBasic
=
stationBasicList
.
get
(
i
);
StationCacheInfoDto
stationCacheInfoDto
=
new
StationCacheInfoDto
();
StationCacheInfoDto
stationCacheInfoDto
=
new
StationCacheInfoDto
();
stationCacheInfoDto
.
setStationId
(
stationBasic
.
getSequenceNbr
().
toString
());
stationCacheInfoDto
.
setStationId
(
stationBasic
.
getSequenceNbr
().
toString
());
stationCacheInfoDto
.
setStationName
(
stationBasic
.
getStationName
());
stationCacheInfoDto
.
setStationName
(
stationBasic
.
getStationName
());
stationCacheInfoDto
.
setStationType
(
stationBasic
.
getStationType
());
stationCacheInfoDto
.
setStationType
(
stationBasic
.
getStationType
());
stationCacheInfoDto
.
setBelongProvince
(
regionList
.
stream
().
filter
(
region
->
region
.
getRegionCode
().
toString
().
equals
(
stationBasic
.
getBelongArea
().
replace
(
"["
,
""
).
split
(
","
)[
0
])).
map
(
region
->
region
.
getRegionName
()).
collect
(
Collectors
.
toList
()).
get
(
0
));
stationCacheInfoDto
.
setBelongProvince
(
regionList
.
stream
().
filter
(
region
->
region
.
getRegionCode
().
toString
().
equals
(
stationBasic
.
getBelongArea
().
replace
(
"["
,
""
).
split
(
","
)[
0
])).
map
(
region
->
region
.
getRegionName
()).
collect
(
Collectors
.
toList
()).
get
(
0
));
stationCacheInfoDto
.
setBelongArea
(
mapRegionList
.
stream
().
filter
(
mapRegion
->
mapRegion
.
getProvince
().
contains
(
stationCacheInfoDto
.
getBelongProvince
().
substring
(
0
,
2
))||
mapRegion
.
getProvince
().
contains
(
stationCacheInfoDto
.
getBelongProvince
().
substring
(
0
,
3
))).
map
(
mapRegion
->
mapRegion
.
getName
()).
collect
(
Collectors
.
toList
()).
get
(
0
));
stationCacheInfoDto
.
setBelongArea
(
mapRegionList
.
stream
().
filter
(
mapRegion
->
mapRegion
.
getProvince
().
contains
(
stationCacheInfoDto
.
getBelongProvince
().
substring
(
0
,
2
))
||
mapRegion
.
getProvince
().
contains
(
stationCacheInfoDto
.
getBelongProvince
().
substring
(
0
,
3
))).
map
(
mapRegion
->
mapRegion
.
getName
()).
collect
(
Collectors
.
toList
()).
get
(
0
));
stationCacheInfoDto
.
setAreaCode
(
mapRegionList
.
stream
().
filter
(
mapRegion
->
mapRegion
.
getProvince
().
contains
(
stationCacheInfoDto
.
getBelongProvince
().
substring
(
0
,
2
))||
mapRegion
.
getProvince
().
contains
(
stationCacheInfoDto
.
getBelongProvince
().
substring
(
0
,
3
))).
map
(
mapRegion
->
mapRegion
.
getAreaCode
()).
collect
(
Collectors
.
toList
()).
get
(
0
));
stationCacheInfoDto
.
setInstalledCapacity
(
String
.
format
(
"%.2f"
,
sjglZsjZsbtzMapper
.
getStationCapactityByStationWerks
(
stationBasic
.
getStationNumber
())
));
stationCacheInfoDto
.
setInstalledCapacity
(
String
.
format
(
"%.2f"
,
sjglZsjZsbtzMapper
.
getStationCapactityByStationWerks
(
stationBasic
.
getStationNumber
())));
try
{
List
<
QueryDto
>
queryDtoList
=
new
ArrayList
<>();
List
<
QueryDto
>
queryDtoList
=
new
ArrayList
<>();
queryDtoList
.
add
(
new
QueryDto
(
"gatewayId"
,
stationBasic
.
getFanGatewayId
()));
queryDtoList
.
add
(
new
QueryDto
(
"gatewayId"
,
stationBasic
.
getFanGatewayId
()));
queryDtoList
.
add
(
new
QueryDto
(
"equipmentIndexName.keyword"
,
"有功功率"
));
queryDtoList
.
add
(
new
QueryDto
(
"equipmentIndexName.keyword"
,
"有功功率"
));
if
(!
stationBasic
.
getStationType
().
equals
(
"FDZ"
))
{
if
(!
stationBasic
.
getStationType
().
equals
(
"FDZ"
))
{
queryDtoList
.
add
(
new
QueryDto
(
"frontModule"
,
"逆变器"
));
queryDtoList
.
add
(
new
QueryDto
(
"frontModule"
,
"逆变器"
));
}
}
stationCacheInfoDto
.
setEquipmentNumbers
(
this
.
getCount
(
queryDtoList
,
"equipmentNumber.Keyword"
,
ESEquipments
.
class
).
toString
());
stationCacheInfoDto
.
setEquipmentNumbers
(
getCount
(
queryDtoList
,
"equipmentNumber.Keyword"
,
ESEquipments
.
class
).
toString
());
stationCacheInfoDto
.
setFanGatewayId
(
stationBasic
.
getFanGatewayId
());
}
catch
(
Exception
exception
)
{
stationCacheInfoDto
.
setBoosterGatewayId
(
stationBasic
.
getBoosterGatewayId
());
}
stationCacheInfoDtos
.
add
(
stationCacheInfoDto
);
stationCacheInfoDto
.
setFanGatewayId
(
stationBasic
.
getFanGatewayId
());
});
stationCacheInfoDto
.
setBoosterGatewayId
(
stationBasic
.
getBoosterGatewayId
());
redisTemplate
.
opsForList
().
leftPushAll
(
"station_info_cache"
,
stationCacheInfoDtos
);
stationCacheInfoDtos
.
add
(
stationCacheInfoDto
);
return
stationCacheInfoDtos
;
}
catch
(
Exception
e
)
{
throw
new
RuntimeException
(
e
);
}
}
redisTemplate
.
opsForList
().
leftPushAll
(
"station_info_cache_bigscreen"
,
stationCacheInfoDtos
);
}
}
return
stationCacheInfoDto
List
;
return
stationCacheInfoDto
s
;
}
}
...
...
amos-boot-system-jxiop/amos-boot-module-jxiop-monitor-biz/src/main/java/com/yeejoin/amos/boot/module/jxiop/biz/dto/StationCacheInfoDto.java
View file @
18fb01a2
...
@@ -6,6 +6,7 @@ import java.io.Serializable;
...
@@ -6,6 +6,7 @@ import java.io.Serializable;
@Data
@Data
public
class
StationCacheInfoDto
implements
Serializable
{
public
class
StationCacheInfoDto
implements
Serializable
{
private
static
final
long
serialVersionUID
=
1L
;
//场站id
//场站id
private
String
stationId
;
private
String
stationId
;
//场站名称
//场站名称
...
...
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