Parcourir la Source

Merge branch 'develop' into feature/单点登录

zhuhaiwen 3 ans auparavant
Parent
commit
76d956172a
19 fichiers modifiés avec 733 ajouts et 20 suppressions
  1. 3 0
      oa-app/src/main/java/com/css/oa/exam/assign/repository/Assign.java
  2. 15 0
      oa-app/src/main/java/com/css/oa/exam/assign/repository/IAssignRepository.java
  3. 8 2
      oa-app/src/main/java/com/css/oa/exam/assign/service/BaseAssignService.java
  4. 10 0
      oa-app/src/main/java/com/css/oa/exam/place/repository/IPlaceRepository.java
  5. 24 0
      oa-app/src/main/java/com/css/oa/exam/report/bean/PRExcelEntity.java
  6. 7 0
      oa-app/src/main/java/com/css/oa/exam/report/bean/PRExportReq.java
  7. 44 0
      oa-app/src/main/java/com/css/oa/exam/report/bean/PRPExcelEntity.java
  8. 16 0
      oa-app/src/main/java/com/css/oa/exam/report/bean/PRPExportReq.java
  9. 16 0
      oa-app/src/main/java/com/css/oa/exam/report/bean/PRPReq.java
  10. 11 0
      oa-app/src/main/java/com/css/oa/exam/report/bean/PRReq.java
  11. 47 0
      oa-app/src/main/java/com/css/oa/exam/report/bean/UPExcelEntity.java
  12. 7 0
      oa-app/src/main/java/com/css/oa/exam/report/bean/UPExportReq.java
  13. 13 0
      oa-app/src/main/java/com/css/oa/exam/report/bean/UPReq.java
  14. 79 11
      oa-app/src/main/java/com/css/oa/exam/report/controller/ReportController.java
  15. 378 6
      oa-app/src/main/java/com/css/oa/exam/report/service/ReportService.java
  16. 10 0
      oa-app/src/main/java/com/css/oa/exam/room/repository/IRoomRepository.java
  17. 1 1
      oa-app/src/main/java/com/css/oa/exam/score/service/ScoreService.java
  18. 10 0
      oa-app/src/main/java/com/css/oa/exam/student/repository/IStudentRepository.java
  19. 34 0
      oa-app/src/main/java/com/css/oa/exam/util/ExportHelper.java

+ 3 - 0
oa-app/src/main/java/com/css/oa/exam/assign/repository/Assign.java

@ -60,6 +60,9 @@ public class Assign implements Serializable {
60 60
    public String level_name;
61 61
62 62
    @Transient
63
    public String subject_name;
64
65
    @Transient
63 66
    public int is_assign;
64 67
65 68
    @Transient

+ 15 - 0
oa-app/src/main/java/com/css/oa/exam/assign/repository/IAssignRepository.java

@ -49,4 +49,19 @@ public interface IAssignRepository extends JpaRepository<Assign, String>, JpaSpe
49 49
    @Query("select ass from Assign ass where ass.adm_num is not null and ass.student_id = :student_id")
50 50
    List<Assign> myAdm(String student_id);
51 51
52
    @Modifying
53
    @Transactional
54
    @Query("select ass from Assign ass where ass.exam_id = :exam_id and ass.place_id = :place_id")
55
    List<Assign> findAllByPlace_id(@Param("exam_id") String exam_id, @Param("place_id") String place_id);
56
57
    @Modifying
58
    @Transactional
59
    @Query("select ass.student_id from Assign ass where ass.exam_id = :exam_id")
60
    List<String> findStuIdsByExam_id(@Param("exam_id") String exam_id);
61
62
    @Modifying
63
    @Transactional
64
    @Query("select ass from Assign ass where ass.exam_id = :exam_id and ass.student_id in :stuIds")
65
    List<Assign> findByThisUnitStuIds(@Param("exam_id") String exam_id, @Param("stuIds") List<String> stuIds);
66
52 67
}

+ 8 - 2
oa-app/src/main/java/com/css/oa/exam/assign/service/BaseAssignService.java

@ -7,6 +7,8 @@ import com.css.oa.exam.assign.repository.IAssignRecord;
7 7
import com.css.oa.exam.base.BaseVerifyService;
8 8
import com.css.oa.exam.constants.BoolState;
9 9
import com.css.oa.exam.constants.VerifyState;
10
import com.css.oa.exam.exam.repository.Exam;
11
import com.css.oa.exam.exam.repository.IExamRepository;
10 12
import com.css.oa.exam.place.repository.IPlaceRepository;
11 13
import com.css.oa.exam.place.repository.Place;
12 14
import com.css.oa.exam.student.repository.IStudentRepository;
@ -90,6 +92,9 @@ public class BaseAssignService extends BaseVerifyService {
90 92
        return null;
91 93
    }
92 94
95
    @Autowired
96
    IExamRepository examRepository;
