电力页面数据绑定接口:
调度模型最新结果查询 动态limit
查询时间范围内预测结果
| | |
| | | |
| | | import com.iailab.framework.common.pojo.PageResult; |
| | | import com.iailab.module.model.api.mcs.dto.*; |
| | | import com.iailab.module.model.api.mdk.dto.StScheduleRecordVO; |
| | | import com.iailab.module.model.enums.ApiConstants; |
| | | import io.swagger.v3.oas.annotations.Operation; |
| | | import io.swagger.v3.oas.annotations.tags.Tag; |
| | |
| | | |
| | | @GetMapping("/schedule-data/last") |
| | | @Operation(summary = "调度模型最新结果查询") |
| | | String getLastScheduleData(String scheduleCode); |
| | | List<StScheduleRecordVO> getLastScheduleData(String scheduleCode, Integer limit); |
| | | |
| | | @GetMapping("/machineRealTimeStatus") |
| | | @Operation(summary = "发电机组实时状态查询") |
| | | List<Map<String, Object>> getRealTimeStatus(@RequestBody List<Map<String, Object>> machines); |
| | | |
| | | @PostMapping("/predict-data/itemNo") |
| | | @Operation(summary = "查询时间范围内预测结果") |
| | | Map<String,List<Object[]>> getPredictDataItemNo(PreDataItemNoReqVO reqVO); |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.model.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; |
| | | |
| | | /** |
| | | * @description: |
| | | * @author: dzd |
| | | * @date: 2025/1/17 14:44 |
| | | **/ |
| | | @Data |
| | | public class PreDataItemNoReqVO implements Serializable { |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | @Schema(description = "预测项编号") |
| | | private String itemNo; |
| | | |
| | | @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; |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.model.api.mdk.dto; |
| | | |
| | | import com.fasterxml.jackson.annotation.JsonFormat; |
| | | import io.swagger.v3.oas.annotations.media.Schema; |
| | | import lombok.Data; |
| | | |
| | | import java.util.Date; |
| | | |
| | | /** |
| | | * @author PanZhibao |
| | | * @Description |
| | | * @createTime 2024年09月06日 |
| | | */ |
| | | @Schema(description = "模型服务 - 调度记录 Response VO") |
| | | @Data |
| | | public class StScheduleRecordVO { |
| | | |
| | | @Schema(description = "ID") |
| | | private String id; |
| | | |
| | | @Schema(description = "方案ID") |
| | | private String schemeId; |
| | | |
| | | @Schema(description = "模型ID") |
| | | private String modelId; |
| | | |
| | | @Schema(description = "模型名称") |
| | | private String modelName; |
| | | |
| | | @Schema(description = "调度时间") |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") |
| | | private Date scheduleTime; |
| | | |
| | | @Schema(description = "创建时间") |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") |
| | | private Date createTime; |
| | | |
| | | @Schema(description = "结果状态") |
| | | private String resultCode; |
| | | |
| | | @Schema(description = "结果数据") |
| | | private String resultData; |
| | | } |
| | |
| | | import com.iailab.module.data.common.ApiDataQueryDTO; |
| | | import com.iailab.module.model.api.mcs.McsApi; |
| | | import com.iailab.module.model.api.mcs.dto.*; |
| | | import com.iailab.module.model.api.mdk.dto.StScheduleRecordVO; |
| | | import com.iailab.module.model.common.enums.DataTypeEnum; |
| | | import com.iailab.module.model.enums.CommonConstant; |
| | | import com.iailab.module.model.common.enums.PreLineTypeEnum; |
| | | import com.iailab.module.model.enums.CommonConstant; |
| | | import com.iailab.module.model.influxdb.pojo.InfluxModelResultByOutPutIdsPOJO; |
| | | import com.iailab.module.model.influxdb.service.InfluxDBService; |
| | | import com.iailab.module.model.influxdb.vo.InfluxModelResultVO; |
| | |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.text.DecimalFormat; |
| | | import java.util.*; |
| | | import java.util.function.Function; |
| | | import java.util.stream.Collectors; |
| | | import java.util.stream.Stream; |
| | | |
| | | /** |
| | | * @author PanZhibao |
| | |
| | | } |
| | | |
| | | @Override |
| | | public String getLastScheduleData(String scheduleCode) { |
| | | public List<StScheduleRecordVO> getLastScheduleData(String scheduleCode, Integer limit) { |
| | | if (StringUtils.isBlank(scheduleCode)) { |
| | | return null; |
| | | } |
| | | return stScheduleRecordService.getLastScheduleResult(scheduleCode); |
| | | return stScheduleRecordService.getLastScheduleResult(scheduleCode,limit); |
| | | } |
| | | |
| | | @Override |
| | |
| | | return results; |
| | | } |
| | | |
| | | @Override |
| | | public Map<String, List<Object[]>> getPredictDataItemNo(PreDataItemNoReqVO reqVO) { |
| | | if (StringUtils.isBlank(reqVO.getItemNo()) || null == reqVO.getStartTime() || null == reqVO.getEndTime()) { |
| | | return new HashMap<>(); |
| | | } |
| | | ItemVO predictItem = mmPredictItemService.getItemByItemNo(reqVO.getItemNo()); |
| | | if (null == predictItem) { |
| | | return new HashMap<>(); |
| | | } |
| | | List<String> itemNos = new ArrayList<String>(){{ |
| | | add(reqVO.getItemNo()); |
| | | }}; |
| | | List<MmPredictItemRespVO> ItemRespVOs = mmPredictItemService.getArrayOutPutsByItemNos(itemNos); |
| | | if (CollectionUtils.isEmpty(ItemRespVOs)) { |
| | | return new HashMap<>(); |
| | | } |
| | | List<MmItemOutputRespVO> outPuts = ItemRespVOs.get(0).getOutPuts(); |
| | | if (CollectionUtils.isEmpty(outPuts)) { |
| | | return new HashMap<>(); |
| | | } |
| | | |
| | | InfluxModelResultByOutPutIdsPOJO pojo = new InfluxModelResultByOutPutIdsPOJO(); |
| | | pojo.setOutPutIds(outPuts.stream().map(MmItemOutputRespVO::getId).collect(Collectors.toList())); |
| | | pojo.setType(DataTypeEnum.FLOAT.getCode()); |
| | | Map<String, List<InfluxModelResultVO>> outPutDatas = influxDBService.queryModelResultsByOutPutIds(pojo, reqVO.getStartTime(), reqVO.getEndTime()); |
| | | Map<String,List<Object[]>> result = new HashMap<>(outPuts.size()); |
| | | for (MmItemOutputRespVO outPut : outPuts) { |
| | | String outPutId = outPut.getId(); |
| | | if (outPutDatas.containsKey(outPutId)) { |
| | | List<InfluxModelResultVO> influxModelResultVOS = outPutDatas.get(outPutId); |
| | | result.put(null == outPut.getResultIndex() ? outPut.getResultstr() : outPut.getResultstr()+"_"+outPut.getResultIndex(),influxModelResultVOS.stream().map(e -> { |
| | | Object[] values = new Object[2]; |
| | | values[0] = DateUtils.format(Date.from(e.getTimestamp()), DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND); |
| | | values[1] = Double.valueOf(e.getValue().toString()); |
| | | return values; |
| | | }).collect(Collectors.toList())); |
| | | } |
| | | } |
| | | return result; |
| | | } |
| | | |
| | | /** |
| | | * 计算功率因数 p²/(根号:p²+Q²) |
| | | **/ |
| | |
| | | import com.iailab.framework.common.util.object.BeanUtils; |
| | | import com.iailab.module.model.api.mcs.McsApi; |
| | | import com.iailab.module.model.api.mcs.dto.*; |
| | | import com.iailab.module.model.api.mdk.dto.StScheduleRecordVO; |
| | | import com.iailab.module.model.common.utils.ApiSecurityUtils; |
| | | import com.iailab.module.model.common.utils.ExcelUtil; |
| | | import com.iailab.module.model.influxdb.vo.InfluxModelResultVO; |
| | | import io.swagger.v3.oas.annotations.Operation; |
| | | import io.swagger.v3.oas.annotations.tags.Tag; |
| | | import lombok.extern.slf4j.Slf4j; |
| | |
| | | } |
| | | @GetMapping("/schedule-data/last") |
| | | @Operation(summary = "调度模型最新结果查询") |
| | | public CommonResult<String> getLastScheduleData(@RequestParam String scheduleCode) { |
| | | return CommonResult.success(mcsApi.getLastScheduleData(scheduleCode)); |
| | | public CommonResult<List<StScheduleRecordVO>> getLastScheduleData(@RequestParam String scheduleCode, @RequestParam Integer limit) { |
| | | if (null == limit) { |
| | | limit = 1; |
| | | } |
| | | return CommonResult.success(mcsApi.getLastScheduleData(scheduleCode,limit)); |
| | | } |
| | | |
| | | @PostMapping("/machineRealTimeStatus") |
| | |
| | | CommonResult<List<Map<String, Object>>> getRealTimeStatus(@RequestBody List<Map<String, Object>> machines) { |
| | | return CommonResult.success(mcsApi.getRealTimeStatus(machines)); |
| | | } |
| | | |
| | | @PostMapping("/predict-data/itemNo") |
| | | @Operation(summary = "查询时间范围内预测结果") |
| | | CommonResult<Map<String,List<Object[]>>> getPredictDataItemNo(@RequestBody PreDataItemNoReqVO reqVO) { |
| | | return CommonResult.success(mcsApi.getPredictDataItemNo(reqVO)); |
| | | } |
| | | } |
| | |
| | | return getPageList(getPage(reqVO), reqVO); |
| | | } |
| | | |
| | | List<MmPredictItemRespVO> getDoubleOutPutsByItemNos(Map<String, Object> params); |
| | | List<MmPredictItemRespVO> getOutPutsByItemNosAndResultType(Map<String, Object> params); |
| | | } |
| | |
| | | MmPredictItemEntity getById(String id); |
| | | |
| | | List<MmPredictItemRespVO> getDoubleOutPutsByItemNos(List<String> itemNos); |
| | | |
| | | List<MmPredictItemRespVO> getArrayOutPutsByItemNos(List<String> itemNos); |
| | | } |
| | |
| | | |
| | | @Override |
| | | public List<MmPredictItemRespVO> getDoubleOutPutsByItemNos(List<String> itemNos) { |
| | | if (CollectionUtils.isEmpty(itemNos)) { |
| | | List<Integer> resultType = new ArrayList<Integer>(){{ |
| | | add(3); |
| | | }}; |
| | | return getOutPutsByItemNosAndResultType(itemNos,resultType); |
| | | } |
| | | |
| | | @Override |
| | | public List<MmPredictItemRespVO> getArrayOutPutsByItemNos(List<String> itemNos) { |
| | | List<Integer> resultType = new ArrayList<Integer>(){{ |
| | | add(1); |
| | | add(2); |
| | | }}; |
| | | return getOutPutsByItemNosAndResultType(itemNos,resultType); |
| | | } |
| | | |
| | | public List<MmPredictItemRespVO> getOutPutsByItemNosAndResultType(List<String> itemNos,List<Integer> resultType) { |
| | | if (CollectionUtils.isEmpty(itemNos) || CollectionUtils.isEmpty(resultType)) { |
| | | return new ArrayList<>(); |
| | | } |
| | | Map<String, Object> params = new HashMap(1); |
| | | params.put("itemNos", itemNos); |
| | | List<MmPredictItemRespVO> list = mmPredictItemDao.getDoubleOutPutsByItemNos(params); |
| | | params.put("resultType", resultType); |
| | | List<MmPredictItemRespVO> list = mmPredictItemDao.getOutPutsByItemNosAndResultType(params); |
| | | return list; |
| | | } |
| | | |
| | |
| | | @ExcelProperty("输出结果") |
| | | private String resultstr; |
| | | |
| | | @Schema(description = "结果索引") |
| | | @ExcelProperty("结果索引") |
| | | private Integer resultIndex; |
| | | |
| | | @Schema(description = "数据点名称") |
| | | @ExcelProperty("数据点名称") |
| | | private String tagname; |
| | |
| | | import com.iailab.framework.mybatis.core.mapper.BaseMapperX; |
| | | import com.iailab.framework.mybatis.core.query.LambdaQueryWrapperX; |
| | | import com.iailab.framework.tenant.core.db.dynamic.TenantDS; |
| | | import com.iailab.module.model.api.mdk.dto.StScheduleRecordVO; |
| | | import com.iailab.module.model.mcs.sche.entity.StScheduleRecordEntity; |
| | | import com.iailab.module.model.mcs.sche.vo.StScheduleRecordPageReqVO; |
| | | import org.apache.ibatis.annotations.Mapper; |
| | | import org.apache.ibatis.annotations.Param; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * @author PanZhibao |
| | |
| | | .orderByDesc(StScheduleRecordEntity::getCreateTime)); |
| | | } |
| | | |
| | | String getLastScheduleResult(String scheduleCode); |
| | | List<StScheduleRecordVO> getLastScheduleResult(@Param("scheduleCode") String scheduleCode, @Param("limit") Integer limit); |
| | | } |
| | |
| | | |
| | | import com.iailab.framework.common.pojo.PageResult; |
| | | import com.iailab.framework.common.service.BaseService; |
| | | import com.iailab.module.model.api.mdk.dto.StScheduleRecordVO; |
| | | import com.iailab.module.model.mcs.sche.entity.StScheduleRecordEntity; |
| | | import com.iailab.module.model.mcs.sche.vo.StScheduleRecordPageReqVO; |
| | | import com.iailab.module.model.mcs.sche.vo.StScheduleRecordRespVO; |
| | | import com.iailab.module.model.mdk.vo.ScheduleResultVO; |
| | | import org.apache.ibatis.annotations.Param; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * @author PanZhibao |
| | |
| | | |
| | | void create(ScheduleResultVO resultVO); |
| | | |
| | | String getLastScheduleResult(String scheduleCode); |
| | | List<StScheduleRecordVO> getLastScheduleResult(String scheduleCode, Integer limit); |
| | | } |
| | |
| | | import com.iailab.framework.common.pojo.PageResult; |
| | | import com.iailab.framework.common.service.impl.BaseServiceImpl; |
| | | import com.iailab.framework.common.util.object.ConvertUtils; |
| | | import com.iailab.module.model.api.mdk.dto.StScheduleRecordVO; |
| | | import com.iailab.module.model.mcs.sche.dao.StScheduleRecordDao; |
| | | import com.iailab.module.model.mcs.sche.entity.StScheduleRecordDetailEntity; |
| | | import com.iailab.module.model.mcs.sche.entity.StScheduleRecordEntity; |
| | |
| | | } |
| | | |
| | | @Override |
| | | public String getLastScheduleResult(String scheduleCode) { |
| | | return baseDao.getLastScheduleResult(scheduleCode); |
| | | public List<StScheduleRecordVO> getLastScheduleResult(String scheduleCode, Integer limit) { |
| | | return baseDao.getLastScheduleResult(scheduleCode,limit); |
| | | } |
| | | } |
| | |
| | | <result property="outputorder" column="out_put_order"/> |
| | | <result property="resultName" column="result_name"/> |
| | | <result property="resultstr" column="result_str"/> |
| | | <result property="resultIndex" column="result_index"/> |
| | | </collection> |
| | | </resultMap> |
| | | |
| | |
| | | FROM t_mm_predict_merge_item t1 |
| | | WHERE t1.itemid = #{ITEMID} |
| | | </select> |
| | | <select id="getDoubleOutPutsByItemNos" resultMap="MmPredictItemRespVO" parameterType="map"> |
| | | <select id="getOutPutsByItemNosAndResultType" resultMap="MmPredictItemRespVO" parameterType="map"> |
| | | SELECT |
| | | TMPI.ID, |
| | | TMPI.ITEMNO, |
| | | TMPI.ITEMNAME, |
| | | TMPI.ITEMTYPEID, |
| | | TMPI.predictlength, |
| | | TMPI.GRANULARITY, |
| | | TMPI.ISFUSE, |
| | | TMPI.WORKCHECKED, |
| | | TMPI.STATUS, |
| | | TMIO.id out_put_id, |
| | | TMIO.outputorder out_put_order, |
| | | TMIO.resultstr result_str, |
| | | TMIO.result_name, |
| | | TMIS.last_time |
| | | TMPI.ID, |
| | | TMPI.ITEMNO, |
| | | TMPI.ITEMNAME, |
| | | TMPI.ITEMTYPEID, |
| | | TMPI.predictlength, |
| | | TMPI.GRANULARITY, |
| | | TMPI.ISFUSE, |
| | | TMPI.WORKCHECKED, |
| | | TMPI.STATUS, |
| | | TMIO.id out_put_id, |
| | | TMIO.outputorder out_put_order, |
| | | TMIO.resultstr result_str, |
| | | TMIO.result_index, |
| | | TMIO.result_name, |
| | | TMIS.last_time |
| | | FROM T_MM_PREDICT_ITEM TMPI |
| | | LEFT JOIN t_mm_item_output TMIO ON TMIO.itemid = TMPI.ID AND TMIO.result_type = 3 |
| | | LEFT JOIN t_mm_item_output TMIO ON TMIO.itemid = TMPI.ID AND TMIO.result_type in |
| | | <foreach collection="resultType" item="item" open="(" close=")" separator=","> |
| | | #{item} |
| | | </foreach> |
| | | LEFT JOIN t_mm_item_status TMIS ON TMIS.item_id = TMPI.ID |
| | | WHERE TMPI.itemno in |
| | | <foreach collection="itemNos" item="item" open="(" close=")" separator=","> |
| | |
| | | <?xml version="1.0" encoding="UTF-8" ?> |
| | | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" > |
| | | <mapper namespace="com.iailab.module.model.mcs.sche.dao.StScheduleRecordDao"> |
| | | <select id="getLastScheduleResult" resultType="java.lang.String"> |
| | | SELECT t2.result_data FROM t_st_schedule_scheme t1 LEFT JOIN t_st_schedule_record t2 on t1.id = t2.scheme_id |
| | | <select id="getLastScheduleResult" resultType="com.iailab.module.model.api.mdk.dto.StScheduleRecordVO"> |
| | | SELECT t2.* FROM t_st_schedule_scheme t1 LEFT JOIN t_st_schedule_record t2 on t1.id = t2.scheme_id |
| | | WHERE t1.`code` = #{scheduleCode} AND result_code = "100" |
| | | ORDER BY t2.schedule_time desc |
| | | LIMIT 1 |
| | | LIMIT #{limit} |
| | | </select> |
| | | </mapper> |