Browse Source

调整信息节点的逻辑

dev_power_axis
YUJT 3 years ago
parent
commit
ea85bda1f5
  1. 40
      epmet-plugins-module/pli-power-base/pli-power-base-client/src/main/java/com/epmet/plugin/power/dto/axis/PowerAxisStructDTO.java
  2. 15
      epmet-plugins-module/pli-power-base/pli-power-base-server/src/main/java/com/epmet/plugin/power/modules/axis/dao/PowerAxisTagDao.java
  3. 12
      epmet-plugins-module/pli-power-base/pli-power-base-server/src/main/java/com/epmet/plugin/power/modules/axis/service/PowerAxisTagService.java
  4. 21
      epmet-plugins-module/pli-power-base/pli-power-base-server/src/main/java/com/epmet/plugin/power/modules/axis/service/impl/PowerAxisStructServiceImpl.java
  5. 5
      epmet-plugins-module/pli-power-base/pli-power-base-server/src/main/java/com/epmet/plugin/power/modules/axis/service/impl/PowerAxisTagServiceImpl.java
  6. 14
      epmet-plugins-module/pli-power-base/pli-power-base-server/src/main/resources/mapper/poweraxis/PowerAxisTagDao.xml

40
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.io.Serializable;
import java.util.Date; import java.util.Date;
import lombok.Data; import lombok.Data;
/** /**
* 动力主轴结构 * 动力主轴结构
* *
* @author generator generator@elink-cn.com * @author generator generator@elink-cn.com
* @since v1.0.0 2022-04-18 * @since v1.0.0 2022-04-18
@ -19,81 +20,86 @@ public class PowerAxisStructDTO implements Serializable {
/** /**
* 主键 * 主键
*/ */
private String id; private String id;
/** /**
* 客户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.已删除 * 删除标识 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;
} }

15
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.dto.axis.result.PowerAxisAllTagCategoryResultDTO;
import com.epmet.plugin.power.modules.axis.entity.PowerAxisTagEntity; import com.epmet.plugin.power.modules.axis.entity.PowerAxisTagEntity;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List; import java.util.List;
@ -24,4 +25,18 @@ public interface PowerAxisTagDao extends BaseDao<PowerAxisTagEntity> {
* @date 2022/4/19/0019 9:14 * @date 2022/4/19/0019 9:14
*/ */
List<PowerAxisAllTagCategoryResultDTO> listSimpleAll(); List<PowerAxisAllTagCategoryResultDTO> 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);
} }

12
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<PowerAxisTagEntity> {
* @date 2022/4/21/0021 17:21 * @date 2022/4/21/0021 17:21
*/ */
int selectStructLevelByCode(String customerId, String tagCategory, String categoryCode); 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);
} }

