Explorar el Código

将解析站端文件时调用反射模式去掉

xusl hace 1 mes
padre
commit
4b032e652e

+ 37 - 8
ipp-idp/src/main/java/com/jiayue/ipp/idp/service/an/ParsingFileService.java

@@ -5,6 +5,7 @@ import com.jiayue.ipp.common.data.entity.an.ChannelStatus;
 import com.jiayue.ipp.common.data.entity.an.ParsingUrl;
 import com.jiayue.ipp.common.data.entity.an.ReportingRateRecords;
 import com.jiayue.ipp.idp.dto.*;
+import com.jiayue.ipp.idp.service.impl.an.*;
 import com.jiayue.ipp.idp.util.FileUtil;
 import com.jiayue.ipp.idp.util.JsonBeanUtil;
 import lombok.RequiredArgsConstructor;
@@ -32,10 +33,17 @@ public class ParsingFileService {
 
     private final ReportingRateRecordsService reportingRateRecordsService;
 
-    private final List<ParsingInterface> parsingInterfaces;
+//    private final List<ParsingInterface> parsingInterfaces;
 
     private final ChannelStatusService channelStatusService;
 
+    private final ParsingDqInfoServiceImpl parsingDqInfoService;
+    private final ParsingFjInfoServiceImpl parsingFjInfoService;
+    private final ParsingRpInfoServiceImpl parsingRpInfoService;
+    private final ParsingCdqInfoServiceImpl parsingCdqInfoService;
+    private final ParsingCftInfoServiceImpl parsingCftInfoService;
+
+
     //文件解析
     /*
      * 解析配置格式规则:
@@ -51,17 +59,38 @@ public class ParsingFileService {
      * */
     public FileAnalysisStatusDto parsingFile(File file, ParsingUrl parsingUrl) {
         log.info("开始尝试解析【{}】的 {}",parsingUrl.getStationCode(),file.getName());
+        String fileName = file.getName();
+
         FileAnalysisStatusDto fileAnalysisStatusDto=new FileAnalysisStatusDto();
-        //因为并不知道当前文件属于哪种类型文件,所以遍历接口实现类来进行对应文件的解析
-        for (ParsingInterface parsingInterface : parsingInterfaces) {
-            fileAnalysisStatusDto = parsingInterface.parsing(file, parsingUrl);
-            if (fileAnalysisStatusDto.getStatus()!=null) {
-                return fileAnalysisStatusDto;
-            }
+        if (fileName.contains("_DQ.WPD")){
+            fileAnalysisStatusDto = parsingDqInfoService.parsing(file, parsingUrl);
+        }
+        else if (fileName.contains("_CFT.RDT")){
+            fileAnalysisStatusDto = parsingCftInfoService.parsing(file, parsingUrl);
         }
-        if (fileAnalysisStatusDto.getStatus()==null){
+        else if (fileName.contains("_FJ.RDT")){
+            fileAnalysisStatusDto = parsingFjInfoService.parsing(file, parsingUrl);
+        }
+        else if (fileName.contains("_CDQ.WPD")){
+            fileAnalysisStatusDto = parsingCdqInfoService.parsing(file, parsingUrl);
+        }
+        else if (fileName.contains("_RP.RDT")){
+            fileAnalysisStatusDto = parsingRpInfoService.parsing(file, parsingUrl);
+        }
+        if (fileAnalysisStatusDto.getStatus()==null) {
             fileAnalysisStatusDto.setMessage("无配置符合文件解析失败!!!");
         }
+
+//        //因为并不知道当前文件属于哪种类型文件,所以遍历接口实现类来进行对应文件的解析
+//        for (ParsingInterface parsingInterface : parsingInterfaces) {
+//            fileAnalysisStatusDto = parsingInterface.parsing(file, parsingUrl);
+//            if (fileAnalysisStatusDto.getStatus()!=null) {
+//                return fileAnalysisStatusDto;
+//            }
+//        }
+//        if (fileAnalysisStatusDto.getStatus()==null){
+//            fileAnalysisStatusDto.setMessage("无配置符合文件解析失败!!!");
+//        }
         return fileAnalysisStatusDto;
     }