|
|
|
@ -1,10 +1,9 @@
|
|
|
|
|
package org.dromara.qms.service.impl;
|
|
|
|
|
|
|
|
|
|
import org.apache.commons.lang3.ObjectUtils;
|
|
|
|
|
import org.dromara.common.core.exception.ServiceException;
|
|
|
|
|
import org.dromara.common.core.utils.MapstructUtils;
|
|
|
|
|
import org.dromara.common.core.utils.StringUtils;
|
|
|
|
|
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
|
|
|
|
import org.dromara.common.mybatis.core.page.PageQuery;
|
|
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
|
|
import com.github.yulichang.toolkit.JoinWrappers;
|
|
|
|
|
import com.github.yulichang.wrapper.MPJLambdaWrapper;
|
|
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
|
@ -25,7 +24,7 @@ import java.util.Collection;
|
|
|
|
|
* 检测项类别Service业务层处理
|
|
|
|
|
*
|
|
|
|
|
* @author zch
|
|
|
|
|
* @date 2025-07-14
|
|
|
|
|
* @date 2025-07-17
|
|
|
|
|
*/
|
|
|
|
|
@RequiredArgsConstructor
|
|
|
|
|
@Service
|
|
|
|
@ -44,19 +43,6 @@ public class QcInspectionItemCategoryServiceImpl implements IQcInspectionItemCat
|
|
|
|
|
return baseMapper.selectVoById(categoryId);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 分页查询检测项类别列表
|
|
|
|
|
*
|
|
|
|
|
* @param bo 查询条件
|
|
|
|
|
* @param pageQuery 分页参数
|
|
|
|
|
* @return 检测项类别分页列表
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
public TableDataInfo<QcInspectionItemCategoryVo> queryPageList(QcInspectionItemCategoryBo bo, PageQuery pageQuery) {
|
|
|
|
|
MPJLambdaWrapper<QcInspectionItemCategory> lqw = buildQueryWrapper(bo);
|
|
|
|
|
Page<QcInspectionItemCategoryVo> result = baseMapper.selectVoPage(pageQuery.build(), lqw);
|
|
|
|
|
return TableDataInfo.build(result);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 查询符合条件的检测项类别列表
|
|
|
|
@ -80,6 +66,8 @@ public class QcInspectionItemCategoryServiceImpl implements IQcInspectionItemCat
|
|
|
|
|
.leftJoin(QcInspectionType.class, QcInspectionType::getTypeId, QcInspectionItemCategory::getTypeId)
|
|
|
|
|
|
|
|
|
|
.eq(bo.getCategoryId() != null, QcInspectionItemCategory::getCategoryId, bo.getCategoryId())
|
|
|
|
|
.eq(bo.getParentId() != null, QcInspectionItemCategory::getParentId, bo.getParentId())
|
|
|
|
|
.eq(StringUtils.isNotBlank(bo.getAncestors()), QcInspectionItemCategory::getAncestors, bo.getAncestors())
|
|
|
|
|
.eq(StringUtils.isNotBlank(bo.getCategoryCode()), QcInspectionItemCategory::getCategoryCode, bo.getCategoryCode())
|
|
|
|
|
.like(StringUtils.isNotBlank(bo.getCategoryName()), QcInspectionItemCategory::getCategoryName, bo.getCategoryName())
|
|
|
|
|
.eq(bo.getTypeId() != null, QcInspectionItemCategory::getTypeId, bo.getTypeId())
|
|
|
|
@ -98,6 +86,18 @@ public class QcInspectionItemCategoryServiceImpl implements IQcInspectionItemCat
|
|
|
|
|
public Boolean insertByBo(QcInspectionItemCategoryBo bo) {
|
|
|
|
|
QcInspectionItemCategory add = MapstructUtils.convert(bo, QcInspectionItemCategory.class);
|
|
|
|
|
validEntityBeforeSave(add);
|
|
|
|
|
|
|
|
|
|
// 获取父节点信息
|
|
|
|
|
QcInspectionItemCategoryVo query = baseMapper.selectVoById(bo.getParentId());
|
|
|
|
|
if (ObjectUtils.isNotEmpty(query)) {
|
|
|
|
|
//若父节点不为空,则将父节点的ancestors拼接父节点id拼接成ancestors
|
|
|
|
|
add.setAncestors(query.getAncestors() + "," + bo.getParentId());
|
|
|
|
|
}else{
|
|
|
|
|
//若父节点为空,则ancestors仅有父节点id
|
|
|
|
|
add.setAncestors(bo.getParentId().toString());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
boolean flag = baseMapper.insert(add) > 0;
|
|
|
|
|
if (flag) {
|
|
|
|
|
bo.setCategoryId(add.getCategoryId());
|
|
|
|
@ -136,7 +136,17 @@ public class QcInspectionItemCategoryServiceImpl implements IQcInspectionItemCat
|
|
|
|
|
public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) {
|
|
|
|
|
if(isValid){
|
|
|
|
|
//TODO 做一些业务上的校验,判断是否需要校验
|
|
|
|
|
for (Long id : ids) {
|
|
|
|
|
// 判断是否存在子节点
|
|
|
|
|
QcInspectionItemCategory query = new QcInspectionItemCategory();
|
|
|
|
|
query.setParentId(id);
|
|
|
|
|
if (baseMapper.selectCount(Wrappers.lambdaQuery(query)) > 0) {
|
|
|
|
|
throw new ServiceException("存在子节点,不允许删除");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return baseMapper.deleteByIds(ids) > 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|