From d1adf7b9c4ca6ce3056695d0ce5af5b94a9dbd67 Mon Sep 17 00:00:00 2001 From: WendyYang Date: Wed, 13 Nov 2024 17:10:07 +0800 Subject: [PATCH] =?UTF-8?q?fix:=201.=20=E6=94=BF=E5=8A=A1=E7=B3=BB?= =?UTF-8?q?=E7=BB=9F=E6=9B=BF=E4=BB=A3=E6=83=85=E5=86=B5=E6=89=B9=E6=AC=A1?= =?UTF-8?q?=E5=8F=B7=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../UpdateProjectSystemReplaceInfoBatchNoUtil.java | 57 ++++++++++++++++++++++ .../manage/ProjectGovSystemReplaceInfoManage.java | 1 - 2 files changed, 57 insertions(+), 1 deletion(-) create mode 100644 hz-pm-api/src/main/java/com/hz/pm/api/common/util/UpdateProjectSystemReplaceInfoBatchNoUtil.java diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/common/util/UpdateProjectSystemReplaceInfoBatchNoUtil.java b/hz-pm-api/src/main/java/com/hz/pm/api/common/util/UpdateProjectSystemReplaceInfoBatchNoUtil.java new file mode 100644 index 0000000..077b2c9 --- /dev/null +++ b/hz-pm-api/src/main/java/com/hz/pm/api/common/util/UpdateProjectSystemReplaceInfoBatchNoUtil.java @@ -0,0 +1,57 @@ +package com.hz.pm.api.common.util; + +import cn.hutool.core.collection.CollUtil; +import cn.hutool.poi.excel.ExcelReader; +import cn.hutool.poi.excel.ExcelUtil; +import com.hz.pm.api.projectlib.entity.ProjectGovSystemReplaceInfos; +import com.ningdatech.basic.util.CollUtils; + +import java.util.Comparator; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.concurrent.atomic.AtomicInteger; + +/** + *

+ * UpdateProjectSystemReplaceInfoBatchNoUtil + *

+ * + * @author WendyYang + * @since 17:08 2024/11/13 + */ +public class UpdateProjectSystemReplaceInfoBatchNoUtil { + + private UpdateProjectSystemReplaceInfoBatchNoUtil() { + } + + public static void main(String[] args) { + ExcelReader reader = ExcelUtil.getReader("/Users/wendy/Desktop/response.xls"); + List replaceInfos = reader.readAll(ProjectGovSystemReplaceInfos.class); + CollUtils.group(replaceInfos, ProjectGovSystemReplaceInfos::getProjectCode).forEach((k, v) -> { + v.sort(Comparator.comparing(ProjectGovSystemReplaceInfos::getBatchNo)); + Integer batchNo = CollUtil.getLast(v).getBatchNo(); + if (batchNo == 1 && v.size() > 1) { + Set targetSystsems = CollUtils.fieldSet(v, ProjectGovSystemReplaceInfos::getTargetSystem); + if (targetSystsems.size() > 1 && CollUtils.fieldSet(v, ProjectGovSystemReplaceInfos::getReplaceType).size() == 1) { + // System.out.println("项目编码:" + k); + // System.out.println(JSONUtil.toJsonStr(targetSystsems)); + Map> group = CollUtils.group(v, ProjectGovSystemReplaceInfos::getTargetSystem); + AtomicInteger newBatchNo = new AtomicInteger(0); + group.entrySet().stream().sorted(Comparator.comparing(w -> { + w.getValue().sort(Comparator.comparing(ProjectGovSystemReplaceInfos::getId)); + return w.getValue().get(0).getId(); + })).forEach(entry -> { + int currBatchNo = newBatchNo.incrementAndGet(); + for (ProjectGovSystemReplaceInfos infos : entry.getValue()) { + String sql = String.format("update ND_PROJECT_GOV_SYSTEM_REPLACE_INFOS set batch_no = %d where id = %d;", currBatchNo, infos.getId()); + System.out.println(sql); + } + }); + } + + } + }); + } + +} diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/manage/ProjectGovSystemReplaceInfoManage.java b/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/manage/ProjectGovSystemReplaceInfoManage.java index e37a972..bf4ba38 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/manage/ProjectGovSystemReplaceInfoManage.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/manage/ProjectGovSystemReplaceInfoManage.java @@ -116,7 +116,6 @@ public class ProjectGovSystemReplaceInfoManage { public void downTmp(HttpServletResponse response) { List replaceInfos = systemReplaceInfosService.list(); - replaceInfos.removeIf(w -> StrUtil.isNotBlank(w.getSourceSystemId())); if (replaceInfos.isEmpty()) { throw ReturnException.wrap("暂无数据可供导出"); }