Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
amos-boot-zx-biz
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
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
Jobs
Commits
Open sidebar
项目统一框架
一体化_户用光伏项目代码
amos-boot-zx-biz
Commits
25c1b88a
Commit
25c1b88a
authored
Aug 13, 2024
by
wujiang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改生成指数问题
parent
779ac0bc
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
274 additions
and
58 deletions
+274
-58
AmosJxiopAnalyseApplication.java
...in/java/com/yeejoin/amos/AmosJxiopAnalyseApplication.java
+6
-3
TDBigScreenAnalyseController.java
...le/jxiop/biz/controller/TDBigScreenAnalyseController.java
+2
-2
TdInfoQueryController.java
...ot/module/jxiop/biz/controller/TdInfoQueryController.java
+192
-1
SyncESDataToTdengineMqttListener.java
.../jxiop/biz/listener/SyncESDataToTdengineMqttListener.java
+69
-51
CommonServiceImpl.java
...boot/module/jxiop/biz/service/impl/CommonServiceImpl.java
+0
-0
application-kingbase8.properties
...e-biz/src/main/resources/application-kingbase8.properties
+1
-1
FanHealthIndex.xml
...iz/src/main/resources/mapper/tdengine2/FanHealthIndex.xml
+2
-0
PvHealthIndex.xml
...biz/src/main/resources/mapper/tdengine2/PvHealthIndex.xml
+2
-0
No files found.
amos-boot-system-jxiop/amos-boot-module-jxiop-analyse-biz/src/main/java/com/yeejoin/amos/AmosJxiopAnalyseApplication.java
View file @
25c1b88a
...
...
@@ -24,11 +24,13 @@ import org.springframework.context.ConfigurableApplicationContext;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.ComponentScan
;
import
org.springframework.context.annotation.FilterType
;
import
org.springframework.core.env.Environment
;
import
org.springframework.scheduling.annotation.EnableAsync
;
import
org.springframework.scheduling.annotation.EnableScheduling
;
import
org.springframework.transaction.annotation.EnableTransactionManagement
;
import
org.typroject.tyboot.component.emq.EmqKeeper
;
import
org.typroject.tyboot.core.restful.exception.GlobalExceptionHandler
;
import
java.net.InetAddress
;
...
...
@@ -52,7 +54,8 @@ import java.net.InetAddress;
"com.yeejoin.amos.boot.module.**.api.mapper"
,
"com.yeejoin.amos.boot.biz.common.dao.mapper"
,
"com.yeejoin.amos.boot.module.common.biz.*"
,
"com.yeejoin.amos.boot.module.jxiop.api.mapper"
,
"com.yeejoin.amos.boot.module.jxiop.biz.tdmapper"
,
"com.yeejoin.amos.boot.module.jxiop.biz.mapper5"
})
@ComponentScan
(
basePackages
=
{
"org.typroject"
,
"com.yeejoin.amos"
})
@ComponentScan
(
basePackages
=
{
"org.typroject"
,
"com.yeejoin.amos"
},
excludeFilters
=
@ComponentScan
.
Filter
(
type
=
FilterType
.
ASSIGNABLE_TYPE
,
classes
=
{
GlobalExceptionHandler
.
class
}))
@SpringBootApplication
(
exclude
=
{
DataSourceAutoConfiguration
.
class
,
DruidDataSourceAutoConfigure
.
class
})
//@SpringBootApplication
public
class
AmosJxiopAnalyseApplication
{
...
...
@@ -86,8 +89,8 @@ public class AmosJxiopAnalyseApplication {
return
;
}
// 订阅固化周期性数据成功的消息
emqKeeper
.
subscript
(
"sync_esdata_to_tdengine_notice"
,
1
,
syncESDataToTdengineMqttListener
);
emqKeeper
.
subscript
(
"sync_esdata_to_tdengine_notice
1
"
,
1
,
syncESDataToTdengineMqttListener
);
// 订阅业务固化同步数据成功消息
emqKeeper
.
subscript
(
"sync_iotdata_to_tdengine_notice"
,
1
,
syncDasSuccessMqttListener
);
//
emqKeeper.subscript("sync_iotdata_to_tdengine_notice", 1, syncDasSuccessMqttListener);
}
}
amos-boot-system-jxiop/amos-boot-module-jxiop-analyse-biz/src/main/java/com/yeejoin/amos/boot/module/jxiop/biz/controller/TDBigScreenAnalyseController.java
View file @
25c1b88a
...
...
@@ -1863,13 +1863,13 @@ public class TDBigScreenAnalyseController extends BaseController implements Appl
@Override
public
void
run
(
ApplicationArguments
args
)
throws
Exception
{
initStationFirstSelect
();
//
initStationFirstSelect();
}
/**
* 初始化场站第一个选中
*/
@Scheduled
(
cron
=
"0 */
3
* * * ?"
)
@Scheduled
(
cron
=
"0 */
10
* * * ?"
)
public
void
initStationFirstSelect
()
{
List
<
StationBasicDto
>
stationBasicDtos
=
stationBasicMapper
.
getStationBasicList
();
if
(
CollectionUtil
.
isNotEmpty
(
stationBasicDtos
)){
...
...
amos-boot-system-jxiop/amos-boot-module-jxiop-analyse-biz/src/main/java/com/yeejoin/amos/boot/module/jxiop/biz/controller/TdInfoQueryController.java
View file @
25c1b88a
...
...
@@ -85,6 +85,99 @@ public class TdInfoQueryController extends BaseController {
@TycloudOperation
(
ApiLevel
=
UserType
.
AGENCY
,
needAuth
=
false
)
@PostMapping
(
value
=
"/getFanHealthIndexInfoOld"
)
@ApiOperation
(
httpMethod
=
"POST"
,
value
=
"分页查询健康指数信息 - 风电"
,
notes
=
"分页查询健康指数信息 - 风电"
)
@GatewayIdAutowired
public
ResponseModel
<
Page
<
FanHealthIndex
>>
getFanHealthIndexInfoOld
(
@RequestBody
FanHealthIndexDto
dto
)
throws
ParseException
{
ReginParams
reginParams
=
getSelectedOrgInfo
();
String
userId
=
reginParams
.
getUserModel
().
getUserId
();
StdUserEmpower
stdUserEmpower
=
userEmpowerMapper
.
selectOne
(
new
QueryWrapper
<
StdUserEmpower
>().
eq
(
"amos_user_id"
,
userId
).
eq
(
"permission_type"
,
"YTH"
));
String
orgCode
=
"86"
+
"%"
;
if
(!
ObjectUtils
.
isEmpty
(
stdUserEmpower
))
{
orgCode
=
stdUserEmpower
.
getAmosOrgCode
().
get
(
0
)+
"%"
;
}
dto
.
setOrgCode
(
orgCode
);
Date
currentDate
=
new
Date
();
if
(
CharSequenceUtil
.
isNotEmpty
(
dto
.
getStartDate
()))
{
String
startDate
=
dto
.
getStartDate
();
if
(
dto
.
getAnalysisType
()
!=
null
&&
dto
.
getAnalysisType
().
equals
(
"按天"
)
&&
startDate
.
length
()
==
10
)
{
Date
date
=
DateUtils
.
dateParse
(
startDate
+
" 00:00:00"
,
DATE_TIME_PATTERN
);
dto
.
setStartDate
(
DateUtils
.
dateFormat
(
DateUtils
.
dateAddHours
(
date
,
0
),
DATE_TIME_PATTERN
));
}
else
if
(
dto
.
getAnalysisType
()
!=
null
&&
dto
.
getAnalysisType
().
equals
(
"按小时"
)
&&
startDate
.
length
()
==
13
)
{
Date
date
=
DateUtils
.
dateParse
(
startDate
+
":00:00"
,
DATE_TIME_PATTERN
);
dto
.
setStartDate
(
DateUtils
.
dateFormat
(
DateUtils
.
dateAddHours
(
date
,
-
9
),
DATE_TIME_PATTERN
));
}
else
if
(
dto
.
getAnalysisType
()
!=
null
&&
dto
.
getAnalysisType
().
equals
(
"按10分钟"
)
&&
startDate
.
length
()
==
16
)
{
StringBuilder
newStartDate
=
new
StringBuilder
(
startDate
);
int
number
=
0
;
if
((
newStartDate
.
charAt
(
15
)
-
'0'
)
>
0
)
{
number
=
9
;
}
newStartDate
.
replace
(
15
,
16
,
number
+
""
);
Date
startDateDate
=
DateUtils
.
dateParse
(
newStartDate
+
":00"
,
DATE_TIME_PATTERN
);
dto
.
setStartDate
(
DateUtils
.
dateFormat
(
DateUtils
.
dateAddHours
(
startDateDate
,
-
8
),
DATE_TIME_PATTERN
));
}
else
{
Date
date
=
DateUtils
.
dateParse
(
startDate
,
DATE_TIME_PATTERN
);
dto
.
setStartDate
(
DateUtils
.
dateFormat
(
DateUtils
.
dateAddHours
(
date
,
-
8
),
DATE_TIME_PATTERN
));
}
}
if
(
CharSequenceUtil
.
isNotEmpty
(
dto
.
getEndDate
()))
{
String
endDate
=
dto
.
getEndDate
();
if
(
dto
.
getAnalysisType
()
!=
null
&&
dto
.
getAnalysisType
().
equals
(
"按天"
)
&&
endDate
.
length
()
==
10
)
{
Date
endDateDate
=
DateUtils
.
dateParse
(
endDate
+
" 23:59:59"
,
DATE_TIME_PATTERN
);
dto
.
setEndDate
(
DateUtils
.
dateFormat
(
DateUtils
.
dateAddHours
(
endDateDate
,
0
),
DATE_TIME_PATTERN
));
}
else
if
(
dto
.
getAnalysisType
()
!=
null
&&
dto
.
getAnalysisType
().
equals
(
"按小时"
)
&&
endDate
.
length
()
==
13
)
{
Date
endDateDate
=
DateUtils
.
dateParse
(
endDate
+
":59:59"
,
DATE_TIME_PATTERN
);
dto
.
setEndDate
(
DateUtils
.
dateFormat
(
DateUtils
.
dateAddHours
(
endDateDate
,
-
9
),
DATE_TIME_PATTERN
));
}
else
if
(
dto
.
getAnalysisType
()
!=
null
&&
dto
.
getAnalysisType
().
equals
(
"按10分钟"
)
&&
endDate
.
length
()
==
16
)
{
StringBuilder
newEndDate
=
new
StringBuilder
(
endDate
);
newEndDate
.
replace
(
15
,
16
,
"9"
);
Date
endDateDate
=
DateUtils
.
dateParse
(
newEndDate
+
":59"
,
DATE_TIME_PATTERN
);
dto
.
setEndDate
(
DateUtils
.
dateFormat
(
DateUtils
.
dateAddHours
(
endDateDate
,
-
8
),
DATE_TIME_PATTERN
));
}
else
{
Date
endDateDate
=
DateUtils
.
dateParse
(
endDate
,
"yyyy-MM-dd HH:mm:ss"
);
dto
.
setEndDate
(
DateUtils
.
dateFormat
(
DateUtils
.
dateAddHours
(
endDateDate
,
-
8
),
DATE_TIME_PATTERN
));
}
}
Page
<
FanHealthIndex
>
resultPage
=
new
Page
<>(
dto
.
getCurrent
(),
dto
.
getSize
());
dto
.
setCurrent
((
dto
.
getCurrent
()
-
1
)
*
dto
.
getSize
());
if
(
CharSequenceUtil
.
isNotEmpty
(
dto
.
getSortsString
()))
{
ObjectMapper
objectMapper
=
new
ObjectMapper
();
try
{
List
<
Map
<
String
,
String
>>
list
=
objectMapper
.
readValue
(
dto
.
getSortsString
(),
new
TypeReference
<
List
<
Map
<
String
,
String
>>>(){});
dto
.
setSorts
(
list
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
}
List
<
Map
<
String
,
String
>>
orderWeight
=
dto
.
getSorts
().
stream
().
sorted
(
Comparator
.
comparing
(
t
->
Integer
.
parseInt
(
t
.
get
(
"orderWeight"
)))).
collect
(
Collectors
.
toList
());
List
<
String
>
orderByList
=
new
ArrayList
<>();
for
(
Map
<
String
,
String
>
map
:
orderWeight
)
{
String
replace
=
map
.
get
(
"order"
).
replace
(
"end"
,
""
);
String
columnOrder
=
convert
(
map
.
get
(
"columnKey"
))
+
" "
+
replace
;
orderByList
.
add
(
columnOrder
);
}
String
join
=
String
.
join
(
","
,
orderByList
);
dto
.
setOrderColumns
(
join
);
if
(
CharSequenceUtil
.
isNotEmpty
(
dto
.
getSortOne
()))
{
String
[]
split
=
dto
.
getSortOne
().
split
(
","
);
String
replace
=
split
[
1
].
replace
(
"end"
,
""
);
String
orderColumn
=
convert
(
split
[
0
])
+
" "
+
replace
;
dto
.
setSortOne
(
orderColumn
);
}
List
<
FanHealthIndex
>
fanHealthIndexIPage
=
fanHealthIndexMapper
.
getInfoByPage
(
dto
);
fanHealthIndexIPage
.
forEach
(
item
->
item
.
setHealthIndex
(
Double
.
valueOf
(
df
.
format
(
item
.
getHealthIndex
()))));
Integer
infoByPageTotal
=
fanHealthIndexMapper
.
getInfoByPageTotal
(
dto
);
resultPage
.
setRecords
(
fanHealthIndexIPage
);
resultPage
.
setTotal
(
infoByPageTotal
);
return
ResponseHelper
.
buildResponse
(
resultPage
);
}
@TycloudOperation
(
ApiLevel
=
UserType
.
AGENCY
,
needAuth
=
false
)
@PostMapping
(
value
=
"/getFanHealthIndexInfo"
)
@ApiOperation
(
httpMethod
=
"POST"
,
value
=
"分页查询健康指数信息 - 风电"
,
notes
=
"分页查询健康指数信息 - 风电"
)
@GatewayIdAutowired
...
...
@@ -123,7 +216,7 @@ public class TdInfoQueryController extends BaseController {
String
dateNowShortStr
=
DateUtils
.
getDateNowShortStr
();
String
endDate
=
dto
.
getEndDate
();
if
(
dateNowShortStr
.
equals
(
endDate
)){
Date
date
=
DateUtils
.
dateAddDays
(
null
,
-
1
);
Date
date
=
DateUtils
.
dateAddDays
(
null
,
0
);
SimpleDateFormat
formatter
=
new
SimpleDateFormat
(
DateUtils
.
DATE_PATTERN
);
endDate
=
formatter
.
format
(
date
);
}
...
...
@@ -310,6 +403,104 @@ public class TdInfoQueryController extends BaseController {
resultPage
.
setTotal
(
infoByPageTotal
);
return
ResponseHelper
.
buildResponse
(
resultPage
);
}
@TycloudOperation
(
ApiLevel
=
UserType
.
AGENCY
,
needAuth
=
false
)
@PostMapping
(
value
=
"/getPvHealthIndexInfoOld"
)
@ApiOperation
(
httpMethod
=
"POST"
,
value
=
"分页查询健康指数信息 - 光伏"
,
notes
=
"分页查询健康指数信息 - 光伏"
)
@GatewayIdAutowired
public
ResponseModel
<
Page
<
PvHealthIndex
>>
getPvHealthIndexInfoOld
(
@RequestBody
PvHealthIndexDto
dto
)
throws
ParseException
{
ReginParams
reginParams
=
getSelectedOrgInfo
();
String
userId
=
reginParams
.
getUserModel
().
getUserId
();
StdUserEmpower
stdUserEmpower
=
userEmpowerMapper
.
selectOne
(
new
QueryWrapper
<
StdUserEmpower
>().
eq
(
"amos_user_id"
,
userId
).
eq
(
"permission_type"
,
"YTH"
));
String
orgCode
=
"86"
+
"%"
;
if
(!
ObjectUtils
.
isEmpty
(
stdUserEmpower
))
{
orgCode
=
stdUserEmpower
.
getAmosOrgCode
().
get
(
0
)+
"%"
;
}
dto
.
setOrgCode
(
orgCode
);
if
(
CharSequenceUtil
.
isNotEmpty
(
dto
.
getStartDate
()))
{
String
startDate
=
dto
.
getStartDate
();
if
(
dto
.
getAnalysisType
()
!=
null
&&
dto
.
getAnalysisType
().
equals
(
"按天"
)
&&
startDate
.
length
()
==
10
)
{
Date
date
=
DateUtils
.
dateParse
(
startDate
+
" 00:00:00"
,
DATE_TIME_PATTERN
);
dto
.
setStartDate
(
DateUtils
.
dateFormat
(
DateUtils
.
dateAddHours
(
date
,
0
),
DATE_TIME_PATTERN
));
}
else
if
(
dto
.
getAnalysisType
()
!=
null
&&
dto
.
getAnalysisType
().
equals
(
"按小时"
)
&&
startDate
.
length
()
==
13
)
{
Date
date
=
DateUtils
.
dateParse
(
startDate
+
":00:00"
,
DATE_TIME_PATTERN
);
dto
.
setStartDate
(
DateUtils
.
dateFormat
(
DateUtils
.
dateAddHours
(
date
,
-
9
),
DATE_TIME_PATTERN
));
}
else
if
(
dto
.
getAnalysisType
()
!=
null
&&
dto
.
getAnalysisType
().
equals
(
"按10分钟"
)
&&
startDate
.
length
()
==
16
)
{
StringBuilder
newStartDate
=
new
StringBuilder
(
startDate
);
int
number
=
0
;
if
((
newStartDate
.
charAt
(
15
)
-
'0'
)
>
0
)
{
number
=
9
;
}
newStartDate
.
replace
(
15
,
16
,
number
+
""
);
Date
startDateDate
=
DateUtils
.
dateParse
(
newStartDate
+
":00"
,
DATE_TIME_PATTERN
);
dto
.
setStartDate
(
DateUtils
.
dateFormat
(
DateUtils
.
dateAddHours
(
startDateDate
,
-
8
),
DATE_TIME_PATTERN
));
}
else
{
Date
date
=
DateUtils
.
dateParse
(
startDate
,
DATE_TIME_PATTERN
);
dto
.
setStartDate
(
DateUtils
.
dateFormat
(
DateUtils
.
dateAddHours
(
date
,
-
8
),
DATE_TIME_PATTERN
));
}
}
if
(
CharSequenceUtil
.
isNotEmpty
(
dto
.
getEndDate
()))
{
String
endDate
=
dto
.
getEndDate
();
if
(
dto
.
getAnalysisType
()
!=
null
&&
dto
.
getAnalysisType
().
equals
(
"按天"
)
&&
endDate
.
length
()
==
10
)
{
Date
endDateDate
=
DateUtils
.
dateParse
(
endDate
+
" 23:59:59"
,
DATE_TIME_PATTERN
);
dto
.
setEndDate
(
DateUtils
.
dateFormat
(
DateUtils
.
dateAddHours
(
endDateDate
,
0
),
DATE_TIME_PATTERN
));
}
else
if
(
dto
.
getAnalysisType
()
!=
null
&&
dto
.
getAnalysisType
().
equals
(
"按小时"
)
&&
endDate
.
length
()
==
13
)
{
Date
endDateDate
=
DateUtils
.
dateParse
(
endDate
+
":59:59"
,
DATE_TIME_PATTERN
);
dto
.
setEndDate
(
DateUtils
.
dateFormat
(
DateUtils
.
dateAddHours
(
endDateDate
,
-
9
),
DATE_TIME_PATTERN
));
}
else
if
(
dto
.
getAnalysisType
()
!=
null
&&
dto
.
getAnalysisType
().
equals
(
"按10分钟"
)
&&
endDate
.
length
()
==
16
)
{
StringBuilder
newEndDate
=
new
StringBuilder
(
endDate
);
newEndDate
.
replace
(
15
,
16
,
"9"
);
Date
endDateDate
=
DateUtils
.
dateParse
(
newEndDate
+
":59"
,
DATE_TIME_PATTERN
);
dto
.
setEndDate
(
DateUtils
.
dateFormat
(
DateUtils
.
dateAddHours
(
endDateDate
,
-
8
),
DATE_TIME_PATTERN
));
}
else
{
Date
endDateDate
=
DateUtils
.
dateParse
(
endDate
,
"yyyy-MM-dd HH:mm:ss"
);
dto
.
setEndDate
(
DateUtils
.
dateFormat
(
DateUtils
.
dateAddHours
(
endDateDate
,
-
8
),
DATE_TIME_PATTERN
));
}
}
if
(
CharSequenceUtil
.
isNotEmpty
(
dto
.
getSortsString
()))
{
ObjectMapper
objectMapper
=
new
ObjectMapper
();
try
{
List
<
Map
<
String
,
String
>>
list
=
objectMapper
.
readValue
(
dto
.
getSortsString
(),
new
TypeReference
<
List
<
Map
<
String
,
String
>>>(){});
dto
.
setSorts
(
list
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
}
Page
<
PvHealthIndex
>
resultPage
=
new
Page
<>(
dto
.
getCurrent
(),
dto
.
getSize
());
dto
.
setCurrent
((
dto
.
getCurrent
()
-
1
)
*
dto
.
getSize
());
List
<
Map
<
String
,
String
>>
orderWeight
=
dto
.
getSorts
().
stream
().
sorted
(
Comparator
.
comparing
(
t
->
Integer
.
parseInt
(
t
.
get
(
"orderWeight"
)))).
collect
(
Collectors
.
toList
());
List
<
String
>
orderByList
=
new
ArrayList
<>();
for
(
Map
<
String
,
String
>
map
:
orderWeight
)
{
String
replace
=
map
.
get
(
"order"
).
replace
(
"end"
,
""
);
String
columnOrder
=
convert
(
map
.
get
(
"columnKey"
))
+
" "
+
replace
;
orderByList
.
add
(
columnOrder
);
}
if
(
CharSequenceUtil
.
isNotEmpty
(
dto
.
getSortOne
()))
{
String
[]
split
=
dto
.
getSortOne
().
split
(
","
);
String
replace
=
split
[
1
].
replace
(
"end"
,
""
);
String
orderColumn
=
convert
(
split
[
0
])
+
" "
+
replace
;
dto
.
setSortOne
(
orderColumn
);
}
String
join
=
String
.
join
(
","
,
orderByList
);
dto
.
setOrderColumns
(
join
);
List
<
PvHealthIndex
>
pvHealthIndexIPage
=
pvHealthIndexMapper
.
getInfoByPage
(
dto
);
pvHealthIndexIPage
.
forEach
(
item
->
item
.
setHealthIndex
(
Double
.
valueOf
(
df
.
format
(
item
.
getHealthIndex
()))));
Integer
infoByPageTotal
=
pvHealthIndexMapper
.
getInfoByPageTotal
(
dto
);
resultPage
.
setRecords
(
pvHealthIndexIPage
);
resultPage
.
setTotal
(
infoByPageTotal
);
return
ResponseHelper
.
buildResponse
(
resultPage
);
}
@TycloudOperation
(
ApiLevel
=
UserType
.
AGENCY
,
needAuth
=
false
)
@PostMapping
(
value
=
"/getFanWarningRecordInfo"
)
...
...
amos-boot-system-jxiop/amos-boot-module-jxiop-analyse-biz/src/main/java/com/yeejoin/amos/boot/module/jxiop/biz/listener/SyncESDataToTdengineMqttListener.java
View file @
25c1b88a
...
...
@@ -9,6 +9,9 @@ import com.yeejoin.amos.boot.module.jxiop.biz.service.impl.TdengineTimeServiceIm
import
lombok.extern.slf4j.Slf4j
;
import
org.eclipse.paho.client.mqttv3.MqttMessage
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.scheduling.annotation.Async
;
import
org.springframework.scheduling.annotation.EnableScheduling
;
import
org.springframework.scheduling.annotation.Scheduled
;
import
org.springframework.stereotype.Component
;
import
org.typroject.tyboot.component.emq.EmqxListener
;
...
...
@@ -27,6 +30,7 @@ import java.util.concurrent.TimeUnit;
*/
@Component
@Slf4j
@EnableScheduling
public
class
SyncESDataToTdengineMqttListener
extends
EmqxListener
{
@Autowired
...
...
@@ -43,10 +47,70 @@ public class SyncESDataToTdengineMqttListener extends EmqxListener {
@PostConstruct
public
void
test
()
{
// 每次启动清空redis
//redisUtils.set(JXIOP_ANALYSE_TIME, "2024-07-30 13:40:00");
//
redisUtils.set(JXIOP_ANALYSE_TIME, "2024-07-30 13:40:00");
redisUtils
.
del
(
JXIOP_ANALYSE_TIME
);
}
// @Async("async")
@Scheduled
(
cron
=
"0 */10 * * * ?"
)
public
void
run
()
throws
ParseException
{
Date
time
=
new
Date
();
time
=
DateUtil
.
offsetMinute
(
time
,
-
DateUtil
.
minute
(
time
)
%
10
);
String
format
=
DateUtil
.
format
(
time
,
"yyyy-MM-dd HH:mm:00"
);
time
=
DateUtil
.
parse
(
format
,
"yyyy-MM-dd HH:mm:00"
);
if
(
redisUtils
.
get
(
JXIOP_ANALYSE_TIME
)
!=
null
)
{
// 如果相差20分钟 按10分钟处理 可能装备发消息晚了
String
lastformat
=
String
.
valueOf
(
redisUtils
.
get
(
JXIOP_ANALYSE_TIME
));
Date
oldTime
=
DateUtil
.
parse
(
lastformat
,
"yyyy-MM-dd HH:mm:00"
);
long
diffInMillies
=
Math
.
abs
(
time
.
getTime
()
-
oldTime
.
getTime
());
long
diffInMinutes
=
TimeUnit
.
MINUTES
.
convert
(
diffInMillies
,
TimeUnit
.
MILLISECONDS
);
if
(
diffInMinutes
==
20
)
{
time
=
DateUtil
.
offsetMinute
(
time
,
-
10
);
format
=
DateUtil
.
format
(
time
,
"yyyy-MM-dd HH:mm:00"
);
}
}
redisUtils
.
set
(
JXIOP_ANALYSE_TIME
,
format
);
System
.
out
.
println
(
format
);
final
Date
timeF
=
time
;
CompletableFuture
<
String
>
fan
=
CompletableFuture
.
supplyAsync
(()
->
{
try
{
commonServiceImpl
.
healthWarningMinuteByFan
(
timeF
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
String
fanResult
=
"风电任务完成.."
;
System
.
out
.
println
(
fanResult
);
return
fanResult
;
});
CompletableFuture
<
String
>
pv
=
CompletableFuture
.
supplyAsync
(()
->
{
try
{
commonServiceImpl
.
healthWarningMinuteByPv
(
timeF
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
String
pvResult
=
"光伏任务完成.."
;
System
.
out
.
println
(
pvResult
);
return
pvResult
;
});
try
{
String
fanResult
=
fan
.
get
();
String
pvResult
=
pv
.
get
();
// 区域 全域最后统一生成
tdengineTimeService
.
insertMomentDataAll
(
format
);
if
(
isWholeHour
(
format
))
{
tdengineTimeService
.
insertHourData
();
}
if
(
isWholeDay
(
format
))
{
tdengineTimeService
.
insertDayData
();
}
}
catch
(
InterruptedException
|
ExecutionException
e
)
{
System
.
out
.
println
(
"任务执行异常"
);
e
.
printStackTrace
();
}
}
@Override
public
void
processMessage
(
String
topic
,
MqttMessage
mqttMessage
)
throws
ParseException
{
log
.
info
(
topic
+
"收到数据同步成功,开始计算健康指数!"
);
...
...
@@ -56,54 +120,7 @@ public class SyncESDataToTdengineMqttListener extends EmqxListener {
JSONObject
jsonObject
=
JSONObject
.
parseObject
(
msg
);
String
flag
=
jsonObject
.
get
(
"sync_flag"
).
toString
();
if
(
"success"
.
equals
(
flag
))
{
Date
time
=
new
Date
();
time
=
DateUtil
.
offsetMinute
(
time
,
-
DateUtil
.
minute
(
time
)
%
10
);
String
format
=
DateUtil
.
format
(
time
,
"yyyy-MM-dd HH:mm:00"
);
time
=
DateUtil
.
parse
(
format
,
"yyyy-MM-dd HH:mm:00"
);
if
(
redisUtils
.
get
(
JXIOP_ANALYSE_TIME
)
!=
null
)
{
// 如果相差20分钟 按10分钟处理 可能装备发消息晚了
String
lastformat
=
String
.
valueOf
(
redisUtils
.
get
(
JXIOP_ANALYSE_TIME
));
Date
oldTime
=
DateUtil
.
parse
(
lastformat
,
"yyyy-MM-dd HH:mm:00"
);
long
diffInMillies
=
Math
.
abs
(
time
.
getTime
()
-
oldTime
.
getTime
());
long
diffInMinutes
=
TimeUnit
.
MINUTES
.
convert
(
diffInMillies
,
TimeUnit
.
MILLISECONDS
);
if
(
diffInMinutes
==
20
)
{
time
=
DateUtil
.
offsetMinute
(
time
,
-
10
);
format
=
DateUtil
.
format
(
time
,
"yyyy-MM-dd HH:mm:00"
);
}
}
redisUtils
.
set
(
JXIOP_ANALYSE_TIME
,
format
);
System
.
out
.
println
(
format
);
final
Date
timeF
=
time
;
CompletableFuture
<
String
>
fan
=
CompletableFuture
.
supplyAsync
(()->{
commonServiceImpl
.
healthWarningMinuteByFan
(
timeF
);
String
fanResult
=
"风电任务完成.."
;
System
.
out
.
println
(
fanResult
);
return
fanResult
;
});
CompletableFuture
<
String
>
pv
=
CompletableFuture
.
supplyAsync
(()->{
commonServiceImpl
.
healthWarningMinuteByPv
(
timeF
);
String
pvResult
=
"光伏任务完成.."
;
System
.
out
.
println
(
pvResult
);
return
pvResult
;
});
try
{
String
fanResult
=
fan
.
get
();
String
pvResult
=
pv
.
get
();
// 区域 全域最后统一生成
tdengineTimeService
.
insertMomentDataAll
(
format
);
if
(
isWholeHour
(
format
)){
tdengineTimeService
.
insertHourData
();
}
if
(
isWholeDay
(
format
)){
tdengineTimeService
.
insertDayData
();
}
}
catch
(
InterruptedException
|
ExecutionException
e
)
{
System
.
out
.
println
(
"任务执行异常"
);
e
.
printStackTrace
();
}
run
();
//
// ExecutorService excutorService = Executors.newFixedThreadPool(10);
// int taskCount = 2;
...
...
@@ -159,7 +176,8 @@ public class SyncESDataToTdengineMqttListener extends EmqxListener {
// }).start();
// }
}
private
boolean
isWholeHour
(
String
dateTimeStr
)
{
private
boolean
isWholeHour
(
String
dateTimeStr
)
{
try
{
DateTimeFormatter
FORMATTER
=
DateTimeFormatter
.
ofPattern
(
"yyyy-MM-dd HH:mm:ss"
);
LocalDateTime
dateTime
=
LocalDateTime
.
parse
(
dateTimeStr
,
FORMATTER
);
...
...
@@ -169,7 +187,7 @@ public class SyncESDataToTdengineMqttListener extends EmqxListener {
}
}
private
boolean
isWholeDay
(
String
dateTimeStr
)
{
private
boolean
isWholeDay
(
String
dateTimeStr
)
{
try
{
DateTimeFormatter
FORMATTER
=
DateTimeFormatter
.
ofPattern
(
"yyyy-MM-dd HH:mm:ss"
);
LocalDateTime
dateTime
=
LocalDateTime
.
parse
(
dateTimeStr
,
FORMATTER
);
...
...
amos-boot-system-jxiop/amos-boot-module-jxiop-analyse-biz/src/main/java/com/yeejoin/amos/boot/module/jxiop/biz/service/impl/CommonServiceImpl.java
View file @
25c1b88a
This source diff could not be displayed because it is too large. You can
view the blob
instead.
amos-boot-system-jxiop/amos-boot-module-jxiop-analyse-biz/src/main/resources/application-kingbase8.properties
View file @
25c1b88a
...
...
@@ -34,7 +34,7 @@ spring.redis.host=10.20.1.210
spring.redis.port
=
6379
spring.redis.password
=
yeejoin@2020
openHealth
=
fals
e
openHealth
=
tru
e
spring.cache.type
=
GENERIC
j2cache.open-spring-cache
=
true
j2cache.cache-clean-mode
=
passive
...
...
amos-boot-system-jxiop/amos-boot-module-jxiop-analyse-biz/src/main/resources/mapper/tdengine2/FanHealthIndex.xml
View file @
25c1b88a
...
...
@@ -173,6 +173,8 @@
<if
test=
"dto.analysisType!= null and dto.analysisType!= ''"
>
and analysis_type = #{dto.analysisType}
</if>
<if
test=
"dto.endDateTs!= null and dto.endDateTs!= '' "
>
and ts
<
= #{dto.endDateTs}
</if>
<if
test=
"dto.startDateTs!= null and dto.startDateTs!= ''"
>
and ts
>
= #{dto.startDateTs}
</if>
<!--<if test="dto.endDate!= null and dto.endDate!= ''"> and ts <= #{dto.endDate} </if>
<if test="dto.startDate!= null and dto.startDate!= ''"> and ts >= #{dto.startDate} </if>-->
<if
test=
"dto.area!= null and dto.area!= ''"
>
AND area = #{dto.area}
</if>
<if
test=
"dto.number!= null and dto.number!= ''"
>
AND `number` = #{dto.number}
</if>
<if
test=
"dto.pointName!= null and dto.pointName!= ''"
>
AND point_name = #{dto.pointName}
</if>
...
...
amos-boot-system-jxiop/amos-boot-module-jxiop-analyse-biz/src/main/resources/mapper/tdengine2/PvHealthIndex.xml
View file @
25c1b88a
...
...
@@ -205,6 +205,8 @@
<if
test=
"dto.analysisType!= null and dto.analysisType!= ''"
>
and analysis_type = #{dto.analysisType}
</if>
<if
test=
"dto.endDateTs!= null and dto.endDateTs!= ''"
>
and ts
<
= #{dto.endDateTs}
</if>
<if
test=
"dto.startDateTs!= null and dto.startDateTs!= ''"
>
and ts
>
= #{dto.startDateTs}
</if>
<!--<if test="dto.endDate!= null and dto.endDate!= ''"> and ts <= #{dto.endDate} </if>
<if test="dto.startDate!= null and dto.startDate!= ''"> and ts >= #{dto.startDate} </if>-->
<if
test=
"dto.area!= null and dto.area!= ''"
>
AND area = #{dto.area}
</if>
<if
test=
"dto.subarray!= null and dto.subarray!= ''"
>
AND subarray = #{dto.subarray}
</if>
<if
test=
"dto.pointName!= null and dto.pointName!= ''"
>
AND point_name = #{dto.pointName}
</if>
...
...
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