Commit f1eeb03d authored by suhuiguang's avatar suhuiguang

1.压测优化

parent fe0d7933
...@@ -116,6 +116,7 @@ public class ControllerAop { ...@@ -116,6 +116,7 @@ public class ControllerAop {
urls.add("/tcm/userInfo/getPersonType"); urls.add("/tcm/userInfo/getPersonType");
// urls.add("/patrol/api/check/checkCalendarForWx"); // urls.add("/patrol/api/check/checkCalendarForWx");
urls.add("/patrol/api/check/saveRecordAll"); urls.add("/patrol/api/check/saveRecordAll");
urls.add("/patrol/api/check/saveRecordAll2");
urls.add("/patrol/api/planTask/queryPlanTaskNew"); urls.add("/patrol/api/planTask/queryPlanTaskNew");
// 获取请求路径 // 获取请求路径
for (String uri : urls) { for (String uri : urls) {
......
...@@ -24,10 +24,23 @@ public class CacheHelper { ...@@ -24,10 +24,23 @@ public class CacheHelper {
@PostConstruct @PostConstruct
public void init() { public void init() {
List<InputItem> inputItems = iInputItemDao.findAll(); List<InputItem> inputItems = iInputItemDao.findAll();
inputItems.forEach(inputItem -> redisUtils.hset(P_INPUT_ITEM_REDIS_KEY_PREFIX, String.valueOf(inputItem.getId()), inputItem)); redisUtils.del(P_INPUT_ITEM_REDIS_KEY_PREFIX);
inputItems.forEach(inputItem -> redisUtils.hset(P_INPUT_ITEM_REDIS_KEY_PREFIX, String.valueOf(inputItem.getId()), inputItem, 3600));
} }
public InputItem getInputItemCacheData(String inputItemId) { public InputItem getInputItemCacheData(String inputItemId) {
if(redisUtils.hHasKey(P_INPUT_ITEM_REDIS_KEY_PREFIX, inputItemId)){
return (InputItem) redisUtils.hget(P_INPUT_ITEM_REDIS_KEY_PREFIX, inputItemId); return (InputItem) redisUtils.hget(P_INPUT_ITEM_REDIS_KEY_PREFIX, inputItemId);
} else {
synchronized (this){
if(redisUtils.hHasKey(P_INPUT_ITEM_REDIS_KEY_PREFIX, inputItemId)){
return (InputItem) redisUtils.hget(P_INPUT_ITEM_REDIS_KEY_PREFIX, inputItemId);
} else{
List<InputItem> inputItems = iInputItemDao.findAll();
inputItems.forEach(inputItem -> redisUtils.hset(P_INPUT_ITEM_REDIS_KEY_PREFIX, String.valueOf(inputItem.getId()), inputItem, 3600));
return (InputItem) redisUtils.hget(P_INPUT_ITEM_REDIS_KEY_PREFIX, inputItemId);
}
}
}
} }
} }
...@@ -230,10 +230,11 @@ public class CheckController extends AbstractBaseController { ...@@ -230,10 +230,11 @@ public class CheckController extends AbstractBaseController {
@TycloudOperation(ApiLevel = UserType.AGENCY) @TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(value = "一键提交巡检任务", notes = "一键提交巡检任务<font color='blue'>手机app</font>") @ApiOperation(value = "一键提交巡检任务", notes = "一键提交巡检任务<font color='blue'>手机app</font>")
@RequestMapping(value = "/saveRecordAll", produces = "application/json;charset=UTF-8", method = RequestMethod.POST) @RequestMapping(value = "/saveRecordAll2", produces = "application/json;charset=UTF-8", method = RequestMethod.POST)
public ResponseModel<Object> saveCheckRecordAll(@RequestParam String ids) { public ResponseModel<Object> saveCheckRecordAll(@RequestParam String ids) {
String userId = RequestContext.getExeUserId(); String userId = RequestContext.getExeUserId();
try { try {
// 查询数据库和es 单线程串行执行
UserTransmittableUtils.setUser(); UserTransmittableUtils.setUser();
planTaskService.handleAllBatch(ids, userId); planTaskService.handleAllBatch(ids, userId);
} catch (Exception e) { } catch (Exception e) {
...@@ -246,10 +247,11 @@ public class CheckController extends AbstractBaseController { ...@@ -246,10 +247,11 @@ public class CheckController extends AbstractBaseController {
@TycloudOperation(ApiLevel = UserType.AGENCY) @TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(value = "一键提交巡检任务", notes = "一键提交巡检任务<font color='blue'>手机app</font>") @ApiOperation(value = "一键提交巡检任务", notes = "一键提交巡检任务<font color='blue'>手机app</font>")
@RequestMapping(value = "/saveRecordAll2", produces = "application/json;charset=UTF-8", method = RequestMethod.POST) @RequestMapping(value = "/saveRecordAll", produces = "application/json;charset=UTF-8", method = RequestMethod.POST)
public ResponseModel<Object> saveCheckRecordAll1(@RequestParam String ids) { public ResponseModel<Object> saveCheckRecordAll2(@RequestParam String ids) {
String userId = RequestContext.getExeUserId(); String userId = RequestContext.getExeUserId();
try { try {
// 查询数据库和es 多线程并行执行
UserTransmittableUtils.setUser(); UserTransmittableUtils.setUser();
planTaskService.handleAllBatch2(ids, userId); planTaskService.handleAllBatch2(ids, userId);
} catch (Exception e) { } catch (Exception e) {
......
...@@ -96,8 +96,10 @@ public class CheckRecordDataConsumer implements Runnable { ...@@ -96,8 +96,10 @@ public class CheckRecordDataConsumer implements Runnable {
} }
private AgencyUserModel getAgencyUserModel(RequestContextModel requestContextModel) { private AgencyUserModel getAgencyUserModel(RequestContextModel requestContextModel) {
List<AgencyUserModel> agencyUserModels = FeignUtil.remoteCall(()->Privilege.agencyUserClient.queryByIds(requestContextModel.getExcutedUserId(),false)); // 记录暂时不用 注释掉
return agencyUserModels.get(0); //List<AgencyUserModel> agencyUserModels = FeignUtil.remoteCall(()->Privilege.agencyUserClient.queryByIds(requestContextModel.getExcutedUserId(),false));
// return agencyUserModels.get(0);
return null;
} }
private void setRequestContext(){ private void setRequestContext(){
......
package com.yeejoin.amos.patrol.business.dto;
import lombok.Getter;
import lombok.Setter;
/**
*
* @author LiuLin
* @date 2023年10月11日 09:31
*/
@Setter
@Getter
public final class EsEntity<T> {
private String id;
private T data;
public EsEntity() {
}
public EsEntity(String id, T data) {
this.data = data;
this.id = id;
}
}
\ No newline at end of file
...@@ -25,6 +25,13 @@ public class ElasticSearchClientConfig { ...@@ -25,6 +25,13 @@ public class ElasticSearchClientConfig {
@Value("${elasticsearch.password}") @Value("${elasticsearch.password}")
private String password; private String password;
@Value("${elasticsearch.maxConnectNum:1000}")
private int maxConnectNum;
@Value("${elasticsearch.maxConnectPerRoute:1000}")
private int maxConnectPerRoute;
@Bean(destroyMethod = "close") @Bean(destroyMethod = "close")
public RestHighLevelClient restHighLevelClient() { public RestHighLevelClient restHighLevelClient() {
final CredentialsProvider credentialsProvider = new BasicCredentialsProvider(); final CredentialsProvider credentialsProvider = new BasicCredentialsProvider();
...@@ -36,6 +43,8 @@ public class ElasticSearchClientConfig { ...@@ -36,6 +43,8 @@ public class ElasticSearchClientConfig {
RestClientBuilder builder = RestClient.builder(httpHosts); RestClientBuilder builder = RestClient.builder(httpHosts);
builder.setHttpClientConfigCallback(httpClientBuilder -> { builder.setHttpClientConfigCallback(httpClientBuilder -> {
httpClientBuilder.disableAuthCaching(); httpClientBuilder.disableAuthCaching();
httpClientBuilder.setMaxConnTotal(maxConnectNum);
httpClientBuilder.setMaxConnPerRoute(maxConnectPerRoute);
return httpClientBuilder.setDefaultCredentialsProvider(credentialsProvider); return httpClientBuilder.setDefaultCredentialsProvider(credentialsProvider);
}); });
// 该方法接收一个RequestConfig.Builder对象,对该对象进行修改后然后返回。 // 该方法接收一个RequestConfig.Builder对象,对该对象进行修改后然后返回。
......
package com.yeejoin.amos.patrol.config;
import org.elasticsearch.client.RestHighLevelClient;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.elasticsearch.core.ElasticsearchRestTemplate;
import org.springframework.data.elasticsearch.repository.config.EnableElasticsearchRepositories;
@Configuration
@EnableElasticsearchRepositories(basePackages = {"com.yeejoin.amos.boot.module.common.biz.dao","com.yeejoin.amos.patrol.business.dao.repository"})
public class ElasticSearchRestTemplateConfig {
@Bean
public ElasticsearchRestTemplate elasticsearchTemplate(RestHighLevelClient restHighLevelClient) {
return new ElasticsearchRestTemplate(restHighLevelClient);
}
}
...@@ -26,7 +26,7 @@ spring.datasource.password=Yeejoin@2023 ...@@ -26,7 +26,7 @@ spring.datasource.password=Yeejoin@2023
spring.datasource.type=com.zaxxer.hikari.HikariDataSource spring.datasource.type=com.zaxxer.hikari.HikariDataSource
spring.datasource.driver-class-name = cn.com.vastbase.Driver spring.datasource.driver-class-name = cn.com.vastbase.Driver
spring.datasource.hikari.maxLifetime = 1765000 spring.datasource.hikari.maxLifetime = 1765000
spring.datasource.hikari.maximum-pool-size = 100 spring.datasource.hikari.maximum-pool-size = 200
spring.datasource.hikari.minimum-idle=15 spring.datasource.hikari.minimum-idle=15
spring.datasource.testWhileIdle = true spring.datasource.testWhileIdle = true
spring.datasource.validationQuery = SELECT 1 spring.datasource.validationQuery = SELECT 1
...@@ -43,7 +43,7 @@ spring.redis.database=1 ...@@ -43,7 +43,7 @@ spring.redis.database=1
spring.redis.host=172.16.10.243 spring.redis.host=172.16.10.243
spring.redis.port=6379 spring.redis.port=6379
spring.redis.password=yeejoin@2020 spring.redis.password=yeejoin@2020
spring.redis.jedis.pool.max-active=200 spring.redis.jedis.pool.max-active=500
spring.redis.jedis.pool.max-wait=-1 spring.redis.jedis.pool.max-wait=-1
spring.redis.jedis.pool.max-idle=10 spring.redis.jedis.pool.max-idle=10
spring.redis.jedis.pool.min-idle=0 spring.redis.jedis.pool.min-idle=0
...@@ -112,6 +112,8 @@ fire-rescue=1432549862557130753 ...@@ -112,6 +112,8 @@ fire-rescue=1432549862557130753
action.auto_create_index:true action.auto_create_index:true
elasticsearch.username=elastic elasticsearch.username=elastic
elasticsearch.password=a123456 elasticsearch.password=a123456
elasticsearch.maxConnectNum= 1000
elasticsearch.maxConnectPerRoute= 1000
spring.elasticsearch.rest.uris=http://172.16.10.243:9200 spring.elasticsearch.rest.uris=http://172.16.10.243:9200
## unit(h) ## unit(h)
alertcall.es.synchrony.time=48 alertcall.es.synchrony.time=48
...@@ -195,8 +197,11 @@ spring.jpa.properties.hibernate.order_updates =true ...@@ -195,8 +197,11 @@ spring.jpa.properties.hibernate.order_updates =true
shardingsphere.create.tables.num=10 shardingsphere.create.tables.num=10
logging.level.com.zaxxer.hikari=DEBUG logging.level.com.zaxxer.hikari=DEBUG
logging.level.org.springframework.data.elasticsearch=error
logging.level.org.elasticsearch=error
amos.system.user.user-name=admin_tzs amos.system.user.user-name=admin_tzs
amos.system.user.password=a1234560 amos.system.user.password=a1234560
amos.system.user.app-key=AMOS_STUDIO amos.system.user.app-key=AMOS_STUDIO
amos.system.user.product=AMOS_STUDIO_WEB amos.system.user.product=AMOS_STUDIO_WEB
spring.application.name = AMOS-PATROL-LTW spring.application.name = AMOS-PATROL
server.servlet.context-path=/patrol server.servlet.context-path=/patrol
server.port = 8082 server.port = 8082
...@@ -17,11 +17,12 @@ spring.jpa.show-sql = false ...@@ -17,11 +17,12 @@ spring.jpa.show-sql = false
spring.jpa.hibernate.ddl-auto = none spring.jpa.hibernate.ddl-auto = none
spring.jpa.hibernate.naming-strategy = org.hibernate.cfg.ImprovedNamingStrategy spring.jpa.hibernate.naming-strategy = org.hibernate.cfg.ImprovedNamingStrategy
spring.jpa.database-platform = org.hibernate.dialect.MySQLDialect spring.jpa.database-platform = org.hibernate.dialect.MySQLDialect
mybatis.mapper-locations = classpath:db/mapper/*.xml mybatis.mapper-locations = classpath:db/mapper/*.xml
mybatis-plus.mapper-locations=classpath:db/mapper/*.xml mybatis-plus.mapper-locations=classpath:db/mapper/*.xml
mybatis.type-aliases-package = com.yeejoin.amos.patrol.business.entity.mybatis mybatis.type-aliases-package = com.yeejoin.amos.patrol.business.entity.mybatis
mybatis.configuration.mapUnderscoreToCamelCase=true mybatis.configuration.mapUnderscoreToCamelCase=true
mybatis-plus.configuration.log-impl=org.apache.ibatis.logging.stdout.StdOutImpl mybatis-plus.configuration.log-impl=org.apache.ibatis.logging.nologging.NoLoggingImpl
mybatis-plus.global-config.db-config.update-strategy=ignored mybatis-plus.global-config.db-config.update-strategy=ignored
spring.liquibase.change-log=classpath:/db/changelog/changelog-master.xml spring.liquibase.change-log=classpath:/db/changelog/changelog-master.xml
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment