Merge remote-tracking branch 'base-version/main' into test
This commit is contained in:
@@ -92,4 +92,18 @@ public class SyncLogController {
|
||||
return success(count);
|
||||
}
|
||||
|
||||
@PostMapping("/batch-rerun/process")
|
||||
@Operation(summary = "处理批量重跑(处理重试中状态的记录)")
|
||||
@PreAuthorize("@ss.hasPermission('system:sync-log:batch-rerun')")
|
||||
public CommonResult<Integer> processBatchRerun(
|
||||
@RequestParam(value = "batchSize", defaultValue = "50") Integer batchSize) {
|
||||
// 参数校验
|
||||
if (batchSize <= 0 || batchSize > 500) {
|
||||
throw new IllegalArgumentException("批次大小必须在1-500之间");
|
||||
}
|
||||
|
||||
int processedCount = syncLogService.processBatchRerun(batchSize);
|
||||
return success(processedCount);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -13,6 +13,7 @@ import com.zt.plat.module.system.dal.mysql.sync.SyncLogMapper;
|
||||
import com.zt.plat.module.system.enums.sync.SyncLogStatusEnum;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import jakarta.annotation.Resource;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@@ -426,12 +427,23 @@ public class SyncLogServiceImpl implements SyncLogService {
|
||||
@Override
|
||||
public Map<String, Object> getBatchRerunProgress(String serviceName) {
|
||||
// 统计各状态的记录数量
|
||||
Map<Integer, Long> statusCounts = syncLogMapper.selectList(
|
||||
new LambdaQueryWrapper<SyncLogDO>()
|
||||
.eq(SyncLogDO::getServiceName, serviceName)
|
||||
.groupBy(SyncLogDO::getStatus))
|
||||
.stream()
|
||||
.collect(Collectors.groupingBy(SyncLogDO::getStatus, Collectors.counting()));
|
||||
// 使用MyBatis-Plus的聚合查询方式,避免DM8数据库GROUP BY语法问题
|
||||
List<Map<String, Object>> statusCountsList = syncLogMapper.selectMaps(
|
||||
new QueryWrapper<SyncLogDO>()
|
||||
.select("status, COUNT(*) as count")
|
||||
.eq("service_name", serviceName)
|
||||
.groupBy("status"));
|
||||
|
||||
// 转换为Map结构
|
||||
Map<Integer, Long> statusCounts = statusCountsList.stream()
|
||||
.filter(map -> map.get("status") != null && map.get("count") != null)
|
||||
.collect(Collectors.toMap(
|
||||
map -> (Integer) map.get("status"),
|
||||
map -> {
|
||||
Object countObj = map.get("count");
|
||||
return countObj instanceof Number ? ((Number) countObj).longValue() : 0L;
|
||||
}
|
||||
));
|
||||
|
||||
Map<String, Object> progress = new HashMap<>();
|
||||
progress.put("serviceName", serviceName);
|
||||
|
||||
Reference in New Issue
Block a user