Commit da5641c7f59a7b53c95934df2023473127def31e

Authored by 张志伟
1 parent 5b538595

feature(*): 新增查询线索到期时间的api接口

- 新增查询线索到期时间的api接口
fw-valhalla-common/src/main/java/cn/fw/valhalla/common/utils/ThreadPoolUtil.java
1 1 package cn.fw.valhalla.common.utils;
2 2  
3 3 import cn.hutool.core.thread.ExecutorBuilder;
  4 +import com.google.common.util.concurrent.ThreadFactoryBuilder;
4 5  
5 6 import java.util.concurrent.ExecutorService;
6 7 import java.util.concurrent.LinkedBlockingQueue;
7 8  
8 9 /**
9   - * ThreadPoolUtl
  10 + * ThreadPoolUtil
10 11 *
11 12 * @author : kurisu
12 13 * @version : 2.0
13   - * @className : ThreadPoolUtl
14   - * @description : ThreadPoolUtl
  14 + * @className : ThreadPoolUtil
  15 + * @description : ThreadPoolUtil
15 16 * @date : 2023-04-19 17:31
16 17 */
17 18 public class ThreadPoolUtil {
... ... @@ -21,7 +22,9 @@ public class ThreadPoolUtil {
21 22 private ThreadPoolUtil() {
22 23 this.executor = ExecutorBuilder.create()
23 24 .setCorePoolSize(20)
24   - .setMaxPoolSize(60)
  25 + .setMaxPoolSize(500)
  26 + .setThreadFactory(new ThreadFactoryBuilder().setNameFormat("valhalla-custom-%d").build())
  27 + .setAllowCoreThreadTimeOut(true)
25 28 .setWorkQueue(new LinkedBlockingQueue<>(4096))
26 29 .build();
27 30 }
... ...
fw-valhalla-rpc/src/main/java/cn/fw/valhalla/rpc/member/MemberRpcService.java
... ... @@ -8,7 +8,6 @@ import cn.fw.member.sdk.vo.BatchUserParam;
8 8 import cn.fw.member.sdk.vo.MobileLocation;
9 9 import cn.fw.member.sdk.vo.UserBaseInfoVO;
10 10 import cn.fw.member.sdk.vo.UserRegistryVO;
11   -import cn.fw.valhalla.common.utils.ThreadPoolUtil;
12 11 import cn.fw.valhalla.rpc.member.dto.MemberUserDTO;
13 12 import lombok.extern.slf4j.Slf4j;
14 13 import org.apache.commons.lang3.StringUtils;
... ... @@ -22,7 +21,6 @@ import java.util.ArrayList;
22 21 import java.util.Collections;
23 22 import java.util.List;
24 23 import java.util.Objects;
25   -import java.util.concurrent.CompletableFuture;
26 24  
27 25 import static org.apache.commons.lang3.Validate.isTrue;
28 26 import static org.apache.commons.lang3.Validate.notNull;
... ... @@ -134,7 +132,7 @@ public class MemberRpcService {
134 132 BeanUtils.copyProperties(user, userDTO);
135 133 return userDTO;
136 134 } catch (Exception e) {
137   - log.error("调用Member系统根据会员手机号[{}]获取会员信息失败,原因:{}", mobile, e);
  135 + log.error("调用Member系统根据会员手机号[{}]获取会员信息失败", mobile, e);
138 136 }
139 137 return null;
140 138 }
... ... @@ -171,29 +169,27 @@ public class MemberRpcService {
171 169 return "";
172 170 }
173 171 try {
174   - CompletableFuture<String> future1 = CompletableFuture.supplyAsync(() -> {
175   - MobileUtil.Result result = MobileUtil.attribution(mobile);
176   - String att = "";
177   - if (Objects.nonNull(result)) {
178   - att = result.getProvince().concat(" ").concat(result.getCity());
179   - }
180   - return att;
181   - }, ThreadPoolUtil.getInstance().getExecutor());
  172 + MobileUtil.Result result = MobileUtil.attribution(mobile);
  173 + String att = "";
  174 + if (Objects.nonNull(result)) {
  175 + att = result.getProvince().concat(" ").concat(result.getCity());
  176 + }
  177 +
  178 + if (!StringUtils.isBlank(att.trim())) {
  179 + return att.trim();
  180 + }
182 181  
183   - CompletableFuture<String> future2 = CompletableFuture.supplyAsync(() -> {
184   - Message<MobileLocation> msg = functionApi.queryMobileLocation(mobile);
185   - if (!msg.isSuccess()) {
186   - return "";
187   - }
188   - MobileLocation data = msg.getData();
189   - if (data != null) {
190   - String province = data.getProvince();
191   - String city = data.getCity();
192   - return province.concat(" ").concat(city);
193   - }
  182 + Message<MobileLocation> msg = functionApi.queryMobileLocation(mobile);
  183 + if (!msg.isSuccess()) {
194 184 return "";
195   - }, ThreadPoolUtil.getInstance().getExecutor());
196   - return future1.applyToEither(future2, String::trim).join();
  185 + }
  186 + MobileLocation data = msg.getData();
  187 + if (data != null) {
  188 + String province = data.getProvince();
  189 + String city = data.getCity();
  190 + att = province.concat(" ").concat(city);
  191 + }
  192 + return att.trim();
197 193 } catch (Exception e) {
198 194 log.warn("查询手机号归属地失败:", e);
199 195 }
... ...
fw-valhalla-service/src/main/java/cn/fw/valhalla/service/bus/follow/ClueApiBizService.java
... ... @@ -109,7 +109,7 @@ public class ClueApiBizService {
109 109 .map(vin -> CompletableFuture.runAsync(() -> list.add(queryClueDeadline(vin, groupId)), ThreadPoolUtil.getInstance().getExecutor()))
110 110 .<CompletableFuture<Void>>toArray(CompletableFuture[]::new);
111 111 try {
112   - CompletableFuture.allOf(futureArr).get();
  112 + CompletableFuture.allOf(futureArr).join();
113 113 } catch (Exception e) {
114 114 log.error("Failed to query clue deadline", e);
115 115 }
... ...