This commit is contained in:
=
2026-08-26 14:54:52 +08:00
parent 35e65076b0
commit d5fe018988
3 changed files with 37 additions and 26 deletions
@@ -57,12 +57,14 @@ public interface SchoolOaTodoService {
void createWelfareReminderTodos(String projectId, String title, String pcUrl, String appUrl, String creatorId, List<String> receiverIds);
/**
* 将用户已完成福利选择对应的学校OA提醒待办改为已办
* 将用户当前福利项目下的全部学校OA提醒待办统一办结
*
* @param projectId 福利项目ID
* @param userId 完成选择的用户ID
* @param pcUrl PC端福利选择地址
* @param appUrl 手机端福利选择地址
*/
void completeWelfareReminderTodo(String projectId, String userId);
void completeWelfareReminderTodos(String projectId, String userId, String pcUrl, String appUrl);
/**
* 删除用户已完成福利选择对应的学校OA提醒待办。
@@ -28,6 +28,7 @@ import org.nutz.ioc.loader.annotation.IocBean;
import java.util.Date;
import java.util.List;
import java.util.UUID;
/**
* 学校 OA 待办同步服务实现。
@@ -225,15 +226,22 @@ public class SchoolOaTodoServiceImpl implements SchoolOaTodoService {
}
@Override
public void completeWelfareReminderTodo(String projectId, String userId) {
if (!isSchoolOaEnabled("完成福利选择提醒待办", null, null) || StrUtil.hasBlank(projectId, userId)) {
public void completeWelfareReminderTodos(String projectId, String userId, String pcUrl, String appUrl) {
if (!isSchoolOaEnabled("办结福利选择提醒流程", null, null)
|| StrUtil.hasBlank(projectId, userId, pcUrl, appUrl)) {
return;
}
String uniqueId = buildWelfareReminderUniqueId(projectId, userId);
String updateUrl = requireConfig("school-oa.todo.update-url").replace("{uniqueId}", uniqueId);
String responseBody = sendTodoRequest(updateUrl, "学校OA福利选择提醒待办完成失败", "学校OA福利选择提醒待办完成异常");
log.info("学校OA福利选择提醒待办完成成功,projectId={}userId={}uniqueId={}response={}",
projectId, userId, uniqueId, responseBody);
String flowId = buildWelfareReminderFlowId(projectId, userId);
JSONObject body = JSONUtil.createObj();
body.set("flowId", flowId);
body.set("stepName", "福利选择完成");
body.set("pcUrl", pcUrl);
body.set("appUrl", appUrl);
String updateFlowUrl = requireConfig("school-oa.todo.update-flow-url");
String responseBody = sendTodoRequest(updateFlowUrl, body,
"学校OA福利选择提醒流程办结失败", "学校OA福利选择提醒流程办结异常");
log.info("学校OA福利选择提醒流程办结成功,projectId={}userId={}flowId={}response={}",
projectId, userId, flowId, responseBody);
}
@Override
@@ -241,7 +249,8 @@ public class SchoolOaTodoServiceImpl implements SchoolOaTodoService {
if (!isSchoolOaEnabled("删除福利选择提醒待办", null, null) || StrUtil.hasBlank(projectId, userId)) {
return;
}
String uniqueId = buildWelfareReminderUniqueId(projectId, userId);
// 兼容删除改造前按项目和用户生成的固定唯一值,新的重复提醒不再调用删除逻辑。
String uniqueId = buildWelfareReminderFlowId(projectId, userId);
String deleteUrl = requireConfig("school-oa.todo.delete-url").replace("{uniqueId}", uniqueId);
sendTodoRequest(deleteUrl, "学校OA福利选择提醒待办删除失败", "学校OA福利选择提醒待办删除异常");
log.info("学校OA福利选择提醒待办删除成功,projectId={}userId={}uniqueId={}", projectId, userId, uniqueId);
@@ -408,7 +417,7 @@ public class SchoolOaTodoServiceImpl implements SchoolOaTodoService {
Sys_user creator, Sys_user receiver, String creatorTime) {
JSONObject body = new JSONObject();
body.set("flowTypeName", "福利选择");
body.set("flowId", "welfare_reminder_" + projectId);
body.set("flowId", buildWelfareReminderFlowId(projectId, receiver.getId()));
body.set("title", title);
body.set("stepName", "福利选择提醒");
body.set("creatorCode", creator.getLoginname());
@@ -418,6 +427,7 @@ public class SchoolOaTodoServiceImpl implements SchoolOaTodoService {
body.set("appUrl", appUrl);
body.set("pcPreviewUrl", pcUrl);
body.set("appPreviewUrl", appUrl);
// 每次提醒使用新的唯一值,重复提醒直接新增待办,不删除或覆盖历史提醒。
body.set("uniqueId", buildWelfareReminderUniqueId(projectId, receiver.getId()));
body.set("receiveCode", receiver.getLoginname());
body.set("receiveName", receiver.getUsername());
@@ -429,16 +439,6 @@ public class SchoolOaTodoServiceImpl implements SchoolOaTodoService {
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)));
}
@@ -466,10 +466,17 @@ public class SchoolOaTodoServiceImpl implements SchoolOaTodoService {
}
/**
* 福利提醒待办按项目和接收人保持唯一;用户完成选择后可据此精确删除待办。
* 同一项目和用户共用流程标识,用户完成选择后可一次办结该流程下的全部提醒待办。
*/
private String buildWelfareReminderFlowId(String projectId, String userId) {
return "welfare_reminder_" + projectId + "_" + userId;
}
/**
* 每次福利提醒生成新的待办唯一值,允许对同一用户重复发送多条学校OA待办。
*/
private String buildWelfareReminderUniqueId(String projectId, String userId) {
return "welfare_reminder_" + projectId + "_" + userId;
return buildWelfareReminderFlowId(projectId, userId) + "_" + UUID.randomUUID().toString().replace("-", "");
}
private String buildAppTaskUrl(String h5FormKey, ProcessTask task) {
@@ -159,10 +159,12 @@ public class WelfareSelectionSituationServiceImpl extends BaseServiceImpl<Welfar
@Override
public void completeReminderTodo(String projectId, String userId) {
try {
schoolOaTodoService.completeWelfareReminderTodo(projectId, userId);
String pcUrl = buildWelfareSelectionUrl("/platform/welfare/userSelect");
String appUrl = buildWelfareSelectionUrl("/platform/h5/welfare/userSelect/list");
schoolOaTodoService.completeWelfareReminderTodos(projectId, userId, pcUrl, appUrl);
} catch (Exception e) {
// 学校OA转已办失败不能影响用户完成福利选择,后续可根据日志人工处理。
log.error("学校OA福利选择提醒待办转已办失败,projectId={}userId={}", projectId, userId, e);
// 学校OA流程办结失败不能影响用户完成福利选择,后续可根据日志人工处理。
log.error("学校OA福利选择提醒流程办结失败,projectId={}userId={}", projectId, userId, e);
}
}