Commit 5f7bf4a44301985b0c85435bad1df9de5940713a
Merge branch 'feat/mes' of https://gitee.com/zhijiantianya/ruoyi-vue-pro into master-jdk17
Showing
11 changed files
with
32 additions
and
22 deletions
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/dv/checkplan/MesDvCheckPlanMachineryServiceImpl.java
| ... | ... | @@ -14,6 +14,7 @@ import org.springframework.stereotype.Service; |
| 14 | 14 | import org.springframework.validation.annotation.Validated; |
| 15 | 15 | |
| 16 | 16 | import java.util.List; |
| 17 | +import java.util.stream.Collectors; | |
| 17 | 18 | |
| 18 | 19 | import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; |
| 19 | 20 | import static cn.iocoder.yudao.module.mes.enums.ErrorCodeConstants.*; |
| ... | ... | @@ -49,7 +50,7 @@ public class MesDvCheckPlanMachineryServiceImpl implements MesDvCheckPlanMachine |
| 49 | 50 | // 1.4 跨方案类型唯一性校验(设备不能存在于同类型多个方案中) |
| 50 | 51 | List<MesDvCheckPlanMachineryDO> existingMachineryList = getCheckPlanMachineryListByMachineryId(createReqVO.getMachineryId()); |
| 51 | 52 | if (CollUtil.isNotEmpty(existingMachineryList)) { |
| 52 | - List<Long> existingPlanIds = existingMachineryList.stream().map(MesDvCheckPlanMachineryDO::getPlanId).toList(); | |
| 53 | + List<Long> existingPlanIds = existingMachineryList.stream().map(MesDvCheckPlanMachineryDO::getPlanId).collect(Collectors.toList()); | |
| 53 | 54 | List<MesDvCheckPlanDO> existingPlans = checkPlanService.getCheckPlanList(existingPlanIds); |
| 54 | 55 | for (MesDvCheckPlanDO existPlan : existingPlans) { |
| 55 | 56 | // 如果存在不同于当前方案、但类型一致的计划方案,则拦截(一机多计划,但不允许同一机多同类型计划) | ... | ... |
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 | +import java.util.Collections; | |
| 4 | 4 | import cn.hutool.core.util.ObjUtil; |
| 5 | 5 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 6 | 6 | import cn.iocoder.yudao.framework.common.util.object.BeanUtils; |
| ... | ... | @@ -128,9 +128,9 @@ public class MesTmToolServiceImpl implements MesTmToolService { |
| 128 | 128 | @Override |
| 129 | 129 | public List<MesTmToolDO> getToolList(Collection<Long> ids) { |
| 130 | 130 | if (ids == null || ids.isEmpty()) { |
| 131 | - return ListUtil.of(); | |
| 131 | + return Collections.emptyList(); | |
| 132 | 132 | } |
| 133 | - return toolMapper.selectBatchIds(ids); | |
| 133 | + return toolMapper.selectByIds(ids); | |
| 134 | 134 | } |
| 135 | 135 | |
| 136 | 136 | } | ... | ... |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/wm/itemconsume/MesWmItemConsumeServiceImpl.java
| ... | ... | @@ -31,6 +31,7 @@ import java.math.BigDecimal; |
| 31 | 31 | import java.time.LocalDateTime; |
| 32 | 32 | import java.util.ArrayList; |
| 33 | 33 | import java.util.List; |
| 34 | +import java.util.stream.Collectors; | |
| 34 | 35 | |
| 35 | 36 | import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; |
| 36 | 37 | import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList; |
| ... | ... | @@ -125,7 +126,7 @@ public class MesWmItemConsumeServiceImpl implements MesWmItemConsumeService { |
| 125 | 126 | MesWmMaterialStockListReqVO stockQuery = new MesWmMaterialStockListReqVO().setItemId(line.getItemId()) |
| 126 | 127 | .setWarehouseId(warehouse.getId()).setLocationId(location.getId()).setAreaId(area.getId()); |
| 127 | 128 | List<MesWmMaterialStockDO> stocks = materialStockService.getMaterialStockList(stockQuery) |
| 128 | - .stream().filter(s -> s.getQuantity().compareTo(BigDecimal.ZERO) > 0).toList(); | |
| 129 | + .stream().filter(s -> s.getQuantity().compareTo(BigDecimal.ZERO) > 0).collect(Collectors.toList()); | |
| 129 | 130 | |
| 130 | 131 | if (CollUtil.isEmpty(stocks)) { |
| 131 | 132 | // 线边库无该物料库存 → 生成不带批次的明细 | ... | ... |
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 | 5 | import cn.hutool.core.util.StrUtil; |
| 6 | 6 | import cn.hutool.core.util.ObjUtil; |
| 7 | 7 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| ... | ... | @@ -31,6 +31,7 @@ import org.springframework.transaction.annotation.Transactional; |
| 31 | 31 | import org.springframework.validation.annotation.Validated; |
| 32 | 32 | |
| 33 | 33 | import java.math.BigDecimal; |
| 34 | +import java.util.Collections; | |
| 34 | 35 | import java.util.List; |
| 35 | 36 | import java.util.Map; |
| 36 | 37 | |
| ... | ... | @@ -147,7 +148,7 @@ public class MesWmOutsourceIssueServiceImpl implements MesWmOutsourceIssueServic |
| 147 | 148 | allDetails, MesWmOutsourceIssueDetailDO::getLineId); |
| 148 | 149 | // 检查每行的明细数量 |
| 149 | 150 | for (MesWmOutsourceIssueLineDO line : lines) { |
| 150 | - List<MesWmOutsourceIssueDetailDO> details = detailMap.getOrDefault(line.getId(), ListUtil.of()); | |
| 151 | + List<MesWmOutsourceIssueDetailDO> details = detailMap.getOrDefault(line.getId(), Collections.emptyList()); | |
| 151 | 152 | BigDecimal totalDetailQuantity = CollectionUtils.getSumValue(details, |
| 152 | 153 | MesWmOutsourceIssueDetailDO::getQuantity, BigDecimal::add, BigDecimal.ZERO); |
| 153 | 154 | // 对比行数量与明细总数量,不满足直接抛出 |
| ... | ... | @@ -220,7 +221,7 @@ public class MesWmOutsourceIssueServiceImpl implements MesWmOutsourceIssueServic |
| 220 | 221 | allDetails, MesWmOutsourceIssueDetailDO::getLineId); |
| 221 | 222 | // 检查每行的明细数量 |
| 222 | 223 | for (MesWmOutsourceIssueLineDO line : lines) { |
| 223 | - List<MesWmOutsourceIssueDetailDO> details = detailMap.getOrDefault(line.getId(), ListUtil.of()); | |
| 224 | + List<MesWmOutsourceIssueDetailDO> details = detailMap.getOrDefault(line.getId(), Collections.emptyList()); | |
| 224 | 225 | BigDecimal totalDetailQuantity = CollectionUtils.getSumValue(details, |
| 225 | 226 | MesWmOutsourceIssueDetailDO::getQuantity, BigDecimal::add, BigDecimal.ZERO); |
| 226 | 227 | // 对比行数量与明细总数量 | ... | ... |
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 | 5 | import cn.hutool.core.util.ObjUtil; |
| 6 | 6 | import cn.hutool.core.util.StrUtil; |
| 7 | 7 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| ... | ... | @@ -31,6 +31,7 @@ import org.springframework.transaction.annotation.Transactional; |
| 31 | 31 | import org.springframework.validation.annotation.Validated; |
| 32 | 32 | |
| 33 | 33 | import java.math.BigDecimal; |
| 34 | +import java.util.Collections; | |
| 34 | 35 | import java.util.List; |
| 35 | 36 | import java.util.Map; |
| 36 | 37 | |
| ... | ... | @@ -166,7 +167,7 @@ public class MesWmOutsourceReceiptServiceImpl implements MesWmOutsourceReceiptSe |
| 166 | 167 | allDetails, MesWmOutsourceReceiptDetailDO::getLineId); |
| 167 | 168 | // 检查每行的明细数量 |
| 168 | 169 | for (MesWmOutsourceReceiptLineDO line : lines) { |
| 169 | - List<MesWmOutsourceReceiptDetailDO> details = detailMap.getOrDefault(line.getId(), ListUtil.of()); | |
| 170 | + List<MesWmOutsourceReceiptDetailDO> details = detailMap.getOrDefault(line.getId(), Collections.emptyList()); | |
| 170 | 171 | BigDecimal totalDetailQuantity = CollectionUtils.getSumValue(details, |
| 171 | 172 | MesWmOutsourceReceiptDetailDO::getQuantity, BigDecimal::add, BigDecimal.ZERO); |
| 172 | 173 | // 对比行数量与明细总数量,不满足直接抛出 | ... | ... |
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 | 5 | import cn.hutool.core.util.ObjUtil; |
| 6 | 6 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 7 | 7 | import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; |
| ... | ... | @@ -35,6 +35,7 @@ import org.springframework.transaction.annotation.Transactional; |
| 35 | 35 | import org.springframework.validation.annotation.Validated; |
| 36 | 36 | |
| 37 | 37 | import java.math.BigDecimal; |
| 38 | +import java.util.Collections; | |
| 38 | 39 | import java.util.List; |
| 39 | 40 | import java.util.Map; |
| 40 | 41 | |
| ... | ... | @@ -162,7 +163,7 @@ public class MesWmReturnIssueServiceImpl implements MesWmReturnIssueService { |
| 162 | 163 | allDetails, MesWmReturnIssueDetailDO::getLineId); |
| 163 | 164 | // 检查每行的明细数量 |
| 164 | 165 | for (MesWmReturnIssueLineDO line : lines) { |
| 165 | - List<MesWmReturnIssueDetailDO> details = detailMap.getOrDefault(line.getId(), ListUtil.of()); | |
| 166 | + List<MesWmReturnIssueDetailDO> details = detailMap.getOrDefault(line.getId(), Collections.emptyList()); | |
| 166 | 167 | BigDecimal totalDetailQuantity = CollectionUtils.getSumValue(details, |
| 167 | 168 | MesWmReturnIssueDetailDO::getQuantity, BigDecimal::add, BigDecimal.ZERO); |
| 168 | 169 | // 对比行数量与明细总数量,不满足直接抛出 | ... | ... |
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 | 5 | import cn.hutool.core.util.ObjUtil; |
| 6 | 6 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 7 | 7 | import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; |
| ... | ... | @@ -28,6 +28,7 @@ import org.springframework.transaction.annotation.Transactional; |
| 28 | 28 | import org.springframework.validation.annotation.Validated; |
| 29 | 29 | |
| 30 | 30 | import java.math.BigDecimal; |
| 31 | +import java.util.Collections; | |
| 31 | 32 | import java.util.List; |
| 32 | 33 | import java.util.Map; |
| 33 | 34 | |
| ... | ... | @@ -164,7 +165,7 @@ public class MesWmReturnSalesServiceImpl implements MesWmReturnSalesService { |
| 164 | 165 | allDetails, MesWmReturnSalesDetailDO::getLineId); |
| 165 | 166 | // 检查每行的明细数量 |
| 166 | 167 | for (MesWmReturnSalesLineDO line : lines) { |
| 167 | - List<MesWmReturnSalesDetailDO> details = detailMap.getOrDefault(line.getId(), ListUtil.of()); | |
| 168 | + List<MesWmReturnSalesDetailDO> details = detailMap.getOrDefault(line.getId(), Collections.emptyList()); | |
| 168 | 169 | BigDecimal totalDetailQuantity = CollectionUtils.getSumValue(details, |
| 169 | 170 | MesWmReturnSalesDetailDO::getQuantity, BigDecimal::add, BigDecimal.ZERO); |
| 170 | 171 | // 对比行数量与明细总数量,不满足直接抛出 | ... | ... |
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 | 5 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 6 | 6 | import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; |
| 7 | 7 | import cn.iocoder.yudao.framework.common.util.object.BeanUtils; |
| ... | ... | @@ -23,6 +23,7 @@ import org.springframework.transaction.annotation.Transactional; |
| 23 | 23 | import org.springframework.validation.annotation.Validated; |
| 24 | 24 | |
| 25 | 25 | import java.math.BigDecimal; |
| 26 | +import java.util.Collections; | |
| 26 | 27 | import java.util.List; |
| 27 | 28 | import java.util.Map; |
| 28 | 29 | |
| ... | ... | @@ -187,7 +188,7 @@ public class MesWmTransferServiceImpl implements MesWmTransferService { |
| 187 | 188 | allDetails, MesWmTransferDetailDO::getLineId); |
| 188 | 189 | // 2. 遍历行和对应的明细,创建事务 |
| 189 | 190 | for (MesWmTransferLineDO line : lines) { |
| 190 | - List<MesWmTransferDetailDO> details = detailMap.getOrDefault(line.getId(), ListUtil.of()); | |
| 191 | + List<MesWmTransferDetailDO> details = detailMap.getOrDefault(line.getId(), Collections.emptyList()); | |
| 191 | 192 | for (MesWmTransferDetailDO detail : details) { |
| 192 | 193 | // 2.1 先执行出库:调拨移出(从源仓库扣减库存),出库数量基于当前明细的数量 |
| 193 | 194 | Long outTransactionId = wmTransactionService.createTransaction(new MesWmTransactionSaveReqDTO() | ... | ... |
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.CollUtil; | |
| 3 | 4 | import cn.hutool.core.collection.ListUtil; |
| 4 | 5 | import cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil; |
| 5 | 6 | import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; |
| ... | ... | @@ -405,15 +406,15 @@ public class MesWmItemConsumeServiceImplTest extends BaseDbUnitTest { |
| 405 | 406 | assertEquals(2, details.size()); |
| 406 | 407 | |
| 407 | 408 | // 物料 A:有批次 |
| 408 | - MesWmItemConsumeDetailDO detailA = details.stream() | |
| 409 | - .filter(d -> itemA.equals(d.getItemId())).findFirst().orElseThrow(); | |
| 409 | + MesWmItemConsumeDetailDO detailA = CollUtil.findOne(details, | |
| 410 | + d -> itemA.equals(d.getItemId())); | |
| 410 | 411 | assertEquals(0, new BigDecimal("10").compareTo(detailA.getQuantity())); |
| 411 | 412 | assertNotNull(detailA.getMaterialStockId()); |
| 412 | 413 | assertEquals("BATCH-A", detailA.getBatchCode()); |
| 413 | 414 | |
| 414 | 415 | // 物料 B:无批次 |
| 415 | - MesWmItemConsumeDetailDO detailB = details.stream() | |
| 416 | - .filter(d -> itemB.equals(d.getItemId())).findFirst().orElseThrow(); | |
| 416 | + MesWmItemConsumeDetailDO detailB = CollUtil.findOne(details, | |
| 417 | + d -> itemB.equals(d.getItemId())); | |
| 417 | 418 | assertEquals(0, new BigDecimal("20").compareTo(detailB.getQuantity())); |
| 418 | 419 | assertNull(detailB.getMaterialStockId()); |
| 419 | 420 | } | ... | ... |
yudao-module-mes/src/test/java/cn/iocoder/yudao/module/mes/service/wm/returnissue/MesWmReturnIssueLineServiceImplTest.java
| ... | ... | @@ -13,6 +13,7 @@ import org.springframework.test.context.bean.override.mockito.MockitoBean; |
| 13 | 13 | import cn.iocoder.yudao.module.mes.service.md.item.MesMdItemService; |
| 14 | 14 | |
| 15 | 15 | import java.math.BigDecimal; |
| 16 | +import java.util.List; | |
| 16 | 17 | |
| 17 | 18 | import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomPojo; |
| 18 | 19 | import static org.junit.jupiter.api.Assertions.assertEquals; |
| ... | ... | @@ -100,7 +101,7 @@ public class MesWmReturnIssueLineServiceImplTest extends BaseDbUnitTest { |
| 100 | 101 | assertEquals(0, qualifiedQty.compareTo(originalLine.getQuantity())); |
| 101 | 102 | |
| 102 | 103 | // 断言:新增了一行不合格品 |
| 103 | - var allLines = returnIssueLineMapper.selectListByIssueId(lineDO.getIssueId()); | |
| 104 | + List<MesWmReturnIssueLineDO> allLines = returnIssueLineMapper.selectListByIssueId(lineDO.getIssueId()); | |
| 104 | 105 | assertEquals(2, allLines.size()); |
| 105 | 106 | MesWmReturnIssueLineDO newLine = allLines.stream() |
| 106 | 107 | .filter(l -> !l.getId().equals(lineDO.getId())) | ... | ... |
yudao-module-mes/src/test/java/cn/iocoder/yudao/module/mes/service/wm/returnsales/MesWmReturnSalesLineServiceImplTest.java
| ... | ... | @@ -13,6 +13,7 @@ import org.springframework.test.context.bean.override.mockito.MockitoBean; |
| 13 | 13 | import cn.iocoder.yudao.module.mes.service.md.item.MesMdItemService; |
| 14 | 14 | |
| 15 | 15 | import java.math.BigDecimal; |
| 16 | +import java.util.List; | |
| 16 | 17 | |
| 17 | 18 | import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomPojo; |
| 18 | 19 | import static org.junit.jupiter.api.Assertions.assertEquals; |
| ... | ... | @@ -100,7 +101,7 @@ public class MesWmReturnSalesLineServiceImplTest extends BaseDbUnitTest { |
| 100 | 101 | assertEquals(0, qualifiedQty.compareTo(originalLine.getQuantity())); |
| 101 | 102 | |
| 102 | 103 | // 断言:新增了一行不合格品 |
| 103 | - var allLines = returnSalesLineMapper.selectListByReturnId(lineDO.getReturnId()); | |
| 104 | + List<MesWmReturnSalesLineDO> allLines = returnSalesLineMapper.selectListByReturnId(lineDO.getReturnId()); | |
| 104 | 105 | assertEquals(2, allLines.size()); |
| 105 | 106 | MesWmReturnSalesLineDO newLine = allLines.stream() |
| 106 | 107 | .filter(l -> !l.getId().equals(lineDO.getId())) | ... | ... |