update 新增eth 币价定时任务

This commit is contained in:
yyb
2025-11-03 11:21:07 +08:00
parent 066c3b48f6
commit 10d85fe508

View File

@@ -44,7 +44,7 @@ public class NeaxPriceTask {
//private String COINMARKETCAP_KEY="7b7a5fc2-795d-4900-a4db-152681382d52";
private String ALL_COINS="nexa,monacoin,groestlcoin,digibyte,radiant,alephium,monero";
private String ALL_COINS="nexa,monacoin,groestlcoin,digibyte,radiant,alephium,monero,ethereum";
@Autowired
private RedisService redisService;
@@ -67,6 +67,7 @@ public class NeaxPriceTask {
|| StringUtils.isNull(map.get("alph"))
|| StringUtils.isNull(map.get("monero"))
|| StringUtils.isNull(map.get("sha3x"))
|| StringUtils.isNull(map.get("eth"))
){
if(count >= 10){
break;
@@ -252,6 +253,30 @@ public class NeaxPriceTask {
xtmVo.setValue(sha3x);
poolMapper.insertPrice("sha3x_price",date , xtmVo);
}
//处理eth
BigDecimal eth = map.get("eth");
if(StringUtils.isNull(eth)){
//重拿eth
eth = getResultFromNet("ethereum");
int ethCount = 1;
while (StringUtils.isNull(eth)){
if(ethCount >= 5){
break;
}
eth = getResultFromNet("ethereum");
ethCount++;
}
}else {
redisService.setCacheObject("eth_price",eth);
//存入数据库
DateValueVo ethVo = new DateValueVo();
ethVo.setDate(now);
ethVo.setValue(eth);
poolMapper.insertPrice("eth_price",date , ethVo);
}
}
}
@@ -407,6 +432,8 @@ public class NeaxPriceTask {
object = data.getJSONObject("14878");
}else if ("monero".equalsIgnoreCase(coin)){
object = data.getJSONObject("328");
}else if("eth".equalsIgnoreCase(coin)){
object = data.getJSONObject("1027");
}
if (StringUtils.isNull(object)){
@@ -444,6 +471,7 @@ public class NeaxPriceTask {
map.put("rxd",null);
map.put("alph",null);
map.put("monero",null);
map.put("eth",null);
@@ -473,6 +501,7 @@ public class NeaxPriceTask {
JSONObject rxdObject = data.getJSONObject("22866");
JSONObject alphObject = data.getJSONObject("14878");
JSONObject moneroObject = data.getJSONObject("328");
JSONObject ethObject = data.getJSONObject("1027");
BigDecimal nexaPrice = getPriceByCoinIdJSONObject(nexaObject);
BigDecimal monaPrice = getPriceByCoinIdJSONObject(monaObject);
@@ -481,6 +510,7 @@ public class NeaxPriceTask {
BigDecimal rxdPrice = getPriceByCoinIdJSONObject(rxdObject);
BigDecimal alphPrice = getPriceByCoinIdJSONObject(alphObject);
BigDecimal moneroPrice = getPriceByCoinIdJSONObject(moneroObject);
BigDecimal ethPrice = getPriceByCoinIdJSONObject(ethObject);
map.put("nexa",nexaPrice);
map.put("mona",monaPrice);
@@ -489,6 +519,7 @@ public class NeaxPriceTask {
map.put("rxd",rxdPrice);
map.put("alph",alphPrice);
map.put("monero",moneroPrice);
map.put("eth",ethPrice);
//xtm 不通过coinmarketcap 获取币价
BlockInfo sha3xBlockInfoForXml = getSha3xBlockInfoForXml();