@ -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<PowerAxisStructD
verifyStructField ( dto ) ;
PowerAxisStructEntity entity = ConvertUtils . sourceToTarget ( dto , PowerAxisStructEntity . class ) ;
this . assembleStruct ( entity ) ;
this . assembleStruct ( entity , dto . getStructLevel ( ) ) ;
baseDao . insert ( entity ) ;
}
@ -111,7 +109,7 @@ public class PowerAxisStructServiceImpl extends BaseServiceImpl<PowerAxisStructD
verifyStructField ( dto ) ;
PowerAxisStructEntity entity = ConvertUtils . sourceToTarget ( dto , PowerAxisStructEntity . class ) ;
this . assembleStruct ( entity ) ;
this . assembleStruct ( entity , dto . getStructLevel ( ) ) ;
baseDao . updateById ( entity ) ;
}
@ -143,12 +141,17 @@ public class PowerAxisStructServiceImpl extends BaseServiceImpl<PowerAxisStructD
String customerId = structDto . getCustomerId ( ) ;
String categoryCode = structDto . getCategoryCode ( ) ;
String agencyId = structDto . getAgencyId ( ) ;
Integer structLevel = structDto . getStructLevel ( ) ;
int structLevel = powerAxisTagService . selectStructLevelByCode ( customerId , PowerTagCategoryEnum . STRUCT . category ( ) , categoryCode ) ;
if ( PowerTagLevelEnum . ROOT . level ( ) = = structLevel ) {
if ( baseDao . countRepeatStructByCategory ( customerId , agencyId , categoryCode , structDto . getId ( ) ) > 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<PowerAxisStructD
/ * *
* 组装节点对象
*
* @param struct 提交的表单
* @param struct 提交的表单
* @param structLevel 节点级别
* @return void
* @author work @yujt.net.cn
* @date 2022 / 4 / 22 / 0022 14 : 04
* /
private void assembleStruct ( PowerAxisStructEntity struct ) {
private void assembleStruct ( PowerAxisStructEntity struct , int structLevel ) {
// 上级节点
String pid = struct . getPid ( ) ;
// 类别编码
String categoryCode = struct . getCategoryCode ( ) ;
if ( StringUtils . isBlank ( pid ) ) {
// 查询类别编码对应的节点级别
int structLevel = powerAxisTagService . selectStructLevelByCode ( struct . getCustomerId ( ) , PowerTagCategoryEnum . STRUCT . category ( ) , categoryCode ) ;
if ( PowerTagLevelEnum . ROOT . level ( ) = = structLevel ) {
pid = NumConstant . ZERO_STR ;
} else {