Browse Source

调整部分接口代码

dev_power_axis
YUJT 3 years ago
parent
commit
85811157ef
  1. 30
      epmet-plugins-common/src/main/java/com/epmet/plugin/commons/utils/NumUtils.java
  2. 9
      epmet-plugins-module/pli-power-base/pli-power-base-client/src/main/java/com/epmet/plugin/power/dto/axis/form/PowerAxisServiceStationFormDTO.java
  3. 15
      epmet-plugins-module/pli-power-base/pli-power-base-client/src/main/java/com/epmet/plugin/power/dto/axis/form/PowerKernelHouseHoldViewListFormDTO.java
  4. 9
      epmet-plugins-module/pli-power-base/pli-power-base-server/src/main/java/com/epmet/plugin/power/modules/axis/controller/PowerAxisDataVisualController.java
  5. 5
      epmet-plugins-module/pli-power-base/pli-power-base-server/src/main/java/com/epmet/plugin/power/modules/axis/controller/PowerServiceStationController.java
  6. 16
      epmet-plugins-module/pli-power-base/pli-power-base-server/src/main/java/com/epmet/plugin/power/modules/axis/dao/PowerAxisStructDao.java
  7. 2
      epmet-plugins-module/pli-power-base/pli-power-base-server/src/main/java/com/epmet/plugin/power/modules/axis/dao/PowerKernelHouseholdDao.java
  8. 15
      epmet-plugins-module/pli-power-base/pli-power-base-server/src/main/java/com/epmet/plugin/power/modules/axis/service/PowerAxisStructService.java
  9. 23
      epmet-plugins-module/pli-power-base/pli-power-base-server/src/main/java/com/epmet/plugin/power/modules/axis/service/impl/PowerAxisStructServiceImpl.java
  10. 28
      epmet-plugins-module/pli-power-base/pli-power-base-server/src/main/java/com/epmet/plugin/power/modules/axis/service/impl/PowerKernelHouseholdServiceImpl.java
  11. 18
      epmet-plugins-module/pli-power-base/pli-power-base-server/src/main/java/com/epmet/plugin/power/modules/axis/service/impl/PowerServiceStationServiceImpl.java
  12. 13
      epmet-plugins-module/pli-power-base/pli-power-base-server/src/main/resources/mapper/poweraxis/PowerAxisStructDao.xml
  13. 15
      epmet-plugins-module/pli-power-base/pli-power-base-server/src/main/resources/mapper/poweraxis/PowerKernelHouseholdDao.xml

30
epmet-plugins-common/src/main/java/com/epmet/plugin/commons/utils/NumUtils.java

@ -0,0 +1,30 @@
package com.epmet.plugin.commons.utils;
import com.epmet.commons.tools.constant.NumConstant;
/***
* 数字处理相关通用方法
* @author work@yujt.net.cn
* @date 2022/5/12/0012 10:02
*/
public class NumUtils {
public final static int ONE_THOUSAND = 1000;
/**
* 获取数值
*
* @param number 数值可能为空
* @param excludeZero 数字不能为0
* @param defaultNumber 默认值数字为空值时 数值为0但excludeZero == true 使用默认值
* @return int
* @author work@yujt.net.cn
* @date 2022/5/12/0012 10:11
*/
public static int getNumberInt(Integer number, boolean excludeZero, int defaultNumber) {
if (null == number || (excludeZero && NumConstant.ZERO == number)) {
return defaultNumber;
}
return number;
}
}

9
epmet-plugins-module/pli-power-base/pli-power-base-client/src/main/java/com/epmet/plugin/power/dto/axis/form/PowerAxisServiceStationFormDTO.java

@ -2,6 +2,7 @@ package com.epmet.plugin.power.dto.axis.form;
import lombok.Data; import lombok.Data;
import javax.validation.constraints.NotBlank;
import java.io.Serializable; import java.io.Serializable;
@Data @Data
@ -9,7 +10,7 @@ public class PowerAxisServiceStationFormDTO implements Serializable {
private static final long serialVersionUID = -8446905334792655596L; private static final long serialVersionUID = -8446905334792655596L;
/** /**
*动力主轴节点id * 动力主轴节点id
*/ */
private String axisStructId; private String axisStructId;
/** /**
@ -19,5 +20,11 @@ public class PowerAxisServiceStationFormDTO implements Serializable {
/** /**
* 客户id * 客户id
*/ */
@NotBlank(message = "所属客户不能为空")
private String customerId; private String customerId;
/**
* 组织id
*/
@NotBlank(message = "所属组织不能为空")
private String agencyId;
} }

