gaoluyang
11 小时以前 298e948226a6773c5432f490f68c671af80dfc16
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/dal/mysql/qc/oqc/MesQcOqcMapper.java
@@ -8,6 +8,7 @@
import cn.iocoder.yudao.module.mes.dal.dataobject.qc.oqc.MesQcOqcDO;
import org.apache.ibatis.annotations.Mapper;
import java.time.LocalDateTime;
import java.util.List;
/**
@@ -43,9 +44,12 @@
                .orderByDesc(MesQcOqcDO::getId);
        if (permittedClientIds != null) {
            if (CollUtil.isEmpty(permittedClientIds)) {
                return PageResult.empty();
                wrapper.isNull(MesQcOqcDO::getClientId);
            } else {
                // 允许 client_id 为空的记录(未填客户的检验单对所有有权限用户可见)
                wrapper.and(w -> w.in(MesQcOqcDO::getClientId, permittedClientIds)
                        .or().isNull(MesQcOqcDO::getClientId));
            }
            wrapper.in(MesQcOqcDO::getClientId, permittedClientIds);
        }
        return selectPage(reqVO, wrapper);
    }
@@ -54,4 +58,22 @@
        return selectOne(MesQcOqcDO::getCode, code);
    }
    /**
     * 按导入去重键查询:同一 物料 + 客户 + 批次号 + 出货日期 视为同一批出货检验数据
     *
     * 客户与出货日期在本分支可为空,故三个可空维度均做空值安全比较(null 比 null)。
     */
    default List<MesQcOqcDO> selectListByImportKey(Long itemId, Long clientId, String batchCode,
                                                   LocalDateTime outDate) {
        return selectList(new LambdaQueryWrapperX<MesQcOqcDO>()
                .eq(MesQcOqcDO::getItemId, itemId)
                .eq(clientId != null, MesQcOqcDO::getClientId, clientId)
                .isNull(clientId == null, MesQcOqcDO::getClientId)
                .eq(batchCode != null, MesQcOqcDO::getBatchCode, batchCode)
                .isNull(batchCode == null, MesQcOqcDO::getBatchCode)
                .eq(outDate != null, MesQcOqcDO::getOutDate, outDate)
                .isNull(outDate == null, MesQcOqcDO::getOutDate)
                .orderByAsc(MesQcOqcDO::getId));
    }
}