派生自 projectDept/qhighschool

yn147
2023-06-01 ef32ca8ced9c90e172fec9c876b0f122c47f222f
问卷管理的多个查询
1个文件已修改
129 ■■■■■ 已修改文件
src/main/java/com/qxueyou/scc/evaluate/service/impl/EvaluateService.java 129 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/qxueyou/scc/evaluate/service/impl/EvaluateService.java
@@ -2,13 +2,12 @@
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
import java.util.stream.Collectors;
import com.querydsl.core.types.dsl.StringPath;
import com.qxueyou.scc.admin.classes.model.ClsClass;
import com.qxueyou.scc.teach.res.model.Res;
import org.apache.commons.beanutils.BeanUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.logging.log4j.LogManager;
@@ -102,7 +101,6 @@
        QStuStudent stuStudent = QStuStudent.stuStudent;
        // 搜索名
        keyword = StringUtils.isBlank(keyword) ? null : "%"+keyword+"%";
            // 获取查询结果集合
            QueryResults<Tuple> results = this.getQueryFactory()
                    .select(qEva, group, subject)
@@ -118,21 +116,20 @@
                    )
                    .orderBy(qEva.createTime.desc())
                    .fetchResults();
            QueryResults<Tuple> results2 = this.getQueryFactory()
                    .select(qEva, group, clsClass)
                    .from(qEva, template, group, clsClass)
                    .where(new QueryDslOptionBuilder()
                            .and(qEva.evalTemplateId::eq, template.evaluateTemplateId)
                            .and(template.groupId::eq, group.groupId)
                            .and(qEva.evalRangeId::like, clsClass.classId)
                            .and(qEva.createId::eq, ClientUtils.getUserId())
                            .and(qEva.evaluateName::like, keyword)
                            .and(qEva.deleteFlag::eq, false)
                            .build()
                    )
                    .orderBy(qEva.createTime.desc())
                    .fetchResults();
//        QueryResults<Tuple> results2 = this.getQueryFactory()
//                    .select(qEva, group, clsClass)
//                    .from(qEva, template, group, clsClass)
//                    .where(new QueryDslOptionBuilder()
//                            .and(qEva.evalTemplateId::eq, template.evaluateTemplateId)
//                            .and(template.groupId::eq, group.groupId)
//                            .and(qEva.evalRangeId::like,clsClass.classId)//qEva.evalRangeId::like, clsClass.classId
//                            .and(qEva.createId::eq, ClientUtils.getUserId())
//                            .and(qEva.evaluateName::like, keyword)
//                            .and(qEva.deleteFlag::eq, false)
//                            .build()
//                    )
//                    .orderBy(qEva.createTime.desc())
//                    .fetchResults();
            QueryResults<Tuple> results3 = this.getQueryFactory()
                    .select(qEva, group, stuStudent)
                    .from(qEva, template, group, stuStudent)
@@ -147,6 +144,47 @@
                    )
                    .orderBy(qEva.createTime.desc())
                    .fetchResults();
                Map<String, Object> args = null;
                String hql = "select s.evaluateId,s.evaluateName,s.evalRangeId,s.evalRangeType,s.evalRangeName,s.evalRangeCount,s.evalObjectName,s.status,s.endTime,s.createTime,e.groupId,s.evaluateCount " +
                "from SchEvaluate as s,SchEvaluateTemplate as t,ExerciseGroup as e,ClsClass as c  " +
                "where s.evalTemplateId =t.evaluateTemplateId  and  e.groupId =t.groupId and find_in_set(c.classId,s.evalRangeId)>0";
                if(keyword != null){
                    hql = hql+" and s.evaluateName like:evaluateName";
                    args = CollectionUtils.newObjectMap("evaluateName", keyword);
                }
                hql = hql+" and s.deleteFlag is false group by s.evaluateId";
        List<Map<String, Object>> results2 = findListWithMapByHql(hql, args);
        for (Map<String, Object> map: results2) {
            map.put("evaluateId", map.get("0"));
            map.put("evaluateName", map.get("1"));
            map.put("evalRangeId", map.get("2"));
            map.put("evalRangeType", map.get("3"));
            map.put("evalRangeName", map.get("4"));
            map.put("evalRangeCount", map.get("5"));
            map.put("evalObjectName", map.get("6"));
            map.put("status", map.get("7"));
            map.put("endTime", map.get("8"));
            map.put("createTime", map.get("9"));
            map.put("groupId", map.get("10"));
            map.put("exerCount", map.get("11"));
            map.remove(map.get("1"));
            map.remove("0");
            map.remove("1");
            map.remove("2");
            map.remove("3");
            map.remove("4");
            map.remove("5");
            map.remove("6");
            map.remove("7");
            map.remove("8");
            map.remove("9");
            map.remove("10");
            map.remove("11");
//            map.put("exerCount", tuple.get(group).getAllCount());
//            map.put("evaluateCount", this.getEvaluateCount(tuple.get(qEva).getEvaluateId()));//已评估人数
//            map.put("evaluateAllCount", this
//                    .queryEvaluateAllCount(tuple.get(qEva).getEvalRangeType(), tuple.get(qEva).getEvalRangeId().split(",")));//应评估人数
        }
            // 封装参数
            List<Map<String, Object>> resultLst =
                    results.getResults()
