From 203c639326c4c8b18f9e2691a1a07149abdbbc5e Mon Sep 17 00:00:00 2001 From: YunaiV Date: Mon, 16 Feb 2026 22:30:01 +0800 Subject: [PATCH] refactor(mes-tm): 工具管理模块代码优化 --- yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/tm/tool/MesTmToolController.java | 44 ++++++++++++++++++++++---------------------- yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/dal/dataobject/tm/tool/MesTmToolDO.java | 7 ++++--- yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/dal/dataobject/tm/tool/MesTmToolTypeDO.java | 4 ++-- yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/enums/DictTypeConstants.java | 4 ++++ yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/enums/ErrorCodeConstants.java | 9 +++++++++ yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/enums/cal/MesCalPlanStatusEnum.java | 37 +++++++++++++++++++++++++++++++++++++ yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/enums/cal/MesCalShiftMethodEnum.java | 39 +++++++++++++++++++++++++++++++++++++++ yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/enums/cal/MesCalShiftTypeEnum.java | 38 ++++++++++++++++++++++++++++++++++++++ yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/enums/tm/MesTmMaintenTypeEnum.java | 37 +++++++++++++++++++++++++++++++++++++ yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/enums/tm/MesTmToolStatusEnum.java | 39 +++++++++++++++++++++++++++++++++++++++ yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/md/client/MesMdClientServiceImpl.java | 4 ++++ yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/md/item/MesMdItemTypeServiceImpl.java | 4 ++++ yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/md/unitmeasure/MesMdUnitMeasureServiceImpl.java | 5 +++++ yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/md/vendor/MesMdVendorServiceImpl.java | 4 ++++ yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/md/workstation/MesMdWorkshopServiceImpl.java | 5 +++++ yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/tm/tool/MesTmToolServiceImpl.java | 14 ++++++-------- yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/tm/tool/MesTmToolTypeServiceImpl.java | 20 +++++++++----------- 17 files changed, 268 insertions(+), 46 deletions(-) create mode 100644 yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/enums/cal/MesCalPlanStatusEnum.java create mode 100644 yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/enums/cal/MesCalShiftMethodEnum.java create mode 100644 yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/enums/cal/MesCalShiftTypeEnum.java create mode 100644 yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/enums/tm/MesTmMaintenTypeEnum.java create mode 100644 yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/enums/tm/MesTmToolStatusEnum.java diff --git a/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/tm/tool/MesTmToolController.java b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/tm/tool/MesTmToolController.java index f017799..6ce72aa 100644 --- a/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/tm/tool/MesTmToolController.java +++ b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/tm/tool/MesTmToolController.java @@ -23,7 +23,11 @@ import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; +import cn.hutool.core.collection.CollUtil; +import cn.iocoder.yudao.framework.common.util.collection.MapUtils; + import java.io.IOException; +import java.util.Collections; import java.util.List; import java.util.Map; @@ -89,17 +93,7 @@ public class MesTmToolController { @PreAuthorize("@ss.hasPermission('mes:tm-tool:query')") public CommonResult> getToolPage(@Valid MesTmToolPageReqVO pageReqVO) { PageResult pageResult = toolService.getToolPage(pageReqVO); - PageResult voPageResult = BeanUtils.toBean(pageResult, MesTmToolRespVO.class); - // 拼接工具类型名称 - Map toolTypeMap = toolTypeService.getToolTypeMap( - convertSet(voPageResult.getList(), MesTmToolRespVO::getToolTypeId)); - voPageResult.getList().forEach(vo -> { - MesTmToolTypeDO toolType = toolTypeMap.get(vo.getToolTypeId()); - if (toolType != null) { - vo.setToolTypeName(toolType.getName()); - } - }); - return success(voPageResult); + return success(new PageResult<>(buildToolRespVOList(pageResult.getList()), pageResult.getTotal())); } @GetMapping("/export-excel") @@ -110,20 +104,26 @@ public class MesTmToolController { HttpServletResponse response) throws IOException { pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE); List list = toolService.getToolPage(pageReqVO).getList(); - List voList = BeanUtils.toBean(list, MesTmToolRespVO.class); - // 拼接工具类型名称 - Map toolTypeMap = toolTypeService.getToolTypeMap( - convertSet(voList, MesTmToolRespVO::getToolTypeId)); - voList.forEach(vo -> { - MesTmToolTypeDO toolType = toolTypeMap.get(vo.getToolTypeId()); - if (toolType != null) { - vo.setToolTypeName(toolType.getName()); - } - }); + List voList = buildToolRespVOList(list); // 导出 Excel ExcelUtils.write(response, "工具台账.xls", "数据", MesTmToolRespVO.class, voList); } - // TODO @AI:page、export 都有拼接;可以参考别的模块的出列方式, 抽 build 公用方法; + // ==================== 拼接 VO ==================== + + @SuppressWarnings("CodeBlock2Expr") + private List buildToolRespVOList(List list) { + if (CollUtil.isEmpty(list)) { + return Collections.emptyList(); + } + // 1. 批量获取工具类型信息 + Map toolTypeMap = toolTypeService.getToolTypeMap( + convertSet(list, MesTmToolDO::getToolTypeId)); + // 2. 拼接 VO + return BeanUtils.toBean(list, MesTmToolRespVO.class, vo -> { + MapUtils.findAndThen(toolTypeMap, vo.getToolTypeId(), + toolType -> vo.setToolTypeName(toolType.getName())); + }); + } } diff --git a/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/dal/dataobject/tm/tool/MesTmToolDO.java b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/dal/dataobject/tm/tool/MesTmToolDO.java index e41b79c..a2b3b89 100644 --- a/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/dal/dataobject/tm/tool/MesTmToolDO.java +++ b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/dal/dataobject/tm/tool/MesTmToolDO.java @@ -1,6 +1,8 @@ package cn.iocoder.yudao.module.mes.dal.dataobject.tm.tool; import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; +import cn.iocoder.yudao.module.mes.enums.tm.MesTmToolStatusEnum; +import cn.iocoder.yudao.module.mes.enums.tm.MesTmMaintenTypeEnum; import com.baomidou.mybatisplus.annotation.KeySequence; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; @@ -58,11 +60,10 @@ public class MesTmToolDO extends BaseDO { * 可用数量 */ private Integer quantityAvailable; - // TODO @AI:枚举类 /** * 保养维护类型 * - * 字典 {@link cn.iocoder.yudao.module.mes.enums.DictTypeConstants#MES_TM_MAINTEN_TYPE} + * 枚举 {@link MesTmMaintenTypeEnum} */ private Integer maintenType; /** @@ -76,7 +77,7 @@ public class MesTmToolDO extends BaseDO { /** * 状态 * - * 字典 {@link cn.iocoder.yudao.module.mes.enums.DictTypeConstants#MES_TM_TOOL_STATUS} + * 枚举 {@link MesTmToolStatusEnum} */ private Integer status; /** diff --git a/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/dal/dataobject/tm/tool/MesTmToolTypeDO.java b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/dal/dataobject/tm/tool/MesTmToolTypeDO.java index 31b382b..35be7ab 100644 --- a/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/dal/dataobject/tm/tool/MesTmToolTypeDO.java +++ b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/dal/dataobject/tm/tool/MesTmToolTypeDO.java @@ -1,6 +1,7 @@ package cn.iocoder.yudao.module.mes.dal.dataobject.tm.tool; import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; +import cn.iocoder.yudao.module.mes.enums.tm.MesTmMaintenTypeEnum; import com.baomidou.mybatisplus.annotation.KeySequence; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; @@ -38,11 +39,10 @@ public class MesTmToolTypeDO extends BaseDO { * 是否编码管理 */ private Boolean codeFlag; - // TODO @AI:枚举类; /** * 保养维护类型 * - * 字典 {@link cn.iocoder.yudao.module.mes.enums.DictTypeConstants#MES_TM_MAINTEN_TYPE} + * 枚举 {@link MesTmMaintenTypeEnum} */ private Integer maintenType; /** diff --git a/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/enums/DictTypeConstants.java b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/enums/DictTypeConstants.java index c5e0e39..73905b3 100644 --- a/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/enums/DictTypeConstants.java +++ b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/enums/DictTypeConstants.java @@ -12,5 +12,9 @@ public interface DictTypeConstants { String MES_CAL_HOLIDAY_TYPE = "mes_cal_holiday_type"; // MES 假期类型 String MES_TM_TOOL_STATUS = "mes_tm_tool_status"; // MES 工具状态 String MES_TM_MAINTEN_TYPE = "mes_tm_mainten_type"; // MES 保养维护类型 + String MES_CAL_SHIFT_TYPE = "mes_cal_shift_type"; // MES 轮班方式 + String MES_CAL_SHIFT_METHOD = "mes_cal_shift_method"; // MES 倒班方式 + String MES_CAL_CALENDAR_TYPE = "mes_cal_calendar_type"; // MES 班组类型 + String MES_CAL_PLAN_STATUS = "mes_cal_plan_status"; // MES 排班计划状态 } diff --git a/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/enums/ErrorCodeConstants.java b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/enums/ErrorCodeConstants.java index 0d00c9c..4675618 100644 --- a/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/enums/ErrorCodeConstants.java +++ b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/enums/ErrorCodeConstants.java @@ -83,12 +83,21 @@ public interface ErrorCodeConstants { // ========== MES 日历排班-班次(1-040-200-000) ========== ErrorCode CAL_SHIFT_NOT_EXISTS = new ErrorCode(1_040_200_000, "班次不存在"); + ErrorCode CAL_SHIFT_COUNT_EXCEED_SINGLE = new ErrorCode(1_040_200_001, "轮班方式为白班时只能有一个班次"); + ErrorCode CAL_SHIFT_COUNT_EXCEED_TWO = new ErrorCode(1_040_200_002, "轮班方式为两班倒时只能有两个班次"); + ErrorCode CAL_SHIFT_COUNT_EXCEED_THREE = new ErrorCode(1_040_200_003, "轮班方式为三班倒时只能有三个班次"); // ========== MES 日历排班-班组(1-040-201-000) ========== ErrorCode CAL_TEAM_NOT_EXISTS = new ErrorCode(1_040_201_000, "班组不存在"); // ========== MES 日历排班-排班计划(1-040-202-000) ========== ErrorCode CAL_PLAN_NOT_EXISTS = new ErrorCode(1_040_202_000, "排班计划不存在"); + ErrorCode CAL_PLAN_CODE_DUPLICATE = new ErrorCode(1_040_202_001, "排班计划编码已存在"); + ErrorCode CAL_PLAN_NOT_PREPARE = new ErrorCode(1_040_202_002, "只能删除草稿状态的排班计划"); + ErrorCode CAL_PLAN_TEAM_COUNT_NOT_MATCH = new ErrorCode(1_040_202_003, "确认排班计划时,分配的班组数量与轮班方式不匹配"); + // ========== MES 日历排班-计划班组关联(1-040-202-100) ========== + ErrorCode CAL_PLAN_TEAM_NOT_EXISTS = new ErrorCode(1_040_202_100, "计划班组关联不存在"); + ErrorCode CAL_PLAN_TEAM_DUPLICATE = new ErrorCode(1_040_202_101, "该班组已分配到此计划"); // ========== MES 日历排班-假期设置(1-040-203-000) ========== ErrorCode CAL_HOLIDAY_NOT_EXISTS = new ErrorCode(1_040_203_000, "假期设置不存在"); diff --git a/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/enums/cal/MesCalPlanStatusEnum.java b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/enums/cal/MesCalPlanStatusEnum.java new file mode 100644 index 0000000..c4cb84a --- /dev/null +++ b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/enums/cal/MesCalPlanStatusEnum.java @@ -0,0 +1,37 @@ +package cn.iocoder.yudao.module.mes.enums.cal; + +import cn.iocoder.yudao.framework.common.core.ArrayValuable; +import lombok.AllArgsConstructor; +import lombok.Getter; + +import java.util.Arrays; + +/** + * MES 排班计划状态枚举 + * + * @author 芋道源码 + */ +@Getter +@AllArgsConstructor +public enum MesCalPlanStatusEnum implements ArrayValuable { + + PREPARE(0, "草稿"), + CONFIRMED(1, "已确认"); + + public static final Integer[] ARRAYS = Arrays.stream(values()).map(MesCalPlanStatusEnum::getStatus).toArray(Integer[]::new); + + /** + * 状态值 + */ + private final Integer status; + /** + * 状态名 + */ + private final String name; + + @Override + public Integer[] array() { + return ARRAYS; + } + +} diff --git a/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/enums/cal/MesCalShiftMethodEnum.java b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/enums/cal/MesCalShiftMethodEnum.java new file mode 100644 index 0000000..4c63360 --- /dev/null +++ b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/enums/cal/MesCalShiftMethodEnum.java @@ -0,0 +1,39 @@ +package cn.iocoder.yudao.module.mes.enums.cal; + +import cn.iocoder.yudao.framework.common.core.ArrayValuable; +import lombok.AllArgsConstructor; +import lombok.Getter; + +import java.util.Arrays; + +/** + * MES 倒班方式枚举 + * + * @author 芋道源码 + */ +@Getter +@AllArgsConstructor +public enum MesCalShiftMethodEnum implements ArrayValuable { + + QUARTER(1, "按季度"), + MONTH(2, "按月"), + WEEK(3, "按周"), + DAY(4, "按天"); + + public static final Integer[] ARRAYS = Arrays.stream(values()).map(MesCalShiftMethodEnum::getMethod).toArray(Integer[]::new); + + /** + * 方式值 + */ + private final Integer method; + /** + * 方式名 + */ + private final String name; + + @Override + public Integer[] array() { + return ARRAYS; + } + +} diff --git a/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/enums/cal/MesCalShiftTypeEnum.java b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/enums/cal/MesCalShiftTypeEnum.java new file mode 100644 index 0000000..9679cc3 --- /dev/null +++ b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/enums/cal/MesCalShiftTypeEnum.java @@ -0,0 +1,38 @@ +package cn.iocoder.yudao.module.mes.enums.cal; + +import cn.iocoder.yudao.framework.common.core.ArrayValuable; +import lombok.AllArgsConstructor; +import lombok.Getter; + +import java.util.Arrays; + +/** + * MES 轮班方式枚举 + * + * @author 芋道源码 + */ +@Getter +@AllArgsConstructor +public enum MesCalShiftTypeEnum implements ArrayValuable { + + SINGLE(1, "单白班"), + TWO(2, "两班倒"), + THREE(3, "三班倒"); + + public static final Integer[] ARRAYS = Arrays.stream(values()).map(MesCalShiftTypeEnum::getType).toArray(Integer[]::new); + + /** + * 类型值 + */ + private final Integer type; + /** + * 类型名 + */ + private final String name; + + @Override + public Integer[] array() { + return ARRAYS; + } + +} diff --git a/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/enums/tm/MesTmMaintenTypeEnum.java b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/enums/tm/MesTmMaintenTypeEnum.java new file mode 100644 index 0000000..16cdffc --- /dev/null +++ b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/enums/tm/MesTmMaintenTypeEnum.java @@ -0,0 +1,37 @@ +package cn.iocoder.yudao.module.mes.enums.tm; + +import cn.iocoder.yudao.framework.common.core.ArrayValuable; +import lombok.AllArgsConstructor; +import lombok.Getter; + +import java.util.Arrays; + +/** + * MES 保养维护类型枚举 + * + * @author 芋道源码 + */ +@Getter +@AllArgsConstructor +public enum MesTmMaintenTypeEnum implements ArrayValuable { + + REGULAR(1, "定期维护"), + USAGE(2, "按使用次数维护"); + + public static final Integer[] ARRAYS = Arrays.stream(values()).map(MesTmMaintenTypeEnum::getType).toArray(Integer[]::new); + + /** + * 类型值 + */ + private final Integer type; + /** + * 类型名 + */ + private final String name; + + @Override + public Integer[] array() { + return ARRAYS; + } + +} diff --git a/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/enums/tm/MesTmToolStatusEnum.java b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/enums/tm/MesTmToolStatusEnum.java new file mode 100644 index 0000000..5152bd3 --- /dev/null +++ b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/enums/tm/MesTmToolStatusEnum.java @@ -0,0 +1,39 @@ +package cn.iocoder.yudao.module.mes.enums.tm; + +import cn.iocoder.yudao.framework.common.core.ArrayValuable; +import lombok.AllArgsConstructor; +import lombok.Getter; + +import java.util.Arrays; + +/** + * MES 工具状态枚举 + * + * @author 芋道源码 + */ +@Getter +@AllArgsConstructor +public enum MesTmToolStatusEnum implements ArrayValuable { + + STORE(1, "在库"), + ISSUE(2, "领用中"), + REPAIR(3, "维修中"), + SCRAP(4, "报废"); + + public static final Integer[] ARRAYS = Arrays.stream(values()).map(MesTmToolStatusEnum::getStatus).toArray(Integer[]::new); + + /** + * 状态值 + */ + private final Integer status; + /** + * 状态名 + */ + private final String name; + + @Override + public Integer[] array() { + return ARRAYS; + } + +} diff --git a/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/md/client/MesMdClientServiceImpl.java b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/md/client/MesMdClientServiceImpl.java index a4ed943..63dfb28 100644 --- a/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/md/client/MesMdClientServiceImpl.java +++ b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/md/client/MesMdClientServiceImpl.java @@ -19,6 +19,7 @@ import org.springframework.validation.annotation.Validated; import java.util.ArrayList; import java.util.Collection; +import java.util.Collections; import java.util.LinkedHashMap; import java.util.List; import java.util.concurrent.atomic.AtomicInteger; @@ -134,6 +135,9 @@ public class MesMdClientServiceImpl implements MesMdClientService { @Override public List getClientList(Collection ids) { + if (CollUtil.isEmpty(ids)) { + return Collections.emptyList(); + } return clientMapper.selectByIds(ids); } diff --git a/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/md/item/MesMdItemTypeServiceImpl.java b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/md/item/MesMdItemTypeServiceImpl.java index e43d29b..c0280ef 100644 --- a/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/md/item/MesMdItemTypeServiceImpl.java +++ b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/md/item/MesMdItemTypeServiceImpl.java @@ -1,5 +1,6 @@ package cn.iocoder.yudao.module.mes.service.md.item; +import cn.hutool.core.collection.CollUtil; import cn.hutool.core.util.ObjUtil; import cn.iocoder.yudao.framework.common.util.object.BeanUtils; import cn.iocoder.yudao.module.mes.controller.admin.md.item.vo.type.MesMdItemTypeListReqVO; @@ -152,6 +153,9 @@ public class MesMdItemTypeServiceImpl implements MesMdItemTypeService { @Override public List getItemTypeList(Collection ids) { + if (CollUtil.isEmpty(ids)) { + return Collections.emptyList(); + } return itemTypeMapper.selectByIds(ids); } diff --git a/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/md/unitmeasure/MesMdUnitMeasureServiceImpl.java b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/md/unitmeasure/MesMdUnitMeasureServiceImpl.java index af85415..1d90ae3 100644 --- a/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/md/unitmeasure/MesMdUnitMeasureServiceImpl.java +++ b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/md/unitmeasure/MesMdUnitMeasureServiceImpl.java @@ -1,5 +1,6 @@ package cn.iocoder.yudao.module.mes.service.md.unitmeasure; +import cn.hutool.core.collection.CollUtil; import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.common.util.object.BeanUtils; import cn.iocoder.yudao.module.mes.controller.admin.md.unitmeasure.vo.MesMdUnitMeasurePageReqVO; @@ -12,6 +13,7 @@ import org.springframework.stereotype.Service; import org.springframework.validation.annotation.Validated; import java.util.Collection; +import java.util.Collections; import java.util.List; import java.util.Objects; @@ -105,6 +107,9 @@ public class MesMdUnitMeasureServiceImpl implements MesMdUnitMeasureService { @Override public List getUnitMeasureList(Collection ids) { + if (CollUtil.isEmpty(ids)) { + return Collections.emptyList(); + } return unitMeasureMapper.selectByIds(ids); } diff --git a/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/md/vendor/MesMdVendorServiceImpl.java b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/md/vendor/MesMdVendorServiceImpl.java index 0f9e189..943895c 100644 --- a/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/md/vendor/MesMdVendorServiceImpl.java +++ b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/md/vendor/MesMdVendorServiceImpl.java @@ -19,6 +19,7 @@ import org.springframework.validation.annotation.Validated; import java.util.ArrayList; import java.util.Collection; +import java.util.Collections; import java.util.LinkedHashMap; import java.util.List; import java.util.concurrent.atomic.AtomicInteger; @@ -133,6 +134,9 @@ public class MesMdVendorServiceImpl implements MesMdVendorService { @Override public List getVendorList(Collection ids) { + if (CollUtil.isEmpty(ids)) { + return Collections.emptyList(); + } return vendorMapper.selectByIds(ids); } diff --git a/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/md/workstation/MesMdWorkshopServiceImpl.java b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/md/workstation/MesMdWorkshopServiceImpl.java index 298b983..2963c4f 100644 --- a/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/md/workstation/MesMdWorkshopServiceImpl.java +++ b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/md/workstation/MesMdWorkshopServiceImpl.java @@ -1,5 +1,6 @@ package cn.iocoder.yudao.module.mes.service.md.workstation; +import cn.hutool.core.collection.CollUtil; import cn.hutool.core.util.ObjUtil; import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.common.util.object.BeanUtils; @@ -15,6 +16,7 @@ import org.springframework.stereotype.Service; import org.springframework.validation.annotation.Validated; import java.util.Collection; +import java.util.Collections; import java.util.List; import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; @@ -115,6 +117,9 @@ public class MesMdWorkshopServiceImpl implements MesMdWorkshopService { @Override public List getWorkshopList(Collection ids) { + if (CollUtil.isEmpty(ids)) { + return Collections.emptyList(); + } return workshopMapper.selectByIds(ids); } diff --git a/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/tm/tool/MesTmToolServiceImpl.java b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/tm/tool/MesTmToolServiceImpl.java index 09738a6..9aaf8ae 100644 --- a/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/tm/tool/MesTmToolServiceImpl.java +++ b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/tm/tool/MesTmToolServiceImpl.java @@ -6,11 +6,14 @@ import cn.iocoder.yudao.module.mes.controller.admin.tm.tool.vo.MesTmToolPageReqV import cn.iocoder.yudao.module.mes.controller.admin.tm.tool.vo.MesTmToolSaveReqVO; import cn.iocoder.yudao.module.mes.dal.dataobject.tm.tool.MesTmToolDO; import cn.iocoder.yudao.module.mes.dal.mysql.tm.tool.MesTmToolMapper; +import cn.iocoder.yudao.module.mes.enums.tm.MesTmMaintenTypeEnum; import jakarta.annotation.Resource; import org.springframework.context.annotation.Lazy; import org.springframework.stereotype.Service; import org.springframework.validation.annotation.Validated; +import cn.hutool.core.util.ObjUtil; + import java.util.Objects; import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; @@ -55,10 +58,9 @@ public class MesTmToolServiceImpl implements MesTmToolService { validateToolCodeUnique(updateReqVO.getId(), updateReqVO.getCode()); // 更新 - // TODO @AI:枚举类维护类型,避免使用魔法值 - if (Objects.equals(updateReqVO.getMaintenType(), 1)) { // 定期维护 + if (Objects.equals(updateReqVO.getMaintenType(), MesTmMaintenTypeEnum.REGULAR.getType())) { updateReqVO.setNextMaintenPeriod(null); - } else if (Objects.equals(updateReqVO.getMaintenType(), 2)) { // 按使用次数维护 + } else if (Objects.equals(updateReqVO.getMaintenType(), MesTmMaintenTypeEnum.USAGE.getType())) { updateReqVO.setNextMaintenDate(null); } MesTmToolDO updateObj = BeanUtils.toBean(updateReqVO, MesTmToolDO.class); @@ -87,11 +89,7 @@ public class MesTmToolServiceImpl implements MesTmToolService { if (tool == null) { return; } - // TODO @AI:ObjUtil notEquals - if (id == null) { - throw exception(TM_TOOL_CODE_DUPLICATE); - } - if (!Objects.equals(tool.getId(), id)) { + if (ObjUtil.notEqual(tool.getId(), id)) { throw exception(TM_TOOL_CODE_DUPLICATE); } } diff --git a/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/tm/tool/MesTmToolTypeServiceImpl.java b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/tm/tool/MesTmToolTypeServiceImpl.java index 65a9d6d..0fda3cd 100644 --- a/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/tm/tool/MesTmToolTypeServiceImpl.java +++ b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/tm/tool/MesTmToolTypeServiceImpl.java @@ -1,5 +1,6 @@ package cn.iocoder.yudao.module.mes.service.tm.tool; +import cn.hutool.core.collection.CollUtil; import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.common.util.object.BeanUtils; import cn.iocoder.yudao.module.mes.controller.admin.tm.tool.vo.type.MesTmToolTypePageReqVO; @@ -11,9 +12,11 @@ import jakarta.annotation.Resource; import org.springframework.stereotype.Service; import org.springframework.validation.annotation.Validated; +import cn.hutool.core.util.ObjUtil; + import java.util.Collection; +import java.util.Collections; import java.util.List; -import java.util.Objects; import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; import static cn.iocoder.yudao.module.mes.enums.ErrorCodeConstants.*; @@ -84,11 +87,7 @@ public class MesTmToolTypeServiceImpl implements MesTmToolTypeService { if (toolType == null) { return; } - // TODO @AI:ObjUtil notEquals - if (id == null) { - throw exception(TM_TOOL_TYPE_CODE_DUPLICATE); - } - if (!Objects.equals(toolType.getId(), id)) { + if (ObjUtil.notEqual(toolType.getId(), id)) { throw exception(TM_TOOL_TYPE_CODE_DUPLICATE); } } @@ -98,11 +97,7 @@ public class MesTmToolTypeServiceImpl implements MesTmToolTypeService { if (toolType == null) { return; } - // TODO @AI:ObjUtil notEquals - if (id == null) { - throw exception(TM_TOOL_TYPE_NAME_DUPLICATE); - } - if (!Objects.equals(toolType.getId(), id)) { + if (ObjUtil.notEqual(toolType.getId(), id)) { throw exception(TM_TOOL_TYPE_NAME_DUPLICATE); } } @@ -124,6 +119,9 @@ public class MesTmToolTypeServiceImpl implements MesTmToolTypeService { @Override public List getToolTypeList(Collection ids) { + if (CollUtil.isEmpty(ids)) { + return Collections.emptyList(); + } return toolTypeMapper.selectByIds(ids); } -- libgit2 0.21.4