From 7e92b33026633f423e7e8e05ed596e94d7e3cf09 Mon Sep 17 00:00:00 2001 From: Jian Shen Date: Wed, 22 Jun 2022 18:24:58 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E4=BB=B7=E6=A0=BC?= =?UTF-8?q?=E5=81=8F=E5=B7=AE=E5=AF=BC=E5=87=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../oracle/ExportExceptionPrice.groovy | 50 +++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/oracle/ExportExceptionPrice.groovy diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/oracle/ExportExceptionPrice.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/oracle/ExportExceptionPrice.groovy new file mode 100644 index 000000000..ce6a0b94b --- /dev/null +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/oracle/ExportExceptionPrice.groovy @@ -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 fiveMap = new HashMap<>() +Map 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, "统计") \ No newline at end of file From acf690d3aca2de0bdc2e6512187f3d5dd4e03f24 Mon Sep 17 00:00:00 2001 From: gaojuan Date: Tue, 28 Jun 2022 10:06:15 +0800 Subject: [PATCH 2/2] update --- .../ronghe/ExportDistrictRongHe.groovy | 2 +- .../script/commData/CommonDatautils.groovy | 59 ++++++++++--------- 2 files changed, 32 insertions(+), 29 deletions(-) diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/ccbevaluation/ronghe/ExportDistrictRongHe.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/ccbevaluation/ronghe/ExportDistrictRongHe.groovy index 830424944..e50059409 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/ccbevaluation/ronghe/ExportDistrictRongHe.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/ccbevaluation/ronghe/ExportDistrictRongHe.groovy @@ -25,7 +25,7 @@ class ExportDistrictRongHe extends BaseBatch{ @Override void process(Object args) { def curDate = DateUtils.formatDateByPattern(new Date()+1, "yyyyMMdd") - def new_dists = ["350604","350605","410307","410308","450181"] + def new_dists = []//["350604","350605","410307","410308","450181"] //按天导(每天一个文件夹) exportBigdataDealFJW2(curDate, DateUtils.formatDateByPattern(DateUtils.getFirstDayOfMonth(new Date()+1,-1), "yyyy-MM-dd"), new_dists) diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/commData/CommonDatautils.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/commData/CommonDatautils.groovy index 5abaef7c1..e374d233a 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/commData/CommonDatautils.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/commData/CommonDatautils.groovy @@ -834,39 +834,42 @@ class CommonDatautils { if(!id){ return null; } - DBObject q = new BasicDBObject(); - q.put("_id", new ObjectId(id.toString().replace("[","").replace("]",""))); - - DBObject keys = new BasicDBObject(); - keys.put("alias", 1); - keys.put("addr_alias", 1); - keys.put("city", 1); - keys.put("region", 1); - keys.put("name", 1); - keys.put("estate_type2", 1); - keys.put("address", 1); - keys.put("build_structure", 1); - keys.put("out_pics", 1); - keys.put("lat", 1); - keys.put("lng", 1); - keys.put("lat2", 1); - keys.put("lng2", 1); - keys.put("name_cat", 1); - keys.put("finish_building_date", 1) - keys.put("mapping_alias", 1) - keys.put("sid", 1) try{ - DSCursor cursor = getDataStoreConnection().find(q, keys); - if(cursor){ - for(def obj : cursor){ - return obj; + DBObject q = new BasicDBObject(); + q.put("_id", new ObjectId(id.toString().replace("[","").replace("]",""))); + + DBObject keys = new BasicDBObject(); + keys.put("alias", 1); + keys.put("addr_alias", 1); + keys.put("city", 1); + keys.put("region", 1); + keys.put("name", 1); + keys.put("estate_type2", 1); + keys.put("address", 1); + keys.put("build_structure", 1); + keys.put("out_pics", 1); + keys.put("lat", 1); + keys.put("lng", 1); + keys.put("lat2", 1); + keys.put("lng2", 1); + keys.put("name_cat", 1); + keys.put("finish_building_date", 1) + keys.put("mapping_alias", 1) + keys.put("sid", 1) + try{ + DSCursor cursor = getDataStoreConnection().find(q, keys); + if(cursor){ + for(def obj : cursor){ + return obj; + } } + }catch(Exception e){ + println "error_id:"+id + e.printStackTrace() } }catch(Exception e){ - println "error_id:"+id - e.printStackTrace() - } + } return null; }