|
@@ -73,78 +73,83 @@ public class ParsingCdqInfoServiceImpl extends ServiceImpl<ParsingCdqInfoMapper,
|
|
|
if (!parsingCdqInfos.isEmpty()) {
|
|
|
ParsingCdqInfo parsingCdqInfo = parsingCdqInfos.get(0);
|
|
|
|
|
|
- // 判断文件名和数据类型是否匹配
|
|
|
- if (file.getName().contains(parsingCdqInfo.getFileName()) && parsingCdqInfo.getDataType().equals(FieldUtil.MULTI)) {
|
|
|
+ if (file.getName().contains(parsingCdqInfo.getFileName())) {
|
|
|
+
|
|
|
List<String> fileContent = FileUtil.getFileContent(file);
|
|
|
- List<BigDecimal> bigDecimals = parsingFpValue(parsingCdqInfo.getFpValue(), fileContent);
|
|
|
-
|
|
|
- if (!bigDecimals.isEmpty()) {
|
|
|
-// Date genDate = parsingGenDate(parsingCdqInfo.getGenDate(), fileContent);
|
|
|
- Long forecastTime = parsingForecastTime(parsingCdqInfo.getForecastTime(), fileContent);
|
|
|
- if (forecastTime != 0L) {
|
|
|
- // 所属产生时刻用第一个点位减去15分钟
|
|
|
- long genDate = forecastTime-1000*60*15L;
|
|
|
-
|
|
|
- int ago = 1;
|
|
|
- List<ForecastPowerUltraShortTermHis> forecastPowerUltraShortTermHisList = new ArrayList<>();
|
|
|
- List<ForecastPowerUltraShortTerm> forecastPowerUltraShortTermList = new ArrayList<>();
|
|
|
-
|
|
|
- for (BigDecimal bigDecimal : bigDecimals) {
|
|
|
- // 构造ForecastPowerUltraShortTermHis对象
|
|
|
- ForecastPowerUltraShortTermHis forecastPowerUltraShortTermHis = new ForecastPowerUltraShortTermHis();
|
|
|
- forecastPowerUltraShortTermHis.setGenDate(new Date(genDate));
|
|
|
- forecastPowerUltraShortTermHis.setStationCode(parsingUrl.getStationCode());
|
|
|
- forecastPowerUltraShortTermHis.setAbleValue(bigDecimal);
|
|
|
- Date localDateTime = new Date(forecastTime);
|
|
|
- forecastPowerUltraShortTermHis.setForecastTime(localDateTime);
|
|
|
- forecastPowerUltraShortTermHis.setForecastHowLongAgo(ago);
|
|
|
- forecastPowerUltraShortTermHis.setForecastManufactor(parsingUrl.getForecastManufactor());
|
|
|
- forecastTime += Constant.INTERVALTIME;
|
|
|
-
|
|
|
- // 构造ForecastPowerUltraShortTerm对象
|
|
|
- ForecastPowerUltraShortTerm forecastPowerUltraShortTerm = new ForecastPowerUltraShortTerm();
|
|
|
- forecastPowerUltraShortTerm.setForecastTime(localDateTime);
|
|
|
- forecastPowerUltraShortTerm.setStationCode(parsingUrl.getStationCode());
|
|
|
- forecastPowerUltraShortTerm.setFpValue(bigDecimal);
|
|
|
- forecastPowerUltraShortTerm.setGenDate(new Date(genDate));
|
|
|
- forecastPowerUltraShortTerm.setForecastManufactor(parsingUrl.getForecastManufactor());
|
|
|
- forecastPowerUltraShortTermList.add(forecastPowerUltraShortTerm);
|
|
|
-
|
|
|
- forecastPowerUltraShortTermHisList.add(forecastPowerUltraShortTermHis);
|
|
|
- ago++;
|
|
|
+ if (parsingCdqInfo.getDataType().equals(FieldUtil.MULTI)) {
|
|
|
+ List<BigDecimal> bigDecimals;
|
|
|
+ if (parsingCdqInfo.getFpValue() != null) ;
|
|
|
+ bigDecimals = parsingFpValue(parsingCdqInfo.getFpValue(), fileContent);
|
|
|
+
|
|
|
+ if (bigDecimals.size() > 0) {
|
|
|
+ Long forecastTime = parsingForecastTime(parsingCdqInfo.getForecastTime(), fileContent);
|
|
|
+ if (forecastTime != 0L) {
|
|
|
+ // 所属产生时刻用第一个点位减去15分钟
|
|
|
+ long genDate = forecastTime-1000*60*15L;
|
|
|
+
|
|
|
+ int ago = 1;
|
|
|
+ List<ForecastPowerUltraShortTermHis> forecastPowerUltraShortTermHisList = new ArrayList<>();
|
|
|
+ List<ForecastPowerUltraShortTerm> forecastPowerUltraShortTermList = new ArrayList<>();
|
|
|
+
|
|
|
+ for (BigDecimal bigDecimal : bigDecimals) {
|
|
|
+ // 构造ForecastPowerUltraShortTermHis对象
|
|
|
+ ForecastPowerUltraShortTermHis forecastPowerUltraShortTermHis = new ForecastPowerUltraShortTermHis();
|
|
|
+ forecastPowerUltraShortTermHis.setGenDate(new Date(genDate));
|
|
|
+ forecastPowerUltraShortTermHis.setStationCode(parsingUrl.getStationCode());
|
|
|
+ forecastPowerUltraShortTermHis.setAbleValue(bigDecimal);
|
|
|
+ Date localDateTime = new Date(forecastTime);
|
|
|
+ forecastPowerUltraShortTermHis.setForecastTime(localDateTime);
|
|
|
+ forecastPowerUltraShortTermHis.setForecastHowLongAgo(ago);
|
|
|
+ forecastPowerUltraShortTermHis.setForecastManufactor(parsingUrl.getForecastManufactor());
|
|
|
+ forecastTime += Constant.INTERVALTIME;
|
|
|
+
|
|
|
+ // 构造ForecastPowerUltraShortTerm对象
|
|
|
+ ForecastPowerUltraShortTerm forecastPowerUltraShortTerm = new ForecastPowerUltraShortTerm();
|
|
|
+ forecastPowerUltraShortTerm.setForecastTime(localDateTime);
|
|
|
+ forecastPowerUltraShortTerm.setStationCode(parsingUrl.getStationCode());
|
|
|
+ forecastPowerUltraShortTerm.setFpValue(bigDecimal);
|
|
|
+ forecastPowerUltraShortTerm.setGenDate(new Date(genDate));
|
|
|
+ forecastPowerUltraShortTerm.setForecastManufactor(parsingUrl.getForecastManufactor());
|
|
|
+ forecastPowerUltraShortTermList.add(forecastPowerUltraShortTerm);
|
|
|
+
|
|
|
+ forecastPowerUltraShortTermHisList.add(forecastPowerUltraShortTermHis);
|
|
|
+ ago++;
|
|
|
+ }
|
|
|
+
|
|
|
+ parsingStatus = FileTypeEnum.CDQ.name();
|
|
|
+ log.info("解析CDQ文件:{} 成功! O(∩_∩)O", file.getName());
|
|
|
+
|
|
|
+ // 删除之前的ForecastPowerUltraShortTerm记录
|
|
|
+ LambdaQueryWrapper<ForecastPowerUltraShortTerm> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ lambdaQueryWrapper.eq(ForecastPowerUltraShortTerm::getStationCode, parsingUrl.getStationCode());
|
|
|
+ lambdaQueryWrapper.eq(ForecastPowerUltraShortTerm::getForecastManufactor, parsingUrl.getForecastManufactor());
|
|
|
+ lambdaQueryWrapper.between(ForecastPowerUltraShortTerm::getForecastTime, forecastPowerUltraShortTermList.get(0).getForecastTime(), forecastPowerUltraShortTermList.get(forecastPowerUltraShortTermList.size() - 1).getForecastTime());
|
|
|
+ forecastPowerUltraShortTermService.remove(lambdaQueryWrapper);
|
|
|
+ // 批量保存新的ForecastPowerUltraShortTerm记录
|
|
|
+ forecastPowerUltraShortTermService.saveBatch(forecastPowerUltraShortTermList);
|
|
|
+
|
|
|
+ // 删除当天的ForecastPowerUltraShortTermHis记录
|
|
|
+ LambdaQueryWrapper<ForecastPowerUltraShortTermHis> forecastPowerUltraShortTermHisLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ forecastPowerUltraShortTermHisLambdaQueryWrapper.eq(ForecastPowerUltraShortTermHis::getGenDate, new Date(genDate));
|
|
|
+ forecastPowerUltraShortTermHisLambdaQueryWrapper.eq(ForecastPowerUltraShortTermHis::getStationCode, parsingUrl.getStationCode());
|
|
|
+ forecastPowerUltraShortTermHisLambdaQueryWrapper.eq(ForecastPowerUltraShortTermHis::getForecastManufactor, parsingUrl.getForecastManufactor());
|
|
|
+ forecastPowerUltraShortTermHisService.remove(forecastPowerUltraShortTermHisLambdaQueryWrapper);
|
|
|
+ // 批量保存新的ForecastPowerUltraShortTermHis记录
|
|
|
+ forecastPowerUltraShortTermHisService.saveBatch(forecastPowerUltraShortTermHisList);
|
|
|
+ } else {
|
|
|
+ parsingStatus += "解析CDQ文件时间错误";
|
|
|
+ log.error("解析CDQ文件时间错误");
|
|
|
}
|
|
|
-
|
|
|
- parsingStatus = FileTypeEnum.CDQ.name();
|
|
|
- log.info("解析CDQ文件:{} 成功! O(∩_∩)O", file.getName());
|
|
|
-
|
|
|
- // 删除之前的ForecastPowerUltraShortTerm记录
|
|
|
- LambdaQueryWrapper<ForecastPowerUltraShortTerm> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
|
|
- lambdaQueryWrapper.eq(ForecastPowerUltraShortTerm::getStationCode, parsingUrl.getStationCode());
|
|
|
- lambdaQueryWrapper.eq(ForecastPowerUltraShortTerm::getForecastManufactor, parsingUrl.getForecastManufactor());
|
|
|
- lambdaQueryWrapper.between(ForecastPowerUltraShortTerm::getForecastTime, forecastPowerUltraShortTermList.get(0).getForecastTime(), forecastPowerUltraShortTermList.get(forecastPowerUltraShortTermList.size() - 1).getForecastTime());
|
|
|
- forecastPowerUltraShortTermService.remove(lambdaQueryWrapper);
|
|
|
- // 批量保存新的ForecastPowerUltraShortTerm记录
|
|
|
- forecastPowerUltraShortTermService.saveBatch(forecastPowerUltraShortTermList);
|
|
|
-
|
|
|
- // 删除当天的ForecastPowerUltraShortTermHis记录
|
|
|
- LambdaQueryWrapper<ForecastPowerUltraShortTermHis> forecastPowerUltraShortTermHisLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
|
|
- forecastPowerUltraShortTermHisLambdaQueryWrapper.eq(ForecastPowerUltraShortTermHis::getGenDate, new Date(genDate));
|
|
|
- forecastPowerUltraShortTermHisLambdaQueryWrapper.eq(ForecastPowerUltraShortTermHis::getStationCode, parsingUrl.getStationCode());
|
|
|
- forecastPowerUltraShortTermHisLambdaQueryWrapper.eq(ForecastPowerUltraShortTermHis::getForecastManufactor, parsingUrl.getForecastManufactor());
|
|
|
- forecastPowerUltraShortTermHisService.remove(forecastPowerUltraShortTermHisLambdaQueryWrapper);
|
|
|
- // 批量保存新的ForecastPowerUltraShortTermHis记录
|
|
|
- forecastPowerUltraShortTermHisService.saveBatch(forecastPowerUltraShortTermHisList);
|
|
|
- } else {
|
|
|
- parsingStatus += "解析CDQ文件时间错误";
|
|
|
- log.error("解析CDQ文件时间错误");
|
|
|
}
|
|
|
- } else {
|
|
|
- parsingStatus += "解析超短期文件无数据";
|
|
|
- log.info("解析超短期文件无数据");
|
|
|
+ else {
|
|
|
+ parsingStatus += "解析超短期文件无数据";
|
|
|
+ log.error("解析超短期文件无数据");
|
|
|
+ }
|
|
|
+
|
|
|
+ }else {
|
|
|
+ parsingStatus += "cdq暂无单行解析方式";
|
|
|
+ log.info("cdq暂无单行解析方式");
|
|
|
}
|
|
|
- } else {
|
|
|
- parsingStatus += "cdq暂无单行解析方式";
|
|
|
- log.info("cdq暂无单行解析方式");
|
|
|
}
|
|
|
}
|
|
|
} catch (Exception e) {
|