update 删除流程分类状态

This commit is contained in:
AprilWind 2024-12-17 11:33:52 +08:00
parent 2d8efda0c6
commit b076574726
7 changed files with 9 additions and 73 deletions

View File

@ -96,12 +96,6 @@ public class FlwCategoryController extends BaseController {
return R.fail("修改流程分类'" + category.getCategoryName() + "'失败,流程分类名称已存在");
} else if (category.getParentId().equals(categoryId)) {
return R.fail("修改流程分类'" + category.getCategoryName() + "'失败,上级流程分类不能是自己");
} else if (StringUtils.equals(SystemConstants.DISABLE, category.getStatus())) {
if (flwCategoryService.selectNormalChildrenCategoryById(categoryId) > 0) {
return R.fail("该流程分类包含未停用的子流程分类!");
} else if (flwCategoryService.checkCategoryExistDefinition(categoryId)) {
return R.fail("该部门下存在已分配流程定义,不能禁用!");
}
}
return toAjax(flwCategoryService.updateByBo(category));
}

View File

@ -49,11 +49,6 @@ public class FlowCategory extends TenantEntity {
*/
private Long orderNum;
/**
* 流程分类状态0正常 1停用
*/
private String status;
/**
* 删除标志0代表存在 2代表删除
*/

View File

@ -44,9 +44,4 @@ public class FlowCategoryBo extends BaseEntity {
*/
private Long orderNum;
/**
* 流程分类状态0正常 1停用
*/
private String status;
}

View File

@ -60,13 +60,6 @@ public class FlowCategoryVo implements Serializable {
@ExcelProperty(value = "显示顺序")
private Long orderNum;
/**
* 流程分类状态0正常 1停用
*/
@ExcelProperty(value = "流程分类状态", converter = ExcelDictConvert.class)
@ExcelDictFormat(readConverterExp = "0=正常,1=停用")
private String status;
/**
* 创建时间
*/

View File

@ -60,14 +60,6 @@ public interface IFlwCategoryService {
*/
boolean checkCategoryNameUnique(FlowCategoryBo category);
/**
* 根据ID查询所有子流程分类数正常状态
*
* @param categoryId 流程分类ID
* @return 子流程分类数
*/
long selectNormalChildrenCategoryById(Long categoryId);
/**
* 查询流程分类是否存在流程定义
*

View File

@ -1,11 +1,9 @@
package org.dromara.workflow.service.impl;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.convert.Convert;
import cn.hutool.core.lang.tree.Tree;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import lombok.RequiredArgsConstructor;
import org.dromara.common.core.constant.SystemConstants;
@ -26,7 +24,6 @@ import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
/**
@ -108,8 +105,7 @@ public class FlwCategoryServiceImpl implements IFlwCategoryService {
tree.setId(dept.getCategoryId())
.setParentId(dept.getParentId())
.setName(dept.getCategoryName())
.setWeight(dept.getOrderNum())
.putExtra("disabled", SystemConstants.DISABLE.equals(dept.getStatus())));
.setWeight(dept.getOrderNum()));
Tree<Long> tree = StreamUtils.findFirst(trees, it -> it.getId().longValue() == d.getCategoryId());
treeList.add(tree);
}
@ -150,19 +146,6 @@ public class FlwCategoryServiceImpl implements IFlwCategoryService {
return !exist;
}
/**
* 根据ID查询所有子流程分类数正常状态
*
* @param categoryId 流程分类ID
* @return 子流程分类数
*/
@Override
public long selectNormalChildrenCategoryById(Long categoryId) {
return baseMapper.selectCount(new LambdaQueryWrapper<FlowCategory>()
.eq(FlowCategory::getStatus, SystemConstants.NORMAL)
.apply(DataBaseHelper.findInSet(categoryId, "ancestors")));
}
/**
* 查询流程分类是否存在流程定义
*
@ -194,7 +177,6 @@ public class FlwCategoryServiceImpl implements IFlwCategoryService {
lqw.eq(ObjectUtil.isNotNull(bo.getCategoryId()), FlowCategory::getCategoryId, bo.getCategoryId());
lqw.eq(ObjectUtil.isNotNull(bo.getParentId()), FlowCategory::getParentId, bo.getParentId());
lqw.like(StringUtils.isNotBlank(bo.getCategoryName()), FlowCategory::getCategoryName, bo.getCategoryName());
lqw.eq(StringUtils.isNotBlank(bo.getStatus()), FlowCategory::getStatus, bo.getStatus());
lqw.orderByAsc(FlowCategory::getAncestors);
lqw.orderByAsc(FlowCategory::getParentId);
lqw.orderByAsc(FlowCategory::getOrderNum);
@ -217,7 +199,6 @@ public class FlwCategoryServiceImpl implements IFlwCategoryService {
FlowCategory info = baseMapper.selectById(bo.getParentId());
category.setAncestors(info.getAncestors() + StringUtils.SEPARATOR + category.getParentId());
}
return baseMapper.insert(category);
}
@ -248,13 +229,7 @@ public class FlwCategoryServiceImpl implements IFlwCategoryService {
} else {
category.setAncestors(oldCategory.getAncestors());
}
int result = baseMapper.updateById(category);
if (SystemConstants.NORMAL.equals(category.getStatus()) && StringUtils.isNotEmpty(category.getAncestors())
&& !StringUtils.equals(SystemConstants.NORMAL, category.getAncestors())) {
// 如果该流程分类是启用状态则启用该流程分类的所有上级流程分类
updateParentCategoryStatusNormal(category);
}
return result;
return baseMapper.updateById(category);
}
/**
@ -279,19 +254,6 @@ public class FlwCategoryServiceImpl implements IFlwCategoryService {
}
}
/**
* 修改该流程分类的父级流程分类状态
*
* @param category 当前流程分类
*/
private void updateParentCategoryStatusNormal(FlowCategory category) {
String ancestors = category.getAncestors();
Long[] categoryIds = Convert.toLongArray(ancestors);
baseMapper.update(null, new LambdaUpdateWrapper<FlowCategory>()
.set(FlowCategory::getStatus, SystemConstants.NORMAL)
.in(FlowCategory::getCategoryId, Arrays.asList(categoryIds)));
}
/**
* 删除流程分类信息
*

View File

@ -157,7 +157,6 @@ create table flow_category
ancestors varchar(500) default '' comment '祖级列表',
category_name varchar(30) not null comment '流程分类名称',
order_num int(4) default 0 comment '显示顺序',
status char(1) default '0' comment '流程分类状态0正常 1停用',
del_flag char(1) default '0' comment '删除标志0代表存在 2代表删除',
create_dept bigint(20) null comment '创建部门',
create_by bigint(20) null comment '创建者',
@ -167,7 +166,13 @@ create table flow_category
primary key (category_id)
) engine = innodb comment = '流程分类';
INSERT INTO flow_category values (1, '000000', 0, '0', 'OA', 0, '0', '0', 103, 1, sysdate(), null, null);
INSERT INTO flow_category values (100, '000000', 0, '0', 'OA审批', 0, '0', 103, 1, sysdate(), null, null);
INSERT INTO flow_category values (101, '000000', 100, '0,100', '假勤管理', 0, '0', 103, 1, sysdate(), null, null);
INSERT INTO flow_category values (102, '000000', 100, '0,100', '人事管理', 0, '0', 103, 1, sysdate(), null, null);
INSERT INTO flow_category values (103, '000000', 100, '0,100', '财税管理', 0, '0', 103, 1, sysdate(), null, null);
INSERT INTO flow_category values (104, '000000', 100, '0,100', '资产管理', 0, '0', 103, 1, sysdate(), null, null);
INSERT INTO flow_category values (105, '000000', 100, '0,100', '工程管理', 0, '0', 103, 1, sysdate(), null, null);
INSERT INTO flow_category values (106, '000000', 100, '0,100', '商旅管理', 0, '0', 103, 1, sysdate(), null, null);
-- ----------------------------
-- 请假单信息