Browse Source

Merge remote-tracking branch 'origin/fix_1113' into dev

master
WendyYang 3 weeks ago
parent
commit
cb9e1820b0
2 changed files with 57 additions and 1 deletions
  1. +57
    -0
      hz-pm-api/src/main/java/com/hz/pm/api/common/util/UpdateProjectSystemReplaceInfoBatchNoUtil.java
  2. +0
    -1
      hz-pm-api/src/main/java/com/hz/pm/api/projectlib/manage/ProjectGovSystemReplaceInfoManage.java

+ 57
- 0
hz-pm-api/src/main/java/com/hz/pm/api/common/util/UpdateProjectSystemReplaceInfoBatchNoUtil.java View File

@@ -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;

/**
* <p>
* UpdateProjectSystemReplaceInfoBatchNoUtil
* </p>
*
* @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<ProjectGovSystemReplaceInfos> 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<String> 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<String, List<ProjectGovSystemReplaceInfos>> 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);
}
});
}

}
});
}

}

+ 0
- 1
hz-pm-api/src/main/java/com/hz/pm/api/projectlib/manage/ProjectGovSystemReplaceInfoManage.java View File

@@ -116,7 +116,6 @@ public class ProjectGovSystemReplaceInfoManage {

public void downTmp(HttpServletResponse response) {
List<ProjectGovSystemReplaceInfos> replaceInfos = systemReplaceInfosService.list();
replaceInfos.removeIf(w -> StrUtil.isNotBlank(w.getSourceSystemId()));
if (replaceInfos.isEmpty()) {
throw ReturnException.wrap("暂无数据可供导出");
}


Loading…
Cancel
Save