From 41ebc04ceeb2930e5bbfe331a90ebf6d2347ae12 Mon Sep 17 00:00:00 2001 From: "H.X" <7458466+huangxing1023@user.noreply.gitee.com> Date: Thu, 2 Mar 2023 20:15:03 +0800 Subject: [PATCH 1/3] =?UTF-8?q?#=20=E8=A7=A3=E5=86=B3=E6=9C=AA=E8=AF=86?= =?UTF-8?q?=E5=88=AB=E6=97=B6=E5=9B=BE=E7=89=87=E4=B8=8A=E4=BC=A0=E5=9C=B0?= =?UTF-8?q?=E5=9D=80=E4=B8=BA=E7=A9=BA=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../inspect/ai/service/impl/DefaultRobotIdentifyTypeHandler.java | 2 +- .../com/hnac/hzinfo/inspect/ai/service/impl/RobotDigitTypeHandler.java | 2 +- .../com/hnac/hzinfo/inspect/ai/service/impl/RobotMeterTypeHandler.java | 3 +-- .../hnac/hzinfo/inspect/ai/service/impl/RobotSwitchHTypeHandler.java | 2 +- .../com/hnac/hzinfo/inspect/ai/service/impl/RobotValueTypeHandler.java | 2 +- .../com/hnac/hzinfo/inspect/ai/service/impl/RobotVoiceTypeHandler.java | 2 +- 6 files changed, 6 insertions(+), 7 deletions(-) diff --git a/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/ai/service/impl/DefaultRobotIdentifyTypeHandler.java b/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/ai/service/impl/DefaultRobotIdentifyTypeHandler.java index 67bc5bd..336bf3c 100644 --- a/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/ai/service/impl/DefaultRobotIdentifyTypeHandler.java +++ b/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/ai/service/impl/DefaultRobotIdentifyTypeHandler.java @@ -46,9 +46,9 @@ public class DefaultRobotIdentifyTypeHandler implements IRobotIdentifyTypeHandle recordVo.setTenantId(tenantId); recordVo.setContentId(content.getId()); String addr = content.getCameraAddr(); + recordVo.setFileUrl(picUrl); if(Func.isNotEmpty(switchs)){ for (RobotAiSwitchReturn re : switchs) { - recordVo.setFileUrl(picUrl); if(addr.trim().equals(re.getRowindex() + AIContants.COMMA + re.getColindex())){ recordVo.setCurrentValue(String.valueOf(re.getState())); recordVo.setCurrentStatus(setCurrentStatus(String.valueOf(re.getState()), content.getCheckVal())); diff --git a/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/ai/service/impl/RobotDigitTypeHandler.java b/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/ai/service/impl/RobotDigitTypeHandler.java index 09af255..df2c241 100644 --- a/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/ai/service/impl/RobotDigitTypeHandler.java +++ b/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/ai/service/impl/RobotDigitTypeHandler.java @@ -32,9 +32,9 @@ public class RobotDigitTypeHandler implements IRobotIdentifyTypeHandler Date: Mon, 6 Mar 2023 17:30:55 +0800 Subject: [PATCH 2/3] =?UTF-8?q?#=20=E6=8E=A5=E7=AB=99=E6=99=BA=E8=83=BD?= =?UTF-8?q?=E8=AF=8A=E6=96=AD=E7=AB=99=E7=82=B9=E5=8F=8A=E9=97=AE=E7=AD=94?= =?UTF-8?q?=E6=8E=A8=E9=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/hnac/hzims/fdp/constants/FdpConstant.java | 13 ++ .../com/hnac/hzims/fdp/request/StationInfoReq.java | 39 ++++++ .../station/enume/StationEnumConstants.java | 7 +- .../hnac/hzims/fdp/config/FdpUrlConfiguration.java | 17 +++ .../fdp/controller/FdpQuestionController.java | 60 ++++++++ .../hnac/hzims/fdp/request/AnswerFormatReq.java | 31 ++++ .../hnac/hzims/fdp/request/SubmitAnswerReq.java | 42 ++++++ .../hnac/hzims/fdp/response/DevsetAnswerResp.java | 38 +++++ .../hzims/fdp/response/DevsetQuestionResp.java | 43 ++++++ .../hzims/fdp/service/IFdpQuestionService.java | 48 +++++++ .../fdp/service/impl/FdpQuestionServiceImpl.java | 156 +++++++++++++++++++++ 11 files changed, 493 insertions(+), 1 deletion(-) create mode 100644 hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/fdp/request/StationInfoReq.java create mode 100644 hzims-service/equipment/src/main/java/com/hnac/hzims/fdp/controller/FdpQuestionController.java create mode 100644 hzims-service/equipment/src/main/java/com/hnac/hzims/fdp/request/AnswerFormatReq.java create mode 100644 hzims-service/equipment/src/main/java/com/hnac/hzims/fdp/request/SubmitAnswerReq.java create mode 100644 hzims-service/equipment/src/main/java/com/hnac/hzims/fdp/response/DevsetAnswerResp.java create mode 100644 hzims-service/equipment/src/main/java/com/hnac/hzims/fdp/response/DevsetQuestionResp.java create mode 100644 hzims-service/equipment/src/main/java/com/hnac/hzims/fdp/service/IFdpQuestionService.java create mode 100644 hzims-service/equipment/src/main/java/com/hnac/hzims/fdp/service/impl/FdpQuestionServiceImpl.java diff --git a/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/fdp/constants/FdpConstant.java b/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/fdp/constants/FdpConstant.java index 36b0c9b..e9cb527 100644 --- a/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/fdp/constants/FdpConstant.java +++ b/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/fdp/constants/FdpConstant.java @@ -3,6 +3,19 @@ package com.hnac.hzims.fdp.constants; import lombok.Getter; public interface FdpConstant { + + /**水电站**/ + Integer HYDROELECTRIC_STATION = 1; + /**泵站**/ + Integer PUMP_STATION = 2; + + /**-----------------------------------------------------------------------------------------**/ + /**公用设备**/ + String COMMON_DEVICE_TYPE = "1"; + /**机组设备**/ + String SET_DEVICE_TYPE = "2"; + /**-----------------------------------------------------------------------------------------**/ + enum FdpTaskStatusEnum{ /** * 未开始 diff --git a/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/fdp/request/StationInfoReq.java b/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/fdp/request/StationInfoReq.java new file mode 100644 index 0000000..c4e56ed --- /dev/null +++ b/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/fdp/request/StationInfoReq.java @@ -0,0 +1,39 @@ +package com.hnac.hzims.fdp.request; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Builder; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NonNull; + +import javax.validation.constraints.NotNull; +import java.io.Serializable; + +/** + * @author hx + * @version 1.0 + * @date 2023/3/6 10:03 + */ +@Data +@EqualsAndHashCode +@ApiModel("FDP站点信息请求") +@Builder +public class StationInfoReq implements Serializable { + + @ApiModelProperty(value = "站点类型",required = true) + @NotNull(message = "站点类型不能为空") + private Integer type; + + @ApiModelProperty("站点ID") + @NotNull(message = "站点ID不能为空") + private String stationId; + + @ApiModelProperty("站点名称") + @NotNull(message = "站点名称不能为空") + private String stationName; + + @ApiModelProperty("站点描述") + private String stationDesc; + +} diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/station/enume/StationEnumConstants.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/station/enume/StationEnumConstants.java index 9f93a16..266ce4e 100644 --- a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/station/enume/StationEnumConstants.java +++ b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/station/enume/StationEnumConstants.java @@ -39,7 +39,12 @@ public interface StationEnumConstants { /** * 充电站 */ - STATION_TYPE_7(7, "充电站"); + STATION_TYPE_7(7, "充电站"), + + /** + * 泵站 + */ + STATION_TYPE_8(8, "泵站"); @Getter private int status; @Getter diff --git a/hzims-service/equipment/src/main/java/com/hnac/hzims/fdp/config/FdpUrlConfiguration.java b/hzims-service/equipment/src/main/java/com/hnac/hzims/fdp/config/FdpUrlConfiguration.java index 2202722..e058b38 100644 --- a/hzims-service/equipment/src/main/java/com/hnac/hzims/fdp/config/FdpUrlConfiguration.java +++ b/hzims-service/equipment/src/main/java/com/hnac/hzims/fdp/config/FdpUrlConfiguration.java @@ -21,4 +21,21 @@ public class FdpUrlConfiguration { /**fdp监测点与数据平台监测点绑定关系推送**/ private String setDataLink; + /**提交站点消息**/ + private String submitStationInfo; + + /**删除站点信息**/ + private String deleteStationInfo; + + /**获取机组问题**/ + private String getDevsetQuestion; + + /**获取站点问题**/ + private String getStationQuestion; + + /**提交机组问题的答案**/ + private String submitDevsetAnswer; + + /**提交站点问题的答案**/ + private String submitStationAnswer; } diff --git a/hzims-service/equipment/src/main/java/com/hnac/hzims/fdp/controller/FdpQuestionController.java b/hzims-service/equipment/src/main/java/com/hnac/hzims/fdp/controller/FdpQuestionController.java new file mode 100644 index 0000000..4d693de --- /dev/null +++ b/hzims-service/equipment/src/main/java/com/hnac/hzims/fdp/controller/FdpQuestionController.java @@ -0,0 +1,60 @@ +package com.hnac.hzims.fdp.controller; + +import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; +import com.hnac.hzims.fdp.request.SubmitAnswerReq; +import com.hnac.hzims.fdp.response.DevsetQuestionResp; +import com.hnac.hzims.fdp.service.IFdpQuestionService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import io.swagger.annotations.ApiParam; +import lombok.AllArgsConstructor; +import org.springblade.core.boot.ctrl.BladeController; +import org.springblade.core.tool.api.R; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; + +import java.util.List; + +/** + * @author hx + * @version 1.0 + * @date 2023/3/6 11:52 + */ +@RestController +@RequestMapping("/fdp/question") +@AllArgsConstructor +@Api(value = "智能诊断接站问答",tags = "智能诊断接站问答") +public class FdpQuestionController extends BladeController { + + private final IFdpQuestionService fdpQuestionService; + + @GetMapping("/submitStationInfo") + @ApiOperation("提交站点信息") + @ApiOperationSupport(order = 1) + public R submitStationInfo(@RequestParam @ApiParam(value = "站点编码",required = true) String stationCode, @RequestParam(required = false) @ApiParam(value = "描述") String stationDesc) { + return R.status(fdpQuestionService.submitStationInfo(stationCode,stationDesc)); + } + + @DeleteMapping("/deleteStationInfo/{stationCode}") + @ApiOperation("删除站点信息") + @ApiOperationSupport(order = 2) + public R deleteStationInfo(@PathVariable @ApiParam(value = "站点编码",required = true) String stationCode) { + return R.status(fdpQuestionService.deleteStationInfo(stationCode)); + } + + @GetMapping("/getDevsetQuestion") + @ApiOperation("获取设备推送Fdp问题") + @ApiOperationSupport(order = 3) + public R> getDevsetQuestion(@RequestParam @ApiParam(value = "设备类型,1:公用;2:机组",required = true) String deviceType, + @RequestParam @ApiParam(value = "站点类型",required = true) Integer stationType) { + return R.data(fdpQuestionService.getDevsetQuestion(deviceType,stationType)); + } + + @PostMapping("/submitDeviceAnswer") + @ApiOperation("提交设备问题答案") + @ApiOperationSupport(order = 4) + public R submitDeviceAnswer(@RequestBody @Validated SubmitAnswerReq submitAnswerReq) { + return R.data(fdpQuestionService.submitDeviceAnswer(submitAnswerReq)); + } + +} diff --git a/hzims-service/equipment/src/main/java/com/hnac/hzims/fdp/request/AnswerFormatReq.java b/hzims-service/equipment/src/main/java/com/hnac/hzims/fdp/request/AnswerFormatReq.java new file mode 100644 index 0000000..48754c0 --- /dev/null +++ b/hzims-service/equipment/src/main/java/com/hnac/hzims/fdp/request/AnswerFormatReq.java @@ -0,0 +1,31 @@ +package com.hnac.hzims.fdp.request; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import javax.validation.constraints.NotNull; +import java.io.Serializable; + +/** + * @author hx + * @version 1.0 + * @date 2023/3/6 16:12 + */ +@Data +@ApiModel("提交答案格式") +@EqualsAndHashCode +public class AnswerFormatReq implements Serializable { + + @ApiModelProperty(value = "问题ID",required = true) + @NotNull + private String questionId; + + @ApiModelProperty(value = "答案ID,选择题需要传多选题答案ID用逗号分隔") + private String answerId; + + @ApiModelProperty("答案内容,填空题需要传") + private String inputValue; + +} diff --git a/hzims-service/equipment/src/main/java/com/hnac/hzims/fdp/request/SubmitAnswerReq.java b/hzims-service/equipment/src/main/java/com/hnac/hzims/fdp/request/SubmitAnswerReq.java new file mode 100644 index 0000000..f5aef16 --- /dev/null +++ b/hzims-service/equipment/src/main/java/com/hnac/hzims/fdp/request/SubmitAnswerReq.java @@ -0,0 +1,42 @@ +package com.hnac.hzims.fdp.request; + +import com.alibaba.fastjson.annotation.JSONField; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import javax.validation.constraints.NotNull; +import javax.xml.soap.Name; +import java.io.Serializable; +import java.util.List; + +/** + * @author hx + * @version 1.0 + * @date 2023/3/6 16:19 + */ +@ApiModel("提交答案") +@Data +@EqualsAndHashCode +public class SubmitAnswerReq implements Serializable { + + @ApiModelProperty(value = "站点类型",required = true) + @NotNull + private Integer stationType; + + private Integer type; + + @ApiModelProperty(value = "站点ID",required = true) + @NotNull + private String stationId; + + @ApiModelProperty(value = "设备类型",required = true) + @NotNull + private String deviceType; + + @ApiModelProperty(value = "站点问题数据",required = true) + @JSONField(name = "data") + private List answerFormatList; + +} diff --git a/hzims-service/equipment/src/main/java/com/hnac/hzims/fdp/response/DevsetAnswerResp.java b/hzims-service/equipment/src/main/java/com/hnac/hzims/fdp/response/DevsetAnswerResp.java new file mode 100644 index 0000000..3c61738 --- /dev/null +++ b/hzims-service/equipment/src/main/java/com/hnac/hzims/fdp/response/DevsetAnswerResp.java @@ -0,0 +1,38 @@ +package com.hnac.hzims.fdp.response; + +import com.alibaba.fastjson.annotation.JSONField; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.io.Serializable; +import java.util.List; + +/** + * @author hx + * @version 1.0 + * @date 2023/3/6 14:40 + */ +@Data +@EqualsAndHashCode +@ApiModel("机组问题答案") +public class DevsetAnswerResp implements Serializable { + + @ApiModelProperty("答案ID") + @JSONField(name = "AID") + private String aId; + + @ApiModelProperty("答案名称") + @JSONField(name = "ANAME") + private String aName; + + @ApiModelProperty("是否默认选中。0为不选中,1为选中") + @JSONField(name = "ADEFAULT") + private Integer aDefault; + + @ApiModelProperty("选中该答案需要继续回答的问题数组") + @JSONField(name = "QUESTION") + private List question; + +} diff --git a/hzims-service/equipment/src/main/java/com/hnac/hzims/fdp/response/DevsetQuestionResp.java b/hzims-service/equipment/src/main/java/com/hnac/hzims/fdp/response/DevsetQuestionResp.java new file mode 100644 index 0000000..873da12 --- /dev/null +++ b/hzims-service/equipment/src/main/java/com/hnac/hzims/fdp/response/DevsetQuestionResp.java @@ -0,0 +1,43 @@ +package com.hnac.hzims.fdp.response; + +/** + * @author hx + * @version 1.0 + * @date 2023/3/6 14:35 + */ + +import com.alibaba.fastjson.annotation.JSONField; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.io.Serializable; +import java.util.List; + +@Data +@EqualsAndHashCode +@ApiModel("机组问题") +public class DevsetQuestionResp implements Serializable { + + @ApiModelProperty("问题ID") + @JSONField(name = "ID") + private String id; + + @ApiModelProperty("问题名称") + @JSONField(name = "NAME") + private String name; + + @ApiModelProperty("问题类型。当前有“单选”、“多选”、“参数填空”、“数量填空”") + @JSONField(name = "QTYPE") + private String qType; + + @ApiModelProperty("问题的父答案ID") + @JSONField(name = "FAID") + private String parentId; + + @ApiModelProperty("问题的答案列表") + @JSONField(name = "ANSWER") + private List answer; + +} diff --git a/hzims-service/equipment/src/main/java/com/hnac/hzims/fdp/service/IFdpQuestionService.java b/hzims-service/equipment/src/main/java/com/hnac/hzims/fdp/service/IFdpQuestionService.java new file mode 100644 index 0000000..dfe1d35 --- /dev/null +++ b/hzims-service/equipment/src/main/java/com/hnac/hzims/fdp/service/IFdpQuestionService.java @@ -0,0 +1,48 @@ +package com.hnac.hzims.fdp.service; + +import com.hnac.hzims.fdp.request.SubmitAnswerReq; +import com.hnac.hzims.fdp.response.DevsetQuestionResp; +import io.swagger.annotations.ApiParam; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestParam; + +import java.util.List; + +/** + * @author hx + * @version 1.0 + * @date 2023/3/6 10:18 + */ +public interface IFdpQuestionService { + + /** + * 提交站点信息 + * @param stationCode 站点编码 + * @param stationDesc 站点描述 + * @return + */ + boolean submitStationInfo(String stationCode,String stationDesc); + + /** + * 删除站点信息 + * @param stationId 站点编码 + * @return + */ + boolean deleteStationInfo(String stationId); + + /** + * 获取设备推送Fdp问题 + * @param deviceType 设备类型 + * @param stationType 站点类型 + * @return + */ + List getDevsetQuestion(String deviceType, Integer stationType); + + /** + * 提交设备问题答案 + * @param submitAnswerReq 提交答案 + * @return + */ + boolean submitDeviceAnswer(@RequestBody SubmitAnswerReq submitAnswerReq); + +} 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 new file mode 100644 index 0000000..ba6d334 --- /dev/null +++ b/hzims-service/equipment/src/main/java/com/hnac/hzims/fdp/service/impl/FdpQuestionServiceImpl.java @@ -0,0 +1,156 @@ +package com.hnac.hzims.fdp.service.impl; + +import cn.hutool.http.HttpRequest; +import cn.hutool.http.HttpResponse; +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import com.google.common.collect.Lists; +import com.hnac.hzims.fdp.config.FdpUrlConfiguration; +import com.hnac.hzims.fdp.constants.FdpConstant; +import com.hnac.hzims.fdp.request.StationInfoReq; +import com.hnac.hzims.fdp.request.SubmitAnswerReq; +import com.hnac.hzims.fdp.response.DevsetQuestionResp; +import com.hnac.hzims.fdp.service.IFdpQuestionService; +import com.hnac.hzims.operational.station.StationConstants; +import com.hnac.hzims.operational.station.entity.StationEntity; +import com.hnac.hzims.operational.station.enume.StationEnumConstants; +import com.hnac.hzims.operational.station.feign.IStationClient; +import lombok.AllArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springblade.core.log.exception.ServiceException; +import org.springblade.core.log.logger.BladeLogger; +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 javax.servlet.http.HttpServletResponse; +import java.util.HashMap; +import java.util.List; +import java.util.Optional; + +/** + * @author hx + * @version 1.0 + * @date 2023/3/6 10:18 + */ +@Service +@AllArgsConstructor +@Slf4j +public class FdpQuestionServiceImpl implements IFdpQuestionService { + + private final IStationClient stationClient; + private final FdpUrlConfiguration fdpUrlConfiguration; + private final BladeLogger logger; + + @Override + public boolean submitStationInfo(String stationCode, String stationDesc) { + R stationResult = stationClient.getStationByCode(stationCode); + if(stationResult.isSuccess()) { + StationEntity stationEntity = stationResult.getData(); + StationInfoReq infoReq = StationInfoReq.builder() + .stationId(stationCode) + .stationName(stationEntity.getName()) + .type(this.getStationType(stationEntity.getType())) + .stationDesc(Optional.ofNullable(stationDesc).orElse("")) + .build(); + if(Func.isNotEmpty(infoReq.getType())) { + HttpResponse httpResponse = HttpRequest.post(fdpUrlConfiguration.getSubmitStationInfo()) + .body(JSON.toJSONString(infoReq)) + .execute(); + if(httpResponse.getStatus() == HttpServletResponse.SC_OK && + "1".equals(JSONObject.parseObject(httpResponse.body()).getString("success"))) { + return true; + } + else { + throw new ServiceException("Fdp信息站点信息失败!"); + } + } + } + return false; + } + + @Override + public boolean deleteStationInfo(String stationId) { + HttpResponse response = HttpRequest.post(fdpUrlConfiguration.getDeleteStationInfo()).body(JSON.toJSONString( + new HashMap(1) {{ + put("stationId", stationId); + }} + )).execute(); + if(response.getStatus() == HttpServletResponse.SC_OK && + "1".equals(JSONObject.parseObject(response.body()).getString("success"))) { + return true; + } + else { + throw new ServiceException("Fdp删除站点信息失败!"); + } + } + + @Override + public List getDevsetQuestion(String deviceType, Integer stationType) { + List result = Lists.newArrayList(); + String getQuestionUrl = ""; + switch(deviceType) { + case FdpConstant.COMMON_DEVICE_TYPE: + getQuestionUrl = fdpUrlConfiguration.getGetStationQuestion(); + break; + case FdpConstant.SET_DEVICE_TYPE: + getQuestionUrl = fdpUrlConfiguration.getGetDevsetQuestion(); + break; + default: + break; + } + if(StringUtil.isNotBlank(getQuestionUrl)) { + HttpResponse response = HttpRequest.post(getQuestionUrl).body(JSON.toJSONString( + new HashMap(1) {{ + put("type", getStationType(stationType)); + }} + )).execute(); + if(response.getStatus() == HttpServletResponse.SC_OK && + "1".equals(JSONObject.parseObject(response.body()).getString("success"))) { + JSONObject responseJSON = JSONObject.parseObject(response.body()); + result = JSONArray.parseArray(responseJSON.getString("data"), DevsetQuestionResp.class); + } + } + return result; + } + + @Override + public boolean submitDeviceAnswer(SubmitAnswerReq submitAnswerReq) { + logger.info("hzims:equipment:submitDeviceAnswer",JSON.toJSONString(submitAnswerReq)); + String submitAnswerUrl = ""; + switch(submitAnswerReq.getDeviceType()) { + case FdpConstant.COMMON_DEVICE_TYPE: + submitAnswerUrl = fdpUrlConfiguration.getSubmitStationAnswer(); + break; + case FdpConstant.SET_DEVICE_TYPE: + submitAnswerUrl = fdpUrlConfiguration.getSubmitDevsetAnswer(); + break; + default: + break; + } + if(StringUtil.isNotBlank(submitAnswerUrl)) { + submitAnswerReq.setType(this.getStationType(submitAnswerReq.getStationType())); + HttpResponse response = HttpRequest.post(submitAnswerUrl).body(JSON.toJSONString(submitAnswerReq)).execute(); + return response.getStatus() == HttpServletResponse.SC_OK && + "1".equals(JSONObject.parseObject(response.body()).getString("success")); + } + return false; + } + + /** + * 根据站点类型获取Fdp的站点类型 + * @param stationType 站点管理站点类型 + * @return Fdp站点类型 + */ + private Integer getStationType(Integer stationType) { + if(StationEnumConstants.StationTypeEnum.STATION_TYPE_0.getStatus() == stationType) { + return FdpConstant.HYDROELECTRIC_STATION; + } + else if(StationEnumConstants.StationTypeEnum.STATION_TYPE_8.getStatus() == stationType) { + return FdpConstant.PUMP_STATION; + } + return null; + } +} From 844533707cd2dc1dfe993ef06cd03bf89a55f1b4 Mon Sep 17 00:00:00 2001 From: "H.X" <7458466+huangxing1023@user.noreply.gitee.com> Date: Wed, 8 Mar 2023 19:27:16 +0800 Subject: [PATCH 3/3] =?UTF-8?q?#=20=E6=99=BA=E8=83=BD=E8=AF=8A=E6=96=AD?= =?UTF-8?q?=E9=97=AE=E7=AD=94=E9=A2=98=E6=8E=A5=E5=8F=A3=E8=A1=A5=E5=85=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../hnac/hzims/fdp/config/FdpUrlConfiguration.java | 11 ++++++ .../fdp/controller/FdpQuestionController.java | 21 ++++++++++ .../hnac/hzims/fdp/request/SubmitAnswerReq.java | 6 +++ .../hzims/fdp/response/DevsetQuestionResp.java | 4 ++ .../hzims/fdp/service/IFdpQuestionService.java | 24 ++++++++++++ .../fdp/service/impl/FdpQuestionServiceImpl.java | 45 +++++++++++++++++++++- .../equipment/src/main/resources/db/1.0.0_0831.sql | 5 --- 7 files changed, 110 insertions(+), 6 deletions(-) delete mode 100644 hzims-service/equipment/src/main/resources/db/1.0.0_0831.sql diff --git a/hzims-service/equipment/src/main/java/com/hnac/hzims/fdp/config/FdpUrlConfiguration.java b/hzims-service/equipment/src/main/java/com/hnac/hzims/fdp/config/FdpUrlConfiguration.java index e058b38..c71a221 100644 --- a/hzims-service/equipment/src/main/java/com/hnac/hzims/fdp/config/FdpUrlConfiguration.java +++ b/hzims-service/equipment/src/main/java/com/hnac/hzims/fdp/config/FdpUrlConfiguration.java @@ -38,4 +38,15 @@ public class FdpUrlConfiguration { /**提交站点问题的答案**/ private String submitStationAnswer; + + /**实例化站点图谱**/ + private String generateGraphInstance; + + /**按物模型实例编号获取问题答案**/ + private String getInstanceAnswer; + + /**按物模型实例编号删除问题答案**/ + private String deleteInstanceAnswer; + + } diff --git a/hzims-service/equipment/src/main/java/com/hnac/hzims/fdp/controller/FdpQuestionController.java b/hzims-service/equipment/src/main/java/com/hnac/hzims/fdp/controller/FdpQuestionController.java index 4d693de..e9aa74d 100644 --- a/hzims-service/equipment/src/main/java/com/hnac/hzims/fdp/controller/FdpQuestionController.java +++ b/hzims-service/equipment/src/main/java/com/hnac/hzims/fdp/controller/FdpQuestionController.java @@ -1,5 +1,6 @@ package com.hnac.hzims.fdp.controller; +import com.alibaba.fastjson.JSONObject; import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; import com.hnac.hzims.fdp.request.SubmitAnswerReq; import com.hnac.hzims.fdp.response.DevsetQuestionResp; @@ -57,4 +58,24 @@ public class FdpQuestionController extends BladeController { return R.data(fdpQuestionService.submitDeviceAnswer(submitAnswerReq)); } + @GetMapping("/generateGraphInstance") + @ApiOperation("实例化站点图谱") + @ApiOperationSupport(order = 5) + public R generateGraphInstance(@RequestParam @ApiParam(value = "站点类型",required = true)Integer stationType,@RequestParam @ApiParam(value = "站点编码",required = true) String stationId) { + return R.data(fdpQuestionService.generateGraphInstance(stationType,stationId)); + } + + @DeleteMapping("/deleteInstanceAnswer/{instanceId}") + @ApiOperation("删除站点信息") + @ApiOperationSupport(order = 6) + public R deleteInstanceAnswer(@PathVariable @ApiParam("物模型实例编号") String instanceId) { + return R.status(fdpQuestionService.deleteInstanceAnswer(instanceId)); + } + + @GetMapping("/getInstanceAnswer/{instanceId}") + @ApiOperation("删除站点信息") + @ApiOperationSupport(order = 7) + public R> getInstanceAnswer(@PathVariable @ApiParam("物模型实例编号") String instanceId) { + return R.data(fdpQuestionService.getInstanceAnswer(instanceId)); + } } diff --git a/hzims-service/equipment/src/main/java/com/hnac/hzims/fdp/request/SubmitAnswerReq.java b/hzims-service/equipment/src/main/java/com/hnac/hzims/fdp/request/SubmitAnswerReq.java index f5aef16..31986e1 100644 --- a/hzims-service/equipment/src/main/java/com/hnac/hzims/fdp/request/SubmitAnswerReq.java +++ b/hzims-service/equipment/src/main/java/com/hnac/hzims/fdp/request/SubmitAnswerReq.java @@ -31,6 +31,12 @@ public class SubmitAnswerReq implements Serializable { @NotNull private String stationId; + @ApiModelProperty(value = "",required = true) + private String index; + + @ApiModelProperty(value = "物模型ID",required = true) + private String instanceId; + @ApiModelProperty(value = "设备类型",required = true) @NotNull private String deviceType; diff --git a/hzims-service/equipment/src/main/java/com/hnac/hzims/fdp/response/DevsetQuestionResp.java b/hzims-service/equipment/src/main/java/com/hnac/hzims/fdp/response/DevsetQuestionResp.java index 873da12..dabcfe1 100644 --- a/hzims-service/equipment/src/main/java/com/hnac/hzims/fdp/response/DevsetQuestionResp.java +++ b/hzims-service/equipment/src/main/java/com/hnac/hzims/fdp/response/DevsetQuestionResp.java @@ -28,6 +28,10 @@ public class DevsetQuestionResp implements Serializable { @JSONField(name = "NAME") private String name; + @ApiModelProperty("问题描述") + @JSONField(name = "INFO") + private String info; + @ApiModelProperty("问题类型。当前有“单选”、“多选”、“参数填空”、“数量填空”") @JSONField(name = "QTYPE") private String qType; diff --git a/hzims-service/equipment/src/main/java/com/hnac/hzims/fdp/service/IFdpQuestionService.java b/hzims-service/equipment/src/main/java/com/hnac/hzims/fdp/service/IFdpQuestionService.java index dfe1d35..2e5f062 100644 --- a/hzims-service/equipment/src/main/java/com/hnac/hzims/fdp/service/IFdpQuestionService.java +++ b/hzims-service/equipment/src/main/java/com/hnac/hzims/fdp/service/IFdpQuestionService.java @@ -1,8 +1,10 @@ package com.hnac.hzims.fdp.service; +import com.alibaba.fastjson.JSONObject; import com.hnac.hzims.fdp.request.SubmitAnswerReq; import com.hnac.hzims.fdp.response.DevsetQuestionResp; import io.swagger.annotations.ApiParam; +import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestParam; @@ -45,4 +47,26 @@ public interface IFdpQuestionService { */ boolean submitDeviceAnswer(@RequestBody SubmitAnswerReq submitAnswerReq); + /** + * 实例化站点图谱 + * @param stationType 站点类型 + * @param stationId 站点编码 + * @return + */ + boolean generateGraphInstance(Integer stationType,String stationId); + + /** + * 按物模型实例编号删除问题答案 + * @param instanceId 物模型实例编号 + * @return + */ + boolean deleteInstanceAnswer(String instanceId); + + /** + * 按物模型实例编号获取问题答案 + * @param instanceId 物模型实例编号 + * @return + */ + List getInstanceAnswer(String instanceId); + } 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 ba6d334..096acbe 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 @@ -118,7 +118,6 @@ public class FdpQuestionServiceImpl implements IFdpQuestionService { @Override public boolean submitDeviceAnswer(SubmitAnswerReq submitAnswerReq) { - logger.info("hzims:equipment:submitDeviceAnswer",JSON.toJSONString(submitAnswerReq)); String submitAnswerUrl = ""; switch(submitAnswerReq.getDeviceType()) { case FdpConstant.COMMON_DEVICE_TYPE: @@ -139,6 +138,50 @@ public class FdpQuestionServiceImpl implements IFdpQuestionService { return false; } + @Override + public boolean generateGraphInstance(Integer stationType, String stationId) { + Integer type = this.getStationType(stationType); + if(Func.isNotEmpty(type)) { + 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; + } + + @Override + public boolean deleteInstanceAnswer(String instanceId) { + HttpResponse httpResponse = HttpRequest.post(fdpUrlConfiguration.getDeleteInstanceAnswer()).body(JSON.toJSONString( + new HashMap(1) {{ + put("instanceId", instanceId); + }} + )).execute(); + return httpResponse.getStatus() == HttpServletResponse.SC_OK && + "1".equals(JSONObject.parseObject(httpResponse.body()).getString("success")); + } + + @Override + public List getInstanceAnswer(String instanceId) { + HttpResponse httpResponse = HttpRequest.post(fdpUrlConfiguration.getGetInstanceAnswer()).body( + JSON.toJSONString( + new HashMap(1){{ + put("instanceId",instanceId); + }} + ) + ).execute(); + JSONObject responseObject = JSONObject.parseObject(httpResponse.body()); + if(httpResponse.getStatus() == HttpServletResponse.SC_OK && + "1".equals(responseObject.getString("success"))) { + return JSONArray.parseArray(JSON.toJSONString(responseObject),JSONObject.class); + } + return Lists.newArrayList(); + } + /** * 根据站点类型获取Fdp的站点类型 * @param stationType 站点管理站点类型 diff --git a/hzims-service/equipment/src/main/resources/db/1.0.0_0831.sql b/hzims-service/equipment/src/main/resources/db/1.0.0_0831.sql deleted file mode 100644 index a2aa9fe..0000000 --- a/hzims-service/equipment/src/main/resources/db/1.0.0_0831.sql +++ /dev/null @@ -1,5 +0,0 @@ -ALTER TABLE hzims_fdp_device ADD FATHER_ID VARCHAR(40) COMMENT '智能诊断-PID'; - -ALTER TABLE hzims_em_info ADD HOME_PAGE_DISPLAY CHAR(2) DEFAULT '0' COMMENT '首页展示:0否,1是'; - -UPDATE `hzims_em_info` SET HOME_PAGE_DISPLAY = 1 WHERE NUMBER IN ('HZ111','HZ112','HZ113','HZ121','HZ122','HZ123','HZ131','HZ132');