97
93 98
    protected void setProperties(List<Assign> assignList) {
94 99
        //设置审核状态
95 100
        setVerifyState(assignList);
@ -108,8 +113,9 @@ public class BaseAssignService extends BaseVerifyService {
108 113
            Place place = placeRepository.findById(assign.getWant_place_id()).get();
109 114
            assign.setWant_place_name(place.getPlace_name());
110 115
111
            assign.setSeries_name("水利工程");
112
            assign.setLevel_name("中高级");
116
            Exam exam = examRepository.findById(assign.exam_id).get();
117
            assign.setSeries_name(exam.getSeries_name());
118
            assign.setLevel_name(exam.getLevel_name());
113 119
            boolean empty = TextUtils.isEmpty(assign.getRoom_id());
114 120
            assign.setIs_assign(empty ? BoolState.NO : BoolState.YES);
115 121
        }

+ 10 - 0
oa-app/src/main/java/com/css/oa/exam/place/repository/IPlaceRepository.java

@ -30,4 +30,14 @@ public interface IPlaceRepository extends JpaRepository<Place, String>, JpaSpeci
30 30
    @Query("select p from Place p where p.create_unit_id in :unitIds and p.exam_id = :exam_id and p.curr_unit_id = " + Unit.TOP_CODE)
31 31
    List<Place> findAllByUnitIds(List<String> unitIds, String exam_id);
32 32
33
    @Modifying
34
    @Transactional
35
    @Query("select p from Place p where p.exam_id  = :exam_id")
36
    List<Place> findAllByExam_id(String exam_id);
37
38
//    @Modifying
39
//    @Transactional
40
//    @Query("select p.uuid from Place p where p.exam_id  = :exam_id")
41
//    List<String> findIdsByExam_id(String exam_id);
42
33 43
}

+ 24 - 0
oa-app/src/main/java/com/css/oa/exam/report/bean/PRExcelEntity.java

@ -0,0 +1,24 @@
1
package com.css.oa.exam.report.bean;
2
3
import cn.afterturn.easypoi.excel.annotation.Excel;
4
import cn.afterturn.easypoi.excel.annotation.ExcelTarget;
5
import lombok.Data;
6
7
@Data
8
@ExcelTarget("deptUtil")
9
public class PRExcelEntity {
10
11
    @Excel(name = "考点", width = 20)
12
    private String place_name;
13
14
    @Excel(name = "考场", width = 20)
15
    private String room_name;
16
17
    @Excel(name = "考场可容纳人数")
18
    private int total;
19
20
    @Excel(name = "考场已分配人数")
21
    private int assigned_count;
22
23
24
}

+ 7 - 0
oa-app/src/main/java/com/css/oa/exam/report/bean/PRExportReq.java

@ -0,0 +1,7 @@
1
package com.css.oa.exam.report.bean;
2
3
public class PRExportReq {
4
5
    public String exam_id;
6
7
}

+ 44 - 0
oa-app/src/main/java/com/css/oa/exam/report/bean/PRPExcelEntity.java

@ -0,0 +1,44 @@
1
package com.css.oa.exam.report.bean;
2
3
import cn.afterturn.easypoi.excel.annotation.Excel;
4
import cn.afterturn.easypoi.excel.annotation.ExcelTarget;
5
import lombok.Data;
6
7
@Data
8
@ExcelTarget("deptUtil")
9
public class PRPExcelEntity {
10
11
    @Excel(name = "考场", width = 20)
12
    private String room_name;
13
14
    @Excel(name = "姓名")
15
    private String name;
16
17
    @Excel(name = "身份证", width = 20)
18
    private String card_num;
19
20
    @Excel(name = "准考证")
21
    private String adm_num;
22
23
    @Excel(name = "座位号")
24
    private String seat_num;
25
26
    @Excel(name = "报考系列", width = 15)
27
    private String series_name;
28
29
    @Excel(name = "报考级别")
30
    private String level_name;
31
32
    @Excel(name = "报考科目", width = 15)
33
    private String subject_name;
34
35
    @Excel(name = "照片", width = 15)
36
    private String pic;
37
38
    @Excel(name = "签名", width = 15)
39
    private String autograph;
40
41
//    @ExcelCollection(name = "员工信息")
42
//    private List<EmpUtil> emps;
43
44
}

+ 16 - 0
oa-app/src/main/java/com/css/oa/exam/report/bean/PRPExportReq.java

@ -0,0 +1,16 @@
1
package com.css.oa.exam.report.bean;
2
3
import com.css.oa.exam.constants.ExportDTO;
4
5
import java.util.ArrayList;
6
import java.util.List;
7
8
public class PRPExportReq {
9
10
    public String exam_id;
11
12
//    public int curPage;
13
//
14
//    public int pageSize;
15
16
}

+ 16 - 0
oa-app/src/main/java/com/css/oa/exam/report/bean/PRPReq.java

@ -0,0 +1,16 @@
1
package com.css.oa.exam.report.bean;
2
3
import com.css.oa.exam.constants.ExportDTO;
4
5
import java.util.ArrayList;
6
import java.util.List;
7
8
public class PRPReq {
9
10
    public String place_id;
11
12
    public int curPage;
13
14
    public int pageSize;
15
16
}

