|
|
@@ -88,9 +88,29 @@ public class TableServiceImpl implements ITableService {
|
|
|
|
|
|
@Override
|
|
|
public void savePriceBatch(List<PriceInfoDto> dtos){
|
|
|
- dtos.forEach(this::savePrice);
|
|
|
+ if(CollectionUtil.isEmpty(dtos)){
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ Set<String> tableNames = new HashSet<>();
|
|
|
+ List<BackupsInfo> addDtos = new LinkedList<>();
|
|
|
+ dtos.forEach(dto -> {
|
|
|
+ String tableName = String.format("%s_%s_%s", dto.getCoin().replaceAll("_", ""), dto.getSource(), dto.getB_type()).toUpperCase();
|
|
|
+ tableNames.add(tableName);
|
|
|
+ addDtos.add(dto.convertAdd());
|
|
|
+ });
|
|
|
+ try {
|
|
|
+ // 建表
|
|
|
+ this.tableMapper.createTables(tableNames);
|
|
|
+ // 写入数据
|
|
|
+ this.tableMapper.savePrices(addDtos);
|
|
|
+ } catch (Exception ex){
|
|
|
+ log.error("插入报错", ex);
|
|
|
+ backupsInfoService.saveBatch(addDtos);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+
|
|
|
@Override
|
|
|
public void savePrice(PriceInfoDto dto){
|
|
|
String tableName = String.format("%s_%s_%s", dto.getCoin().replaceAll("_", ""), dto.getSource(), dto.getB_type()).toUpperCase();
|