|
|
@@ -89,17 +89,17 @@ public class PrintServiceImpl implements PrintService {
|
|
|
String otherParameters, Integer pageIndex) {
|
|
|
DataSource dataSource = null;
|
|
|
if (!StringUtils.isEmpty(profile)) {
|
|
|
- logger.info("point 6");
|
|
|
+ logger.info("getPlatformDataSource...");
|
|
|
dataSource = DataSourceUtils.getPlatformDataSource(userName, profile);
|
|
|
} else {
|
|
|
- logger.info("point 7");
|
|
|
+ logger.info("getUASDataSource...");
|
|
|
// 为空,说明不是来自B2C或B2B的请求,而是UAS系统
|
|
|
dataSource = DataSourceUtils.getUASDataSource(userName);
|
|
|
}
|
|
|
if (dataSource == null) {
|
|
|
throw new ReportException("获取数据源失败");
|
|
|
}
|
|
|
- logger.info("point 8");
|
|
|
+ logger.info("dataSource getted...");
|
|
|
return print(userName, reportName, whereCondition, otherParameters, null, pageIndex, dataSource);
|
|
|
}
|
|
|
|
|
|
@@ -140,17 +140,18 @@ public class PrintServiceImpl implements PrintService {
|
|
|
|
|
|
Connection connection = null;
|
|
|
try {
|
|
|
- logger.info("point 13");
|
|
|
+ logger.info("dataSource.getConnection...");
|
|
|
connection = dataSource.getConnection();
|
|
|
- logger.info("point 14");
|
|
|
- Map<String, Object> result = new HashMap<>();
|
|
|
+ logger.info("dataSource.getConnection done...");
|
|
|
|
|
|
+ Map<String, Object> result = new HashMap<>();
|
|
|
+ byte[] data = null;
|
|
|
// 从数据库获取数据填充报表
|
|
|
JasperPrint jasperPrint = null;
|
|
|
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
|
|
|
-
|
|
|
// exportFileType导出文件的格式不为空,表示是导出,并非预览
|
|
|
if (!StringUtils.isEmpty(exportFileType)) {
|
|
|
+ logger.info("export fillReport...");
|
|
|
// 只导出数据
|
|
|
if (exportFileType.equals("xls_with_only_data")) {
|
|
|
JasperDesign jasperDesign = JRXmlLoader.load(jrxmlFilePath);
|
|
|
@@ -165,13 +166,13 @@ public class PrintServiceImpl implements PrintService {
|
|
|
}
|
|
|
|
|
|
exportReport(jasperPrint, exportFileType, outputStream);
|
|
|
- byte[] data = outputStream.toByteArray();
|
|
|
+ logger.info("export fillReport done...");
|
|
|
+ data = outputStream.toByteArray();
|
|
|
outputStream.close();
|
|
|
- result.put("data", data);
|
|
|
- return result;
|
|
|
}
|
|
|
// 报表预览,则直接输出pdf,并且需要进行分页
|
|
|
else {
|
|
|
+ logger.info("preview fillReport...");
|
|
|
jasperPrint = JasperFillManager.fillReport(jasperFilePath, parameters, connection);
|
|
|
JRPdfExporter exporter = new JRPdfExporter();
|
|
|
if (pageIndex != null) {
|
|
|
@@ -191,20 +192,21 @@ public class PrintServiceImpl implements PrintService {
|
|
|
exporter.setExporterOutput(exporterOutput);
|
|
|
exporter.exportReport();
|
|
|
|
|
|
- byte[] data = outputStream.toByteArray();
|
|
|
+ logger.info("preview fillReport done...");
|
|
|
+ data = outputStream.toByteArray();
|
|
|
outputStream.close();
|
|
|
- result.put("data", data);
|
|
|
result.put("pageSize", jasperPrint.getPages().size());
|
|
|
- return result;
|
|
|
}
|
|
|
+ result.put("data", data);
|
|
|
+ return result;
|
|
|
} catch (SQLException | JRException | IOException e) {
|
|
|
throw new ReportException(e).setDetailedMessage(e);
|
|
|
} finally {
|
|
|
if (connection != null) {
|
|
|
try {
|
|
|
- logger.info("point 21");
|
|
|
+ logger.info("connection.close...");
|
|
|
connection.close();
|
|
|
- logger.info("point 22");
|
|
|
+ logger.info("connection.close done...");
|
|
|
} catch (SQLException e) {
|
|
|
throw new ReportException(e).setDetailedMessage(e);
|
|
|
}
|