产品需求:环节1、2、3、4
当前登录环节:2
需求为:查询环节>=2,且环节2的用户只为当前登录人的数据
参数:stepList,为>环节2的step集合
private Query queryMarkHistory(String traceId, List<Integer> stepList, UserTaskFile userTaskFile) { Query query = new Query(); Criteria criteria = new Criteria(); criteria.andOperator(Criteria.where("traceId").is(traceId)); Criteria gtStepCriteria = Criteria.where("step").in(stepList); Criteria contentNameCriteria = Criteria.where("step").is(userTaskFile.getStep()).and("userId").is(userTaskFile.getUserId()); criteria.orOperator(gtStepCriteria, contentNameCriteria); query.addCriteria(criteria); query.with(Sort.by(Sort.Direction.DESC, "createTime")); return query; }
需求为:查询环节>2,且环节2的用户只为当前登录人的记录 + 验收不合格记录或管理员打回记录
private Query queryMarkHistory(String traceId, List<Integer> stepList, UserTaskFile userTaskFile) { Query query = new Query(); Criteria criteria = new Criteria(); criteria.andOperator(Criteria.where("traceId").is(traceId));
// 后续环节 Criteria afterStepCriteria = Criteria.where("step").in(stepList); // 当前环节,包括:当前用户记录 + 管理员打回 + 公会任务验收不合格 Criteria curStepCriteria = new Criteria(); curStepCriteria.andOperator(Criteria.where("step").is(userTaskFile.getStep())); Criteria criteria1 = Criteria.where("userId").is(userTaskFile.getUserId()); Criteria criteria2 = Criteria.where("type").in(MarkHistoryConst.MARK_HISTORY_TYPE_BACK_MANAGER, MarkHistoryConst.MARK_HISTORY_TYPE_ACCEPTANCE_NOT_PASSED); curStepCriteria.orOperator(criteria1, criteria2); criteria.orOperator(afterStepCriteria, curStepCriteria); query.addCriteria(criteria); query.with(Sort.by(Sort.Direction.DESC, "createTime")); return query; }