Explorar el Código

解析实际功率

xusl hace 1 año
padre
commit
4f3ffe8bb6

+ 1 - 8
ipp-common/ipp-common-core/src/main/java/com/jiayue/ipfcst/common/core/util/DateMomentUtil.java

@@ -160,14 +160,7 @@ public abstract class DateMomentUtil {
      * @return 自然天数
      */
     public static Integer getDaysBetweenTwoDate(Long dateFrom, Long dateTo) {
-        int a = (int) ((DateMomentUtil.getDayStartTime(dateTo) - DateMomentUtil.getDayStartTime(dateFrom)) / (1000 * 60 * 60 * 24L));
-        if (a==2){
-            System.out.println(dateTo);
-            System.out.println(DateMomentUtil.getDayStartTime(dateTo));
-            System.out.println(DateUtil.format(new Date(dateTo),"yyyy-MM-dd HH:mm:ss"));
-            System.out.println("##############################################");
-        }
-        return a;
+        return (int) ((DateMomentUtil.getDayStartTime(dateTo) - DateMomentUtil.getDayStartTime(dateFrom)) / (1000 * 60 * 60 * 24L));
     }
 
 

+ 73 - 68
ipp-idp/src/main/java/com/jiayue/ipp/idp/service/impl/an/ParsingCdqInfoServiceImpl.java

@@ -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) {

+ 18 - 22
ipp-idp/src/main/java/com/jiayue/ipp/idp/service/impl/an/ParsingRpInfoServiceImpl.java

@@ -67,36 +67,32 @@ public class ParsingRpInfoServiceImpl extends ServiceImpl<ParsingRpInfoMapper, P
                 if (file.getName().contains(parsingRpInfo.getFileName())) {
 
                     List<String> fileContent = FileUtil.getFileContent(file);
-                    if (parsingRpInfo.getDataType().equals(FieldUtil.MULTI)) {
-                        List<BigDecimal> bigDecimals;
+                    if (parsingRpInfo.getDataType().equals(FieldUtil.SINGLE)) {
+                        BigDecimal bigDecimal;
                         if (parsingRpInfo.getAbleValue() != null) ;
-                        bigDecimals = parsingFpValue(parsingRpInfo.getRealValue(), fileContent);
+                        bigDecimal = parsingValue(parsingRpInfo.getRealValue(), fileContent);
 
-                        if (bigDecimals.size() > 0) {
 
-                            Long time = parsingForecastTime(parsingRpInfo.getTime(), fileContent);
+                        Long time = parsingForecastTime(parsingRpInfo.getTime(), fileContent);
 
-                            if (time != 0l) {
-                                PowerStationStatusData powerStationStatusData = new PowerStationStatusData();
-                                powerStationStatusData.setStationCode(parsingUrl.getStationCode());
-                                powerStationStatusData.setAbleValue(bigDecimals.get(0));
-                                powerStationStatusData.setRealValue(bigDecimals.get(0));
-                                LocalDateTime localDateTime = LocalDateTime.ofInstant(Instant.ofEpochMilli(time), ZoneId.systemDefault());
-                                powerStationStatusData.setTime(localDateTime);
+                        if (time != 0l) {
+                            PowerStationStatusData powerStationStatusData = new PowerStationStatusData();
+                            powerStationStatusData.setStationCode(parsingUrl.getStationCode());
+//                                powerStationStatusData.setAbleValue(bigDecimals.get(0));
+                            powerStationStatusData.setRealValue(bigDecimal);
+                            LocalDateTime localDateTime = LocalDateTime.ofInstant(Instant.ofEpochMilli(time), ZoneId.systemDefault());
+                            powerStationStatusData.setTime(localDateTime);
 
-                                powerStationStatusDataService.save(powerStationStatusData);
-
-                                log.info("解析RP文件:{} 成功! O(∩_∩)O", file.getName());
-                                parsingStatus = FileTypeEnum.RP.name();
-                            } else {
-                                parsingStatus += "解析RP文件时间错误";
-                                log.error("解析RP文件时间错误");
-                            }
+                            powerStationStatusDataService.save(powerStationStatusData);
 
+                            log.info("解析RP文件:{} 成功! O(∩_∩)O", file.getName());
+                            parsingStatus = FileTypeEnum.RP.name();
                         } else {
-                            parsingStatus += "解析实际功率文件无数据";
-                            log.error("解析实际功率文件无数据");
+                            parsingStatus += "解析RP文件时间错误";
+                            log.error("解析RP文件时间错误");
                         }
+
+
                     } else {
                         parsingStatus += "RP暂无单行解析方式";
                         log.info("RP暂无单行解析方式");