+ 11 - 0
oa-app/src/main/java/com/css/oa/exam/report/bean/PRReq.java

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

+ 47 - 0
oa-app/src/main/java/com/css/oa/exam/report/bean/UPExcelEntity.java

@ -0,0 +1,47 @@
1
package com.css.oa.exam.report.bean;
2
3
import cn.afterturn.easypoi.excel.annotation.Excel;
4
import cn.afterturn.easypoi.excel.annotation.ExcelTarget;
5
import lombok.Data;
6
7
@Data
8
@ExcelTarget("deptUtil")
9
public class UPExcelEntity {
10
11
    @Excel(name = "考点", width = 20)
12
    private String place_name;
13
14
    @Excel(name = "考场", width = 20)
15
    private String room_name;
16
17
    @Excel(name = "姓名")
18
    private String name;
19
20
    @Excel(name = "身份证", width = 20)
21
    private String card_num;
22
23
    @Excel(name = "准考证")
24
    private String adm_num;
25
26
    @Excel(name = "座位号")
27
    private String seat_num;
28
29
    @Excel(name = "报考系列", width = 15)
30
    private String series_name;
31
32
    @Excel(name = "报考级别")
33
    private String level_name;
34
35
    @Excel(name = "报考科目", width = 15)
36
    private String subject_name;
37
38
    @Excel(name = "照片", width = 15)
39
    private String pic;
40
41
    @Excel(name = "签名", width = 15)
42
    private String autograph;
43
44
//    @ExcelCollection(name = "员工信息")
45
//    private List<EmpUtil> emps;
46
47
}

+ 7 - 0
oa-app/src/main/java/com/css/oa/exam/report/bean/UPExportReq.java

@ -0,0 +1,7 @@
1
package com.css.oa.exam.report.bean;
2
3
public class UPExportReq {
4
5
    public String exam_id;
6
7
}

+ 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
}

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

@ -1,6 +1,8 @@
1 1
package com.css.oa.exam.report.controller;
2 2
3
import com.css.oa.exam.assign.bean.AssignExportReq;
3 4
import com.css.oa.exam.base.BaseController;
5
import com.css.oa.exam.report.bean.*;
4 6
import com.css.oa.exam.report.service.ReportService;
5 7
import com.css.oa.utils.Result;
6 8
import io.swagger.annotations.Api;
@ -9,6 +11,7 @@ import org.apache.http.util.TextUtils;
9 11
import org.springframework.beans.factory.annotation.Autowired;
10 12
import org.springframework.web.bind.annotation.*;
11 13
14
import javax.servlet.http.HttpServletResponse;
12 15
import java.util.HashMap;
13 16
import java.util.List;
14 17
import java.util.Map;
@ -36,12 +39,12 @@ public class ReportController extends BaseController {
36 39
    }
37 40
38 41
    @ApiOperation(value = "统计报表-考点考场人员信息")
39
    @GetMapping("/roomPeople")
