فهرست منبع

地区
线程池

24282 2 سال پیش
والد
کامیت
c8a8842adb

+ 6 - 0
hx-area/src/main/java/com/fjhx/area/service/AreaInfoService.java

@@ -5,6 +5,7 @@ import com.fjhx.area.entity.dto.AreaInfoSelectDto;
 import com.fjhx.area.entity.po.AreaInfo;
 
 import java.util.List;
+import java.util.Map;
 
 /**
  * <p>
@@ -26,4 +27,9 @@ public interface AreaInfoService extends IService<AreaInfo> {
      */
     void setAreaName(List<? extends ISetAreaName> setAreaNameList);
 
+    /**
+     * 获取地区map
+     */
+    Map<String, String> getAreaMapByIds(List<String> idList);
+
 }

+ 7 - 3
hx-area/src/main/java/com/fjhx/area/service/impl/AreaInfoServiceImpl.java

@@ -12,8 +12,6 @@ import com.fjhx.area.service.AreaInfoService;
 import com.fjhx.area.service.ISetAreaName;
 import com.ruoyi.common.constant.BaseSourceConstant;
 import org.springframework.stereotype.Service;
-import org.springframework.transaction.annotation.Propagation;
-import org.springframework.transaction.annotation.Transactional;
 
 import java.util.HashSet;
 import java.util.List;
@@ -38,7 +36,6 @@ public class AreaInfoServiceImpl extends ServiceImpl<AreaInfoMapper, AreaInfo> i
         return list(Wrappers.<AreaInfo>lambdaQuery().eq(AreaInfo::getParentId, parentId));
     }
 
-    @Transactional(propagation = Propagation.REQUIRES_NEW)
     @DS(BaseSourceConstant.BASE)
     @Override
     public void setAreaName(List<? extends ISetAreaName> areaList) {
@@ -88,4 +85,11 @@ public class AreaInfoServiceImpl extends ServiceImpl<AreaInfoMapper, AreaInfo> i
 
     }
 
+    @DS(BaseSourceConstant.BASE)
+    @Override
+    public Map<String, String> getAreaMapByIds(List<String> idList) {
+        List<AreaInfo> areaInfos = listByIds(idList);
+        return areaInfos.stream().collect(Collectors.toMap(AreaInfo::getId, AreaInfo::getName));
+    }
+
 }

+ 8 - 0
hx-area/src/main/java/com/fjhx/area/utils/AreaUtil.java

@@ -6,6 +6,7 @@ import com.fjhx.area.service.ISetAreaName;
 
 import java.util.Collections;
 import java.util.List;
+import java.util.Map;
 
 public class AreaUtil {
 
@@ -25,4 +26,11 @@ public class AreaUtil {
         fileInfoService.setAreaName(Collections.singletonList(setAreaName));
     }
 
+    /**
+     * 获取地区map
+     */
+    public static Map<String, String> getAreaMapByIds(List<String> idList) {
+        return fileInfoService.getAreaMapByIds(idList);
+    }
+
 }

+ 10 - 13
ruoyi-framework/src/main/java/com/ruoyi/framework/config/ThreadPoolConfig.java

@@ -4,11 +4,8 @@ import com.ruoyi.common.utils.Threads;
 import org.apache.commons.lang3.concurrent.BasicThreadFactory;
 import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.Configuration;
-import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
 
-import java.util.concurrent.ScheduledExecutorService;
-import java.util.concurrent.ScheduledThreadPoolExecutor;
-import java.util.concurrent.ThreadPoolExecutor;
+import java.util.concurrent.*;
 
 /**
  * 线程池配置
@@ -32,15 +29,15 @@ public class ThreadPoolConfig {
     public static final String threadPoolTaskExecutor = "threadPoolTaskExecutor";
 
     @Bean(name = threadPoolTaskExecutor)
-    public ThreadPoolTaskExecutor threadPoolTaskExecutor() {
-        ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
-        executor.setMaxPoolSize(maxPoolSize);
-        executor.setCorePoolSize(corePoolSize);
-        executor.setQueueCapacity(queueCapacity);
-        executor.setKeepAliveSeconds(keepAliveSeconds);
-        // 线程池对拒绝任务(无线程可用)的处理策略
-        executor.setRejectedExecutionHandler(new ThreadPoolExecutor.CallerRunsPolicy());
-        return executor;
+    public ThreadPoolExecutor threadPoolTaskExecutor() {
+        return new ThreadPoolExecutor(
+                10,
+                20,
+                60,
+                TimeUnit.SECONDS,
+                new ArrayBlockingQueue<>(30),
+                new ThreadPoolExecutor.CallerRunsPolicy()
+        );
     }
 
     /**