From f00a0fdb9d19a644f8b09a8857f1e4235a2d96f4 Mon Sep 17 00:00:00 2001 From: YUJT Date: Thu, 21 Apr 2022 17:41:20 +0800 Subject: [PATCH] update --- .../PowerAxisStructLeaderResultDTO.java | 5 ++ .../power/enums/PowerTagCategoryEnum.java | 29 ++++++++++++ .../plugin/power/enums/PowerTagLevelEnum.java | 34 ++++++++++++++ .../controller/PowerAxisStructController.java | 10 +--- .../axis/service/PowerAxisStructService.java | 2 +- .../axis/service/PowerAxisTagService.java | 12 +++++ .../impl/PowerAxisStructServiceImpl.java | 46 +++++++++++-------- .../service/impl/PowerAxisTagServiceImpl.java | 19 +++++++- .../src/main/resources/logback-spring.xml | 13 ++++-- .../mapper/poweraxis/PowerAxisStructDao.xml | 4 +- 10 files changed, 138 insertions(+), 36 deletions(-) create mode 100644 epmet-plugins-module/pli-power-base/pli-power-base-client/src/main/java/com/epmet/plugin/power/enums/PowerTagCategoryEnum.java create mode 100644 epmet-plugins-module/pli-power-base/pli-power-base-client/src/main/java/com/epmet/plugin/power/enums/PowerTagLevelEnum.java diff --git a/epmet-plugins-module/pli-power-base/pli-power-base-client/src/main/java/com/epmet/plugin/power/dto/axis/result/PowerAxisStructLeaderResultDTO.java b/epmet-plugins-module/pli-power-base/pli-power-base-client/src/main/java/com/epmet/plugin/power/dto/axis/result/PowerAxisStructLeaderResultDTO.java index 42ae015..628a394 100644 --- a/epmet-plugins-module/pli-power-base/pli-power-base-client/src/main/java/com/epmet/plugin/power/dto/axis/result/PowerAxisStructLeaderResultDTO.java +++ b/epmet-plugins-module/pli-power-base/pli-power-base-client/src/main/java/com/epmet/plugin/power/dto/axis/result/PowerAxisStructLeaderResultDTO.java @@ -67,4 +67,9 @@ public class PowerAxisStructLeaderResultDTO implements Serializable { */ private String leaderMobile; + /** + * 对应节点等级 0,1,2 + */ + private Integer structLevel; + } \ No newline at end of file diff --git a/epmet-plugins-module/pli-power-base/pli-power-base-client/src/main/java/com/epmet/plugin/power/enums/PowerTagCategoryEnum.java b/epmet-plugins-module/pli-power-base/pli-power-base-client/src/main/java/com/epmet/plugin/power/enums/PowerTagCategoryEnum.java new file mode 100644 index 0000000..7e42bd6 --- /dev/null +++ b/epmet-plugins-module/pli-power-base/pli-power-base-client/src/main/java/com/epmet/plugin/power/enums/PowerTagCategoryEnum.java @@ -0,0 +1,29 @@ +package com.epmet.plugin.power.enums; + + +/*** + * 动力主轴相关标签类别 + * @author work@yujt.net.cn + * @date 2022/4/21/0021 17:11 + */ +public enum PowerTagCategoryEnum { + + /** + * 动力主轴负责人 + */ + LEADER("leader"), + /** + * 动力主轴节点 + */ + STRUCT("struct"); + + private String category; + + PowerTagCategoryEnum(String category) { + this.category = category; + } + + public String category() { + return category; + } +} diff --git a/epmet-plugins-module/pli-power-base/pli-power-base-client/src/main/java/com/epmet/plugin/power/enums/PowerTagLevelEnum.java b/epmet-plugins-module/pli-power-base/pli-power-base-client/src/main/java/com/epmet/plugin/power/enums/PowerTagLevelEnum.java new file mode 100644 index 0000000..03aa721 --- /dev/null +++ b/epmet-plugins-module/pli-power-base/pli-power-base-client/src/main/java/com/epmet/plugin/power/enums/PowerTagLevelEnum.java @@ -0,0 +1,34 @@ +package com.epmet.plugin.power.enums; + +import com.epmet.commons.tools.constant.NumConstant; + +/*** + * 动力主轴相关节点级别 + * @author work@yujt.net.cn + * @date 2022/4/21/0021 17:11 + */ +public enum PowerTagLevelEnum { + + /** + * 顶级节点 + */ + ROOT(NumConstant.ZERO), + /** + * 二级节点 + */ + CHILD_FIRST(NumConstant.ONE), + /** + * 三级节点 + */ + CHILD_SECOND(NumConstant.TWO); + + private int level; + + PowerTagLevelEnum(int level) { + this.level = level; + } + + public int level() { + return level; + } +} diff --git a/epmet-plugins-module/pli-power-base/pli-power-base-server/src/main/java/com/epmet/plugin/power/modules/axis/controller/PowerAxisStructController.java b/epmet-plugins-module/pli-power-base/pli-power-base-server/src/main/java/com/epmet/plugin/power/modules/axis/controller/PowerAxisStructController.java index da94724..1281b01 100644 --- a/epmet-plugins-module/pli-power-base/pli-power-base-server/src/main/java/com/epmet/plugin/power/modules/axis/controller/PowerAxisStructController.java +++ b/epmet-plugins-module/pli-power-base/pli-power-base-server/src/main/java/com/epmet/plugin/power/modules/axis/controller/PowerAxisStructController.java @@ -17,12 +17,10 @@ import com.epmet.plugin.power.dto.axis.PowerAxisStructDTO; import com.epmet.plugin.power.dto.axis.form.PowerAxisStructLeaderFormDTO; import com.epmet.plugin.power.dto.axis.form.PowerAxisStructListByCategoryCodeFormDTO; import com.epmet.plugin.power.dto.axis.result.*; -import com.epmet.plugin.power.dto.axis.form.PowerAxisStructAddFormDTO; import com.epmet.plugin.power.dto.axis.form.PowerAxisStructFormDTO; import com.epmet.plugin.power.modules.axis.entity.PowerAxisStructEntity; import com.epmet.plugin.power.modules.axis.excel.PowerAxisStructExcel; import com.epmet.plugin.power.modules.axis.service.PowerAxisStructService; -import oracle.jdbc.proxy.annotation.Post; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; @@ -122,13 +120,7 @@ public class PowerAxisStructController { */ @PostMapping("/addOrg") public Result addOrg(@RequestBody PowerAxisStructEntity form){ - int i = powerAxisStructService.addOrg(form); - if(i == -1){ - return new Result().error(1,"名字重复"); - } - if(i == -2){ - return new Result().error(1,"同一组织下只允许存在一个党委"); - } + powerAxisStructService.addOrg(form); return new Result(); } /** diff --git a/epmet-plugins-module/pli-power-base/pli-power-base-server/src/main/java/com/epmet/plugin/power/modules/axis/service/PowerAxisStructService.java b/epmet-plugins-module/pli-power-base/pli-power-base-server/src/main/java/com/epmet/plugin/power/modules/axis/service/PowerAxisStructService.java index 7ac0651..18999c4 100644 --- a/epmet-plugins-module/pli-power-base/pli-power-base-server/src/main/java/com/epmet/plugin/power/modules/axis/service/PowerAxisStructService.java +++ b/epmet-plugins-module/pli-power-base/pli-power-base-server/src/main/java/com/epmet/plugin/power/modules/axis/service/PowerAxisStructService.java @@ -102,7 +102,7 @@ public interface PowerAxisStructService extends BaseService { * @date 2022/4/19/0019 9:23 */ List listSimpleAll(); + + /** + * 根据标签编码,查询节点级别 + * + * @param customerId 客户ID + * @param tagCategory 标签类型 + * @param categoryCode 标签编码 + * @return int + * @author work@yujt.net.cn + * @date 2022/4/21/0021 17:21 + */ + int selectStructLevelByCode(String customerId, String tagCategory, String categoryCode); } \ 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 c27a108..2198c07 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 @@ -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; @@ -25,7 +31,7 @@ import java.util.List; import java.util.Map; /** - * 动力主轴结构 + * 动力主轴结构 * * @author generator generator@elink-cn.com * @since v1.0.0 2022-04-18 @@ -34,7 +40,10 @@ import java.util.Map; public class PowerAxisStructServiceImpl extends BaseServiceImpl 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 getWrapper(Map params){ - String id = (String)params.get(FieldConstant.ID_HUMP); + private QueryWrapper getWrapper(Map params) { + String id = (String) params.get(FieldConstant.ID_HUMP); QueryWrapper wrapper = new QueryWrapper<>(); wrapper.eq(StringUtils.isNotBlank(id), FieldConstant.ID, id); @@ -104,43 +113,42 @@ public class PowerAxisStructServiceImpl extends BaseServiceImpl 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); diff --git a/epmet-plugins-module/pli-power-base/pli-power-base-server/src/main/java/com/epmet/plugin/power/modules/axis/service/impl/PowerAxisTagServiceImpl.java b/epmet-plugins-module/pli-power-base/pli-power-base-server/src/main/java/com/epmet/plugin/power/modules/axis/service/impl/PowerAxisTagServiceImpl.java index 0926cba..7e1891c 100644 --- a/epmet-plugins-module/pli-power-base/pli-power-base-server/src/main/java/com/epmet/plugin/power/modules/axis/service/impl/PowerAxisTagServiceImpl.java +++ b/epmet-plugins-module/pli-power-base/pli-power-base-server/src/main/java/com/epmet/plugin/power/modules/axis/service/impl/PowerAxisTagServiceImpl.java @@ -1,13 +1,14 @@ 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; import com.epmet.commons.tools.exception.EpmetErrorCode; import com.epmet.commons.tools.exception.EpmetException; -import com.epmet.commons.tools.exception.RenException; import com.epmet.commons.tools.page.PageData; import com.epmet.commons.tools.security.user.LoginUserUtil; import com.epmet.commons.tools.utils.ConvertUtils; @@ -16,7 +17,6 @@ import com.epmet.plugin.power.dto.axis.result.PowerAxisAllTagCategoryResultDTO; import com.epmet.plugin.power.dto.axis.result.PowerAxisTagCategoryResultDTO; import com.epmet.plugin.power.modules.axis.dao.PowerAxisTagDao; import com.epmet.plugin.power.modules.axis.entity.PowerAxisTagEntity; -import com.epmet.plugin.power.modules.axis.redis.PowerAxisTagRedis; import com.epmet.plugin.power.modules.axis.service.PowerAxisTagService; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; @@ -115,4 +115,19 @@ public class PowerAxisTagServiceImpl extends BaseServiceImpl listSimpleAll() { return baseDao.listSimpleAll(); } + + @Override + public int selectStructLevelByCode(String customerId, String tagCategory, String categoryCode) { + LambdaQueryWrapper lqw = new LambdaQueryWrapper<>(); + lqw.eq(PowerAxisTagEntity::getTagCategory, tagCategory) + .eq(PowerAxisTagEntity::getCategoryCode, categoryCode) + .eq(PowerAxisTagEntity::getCustomerId, customerId) + .eq(PowerAxisTagEntity::getDelFlag, EpmetDelFlagEnum.NORMAL.value()) + .select(PowerAxisTagEntity::getStructLevel); + List list = baseDao.selectList(lqw); + if (list.size() != NumConstant.ONE) { + throw new EpmetException(EpmetErrorCode.SERVER_ERROR.getCode(), "动力主轴标签配置出错", EpmetErrorCode.SERVER_ERROR.getMsg()); + } + return list.get(NumConstant.ZERO).getStructLevel(); + } } \ No newline at end of file diff --git a/epmet-plugins-module/pli-power-base/pli-power-base-server/src/main/resources/logback-spring.xml b/epmet-plugins-module/pli-power-base/pli-power-base-server/src/main/resources/logback-spring.xml index 46271c1..eba24e9 100644 --- a/epmet-plugins-module/pli-power-base/pli-power-base-server/src/main/resources/logback-spring.xml +++ b/epmet-plugins-module/pli-power-base/pli-power-base-server/src/main/resources/logback-spring.xml @@ -35,7 +35,8 @@ ${log.path}/debug.log - %d{yyyy-MM-dd HH:mm:ss.SSS} [%contextName] [%X{Transaction-Serial}] %-5level %logger{50} - %msg%n + %d{yyyy-MM-dd HH:mm:ss.SSS} [%contextName] [%X{Transaction-Serial}] %-5level %logger{50} - %msg%n + UTF-8 @@ -62,7 +63,8 @@ ${log.path}/info.log - %d{yyyy-MM-dd HH:mm:ss.SSS} [%contextName] [%X{Transaction-Serial}] %-5level %logger{50} - %msg%n + %d{yyyy-MM-dd HH:mm:ss.SSS} [%contextName] [%X{Transaction-Serial}] %-5level %logger{50} - %msg%n + UTF-8 @@ -89,7 +91,8 @@ ${log.path}/warn.log - %d{yyyy-MM-dd HH:mm:ss.SSS} [%contextName] [%X{Transaction-Serial}] %-5level %logger{50} - %msg%n + %d{yyyy-MM-dd HH:mm:ss.SSS} [%contextName] [%X{Transaction-Serial}] %-5level %logger{50} - %msg%n + UTF-8 @@ -115,7 +118,8 @@ ${log.path}/error.log - %d{yyyy-MM-dd HH:mm:ss.SSS} [%contextName] [%X{Transaction-Serial}] %-5level %logger{50} - %msg%n + %d{yyyy-MM-dd HH:mm:ss.SSS} [%contextName] [%X{Transaction-Serial}] %-5level %logger{50} - %msg%n + UTF-8 @@ -142,6 +146,7 @@ + diff --git a/epmet-plugins-module/pli-power-base/pli-power-base-server/src/main/resources/mapper/poweraxis/PowerAxisStructDao.xml b/epmet-plugins-module/pli-power-base/pli-power-base-server/src/main/resources/mapper/poweraxis/PowerAxisStructDao.xml index f590ac2..82dc6f4 100644 --- a/epmet-plugins-module/pli-power-base/pli-power-base-server/src/main/resources/mapper/poweraxis/PowerAxisStructDao.xml +++ b/epmet-plugins-module/pli-power-base/pli-power-base-server/src/main/resources/mapper/poweraxis/PowerAxisStructDao.xml @@ -44,10 +44,12 @@ s.CREATED_TIME, sl.LEADER_ID, l.NAME as LEADER_NAME, - l.MOBILE as LEADER_MOBILE + l.MOBILE as LEADER_MOBILE, + t.STRUCT_LEVEL from pli_power_axis_struct s left join pli_power_axis_struct_leader sl on s.ID = sl.STRUCT_REFERENCE_ID left join pli_power_axis_leader l on l.ID = sl.LEADER_ID + left join pli_power_axis_tag t on s.CATEGORY_CODE = t.CATEGORY_CODE where s.DEL_FLAG = '0' and s.AGENCY_ID = #{agencyId}