!93 czh-20260725-getDistinctHandlerNames同时返回工号+姓名
* czh-20260725-getDistinctHandlerNames同时返回工号+姓名 * czh-20260725-移除linkOpenMode和dataFormat默认值 * czh-20260725-移除接收人上限限制 * czh-20260725-IM模块code-review补充修复 * czh-20260725-code-review问题修复
This commit is contained in:
+4
-3
@@ -58,12 +58,13 @@ public class KsimApiClient {
|
|||||||
HttpHeaders headers = jsonHeaders();
|
HttpHeaders headers = jsonHeaders();
|
||||||
headers.add("imOpenApiToken", token);
|
headers.add("imOpenApiToken", token);
|
||||||
|
|
||||||
String bodyJson = JSON.toJSONString(dto);
|
// 直接 POJO→JSONObject,避免 DTO→String→JSONObject 三重序列化
|
||||||
|
JSONObject body = (JSONObject) JSON.toJSON(dto);
|
||||||
String url = ksimProperties.getHost() + "/api-open/v1/msg/sendBatch";
|
String url = ksimProperties.getHost() + "/api-open/v1/msg/sendBatch";
|
||||||
log.info("【即时通推送-消息发送】请求体: {}", bodyJson);
|
log.debug("【即时通推送-消息发送】请求体: {}", body.toJSONString());
|
||||||
|
|
||||||
ResponseEntity<JSONObject> resp = RestUtil.request(url, HttpMethod.POST, headers, null,
|
ResponseEntity<JSONObject> resp = RestUtil.request(url, HttpMethod.POST, headers, null,
|
||||||
JSON.parseObject(bodyJson), JSONObject.class);
|
body, JSONObject.class);
|
||||||
|
|
||||||
JSONObject respBody = resp.getBody();
|
JSONObject respBody = resp.getBody();
|
||||||
int code = respBody != null ? respBody.getIntValue("code") : -1;
|
int code = respBody != null ? respBody.getIntValue("code") : -1;
|
||||||
|
|||||||
+7
-24
@@ -19,7 +19,6 @@ import java.util.Arrays;
|
|||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@@ -28,8 +27,6 @@ import java.util.stream.Collectors;
|
|||||||
@RequestMapping("/ksim/test")
|
@RequestMapping("/ksim/test")
|
||||||
public class KsimTestController {
|
public class KsimTestController {
|
||||||
|
|
||||||
private static final Set<String> ALLOWED_LINK_OPEN_MODES = Set.of("Exe", "Web", "None");
|
|
||||||
|
|
||||||
@PostMapping("/sendBatch")
|
@PostMapping("/sendBatch")
|
||||||
public Result<Map<String, Object>> sendBatch(@RequestBody Map<String, Object> params) {
|
public Result<Map<String, Object>> sendBatch(@RequestBody Map<String, Object> params) {
|
||||||
Map<String, Object> result = new LinkedHashMap<>();
|
Map<String, Object> result = new LinkedHashMap<>();
|
||||||
@@ -47,8 +44,8 @@ public class KsimTestController {
|
|||||||
String content = (String) params.getOrDefault("content", "");
|
String content = (String) params.getOrDefault("content", "");
|
||||||
String linkUrl = (String) params.getOrDefault("linkUrl", "");
|
String linkUrl = (String) params.getOrDefault("linkUrl", "");
|
||||||
String linkTitle = (String) params.getOrDefault("linkTitle", "");
|
String linkTitle = (String) params.getOrDefault("linkTitle", "");
|
||||||
String linkOpenMode = (String) params.getOrDefault("linkOpenMode", "Exe");
|
String linkOpenMode = (String) params.getOrDefault("linkOpenMode", "");
|
||||||
String dataFormat = (String) params.getOrDefault("dataFormat", "JsonListView");
|
String dataFormat = (String) params.getOrDefault("dataFormat", "");
|
||||||
String data = (String) params.getOrDefault("data", "");
|
String data = (String) params.getOrDefault("data", "");
|
||||||
|
|
||||||
// --- Step 1: 创建 Token ---
|
// --- Step 1: 创建 Token ---
|
||||||
@@ -82,25 +79,11 @@ public class KsimTestController {
|
|||||||
dto.setToUserValueList(toUserValueList);
|
dto.setToUserValueList(toUserValueList);
|
||||||
dto.setTitle(title);
|
dto.setTitle(title);
|
||||||
dto.setContent(content);
|
dto.setContent(content);
|
||||||
// 可选字段:传了才设置,不传则不发给 ksim
|
// 可选字段统一通过 setOptionalFields 设置
|
||||||
if (data != null && !data.isEmpty()) {
|
try {
|
||||||
dto.setData(data);
|
dto.setOptionalFields(data, linkOpenMode, dataFormat, linkTitle, linkUrl);
|
||||||
}
|
} catch (IllegalArgumentException e) {
|
||||||
if (linkOpenMode != null && !linkOpenMode.isEmpty()) {
|
log.warn("【即时通测试-sendBatch】可选字段校验失败: {}", e.getMessage());
|
||||||
if (!ALLOWED_LINK_OPEN_MODES.contains(linkOpenMode)) {
|
|
||||||
log.warn("【即时通测试-sendBatch】非法的 linkOpenMode: {}, 已跳过", linkOpenMode);
|
|
||||||
} else {
|
|
||||||
dto.setLinkOpenMode(linkOpenMode);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (dataFormat != null && !dataFormat.isEmpty()) {
|
|
||||||
dto.setDataFormat(dataFormat);
|
|
||||||
}
|
|
||||||
if (linkTitle != null && !linkTitle.isEmpty()) {
|
|
||||||
dto.setLinkTitle(linkTitle);
|
|
||||||
}
|
|
||||||
if (linkUrl != null && !linkUrl.isEmpty()) {
|
|
||||||
dto.setLinkUrl(linkUrl);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
String msgUrl = host + "/api-open/v1/msg/sendBatch";
|
String msgUrl = host + "/api-open/v1/msg/sendBatch";
|
||||||
|
|||||||
+30
@@ -1,12 +1,15 @@
|
|||||||
package org.jeecg.modules.ksim.dto;
|
package org.jeecg.modules.ksim.dto;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 对应即时通文档 3.4.3 ReqMsgSendDTO
|
* 对应即时通文档 3.4.3 ReqMsgSendDTO
|
||||||
*/
|
*/
|
||||||
public class KsimMsgSendDTO {
|
public class KsimMsgSendDTO {
|
||||||
|
|
||||||
|
public static final Set<String> ALLOWED_LINK_OPEN_MODES = Set.of("Exe", "Web", "None");
|
||||||
|
|
||||||
private String title;
|
private String title;
|
||||||
private String content;
|
private String content;
|
||||||
private String toUserKeyType;
|
private String toUserKeyType;
|
||||||
@@ -17,6 +20,33 @@ public class KsimMsgSendDTO {
|
|||||||
private String linkTitle;
|
private String linkTitle;
|
||||||
private String linkUrl;
|
private String linkUrl;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置可选字段。仅当值非空时才设置,避免向 ksim 发送 null 字段。
|
||||||
|
* linkOpenMode 会校验白名单。
|
||||||
|
*/
|
||||||
|
public void setOptionalFields(String data, String linkOpenMode, String dataFormat,
|
||||||
|
String linkTitle, String linkUrl) {
|
||||||
|
if (data != null && !data.isEmpty()) {
|
||||||
|
this.data = data;
|
||||||
|
}
|
||||||
|
if (linkOpenMode != null && !linkOpenMode.isEmpty()) {
|
||||||
|
if (!ALLOWED_LINK_OPEN_MODES.contains(linkOpenMode)) {
|
||||||
|
throw new IllegalArgumentException("非法的 linkOpenMode: " + linkOpenMode
|
||||||
|
+ ",允许的值: " + ALLOWED_LINK_OPEN_MODES);
|
||||||
|
}
|
||||||
|
this.linkOpenMode = linkOpenMode;
|
||||||
|
}
|
||||||
|
if (dataFormat != null && !dataFormat.isEmpty()) {
|
||||||
|
this.dataFormat = dataFormat;
|
||||||
|
}
|
||||||
|
if (linkTitle != null && !linkTitle.isEmpty()) {
|
||||||
|
this.linkTitle = linkTitle;
|
||||||
|
}
|
||||||
|
if (linkUrl != null && !linkUrl.isEmpty()) {
|
||||||
|
this.linkUrl = linkUrl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public String getTitle() { return title; }
|
public String getTitle() { return title; }
|
||||||
public void setTitle(String title) { this.title = title; }
|
public void setTitle(String title) { this.title = title; }
|
||||||
public String getContent() { return content; }
|
public String getContent() { return content; }
|
||||||
|
|||||||
+16
-22
@@ -3,6 +3,7 @@ package org.jeecg.modules.ksim.service.impl;
|
|||||||
import com.alibaba.fastjson2.JSONObject;
|
import com.alibaba.fastjson2.JSONObject;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.jeecg.common.api.vo.Result;
|
import org.jeecg.common.api.vo.Result;
|
||||||
|
import org.jeecg.common.util.oConvertUtils;
|
||||||
import org.jeecg.modules.ksim.client.KsimApiClient;
|
import org.jeecg.modules.ksim.client.KsimApiClient;
|
||||||
import org.jeecg.modules.ksim.dto.KsimApiResult;
|
import org.jeecg.modules.ksim.dto.KsimApiResult;
|
||||||
import org.jeecg.modules.ksim.dto.KsimMsgSendDTO;
|
import org.jeecg.modules.ksim.dto.KsimMsgSendDTO;
|
||||||
@@ -12,14 +13,11 @@ import org.springframework.stereotype.Service;
|
|||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@Service
|
@Service
|
||||||
public class KsimMessageServiceImpl implements IKsimMessageService {
|
public class KsimMessageServiceImpl implements IKsimMessageService {
|
||||||
|
|
||||||
private static final Set<String> ALLOWED_LINK_OPEN_MODES = Set.of("Exe", "Web", "None");
|
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private KsimTokenManager tokenManager;
|
private KsimTokenManager tokenManager;
|
||||||
|
|
||||||
@@ -31,6 +29,16 @@ public class KsimMessageServiceImpl implements IKsimMessageService {
|
|||||||
String title, String content,
|
String title, String content,
|
||||||
String linkUrl, String linkTitle,
|
String linkUrl, String linkTitle,
|
||||||
String data, String linkOpenMode, String dataFormat) {
|
String data, String linkOpenMode, String dataFormat) {
|
||||||
|
if (toUserValueList == null || toUserValueList.isEmpty()) {
|
||||||
|
log.warn("【即时通推送-sendBatch】toUserValueList为空,跳过发送");
|
||||||
|
return Result.error("接收人列表为空");
|
||||||
|
}
|
||||||
|
if (oConvertUtils.isEmpty(title)) {
|
||||||
|
log.warn("【即时通推送-sendBatch】title为空");
|
||||||
|
}
|
||||||
|
if (oConvertUtils.isEmpty(content)) {
|
||||||
|
log.warn("【即时通推送-sendBatch】content为空");
|
||||||
|
}
|
||||||
String token = tokenManager.getToken();
|
String token = tokenManager.getToken();
|
||||||
|
|
||||||
KsimMsgSendDTO dto = new KsimMsgSendDTO();
|
KsimMsgSendDTO dto = new KsimMsgSendDTO();
|
||||||
@@ -38,25 +46,11 @@ public class KsimMessageServiceImpl implements IKsimMessageService {
|
|||||||
dto.setToUserValueList(toUserValueList);
|
dto.setToUserValueList(toUserValueList);
|
||||||
dto.setTitle(title);
|
dto.setTitle(title);
|
||||||
dto.setContent(content);
|
dto.setContent(content);
|
||||||
// 以下可选字段:传了才设置,不传则不发给 ksim
|
// 可选字段统一通过 setOptionalFields 设置,避免与测试控制器重复
|
||||||
if (data != null && !data.isEmpty()) {
|
try {
|
||||||
dto.setData(data);
|
dto.setOptionalFields(data, linkOpenMode, dataFormat, linkTitle, linkUrl);
|
||||||
}
|
} catch (IllegalArgumentException e) {
|
||||||
if (linkOpenMode != null && !linkOpenMode.isEmpty()) {
|
log.warn("【即时通推送-sendBatch】可选字段校验失败: {}", e.getMessage());
|
||||||
if (!ALLOWED_LINK_OPEN_MODES.contains(linkOpenMode)) {
|
|
||||||
log.warn("【即时通推送-sendBatch】非法的 linkOpenMode: {}, 已跳过", linkOpenMode);
|
|
||||||
} else {
|
|
||||||
dto.setLinkOpenMode(linkOpenMode);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (dataFormat != null && !dataFormat.isEmpty()) {
|
|
||||||
dto.setDataFormat(dataFormat);
|
|
||||||
}
|
|
||||||
if (linkTitle != null && !linkTitle.isEmpty()) {
|
|
||||||
dto.setLinkTitle(linkTitle);
|
|
||||||
}
|
|
||||||
if (linkUrl != null && !linkUrl.isEmpty()) {
|
|
||||||
dto.setLinkUrl(linkUrl);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
KsimApiResult<JSONObject> apiResult = apiClient.sendMsg(token, dto);
|
KsimApiResult<JSONObject> apiResult = apiClient.sendMsg(token, dto);
|
||||||
|
|||||||
+75
-53
@@ -21,16 +21,14 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|||||||
import org.springframework.context.annotation.Lazy;
|
import org.springframework.context.annotation.Lazy;
|
||||||
import org.springframework.jdbc.core.JdbcTemplate;
|
import org.springframework.jdbc.core.JdbcTemplate;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.LinkedHashSet;
|
import java.util.LinkedHashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 审批意见快照 Service 实现。
|
* 审批意见快照 Service 实现。
|
||||||
@@ -54,7 +52,6 @@ public class TaskApprovalOpinionServiceImpl extends ServiceImpl<TaskApprovalOpin
|
|||||||
private IKsimMessageService ksimMessageService;
|
private IKsimMessageService ksimMessageService;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
|
||||||
public Map<String, Object> saveSupplementOpinion(SupplementApprovalOpinionDTO supplementDTO) {
|
public Map<String, Object> saveSupplementOpinion(SupplementApprovalOpinionDTO supplementDTO) {
|
||||||
if (supplementDTO == null || oConvertUtils.isEmpty(supplementDTO.getProcessInstId())) {
|
if (supplementDTO == null || oConvertUtils.isEmpty(supplementDTO.getProcessInstId())) {
|
||||||
throw new JeecgBootException("流程实例ID不能为空");
|
throw new JeecgBootException("流程实例ID不能为空");
|
||||||
@@ -93,41 +90,61 @@ public class TaskApprovalOpinionServiceImpl extends ServiceImpl<TaskApprovalOpin
|
|||||||
opinion.setSysOrgCode(deptInfo.code);
|
opinion.setSysOrgCode(deptInfo.code);
|
||||||
|
|
||||||
fillBusinessSnapshot(opinion);
|
fillBusinessSnapshot(opinion);
|
||||||
save(opinion);
|
if (!save(opinion)) {
|
||||||
|
throw new JeecgBootException("保存增补审批意见失败");
|
||||||
|
}
|
||||||
|
|
||||||
// --- 所领导增补意见 → 即时通推送 ---
|
// --- 所领导增补意见 → 即时通推送(DB 事务外执行,避免 HTTP 调用占用连接池)---
|
||||||
|
return doPushNotification(opinion, deptInfo, loginUser, opinionText, supplementDTO.getBizTitle());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 所领导增补意见即时通推送。在 DB 事务外执行,避免 HTTP 调用占用数据库连接。
|
||||||
|
*/
|
||||||
|
private Map<String, Object> doPushNotification(TaskApprovalOpinion opinion, ApprovalDeptInfo deptInfo,
|
||||||
|
LoginUser loginUser, String opinionText, String frontendBizTitle) {
|
||||||
Map<String, Object> pushResult = new HashMap<>();
|
Map<String, Object> pushResult = new HashMap<>();
|
||||||
|
// 确保所有代码路径返回一致的 key 集合
|
||||||
|
pushResult.put("pushed", false);
|
||||||
|
pushResult.put("toUsers", Collections.emptyList());
|
||||||
|
pushResult.put("content", "");
|
||||||
|
pushResult.put("title", "");
|
||||||
|
pushResult.put("error", "");
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (isSuoLeader(loginUser, deptInfo.id)) {
|
if (!isSuoLeader(deptInfo)) {
|
||||||
String bizTitle = oConvertUtils.isNotEmpty(supplementDTO.getBizTitle())
|
return pushResult;
|
||||||
? supplementDTO.getBizTitle()
|
}
|
||||||
|
String bizTitle = oConvertUtils.isNotEmpty(frontendBizTitle)
|
||||||
|
? frontendBizTitle
|
||||||
: getBizTitle(opinion.getTaskTaskId(), opinion.getProcessInstId());
|
: getBizTitle(opinion.getTaskTaskId(), opinion.getProcessInstId());
|
||||||
String content = "所领导" + (oConvertUtils.isNotEmpty(loginUser.getRealname()) ? loginUser.getRealname() : loginUser.getUsername())
|
String content = "所领导" + (oConvertUtils.isNotEmpty(loginUser.getRealname()) ? loginUser.getRealname() : loginUser.getUsername())
|
||||||
+ "增补意见:" + opinionText;
|
+ "增补意见:" + opinionText;
|
||||||
List<String> handlerNames = getDistinctHandlerNames(opinion.getProcessInstId(), loginUser.getUsername(), loginUser.getRealname());
|
LinkedHashMap<String, String> handlerMap = getDistinctHandlerNames(opinion.getProcessInstId(), loginUser.getUsername(), loginUser.getRealname());
|
||||||
pushResult.put("pushed", !handlerNames.isEmpty());
|
List<String> handlerIds = new ArrayList<>(handlerMap.keySet());
|
||||||
|
List<String> handlerNames = new ArrayList<>(handlerMap.values());
|
||||||
|
pushResult.put("pushed", !handlerIds.isEmpty());
|
||||||
pushResult.put("toUsers", handlerNames);
|
pushResult.put("toUsers", handlerNames);
|
||||||
pushResult.put("content", content);
|
pushResult.put("content", content);
|
||||||
pushResult.put("title", bizTitle);
|
pushResult.put("title", bizTitle);
|
||||||
if (!handlerNames.isEmpty()) {
|
if (!handlerIds.isEmpty()) {
|
||||||
Result<String> sendResult = ksimMessageService.sendBatch("Account", handlerNames, bizTitle, content,
|
Result<String> sendResult = ksimMessageService.sendBatch("Account", handlerIds, bizTitle, content,
|
||||||
null, null, null, null, null);
|
null, null, null, null, null);
|
||||||
if (sendResult != null && sendResult.isSuccess()) {
|
if (sendResult != null && sendResult.isSuccess()) {
|
||||||
log.info("【增补意见-即时通推送】已发送, processInstId: {}, toUserCount: {}, toUsers: {}, title: {}, content: {}",
|
log.info("【增补意见-即时通推送】已发送, processInstId: {}, toUserCount: {}, toUsers: {}, title: {}, content: {}",
|
||||||
opinion.getProcessInstId(), handlerNames.size(), handlerNames, bizTitle, content);
|
opinion.getProcessInstId(), handlerIds.size(), handlerNames, bizTitle, content);
|
||||||
} else {
|
} else {
|
||||||
log.warn("【增补意见-即时通推送】发送失败, reason: {}",
|
String reason = sendResult != null ? sendResult.getMessage() : "null";
|
||||||
sendResult != null ? sendResult.getMessage() : "null");
|
log.warn("【增补意见-即时通推送】发送失败, reason: {}", reason);
|
||||||
pushResult.put("pushed", false);
|
pushResult.put("pushed", false);
|
||||||
|
pushResult.put("error", reason);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
pushResult.put("pushed", false);
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.warn("【增补意见-即时通推送】失败,不影响增补意见保存, error: {}", e.getMessage());
|
String errMsg = e.getMessage() != null ? e.getMessage() : e.getClass().getSimpleName();
|
||||||
|
log.warn("【增补意见-即时通推送】失败,不影响增补意见保存, error: {}", errMsg);
|
||||||
pushResult.put("pushed", false);
|
pushResult.put("pushed", false);
|
||||||
pushResult.put("error", e.getMessage());
|
pushResult.put("error", errMsg);
|
||||||
}
|
}
|
||||||
return pushResult;
|
return pushResult;
|
||||||
}
|
}
|
||||||
@@ -144,6 +161,7 @@ public class TaskApprovalOpinionServiceImpl extends ServiceImpl<TaskApprovalOpin
|
|||||||
String deptId = user != null ? user.getOrgId() : null;
|
String deptId = user != null ? user.getOrgId() : null;
|
||||||
String deptCode = user != null ? user.getOrgCode() : null;
|
String deptCode = user != null ? user.getOrgCode() : null;
|
||||||
String deptName = null;
|
String deptName = null;
|
||||||
|
String departType = null;
|
||||||
|
|
||||||
if (oConvertUtils.isNotEmpty(deptCode)) {
|
if (oConvertUtils.isNotEmpty(deptCode)) {
|
||||||
try {
|
try {
|
||||||
@@ -157,16 +175,33 @@ public class TaskApprovalOpinionServiceImpl extends ServiceImpl<TaskApprovalOpin
|
|||||||
if (oConvertUtils.isEmpty(deptName)) {
|
if (oConvertUtils.isEmpty(deptName)) {
|
||||||
deptName = depart.getString("depart_name");
|
deptName = depart.getString("depart_name");
|
||||||
}
|
}
|
||||||
|
// 一次查询同时捕获 departType,避免 isSuoLeader 再查 sys_depart
|
||||||
|
departType = depart.getString("departType");
|
||||||
|
if (oConvertUtils.isEmpty(departType)) {
|
||||||
|
departType = depart.getString("depart_type");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.debug("获取当前登录部门失败, username={}, orgCode={}", username, deptCode, e);
|
log.warn("【增补意见-审批意见】获取当前登录部门失败, username={}, orgCode={}", username, deptCode, e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (oConvertUtils.isEmpty(deptName) && oConvertUtils.isNotEmpty(username)) {
|
if (oConvertUtils.isEmpty(deptName) && oConvertUtils.isNotEmpty(username)) {
|
||||||
deptName = resolveDeptName(username);
|
deptName = resolveDeptName(username);
|
||||||
}
|
}
|
||||||
return new ApprovalDeptInfo(deptId, deptName, deptCode);
|
// 若 departType 仍未获取到,回退查 sys_depart 表(补回退,通常不会执行)
|
||||||
|
if (oConvertUtils.isEmpty(departType) && oConvertUtils.isNotEmpty(deptId) && jdbcTemplate != null) {
|
||||||
|
try {
|
||||||
|
List<Map<String, Object>> rows = jdbcTemplate.queryForList(
|
||||||
|
"SELECT depart_type FROM sys_depart WHERE id = ?", deptId);
|
||||||
|
if (!rows.isEmpty()) {
|
||||||
|
departType = getStringValue(rows.get(0), "depart_type");
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.warn("【增补意见-审批意见】查询部门类型失败, deptId={}", deptId, e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return new ApprovalDeptInfo(deptId, deptName, deptCode, departType);
|
||||||
}
|
}
|
||||||
|
|
||||||
private String resolveDeptName(String username) {
|
private String resolveDeptName(String username) {
|
||||||
@@ -176,7 +211,7 @@ public class TaskApprovalOpinionServiceImpl extends ServiceImpl<TaskApprovalOpin
|
|||||||
return names.get(0);
|
return names.get(0);
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.debug("获取部门名称失败, username={}", username, e);
|
log.warn("【增补意见-审批意见】获取部门名称失败, username={}", username, e);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -239,24 +274,8 @@ public class TaskApprovalOpinionServiceImpl extends ServiceImpl<TaskApprovalOpin
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isSuoLeader(LoginUser user, String deptId) {
|
private boolean isSuoLeader(ApprovalDeptInfo deptInfo) {
|
||||||
if (oConvertUtils.isEmpty(deptId)) {
|
return "1".equals(deptInfo.departType);
|
||||||
return false;
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
if (jdbcTemplate == null) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
List<Map<String, Object>> rows = jdbcTemplate.queryForList(
|
|
||||||
"select depart_type from sys_depart where id = ?", deptId);
|
|
||||||
if (!rows.isEmpty()) {
|
|
||||||
Object val = rows.get(0).get("depart_type");
|
|
||||||
return val != null && "1".equals(String.valueOf(val));
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
|
||||||
log.debug("查询部门类型失败, deptId={}", deptId, e);
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getBizTitle(String taskTaskId, String processInstId) {
|
private String getBizTitle(String taskTaskId, String processInstId) {
|
||||||
@@ -287,15 +306,16 @@ public class TaskApprovalOpinionServiceImpl extends ServiceImpl<TaskApprovalOpin
|
|||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<String> getDistinctHandlerNames(String processInstId, String excludeUserId, String excludeRealName) {
|
/** userId → userName 映射,保持插入顺序 */
|
||||||
|
private LinkedHashMap<String, String> getDistinctHandlerNames(String processInstId, String excludeUserId, String excludeRealName) {
|
||||||
if (jdbcTemplate == null || oConvertUtils.isEmpty(processInstId)) {
|
if (jdbcTemplate == null || oConvertUtils.isEmpty(processInstId)) {
|
||||||
return Collections.emptyList();
|
return new LinkedHashMap<>();
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
List<Map<String, Object>> rows = jdbcTemplate.queryForList(
|
List<Map<String, Object>> rows = jdbcTemplate.queryForList(
|
||||||
"select distinct op_user_id, op_user_name from task_approval_opinion where process_inst_id = ?",
|
"SELECT DISTINCT op_user_id, op_user_name FROM task_approval_opinion WHERE process_inst_id = ?",
|
||||||
processInstId);
|
processInstId);
|
||||||
Set<String> userIds = new LinkedHashSet<>();
|
LinkedHashMap<String, String> handlerMap = new LinkedHashMap<>();
|
||||||
for (Map<String, Object> row : rows) {
|
for (Map<String, Object> row : rows) {
|
||||||
Object idVal = row.get("op_user_id");
|
Object idVal = row.get("op_user_id");
|
||||||
Object nameVal = row.get("op_user_name");
|
Object nameVal = row.get("op_user_name");
|
||||||
@@ -318,14 +338,14 @@ public class TaskApprovalOpinionServiceImpl extends ServiceImpl<TaskApprovalOpin
|
|||||||
log.info("【增补意见-即时通推送】排除本人(姓名匹配), name: {}, userId: {}", name, userId);
|
log.info("【增补意见-即时通推送】排除本人(姓名匹配), name: {}, userId: {}", name, userId);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
userIds.add(userId);
|
handlerMap.putIfAbsent(userId, name);
|
||||||
}
|
}
|
||||||
log.info("【增补意见-即时通推送】查询经办人完成, processInstId: {}, DB记录数: {}, 排除后: {}",
|
log.info("【增补意见-即时通推送】查询经办人完成, processInstId: {}, DB记录数: {}, 排除后: {}",
|
||||||
processInstId, rows.size(), userIds.size());
|
processInstId, rows.size(), handlerMap.size());
|
||||||
return userIds.stream().collect(Collectors.toList());
|
return handlerMap;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.debug("查询经办人失败, processInstId={}", processInstId, e);
|
log.warn("【增补意见-即时通推送】查询经办人失败, processInstId={}", processInstId, e);
|
||||||
return Collections.emptyList();
|
return new LinkedHashMap<>();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -333,11 +353,13 @@ public class TaskApprovalOpinionServiceImpl extends ServiceImpl<TaskApprovalOpin
|
|||||||
private final String id;
|
private final String id;
|
||||||
private final String name;
|
private final String name;
|
||||||
private final String code;
|
private final String code;
|
||||||
|
private final String departType;
|
||||||
|
|
||||||
private ApprovalDeptInfo(String id, String name, String code) {
|
private ApprovalDeptInfo(String id, String name, String code, String departType) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.code = code;
|
this.code = code;
|
||||||
|
this.departType = departType;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user