diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/scheduler/task/EarlyWarningWithoutSubmitTask.java b/hz-pm-api/src/main/java/com/hz/pm/api/scheduler/task/EarlyWarningWithoutSubmitTask.java index e5e0678..f31d133 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/scheduler/task/EarlyWarningWithoutSubmitTask.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/scheduler/task/EarlyWarningWithoutSubmitTask.java @@ -100,16 +100,10 @@ public class EarlyWarningWithoutSubmitTask { StopWatch stopWatch = new StopWatch(); stopWatch.start(); // 获取项目库所有建设单位不为空的项目 - LambdaQueryWrapper queryWrapper = Wrappers.lambdaQuery(Project.class).isNotNull(Project::getBuildOrgCode); + LambdaQueryWrapper queryWrapper = Wrappers.lambdaQuery(Project.class) + .isNotNull(Project::getBuildOrgCode) + .eq(Project::getNewest, Boolean.TRUE); List projects = projectService.list(queryWrapper); - // 根据项目code分组 获取最新的一条数据 - Map projectMap = projects.stream().collect(Collectors.groupingBy(Project::getProjectCode, Collectors.collectingAndThen( - // 根据创建日期找到最新的记录 - Collectors.maxBy(Comparator.comparing(Project::getCreateOn)), - // 如果没有记录则返回null - optional -> optional.orElse(null) - ))); - List projectList = new ArrayList<>(projectMap.values()); List projectEarlyWarnings = Lists.newArrayList(); List earlyWarningRecords = Lists.newArrayList(); List needRemoved = Lists.newArrayList(); @@ -119,7 +113,7 @@ public class EarlyWarningWithoutSubmitTask { List earlyWarnings = projectEarlyWarningService.list(warningQuery); Map projectEarlyWarningMap = CollUtils.listToMap(earlyWarnings, c -> c.getProjectCode() + StrPool.DASH + c.getStepName()); // 遍历项目 获取对应申报单位的滞后预警规则 - for (Project project : projectList) { + for (Project project : projects) { String buildOrgCode = project.getBuildOrgCode(); String projectCode = project.getProjectCode(); Long mhUnitId = Long.valueOf(buildOrgCode); diff --git a/hz-pm-api/src/test/java/com/hz/pm/api/warning/DelayWarningTest.java b/hz-pm-api/src/test/java/com/hz/pm/api/warning/DelayWarningTest.java index b502b7b..0d85977 100644 --- a/hz-pm-api/src/test/java/com/hz/pm/api/warning/DelayWarningTest.java +++ b/hz-pm-api/src/test/java/com/hz/pm/api/warning/DelayWarningTest.java @@ -114,16 +114,10 @@ public class DelayWarningTest extends AppTests { StopWatch stopWatch = new StopWatch(); stopWatch.start(); // 获取项目库所有建设单位不为空的项目 - LambdaQueryWrapper queryWrapper = Wrappers.lambdaQuery(Project.class).isNotNull(Project::getBuildOrgCode); + LambdaQueryWrapper queryWrapper = Wrappers.lambdaQuery(Project.class) + .isNotNull(Project::getBuildOrgCode) + .eq(Project::getNewest, Boolean.TRUE); List projects = projectService.list(queryWrapper); - // 根据项目code分组 获取最新的一条数据 - Map projectMap = projects.stream().collect(Collectors.groupingBy(Project::getProjectCode, Collectors.collectingAndThen( - // 根据创建日期找到最新的记录 - Collectors.maxBy(Comparator.comparing(Project::getCreateOn)), - // 如果没有记录则返回null - optional -> optional.orElse(null) - ))); - List projectList = new ArrayList<>(projectMap.values()); List projectEarlyWarnings = Lists.newArrayList(); List earlyWarningRecords = Lists.newArrayList(); List needRemoved = Lists.newArrayList(); @@ -133,7 +127,7 @@ public class DelayWarningTest extends AppTests { List earlyWarnings = projectEarlyWarningService.list(warningQuery); Map projectEarlyWarningMap = CollUtils.listToMap(earlyWarnings, c -> c.getProjectCode() + StrPool.DASH + c.getStepName()); // 遍历项目 获取对应申报单位的滞后预警规则 - for (Project project : projectList) { + for (Project project : projects) { String buildOrgCode = project.getBuildOrgCode(); String projectCode = project.getProjectCode(); Long mhUnitId = Long.valueOf(buildOrgCode);