浏览代码

Merge branch 'feature_report_929' into develop

wangzaijun 6 月之前
父节点
当前提交
b9b8703089

+ 7 - 2
service-base/src/main/java/com/simuwang/base/common/exception/ReportParseException.java

@@ -1,5 +1,6 @@
 package com.simuwang.base.common.exception;
 
+import cn.hutool.core.util.StrUtil;
 import com.smppw.common.pojo.enums.status.StatusCode;
 
 /**
@@ -8,19 +9,23 @@ import com.smppw.common.pojo.enums.status.StatusCode;
  * @description 报告解析的异常
  */
 public class ReportParseException extends RuntimeException {
-    private final int code;
+    private final Integer code;
     private final String msg;
 
     public ReportParseException(StatusCode statusCode) {
         this(statusCode.getCode(), statusCode.getMsg());
     }
 
-    public ReportParseException(int code, String msg) {
+    public ReportParseException(Integer code, String msg) {
         super(msg);
         this.code = code;
         this.msg = msg;
     }
 
+    public ReportParseException(StatusCode statusCode, Object... msgs) {
+        this(statusCode.getCode(), StrUtil.format(statusCode.getMsg(), msgs));
+    }
+
     public int getCode() {
         return code;
     }

+ 4 - 0
service-daq/src/main/java/com/simuwang/daq/components/report/parser/py/AbstractPyReportParser.java

@@ -11,6 +11,7 @@ import com.simuwang.base.mapper.FundInfoMapper;
 import com.simuwang.base.pojo.dos.FundAndCompanyInfoDO;
 import com.simuwang.base.pojo.dto.report.ParseResult;
 import com.simuwang.base.pojo.dto.report.ReportData;
+import com.simuwang.base.pojo.dto.report.ReportParseStatus;
 import com.simuwang.base.pojo.dto.report.ReportParserParams;
 import com.simuwang.daq.components.PythonReportConverter;
 import com.simuwang.daq.components.report.parser.ReportParser;
@@ -63,6 +64,9 @@ public abstract class AbstractPyReportParser<T extends ReportData> implements Re
         }
         String body = HttpUtil.post(pyBaseUrl + api, JSONUtil.toJsonStr(params));
         ParseResult<T> result = PythonReportConverter.convert(JSONUtil.parseObj(body), reportType);
+        if (result.getStatus() == null) {
+            throw new ReportParseException(ReportParseStatus.PARSE_FAIL, "资源文件不存在");
+        }
         if (!Objects.equals(1, result.getStatus())) {
             this.logger.error("报告{} 解析失败:{}", params, result.getMsg());
             throw new ReportParseException(result.getStatus(), result.getMsg());

+ 3 - 3
service-daq/src/main/java/com/simuwang/daq/service/EmailParseService.java

@@ -408,6 +408,9 @@ public class EmailParseService {
                     .filepath(emailContentInfoDTO.getFilePath()).registerNumber(registerNumber).build();
             ReportParser<ReportData> instance = this.reportParserFactory.getInstance(reportType, fileType);
             reportData = instance.parse(params);
+            result.setStatus(1);
+            result.setMsg("报告解析成功");
+            result.setData(reportData);
         } catch (ReportParseException e) {
             log.error("报告{}解析失败\n{}", params, e.getMsg());
             result.setStatus(e.getCode());
@@ -438,9 +441,6 @@ public class EmailParseService {
                 }
             }
         }
-        result.setStatus(1);
-        result.setMsg("报告解析成功");
-        result.setData(reportData);
         return result;
     }