业务流已存在友好返回提示

This commit is contained in:
syruan 2025-12-17 14:54:34 +08:00
parent a7c05d744d
commit e0e8e1c836
2 changed files with 20 additions and 13 deletions

View File

@ -56,17 +56,25 @@ public class ApprovalProcessServiceImpl implements IApprovalProcessService {
@Override
@Transactional(rollbackFor = Exception.class)
public int insertProcess(ApprovalProcess process) {
// 检查是否已存在相同业务类型的流程
ApprovalProcess existingProcess = processMapper.selectProcessByBusinessType(process.getBusinessType());
if (existingProcess != null) {
throw new RuntimeException("业务类型 [" + process.getBusinessType() + "] 的审批流程已存在,流程名称:" + existingProcess.getProcessName());
}
// 插入流程
int rows = processMapper.insertProcess(process);
// 插入节点
if (process.getNodeList() != null && !process.getNodeList().isEmpty()) {
for (ApprovalNode node : process.getNodeList()) {
node.setProcessId(process.getId());
if (rows > 0) {
// 插入节点
if (process.getNodeList() != null && !process.getNodeList().isEmpty()) {
for (ApprovalNode node : process.getNodeList()) {
node.setProcessId(process.getId());
}
nodeMapper.batchInsertNode(process.getNodeList());
}
nodeMapper.batchInsertNode(process.getNodeList());
}
return rows;
}
@ -75,10 +83,10 @@ public class ApprovalProcessServiceImpl implements IApprovalProcessService {
public int updateProcess(ApprovalProcess process) {
// 更新流程
int rows = processMapper.updateProcess(process);
// 删除旧节点
nodeMapper.deleteNodeByProcessId(process.getId());
// 插入新节点
if (process.getNodeList() != null && !process.getNodeList().isEmpty()) {
for (ApprovalNode node : process.getNodeList()) {
@ -86,7 +94,7 @@ public class ApprovalProcessServiceImpl implements IApprovalProcessService {
}
nodeMapper.batchInsertNode(process.getNodeList());
}
return rows;
}

View File

@ -52,8 +52,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="selectProcessByBusinessType" parameterType="String" resultMap="ApprovalProcessResult">
<include refid="selectProcessVo"/>
where business_type = #{businessType} and status = '1'
limit 1
where business_type = #{businessType} limit 1
</select>
<select id="selectProcessByCode" parameterType="String" resultMap="ApprovalProcessResult">
@ -62,7 +61,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</select>
<insert id="insertProcess" parameterType="com.bonus.material.approval.domain.ApprovalProcess" useGeneratedKeys="true" keyProperty="id">
insert into bm_approval_process
insert ignore into bm_approval_process
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="processCode != null and processCode != ''">process_code,</if>
<if test="processName != null and processName != ''">process_name,</if>