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
3aaafd36
Commit
3aaafd36
authored
May 27, 2024
by
wujiang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加异步配置
parent
f0468699
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
92 additions
and
6 deletions
+92
-6
pom.xml
amos-boot-data/amos-boot-data-housepvapi/pom.xml
+2
-0
HousevPVapiApplication.java
...rc/main/java/com/yeejoin/amos/HousevPVapiApplication.java
+7
-6
SunlightServiceImpl.java
...i/householdapi/face/service/impl/SunlightServiceImpl.java
+7
-0
ListenerAsyncConfiguration.java
...a/com/yeejoin/amos/config/ListenerAsyncConfiguration.java
+76
-0
No files found.
amos-boot-data/amos-boot-data-housepvapi/pom.xml
View file @
3aaafd36
...
@@ -58,6 +58,7 @@
...
@@ -58,6 +58,7 @@
<artifactId>
tyboot-component-emq
</artifactId>
<artifactId>
tyboot-component-emq
</artifactId>
<version>
${tyboot-version}
</version>
<version>
${tyboot-version}
</version>
</dependency>
</dependency>
<!--
<dependency>
<dependency>
<groupId>org.typroject</groupId>
<groupId>org.typroject</groupId>
<artifactId>tyboot-component-event</artifactId>
<artifactId>tyboot-component-event</artifactId>
...
@@ -69,6 +70,7 @@
...
@@ -69,6 +70,7 @@
</exclusion>
</exclusion>
</exclusions>
</exclusions>
</dependency>
</dependency>
-->
<dependency>
<dependency>
<groupId>
org.typroject
</groupId>
<groupId>
org.typroject
</groupId>
<artifactId>
tyboot-component-opendata
</artifactId>
<artifactId>
tyboot-component-opendata
</artifactId>
...
...
amos-boot-data/amos-boot-data-housepvapi/src/main/java/com/yeejoin/amos/HousevPVapiApplication.java
View file @
3aaafd36
...
@@ -5,23 +5,21 @@ import java.net.InetAddress;
...
@@ -5,23 +5,21 @@ import java.net.InetAddress;
import
org.apache.logging.log4j.LogManager
;
import
org.apache.logging.log4j.LogManager
;
import
org.apache.logging.log4j.Logger
;
import
org.apache.logging.log4j.Logger
;
import
org.mybatis.spring.annotation.MapperScan
;
import
org.mybatis.spring.annotation.MapperScan
;
import
org.mybatis.spring.boot.autoconfigure.MybatisAutoConfiguration
;
import
org.springframework.boot.SpringApplication
;
import
org.springframework.boot.SpringApplication
;
import
org.springframework.boot.autoconfigure.SpringBootApplication
;
import
org.springframework.boot.autoconfigure.SpringBootApplication
;
import
org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration
;
import
org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration
;
import
org.springframework.boot.autoconfigure.jdbc.DataSourceTransactionManagerAutoConfiguration
;
import
org.springframework.boot.autoconfigure.jdbc.DataSourceTransactionManagerAutoConfiguration
;
import
org.springframework.boot.context.properties.EnableConfigurationProperties
;
import
org.springframework.boot.context.properties.EnableConfigurationProperties
;
import
org.springframework.boot.web.servlet.ServletComponentScan
;
import
org.springframework.boot.web.servlet.ServletComponentScan
;
import
org.springframework.cloud.client.discovery.EnableDiscoveryClient
;
import
org.springframework.cloud.netflix.eureka.EnableEurekaClient
;
import
org.springframework.cloud.openfeign.EnableFeignClients
;
import
org.springframework.context.ConfigurableApplicationContext
;
import
org.springframework.context.ConfigurableApplicationContext
;
import
org.springframework.context.annotation.ComponentScan
;
import
org.springframework.context.annotation.ComponentScan
;
import
org.springframework.context.annotation.FilterType
;
import
org.springframework.core.env.Environment
;
import
org.springframework.core.env.Environment
;
import
org.springframework.scheduling.annotation.EnableAsync
;
import
org.springframework.scheduling.annotation.EnableAsync
;
import
org.springframework.scheduling.annotation.EnableScheduling
;
import
org.springframework.scheduling.annotation.EnableScheduling
;
import
org.springframework.transaction.annotation.EnableTransactionManagement
;
import
org.springframework.transaction.annotation.EnableTransactionManagement
;
import
org.typroject.tyboot.core.restful.exception.GlobalExceptionHandler
;
import
org.typroject.tyboot.core.restful.exception.GlobalExceptionHandler
;
/**
/**
*
*
* <pre>
* <pre>
...
@@ -41,10 +39,13 @@ import org.typroject.tyboot.core.restful.exception.GlobalExceptionHandler;
...
@@ -41,10 +39,13 @@ import org.typroject.tyboot.core.restful.exception.GlobalExceptionHandler;
@EnableScheduling
@EnableScheduling
@MapperScan
(
value
=
{
"org.typroject.tyboot.*.*.face.orm.dao"
,
"com.yeejoin.amos.api.*.face.orm.dao"
,
@MapperScan
(
value
=
{
"org.typroject.tyboot.*.*.face.orm.dao"
,
"com.yeejoin.amos.api.*.face.orm.dao"
,
"org.typroject.tyboot.face.*.orm.dao*"
,
"com.yeejoin.amos.boot.biz.common.dao.mapper"
})
"org.typroject.tyboot.face.*.orm.dao*"
,
"com.yeejoin.amos.boot.biz.common.dao.mapper"
})
@ComponentScan
({
"org.typroject"
,
"com.yeejoin.amos"
})
@ComponentScan
(
value
=
{
"org.typroject"
,
@SpringBootApplication
(
exclude
=
{
DataSourceAutoConfiguration
.
class
,
DataSourceTransactionManagerAutoConfiguration
.
class
})
"com.yeejoin.amos"
},
excludeFilters
=
@ComponentScan
.
Filter
(
type
=
FilterType
.
REGEX
,
pattern
=
"org.typroject.tyboot.component.event"
))
@SpringBootApplication
(
exclude
=
{
DataSourceAutoConfiguration
.
class
,
DataSourceTransactionManagerAutoConfiguration
.
class
})
public
class
HousevPVapiApplication
{
public
class
HousevPVapiApplication
{
private
static
final
Logger
logger
=
LogManager
.
getLogger
(
HousevPVapiApplication
.
class
);
private
static
final
Logger
logger
=
LogManager
.
getLogger
(
HousevPVapiApplication
.
class
);
public
static
void
main
(
String
[]
args
)
throws
Exception
{
public
static
void
main
(
String
[]
args
)
throws
Exception
{
// 服务启动
// 服务启动
ConfigurableApplicationContext
context
=
SpringApplication
.
run
(
HousevPVapiApplication
.
class
,
args
);
ConfigurableApplicationContext
context
=
SpringApplication
.
run
(
HousevPVapiApplication
.
class
,
args
);
...
...
amos-boot-data/amos-boot-data-housepvapi/src/main/java/com/yeejoin/amos/api/householdapi/face/service/impl/SunlightServiceImpl.java
View file @
3aaafd36
...
@@ -909,11 +909,18 @@ public class SunlightServiceImpl implements SunlightService {
...
@@ -909,11 +909,18 @@ public class SunlightServiceImpl implements SunlightService {
jpCollector
.
setThirdStationId
(
jpStation
.
getThirdStationId
());
jpCollector
.
setThirdStationId
(
jpStation
.
getThirdStationId
());
// 第三方厂商标识
// 第三方厂商标识
jpCollector
.
setThirdCode
(
PVProducerInfoEnum
.
YG
.
getCode
());
jpCollector
.
setThirdCode
(
PVProducerInfoEnum
.
YG
.
getCode
());
if
(
device
.
getGetPs_fault_status
()
!=
null
)
{
if
(
device
.
getGetPs_fault_status
()
>
2
)
{
if
(
device
.
getGetPs_fault_status
()
>
2
)
{
jpCollector
.
setState
(
SunlightUtil
.
zt
.
get
(
device
.
getDev_status
()
+
""
));
jpCollector
.
setState
(
SunlightUtil
.
zt
.
get
(
device
.
getDev_status
()
+
""
));
}
else
{
}
else
{
jpCollector
.
setState
(
"报警"
);
// 电站状态
jpCollector
.
setState
(
"报警"
);
// 电站状态
}
}
}
else
{
//如果获取不了逆变器状态 并且逆变器没状态就默认离线
if
(
jpCollector
.
getState
()
==
null
)
{
jpCollector
.
setState
(
"离线"
);
}
}
jpCollector
.
setStationName
(
jpStation
.
getName
());
jpCollector
.
setStationName
(
jpStation
.
getName
());
// jpCollector.setVersion(imasterCollectorList.getSoftwareVersion());
// jpCollector.setVersion(imasterCollectorList.getSoftwareVersion());
jpCollector
.
setRecDate
(
new
Date
());
jpCollector
.
setRecDate
(
new
Date
());
...
...
amos-boot-data/amos-boot-data-housepvapi/src/main/java/com/yeejoin/amos/config/ListenerAsyncConfiguration.java
0 → 100644
View file @
3aaafd36
package
com
.
yeejoin
.
amos
.
config
;
import
java.lang.reflect.Method
;
import
java.util.concurrent.Executor
;
import
java.util.concurrent.ThreadPoolExecutor
;
import
org.apache.logging.log4j.LogManager
;
import
org.apache.logging.log4j.Logger
;
import
org.springframework.aop.interceptor.AsyncUncaughtExceptionHandler
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.context.annotation.Primary
;
import
org.springframework.scheduling.annotation.AsyncConfigurer
;
import
org.springframework.scheduling.annotation.EnableAsync
;
import
org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor
;
import
com.yeejoin.amos.HousevPVapiApplication
;
@EnableAsync
@Configuration
@Primary
public
class
ListenerAsyncConfiguration
implements
AsyncConfigurer
{
private
static
final
Logger
logger
=
LogManager
.
getLogger
(
ListenerAsyncConfiguration
.
class
);
/**
* 用于@Async注解获取默认线程连接池
*
* @return
*/
@Override
public
Executor
getAsyncExecutor
()
{
// 此类由Spring提供,org.springframework.scheduling.concurrent包下,是线程池的封装类
ThreadPoolTaskExecutor
taskExecutor
=
new
ThreadPoolTaskExecutor
();
// 线程池中线程的名字前缀
taskExecutor
.
setThreadNamePrefix
(
"taskThreadPool-async-"
);
// 线程池核心线程数量
taskExecutor
.
setCorePoolSize
(
20
);
// 线程池最大线程数量
taskExecutor
.
setMaxPoolSize
(
50
);
// 线程池空闲线程存活时间,单位秒
taskExecutor
.
setKeepAliveSeconds
(
100
);
// 线程池拒绝策略
taskExecutor
.
setRejectedExecutionHandler
(
new
ThreadPoolExecutor
.
DiscardOldestPolicy
());
// 线程池任务队容量,如果不设置则默认 Integer.MAX_VALUE,
// 队列默认使用LinkedBlockingQueue 若queueCapacity的值 <= 0,则使用SynchronousQueue
taskExecutor
.
setQueueCapacity
(
1000
);
// 线程池中核心线程是否允许超时,默认为false
taskExecutor
.
setAllowCoreThreadTimeOut
(
true
);
// 线程池中的超时处理时间,单位秒,有一个对应方法为毫秒,默认为不超时
taskExecutor
.
setAwaitTerminationSeconds
(
60
);
// 初始化线程池,不可以少,否者会抛出 线程池没有初始化
taskExecutor
.
initialize
();
return
taskExecutor
;
}
/**
* 线程未处理异常的统一处理机制,即线程池异常处理器,简单示例
*
* @return
*/
@Override
public
AsyncUncaughtExceptionHandler
getAsyncUncaughtExceptionHandler
()
{
// 异常处理器函数接口类
return
new
AsyncUncaughtExceptionHandler
()
{
@Override
public
void
handleUncaughtException
(
Throwable
throwable
,
Method
method
,
Object
...
objects
)
{
logger
.
error
(
"============ "
+
throwable
.
getMessage
()
+
" ==========="
,
throwable
);
logger
.
error
(
"============ "
+
method
.
getName
()
+
" ==========="
,
objects
);
}
};
}
}
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