Browse Source

解析站端文件调整

xusl 8 months ago
parent
commit
3c96703783

+ 34 - 7
ipp-idp/src/main/java/com/jiayue/ipp/idp/service/an/ParsingInterface.java

@@ -98,16 +98,12 @@ public interface ParsingInterface {
     }
 
 
-    default String parsingName(String sign, List<String> fileContent) {
-
+    default String parsingName(String sign, String dataRow) {
         String name = "";
         try {
             if (sign != null && !sign.equals("")) {
                 FileParsingConfig config = FieldUtil.getConfig(sign);
-
-                String s = fileContent.get(Integer.parseInt(config.getLineNumber()) - 1);
-
-                String[] strings = PUtil.splitLineWithSpace(s);
+                String[] strings = PUtil.splitLineWithSpace(dataRow);
                 int rowNumber = Integer.parseInt(config.getRowNumber()) - 1;
                 name = strings[rowNumber];
             }
@@ -116,8 +112,39 @@ public interface ParsingInterface {
         } finally {
             return name;
         }
-    }
 
+    }
 
+    default BigDecimal parsingRowValue(String sign, String dataRow) {
+        BigDecimal value = new BigDecimal(-99);
+        try {
+            if (sign != null && !sign.equals("")) {
+                FileParsingConfig config = FieldUtil.getConfig(sign);
+                String[] strings = PUtil.splitLineWithSpace(dataRow);
+                int rowNumber = Integer.parseInt(config.getRowNumber()) - 1;
+                String result = strings[rowNumber];
+                value = new BigDecimal(result);
+            }
+        } catch (RuntimeException e) {
+            e.printStackTrace();
+        } finally {
+            return value;
+        }
+    }
 
+    default String parsingRowStatus(String sign, String dataRow) {
+        String status = null;
+        try {
+            if (sign != null&&!sign.equals("")) {
+                FileParsingConfig config = FieldUtil.getConfig(sign);
+                String[] strings = PUtil.splitLineWithSpace(dataRow);
+                int rowNumber = Integer.parseInt(config.getRowNumber()) - 1;
+                status = strings[rowNumber];
+            }
+        } catch (RuntimeException e) {
+            e.printStackTrace();
+        } finally {
+            return status;
+        }
+    }
 }

+ 12 - 14
ipp-idp/src/main/java/com/jiayue/ipp/idp/service/impl/an/ParsingCftInfoServiceImpl.java

