diff --git a/projects/fangjia-core/pom.xml b/projects/fangjia-core/pom.xml
index 2a0d00ddd..4b5915438 100644
--- a/projects/fangjia-core/pom.xml
+++ b/projects/fangjia-core/pom.xml
@@ -1,5 +1,5 @@
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
4.0.0
com.fangjia
fangjia-core
@@ -17,8 +17,8 @@
maven-compiler-plugin
2.3.2
- 1.6
- 1.6
+ 8
+ 8
GBK
@@ -105,15 +105,15 @@
3.5.0
- net.sourceforge.pinyin4j
- pinyin4j
- 2.5.0
+ net.sourceforge.pinyin4j
+ pinyin4j
+ 2.5.0
- com.ibm.icu
- icu4j
- 3.4.4
-
+ com.ibm.icu
+ icu4j
+ 3.4.4
+
net.sf.json-lib
json-lib
@@ -124,7 +124,7 @@
commons-beanutils
1.8.3
-
+
org.apache.httpcomponents
httpclient
@@ -155,11 +155,11 @@
hanlp
portable-1.6.6
-
- org.codehaus.jackson
- jackson-mapper-asl
- 1.9.13
-
+
+ org.codehaus.jackson
+ jackson-mapper-asl
+ 1.9.13
+
com.alibaba.nacos
nacos-client
@@ -170,5 +170,11 @@
json
RELEASE
+
+ org.projectlombok
+ lombok
+ 1.18.20
+ compile
+
diff --git a/projects/fangjia-core/src/main/java/com/fangjia/core/util/PriceData.java b/projects/fangjia-core/src/main/java/com/fangjia/core/util/PriceData.java
new file mode 100644
index 000000000..7c3d7e4f8
--- /dev/null
+++ b/projects/fangjia-core/src/main/java/com/fangjia/core/util/PriceData.java
@@ -0,0 +1,82 @@
+package com.fangjia.core.util;
+
+import lombok.Data;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Random;
+
+@Data
+public class PriceData {
+ private String yearmonth;
+ private Double price;
+ private Double volume; // 新增æˆ�交é‡�å—æ®µ
+
+ public PriceData() {}
+
+ public PriceData(String yearmonth, Double price) {
+ this.yearmonth = yearmonth;
+ this.price = price;
+ }
+
+ public PriceData(String yearmonth, Double price, Double volume) {
+ this.yearmonth = yearmonth;
+ this.price = price;
+ this.volume = volume;
+ }
+
+ public static List getSampleData() {
+ List data = new ArrayList<>();
+ double basePrice = 22000;
+ double minPrice = basePrice * (1 - 0.04);
+ double maxPrice = basePrice * (1 + 0.04);
+ Random random = new Random();
+
+ for (int i = 0; i < 2; i++) {
+ int year = 2024;
+ int month = i + 4;
+ if (month > 12) {
+ year++;
+ month -= 12;
+ }
+ String date = String.format("%d-%02d", year, month);
+ double price = minPrice + random.nextDouble() * (maxPrice - minPrice);
+ double volume = 100 + random.nextInt(100);
+ data.add(new PriceData(date, price, volume));
+ System.out.println(data.get(i));
+ }
+ return data;
+ }
+
+ public static List getSampleData(double basePrice) {
+ List data = new ArrayList<>();
+ double minPrice = basePrice * (1 - 0.02);
+ double maxPrice = basePrice * (1 + 0.02);
+ Random random = new Random();
+
+ for (int i = 0; i < 12; i++) {
+ int year = 2025;
+ int month = i + 1;
+ if (month > 12) {
+ year++;
+ month -= 12;
+ }
+ String date = String.format("%d-%02d", year, month);
+ double price = minPrice + random.nextDouble() * (maxPrice - minPrice);
+ double volume = 100 + random.nextInt(200);
+ data.add(new PriceData(date, price, volume));
+ System.out.println(data.get(i));
+ }
+ return data;
+ }
+
+ public static List getSampleData2() {
+ List data = new ArrayList<>();
+ data.add(new PriceData("2025-01", 11110.0, 90.0));
+ data.add(new PriceData("2025-02", 11115.0, 110.0));
+ data.add(new PriceData("2025-03", 11112.0, 95.0));
+ data.add(new PriceData("2025-04", 11120.0, 150.0));
+ data.add(new PriceData("2025-05", 11118.0, 140.0));
+ return data;
+ }
+}
diff --git a/projects/fangjia-core/src/main/java/com/fangjia/core/util/PriceDto.java b/projects/fangjia-core/src/main/java/com/fangjia/core/util/PriceDto.java
new file mode 100644
index 000000000..899c1832f
--- /dev/null
+++ b/projects/fangjia-core/src/main/java/com/fangjia/core/util/PriceDto.java
@@ -0,0 +1,49 @@
+package com.fangjia.core.util;
+
+import lombok.Builder;
+import lombok.Data;
+
+import java.util.List;
+
+/**
+ * @author shenjian
+ * @since 2024/12/17
+ */
+@Data
+public class PriceDto {
+ private Integer id;
+
+ private Integer avgPrice;//本周�价
+
+ private PriceTrend priceTrend; //�价走势
+
+ private List rentPrices;//本月租金
+
+ private PriceTrend rentTrend;//租金走势
+
+ @Data
+ @Builder
+ public static class RentPrice {
+ private String name;
+ private Integer price;
+ }
+
+ @Data
+ public static class PriceTrend {
+ private List categories;
+ private List series;
+ private List doubleSeries;
+ }
+
+ @Data
+ public static class Series {
+ private String name;
+ private List data;
+ }
+
+ @Data
+ public static class DoubleSeries {
+ private String name;
+ private List data;
+ }
+}
diff --git a/projects/fangjia-core/src/main/java/com/fangjia/core/util/SvgUtils.java b/projects/fangjia-core/src/main/java/com/fangjia/core/util/SvgUtils.java
new file mode 100644
index 000000000..ce45c16da
--- /dev/null
+++ b/projects/fangjia-core/src/main/java/com/fangjia/core/util/SvgUtils.java
@@ -0,0 +1,316 @@
+package com.fangjia.core.util;
+
+
+
+import java.io.FileWriter;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.stream.Collectors;
+
+
+/**
+ * SVG工具类,用于生æˆ�ä»·æ ¼è¶‹åŠ¿çš„SVG图表
+ */
+
+public class SvgUtils {
+
+ // SVG画布尺寸
+ private static final int WIDTH = 800;
+ private static final int HEIGHT = 500;
+ private static final int PADDING = 60;
+
+ // 生�SVG折线图(支�多�线),新增decimalPlaces�数控制Y轴�数�
+ public static String generatePriceTrendSvg(List> dataSets, List labels, String title, String subtitle, int decimalPlaces) {
+ if (dataSets.isEmpty() || dataSets.get(0).isEmpty()) {
+ return "";
+ }
+ // 过滤为空的数�
+ dataSets = dataSets.stream()
+ .map(innerList -> innerList.stream()
+ .filter(priceData -> priceData != null && priceData.getPrice() != null)
+ .collect(Collectors.toList()))
+ .collect(Collectors.toList());
+
+ // è®¡ç®—ä»·æ ¼å’Œæ—¶é—´çš„èŒƒå›´
+ double minPrice = dataSets.stream()
+ .flatMap(List::stream)
+ .filter((p) -> p != null && p.getPrice() != null)
+ .mapToDouble(PriceData::getPrice)
+ .min()
+ .orElse(0) * 0.8;
+ double maxPrice = dataSets.stream()
+ .flatMap(List::stream)
+ .filter((p) -> p != null && p.getPrice() != null)
+ .mapToDouble(PriceData::getPrice)
+ .max()
+ .orElse(1) * 1.2;
+ double buffer = 0.1;
+ minPrice = minPrice * (1 - buffer);
+ maxPrice = maxPrice * (1 + buffer);
+
+ // 如果decimalPlaces为0,调整minPriceå’ŒmaxPrice为整数ç‰å·®
+// if (decimalPlaces == 0) {
+// long step = calculateStep((long) Math.ceil(maxPrice) - (long) Math.floor(minPrice));
+// minPrice = Math.floor(minPrice / step) * step;
+// maxPrice = Math.ceil(maxPrice / step) * step;
+// }
+
+ // 解�最�和最大日期
+ String minYearMonth = dataSets.stream()
+ .flatMap(List::stream)
+ .map(PriceData::getYearmonth)
+ .min(String::compareTo)
+ .orElse("2024-08");
+ String maxYearMonth = dataSets.stream()
+ .flatMap(List::stream)
+ .map(PriceData::getYearmonth)
+ .max(String::compareTo)
+ .orElse("2025-01");
+
+ // 构建SVG内容
+ StringBuilder svg = new StringBuilder();
+ svg.append(String.format("");
+ return svg.toString();
+ }
+
+ // 绘制平滑折线
+ private static String drawSmoothLine(List data, String minYearMonth, String maxYearMonth, double minPrice, double maxPrice, String color, int decimalPlaces) {
+// if (data.size() < 2) return "";
+ StringBuilder path = new StringBuilder("", x, y, color));
+ pointsAndLabels.append(String.format("%." + decimalPlaces + "f",
+ x + 5, y - 5, color, point.getPrice()));
+
+ path.append("M").append(x).append(",").append(y);
+ } else if (data.size() > 1) {
+ for (int i = 0; i < data.size() - 1; i++) {
+ PriceData point1 = data.get(i);
+ PriceData point2 = data.get(i + 1);
+ int monthIndex1 = Math.max(0, Math.min(totalMonths - 1, getMonthIndex(point1.getYearmonth()) - getMonthIndex(minYearMonth)));
+ int monthIndex2 = Math.max(0, Math.min(totalMonths - 1, getMonthIndex(point2.getYearmonth()) - getMonthIndex(minYearMonth)));
+
+ int x1 = PADDING + (monthIndex1 * (WIDTH - 2 * PADDING) / (totalMonths - 1));
+ int y1 = HEIGHT - PADDING - (int) ((point1.getPrice() - minPrice) * (HEIGHT - 2 * PADDING) / (maxPrice - minPrice));
+ int x2 = PADDING + (monthIndex2 * (WIDTH - 2 * PADDING) / (totalMonths - 1));
+ int y2 = HEIGHT - PADDING - (int) ((point2.getPrice() - minPrice) * (HEIGHT - 2 * PADDING) / (maxPrice - minPrice));
+
+ int controlX1 = x1 + (x2 - x1) / 3;
+ int controlY1 = y1;
+ int controlX2 = x2 - (x2 - x1) / 3;
+ int controlY2 = y2;
+
+ if (i == 0) path.append(x1).append(",").append(y1);
+ path.append(" C").append(controlX1).append(",").append(controlY1).append(" ").append(controlX2).append(",").append(controlY2).append(" ").append(x2).append(",").append(y2);
+
+ pointsAndLabels.append(String.format("", x1, y1, color));
+ pointsAndLabels.append(String.format("%." + decimalPlaces + "f",
+ x1 + 5, y1 - 5, color, point1.getPrice()));
+ }
+
+ PriceData lastPoint = data.get(data.size() - 1);
+ int lastMonthIndex = Math.max(0, Math.min(totalMonths - 1, getMonthIndex(lastPoint.getYearmonth()) - getMonthIndex(minYearMonth)));
+ int lastX = PADDING + (lastMonthIndex * (WIDTH - 2 * PADDING) / (totalMonths - 1));
+ int lastY = HEIGHT - PADDING - (int) ((lastPoint.getPrice() - minPrice) * (HEIGHT - 2 * PADDING) / (maxPrice - minPrice));
+ pointsAndLabels.append(String.format("", lastX, lastY, color));
+ pointsAndLabels.append(String.format("%." + decimalPlaces + "f",
+ lastX + 5, lastY - 5, color, lastPoint.getPrice()));
+ }
+ path.append("' fill='none' stroke='").append(color).append("' stroke-width='2'/>");
+ path.append(pointsAndLabels);
+ return path.toString();
+ }
+
+ // ç»˜åˆ¶ç½‘æ ¼çº¿
+ private static String drawGrid(String minYearMonth, String maxYearMonth, double minPrice, double maxPrice, int decimalPlaces) {
+ StringBuilder grid = new StringBuilder();
+ double step = calculateYStep(minPrice, maxPrice, decimalPlaces);
+ int numSteps = (int) ((maxPrice - minPrice) / step) + 1;
+
+ for (int i = 0; i < numSteps; i++) {
+ double price = minPrice + i * step;
+ if (price > maxPrice) break;
+ int y = HEIGHT - PADDING - (int) ((price - minPrice) * (HEIGHT - 2 * PADDING) / (maxPrice - minPrice));
+ grid.append(String.format("",
+ PADDING, y, WIDTH - PADDING, y));
+ }
+ return grid.toString();
+ }
+
+ // 绘制å��æ ‡è½´
+ private static String drawAxis(String minYearMonth, String maxYearMonth, double minPrice, double maxPrice, int decimalPlaces) {
+ StringBuilder axis = new StringBuilder();
+
+ // Xè½´
+ axis.append(String.format("",
+ PADDING, HEIGHT - PADDING, WIDTH - PADDING, HEIGHT - PADDING));
+ axis.append(String.format("",
+ PADDING, PADDING, PADDING, HEIGHT - PADDING));
+
+ // X轴刻度
+ int totalMonths = getMonthIndex(maxYearMonth) - getMonthIndex(minYearMonth) + 1;
+ for (int i = 0; i < totalMonths; i++) {
+ int x;
+ if (totalMonths == 1) {
+ // 当å�ªæœ‰ä¸€ä¸ªæœˆæ—¶ï¼Œå°†åˆ»åº¦æ”¾åœ¨ä¸é—´ä½�ç½®
+ x = PADDING + (WIDTH - 2 * PADDING) / 2;
+ } else {
+ x = PADDING + i * (WIDTH - 2 * PADDING) / (totalMonths - 1);
+ }
+ String monthLabel = getMonthLabel(minYearMonth, i);
+ axis.append(String.format("",
+ x, HEIGHT - PADDING + 5, x, HEIGHT - PADDING));
+ axis.append(String.format("%s",
+ x, HEIGHT - PADDING + 20, monthLabel));
+ }
+
+ // Y轴刻度
+ double step = calculateYStep(minPrice, maxPrice, decimalPlaces);
+ int numSteps = (int) ((maxPrice - minPrice) / step) + 1;
+ for (int i = 0; i < numSteps; i++) {
+ double price = minPrice + i * step;
+ int y = HEIGHT - PADDING - (int) ((price - minPrice) * (HEIGHT - 2 * PADDING) / (maxPrice - minPrice));
+ axis.append(String.format("",
+ PADDING - 5, y, PADDING, y));
+ axis.append(String.format("%." + decimalPlaces + "f",
+ PADDING - 10, y + 5, price));
+ }
+
+ return axis.toString();
+ }
+
+ // 计算Yè½´æ¥é•¿
+ private static double calculateYStep(double minPrice, double maxPrice, int decimalPlaces) {
+ double range = maxPrice - minPrice;
+ if (decimalPlaces == 0) {
+ return calculateStep((long) range);
+ }
+ double step = range / 10.0; // 默认10个间隔
+ double scale = Math.pow(10, decimalPlaces);
+ return Math.round(step * scale) / scale;
+ }
+
+ // 计算整数æ¥é•¿
+ private static long calculateStep(long range) {
+ long step = (long) Math.pow(10, Math.floor(Math.log10(range)));
+ if (range / step < 4) step /= 2;
+ else if (range / step > 8) step *= 2;
+ return step;
+ }
+
+ // 获å�–æœˆä»½æ ‡ç¾å’Œç´¢å¼•(ä¿�æŒ�ä¸�å�˜ï¼‰
+ private static String getMonthLabel(String minYearMonth, int offset) {
+ int totalMonths = getMonthIndex(minYearMonth);
+ int targetMonthIndex = totalMonths + offset;
+ int year = 2024 + targetMonthIndex / 12;
+ int month = targetMonthIndex % 12 + 1;
+ return String.format("%d-%02d", year, month);
+ }
+
+ private static int getMonthIndex(String yearMonth) {
+ int year = Integer.parseInt(yearMonth.substring(0, 4));
+ int month = Integer.parseInt(yearMonth.substring(5));
+ return (year - 2024) * 12 + (month - 1);
+ }
+
+
+ public static void generateSvg(String svgContent, String outputPath) {
+ try (FileWriter writer = new FileWriter(outputPath)) {
+ writer.write(svgContent);
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ * 对�已有系列数�与新的时间轴
+ */
+ public static void alignSeriesData(List newCategories, List series, PriceDto.PriceTrend rentTrend) {
+ for (PriceDto.DoubleSeries s : series) {
+ List originalData = s.getData();
+ List originalCategories = new ArrayList<>(rentTrend.getCategories()); // �设原始时间轴�从别处获�
+ List alignedData = new ArrayList<>();
+
+ // æ ¹æ�®æ–°çš„æ—¶é—´è½´å¯¹é½�æ•°æ�®
+ for (String date : newCategories) {
+ int index = originalCategories.indexOf(date);
+ if (index >= 0 && index < originalData.size()) {
+ alignedData.add(originalData.get(index));
+ } else {
+ alignedData.add(null); // 日期ä¸�å˜åœ¨æ—¶è¡¥ null
+ }
+ }
+ s.setData(alignedData);
+ }
+ }
+
+ // 测试方法
+ public static void main(String[] args) {
+ List data1 = PriceData.getSampleData(5200);
+ List> dataSets = new ArrayList<>();
+ dataSets.add(data1);
+ String name = "新世纪大厦";
+ List labels = Arrays.asList(name);
+
+ String title = "ä»·æ ¼èµ°åŠ¿å›¾";
+ String subtitle = "2024-12 至 2025-11";
+
+// // 测试�数�为2
+// String svgWithoutDecimals = generatePriceTrendSvg(dataSets, labels, title, subtitle, 2);
+// System.out.println("With 2 decimal places:");
+// System.out.println(svgWithoutDecimals);
+
+ // 测试å°�æ•°ä½�为0(整数ç‰å·®ï¼‰
+ String svgWithoutDecimals = generatePriceTrendSvg(dataSets, labels, title, subtitle, 0);
+ System.out.println("With 0 decimal places (integer steps):");
+ System.out.println(svgWithoutDecimals);
+
+ try {
+ generateSvg(svgWithoutDecimals, name + ".svg");
+ System.out.println("PNG image generated successfully at: price_trend.png");
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+
+// String locationStr = "114.407048,30.481859";
+// String[] location = locationStr.split(",");
+// Double lng = Double.parseDouble(location[0]);
+// Double lat = Double.parseDouble(location[1]);
+// String mapUrl = "https://restapi.amap.com/v3/staticmap?location=" + lng + "," + lat
+// + "&zoom=14&size=780*300&markers=mid,,A:" + lng + "," + lat
+// + "&key=ee95e52bf08006f63fd29bcfbcf21df0";
+// System.out.println(mapUrl);
+ }
+}
\ No newline at end of file
diff --git a/projects/fangjia-script/pom.xml b/projects/fangjia-script/pom.xml
index 80cdd5037..d02a60460 100644
--- a/projects/fangjia-script/pom.xml
+++ b/projects/fangjia-script/pom.xml
@@ -602,5 +602,6 @@
+
diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/district/DistrictLocationGeo.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/district/DistrictLocationGeo.groovy
index b25c63f1e..23e7330f1 100644
--- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/district/DistrictLocationGeo.groovy
+++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/district/DistrictLocationGeo.groovy
@@ -1,22 +1,19 @@
package com.fangjia.script.gj.district
-import com.fangjia.core.util.GeoUtils
+import com.fangjia.script.commData.CommonDatautils
import com.fangjia.script.util.ExcelUtils
import com.fangjia.script.util.MongoUtils
import com.fangjia.script.yinjihaun.amap.GaoDeApiUtils
import com.mongodb.BasicDBList
import com.mongodb.BasicDBObject
import com.mongodb.DBCollection
-
import net.sf.json.JSONNull
-import org.bson.types.ObjectId
-
class DistrictLocationGeo {
final DBCollection JD_SEAWEED_COLL = MongoUtils.getCollectionByName("business", "jingdong_community", "192.168.0.206",27020)
final DBCollection JD_GEO_COLL = MongoUtils.getCollectionByName("business", "jingdong_geo", "192.168.0.206",27020)
-
+ final DBCollection JD_review_GEO_COLL = MongoUtils.getCollectionByName("business", "jingdong_review_geo", "192.168.0.206",27020)
static main(args) {
def task = new DistrictLocationGeo()
task.run()//ͨ¹ý¾Î³¶È£¬µ÷ÓøߵÂÄæ½âÎö£¬²¢±£´æÊý¾Ý
@@ -25,14 +22,23 @@ class DistrictLocationGeo {
}
def run(){
- ExcelUtils.multiThreadingModify("D:\\Êý¾Ý\\¾©¶«\\¾©¶«ÐÂÔöÊý¾Ý5.6Íò.xlsx",{ d->
+ ExcelUtils.multiThreadingModify("D:\\Êý¾Ý\\¾©¶«\\·¿¼ÛÍøÖØ¸´Ð¡ÇøÊý¾Ý5-1217¡¾»úÃÜ¡¿(1).xlsx",{ d->
if(d['A']){
- def dbo = JD_SEAWEED_COLL.findOne(new BasicDBObject("_id", new ObjectId(d['A'])))
- if(dbo && dbo.longitude){
- def jsonObject = GaoDeApiUtils.geocode(dbo.longitude+","+dbo.latitude)
+// def dbo = JD_SEAWEED_COLL.findOne(new BasicDBObject("_id", new ObjectId(d['A'])))
+ def obj = CommonDatautils.findDistrictById(d['A'])
+ if(obj && obj.lat){
+ def lat = obj.lat/10000000000.0;
+ def lng = obj.lng/10000000000.0;
+ def jsonObject = GaoDeApiUtils.geocode(lng+","+lat)
if(jsonObject){
d["F"] = "¸ßµÂ"
-// def dbo = new BasicDBObject()
+ def dbo = new BasicDBObject()
+ dbo.put("city", obj.city)
+ dbo.put("district", obj.region)
+ dbo.put("name", obj.name)
+ dbo.put("comm_id", d['A'])
+ dbo.put("lng", lng)
+ dbo.put("lat", lat)
dbo.put("formatted_address", jsonObject.regeocode.formatted_address)
def addrComp = jsonObject.regeocode.addressComponent
dbo.put("addressComponent", addrComp)
@@ -42,13 +48,14 @@ class DistrictLocationGeo {
dbo.put("aois", jsonObject.regeocode.aois)
dbo = cleanGeoData(dbo)
dbo = convertToDBObject(dbo)
- JD_GEO_COLL.save(dbo)
+ JD_review_GEO_COLL.save(dbo)
}
}
}
})
+
}
static BasicDBObject convertToDBObject(Map map) {
diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/test/JingDongTest.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/test/JingDongTest.groovy
new file mode 100644
index 000000000..8acc1ff69
--- /dev/null
+++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/test/JingDongTest.groovy
@@ -0,0 +1,62 @@
+package com.fangjia.script.gj.test
+
+import com.fangjia.script.commData.CommonDatautils
+import com.fangjia.script.util.DateUtils
+import com.fangjia.script.util.ExcelUtils
+import com.fangjia.script.util.GeoHelper
+
+class JingDongTest {
+
+ static main(args) {
+// def task = new JingDongTest()
+// def path = "D:\\Êý¾Ý\\¾©¶«\\¾©¶«²âÊÔÊý¾Ý.xlsx"
+// task.run(path)
+// task.addPrice(path)
+// 120.12063,30.281452
+// 120.120419,30.2767
+// 120.116349,30.29144
+// 120.137169,30.272963
+// 120.108109,30.265553
+
+ ExcelUtils.modify("C:\\Users\\gaojuan\\Downloads\\ÉÌÆÌ³ö×âÐÅÏ¢ (3).xlsx",{d->
+ if(d['J']){
+ def arrs = d['J'].split(",")
+ def distance = GeoHelper.GetDistance(arrs[1].toString().toDouble(), arrs[0].toString().toDouble(), 22.554693, 113.869516)
+ d['F'] = distance
+ }
+
+ })
+
+ }
+
+ def run(path){
+
+ def cityMap = ["±±¾©":"´óÐË","ÏÃÃÅ":"˼Ã÷","ȪÖÝ":"·áÔó","°²Ë³":"Î÷Ðã"]
+ def rets = []
+ rets << ["³ÇÊÐ","ÇøÓò","Ãû³Æ","µØÖ·","¸ßµÂ¾¶È","¸ßµÂγ¶È","¾ù¼Û"]
+ for(def m : cityMap) {
+ println m.key +" "+m.value
+ def districts = CommonDatautils.findAllRegionDistricts(m.key, m.value, "district", ["city", "region", "name", "address", "lng", "lat"]);
+ for(def d : districts){
+ if(d.lng){
+ println d
+ rets << [d.city, d.region, d.name, d.address, d.lng/10000000000.0, d.lat/10000000000.0]
+ }
+
+ }
+ }
+ ExcelUtils.write(path, rets, "Êý¾Ý")
+ }
+
+ def addPrice(path){
+ ExcelUtils.multiThreadingModify(path,{d->
+ if(!d['G']){
+ def dbo = CommonDatautils.findDistrictPrice(d['A'], d['B'], d['C'])
+ if(dbo){
+ d['G'] = dbo.avg_price_2b
+ d['H'] = DateUtils.formatDateByPattern(dbo.weekend,"yyyy-MM-dd")
+ }
+ }
+ })
+ }
+}
diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/village/NanjiangVillage.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/village/NanjiangVillage.groovy
index 76b670d6b..cc128d0cc 100644
--- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/village/NanjiangVillage.groovy
+++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/village/NanjiangVillage.groovy
@@ -11,7 +11,7 @@ class NanjiangVillage {
}
def run(){
- ExcelUtils.multiThreadingModify("D:\\Êý¾Ý\\ÄϾ©ÒøÐÐ\\ÏØ³ÇÇåÏ´-½á¹û.xlsx",{d->
+ ExcelUtils.multiThreadingModify("D:\\Êý¾Ý\\ÄϾ©ÒøÐÐ\\еØÖ·ºËʵ£¨Ïسǣ©.xlsx",{d->
if(!d['F']){
def dto = OpenApiUtils.addrVerifyNanjing(null, d['A'], 2)
diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/village/XiamenVillage.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/village/XiamenVillage.groovy
index 4337e871e..a6240e4bd 100644
--- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/village/XiamenVillage.groovy
+++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/village/XiamenVillage.groovy
@@ -10,10 +10,10 @@ class XiamenVillage {
}
def run(){
- ExcelUtils.multiThreadingModify("D:\\Êý¾Ý\\ÏÃÃÅ\\ɿũ×éÖ¯ÀàÐÍÅж¨£¨to¹À¼Ò£¬2025-10-31£©-ÒÔ´ËΪ׼.xlsx",{ d->
+ ExcelUtils.multiThreadingModify("D:\\Êý¾Ý\\ÏÃÃÅ\\¹¤ÒµÔ°ÇøÓëɿũ×éÖ¯ÀàÐÍì¶Ü.xlsx",{ d->
if(!d['R']){
- def dto = OpenApiUtils.addrVerifyXiameng(null, d['B'], 2)
+ def dto = OpenApiUtils.addrVerifyXiameng(null, d['A'], 2)
if(dto){
// def dto = jsonObj.result
d['F'] = dto.province
diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/xiamen/RelatedTaiWanBatch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/xiamen/RelatedTaiWanBatch.groovy
index 5cf2d132a..d04835c28 100644
--- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/xiamen/RelatedTaiWanBatch.groovy
+++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/xiamen/RelatedTaiWanBatch.groovy
@@ -18,7 +18,7 @@ import com.mongodb.DBCollection
*/
-//@BatchOwner(Watcher.GaoJuan)
+@BatchOwner(Watcher.GaoJuan)
class RelatedTaiWanBatch extends BaseBatch{
diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/xiamen/XiaMenVillageBatch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/xiamen/XiaMenVillageBatch.groovy
new file mode 100644
index 000000000..ed8e73738
--- /dev/null
+++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/xiamen/XiaMenVillageBatch.groovy
@@ -0,0 +1,86 @@
+package com.fangjia.script.gj.xiamen
+
+import com.fangjia.script.BaseBatch
+import com.fangjia.script.gj.OpenApiUtils
+import com.fangjia.script.util.DateUtil
+import com.fangjia.script.util.ExcelUtils
+
+/**
+ * ÏÃÃÅÿÔÂÔ³õ×Ô¶¯ÅÜɿũÊý¾Ý
+ */
+class XiaMenVillageBatch extends BaseBatch{
+
+
+ static main(args) {
+ runBatch(new XiaMenVillageBatch(), args);
+ }
+
+ @Override
+ void process(Object args) {
+ def monthStr = DateUtil.formatByPattern(new Date(), "yyyy-MM");
+ def outFileName = "xmbank_"+monthStr+"_result.xlsx"
+ def inFileName = "xmbank_"+monthStr+".xlsx"
+ def exists = checkFileExists(outFileName)
+ if(!exists){
+ def rows = []
+ rows << ["ÐòºÅ","µØÖ·","Åж¨ºóɿũ×éÖ¯ÀàÐÍ£¨³ÇÊÐÆóÒµ[²»º¬ÏØ³ÇÆóÒµ]¡¢Å©´åÆóÒµ¡¢ÏØ³ÇÆóÒµ£©","ËùÊô¹¤ÒµÔ°Çø»ò¾¼Ã¿ª·¢Çø"]
+ def rets = XmBankVillageFtpUtils.readExcelFile(inFileName)
+ if(rets){
+ for(def row : rets){
+ if(row[1]){
+ def dto = OpenApiUtils.addrVerifyXiameng(null, row[1], 2)
+ if(dto){
+ row[2] = dto.addrArea //ËùÊôÇøÓò Å©´åÇøÓò ³ÇÊÐÇøÓò ÏØ³Ç³ÇÇø(¶Ô¹«)
+ if(dto.devDistrictName){
+ row[3] = dto.devDistrictName//¿ª·¢Çø
+ }else{
+ row[3] = ""
+ }
+
+ }
+ }
+ rows << row
+ }
+ }
+ uploadExcel(rows, outFileName)
+
+ }else{
+ println "ÒÑ´æÔÚ "+ DateUtil.formatByPattern(new Date(), "yyyy-MM-dd HH:mm:ss")
+ }
+
+ }
+
+ static boolean uploadExcel(def data, String fileName, String sheetName = "Sheet1") {
+ if (data == null || data.isEmpty()) {
+ println "Êý¾ÝΪ¿Õ£¬ÎÞ·¨Éú³ÉExcel"
+ return false
+ }
+
+ try {
+ // 1. Éú³ÉExcelÄÚÈÝ
+ byte[] excelBytes = ExcelUtils.createExcelBytes(data, sheetName)
+
+ // 2. ÉÏ´«µ½·þÎñÆ÷
+ return XmBankVillageFtpUtils.uploadExcelBytes(excelBytes, fileName)
+
+ } catch (Exception e) {
+ println "Éú³É²¢ÉÏ´«Excelʧ°Ü: ${e.message}"
+ e.printStackTrace()
+ return false
+ }
+ }
+
+ def checkFileExists(def fileName){
+ def files = XmBankVillageFtpUtils.listOutFileNames()
+ def existsFlag = false
+ if(files){
+ for(def file : files){
+ if(file.filename == fileName){
+ existsFlag = true
+ break
+ }
+ }
+ }
+ return existsFlag
+ }
+}
diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/xiamen/XmBankVillageFtpUtils.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/xiamen/XmBankVillageFtpUtils.groovy
new file mode 100644
index 000000000..3f43e236e
--- /dev/null
+++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/xiamen/XmBankVillageFtpUtils.groovy
@@ -0,0 +1,127 @@
+package com.fangjia.script.gj.xiamen
+
+import com.fangjia.script.jiangnanblank.SFTP
+import com.fangjia.script.util.ExcelUtils
+import com.jcraft.jsch.ChannelSftp
+import org.apache.poi.ss.usermodel.Cell
+import org.apache.poi.ss.usermodel.Row
+import org.apache.poi.ss.usermodel.Sheet
+import org.apache.poi.ss.usermodel.Workbook
+import org.apache.poi.ss.usermodel.WorkbookFactory
+
+import java.nio.charset.Charset
+
+class XmBankVillageFtpUtils {
+ static def ftpServer = "192.168.0.86"
+ static def ftpPort = 17495
+ static def ftpUser = "xmbank"
+ static def ftpPassword = "Xmbank123!@#"
+ static def ftpPath = "/output/village_data"
+ static def ftpInPath = "/input/village"
+
+
+
+ static SFTP sftp = new SFTP();
+ static ChannelSftp sftpChannel = sftp.connect(ftpServer, ftpPort, ftpUser, ftpPassword);
+
+
+ static def ftpUpload(outputPath_dist, month){
+ //ÉÏ´«µ½ftp
+ sftpChannel = reConnect();
+ sftp.upload(ftpPath, outputPath_dist, sftpChannel);
+
+
+ }
+
+ static def reConnect(){
+ if(sftpChannel == null){
+ println "sftpChannel Ϊ¿Õ£¬ÐèÖØÁ¬....."
+ if(sftp == null){
+ sftp = new SFTP();
+ }
+ sftpChannel = sftp.connect(ftpServer, ftpPort, ftpUser, ftpPassword);
+ }else{
+ println "sftpChannel Õý³£....."
+ }
+ return sftpChannel;
+ }
+
+
+
+ static def listOutFileNames(){
+ //ÉÏ´«µ½ftp
+ sftpChannel = reConnect();
+ Vector files = sftp.listFiles(ftpPath+"/", sftpChannel);
+ return files
+ }
+
+ static def listInFileNames(){
+ //ÉÏ´«µ½ftp
+ sftpChannel = reConnect();
+ Vector files = sftp.listFiles(ftpInPath+"/", sftpChannel);
+ return files
+ }
+
+ static def getFileLength(String path, String month){
+ sftpChannel = reConnect();
+ def size = sftp.getFileSize(ftpPath+ month+"/"+path, sftpChannel)
+ return size
+ }
+
+ static def readExcelFile(String fileName) {
+ sftpChannel = reConnect()
+ try {
+ // ¹¹½¨ÍêÕûµÄÔ¶³Ì·¾¶
+ String fullRemotePath = ftpInPath + "/"+fileName
+ println "¿ªÊ¼¶ÁÈ¡ExcelÎļþ: ${fullRemotePath}"
+ // ´ÓSFTP·þÎñÆ÷»ñÈ¡ÎļþÁ÷
+ InputStream inputStream = sftpChannel.get(fullRemotePath)
+ def excelData = ExcelUtils.readFromStream(inputStream, 0, 1)
+ println "Excel¹²ÓÐ ${excelData.size()} ÐÐÊý¾Ý"
+ inputStream.close()
+ return excelData
+ } catch (Exception e) {
+ println "¶ÁÈ¡ExcelÎļþʧ°Ü: ${e.message}"
+ e.printStackTrace()
+ return null
+ }
+ }
+
+
+ /**
+ * ÉÏ´«Excel×Ö½ÚÊý×éµ½·þÎñÆ÷
+ * @param excelBytes Excel×Ö½ÚÊý×é
+ * @param fileName ÎļþÃû
+ * @return ÉÏ´«ÊÇ·ñ³É¹¦
+ */
+ private static boolean uploadExcelBytes(byte[] excelBytes, String fileName) {
+ sftpChannel = reConnect()
+
+ try {
+ // ¹¹½¨ÍêÕûµÄÔ¶³Ì·¾¶
+ String remoteFilePath = "${ftpPath}/${fileName}"
+
+ println "¿ªÊ¼ÉÏ´«ExcelÎļþµ½: ${remoteFilePath}"
+ println "Îļþ´óС: ${excelBytes.length} ×Ö½Ú"
+
+ // ½«×Ö½ÚÊý×éת»»ÎªÊäÈëÁ÷
+ InputStream inputStream = new ByteArrayInputStream(excelBytes)
+
+ // ÉÏ´«Îļþ
+ sftpChannel.put(inputStream, remoteFilePath)
+
+ // ¹Ø±ÕÁ÷
+ inputStream.close()
+
+ println "ExcelÎļþÉÏ´«³É¹¦: ${remoteFilePath}"
+
+ return true
+
+ } catch (Exception e) {
+ println "ÉÏ´«ExcelÎļþʧ°Ü: ${e.message}"
+ e.printStackTrace()
+ return false
+ }
+ }
+
+}
diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/jiangnanblank/TestEvaluation.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/jiangnanblank/TestEvaluation.groovy
index 5a92ee89f..c92f34b28 100644
--- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/jiangnanblank/TestEvaluation.groovy
+++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/jiangnanblank/TestEvaluation.groovy
@@ -1,24 +1,27 @@
package com.fangjia.script.jiangnanblank
import com.fangjia.core.util.HttpRequest
+import com.fangjia.core.util.PriceData
+import com.fangjia.core.util.SvgUtils
import com.fangjia.script.ccbevaluation.CcbCommonUtils
import com.fangjia.script.commData.CommonDatautils
+import com.fangjia.script.gj.OpenApiUtils
import com.fangjia.script.gj.district.FangjiaClientUtils
import com.fangjia.script.util.ExcelUtils
-import com.fangjia.script.util.MongoUtils
import com.fangjia.script.util.OpenApiClient
-import com.mongodb.DBCollection
+import groovy.json.JsonBuilder
import groovy.sql.Sql
import java.util.concurrent.ExecutorService
import java.util.concurrent.Executors
+import groovy.json.JsonOutput
/**
* Created by gaojuan on 2017/12/7.
*/
class TestEvaluation {
def sql = Sql.newInstance(
- "jdbc:mysql://192.168.0.92:3306/fangjiatong?useSSL=false&serverTimezone=Asia/Shanghai",
+ "jdbc:mysql://192.168.0.92:3306/fangjiatong?useSSL=false&useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai",
"goojia",
"G0ojia123456!@#",
"com.mysql.cj.jdbc.Driver"
@@ -36,11 +39,13 @@ class TestEvaluation {
// task.newAndOldMatch()
// task.addFjwToBprice("D:\\Êý¾Ý\\ºêÐÅÏ¢\\ºêÐÅ·¿Ô´Ì¨ÕË-¼Û¸ñ.xlsx")
-// task.addAreaFactor()
+ task.addAreaFactor()
// task.addOptName()
// task.addDistId()
- task.addEvaluationToDB()
+// task.addEvaluationToDB()
+
+// task.addEvaluationDetail()
}
def houseSimilar(){
@@ -293,7 +298,7 @@ class TestEvaluation {
def addAreaFactor(){
- ExcelUtils.multiThreadingModify("D:\\Êý¾Ý\\ºêÐÅÏ¢\\ºêÐÅ·¿Ô´Ì¨ÕË-»ù×¼¼Û£¨º¬ID£©.xlsx",{d->
+ ExcelUtils.multiThreadingModify("D:\\Êý¾Ý\\ºêÐÅÏ¢\\£¨ºìÉ«£©ºêÐŹÀÖµÏêÇé-×îÐÂ0106.xlsx",{d->
if(d['I'] && d['J'] && d['K']){
def dist = CommonDatautils.findDistrictById(d['I'])
if(dist){
@@ -309,6 +314,11 @@ class TestEvaluation {
// }
// d['L']=(int)(d['J']*d['K'])
// d['N'] = (int)(d['L'] + d['L']*d['M'])
+ def obj = CommonDatautils.queryDistrictPriceData(dist.city, dist.region, dist.name)
+ if(obj && obj.avg_price_2b){
+ d['M'] = obj.avg_price_2b
+ d['L'] = (int)(obj.avg_price_2b * d['K'])
+ }
}
}
@@ -357,7 +367,7 @@ class TestEvaluation {
if(d['B'] == "¹«Ô¢"){
buildType = 8
}else if(d['B'] == "±ðÊû"){
- buildType = 4
+ buildType = 11
}else if(d['B'] == "ÉÌÆÌ"){
buildType = 1
}else if(d['B'] == "°ì¹«Â¥"){
@@ -365,14 +375,16 @@ class TestEvaluation {
}
def lat = dist.lat/10000000000.0
def lng = dist.lng/10000000000.0
- def cat = 5
- if(buildType==3 || buildType==8 || buildType ==4){
+ def cat = 6
+ if(buildType==3 || buildType==8 || buildType ==11){
cat = 1
}else if(buildType == 1){
cat = 4
+ }else if(buildType == 2){
+ cat = 6
}
def date = new Date()
- rets << [d['E'], dist.city, dist.region, dist.name, dist.address,buildType,d['I'], d['J'].toString().toDouble().toInteger(), lng, lat, d['F'], date, date, cat, d['K'].toString().toDouble().toInteger()]
+ rets << [d['E'], dist.city, dist.region, dist.name, dist.address,buildType,d['I'], d['J'].toString().toDouble().toInteger(), lng, lat, d['F'], date, date, cat, d['K'].toString().toDouble().toInteger(), 2]
}
}
},1)
@@ -381,15 +393,208 @@ class TestEvaluation {
}
def addDataToDB(rows){
- def sqlstring = "insert into evaluation(user_id, city, region, district_name, address, build_type, house_area, total_price, lng, lat, org_code, create_time, update_time, cat, unit_price ) values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)"
+ def sqlstring = "insert into evaluation(user_id, city, region, district_name, address, build_type, house_area, total_price, lng, lat, org_code, create_time, update_time, cat, unit_price,report_type,average_price ) values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)"
sql.withBatch(1, sqlstring){ ps->
for(def r : rows) {
- ps.addBatch(r[0], r[1], r[2], r[3], r[4], r[5], r[6], r[7], r[8], r[9], r[10], r[11], r[12], r[13], r[14])
+ ps.addBatch(r[0], r[1], r[2], r[3], r[4], r[5], r[6], r[7], r[8], r[9], r[10], r[11], r[12], r[13], r[14], r[15],r[14])
ps.toString()
}
}
}
+ def addEvaluationDetail(){
+ def rets = []
+
+ def detailList = ExcelUtils.read("D:\\Êý¾Ý\\ºêÐÅÏ¢\\ºêÐÅ·¿Ô´Ì¨ÕË-»ù×¼¼Û-ÏêÇé.xlsx", 0 , 1)
+ ExcelUtils.modify("D:\\Êý¾Ý\\ºêÐÅÏ¢\\ºêÐÅÏîÄ¿-×îÖÕ.xlsx", { d ->
+ if (d['G'] && d['L'] && d['L'].toString().toDouble().toInteger()>=3472507) {
+ def rows = findEvaluationIdExists(d['L'].toString().toDouble().toInteger())
+ if(!rows){
+ def dist = CommonDatautils.findDistrictById(d['G'])
+ if (dist) {
+ def ret = []
+ ret << d['L'].toString().toDouble().toInteger()
+ def houses = []
+ if(["סլ","±ðÊû","¹«Ô¢"].contains(d["B"])){
+ def propertyType = 0
+ if(d["B"] == "±ðÊû"){
+ propertyType = 1
+ }
+ def avgPrice = d['K']
+ def minPrice = null
+ def maxPrice = null
+ if(avgPrice){
+ minPrice = avgPrice
+ maxPrice = (int)(avgPrice + avgPrice * 0.1)
+ }
+ houses = OpenApiClient.newHouseAction(dist.city, dist.region, dist.name, propertyType.toString(), minPrice, maxPrice, 5)
+
+ if(houses.size()<5){
+ if(avgPrice){
+ minPrice = avgPrice
+ maxPrice = (int)(avgPrice + avgPrice * 0.2)
+ }
+ houses = OpenApiClient.newHouseAction(dist.city, dist.region, dist.name, propertyType.toString(), minPrice, maxPrice, 15)
+ }
+ }
+ if(houses){
+ ret << createHouse(houses)
+ }else{
+ ret << []
+ }
+ if(d['K']){
+ ret << createTrend(d['K'].toString().toDouble().toInteger(), d['A'])
+ }else{
+ ret << '{"trendSvg":""}'
+ }
+ ret << []
+ ret << "ÉϺ£ºêÐŽ¨Éè·¢Õ¹ÓÐÏÞ¹«Ë¾"
+ ret << new Date()
+ ret << new Date()
+ ret << 1
+ ret << d['A']
+ ret << createAttachment(detailList, d['G'], d['B'], dist)
+// rets.add(ret)
+ saveEvaluationEditData(ret)
+
+ }
+ }
+ }
+ });
+ }
+
+ def saveEvaluationEditData(r){
+
+ def sqlstring = "insert into evaluation_edit_data(evaluation_id, house_samples, market_analysis, custom_properties, company, create_time, update_time, validity_period, subject_name, attachments) values (?,?,?,?,?,?,?,?,?,?)"
+
+ sql.withBatch(1, sqlstring){ ps->
+ def houseSamplesJson = null
+ if (r[1]) {
+ // ÐÞ¸´ÖÐÎÄתÒå
+ houseSamplesJson = fixUnicodeEscapes(JsonOutput.toJson(r[1]))
+ }
+ def marketAnalysisJson = null
+ if (r[2]) {
+ // ÐÞ¸´ÖÐÎÄתÒå
+ marketAnalysisJson = fixUnicodeEscapes(JsonOutput.toJson(r[2]))
+ }
+
+ def customPropertiesJson = r[1] ? JsonOutput.toJson(r[3]) : null
+ def attachmentsJson = null
+ if(r[9]){
+ // ÐÞ¸´ÖÐÎÄתÒå
+ attachmentsJson = fixUnicodeEscapes(JsonOutput.toJson(r[9]))
+ }
+
+ ps.addBatch(r[0], houseSamplesJson, marketAnalysisJson, customPropertiesJson, r[4], r[5], r[6], r[7], r[8], attachmentsJson)
+ ps.toString()
+ }
+ }
+
+
+ def findEvaluationIdExists(evaluationId){
+ def query = "SELECT * FROM evaluation_edit_data WHERE evaluation_id = ? LIMIT 1"
+ return sql.firstRow(query, [evaluationId])
+ }
+
+ def createTrend(price, name){
+ List data1 = PriceData.getSampleData(price);
+ List> dataSets = new ArrayList<>();
+ dataSets.add(data1);
+ List labels = Arrays.asList(name);
+
+ def priceTrendMap = [:]
+ def categories = []
+
+ def priceData = []
+ for(PriceData pd : data1){
+ categories << pd.yearmonth
+ priceData << (int)pd.price
+ }
+
+ priceTrendMap.put("categories", categories)
+ priceTrendMap.put("series", [["name":name,"data":priceData]])
+
+ String title = "¼Û¸ñ×ßÊÆÍ¼";
+ String subtitle = categories[0] + " ÖÁ "+categories[categories.size()-1];
+ // ²âÊÔСÊýλΪ0£¨ÕûÊýµÈ²î£©
+ String svgWithoutDecimals = SvgUtils.generatePriceTrendSvg(dataSets, labels, title, subtitle, 0);
+ return ["avgPrice":price, "priceTrend":priceTrendMap,"trendSvg":svgWithoutDecimals]
+ }
+
+ def createAttachment(detailList, id, type, dist){
+ def items = []
+ for(def data : detailList){
+ if(data["I"]==id && type==data['D']){
+ def totalPrice = 0
+ if (data['H'] && data['N']){
+ totalPrice = (int)(data['H'] * data['N'])
+ }
+ def unitPrice = 0
+ if(data['N']){
+ unitPrice = data['N'].toString().toDouble().toInteger()
+ }
+ items << ["city":dist.city, "district":dist.region, "address":data['B'], "area":data['H'], "unitPrice":unitPrice, "totalPrice":totalPrice]
+ }
+ }
+
+ if(items.size()>1){
+ def time = new Date().getTime()
+ def resMap = ["id":"attachment_"+time, "title": "³öÊÛ×ʲú¼Û¸ñÇåµ¥","type": 1,"editing": false,"items":items]
+ return [resMap]
+ }
+ return []
+ }
+
+
+ def fixUnicodeEscapes(jsonString){
+ if (!jsonString){
+ return jsonString
+ }
+
+ def result = new StringBuilder()
+ def matcher = jsonString =~ /\\u([0-9a-fA-F]{4})/
+ def lastIndex = 0
+
+ while (matcher.find()) {
+ // Ìí¼ÓÇ°ÃæµÄ²¿·Ö
+ result.append(jsonString.substring(lastIndex, matcher.start()))
+
+ // ת»»UnicodeתÒå×Ö·û
+ String hex = matcher.group(1)
+ int codePoint = Integer.parseInt(hex, 16)
+
+ // ¼ì²éÊÇ·ñÊÇÖÐÎÄ×Ö·û£¨³£ÓÃÖÐÎÄ×Ö·û·¶Î§£©
+ // ÖÐÎÄUnicode·¶Î§£º0x4E00-0x9FFF£¬0x3400-0x4DBF£¬0x20000-0x2A6DFµÈ
+ if ((codePoint >= 0x4E00 && codePoint <= 0x9FFF) ||
+ (codePoint >= 0x3400 && codePoint <= 0x4DBF)) {
+ // ÊÇÖÐÎÄ£¬×ª»»ÎªÊµ¼Ê×Ö·û
+ result.append(new String(Character.toChars(codePoint)))
+ } else {
+ // ²»ÊÇÖÐÎÄ£¬±£ÁôתÒå¸ñʽ
+ result.append("\\u").append(hex)
+ }
+
+ lastIndex = matcher.end()
+ }
+
+ // Ìí¼ÓÊ£Óಿ·Ö
+ result.append(jsonString.substring(lastIndex))
+ return result.toString()
+ }
+
+ def createHouse(houses){
+ def rets = []
+ def i = 0
+ def time = new Date().getTime()
+ for(def h : houses){
+ def pdate = h.caseDate.replace("-","").substring(0,6)
+ rets << ["city":h.city, "district":h.district, "name":h.name, "publishDate":pdate, "unitPrice":h.unitPrice, "_uid":"sample_"+time+"_"+i,"source":h.source, "area":h.size, "distance":h.distance, "totalPrice":h.totalPrice]
+ i++
+ }
+ return rets;
+ }
+
}
diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/util/ExcelUtils.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/util/ExcelUtils.groovy
index 50882747b..43265e606 100644
--- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/util/ExcelUtils.groovy
+++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/util/ExcelUtils.groovy
@@ -11,6 +11,7 @@ import org.apache.poi.ss.usermodel.*
import org.apache.poi.ss.util.CellRangeAddress
import org.apache.poi.ss.util.RegionUtil
import org.apache.poi.xssf.streaming.SXSSFWorkbook
+import org.apache.poi.xssf.usermodel.XSSFWorkbook
import java.util.concurrent.ExecutorService
import java.util.concurrent.Executors
@@ -103,6 +104,50 @@ public class ExcelUtils{
}
+ public static List> readFromStream(def inp,int sheetIndex = 0,int skipRow = 1){
+ List> ret = new ArrayList>();
+ try {
+ Workbook workbook = WorkbookFactory.create(inp)
+ workbook.setForceFormulaRecalculation(true)
+ Sheet sheet = workbook.getSheetAt(sheetIndex);
+ //ÐкÅ
+ int rowIndex = 0;
+ for(Row row : sheet){
+ rowIndex ++
+ if(rowIndex <= skipRow){
+ continue;
+ }
+ short minColIx = 0;
+ short maxColIx = row.getLastCellNum();
+ List