From c04e4edab2818f8fa6db464ea64970dda2fbad8c Mon Sep 17 00:00:00 2001 From: WendyYang Date: Sat, 14 Sep 2024 10:24:15 +0800 Subject: [PATCH] =?UTF-8?q?modify:=201.=20=E5=BE=85=E5=8A=9E=E6=8E=A8?= =?UTF-8?q?=E9=80=81;?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../enumeration/IsAppendProjectEnum.java | 26 +++++----------- .../pm/api/todocenter/manage/TodoCenterManage.java | 36 +++++++++------------- 2 files changed, 21 insertions(+), 41 deletions(-) diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/todocenter/enumeration/IsAppendProjectEnum.java b/hz-pm-api/src/main/java/com/hz/pm/api/todocenter/enumeration/IsAppendProjectEnum.java index d507d33..e1786cb 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/todocenter/enumeration/IsAppendProjectEnum.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/todocenter/enumeration/IsAppendProjectEnum.java @@ -1,9 +1,7 @@ package com.hz.pm.api.todocenter.enumeration; -import io.swagger.annotations.ApiModel; import lombok.AllArgsConstructor; import lombok.Getter; -import lombok.NoArgsConstructor; import org.apache.commons.lang3.StringUtils; import java.util.Objects; @@ -15,44 +13,34 @@ import java.util.Objects; */ @Getter @AllArgsConstructor -@NoArgsConstructor -@ApiModel(value = "IsAppendProjectEnum", description = "是否增补项目-枚举") public enum IsAppendProjectEnum { /** * 非增补项目 */ - NOT_APPEND_PROJECT(0, "非增补项目"), + NOT_APPEND(0, "非增补项目"), /** * 增补项目 */ - APPEND_PROJECT(1, "增补项目"); + APPEND(1, "增补项目"); - private Integer code; - private String desc; + private final Integer code; + private final String val; - public String getDesc() { - return desc; - } - - public void setDesc(String desc) { - this.desc = desc; - } - - public static String getDescByCode(Integer code) { + public static String getVal(Integer code) { if (Objects.isNull(code)) { return StringUtils.EMPTY; } for (IsAppendProjectEnum t : IsAppendProjectEnum.values()) { if (code.equals(t.getCode())) { - return t.desc; + return t.val; } } return StringUtils.EMPTY; } - public static IsAppendProjectEnum getEnumByValue(Integer code) { + public static IsAppendProjectEnum get(Integer code) { if (Objects.isNull(code)) { return null; } diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/todocenter/manage/TodoCenterManage.java b/hz-pm-api/src/main/java/com/hz/pm/api/todocenter/manage/TodoCenterManage.java index 13dd296..2866f93 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/todocenter/manage/TodoCenterManage.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/todocenter/manage/TodoCenterManage.java @@ -49,7 +49,6 @@ import com.hz.pm.api.sys.service.IRegionService; import com.hz.pm.api.todocenter.constant.TodoCenterConst; import com.hz.pm.api.todocenter.constant.TodoCenterConst.Declared; import com.hz.pm.api.todocenter.constant.TodoCenterConst.SealTemplate; -import com.hz.pm.api.todocenter.enumeration.IsAppendProjectEnum; import com.hz.pm.api.todocenter.handle.PassHandle; import com.hz.pm.api.todocenter.handle.WithDrawHandle; import com.hz.pm.api.todocenter.model.dto.AdjustHandleDTO; @@ -122,6 +121,9 @@ import java.util.*; import java.util.stream.Collectors; import java.util.stream.Stream; +import static com.hz.pm.api.todocenter.enumeration.IsAppendProjectEnum.APPEND; +import static com.hz.pm.api.todocenter.enumeration.IsAppendProjectEnum.NOT_APPEND; + /** * @author ZPF * @since 2023/02/19 16:09 @@ -413,9 +415,9 @@ public class TodoCenterManage { } ExcelExportWriter excelExportWriter = new ExcelExportWriter(); String fileName; - if (IsAppendProjectEnum.APPEND_PROJECT.eq(param.getIsTemporaryAugment())) { + if (APPEND.eq(param.getIsTemporaryAugment())) { fileName = "待办中心_待我处理_增补项目列表"; - } else if (IsAppendProjectEnum.NOT_APPEND_PROJECT.eq(param.getIsTemporaryAugment())) { + } else if (NOT_APPEND.eq(param.getIsTemporaryAugment())) { fileName = "待办中心_待我处理_非增补项目列表"; } else { fileName = "待办中心_待我处理_全部项目列表"; @@ -546,7 +548,7 @@ public class TodoCenterManage { } break; default: - throw new IllegalStateException("Unexpected value: " + param.getAction()); + throw BizException.wrap("暂不支持该操作:%s", param.getAction()); } return "操作成功"; } @@ -1069,9 +1071,9 @@ public class TodoCenterManage { ExcelExportWriter excelExportWriter = new ExcelExportWriter(); String fileName = null; - if (IsAppendProjectEnum.APPEND_PROJECT.getCode().equals(param.getIsTemporaryAugment())) { + if (APPEND.eq(param.getIsTemporaryAugment())) { fileName = "待办中心_我已处理_增补项目列表"; - } else if (IsAppendProjectEnum.NOT_APPEND_PROJECT.getCode().equals(param.getIsTemporaryAugment())) { + } else if (NOT_APPEND.eq(param.getIsTemporaryAugment())) { fileName = "待办中心_我已处理_非增补项目列表"; } excelExportWriter.setFileName(fileName); @@ -1281,9 +1283,9 @@ public class TodoCenterManage { ExcelExportWriter excelExportWriter = new ExcelExportWriter(); String fileName = null; - if (IsAppendProjectEnum.APPEND_PROJECT.getCode().equals(param.getIsTemporaryAugment())) { + if (APPEND.getCode().equals(param.getIsTemporaryAugment())) { fileName = "待办中心_我发起的_增补项目列表"; - } else if (IsAppendProjectEnum.NOT_APPEND_PROJECT.getCode().equals(param.getIsTemporaryAugment())) { + } else if (NOT_APPEND.getCode().equals(param.getIsTemporaryAugment())) { fileName = "待办中心_我发起的_非增补项目列表"; } excelExportWriter.setFileName(fileName); @@ -1488,9 +1490,9 @@ public class TodoCenterManage { ExcelExportWriter excelExportWriter = new ExcelExportWriter(); String fileName = null; - if (IsAppendProjectEnum.APPEND_PROJECT.getCode().equals(param.getIsTemporaryAugment())) { + if (APPEND.getCode().equals(param.getIsTemporaryAugment())) { fileName = "待办中心_抄送我的_增补项目列表"; - } else if (IsAppendProjectEnum.NOT_APPEND_PROJECT.getCode().equals(param.getIsTemporaryAugment())) { + } else if (NOT_APPEND.getCode().equals(param.getIsTemporaryAugment())) { fileName = "待办中心_抄送我的_非增补项目列表"; } excelExportWriter.setFileName(fileName); @@ -1734,18 +1736,8 @@ public class TodoCenterManage { retTodoNum.setTotalNum(projectList.size()); } // 筛选出增补项目和非增补项目 - List appendProjects = projectList.stream() - .filter(p -> IsAppendProjectEnum.APPEND_PROJECT.getCode().equals(p.getIsTemporaryAugment())) - .collect(Collectors.toList()); - if (CollUtil.isNotEmpty(appendProjects)) { - retTodoNum.setAppendNum(appendProjects.size()); - } - List notAppendProjects = projectList.stream() - .filter(p -> IsAppendProjectEnum.NOT_APPEND_PROJECT.getCode().equals(p.getIsTemporaryAugment())) - .collect(Collectors.toList()); - if (CollUtil.isNotEmpty(notAppendProjects)) { - retTodoNum.setNotAppendNum(notAppendProjects.size()); - } + retTodoNum.setAppendNum(CollUtil.count(projectList, p -> APPEND.eq(p.getIsTemporaryAugment()))); + retTodoNum.setNotAppendNum(CollUtil.count(projectList, p -> NOT_APPEND.eq(p.getIsTemporaryAugment()))); return retTodoNum; }