yxk-20260622-bug修复:写入审批历史的部门为当前用户登录所在部门
This commit is contained in:
+60
-12
@@ -117,13 +117,14 @@ public class ExtActBpmLogServiceImpl extends ServiceImpl<ExtActBpmLogMapper, Ext
|
|||||||
String fileList = oConvertUtils.getString(map.get("fileList"));
|
String fileList = oConvertUtils.getString(map.get("fileList"));
|
||||||
saveBpmFiles(bpmlog.getId(), fileList);
|
saveBpmFiles(bpmlog.getId(), fileList);
|
||||||
|
|
||||||
|
ApprovalDeptInfo approvalDept = resolveCurrentApprovalDept(user, username);
|
||||||
//写入新的审批意见表
|
//写入新的审批意见表
|
||||||
saveTaskApprovalOpinion(bpmlog, processInstance, RECORD_TYPE_PROCESS,
|
saveTaskApprovalOpinion(bpmlog, processInstance, RECORD_TYPE_PROCESS,
|
||||||
resolveHandleActionType(map, rejectDescription), resolveActionResult(reason, "同意"),
|
resolveHandleActionType(map, rejectDescription), resolveActionResult(reason, "同意"),
|
||||||
task != null ? task.getCreateTime() : null,
|
task != null ? task.getCreateTime() : null,
|
||||||
user != null ? user.getOrgId() : null,
|
approvalDept.id,
|
||||||
resolveDeptName(username),
|
approvalDept.name,
|
||||||
user != null ? user.getOrgCode() : null);
|
approvalDept.code);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -156,12 +157,13 @@ public class ExtActBpmLogServiceImpl extends ServiceImpl<ExtActBpmLogMapper, Ext
|
|||||||
}
|
}
|
||||||
this.baseMapper.insert(taskLog);
|
this.baseMapper.insert(taskLog);
|
||||||
|
|
||||||
|
ApprovalDeptInfo approvalDept = resolveCurrentApprovalDept(user, username);
|
||||||
saveTaskApprovalOpinion(taskLog, processInstance, RECORD_TYPE_SYSTEM,
|
saveTaskApprovalOpinion(taskLog, processInstance, RECORD_TYPE_SYSTEM,
|
||||||
resolveSystemActionType(comment), resolveActionResult(comment, "系统记录"),
|
resolveSystemActionType(comment), resolveActionResult(comment, "系统记录"),
|
||||||
task != null ? task.getCreateTime() : null,
|
task != null ? task.getCreateTime() : null,
|
||||||
user != null ? user.getOrgId() : null,
|
approvalDept.id,
|
||||||
resolveDeptName(username),
|
approvalDept.name,
|
||||||
user != null ? user.getOrgCode() : null);
|
approvalDept.code);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -194,11 +196,12 @@ public class ExtActBpmLogServiceImpl extends ServiceImpl<ExtActBpmLogMapper, Ext
|
|||||||
bpmlog.setTaskName(task.getName());
|
bpmlog.setTaskName(task.getName());
|
||||||
this.baseMapper.insert(bpmlog);
|
this.baseMapper.insert(bpmlog);
|
||||||
|
|
||||||
|
ApprovalDeptInfo approvalDept = resolveCurrentApprovalDept(user, username);
|
||||||
saveTaskApprovalOpinion(bpmlog, processInstance, RECORD_TYPE_PROCESS, ACTION_ADD_SIGN, resolveActionResult(reason, "加签"),
|
saveTaskApprovalOpinion(bpmlog, processInstance, RECORD_TYPE_PROCESS, ACTION_ADD_SIGN, resolveActionResult(reason, "加签"),
|
||||||
task != null ? task.getCreateTime() : null,
|
task != null ? task.getCreateTime() : null,
|
||||||
user != null ? user.getOrgId() : null,
|
approvalDept.id,
|
||||||
resolveDeptName(username),
|
approvalDept.name,
|
||||||
user != null ? user.getOrgCode() : null);
|
approvalDept.code);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -225,12 +228,13 @@ public class ExtActBpmLogServiceImpl extends ServiceImpl<ExtActBpmLogMapper, Ext
|
|||||||
|
|
||||||
String username = bpmLog.getOpUserId();
|
String username = bpmLog.getOpUserId();
|
||||||
LoginUser user = oConvertUtils.isNotEmpty(username) ? sysBaseAPI.getUserByName(username) : null;
|
LoginUser user = oConvertUtils.isNotEmpty(username) ? sysBaseAPI.getUserByName(username) : null;
|
||||||
|
ApprovalDeptInfo approvalDept = resolveCurrentApprovalDept(user, username);
|
||||||
saveTaskApprovalOpinion(bpmLog, processInstance, RECORD_TYPE_SYSTEM,
|
saveTaskApprovalOpinion(bpmLog, processInstance, RECORD_TYPE_SYSTEM,
|
||||||
resolveSystemActionType(bpmLog.getRemarks()), resolveActionResult(bpmLog.getRemarks(), ACTION_SYSTEM),
|
resolveSystemActionType(bpmLog.getRemarks()), resolveActionResult(bpmLog.getRemarks(), ACTION_SYSTEM),
|
||||||
startTime,
|
startTime,
|
||||||
user != null ? user.getOrgId() : null,
|
approvalDept.id,
|
||||||
oConvertUtils.isNotEmpty(username) ? resolveDeptName(username) : null,
|
approvalDept.name,
|
||||||
user != null ? user.getOrgCode() : null);
|
approvalDept.code);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("补写系统审批历史失败,已保留原 ext_act_bpm_log。procInstId={}, taskId={}",
|
log.error("补写系统审批历史失败,已保留原 ext_act_bpm_log。procInstId={}, taskId={}",
|
||||||
bpmLog.getProcInstId(), bpmLog.getTaskId(), e);
|
bpmLog.getProcInstId(), bpmLog.getTaskId(), e);
|
||||||
@@ -273,6 +277,50 @@ public class ExtActBpmLogServiceImpl extends ServiceImpl<ExtActBpmLogMapper, Ext
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新审批意见表记录办理人当前登录部门,避免多部门用户按部门列表第一个写入导致部门不一致。
|
||||||
|
*/
|
||||||
|
private ApprovalDeptInfo resolveCurrentApprovalDept(LoginUser user, String username) {
|
||||||
|
String deptId = user != null ? user.getOrgId() : null;
|
||||||
|
String deptCode = user != null ? user.getOrgCode() : null;
|
||||||
|
String deptName = null;
|
||||||
|
|
||||||
|
if (oConvertUtils.isNotEmpty(deptCode)) {
|
||||||
|
try {
|
||||||
|
List<JSONObject> departs = sysBaseAPI.queryDepartsByOrgcodes(deptCode);
|
||||||
|
if (departs != null && !departs.isEmpty()) {
|
||||||
|
JSONObject depart = departs.get(0);
|
||||||
|
if (oConvertUtils.isEmpty(deptId)) {
|
||||||
|
deptId = depart.getString("id");
|
||||||
|
}
|
||||||
|
deptName = depart.getString("departName");
|
||||||
|
if (oConvertUtils.isEmpty(deptName)) {
|
||||||
|
deptName = depart.getString("depart_name");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.debug("获取当前登录部门失败, username={}, orgCode={}", username, deptCode, e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (oConvertUtils.isEmpty(deptName) && oConvertUtils.isNotEmpty(username)) {
|
||||||
|
deptName = resolveDeptName(username);
|
||||||
|
}
|
||||||
|
return new ApprovalDeptInfo(deptId, deptName, deptCode);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static class ApprovalDeptInfo {
|
||||||
|
private final String id;
|
||||||
|
private final String name;
|
||||||
|
private final String code;
|
||||||
|
|
||||||
|
private ApprovalDeptInfo(String id, String name, String code) {
|
||||||
|
this.id = id;
|
||||||
|
this.name = name;
|
||||||
|
this.code = code;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private String resolveDeptName(String username) {
|
private String resolveDeptName(String username) {
|
||||||
try {
|
try {
|
||||||
List<String> names = sysBaseAPI.getDepartNamesByUsername(username);
|
List<String> names = sysBaseAPI.getDepartNamesByUsername(username);
|
||||||
|
|||||||
Reference in New Issue
Block a user