diff --git a/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/equipment/entity/EmInfoEntity.java b/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/equipment/entity/EmInfoEntity.java index 26708ed..b78e45f 100644 --- a/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/equipment/entity/EmInfoEntity.java +++ b/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; + } diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/station/feign/IStationClient.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/station/feign/IStationClient.java index db8874d..928167a 100644 --- a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/station/feign/IStationClient.java +++ b/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> getListAll(); @@ -62,4 +63,12 @@ public interface IStationClient { @GetMapping(QUERY_EXIST_LGTD_LTTD) R> queryExistLgtdAndLttd(); + + /** + * 根据条件获取唯一站点 + * @param request 站点信息 + * @return 站点 + */ + @PostMapping(GET_ONE) + R getOne(@RequestBody StationEntity request); } diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/station/feign/IStationClientFallBack.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/station/feign/IStationClientFallBack.java index e118312..741a479 100644 --- a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/station/feign/IStationClientFallBack.java +++ b/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> queryExistLgtdAndLttd() { return R.fail(400,"未获取当相关站点"); } + + @Override + public R getOne(StationEntity request) { + return R.data(null); + } } diff --git a/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/controller/EmInfoController.java b/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/controller/EmInfoController.java index 4b8e93c..cd3f611 100644 --- a/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/controller/EmInfoController.java +++ b/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 queryWrapper = Condition.getQueryWrapper(em_info, EmInfoEntity.class); queryWrapper.lambda().eq(EmInfoEntity::getGpid, 0); IPage 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 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); } diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/controller/StationController.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/controller/StationController.java index 0127ad0..e0e1cb8 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/controller/StationController.java +++ b/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> getList(StationEntity entity) { + LambdaQueryWrapper 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 = "") diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/feign/StationClient.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/feign/StationClient.java index 5a78804..bad6654 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/feign/StationClient.java +++ b/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 getOne(@RequestBody StationEntity request) { + return R.data(stationService.getOne(request)); + } + + @Override @PostMapping("/getStationByCodeOrRedDept") @ApiOperation("根据条件查询单个站点") @ApiOperationSupport(order = 9) diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/IStationService.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/IStationService.java index a8dafa5..83a30ef 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/IStationService.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/IStationService.java @@ -118,4 +118,11 @@ public interface IStationService extends BaseService { List getStationCount(); List select(Integer type, Integer serveType); + + /** + * 根据条件获取唯一站点 + * @param request 站点信息 + * @return 站点 + */ + StationEntity getOne(StationEntity request); } diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/StationServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/StationServiceImpl.java index c174274..4244edd 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/StationServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/StationServiceImpl.java @@ -632,6 +632,19 @@ public class StationServiceImpl extends BaseServiceImpl queryWrapper = Condition.getQueryWrapper(new StationEntity(), request); + if(Func.isNotEmpty(request.getStatus())) { + queryWrapper.eq(StationEntity::getStatus,request.getStatus()); + } + List 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集合