15
epmet-plugins-module/pli-power-base/pli-power-base-client/src/main/java/com/epmet/plugin/power/dto/axis/form/PowerKernelHouseHoldViewListFormDTO.java

@ -2,6 +2,8 @@ package com.epmet.plugin.power.dto.axis.form;
import lombok.Data; import lombok.Data;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.io.Serializable; import java.io.Serializable;
@Data @Data
@ -17,15 +19,24 @@ public class PowerKernelHouseHoldViewListFormDTO implements Serializable {
/** /**
* 页码 * 页码
*/ */
private int pageNo; @NotNull(message = "页码不能为空")
private Integer pageNo;
/** /**
* 条数 * 条数
*/ */
private int pageSize; @NotNull(message = "页容量不能为空")
private Integer pageSize;
/**
* 组织id
*/
@NotBlank(message = "所属组织不能为空")
private String agencyId;
/** /**
* 客户id * 客户id
*/ */
@NotBlank(message = "所属客户不能为空")
private String customerId; private String customerId;
} }

9
epmet-plugins-module/pli-power-base/pli-power-base-server/src/main/java/com/epmet/plugin/power/modules/axis/controller/PowerAxisDataVisualController.java

@ -14,7 +14,6 @@ import com.epmet.plugin.power.modules.axis.service.PowerServiceStationService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import javax.validation.Valid;
import java.util.List; import java.util.List;
/*** /***
@ -47,7 +46,9 @@ public class PowerAxisDataVisualController {
* @date 2022/4/22 19:53 * @date 2022/4/22 19:53
*/ */
@PostMapping("serviceStation/listPosition") @PostMapping("serviceStation/listPosition")
public Result<List<PowerAxisServiceStationResultDTO>> getListPostition(@RequestBody PowerAxisServiceStationFormDTO form) { public Result<List<PowerAxisServiceStationResultDTO>> getListPostition(@RequestBody PowerAxisServiceStationFormDTO form, @LoginUser TokenDto tokenDto) {
form.setCustomerId(tokenDto.getCustomerId());
ValidatorUtils.validateEntity(form);
return new Result().ok(powerServiceStationService.getListPosition(form)); return new Result().ok(powerServiceStationService.getListPosition(form));
} }
@ -118,7 +119,9 @@ public class PowerAxisDataVisualController {
* @date 2022/4/23 10:20 * @date 2022/4/23 10:20
*/ */
@PostMapping("kernelHousehold/list") @PostMapping("kernelHousehold/list")
public ResultDTO getList(@RequestBody PowerKernelHouseHoldViewListFormDTO form) { public ResultDTO getList(@RequestBody PowerKernelHouseHoldViewListFormDTO form, @LoginUser TokenDto tokenDto) {
form.setCustomerId(tokenDto.getCustomerId());
ValidatorUtils.validateEntity(form);
List<PowerKernelHouseHoldViewListResultDTO> dto = powerKernelHouseholdService.getList(form); List<PowerKernelHouseHoldViewListResultDTO> dto = powerKernelHouseholdService.getList(form);
return ResultDTO.success("查询成功", dto, powerKernelHouseholdService.getTotal(form)); return ResultDTO.success("查询成功", dto, powerKernelHouseholdService.getTotal(form));
} }

5
epmet-plugins-module/pli-power-base/pli-power-base-server/src/main/java/com/epmet/plugin/power/modules/axis/controller/PowerServiceStationController.java

@ -1,8 +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;
@ -48,7 +50,8 @@ public class PowerServiceStationController {
@NoRepeatSubmit @NoRepeatSubmit
@PostMapping("save") @PostMapping("save")
public Result save(@RequestBody PowerServiceStationDTO dto){ public Result save(@RequestBody PowerServiceStationDTO dto, @LoginUser TokenDto tokenDto){
dto.setCustomerId(tokenDto.getCustomerId());
//效验数据 //效验数据
ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class); ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class);
powerServiceStationService.save(dto); powerServiceStationService.save(dto);

16
epmet-plugins-module/pli-power-base/pli-power-base-server/src/main/java/com/epmet/plugin/power/modules/axis/dao/PowerAxisStructDao.java

@ -81,7 +81,7 @@ public interface PowerAxisStructDao extends BaseDao<PowerAxisStructEntity> {
int getKernelHouseHold(@Param("agencyId") String agencyId, @Param("customerId") String customerId); int getKernelHouseHold(@Param("agencyId") String agencyId, @Param("customerId") String customerId);
int getServiceStation(@Param("agencyId") String agencyId,@Param("customerId") String customerId); int getServiceStation(@Param("agencyId") String agencyId, @Param("customerId") String customerId);
List<PowerAxisStructTreeResultDTO> getStructTree(PowerAxisStructStructTreeFormDTO form); List<PowerAxisStructTreeResultDTO> getStructTree(PowerAxisStructStructTreeFormDTO form);
@ -111,4 +111,18 @@ public interface PowerAxisStructDao extends BaseDao<PowerAxisStructEntity> {
* @date 2022/4/24 19:29 * @date 2022/4/24 19:29
*/ */
String getCateGoryCode(String customerId, int level, String tagCateGory); String getCateGoryCode(String customerId, int level, String tagCateGory);
/**
* 查询动力主轴跟节点
*
* @param customerId 客户
* @param agencyId 组织
* @param structLevel 级别 {@link com.epmet.plugin.power.enums.PowerTagLevelEnum#ROOT}
* @return java.lang.String
* @author work@yujt.net.cn
* @date 2022/5/12/0012 9:52
*/
String getRootAxisStructId(@Param("customerId") String customerId,
@Param("agencyId") String agencyId,
@Param("structLevel") int structLevel);
} }

2
epmet-plugins-module/pli-power-base/pli-power-base-server/src/main/java/com/epmet/plugin/power/modules/axis/dao/PowerKernelHouseholdDao.java

@ -54,6 +54,4 @@ public interface PowerKernelHouseholdDao extends BaseDao<PowerKernelHouseholdEnt
List<PowerKernelHouseholdDTO> getPage(Map<String, Object> params); List<PowerKernelHouseholdDTO> getPage(Map<String, Object> params);
String queryAxisStructId(@Param("agencyId") String agencyId,
@Param("customerId") String customerId);
} }

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

