北交所接口合并

This commit is contained in:
mjt
2023-12-19 10:51:18 +08:00
parent 316297aeb6
commit c4eebbfe36
24 changed files with 4581 additions and 458 deletions
@@ -0,0 +1,71 @@
package com.fangjia.script.majintao
import com.fangjia.core.util.HttpRequest
import com.fangjia.script.util.ExcelUtils
import net.sf.json.JSONObject
ExcelUtils.removeEmptyRow("F:\\估家\\文件\\北交所\\testcopy.xlsx")
ExcelUtils.singleThreadingModify("F:\\估家\\文件\\北交所\\testcopy.xlsx", { List items ->
String excelFilePath = "F:\\估家\\文件\\北交所\\testcopy.xlsx";
String comprehensiveUrl = "http://192.168.10.15:9180/comprehensiveQuery/houseValueInformation";
String communityUrl = "http://192.168.10.15:9180/addrSvc/avgPrice";
String valueUrl = "http://192.168.10.15:9180/property/addressEvaluate";
String caseUrl = "http://192.168.10.15:9180/house/case";
String poiUrl = "http://192.168.10.15:9180/district/addrFacilitys";
HttpRequest httpRequest = new HttpRequest();
map = new HashMap<String, String>()
String city = items['A']
String address = items['B']
double size = items['C']
System.out.println(city + "---" + address + "----" + size);
map.put("city", city)
map.put("address", address)
map.put("size", size.toString())
map.put("strctureArea", size.toString())
map.put("token", "F54F52381C49BB9EB4A33EB1B65604AE4B71A28AEE53518A94A2F360408B9056D57553931D15CE6DDE765562DAD286BA38E05A4CDAFC51C3D527A4959BF8E75A3B95DB7108FCEA340DDE61925616DB55118E1851E67D83EAD800460D100D6B667A4ED8EE67C8F7FB")
if (!address.contains("%")) {
// 发送HTTP请求
long start
long end
// start = System.currentTimeMillis();
// httpRequest.getJsonContent(communityUrl, map, "UTF-8")
//
//
// end = System.currentTimeMillis();
// items['D'] = String.valueOf(end - start);
//
// start = System.currentTimeMillis();
// httpRequest.getJsonContent(valueUrl, map, "UTF-8")
// end = System.currentTimeMillis();
// items['E'] = String.valueOf(end - start);
//
// start = System.currentTimeMillis();
// httpRequest.getJsonContent(caseUrl, map, "UTF-8")
// end = System.currentTimeMillis();
// items['F'] = String.valueOf(end - start);
//
// start = System.currentTimeMillis();
// httpRequest.getJsonContent(poiUrl, map, "UTF-8")
// end = System.currentTimeMillis();
// items['G'] = String.valueOf(end - start);
start = System.currentTimeMillis();
def content = httpRequest.getJsonContent(comprehensiveUrl, map, "UTF-8")
end = System.currentTimeMillis();
items['H'] = String.valueOf(end - start);
println content.get("msg")
if(content.get("msg").contains("该地址不支持估价!")) {
items['I'] = "该地址不支持估价!"
}
}
})
@@ -443,6 +443,45 @@ public class ExcelUtils{
}
public static singleThreadingModify(String fileName, Closure closure, Integer srcSheetIndex = 0, String destSheetName = null){
if(!destSheetName){
def inp = new FileInputStream(fileName);
Workbook workbook = WorkbookFactory.create(inp)
workbook.setForceFormulaRecalculation(true)
Sheet sheet = workbook.getSheetAt(srcSheetIndex);
destSheetName = sheet.getSheetName();
}
def data = ExcelUtils.read(fileName, srcSheetIndex, 0)
def body = data.subList(1, data.size())
def nThread = Runtime.getRuntime().availableProcessors() * 3
println nThread
ExecutorService executorService = Executors.newFixedThreadPool(3)
final AtomicInteger counter = new AtomicInteger(0)
final double total = body.size()
for(int i = 0 ; i < body.size(); i++){
final row = body[i]
executorService.submit(new Runnable() {
@Override
void run() {
try{
closure.call(row)
int count = counter.incrementAndGet()
if(count % 1000 == 0){
println(DateUtils.formatDateByPattern(new Date(), "yyyy-MM-dd HH:mm:ss")+"执行进度:${com.fangjia.core.util.DataUtil.roundDouble((count * 100)/total, 2)}%")
}
}catch (Exception e){
println(row)
e.printStackTrace()
}
}
})
}
executorService.shutdown()
executorService.awaitTermination(30, TimeUnit.DAYS)
ExcelUtils.write(fileName, data, destSheetName)
}
public static Object getCellValue(Cell cell){