@@ -64,20 +64,19 @@ public class ParsingCftInfoServiceImpl extends ServiceImpl<ParsingCftInfoMapper,
     public FileAnalysisStatusDto parsing(File file, ParsingUrl parsingUrl) {
         FileAnalysisStatusDto fileAnalysisStatusDto = new FileAnalysisStatusDto();
         fileAnalysisStatusDto.setFileName(file.getName());
-        fileAnalysisStatusDto.setFileType(FileTypeEnum.CFT.getCode()+"");
+        fileAnalysisStatusDto.setFileType(FileTypeEnum.CFT.getCode() + "");
 
         try {
             List<ParsingCftInfo> parsingCftInfos = baseMapper.selectList(Wrappers.lambdaQuery(ParsingCftInfo.class).like(ParsingInfo::getStationCode, parsingUrl.getStationCode()));
             if (parsingCftInfos.size() > 0) {
-                List<WindTowerInfo> windTowerInfoList = windTowerInfoService.list(Wrappers.lambdaQuery(WindTowerInfo.class)
-                        .eq(WindTowerInfo::getStationCode, parsingUrl.getStationCode()));
-                if (windTowerInfoList.size() > 0) {
-                    List<String> fileContent = FileUtil.getFileContent(file);
-                    for (ParsingCftInfo parsingCftInfo : parsingCftInfos) {
-                        //判断文件名是否符合配置
-                        if (file.getName().indexOf(parsingCftInfo.getFileName()) >= 0) {
-
+                for (ParsingCftInfo parsingCftInfo : parsingCftInfos) {
+                    //判断文件名是否符合配置
+                    if (file.getName().indexOf(parsingCftInfo.getFileName()) >= 0) {
+                        List<WindTowerInfo> windTowerInfoList = windTowerInfoService.list(Wrappers.lambdaQuery(WindTowerInfo.class)
+                                .eq(WindTowerInfo::getStationCode, parsingUrl.getStationCode()));
+                        if (windTowerInfoList.size() > 0) {
                             if (parsingCftInfo.getDataType().equals(FieldUtil.SINGLE)) {
+                                List<String> fileContent = FileUtil.getFileContent(file);
                                 Long time = parsingTime(parsingCftInfo.getTime(), fileContent);
                                 if (time != 0L) {
                                     WindTowerStatusData windTowerStatusData = new WindTowerStatusData();
@@ -128,14 +127,13 @@ public class ParsingCftInfoServiceImpl extends ServiceImpl<ParsingCftInfoMapper,
                                 fileAnalysisStatusDto.setMessage("测风塔暂无多行解析方式");
                                 log.info("cft暂无多行解析方式");
                             }
+                        } else {
+                            fileAnalysisStatusDto.setStatus("0");
+                            fileAnalysisStatusDto.setMessage("测风塔未配置作为解析使用设备");
+                            log.info("cft未配置作为解析使用设备");
                         }
                     }
-                } else {
-                    fileAnalysisStatusDto.setStatus("0");
-                    fileAnalysisStatusDto.setMessage("测风塔未配置作为解析使用设备");
-                    log.info("cft未配置作为解析使用设备");
                 }
-
             }
         } catch (Exception e) {
             fileAnalysisStatusDto.setStatus("0");

+ 18 - 16
ipp-idp/src/main/java/com/jiayue/ipp/idp/service/impl/an/ParsingDqInfoServiceImpl.java

@@ -82,26 +82,28 @@ public class ParsingDqInfoServiceImpl extends ServiceImpl<ParsingDqInfoMapper, P
 
                         List<String> fileContent = FileUtil.getFileContent(file);
                         if (parsingDqInfo.getDataType().equals(FieldUtil.MULTI)) {
-                            List<BigDecimal> bigDecimals;
-                            if (parsingDqInfo.getFpValue() != null) ;
-                            bigDecimals = parsingFpValue(parsingDqInfo.getFpValue(), fileContent);
-
+                            List<BigDecimal> bigDecimals = null;
+                            if (parsingDqInfo.getFpValue() != null) {
+                                bigDecimals = parsingFpValue(parsingDqInfo.getFpValue(), fileContent);
+                            }
                             if (bigDecimals.size() > 0) {
 
 //                                LocalDate genDate = parsingGenDate(parsingDqInfo.getGenDate(), fileContent);
                                 Long forecastTime = parsingForecastTime(parsingDqInfo.getForecastTime(), fileContent);
-                                long secondDayTime = com.jiayue.ipp.idp.util.DateMomentUtil.getDayStartTime(System.currentTimeMillis())+1000*60*60*24;
-                                if (forecastTime==secondDayTime){
+//                                long secondDayTime = com.jiayue.ipp.idp.util.DateMomentUtil.getDayStartTime(System.currentTimeMillis())+1000*60*60*24;
+//                                if (forecastTime==secondDayTime){
                                     if (forecastTime != 0l) {
-                                        Long systemTime = System.currentTimeMillis();
+//                                        Long systemTime = System.currentTimeMillis();
+                                        // 生成日期
+                                        long genDate = DateMomentUtil.getDayStartTime(forecastTime-1000*60*60*24);
                                         for (BigDecimal bigDecimal : bigDecimals) {
                                             Date forecastDate = new Date(forecastTime);
                                             ForecastPowerShortTermHis forecastPowerShortTermHis = new ForecastPowerShortTermHis();
-                                            forecastPowerShortTermHis.setGenDate(new Date());
+                                            forecastPowerShortTermHis.setGenDate(new Date(genDate));
                                             forecastPowerShortTermHis.setStationCode(parsingUrl.getStationCode());
                                             forecastPowerShortTermHis.setAbleValue(bigDecimal);
                                             forecastPowerShortTermHis.setForecastTime(forecastDate);
-                                            forecastPowerShortTermHis.setForecastHowLongAgo(DateMomentUtil.getDaysBetweenTwoDate(systemTime,forecastTime));
+                                            forecastPowerShortTermHis.setForecastHowLongAgo(DateMomentUtil.getDaysBetweenTwoDate(genDate,forecastTime));
                                             forecastPowerShortTermHis.setForecastManufactor(parsingUrl.getForecastManufactor());
                                             forecastPowerShortTermHisList.add(forecastPowerShortTermHis);
 
@@ -109,7 +111,7 @@ public class ParsingDqInfoServiceImpl extends ServiceImpl<ParsingDqInfoMapper, P
                                             forecastPowerShortTerm.setForecastTime(forecastDate);
                                             forecastPowerShortTerm.setStationCode(parsingUrl.getStationCode());
                                             forecastPowerShortTerm.setFpValue(bigDecimal);
-                                            forecastPowerShortTerm.setGenDate(new Date());
+                                            forecastPowerShortTerm.setGenDate(new Date(genDate));
                                             forecastPowerShortTerm.setForecastManufactor(parsingUrl.getForecastManufactor());
                                             forecastPowerShortTermList.add(forecastPowerShortTerm);
 
@@ -131,18 +133,18 @@ public class ParsingDqInfoServiceImpl extends ServiceImpl<ParsingDqInfoMapper, P
                                         LambdaQueryWrapper<ForecastPowerShortTermHis> forecastPowerShortTermHisLambdaQueryWrapper = new LambdaQueryWrapper<>();
                                         forecastPowerShortTermHisLambdaQueryWrapper.eq(ForecastPowerShortTermHis::getStationCode, parsingUrl.getStationCode());
                                         forecastPowerShortTermHisLambdaQueryWrapper.eq(ForecastPowerShortTermHis::getForecastManufactor, parsingUrl.getForecastManufactor());
-                                        forecastPowerShortTermHisLambdaQueryWrapper.eq(ForecastPowerShortTermHis::getGenDate, DateUtil.format(new Date(),"yyyy-MM-dd"));
+                                        forecastPowerShortTermHisLambdaQueryWrapper.eq(ForecastPowerShortTermHis::getGenDate, new Date(genDate));
                                         forecastPowerShortTermHisService.remove(forecastPowerShortTermHisLambdaQueryWrapper);
                                         forecastPowerShortTermHisService.saveBatch(forecastPowerShortTermHisList);
 
 
                                         log.info("解析DQ文件:{} 成功! O(∩_∩)O", file.getName());
                                         fileAnalysisStatusDto.setStatus("1");
-                                    } else {
-                                        fileAnalysisStatusDto.setStatus("0");
-                                        fileAnalysisStatusDto.setMessage("解析短期文件时间错误");
-                                        log.error("解析DQ文件时间错误");
-                                    }
+//                                    } else {
+//                                        fileAnalysisStatusDto.setStatus("0");
+//                                        fileAnalysisStatusDto.setMessage("解析短期文件时间错误");
+//                                        log.error("解析DQ文件时间错误");
+//                                    }
                                 }
                                 else{
                                     fileAnalysisStatusDto.setStatus("0");

+ 47 - 52
ipp-idp/src/main/java/com/jiayue/ipp/idp/service/impl/an/ParsingFjInfoServiceImpl.java

@@ -27,6 +27,7 @@ import java.io.File;
 import java.time.Instant;
 import java.time.LocalDateTime;
 import java.time.ZoneId;
+import java.util.ArrayList;
 import java.util.Date;
 import java.util.List;
 import java.util.stream.Collectors;
@@ -68,71 +69,68 @@ public class ParsingFjInfoServiceImpl extends ServiceImpl<ParsingFjInfoMapper, P
         fileAnalysisStatusDto.setFileType(FileTypeEnum.FJ.getCode()+"");
 
         try {
-
-
             List<ParsingFjInfo> parsingFjInfos = baseMapper.selectList(Wrappers.lambdaQuery(ParsingFjInfo.class).like(ParsingInfo::getStationCode, ftpParsingUrl.getStationCode()));
             if (parsingFjInfos.size() > 0) {
-
-                List<String> fileContent = FileUtil.getFileContent(file);
-                List<WindTurbineInfo> windTurbineInfoList = windTurbineInfoService.list(Wrappers.lambdaQuery(WindTurbineInfo.class).eq(WindTurbineInfo::getStationCode, ftpParsingUrl.getStationCode()));
-
                 for (ParsingFjInfo parsingFjInfo : parsingFjInfos) {
                     //判断文件名是否符合配置
                     if (file.getName().indexOf(parsingFjInfo.getFileName()) >= 0) {
-
-                        WindTurbineStatusData windTurbineStatusData = new WindTurbineStatusData();
-
+                        List<WindTurbineStatusData> windTurbineStatusDataList = new ArrayList<>();
                         if (parsingFjInfo.getDataType().equals(FieldUtil.SINGLE)) {
-
-                            String fjName = parsingName(parsingFjInfo.getEquipmentName(), fileContent);
-
-                            List<WindTurbineInfo> filterWindTurbineInfos = windTurbineInfoList.stream().filter(i -> i.getName().equals(fjName)).collect(Collectors.toList());
-
-                            if (filterWindTurbineInfos.size() > 0) {
-                                windTurbineStatusData.setEquipmentId(filterWindTurbineInfos.get(0).getEquipmentNo());
-                                Long time = parsingTime(parsingFjInfo.getTime(), fileContent);
-                                if (time != 0l) {
-                                    windTurbineStatusData.setTime(new Date(time));
-
-                                    windTurbineStatusData.setActivePower(parsingValue(parsingFjInfo.getActivePower(), fileContent));
-                                    windTurbineStatusData.setCumulativeGeneratedEnergy(parsingValue(parsingFjInfo.getCumulativeGeneratedEnergy(), fileContent));
-                                    windTurbineStatusData.setDayGridConnectedHours(parsingValue(parsingFjInfo.getDayGridConnectedHours(), fileContent));
-                                    windTurbineStatusData.setWindWheelRatedSpeed(parsingValue(parsingFjInfo.getWindWheelRatedSpeed(), fileContent));
-                                    windTurbineStatusData.setDayElectricQuantity(parsingValue(parsingFjInfo.getDayElectricQuantity(), fileContent));
-                                    windTurbineStatusData.setElectricalCurrent(parsingValue(parsingFjInfo.getElectricalCurrent(), fileContent));
-                                    windTurbineStatusData.setPitchAngle(parsingValue(parsingFjInfo.getPitchAngle(), fileContent));
-                                    windTurbineStatusData.setPowerFactor(parsingValue(parsingFjInfo.getPowerFactor(), fileContent));
-                                    windTurbineStatusData.setReactivePower(parsingValue(parsingFjInfo.getReactivePower(), fileContent));
-                                    windTurbineStatusData.setVoltage(parsingValue(parsingFjInfo.getVoltage(), fileContent));
-                                    windTurbineStatusData.setWd(parsingValue(parsingFjInfo.getWd(), fileContent));
-                                    windTurbineStatusData.setWs(parsingValue(parsingFjInfo.getWs(), fileContent));
-                                    windTurbineStatusData.setT(parsingValue(parsingFjInfo.getT(), fileContent));
-
-                                    windTurbineStatusData.setStatus(parsingStatus(parsingFjInfo.getStatus(), fileContent));
-                                    windTurbineStatusData.setStationCode(parsingFjInfo.getStationCode());
-
-                                    windTurbineStatusDataService.save(windTurbineStatusData);
-                                    log.info("解析FJ文件:" + file.getName() + " 成功! O(∩_∩)O");
-                                    fileAnalysisStatusDto.setStatus("1");
-                                } else {
-                                    fileAnalysisStatusDto.setStatus("0");
-                                    fileAnalysisStatusDto.setMessage("解析风机文件时间错误");
-                                    log.error("解析FJ文件时间错误");
+                            List<WindTurbineInfo> windTurbineInfoList = windTurbineInfoService.list(Wrappers.lambdaQuery(WindTurbineInfo.class).eq(WindTurbineInfo::getStationCode, ftpParsingUrl.getStationCode()));
+                            List<String> fileContent = FileUtil.getFileContent(file);
+                            // 对#号开头的数据行获取
+                            for (String str: fileContent){
+                                if (str.startsWith("#")){
+                                    // 循环获取每行数据风机名称
+                                    String fjName = parsingName(parsingFjInfo.getEquipmentName(), str);
+                                    List<WindTurbineInfo> filterWindTurbineInfos = windTurbineInfoList.stream().filter(i -> i.getName().equals(fjName)).collect(Collectors.toList());
+                                    if (filterWindTurbineInfos.size() > 0) {
+                                        WindTurbineStatusData windTurbineStatusData = new WindTurbineStatusData();
+                                        windTurbineStatusData.setEquipmentId(filterWindTurbineInfos.get(0).getEquipmentNo());
+                                        Long time = parsingTime(parsingFjInfo.getTime(), fileContent);
+                                        if (time != 0l) {
+                                            windTurbineStatusData.setTime(new Date(time));
+                                            windTurbineStatusData.setActivePower(parsingRowValue(parsingFjInfo.getActivePower(), str));
+                                            windTurbineStatusData.setCumulativeGeneratedEnergy(parsingRowValue(parsingFjInfo.getCumulativeGeneratedEnergy(), str));
+                                            windTurbineStatusData.setDayGridConnectedHours(parsingRowValue(parsingFjInfo.getDayGridConnectedHours(), str));
+                                            windTurbineStatusData.setWindWheelRatedSpeed(parsingRowValue(parsingFjInfo.getWindWheelRatedSpeed(), str));
+                                            windTurbineStatusData.setDayElectricQuantity(parsingRowValue(parsingFjInfo.getDayElectricQuantity(), str));
+                                            windTurbineStatusData.setElectricalCurrent(parsingRowValue(parsingFjInfo.getElectricalCurrent(), str));
+                                            windTurbineStatusData.setPitchAngle(parsingRowValue(parsingFjInfo.getPitchAngle(), str));
+                                            windTurbineStatusData.setPowerFactor(parsingRowValue(parsingFjInfo.getPowerFactor(), str));
+                                            windTurbineStatusData.setReactivePower(parsingRowValue(parsingFjInfo.getReactivePower(), str));
+                                            windTurbineStatusData.setVoltage(parsingRowValue(parsingFjInfo.getVoltage(), str));
+                                            windTurbineStatusData.setWd(parsingRowValue(parsingFjInfo.getWd(), str));
+                                            windTurbineStatusData.setWs(parsingRowValue(parsingFjInfo.getWs(), str));
+                                            windTurbineStatusData.setT(parsingRowValue(parsingFjInfo.getT(), str));
+                                            windTurbineStatusData.setStatus(parsingRowStatus(parsingFjInfo.getStatus(), str));
+                                            windTurbineStatusData.setStationCode(ftpParsingUrl.getStationCode());
+                                        } else {
+                                            fileAnalysisStatusDto.setStatus("0");
+                                            fileAnalysisStatusDto.setMessage("解析风机文件时间错误");
+                                            log.error("解析FJ文件时间错误");
+                                        }
+                                        windTurbineStatusDataList.add(windTurbineStatusData);
+                                    } else {
+                                        fileAnalysisStatusDto.setStatus("0");
+                                        fileAnalysisStatusDto.setMessage("风机缺少配置无法解析");
+                                        log.info("风机 {} 缺少配置无法解析", fjName);
+                                    }
                                 }
-                            } else {
-                                fileAnalysisStatusDto.setStatus("0");
-                                fileAnalysisStatusDto.setMessage("风机在本地无配置无法解析");
-                                log.info("fj {} 在本地无配置无法解析", fjName);
                             }
                         } else {
                             fileAnalysisStatusDto.setStatus("0");
                             fileAnalysisStatusDto.setMessage("风机暂无多行解析方式");
                             log.info("fj暂无多行解析方式");
                         }
+                        if (!"0".equals(fileAnalysisStatusDto.getStatus()) && windTurbineStatusDataList.size() > 0){
+                            windTurbineStatusDataService.saveBatch(windTurbineStatusDataList);
+                            log.info("解析FJ文件:" + file.getName() + " 成功! O(∩_∩)O");
+                            fileAnalysisStatusDto.setStatus("1");
+                        }
                     }
                 }
             }
-
         } catch (Exception e) {
             fileAnalysisStatusDto.setStatus("0");
             fileAnalysisStatusDto.setMessage("解析风机数据错误!");
@@ -140,8 +138,5 @@ public class ParsingFjInfoServiceImpl extends ServiceImpl<ParsingFjInfoMapper, P
         } finally {
             return fileAnalysisStatusDto;
         }
-
     }
-
-
 }

+ 43 - 43
ipp-idp/src/main/java/com/jiayue/ipp/idp/service/impl/an/ParsingNbqInfoServiceImpl.java

@@ -79,49 +79,49 @@ public class ParsingNbqInfoServiceImpl extends ServiceImpl<ParsingNbqInfoMapper,
                     if (file.getName().indexOf(parsingNbqInfo.getFileName()) >= 0) {
 
                         //判断数据类型是单行还是多行
-                        if (parsingNbqInfo.getDataType().equals(FieldUtil.SINGLE)) {
-                            /**
-                             * 逆变器和风机id  需要解析名称找出对应设备存入id
-                             *
-                             */
-                            String nbqName = parsingName(parsingNbqInfo.getEquipmentName(), fileContent);
-                            List<InverterInfo> filterInverterInfos = inverterInfoList.stream().filter(i -> i.getName().equals(nbqName)).collect(Collectors.toList());
-                            if (filterInverterInfos.size() > 0) {
-                                Long time = parsingTime(parsingNbqInfo.getTime(), fileContent);
-                                if (time != 0l) {
-                                    InverterStatusData inverterStatusData = new InverterStatusData();
-                                    LocalDateTime localDateTime = LocalDateTime.ofInstant(Instant.ofEpochMilli(time), ZoneId.systemDefault());
-                                    inverterStatusData.setTime(localDateTime);
-
-                                    inverterStatusData.setActivePower(parsingValue(parsingNbqInfo.getActivePower(), fileContent));
-                                    inverterStatusData.setCumulativeGeneratedEnergy(parsingValue(parsingNbqInfo.getCumulativeGeneratedEnergy(), fileContent));
-                                    inverterStatusData.setDayGridConnectedHours(parsingValue(parsingNbqInfo.getDayGridConnectedHours(), fileContent));
-                                    inverterStatusData.setDayElectricQuantity(parsingValue(parsingNbqInfo.getDayElectricQuantity(), fileContent));
-                                    inverterStatusData.setElectricalCurrent(parsingValue(parsingNbqInfo.getElectricalCurrent(), fileContent));
-                                    inverterStatusData.setReactivePower(parsingValue(parsingNbqInfo.getReactivePower(), fileContent));
-                                    inverterStatusData.setPowerFactor(parsingValue(parsingNbqInfo.getPowerFactor(), fileContent));
-                                    inverterStatusData.setVoltage(parsingValue(parsingNbqInfo.getVoltage(), fileContent));
-                                    inverterStatusData.setStatus(parsingStatus(parsingNbqInfo.getStatus(), fileContent));
-                                    inverterStatusData.setEquipmentId(filterInverterInfos.get(0).getEquipmentNo());
-                                    inverterStatusData.setStationCode(ftpParsingUrl.getStationCode());
-                                    inverterStatusDataService.save(inverterStatusData);
-                                    log.info("解析NBQ文件:{} 成功! O(∩_∩)O", file.getName());
-                                    fileAnalysisStatusDto.setStatus("1");
-                                } else {
-                                    fileAnalysisStatusDto.setStatus("0");
-                                    fileAnalysisStatusDto.setMessage("逆变器在本地无配置无法解析");
-                                    log.info("nbq {} 在本地无配置无法解析", nbqName);
-                                }
-                            } else {
-                                fileAnalysisStatusDto.setStatus("0");
-                                fileAnalysisStatusDto.setMessage("解析逆变器文件时间错误");
-                                log.error("解析NBQ文件时间错误");
-                            }
-                        } else {
-                            fileAnalysisStatusDto.setStatus("0");
-                            fileAnalysisStatusDto.setMessage("逆变器暂无多行解析方式");
-                            log.info("nbq暂无多行解析方式");
-                        }
+//                        if (parsingNbqInfo.getDataType().equals(FieldUtil.SINGLE)) {
+//                            /**
+//                             * 逆变器和风机id  需要解析名称找出对应设备存入id
+//                             *
+//                             */
+//                            String nbqName = parsingName(parsingNbqInfo.getEquipmentName(), fileContent);
+//                            List<InverterInfo> filterInverterInfos = inverterInfoList.stream().filter(i -> i.getName().equals(nbqName)).collect(Collectors.toList());
+//                            if (filterInverterInfos.size() > 0) {
+//                                Long time = parsingTime(parsingNbqInfo.getTime(), fileContent);
+//                                if (time != 0l) {
+//                                    InverterStatusData inverterStatusData = new InverterStatusData();
+//                                    LocalDateTime localDateTime = LocalDateTime.ofInstant(Instant.ofEpochMilli(time), ZoneId.systemDefault());
+//                                    inverterStatusData.setTime(localDateTime);
+//
+//                                    inverterStatusData.setActivePower(parsingValue(parsingNbqInfo.getActivePower(), fileContent));
+//                                    inverterStatusData.setCumulativeGeneratedEnergy(parsingValue(parsingNbqInfo.getCumulativeGeneratedEnergy(), fileContent));
+//                                    inverterStatusData.setDayGridConnectedHours(parsingValue(parsingNbqInfo.getDayGridConnectedHours(), fileContent));
+//                                    inverterStatusData.setDayElectricQuantity(parsingValue(parsingNbqInfo.getDayElectricQuantity(), fileContent));
+//                                    inverterStatusData.setElectricalCurrent(parsingValue(parsingNbqInfo.getElectricalCurrent(), fileContent));
+//                                    inverterStatusData.setReactivePower(parsingValue(parsingNbqInfo.getReactivePower(), fileContent));
+//                                    inverterStatusData.setPowerFactor(parsingValue(parsingNbqInfo.getPowerFactor(), fileContent));
+//                                    inverterStatusData.setVoltage(parsingValue(parsingNbqInfo.getVoltage(), fileContent));
+//                                    inverterStatusData.setStatus(parsingStatus(parsingNbqInfo.getStatus(), fileContent));
+//                                    inverterStatusData.setEquipmentId(filterInverterInfos.get(0).getEquipmentNo());
+//                                    inverterStatusData.setStationCode(ftpParsingUrl.getStationCode());
+//                                    inverterStatusDataService.save(inverterStatusData);
+//                                    log.info("解析NBQ文件:{} 成功! O(∩_∩)O", file.getName());
+//                                    fileAnalysisStatusDto.setStatus("1");
+//                                } else {
+//                                    fileAnalysisStatusDto.setStatus("0");
+//                                    fileAnalysisStatusDto.setMessage("逆变器在本地无配置无法解析");
+//                                    log.info("nbq {} 在本地无配置无法解析", nbqName);
+//                                }
+//                            } else {
+//                                fileAnalysisStatusDto.setStatus("0");
+//                                fileAnalysisStatusDto.setMessage("解析逆变器文件时间错误");
+//                                log.error("解析NBQ文件时间错误");
+//                            }
+//                        } else {
+//                            fileAnalysisStatusDto.setStatus("0");
+//                            fileAnalysisStatusDto.setMessage("逆变器暂无多行解析方式");
+//                            log.info("nbq暂无多行解析方式");
+//                        }
                     }
                 }
             }

+ 39 - 39
ipp-idp/src/main/java/com/jiayue/ipp/idp/service/impl/an/ParsingQxzInfoServiceImpl.java

@@ -63,56 +63,56 @@ public class ParsingQxzInfoServiceImpl extends ServiceImpl<ParsingQxzInfoMapper,
 
             List<ParsingQxzInfo> parsingQxzInfos = baseMapper.selectList(Wrappers.lambdaQuery(ParsingQxzInfo.class).like(ParsingInfo::getStationCode, parsingUrl.getStationCode()));
             if (parsingQxzInfos.size() > 0) {
-                List<WeatherStationInfo> weatherStationInfoList = weatherStationInfoService.list(Wrappers.lambdaQuery(WeatherStationInfo.class)
-                        .eq(WeatherStationInfo::getStationCode, parsingUrl.getStationCode()));
-                if (weatherStationInfoList.size() > 0) {
-                    List<String> fileContent = FileUtil.getFileContent(file);
                     for (ParsingQxzInfo parsingQxzInfo : parsingQxzInfos) {
                         //判断文件名是否符合配置
                         if (file.getName().indexOf(parsingQxzInfo.getFileName()) >= 0) {
-                            if (parsingQxzInfo.getDataType().equals(FieldUtil.SINGLE)) {
-                                Long time = parsingTime(parsingQxzInfo.getTime(), fileContent);
-                                if (time != 0L) {
-                                    WeatherStationStatusData w = new WeatherStationStatusData();
-                                    w.setTime(new Date(time));
-                                    w.setAirT(parsingValue(parsingQxzInfo.getAirT(), fileContent));
-                                    w.setCellT(parsingValue(parsingQxzInfo.getCellT(), fileContent));
-                                    w.setDiffuseR(parsingValue(parsingQxzInfo.getDiffuseR(), fileContent));
-                                    w.setDiffuseRDA(parsingValue(parsingQxzInfo.getDiffuseRDA(), fileContent));
-                                    w.setDirectR(parsingValue(parsingQxzInfo.getDirectR(), fileContent));
-                                    w.setDirectRDA(parsingValue(parsingQxzInfo.getDirectRDA(), fileContent));
-                                    w.setGlobalR(parsingValue(parsingQxzInfo.getGlobalR(), fileContent));
-                                    w.setGlobalRDA(parsingValue(parsingQxzInfo.getGlobalRDA(), fileContent));
-                                    w.setHourDA(parsingValue(parsingQxzInfo.getHourDA(), fileContent));
-                                    w.setObliqueR(parsingValue(parsingQxzInfo.getObliqueR(), fileContent));
-                                    w.setObliqueRDA(parsingValue(parsingQxzInfo.getObliqueRDA(), fileContent));
-                                    w.setP(parsingValue(parsingQxzInfo.getP(), fileContent));
-                                    w.setRh(parsingValue(parsingQxzInfo.getRh(), fileContent));
-                                    w.setWd(parsingValue(parsingQxzInfo.getWd(), fileContent));
-                                    w.setWs(parsingValue(parsingQxzInfo.getWs(), fileContent));
-                                    w.setStatus(parsingStatus(parsingQxzInfo.getStatus(), fileContent));
-                                    w.setStationCode(parsingQxzInfo.getStationCode());
-                                    w.setEquipmentId(weatherStationInfoList.get(0).getEquipmentNo());
-                                    weatherStationStatusDataService.save(w);
-                                    fileAnalysisStatusDto.setStatus("1");
-                                    log.info("解析QXZ文件:{} 成功! O(∩_∩)O", file.getName());
+                            List<WeatherStationInfo> weatherStationInfoList = weatherStationInfoService.list(Wrappers.lambdaQuery(WeatherStationInfo.class)
+                                    .eq(WeatherStationInfo::getStationCode, parsingUrl.getStationCode()));
+                            if (weatherStationInfoList.size() > 0) {
+                                if (parsingQxzInfo.getDataType().equals(FieldUtil.SINGLE)) {
+                                    List<String> fileContent = FileUtil.getFileContent(file);
+                                    Long time = parsingTime(parsingQxzInfo.getTime(), fileContent);
+                                    if (time != 0L) {
+                                        WeatherStationStatusData w = new WeatherStationStatusData();
+                                        w.setTime(new Date(time));
+                                        w.setAirT(parsingValue(parsingQxzInfo.getAirT(), fileContent));
+                                        w.setCellT(parsingValue(parsingQxzInfo.getCellT(), fileContent));
+                                        w.setDiffuseR(parsingValue(parsingQxzInfo.getDiffuseR(), fileContent));
+                                        w.setDiffuseRDA(parsingValue(parsingQxzInfo.getDiffuseRDA(), fileContent));
+                                        w.setDirectR(parsingValue(parsingQxzInfo.getDirectR(), fileContent));
+                                        w.setDirectRDA(parsingValue(parsingQxzInfo.getDirectRDA(), fileContent));
+                                        w.setGlobalR(parsingValue(parsingQxzInfo.getGlobalR(), fileContent));
+                                        w.setGlobalRDA(parsingValue(parsingQxzInfo.getGlobalRDA(), fileContent));
+                                        w.setHourDA(parsingValue(parsingQxzInfo.getHourDA(), fileContent));
+                                        w.setObliqueR(parsingValue(parsingQxzInfo.getObliqueR(), fileContent));
+                                        w.setObliqueRDA(parsingValue(parsingQxzInfo.getObliqueRDA(), fileContent));
+                                        w.setP(parsingValue(parsingQxzInfo.getP(), fileContent));
+                                        w.setRh(parsingValue(parsingQxzInfo.getRh(), fileContent));
+                                        w.setWd(parsingValue(parsingQxzInfo.getWd(), fileContent));
+                                        w.setWs(parsingValue(parsingQxzInfo.getWs(), fileContent));
+                                        w.setStatus(parsingStatus(parsingQxzInfo.getStatus(), fileContent));
+                                        w.setStationCode(parsingQxzInfo.getStationCode());
+                                        w.setEquipmentId(weatherStationInfoList.get(0).getEquipmentNo());
+                                        weatherStationStatusDataService.save(w);
+                                        fileAnalysisStatusDto.setStatus("1");
+                                        log.info("解析QXZ文件:{} 成功! O(∩_∩)O", file.getName());
+                                    } else {
+                                        fileAnalysisStatusDto.setStatus("0");
+                                        fileAnalysisStatusDto.setMessage("解析气象站文件时间错误");
+                                        log.error("解析QXZ文件时间错误");
+                                    }
                                 } else {
                                     fileAnalysisStatusDto.setStatus("0");
-                                    fileAnalysisStatusDto.setMessage("解析气象站文件时间错误");
-                                    log.error("解析QXZ文件时间错误");
+                                    fileAnalysisStatusDto.setMessage("气象站暂无多行解析方式");
+                                    log.info("qxz暂无多行解析方式");
                                 }
                             } else {
                                 fileAnalysisStatusDto.setStatus("0");
-                                fileAnalysisStatusDto.setMessage("气象站暂无多行解析方式");
-                                log.info("qxz暂无多行解析方式");
+                                fileAnalysisStatusDto.setMessage("气象站未配置作为解析使用设备");
+                                log.info("qxz未配置作为解析使用设备");
                             }
                         }
                     }
-                } else {
-                    fileAnalysisStatusDto.setStatus("0");
-                    fileAnalysisStatusDto.setMessage("气象站未配置作为解析使用设备");
-                    log.info("qxz未配置作为解析使用设备");
-                }
             }
         } catch (Exception e) {
             fileAnalysisStatusDto.setStatus("0");