Преглед изворни кода

B2C打印支持不同的profile配置

sunyj пре 9 година
родитељ
комит
6703fa27eb

+ 23 - 14
src/main/java/com/uas/report/controller/PrintController.java

@@ -45,6 +45,8 @@ public class PrintController {
 	 * 
 	 * @param userName
 	 *            不为null;当前账套用户名
+	 * @param profile
+	 *            可选(UAS系统不必传递该参数),用于标识请求源(B2C、B2B)是正式、测试还是开发版本:prod、test、dev
 	 * @param reportName
 	 *            不为null;需要导出的报表的名称,不带任何后缀(如导出采购单,即为"Purchase")
 	 * @param whereCondition
@@ -59,7 +61,7 @@ public class PrintController {
 	 * @param response
 	 */
 	@RequestMapping("")
-	public void print(String userName, String reportName, String whereCondition, String otherParameters,
+	public void print(String userName, String profile, String reportName, String whereCondition, String otherParameters,
 			String printType, HttpServletRequest request, HttpServletResponse response) {
 		// printType为空,默认进入预览页
 		if (StringUtils.isEmpty(printType)) {
@@ -77,9 +79,9 @@ public class PrintController {
 		}
 		// 下载pdf、纯数据excel
 		else if (printType.equals(ReportConstants.PDF_PRINT_TYPE)) {
-			export(userName, reportName, whereCondition, otherParameters, "pdf", response);
+			export(userName, profile, reportName, whereCondition, otherParameters, "pdf", response);
 		} else if (printType.equals(ReportConstants.EXCEL_PRINT_TYPE)) {
-			export(userName, reportName, whereCondition, otherParameters, "xls_with_only_data", response);
+			export(userName, profile, reportName, whereCondition, otherParameters, "xls_with_only_data", response);
 		} else {
 			throw new ReportException("printType不合法");
 		}
@@ -90,6 +92,8 @@ public class PrintController {
 	 * 
 	 * @param userName
 	 *            不为null;当前账套用户名
+	 * @param profile
+	 *            可选(UAS系统不必传递该参数),用于标识请求源(B2C、B2B)是正式、测试还是开发版本:prod、test、dev
 	 * @param reportName
 	 *            不为null;需要导出的报表的名称,不带任何后缀(如导出采购单,即为"Purchase")
 	 * @param whereCondition
@@ -103,8 +107,8 @@ public class PrintController {
 	 */
 	@RequestMapping("/export")
 	@ResponseBody
-	public void export(String userName, String reportName, String whereCondition, String otherParameters,
-			String exportFileType, HttpServletResponse response) {
+	public void export(String userName, String profile, String reportName, String whereCondition,
+			String otherParameters, String exportFileType, HttpServletResponse response) {
 		checkParameters(userName, reportName);
 
 		logger.info("开始导出报表:" + reportName);
@@ -115,7 +119,7 @@ public class PrintController {
 		byte[] data = null;
 
 		String filePath = ReportConstants.GENERATED_FILES_PATH + reportName + "/"
-				+ printService.generateFileName(userName, reportName, whereCondition, otherParameters);
+				+ printService.generateFileName(userName, profile, reportName, whereCondition, otherParameters);
 		if (exportFileType.equals("xls_with_only_data")) {
 			filePath += ".xls";
 		} else {
@@ -124,7 +128,7 @@ public class PrintController {
 		File file = new File(PathUtils.getAppPath() + filePath);
 		// 文件无效(不存在或过期),创建
 		if (!printService.isFileValid(file.getPath())) {
-			data = printService.export(userName, reportName, whereCondition, otherParameters, exportFileType);
+			data = printService.export(userName, profile, reportName, whereCondition, otherParameters, exportFileType);
 			if (ArrayUtils.isEmpty(data)) {
 				throw new ReportException("报表导出失败:" + reportName);
 			}
@@ -171,6 +175,8 @@ public class PrintController {
 	 * 
 	 * @param userName
 	 *            不为null;当前账套用户名
+	 * @param profile
+	 *            可选(UAS系统不必传递该参数),用于标识请求源(B2C、B2B)是正式、测试还是开发版本:prod、test、dev
 	 * @param reportName
 	 *            不为null;需要预览的报表的名称,不带任何后缀(如预览采购单,即为"Purchase")
 	 * @param whereCondition
@@ -185,7 +191,7 @@ public class PrintController {
 	 */
 	@RequestMapping(value = "/loadPdfData")
 	@ResponseBody
-	public Map<String, Object> loadPdfData(String userName, String reportName, String whereCondition,
+	public Map<String, Object> loadPdfData(String userName, String profile, String reportName, String whereCondition,
 			String otherParameters, Integer pageIndex, HttpServletResponse response) {
 		checkParameters(userName, reportName);
 		logger.info("开始预览报表:" + reportName);
@@ -193,7 +199,8 @@ public class PrintController {
 
 		// 相对路径,返回给前端
 		String pdfPath = ReportConstants.GENERATED_FILES_PATH + reportName + "/"
-				+ printService.generateFileName(userName, reportName, whereCondition, otherParameters) + ".pdf";
+				+ printService.generateFileName(userName, profile, reportName, whereCondition, otherParameters)
+				+ ".pdf";
 		File file = new File(PathUtils.getAppPath() + pdfPath);
 		// 文件无效(不存在或过期),重新创建pdf文件
 		if (!printService.isFileValid(file.getPath())) {
@@ -201,14 +208,14 @@ public class PrintController {
 			// 检查第一页的pdf文件是否存在,若不存在,先生成第一页pdf,返回给前台展示,
 			// 再开线程生成后面页的pdf和总的pdf(即未分页的pdf),以备后续可能的打印、下载操作使用
 			if (pageIndex != null) {
-				Integer pageSize = printService.previewFirstPage(userName, reportName, whereCondition, otherParameters,
-						file.getPath());
+				Integer pageSize = printService.previewFirstPage(userName, profile, reportName, whereCondition,
+						otherParameters, file.getPath());
 				result = new HashMap<>();
 				result.put("pageSize", pageSize);
 			}
 			// 参数pageIndex为null,表示是直接打印,需要先生成总的pdf
 			else {
-				result = printService.preview(userName, reportName, whereCondition, otherParameters, null);
+				result = printService.preview(userName, profile, reportName, whereCondition, otherParameters, null);
 				byte[] data = null;
 				if (result != null && result.containsKey("data")) {
 					data = (byte[]) result.remove("data");
@@ -234,6 +241,8 @@ public class PrintController {
 	 * 
 	 * @param userName
 	 *            不为null;当前账套用户名
+	 * @param profile
+	 *            可选(UAS系统不必传递该参数),用于标识请求源(B2C、B2B)是正式、测试还是开发版本:prod、test、dev
 	 * @param reportName
 	 *            不为null;需要预览的报表的名称,不带任何后缀(如预览采购单,即为"Purchase")
 	 * @param whereCondition
@@ -247,14 +256,14 @@ public class PrintController {
 	 */
 	@RequestMapping(value = "/getGeneratedPdfOrXlsInformation")
 	@ResponseBody
-	public Map<String, Object> getGeneratedPdfOrXlsInformation(String userName, String reportName,
+	public Map<String, Object> getGeneratedPdfOrXlsInformation(String userName, String profile, String reportName,
 			String whereCondition, String otherParameters, String pdfOrXls) {
 		Map<String, Object> result = new HashMap<>();
 		if (StringUtils.isEmpty(pdfOrXls)) {
 			pdfOrXls = "pdf";
 		}
 		String filePath = ReportConstants.GENERATED_FILES_PATH + reportName + "/"
-				+ printService.generateFileName(userName, reportName, whereCondition, otherParameters);
+				+ printService.generateFileName(userName, profile, reportName, whereCondition, otherParameters);
 		File file = new File(PathUtils.getAppPath() + filePath + "." + pdfOrXls);
 		result.put("file", file.getPath());
 		if (pdfOrXls.equals("pdf")) {

+ 68 - 2
src/main/java/com/uas/report/service/PrintService.java

@@ -26,9 +26,31 @@ public interface PrintService {
 	 *            报表导出的格式,默认为pdf
 	 * @return 导出的文件的字节数组
 	 */
+	// TODO delete
 	public byte[] export(String userName, String reportName, String whereCondition, String otherParameters,
 			String exportFileType);
 
+	/**
+	 * 导出报表
+	 * 
+	 * @param userName
+	 *            不为null;当前账套用户名
+	 * @param profile
+	 *            用于标识请求源(B2C、B2B)是正式、测试还是开发版本:prod、test、dev
+	 * @param reportName
+	 *            不为null;需要导出的报表的名称,不带任何后缀(如导出采购单,即为"Purchase")
+	 * @param whereCondition
+	 *            可为null;where之后的条件(包括where)
+	 * @param otherParameters
+	 *            若模板已指定需要的参数,则不可为null;其他参数,区别于whereCondition,报表某些字段的值取决于这些参数;
+	 *            JSON格式,数据为键值对
+	 * @param exportFileType
+	 *            报表导出的格式,默认为pdf
+	 * @return 导出的文件的字节数组
+	 */
+	public byte[] export(String userName, String profile, String reportName, String whereCondition,
+			String otherParameters, String exportFileType);
+
 	/**
 	 * 预览报表
 	 * 
@@ -45,9 +67,31 @@ public interface PrintService {
 	 *            分页展示,当前页码,从0开始
 	 * @return 报表数据"data": byte[];总页数"pageSize": Integer
 	 */
+	// TODO delete
 	public Map<String, Object> preview(String userName, String reportName, String whereCondition,
 			String otherParameters, Integer pageIndex);
 
+	/**
+	 * 预览报表
+	 * 
+	 * @param userName
+	 *            不为null;当前账套用户名
+	 * @param profile
+	 *            用于标识请求源(B2C、B2B)是正式、测试还是开发版本:prod、test、dev
+	 * @param reportName
+	 *            不为null;需要预览的报表的名称,不带任何后缀(如预览采购单,即为"Purchase")
+	 * @param whereCondition
+	 *            可为null;where之后的条件(包括where)
+	 * @param otherParameters
+	 *            若模板已指定需要的参数,则不可为null;其他参数,区别于whereCondition,报表某些字段的值取决于这些参数;
+	 *            JSON格式,数据为键值对
+	 * @param pageIndex
+	 *            分页展示,当前页码,从0开始
+	 * @return 报表数据"data": byte[];总页数"pageSize": Integer
+	 */
+	public Map<String, Object> preview(String userName, String profile, String reportName, String whereCondition,
+			String otherParameters, Integer pageIndex);
+
 	/**
 	 * 先生成第一页pdf,返回给前台展示,以提高预览速度;
 	 * 
@@ -55,6 +99,8 @@ public interface PrintService {
 	 * 
 	 * @param userName
 	 *            不为null;当前账套用户名
+	 * @param profile
+	 *            可选(UAS系统不必传递该参数),用于标识请求源(B2C、B2B)是正式、测试还是开发版本:prod、test、dev
 	 * @param reportName
 	 *            不为null;需要预览的报表的名称,不带任何后缀(如预览采购单,即为"Purchase")
 	 * @param whereCondition
@@ -66,8 +112,8 @@ public interface PrintService {
 	 *            该报表对应的pdf绝对路径
 	 * @return 总页数
 	 */
-	public Integer previewFirstPage(String userName, String reportName, String whereCondition, String otherParameters,
-			String pdfFilePath);
+	public Integer previewFirstPage(String userName, String profile, String reportName, String whereCondition,
+			String otherParameters, String pdfFilePath);
 
 	/**
 	 * 利用字节数组数据创建文件
@@ -112,8 +158,28 @@ public interface PrintService {
 	 *            JSON格式,数据为键值对
 	 * @return 生成的文件名(不含后缀名)
 	 */
+	// TODO delete
 	public String generateFileName(String userName, String reportName, String whereCondition, String otherParameters);
 
+	/**
+	 * 根据报表名、账套名等生成文件名
+	 * 
+	 * @param userName
+	 *            不为null;当前账套用户名
+	 * @param profile
+	 *            用于标识请求源(B2C、B2B)是正式、测试还是开发版本:prod、test、dev
+	 * @param reportName
+	 *            不为null;需要预览的报表的名称,不带任何后缀(如预览采购单,即为"Purchase")
+	 * @param whereCondition
+	 *            可为null;where之后的条件(包括where)
+	 * @param otherParameters
+	 *            若模板已指定需要的参数,则不可为null;其他参数,区别于whereCondition,报表某些字段的值取决于这些参数;
+	 *            JSON格式,数据为键值对
+	 * @return 生成的文件名(不含后缀名)
+	 */
+	public String generateFileName(String userName, String profile, String reportName, String whereCondition,
+			String otherParameters);
+
 	/**
 	 * 判断文件是否有效(文件存在并且未过有效期)
 	 * 

+ 92 - 24
src/main/java/com/uas/report/service/impl/PrintServiceImpl.java

@@ -74,7 +74,24 @@ public class PrintServiceImpl implements PrintService {
 	@Override
 	public byte[] export(String userName, String reportName, String whereCondition, String otherParameters,
 			String exportFileType) {
-		Map<String, Object> result = print(userName, reportName, whereCondition, otherParameters, exportFileType, null);
+		return export(userName, null, reportName, whereCondition, otherParameters, exportFileType);
+	}
+
+	@Override
+	public byte[] export(String userName, String profile, String reportName, String whereCondition,
+			String otherParameters, String exportFileType) {
+		DataSource dataSource = null;
+		if (!StringUtils.isEmpty(profile)) {
+			dataSource = getDataSource(userName, profile);
+		} else {
+			// 为空,说明不是来自B2C或B2B的请求,而是UAS系统
+			dataSource = getUASDataSource(userName);
+		}
+		if (dataSource == null) {
+			throw new ReportException("获取数据源失败");
+		}
+		Map<String, Object> result = print(userName, reportName, whereCondition, otherParameters, exportFileType, null,
+				dataSource);
 		if (!CollectionUtils.isEmpty(result)) {
 			return (byte[]) result.get("data");
 		}
@@ -84,14 +101,30 @@ public class PrintServiceImpl implements PrintService {
 	@Override
 	public Map<String, Object> preview(String userName, String reportName, String whereCondition,
 			String otherParameters, Integer pageIndex) {
-		return print(userName, reportName, whereCondition, otherParameters, null, pageIndex);
+		return preview(userName, null, reportName, whereCondition, otherParameters, pageIndex);
+	}
+
+	@Override
+	public Map<String, Object> preview(String userName, String profile, String reportName, String whereCondition,
+			String otherParameters, Integer pageIndex) {
+		DataSource dataSource = null;
+		if (!StringUtils.isEmpty(profile)) {
+			dataSource = getDataSource(userName, profile);
+		} else {
+			// 为空,说明不是来自B2C或B2B的请求,而是UAS系统
+			dataSource = getUASDataSource(userName);
+		}
+		if (dataSource == null) {
+			throw new ReportException("获取数据源失败");
+		}
+		return print(userName, reportName, whereCondition, otherParameters, null, pageIndex, dataSource);
 	}
 
 	@Override
-	public Integer previewFirstPage(final String userName, final String reportName, final String whereCondition,
-			final String otherParameters, final String pdfFilePath) {
+	public Integer previewFirstPage(final String userName, final String profile, final String reportName,
+			final String whereCondition, final String otherParameters, final String pdfFilePath) {
 		// 先生成第一页pdf
-		final Integer pageSize = writePdfData(userName, reportName, whereCondition, otherParameters,
+		final Integer pageSize = writePdfData(userName, profile, reportName, whereCondition, otherParameters,
 				pdfFilePath.replace(".pdf", "_1.pdf"), 1);
 
 		// 再开线程生成后面页的pdf、总的pdf(即未分页的pdf)、纯数据excel
@@ -100,17 +133,18 @@ public class PrintServiceImpl implements PrintService {
 			public void run() {
 				// 生成之后2~5页的pdf,防止数据量较大的情况下,卡在生成总的pdf阶段,此时查看前5页也不会卡顿
 				for (int i = 2; i <= Math.min(pageSize, 5); i++) {
-					writePdfData(userName, reportName, whereCondition, otherParameters,
+					writePdfData(userName, profile, reportName, whereCondition, otherParameters,
 							pdfFilePath.replace(".pdf", "_" + i + ".pdf"), i);
 				}
 				// 生成总的pdf
-				writePdfData(userName, reportName, whereCondition, otherParameters, pdfFilePath, null);
+				writePdfData(userName, profile, reportName, whereCondition, otherParameters, pdfFilePath, null);
 				writePagedPdfFiles(pdfFilePath);
 				// 生成纯数据excel
 				File file = new File(pdfFilePath.replace(".pdf", ".xls"));
 				// 文件无效(不存在或过期),创建
 				if (!isFileValid(file.getPath())) {
-					byte[] data = export(userName, reportName, whereCondition, otherParameters, "xls_with_only_data");
+					byte[] data = export(userName, profile, reportName, whereCondition, otherParameters,
+							"xls_with_only_data");
 					if (ArrayUtils.isEmpty(data)) {
 						throw new ReportException("报表导出失败:" + reportName);
 					}
@@ -126,17 +160,26 @@ public class PrintServiceImpl implements PrintService {
 	 * 获取第pageIndex页的pdf数据并写入pdfFilePath路径下
 	 * 
 	 * @param userName
+	 *            不为null;当前账套用户名
+	 * @param profile
+	 *            可选(UAS系统不必传递该参数),用于标识请求源(B2C、B2B)是正式、测试还是开发版本:prod、test、dev
 	 * @param reportName
+	 *            不为null;需要预览的报表的名称,不带任何后缀(如预览采购单,即为"Purchase")
 	 * @param whereCondition
+	 *            可为null;where之后的条件(包括where)
 	 * @param otherParameters
+	 *            若模板已指定需要的参数,则不可为null;其他参数,区别于whereCondition,报表某些字段的值取决于这些参数;
+	 *            JSON格式,数据为键值对
 	 * @param pdfFilePath
+	 *            该报表对应的pdf绝对路径
 	 * @param pageIndex
+	 *            页码
 	 * @return 总页数
 	 */
-	public Integer writePdfData(String userName, String reportName, String whereCondition, String otherParameters,
-			String pdfFilePath, Integer pageIndex) {
+	private Integer writePdfData(String userName, String profile, String reportName, String whereCondition,
+			String otherParameters, String pdfFilePath, Integer pageIndex) {
 		File file = new File(pdfFilePath);
-		Map<String, Object> result = preview(userName, reportName, whereCondition, otherParameters, pageIndex);
+		Map<String, Object> result = preview(userName, profile, reportName, whereCondition, otherParameters, pageIndex);
 		byte[] data = null;
 		Integer pageSize = null;
 		if (result != null && result.containsKey("data") && result.containsKey("pageSize")) {
@@ -200,10 +243,19 @@ public class PrintServiceImpl implements PrintService {
 
 	@Override
 	public String generateFileName(String userName, String reportName, String whereCondition, String otherParameters) {
+		return generateFileName(userName, null, reportName, whereCondition, otherParameters);
+	}
+
+	@Override
+	public String generateFileName(String userName, String profile, String reportName, String whereCondition,
+			String otherParameters) {
 		if (StringUtils.isEmpty(userName) || StringUtils.isEmpty(reportName)) {
 			return null;
 		}
 		StringBuilder stringBuilder = new StringBuilder(userName);
+		if (!StringUtils.isEmpty(profile)) {
+			stringBuilder.append(profile);
+		}
 		if (!StringUtils.isEmpty(whereCondition)) {
 			stringBuilder.append(whereCondition);
 		}
@@ -243,7 +295,7 @@ public class PrintServiceImpl implements PrintService {
 	 * @return
 	 */
 	private Map<String, Object> print(String userName, String reportName, String whereCondition, String otherParameters,
-			String exportFileType, Integer pageIndex) {
+			String exportFileType, Integer pageIndex, DataSource dataSource) {
 		try {
 			resourceService.syncResources(userName);
 		} catch (URISyntaxException | IOException e) {
@@ -297,12 +349,6 @@ public class PrintServiceImpl implements PrintService {
 
 		Connection connection = null;
 		try {
-			// 获取数据源
-			DataSource dataSource = getDataSource(userName);
-			if (dataSource == null) {
-				throw new ReportException("获取数据源失败");
-			}
-
 			connection = dataSource.getConnection();
 			Map<String, Object> result = new HashMap<>();
 
@@ -372,17 +418,13 @@ public class PrintServiceImpl implements PrintService {
 	}
 
 	/**
-	 * 根据当前账套用户名,从主数据库master表获取账套数据库配置信息,作为报表模板的数据源
+	 * 根据当前账套用户名,从主数据库master表获取(UAS系统)账套数据库配置信息,作为报表模板的数据源
 	 * 
 	 * @param userName
 	 *            当前账套用户名
 	 * @return
 	 */
-	private DataSource getDataSource(String userName) {
-		// 如果userName是B2C,直接获取配置好的B2C数据源
-		if (userName.equals("B2C")) {
-			return ContextUtils.getApplicationContext().getBean("b2cDataSource", DruidDataSource.class);
-		}
+	private DataSource getUASDataSource(String userName) {
 		// 默认数据源(主数据库)
 		DruidDataSource defaultDataSource = ContextUtils.getApplicationContext().getBean("defaultSob",
 				DruidDataSource.class);
@@ -445,6 +487,32 @@ public class PrintServiceImpl implements PrintService {
 		return null;
 	}
 
+	/**
+	 * 根据当前账套用户名和profile配置,获取相应B2C、B2B数据源
+	 * 
+	 * @param userName
+	 *            当前账套用户名
+	 * @param profile
+	 *            用于标识请求源(B2C、B2B)是正式、测试还是开发版本:prod、test、dev
+	 * @return
+	 */
+	private DataSource getDataSource(String userName, String profile) {
+		// 如果userName是B2C,直接获取配置好的B2C数据源
+		if (userName.equalsIgnoreCase("B2C")) {
+			if (profile.equalsIgnoreCase("dev")) {
+				return ContextUtils.getApplicationContext().getBean("b2cDevDataSource", DruidDataSource.class);
+			} else if (profile.equalsIgnoreCase("test")) {
+				return ContextUtils.getApplicationContext().getBean("b2cTestDataSource", DruidDataSource.class);
+			} else if (profile.equalsIgnoreCase("prod")) {
+				return ContextUtils.getApplicationContext().getBean("b2cProdDataSource", DruidDataSource.class);
+			} else {
+				throw new ReportException("profile只能为:dev、test或prod,不可为" + profile);
+			}
+		} else {
+			throw new ReportException("暂时不支持" + userName);
+		}
+	}
+
 	/**
 	 * 以不同的格式导出报表
 	 * 

+ 14 - 4
src/main/resources/dev/jdbc-b2c.properties

@@ -1,8 +1,18 @@
-#B2C的数据库信息
+#B2C
+#dev
+jdbc.b2c.dev.url=jdbc:oracle:thin:@192.168.253.6:1521:orcl
+jdbc.b2c.dev.username=uuplatformdemo
+jdbc.b2c.dev.password=selectuuplatform
+#test
+jdbc.b2c.test.url=jdbc:oracle:thin:@192.168.253.6:1521:orcl
+jdbc.b2c.test.username=uuplatformdemo
+jdbc.b2c.test.password=selectuuplatform
+#prod
+jdbc.b2c.prod.url=jdbc:oracle:thin:@10.10.100.200:1521:orcl
+jdbc.b2c.prod.username=platform$b2b
+jdbc.b2c.prod.password=select*fromuu
+#other configuration
 jdbc.b2c.driverClassName=oracle.jdbc.driver.OracleDriver
-jdbc.b2c.url=jdbc:oracle:thin:@192.168.253.6:1521:orcl
-jdbc.b2c.username=uuplatformdemo
-jdbc.b2c.password=selectuuplatform
 jdbc.b2c.initialSize=1
 jdbc.b2c.maxActive=100
 jdbc.b2c.maxIdle=50

+ 0 - 0
src/main/resources/dev/jdbc.properties → src/main/resources/dev/jdbc-uas.properties


+ 64 - 6
src/main/resources/spring/applicationContext.xml

@@ -24,7 +24,7 @@
 	<!-- 扫描的包 -->
 	<context:component-scan base-package="com.uas.report" />
 
-	<!-- 标准帐套 -->
+	<!-- UAS标准帐套 -->
 	<bean id="defaultSob" class="com.alibaba.druid.pool.DruidDataSource"
 		init-method="init" destroy-method="close">
 		<property name="driverClassName" value="${jdbc.driverClassName}" />
@@ -53,13 +53,71 @@
 		<property name="filters" value="stat" />
 	</bean>
 
-	<!-- B2C数据库 -->
-	<bean id="b2cDataSource" class="com.alibaba.druid.pool.DruidDataSource"
+	<!-- B2C dev数据库 -->
+	<bean id="b2cDevDataSource" class="com.alibaba.druid.pool.DruidDataSource"
 		init-method="init" destroy-method="close">
 		<property name="driverClassName" value="${jdbc.b2c.driverClassName}" />
-		<property name="url" value="${jdbc.b2c.url}" />
-		<property name="username" value="${jdbc.b2c.username}" />
-		<property name="password" value="${jdbc.b2c.password}" />
+		<property name="url" value="${jdbc.b2c.dev.url}" />
+		<property name="username" value="${jdbc.b2c.dev.username}" />
+		<property name="password" value="${jdbc.b2c.dev.password}" />
+		<property name="initialSize" value="${jdbc.b2c.initialSize}" />
+		<property name="maxActive" value="${jdbc.b2c.maxActive}" />
+		<property name="maxIdle" value="${jdbc.b2c.maxIdle}" />
+		<property name="minIdle" value="${jdbc.b2c.minIdle}" />
+		<!-- 配置获取连接等待超时的时间 -->
+		<property name="maxWait" value="60000" />
+		<property name="testOnBorrow" value="false" />
+		<property name="testOnReturn" value="false" />
+		<property name="testWhileIdle" value="true" />
+		<property name="validationQuery" value="SELECT 1 FROM SYS.DUAL" />
+		<!-- 配置间隔多久才进行一次检测,检测需要关闭的空闲连接 -->
+		<property name="timeBetweenEvictionRunsMillis" value="${jdbc.b2c.timeBetweenEvictionRunsMillis}" />
+		<!-- 配置一个连接在池中最小生存的时间 -->
+		<property name="minEvictableIdleTimeMillis" value="${jdbc.b2c.minEvictableIdleTimeMillis}" />
+		<!-- 打开PSCache,并且指定每个连接上PSCache的大小 -->
+		<property name="poolPreparedStatements" value="true" />
+		<property name="maxPoolPreparedStatementPerConnectionSize"
+			value="100" />
+		<!-- 配置监控统计拦截的filters -->
+		<property name="filters" value="stat" />
+	</bean>
+
+	<!-- B2C test数据库 -->
+	<bean id="b2cTestDataSource" class="com.alibaba.druid.pool.DruidDataSource"
+		init-method="init" destroy-method="close">
+		<property name="driverClassName" value="${jdbc.b2c.driverClassName}" />
+		<property name="url" value="${jdbc.b2c.test.url}" />
+		<property name="username" value="${jdbc.b2c.test.username}" />
+		<property name="password" value="${jdbc.b2c.test.password}" />
+		<property name="initialSize" value="${jdbc.b2c.initialSize}" />
+		<property name="maxActive" value="${jdbc.b2c.maxActive}" />
+		<property name="maxIdle" value="${jdbc.b2c.maxIdle}" />
+		<property name="minIdle" value="${jdbc.b2c.minIdle}" />
+		<!-- 配置获取连接等待超时的时间 -->
+		<property name="maxWait" value="60000" />
+		<property name="testOnBorrow" value="false" />
+		<property name="testOnReturn" value="false" />
+		<property name="testWhileIdle" value="true" />
+		<property name="validationQuery" value="SELECT 1 FROM SYS.DUAL" />
+		<!-- 配置间隔多久才进行一次检测,检测需要关闭的空闲连接 -->
+		<property name="timeBetweenEvictionRunsMillis" value="${jdbc.b2c.timeBetweenEvictionRunsMillis}" />
+		<!-- 配置一个连接在池中最小生存的时间 -->
+		<property name="minEvictableIdleTimeMillis" value="${jdbc.b2c.minEvictableIdleTimeMillis}" />
+		<!-- 打开PSCache,并且指定每个连接上PSCache的大小 -->
+		<property name="poolPreparedStatements" value="true" />
+		<property name="maxPoolPreparedStatementPerConnectionSize"
+			value="100" />
+		<!-- 配置监控统计拦截的filters -->
+		<property name="filters" value="stat" />
+	</bean>
+
+	<!-- B2C prod数据库 -->
+	<bean id="b2cProdDataSource" class="com.alibaba.druid.pool.DruidDataSource"
+		init-method="init" destroy-method="close">
+		<property name="driverClassName" value="${jdbc.b2c.driverClassName}" />
+		<property name="url" value="${jdbc.b2c.prod.url}" />
+		<property name="username" value="${jdbc.b2c.prod.username}" />
+		<property name="password" value="${jdbc.b2c.prod.password}" />
 		<property name="initialSize" value="${jdbc.b2c.initialSize}" />
 		<property name="maxActive" value="${jdbc.b2c.maxActive}" />
 		<property name="maxIdle" value="${jdbc.b2c.maxIdle}" />

+ 14 - 4
src/main/resources/test/jdbc-b2c.properties

@@ -1,8 +1,18 @@
-#B2C的数据库信息
+#B2C
+#dev
+jdbc.b2c.dev.url=jdbc:oracle:thin:@192.168.253.6:1521:orcl
+jdbc.b2c.dev.username=uuplatformdemo
+jdbc.b2c.dev.password=selectuuplatform
+#test
+jdbc.b2c.test.url=jdbc:oracle:thin:@192.168.253.6:1521:orcl
+jdbc.b2c.test.username=uuplatformdemo
+jdbc.b2c.test.password=selectuuplatform
+#prod
+jdbc.b2c.prod.url=jdbc:oracle:thin:@10.10.100.200:1521:orcl
+jdbc.b2c.prod.username=platform$b2b
+jdbc.b2c.prod.password=select*fromuu
+#other configuration
 jdbc.b2c.driverClassName=oracle.jdbc.driver.OracleDriver
-jdbc.b2c.url=jdbc:oracle:thin:@192.168.253.6:1521:orcl
-jdbc.b2c.username=uuplatformdemo
-jdbc.b2c.password=selectuuplatform
 jdbc.b2c.initialSize=1
 jdbc.b2c.maxActive=100
 jdbc.b2c.maxIdle=50

+ 0 - 0
src/main/resources/test/jdbc.properties → src/main/resources/test/jdbc-uas.properties