|
@@ -10,12 +10,14 @@ import cn.iocoder.yudao.module.pms.controller.admin.vo.IotInfoClassifySaveReqVO;
|
|
|
import cn.iocoder.yudao.module.pms.dal.dataobject.IotInfoClassifyDO;
|
|
|
import cn.iocoder.yudao.module.pms.dal.mysql.IotInfoClassifyMapper;
|
|
|
import cn.iocoder.yudao.module.pms.dal.dataobject.IotTreeDO;
|
|
|
+import cn.iocoder.yudao.module.pms.dal.mysql.IotInfoMapper;
|
|
|
import cn.iocoder.yudao.module.pms.dal.mysql.IotTreeMapper;
|
|
|
import cn.iocoder.yudao.module.system.dal.redis.RedisKeyConstants;
|
|
|
import cn.iocoder.yudao.module.system.enums.ErrorCodeConstants;
|
|
|
import com.google.common.annotations.VisibleForTesting;
|
|
|
import com.google.common.collect.ImmutableMap;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.cache.annotation.CacheEvict;
|
|
|
import org.springframework.cache.annotation.Cacheable;
|
|
|
import org.springframework.stereotype.Service;
|
|
@@ -27,6 +29,7 @@ import java.util.*;
|
|
|
|
|
|
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
|
|
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet;
|
|
|
+import static cn.iocoder.yudao.module.pms.enums.ErrorCodeConstant.IOT_INFO_EXISTS;
|
|
|
import static cn.iocoder.yudao.module.system.enums.ErrorCodeConstants.*;
|
|
|
|
|
|
/**
|
|
@@ -43,6 +46,8 @@ public class IotInfoClassifyServiceImpl implements IotInfoClassifyService {
|
|
|
private IotInfoClassifyMapper iotInfoClassifyMapper;
|
|
|
@Resource
|
|
|
private IotTreeMapper iotTreeMapper;
|
|
|
+ @Autowired
|
|
|
+ private IotInfoMapper iotInfoMapper;
|
|
|
|
|
|
@Override
|
|
|
@CacheEvict(cacheNames = RedisKeyConstants.IOT_INFO_CHILDREN_ID_LIST,
|
|
@@ -93,11 +98,16 @@ public class IotInfoClassifyServiceImpl implements IotInfoClassifyService {
|
|
|
iotInfoClassifyMapper.updateById(updateObj);
|
|
|
//更新pms树
|
|
|
List<IotTreeDO> iotTreeDOS = iotTreeMapper.selectListByOriginId(updateObj.getId(), "file");
|
|
|
- if (org.apache.commons.collections4.CollectionUtils.isNotEmpty(iotTreeDOS)) {
|
|
|
+ List<IotTreeDO> parentIotTreeDOS = iotTreeMapper.selectListByOriginId(updateObj.getParentId(), "file");
|
|
|
+ if (org.apache.commons.collections4.CollectionUtils.isEmpty(iotTreeDOS)) {
|
|
|
throw new ServiceException(ErrorCodeConstants.DEPT_NOT_FOUND.getCode(),"无该部门");
|
|
|
}
|
|
|
+ if (org.apache.commons.collections4.CollectionUtils.isEmpty(parentIotTreeDOS)) {
|
|
|
+ throw new ServiceException(ErrorCodeConstants.DEPT_NOT_FOUND.getCode(),"无该节点");
|
|
|
+ }
|
|
|
IotTreeDO iotTreeDO = iotTreeDOS.get(0);
|
|
|
iotTreeDO.setName(updateObj.getName());
|
|
|
+ iotTreeDO.setParentId(parentIotTreeDOS.get(0).getId());
|
|
|
iotTreeMapper.updateById(iotTreeDO);
|
|
|
}
|
|
|
|
|
@@ -110,12 +120,14 @@ public class IotInfoClassifyServiceImpl implements IotInfoClassifyService {
|
|
|
validateIotInfoClassifyExists(id);
|
|
|
// 校验是否有子产品分类
|
|
|
if (iotInfoClassifyMapper.selectCountByParentId(id) > 0) {
|
|
|
- throw exception(DEPT_EXITS_CHILDREN);
|
|
|
+ throw exception(IOT_INFO_EXISTS);
|
|
|
}
|
|
|
// 删除产品分类
|
|
|
iotInfoClassifyMapper.deleteById(id);
|
|
|
//删除pms树
|
|
|
iotTreeMapper.deleteByMap(ImmutableMap.of("origin_id", id));
|
|
|
+ //删除文件
|
|
|
+ iotInfoMapper.deleteByMap(ImmutableMap.of("class_id", id));
|
|
|
}
|
|
|
|
|
|
@VisibleForTesting
|