From edd0086985319bd8d0a6e25a20a582259ace4565 Mon Sep 17 00:00:00 2001 From: "H.X" <7458466+huangxing1023@user.noreply.gitee.com> Date: Wed, 22 Mar 2023 10:16:36 +0800 Subject: [PATCH] =?UTF-8?q?#=20=E6=8E=A5=E7=AB=99=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../hnac/hzims/equipment/entity/EmInfoEntity.java | 6 +++ .../com/hnac/hzims/fdp/feign/IQuestionClient.java | 2 +- .../operational/station/StationConstants.java | 12 ++++++ hzims-service/equipment/pom.xml | 46 +++------------------- .../equipment/service/impl/EmInfoServiceImpl.java | 11 ++++++ .../com/hnac/hzims/fdp/feign/QuestionClient.java | 2 +- .../fdp/service/impl/FdpQuestionServiceImpl.java | 17 +++++--- .../server/impl/EquipmentInstanceServiceImpl.java | 18 ++++----- .../station/controller/StationController.java | 7 ++++ .../station/service/impl/StationServiceImpl.java | 24 ++++++----- 10 files changed, 80 insertions(+), 65 deletions(-) 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 b8ace93..26708ed 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 @@ -209,4 +209,10 @@ public class EmInfoEntity extends TenantEntity { @JsonSerialize(nullsUsing = NullSerializer.class) private Long deviceInstanceId; + @ApiModelProperty("设备类型") + private String emType; + + @ApiModelProperty("机组类型") + private String setType; + } diff --git a/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/fdp/feign/IQuestionClient.java b/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/fdp/feign/IQuestionClient.java index 7227cc2..3fc49c2 100644 --- a/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/fdp/feign/IQuestionClient.java +++ b/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/fdp/feign/IQuestionClient.java @@ -25,6 +25,6 @@ public interface IQuestionClient { * @return */ @GetMapping(SUBMIT_STATION_INFO) - R submitStationInfo(@RequestParam String stationCode, @RequestParam(required = false) String stationDesc); + R submitStationInfo(@RequestParam("stationCode") String stationCode, @RequestParam(value = "stationDesc",required = false) String stationDesc); } diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/station/StationConstants.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/station/StationConstants.java index f487fcc..8f9da7f 100644 --- a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/station/StationConstants.java +++ b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/station/StationConstants.java @@ -3,6 +3,18 @@ package com.hnac.hzims.operational.station; import lombok.Getter; public interface StationConstants { + + /*==============================================================================================*/ + /**数据来源-hz3000-v3**/ + String HZ3000_V3 = "3"; + /**数据来源-hz3000-v4**/ + String HZ3000_V4 = "4"; + /**数据来源-hz3000-v4s**/ + String HZ3000_V4S = "4S"; + /**数据来源-hz3000-v5**/ + String HZ3000_OTHER = "5"; + /*==============================================================================================*/ + String STATION_VIDEO_TYPE_CODE = "vedio_address_type"; //自动添加或修改机构数据 diff --git a/hzims-service/equipment/pom.xml b/hzims-service/equipment/pom.xml index ddb962c..87ed4dd 100644 --- a/hzims-service/equipment/pom.xml +++ b/hzims-service/equipment/pom.xml @@ -24,46 +24,6 @@ org.springblade blade-starter-oss-all - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - com.hnac.hzims spare-api @@ -95,6 +55,12 @@ com.hnac.hzinfo read-data 1.0.0 + + + org.slf4j + slf4j-log4j12 + + diff --git a/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/service/impl/EmInfoServiceImpl.java b/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/service/impl/EmInfoServiceImpl.java index a6129b2..925ee47 100644 --- a/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/service/impl/EmInfoServiceImpl.java +++ b/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/service/impl/EmInfoServiceImpl.java @@ -19,7 +19,9 @@ import com.hnac.hzims.util.TableJsonUtils; import com.hnac.hzinfo.datasearch.analyse.IAnalyseDataSearchClient; import com.hnac.hzinfo.datasearch.analyse.vo.AnalyzeCodeBySignagesVO; import com.hnac.hzinfo.sdk.analyse.po.MultiAnalyzeCodePO; +import com.hnac.hzinfo.sdk.v5.device.client.DeviceClient; import org.apache.commons.collections4.MapUtils; +import org.springblade.core.log.exception.ServiceException; import org.springblade.core.mp.base.BaseServiceImpl; import org.springblade.core.tool.api.R; import org.springblade.core.tool.utils.*; @@ -30,6 +32,7 @@ import org.springframework.data.redis.core.RedisTemplate; import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import org.springframework.util.Assert; import javax.validation.Valid; import java.util.*; @@ -61,6 +64,9 @@ public class EmInfoServiceImpl extends BaseServiceImpl existResult = deviceClient.isDeviceCodeExist(em_info.getInfo().getNumber()); + Assert.isTrue(existResult.isSuccess() && !existResult.getData(),() -> { + throw new ServiceException("该设备编码在设备实例中找到对应记录,保存失败!"); + }); EmInfoEntity emInfoEntity = this.baseMapper.selectEmInfoByCode(em_info.getInfo().getNumber()); if (ObjectUtil.isNotEmpty(emInfoEntity)) { return R.fail("设备编号已存在"); diff --git a/hzims-service/equipment/src/main/java/com/hnac/hzims/fdp/feign/QuestionClient.java b/hzims-service/equipment/src/main/java/com/hnac/hzims/fdp/feign/QuestionClient.java index 6e11a3f..899ac9a 100644 --- a/hzims-service/equipment/src/main/java/com/hnac/hzims/fdp/feign/QuestionClient.java +++ b/hzims-service/equipment/src/main/java/com/hnac/hzims/fdp/feign/QuestionClient.java @@ -20,7 +20,7 @@ public class QuestionClient implements IQuestionClient { @GetMapping(SUBMIT_STATION_INFO) @Override - public R submitStationInfo(@RequestParam String stationCode,@RequestParam String stationDesc) { + public R submitStationInfo(@RequestParam String stationCode,@RequestParam(required = false) String stationDesc) { return R.status(fdpQuestionService.submitStationInfo(stationCode,stationDesc)); } diff --git a/hzims-service/equipment/src/main/java/com/hnac/hzims/fdp/service/impl/FdpQuestionServiceImpl.java b/hzims-service/equipment/src/main/java/com/hnac/hzims/fdp/service/impl/FdpQuestionServiceImpl.java index 4a75276..a70d510 100644 --- a/hzims-service/equipment/src/main/java/com/hnac/hzims/fdp/service/impl/FdpQuestionServiceImpl.java +++ b/hzims-service/equipment/src/main/java/com/hnac/hzims/fdp/service/impl/FdpQuestionServiceImpl.java @@ -24,11 +24,13 @@ import org.springblade.core.tool.api.R; import org.springblade.core.tool.utils.Func; import org.springblade.core.tool.utils.StringUtil; import org.springframework.stereotype.Service; +import org.springframework.util.Assert; import javax.servlet.http.HttpServletResponse; import java.util.HashMap; import java.util.List; import java.util.Optional; +import java.util.concurrent.Executors; /** * @author hx @@ -141,17 +143,22 @@ public class FdpQuestionServiceImpl implements IFdpQuestionService { @Override public boolean generateGraphInstance(Integer stationType, String stationId) { Integer type = this.getStationType(stationType); - if(Func.isNotEmpty(type)) { + Assert.isTrue(Func.isNotEmpty(type),() -> { + throw new ServiceException("设备所属站点类型只能为水电站或泵站"); + }); + Executors.newSingleThreadExecutor().submit(() -> { HttpResponse httpResponse = HttpRequest.post(fdpUrlConfiguration.getGenerateGraphInstance()).body(JSON.toJSONString( new HashMap(){{ put("type",type); put("stationId",stationId); }} )).execute(); - return httpResponse.getStatus() == HttpServletResponse.SC_OK && - "1".equals(JSONObject.parseObject(httpResponse.body()).getString("success")); - } - return false; + if(httpResponse.getStatus() != HttpServletResponse.SC_OK || + !"1".equals(JSONObject.parseObject(httpResponse.body()).getString("success"))) { + logger.error("equipment:fdp:generateGraphInstance",httpResponse.body()); + } + }); + return true; } @Override diff --git a/hzims-service/equipment/src/main/java/com/hnac/hzims/monitor/server/impl/EquipmentInstanceServiceImpl.java b/hzims-service/equipment/src/main/java/com/hnac/hzims/monitor/server/impl/EquipmentInstanceServiceImpl.java index efe336b..05fc2cf 100644 --- a/hzims-service/equipment/src/main/java/com/hnac/hzims/monitor/server/impl/EquipmentInstanceServiceImpl.java +++ b/hzims-service/equipment/src/main/java/com/hnac/hzims/monitor/server/impl/EquipmentInstanceServiceImpl.java @@ -51,17 +51,17 @@ public class EquipmentInstanceServiceImpl implements IEquipmentInstanceService { // 模型标识根据题目答案获取 virtualDeviceDTO.setModelSignage(this.getModelSignageByAnswer(submitAnswerReq)); R saveResult = deviceClient.saveVirtualDevice(virtualDeviceDTO); - Assert.isTrue(saveResult.isSuccess() && Func.isNotEmpty(saveResult.getData()),() -> { + Assert.isTrue(saveResult.isSuccess(),() -> { throw new ServiceException(saveResult.getMsg()); }); - Long instanceId = Long.valueOf(String.valueOf(saveResult.getData())); - LambdaUpdateWrapper luw = Wrappers.lambdaUpdate() - .set(EmInfoEntity::getDeviceInstanceId, instanceId) - .eq(EmInfoEntity::getNumber, submitAnswerReq.getEmCode()); - Assert.isTrue(emInfoService.update(luw),() -> { - throw new ServiceException("保存设备实例ID失败"); - }); - submitAnswerReq.setInstanceId(instanceId.toString()); +// Long instanceId = Long.valueOf(String.valueOf(saveResult.getData())); +// LambdaUpdateWrapper luw = Wrappers.lambdaUpdate() +// .set(EmInfoEntity::getDeviceInstanceId, instanceId) +// .eq(EmInfoEntity::getNumber, submitAnswerReq.getEmCode()); +// Assert.isTrue(emInfoService.update(luw),() -> { +// throw new ServiceException("保存设备实例ID失败"); +// }); + submitAnswerReq.setInstanceId(submitAnswerReq.getEmCode()); return fdpQuestionService.submitDeviceAnswer(submitAnswerReq); } 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 16494d1..0127ad0 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 @@ -59,6 +59,13 @@ public class StationController extends BladeController { return R.data(vos); } + @GetMapping("/detail/{id}") + @ApiOperationSupport(order = 60) + @ApiOperation(value = "查看详情", notes = "查看详情") + public R detail(@PathVariable @ApiParam("主键ID") Long id) { + return R.data(stationService.getById(id)); + } + /** * 新增 */ 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 54809c4..c174274 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 @@ -24,6 +24,9 @@ import com.hnac.hzims.operational.station.wrapper.StationWrapper; import com.hnac.hzinfo.sdk.v5.project.ProjectClient; import com.hnac.hzinfo.sdk.v5.project.dto.ProjectDTO; import com.hnac.hzinfo.sdk.v5.project.vo.ProjectVO;*/ +import com.hnac.hzinfo.sdk.core.response.Result; +import com.hnac.hzinfo.sdk.v5.project.ProjectClient; +import com.hnac.hzinfo.sdk.v5.project.dto.ProjectDTO; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang.StringUtils; @@ -62,7 +65,7 @@ public class StationServiceImpl extends BaseServiceImpl { throw new ServiceException("创建/修改站点信息失败!"); }); - // 智能诊断站点推送 - ExecutorService executor = Executors.newSingleThreadExecutor(); - executor.submit(() -> questionClient.submitStationInfo(req.getCode(), null)); - // 新建项目 - executor.submit(() -> this.instanceProject(req)); + // 如果设备数据来源未选定其他 则进行站点初始化操作 + if(!StationConstants.HZ3000_OTHER.equals(req.getDataSource())) { + // 智能诊断站点推送 + ExecutorService executor = Executors.newSingleThreadExecutor(); + executor.submit(() -> questionClient.submitStationInfo(req.getCode(), "")); + // 新建项目 + executor.submit(() -> this.instanceProject(req)); + } } @Override @@ -103,7 +109,7 @@ public class StationServiceImpl extends BaseServiceImpl