瀏覽代碼

修改了增长比例的算法,去掉了db.properties的连库方式

Rain 4 年之前
父節點
當前提交
47edd72084
共有 2 個文件被更改,包括 19 次插入19 次删除
  1. 3 3
      src/java/com/bus/dao/impl/BusOrgDaoImpl.java
  2. 16 16
      src/java/com/core/util/DBUtils.java

+ 3 - 3
src/java/com/bus/dao/impl/BusOrgDaoImpl.java

@@ -66,7 +66,7 @@ public class BusOrgDaoImpl extends GenericDaoImpl<BusOrg, Long>
 		//先将int值转为float否则会发生精度丢失
 		//Float v = (float) (1+GR/100);
 		//通过sql查询增长比例
-		String v = " (select growth_ratio from base_org_type o where o.org_type_id = b.org_type_id) ";
+		String v = " (select 1+(growth_ratio/100) from base_org_type o where o.org_type_id = b.org_type_id) ";
 		String quarterSql = "ROUND(SUM(bm.`water`) * "+v+"/4)";
 		String montherSql = "ROUND(SUM(bm.`water`) * "+v+"/12)";
 		String sql = " INSERT INTO `bus_annual_plan_for_water`                                                           "
@@ -200,7 +200,7 @@ public class BusOrgDaoImpl extends GenericDaoImpl<BusOrg, Long>
 			Date eMonthEndTime) {
 //		Float v = (float) (1+GR/100);
 		//通过sql查询增长比例
-		String v = " (select growth_ratio from base_org_type o where o.org_type_id = b.org_type_id) ";
+		String v = " (select 1+(growth_ratio/100) from base_org_type o where o.org_type_id = b.org_type_id) ";
 
 		String sql =" INSERT INTO `bus_quarterly_assessment`                                                                   "
 				   +" (                                                                                                        " 
@@ -239,7 +239,7 @@ public class BusOrgDaoImpl extends GenericDaoImpl<BusOrg, Long>
 			Date bMonthStartTime, Date bMonthEndTime, Date eMonthStartTime,
 			Date eMonthEndTime) {
 		//通过sql查询增长比例
-		String v = " (select growth_ratio from base_org_type o where o.org_type_id = b.org_type_id ) ";
+		String v = " (select 1+(growth_ratio/100) from base_org_type o where o.org_type_id = b.org_type_id ) ";
 
 		String sql =" INSERT INTO `bus_month_assessment`                                                                   "
 				+" (                                                                                                        "

+ 16 - 16
src/java/com/core/util/DBUtils.java

@@ -27,22 +27,22 @@ public class DBUtils {
 		mysql
 	}
 
-	static {
-		Properties p = new Properties();
-		try {
-			p.load(DBUtils.class.getClassLoader().getResourceAsStream(
-					"db.properties"));
-			user = p.getProperty("jdbc.username");
-			password = p.getProperty("jdbc.password");
-//			url = p.getProperty("jdbc.url");
-			encoding = p.getProperty("jdbc.encoding");
-			driverName = p.getProperty("jdbc.driverClassName");
-			Class.forName(driverName);
-		} catch (Exception e) {
-			e.printStackTrace();
-			throw new RuntimeException("Read the database configuration file failed!");
-		}
-	}
+//	static {
+//		Properties p = new Properties();
+//		try {
+//			p.load(DBUtils.class.getClassLoader().getResourceAsStream(
+//					"db.properties"));
+//			user = p.getProperty("jdbc.username");
+//			password = p.getProperty("jdbc.password");
+////			url = p.getProperty("jdbc.url");
+//			encoding = p.getProperty("jdbc.encoding");
+//			driverName = p.getProperty("jdbc.driverClassName");
+//			Class.forName(driverName);
+//		} catch (Exception e) {
+//			e.printStackTrace();
+//			throw new RuntimeException("Read the database configuration file failed!");
+//		}
+//	}
 
 	/**
 	 * open a database connection