@ -122,7 +122,6 @@ public interface PowerAxisStructService extends BaseService<PowerAxisStructEntit
List<String> getIdByAgencyId(String agencyId); List<String> getIdByAgencyId(String agencyId);
/** /**
*
* 关键指标统计 * 关键指标统计
* *
* @param form * @param form
@ -142,7 +141,7 @@ public interface PowerAxisStructService extends BaseService<PowerAxisStructEntit
*/ */
List<PowerAxisStructTreeResultDTO> getStructTree(PowerAxisStructStructTreeFormDTO form); List<PowerAxisStructTreeResultDTO> getStructTree(PowerAxisStructStructTreeFormDTO form);
List<PowerAxisListPositionResultDTO> getListPosition(int structLevel,PowerAxisDataListPositionFormDTO form); List<PowerAxisListPositionResultDTO> getListPosition(int structLevel, PowerAxisDataListPositionFormDTO form);
/** /**
* 根据节点接报组装其上级节点树 * 根据节点接报组装其上级节点树
@ -154,4 +153,16 @@ public interface PowerAxisStructService extends BaseService<PowerAxisStructEntit
* @date 2022/4/23/0023 14:37 * @date 2022/4/23/0023 14:37
*/ */
List<PowerAxisStructTreeResultDTO> listParentTreeByLevel(String structLevel, String customerId); List<PowerAxisStructTreeResultDTO> listParentTreeByLevel(String structLevel, String customerId);
/**
* 获取动力主轴根节点ID
*
* @param rootStructId 根节点ID不为空直接返回该值
* @param customerId 客户
* @param agencyId 组织
* @return java.lang.String
* @author work@yujt.net.cn
* @date 2022/5/12/0012 10:26
*/
String getRootAxisStructId(String rootStructId, String customerId, String agencyId);
} }

