From a7b10c7fb28552e71e980d97a6b23c21cbcb212a Mon Sep 17 00:00:00 2001 From: xiaoyong931011 <15274802129@163.com> Date: Fri, 28 May 2021 14:37:47 +0800 Subject: [PATCH] 20210528 --- src/main/java/com/xcong/excoin/quartz/job/XchBaseDataUpdateJob.java | 27 ++++++++++++--------------- 1 files changed, 12 insertions(+), 15 deletions(-) diff --git a/src/main/java/com/xcong/excoin/quartz/job/XchBaseDataUpdateJob.java b/src/main/java/com/xcong/excoin/quartz/job/XchBaseDataUpdateJob.java index 140492a..23e5f5c 100644 --- a/src/main/java/com/xcong/excoin/quartz/job/XchBaseDataUpdateJob.java +++ b/src/main/java/com/xcong/excoin/quartz/job/XchBaseDataUpdateJob.java @@ -42,28 +42,27 @@ log.info("基础数据更新任务"); // 请求价格等数据 "https://api2.chiaexplorer.com/blockchainSummary" String result = pyExec(); - log.info("result======>>{}", result); +// log.info("result======>>{}", result); // 每t预计收益 // String profitPerT = execCurl("https://api2.chiaexplorer.com/chart/xchTibDay?period=2w"); // // String xchPrice24HStr = execCurl("https://api2.chiaexplorer.com/chart/xchPriceChart?period=24h"); - JSONObject jsonObject = (JSONObject) JSONObject.parse(result); +// JSONObject jsonObject = (JSONObject) JSONObject.parse(result); // JSONObject perTObject = (JSONObject) JSONObject.parse(profitPerT); -// JSONObject xchPrice24HObj = (JSONObject) JSONObject.parse(xchPrice24HStr); + JSONObject xchPrice24HObj = (JSONObject) JSONObject.parse(result); List<YdBasicSettingEntity> list = ydBasicSettingDao.selectList(null); if (CollUtil.isNotEmpty(list)) { YdBasicSettingEntity settingEntity = list.get(0); - String netspaceStr = jsonObject.getString("netspace"); - BigDecimal baseUnit = BigDecimal.valueOf(1024); - BigDecimal netspace = new BigDecimal(netspaceStr).divide(baseUnit.multiply(baseUnit.multiply(baseUnit.multiply(baseUnit.multiply(baseUnit)))), 2, BigDecimal.ROUND_DOWN); - settingEntity.setAllPower(netspace); +// String netspaceStr = jsonObject.getString("netspace"); +// BigDecimal baseUnit = BigDecimal.valueOf(1024); +// BigDecimal netspace = new BigDecimal(netspaceStr).divide(baseUnit.multiply(baseUnit.multiply(baseUnit.multiply(baseUnit.multiply(baseUnit)))), 2, BigDecimal.ROUND_DOWN); +// settingEntity.setAllPower(netspace); - BigDecimal newPrice = new BigDecimal(jsonObject.getString("price")); - redisUtils.set("XCH_NEW_PRICE", newPrice); - settingEntity.setCurrentPrice(newPrice); + List<String> xchPrice24H = JSONObject.parseArray(xchPrice24HObj.getString("data"), String.class); + BigDecimal newestPrice = new BigDecimal(xchPrice24H.get(xchPrice24H.size() - 1)); -// List<String> xchPrice24H = JSONObject.parseArray(xchPrice24HObj.getString("data"), String.class); -// BigDecimal newestPrice = new BigDecimal(xchPrice24H.get(xchPrice24H.size() - 1)); + redisUtils.set("XCH_NEW_PRICE", newestPrice); + settingEntity.setCurrentPrice(newestPrice); // BigDecimal lastPrice = new BigDecimal(xchPrice24H.get(xchPrice24H.size() - 1 -24)); // BigDecimal upOrDown = newestPrice.subtract(lastPrice).multiply(BigDecimal.valueOf(100)).divide(lastPrice, 2, BigDecimal.ROUND_HALF_UP); // redisUtils.set("XCH_UP_DOWN", upOrDown); @@ -155,10 +154,8 @@ public String pyExec() { String result = ""; - String path = ClassUtils.getDefaultClassLoader().getResource("").getPath(); - String filePath = path + "static/xch.py"; try { - Process process = Runtime.getRuntime().exec("python2.7 " + filePath); + Process process = Runtime.getRuntime().exec("python2.7 /home/javaweb/yunding/xch.py"); process.waitFor(); InputStreamReader ir = new InputStreamReader(process.getInputStream()); LineNumberReader input = new LineNumberReader(ir); -- Gitblit v1.9.1