Browse Source

# 接站接口优化

zhongwei
H.X 2 years ago
parent
commit
3d75a32a5e
  1. 13
      hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/equipment/entity/EmInfoEntity.java
  2. 9
      hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/station/feign/IStationClient.java
  3. 5
      hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/station/feign/IStationClientFallBack.java
  4. 19
      hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/controller/EmInfoController.java
  5. 12
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/controller/StationController.java
  6. 8
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/feign/StationClient.java
  7. 7
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/IStationService.java
  8. 13
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/StationServiceImpl.java

13
hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/equipment/entity/EmInfoEntity.java

@ -1,5 +1,6 @@
package com.hnac.hzims.equipment.entity;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
@ -215,4 +216,16 @@ public class EmInfoEntity extends TenantEntity {
@ApiModelProperty("机组类型")
private String setType;
@TableField(exist = false)
@ApiModelProperty("站点编码")
private String stationCode;
@TableField(exist = false)
@ApiModelProperty("站点名称")
private String stationName;
@TableField(exist = false)
@ApiModelProperty("站点类型")
private Integer stationType;
}

9
hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/station/feign/IStationClient.java

@ -29,6 +29,7 @@ public interface IStationClient {
String GET_STATIONS_BY_REF_DEPT = API_PREFIX + "/getStationsByRefDept";
String LIST = API_PREFIX + "/list";
String QUERY_EXIST_LGTD_LTTD = API_PREFIX + "/queryExistLgtdAndLttd";
String GET_ONE = API_PREFIX + "/getOne";
@GetMapping(GET_LIST_ALL)
R<List<StationEntity>> getListAll();
@ -62,4 +63,12 @@ public interface IStationClient {
@GetMapping(QUERY_EXIST_LGTD_LTTD)
R<List<StationEntity>> queryExistLgtdAndLttd();
/**
* 根据条件获取唯一站点
* @param request 站点信息
* @return 站点
*/
@PostMapping(GET_ONE)
R<StationEntity> getOne(@RequestBody StationEntity request);
}

5
hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/station/feign/IStationClientFallBack.java

@ -65,4 +65,9 @@ public class IStationClientFallBack implements IStationClient {
public R<List<StationEntity>> queryExistLgtdAndLttd() {
return R.fail(400,"未获取当相关站点");
}
@Override
public R<StationEntity> getOne(StationEntity request) {
return R.data(null);
}
}

19
hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/controller/EmInfoController.java

@ -8,6 +8,8 @@ import com.hnac.hzims.equipment.entity.EmInfoEntity;
import com.hnac.hzims.equipment.service.IEmInfoService;
import com.hnac.hzims.equipment.vo.EmInfoAddVo;
import com.hnac.hzims.equipment.vo.EmInfoVO;
import com.hnac.hzims.operational.station.entity.StationEntity;
import com.hnac.hzims.operational.station.feign.IStationClient;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
@ -21,6 +23,7 @@ import org.springblade.core.secure.utils.AuthUtil;
import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.CollectionUtil;
import org.springblade.core.tool.utils.Func;
import org.springblade.core.tool.utils.ObjectUtil;
import org.springframework.util.Assert;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
@ -29,6 +32,7 @@ import springfox.documentation.annotations.ApiIgnore;
import javax.validation.Valid;
import java.util.List;
import java.util.Map;
import java.util.Optional;
/**
* 设备控制器
@ -42,6 +46,7 @@ import java.util.Map;
public class EmInfoController extends BladeController {
private final IEmInfoService em_infoService;
private final IStationClient stationClient;
/**
* 详情
@ -80,6 +85,20 @@ public class EmInfoController extends BladeController {
QueryWrapper<EmInfoEntity> queryWrapper = Condition.getQueryWrapper(em_info, EmInfoEntity.class);
queryWrapper.lambda().eq(EmInfoEntity::getGpid, 0);
IPage<EmInfoEntity> pages = em_infoService.page(Condition.getPage(query), queryWrapper);
if(CollectionUtil.isNotEmpty(pages.getRecords())) {
pages.getRecords().forEach(emInfoEntity -> {
if(Func.isNotEmpty(emInfoEntity.getDepartment())) {
StationEntity request = new StationEntity();
request.setRefDept(emInfoEntity.getDepartment());
R<StationEntity> result = stationClient.getOne(request);
if(result.isSuccess() && ObjectUtil.isNotEmpty(result.getData())) {
emInfoEntity.setStationCode(result.getData().getCode());
emInfoEntity.setStationType(result.getData().getType());
emInfoEntity.setStationName(result.getData().getName());
}
}
});
}
return R.data(pages);
}

12
hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/controller/StationController.java

@ -16,6 +16,7 @@ import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springblade.core.boot.ctrl.BladeController;
import org.springblade.core.log.exception.ServiceException;
import org.springblade.core.mp.support.Condition;
import org.springblade.core.mp.support.Query;
import org.springblade.core.secure.BladeUser;
import org.springblade.core.secure.utils.AuthUtil;
@ -150,6 +151,17 @@ public class StationController extends BladeController {
return R.data(stationService.getStationByCode(code));
}
@GetMapping(value = "/getList")
@ApiOperationSupport(order = 70)
@ApiOperation(value = "获取站点列表(不分页查询)", notes = "传入StationEntity")
public R<List<StationEntity>> getList(StationEntity entity) {
LambdaQueryWrapper<StationEntity> lwq = Condition.getQueryWrapper(new StationEntity(),entity);
if(Func.isNotEmpty(entity.getStatus())) {
lwq.eq(StationEntity::getStatus,entity.getStatus());
}
return R.data(stationService.list(lwq));
}
@GetMapping("/list/all")
@ApiOperationSupport(order = 80)
@ApiOperation(value = "查询所有", notes = "")

8
hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/feign/StationClient.java

@ -118,6 +118,14 @@ public class StationClient implements IStationClient {
}
@Override
@PostMapping("/getOne")
@ApiOperation("根据条件获取唯一站点")
@ApiOperationSupport(order = 11)
public R<StationEntity> getOne(@RequestBody StationEntity request) {
return R.data(stationService.getOne(request));
}
@Override
@PostMapping("/getStationByCodeOrRedDept")
@ApiOperation("根据条件查询单个站点")
@ApiOperationSupport(order = 9)

7
hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/IStationService.java

@ -118,4 +118,11 @@ public interface IStationService extends BaseService<StationEntity> {
List<HzimsStationCountVo> getStationCount();
List<StationEntity> select(Integer type, Integer serveType);
/**
* 根据条件获取唯一站点
* @param request 站点信息
* @return 站点
*/
StationEntity getOne(StationEntity request);
}

13
hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/StationServiceImpl.java

@ -632,6 +632,19 @@ public class StationServiceImpl extends BaseServiceImpl<StationMapper, StationEn
);
}
@Override
public StationEntity getOne(StationEntity request) {
LambdaQueryWrapper<StationEntity> queryWrapper = Condition.getQueryWrapper(new StationEntity(), request);
if(Func.isNotEmpty(request.getStatus())) {
queryWrapper.eq(StationEntity::getStatus,request.getStatus());
}
List<StationEntity> list = this.list(queryWrapper);
if(CollectionUtil.isNotEmpty(list) && list.size() > 1) {
throw new ServiceException("获取站点数量超过一条");
}
return Optional.ofNullable(list).map(l -> l.get(0)).orElse(null);
}
/**
* 删除新建站点时绑定的数据项目智能诊断站点
* @param idList id集合

Loading…
Cancel
Save