1.修复部分拼写问题

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

@ -3,6 +3,7 @@ package com.java3y.austin.constant;
/**
*
*
* @author 3y
*/
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 = "[]";
}

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

@ -38,14 +38,14 @@ public class Receiver {
Optional<String> kafkaMessage = Optional.ofNullable(consumerRecord.value());
if (kafkaMessage.isPresent()) {
List<TaskInfo> TaskInfoLists = JSON.parseArray(kafkaMessage.get(), TaskInfo.class);
String messageGroupId = GroupIdMappingUtils.getGroupIdByTaskInfo(TaskInfoLists.get(0));
List<TaskInfo> taskInfoLists = JSON.parseArray(kafkaMessage.get(), TaskInfo.class);
String messageGroupId = GroupIdMappingUtils.getGroupIdByTaskInfo(taskInfoLists.get(0));
/**
*
*/
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());
Task task = context.getBean(Task.class).setTaskInfo(taskInfo);
taskPendingHolder.route(topicGroupId).execute(task);

@ -47,9 +47,9 @@ public class TencentSmsScript implements SmsScript {
public List<SmsRecord> send(SmsParam smsParam) throws Exception {
TencentSmsParam tencentSmsParam = accountUtils.getAccount(smsParam.getSendAccount(), SMS_ACCOUNT_KEY, PREFIX, TencentSmsParam.builder().build());
SmsClient client = init(tencentSmsParam);
SendSmsRequest request = assembleReq(smsParam,tencentSmsParam);
SendSmsRequest request = assembleReq(smsParam, tencentSmsParam);
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();
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())
.phone(Long.valueOf(phone))
.supplierId(tencentSmsParam.getSupplierId())
@ -102,6 +102,7 @@ public class TencentSmsScript implements SmsScript {
/**
* client
*
* @param account
*/
private SmsClient init(TencentSmsParam account) {

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

@ -14,7 +14,6 @@ import com.java3y.austin.pipeline.ProcessContext;
import com.java3y.austin.vo.BasicResultVO;
import lombok.extern.slf4j.Slf4j;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
@ -22,7 +21,7 @@ import java.util.stream.Collectors;
/**
* @author 3y
*
* <p>
*
*/
@Slf4j
@ -43,12 +42,12 @@ public class AfterParamCheckAction implements BusinessProcess {
if (CollUtil.isEmpty(taskInfo)) {
context.setNeedBreak(true).setResponse(BasicResultVO.fail(RespStatusEnum.CLIENT_BAD_PARAMETERS));
return;
}
}
/**
*
*
* @param 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.stereotype.Service;
import java.util.Arrays;
import java.util.Collections;
/**
*
*
* @author 3y
*/
@Service
public class SendServiceImpl implements SendService {
public class SendServiceImpl implements SendService {
@Autowired
private ProcessController processController;
@ -29,7 +30,7 @@ public class SendServiceImpl implements SendService {
SendTaskModel sendTaskModel = SendTaskModel.builder()
.messageTemplateId(sendRequest.getMessageTemplateId())
.messageParamList(Arrays.asList(sendRequest.getMessageParam()))
.messageParamList(Collections.singletonList(sendRequest.getMessageParam()))
.build();
ProcessContext context = ProcessContext.builder()

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

@ -4,7 +4,6 @@ import cn.hutool.core.map.MapUtil;
import com.google.common.base.Throwables;
import lombok.extern.slf4j.Slf4j;
import okhttp3.*;
import org.jetbrains.annotations.NotNull;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@ -53,7 +52,7 @@ public class OkHttpUtils {
* @param headers {k1, v1 k2, v2, ...}
* @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);
}
@ -66,7 +65,7 @@ public class OkHttpUtils {
* @param headers {k1, v1 k2, v2, ...}
* @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);
if (params != null && params.keySet().size() > 0) {
boolean firstFlag = true;
@ -82,7 +81,7 @@ public class OkHttpUtils {
Request.Builder builder = getBuilderWithHeaders(headers);
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);
}
@ -94,7 +93,7 @@ public class OkHttpUtils {
* @param headers {k1, v1 k2, v2, ...}
* @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();
if (params != null && params.keySet().size() > 0) {
@ -117,7 +116,7 @@ public class OkHttpUtils {
* @param headers {k1, v1 k2, v2, ...}
* @return
*/
private Request.Builder getBuilderWithHeaders(Map<String,String> headers) {
private Request.Builder getBuilderWithHeaders(Map<String, String> headers) {
Request.Builder builder = new Request.Builder();
if (!MapUtil.isEmpty(headers)) {
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);
Request.Builder builder = getBuilderWithHeaders(headers);
Request request = builder.url(url).post(requestBody).build();
@ -175,18 +174,12 @@ public class OkHttpUtils {
}
private String execute(Request request) {
Response response = null;
try {
response = okHttpClient.newCall(request).execute();
try (Response response = okHttpClient.newCall(request).execute()) {
if (response.isSuccessful()) {
return response.body().string();
}
} catch (Exception e) {
log.error(Throwables.getStackTraceAsString(e));
} finally {
if (response != null) {
response.close();
}
}
return "";
}

@ -12,7 +12,7 @@ import java.util.Date;
*/
public class TaskInfoUtils {
private static int TYPE_FLAG = 1000000;
private static final int TYPE_FLAG = 1000000;
/**
* BusinessId
@ -20,7 +20,7 @@ public class TaskInfoUtils {
* (16)
*/
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));
}

Loading…
Cancel
Save