瀏覽代碼

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

sunyj 9 年之前
父節點
當前提交
13a788a44c

+ 3 - 0
src/main/java/com/uas/report/controller/PrintController.java

@@ -279,6 +279,7 @@ public class PrintController {
 	@ResponseBody
 	public Map<String, Object> getGeneratedPdfOrXlsInformation(String userName, String profile, String reportName,
 			String whereCondition, String otherParameters, String fileType, HttpServletRequest request) {
+		ReportUtils.checkParameters(userName, reportName);
 		Map<String, Object> result = new HashMap<>();
 		if (StringUtils.isEmpty(fileType)) {
 			fileType = ReportConstants.PDF_FILE_TYPE;
@@ -286,6 +287,8 @@ public class PrintController {
 		String filePath = ReportConstants.GENERATED_FILES_PATH + reportName + "/" + fileService.generateFileName(
 				userName, profile, reportName, whereCondition, otherParameters, ReportConstants.PDF_FILE_TYPE);
 		File file = null;
+
+		userName = printService.processMasterOfB2B(userName, reportName);
 		if (fileType.equals(ReportConstants.PDF_FILE_TYPE)) {
 			file = new File(PathUtils.getAppPath() + filePath + "." + ReportConstants.PDF_FILE_TYPE);
 			result.put("valid",

+ 11 - 0
src/main/java/com/uas/report/service/PrintService.java

@@ -75,4 +75,15 @@ public interface PrintService {
 	public Integer createPdfFile(String userName, String profile, String reportName, String whereCondition,
 			String otherParameters, String pdfFilePath, Integer pageIndex);
 
+	/**
+	 * 处理B2B账套,如果企业没有自己的模板,则使用B2B的标准模板(返回B2B标准账套)
+	 * 
+	 * @param userName
+	 *            账套名称
+	 * @param reportName
+	 *            模板名称
+	 * @return 处理后的B2B账套
+	 */
+	String processMasterOfB2B(String userName, String reportName);
+
 }

+ 20 - 25
src/main/java/com/uas/report/service/impl/PrintServiceImpl.java

@@ -31,6 +31,7 @@ import com.uas.report.support.SysConf;
 import com.uas.report.util.DataSourceUtils;
 import com.uas.report.util.FileUtils;
 import com.uas.report.util.ReportConstants;
+import com.uas.report.util.ReportUtils;
 
 import net.sf.jasperreports.engine.JRException;
 import net.sf.jasperreports.engine.JasperCompileManager;
@@ -59,6 +60,9 @@ public class PrintServiceImpl implements PrintService {
 	@Autowired
 	private FileService fileService;
 
+	@Autowired
+	private SysConf sysConf;
+
 	// @Autowired
 	// private ResourceService resourceService;
 
@@ -109,7 +113,8 @@ public class PrintServiceImpl implements PrintService {
 		// throw new ReportException(e).setDetailedMessage(e);
 		// }
 
-		String jrxmlFilePath = processJrxmlFilePathOfB2B(userName, reportName);
+		userName = processMasterOfB2B(userName, reportName);
+		String jrxmlFilePath = fileService.getJrxmlFilePath(userName, reportName);
 		String jasperFilePath = maybeCompileJrxmlFile(jrxmlFilePath);
 
 		// 向报表模板传递参数:报表路径、where条件、其他参数
@@ -201,30 +206,6 @@ 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;
-	}
-
 	/**
 	 * 可能需要编译报表模板文件
 	 * 
@@ -367,4 +348,18 @@ public class PrintServiceImpl implements PrintService {
 		return pageSize;
 	}
 
+	@Override
+	public String processMasterOfB2B(String userName, String reportName) {
+		ReportUtils.checkParameters(userName, reportName);
+		if (userName.startsWith("B2B")) {
+			String jrxmlFilePath = fileService.getJrxmlFilePath(userName, reportName);
+			File jrxmlFile = new File(jrxmlFilePath);
+			// 报表模板不存在,返回B2B标准模板账套
+			if (!jrxmlFile.exists()) {
+				return sysConf.getStandardMaster() + "/B2B";
+			}
+		}
+		return userName;
+	}
+
 }