| | |
| | | import cn.iocoder.yudao.framework.common.util.object.BeanUtils; |
| | | import cn.iocoder.yudao.module.mes.controller.admin.pro.route.vo.process.MesProRouteProcessSaveReqVO; |
| | | import cn.iocoder.yudao.module.mes.dal.dataobject.pro.route.MesProRouteProcessDO; |
| | | import cn.iocoder.yudao.module.mes.dal.dataobject.pro.route.MesProRouteProductBomDO; |
| | | import cn.iocoder.yudao.module.mes.dal.dataobject.pro.route.MesProRouteProductDO; |
| | | import cn.iocoder.yudao.module.mes.dal.mysql.pro.route.MesProRouteProcessMapper; |
| | | import cn.iocoder.yudao.module.mes.service.pro.process.MesProProcessService; |
| | |
| | | import java.util.Collections; |
| | | import java.util.Comparator; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.stream.Collectors; |
| | | |
| | | import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; |
| | | import static cn.iocoder.yudao.module.mes.enums.ErrorCodeConstants.*; |
| | |
| | | @Resource |
| | | @Lazy |
| | | private MesProRouteService routeService; |
| | | @Resource |
| | | @Lazy |
| | | private MesProRouteProductBomService routeProductBomService; |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | |
| | | |
| | | // 2. 插入 |
| | | MesProRouteProcessDO routeProcess = BeanUtils.toBean(createReqVO, MesProRouteProcessDO.class); |
| | | if (CollUtil.isNotEmpty(createReqVO.getOutputItemIds())) { |
| | | routeProcess.setOutputItemId( |
| | | createReqVO.getOutputItemIds().stream() |
| | | .map(String::valueOf) |
| | | .collect(Collectors.joining(","))); |
| | | } |
| | | routeProcessMapper.insert(routeProcess); |
| | | |
| | | // 3. 更新工序链 |
| | |
| | | |
| | | // 2. 更新 |
| | | MesProRouteProcessDO updateObj = BeanUtils.toBean(updateReqVO, MesProRouteProcessDO.class); |
| | | if (CollUtil.isNotEmpty(updateReqVO.getOutputItemIds())) { |
| | | updateObj.setOutputItemId( |
| | | updateReqVO.getOutputItemIds().stream() |
| | | .map(String::valueOf) |
| | | .collect(Collectors.joining(","))); |
| | | } |
| | | routeProcessMapper.updateById(updateObj); |
| | | |
| | | // 3. 重建工序链 |
| | |
| | | } |
| | | |
| | | @Override |
| | | public Map<Long, List<MesProRouteProductBomDO>> getRouteProcessBomMapByProductId(Long productId) { |
| | | MesProRouteProductDO routeProduct = routeProductService.getRouteProductByItemId(productId); |
| | | if (routeProduct == null) { |
| | | return Collections.emptyMap(); |
| | | } |
| | | List<MesProRouteProductBomDO> bomList = routeProductBomService |
| | | .getRouteProductBomListByRouteIdAndProductId(routeProduct.getRouteId(), productId); |
| | | if (CollUtil.isEmpty(bomList)) { |
| | | return Collections.emptyMap(); |
| | | } |
| | | return bomList.stream().collect(Collectors.groupingBy(MesProRouteProductBomDO::getProcessId)); |
| | | } |
| | | |
| | | @Override |
| | | public List<MesProRouteProcessDO> getRouteProcessListByProcessId(Long processId) { |
| | | return routeProcessMapper.selectListByProcessId(processId); |
| | | } |