@@ -170,29 +208,28 @@
                                        .queryEvaluateAllCount(tuple.get(qEva).getEvalRangeType(), tuple.get(qEva).getEvalRangeId().split(",")));//应评估人数
                                return map;
                            }).collect(Collectors.toList());
            resultLst.addAll(
                    results2.getResults()
                            .stream()
                            .map(tuple -> {
                                Map<String, Object> map = new HashMap<String, Object>(2);
                                map.put("evaluateId", tuple.get(qEva).getEvaluateId());
                                map.put("evaluateName", tuple.get(qEva).getEvaluateName());
                                map.put("evalRangeId", tuple.get(qEva).getEvalRangeId());
                                map.put("evalRangeType", tuple.get(qEva).getEvalRangeType());
                                map.put("evalRangeName", tuple.get(clsClass).getName());
                                map.put("evalRangeCount", tuple.get(qEva).getEvalRangeCount());
                                map.put("evalObjectName", tuple.get(qEva).getEvalObjectName());
                                map.put("status", tuple.get(qEva).getStatus());
                                map.put("endTime", tuple.get(qEva).getEndTime());
                                map.put("createTime", tuple.get(qEva).getCreateTime());
                                map.put("groupId", tuple.get(group).getGroupId());
                                map.put("exerCount", tuple.get(group).getAllCount());
                                map.put("evaluateCount", this.getEvaluateCount(tuple.get(qEva).getEvaluateId()));//已评估人数
                                map.put("evaluateAllCount", this
                                        .queryEvaluateAllCount(tuple.get(qEva).getEvalRangeType(), tuple.get(qEva).getEvalRangeId().split(",")));//应评估人数
                                return map;
                            }).collect(Collectors.toList()));
//            resultLst.addAll(
//                    results2.getResults()
//                            .stream()
//                            .map(tuple -> {
//                                Map<String, Object> map = new HashMap<String, Object>(2);
//                                    map.put("evaluateId", tuple.get(qEva).getEvaluateId());
//                                    map.put("evaluateName", tuple.get(qEva).getEvaluateName());
//                                    map.put("evalRangeId", tuple.get(qEva).getEvalRangeId());
//                                    map.put("evalRangeType", tuple.get(qEva).getEvalRangeType());
//                                    map.put("evalRangeName", tuple.get(clsClass).getName());
//                                    map.put("evalRangeCount", tuple.get(qEva).getEvalRangeCount());
//                                    map.put("evalObjectName", tuple.get(qEva).getEvalObjectName());
//                                    map.put("status", tuple.get(qEva).getStatus());
//                                    map.put("endTime", tuple.get(qEva).getEndTime());
//                                    map.put("createTime", tuple.get(qEva).getCreateTime());
//                                    map.put("groupId", tuple.get(group).getGroupId());
//                                    map.put("exerCount", tuple.get(group).getAllCount());
//                                    map.put("evaluateCount", this.getEvaluateCount(tuple.get(qEva).getEvaluateId()));//已评估人数
//                                    map.put("evaluateAllCount", this
//                                            .queryEvaluateAllCount(tuple.get(qEva).getEvalRangeType(), tuple.get(qEva).getEvalRangeId().split(",")));//应评估人数
//                                return map;
//                            }).collect(Collectors.toList()));
            resultLst.addAll(
                    results3.getResults()
                            .stream()
@@ -215,9 +252,9 @@
                                        .queryEvaluateAllCount(tuple.get(qEva).getEvalRangeType(), tuple.get(qEva).getEvalRangeId().split(",")));//应评估人数
                                return map;
                            }).collect(Collectors.toList()));
        resultLst = results2.stream().collect(Collectors.toList());
        return new ResultJson(true, "success",
                CollectionUtils.newObjectMap("allCount",results.getTotal()+results2.getTotal()+results3.getTotal(),"datas",resultLst));
                CollectionUtils.newObjectMap("allCount",results.getTotal()+results2.stream().count()+results3.getTotal(),"datas",resultLst));
    }
    /**