|
|
|
@ -108,20 +108,10 @@ public class FarmMsgAspect {
|
|
|
|
|
AdminUserDO adminUser = adminUserMapper.selectOne(AdminUserDO::getId, getLoginUserId()); |
|
|
|
|
CpUserDO user = cpUserMapper.selectOne(CpUserDO::getUserId, adminUser.getCpUserId()); |
|
|
|
|
|
|
|
|
|
StringBuilder description = new StringBuilder() |
|
|
|
|
.append(user.getName()) |
|
|
|
|
.append(" ") |
|
|
|
|
.append(farmMsgDTO.getOperation().getDesc()) |
|
|
|
|
.append(farmMsgDTO.getType().getDesc()) |
|
|
|
|
.append(":") |
|
|
|
|
.append(ObjectUtil.isEmpty(farmMsgDTO.getMsg()) ? farmMsgDTO.getTitle() : farmMsgDTO.getMsg()) |
|
|
|
|
.append("(其中有你)"); |
|
|
|
|
if (!toUserStr.contains("WeiLaiKeQi")){ |
|
|
|
|
return object; |
|
|
|
|
} |
|
|
|
|
// if (!toUserStr.contains("WeiLaiKeQi")){
|
|
|
|
|
// return object;
|
|
|
|
|
// }
|
|
|
|
|
if (!farmMsgDTO.getNoSendMsg()){ |
|
|
|
|
//企业微信内部发送信息
|
|
|
|
|
//this.sendCpMsg(description.toString(), toUserStr);
|
|
|
|
|
//企业微信小程序通知消息
|
|
|
|
|
this.sendMiniMsg(user, farmMsgDTO, toUserStr); |
|
|
|
|
} |
|
|
|
@ -141,31 +131,6 @@ public class FarmMsgAspect {
|
|
|
|
|
return object; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void sendCpMsg(String desc, String userStr) throws Throwable{ |
|
|
|
|
// 构造一个企业推送消息
|
|
|
|
|
WxCpMessage message = new WxCpMessage(); |
|
|
|
|
// 发企业微信
|
|
|
|
|
WxCpMessageService wxCpMessageService = wxCpService.getMessageService(); |
|
|
|
|
|
|
|
|
|
//消息类型 必填 此处固定为 文本卡片
|
|
|
|
|
message.setMsgType("textcard"); |
|
|
|
|
//企业应用id 必填
|
|
|
|
|
message.setAgentId(wxCpService.getWxCpConfigStorage().getAgentId()); |
|
|
|
|
//消息标题 必填
|
|
|
|
|
message.setTitle("回乡农场通知"); |
|
|
|
|
//消息描述 必填
|
|
|
|
|
message.setDescription(desc); |
|
|
|
|
//点击后跳转链接 必填
|
|
|
|
|
message.setUrl("https://www.baidu.com"); |
|
|
|
|
|
|
|
|
|
//接受消息成员 选填
|
|
|
|
|
message.setToUser(userStr); |
|
|
|
|
log.info("企业微信消息发送内容:{}", message); |
|
|
|
|
WxCpMessageSendResult result = wxCpMessageService.send(message); |
|
|
|
|
log.info("企业微信消息发送结果:{}",result); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//发送小程序通知消息
|
|
|
|
|
public void sendMiniMsg(CpUserDO createUser, FarmMsgDTO farmMsgDTO, String toUserStr) throws WxErrorException { |
|
|
|
|
// 发小程序
|
|
|
|
@ -181,6 +146,7 @@ public class FarmMsgAspect {
|
|
|
|
|
message.setAppId(appid); |
|
|
|
|
message.setTitle(farmMsgDTO.getType().getDesc() + farmMsgDTO.getOperation().getDesc() + "通知"); |
|
|
|
|
message.setDescription(LocalDateTimeUtil.formatNormal(LocalDateTime.now())); |
|
|
|
|
message.setPage(farmMsgDTO.getType().equals(FarmMsgTypeEnum.PROJECT) ? "pages/project/index" : "pages/task/index"); |
|
|
|
|
|
|
|
|
|
Map<String, String> map2 = new HashMap<>(); |
|
|
|
|
map2.put("发起人", createUser.getName()); |
|
|
|
|