package com.ycl.thread; import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper; import com.baomidou.mybatisplus.extension.conditions.update.LambdaUpdateChainWrapper; import com.ycl.platform.domain.entity.YwPoint; import com.ycl.platform.mapper.YwPointMapper; import java.util.ArrayList; import java.util.List; import java.util.concurrent.Callable; /** * @author:xp * @date:2024/8/22 14:24 */ public class PointImportCallable implements Callable { private List updateList; private YwPointMapper ywPointMapper; private List failedList = new ArrayList<>(); private Integer maxFailedTimes = 5; public PointImportCallable(List updateList, YwPointMapper ywPointMapper) { this.updateList = updateList; this.ywPointMapper = ywPointMapper; } @Override public Boolean call() throws Exception { this.updateFailed(updateList); return this.failedList.size() < 1; } private void updateFailed(List list) { this.maxFailedTimes -= 1; if (this.maxFailedTimes < 0) { return; } for (YwPoint ywPoint : list) { boolean update = new LambdaUpdateChainWrapper<>(ywPointMapper) .eq(YwPoint::getSerialNumber, ywPoint.getSerialNumber()) .set(YwPoint::getProvinceTagVideo, ywPoint.getProvinceTagVideo()) .set(YwPoint::getProvinceTagCar, ywPoint.getProvinceTagCar()) .set(YwPoint::getProvinceTagFace, ywPoint.getProvinceTagFace()) .set(YwPoint::getImportantCommandImageTag, ywPoint.getImportantCommandImageTag()) .set(YwPoint::getUnitId, ywPoint.getUnitId()) .set(YwPoint::getStartTime, ywPoint.getStartTime()) .set(YwPoint::getEndTime, ywPoint.getEndTime()) .update(); if (! update) { failedList.add(ywPoint); } else if (failedList.contains(ywPoint)) { failedList.remove(ywPoint); } } if (failedList.size() > 0) { this.updateFailed(failedList); } } }