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 5d87134..599aa52 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 @@ -1,9 +1,10 @@ package com.epmet.plugin.power.modules.axis.controller; - +import com.epmet.commons.tools.annotation.LoginUser; import com.epmet.commons.tools.aop.NoRepeatSubmit; import com.epmet.commons.tools.page.PageData; +import com.epmet.commons.tools.security.dto.TokenDto; import com.epmet.commons.tools.utils.ExcelUtils; import com.epmet.commons.tools.utils.Result; import com.epmet.commons.tools.validator.AssertUtils; @@ -30,7 +31,7 @@ import java.util.Map; /** - * 动力主轴结构 + * 动力主轴结构 * * @author generator generator@elink-cn.com * @since v1.0.0 2022-04-18 @@ -43,21 +44,22 @@ public class PowerAxisStructController { private PowerAxisStructService powerAxisStructService; @RequestMapping("page") - public Result> page(@RequestParam Map params){ + public Result> page(@RequestParam Map params) { PageData page = powerAxisStructService.page(params); return new Result>().ok(page); } - @RequestMapping(value = "{id}",method = {RequestMethod.POST,RequestMethod.GET}) - public Result get(@PathVariable("id") String id){ + @RequestMapping(value = "{id}", method = {RequestMethod.POST, RequestMethod.GET}) + public Result get(@PathVariable("id") String id) { PowerAxisStructDTO data = powerAxisStructService.get(id); return new Result().ok(data); } @NoRepeatSubmit @PostMapping("save") - public Result save(@RequestBody PowerAxisStructDTO dto){ + public Result save(@RequestBody PowerAxisStructDTO dto, @LoginUser TokenDto tokenDto) { //效验数据 + dto.setCustomerId(tokenDto.getCustomerId()); ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class); powerAxisStructService.save(dto); return new Result(); @@ -65,15 +67,16 @@ public class PowerAxisStructController { @NoRepeatSubmit @PostMapping("update") - public Result update(@RequestBody PowerAxisStructDTO dto){ + public Result update(@RequestBody PowerAxisStructDTO dto, @LoginUser TokenDto tokenDto) { //效验数据 + dto.setCustomerId(tokenDto.getCustomerId()); ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class); powerAxisStructService.update(dto); return new Result(); } @PostMapping("delete") - public Result delete(@RequestBody String[] ids){ + public Result delete(@RequestBody String[] ids) { //效验数据 AssertUtils.isArrayEmpty(ids, "id"); powerAxisStructService.delete(ids); @@ -98,46 +101,30 @@ public class PowerAxisStructController { public Result> selectAllForTree(@RequestBody PowerAxisStructLeaderFormDTO formDto) { return new Result().ok(powerAxisStructService.selectAllForTree(formDto)); } + /** * 根据名字查询 */ @PostMapping("/queryDeptByName") - public Result queryDeptByName(@RequestBody PowerAxisStructFormDTO form){ + public Result queryDeptByName(@RequestBody PowerAxisStructFormDTO form) { List result = powerAxisStructService.queryDeptByName(form); return new Result>().ok(result); } - - /** - * 添加组织 - */ - @PostMapping("/addOrg") - public Result addOrg(@RequestBody PowerAxisStructEntity form){ - powerAxisStructService.addOrg(form); - return new Result(); - } - /** - * 修改组织 - */ - @PostMapping("/modifyOrg") - public Result modifyOrg(@RequestBody PowerAxisStructEntity form){ - powerAxisStructService.modifyRog(form); - return new Result(); - } - /** * 根据id删除 */ @PostMapping("/deleteById/{id}") - public Result deleteById(@PathVariable String id){ + public Result deleteById(@PathVariable String id) { powerAxisStructService.delete(id); return new Result(); } + /** * 获取上级网格党支部 */ @PostMapping("/GridPartyBranchList") - public Result> getGridPartyBranchList(){ + public Result> getGridPartyBranchList() { List list = powerAxisStructService.getGridPartyBranchList(); return new Result>().ok(list); } @@ -146,7 +133,7 @@ public class PowerAxisStructController { * 获取上级组织 */ @PostMapping("/getPartyCommList") - public Result> getPartyCommList(){ + public Result> getPartyCommList() { List list = powerAxisStructService.getPartyCommList(); return new Result>().ok(list); } @@ -155,15 +142,16 @@ public class PowerAxisStructController { * 查询父id */ @PostMapping("/getPid") - public Result> getPid(){ + public Result> getPid() { List pid = powerAxisStructService.getPid(); return new Result>().ok(pid); } + /** * 根据id查询修改表单数据 */ @PostMapping("/queryModifyById/{id}") - public Result queryModifyById(@PathVariable String id){ + public Result queryModifyById(@PathVariable String id) { PowerAxisStructEntity power = powerAxisStructService.queryModifyById(id); return new Result().ok(power); } @@ -172,7 +160,7 @@ public class PowerAxisStructController { * 按节点类型获取节点列表 */ @PostMapping("/listByCategoryCode") - public Result getListByCategoryCode(@RequestBody PowerAxisStructListByCategoryCodeFormDTO form){ + public Result getListByCategoryCode(@RequestBody PowerAxisStructListByCategoryCodeFormDTO form) { List dto = powerAxisStructService.getListByCategoryCode(form); return new Result().ok(dto); } diff --git a/epmet-plugins-module/pli-power-base/pli-power-base-server/src/main/java/com/epmet/plugin/power/modules/axis/dao/PowerAxisStructDao.java b/epmet-plugins-module/pli-power-base/pli-power-base-server/src/main/java/com/epmet/plugin/power/modules/axis/dao/PowerAxisStructDao.java index 7400a01..e46547b 100644 --- a/epmet-plugins-module/pli-power-base/pli-power-base-server/src/main/java/com/epmet/plugin/power/modules/axis/dao/PowerAxisStructDao.java +++ b/epmet-plugins-module/pli-power-base/pli-power-base-server/src/main/java/com/epmet/plugin/power/modules/axis/dao/PowerAxisStructDao.java @@ -7,6 +7,7 @@ import com.epmet.plugin.power.dto.axis.form.*; import com.epmet.plugin.power.dto.axis.result.*; import com.epmet.plugin.power.modules.axis.entity.PowerAxisStructEntity; import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; import java.util.List; import java.util.Map; @@ -14,7 +15,7 @@ import java.util.Map; import java.util.List; /** - * 动力主轴结构 + * 动力主轴结构 * * @author generator generator@elink-cn.com * @since v1.0.0 2022-04-18 @@ -37,8 +38,6 @@ public interface PowerAxisStructDao extends BaseDao { List queryDeptByName(PowerAxisStructFormDTO form); - - void delete(String id); /** @@ -56,12 +55,37 @@ public interface PowerAxisStructDao extends BaseDao { */ List getPartyCommList(String customerId); + /** + * 查询同组织下是否有同名的节点 + * + * @param customerId 客户ID + * @param name 节点名 + * @param agencyId 组织ID + * @param categoryCode 节点级别编码 + * @return int + * @author work@yujt.net.cn + * @date 2022/4/23/0023 11:00 + */ + int countRepeatStructByName(@Param("customerId") String customerId, + @Param("name") String name, + @Param("agencyId") String agencyId, + @Param("categoryCode") String categoryCode); - int countRepeatStructByName(PowerAxisStructEntity form); - - int countRepeatStructByCategory(PowerAxisStructEntity form); + /** + * 查询同组织下是否有同级的节点 (主要用于一级节点判重) + * + * @param customerId 客户ID + * @param agencyId 组织ID + * @param categoryCode 节点级别编码(一级节点级别编码) + * @return int + * @author work@yujt.net.cn + * @date 2022/4/23/0023 10:57 + */ + int countRepeatStructByCategory(@Param("customerId") String customerId, + @Param("agencyId") String agencyId, + @Param("categoryCode") String categoryCode); - List getIdsByAgencyId(String agencyId,String customerId); + List getIdsByAgencyId(String agencyId, String customerId); List getListByCategoryCode(PowerAxisStructListByCategoryCodeFormDTO form); 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 ec6a992..7f78329 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 @@ -12,7 +12,7 @@ import java.util.List; import java.util.Map; /** - * 动力主轴结构 + * 动力主轴结构 * * @author generator generator@elink-cn.com * @since v1.0.0 2022-04-18 @@ -85,8 +85,6 @@ public interface PowerAxisStructService extends BaseService queryDeptByName(PowerAxisStructFormDTO form); - - /** * 查询动力主轴全部机构,用于前端组装展示树 * @@ -96,18 +94,9 @@ public interface PowerAxisStructService extends BaseService selectAllForTree(PowerAxisStructLeaderFormDTO formDto); - /** - * 添加组织 - */ - void addOrg(PowerAxisStructEntity form); - - /** - * 修改组织 - */ - void modifyRog(PowerAxisStructEntity form); - /** * 删除 + * * @param id */ void delete(String id); @@ -119,6 +108,7 @@ public interface PowerAxisStructService extends BaseService getPid(); 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 94a1627..ca00f70 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 @@ -93,15 +93,29 @@ public class PowerAxisStructServiceImpl extends BaseServiceImpl selectAllForTree(PowerAxisStructLeaderFormDTO formDto) { return baseDao.selectAllForTree(formDto); } - @Override - public void addOrg(PowerAxisStructEntity form) { - verifyStructField(form); - - this.assembleStruct(form, loginUserUtil.getLoginUserCustomerId()); - - baseDao.insert(form); - } - - @Override - public void modifyRog(PowerAxisStructEntity form) { - if (form.getId().equals(form.getPid())) { - throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "不能选择自身为上级节点"); - } - - verifyStructField(form); - - this.assembleStruct(form, loginUserUtil.getLoginUserCustomerId()); - - baseDao.updateById(form); - } - // 验证表单字段 - private void verifyStructField(PowerAxisStructEntity struct) { - int structLevel = powerAxisTagService.selectStructLevelByCode(loginUserUtil.getLoginUserCustomerId(), PowerTagCategoryEnum.STRUCT.category(), struct.getCategoryCode()); + private void verifyStructField(PowerAxisStructDTO structDto) { + String customerId = structDto.getCustomerId(); + String categoryCode = structDto.getCategoryCode(); + String agencyId = structDto.getAgencyId(); + + int structLevel = powerAxisTagService.selectStructLevelByCode(customerId, PowerTagCategoryEnum.STRUCT.category(), categoryCode); if (PowerTagLevelEnum.ROOT.level() == structLevel) { - if (baseDao.countRepeatStructByCategory(struct) > NumConstant.ZERO) { + if (baseDao.countRepeatStructByCategory(customerId, agencyId, categoryCode) > NumConstant.ZERO) { throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "同一组织下只允许存在一个顶级节点"); } } - if (baseDao.countRepeatStructByName(struct) > NumConstant.ZERO) { + if (baseDao.countRepeatStructByName(customerId, structDto.getName(), agencyId, categoryCode) > NumConstant.ZERO) { throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "同一组织下不允许存在重名的节点"); } } @@ -166,15 +160,12 @@ public class PowerAxisStructServiceImpl extends BaseServiceImpl getIdByAgencyId(String agencyId) { String customerId = loginUserUtil.getLoginUserCustomerId(); - List ids = baseDao.getIdsByAgencyId(agencyId,customerId); + List ids = baseDao.getIdsByAgencyId(agencyId, customerId); return ids; } @@ -341,7 +332,7 @@ public class PowerAxisStructServiceImpl extends BaseServiceImpl list = baseDao.querylistPosition(customerId,code); + List list = baseDao.querylistPosition(customerId, code); return list; } @@ -353,7 +344,7 @@ public class PowerAxisStructServiceImpl extends BaseServiceImpl