Browse Source

统计报表2

zhuhaiwen 3 years ago
parent
commit
5a9a8cd590

+ 13 - 0
oa-app/src/main/java/com/css/oa/exam/report/bean/UPReq.java

@ -0,0 +1,13 @@
1
package com.css.oa.exam.report.bean;
2
3
public class UPReq {
4
5
    public String exam_id;
6
7
    public String unit_id;
8
9
    public int curPage;
10
11
    public int pageSize;
12
13
}

+ 11 - 4
oa-app/src/main/java/com/css/oa/exam/report/controller/ReportController.java

@ -4,6 +4,7 @@ import com.css.oa.exam.assign.bean.AssignExportReq;
4 4
import com.css.oa.exam.base.BaseController;
5 5
import com.css.oa.exam.report.bean.PRPExportReq;
6 6
import com.css.oa.exam.report.bean.PRPReq;
7
import com.css.oa.exam.report.bean.UPReq;
7 8
import com.css.oa.exam.report.service.ReportService;
8 9
import com.css.oa.utils.Result;
9 10
import io.swagger.annotations.Api;
@ -68,12 +69,18 @@ public class ReportController extends BaseController {
68 69
    }
69 70
70 71
    @ApiOperation(value = "统计报表-单位人员信息表")
71
    @GetMapping("/unit_personnel")
72
    public Result unit_personnel() {
72
    @GetMapping("/u_p")
73
    public Result u_p(@RequestBody UPReq req) {
73 74
        Result<Map> result = null;
74 75
        try {
75
//            Map obj = mService.unitPeople();
76
//            result = setResult("res", obj);
76
            if (TextUtils.isEmpty(req.exam_id)) {
77
                return setErr("exam_id不能为空");
78
            }
79
            if (TextUtils.isEmpty(req.unit_id)) {
80
                return setErr("unit_id不能为空");
81
            }
82
            Map obj = mService.u_p(req);
83
            result = setResult("res", obj);
77 84
        } catch (Exception e) {
78 85
            result = setErr(e.toString());
79 86
            e.printStackTrace();

+ 39 - 1
oa-app/src/main/java/com/css/oa/exam/report/service/ReportService.java

@ -20,6 +20,7 @@ import com.css.oa.exam.place.repository.Place;
20 20
import com.css.oa.exam.report.bean.PRPExcelEntity;
21 21
import com.css.oa.exam.report.bean.PRPExportReq;
22 22
import com.css.oa.exam.report.bean.PRPReq;
23
import com.css.oa.exam.report.bean.UPReq;
23 24
import com.css.oa.exam.room.repository.IRoomRepository;
24 25
import com.css.oa.exam.score.bean.AnalyseColumn;
25 26
import com.css.oa.exam.student.repository.IStudentRepository;
@ -155,7 +156,44 @@ public class ReportService extends BaseService implements IReportService {
155 156
        Workbook workBook = ExcelExportUtil.exportExcel(sheetsList, ExcelType.HSSF);
156 157
        workBook.createCellStyle().setLocked(true);
157 158
        ExcelDelegate.exportExcel(workBook, "考点考场人员信息.xls", response);
158
159 159
    }
160 160
161
    public Map u_p(UPReq req) {
162
        if (req.pageSize == 0) {
163
            req.pageSize = 20;
164
        }
165
        List<String> stuIds = studentRepository.findStuIdsByUnit_id(req.unit_id);
166
        Specification<Assign> spec = new Specification<Assign>() {
167
            @Override
168
            public Predicate toPredicate(Root<Assign> root, CriteriaQuery<?> criteriaQuery, CriteriaBuilder criteriaBuilder) {
169
                List<Predicate> predicateList = new ArrayList<>();
170
                //0.所属考试
171
                if (!TextUtils.isEmpty(req.exam_id)) {
172
                    Predicate exam_id = criteriaBuilder.equal(root.get("exam_id").as(String.class), req.exam_id);
173
                    predicateList.add(exam_id);
174
                }
175
                //TODO 加入第二个条件
176
//                if (stuIds.size() > 0) {
177
//                    Path<String> path = root.get("student_id");//定义查询的字段
178
//                    CriteriaBuilder.In<String> in = criteriaBuilder.in(path);
179
//                    for (int i = 0; i < roomIds.size(); i++) {
180
//                        in.value(roomIds.get(i));//存入值
181
//                    }
182
//                    predicateList.add(in);
183
//                }
184
                Predicate[] pre = new Predicate[predicateList.size()];
185
                pre = predicateList.toArray(pre);
186
                return criteriaQuery.where(pre).getRestriction();
187
            }
188
        };
189
        PageRequest pageReques = PageRequest.of(req.curPage, req.pageSize);
190
        Page<Assign> pages = assignRepository.findAll(spec, pageReques);
191
        List<Assign> list = pages.getContent();
192
193
        setAssignProperties(list);
194
        Map map = new HashMap();
195
        map.put("total", list.size());
196
        map.put("list", list);
197
        return map;
198
    }
161 199
}

+ 5 - 0
oa-app/src/main/java/com/css/oa/exam/student/repository/IStudentRepository.java

@ -34,4 +34,9 @@ public interface IStudentRepository extends JpaRepository<Student, String>, JpaS
34 34
    @Query("select stu.card_num from Student stu where stu.uuid in :uuids")
35 35
    List<String> findCardNums(@Param("uuids") List<String> uuids);
36 36
37
    @Modifying
38
    @Transactional
39
    @Query("select stu.uuid from Student stu where stu.unit_id = :unit_id")
40
    List<String> findStuIdsByUnit_id(@Param("unit_id") String unit_id);
41
37 42
}