✨ 组织类型改业务字典,并完善金蝶部门代码与MK再提交
组织类型翻译切换为 organization_type;新增金蝶部门代码字段;流程已结束或已通过时强制新建MK表单实例。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
+6
@@ -138,6 +138,12 @@ public class Dept extends TenantEntity {
|
||||
@Schema(description = "部门编码")
|
||||
private String deptCode;
|
||||
|
||||
/**
|
||||
* 金蝶部门代码
|
||||
*/
|
||||
@Schema(description = "金蝶部门代码")
|
||||
private String kingdeeDeptCode;
|
||||
|
||||
/**
|
||||
* 组织简称
|
||||
*/
|
||||
|
||||
+43
-7
@@ -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不能为空");
|
||||
|
||||
+2
-3
@@ -44,11 +44,10 @@ import org.springblade.core.tenant.annotation.NonDS;
|
||||
import org.springblade.core.tool.api.R;
|
||||
import org.springblade.core.tool.support.Kv;
|
||||
import org.springblade.core.tool.utils.Func;
|
||||
import org.springblade.system.cache.DictCache;
|
||||
import org.springblade.system.cache.DictBizCache;
|
||||
import org.springblade.system.cache.UserCache;
|
||||
import org.springblade.system.pojo.entity.Dept;
|
||||
import org.springblade.system.pojo.entity.User;
|
||||
import org.springblade.system.pojo.enums.DictEnum;
|
||||
import org.springblade.system.pojo.vo.DeptVO;
|
||||
import org.springblade.system.pojo.vo.OaOrgSyncPageVO;
|
||||
import org.springblade.system.pojo.vo.UserVO;
|
||||
@@ -156,7 +155,7 @@ public class DeptController extends BladeController {
|
||||
CacheUtil.clear(SYS_CACHE, Boolean.FALSE);
|
||||
// 返回懒加载树更新节点所需字段
|
||||
Kv kv = Kv.create().set("id", String.valueOf(dept.getId())).set("tenantId", dept.getTenantId())
|
||||
.set("deptCategoryName", DictCache.getValue(DictEnum.ORG_CATEGORY, dept.getDeptCategory()));
|
||||
.set("deptCategoryName", DictBizCache.getValue("organization_type", dept.getDeptCategory()));
|
||||
return R.data(kv);
|
||||
}
|
||||
return R.fail("操作失败");
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
<result column="leader_id" property="leaderId"/>
|
||||
<result column="dept_category" property="deptCategory"/>
|
||||
<result column="dept_code" property="deptCode"/>
|
||||
<result column="kingdee_dept_code" property="kingdeeDeptCode"/>
|
||||
<result column="short_name" property="shortName"/>
|
||||
<result column="pinyin_mnemonic" property="pinyinMnemonic"/>
|
||||
<result column="mnemonic_code" property="mnemonicCode"/>
|
||||
@@ -32,6 +33,7 @@
|
||||
<result column="leader_id" property="leaderId"/>
|
||||
<result column="dept_category" property="deptCategory"/>
|
||||
<result column="dept_code" property="deptCode"/>
|
||||
<result column="kingdee_dept_code" property="kingdeeDeptCode"/>
|
||||
<result column="short_name" property="shortName"/>
|
||||
<result column="pinyin_mnemonic" property="pinyinMnemonic"/>
|
||||
<result column="mnemonic_code" property="mnemonicCode"/>
|
||||
|
||||
+9
-5
@@ -30,10 +30,9 @@ import org.springblade.core.tool.constant.BladeConstant;
|
||||
import org.springblade.core.tool.node.ForestNodeMerger;
|
||||
import org.springblade.core.tool.utils.BeanUtil;
|
||||
import org.springblade.core.tool.utils.Func;
|
||||
import org.springblade.system.cache.DictCache;
|
||||
import org.springblade.system.cache.DictBizCache;
|
||||
import org.springblade.system.cache.SysCache;
|
||||
import org.springblade.system.pojo.entity.Dept;
|
||||
import org.springblade.system.pojo.enums.DictEnum;
|
||||
import org.springblade.system.pojo.vo.DeptVO;
|
||||
|
||||
import java.util.List;
|
||||
@@ -47,6 +46,11 @@ import java.util.stream.Collectors;
|
||||
*/
|
||||
public class DeptWrapper extends BaseEntityWrapper<Dept, DeptVO> {
|
||||
|
||||
/**
|
||||
* 组织类型业务字典编码
|
||||
*/
|
||||
private static final String ORGANIZATION_TYPE_CODE = "organization_type";
|
||||
|
||||
public static DeptWrapper build() {
|
||||
return new DeptWrapper();
|
||||
}
|
||||
@@ -60,7 +64,7 @@ public class DeptWrapper extends BaseEntityWrapper<Dept, DeptVO> {
|
||||
Dept parent = SysCache.getDept(dept.getParentId());
|
||||
deptVO.setParentName(parent.getDeptName());
|
||||
}
|
||||
String category = DictCache.getValue(DictEnum.ORG_CATEGORY, dept.getDeptCategory());
|
||||
String category = DictBizCache.getValue(ORGANIZATION_TYPE_CODE, dept.getDeptCategory());
|
||||
deptVO.setDeptCategoryName(category);
|
||||
return deptVO;
|
||||
}
|
||||
@@ -69,7 +73,7 @@ public class DeptWrapper extends BaseEntityWrapper<Dept, DeptVO> {
|
||||
public List<DeptVO> listNodeVO(List<Dept> list) {
|
||||
List<DeptVO> collect = list.stream().map(dept -> {
|
||||
DeptVO deptVO = BeanUtil.copyProperties(dept, DeptVO.class);
|
||||
String category = DictCache.getValue(DictEnum.ORG_CATEGORY, dept.getDeptCategory());
|
||||
String category = DictBizCache.getValue(ORGANIZATION_TYPE_CODE, dept.getDeptCategory());
|
||||
Objects.requireNonNull(deptVO).setDeptCategoryName(category);
|
||||
return deptVO;
|
||||
}).collect(Collectors.toList());
|
||||
@@ -78,7 +82,7 @@ public class DeptWrapper extends BaseEntityWrapper<Dept, DeptVO> {
|
||||
|
||||
public List<DeptVO> listNodeLazyVO(List<DeptVO> list) {
|
||||
List<DeptVO> collect = list.stream().peek(dept -> {
|
||||
String category = DictCache.getValue(DictEnum.ORG_CATEGORY, dept.getDeptCategory());
|
||||
String category = DictBizCache.getValue(ORGANIZATION_TYPE_CODE, dept.getDeptCategory());
|
||||
Objects.requireNonNull(dept).setDeptCategoryName(category);
|
||||
}).collect(Collectors.toList());
|
||||
return ForestNodeMerger.merge(collect);
|
||||
|
||||
@@ -303,6 +303,7 @@ CREATE TABLE `blade_dept` (
|
||||
`dept_name` varchar(45) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '部门名',
|
||||
`full_name` varchar(45) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '部门全称',
|
||||
`dept_code` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '组织编码',
|
||||
`kingdee_dept_code` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '金蝶部门代码',
|
||||
`short_name` varchar(45) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '组织简称',
|
||||
`pinyin_mnemonic` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '拼音助记码',
|
||||
`mnemonic_code` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '助记码',
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
-- 机构表:新增「金蝶部门代码」字段,非必填
|
||||
|
||||
ALTER TABLE `blade_dept`
|
||||
ADD COLUMN `kingdee_dept_code` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '金蝶部门代码' AFTER `dept_code`;
|
||||
Reference in New Issue
Block a user