1. 微信服务号和微信小程序handler 单发 适配埋点结构

2. web后端增加埋点微信渠道的描述
3. idea reformat code
pull/57/head
3y 11 months ago
parent 038a16dbdc
commit d63f4b3959

@ -6,6 +6,7 @@ import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serializable;
import java.util.Set;
/**
@ -17,7 +18,7 @@ import java.util.Set;
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class TaskInfo {
public class TaskInfo implements Serializable {
/**
* Id, , , 使 messageId

@ -27,16 +27,14 @@ public abstract class AbstractDeduplicationService implements DeduplicationServi
@Autowired
private DeduplicationHolder deduplicationHolder;
@Autowired
private LogUtils logUtils;
@PostConstruct
private void init() {
deduplicationHolder.putService(deduplicationType, this);
}
@Autowired
private LogUtils logUtils;
@Override
public void deduplication(DeduplicationParam param) {
TaskInfo taskInfo = param.getTaskInfo();

@ -18,6 +18,8 @@ import org.springframework.stereotype.Service;
public class FrequencyDeduplicationService extends AbstractDeduplicationService {
private static final String PREFIX = "FRE";
@Autowired
public FrequencyDeduplicationService(@Qualifier("SimpleLimitService") LimitService limitService) {
@ -26,8 +28,6 @@ public class FrequencyDeduplicationService extends AbstractDeduplicationService
}
private static final String PREFIX = "FRE";
/**
* key
* <p>

@ -16,24 +16,22 @@ import java.util.Objects;
* handler
*/
public abstract class BaseHandler implements Handler {
@Autowired
private HandlerHolder handlerHolder;
@Autowired
private LogUtils logUtils;
@Autowired
private FlowControlFactory flowControlFactory;
/**
* Code
*
*/
protected Integer channelCode;
/**
*
*
*/
protected FlowControlParam flowControlParam;
@Autowired
private HandlerHolder handlerHolder;
@Autowired
private LogUtils logUtils;
@Autowired
private FlowControlFactory flowControlFactory;
/**
* Handler
@ -43,21 +41,13 @@ public abstract class BaseHandler implements Handler {
handlerHolder.putHandler(channelCode, this);
}
/**
*
*
* @param taskInfo
*/
public void flowControl(TaskInfo taskInfo) {
@Override
public void doHandler(TaskInfo taskInfo) {
// 只有子类指定了限流参数,才需要限流
if (Objects.nonNull(flowControlParam)) {
flowControlFactory.flowControl(taskInfo, flowControlParam);
}
}
@Override
public void doHandler(TaskInfo taskInfo) {
flowControl(taskInfo);
if (handler(taskInfo)) {
logUtils.print(AnchorInfo.builder().state(AnchorState.SEND_SUCCESS.getCode()).bizId(taskInfo.getBizId()).messageId(taskInfo.getMessageId()).businessId(taskInfo.getBusinessId()).ids(taskInfo.getReceiver()).build());
return;

@ -50,6 +50,8 @@ import java.util.concurrent.TimeUnit;
public class DingDingWorkNoticeHandler extends BaseHandler implements Handler {
private static final String DING_DING_RECALL_KEY_PREFIX = "RECALL_";
private static final String RECALL_BIZ_TYPE = "DingDingWorkNoticeHandler#recall";
@Autowired
private AccountUtils accountUtils;
@Autowired
@ -63,9 +65,6 @@ public class DingDingWorkNoticeHandler extends BaseHandler implements Handler {
channelCode = ChannelType.DING_DING_WORK_NOTICE.getCode();
}
private static final String DING_DING_RECALL_KEY_PREFIX = "RECALL_";
private static final String RECALL_BIZ_TYPE = "DingDingWorkNoticeHandler#recall";
@Override
public boolean handler(TaskInfo taskInfo) {
try {

@ -16,7 +16,7 @@ import com.java3y.austin.handler.handler.Handler;
import com.java3y.austin.support.utils.AccountUtils;
import com.java3y.austin.support.utils.LogUtils;
import lombok.extern.slf4j.Slf4j;
import me.chanjar.weixin.common.error.WxMpErrorMsgEnum;
import me.chanjar.weixin.common.error.WxCpErrorMsgEnum;
import me.chanjar.weixin.cp.api.WxCpService;
import me.chanjar.weixin.cp.api.impl.WxCpMessageServiceImpl;
import me.chanjar.weixin.cp.api.impl.WxCpServiceImpl;
@ -55,7 +55,7 @@ public class EnterpriseWeChatHandler extends BaseHandler implements Handler {
WxCpDefaultConfigImpl accountConfig = accountUtils.getAccountById(taskInfo.getSendAccount(), WxCpDefaultConfigImpl.class);
WxCpMessageServiceImpl messageService = new WxCpMessageServiceImpl(initService(accountConfig));
WxCpMessageSendResult result = messageService.send(buildWxCpMessage(taskInfo, accountConfig.getAgentId()));
if (Integer.valueOf(WxMpErrorMsgEnum.CODE_0.getCode()).equals(result.getErrCode())) {
if (Integer.valueOf(WxCpErrorMsgEnum.CODE_0.getCode()).equals(result.getErrCode())) {
return true;
}
logUtils.print(AnchorInfo.builder().bizId(taskInfo.getBizId()).messageId(taskInfo.getMessageId()).businessId(taskInfo.getBusinessId())

@ -19,6 +19,7 @@ import com.java3y.austin.handler.handler.Handler;
import com.java3y.austin.support.utils.AccountUtils;
import com.java3y.austin.support.utils.LogUtils;
import lombok.extern.slf4j.Slf4j;
import me.chanjar.weixin.common.error.WxCpErrorMsgEnum;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@ -52,7 +53,7 @@ public class EnterpriseWeChatRobotHandler extends BaseHandler implements Handler
.timeout(2000)
.execute().body();
EnterpriseWeChatRootResult weChatRootResult = JSON.parseObject(result, EnterpriseWeChatRootResult.class);
if (weChatRootResult.getErrcode() == 0) {
if (Integer.valueOf(WxCpErrorMsgEnum.CODE_0.getCode()).equals(weChatRootResult.getErrcode())) {
return true;
}
logUtils.print(AnchorInfo.builder().bizId(taskInfo.getBizId()).messageId(taskInfo.getMessageId()).businessId(taskInfo.getBusinessId())

@ -2,9 +2,9 @@ package com.java3y.austin.handler.handler.impl;
import cn.binarywang.wx.miniapp.api.WxMaService;
import cn.binarywang.wx.miniapp.bean.WxMaSubscribeMessage;
import cn.hutool.core.collection.CollUtil;
import com.alibaba.fastjson.JSON;
import com.google.common.base.Throwables;
import com.google.common.collect.Sets;
import com.java3y.austin.common.domain.AnchorInfo;
import com.java3y.austin.common.domain.RecallTaskInfo;
import com.java3y.austin.common.domain.TaskInfo;
@ -45,16 +45,13 @@ public class MiniProgramAccountHandler extends BaseHandler implements Handler {
try {
MiniProgramContentModel contentModel = (MiniProgramContentModel) taskInfo.getContentModel();
WxMaService wxMaService = accountUtils.getAccountById(taskInfo.getSendAccount(), WxMaService.class);
List<WxMaSubscribeMessage> wxMaSubscribeMessages = assembleReq(taskInfo.getReceiver(), contentModel);
for (WxMaSubscribeMessage message : wxMaSubscribeMessages) {
try {
wxMaService.getSubscribeService().sendSubscribeMsg(message);
} catch (WxErrorException e) {
logUtils.print(AnchorInfo.builder().bizId(taskInfo.getBizId()).messageId(taskInfo.getMessageId()).businessId(taskInfo.getBusinessId())
.ids(Sets.newHashSet(message.getToUser())).state(e.getError().getErrorCode()).build());
}
}
WxMaSubscribeMessage message = assembleReq(taskInfo.getReceiver(), contentModel);
wxMaService.getSubscribeService().sendSubscribeMsg(message);
return true;
} catch (WxErrorException e) {
logUtils.print(AnchorInfo.builder().bizId(taskInfo.getBizId()).messageId(taskInfo.getMessageId()).businessId(taskInfo.getBusinessId())
.ids(taskInfo.getReceiver()).state(e.getError().getErrorCode()).build());
} catch (Exception e) {
log.error("MiniProgramAccountHandler#handler fail:{},params:{}", Throwables.getStackTraceAsString(e), JSON.toJSONString(taskInfo));
}
@ -65,18 +62,13 @@ public class MiniProgramAccountHandler extends BaseHandler implements Handler {
/**
*
*/
private List<WxMaSubscribeMessage> assembleReq(Set<String> receiver, MiniProgramContentModel contentModel) {
List<WxMaSubscribeMessage> messageList = new ArrayList<>(receiver.size());
for (String openId : receiver) {
WxMaSubscribeMessage subscribeMessage = WxMaSubscribeMessage.builder()
.toUser(openId)
.data(getWxMaTemplateData(contentModel.getMiniProgramParam()))
.templateId(contentModel.getTemplateId())
.page(contentModel.getPage())
.build();
messageList.add(subscribeMessage);
}
return messageList;
private WxMaSubscribeMessage assembleReq(Set<String> receiver, MiniProgramContentModel contentModel) {
return WxMaSubscribeMessage.builder()
.toUser(CollUtil.getFirst(receiver.iterator()))
.data(getWxMaTemplateData(contentModel.getMiniProgramParam()))
.templateId(contentModel.getTemplateId())
.page(contentModel.getPage())
.build();
}
/**

@ -1,8 +1,8 @@
package com.java3y.austin.handler.handler.impl;
import cn.hutool.core.collection.CollUtil;
import com.alibaba.fastjson.JSON;
import com.google.common.base.Throwables;
import com.google.common.collect.Sets;
import com.java3y.austin.common.domain.AnchorInfo;
import com.java3y.austin.common.domain.RecallTaskInfo;
import com.java3y.austin.common.domain.TaskInfo;
@ -47,39 +47,31 @@ public class OfficialAccountHandler extends BaseHandler implements Handler {
try {
OfficialAccountsContentModel contentModel = (OfficialAccountsContentModel) taskInfo.getContentModel();
WxMpService wxMpService = accountUtils.getAccountById(taskInfo.getSendAccount(), WxMpService.class);
List<WxMpTemplateMessage> messages = assembleReq(taskInfo.getReceiver(), contentModel);
for (WxMpTemplateMessage message : messages) {
try {
wxMpService.getTemplateMsgService().sendTemplateMsg(message);
} catch (WxErrorException e) {
logUtils.print(AnchorInfo.builder().bizId(taskInfo.getBizId()).messageId(taskInfo.getMessageId()).businessId(taskInfo.getBusinessId())
.ids(Sets.newHashSet(message.getToUser())).state(e.getError().getErrorCode()).build());
}
}
WxMpTemplateMessage message = assembleReq(taskInfo.getReceiver(), contentModel);
wxMpService.getTemplateMsgService().sendTemplateMsg(message);
return true;
} catch (WxErrorException e) {
logUtils.print(AnchorInfo.builder().bizId(taskInfo.getBizId()).messageId(taskInfo.getMessageId()).businessId(taskInfo.getBusinessId())
.ids(taskInfo.getReceiver()).state(e.getError().getErrorCode()).build());
} catch (Exception e) {
log.error("OfficialAccountHandler#handler fail:{},params:{}", Throwables.getStackTraceAsString(e), JSON.toJSONString(taskInfo));
}
return false;
}
/**
*
*/
private List<WxMpTemplateMessage> assembleReq(Set<String> receiver, OfficialAccountsContentModel contentModel) {
List<WxMpTemplateMessage> wxMpTemplateMessages = new ArrayList<>(receiver.size());
for (String openId : receiver) {
WxMpTemplateMessage templateMessage = WxMpTemplateMessage.builder()
.toUser(openId)
.templateId(contentModel.getTemplateId())
.url(contentModel.getUrl())
.data(getWxMpTemplateData(contentModel.getOfficialAccountParam()))
.miniProgram(new WxMpTemplateMessage.MiniProgram(contentModel.getMiniProgramId(), contentModel.getPath(), false))
.build();
wxMpTemplateMessages.add(templateMessage);
}
return wxMpTemplateMessages;
private WxMpTemplateMessage assembleReq(Set<String> receiver, OfficialAccountsContentModel contentModel) {
return WxMpTemplateMessage.builder()
.toUser(CollUtil.getFirst(receiver.iterator()))
.templateId(contentModel.getTemplateId())
.url(contentModel.getUrl())
.data(getWxMpTemplateData(contentModel.getOfficialAccountParam()))
.miniProgram(new WxMpTemplateMessage.MiniProgram(contentModel.getMiniProgramId(), contentModel.getPath(), false))
.build();
}
/**

@ -38,15 +38,14 @@ import java.util.Set;
@Slf4j
public class PushHandler extends BaseHandler implements Handler {
public PushHandler() {
channelCode = ChannelType.PUSH.getCode();
}
@Autowired
private AccountUtils accountUtils;
@Autowired
private AccessTokenUtils accessTokenUtils;
public PushHandler() {
channelCode = ChannelType.PUSH.getCode();
}
@Override
public boolean handler(TaskInfo taskInfo) {

@ -39,29 +39,24 @@ import java.util.Random;
@Slf4j
public class SmsHandler extends BaseHandler implements Handler {
public SmsHandler() {
channelCode = ChannelType.SMS.getCode();
}
/**
*
*/
private static final Integer AUTO_FLOW_RULE = 0;
private static final String FLOW_KEY = "msgTypeSmsConfig";
private static final String FLOW_KEY_PREFIX = "message_type_";
@Autowired
private SmsRecordDao smsRecordDao;
@Autowired
private ConfigService config;
@Autowired
private ApplicationContext applicationContext;
@Autowired
private AccountUtils accountUtils;
/**
*
*/
private static final Integer AUTO_FLOW_RULE = 0;
private static final String FLOW_KEY = "msgTypeSmsConfig";
private static final String FLOW_KEY_PREFIX = "message_type_";
public SmsHandler() {
channelCode = ChannelType.SMS.getCode();
}
@Override
public boolean handler(TaskInfo taskInfo) {

@ -2,7 +2,10 @@ package com.java3y.austin.handler.pending;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.ObjectUtil;
import com.google.common.collect.Sets;
import com.java3y.austin.common.domain.TaskInfo;
import com.java3y.austin.common.enums.ChannelType;
import com.java3y.austin.handler.deduplication.DeduplicationRuleService;
import com.java3y.austin.handler.discard.DiscardMessageService;
import com.java3y.austin.handler.handler.HandlerHolder;
@ -63,6 +66,17 @@ public class Task implements Runnable {
// 3. 真正发送消息
if (CollUtil.isNotEmpty(taskInfo.getReceiver())) {
// 3.1 微信小程序&服务号只支持单人推送,为了后续逻辑统一处理,于是在这做了打散
if (ChannelType.MINI_PROGRAM.getCode().equals(taskInfo.getSendChannel())
|| ChannelType.OFFICIAL_ACCOUNT.getCode().equals(taskInfo.getSendChannel())) {
for (String receiver : taskInfo.getReceiver()) {
TaskInfo taskClone = ObjectUtil.cloneByStream(this.taskInfo);
taskClone.setReceiver(Sets.newHashSet(receiver));
handlerHolder.route(taskInfo.getSendChannel()).doHandler(taskClone);
}
return;
}
handlerHolder.route(taskInfo.getSendChannel()).doHandler(taskInfo);
}

@ -21,15 +21,13 @@ import java.util.concurrent.ExecutorService;
*/
@Component
public class TaskPendingHolder {
@Autowired
private ThreadPoolUtils threadPoolUtils;
private Map<String, ExecutorService> taskPendingHolder = new HashMap<>(32);
/**
* groupId
*/
private static List<String> groupIds = GroupIdMappingUtils.getAllGroupIds();
@Autowired
private ThreadPoolUtils threadPoolUtils;
private Map<String, ExecutorService> taskPendingHolder = new HashMap<>(32);
/**
* 线

@ -32,35 +32,22 @@ import java.util.Optional;
@Slf4j
public class ReceiverStart {
@Autowired
private ApplicationContext context;
@Autowired
private ConsumerFactory consumerFactory;
/**
* receiver
*/
private static final String RECEIVER_METHOD_NAME = "Receiver.consumer";
/**
* groupId
*/
private static List<String> groupIds = GroupIdMappingUtils.getAllGroupIds();
/**
* (groupIds)
*/
private static Integer index = 0;
/**
* Receiver
*/
@PostConstruct
public void init() {
for (int i = 0; i < groupIds.size(); i++) {
context.getBean(Receiver.class);
}
}
@Autowired
private ApplicationContext context;
@Autowired
private ConsumerFactory consumerFactory;
/**
* Receiverconsumer @KafkaListenergroupId
@ -78,6 +65,16 @@ public class ReceiverStart {
};
}
/**
* Receiver
*/
@PostConstruct
public void init() {
for (int i = 0; i < groupIds.size(); i++) {
context.getBean(Receiver.class);
}
}
/**
* tag
* producer tagheader

@ -34,15 +34,12 @@ import java.util.stream.Collectors;
@Component("YunPianSmsScript")
public class YunPianSmsScript implements SmsScript {
private static final String PARAMS_SPLIT_KEY = "{|}";
private static final String PARAMS_KV_SPLIT_KEY = "{:}";
private static Logger log = LoggerFactory.getLogger(YunPianSmsScript.class);
@Autowired
private AccountUtils accountUtils;
private static final String PARAMS_SPLIT_KEY = "{|}";
private static final String PARAMS_KV_SPLIT_KEY = "{:}";
@Override
public List<SmsRecord> send(SmsParam smsParam) {

@ -41,6 +41,42 @@ public class SendAssembleAction implements BusinessProcess<SendTaskModel> {
@Autowired
private MessageTemplateDao messageTemplateDao;
/**
* contentModelmsgContent
*/
private static ContentModel getContentModelValue(MessageTemplate messageTemplate, MessageParam messageParam) {
// 得到真正的ContentModel 类型
Integer sendChannel = messageTemplate.getSendChannel();
Class<? extends ContentModel> contentModelClass = ChannelType.getChanelModelClassByCode(sendChannel);
// 得到模板的 msgContent 和 入参
Map<String, String> variables = messageParam.getVariables();
JSONObject jsonObject = JSON.parseObject(messageTemplate.getMsgContent());
// 通过反射 组装出 contentModel
Field[] fields = ReflectUtil.getFields(contentModelClass);
ContentModel contentModel = ReflectUtil.newInstance(contentModelClass);
for (Field field : fields) {
String originValue = jsonObject.getString(field.getName());
if (StrUtil.isNotBlank(originValue)) {
String resultValue = ContentHolderUtil.replacePlaceHolder(originValue, variables);
Object resultObj = JSONUtil.isJsonObj(resultValue) ? JSONUtil.toBean(resultValue, field.getType()) : resultValue;
ReflectUtil.setFieldValue(contentModel, field, resultObj);
}
}
// 如果 url 字段存在则在url拼接对应的埋点参数
String url = (String) ReflectUtil.getFieldValue(contentModel, LINK_NAME);
if (StrUtil.isNotBlank(url)) {
String resultUrl = TaskInfoUtils.generateUrl(url, messageTemplate.getId(), messageTemplate.getTemplateType());
ReflectUtil.setFieldValue(contentModel, LINK_NAME, resultUrl);
}
return contentModel;
}
@Override
public void process(ProcessContext<SendTaskModel> context) {
SendTaskModel sendTaskModel = context.getProcessModel();
@ -97,41 +133,4 @@ public class SendAssembleAction implements BusinessProcess<SendTaskModel> {
return taskInfoList;
}
/**
* contentModelmsgContent
*/
private static ContentModel getContentModelValue(MessageTemplate messageTemplate, MessageParam messageParam) {
// 得到真正的ContentModel 类型
Integer sendChannel = messageTemplate.getSendChannel();
Class<? extends ContentModel> contentModelClass = ChannelType.getChanelModelClassByCode(sendChannel);
// 得到模板的 msgContent 和 入参
Map<String, String> variables = messageParam.getVariables();
JSONObject jsonObject = JSON.parseObject(messageTemplate.getMsgContent());
// 通过反射 组装出 contentModel
Field[] fields = ReflectUtil.getFields(contentModelClass);
ContentModel contentModel = ReflectUtil.newInstance(contentModelClass);
for (Field field : fields) {
String originValue = jsonObject.getString(field.getName());
if (StrUtil.isNotBlank(originValue)) {
String resultValue = ContentHolderUtil.replacePlaceHolder(originValue, variables);
Object resultObj = JSONUtil.isJsonObj(resultValue) ? JSONUtil.toBean(resultValue, field.getType()) : resultValue;
ReflectUtil.setFieldValue(contentModel, field, resultObj);
}
}
// 如果 url 字段存在则在url拼接对应的埋点参数
String url = (String) ReflectUtil.getFieldValue(contentModel, LINK_NAME);
if (StrUtil.isNotBlank(url)) {
String resultUrl = TaskInfoUtils.generateUrl(url, messageTemplate.getId(), messageTemplate.getTemplateType());
ReflectUtil.setFieldValue(contentModel, LINK_NAME, resultUrl);
}
return contentModel;
}
}

@ -22,24 +22,21 @@ import java.util.concurrent.ExecutorService;
@Accessors(chain = true)
public class PendingParam<T> {
/**
* 线
*/
protected ExecutorService executorService;
/**
*
*/
private BlockingQueue<T> queue;
/**
* batch
*/
private Integer numThreshold;
/**
* batch
*/
private Long timeThreshold;
/**
* 线
*/
protected ExecutorService executorService;
}

@ -18,25 +18,21 @@ import lombok.experimental.Accessors;
@Builder
@Accessors(chain = true)
public class ProcessContext<T extends ProcessModel> {
/**
* code
*/
private String code;
/**
*
*/
private T processModel;
/**
*
*/
private Boolean needBreak;
/**
*
*/
BasicResultVO response;
private BasicResultVO response;
}

@ -22,16 +22,14 @@ import java.util.Properties;
@Slf4j
@Component
public class NacosUtils {
private final Properties properties = new Properties();
@NacosInjected
private ConfigService configService;
@Value("${nacos.group}")
private String nacosGroup;
@Value("${nacos.data-id}")
private String nacosDataId;
private final Properties properties = new Properties();
public String getProperty(String key, String defaultValue) {
try {
String property = this.getContext();

@ -14,12 +14,10 @@ import org.springframework.stereotype.Component;
@Component
public class ThreadPoolUtils {
private static final String SOURCE_NAME = "austin";
@Autowired
private ThreadPoolExecutorShutdownDefinition shutdownDefinition;
private static final String SOURCE_NAME = "austin";
/**
* 1. 线 线
* 2. 线 Spring

@ -33,13 +33,12 @@ import java.util.List;
@Component
public class AustinAspect {
@Autowired
private HttpServletRequest request;
/**
* KEY
*/
private final String REQUEST_ID_KEY = "request_unique_id";
@Autowired
private HttpServletRequest request;
/**
* AustinAspect

@ -21,6 +21,7 @@ import com.java3y.austin.support.domain.SmsRecord;
import com.java3y.austin.support.utils.RedisUtils;
import com.java3y.austin.support.utils.TaskInfoUtils;
import com.java3y.austin.web.service.DataService;
import com.java3y.austin.web.utils.AnchorStateUtils;
import com.java3y.austin.web.utils.Convert4Amis;
import com.java3y.austin.web.vo.DataParam;
import com.java3y.austin.web.vo.amis.EchartsVo;
@ -91,7 +92,7 @@ public class DataServiceImpl implements DataService {
*/
Map<Object, Object> anchorResult = redisUtils.hGetAll(getRealBusinessId(businessId));
return Convert4Amis.getEchartsVo(anchorResult, optional.get().getName(), businessId);
return Convert4Amis.getEchartsVo(anchorResult, optional.get(), businessId);
}
@Override
@ -151,7 +152,8 @@ public class DataServiceImpl implements DataService {
sb.append(StrPool.CRLF);
}
String startTime = DateUtil.format(new Date(simpleAnchorInfo.getTimestamp()), DatePattern.NORM_DATETIME_PATTERN);
String stateDescription = EnumUtil.getDescriptionByCode(simpleAnchorInfo.getState(), AnchorState.class);
String stateDescription = AnchorStateUtils.getDescriptionByState(messageTemplate.getSendChannel(), simpleAnchorInfo.getState());
sb.append(startTime).append(StrPool.C_COLON).append(stateDescription).append("==>");
}

@ -30,7 +30,6 @@ import me.chanjar.weixin.common.bean.result.WxMediaUploadResult;
import me.chanjar.weixin.cp.api.impl.WxCpServiceImpl;
import me.chanjar.weixin.cp.config.impl.WxCpDefaultConfigImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;

@ -0,0 +1,41 @@
package com.java3y.austin.web.utils;
import cn.hutool.core.util.StrUtil;
import com.java3y.austin.common.enums.AnchorState;
import com.java3y.austin.common.enums.ChannelType;
import com.java3y.austin.common.enums.EnumUtil;
import me.chanjar.weixin.common.error.WxCpErrorMsgEnum;
import me.chanjar.weixin.common.error.WxMaErrorMsgEnum;
import me.chanjar.weixin.common.error.WxMpErrorMsgEnum;
/**
* @author 3y
* AnchorStateUtils
*/
public class AnchorStateUtils {
/**
*
*
* @param channel
* @param state
* @return
*/
public static String getDescriptionByState(Integer channel, Integer state) {
String stateDescription = EnumUtil.getDescriptionByCode(state, AnchorState.class);
// 如果 AnchorState 找不到对应的点位描述,那就是在对应渠道的点位信息
if (StrUtil.isBlank(stateDescription)) {
if (ChannelType.MINI_PROGRAM.getCode().equals(channel)) {
stateDescription = WxMaErrorMsgEnum.findMsgByCode(state);
} else if (ChannelType.OFFICIAL_ACCOUNT.getCode().equals(channel)) {
stateDescription = WxMpErrorMsgEnum.findMsgByCode(state);
} else if (ChannelType.ENTERPRISE_WE_CHAT.getCode().equals(channel)) {
stateDescription = WxCpErrorMsgEnum.findMsgByCode(state);
}
}
return stateDescription;
}
}

@ -8,11 +8,11 @@ import cn.hutool.core.util.ReflectUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.java3y.austin.common.enums.AnchorState;
import com.java3y.austin.common.enums.ChannelType;
import com.java3y.austin.common.enums.EnumUtil;
import com.java3y.austin.common.enums.SmsStatus;
import com.java3y.austin.support.domain.ChannelAccount;
import com.java3y.austin.support.domain.MessageTemplate;
import com.java3y.austin.support.domain.SmsRecord;
import com.java3y.austin.support.utils.TaskInfoUtils;
import com.java3y.austin.web.vo.amis.CommonAmisVo;
@ -386,19 +386,19 @@ public class Convert4Amis {
* @param businessId
* @return
*/
public static EchartsVo getEchartsVo(Map<Object, Object> anchorResult, String templateName, String businessId) {
public static EchartsVo getEchartsVo(Map<Object, Object> anchorResult, MessageTemplate messageTemplate, String businessId) {
List<String> xAxisList = new ArrayList<>();
List<Integer> actualData = new ArrayList<>();
if (CollUtil.isNotEmpty(anchorResult)) {
anchorResult = MapUtil.sort(anchorResult);
for (Map.Entry<Object, Object> entry : anchorResult.entrySet()) {
String description = EnumUtil.getDescriptionByCode(Integer.valueOf(String.valueOf(entry.getKey())), AnchorState.class);
String description = AnchorStateUtils.getDescriptionByState(messageTemplate.getSendChannel(), Integer.valueOf(String.valueOf(entry.getKey())));
xAxisList.add(description);
actualData.add(Integer.valueOf(String.valueOf(entry.getValue())));
}
}
String title = "【" + templateName + "】在" + DateUtil.format(DateUtil.parse(String.valueOf(TaskInfoUtils.getDateFromBusinessId(Long.valueOf(businessId)))), DatePattern.CHINESE_DATE_FORMATTER) + "的下发情况:";
String title = "【" + messageTemplate.getName() + "】在" + DateUtil.format(DateUtil.parse(String.valueOf(TaskInfoUtils.getDateFromBusinessId(Long.valueOf(businessId)))), DatePattern.CHINESE_DATE_FORMATTER) + "的下发情况:";
return EchartsVo.builder()
.title(EchartsVo.TitleVO.builder().text(title).build())

Loading…
Cancel
Save