40
    public Result roomPeople() {
42
    @PostMapping("/prp")
43
    public Result prp(@RequestBody PRPReq req) {
41 44
        Result<Map> result = null;
42 45
        try {
43
//            Map obj = mService.roomPeople();
44
//            result = setResult("res", obj);
46
            Map obj = mService.prp(req);
47
            result = setResult("res", obj);
45 48
        } catch (Exception e) {
46 49
            result = setErr(e.toString());
47 50
            e.printStackTrace();
@ -49,13 +52,33 @@ public class ReportController extends BaseController {
49 52
        return result;
50 53
    }
51 54
55
    @ApiOperation(value = "统计报表-考点考场人员信息-导出")
56
    @PostMapping("/prp_export")
57
    public void prp_export(HttpServletResponse response, @RequestBody PRPExportReq req) {
58
        try {
59
            if (TextUtils.isEmpty(req.exam_id)) {
60
                exportPrint(response, "exam_id不能为空");
61
            }
62
            mService.prp_export(response, req);
63
        } catch (Exception e) {
64
            System.out.println(e.getMessage());
65
            exportPrint(response, e.getMessage());
66
        }
67
    }
68
52 69
    @ApiOperation(value = "统计报表-单位人员信息表")
53
    @GetMapping("/unitPeople")
54
    public Result unitPeople() {
70
    @GetMapping("/u_p")
71
    public Result u_p(@RequestBody UPReq req) {
55 72
        Result<Map> result = null;
56 73
        try {
57
//            Map obj = mService.unitPeople();
58
//            result = setResult("res", obj);
74
            if (TextUtils.isEmpty(req.exam_id)) {
75
                return setErr("exam_id不能为空");
76
            }
77
            if (TextUtils.isEmpty(req.unit_id)) {
78
                return setErr("unit_id不能为空");
79
            }
80
            Map obj = mService.u_p(req);
81
            result = setResult("res", obj);
59 82
        } catch (Exception e) {
60 83
            result = setErr(e.toString());
61 84
            e.printStackTrace();
@ -63,9 +86,54 @@ public class ReportController extends BaseController {
63 86
        return result;
64 87
    }
65 88
89
    @ApiOperation(value = "统计报表-单位人员信息表-导出")
90
    @PostMapping("/up_export")
91
    public void up_export(HttpServletResponse response, @RequestBody UPExportReq req) {
92
        try {
93
            if (TextUtils.isEmpty(req.exam_id)) {
94
                exportPrint(response, "exam_id不能为空");
95
            }
96
            mService.up_export(response, req);
97
        } catch (Exception e) {
98
            System.out.println(e.getMessage());
99
            exportPrint(response, e.getMessage());
100
        }
101
    }
102
66 103
    @ApiOperation(value = "统计报表-考点考场统计一览表")
67
    @GetMapping("/place_room")
68
    public Result place_room() {
104
    @GetMapping("/pr")
105
    public Result pr(@RequestBody PRReq req) {
106
        Result<Map> result = null;
107
        try {
108
            if (TextUtils.isEmpty(req.exam_id)) {
109
                return setErr("exam_id不能为空");
110
            }
111
            Map obj = mService.pr(req);
112
            result = setResult("res", obj);
113
        } catch (Exception e) {
114
            result = setErr(e.toString());
115
            e.printStackTrace();
116
        }
117
        return result;
118
    }
119
120
    @ApiOperation(value = "统计报表-考点考场统计一览表-导出")
121
    @PostMapping("/pr_export")
122
    public void pr_export(HttpServletResponse response, @RequestBody PRExportReq req) {
123
        try {
124
            if (TextUtils.isEmpty(req.exam_id)) {
125
                exportPrint(response, "exam_id不能为空");
126
            }
127
            mService.pr_export(response, req);
128
        } catch (Exception e) {
129
            System.out.println(e.getMessage());
130
            exportPrint(response, e.getMessage());
131
        }
132
    }
133
134
    @ApiOperation(value = "统计报表-考点考场统计一览表")
135
    @GetMapping("/place_room_multi")
136
    public Result place_room_multi() {
69 137
        Result<Map> result = null;
70 138
        try {
71 139
//            Map obj = mService.place_room();
@ -77,7 +145,7 @@ public class ReportController extends BaseController {
77 145
        return result;
78 146
    }
79 147
80
    @ApiOperation(value = "统计报表-考点考场统计一览表")
148
    @ApiOperation(value = "统计报表-督考员一览表")
81 149
    @GetMapping("/monitor")
82 150
    public Result monitor() {
83 151
        Result<Map> result = null;

+ 378 - 6
oa-app/src/main/java/com/css/oa/exam/report/service/ReportService.java

@ -1,9 +1,54 @@
1 1
package com.css.oa.exam.report.service;
2 2
3
import cn.afterturn.easypoi.excel.ExcelExportUtil;
4
import cn.afterturn.easypoi.excel.entity.ExportParams;
5
import cn.afterturn.easypoi.excel.entity.enmus.ExcelType;
6
import cn.afterturn.easypoi.excel.entity.params.ExcelExportEntity;
7
import com.css.oa.exam.admin.bean.Admin;
8
import com.css.oa.exam.assign.bean.AssignExportReq;
9
import com.css.oa.exam.assign.repository.Assign;
10
import com.css.oa.exam.assign.repository.AssignRecord;
11
import com.css.oa.exam.assign.repository.IAssignRepository;
3 12
import com.css.oa.exam.base.BaseService;
13
import com.css.oa.exam.constants.BoolState;
14
import com.css.oa.exam.constants.ExamConfig;
15
import com.css.oa.exam.constants.ExportDTO;
16
import com.css.oa.exam.exam.repository.Exam;
17
import com.css.oa.exam.exam.repository.IExamRepository;
18
import com.css.oa.exam.place.repository.IPlaceRepository;
19
import com.css.oa.exam.place.repository.Place;
20
import com.css.oa.exam.report.bean.*;
21
import com.css.oa.exam.room.repository.IRoomRepository;
22
import com.css.oa.exam.room.repository.Room;
23
import com.css.oa.exam.score.bean.AnalyseColumn;
24
import com.css.oa.exam.student.repository.IStudentRepository;
25
import com.css.oa.exam.student.repository.Student;
26
import com.css.oa.exam.unit.repository.IUnitRepository;
27
import com.css.oa.exam.unit.repository.Unit;
28
import com.css.oa.exam.util.CopyObjTool;
29
import com.css.oa.exam.util.ExcelDelegate;
30
import com.css.oa.exam.util.ExportHelper;
4 31
import lombok.extern.slf4j.Slf4j;
32
import org.apache.http.util.TextUtils;
33
import org.apache.poi.hssf.usermodel.HSSFRow;
34
import org.apache.poi.hssf.usermodel.HSSFSheet;
35
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
36
import org.apache.poi.ss.usermodel.Workbook;
37
import org.springframework.beans.BeanUtils;
38
import org.springframework.beans.factory.annotation.Autowired;
39
import org.springframework.data.domain.Page;
40
import org.springframework.data.domain.PageRequest;
41
import org.springframework.data.domain.Sort;
42
import org.springframework.data.jpa.domain.Specification;
5 43
import org.springframework.stereotype.Service;
6 44
45
import javax.persistence.criteria.*;
46
import javax.servlet.http.HttpServletResponse;
47
import java.io.BufferedOutputStream;
48
import java.io.ByteArrayInputStream;
49
import java.io.ByteArrayOutputStream;
50
import java.io.OutputStream;
51
import java.net.URLEncoder;
7 52
import java.util.ArrayList;
8 53
import java.util.HashMap;
9 54
import java.util.List;
@ -21,11 +66,338 @@ public class ReportService extends BaseService implements IReportService {
21 66
        map.put("list", arr);
22 67
        return map;
23 68
    }
24
//
25
//    @Autowired
26
//    IExamRepository repository;
27
//
28
//    @Autowired
29
//    IUnitRepository unitRepository;
30 69
70
    @Autowired
71
    IRoomRepository roomRepository;
72
    @Autowired
73
    IAssignRepository assignRepository;
74
    @Autowired
75
    IStudentRepository studentRepository;
76
    @Autowired
77
    IExamRepository examRepository;
78
79
    public Map prp(PRPReq req) {
80
        if (req.pageSize == 0) {
81
            req.pageSize = 20;
82
        }
83
        List<String> roomIds = roomRepository.findAllIdByPlace_id(req.place_id);
84
        Specification<Assign> spec = new Specification<Assign>() {
85
            @Override
86
            public Predicate toPredicate(Root<Assign> root, CriteriaQuery<?> criteriaQuery, CriteriaBuilder criteriaBuilder) {
87
                List<Predicate> predicateList = new ArrayList<>();
88
                //0.所属考试
89
                if (roomIds.size() > 0) {
90
                    Path<String> path = root.get("room_id");//定义查询的字段
91
                    CriteriaBuilder.In<String> in = criteriaBuilder.in(path);
92
                    for (int i = 0; i < roomIds.size(); i++) {
93
                        in.value(roomIds.get(i));//存入值
94
                    }
95
                    predicateList.add(in);
96
                }
97
                Predicate[] pre = new Predicate[predicateList.size()];
98
                pre = predicateList.toArray(pre);
99
                return criteriaQuery.where(pre).getRestriction();
100
            }
101
        };
102
        PageRequest pageReques = PageRequest.of(req.curPage, req.pageSize);
103
        Page<Assign> pages = assignRepository.findAll(spec, pageReques);
104
        List<Assign> list = pages.getContent();
105
106
        setAssignProperties(list);
107
        Map map = new HashMap();
108
        map.put("total", list.size());
109
        map.put("list", list);
110
        return map;
111
    }
112
113
    private void setAssignProperties(List<Assign> list) {
114
        for (Assign assign : list) {
115
            //附加学生信息
116
            String student_id = assign.getStudent_id();
117
            Student student = studentRepository.findById(student_id).get();
118
            CopyObjTool.copyProperties(student, assign);
119
            Exam exam = examRepository.findById(assign.exam_id).get();
120
            assign.setSeries_name(exam.getSeries_name());
121
            assign.setLevel_name(exam.getLevel_name());
122
            assign.setSubject_name(exam.getSubject_name());
123
        }
124
    }
125
126
    @Autowired
127
    IPlaceRepository placeRepository;
128
129
    public void prp_export(HttpServletResponse response, PRPExportReq req) {
130
        //查询这个考试里边的所有考点
131
        List<Place> places = placeRepository.findAllByExam_id(req.exam_id);
132
133
        List<Map<String, Object>> sheetsList = new ArrayList<>();
134
        for (int i = 0; i < places.size(); i++) {
135
            Place place = places.get(i);
136
            List<Assign> list = assignRepository.findAllByPlace_id(req.exam_id, place.getUuid());
137
            setAssignProperties(list);
138
            List<PRPExcelEntity> beans = new ArrayList<>();
139
            for (Assign assign : list) {
140
                PRPExcelEntity entity = new PRPExcelEntity();
141
                BeanUtils.copyProperties(assign, entity);
142
                beans.add(entity);
143
            }
144
            ExportParams exportParams = new ExportParams();
145
            exportParams.setSheetName(place.getPlace_name());
146
            // 创建sheet1使用得map
147
            Map<String, Object> map = new HashMap<>();
148
            // title的参数为ExportParams类型,目前仅仅在ExportParams中设置了sheetName
149
            map.put("title", exportParams);
150
            // 模版导出对应得实体类型
151
            map.put("entity", PRPExcelEntity.class);
152
            // sheet中要填充得数据
153
            map.put("data", beans);
154
            sheetsList.add(map);
155
        }
156
        // 执行方法
157
        Workbook workBook = ExcelExportUtil.exportExcel(sheetsList, ExcelType.HSSF);
158
        workBook.createCellStyle().setLocked(true);
159
        ExcelDelegate.exportExcel(workBook, "考点考场人员信息.xls", response);
160
    }
161
162
    public Map u_p(UPReq req) {
163
        if (req.pageSize == 0) {
164
            req.pageSize = 20;
165
        }
166
        List<String> stuIds = studentRepository.findStuIdsByUnit_id(req.unit_id);
167
        Specification<Assign> spec = new Specification<Assign>() {
168
            @Override
169
            public Predicate toPredicate(Root<Assign> root, CriteriaQuery<?> criteriaQuery, CriteriaBuilder criteriaBuilder) {
170
                List<Predicate> predicateList = new ArrayList<>();
171
                //0.所属考试
172
                if (!TextUtils.isEmpty(req.exam_id)) {
173
                    Predicate exam_id = criteriaBuilder.equal(root.get("exam_id").as(String.class), req.exam_id);
174
                    predicateList.add(exam_id);
175
                }
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 < stuIds.size(); i++) {
180
                        in.value(stuIds.get(i));//存入值
181
                    }
182
                    predicateList.add(in);
183
                }
184
                Predicate[] pre = new Predicate[predicateList.size()];
185
                pre = predicateList.toArray(pre);
186
187
                Order place_order = criteriaBuilder.asc(root.get("place_id"));
188
                Order room_order = criteriaBuilder.asc(root.get("room_id"));
189
                criteriaQuery.orderBy(place_order, room_order);
190
                criteriaQuery.where(pre);
191
                return criteriaQuery.getRestriction();
192
            }
193
        };
194
//        Sort sort = Sort.by(Sort.Direction.ASC, "place_id");
195
//        PageRequest pageReques = PageRequest.of(req.curPage, req.pageSize, sort);
196
        PageRequest pageReques = PageRequest.of(req.curPage, req.pageSize);
197
        Page<Assign> pages = assignRepository.findAll(spec, pageReques);
198
        List<Assign> list = pages.getContent();
199
200
        setAssignProperties(list);
201
        Map map = new HashMap();
202
        map.put("total", list.size());
203
        map.put("list", list);
204
        return map;
205
    }
206
207
    @Autowired
208
    IUnitRepository unitRepository;
209
210
    public void up_export(HttpServletResponse response, UPExportReq req) {
211
        //查询这个考试里边的所有单位
212
        List<String> stuIds = assignRepository.findStuIdsByExam_id(req.exam_id);
213
        List<String> unitIDs = studentRepository.findUnitsByUuids(stuIds);
214
        List<Unit> units = unitRepository.findAllById(unitIDs);
215
        List<Student> stus = studentRepository.findAllById(stuIds);
216
217
        List<Map<String, Object>> sheetsList = new ArrayList<>();
218
        for (int i = 0; i < units.size(); i++) {
219
            Unit unit = units.get(i);
220
            //这个考试里边,某个单位下的所有考生
221
            List<String> thisUnitStuIds = new ArrayList<>();
222
            for (int j = 0; j < stus.size(); j++) {
223
                if (stus.get(i).unit_id.equalsIgnoreCase(unit.uuid)) {
224
                    thisUnitStuIds.add(stus.get(j).uuid);
225
                }
226
            }
227
            List<Assign> list = assignRepository.findByThisUnitStuIds(req.exam_id, thisUnitStuIds);
228
            setAssignProperties(list);
229
            List<UPExcelEntity> beans = new ArrayList<>();
230
            for (Assign assign : list) {
231
                UPExcelEntity entity = new UPExcelEntity();
232
                BeanUtils.copyProperties(assign, entity);
233
                beans.add(entity);
234
            }
235
            ExportParams exportParams = new ExportParams();
236
            exportParams.setSheetName(unit.name);
237
            // 创建sheet1使用得map
238
            Map<String, Object> oneSheet = new HashMap<>();
239
            // title的参数为ExportParams类型,目前仅仅在ExportParams中设置了sheetName
240
            oneSheet.put("title", exportParams);
241
            // 模版导出对应得实体类型
242
            oneSheet.put("entity", UPExcelEntity.class);
243
            // sheet中要填充得数据
244
            oneSheet.put("data", beans);
245
            sheetsList.add(oneSheet);
246
        }
247
        // 执行方法
248
        Workbook workBook = ExcelExportUtil.exportExcel(sheetsList, ExcelType.HSSF);
249
        workBook.createCellStyle().setLocked(true);
250
        ExcelDelegate.exportExcel(workBook, "单位人员信息表.xls", response);
251
    }
252
253
    public Map pr(PRReq req) {
254
        if (req.pageSize == 0) {
255
            req.pageSize = 20;
256
        }
257
        List<Place> places = placeRepository.findAllByExam_id(req.exam_id);
258
        List<String> placeIds = new ArrayList<>();
259
        for (Place place : places) {
260
            placeIds.add(place.getUuid());
261
        }
262
        Specification<Room> roomSpec = new Specification<Room>() {
263
            @Override
264
            public Predicate toPredicate(Root<Room> root, CriteriaQuery<?> criteriaQuery, CriteriaBuilder criteriaBuilder) {
265
                List<Predicate> predicateList = new ArrayList<>();
266
                if (placeIds.size() > 0) {
267
                    Path<String> path = root.get("student_id");//定义查询的字段
268
                    CriteriaBuilder.In<String> in = criteriaBuilder.in(path);
269
                    for (int i = 0; i < placeIds.size(); i++) {
270
                        in.value(placeIds.get(i));//存入值
271
                    }
272
                    predicateList.add(in);
273
                }
274
                Predicate[] pre = new Predicate[predicateList.size()];
275
                pre = predicateList.toArray(pre);
276
277
                Order place_order = criteriaBuilder.asc(root.get("place_id"));
278
                criteriaQuery.orderBy(place_order);
279
                criteriaQuery.where(pre);
280
                return criteriaQuery.getRestriction();
281
            }
282
        };
283
        PageRequest pageReques = PageRequest.of(req.curPage, req.pageSize);
284
        Page<Room> pages = roomRepository.findAll(roomSpec, pageReques);
285
        List<Room> rooms = pages.getContent();
286
287
        List<PRExcelEntity> list = new ArrayList();
288
        for (int i = 0; i < rooms.size(); i++) {
289
            Room room = rooms.get(i);
290
            PRExcelEntity entity = new PRExcelEntity();
291
            String pName = "";
292
            for (Place p : places) {
293
                if (room.getPlace_id().equalsIgnoreCase(p.getUuid())) {
294
                    pName = p.getPlace_name();
295
                    break;
296
                }
297
            }
298
            entity.setPlace_name(pName);
299
            entity.setRoom_name(room.getRoom_name());
300
            entity.setTotal(room.getPeaple_count());
301
            //查询已经分配的人数
302
            Specification<Assign> spec = new Specification<Assign>() {
303
                @Override
304
                public Predicate toPredicate(Root<Assign> root, CriteriaQuery<?> criteriaQuery, CriteriaBuilder criteriaBuilder) {
305
                    List<Predicate> predicateList = new ArrayList<>();
306
                    //0.所属考试
307
                    if (!TextUtils.isEmpty(req.exam_id)) {
308
                        Predicate exam_id = criteriaBuilder.equal(root.get("exam_id").as(String.class), req.exam_id);
309
                        predicateList.add(exam_id);
310
                    }
311
                    String room_id = room.getUuid();
312
                    if (!TextUtils.isEmpty(room_id)) {
313
                        Predicate exam_id = criteriaBuilder.equal(root.get("room_id").as(String.class), room_id);
314
                        predicateList.add(exam_id);
315
                    }
316
                    Predicate[] pre = new Predicate[predicateList.size()];
317
                    pre = predicateList.toArray(pre);
318
319
                    Order place_order = criteriaBuilder.asc(root.get("place_id"));
320
                    Order room_order = criteriaBuilder.asc(root.get("room_id"));
321
                    criteriaQuery.orderBy(place_order, room_order);
322
                    criteriaQuery.where(pre);
323
                    return criteriaQuery.getRestriction();
324
                }
325
            };
326
            long count = assignRepository.count(spec);
327
            entity.setAssigned_count((int) count);
328
            list.add(entity);
329
        }
330
        Map map = new HashMap();
331
        map.put("total", list.size());
332
        map.put("list", list);
333
        return map;
334
    }
335
336
    public void pr_export(HttpServletResponse response, PRExportReq req) {
337
        List<Place> places = placeRepository.findAllByExam_id(req.exam_id);
338
        List<String> placeIds = new ArrayList<>();
339
        for (Place place : places) {
340
            placeIds.add(place.getUuid());
341
        }
342
        List<Room> rooms = roomRepository.findAllByPlace_ids(placeIds);
343
        List<PRExcelEntity> list = new ArrayList();
344
        for (int i = 0; i < rooms.size(); i++) {
345
            Room room = rooms.get(i);
346
            PRExcelEntity entity = new PRExcelEntity();
347
            String pName = "";
348
            for (Place p : places) {
349
                if (room.getPlace_id().equalsIgnoreCase(p.getUuid())) {
350
                    pName = p.getPlace_name();
351
                    break;
352
                }
353
            }
354
            entity.setPlace_name(pName);
355
            entity.setRoom_name(room.getRoom_name());
356
            entity.setTotal(room.getPeaple_count());
357
            //查询已经分配的人数
358
            Specification<Assign> spec = new Specification<Assign>() {
359
                @Override
360
                public Predicate toPredicate(Root<Assign> root, CriteriaQuery<?> criteriaQuery, CriteriaBuilder criteriaBuilder) {
361
                    List<Predicate> predicateList = new ArrayList<>();
362
                    //0.所属考试
363
                    if (!TextUtils.isEmpty(req.exam_id)) {
364
                        Predicate exam_id = criteriaBuilder.equal(root.get("exam_id").as(String.class), req.exam_id);
365
                        predicateList.add(exam_id);
366
                    }
367
                    String room_id = room.getUuid();
368
                    if (!TextUtils.isEmpty(room_id)) {
369
                        Predicate exam_id = criteriaBuilder.equal(root.get("room_id").as(String.class), room_id);
370
                        predicateList.add(exam_id);
371
                    }
372
                    Predicate[] pre = new Predicate[predicateList.size()];
373
                    pre = predicateList.toArray(pre);
374
                    criteriaQuery.where(pre);
375
                    return criteriaQuery.getRestriction();
376
                }
377
            };
378
            long count = assignRepository.count(spec);
379
            entity.setAssigned_count((int) count);
380
            list.add(entity);
381
        }
382
383
        //原料 beans
384
        List<Map<String, Object>> sheetsList = new ArrayList<>();
385
        List<PRExcelEntity> beans = new ArrayList<>();
386
        beans = list;
387
        ExportParams exportParams = new ExportParams();
388
        exportParams.setSheetName("考点考场统计一览表");
389
        // 创建sheet1使用得map
390
        Map<String, Object> oneSheet = new HashMap<>();
391
        // title的参数为ExportParams类型,目前仅仅在ExportParams中设置了sheetName
392
        oneSheet.put("title", exportParams);
393
        // 模版导出对应得实体类型
394
        oneSheet.put("entity", PRExcelEntity.class);
395
        // sheet中要填充得数据
396
        oneSheet.put("data", beans);
397
        sheetsList.add(oneSheet);
398
        // 执行方法
399
        Workbook workBook = ExcelExportUtil.exportExcel(sheetsList, ExcelType.HSSF);
400
        workBook.createCellStyle().setLocked(true);
401
        ExcelDelegate.exportExcel(workBook, "考点考场统计一览表.xls", response);
402
    }
31 403
}

+ 10 - 0
oa-app/src/main/java/com/css/oa/exam/room/repository/IRoomRepository.java

@ -36,4 +36,14 @@ public interface IRoomRepository extends JpaRepository<Room, String>, JpaSpecifi
36 36
    @Query("select r from Room r where r.create_unit_id in :unitIds and r.place_id = :place_id and r.curr_unit_id = " + Unit.TOP_CODE)
37 37
    List<Room> findAllByUnitIds(List<String> unitIds, String place_id);
38 38
39
    @Modifying
40
    @Transactional
41
    @Query("select r.uuid from Room r where r.place_id = :place_id")
42
    List<String> findAllIdByPlace_id(@Param("place_id") String place_id);
43
44
    @Modifying
45
    @Transactional
46
    @Query("select r from Room r where r.place_id in :place_ids")
47
    List<Room> findAllByPlace_ids(@Param("place_ids") List<String> place_ids);
48
39 49
}

+ 1 - 1
oa-app/src/main/java/com/css/oa/exam/score/service/ScoreService.java

@ -274,7 +274,7 @@ public class ScoreService extends BaseVerifyService implements IScoreService {
274 274
            }
275 275
            data.add(columns);
276 276
        }
277
277
        //原生POI
278 278
        //1.实例化HSSFWorkbook
279 279
        HSSFWorkbook workbook = new HSSFWorkbook();
280 280
        //2.创建一个Excel表单,参数为sheet的名字

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

@ -34,4 +34,14 @@ 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
42
    @Modifying
43
    @Transactional
44
    @Query("select stu.unit_id from Student stu where stu.uuid in :uuids")
45
    List<String> findUnitsByUuids(@Param("uuids") List<String> uuids);
46
37 47
}

+ 34 - 0
oa-app/src/main/java/com/css/oa/exam/util/ExportHelper.java

@ -0,0 +1,34 @@
1
package com.css.oa.exam.util;
2
3
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
4
5
import javax.servlet.http.HttpServletResponse;
6
import java.io.BufferedOutputStream;
7
import java.io.OutputStream;
8
9
public class ExportHelper {
10
11
    public static void export(HttpServletResponse response, HSSFWorkbook workbook,String fileName){
12
        try {
13
            //String fileName = "成绩分析-导出.xls";
14
            //清空response
15
            response.reset();
16
            //设置response的Header
17
            response.addHeader("Access-Control-Allow-Origin", "*");
18
            response.setHeader("Access-Control-Expose-Headers", "Content-Disposition");
19
            response.setCharacterEncoding("UTF-8");
20
            response.setHeader("content-Type", "application/vnd.ms-excel");
21
            response.addHeader("Content-Disposition", "attachment;filename=" + fileName);
22
23
            OutputStream os = new BufferedOutputStream(response.getOutputStream());
24
            //将excel写入到输出流中
25
            workbook.write(os);
26
            os.flush();
27
            os.close();
28
            System.out.println("设置浏览器下载成功!");
29
        } catch (Exception e) {
30
            System.out.println("设置浏览器下载失败!");
31
            e.printStackTrace();
32
        }
33
    }
34
}