| | |
| | | import cn.hutool.core.util.ObjUtil; |
| | | import cn.hutool.core.util.StrUtil; |
| | | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| | | import cn.iocoder.yudao.module.mes.controller.admin.wm.batch.vo.MesWmBatchFlowRespVO; |
| | | import cn.iocoder.yudao.module.mes.controller.admin.wm.batch.vo.MesWmBatchGenerateReqVO; |
| | | import cn.iocoder.yudao.module.mes.controller.admin.wm.batch.vo.MesWmBatchPageReqVO; |
| | | import cn.iocoder.yudao.module.mes.controller.admin.wm.batch.vo.MesWmBatchProcessTraceRespVO; |
| | |
| | | } |
| | | |
| | | @Override |
| | | public List<MesWmBatchFlowRespVO> getBatchFlowList(String code) { |
| | | return batchMapper.selectBatchFlowList(code); |
| | | } |
| | | |
| | | @Override |
| | | public MesWmBatchDO getBatchBySn(String sn) { |
| | | MesWmSnDO snDO = snMapper.selectOne(MesWmSnDO::getCode, sn); |
| | | if (snDO == null || StrUtil.isBlank(snDO.getBatchCode())) { |
| | |
| | | if (proBatch == null || StrUtil.isBlank(proBatch.getCode())) { |
| | | return null; |
| | | } |
| | | // 1. 复用已有仓库批次(同一生产批次号) |
| | | MesWmBatchDO existing = batchMapper.selectByCode(proBatch.getCode()); |
| | | // 1. 优先按生产批次 ID 复用,兼容历史数据再按批次号匹配 |
| | | MesWmBatchDO existing = batchMapper.selectOne(MesWmBatchDO::getProBatchId, proBatch.getId()); |
| | | if (existing == null) { |
| | | existing = batchMapper.selectByCode(proBatch.getCode()); |
| | | } |
| | | if (existing != null) { |
| | | if (existing.getProBatchId() == null && proBatch.getId() != null) { |
| | | existing.setProBatchId(proBatch.getId()); |
| | | batchMapper.updateById(existing); |
| | | } |
| | | return existing; |
| | | } |
| | | // 2. 新建仓库批次:以生产批次号作为仓库批次号,质量状态置为待检验 |
| | | MesWmBatchDO batch = MesWmBatchDO.builder() |
| | | .proBatchId(proBatch.getId()) |
| | | .code(proBatch.getCode()) |
| | | .itemId(proBatch.getItemId()) |
| | | .produceDate(proBatch.getProduceDate()) |