hzh 4 лет назад
Родитель
Сommit
955611d338

+ 5 - 3
src/main/java/platform/config/AsyncConfig.java

@@ -7,6 +7,7 @@ import org.springframework.scheduling.annotation.EnableAsync;
 import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
 
 import java.util.concurrent.Executor;
+import java.util.concurrent.ThreadPoolExecutor;
 
 /**
  * @author lhf
@@ -19,9 +20,10 @@ public class AsyncConfig implements AsyncConfigurer {
     @Override
     public Executor getAsyncExecutor() {
         ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
-        executor.setCorePoolSize(7);
-        executor.setMaxPoolSize(42);
-        executor.setQueueCapacity(11);
+        executor.setCorePoolSize(Runtime.getRuntime().availableProcessors());
+        executor.setMaxPoolSize(Runtime.getRuntime().availableProcessors() * 2);
+        executor.setQueueCapacity(100);
+        executor.setRejectedExecutionHandler(new ThreadPoolExecutor.CallerRunsPolicy());
         executor.initialize();
         return executor;
     }

+ 1 - 0
src/main/java/platform/modules/company/service/ProjectApplicationService.java

@@ -15,6 +15,7 @@ import org.apache.commons.lang3.StringUtils;
 import org.apache.xmlbeans.impl.xb.xsdschema.Public;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
+import org.springframework.scheduling.annotation.Async;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.ui.ModelMap;

+ 5 - 3
src/main/java/platform/modules/sys/web/UserController.java

@@ -16,6 +16,7 @@ import platform.common.annotation.OperationLog;
 import platform.common.base.controller.BaseController;
 import platform.common.exception.BaseException;
 import platform.common.util.ShiroUtils;
+import platform.common.util.ThreadPoolUtil;
 import platform.common.util.VerificationCodeUtil;
 import platform.modules.api.dto.SyncUserDto;
 import platform.modules.api.service.SkyImageApiService;
@@ -38,6 +39,7 @@ import platform.modules.sys.vo.RoleQuery;
 
 import java.util.ArrayList;
 import java.util.List;
+import java.util.concurrent.CompletableFuture;
 
 /**
  * 用户管理(政府)Controller
@@ -469,17 +471,17 @@ public class UserController extends BaseController {
         u.setPassword(SecureUtil.md5().digestHex(resetPassword));
         Boolean flag = userService.updateUser(u);
         if (flag) {
-            new Thread(() -> {
+            CompletableFuture.runAsync(() -> {
                 //同步信息给天启
                 SyncUserDto dto = new SyncUserDto();
                 dto.setAction(Constant.METHOD_STATUS.UPDATE);
-                dto.setOldUserName(u.getNick_name());
+                dto.setOldUserName("");
                 dto.setUserName(u.getUser_name());
                 dto.setUserLoginName(u.getNick_name());
                 dto.setPassword(resetPassword);
                 dto.setToken(skyImageApiService.accessToken());
                 skyImageApiService.syncUserInfo(dto);
-            }, "syncUserInfo").start();
+            }, ThreadPoolUtil.getInstance());
 
             log.info("重置密码成功! id= {}, u = {}", id);
             return ResponseMessage.success("重置密码成功");