java项目两种方法实现大批量数据:存在就更新,不存在就新增,脏数据就删除。
一、法一:存在就更新,不存在就新增,原本的脏数据就删除
@Component
public class InsetUserUtils {
@Resource
private ThreadPoolExecutor threadPoolExecutor;
public void getNewUserInfo() {
List<User> userList = userService.listInformation();
if (!CollectionUtils.isEmpty(userList)) {
Map<String, Integer> cache = userService.list(new LambdaQueryWrapper<User>())
.stream().collect(Collectors.toMap(data -> data.getCode()
, User::getId));
List<TableRowStatistics> update = new ArrayList<>();
List<TableRowUStatistics> save = new ArrayList<>();
for (User user : userList) {
Future<