Browse Source

修改动力主轴节点的新增和更新方法

dev_power_axis
YUJT 3 years ago
parent
commit
fa81786171
  1. 30
      epmet-plugins-module/pli-power-base/pli-power-base-server/src/main/java/com/epmet/plugin/power/modules/axis/controller/PowerAxisStructController.java
  2. 34
      epmet-plugins-module/pli-power-base/pli-power-base-server/src/main/java/com/epmet/plugin/power/modules/axis/dao/PowerAxisStructDao.java
  3. 14
      epmet-plugins-module/pli-power-base/pli-power-base-server/src/main/java/com/epmet/plugin/power/modules/axis/service/PowerAxisStructService.java
  4. 59
      epmet-plugins-module/pli-power-base/pli-power-base-server/src/main/java/com/epmet/plugin/power/modules/axis/service/impl/PowerAxisStructServiceImpl.java

30
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; 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.aop.NoRepeatSubmit;
import com.epmet.commons.tools.page.PageData; 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.ExcelUtils;
import com.epmet.commons.tools.utils.Result; import com.epmet.commons.tools.utils.Result;
import com.epmet.commons.tools.validator.AssertUtils; import com.epmet.commons.tools.validator.AssertUtils;
@ -56,8 +57,9 @@ public class PowerAxisStructController {
@NoRepeatSubmit @NoRepeatSubmit
@PostMapping("save") @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); ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class);
powerAxisStructService.save(dto); powerAxisStructService.save(dto);
return new Result(); return new Result();
@ -65,8 +67,9 @@ public class PowerAxisStructController {
@NoRepeatSubmit @NoRepeatSubmit
@PostMapping("update") @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); ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class);
powerAxisStructService.update(dto); powerAxisStructService.update(dto);
return new Result(); return new Result();
@ -98,6 +101,7 @@ public class PowerAxisStructController {
public Result<List<PowerAxisStructLeaderResultDTO>> selectAllForTree(@RequestBody PowerAxisStructLeaderFormDTO formDto) { public Result<List<PowerAxisStructLeaderResultDTO>> selectAllForTree(@RequestBody PowerAxisStructLeaderFormDTO formDto) {
return new Result().ok(powerAxisStructService.selectAllForTree(formDto)); return new Result().ok(powerAxisStructService.selectAllForTree(formDto));
} }
/** /**
* 根据名字查询 * 根据名字查询
*/ */
@ -107,24 +111,6 @@ public class PowerAxisStructController {
return new Result<List<PowerAxisStructResultDTO>>().ok(result); return new Result<List<PowerAxisStructResultDTO>>().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删除 * 根据id删除
*/ */
@ -133,6 +119,7 @@ public class PowerAxisStructController {
powerAxisStructService.delete(id); powerAxisStructService.delete(id);
return new Result(); return new Result();
} }
/** /**
* 获取上级网格党支部 * 获取上级网格党支部
*/ */
@ -159,6 +146,7 @@ public class PowerAxisStructController {
List<String> pid = powerAxisStructService.getPid(); List<String> pid = powerAxisStructService.getPid();
return new Result<List<String>>().ok(pid); return new Result<List<String>>().ok(pid);
} }
/** /**
* 根据id查询修改表单数据 * 根据id查询修改表单数据
*/ */

