ansteel-biz/src/main/java/com/iailab/module/ansteel/api/controller/admin/PowerController.java
@@ -16,6 +16,7 @@ import com.iailab.module.ansteel.api.vo.PowerMaxDemandMainPageReqVO; import com.iailab.module.ansteel.common.constant.CommonConstant; import com.iailab.module.ansteel.common.enums.ProcessConfDataTypeEnum; import com.iailab.module.ansteel.common.utils.CalendarUtil; import com.iailab.module.ansteel.common.utils.DecimalUtil; import com.iailab.module.ansteel.common.utils.PowerUtil; import com.iailab.module.ansteel.power.entity.*; @@ -739,13 +740,13 @@ Map<String, Object> params0 = new HashMap<>(); params0.put("groupName", entity.getName()); List<PowerNetDropdownEntity> list0 = powerNetDropdownService.list(params0); if (CollectionUtils.isEmpty(list0)) { if (!CollectionUtils.isEmpty(list0)) { list.addAll(list0); } Map<String, Object> params1 = new HashMap<>(); params1.put("groupName", "COMMON1"); List<PowerNetDropdownEntity> list1 = powerNetDropdownService.list(params1); if (CollectionUtils.isEmpty(list1)) { if (!CollectionUtils.isEmpty(list1)) { list.addAll(list1); } @@ -1600,6 +1601,7 @@ throw new IllegalArgumentException("不支持的queryType: " + queryType); } // 查询历史数据 ApiPointValueQueryDTO query = new ApiPointValueQueryDTO(); query.setPointNo(pointNo); @@ -1614,10 +1616,13 @@ }) .collect(Collectors.toList()); List<Double> valueList = chartData.stream().map(pv -> { return pv.getV(); }).collect(Collectors.toList()); powerHistoryDTO.setDataList(dataList); //查询月最大最小值 ApiPointValueQueryDTO apiPointValueQueryDTO1 = new ApiPointValueQueryDTO(); /*ApiPointValueQueryDTO apiPointValueQueryDTO1 = new ApiPointValueQueryDTO(); apiPointValueQueryDTO1.setStart(start1); apiPointValueQueryDTO1.setEnd(new Date()); apiPointValueQueryDTO1.setPointNo(pointNo); @@ -1628,7 +1633,40 @@ } if (minV != null && minV.containsKey(pointNo)) { powerHistoryDTO.setMin(new BigDecimal(minV.get(pointNo).toString())); }*/ double max = 0; double min = 0; double avg = 0; String maxTime = ""; String minTime = ""; if (!CollectionUtils.isEmpty(valueList)) { // max = valueList.stream().mapToDouble(Double::doubleValue).max().getAsDouble(); // min = valueList.stream().mapToDouble(Double::doubleValue).min().getAsDouble(); avg = valueList.stream().mapToDouble(Double::doubleValue).average().getAsDouble(); max = valueList.get(0).doubleValue(); min = valueList.get(0).doubleValue(); for (Object[] dataItem : dataList) { String time = (String) dataItem[0]; double value = (double)dataItem[1]; if (value > max) { max = value; maxTime = time; } if (value < min) { min = value; minTime = time; } } } powerHistoryDTO.setMax(new BigDecimal(max).setScale(2, BigDecimal.ROUND_HALF_UP)); powerHistoryDTO.setMin(new BigDecimal(min).setScale(2, BigDecimal.ROUND_HALF_UP)); powerHistoryDTO.setAvg(new BigDecimal(avg).setScale(2, BigDecimal.ROUND_HALF_UP)); powerHistoryDTO.setMaxTime(maxTime); powerHistoryDTO.setMinTime(minTime); powerHistoryDTO.setDataList(dataList); result.put(code, powerHistoryDTO); } @@ -1677,6 +1715,11 @@ log.info("code is blank"); return error(GlobalErrorCodeConstants.BAD_REQUEST); } // 默认只展示当月 if(reqVO.getStartTime() == null) { reqVO.setStartTime(CalendarUtil.getMonthFirstDay()); } PageResult<PowerMaxdemandMainEntity> page = powerMaxDemandMainService.page(reqVO); PageResult<PowerMaxDemandMainDTO> result = BeanUtils.toBean(page, PowerMaxDemandMainDTO.class); result.getList().forEach(dto0 -> { ansteel-biz/src/main/java/com/iailab/module/ansteel/api/dto/PowerHistoryDTO.java
@@ -1,12 +1,10 @@ package com.iailab.module.ansteel.api.dto; 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; import java.util.List; /** ansteel-biz/src/main/java/com/iailab/module/ansteel/api/dto/PreDataChartRespVO.java
@@ -1,7 +1,6 @@ package com.iailab.module.ansteel.api.dto; import com.fasterxml.jackson.annotation.JsonFormat; import com.iailab.module.model.api.mcs.dto.PreDataViewRespDTO; import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; ansteel-biz/src/main/java/com/iailab/module/ansteel/api/service/impl/DataServiceImpl.java
@@ -175,6 +175,7 @@ if (predictItem == null || predictItem.getLastTime() == null) { return null; } String timeFormat = StringUtils.isBlank(reqVO.getTimeFormat()) ? DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND : reqVO.getTimeFormat(); 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(); @@ -186,10 +187,24 @@ Date[] timeArray = calResultTime(predictItem, reqVO.getStartTime(), reqVO.getEndTime(), lengthLeft, lengthRight); Date startTime = timeArray[1]; Date endTime = timeArray[2]; /*String timeFormat = null; if (StringUtils.isNotBlank(reqVO.getTimeFormat())) { timeFormat = reqVO.getTimeFormat(); } else if ((endTime.getTime() - startTime.getTime()) < 1000 * 60 * 60 * 24 ) { // 时间范围短,默认使用短时间格式 "HH:mm" timeFormat = DateUtils.FORMAT_SIMPLE_TIME; } else { timeFormat = DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; }*/ final String finalTimeFormat = timeFormat; // reqVO.setTimeFormat(finalTimeFormat); PreDataSingleChartRespVO resultOld = mcsApi.getPreDataSingleChart(reqVO); PreDataChartRespVO result = ConvertUtils.sourceToTarget(resultOld, PreDataChartRespVO.class); //result.setPredictTime(DateUtils.format(resultOld.getPredictTime(), finalTimeFormat)); PreDataViewDTO preDataView = ConvertUtils.sourceToTarget(resultOld.getDataView(), PreDataViewDTO.class); //preDataView.setPredictTime(DateUtils.format(resultOld.getDataView().getPredictTime(), finalTimeFormat)); if (StringUtils.isNotBlank(trendsDataH)) { // 动态上限 ApiPointValueQueryDTO pointValueQueryDTO = new ApiPointValueQueryDTO(); @@ -200,7 +215,7 @@ List<Object[]> newList = new ArrayList<>(); trendsDataHList.forEach(item -> { Object[] dataItem = new Object[2]; dataItem[0] = DateUtils.format(item.getT(), "yyyy-MM-dd HH:mm:00"); dataItem[0] = DateUtils.format(item.getT(), finalTimeFormat); dataItem[1] = item.getV(); newList.add(dataItem); }); @@ -216,7 +231,7 @@ List<Object[]> newList = new ArrayList<>(); trendsDataLList.forEach(item -> { Object[] dataItem = new Object[2]; dataItem[0] = DateUtils.format(item.getT(), "yyyy-MM-dd HH:mm:00"); dataItem[0] = DateUtils.format(item.getT(), finalTimeFormat); dataItem[1] = item.getV(); newList.add(dataItem); }); @@ -478,6 +493,8 @@ @Override public List<PreDataViewSimpleDTO> getPreDataByOutIds(PreDataBarLineReqVO reqVO) { PreDataBarLineRespVO preDataBarLineRespVO = mcsApi.getPreDataCharts(reqVO); String predictTime = DateUtils.format(preDataBarLineRespVO.getPredictTime(), DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND); List<PreDataViewSimpleDTO> preDataViewSimpleDTOList = new ArrayList<>(); preDataBarLineRespVO.getDataViewList().forEach(item -> { PreDataViewSimpleDTO preDataViewSimpleDTO = new PreDataViewSimpleDTO(); ansteel-biz/src/main/java/com/iailab/module/ansteel/api/vo/PreDataByOutReqVO.java
对比新文件 @@ -0,0 +1,44 @@ package com.iailab.module.ansteel.api.vo; 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 2025年06月18日 */ @Data public class PreDataByOutReqVO implements Serializable { private static final long serialVersionUID = 1L; @Schema(description = "查询ID列表") private List<String[]> queryIds; @Schema(description = "输出ID列表") private List<String> outIds; @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 = "数据精度,小于0,不限制位数,大于0设置位数") private Integer prec; @Schema(description = "时间格式化") private String timeFormat; } ansteel-biz/src/main/java/com/iailab/module/ansteel/common/utils/CalendarUtil.java
对比新文件 @@ -0,0 +1,22 @@ package com.iailab.module.ansteel.common.utils; import java.util.Calendar; import java.util.Date; /** * @author PanZhibao * @Description * @createTime 2025年06月18日 */ public class CalendarUtil { public static Date getMonthFirstDay() { Calendar calendar = Calendar.getInstance(); calendar.set(Calendar.MILLISECOND, 0); calendar.set(Calendar.SECOND, 0); calendar.set(Calendar.MINUTE, 0); calendar.set(Calendar.HOUR_OF_DAY, 0); calendar.set(Calendar.DAY_OF_MONTH, 1); return calendar.getTime(); } }