配置连接池大小,减少一些不必要的事务

This commit is contained in:
lulz1 2024-04-22 22:37:01 +08:00
parent a274e4ce48
commit d6963666f4
5 changed files with 25 additions and 18 deletions

View File

@ -42,7 +42,7 @@ public class OrderController {
@Autowired
private RouteRequestDomainService routeRequestDomainService;
@Transactional
@ApiOperation("保存行程规划单")
@PostMapping("/save")
public Result<RouteOrder> creatOrder(@RequestBody OrderSaveData orderCreateData) {
@ -51,7 +51,7 @@ public class OrderController {
}
@Transactional
@ApiOperation("同步行程规划单到供应商")
@PostMapping("/sync")
public Result<String> syncOrder(@RequestBody SyncLegData syncLegData) {
@ -59,7 +59,7 @@ public class OrderController {
return Result.Success(SUCCESS);
}
@Transactional
@ApiOperation("取消已同步的行程规划单")
@PostMapping("/sync/cancel")
public Result<String> syncOrderCancel(@RequestBody SyncLegData syncLegData) {
@ -67,7 +67,7 @@ public class OrderController {
return Result.Success(SUCCESS);
}
@Transactional
@ApiOperation("批量同步行程规划单到供应商")
@PostMapping("/sync/batch")
public Result<String> syncOrderBatch(@RequestBody SyncLegData syncLegData) {
@ -80,7 +80,7 @@ public class OrderController {
return Result.Success(SUCCESS);
}
@Transactional
@ApiOperation("修改规划节点关联的订单")
@PostMapping("/leg/update")
public Result<String> updateLegOrder(@RequestBody UpdateLegData updateLegData) {
@ -88,7 +88,7 @@ public class OrderController {
return Result.Success(SUCCESS);
}
@Transactional
@ApiOperation("添加行程节点")
@PostMapping("/leg/add")
public Result<String> addLeg(@RequestBody AddLegData addLegData) {
@ -105,7 +105,7 @@ public class OrderController {
}
@Transactional
@ApiOperation("删除行程节点")
@PostMapping("/leg/delete")
public Result<String> deleteLeg(@RequestBody DeleteLegData deleteLegData) {

View File

@ -38,7 +38,7 @@ public class OrderPublicController {
@Autowired
private OrderDomainService orderDomainService;
@Transactional
@ApiOperation("提交审批行程规划单")
@PostMapping("/approve")
public Result<String> approveOrder(@RequestBody ApproveRouteData approveRouteData) {
@ -48,7 +48,7 @@ public class OrderPublicController {
return Result.Success(SUCCESS);
}
@Transactional
@ApiOperation("审批拒绝行程规划单")
@PostMapping("/reject")
public Result<String> rejectOrder(@RequestBody ApproveRouteData approveRouteData) {
@ -56,7 +56,7 @@ public class OrderPublicController {
return Result.Success(SUCCESS);
}
@Transactional
@ApiOperation("回复未同步行程规划单")
@PostMapping("/recover")
public Result<String> recoverOrder(@RequestBody ApproveRouteData approvalLegData) {
@ -64,7 +64,7 @@ public class OrderPublicController {
return Result.Success(SUCCESS);
}
@Transactional
@ApiOperation("审批通过行程规划单")
@PostMapping("/success")
public Result<String> approvalOrder(@RequestBody ApproveRouteData approvalLegData) {
@ -73,7 +73,6 @@ public class OrderPublicController {
}
@Transactional
@ApiOperation("根据行程节点号删除")
@PostMapping("/leg/delete/legNo")
public Result<String> deleteLeg(@RequestBody DeleteLegData deleteLegData) {

View File

@ -199,7 +199,7 @@ public class OrderApplicationService {
return legs;
}
@Transactional
public RouteOrder deleteLegToOrder(DeleteLegData deleteLegData) {
RouteOrder order = Optional.ofNullable(routeRepository.queryById(deleteLegData.getRouteId()))
.orElseThrow(() -> new NotFoundException(CommonMessageConstant.NOT_FOUND)).reloadStatus();

View File

@ -99,11 +99,11 @@ public class RouteRequestDomainService {
legs.forEach(it -> it.addEvent(legEventFactory.creatLegEvent(LEG_EVENT_NOT_ORDERED)));
//这里执行同步
syncAdapter.of(syncLegData.getSupplierName()).syncRouteRequest(routeRequest);
routeRequest.addEvent(RouteRequestEvent.sync(syncLegData.getSupplierName()));
//通过保存聚合根来保存差旅申请单
routeRepository.save(routeOrder);
if (syncAdapter.of(syncLegData.getSupplierName()).syncRouteRequest(routeRequest)) {
routeRequest.addEvent(RouteRequestEvent.sync(syncLegData.getSupplierName()));
//通过保存聚合根来保存差旅申请单
routeRepository.save(routeOrder);
}
return routeRequest;
}

View File

@ -6,6 +6,14 @@ spring:
url: jdbc:mysql://${chint.datasource.host}:${chint.datasource.port}/${chint.datasource.database}?serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&useSSL=false&allowPublicKeyRetrieval=true
username: ${chint.datasource.username}
password: ${chint.datasource.password}
hikari:
minimum-idle: 10
maximum-pool-size: 30 # 连接池最大连接数
idle-timeout: 300000 # 空闲连接超时时间(毫秒)
max-lifetime: 1800000 # 连接的最长生命周期(毫秒)
connection-timeout: 60000 # 连接超时时间(毫秒)
pool-name: 'SpringBootHikariCP' # 连接池名字
leak-detection-threshold: 30000 # 连接泄露检测阈值(毫秒)
data:
redis:
host: ${chint.redis.host}