From 94d21ed1ede2b1596aa35e8fa41ae1b9d46c3025 Mon Sep 17 00:00:00 2001 From: 潘志宝 <979469083@qq.com> Date: 星期二, 18 三月 2025 17:01:01 +0800 Subject: [PATCH] Merge remote-tracking branch 'origin/master' --- ansteel-biz/src/main/java/com/iailab/module/ansteel/common/constant/CommonConstant.java | 72 ++++ ansteel-biz/src/main/java/com/iailab/module/ansteel/common/enums/PreLineTypeEnum.java | 33 ++ ansteel-api/src/main/java/com/iailab/module/enums/ApiConstants.java | 20 + ansteel-biz/src/main/java/com/iailab/module/ansteel/util/ApiSecurityUtils.java | 82 +++++ ansteel-biz/src/main/java/com/iailab/module/ansteel/api/entity/PowerRunStateEntity.java | 60 +++ pom.xml | 2 /dev/null | 1 ansteel-api/src/main/java/com/iailab/module/api/mcs/dto/ApiPointValueDTO.java | 22 + ansteel-biz/src/main/java/com/iailab/module/ansteel/api/McsServiceImpl.java | 189 +++++++++++ ansteel-api/src/main/java/com/iailab/module/api/package-info.java | 1 ansteel-api/src/main/java/com/iailab/module/enums/package-info.java | 1 ansteel-api/pom.xml | 7 ansteel-biz/src/main/java/com/iailab/module/ansteel/api/vo/ItemVO.java | 41 ++ ansteel-biz/src/main/java/com/iailab/module/ansteel/api/controller/McsController.java | 53 +++ ansteel-biz/src/main/java/com/iailab/module/ansteel/api/entity/ProductProcessEntity.java | 56 +++ ansteel-api/src/main/java/com/iailab/module/api/mcs/AnSteelApi.java | 36 ++ ansteel-api/src/main/java/com/iailab/module/api/mcs/dto/PowerRunStateDTO.java | 26 + ansteel-biz/src/main/java/com/iailab/module/ansteel/api/dao/PowerRunStateDao.java | 12 ansteel-api/src/main/java/com/iailab/module/api/mcs/dto/PreDataChartRespVO.java | 40 ++ ansteel-api/src/main/java/com/iailab/module/api/mcs/dto/AlarmMessageRespDTO.java | 70 ++++ ansteel-api/src/main/java/com/iailab/module/api/mcs/dto/PreDataViewDTO.java | 116 +++++++ ansteel-biz/pom.xml | 10 22 files changed, 943 insertions(+), 7 deletions(-) diff --git a/ansteel-api/pom.xml b/ansteel-api/pom.xml index 04f95b8..5edf0db 100644 --- a/ansteel-api/pom.xml +++ b/ansteel-api/pom.xml @@ -42,6 +42,13 @@ <artifactId>spring-cloud-starter-openfeign</artifactId> <optional>true</optional> </dependency> + <dependency> + <groupId>com.iailab</groupId> + <artifactId>iailab-module-model-api</artifactId> + <version>1.0.0</version> + <scope>compile</scope> + </dependency> + </dependencies> diff --git a/ansteel-api/src/main/java/com/iailab/module/api/mcs/AnSteelApi.java b/ansteel-api/src/main/java/com/iailab/module/api/mcs/AnSteelApi.java new file mode 100644 index 0000000..3082460 --- /dev/null +++ b/ansteel-api/src/main/java/com/iailab/module/api/mcs/AnSteelApi.java @@ -0,0 +1,36 @@ +package com.iailab.module.api.mcs; + +import com.iailab.module.api.mcs.dto.PowerRunStateDTO; +import com.iailab.module.api.mcs.dto.PreDataChartRespVO; +import com.iailab.module.enums.ApiConstants; +import com.iailab.module.model.api.mcs.dto.PreDataSingleChartReqVO; +import com.iailab.module.model.api.mcs.dto.PreDataSingleChartRespVO; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.tags.Tag; +import org.springframework.cloud.openfeign.FeignClient; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; + +import java.util.List; + +/** + * @author lirm + * @Description + * @createTime 2025年03月17日 + */ +@FeignClient(name = ApiConstants.NAME) +@Tag(name = "RPC 服务 - 信息接口") +public interface AnSteelApi { + + String PREFIX = ApiConstants.PREFIX + "/api/mcs"; + + @GetMapping(PREFIX + "/power-run-state/list") + @Operation(summary = "发电厂机组运行情况") + List<PowerRunStateDTO> getPowerRunState(); + + @PostMapping(PREFIX + "/predict-data/charts") + @Operation(summary = "预测数据图表") + PreDataChartRespVO getPreDataChart(@RequestBody PreDataSingleChartReqVO reqVO); + +} \ No newline at end of file diff --git a/ansteel-api/src/main/java/com/iailab/module/api/mcs/dto/AlarmMessageRespDTO.java b/ansteel-api/src/main/java/com/iailab/module/api/mcs/dto/AlarmMessageRespDTO.java new file mode 100644 index 0000000..c5a5fca --- /dev/null +++ b/ansteel-api/src/main/java/com/iailab/module/api/mcs/dto/AlarmMessageRespDTO.java @@ -0,0 +1,70 @@ +package com.iailab.module.api.mcs.dto; + +/** + * @author PanZhibao + * @Description + * @createTime 2024年08月29日 + */ + +import com.fasterxml.jackson.annotation.JsonFormat; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import java.io.Serializable; +import java.math.BigDecimal; +import java.util.Date; + +/** + * @author PanZhibao + * @Description + * @createTime 2024年08月29日 + */ +@Schema(description = "RPC 模型 - 预警消息 DTO") +@Data +public class AlarmMessageRespDTO implements Serializable { + + private static final long serialVersionUID = 1L; + + @Schema(description = "ID") + private String id; + + @Schema(description = "配置ID") + private String configId; + + @Schema(description = "消息标题") + private String title; + + @Schema(description = "消息内容") + private String content; + + @Schema(description = "监控对象") + private String alarmObj; + + @Schema(description = "监控点位ID") + private String pointId; + + @Schema(description = "预测项ID") + private String itemId; + + @Schema(description = "当前值") + private BigDecimal currentValue; + + @Schema(description = "超出时间") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") + private Date outTime; + + @Schema(description = "超出值") + private BigDecimal outValue; + + @Schema(description = "预警类型") + private String alarmType; + + @Schema(description = "预警时间") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") + private Date alarmTime; + + @Schema(description = "创建时间") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") + private Date createTime; + +} \ No newline at end of file diff --git a/ansteel-api/src/main/java/com/iailab/module/api/mcs/dto/ApiPointValueDTO.java b/ansteel-api/src/main/java/com/iailab/module/api/mcs/dto/ApiPointValueDTO.java new file mode 100644 index 0000000..fdcbe4b --- /dev/null +++ b/ansteel-api/src/main/java/com/iailab/module/api/mcs/dto/ApiPointValueDTO.java @@ -0,0 +1,22 @@ +package com.iailab.module.api.mcs.dto; + +import com.fasterxml.jackson.annotation.JsonFormat; +import lombok.Data; + +import java.io.Serializable; +import java.util.Date; + +/** + * @author PanZhibao + * @Description + * @createTime 2024年08月19日 + */ +@Data +public class ApiPointValueDTO implements Serializable { + private static final long serialVersionUID = 1L; + + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") + private Date t; + + private double v; +} \ No newline at end of file diff --git a/ansteel-api/src/main/java/com/iailab/module/api/mcs/dto/PowerRunStateDTO.java b/ansteel-api/src/main/java/com/iailab/module/api/mcs/dto/PowerRunStateDTO.java new file mode 100644 index 0000000..88c5309 --- /dev/null +++ b/ansteel-api/src/main/java/com/iailab/module/api/mcs/dto/PowerRunStateDTO.java @@ -0,0 +1,26 @@ +package com.iailab.module.api.mcs.dto; + +import lombok.Data; + +import java.io.Serializable; + +/** + * @author lirm + * @date 2025年03月13日 + */ +@Data +public class PowerRunStateDTO implements Serializable { + + private static final long serialVersionUID = 1L; + + private String id; + private String machineName; + private String qhRate; + private String fhRate; + private String gasTotal; + private String gasCost; + private String gasSurplus; + private String bfg; + private String ldg; + private String cog; +} diff --git a/ansteel-api/src/main/java/com/iailab/module/api/mcs/dto/PreDataChartRespVO.java b/ansteel-api/src/main/java/com/iailab/module/api/mcs/dto/PreDataChartRespVO.java new file mode 100644 index 0000000..318d4a8 --- /dev/null +++ b/ansteel-api/src/main/java/com/iailab/module/api/mcs/dto/PreDataChartRespVO.java @@ -0,0 +1,40 @@ +package com.iailab.module.api.mcs.dto; + +import com.fasterxml.jackson.annotation.JsonFormat; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import java.io.Serializable; +import java.util.Date; +import java.util.List; + +/** + * @author PanZhibao + * @Description + * @createTime 2024年11月18日 + */ +@Data +public class PreDataChartRespVO implements Serializable { + private static final long serialVersionUID = 1L; + + @Schema(description = "预测时间") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") + private Date predictTime; + + @Schema(description = "开始时间") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") + private Date startTime; + + @Schema(description = "结束时间") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") + private Date endTime; + + @Schema(description = "图例") + private List<String> legend; + + @Schema(description = "X轴数据") + private List<String> categories; + + private PreDataViewDTO dataView; + +} \ No newline at end of file diff --git a/ansteel-api/src/main/java/com/iailab/module/api/mcs/dto/PreDataViewDTO.java b/ansteel-api/src/main/java/com/iailab/module/api/mcs/dto/PreDataViewDTO.java new file mode 100644 index 0000000..621f060 --- /dev/null +++ b/ansteel-api/src/main/java/com/iailab/module/api/mcs/dto/PreDataViewDTO.java @@ -0,0 +1,116 @@ +package com.iailab.module.api.mcs.dto; + +import com.fasterxml.jackson.annotation.JsonFormat; +import com.iailab.module.model.api.mcs.dto.AlarmMessageRespDTO; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import java.io.Serializable; +import java.math.BigDecimal; +import java.util.Date; +import java.util.List; + +/** + * @author PanZhibao + * @Description + * @createTime 2024年08月26日 + */ +@Schema(description = "RPC 模型 - 预测数据 DTO") +@Data +public class PreDataViewDTO implements Serializable { + private static final long serialVersionUID = 1L; + + @Schema(description = "预测项ID") + private String itemId; + + @Schema(description = "预测项名称") + private String itemName; + + @Schema(description = "输出ID") + private String outId; + + @Schema(description = "输出结果") + private String resultstr; + + @Schema(description = "输出结果") + private String resultName; + + @Schema(description = "预测时间") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") + private Date predictTime; + + @Schema(description = "量程上限") + private BigDecimal rangeH; + + @Schema(description = "量程下限") + private BigDecimal rangeL; + + @Schema(description = "柜位上限") + private BigDecimal deadLineH; + + @Schema(description = "柜位下限") + private BigDecimal deadLineL; + + @Schema(description = "运行上限") + private BigDecimal limitH; + + @Schema(description = "运行下限") + private BigDecimal limitL; + + @Schema(description = "动态上限") + private List<ApiPointValueDTO> trendsDataH; + + @Schema(description = "动态下限") + private List<ApiPointValueDTO> trendsDataL; + + @Schema(description = "当前") + private BigDecimal currValue; + + @Schema(description = "最大值") + private BigDecimal maxValue; + + @Schema(description = "最小值") + private BigDecimal minValue; + + @Schema(description = "历史最大值") + private BigDecimal hisMax; + + @Schema(description = "历史最小值") + private BigDecimal hisMin; + + @Schema(description = "历史最大值") + private BigDecimal hisCumulant; + + @Schema(description = "预测最大值") + private BigDecimal preMax; + + @Schema(description = "预测最小值") + private BigDecimal preMin; + + @Schema(description = "预测最后一个值") + private BigDecimal preLast; + + @Schema(description = "预测累计值") + private BigDecimal preCumulant; + + @Schema(description = "真实值") + private List<Object[]> realData; + + @Schema(description = "T+L/N预测值") + private List<Object[]> preData; + + @Schema(description = "预警信息") + private List<AlarmMessageRespDTO> alarmList; + + @Schema(description = "预警信息") + private String alarmMessage; + + @Schema(description = "展示线类型") + private String lineType; + + @Schema(description = "累计真实值") + private List<Object[]> cumulantRealData; + + @Schema(description = "累计预测值") + private List<Object[]> cumulantPreData; +} \ No newline at end of file diff --git a/ansteel-api/src/main/java/com/iailab/module/api/package-info.java b/ansteel-api/src/main/java/com/iailab/module/api/package-info.java new file mode 100644 index 0000000..7f2ef16 --- /dev/null +++ b/ansteel-api/src/main/java/com/iailab/module/api/package-info.java @@ -0,0 +1 @@ +package com.iailab.module.api; \ No newline at end of file diff --git a/ansteel-api/src/main/java/com/iailab/module/enums/ApiConstants.java b/ansteel-api/src/main/java/com/iailab/module/enums/ApiConstants.java new file mode 100644 index 0000000..6ad39b7 --- /dev/null +++ b/ansteel-api/src/main/java/com/iailab/module/enums/ApiConstants.java @@ -0,0 +1,20 @@ +package com.iailab.module.enums; + +import com.iailab.framework.common.enums.RpcConstants; + +/** + * @author PanZhibao + * @Description + * @createTime 2024年08月26日 + */ +public class ApiConstants { + /** + * 服务名 + * + * 注意,需要保证和 spring.application.name 保持一致 + */ + public static final String NAME = "ansteel-server"; + + public static final String PREFIX = RpcConstants.RPC_API_PREFIX + "/ansteel"; + +} \ No newline at end of file diff --git a/ansteel-api/src/main/java/com/iailab/module/enums/package-info.java b/ansteel-api/src/main/java/com/iailab/module/enums/package-info.java new file mode 100644 index 0000000..59fc466 --- /dev/null +++ b/ansteel-api/src/main/java/com/iailab/module/enums/package-info.java @@ -0,0 +1 @@ +package com.iailab.module.enums; \ No newline at end of file diff --git a/ansteel-api/src/main/java/com/iailab/module/sms/api/package-info.java b/ansteel-api/src/main/java/com/iailab/module/sms/api/package-info.java deleted file mode 100644 index 78b9dea..0000000 --- a/ansteel-api/src/main/java/com/iailab/module/sms/api/package-info.java +++ /dev/null @@ -1 +0,0 @@ -package com.iailab.module.ansteel.api; \ No newline at end of file diff --git a/ansteel-api/src/main/java/com/iailab/module/sms/enums/package-info.java b/ansteel-api/src/main/java/com/iailab/module/sms/enums/package-info.java deleted file mode 100644 index 8f422d0..0000000 --- a/ansteel-api/src/main/java/com/iailab/module/sms/enums/package-info.java +++ /dev/null @@ -1 +0,0 @@ -package com.iailab.module.ansteel.enums; \ No newline at end of file diff --git a/ansteel-biz/pom.xml b/ansteel-biz/pom.xml index b678ed3..c172627 100644 --- a/ansteel-biz/pom.xml +++ b/ansteel-biz/pom.xml @@ -19,11 +19,6 @@ <dependencies> <!-- 依赖服务 --> -<!-- <dependency>--> -<!-- <groupId>com.iailab</groupId>--> -<!-- <artifactId>ansteel-api</artifactId>--> -<!-- <version>${revision}</version>--> -<!-- </dependency>--> <dependency> <groupId>com.iailab</groupId> <artifactId>iailab-module-infra-api</artifactId> @@ -125,6 +120,11 @@ <groupId>com.iailab</groupId> <artifactId>iailab-common-mq</artifactId> </dependency> + <dependency> + <groupId>com.iailab</groupId> + <artifactId>ansteel-api</artifactId> + <version>1.0.0</version> + </dependency> </dependencies> diff --git a/ansteel-biz/src/main/java/com/iailab/module/ansteel/api/McsServiceImpl.java b/ansteel-biz/src/main/java/com/iailab/module/ansteel/api/McsServiceImpl.java new file mode 100644 index 0000000..8cb1be3 --- /dev/null +++ b/ansteel-biz/src/main/java/com/iailab/module/ansteel/api/McsServiceImpl.java @@ -0,0 +1,189 @@ +package com.iailab.module.ansteel.api; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.iailab.framework.common.util.date.DateUtils; +import com.iailab.framework.common.util.object.ConvertUtils; +import com.iailab.module.ansteel.api.dao.PowerRunStateDao; +import com.iailab.module.ansteel.common.constant.CommonConstant; +import com.iailab.module.ansteel.common.enums.PreLineTypeEnum; +import com.iailab.module.api.mcs.AnSteelApi; +import com.iailab.module.api.mcs.dto.ApiPointValueDTO; +import com.iailab.module.api.mcs.dto.PowerRunStateDTO; +import com.iailab.module.api.mcs.dto.PreDataChartRespVO; +import com.iailab.module.api.mcs.dto.PreDataViewDTO; +import com.iailab.module.data.api.point.DataPointApi; +import com.iailab.module.data.api.point.dto.ApiPointValueQueryDTO; +import com.iailab.module.model.api.mcs.McsApi; +import com.iailab.module.model.api.mcs.dto.ChartParamDTO; +import com.iailab.module.model.api.mcs.dto.MmItemOutputDTO; +import com.iailab.module.model.api.mcs.dto.PreDataSingleChartReqVO; +import com.iailab.module.model.api.mcs.dto.PredictItemVO; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.util.CollectionUtils; +import org.springframework.util.ObjectUtils; + +import java.math.BigDecimal; +import java.util.*; +import java.util.stream.Collectors; + +@Slf4j +@Service +public class McsServiceImpl implements AnSteelApi { + + @Autowired + private DataPointApi dataPointApi; + + @Autowired + private McsApi mcsApi; + + @Autowired + private PowerRunStateDao powerRunStateDao; + + @Override + public List<PowerRunStateDTO> getPowerRunState() { + List<PowerRunStateDTO> list = ConvertUtils.sourceToTarget(powerRunStateDao.selectList(new QueryWrapper<>()), PowerRunStateDTO.class); + if (!CollectionUtils.isEmpty(list)) { + list.stream().map(item -> { + StringBuffer sb = new StringBuffer(); + sb.append(item.getQhRate()); + sb.append(","); + sb.append(item.getFhRate()); + sb.append(","); + sb.append(item.getGasTotal()); + sb.append(","); + sb.append(item.getGasCost()); + sb.append(","); + sb.append(item.getGasSurplus()); + sb.append(","); + sb.append(item.getBfg()); + sb.append(","); + sb.append(item.getLdg()); + sb.append(","); + sb.append(item.getCog()); + String[] arr = sb.toString().split(","); + Map<String, Object> adjValue = dataPointApi.queryPointsRealValue(Arrays.asList(arr)); + item.setQhRate(ObjectUtils.isEmpty(adjValue.get(arr[0])) ? "0" : new BigDecimal(adjValue.get(arr[0]).toString()).setScale(2, BigDecimal.ROUND_HALF_UP).toString()); + item.setFhRate(ObjectUtils.isEmpty(adjValue.get(arr[1])) ? "0" : new BigDecimal(adjValue.get(arr[1]).toString()).setScale(2, BigDecimal.ROUND_HALF_UP).toString()); + item.setGasTotal(ObjectUtils.isEmpty(adjValue.get(arr[2])) ? "0" : new BigDecimal(adjValue.get(arr[2]).toString()).setScale(2, BigDecimal.ROUND_HALF_UP).toString()); + item.setGasCost(ObjectUtils.isEmpty(adjValue.get(arr[3])) ? "0" : new BigDecimal(adjValue.get(arr[3]).toString()).setScale(2, BigDecimal.ROUND_HALF_UP).toString()); + item.setGasSurplus(ObjectUtils.isEmpty(adjValue.get(arr[4])) ? "0" : new BigDecimal(adjValue.get(arr[4]).toString()).setScale(2, BigDecimal.ROUND_HALF_UP).toString()); + item.setBfg(ObjectUtils.isEmpty(adjValue.get(arr[5])) ? "0" : new BigDecimal(adjValue.get(arr[5]).toString()).setScale(2, BigDecimal.ROUND_HALF_UP).toString()); + item.setLdg(ObjectUtils.isEmpty(adjValue.get(arr[6])) ? "0" : new BigDecimal(adjValue.get(arr[6]).toString()).setScale(2, BigDecimal.ROUND_HALF_UP).toString()); + item.setCog(ObjectUtils.isEmpty(adjValue.get(arr[7])) ? "0" : new BigDecimal(adjValue.get(arr[7]).toString()).setScale(2, BigDecimal.ROUND_HALF_UP).toString()); + + return item; + }).collect(Collectors.toList()); + } + return list; + } + + @Override + public PreDataChartRespVO getPreDataChart(PreDataSingleChartReqVO reqVO) { + Map<String, String> tMap = new HashMap<>(); + List<ChartParamDTO> list = mcsApi.getChartParamList(reqVO.getChartCode()); + if (CollectionUtils.isEmpty(list)) { + return null; + } + list.forEach(item -> { + tMap.put(item.getParamCode(), item.getParamValue()); + }); + String itemCode = tMap.get(CommonConstant.ITEM_CODE); + if (itemCode == null) { + return null; + } + String resultStr = tMap.get(CommonConstant.RESULT_STR); + if (resultStr == null) { + return null; + } + String resultIndex = tMap.get(CommonConstant.RESULT_INDEX); + if (resultIndex == null) { + return null; + } + PredictItemVO predictItem = mcsApi.getPredictItemByItemNo(itemCode); + if (predictItem == null || predictItem.getLastTime() == null) { + return null; + } + String timeFormat = StringUtils.isBlank(reqVO.getTimeFormat()) ? DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND : reqVO.getTimeFormat(); + PreLineTypeEnum lineType = tMap.get(CommonConstant.LINE_TYPE) == null ? PreLineTypeEnum.TN : PreLineTypeEnum.getEumByCode(tMap.get(CommonConstant.LINE_TYPE)); + int lengthLeft = tMap.get(CommonConstant.LENGTH_LEFT) == null ? predictItem.getPredictLength() : new BigDecimal(tMap.get(CommonConstant.LENGTH_LEFT)).intValue(); + int lengthRight = tMap.get(CommonConstant.LENGTH_RIGHT) == null ? predictItem.getPredictLength() : new BigDecimal(tMap.get(CommonConstant.LENGTH_RIGHT)).intValue(); + String trendsDataH = tMap.get(CommonConstant.TRENDSDATA_H) == null ? null : tMap.get(CommonConstant.TRENDSDATA_H); + String trendsDataL = tMap.get(CommonConstant.TRENDSDATA_L) == null ? null : tMap.get(CommonConstant.TRENDSDATA_L); + + Date[] timeArray = calResultTime(predictItem, reqVO.getStartTime(), reqVO.getEndTime(), lengthLeft, lengthRight); + Date predictTime = timeArray[0]; + Date startTime = timeArray[1]; + Date endTime = timeArray[2]; + + PreDataChartRespVO result = ConvertUtils.sourceToTarget(mcsApi.getPreDataSingleChart(reqVO), PreDataChartRespVO.class); + PreDataViewDTO dataView = result.getDataView(); + if(trendsDataH != null) { + ApiPointValueQueryDTO pointValueQueryDTO = new ApiPointValueQueryDTO(); + pointValueQueryDTO.setPointNo(trendsDataH); + List<ApiPointValueDTO> trendsDataHList = ConvertUtils.sourceToTarget(dataPointApi.queryPointHistoryValue(pointValueQueryDTO), ApiPointValueDTO.class); + dataView.setTrendsDataH(trendsDataHList); + } + if(trendsDataL != null) { + ApiPointValueQueryDTO pointValueQueryDTO = new ApiPointValueQueryDTO(); + pointValueQueryDTO.setPointNo(trendsDataL); + List<ApiPointValueDTO> trendsDataLList = ConvertUtils.sourceToTarget(dataPointApi.queryPointHistoryValue(pointValueQueryDTO), ApiPointValueDTO.class); + dataView.setTrendsDataL(trendsDataLList); + } + MmItemOutputDTO outputDTO = mcsApi.getItemOutputByItemid(predictItem.getId(), resultStr, resultIndex); + switch (lineType) { + case TN: + if(reqVO.getChartCode().equals(CommonConstant.LDG_CHARRCODE)){ + dataView.setPreData(mcsApi.getItemResult(outputDTO.getId(), predictTime, endTime, timeFormat)); + }else{ + dataView.setPreData(mcsApi.getItemResult(outputDTO.getId(), startTime, endTime, timeFormat)); + } + + break; + case TL: + if(reqVO.getChartCode().equals(CommonConstant.LDG_CHARRCODE)){ + dataView.setPreData(mcsApi.getItemResultLastPoint(outputDTO.getId(), predictTime, endTime, timeFormat)); + }else{ + dataView.setPreData(mcsApi.getItemResultLastPoint(outputDTO.getId(), startTime, endTime, timeFormat)); + } + break; + default: + break; + } + result.setDataView(dataView); + return result; + } + + private Date[] calResultTime(PredictItemVO predictItem, Date startTimeReq, Date endTimeReq, int lengthLeft, int lengthRight) { + Date[] result = new Date[3]; + Date predictTime = predictItem.getLastTime(); + Integer granularity = predictItem.getGranularity(); + Date startTime = startTimeReq; + if (startTime == null) { + Calendar calendar = Calendar.getInstance(); + calendar.setTime(predictItem.getLastTime()); + calendar.add(Calendar.SECOND, -1 * lengthLeft * granularity); + startTime = calendar.getTime(); + } + Date endTime = endTimeReq; + if (endTime == null) { + Calendar calendar = Calendar.getInstance(); + calendar.setTime(predictItem.getLastTime()); + calendar.add(Calendar.SECOND, lengthRight * granularity); + endTime = calendar.getTime(); + } + if (endTime.getTime() <= startTime.getTime()) { + Calendar calendar = Calendar.getInstance(); + calendar.setTime(startTime); + calendar.add(Calendar.SECOND, lengthRight * granularity); + endTime = calendar.getTime(); + } + result[0] = predictTime; + result[1] = startTime; + result[2] = endTime; + return result; + } + +} \ No newline at end of file diff --git a/ansteel-biz/src/main/java/com/iailab/module/ansteel/api/controller/McsController.java b/ansteel-biz/src/main/java/com/iailab/module/ansteel/api/controller/McsController.java new file mode 100644 index 0000000..650a9f5 --- /dev/null +++ b/ansteel-biz/src/main/java/com/iailab/module/ansteel/api/controller/McsController.java @@ -0,0 +1,53 @@ +package com.iailab.module.ansteel.api.controller; + +import com.iailab.framework.common.pojo.CommonResult; +import com.iailab.module.ansteel.util.ApiSecurityUtils; +import com.iailab.module.api.mcs.AnSteelApi; +import com.iailab.module.api.mcs.dto.PowerRunStateDTO; +import com.iailab.module.api.mcs.dto.PreDataChartRespVO; +import com.iailab.module.model.api.mcs.dto.PreDataItemChartReqVO; +import com.iailab.module.model.api.mcs.dto.PreDataItemChartRespVO; +import com.iailab.module.model.api.mcs.dto.PreDataSingleChartReqVO; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.tags.Tag; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import javax.annotation.Resource; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.util.List; +import java.util.Map; + +import static com.iailab.framework.common.pojo.CommonResult.success; + +/** + * @author: lirm + * @date: 2025/03/17 + **/ +@Tag(name = "发电厂机组运行情况") +@RestController +@RequestMapping("/ansteel/api/mcs") +public class McsController { + + @Autowired + private AnSteelApi anSteelApi; + + @Resource + private ApiSecurityUtils apiSecurityUtils; + + @GetMapping("/power-run-state/list") + public CommonResult<List<PowerRunStateDTO>> list(@RequestParam Map<String, Object> params) { + List<PowerRunStateDTO> list = anSteelApi.getPowerRunState(); + return success(list); + } + + @PostMapping("/predict-data/charts") + @Operation(summary = "预测数据图表") + public CommonResult<PreDataChartRespVO> getPreDataChart(HttpServletResponse response, HttpServletRequest request, @RequestBody PreDataSingleChartReqVO reqVO) throws Exception { + apiSecurityUtils.validate(request); + PreDataChartRespVO respVO = anSteelApi.getPreDataChart(reqVO); + return CommonResult.success(respVO); + } + +} \ No newline at end of file diff --git a/ansteel-biz/src/main/java/com/iailab/module/ansteel/api/dao/PowerRunStateDao.java b/ansteel-biz/src/main/java/com/iailab/module/ansteel/api/dao/PowerRunStateDao.java new file mode 100644 index 0000000..c8eb3db --- /dev/null +++ b/ansteel-biz/src/main/java/com/iailab/module/ansteel/api/dao/PowerRunStateDao.java @@ -0,0 +1,12 @@ +package com.iailab.module.ansteel.api.dao; + +import com.iailab.framework.common.dao.BaseDao; +import com.iailab.framework.tenant.core.db.dynamic.TenantDS; +import com.iailab.module.ansteel.api.entity.PowerRunStateEntity; +import org.apache.ibatis.annotations.Mapper; + +@TenantDS +@Mapper +public interface PowerRunStateDao extends BaseDao<PowerRunStateEntity> { + +} diff --git a/ansteel-biz/src/main/java/com/iailab/module/ansteel/api/entity/PowerRunStateEntity.java b/ansteel-biz/src/main/java/com/iailab/module/ansteel/api/entity/PowerRunStateEntity.java new file mode 100644 index 0000000..dab3187 --- /dev/null +++ b/ansteel-biz/src/main/java/com/iailab/module/ansteel/api/entity/PowerRunStateEntity.java @@ -0,0 +1,60 @@ +package com.iailab.module.ansteel.api.entity; + +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.Data; + +import java.io.Serializable; + +/** + * @description: 发电厂机组运行情况 + * @author: lirm + * @date: 2025/03/13 + **/ +@Data +@TableName("t_power_run_state") +public class PowerRunStateEntity implements Serializable { + private static final long serialVersionUID = 1L; + + /** + * id + */ + @TableId + private String id; + /** + * 机组名称 + */ + private String machineName; + /** + * 气耗率 + */ + private String qhRate; + /** + * 负荷率 + */ + private String fhRate; + /** + * 煤气总消耗 + */ + private String gasTotal; + /** + * 煤气可消纳量 + */ + private String gasCost; + /** + * 煤气剩余调节量 + */ + private String gasSurplus; + /** + * BFG + */ + private String bfg; + /** + * COG + */ + private String ldg; + /** + * LDG + */ + private String cog; +} \ No newline at end of file diff --git a/ansteel-biz/src/main/java/com/iailab/module/ansteel/api/entity/ProductProcessEntity.java b/ansteel-biz/src/main/java/com/iailab/module/ansteel/api/entity/ProductProcessEntity.java new file mode 100644 index 0000000..c1a2cb4 --- /dev/null +++ b/ansteel-biz/src/main/java/com/iailab/module/ansteel/api/entity/ProductProcessEntity.java @@ -0,0 +1,56 @@ +package com.iailab.module.ansteel.api.entity; + +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.Data; + +import java.io.Serializable; + +/** + * @description: 工序 + * @author: lirm + * @date: 2025/03/13 + **/ +@Data +@TableName("t_product_process") +public class ProductProcessEntity implements Serializable { + private static final long serialVersionUID = 1L; + + /** + * id + */ + @TableId + private String id; + /** + * 工序名称 + */ + private String name; + /** + * BFG单耗 + */ + private String bfgCost; + /** + * BFG产率 + */ + private String bfgProdRate; + /** + * COG单耗 + */ + private String cogCost; + /** + * COG产率 + */ + private String cogProdRate; + /** + * LDG单耗 + */ + private String ldgCost; + /** + * LDG产率 + */ + private String ldgProdRate; + /** + * 混合煤气单耗 + */ + private String gasCost; +} \ No newline at end of file diff --git a/ansteel-biz/src/main/java/com/iailab/module/ansteel/api/vo/ItemVO.java b/ansteel-biz/src/main/java/com/iailab/module/ansteel/api/vo/ItemVO.java new file mode 100644 index 0000000..4362d09 --- /dev/null +++ b/ansteel-biz/src/main/java/com/iailab/module/ansteel/api/vo/ItemVO.java @@ -0,0 +1,41 @@ +package com.iailab.module.ansteel.api.vo; + +import lombok.Data; + +import java.util.Date; + +/** + * @author PanZhibao + * @Description + * @createTime 2024年09月01日 + */ +@Data +public class ItemVO { + private String id; + private String itemNo; + private String itemName; + private String itemType; + private Integer predictLength; + private Integer granularity; + private Integer status; + private Integer isFuse; + private Integer predictPhase; + private Integer workChecked; + private Integer isDisplay; + private Integer unitTransFactor; + + /** + * 保留的预测点位 (T+2 则n=2, T+30则n=30, T+n则表示从最后点位开始,n=预测长度;n由系统配置得出) + */ + private String saveIndex; + + /** + * 项目id + */ + private String mpkProjectId; + + /** + * 最后运行时间 + */ + private Date lastTime; +} \ No newline at end of file diff --git a/ansteel-biz/src/main/java/com/iailab/module/ansteel/common/constant/CommonConstant.java b/ansteel-biz/src/main/java/com/iailab/module/ansteel/common/constant/CommonConstant.java new file mode 100644 index 0000000..0f06e14 --- /dev/null +++ b/ansteel-biz/src/main/java/com/iailab/module/ansteel/common/constant/CommonConstant.java @@ -0,0 +1,72 @@ +package com.iailab.module.ansteel.common.constant; + + +import java.math.BigDecimal; + +/** + * @Description: 通用常量 + */ +public interface CommonConstant { + + int IS_ENABLE = 1; + + BigDecimal BAD_VALUE = new BigDecimal("-2"); + + BigDecimal ZERO_VALUE = new BigDecimal("0"); + + String MDK_SUFFIX = ".miail"; + + String MDK_RESULT = "result"; + + String MDK_STATUS_CODE = "status_code"; + + String MDK_STATUS_100 = "100"; + + String MDK_STATUS_500 = "500 "; + + String RANGE_H = "RANGE_H"; + + String RANGE_L = "RANGE_L"; + + String LIMIT_H = "LIMIT_H"; + + String LIMIT_L = "LIMIT_L"; + + String TRENDSDATA_H = "TRENDSDATA_H"; + + String TRENDSDATA_L = "TRENDSDATA_L"; + + String ITEM_CODE = "ITEM_CODE"; + + String ALARM_OBJ = "ALARM_OBJ"; + + String PLAN_ITEM_LIST = "PLAN_ITEM_LIST"; + + String RESULT_STR = "RESULT_STR"; + + String RESULT_INDEX = "RESULT_INDEX"; + + String LENGTH_LEFT = "LENGTH_LEFT"; + + String LENGTH_RIGHT = "LENGTH_RIGHT"; + + String ADJ_VALUE_POINT = "ADJ_VALUE_POINT"; + + String ADJ_VALUE_ARR_POINT = "ADJ_VALUE_ARR_POINT"; + + // 趋势预测曲线类型,0:展示T+N,1:展示T+L, + String LINE_TYPE = "LINE_TYPE"; + + // 模型输出预测值 + String OUT_PREDICT_VALUES = "predictValues"; + + // 模型输出优化值 + String OUT_OPT_VALUES = "optValues"; + + // 模型输出调整值 + String OUT_ADJUST_VALUES = "adjustValues"; + + String BFG_CHARRCODE = "BFG_PRED01"; + String COG_CHARRCODE = "COG_PRED01"; + String LDG_CHARRCODE = "LDG_PRED01"; +} diff --git a/ansteel-biz/src/main/java/com/iailab/module/ansteel/common/enums/PreLineTypeEnum.java b/ansteel-biz/src/main/java/com/iailab/module/ansteel/common/enums/PreLineTypeEnum.java new file mode 100644 index 0000000..e1fd219 --- /dev/null +++ b/ansteel-biz/src/main/java/com/iailab/module/ansteel/common/enums/PreLineTypeEnum.java @@ -0,0 +1,33 @@ +package com.iailab.module.ansteel.common.enums; + +import lombok.AllArgsConstructor; +import lombok.Getter; + +/** + * @author PanZhibao + * @Description + * @createTime 2024年11月18日 + */ +@Getter +@AllArgsConstructor +public enum PreLineTypeEnum { + TN("0", "T+N"), + TL("1", "T+L"), + CD("2", "curData"); + + private String code; + private String desc; + + public static PreLineTypeEnum getEumByCode(String code) { + if (code == null) { + return null; + } + + for (PreLineTypeEnum statusEnum : PreLineTypeEnum.values()) { + if (statusEnum.getCode().equals(code)) { + return statusEnum; + } + } + return null; + } +} \ No newline at end of file diff --git a/ansteel-biz/src/main/java/com/iailab/module/ansteel/util/ApiSecurityUtils.java b/ansteel-biz/src/main/java/com/iailab/module/ansteel/util/ApiSecurityUtils.java new file mode 100644 index 0000000..b1bf747 --- /dev/null +++ b/ansteel-biz/src/main/java/com/iailab/module/ansteel/util/ApiSecurityUtils.java @@ -0,0 +1,82 @@ +package com.iailab.module.ansteel.util; + + +import com.iailab.framework.common.constant.Constant; +import com.iailab.framework.tenant.core.context.TenantContextHolder; +import com.iailab.module.system.api.user.AdminUserApi; +import org.apache.commons.lang3.StringUtils; +import org.springframework.stereotype.Component; + +import javax.annotation.Resource; +import javax.servlet.http.HttpServletRequest; +import java.util.regex.Pattern; + +/** + * @author PanZhibao + * @Description + * @createTime 2023年12月06日 15:55:00 + */ +@Component +public class ApiSecurityUtils { + + /*@Resource + private ApiAppService apiAppService;*/ + + @Resource + private AdminUserApi adminUserApi; + + private Pattern pattern = Pattern.compile("^[-\\+]?[\\d]*$"); + + private String getRequestToken(HttpServletRequest httpRequest) { + //从header中获取token + String token = httpRequest.getHeader(Constant.TOKEN_HEADER); + + //如果header中不存在token,则从参数中获取token + if (StringUtils.isBlank(token)) { + token = httpRequest.getParameter(Constant.TOKEN_HEADER); + } + + return token; + } + + private void setTenantId(HttpServletRequest httpRequest) { + String tenantId = httpRequest.getHeader(Constant.HEAD_TENANT_ID); + + if (StringUtils.isNotBlank(tenantId)) { + TenantContextHolder.setTenantId(Long.parseLong(tenantId)); + } + } + + + public void validate(HttpServletRequest httpRequest) throws Exception { + setTenantId(httpRequest); + /*String token = getRequestToken(httpRequest); + if (StringUtils.isBlank(token)) { + throw new Exception("token 不能为空!"); + } + LoginUser loginUser = SecurityFrameworkUtils.getLoginUser(); + if (ObjectUtils.isEmpty(loginUser)) { + throw new RuntimeException("用户不能为空"); + } + CommonResult<AdminUserRespDTO> user = adminUserApi.getUser(loginUser.getId()); + if(ObjectUtils.isEmpty(user)) { + throw new RuntimeException("用户不存在"); + } + AdminUserRespDTO userData = user.getData(); + String username = userData.getUsername();*/ + /*ApiAppEntity appInfo = apiAppService.getInfoByAppKey(username); + if (appInfo == null) { + throw new RuntimeException("应用未授权"); + }*/ + //TODO 验证签名 +// if(!com.iailab.common.utils.JwtUtils.verify(token, appInfo.getAppSecret())){ +// throw new RuntimeException("签名错误"); +// } + } + + private boolean isInteger(String str) { + return pattern.matcher(str).matches(); + } + + +} diff --git a/pom.xml b/pom.xml index f58865e..31d413a 100644 --- a/pom.xml +++ b/pom.xml @@ -11,7 +11,7 @@ 快速开发框架,默认基础system,data,model </description> <modules> -<!-- <module>ansteel-api</module>--> + <module>ansteel-api</module> <module>ansteel-biz</module> </modules> -- Gitblit v1.9.3