Browse Source

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

dev_power_axis
YUJT 3 years ago
parent
commit
fa81786171
  1. 52
      epmet-plugins-module/pli-power-base/pli-power-base-server/src/main/java/com/epmet/plugin/power/modules/axis/controller/PowerAxisStructController.java
  2. 36
      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. 67
      epmet-plugins-module/pli-power-base/pli-power-base-server/src/main/java/com/epmet/plugin/power/modules/axis/service/impl/PowerAxisStructServiceImpl.java

52
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;
@ -43,21 +44,22 @@ public class PowerAxisStructController {
private PowerAxisStructService powerAxisStructService;
@RequestMapping("page")
public Result<PageData<PowerAxisStructDTO>> page(@RequestParam Map<String, Object> params){
public Result<PageData<PowerAxisStructDTO>> page(@RequestParam Map<String, Object> params) {
PageData<PowerAxisStructDTO> page = powerAxisStructService.page(params);
return new Result<PageData<PowerAxisStructDTO>>().ok(page);
}
@RequestMapping(value = "{id}",method = {RequestMethod.POST,RequestMethod.GET})
public Result<PowerAxisStructDTO> get(@PathVariable("id") String id){
@RequestMapping(value = "{id}", method = {RequestMethod.POST, RequestMethod.GET})
public Result<PowerAxisStructDTO> get(@PathVariable("id") String id) {
PowerAxisStructDTO data = powerAxisStructService.get(id);
return new Result<PowerAxisStructDTO>().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<List<PowerAxisStructLeaderResultDTO>> 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<PowerAxisStructResultDTO> result = powerAxisStructService.queryDeptByName(form);
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删除
*/
@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<List<PowerAxisStructGridPartyBranchResultDTO>> getGridPartyBranchList(){
public Result<List<PowerAxisStructGridPartyBranchResultDTO>> getGridPartyBranchList() {
List<PowerAxisStructGridPartyBranchResultDTO> list = powerAxisStructService.getGridPartyBranchList();
return new Result<List<PowerAxisStructGridPartyBranchResultDTO>>().ok(list);
}
@ -146,7 +133,7 @@ public class PowerAxisStructController {
* 获取上级组织
*/
@PostMapping("/getPartyCommList")
public Result<List<PowerAxisStructPartyCommResultDTO>> getPartyCommList(){
public Result<List<PowerAxisStructPartyCommResultDTO>> getPartyCommList() {
List<PowerAxisStructPartyCommResultDTO> list = powerAxisStructService.getPartyCommList();
return new Result<List<PowerAxisStructPartyCommResultDTO>>().ok(list);
}
@ -155,15 +142,16 @@ public class PowerAxisStructController {
* 查询父id
*/
@PostMapping("/getPid")
public Result<List<String>> getPid(){
public Result<List<String>> getPid() {
List<String> pid = powerAxisStructService.getPid();
return new Result<List<String>>().ok(pid);
}
/**
* 根据id查询修改表单数据
*/
@PostMapping("/queryModifyById/{id}")
public Result<PowerAxisStructEntity> queryModifyById(@PathVariable String id){
public Result<PowerAxisStructEntity> queryModifyById(@PathVariable String id) {
PowerAxisStructEntity power = powerAxisStructService.queryModifyById(id);
return new Result<PowerAxisStructEntity>().ok(power);
}
@ -172,7 +160,7 @@ public class PowerAxisStructController {
* 按节点类型获取节点列表
*/
@PostMapping("/listByCategoryCode")
public Result getListByCategoryCode(@RequestBody PowerAxisStructListByCategoryCodeFormDTO form){
public Result getListByCategoryCode(@RequestBody PowerAxisStructListByCategoryCodeFormDTO form) {
List<PowerAixsStructListByCategoryResultDTO> dto = powerAxisStructService.getListByCategoryCode(form);
return new Result().ok(dto);
}

36
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;
@ -37,8 +38,6 @@ public interface PowerAxisStructDao extends BaseDao<PowerAxisStructEntity> {
List<PowerAxisStructResultDTO> queryDeptByName(PowerAxisStructFormDTO form);
void delete(String id);
/**
@ -56,12 +55,37 @@ public interface PowerAxisStructDao extends BaseDao<PowerAxisStructEntity> {
*/
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);
List<PowerAixsStructListByCategoryResultDTO> getListByCategoryCode(PowerAxisStructListByCategoryCodeFormDTO form);

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);
/**
* 查询动力主轴全部机构用于前端组装展示树
*
@ -96,18 +94,9 @@ public interface PowerAxisStructService extends BaseService<PowerAxisStructEntit
*/
List<PowerAxisStructLeaderResultDTO> 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<PowerAxisStructEntit
/**
* 查询父id
*
* @return String
*/
List<String> getPid();

67
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
@Transactional(rollbackFor = Exception.class)
public void save(PowerAxisStructDTO dto) {
verifyStructField(dto);
PowerAxisStructEntity entity = ConvertUtils.sourceToTarget(dto, PowerAxisStructEntity.class);
this.assembleStruct(entity);
baseDao.insert(entity);
insert(entity);
}
@Override
@Transactional(rollbackFor = Exception.class)
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);
updateById(entity);
this.assembleStruct(entity);
baseDao.updateById(entity);
}
@Override
@ -120,45 +134,25 @@ public class PowerAxisStructServiceImpl extends BaseServiceImpl<PowerAxisStructD
}
@Override
public List<PowerAxisStructLeaderResultDTO> 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<PowerAxisStructD
/**
* 组装节点对象
*
* @param struct 提交的表单
* @param customerId 客户ID
* @param struct 提交的表单
* @return void
* @author work@yujt.net.cn
* @date 2022/4/22/0022 14:04
*/
private void assembleStruct(PowerAxisStructEntity struct, String customerId) {
struct.setCustomerId(customerId);
private void assembleStruct(PowerAxisStructEntity struct) {
// 上级节点
String pid = struct.getPid();
@ -182,7 +173,7 @@ public class PowerAxisStructServiceImpl extends BaseServiceImpl<PowerAxisStructD
String categoryCode = struct.getCategoryCode();
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) {
pid = NumConstant.ZERO_STR;
} else {
@ -255,7 +246,7 @@ public class PowerAxisStructServiceImpl extends BaseServiceImpl<PowerAxisStructD
@Override
public List<String> getIdByAgencyId(String agencyId) {
String customerId = loginUserUtil.getLoginUserCustomerId();
List<String> ids = baseDao.getIdsByAgencyId(agencyId,customerId);
List<String> ids = baseDao.getIdsByAgencyId(agencyId, customerId);
return ids;
}
@ -341,7 +332,7 @@ public class PowerAxisStructServiceImpl extends BaseServiceImpl<PowerAxisStructD
form.setStructLevel(structLevel);
form.setTagCategory(PowerTagCategoryEnum.STRUCT.category());
String code = baseDao.queryCategoryCode(form);
List<PowerAxisListPositionResultDTO> list = baseDao.querylistPosition(customerId,code);
List<PowerAxisListPositionResultDTO> list = baseDao.querylistPosition(customerId, code);
return list;
}
@ -353,7 +344,7 @@ public class PowerAxisStructServiceImpl extends BaseServiceImpl<PowerAxisStructD
form.setStructLevel(structLevel);
form.setTagCategory(PowerTagCategoryEnum.STRUCT.category());
String code = baseDao.queryCategoryCode(form);
long total = baseDao.queryTotal(customerId,code);
long total = baseDao.queryTotal(customerId, code);
return total;
}

Loading…
Cancel
Save