✨ 组织类型改业务字典,并完善金蝶部门代码与MK再提交

组织类型翻译切换为 organization_type;新增金蝶部门代码字段;流程已结束或已通过时强制新建MK表单实例。

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-09-29 03:15:26 +08:00
parent 32cff235e0
commit 087f361a8b
7 changed files with 67 additions and 15 deletions
@@ -140,22 +140,23 @@ public class BusinessProcessServiceImpl extends ServiceImpl<BusinessProcessMappe
String bizType = param.getBizType();
Long bizId = resolveBizIdFromSubmitParam(param);
boolean forceNew = Boolean.TRUE.equals(param.getForceNewFormInstance());
Long formInstanceId = mkFormBindService.resolveOrCreateFormInstanceId(bizType, bizId, forceNew);
String formInstanceIdText = String.valueOf(formInstanceId);
param.setFormInstanceId(formInstanceIdText);
BusinessProcess businessProcess = this.getOne(Wrappers.<BusinessProcess>lambdaQuery()
.eq(BusinessProcess::getBizId, bizId)
.orderByDesc(BusinessProcess::getUpdateTime)
.last("limit 1")
);
// 已有流程实例且 MK 仍能查到详情时,不再删除、不再重新创建提交(强制新建时跳过短路)
boolean forceNew = Boolean.TRUE.equals(param.getForceNewFormInstance())
|| shouldForceNewFormInstance(businessProcess, loginName);
Long formInstanceId = mkFormBindService.resolveOrCreateFormInstanceId(bizType, bizId, forceNew);
String formInstanceIdText = String.valueOf(formInstanceId);
param.setFormInstanceId(formInstanceIdText);
// 已有流程实例且 MK 仍能查到详情时,不再删除、不再重新创建提交(强制新建或流程已结束时跳过短路)
if (!forceNew && businessProcess != null && StringUtil.isNotBlank(businessProcess.getProcessInstanceId())
&& Objects.equals(formInstanceId, businessProcess.getFormInstanceId())) {
String existingProcessInstanceId = businessProcess.getProcessInstanceId();
Object existingProcessInfo = this.getProcessInfo(existingProcessInstanceId, loginName);
if (hasProcessInfoData(existingProcessInfo)) {
if (hasProcessInfoData(existingProcessInfo) && !isMkProcessFinished(existingProcessInfo)) {
log.info("MK流程实例已存在,跳过创建并提交流程 bizId={} formInstanceId={} processInstanceId={}",
bizId, formInstanceIdText, existingProcessInstanceId);
businessProcess.setApproveStatus(ApproveStatusEnum.APPROVING.getValue());
@@ -169,6 +170,11 @@ public class BusinessProcessServiceImpl extends ServiceImpl<BusinessProcessMappe
this.syncBizFromProcessInfo(bizType, String.valueOf(bizId), existingProcessInfo);
return existingProcessInstanceId;
}
// 已结束但仍能查到详情:继续走新建提交流程
forceNew = true;
formInstanceId = mkFormBindService.resolveOrCreateFormInstanceId(bizType, bizId, true);
formInstanceIdText = String.valueOf(formInstanceId);
param.setFormInstanceId(formInstanceIdText);
}
MKProcessCreateDTO mkParam = new MKProcessCreateDTO();
@@ -231,6 +237,36 @@ public class BusinessProcessServiceImpl extends ServiceImpl<BusinessProcessMappe
}
}
/**
* 是否需要强制新建表单实例:本地已通过/已完结,或 MK 流程已结束
*/
private boolean shouldForceNewFormInstance(BusinessProcess businessProcess, String loginName) {
if (businessProcess == null) {
return false;
}
if (Objects.equals(ApproveStatusEnum.APPROVED.getValue(), businessProcess.getApproveStatus())) {
return true;
}
if (businessProcess.getIsCompleted() != null && businessProcess.getIsCompleted() == 1) {
return true;
}
if (StringUtil.isBlank(businessProcess.getProcessInstanceId())) {
return false;
}
String resolvedLoginName = loginName;
if (StringUtil.isBlank(resolvedLoginName)) {
resolvedLoginName = businessProcess.getPromoterLoginName();
}
if (StringUtil.isBlank(resolvedLoginName)) {
resolvedLoginName = resolveCurrentUserPhone();
}
if (StringUtil.isBlank(resolvedLoginName)) {
return false;
}
Object processInfo = this.getProcessInfo(businessProcess.getProcessInstanceId(), resolvedLoginName);
return isMkProcessFinished(processInfo);
}
@Override
public boolean hasMkProcessInstance(String bizId) {
AssertUtils.notBlank(bizId, "业务id不能为空");