feat(emergency): 宣教推送IM消息改为独立方法sendGroupMsgArticle,不影响已有业务
- 新增 TencentCloudImUtil.sendGroupMsgArticle: From_Account生效、不覆盖businessID、fromAdmin动态判断 - 新增 TXController.sendGroupMsgArticle / IMHelloApi.sendGroupMsgArticle - FirstAidPushServiceImpl 推送人改为当前登录用户,调用新方法
This commit is contained in:
+4
-3
@@ -152,9 +152,10 @@ public class FirstAidPushServiceImpl implements IFirstAidPushService {
|
|||||||
im.setFromUserId(loginUser != null ? loginUser.getId() : "administrator");
|
im.setFromUserId(loginUser != null ? loginUser.getId() : "administrator");
|
||||||
im.setContent(JSONObject.toJSON(sendIm).toString());
|
im.setContent(JSONObject.toJSON(sendIm).toString());
|
||||||
|
|
||||||
imHelloApi.sendGroupMsg(im);
|
imHelloApi.sendGroupMsgArticle(im);
|
||||||
log.info("急救宣教推送IM消息已发送: resourceId={}, title={}, orderId={}, sessionId={}, businessId=article",
|
log.info("急救宣教推送IM消息已发送: resourceId={}, title={}, orderId={}, sessionId={}, pushBy={}, businessId=article",
|
||||||
resourceId, resource.getTitle(), orderId, order.getSessionId());
|
resourceId, resource.getTitle(), orderId, order.getSessionId(),
|
||||||
|
loginUser != null ? loginUser.getRealname() : "unknown");
|
||||||
} else {
|
} else {
|
||||||
log.warn("急救宣教推送IM消息未发送(工单无群聊sessionId): resourceId={}, orderId={}",
|
log.warn("急救宣教推送IM消息未发送(工单无群聊sessionId): resourceId={}, orderId={}",
|
||||||
resourceId, orderId);
|
resourceId, orderId);
|
||||||
|
|||||||
@@ -48,6 +48,9 @@ public interface IMHelloApi {
|
|||||||
@PostMapping(value = "/wnapp/sendGroupMsg")
|
@PostMapping(value = "/wnapp/sendGroupMsg")
|
||||||
IMGroupMsgResDO sendGroupMsg(@RequestBody @Validated ImGroupMsgTextReqDO imGroupMsgTextReqDO);
|
IMGroupMsgResDO sendGroupMsg(@RequestBody @Validated ImGroupMsgTextReqDO imGroupMsgTextReqDO);
|
||||||
|
|
||||||
|
@PostMapping(value = "/wnapp/sendGroupMsgArticle")
|
||||||
|
IMGroupMsgResDO sendGroupMsgArticle(@RequestBody @Validated ImGroupMsgTextReqDO imGroupMsgTextReqDO);
|
||||||
|
|
||||||
@PostMapping(value = "/wnapp/sendGroupMsgTextNew")
|
@PostMapping(value = "/wnapp/sendGroupMsgTextNew")
|
||||||
IMGroupMsgResDO sendGroupMsgTextNew(@RequestBody @Validated ImGroupMsgTextReqDO imGroupMsgTextReqDO);
|
IMGroupMsgResDO sendGroupMsgTextNew(@RequestBody @Validated ImGroupMsgTextReqDO imGroupMsgTextReqDO);
|
||||||
|
|
||||||
|
|||||||
@@ -247,6 +247,14 @@ public class TXController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Operation(summary = "文章推送群消息(宣教推送专用)", description = "发送方由调用方指定,不覆盖businessID")
|
||||||
|
@PostMapping("/sendGroupMsgArticle")
|
||||||
|
public IMGroupMsgResDO sendGroupMsgArticle(@RequestBody @Validated ImGroupMsgTextReqDO imGroupMsgTextReqDO) {
|
||||||
|
|
||||||
|
return tencentCloudImUtil.sendGroupMsgArticle(imGroupMsgTextReqDO);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@Operation(summary = "用户发送群消息", description = "用户发送群消息")
|
@Operation(summary = "用户发送群消息", description = "用户发送群消息")
|
||||||
@PostMapping("/sendGroupMsgTextNew")
|
@PostMapping("/sendGroupMsgTextNew")
|
||||||
public IMGroupMsgResDO sendGroupMsgTextNew(@RequestBody @Validated ImGroupMsgTextReqDO imGroupMsgTextReqDO) {
|
public IMGroupMsgResDO sendGroupMsgTextNew(@RequestBody @Validated ImGroupMsgTextReqDO imGroupMsgTextReqDO) {
|
||||||
|
|||||||
@@ -239,7 +239,7 @@ public class TencentCloudImUtil {
|
|||||||
param.put("GroupId", imGroupMsgTextReqVO.getGroupId());
|
param.put("GroupId", imGroupMsgTextReqVO.getGroupId());
|
||||||
param.put("MsgPriority", "High");
|
param.put("MsgPriority", "High");
|
||||||
param.put("Random", this.getRandom());
|
param.put("Random", this.getRandom());
|
||||||
param.put("From_Account", imGroupMsgTextReqVO.getFromUserId());
|
// param.put("From_Account", imGroupMsgTextReqVO.getFromUserId());
|
||||||
param.put("MsgRandom", this.getRandomNum(8));
|
param.put("MsgRandom", this.getRandomNum(8));
|
||||||
param.put("MsgTimeStamp", DateUtils.dateToUnixLong(new Date()));
|
param.put("MsgTimeStamp", DateUtils.dateToUnixLong(new Date()));
|
||||||
param.put("CloudCustomData", new JSONObject().fluentPut("fromAdmin", true).toJSONString());
|
param.put("CloudCustomData", new JSONObject().fluentPut("fromAdmin", true).toJSONString());
|
||||||
@@ -272,6 +272,58 @@ public class TencentCloudImUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 发送文章推送群消息(宣教推送专用)
|
||||||
|
* <p>
|
||||||
|
* 与 sendGroupMsgText 的区别:
|
||||||
|
* 1. From_Account 由调用方指定,不写死为 administrator
|
||||||
|
* 2. 不覆盖 businessID,保留调用方传入的业务标识
|
||||||
|
* 3. CloudCustomData.fromAdmin 根据实际发送人动态设置
|
||||||
|
*
|
||||||
|
* @param req 消息请求
|
||||||
|
* @return IMGroupMsgResDO
|
||||||
|
*/
|
||||||
|
public IMGroupMsgResDO sendGroupMsgArticle(ImGroupMsgTextReqDO req) {
|
||||||
|
IMGroupMsgResDO res = new IMGroupMsgResDO();
|
||||||
|
String url = HTTPS_URL_PREFIX + "v4/group_open_http_svc/send_group_msg";
|
||||||
|
|
||||||
|
String fromUserId = req.getFromUserId();
|
||||||
|
boolean isAdmin = "administrator".equals(fromUserId);
|
||||||
|
|
||||||
|
JSONObject param = new JSONObject();
|
||||||
|
param.put("GroupId", req.getGroupId());
|
||||||
|
param.put("MsgPriority", "High");
|
||||||
|
param.put("Random", this.getRandom());
|
||||||
|
param.put("From_Account", fromUserId);
|
||||||
|
param.put("MsgRandom", this.getRandomNum(8));
|
||||||
|
param.put("MsgTimeStamp", DateUtils.dateToUnixLong(new Date()));
|
||||||
|
param.put("CloudCustomData", new JSONObject().fluentPut("fromAdmin", isAdmin).toJSONString());
|
||||||
|
|
||||||
|
JSONObject jj = JSONObject.parseObject(req.getContent());
|
||||||
|
try {
|
||||||
|
JSONObject item = new JSONObject();
|
||||||
|
JSONObject msgContentData = new JSONObject();
|
||||||
|
msgContentData.put("Data", jj.toString());
|
||||||
|
item.put("MsgType", ImSendEnum.TIMCustomElem.getValue());
|
||||||
|
item.put("MsgContent", msgContentData);
|
||||||
|
JSONArray msgBody = new JSONArray();
|
||||||
|
msgBody.add(item);
|
||||||
|
param.put("MsgBody", msgBody);
|
||||||
|
String jsonStr = HttpUtil.doPost(buildRequestUrl(url), param.toString());
|
||||||
|
if (StringUtils.isNotEmpty(jsonStr)) {
|
||||||
|
JSONObject jsonObj = JSONObject.parseObject(jsonStr);
|
||||||
|
if (jsonObj.containsKey("ErrorCode") && jsonObj.getInteger("ErrorCode") == 0) {
|
||||||
|
log.info("=========={}==========", "文章推送发送成功!");
|
||||||
|
}
|
||||||
|
res = JsonUtil.toObject(jsonStr, IMGroupMsgResDO.class);
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 默认单发发群文本消息
|
* 默认单发发群文本消息
|
||||||
*
|
*
|
||||||
|
|||||||
Reference in New Issue
Block a user