|
|
@@ -4,6 +4,7 @@ import java.io.ByteArrayOutputStream;
|
|
|
import java.io.File;
|
|
|
import java.io.IOException;
|
|
|
import java.io.OutputStream;
|
|
|
+import java.net.URISyntaxException;
|
|
|
import java.sql.Connection;
|
|
|
import java.sql.PreparedStatement;
|
|
|
import java.sql.ResultSet;
|
|
|
@@ -15,6 +16,7 @@ import java.util.Properties;
|
|
|
import javax.sql.DataSource;
|
|
|
|
|
|
import org.apache.log4j.Logger;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.util.CollectionUtils;
|
|
|
import org.springframework.util.StringUtils;
|
|
|
@@ -24,6 +26,8 @@ import com.alibaba.druid.pool.DruidDataSourceFactory;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.uas.report.core.exception.SystemError;
|
|
|
import com.uas.report.service.PrintService;
|
|
|
+import com.uas.report.service.ResourceService;
|
|
|
+import com.uas.report.support.JasperserverRestAPIConf;
|
|
|
import com.uas.report.util.ContextUtils;
|
|
|
import com.uas.report.util.ReportConstants;
|
|
|
|
|
|
@@ -56,7 +60,13 @@ import net.sf.jasperreports.export.SimplePdfReportConfiguration;
|
|
|
@Service
|
|
|
public class PrintServiceImpl implements PrintService {
|
|
|
|
|
|
- private static Logger logger = Logger.getLogger(PrintService.class);
|
|
|
+ @Autowired
|
|
|
+ private JasperserverRestAPIConf jsRestAPIConf;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private ResourceService resourceService;
|
|
|
+
|
|
|
+ private Logger logger = Logger.getLogger(getClass());
|
|
|
|
|
|
@Override
|
|
|
public byte[] export(String userName, String reportName, String whereCondition, String otherParameters,
|
|
|
@@ -87,6 +97,12 @@ public class PrintServiceImpl implements PrintService {
|
|
|
*/
|
|
|
private Map<String, Object> print(String userName, String reportName, String whereCondition, String otherParameters,
|
|
|
String exportFileType, Integer pageIndex) {
|
|
|
+ try {
|
|
|
+ resourceService.syncResources(userName);
|
|
|
+ } catch (URISyntaxException | IOException e1) {
|
|
|
+ e1.printStackTrace();
|
|
|
+ }
|
|
|
+
|
|
|
String message = "";
|
|
|
if (StringUtils.isEmpty(userName) || StringUtils.isEmpty(reportName)) {
|
|
|
message = "参数错误";
|
|
|
@@ -95,10 +111,10 @@ public class PrintServiceImpl implements PrintService {
|
|
|
}
|
|
|
|
|
|
// 报表路径为报表根路径REPORT_DIR + 当前账套用户名userName
|
|
|
- String reportDir = new StringBuilder(ReportConstants.REPORT_DIR).append(userName).append(File.separator)
|
|
|
+ String reportDir = new StringBuilder(jsRestAPIConf.getLocalBaseDir()).append("/").append(userName).append("/")
|
|
|
.toString();
|
|
|
|
|
|
- String jrxmlFilePath = new StringBuilder(reportDir).append("jrxml").append(File.separator).append(reportName)
|
|
|
+ String jrxmlFilePath = new StringBuilder(reportDir).append("jrxml").append("/").append(reportName)
|
|
|
.append(".jrxml").toString();
|
|
|
File jrxmlFile = new File(jrxmlFilePath);
|
|
|
// 报表模板不存在
|