23
epmet-plugins-module/pli-power-base/pli-power-base-server/src/main/java/com/epmet/plugin/power/modules/axis/service/impl/PowerAxisStructServiceImpl.java

@ -10,12 +10,11 @@ import com.epmet.commons.tools.constant.StrConstant;
import com.epmet.commons.tools.exception.EpmetErrorCode; import com.epmet.commons.tools.exception.EpmetErrorCode;
import com.epmet.commons.tools.exception.EpmetException; import com.epmet.commons.tools.exception.EpmetException;
import com.epmet.commons.tools.page.PageData; import com.epmet.commons.tools.page.PageData;
import com.epmet.commons.tools.redis.common.CustomerOrgRedis;
import com.epmet.commons.tools.redis.common.bean.AgencyInfoCache;
import com.epmet.commons.tools.security.user.LoginUserUtil; import com.epmet.commons.tools.security.user.LoginUserUtil;
import com.epmet.commons.tools.utils.ConvertUtils; import com.epmet.commons.tools.utils.ConvertUtils;
import com.epmet.commons.tools.utils.Result;
import com.epmet.commons.tools.utils.TreeUtils; import com.epmet.commons.tools.utils.TreeUtils;
import com.epmet.dto.CustomerAgencyDTO;
import com.epmet.feign.GovOrgOpenFeignClient;
import com.epmet.plugin.power.dto.axis.PowerAxisStructDTO; import com.epmet.plugin.power.dto.axis.PowerAxisStructDTO;
import com.epmet.plugin.power.dto.axis.form.*; import com.epmet.plugin.power.dto.axis.form.*;
import com.epmet.plugin.power.dto.axis.result.*; import com.epmet.plugin.power.dto.axis.result.*;
@ -31,7 +30,6 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource; import javax.annotation.Resource;
import javax.validation.constraints.NotBlank;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -45,9 +43,6 @@ import java.util.Map;
@Service @Service
public class PowerAxisStructServiceImpl extends BaseServiceImpl<PowerAxisStructDao, PowerAxisStructEntity> implements PowerAxisStructService { public class PowerAxisStructServiceImpl extends BaseServiceImpl<PowerAxisStructDao, PowerAxisStructEntity> implements PowerAxisStructService {
@Autowired
private GovOrgOpenFeignClient govOrgOpenFeignClient;
@Autowired @Autowired
private PowerAxisTagService powerAxisTagService; private PowerAxisTagService powerAxisTagService;
@ -186,11 +181,7 @@ public class PowerAxisStructServiceImpl extends BaseServiceImpl<PowerAxisStructD
} }
if (NumConstant.ZERO_STR.equals(pid)) { if (NumConstant.ZERO_STR.equals(pid)) {
// 新增顶级节点 // 新增顶级节点
Result<CustomerAgencyDTO> agencyInfoResult = govOrgOpenFeignClient.getAgencyById(agencyId); AgencyInfoCache agencyInfo = CustomerOrgRedis.getAgencyInfo(agencyId);
if (!agencyInfoResult.success()) {
throw new EpmetException(agencyInfoResult.getCode(), agencyInfoResult.getMsg());
}
CustomerAgencyDTO agencyInfo = agencyInfoResult.getData();
struct.setAgencyId(agencyInfo.getId()); struct.setAgencyId(agencyInfo.getId());
struct.setAgencyName(agencyInfo.getOrganizationName()); struct.setAgencyName(agencyInfo.getOrganizationName());
struct.setAgencyType(agencyInfo.getLevel()); struct.setAgencyType(agencyInfo.getLevel());
@ -275,4 +266,12 @@ public class PowerAxisStructServiceImpl extends BaseServiceImpl<PowerAxisStructD
List<PowerAxisStructTreeResultDTO> result = baseDao.listParentTreeByLevel(Integer.parseInt(structLevel), customerId); List<PowerAxisStructTreeResultDTO> result = baseDao.listParentTreeByLevel(Integer.parseInt(structLevel), customerId);
return TreeUtils.build(result); return TreeUtils.build(result);
} }
@Override
public String getRootAxisStructId(String rootStructId, String customerId, String agencyId) {
if (StringUtils.isNotBlank(rootStructId)) {
return rootStructId;
}
return baseDao.getRootAxisStructId(customerId, agencyId, PowerTagLevelEnum.ROOT.level());
}
} }

