| | |
| | | import com.ruoyi.common.enums.StockInQualifiedRecordTypeEnum; |
| | | import com.ruoyi.common.enums.StockOutQualifiedRecordTypeEnum; |
| | | import com.ruoyi.common.exception.ServiceException; |
| | | import com.ruoyi.common.utils.SecurityUtils; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.production.bean.dto.ProductionOrderPickDto; |
| | | import com.ruoyi.production.bean.vo.ProductionOrderPickVo; |
| | |
| | | // 数量格式化输出(去除末尾无效0)。 |
| | | return defaultDecimal(value).stripTrailingZeros().toPlainString(); |
| | | } |
| | | |
| | | /** |
| | | * 校验当前用户必须为订单班组长 |
| | | * @param dto 领料DTO |
| | | */ |
| | | private void validateTeamLeader(ProductionOrderPickDto dto) { |
| | | // 获取当前登录用户ID |
| | | Long currentUserId = SecurityUtils.getLoginUser().getUserId(); |
| | | |
| | | // 获取生产订单ID |
| | | Long productionOrderId = resolveProductionOrderId(dto); |
| | | if (productionOrderId == null) { |
| | | throw new ServiceException("生产订单ID不能为空"); |
| | | } |
| | | |
| | | // 查询生产订单 |
| | | ProductionOrder productionOrder = productionOrderMapper.selectById(productionOrderId); |
| | | if (productionOrder == null) { |
| | | throw new ServiceException("生产订单不存在"); |
| | | } |
| | | |
| | | // 获取订单的班组长ID |
| | | Long teamLeaderUserId = productionOrder.getTeamLeaderUserId(); |
| | | if (teamLeaderUserId == null) { |
| | | throw new ServiceException("该订单未设置班组长"); |
| | | } |
| | | |
| | | // 校验当前用户是否为班组长 |
| | | if (!Objects.equals(currentUserId, teamLeaderUserId)) { |
| | | throw new ServiceException("当前用户不是该订单的班组长,无法进行领料操作"); |
| | | } |
| | | } |
| | | } |