21
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; 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.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage; 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.mybatis.service.impl.BaseServiceImpl;
import com.epmet.commons.tools.constant.FieldConstant; import com.epmet.commons.tools.constant.FieldConstant;
import com.epmet.commons.tools.constant.NumConstant; import com.epmet.commons.tools.constant.NumConstant;
@ -96,7 +94,7 @@ public class PowerAxisStructServiceImpl extends BaseServiceImpl<PowerAxisStructD
verifyStructField(dto); verifyStructField(dto);
PowerAxisStructEntity entity = ConvertUtils.sourceToTarget(dto, PowerAxisStructEntity.class); PowerAxisStructEntity entity = ConvertUtils.sourceToTarget(dto, PowerAxisStructEntity.class);
this.assembleStruct(entity); this.assembleStruct(entity, dto.getStructLevel());
baseDao.insert(entity); baseDao.insert(entity);
} }
@ -111,7 +109,7 @@ public class PowerAxisStructServiceImpl extends BaseServiceImpl<PowerAxisStructD
verifyStructField(dto); verifyStructField(dto);
PowerAxisStructEntity entity = ConvertUtils.sourceToTarget(dto, PowerAxisStructEntity.class); PowerAxisStructEntity entity = ConvertUtils.sourceToTarget(dto, PowerAxisStructEntity.class);
this.assembleStruct(entity); this.assembleStruct(entity, dto.getStructLevel());
baseDao.updateById(entity); baseDao.updateById(entity);
} }
@ -143,12 +141,17 @@ public class PowerAxisStructServiceImpl extends BaseServiceImpl<PowerAxisStructD
String customerId = structDto.getCustomerId(); String customerId = structDto.getCustomerId();
String categoryCode = structDto.getCategoryCode(); String categoryCode = structDto.getCategoryCode();
String agencyId = structDto.getAgencyId(); String agencyId = structDto.getAgencyId();
Integer structLevel = structDto.getStructLevel();
int structLevel = powerAxisTagService.selectStructLevelByCode(customerId, PowerTagCategoryEnum.STRUCT.category(), categoryCode);
if (PowerTagLevelEnum.ROOT.level() == structLevel) { if (PowerTagLevelEnum.ROOT.level() == structLevel) {
if (baseDao.countRepeatStructByCategory(customerId, agencyId, categoryCode, structDto.getId()) > NumConstant.ZERO) { if (baseDao.countRepeatStructByCategory(customerId, agencyId, categoryCode, structDto.getId()) > NumConstant.ZERO) {
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "同一组织下只允许存在一个顶级节点"); 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) { if (baseDao.countRepeatStructByName(customerId, structDto.getName(), agencyId, structDto.getPid(), structDto.getId()) > NumConstant.ZERO) {
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "同一组织下不允许存在重名的节点"); throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "同一组织下不允许存在重名的节点");
@ -158,20 +161,18 @@ public class PowerAxisStructServiceImpl extends BaseServiceImpl<PowerAxisStructD
/** /**
* 组装节点对象 * 组装节点对象
* *
* @param struct 提交的表单 * @param struct 提交的表单
* @param structLevel 节点级别
* @return void * @return void
* @author work@yujt.net.cn * @author work@yujt.net.cn
* @date 2022/4/22/0022 14:04 * @date 2022/4/22/0022 14:04
*/ */
private void assembleStruct(PowerAxisStructEntity struct) { private void assembleStruct(PowerAxisStructEntity struct, int structLevel) {
// 上级节点 // 上级节点
String pid = struct.getPid(); String pid = struct.getPid();
// 类别编码
String categoryCode = struct.getCategoryCode();
if (StringUtils.isBlank(pid)) { if (StringUtils.isBlank(pid)) {
// 查询类别编码对应的节点级别 // 查询类别编码对应的节点级别
int structLevel = powerAxisTagService.selectStructLevelByCode(struct.getCustomerId(), PowerTagCategoryEnum.STRUCT.category(), categoryCode);
if (PowerTagLevelEnum.ROOT.level() == structLevel) { if (PowerTagLevelEnum.ROOT.level() == structLevel) {
pid = NumConstant.ZERO_STR; pid = NumConstant.ZERO_STR;
} else { } else {

5
epmet-plugins-module/pli-power-base/pli-power-base-server/src/main/java/com/epmet/plugin/power/modules/axis/service/impl/PowerAxisTagServiceImpl.java

@ -130,4 +130,9 @@ public class PowerAxisTagServiceImpl extends BaseServiceImpl<PowerAxisTagDao, Po
} }
return list.get(NumConstant.ZERO).getStructLevel(); return list.get(NumConstant.ZERO).getStructLevel();
} }
@Override
public Integer selectStructLevelById(String customerId, String tagCategory, String axisStructId) {
return baseDao.selectStructLevelById(customerId, tagCategory, axisStructId);
}
} }

14
epmet-plugins-module/pli-power-base/pli-power-base-server/src/main/resources/mapper/poweraxis/PowerAxisTagDao.xml

@ -31,6 +31,20 @@
<select id="listSimpleAll" resultMap="listSimpleAllResultMap"> <select id="listSimpleAll" resultMap="listSimpleAllResultMap">
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 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
</select> </select>
<select id="selectStructLevelById" resultType="java.lang.Integer">
SELECT
t.struct_level
FROM
pli_power_axis_struct s
LEFT JOIN pli_power_axis_tag t ON t.CATEGORY_CODE = s.CATEGORY_CODE
WHERE
t.DEL_FLAG = '0'
AND s.DEL_FLAG = '0'
AND t.TAG_CATEGORY = #{tagCategory}
AND s.CUSTOMER_ID = #{customerId}
AND t.CUSTOMER_ID = #{customerId}
AND s.id = #{axisStructId}
</select>
</mapper> </mapper>
Loading…
Cancel
Save