选址相关枚举 消息

This commit is contained in:
zhangchenbiao
2024-03-27 11:13:44 +08:00
parent e98fcf626d
commit 3bd0091e7d
35 changed files with 1221 additions and 6 deletions

View File

@@ -1,13 +1,29 @@
package com.cool.store.service.impl;
import com.alibaba.fastjson.JSONObject;
import com.cool.store.dao.EnterpriseUserDAO;
import com.cool.store.dto.message.SendMessageDTO;
import com.cool.store.enums.MessageEnum;
import com.cool.store.enums.RocketMqTagEnum;
import com.cool.store.enums.UserRoleEnum;
import com.cool.store.enums.WorkflowSubStageEnum;
import com.cool.store.mq.producer.SimpleMessageService;
import com.cool.store.utils.UUIDUtils;
import com.cool.store.utils.poi.constant.Constants;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import java.text.MessageFormat;
import java.util.List;
import java.util.stream.Collectors;
/**
* @author zhangchenbiao
@@ -22,6 +38,14 @@ public class CommonService {
private ApplicationContext applicationContext;
@Resource
private EnterpriseUserDAO enterpriseUserDAO;
@Resource
private SimpleMessageService simpleMessageService;
@Value("${coolstore.page.domain}")
private String coolStoreDomainUrl;
@Value("${mybatis.configuration.variables.enterpriseId}")
private String enterpriseId;
@Value("${enterprise.dingCorpId}")
private String dingCorpId;
public LineFlowService getLineFlowService(Integer workflowSubStage){
WorkflowSubStageEnum workflowSubStageEnum = WorkflowSubStageEnum.getWorkflowSubStageEnum(workflowSubStage);
@@ -38,4 +62,37 @@ public class CommonService {
//随机一个
return enterpriseUserDAO.getUserInfoByUserIds(null).stream().findAny().get().getUserId();
}
public void sendMessage(List<String> userIds, Long lineId, MessageEnum message, String... param){
if(CollectionUtils.isEmpty(userIds)){
return;
}
userIds = userIds.stream().filter(StringUtils::isNotBlank).collect(Collectors.toList());
if(CollectionUtils.isEmpty(userIds)){
return;
}
String mobileParam = MessageFormat.format("{0}&eid={1}&corpId={2}&appType=dingding2&lineId={3}", "", enterpriseId, dingCorpId, String.valueOf(lineId));
try {
String messageUrl = coolStoreDomainUrl + "dd-noticemsg?miniAppId={0}&appId={1}&corpId={2}&appUrl=" + URLEncoder.encode("pages/common-web-view/index?routerUrl=notice&target=" + mobileParam, StandardCharsets.UTF_8.name());
SendMessageDTO messageDTO = new SendMessageDTO();
messageDTO.setCorpId(dingCorpId);
messageDTO.setUserIds(String.join(Constants.COMMA, userIds));
messageDTO.setOutBusinessId(UUIDUtils.get32UUID());
messageDTO.setAppType("dingding2");
JSONObject map = new JSONObject();
map.put("message_url", messageUrl);
JSONObject headJson = new JSONObject();
headJson.put("bgcolor", "FFBBBBBB");
map.put("head", headJson);
JSONObject body = new JSONObject();
body.put("title", message.getTitle());
body.put("image", message.getImageUrl());
body.put("content", MessageFormat.format(message.getContent(), param));
map.put("body",body);
messageDTO.setOaJson(map);
simpleMessageService.send(JSONObject.toJSONString(messageDTO), RocketMqTagEnum.STORE_DING_QUEUE);
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
}
}