Commit dd85e6bd4bbae741685f28f4dbb4bed419945eb9

Authored by YunaiV
1 parent 936783f9

♻️ refactor(mes): 使用 ListUtil 替换 List.of

Showing 22 changed files with 67 additions and 47 deletions
yudao-framework/yudao-spring-boot-starter-excel/src/test/java/cn/iocoder/yudao/framework/dict/core/util/DictFrameworkUtilsTest.java
1 1 package cn.iocoder.yudao.framework.dict.core.util;
2 2  
  3 +import cn.hutool.core.collection.ListUtil;
3 4 import cn.iocoder.yudao.framework.common.biz.system.dict.DictDataCommonApi;
4 5 import cn.iocoder.yudao.framework.common.biz.system.dict.dto.DictDataRespDTO;
5 6 import cn.iocoder.yudao.framework.dict.core.DictFrameworkUtils;
... ... @@ -32,7 +33,7 @@ public class DictFrameworkUtilsTest extends BaseMockitoUnitTest {
32 33 @Test
33 34 public void testParseDictDataLabel() {
34 35 // mock 数据
35   - List<DictDataRespDTO> dictDatas = List.of(
  36 + List<DictDataRespDTO> dictDatas = ListUtil.of(
36 37 randomPojo(DictDataRespDTO.class, o -> o.setDictType("animal").setValue("cat").setLabel("猫")),
37 38 randomPojo(DictDataRespDTO.class, o -> o.setDictType("animal").setValue("dog").setLabel("狗"))
38 39 );
... ... @@ -46,7 +47,7 @@ public class DictFrameworkUtilsTest extends BaseMockitoUnitTest {
46 47 @Test
47 48 public void testParseDictDataValue() {
48 49 // mock 数据
49   - List<DictDataRespDTO> dictDatas = List.of(
  50 + List<DictDataRespDTO> dictDatas = ListUtil.of(
50 51 randomPojo(DictDataRespDTO.class, o -> o.setDictType("animal").setValue("cat").setLabel("猫")),
51 52 randomPojo(DictDataRespDTO.class, o -> o.setDictType("animal").setValue("dog").setLabel("狗"))
52 53 );
... ...
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/pro/andon/MesProAndonConfigController.java
1 1 package cn.iocoder.yudao.module.mes.controller.admin.pro.andon;
2 2  
3 3 import cn.hutool.core.collection.CollUtil;
  4 +import cn.hutool.core.collection.ListUtil;
4 5 import cn.iocoder.yudao.framework.common.pojo.CommonResult;
5 6 import cn.iocoder.yudao.framework.common.pojo.PageResult;
6 7 import cn.iocoder.yudao.framework.common.util.collection.MapUtils;
... ... @@ -73,7 +74,7 @@ public class MesProAndonConfigController {
73 74 if (config == null) {
74 75 return success(null);
75 76 }
76   - return success(buildConfigRespVOList(List.of(config)).get(0));
  77 + return success(buildConfigRespVOList(ListUtil.of(config)).get(0));
77 78 }
78 79  
79 80 @GetMapping("/page")
... ...
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/pro/andon/MesProAndonRecordController.java
1 1 package cn.iocoder.yudao.module.mes.controller.admin.pro.andon;
2 2  
3 3 import cn.hutool.core.collection.CollUtil;
  4 +import cn.hutool.core.collection.ListUtil;
4 5 import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog;
5 6 import cn.iocoder.yudao.framework.common.pojo.CommonResult;
6 7 import cn.iocoder.yudao.framework.common.pojo.PageParam;
... ... @@ -95,7 +96,7 @@ public class MesProAndonRecordController {
95 96 if (record == null) {
96 97 return success(null);
97 98 }
98   - return success(buildRecordRespVOList(List.of(record)).get(0));
  99 + return success(buildRecordRespVOList(ListUtil.of(record)).get(0));
99 100 }
100 101  
101 102 @GetMapping("/page")
... ...
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/pro/card/MesProCardController.java
1 1 package cn.iocoder.yudao.module.mes.controller.admin.pro.card;
2 2  
3 3 import cn.hutool.core.collection.CollUtil;
  4 +import cn.hutool.core.collection.ListUtil;
4 5 import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog;
5 6 import cn.iocoder.yudao.framework.common.pojo.CommonResult;
6 7 import cn.iocoder.yudao.framework.common.pojo.PageParam;
... ... @@ -116,7 +117,7 @@ public class MesProCardController {
116 117 if (card == null) {
117 118 return success(null);
118 119 }
119   - return success(buildCardRespVOList(List.of(card)).get(0));
  120 + return success(buildCardRespVOList(ListUtil.of(card)).get(0));
120 121 }
121 122  
122 123 @GetMapping("/page")
... ...
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/pro/card/MesProCardProcessController.java
1 1 package cn.iocoder.yudao.module.mes.controller.admin.pro.card;
2 2  
3 3 import cn.hutool.core.collection.CollUtil;
  4 +import cn.hutool.core.collection.ListUtil;
4 5 import cn.iocoder.yudao.framework.common.pojo.CommonResult;
5 6 import cn.iocoder.yudao.framework.common.pojo.PageResult;
6 7 import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
... ... @@ -82,7 +83,7 @@ public class MesProCardProcessController {
82 83 if (cardProcess == null) {
83 84 return success(null);
84 85 }
85   - return success(buildCardProcessRespVOList(List.of(cardProcess)).get(0));
  86 + return success(buildCardProcessRespVOList(ListUtil.of(cardProcess)).get(0));
86 87 }
87 88  
88 89 @GetMapping("/page")
... ...
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/pro/feedback/MesProFeedbackController.java
1 1 package cn.iocoder.yudao.module.mes.controller.admin.pro.feedback;
2 2  
3 3 import cn.hutool.core.collection.CollUtil;
  4 +import cn.hutool.core.collection.ListUtil;
4 5 import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog;
5 6 import cn.iocoder.yudao.framework.common.pojo.CommonResult;
6 7 import cn.iocoder.yudao.framework.common.pojo.PageParam;
... ... @@ -111,7 +112,7 @@ public class MesProFeedbackController {
111 112 if (feedback == null) {
112 113 return success(null);
113 114 }
114   - return success(buildFeedbackRespVOList(List.of(feedback)).get(0));
  115 + return success(buildFeedbackRespVOList(ListUtil.of(feedback)).get(0));
115 116 }
116 117  
117 118 @GetMapping("/page")
... ...
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/pro/route/MesProRouteProcessController.java
1 1 package cn.iocoder.yudao.module.mes.controller.admin.pro.route;
2 2  
3 3 import cn.hutool.core.collection.CollUtil;
  4 +import cn.hutool.core.collection.ListUtil;
4 5 import cn.iocoder.yudao.framework.common.pojo.CommonResult;
5 6 import cn.iocoder.yudao.framework.common.util.collection.MapUtils;
6 7 import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
... ... @@ -129,7 +130,7 @@ public class MesProRouteProcessController {
129 130 if (routeProcess == null) {
130 131 return null;
131 132 }
132   - return buildRouteProcessRespVOList(List.of(routeProcess)).get(0);
  133 + return buildRouteProcessRespVOList(ListUtil.of(routeProcess)).get(0);
133 134 }
134 135  
135 136 }
... ...
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/pro/route/MesProRouteProductBomController.java
1 1 package cn.iocoder.yudao.module.mes.controller.admin.pro.route;
2 2  
3 3 import cn.hutool.core.collection.CollUtil;
  4 +import cn.hutool.core.collection.ListUtil;
4 5 import cn.iocoder.yudao.framework.common.pojo.CommonResult;
5 6 import cn.iocoder.yudao.framework.common.util.collection.MapUtils;
6 7 import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
... ... @@ -120,7 +121,7 @@ public class MesProRouteProductBomController {
120 121 if (routeProductBom == null) {
121 122 return null;
122 123 }
123   - return buildRouteProductBomRespVOList(List.of(routeProductBom)).get(0);
  124 + return buildRouteProductBomRespVOList(ListUtil.of(routeProductBom)).get(0);
124 125 }
125 126  
126 127 }
... ...
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/pro/route/MesProRouteProductController.java
1 1 package cn.iocoder.yudao.module.mes.controller.admin.pro.route;
2 2  
3 3 import cn.hutool.core.collection.CollUtil;
  4 +import cn.hutool.core.collection.ListUtil;
4 5 import cn.iocoder.yudao.framework.common.pojo.CommonResult;
5 6 import cn.iocoder.yudao.framework.common.util.collection.MapUtils;
6 7 import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
... ... @@ -112,7 +113,7 @@ public class MesProRouteProductController {
112 113 if (routeProduct == null) {
113 114 return null;
114 115 }
115   - return buildRouteProductRespVOList(List.of(routeProduct)).get(0);
  116 + return buildRouteProductRespVOList(ListUtil.of(routeProduct)).get(0);
116 117 }
117 118  
118 119 }
... ...
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/pro/task/MesProTaskController.java
1 1 package cn.iocoder.yudao.module.mes.controller.admin.pro.task;
2 2  
3 3 import cn.hutool.core.collection.CollUtil;
  4 +import cn.hutool.core.collection.ListUtil;
4 5 import cn.hutool.core.util.ObjUtil;
5 6 import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog;
6 7 import cn.iocoder.yudao.framework.common.pojo.CommonResult;
... ... @@ -110,7 +111,7 @@ public class MesProTaskController {
110 111 if (task == null) {
111 112 return success(null);
112 113 }
113   - return success(buildTaskRespVOList(List.of(task)).get(0));
  114 + return success(buildTaskRespVOList(ListUtil.of(task)).get(0));
114 115 }
115 116  
116 117 @GetMapping("/page")
... ...
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/pro/task/MesProTaskIssueController.java
1 1 package cn.iocoder.yudao.module.mes.controller.admin.pro.task;
2 2  
3 3 import cn.hutool.core.collection.CollUtil;
  4 +import cn.hutool.core.collection.ListUtil;
4 5 import cn.iocoder.yudao.framework.common.pojo.CommonResult;
5 6 import cn.iocoder.yudao.framework.common.pojo.PageResult;
6 7 import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
... ... @@ -79,7 +80,7 @@ public class MesProTaskIssueController {
79 80 if (taskIssue == null) {
80 81 return success(null);
81 82 }
82   - return success(buildIssueRespVOList(List.of(taskIssue)).get(0));
  83 + return success(buildIssueRespVOList(ListUtil.of(taskIssue)).get(0));
83 84 }
84 85  
85 86 @GetMapping("/page")
... ...
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/pro/workorder/MesProWorkOrderBomController.java
1 1 package cn.iocoder.yudao.module.mes.controller.admin.pro.workorder;
2 2  
3 3 import cn.hutool.core.collection.CollUtil;
  4 +import cn.hutool.core.collection.ListUtil;
4 5 import cn.iocoder.yudao.framework.common.pojo.CommonResult;
5 6 import cn.iocoder.yudao.framework.common.pojo.PageResult;
6 7 import cn.iocoder.yudao.framework.common.util.collection.MapUtils;
... ... @@ -88,7 +89,7 @@ public class MesProWorkOrderBomController {
88 89 if (workOrderBom == null) {
89 90 return success(null);
90 91 }
91   - return success(buildWorkOrderBomRespVOList(List.of(workOrderBom)).get(0));
  92 + return success(buildWorkOrderBomRespVOList(ListUtil.of(workOrderBom)).get(0));
92 93 }
93 94  
94 95 @GetMapping("/page")
... ...
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/pro/workorder/MesProWorkOrderController.java
1 1 package cn.iocoder.yudao.module.mes.controller.admin.pro.workorder;
2 2  
3 3 import cn.hutool.core.collection.CollUtil;
  4 +import cn.hutool.core.collection.ListUtil;
4 5 import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog;
5 6 import cn.iocoder.yudao.framework.common.pojo.CommonResult;
6 7 import cn.iocoder.yudao.framework.common.pojo.PageParam;
... ... @@ -92,7 +93,7 @@ public class MesProWorkOrderController {
92 93 if (workOrder == null) {
93 94 return success(null);
94 95 }
95   - return success(buildWorkOrderRespVOList(List.of(workOrder)).get(0));
  96 + return success(buildWorkOrderRespVOList(ListUtil.of(workOrder)).get(0));
96 97 }
97 98  
98 99 @GetMapping("/page")
... ...
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/tm/tool/MesTmToolServiceImpl.java
1 1 package cn.iocoder.yudao.module.mes.service.tm.tool;
2 2  
  3 +import cn.hutool.core.collection.ListUtil;
3 4 import cn.hutool.core.util.ObjUtil;
4 5 import cn.iocoder.yudao.framework.common.pojo.PageResult;
5 6 import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
... ... @@ -127,7 +128,7 @@ public class MesTmToolServiceImpl implements MesTmToolService {
127 128 @Override
128 129 public List<MesTmToolDO> getToolList(Collection<Long> ids) {
129 130 if (ids == null || ids.isEmpty()) {
130   - return List.of();
  131 + return ListUtil.of();
131 132 }
132 133 return toolMapper.selectBatchIds(ids);
133 134 }
... ...
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/wm/outsourceissue/MesWmOutsourceIssueServiceImpl.java
1 1 package cn.iocoder.yudao.module.mes.service.wm.outsourceissue;
2 2  
3 3 import cn.hutool.core.collection.CollUtil;
  4 +import cn.hutool.core.collection.ListUtil;
4 5 import cn.hutool.core.util.StrUtil;
5 6 import cn.hutool.core.util.ObjUtil;
6 7 import cn.iocoder.yudao.framework.common.pojo.PageResult;
... ... @@ -146,7 +147,7 @@ public class MesWmOutsourceIssueServiceImpl implements MesWmOutsourceIssueServic
146 147 allDetails, MesWmOutsourceIssueDetailDO::getLineId);
147 148 // 检查每行的明细数量
148 149 for (MesWmOutsourceIssueLineDO line : lines) {
149   - List<MesWmOutsourceIssueDetailDO> details = detailMap.getOrDefault(line.getId(), List.of());
  150 + List<MesWmOutsourceIssueDetailDO> details = detailMap.getOrDefault(line.getId(), ListUtil.of());
150 151 BigDecimal totalDetailQuantity = CollectionUtils.getSumValue(details,
151 152 MesWmOutsourceIssueDetailDO::getQuantity, BigDecimal::add, BigDecimal.ZERO);
152 153 // 对比行数量与明细总数量,不满足直接抛出
... ... @@ -219,7 +220,7 @@ public class MesWmOutsourceIssueServiceImpl implements MesWmOutsourceIssueServic
219 220 allDetails, MesWmOutsourceIssueDetailDO::getLineId);
220 221 // 检查每行的明细数量
221 222 for (MesWmOutsourceIssueLineDO line : lines) {
222   - List<MesWmOutsourceIssueDetailDO> details = detailMap.getOrDefault(line.getId(), List.of());
  223 + List<MesWmOutsourceIssueDetailDO> details = detailMap.getOrDefault(line.getId(), ListUtil.of());
223 224 BigDecimal totalDetailQuantity = CollectionUtils.getSumValue(details,
224 225 MesWmOutsourceIssueDetailDO::getQuantity, BigDecimal::add, BigDecimal.ZERO);
225 226 // 对比行数量与明细总数量
... ...
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/wm/outsourcereceipt/MesWmOutsourceReceiptServiceImpl.java
1 1 package cn.iocoder.yudao.module.mes.service.wm.outsourcereceipt;
2 2  
3 3 import cn.hutool.core.collection.CollUtil;
  4 +import cn.hutool.core.collection.ListUtil;
4 5 import cn.hutool.core.util.ObjUtil;
5 6 import cn.hutool.core.util.StrUtil;
6 7 import cn.iocoder.yudao.framework.common.pojo.PageResult;
... ... @@ -165,7 +166,7 @@ public class MesWmOutsourceReceiptServiceImpl implements MesWmOutsourceReceiptSe
165 166 allDetails, MesWmOutsourceReceiptDetailDO::getLineId);
166 167 // 检查每行的明细数量
167 168 for (MesWmOutsourceReceiptLineDO line : lines) {
168   - List<MesWmOutsourceReceiptDetailDO> details = detailMap.getOrDefault(line.getId(), List.of());
  169 + List<MesWmOutsourceReceiptDetailDO> details = detailMap.getOrDefault(line.getId(), ListUtil.of());
169 170 BigDecimal totalDetailQuantity = CollectionUtils.getSumValue(details,
170 171 MesWmOutsourceReceiptDetailDO::getQuantity, BigDecimal::add, BigDecimal.ZERO);
171 172 // 对比行数量与明细总数量,不满足直接抛出
... ...
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/wm/returnissue/MesWmReturnIssueServiceImpl.java
1 1 package cn.iocoder.yudao.module.mes.service.wm.returnissue;
2 2  
3 3 import cn.hutool.core.collection.CollUtil;
  4 +import cn.hutool.core.collection.ListUtil;
4 5 import cn.hutool.core.util.ObjUtil;
5 6 import cn.iocoder.yudao.framework.common.pojo.PageResult;
6 7 import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
... ... @@ -161,7 +162,7 @@ public class MesWmReturnIssueServiceImpl implements MesWmReturnIssueService {
161 162 allDetails, MesWmReturnIssueDetailDO::getLineId);
162 163 // 检查每行的明细数量
163 164 for (MesWmReturnIssueLineDO line : lines) {
164   - List<MesWmReturnIssueDetailDO> details = detailMap.getOrDefault(line.getId(), List.of());
  165 + List<MesWmReturnIssueDetailDO> details = detailMap.getOrDefault(line.getId(), ListUtil.of());
165 166 BigDecimal totalDetailQuantity = CollectionUtils.getSumValue(details,
166 167 MesWmReturnIssueDetailDO::getQuantity, BigDecimal::add, BigDecimal.ZERO);
167 168 // 对比行数量与明细总数量,不满足直接抛出
... ...
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/wm/returnsales/MesWmReturnSalesServiceImpl.java
1 1 package cn.iocoder.yudao.module.mes.service.wm.returnsales;
2 2  
3 3 import cn.hutool.core.collection.CollUtil;
  4 +import cn.hutool.core.collection.ListUtil;
4 5 import cn.hutool.core.util.ObjUtil;
5 6 import cn.iocoder.yudao.framework.common.pojo.PageResult;
6 7 import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
... ... @@ -163,7 +164,7 @@ public class MesWmReturnSalesServiceImpl implements MesWmReturnSalesService {
163 164 allDetails, MesWmReturnSalesDetailDO::getLineId);
164 165 // 检查每行的明细数量
165 166 for (MesWmReturnSalesLineDO line : lines) {
166   - List<MesWmReturnSalesDetailDO> details = detailMap.getOrDefault(line.getId(), List.of());
  167 + List<MesWmReturnSalesDetailDO> details = detailMap.getOrDefault(line.getId(), ListUtil.of());
167 168 BigDecimal totalDetailQuantity = CollectionUtils.getSumValue(details,
168 169 MesWmReturnSalesDetailDO::getQuantity, BigDecimal::add, BigDecimal.ZERO);
169 170 // 对比行数量与明细总数量,不满足直接抛出
... ...
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/wm/transfer/MesWmTransferServiceImpl.java
1 1 package cn.iocoder.yudao.module.mes.service.wm.transfer;
2 2  
3 3 import cn.hutool.core.collection.CollUtil;
  4 +import cn.hutool.core.collection.ListUtil;
4 5 import cn.iocoder.yudao.framework.common.pojo.PageResult;
5 6 import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
6 7 import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
... ... @@ -186,7 +187,7 @@ public class MesWmTransferServiceImpl implements MesWmTransferService {
186 187 allDetails, MesWmTransferDetailDO::getLineId);
187 188 // 2. 遍历行和对应的明细,创建事务
188 189 for (MesWmTransferLineDO line : lines) {
189   - List<MesWmTransferDetailDO> details = detailMap.getOrDefault(line.getId(), List.of());
  190 + List<MesWmTransferDetailDO> details = detailMap.getOrDefault(line.getId(), ListUtil.of());
190 191 for (MesWmTransferDetailDO detail : details) {
191 192 // 2.1 先执行出库:调拨移出(从源仓库扣减库存),出库数量基于当前明细的数量
192 193 Long outTransactionId = wmTransactionService.createTransaction(new MesWmTransactionSaveReqDTO()
... ...
yudao-module-mes/src/test/java/cn/iocoder/yudao/module/mes/service/pro/feedback/MesProFeedbackServiceImplTest.java
1 1 package cn.iocoder.yudao.module.mes.service.pro.feedback;
2 2  
  3 +import cn.hutool.core.collection.ListUtil;
3 4 import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest;
4 5 import cn.iocoder.yudao.module.mes.dal.dataobject.pro.feedback.MesProFeedbackDO;
5 6 import cn.iocoder.yudao.module.mes.dal.dataobject.wm.productproduce.MesWmProductProduceLineDO;
... ... @@ -19,11 +20,11 @@ import org.springframework.context.annotation.Import;
19 20 import org.springframework.test.context.bean.override.mockito.MockitoBean;
20 21  
21 22 import java.math.BigDecimal;
22   -import java.util.List;
23 23  
24 24 import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomLongId;
25 25 import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomPojo;
26   -import static org.junit.jupiter.api.Assertions.*;
  26 +import static org.junit.jupiter.api.Assertions.assertEquals;
  27 +import static org.junit.jupiter.api.Assertions.assertThrows;
27 28 import static org.mockito.Mockito.*;
28 29  
29 30 /**
... ... @@ -78,7 +79,7 @@ public class MesProFeedbackServiceImplTest extends BaseDbUnitTest {
78 79 .qualityStatus(MesWmQualityStatusEnum.FAIL.getStatus())
79 80 .build();
80 81 when(produceLineService.getProductProduceLineListByFeedbackId(feedback.getId()))
81   - .thenReturn(List.of(qualifiedLine, unqualifiedLine));
  82 + .thenReturn(ListUtil.of(qualifiedLine, unqualifiedLine));
82 83  
83 84 // 调用
84 85 BigDecimal qualifiedQty = BigDecimal.valueOf(80);
... ... @@ -133,7 +134,7 @@ public class MesProFeedbackServiceImplTest extends BaseDbUnitTest {
133 134 .qualityStatus(MesWmQualityStatusEnum.PASS.getStatus())
134 135 .build();
135 136 when(produceLineService.getProductProduceLineListByFeedbackId(feedback.getId()))
136   - .thenReturn(List.of(qualifiedLine));
  137 + .thenReturn(ListUtil.of(qualifiedLine));
137 138  
138 139 // 调用
139 140 feedbackService.updateProFeedbackWhenIpqcFinish(feedback.getId(),
... ...
yudao-module-mes/src/test/java/cn/iocoder/yudao/module/mes/service/wm/itemconsume/MesWmItemConsumeServiceImplTest.java
1 1 package cn.iocoder.yudao.module.mes.service.wm.itemconsume;
2 2  
  3 +import cn.hutool.core.collection.ListUtil;
3 4 import cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil;
4 5 import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest;
5 6 import cn.iocoder.yudao.module.mes.controller.admin.wm.materialstock.vo.MesWmMaterialStockListReqVO;
... ... @@ -43,9 +44,7 @@ import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomLongId
43 44 import static cn.iocoder.yudao.module.mes.enums.ErrorCodeConstants.PRO_FEEDBACK_ROUTE_PROCESS_INVALID;
44 45 import static cn.iocoder.yudao.module.mes.enums.ErrorCodeConstants.PRO_ROUTE_NOT_EXISTS;
45 46 import static org.junit.jupiter.api.Assertions.*;
46   -import static org.mockito.ArgumentMatchers.any;
47   -import static org.mockito.ArgumentMatchers.anyLong;
48   -import static org.mockito.ArgumentMatchers.argThat;
  47 +import static org.mockito.ArgumentMatchers.*;
49 48 import static org.mockito.Mockito.*;
50 49  
51 50 /**
... ... @@ -181,7 +180,7 @@ public class MesWmItemConsumeServiceImplTest extends BaseDbUnitTest {
181 180 bom.setItemId(bomItemId);
182 181 bom.setQuantity(new BigDecimal("2")); // 用料比例 = 2
183 182 when(routeProductBomService.getRouteProductBomList(any(), any(), any()))
184   - .thenReturn(List.of(bom));
  183 + .thenReturn(ListUtil.of(bom));
185 184 when(materialStockService.getMaterialStockList(any(MesWmMaterialStockListReqVO.class)))
186 185 .thenReturn(Collections.emptyList());
187 186  
... ... @@ -229,7 +228,7 @@ public class MesWmItemConsumeServiceImplTest extends BaseDbUnitTest {
229 228 bom.setItemId(bomItemId);
230 229 bom.setQuantity(new BigDecimal("3")); // 消耗 = 3 × 10 = 30
231 230 when(routeProductBomService.getRouteProductBomList(any(), any(), any()))
232   - .thenReturn(List.of(bom));
  231 + .thenReturn(ListUtil.of(bom));
233 232  
234 233 Long stockId = randomLongId();
235 234 Long batchId = randomLongId();
... ... @@ -240,7 +239,7 @@ public class MesWmItemConsumeServiceImplTest extends BaseDbUnitTest {
240 239 stock.setBatchId(batchId);
241 240 stock.setBatchCode("BATCH-001");
242 241 when(materialStockService.getMaterialStockList(any(MesWmMaterialStockListReqVO.class)))
243   - .thenReturn(List.of(stock));
  242 + .thenReturn(ListUtil.of(stock));
244 243  
245 244 // 调用
246 245 MesWmItemConsumeDO result = itemConsumeService.generateItemConsume(feedback);
... ... @@ -268,7 +267,7 @@ public class MesWmItemConsumeServiceImplTest extends BaseDbUnitTest {
268 267 bom.setItemId(bomItemId);
269 268 bom.setQuantity(new BigDecimal("3")); // 消耗 = 3 × 10 = 30
270 269 when(routeProductBomService.getRouteProductBomList(any(), any(), any()))
271   - .thenReturn(List.of(bom));
  270 + .thenReturn(ListUtil.of(bom));
272 271  
273 272 Long stockId1 = randomLongId();
274 273 Long stockId2 = randomLongId();
... ... @@ -321,7 +320,7 @@ public class MesWmItemConsumeServiceImplTest extends BaseDbUnitTest {
321 320 bom.setItemId(bomItemId);
322 321 bom.setQuantity(new BigDecimal("3")); // 消耗 = 3 × 10 = 30
323 322 when(routeProductBomService.getRouteProductBomList(any(), any(), any()))
324   - .thenReturn(List.of(bom));
  323 + .thenReturn(ListUtil.of(bom));
325 324  
326 325 Long stockId = randomLongId();
327 326 MesWmMaterialStockDO stock = new MesWmMaterialStockDO();
... ... @@ -331,7 +330,7 @@ public class MesWmItemConsumeServiceImplTest extends BaseDbUnitTest {
331 330 stock.setBatchId(1L);
332 331 stock.setBatchCode("BATCH-001");
333 332 when(materialStockService.getMaterialStockList(any(MesWmMaterialStockListReqVO.class)))
334   - .thenReturn(List.of(stock));
  333 + .thenReturn(ListUtil.of(stock));
335 334  
336 335 // 调用
337 336 MesWmItemConsumeDO result = itemConsumeService.generateItemConsume(feedback);
... ... @@ -383,7 +382,7 @@ public class MesWmItemConsumeServiceImplTest extends BaseDbUnitTest {
383 382  
384 383 when(materialStockService.getMaterialStockList(argThat((MesWmMaterialStockListReqVO req) ->
385 384 req != null && itemA.equals(req.getItemId()))))
386   - .thenReturn(List.of(stockA));
  385 + .thenReturn(ListUtil.of(stockA));
387 386 when(materialStockService.getMaterialStockList(argThat((MesWmMaterialStockListReqVO req) ->
388 387 req != null && itemB.equals(req.getItemId()))))
389 388 .thenReturn(Collections.emptyList());
... ...
yudao-module-mes/src/test/java/cn/iocoder/yudao/module/mes/service/wm/productproduce/MesWmProductProduceServiceImplTest.java
1 1 package cn.iocoder.yudao.module.mes.service.wm.productproduce;
2 2  
  3 +import cn.hutool.core.collection.ListUtil;
3 4 import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest;
4   -import cn.iocoder.yudao.module.mes.dal.dataobject.wm.productproduce.MesWmProductProduceDetailDO;
5 5 import cn.iocoder.yudao.module.mes.dal.dataobject.wm.productproduce.MesWmProductProduceDO;
  6 +import cn.iocoder.yudao.module.mes.dal.dataobject.wm.productproduce.MesWmProductProduceDetailDO;
6 7 import cn.iocoder.yudao.module.mes.dal.dataobject.wm.productproduce.MesWmProductProduceLineDO;
7 8 import cn.iocoder.yudao.module.mes.dal.dataobject.wm.warehouse.MesWmWarehouseAreaDO;
8 9 import cn.iocoder.yudao.module.mes.dal.dataobject.wm.warehouse.MesWmWarehouseDO;
... ... @@ -23,11 +24,11 @@ import org.springframework.context.annotation.Import;
23 24 import org.springframework.test.context.bean.override.mockito.MockitoBean;
24 25  
25 26 import java.math.BigDecimal;
26   -import java.util.List;
27 27  
28 28 import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomLongId;
29 29 import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomPojo;
30   -import static org.junit.jupiter.api.Assertions.*;
  30 +import static org.junit.jupiter.api.Assertions.assertEquals;
  31 +import static org.junit.jupiter.api.Assertions.assertThrows;
31 32 import static org.mockito.Mockito.*;
32 33  
33 34 /**
... ... @@ -92,7 +93,7 @@ public class MesWmProductProduceServiceImplTest extends BaseDbUnitTest {
92 93 .qualityStatus(MesWmQualityStatusEnum.PENDING.getStatus())
93 94 .build();
94 95 when(productProduceLineService.getProductProduceLineListByProduceId(produce.getId()))
95   - .thenReturn(List.of(pendingLine));
  96 + .thenReturn(ListUtil.of(pendingLine));
96 97  
97 98 // mock: finishProductProduce 内部会再查一次行和明细(用于创建库存事务)
98 99 // 由于 finishProductProduce 在拆分行后调用,此时行已经变了,但由于 line/detail 是 mock 的,
... ... @@ -109,8 +110,8 @@ public class MesWmProductProduceServiceImplTest extends BaseDbUnitTest {
109 110 .build();
110 111 // finishProductProduce 内部第二次调用 getProductProduceLineListByProduceId
111 112 when(productProduceLineService.getProductProduceLineListByProduceId(produce.getId()))
112   - .thenReturn(List.of(pendingLine)) // 第 1 次:splitPendingAndFinishProduce 查待检行
113   - .thenReturn(List.of(qualifiedLine, unqualifiedLine)); // 第 2 次:finishProductProduce 查所有行
  113 + .thenReturn(ListUtil.of(pendingLine)) // 第 1 次:splitPendingAndFinishProduce 查待检行
  114 + .thenReturn(ListUtil.of(qualifiedLine, unqualifiedLine)); // 第 2 次:finishProductProduce 查所有行
114 115  
115 116 // mock: finishProductProduce 中按行查明细
116 117 MesWmProductProduceDetailDO qualifiedDetail = MesWmProductProduceDetailDO.builder()
... ... @@ -118,9 +119,9 @@ public class MesWmProductProduceServiceImplTest extends BaseDbUnitTest {
118 119 MesWmProductProduceDetailDO unqualifiedDetail = MesWmProductProduceDetailDO.builder()
119 120 .lineId(101L).quantity(BigDecimal.valueOf(20)).build();
120 121 when(productProduceDetailService.getProductProduceDetailListByLineId(100L))
121   - .thenReturn(List.of(qualifiedDetail));
  122 + .thenReturn(ListUtil.of(qualifiedDetail));
122 123 when(productProduceDetailService.getProductProduceDetailListByLineId(101L))
123   - .thenReturn(List.of(unqualifiedDetail));
  124 + .thenReturn(ListUtil.of(unqualifiedDetail));
124 125  
125 126 // 调用
126 127 productProduceService.splitPendingAndFinishProduce(feedbackId, BigDecimal.valueOf(80), BigDecimal.valueOf(20));
... ... @@ -185,14 +186,14 @@ public class MesWmProductProduceServiceImplTest extends BaseDbUnitTest {
185 186 .qualityStatus(MesWmQualityStatusEnum.PASS.getStatus())
186 187 .build();
187 188 when(productProduceLineService.getProductProduceLineListByProduceId(produce.getId()))
188   - .thenReturn(List.of(pendingLine))
189   - .thenReturn(List.of(qualifiedLine));
  189 + .thenReturn(ListUtil.of(pendingLine))
  190 + .thenReturn(ListUtil.of(qualifiedLine));
190 191  
191 192 // mock: finishProductProduce 中按行查明细
192 193 MesWmProductProduceDetailDO detail = MesWmProductProduceDetailDO.builder()
193 194 .lineId(200L).quantity(BigDecimal.valueOf(50)).build();
194 195 when(productProduceDetailService.getProductProduceDetailListByLineId(200L))
195   - .thenReturn(List.of(detail));
  196 + .thenReturn(ListUtil.of(detail));
196 197  
197 198 // 调用:不合格品数量 = 0
198 199 productProduceService.splitPendingAndFinishProduce(feedbackId, BigDecimal.valueOf(50), BigDecimal.ZERO);
... ... @@ -245,7 +246,7 @@ public class MesWmProductProduceServiceImplTest extends BaseDbUnitTest {
245 246 .qualityStatus(MesWmQualityStatusEnum.PASS.getStatus())
246 247 .build();
247 248 when(productProduceLineService.getProductProduceLineListByProduceId(produce.getId()))
248   - .thenReturn(List.of(passLine));
  249 + .thenReturn(ListUtil.of(passLine));
249 250  
250 251 // 调用,应该抛异常(找不到 PENDING 行)
251 252 assertThrows(Exception.class, () ->
... ...