34
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.dto.axis.result.*;
import com.epmet.plugin.power.modules.axis.entity.PowerAxisStructEntity; import com.epmet.plugin.power.modules.axis.entity.PowerAxisStructEntity;
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;
import java.util.Map; import java.util.Map;
@ -37,8 +38,6 @@ public interface PowerAxisStructDao extends BaseDao<PowerAxisStructEntity> {
List<PowerAxisStructResultDTO> queryDeptByName(PowerAxisStructFormDTO form); List<PowerAxisStructResultDTO> queryDeptByName(PowerAxisStructFormDTO form);
void delete(String id); void delete(String id);
/** /**
@ -56,10 +55,35 @@ public interface PowerAxisStructDao extends BaseDao<PowerAxisStructEntity> {
*/ */
List<PowerAxisStructPartyCommResultDTO> getPartyCommList(String customerId); List<PowerAxisStructPartyCommResultDTO> 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<String> getIdsByAgencyId(String agencyId, String customerId); List<String> getIdsByAgencyId(String agencyId, String customerId);

14
epmet-plugins-module/pli-power-base/pli-power-base-server/src/main/java/com/epmet/plugin/power/modules/axis/service/PowerAxisStructService.java

@ -85,8 +85,6 @@ public interface PowerAxisStructService extends BaseService<PowerAxisStructEntit
List<PowerAxisStructResultDTO> queryDeptByName(PowerAxisStructFormDTO form); List<PowerAxisStructResultDTO> queryDeptByName(PowerAxisStructFormDTO form);
/** /**
* 查询动力主轴全部机构用于前端组装展示树 * 查询动力主轴全部机构用于前端组装展示树
* *
@ -96,18 +94,9 @@ public interface PowerAxisStructService extends BaseService<PowerAxisStructEntit
*/ */
List<PowerAxisStructLeaderResultDTO> selectAllForTree(PowerAxisStructLeaderFormDTO formDto); List<PowerAxisStructLeaderResultDTO> selectAllForTree(PowerAxisStructLeaderFormDTO formDto);
/**
* 添加组织
*/
void addOrg(PowerAxisStructEntity form);
/**
* 修改组织
*/
void modifyRog(PowerAxisStructEntity form);
/** /**
* 删除 * 删除
*
* @param id * @param id
*/ */
void delete(String id); void delete(String id);
@ -119,6 +108,7 @@ public interface PowerAxisStructService extends BaseService<PowerAxisStructEntit
/** /**
* 查询父id * 查询父id
*
* @return String * @return String
*/ */
List<String> getPid(); List<String> getPid();

59
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<PowerAxisStructD
@Override @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public void save(PowerAxisStructDTO dto) { public void save(PowerAxisStructDTO dto) {
verifyStructField(dto);
PowerAxisStructEntity entity = ConvertUtils.sourceToTarget(dto, PowerAxisStructEntity.class); PowerAxisStructEntity entity = ConvertUtils.sourceToTarget(dto, PowerAxisStructEntity.class);
this.assembleStruct(entity);
baseDao.insert(entity);
insert(entity); insert(entity);
} }
@Override @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public void update(PowerAxisStructDTO dto) { public void update(PowerAxisStructDTO dto) {
if (dto.getId().equals(dto.getPid())) {
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "不能选择自身为上级节点");
}
verifyStructField(dto);
PowerAxisStructEntity entity = ConvertUtils.sourceToTarget(dto, PowerAxisStructEntity.class); PowerAxisStructEntity entity = ConvertUtils.sourceToTarget(dto, PowerAxisStructEntity.class);
updateById(entity); this.assembleStruct(entity);
baseDao.updateById(entity);
} }
@Override @Override
@ -120,45 +134,25 @@ public class PowerAxisStructServiceImpl extends BaseServiceImpl<PowerAxisStructD
} }
@Override @Override
public List<PowerAxisStructLeaderResultDTO> selectAllForTree(PowerAxisStructLeaderFormDTO formDto) { public List<PowerAxisStructLeaderResultDTO> selectAllForTree(PowerAxisStructLeaderFormDTO formDto) {
return baseDao.selectAllForTree(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) { private void verifyStructField(PowerAxisStructDTO structDto) {
int structLevel = powerAxisTagService.selectStructLevelByCode(loginUserUtil.getLoginUserCustomerId(), PowerTagCategoryEnum.STRUCT.category(), struct.getCategoryCode()); 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 (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(), "同一组织下只允许存在一个顶级节点"); 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(), "同一组织下不允许存在重名的节点"); throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "同一组织下不允许存在重名的节点");
} }
} }
@ -167,14 +161,11 @@ public class PowerAxisStructServiceImpl extends BaseServiceImpl<PowerAxisStructD
* 组装节点对象 * 组装节点对象
* *
* @param struct 提交的表单 * @param struct 提交的表单
* @param customerId 客户ID
* @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, String customerId) { private void assembleStruct(PowerAxisStructEntity struct) {
struct.setCustomerId(customerId);
// 上级节点 // 上级节点
String pid = struct.getPid(); String pid = struct.getPid();
@ -182,7 +173,7 @@ public class PowerAxisStructServiceImpl extends BaseServiceImpl<PowerAxisStructD
String categoryCode = struct.getCategoryCode(); String categoryCode = struct.getCategoryCode();
if (StringUtils.isBlank(pid)) { if (StringUtils.isBlank(pid)) {
// 查询类别编码对应的节点级别 // 查询类别编码对应的节点级别
int structLevel = powerAxisTagService.selectStructLevelByCode(customerId, PowerTagCategoryEnum.STRUCT.category(), categoryCode); 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 {

Loading…
Cancel
Save