| | |
| | | package cn.iocoder.yudao.module.mes.dal.mysql.pro.workorder; |
| | | |
| | | import cn.hutool.core.collection.CollUtil; |
| | | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| | | import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; |
| | | import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; |
| | |
| | | import org.apache.ibatis.annotations.Mapper; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * MES 生产工单 Mapper |
| | |
| | | .orderByDesc(MesProWorkOrderDO::getId)); |
| | | } |
| | | |
| | | /** |
| | | * 分页查询(带客户权限过滤) |
| | | */ |
| | | default PageResult<MesProWorkOrderDO> selectPage(MesProWorkOrderPageReqVO reqVO, List<Long> permittedClientIds) { |
| | | LambdaQueryWrapperX<MesProWorkOrderDO> wrapper = new LambdaQueryWrapperX<MesProWorkOrderDO>() |
| | | .likeIfPresent(MesProWorkOrderDO::getCode, reqVO.getCode()) |
| | | .likeIfPresent(MesProWorkOrderDO::getName, reqVO.getName()) |
| | | .eqIfPresent(MesProWorkOrderDO::getType, reqVO.getType()) |
| | | .likeIfPresent(MesProWorkOrderDO::getOrderSourceCode, reqVO.getOrderSourceCode()) |
| | | .eqIfPresent(MesProWorkOrderDO::getProductId, reqVO.getProductId()) |
| | | .eqIfPresent(MesProWorkOrderDO::getClientId, reqVO.getClientId()) |
| | | .eqIfPresent(MesProWorkOrderDO::getStatus, reqVO.getStatus()) |
| | | .betweenIfPresent(MesProWorkOrderDO::getRequestDate, reqVO.getRequestDate()) |
| | | .orderByDesc(MesProWorkOrderDO::getId); |
| | | if (permittedClientIds != null) { |
| | | if (CollUtil.isEmpty(permittedClientIds)) { |
| | | return PageResult.empty(); |
| | | } |
| | | // 允许 client_id 为空的记录(无客户工单对所有有权限用户可见) |
| | | wrapper.and(w -> w.in(MesProWorkOrderDO::getClientId, permittedClientIds) |
| | | .or().isNull(MesProWorkOrderDO::getClientId)); |
| | | } |
| | | return selectPage(reqVO, wrapper); |
| | | } |
| | | |
| | | 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); |
| | | } |