1.修复部分拼写问题

2.去掉部分无用代码
master
廖亦浪 3 years ago
parent 90df02d8ca
commit 01061c6093

@ -3,6 +3,7 @@ package com.java3y.austin.constant;
/** /**
* *
*
* @author 3y * @author 3y
*/ */
public class AustinConstant { public class AustinConstant {
@ -17,7 +18,7 @@ public class AustinConstant {
/** /**
* *
*/ */
public final static String YYYYMMDD = "yyyyMMdd"; public final static String YYYY_MM_DD = "yyyyMMdd";
/** /**
@ -27,5 +28,4 @@ public class AustinConstant {
public final static String APOLLO_DEFAULT_VALUE_JSON_ARRAY = "[]"; public final static String APOLLO_DEFAULT_VALUE_JSON_ARRAY = "[]";
} }

@ -9,6 +9,7 @@ import java.util.concurrent.TimeUnit;
/** /**
* 线 * 线
*
* @author 3y * @author 3y
*/ */
public class ThreadPoolConfig { public class ThreadPoolConfig {
@ -16,19 +17,17 @@ public class ThreadPoolConfig {
/** /**
* @param coreSize * @param coreSize
* @param maxSize * @param maxSize
* @param queueSize * @param queueSize CallerRunsPolicy
* CallerRunsPolicy
* @return * @return
*/ */
public static ExecutorService getThreadPool(Integer coreSize, Integer maxSize, Integer queueSize) { public static ExecutorService getThreadPool(Integer coreSize, Integer maxSize, Integer queueSize) {
ThreadPoolExecutor threadPoolExecutor = ExecutorBuilder.create() return ExecutorBuilder.create()
.setCorePoolSize(coreSize) .setCorePoolSize(coreSize)
.setMaxPoolSize(maxSize) .setMaxPoolSize(maxSize)
.setKeepAliveTime(60, TimeUnit.SECONDS) .setKeepAliveTime(60, TimeUnit.SECONDS)
.setWorkQueue(new LinkedBlockingQueue<>(queueSize)) .setWorkQueue(new LinkedBlockingQueue<>(queueSize))
.setHandler(new ThreadPoolExecutor.CallerRunsPolicy()) .setHandler(new ThreadPoolExecutor.CallerRunsPolicy())
.build(); .build();
return threadPoolExecutor;
} }

@ -38,14 +38,14 @@ public class Receiver {
Optional<String> kafkaMessage = Optional.ofNullable(consumerRecord.value()); Optional<String> kafkaMessage = Optional.ofNullable(consumerRecord.value());
if (kafkaMessage.isPresent()) { if (kafkaMessage.isPresent()) {
List<TaskInfo> TaskInfoLists = JSON.parseArray(kafkaMessage.get(), TaskInfo.class); List<TaskInfo> taskInfoLists = JSON.parseArray(kafkaMessage.get(), TaskInfo.class);
String messageGroupId = GroupIdMappingUtils.getGroupIdByTaskInfo(TaskInfoLists.get(0)); String messageGroupId = GroupIdMappingUtils.getGroupIdByTaskInfo(taskInfoLists.get(0));
/** /**
* *
*/ */
if (topicGroupId.equals(messageGroupId)) { if (topicGroupId.equals(messageGroupId)) {
for (TaskInfo taskInfo : TaskInfoLists) { for (TaskInfo taskInfo : taskInfoLists) {
LogUtils.print(LogParam.builder().bizType(LOG_BIZ_TYPE).object(taskInfo).build(), AnchorInfo.builder().ids(taskInfo.getReceiver()).businessId(taskInfo.getBusinessId()).state(AnchorState.RECEIVE.getCode()).build()); LogUtils.print(LogParam.builder().bizType(LOG_BIZ_TYPE).object(taskInfo).build(), AnchorInfo.builder().ids(taskInfo.getReceiver()).businessId(taskInfo.getBusinessId()).state(AnchorState.RECEIVE.getCode()).build());
Task task = context.getBean(Task.class).setTaskInfo(taskInfo); Task task = context.getBean(Task.class).setTaskInfo(taskInfo);
taskPendingHolder.route(topicGroupId).execute(task); taskPendingHolder.route(topicGroupId).execute(task);

@ -47,9 +47,9 @@ public class TencentSmsScript implements SmsScript {
public List<SmsRecord> send(SmsParam smsParam) throws Exception { public List<SmsRecord> send(SmsParam smsParam) throws Exception {
TencentSmsParam tencentSmsParam = accountUtils.getAccount(smsParam.getSendAccount(), SMS_ACCOUNT_KEY, PREFIX, TencentSmsParam.builder().build()); TencentSmsParam tencentSmsParam = accountUtils.getAccount(smsParam.getSendAccount(), SMS_ACCOUNT_KEY, PREFIX, TencentSmsParam.builder().build());
SmsClient client = init(tencentSmsParam); SmsClient client = init(tencentSmsParam);
SendSmsRequest request = assembleReq(smsParam,tencentSmsParam); SendSmsRequest request = assembleReq(smsParam, tencentSmsParam);
SendSmsResponse response = client.SendSms(request); SendSmsResponse response = client.SendSms(request);
return assembleSmsRecord(smsParam, response,tencentSmsParam); return assembleSmsRecord(smsParam, response, tencentSmsParam);
} }
@ -66,7 +66,7 @@ public class TencentSmsScript implements SmsScript {
.reverse().substring(0, PHONE_NUM)).reverse().toString(); .reverse().substring(0, PHONE_NUM)).reverse().toString();
SmsRecord smsRecord = SmsRecord.builder() SmsRecord smsRecord = SmsRecord.builder()
.sendDate(Integer.valueOf(DateUtil.format(new Date(), AustinConstant.YYYYMMDD))) .sendDate(Integer.valueOf(DateUtil.format(new Date(), AustinConstant.YYYY_MM_DD)))
.messageTemplateId(smsParam.getMessageTemplateId()) .messageTemplateId(smsParam.getMessageTemplateId())
.phone(Long.valueOf(phone)) .phone(Long.valueOf(phone))
.supplierId(tencentSmsParam.getSupplierId()) .supplierId(tencentSmsParam.getSupplierId())
@ -102,6 +102,7 @@ public class TencentSmsScript implements SmsScript {
/** /**
* client * client
*
* @param account * @param account
*/ */
private SmsClient init(TencentSmsParam account) { private SmsClient init(TencentSmsParam account) {

@ -49,7 +49,7 @@ public abstract class AbstractDeduplicationService implements DeduplicationServi
String value = inRedisValue.get(key); String value = inRedisValue.get(key);
// 符合条件的用户 // 符合条件的用户
if (value != null && Integer.valueOf(value) >= param.getCountNum()) { if (value != null && Integer.parseInt(value) >= param.getCountNum()) {
filterReceiver.add(receiver); filterReceiver.add(receiver);
} else { } else {
readyPutRedisReceiver.add(receiver); readyPutRedisReceiver.add(receiver);

@ -14,7 +14,6 @@ import com.java3y.austin.pipeline.ProcessContext;
import com.java3y.austin.vo.BasicResultVO; import com.java3y.austin.vo.BasicResultVO;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import java.util.HashSet;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
@ -22,7 +21,7 @@ import java.util.stream.Collectors;
/** /**
* @author 3y * @author 3y
* * <p>
* *
*/ */
@Slf4j @Slf4j
@ -43,12 +42,12 @@ public class AfterParamCheckAction implements BusinessProcess {
if (CollUtil.isEmpty(taskInfo)) { if (CollUtil.isEmpty(taskInfo)) {
context.setNeedBreak(true).setResponse(BasicResultVO.fail(RespStatusEnum.CLIENT_BAD_PARAMETERS)); context.setNeedBreak(true).setResponse(BasicResultVO.fail(RespStatusEnum.CLIENT_BAD_PARAMETERS));
return;
} }
} }
/** /**
* *
*
* @param taskInfo * @param taskInfo
*/ */
private void filterIllegalPhoneNum(List<TaskInfo> taskInfo) { private void filterIllegalPhoneNum(List<TaskInfo> taskInfo) {

@ -11,14 +11,15 @@ import com.java3y.austin.vo.BasicResultVO;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.Arrays; import java.util.Collections;
/** /**
* *
*
* @author 3y * @author 3y
*/ */
@Service @Service
public class SendServiceImpl implements SendService { public class SendServiceImpl implements SendService {
@Autowired @Autowired
private ProcessController processController; private ProcessController processController;
@ -29,7 +30,7 @@ public class SendServiceImpl implements SendService {
SendTaskModel sendTaskModel = SendTaskModel.builder() SendTaskModel sendTaskModel = SendTaskModel.builder()
.messageTemplateId(sendRequest.getMessageTemplateId()) .messageTemplateId(sendRequest.getMessageTemplateId())
.messageParamList(Arrays.asList(sendRequest.getMessageParam())) .messageParamList(Collections.singletonList(sendRequest.getMessageParam()))
.build(); .build();
ProcessContext context = ProcessContext.builder() ProcessContext context = ProcessContext.builder()

@ -10,55 +10,55 @@ import java.util.Map;
/** /**
* @author 3y * @author 3y
* *
* * <p>
* austin{$var} * austin{$var}
*/ */
public class ContentHolderUtil { public class ContentHolderUtil {
/** /**
* *
*/ */
private static final String PLACE_HOLDER_PREFIX = "{$"; private static final String PLACE_HOLDER_PREFIX = "{$";
/** /**
* *
*/ */
private static final String PLACE_HOLDER_ENDFIX = "}"; private static final String PLACE_HOLDER_SUFFIX = "}";
private static final StandardEvaluationContext EVALUTION_CONTEXT; private static final StandardEvaluationContext EVALUATION_CONTEXT;
private static PropertyPlaceholderHelper propertyPlaceholderHelper = new PropertyPlaceholderHelper( private static final PropertyPlaceholderHelper propertyPlaceholderHelper = new PropertyPlaceholderHelper(
PLACE_HOLDER_PREFIX, PLACE_HOLDER_ENDFIX); PLACE_HOLDER_PREFIX, PLACE_HOLDER_SUFFIX);
static { static {
EVALUTION_CONTEXT = new StandardEvaluationContext(); EVALUATION_CONTEXT = new StandardEvaluationContext();
EVALUTION_CONTEXT.addPropertyAccessor(new MapAccessor()); EVALUATION_CONTEXT.addPropertyAccessor(new MapAccessor());
} }
public static String replacePlaceHolder(final String template, final Map<String, String> paramMap) { public static String replacePlaceHolder(final String template, final Map<String, String> paramMap) {
String replacedPushContent = propertyPlaceholderHelper.replacePlaceholders(template, String replacedPushContent = propertyPlaceholderHelper.replacePlaceholders(template,
new CustomPlaceholderResolver(paramMap)); new CustomPlaceholderResolver(paramMap));
return replacedPushContent; return replacedPushContent;
} }
private static class CustomPlaceholderResolver implements PropertyPlaceholderHelper.PlaceholderResolver { private static class CustomPlaceholderResolver implements PropertyPlaceholderHelper.PlaceholderResolver {
private Map<String, String> paramMap; private final Map<String, String> paramMap;
public CustomPlaceholderResolver(Map<String, String> paramMap) { public CustomPlaceholderResolver(Map<String, String> paramMap) {
super(); super();
this.paramMap = paramMap; this.paramMap = paramMap;
} }
@Override @Override
public String resolvePlaceholder(String placeholderName) { public String resolvePlaceholder(String placeholderName) {
String value = paramMap.get(placeholderName); String value = paramMap.get(placeholderName);
if (null == value) { if (null == value) {
String errorStr = MessageFormat.format("template:{} require param:{},but not exist! paramMap:{}", String errorStr = MessageFormat.format("template:{} require param:{},but not exist! paramMap:{}",
placeholderName, paramMap.toString()); placeholderName, paramMap.toString());
throw new IllegalArgumentException(errorStr); throw new IllegalArgumentException(errorStr);
} }
return value; return value;
} }
} }
} }

@ -4,7 +4,6 @@ import cn.hutool.core.map.MapUtil;
import com.google.common.base.Throwables; import com.google.common.base.Throwables;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import okhttp3.*; import okhttp3.*;
import org.jetbrains.annotations.NotNull;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
@ -53,7 +52,7 @@ public class OkHttpUtils {
* @param headers {k1, v1 k2, v2, ...} * @param headers {k1, v1 k2, v2, ...}
* @return string * @return string
*/ */
public String doGetWithHeaders(String url, Map<String,String> headers) { public String doGetWithHeaders(String url, Map<String, String> headers) {
return doGet(url, null, headers); return doGet(url, null, headers);
} }
@ -66,7 +65,7 @@ public class OkHttpUtils {
* @param headers {k1, v1 k2, v2, ...} * @param headers {k1, v1 k2, v2, ...}
* @return string * @return string
*/ */
public String doGet(String url, Map<String, String> params, Map<String,String> headers) { public String doGet(String url, Map<String, String> params, Map<String, String> headers) {
StringBuilder sb = new StringBuilder(url); StringBuilder sb = new StringBuilder(url);
if (params != null && params.keySet().size() > 0) { if (params != null && params.keySet().size() > 0) {
boolean firstFlag = true; boolean firstFlag = true;
@ -82,7 +81,7 @@ public class OkHttpUtils {
Request.Builder builder = getBuilderWithHeaders(headers); Request.Builder builder = getBuilderWithHeaders(headers);
Request request = builder.url(sb.toString()).build(); Request request = builder.url(sb.toString()).build();
log.info("do get request and url[{}]", sb.toString()); log.info("do get request and url[{}]", sb);
return execute(request); return execute(request);
} }
@ -94,7 +93,7 @@ public class OkHttpUtils {
* @param headers {k1, v1 k2, v2, ...} * @param headers {k1, v1 k2, v2, ...}
* @return string * @return string
*/ */
public String doPost(String url, Map<String, String> params, Map<String,String> headers) { public String doPost(String url, Map<String, String> params, Map<String, String> headers) {
FormBody.Builder formBuilder = new FormBody.Builder(); FormBody.Builder formBuilder = new FormBody.Builder();
if (params != null && params.keySet().size() > 0) { if (params != null && params.keySet().size() > 0) {
@ -117,7 +116,7 @@ public class OkHttpUtils {
* @param headers {k1, v1 k2, v2, ...} * @param headers {k1, v1 k2, v2, ...}
* @return * @return
*/ */
private Request.Builder getBuilderWithHeaders(Map<String,String> headers) { private Request.Builder getBuilderWithHeaders(Map<String, String> headers) {
Request.Builder builder = new Request.Builder(); Request.Builder builder = new Request.Builder();
if (!MapUtil.isEmpty(headers)) { if (!MapUtil.isEmpty(headers)) {
for (Map.Entry<String, String> entry : headers.entrySet()) { for (Map.Entry<String, String> entry : headers.entrySet()) {
@ -166,7 +165,7 @@ public class OkHttpUtils {
} }
private String executePost(String url, String data, MediaType contentType, Map<String,String> headers) { private String executePost(String url, String data, MediaType contentType, Map<String, String> headers) {
RequestBody requestBody = RequestBody.create(data.getBytes(StandardCharsets.UTF_8), contentType); RequestBody requestBody = RequestBody.create(data.getBytes(StandardCharsets.UTF_8), contentType);
Request.Builder builder = getBuilderWithHeaders(headers); Request.Builder builder = getBuilderWithHeaders(headers);
Request request = builder.url(url).post(requestBody).build(); Request request = builder.url(url).post(requestBody).build();
@ -175,18 +174,12 @@ public class OkHttpUtils {
} }
private String execute(Request request) { private String execute(Request request) {
Response response = null; try (Response response = okHttpClient.newCall(request).execute()) {
try {
response = okHttpClient.newCall(request).execute();
if (response.isSuccessful()) { if (response.isSuccessful()) {
return response.body().string(); return response.body().string();
} }
} catch (Exception e) { } catch (Exception e) {
log.error(Throwables.getStackTraceAsString(e)); log.error(Throwables.getStackTraceAsString(e));
} finally {
if (response != null) {
response.close();
}
} }
return ""; return "";
} }

@ -12,7 +12,7 @@ import java.util.Date;
*/ */
public class TaskInfoUtils { public class TaskInfoUtils {
private static int TYPE_FLAG = 1000000; private static final int TYPE_FLAG = 1000000;
/** /**
* BusinessId * BusinessId
@ -20,7 +20,7 @@ public class TaskInfoUtils {
* (16) * (16)
*/ */
public static Long generateBusinessId(Long templateId, Integer templateType) { public static Long generateBusinessId(Long templateId, Integer templateType) {
Integer today = Integer.valueOf(DateUtil.format(new Date(), AustinConstant.YYYYMMDD)); Integer today = Integer.valueOf(DateUtil.format(new Date(), AustinConstant.YYYY_MM_DD));
return Long.valueOf(String.format("%d%s", templateType * TYPE_FLAG + templateId, today)); return Long.valueOf(String.format("%d%s", templateType * TYPE_FLAG + templateId, today));
} }

Loading…
Cancel
Save