| | |
| | | /** |
| | | * MES 生产工单 Mapper |
| | | * |
| | | * @author 芋道源码 |
| | | * @author 超级管理员 |
| | | */ |
| | | @Mapper |
| | | public interface MesProWorkOrderMapper extends BaseMapperX<MesProWorkOrderDO> { |
| | |
| | | if (CollUtil.isEmpty(permittedClientIds)) { |
| | | return PageResult.empty(); |
| | | } |
| | | wrapper.in(MesProWorkOrderDO::getClientId, permittedClientIds); |
| | | // 允许 client_id 为空的记录(无客户工单对所有有权限用户可见) |
| | | wrapper.and(w -> w.in(MesProWorkOrderDO::getClientId, permittedClientIds) |
| | | .or().isNull(MesProWorkOrderDO::getClientId)); |
| | | } |
| | | return selectPage(reqVO, wrapper); |
| | | } |
| | | |
| | | /** |
| | | * 分页查询(带客户权限过滤且支持调度状态查询) |
| | | */ |
| | | default PageResult<MesProWorkOrderDO> selectSchedulePage(MesProWorkOrderPageReqVO pageReqVO, List<Long> permittedClientIds) { |
| | | com.baomidou.mybatisplus.core.metadata.IPage<MesProWorkOrderDO> mpPage = cn.iocoder.yudao.framework.mybatis.core.util.MyBatisUtils.buildPage(pageReqVO); |
| | | com.baomidou.mybatisplus.core.metadata.IPage<MesProWorkOrderDO> result = selectSchedulePage(mpPage, pageReqVO, permittedClientIds); |
| | | return new PageResult<>(result.getRecords(), result.getTotal()); |
| | | } |
| | | |
| | | com.baomidou.mybatisplus.core.metadata.IPage<MesProWorkOrderDO> selectSchedulePage( |
| | | com.baomidou.mybatisplus.core.metadata.IPage<MesProWorkOrderDO> page, |
| | | @org.apache.ibatis.annotations.Param("pageReqVO") MesProWorkOrderPageReqVO pageReqVO, |
| | | @org.apache.ibatis.annotations.Param("permittedClientIds") List<Long> permittedClientIds); |
| | | |
| | | default MesProWorkOrderDO selectByCode(String code) { |
| | | return selectOne(MesProWorkOrderDO::getCode, code); |
| | |
| | | .setSql("quantity_produced = IFNULL(quantity_produced, 0) + " + incrQuantityProduced)); |
| | | } |
| | | |
| | | /** |
| | | * 累加工单的已排产数量 |
| | | * |
| | | * @param id 工单编号 |
| | | * @param incrQuantityScheduled 本次排产数量增量 |
| | | */ |
| | | default void updateScheduledQuantity(Long id, BigDecimal incrQuantityScheduled) { |
| | | update(null, new LambdaUpdateWrapper<MesProWorkOrderDO>() |
| | | .eq(MesProWorkOrderDO::getId, id) |
| | | .setSql("quantity_scheduled = IFNULL(quantity_scheduled, 0) + " + incrQuantityScheduled)); |
| | | } |
| | | |
| | | default Long selectCountByVendorId(Long vendorId) { |
| | | return selectCount(MesProWorkOrderDO::getVendorId, vendorId); |
| | | } |