|
@@ -1,10 +1,19 @@
|
|
|
package com.ufo.project.forecast.fileupload.service.impl;
|
|
package com.ufo.project.forecast.fileupload.service.impl;
|
|
|
|
|
|
|
|
|
|
+import java.time.LocalDate;
|
|
|
|
|
+import java.time.ZoneId;
|
|
|
|
|
+import java.util.Date;
|
|
|
|
|
+import java.util.HashMap;
|
|
|
|
|
+import java.util.LinkedHashSet;
|
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
|
|
+import java.util.Map;
|
|
|
|
|
+import java.util.Set;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.ufo.base.common.utils.StringUtils;
|
|
import com.ufo.base.common.utils.StringUtils;
|
|
|
|
|
+import com.ufo.project.config.domain.ConfigStation;
|
|
|
|
|
+import com.ufo.project.config.service.IConfigStationService;
|
|
|
import com.ufo.project.forecast.fileupload.domain.DataReportLog;
|
|
import com.ufo.project.forecast.fileupload.domain.DataReportLog;
|
|
|
import com.ufo.project.forecast.fileupload.mapper.DataReportLogMapper;
|
|
import com.ufo.project.forecast.fileupload.mapper.DataReportLogMapper;
|
|
|
import com.ufo.project.forecast.fileupload.service.IDataReportLogService;
|
|
import com.ufo.project.forecast.fileupload.service.IDataReportLogService;
|
|
@@ -21,6 +30,21 @@ public class DataReportLogServiceImpl implements IDataReportLogService
|
|
|
@Autowired
|
|
@Autowired
|
|
|
private DataReportLogMapper dataReportLogMapper;
|
|
private DataReportLogMapper dataReportLogMapper;
|
|
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private IConfigStationService configStationService;
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 查询功率预测上报日志
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param id 功率预测上报日志主键
|
|
|
|
|
+ * @return 功率预测上报日志
|
|
|
|
|
+ */
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public DataReportLog selectDataReportLogById(Long id)
|
|
|
|
|
+ {
|
|
|
|
|
+ return dataReportLogMapper.selectById(id);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* 查询功率预测上报日志列表
|
|
* 查询功率预测上报日志列表
|
|
|
*
|
|
*
|
|
@@ -32,15 +56,83 @@ public class DataReportLogServiceImpl implements IDataReportLogService
|
|
|
{
|
|
{
|
|
|
LambdaQueryWrapper<DataReportLog> wrapper = new LambdaQueryWrapper<>();
|
|
LambdaQueryWrapper<DataReportLog> wrapper = new LambdaQueryWrapper<>();
|
|
|
wrapper.eq(StringUtils.isNotEmpty(dataReportLog.getType()), DataReportLog::getType, dataReportLog.getType())
|
|
wrapper.eq(StringUtils.isNotEmpty(dataReportLog.getType()), DataReportLog::getType, dataReportLog.getType())
|
|
|
|
|
+ .eq(StringUtils.isNotEmpty(dataReportLog.getStationCode()), DataReportLog::getStationCode, dataReportLog.getStationCode())
|
|
|
.eq(dataReportLog.getCurveId() != null, DataReportLog::getCurveId, dataReportLog.getCurveId())
|
|
.eq(dataReportLog.getCurveId() != null, DataReportLog::getCurveId, dataReportLog.getCurveId())
|
|
|
.like(StringUtils.isNotEmpty(dataReportLog.getTargetDispatch()), DataReportLog::getTargetDispatch, dataReportLog.getTargetDispatch())
|
|
.like(StringUtils.isNotEmpty(dataReportLog.getTargetDispatch()), DataReportLog::getTargetDispatch, dataReportLog.getTargetDispatch())
|
|
|
.eq(StringUtils.isNotEmpty(dataReportLog.getMessageNo()), DataReportLog::getMessageNo, dataReportLog.getMessageNo())
|
|
.eq(StringUtils.isNotEmpty(dataReportLog.getMessageNo()), DataReportLog::getMessageNo, dataReportLog.getMessageNo())
|
|
|
.eq(dataReportLog.getChannel() != null, DataReportLog::getChannel, dataReportLog.getChannel())
|
|
.eq(dataReportLog.getChannel() != null, DataReportLog::getChannel, dataReportLog.getChannel())
|
|
|
.eq(dataReportLog.getStatus() != null, DataReportLog::getStatus, dataReportLog.getStatus())
|
|
.eq(dataReportLog.getStatus() != null, DataReportLog::getStatus, dataReportLog.getStatus())
|
|
|
.ge(dataReportLog.getStartTime() != null, DataReportLog::getReportTime, dataReportLog.getStartTime())
|
|
.ge(dataReportLog.getStartTime() != null, DataReportLog::getReportTime, dataReportLog.getStartTime())
|
|
|
- .le(dataReportLog.getEndTime() != null, DataReportLog::getReportTime, dataReportLog.getEndTime())
|
|
|
|
|
- .orderByDesc(DataReportLog::getReportTime)
|
|
|
|
|
|
|
+ .le(dataReportLog.getEndTime() != null, DataReportLog::getReportTime, dataReportLog.getEndTime());
|
|
|
|
|
+ applyEstReportDate(wrapper, dataReportLog.getQueryDate());
|
|
|
|
|
+ wrapper.orderByDesc(DataReportLog::getEstReportTime)
|
|
|
.orderByDesc(DataReportLog::getId);
|
|
.orderByDesc(DataReportLog::getId);
|
|
|
- return dataReportLogMapper.selectList(wrapper);
|
|
|
|
|
|
|
+ List<DataReportLog> list = dataReportLogMapper.selectList(wrapper);
|
|
|
|
|
+ fillStationName(list);
|
|
|
|
|
+ return list;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 按计划上报时间过滤单日(queryDate, yyyy-MM-dd)
|
|
|
|
|
+ */
|
|
|
|
|
+ private void applyEstReportDate(LambdaQueryWrapper<DataReportLog> wrapper, String queryDate)
|
|
|
|
|
+ {
|
|
|
|
|
+ if (StringUtils.isEmpty(queryDate))
|
|
|
|
|
+ {
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ try
|
|
|
|
|
+ {
|
|
|
|
|
+ LocalDate day = LocalDate.parse(queryDate);
|
|
|
|
|
+ Date start = Date.from(day.atStartOfDay(ZoneId.systemDefault()).toInstant());
|
|
|
|
|
+ Date end = Date.from(day.plusDays(1).atStartOfDay(ZoneId.systemDefault()).toInstant());
|
|
|
|
|
+ wrapper.ge(DataReportLog::getEstReportTime, start)
|
|
|
|
|
+ .lt(DataReportLog::getEstReportTime, end);
|
|
|
|
|
+ }
|
|
|
|
|
+ catch (Exception e)
|
|
|
|
|
+ {
|
|
|
|
|
+ // queryDate格式非法时忽略该条件
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 按station_code关联config_station回填场站名称
|
|
|
|
|
+ */
|
|
|
|
|
+ private void fillStationName(List<DataReportLog> list)
|
|
|
|
|
+ {
|
|
|
|
|
+ if (list == null || list.isEmpty())
|
|
|
|
|
+ {
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ Set<String> stationCodes = new LinkedHashSet<>();
|
|
|
|
|
+ for (DataReportLog item : list)
|
|
|
|
|
+ {
|
|
|
|
|
+ if (StringUtils.isNotEmpty(item.getStationCode()))
|
|
|
|
|
+ {
|
|
|
|
|
+ stationCodes.add(item.getStationCode());
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ if (stationCodes.isEmpty())
|
|
|
|
|
+ {
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ Map<String, String> nameMap = new HashMap<>();
|
|
|
|
|
+ for (String stationCode : stationCodes)
|
|
|
|
|
+ {
|
|
|
|
|
+ ConfigStation query = new ConfigStation();
|
|
|
|
|
+ query.setStationCode(stationCode);
|
|
|
|
|
+ List<ConfigStation> stations = configStationService.selectConfigStationList(query);
|
|
|
|
|
+ if (stations != null && !stations.isEmpty())
|
|
|
|
|
+ {
|
|
|
|
|
+ nameMap.put(stationCode, stations.get(0).getStationName());
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ for (DataReportLog item : list)
|
|
|
|
|
+ {
|
|
|
|
|
+ if (StringUtils.isNotEmpty(item.getStationCode()) && nameMap.containsKey(item.getStationCode()))
|
|
|
|
|
+ {
|
|
|
|
|
+ item.setStationName(nameMap.get(item.getStationCode()));
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|