|
|
@ -5,15 +5,21 @@ import com.baomidou.mybatisplus.core.metadata.IPage; |
|
|
|
|
|
|
|
import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; |
|
|
|
import com.epmet.commons.tools.constant.FieldConstant; |
|
|
|
import com.epmet.commons.tools.constant.NumConstant; |
|
|
|
import com.epmet.commons.tools.exception.EpmetErrorCode; |
|
|
|
import com.epmet.commons.tools.exception.EpmetException; |
|
|
|
import com.epmet.commons.tools.page.PageData; |
|
|
|
import com.epmet.commons.tools.security.user.LoginUserUtil; |
|
|
|
import com.epmet.commons.tools.utils.ConvertUtils; |
|
|
|
import com.epmet.plugin.power.dto.axis.PowerAxisStructDTO; |
|
|
|
import com.epmet.plugin.power.dto.axis.form.*; |
|
|
|
import com.epmet.plugin.power.dto.axis.result.*; |
|
|
|
import com.epmet.plugin.power.enums.PowerTagCategoryEnum; |
|
|
|
import com.epmet.plugin.power.enums.PowerTagLevelEnum; |
|
|
|
import com.epmet.plugin.power.modules.axis.dao.PowerAxisStructDao; |
|
|
|
import com.epmet.plugin.power.modules.axis.entity.PowerAxisStructEntity; |
|
|
|
import com.epmet.plugin.power.modules.axis.redis.PowerAxisStructRedis; |
|
|
|
import com.epmet.plugin.power.modules.axis.service.PowerAxisStructService; |
|
|
|
import com.epmet.plugin.power.modules.axis.service.PowerAxisTagService; |
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
@ -34,7 +40,10 @@ import java.util.Map; |
|
|
|
public class PowerAxisStructServiceImpl extends BaseServiceImpl<PowerAxisStructDao, PowerAxisStructEntity> implements PowerAxisStructService { |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private PowerAxisStructRedis powerAxisStructRedis; |
|
|
|
private PowerAxisTagService powerAxisTagService; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private LoginUserUtil loginUserUtil; |
|
|
|
|
|
|
|
@Resource |
|
|
|
private PowerAxisStructDao powerAxisStructDao; |
|
|
@ -55,8 +64,8 @@ public class PowerAxisStructServiceImpl extends BaseServiceImpl<PowerAxisStructD |
|
|
|
return ConvertUtils.sourceToTarget(entityList, PowerAxisStructDTO.class); |
|
|
|
} |
|
|
|
|
|
|
|
private QueryWrapper<PowerAxisStructEntity> getWrapper(Map<String, Object> params){ |
|
|
|
String id = (String)params.get(FieldConstant.ID_HUMP); |
|
|
|
private QueryWrapper<PowerAxisStructEntity> getWrapper(Map<String, Object> params) { |
|
|
|
String id = (String) params.get(FieldConstant.ID_HUMP); |
|
|
|
|
|
|
|
QueryWrapper<PowerAxisStructEntity> wrapper = new QueryWrapper<>(); |
|
|
|
wrapper.eq(StringUtils.isNotBlank(id), FieldConstant.ID, id); |
|
|
@ -104,43 +113,42 @@ public class PowerAxisStructServiceImpl extends BaseServiceImpl<PowerAxisStructD |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
public List<PowerAxisStructLeaderResultDTO> selectAllForTree(PowerAxisStructLeaderFormDTO formDto) { |
|
|
|
return baseDao.selectAllForTree(formDto); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public int addOrg(PowerAxisStructEntity form) { |
|
|
|
if(form.getCategoryCode().equals("community_party")){ |
|
|
|
public void addOrg(PowerAxisStructEntity form) { |
|
|
|
int structLevel = powerAxisTagService.selectStructLevelByCode(loginUserUtil.getLoginUserCustomerId(), PowerTagCategoryEnum.LEADER.category(), form.getCategoryCode()); |
|
|
|
if (PowerTagLevelEnum.ROOT.level() == structLevel) { |
|
|
|
int y = baseDao.queryCategory(form); |
|
|
|
if(y != 0){ |
|
|
|
return -2; |
|
|
|
if (y > NumConstant.ZERO) { |
|
|
|
throw new EpmetException(EpmetErrorCode.SERVER_ERROR.getCode(), StringUtils.EMPTY, "同一组织下只允许存在一个顶级节点"); |
|
|
|
} |
|
|
|
} |
|
|
|
int x = baseDao.queryName(form); |
|
|
|
if(x == 0){ |
|
|
|
int i = baseDao.insert(form); |
|
|
|
return i; |
|
|
|
if (x > NumConstant.ZERO) { |
|
|
|
throw new EpmetException(EpmetErrorCode.SERVER_ERROR.getCode(), StringUtils.EMPTY, "同一组织下不允许存在重名的节点"); |
|
|
|
} |
|
|
|
return -1; |
|
|
|
baseDao.insert(form); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public int modifyRog(PowerAxisStructEntity form) { |
|
|
|
if(form.getId().equals( form.getPid())){ |
|
|
|
if (form.getId().equals(form.getPid())) { |
|
|
|
return 0; |
|
|
|
} |
|
|
|
if(form.getCategoryCode().equals("community_party")){ |
|
|
|
if (form.getCategoryCode().equals("community_party")) { |
|
|
|
int y = baseDao.queryCategory(form); |
|
|
|
y = y-1; |
|
|
|
if(y != 0){ |
|
|
|
y = y - 1; |
|
|
|
if (y != 0) { |
|
|
|
return -2; |
|
|
|
} |
|
|
|
} |
|
|
|
int x = baseDao.queryName(form); |
|
|
|
x = x - 1; |
|
|
|
if(x != 0){ |
|
|
|
if (x != 0) { |
|
|
|
return -3; |
|
|
|
} |
|
|
|
int i = baseDao.updateById(form); |
|
|
|