diff --git a/epmet-plugins-module/pli-power-base/pli-power-base-client/src/main/java/com/epmet/plugin/power/dto/axis/PowerAxisStructDTO.java b/epmet-plugins-module/pli-power-base/pli-power-base-client/src/main/java/com/epmet/plugin/power/dto/axis/PowerAxisStructDTO.java index b503092..bf4a256 100644 --- a/epmet-plugins-module/pli-power-base/pli-power-base-client/src/main/java/com/epmet/plugin/power/dto/axis/PowerAxisStructDTO.java +++ b/epmet-plugins-module/pli-power-base/pli-power-base-client/src/main/java/com/epmet/plugin/power/dto/axis/PowerAxisStructDTO.java @@ -2,11 +2,12 @@ package com.epmet.plugin.power.dto.axis; import java.io.Serializable; import java.util.Date; + import lombok.Data; /** - * 动力主轴结构 + * 动力主轴结构 * * @author generator generator@elink-cn.com * @since v1.0.0 2022-04-18 @@ -19,81 +20,86 @@ public class PowerAxisStructDTO implements Serializable { /** * 主键 */ - private String id; + private String id; /** * 客户ID */ - private String customerId; + private String customerId; /** * 名称 */ - private String name; + private String name; /** * 绑定组织主键 */ - private String agencyId; + private String agencyId; /** * 绑定组织名称 */ - private String agencyName; + private String agencyName; /** * 绑定组织类别编码 */ - private String agencyType; + private String agencyType; /** * 上级主键 */ - private String pid; + private String pid; /** * 上级主键路径 全部上级主键,以:拼接 */ - private String pids; + private String pids; /** * 类别编码 */ - private String categoryCode; + private String categoryCode; /** * 排序 正序 */ - private Integer sort; + private Integer sort; + + /** + * 对应节点等级 0,1,2 + */ + private Integer structLevel; /** * 删除标识 0.未删除 1.已删除 */ - private String delFlag; + private String delFlag; /** * 乐观锁 */ - private Integer revision; + private Integer revision; /** * 创建人 */ - private String createdBy; + private String createdBy; /** * 创建时间 */ - private Date createdTime; + private Date createdTime; /** * 更新人 */ - private String updatedBy; + private String updatedBy; /** * 更新时间 */ - private Date updatedTime; + private Date updatedTime; } \ No newline at end of file diff --git a/epmet-plugins-module/pli-power-base/pli-power-base-server/src/main/java/com/epmet/plugin/power/modules/axis/dao/PowerAxisTagDao.java b/epmet-plugins-module/pli-power-base/pli-power-base-server/src/main/java/com/epmet/plugin/power/modules/axis/dao/PowerAxisTagDao.java index 81f435b..ef10c7e 100644 --- a/epmet-plugins-module/pli-power-base/pli-power-base-server/src/main/java/com/epmet/plugin/power/modules/axis/dao/PowerAxisTagDao.java +++ b/epmet-plugins-module/pli-power-base/pli-power-base-server/src/main/java/com/epmet/plugin/power/modules/axis/dao/PowerAxisTagDao.java @@ -4,6 +4,7 @@ import com.epmet.commons.mybatis.dao.BaseDao; import com.epmet.plugin.power.dto.axis.result.PowerAxisAllTagCategoryResultDTO; import com.epmet.plugin.power.modules.axis.entity.PowerAxisTagEntity; import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; import java.util.List; @@ -24,4 +25,18 @@ public interface PowerAxisTagDao extends BaseDao { * @date 2022/4/19/0019 9:14 */ List listSimpleAll(); + + /** + * 根据ID查询节点等级 + * + * @param customerId 客户ID + * @param tagCategory 标签类别 + * @param axisStructId 节点ID + * @return int + * @author work@yujt.net.cn + * @date 2022/4/23/0023 15:42 + */ + Integer selectStructLevelById(@Param("customerId") String customerId, + @Param("tagCategory") String tagCategory, + @Param("axisStructId") String axisStructId); } \ No newline at end of file diff --git a/epmet-plugins-module/pli-power-base/pli-power-base-server/src/main/java/com/epmet/plugin/power/modules/axis/service/PowerAxisTagService.java b/epmet-plugins-module/pli-power-base/pli-power-base-server/src/main/java/com/epmet/plugin/power/modules/axis/service/PowerAxisTagService.java index 994b2b1..decaebf 100644 --- a/epmet-plugins-module/pli-power-base/pli-power-base-server/src/main/java/com/epmet/plugin/power/modules/axis/service/PowerAxisTagService.java +++ b/epmet-plugins-module/pli-power-base/pli-power-base-server/src/main/java/com/epmet/plugin/power/modules/axis/service/PowerAxisTagService.java @@ -109,4 +109,16 @@ public interface PowerAxisTagService extends BaseService { * @date 2022/4/21/0021 17:21 */ int selectStructLevelByCode(String customerId, String tagCategory, String categoryCode); + + /** + * 根据ID查询节点等级 + * + * @param customerId 客户ID + * @param tagCategory 标签类别 + * @param axisStructId 节点ID + * @return java.lang.Integer + * @author work@yujt.net.cn + * @date 2022/4/23/0023 15:51 + */ + Integer selectStructLevelById(String customerId, String tagCategory, String axisStructId); } \ No newline at end of file diff --git a/epmet-plugins-module/pli-power-base/pli-power-base-server/src/main/java/com/epmet/plugin/power/modules/axis/service/impl/PowerAxisStructServiceImpl.java b/epmet-plugins-module/pli-power-base/pli-power-base-server/src/main/java/com/epmet/plugin/power/modules/axis/service/impl/PowerAxisStructServiceImpl.java index af51fe0..67c41e1 100644 --- a/epmet-plugins-module/pli-power-base/pli-power-base-server/src/main/java/com/epmet/plugin/power/modules/axis/service/impl/PowerAxisStructServiceImpl.java +++ b/epmet-plugins-module/pli-power-base/pli-power-base-server/src/main/java/com/epmet/plugin/power/modules/axis/service/impl/PowerAxisStructServiceImpl.java @@ -1,10 +1,8 @@ package com.epmet.plugin.power.modules.axis.service.impl; -import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; -import com.epmet.commons.mybatis.enums.EpmetDelFlagEnum; import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; import com.epmet.commons.tools.constant.FieldConstant; import com.epmet.commons.tools.constant.NumConstant; @@ -96,7 +94,7 @@ public class PowerAxisStructServiceImpl extends BaseServiceImpl NumConstant.ZERO) { throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "同一组织下只允许存在一个顶级节点"); } + } else { + int parentStructLevel = powerAxisTagService.selectStructLevelById(customerId, PowerTagCategoryEnum.STRUCT.category(), structDto.getPid()); + if (parentStructLevel - structLevel > NumConstant.ONE) { + throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "无法跨级添加节点"); + } } if (baseDao.countRepeatStructByName(customerId, structDto.getName(), agencyId, structDto.getPid(), structDto.getId()) > NumConstant.ZERO) { throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "同一组织下不允许存在重名的节点"); @@ -158,20 +161,18 @@ public class PowerAxisStructServiceImpl extends BaseServiceImpl select t.TAG_CATEGORY,t.CATEGORY_NAME,t.CATEGORY_CODE,t.STRUCT_LEVEL from pli_power_axis_tag t where t.DEL_FLAG = '0' and t.FORBIDDEN_FLAG = '0' order by t.STRUCT_LEVEL + \ No newline at end of file