新增价格偏差导出
This commit is contained in:
+50
@@ -0,0 +1,50 @@
|
||||
package com.fangjia.script.temp.shenjian.oracle;
|
||||
|
||||
import com.fangjia.core.RegionData
|
||||
import com.fangjia.core.util.DistrictCodeUtils
|
||||
import com.fangjia.script.commData.CommonDatautils
|
||||
import com.fangjia.script.gj.district.FangjiaClientUtils
|
||||
import com.fangjia.script.lixue.util.DBUtils
|
||||
import com.fangjia.script.util.DataUtil
|
||||
import com.fangjia.script.util.DateUtils
|
||||
import com.fangjia.script.util.DbUtils
|
||||
import com.fangjia.script.util.ElasticUtils
|
||||
import com.fangjia.script.util.ExcelUtils
|
||||
import com.fangjia.script.util.MongoUtils
|
||||
import com.mongodb.BasicDBObject
|
||||
import com.mongodb.DBCollection
|
||||
import com.mongodb.DBObject
|
||||
import groovy.sql.Sql
|
||||
|
||||
/**
|
||||
* 导出异常价格
|
||||
*/
|
||||
def sqlInstance = Sql.newInstance("jdbc:oracle:thin:@192.168.0.236:1521:orcl",
|
||||
"GOOJIA", "GOOJIA", "oracle.jdbc.driver.OracleDriver")
|
||||
|
||||
def sql = "SELECT id, cityname, distname, commid, commname, calc_type, avg_price, year_month FROM community_base_price_gj WHERE year_month IN('202206', '202205') " +
|
||||
" AND cityname IN ('东莞', '上海') AND rownum <= 10 ORDER BY cityname, distname, commid, commname, year_month"
|
||||
def result = []
|
||||
result << ["城市", "区域", "小区ID", "小区名", "五月均价", "五月计算方式", "六月均价", "六月计算方式"]
|
||||
Map<String, Integer> fiveMap = new HashMap<>()
|
||||
Map<String, Integer> sixMap = new HashMap<>()
|
||||
sqlInstance.eachRow(sql, { r ->
|
||||
def year_month = r['year_month']
|
||||
String key = r['cityname'] + "," + r['distname'] + "," + r['commid'] + "," + r['commname']
|
||||
if (year_month == '202205') {
|
||||
fiveMap.put(key, r['avg_price'] + "|" + r['calc_type'])
|
||||
} else if ((year_month == '202206')) {
|
||||
fiveMap.put(key, r['avg_price'] + "|" + r['calc_type'])
|
||||
}
|
||||
})
|
||||
for (String key : sixMap.keySet()) {
|
||||
Integer fivePrice = fiveMap.get(key).split("|")[0]
|
||||
Integer sixPrice = sixMap.get(key).split("|")[0]
|
||||
if (fivePrice != null && sixPrice != null) {
|
||||
if (Math.abs(sixPrice - fivePrice) * 100 / fivePrice > 10) {
|
||||
def info = key.split(",")
|
||||
result << [info[0], info[1], info[2], info[3], fivePrice, fiveMap.get(key).split("|")[1], sixPrice, sixMap.get(key).split("|")[1]]
|
||||
}
|
||||
}
|
||||
}
|
||||
ExcelUtils.write("F:\\数据\\价格\\东莞上海价格偏差大.xlsx", result, "统计")
|
||||
Reference in New Issue
Block a user