Pārlūkot izejas kodu

B2B打印时若当前公司没有模板,则使用B2B标准库里的模板

sunyj 9 gadi atpakaļ
vecāks
revīzija
ee9636a96e

+ 1 - 1
src/main/java/com/uas/report/service/impl/FileServiceImpl.java

@@ -192,7 +192,7 @@ public class FileServiceImpl implements FileService {
 	@Override
 	public String getJrxmlFilePath(String userName, String reportName) {
 		ReportUtils.checkParameters(userName, reportName);
-		return new StringBuilder(getMasterPath(userName)).append("/").append(sysConf.getLocalJrxmlDir()).append("/")
+		return new StringBuilder(getMasterPath(userName)).append(sysConf.getLocalJrxmlDir()).append("/")
 				.append(reportName).append(".jrxml").toString();
 	}
 

+ 26 - 1
src/main/java/com/uas/report/service/impl/PrintServiceImpl.java

@@ -27,6 +27,7 @@ import com.uas.report.core.exception.ReportException;
 import com.uas.report.jasperreports.engine.export.CustomJRXlsExporter;
 import com.uas.report.service.FileService;
 import com.uas.report.service.PrintService;
+import com.uas.report.support.SysConf;
 import com.uas.report.util.DataSourceUtils;
 import com.uas.report.util.FileUtils;
 import com.uas.report.util.ReportConstants;
@@ -108,7 +109,7 @@ public class PrintServiceImpl implements PrintService {
 		// throw new ReportException(e).setDetailedMessage(e);
 		// }
 
-		String jrxmlFilePath = fileService.getJrxmlFilePath(userName, reportName);
+		String jrxmlFilePath = processJrxmlFilePathOfB2B(userName, reportName);
 		String jasperFilePath = maybeCompileJrxmlFile(jrxmlFilePath);
 
 		// 向报表模板传递参数:报表路径、where条件、其他参数
@@ -200,6 +201,30 @@ public class PrintServiceImpl implements PrintService {
 		}
 	}
 
+	@Autowired
+	private SysConf sysConf;
+
+	/**
+	 * 处理B2B的模板路径,如果企业没有自己的模板,则使用B2B的标准模板
+	 * 
+	 * @param userName
+	 *            账套名称
+	 * @param reportName
+	 *            模板名称
+	 * @return 模板路径
+	 */
+	private String processJrxmlFilePathOfB2B(String userName, String reportName) {
+		String jrxmlFilePath = fileService.getJrxmlFilePath(userName, reportName);
+		if (userName.startsWith("B2B")) {
+			File jrxmlFile = new File(jrxmlFilePath);
+			// 报表模板不存在,返回B2B标准模板路径
+			if (!jrxmlFile.exists()) {
+				return fileService.getJrxmlFilePath(sysConf.getStandardMaster() + "/B2B", reportName);
+			}
+		}
+		return jrxmlFilePath;
+	}
+
 	/**
 	 * 可能需要编译报表模板文件
 	 * 

+ 1 - 1
src/main/webapp/resources/js/preview/app.js

@@ -40,7 +40,7 @@ var waitWholePdfGeneratedCount = 0;
 // 页面过期时间为10分钟,之后必须重新加载
 var MAX_TIME = 10 * 60 * 1000;
 // 查询总的pdf状态的次数最高为100次,超过后需要重新加载页面
-var MAX_WAIT_WHOLE_PDF_GENERATED = 3;
+var MAX_WAIT_WHOLE_PDF_GENERATED = 100;
 var ALERT_TIMEOUT = "页面已过期,请刷新页面!";
 var ALERT_WAIT_WHOLE_PDF_GENERATED_TOO_LARGE = "PDF加载错误,请刷新页面!";