|
|
@@ -31,7 +31,7 @@ import com.itextpdf.text.Document;
|
|
|
import com.itextpdf.text.DocumentException;
|
|
|
import com.itextpdf.text.pdf.PdfCopy;
|
|
|
import com.itextpdf.text.pdf.PdfReader;
|
|
|
-import com.uas.report.core.exception.SystemError;
|
|
|
+import com.uas.report.core.exception.ReportException;
|
|
|
import com.uas.report.service.PrintService;
|
|
|
import com.uas.report.service.ResourceService;
|
|
|
import com.uas.report.support.JasperserverRestAPIConf;
|
|
|
@@ -112,7 +112,7 @@ public class PrintServiceImpl implements PrintService {
|
|
|
if (!isFileValid(file.getPath())) {
|
|
|
byte[] data = export(userName, reportName, whereCondition, otherParameters, "xls_with_only_data");
|
|
|
if (ArrayUtils.isEmpty(data)) {
|
|
|
- throw new SystemError("报表导出失败:" + reportName);
|
|
|
+ throw new ReportException("报表导出失败:" + reportName);
|
|
|
}
|
|
|
writeDataToFile(file.getPath(), data);
|
|
|
}
|
|
|
@@ -144,7 +144,7 @@ public class PrintServiceImpl implements PrintService {
|
|
|
pageSize = (Integer) result.remove("pageSize");
|
|
|
}
|
|
|
if (data == null || pageSize == null) {
|
|
|
- throw new SystemError("获取预览数据失败");
|
|
|
+ throw new ReportException("获取预览数据失败");
|
|
|
}
|
|
|
writeDataToFile(file.getPath(), data);
|
|
|
return pageSize;
|
|
|
@@ -163,7 +163,7 @@ public class PrintServiceImpl implements PrintService {
|
|
|
logger.info("Writed file..." + file.getPath());
|
|
|
fos.close();
|
|
|
} catch (IOException e) {
|
|
|
- throw new SystemError(e);
|
|
|
+ throw new ReportException(e).setDetailedMessage(e);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -185,7 +185,7 @@ public class PrintServiceImpl implements PrintService {
|
|
|
}
|
|
|
pdfReader.close();
|
|
|
} catch (IOException | DocumentException e) {
|
|
|
- throw new SystemError(e);
|
|
|
+ throw new ReportException(e).setDetailedMessage(e);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -194,7 +194,7 @@ public class PrintServiceImpl implements PrintService {
|
|
|
try {
|
|
|
return new PdfReader(pdfFilePath).getNumberOfPages();
|
|
|
} catch (IOException e) {
|
|
|
- throw new SystemError(e);
|
|
|
+ throw new ReportException(e).setDetailedMessage(e);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -247,7 +247,7 @@ public class PrintServiceImpl implements PrintService {
|
|
|
try {
|
|
|
resourceService.syncResources(userName);
|
|
|
} catch (URISyntaxException | IOException e) {
|
|
|
- throw new SystemError(e);
|
|
|
+ throw new ReportException(e).setDetailedMessage(e);
|
|
|
}
|
|
|
|
|
|
// 报表路径为报表根路径REPORT_DIR + 当前账套用户名userName
|
|
|
@@ -258,7 +258,7 @@ public class PrintServiceImpl implements PrintService {
|
|
|
// 报表模板不存在
|
|
|
if (!jrxmlFile.exists()) {
|
|
|
// 替换windows下路径中的双反斜杠为单斜杠
|
|
|
- throw new SystemError("未发现模板文件:" + jrxmlFile.getPath().replaceAll("\\\\", "/"));
|
|
|
+ throw new ReportException("未发现模板文件:" + jrxmlFile.getPath().replaceAll("\\\\", "/"));
|
|
|
}
|
|
|
|
|
|
String jasperFilePath = jrxmlFile.getPath().replace(".jrxml", ".jasper");
|
|
|
@@ -280,7 +280,7 @@ public class PrintServiceImpl implements PrintService {
|
|
|
}
|
|
|
} catch (JRException e) {
|
|
|
logger.error(e);
|
|
|
- throw new SystemError("编译报表模板失败:" + e.getMessage());
|
|
|
+ throw new ReportException("编译报表模板失败:" + e.getMessage()).setDetailedMessage(e);
|
|
|
}
|
|
|
|
|
|
// 向报表模板传递参数:报表路径、where条件、其他参数
|
|
|
@@ -300,7 +300,7 @@ public class PrintServiceImpl implements PrintService {
|
|
|
// 获取数据源
|
|
|
DataSource dataSource = getDataSource(userName);
|
|
|
if (dataSource == null) {
|
|
|
- throw new SystemError("获取数据源失败");
|
|
|
+ throw new ReportException("获取数据源失败");
|
|
|
}
|
|
|
|
|
|
connection = dataSource.getConnection();
|
|
|
@@ -359,13 +359,13 @@ public class PrintServiceImpl implements PrintService {
|
|
|
return result;
|
|
|
}
|
|
|
} catch (SQLException | JRException | IOException e) {
|
|
|
- throw new SystemError(e);
|
|
|
+ throw new ReportException(e).setDetailedMessage(e);
|
|
|
} finally {
|
|
|
if (connection != null) {
|
|
|
try {
|
|
|
connection.close();
|
|
|
} catch (SQLException e) {
|
|
|
- throw new SystemError(e);
|
|
|
+ throw new ReportException(e).setDetailedMessage(e);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -418,7 +418,7 @@ public class PrintServiceImpl implements PrintService {
|
|
|
}
|
|
|
}
|
|
|
} catch (Exception e) {
|
|
|
- throw new SystemError(e);
|
|
|
+ throw new ReportException(e).setDetailedMessage(e);
|
|
|
} finally {
|
|
|
try {
|
|
|
if (resultSet != null) {
|
|
|
@@ -439,7 +439,7 @@ public class PrintServiceImpl implements PrintService {
|
|
|
connection.close();
|
|
|
}
|
|
|
} catch (SQLException e) {
|
|
|
- throw new SystemError(e);
|
|
|
+ throw new ReportException(e).setDetailedMessage(e);
|
|
|
}
|
|
|
}
|
|
|
return null;
|
|
|
@@ -459,10 +459,10 @@ public class PrintServiceImpl implements PrintService {
|
|
|
} else if (exportFileType.equals("xls")) {
|
|
|
exportReportToXls(jasperPrint, outputStream);
|
|
|
} else {
|
|
|
- throw new SystemError("不支持导出为 " + exportFileType + "格式!");
|
|
|
+ throw new ReportException("不支持导出为 " + exportFileType + "格式!");
|
|
|
}
|
|
|
} catch (JRException e) {
|
|
|
- throw new SystemError(e);
|
|
|
+ throw new ReportException(e).setDetailedMessage(e);
|
|
|
}
|
|
|
}
|
|
|
|