feat(mes): 增加物料编号集合查询参数并优化工艺路线验证逻辑
- 在 MesMdItemPageReqVO 中增加 ids 字段用于限定物料编号集合查询
- 在 MesMdItemMapper 的分页查询中添加对物料编号集合的过滤条件
- 优化 MesProRouteServiceImpl 中的工艺路线验证逻辑
- 允许中间工序不配置产出,仅末道工序必须产出成品
- 重构代码结构提高可读性
| | |
| | | import org.springframework.format.annotation.DateTimeFormat; |
| | | |
| | | import java.time.LocalDateTime; |
| | | import java.util.List; |
| | | |
| | | import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; |
| | | |
| | |
| | | @ToString(callSuper = true) |
| | | public class MesMdItemPageReqVO extends PageParam { |
| | | |
| | | @Schema(description = "限定物料编号集合,用于业务范围内选择", example = "1,2,3") |
| | | private List<Long> ids; |
| | | |
| | | @Schema(description = "物料编码", example = "ITEM001") |
| | | private String code; |
| | | |
| | |
| | | |
| | | default PageResult<MesMdItemDO> selectPage(MesMdItemPageReqVO reqVO, Collection<Long> itemTypeIds) { |
| | | return selectPage(reqVO, new LambdaQueryWrapperX<MesMdItemDO>() |
| | | .inIfPresent(MesMdItemDO::getId, reqVO.getIds()) |
| | | .likeIfPresent(MesMdItemDO::getCode, reqVO.getCode()) |
| | | .likeIfPresent(MesMdItemDO::getName, reqVO.getName()) |
| | | .inIfPresent(MesMdItemDO::getItemTypeId, itemTypeIds) |
| | |
| | | .max(Comparator.comparing(MesProRouteProcessDO::getSort)).orElseThrow(); |
| | | for (MesProRouteProcessDO process : processList) { |
| | | Set<Long> outputIds = parseOutputItemIds(process.getOutputItemId()); |
| | | boolean last = process.getId().equals(lastProcess.getId()); |
| | | if (CollUtil.isEmpty(outputIds)) { |
| | | throw exception(PRO_ROUTE_PROCESS_OUTPUT_REQUIRED, process.getProcessId()); |
| | | // 中间工序不一定形成可入库的独立半成品,允许不配置产出;末道工序必须产出成品。 |
| | | if (last) { |
| | | throw exception(PRO_ROUTE_LAST_OUTPUT_INVALID, process.getProcessId()); |
| | | } |
| | | continue; |
| | | } |
| | | for (Long outputId : outputIds) { |
| | | if (!boundItemIds.contains(outputId)) { |
| | |
| | | throw exception(PRO_ROUTE_PROCESS_OUTPUT_NOT_BOUND, item.getName()); |
| | | } |
| | | } |
| | | if (process.getId().equals(lastProcess.getId())) { |
| | | if (last) { |
| | | if (finishedItemIds.isEmpty() || !outputIds.equals(finishedItemIds)) { |
| | | throw exception(PRO_ROUTE_LAST_OUTPUT_INVALID, process.getProcessId()); |
| | | } |