28
epmet-plugins-module/pli-power-base/pli-power-base-server/src/main/java/com/epmet/plugin/power/modules/axis/service/impl/PowerKernelHouseholdServiceImpl.java

@ -15,6 +15,7 @@ import com.epmet.commons.tools.utils.Result;
import com.epmet.dto.IcHouseDTO; import com.epmet.dto.IcHouseDTO;
import com.epmet.dto.result.HouseInfoDTO; import com.epmet.dto.result.HouseInfoDTO;
import com.epmet.feign.GovOrgOpenFeignClient; import com.epmet.feign.GovOrgOpenFeignClient;
import com.epmet.plugin.commons.utils.NumUtils;
import com.epmet.plugin.power.dto.axis.PowerKernelHouseholdDTO; import com.epmet.plugin.power.dto.axis.PowerKernelHouseholdDTO;
import com.epmet.plugin.power.dto.axis.form.PowerKernelHouseFormDTO; import com.epmet.plugin.power.dto.axis.form.PowerKernelHouseFormDTO;
import com.epmet.plugin.power.dto.axis.form.PowerKernelHouseHoldViewListFormDTO; import com.epmet.plugin.power.dto.axis.form.PowerKernelHouseHoldViewListFormDTO;
@ -24,14 +25,15 @@ import com.epmet.plugin.power.dto.axis.result.PowerKernelListPostitionResultDTO;
import com.epmet.plugin.power.dto.axis.result.PowerkernelMemberListResultDTO; import com.epmet.plugin.power.dto.axis.result.PowerkernelMemberListResultDTO;
import com.epmet.plugin.power.modules.axis.dao.PowerKernelHouseholdDao; import com.epmet.plugin.power.modules.axis.dao.PowerKernelHouseholdDao;
import com.epmet.plugin.power.modules.axis.entity.PowerKernelHouseholdEntity; import com.epmet.plugin.power.modules.axis.entity.PowerKernelHouseholdEntity;
import com.epmet.plugin.power.modules.axis.service.PowerAxisStructService;
import com.epmet.plugin.power.modules.axis.service.PowerKernelHouseholdService; import com.epmet.plugin.power.modules.axis.service.PowerKernelHouseholdService;
import com.google.common.collect.Sets; import com.google.common.collect.Sets;
import org.apache.commons.compress.utils.Lists;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import javax.validation.constraints.NotBlank;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.*; import java.util.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@ -54,6 +56,9 @@ public class PowerKernelHouseholdServiceImpl extends BaseServiceImpl<PowerKernel
@Autowired @Autowired
private PowerKernelHouseholdService powerKernelHouseholdService; private PowerKernelHouseholdService powerKernelHouseholdService;
@Autowired
private PowerAxisStructService powerAxisStructService;
@Override @Override
public PageData<PowerKernelHouseholdDTO> page(Map<String, Object> params) { public PageData<PowerKernelHouseholdDTO> page(Map<String, Object> params) {
@ -123,8 +128,12 @@ public class PowerKernelHouseholdServiceImpl extends BaseServiceImpl<PowerKernel
*/ */
@Override @Override
public List<PowerKernelHouseHoldViewListResultDTO> getList(PowerKernelHouseHoldViewListFormDTO form) { public List<PowerKernelHouseHoldViewListResultDTO> getList(PowerKernelHouseHoldViewListFormDTO form) {
form.setPageNo((form.getPageNo() - 1) * form.getPageSize()); String axisStructId = powerAxisStructService.getRootAxisStructId(form.getAxisStructId(), form.getCustomerId(), form.getAgencyId());
form.setCustomerId(loginUserUtil.getLoginUserCustomerId()); if (StringUtils.isBlank(axisStructId)) {
return Lists.newArrayList();
}
form.setAxisStructId(axisStructId);
form.setPageNo((form.getPageNo() - NumConstant.ONE) * form.getPageSize());
List<PowerKernelHouseHoldViewListResultDTO> list = baseDao.getList(form); List<PowerKernelHouseHoldViewListResultDTO> list = baseDao.getList(form);
for (PowerKernelHouseHoldViewListResultDTO dto : list) { for (PowerKernelHouseHoldViewListResultDTO dto : list) {
List<String> nameList = dto.getKernelMemberList().stream().map(PowerkernelMemberListResultDTO::getKernelMemberName).distinct().collect(Collectors.toList()); List<String> nameList = dto.getKernelMemberList().stream().map(PowerkernelMemberListResultDTO::getKernelMemberName).distinct().collect(Collectors.toList());
@ -135,22 +144,17 @@ public class PowerKernelHouseholdServiceImpl extends BaseServiceImpl<PowerKernel
@Override @Override
public long getTotal(PowerKernelHouseHoldViewListFormDTO form) { public long getTotal(PowerKernelHouseHoldViewListFormDTO form) {
form.setCustomerId(loginUserUtil.getLoginUserCustomerId());
return baseDao.getTotal(form); return baseDao.getTotal(form);
} }
@Override @Override
public List<PowerKernelListPostitionResultDTO> getListPosition(PowerKernelListPostitionFormDTO form) { public List<PowerKernelListPostitionResultDTO> getListPosition(PowerKernelListPostitionFormDTO form) {
Integer limit = form.getLimit(); String customerId = form.getCustomerId();
if (null == limit || NumConstant.ZERO_L == limit) { String axisStructId = powerAxisStructService.getRootAxisStructId(form.getAxisStructId(), customerId, form.getAgencyId());
limit = 999;
}
String axisStructId = form.getAxisStructId();
if (StringUtils.isBlank(axisStructId)) { if (StringUtils.isBlank(axisStructId)) {
String agencyId = form.getAgencyId(); return Lists.newArrayList();
axisStructId = baseDao.queryAxisStructId(agencyId,form.getCustomerId());
} }
return baseDao.queryListPosition(axisStructId, form.getCustomerId(), limit); return baseDao.queryListPosition(axisStructId, customerId, NumUtils.getNumberInt(form.getLimit(), true, NumUtils.ONE_THOUSAND));
} }
@Override @Override

18
epmet-plugins-module/pli-power-base/pli-power-base-server/src/main/java/com/epmet/plugin/power/modules/axis/service/impl/PowerServiceStationServiceImpl.java

@ -6,14 +6,16 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; import com.epmet.commons.mybatis.service.impl.BaseServiceImpl;
import com.epmet.commons.tools.constant.FieldConstant; import com.epmet.commons.tools.constant.FieldConstant;
import com.epmet.commons.tools.page.PageData; 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.commons.tools.utils.ConvertUtils;
import com.epmet.plugin.commons.utils.NumUtils;
import com.epmet.plugin.power.dto.axis.PowerServiceStationDTO; import com.epmet.plugin.power.dto.axis.PowerServiceStationDTO;
import com.epmet.plugin.power.dto.axis.form.PowerAxisServiceStationFormDTO; import com.epmet.plugin.power.dto.axis.form.PowerAxisServiceStationFormDTO;
import com.epmet.plugin.power.dto.axis.result.PowerAxisServiceStationResultDTO; import com.epmet.plugin.power.dto.axis.result.PowerAxisServiceStationResultDTO;
import com.epmet.plugin.power.modules.axis.dao.PowerServiceStationDao; import com.epmet.plugin.power.modules.axis.dao.PowerServiceStationDao;
import com.epmet.plugin.power.modules.axis.entity.PowerServiceStationEntity; import com.epmet.plugin.power.modules.axis.entity.PowerServiceStationEntity;
import com.epmet.plugin.power.modules.axis.service.PowerAxisStructService;
import com.epmet.plugin.power.modules.axis.service.PowerServiceStationService; import com.epmet.plugin.power.modules.axis.service.PowerServiceStationService;
import org.apache.commons.compress.utils.Lists;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@ -32,9 +34,8 @@ import java.util.Map;
@Service @Service
public class PowerServiceStationServiceImpl extends BaseServiceImpl<PowerServiceStationDao, PowerServiceStationEntity> implements PowerServiceStationService { public class PowerServiceStationServiceImpl extends BaseServiceImpl<PowerServiceStationDao, PowerServiceStationEntity> implements PowerServiceStationService {
@Autowired @Autowired
private LoginUserUtil loginUser; private PowerAxisStructService powerAxisStructService;
@Override @Override
public PageData<PowerServiceStationDTO> page(Map<String, Object> params) { public PageData<PowerServiceStationDTO> page(Map<String, Object> params) {
@ -74,7 +75,6 @@ public class PowerServiceStationServiceImpl extends BaseServiceImpl<PowerService
@Override @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public void save(PowerServiceStationDTO dto) { public void save(PowerServiceStationDTO dto) {
dto.setCustomerId(loginUser.getLoginUserCustomerId());
PowerServiceStationEntity entity = ConvertUtils.sourceToTarget(dto, PowerServiceStationEntity.class); PowerServiceStationEntity entity = ConvertUtils.sourceToTarget(dto, PowerServiceStationEntity.class);
insert(entity); insert(entity);
} }
@ -95,9 +95,13 @@ public class PowerServiceStationServiceImpl extends BaseServiceImpl<PowerService
@Override @Override
public List<PowerAxisServiceStationResultDTO> getListPosition(PowerAxisServiceStationFormDTO form) { public List<PowerAxisServiceStationResultDTO> getListPosition(PowerAxisServiceStationFormDTO form) {
form.setCustomerId(loginUser.getLoginUserCustomerId()); String axisStructId = powerAxisStructService.getRootAxisStructId(form.getAxisStructId(), form.getCustomerId(), form.getAgencyId());
List<PowerAxisServiceStationResultDTO> list = baseDao.getListPosition(form); if (StringUtils.isBlank(axisStructId)) {
return list; return Lists.newArrayList();
}
form.setAxisStructId(axisStructId);
form.setLimit(NumUtils.getNumberInt(form.getLimit(), true, NumUtils.ONE_THOUSAND));
return baseDao.getListPosition(form);
} }
} }

13
epmet-plugins-module/pli-power-base/pli-power-base-server/src/main/resources/mapper/poweraxis/PowerAxisStructDao.xml

@ -244,6 +244,19 @@
AND s.AGENCY_ID = #{agencyId} AND s.AGENCY_ID = #{agencyId}
AND h.CUSTOMER_ID = #{customerId} AND h.CUSTOMER_ID = #{customerId}
</select> </select>
<select id="getRootAxisStructId" resultType="java.lang.String">
SELECT
s.ID
FROM
pli_power_axis_struct s
LEFT JOIN pli_power_axis_tag t ON s.CATEGORY_CODE = t.CATEGORY_CODE
AND s.CUSTOMER_ID = t.CUSTOMER_ID
WHERE
s.CUSTOMER_ID = #{customerId}
AND s.AGENCY_ID = #{agencyId}
AND s.DEL_FLAG = '0'
AND t.STRUCT_LEVEL = #{structLevel}
</select>
</mapper> </mapper>

15
epmet-plugins-module/pli-power-base/pli-power-base-server/src/main/resources/mapper/poweraxis/PowerKernelHouseholdDao.xml

@ -128,7 +128,8 @@
GROUP BY GROUP BY
h.HOUSE_ID h.HOUSE_ID
ORDER BY ORDER BY
s.SORT s.SORT,h.CREATED_TIME
LIMIT #{limit}
</select> </select>
<resultMap id="getPageList" type="com.epmet.plugin.power.dto.axis.PowerKernelHouseholdDTO"> <resultMap id="getPageList" type="com.epmet.plugin.power.dto.axis.PowerKernelHouseholdDTO">
<result property="ownerName" column="OWNER_NAME" /> <result property="ownerName" column="OWNER_NAME" />
@ -171,17 +172,5 @@
ORDER BY ORDER BY
h.CREATED_TIME h.CREATED_TIME
</select> </select>
<select id="queryAxisStructId" resultType="java.lang.String">
SELECT
id
FROM
pli_power_axis_struct
WHERE
agency_id = #{agencyId}
AND DEL_FLAG = '0'
AND pid = '0'
AND CUSTOMER_ID = #{customerId}
</select>
</mapper> </mapper>
Loading…
Cancel
Save