lambdaQueryWrapper多条件嵌套查询
queryWrapper.and(wq -> { if(!CollectionUtils.isEmpty(orgList)){ wq.or(wq0 -> wq0.in(PatrolPlan::getOrgId, orgList)); wq.or(wq1 -> wq1.eq(PatrolPlan::getPlanExecType, PlanExecTypeEnum.ORG.getCode()).in(PatrolPlan::getPlanExecTypeId, orgList)); } wq.or(wq2 -> wq2.eq(PatrolPlan::getPlanExecType, PlanExecTypeEnum.PERSON.getCode()).eq(PatrolPlan::getPlanExecTypeId, userId)); }); //业务类型 Long typeId = data.getTypeId(); if (Objects.nonNull(typeId)) { queryWrapper.eq(PatrolPlan::getTypeId, typeId); }
(((org_id IN (?)) OR (plan_exec_type = ? AND plan_exec_type_id IN (?)) OR (plan_exec_type = ? AND plan_exec_type_id = ?)) and type_id = ?