commit
This commit is contained in:
@@ -1,5 +1,7 @@
|
|||||||
package com.budwk.app.base.sms;
|
package com.budwk.app.base.sms;
|
||||||
|
|
||||||
|
import com.budwk.app.sys.models.Sys_user;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public interface SmsService {
|
public interface SmsService {
|
||||||
@@ -36,4 +38,15 @@ public interface SmsService {
|
|||||||
* @param link 链接
|
* @param link 链接
|
||||||
*/
|
*/
|
||||||
void massSend(List<String> loginNames, String title, String content, String link);
|
void massSend(List<String> loginNames, String title, String content, String link);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 按学校统一消息V4协议批量发送消息,接收人同时携带工号和姓名,并分别传递PC、手机端链接。
|
||||||
|
*
|
||||||
|
* @param users 接收人用户信息
|
||||||
|
* @param title 消息标题
|
||||||
|
* @param content 消息正文
|
||||||
|
* @param pcUrl PC端跳转链接
|
||||||
|
* @param mobileUrl 手机端跳转链接
|
||||||
|
*/
|
||||||
|
void massSendByUsers(List<Sys_user> users, String title, String content, String pcUrl, String mobileUrl);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import cn.hutool.crypto.digest.DigestUtil;
|
|||||||
import cn.hutool.http.HttpRequest;
|
import cn.hutool.http.HttpRequest;
|
||||||
import cn.hutool.http.HttpResponse;
|
import cn.hutool.http.HttpResponse;
|
||||||
import com.budwk.app.base.sms.SmsService;
|
import com.budwk.app.base.sms.SmsService;
|
||||||
|
import com.budwk.app.sys.models.Sys_user;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.nutz.integration.jedis.RedisService;
|
import org.nutz.integration.jedis.RedisService;
|
||||||
import org.nutz.ioc.loader.annotation.Inject;
|
import org.nutz.ioc.loader.annotation.Inject;
|
||||||
@@ -24,7 +25,8 @@ import java.util.Map;
|
|||||||
* @Description TODO
|
* @Description TODO
|
||||||
*/
|
*/
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@IocBean
|
// 旧版网关协议保留用于回溯;当前学校统一消息已切换至 UnifiedMessageV4ServiceImpl。
|
||||||
|
// @IocBean
|
||||||
public class SmsYpiServiceImpl implements SmsService {
|
public class SmsYpiServiceImpl implements SmsService {
|
||||||
|
|
||||||
private static final String APPID = "1430576717768122368";
|
private static final String APPID = "1430576717768122368";
|
||||||
@@ -60,6 +62,18 @@ public class SmsYpiServiceImpl implements SmsService {
|
|||||||
doSend(title, content, receivers, link);
|
doSend(title, content, receivers, link);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 兼容统一消息V4新增的批量发送接口;旧版实现不再注册为发送服务,仅保留历史调用能力。
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void massSendByUsers(List<Sys_user> users, String title, String content, String pcUrl, String mobileUrl) {
|
||||||
|
List<String> loginNames = users.stream()
|
||||||
|
.map(Sys_user::getLoginname)
|
||||||
|
.filter(StrUtil::isNotBlank)
|
||||||
|
.toList();
|
||||||
|
massSend(loginNames, title, content, StrUtil.blankToDefault(mobileUrl, pcUrl));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* sign: 请求签名:(accessToken + 第一个receivers 的userID )的32位小写的MD5加密值,其中如果相应部分没有则忽略
|
* sign: 请求签名:(accessToken + 第一个receivers 的userID )的32位小写的MD5加密值,其中如果相应部分没有则忽略
|
||||||
* msgType: 0: 普通消息(默认) 1: 必读消息 2: 验证码(为验证码时消息一定不入收件箱)
|
* msgType: 0: 普通消息(默认) 1: 必读消息 2: 验证码(为验证码时消息一定不入收件箱)
|
||||||
|
|||||||
@@ -415,22 +415,40 @@ public class SchoolOaTodoServiceImpl implements SchoolOaTodoService {
|
|||||||
String requestBody = JSONUtil.toJsonStr(body);
|
String requestBody = JSONUtil.toJsonStr(body);
|
||||||
log.info("学校OA福利选择提醒待办创建请求,url={},projectId={},receiveCode={},body={}",
|
log.info("学校OA福利选择提醒待办创建请求,url={},projectId={},receiveCode={},body={}",
|
||||||
insertUrl, projectId, receiver.getLoginname(), requestBody);
|
insertUrl, projectId, receiver.getLoginname(), requestBody);
|
||||||
|
JSONObject response = executeWelfareReminderTodoRequest(insertUrl, requestBody, projectId, receiver.getLoginname());
|
||||||
|
String responseMessage = response.getStr("message", "");
|
||||||
|
// 同一项目重复提醒时,学校OA不允许相同uniqueId重复新增,先删除旧待办再覆盖创建。
|
||||||
|
if (response.getInt("state", 0) != 200 && StrUtil.contains(responseMessage, "uniqueId已存在")) {
|
||||||
|
String uniqueId = buildWelfareReminderUniqueId(projectId, receiver.getId());
|
||||||
|
String deleteUrl = requireConfig("school-oa.todo.delete-url").replace("{uniqueId}", uniqueId);
|
||||||
|
log.info("学校OA福利选择提醒待办已存在,删除旧待办后重试创建,projectId={},receiveCode={},uniqueId={}",
|
||||||
|
projectId, receiver.getLoginname(), uniqueId);
|
||||||
|
sendTodoRequest(deleteUrl, "学校OA福利选择提醒旧待办删除失败", "学校OA福利选择提醒旧待办删除异常");
|
||||||
|
response = executeWelfareReminderTodoRequest(insertUrl, requestBody, projectId, receiver.getLoginname());
|
||||||
|
responseMessage = response.getStr("message", "");
|
||||||
|
}
|
||||||
|
if (response.getInt("state", 0) != 200) {
|
||||||
|
throw new BaseException("学校OA福利选择提醒待办创建失败:{}", StrUtil.blankToDefault(responseMessage, JSONUtil.toJsonStr(response)));
|
||||||
|
}
|
||||||
|
log.info("学校OA福利选择提醒待办创建成功,projectId={},receiveCode={},response={}",
|
||||||
|
projectId, receiver.getLoginname(), JSONUtil.toJsonStr(response));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 调用学校OA插入待办接口并返回原始响应;网络和解析异常统一转换为业务异常。
|
||||||
|
*/
|
||||||
|
private JSONObject executeWelfareReminderTodoRequest(String insertUrl, String requestBody, String projectId, String receiverLoginName) {
|
||||||
try {
|
try {
|
||||||
HttpRequest request = HttpUtil.createPost(insertUrl);
|
HttpRequest request = HttpUtil.createPost(insertUrl);
|
||||||
setTodoRequestHeaders(request);
|
setTodoRequestHeaders(request);
|
||||||
request.body(requestBody);
|
request.body(requestBody);
|
||||||
String responseBody = request.execute().body();
|
String responseBody = request.execute().body();
|
||||||
JSONObject response = JSONUtil.parseObj(responseBody);
|
log.info("学校OA福利选择提醒待办创建响应,projectId={},receiveCode={},response={}",
|
||||||
if (response.getInt("state", 0) != 200) {
|
projectId, receiverLoginName, responseBody);
|
||||||
throw new BaseException("学校OA福利选择提醒待办创建失败:{}", response.getStr("message", responseBody));
|
return JSONUtil.parseObj(responseBody);
|
||||||
}
|
|
||||||
log.info("学校OA福利选择提醒待办创建成功,projectId={},receiveCode={},response={}",
|
|
||||||
projectId, receiver.getLoginname(), responseBody);
|
|
||||||
} catch (BaseException e) {
|
|
||||||
throw e;
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("学校OA福利选择提醒待办创建异常,url={},projectId={},receiveCode={},body={}",
|
log.error("学校OA福利选择提醒待办创建异常,url={},projectId={},receiveCode={},body={}",
|
||||||
insertUrl, projectId, receiver.getLoginname(), requestBody, e);
|
insertUrl, projectId, receiverLoginName, requestBody, e);
|
||||||
throw new BaseException("学校OA福利选择提醒待办创建异常:{}", e.getMessage());
|
throw new BaseException("学校OA福利选择提醒待办创建异常:{}", e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+8
-12
@@ -143,20 +143,16 @@ public class WelfareSelectionSituationServiceImpl extends BaseServiceImpl<Welfar
|
|||||||
// 本地消息始终发送,确保外部渠道关闭时仍可在系统内查看提醒。
|
// 本地消息始终发送,确保外部渠道关闭时仍可在系统内查看提醒。
|
||||||
localMessageSendStrategy.send(title, content, 2, recipientIds, null);
|
localMessageSendStrategy.send(title, content, 2, recipientIds, null);
|
||||||
|
|
||||||
List<String> receiverLoginNames = dao().query(Sys_user.class, Cnd.where(Sys_user::getId, "in", recipientIds)).stream()
|
List<Sys_user> receiverUsers = dao().query(Sys_user.class, Cnd.where(Sys_user::getId, "in", recipientIds));
|
||||||
.map(Sys_user::getLoginname)
|
|
||||||
.filter(StrUtil::isNotBlank)
|
|
||||||
.distinct()
|
|
||||||
.toList();
|
|
||||||
// AppSms 控制学校消息平台发送,消息链接跳转到手机端福利选择列表。
|
// AppSms 控制学校消息平台发送,消息链接跳转到手机端福利选择列表。
|
||||||
if (Boolean.TRUE.equals(Globals.MyConfig.getBoolean("AppSms")) && !receiverLoginNames.isEmpty()) {
|
if (Boolean.TRUE.equals(Globals.MyConfig.getBoolean("AppSms")) && !receiverUsers.isEmpty()) {
|
||||||
smsService.massSend(receiverLoginNames, title, content, appUrl);
|
smsService.massSendByUsers(receiverUsers, title, content, pcUrl, appUrl);
|
||||||
}
|
|
||||||
// AppSchoolOa 控制学校OA待办;学校OA没有正文栏位,标题使用自定义提醒内容。
|
|
||||||
if (Boolean.TRUE.equals(Globals.MyConfig.getBoolean("AppSchoolOa"))) {
|
|
||||||
schoolOaTodoService.createWelfareReminderTodos(pageForm.getProjectId(), title + content,
|
|
||||||
pcUrl, appUrl, SecurityUtil.getUserId(), recipientIds);
|
|
||||||
}
|
}
|
||||||
|
// 学校OA待办暂不发送,保留原调用以便后续恢复学校OA福利提醒。
|
||||||
|
// if (Boolean.TRUE.equals(Globals.MyConfig.getBoolean("AppSchoolOa"))) {
|
||||||
|
// schoolOaTodoService.createWelfareReminderTodos(pageForm.getProjectId(), title + content,
|
||||||
|
// pcUrl, appUrl, SecurityUtil.getUserId(), recipientIds);
|
||||||
|
// }
|
||||||
return recipientIds.size();
|
return recipientIds.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user