| | |
| | | BigDecimal coinAPrice = coinAUsdt.divide(coinACnt,12,BigDecimal.ROUND_DOWN); |
| | | coinAPriceDic.setValue(coinAPrice.toString()); |
| | | dataDictionaryCustomMapper.updateById(coinAPriceDic); |
| | | |
| | | chainProducer.sendAntKLineMsg(0); |
| | | /** |
| | | * 增加K线数据 |
| | | */ |
| | | DappAKlineEntity dappAKlineEntity = new DappAKlineEntity(); |
| | | dappAKlineEntity.setType(0); |
| | | /** |
| | | * 获取最新一条小时或者分钟的数据 |
| | | */ |
| | | DappAKlineEntity oldOne = dappAKlineMapper.selectOneByType(); |
| | | if(ObjectUtil.isNotEmpty(oldOne)){ |
| | | dappAKlineEntity.setOpenPrice(oldOne.getClosePrice()); |
| | | dappAKlineEntity.setLowestPrice(oldOne.getOpenPrice()); |
| | | }else{ |
| | | dappAKlineEntity.setOpenPrice(coinAPrice); |
| | | dappAKlineEntity.setLowestPrice(coinAPrice); |
| | | } |
| | | dappAKlineEntity.setHighestPrice(coinAPrice); |
| | | dappAKlineEntity.setClosePrice(coinAPrice); |
| | | dappAKlineMapper.insert(dappAKlineEntity); |
| | | } |
| | | |
| | | @Override |
| | |
| | | */ |
| | | DappAKlineEntity minRecord = dappAKlineMapper.selectOneHourByType(); |
| | | if(ObjectUtil.isEmpty(minRecord)){ |
| | | minRecord = dappAKlineMapper.selectOneByType(); |
| | | minRecord = dappAKlineMapper.selectOneByTypeAsc(); |
| | | } |
| | | DappAKlineEntity maxRecord = dappAKlineMapper.selectOneByType(); |
| | | List<DappAKlineEntity> dappAKlineEntities = dappAKlineMapper.selectListByIds(minRecord.getId(),maxRecord.getId()); |
| | |
| | | dappAKlineEntity.setType(1); |
| | | if(CollUtil.isNotEmpty(dappAKlineEntities)){ |
| | | |
| | | List<BigDecimal> openPriceList = dappAKlineEntities.stream().map(DappAKlineEntity::getOpenPrice).collect(Collectors.toList()); |
| | | List<BigDecimal> openPriceList = dappAKlineEntities.stream().map(DappAKlineEntity::getClosePrice).collect(Collectors.toList()); |
| | | BigDecimal openPrice = openPriceList.stream().min(BigDecimal::compareTo).get(); |
| | | dappAKlineEntity.setOpenPrice(openPrice); |
| | | //获取最高价 |
| | |
| | | DappAKlineEntity oldOne = dappAKlineMapper.selectOneByType(); |
| | | if(ObjectUtil.isNotEmpty(oldOne)){ |
| | | dappAKlineEntity.setOpenPrice(oldOne.getClosePrice()); |
| | | dappAKlineEntity.setLowestPrice(oldOne.getOpenPrice()); |
| | | }else{ |
| | | dappAKlineEntity.setOpenPrice(coinAPrice); |
| | | } |
| | | dappAKlineEntity.setLowestPrice(coinAPrice); |
| | | } |
| | | dappAKlineEntity.setHighestPrice(coinAPrice); |
| | | dappAKlineEntity.setClosePrice(coinAPrice); |
| | | dappAKlineMapper.insert(dappAKlineEntity); |