Browse Source

单位人员信息表

zhuhaiwen 3 years ago
parent
commit
eaca03020c

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

@ -54,4 +54,14 @@ public interface IAssignRepository extends JpaRepository<Assign, String>, JpaSpe
54 54
    @Query("select ass from Assign ass where ass.exam_id = :exam_id and ass.place_id = :place_id")
55 55
    List<Assign> findAllByPlace_id(@Param("exam_id") String exam_id, @Param("place_id") String place_id);
56 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
57 67
}

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

+ 14 - 0
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.UPExportReq;
7 8
import com.css.oa.exam.report.bean.UPReq;
8 9
import com.css.oa.exam.report.service.ReportService;
9 10
import com.css.oa.utils.Result;
@ -87,6 +88,19 @@ public class ReportController extends BaseController {
87 88
        }
88 89
        return result;
89 90
    }
91
    @ApiOperation(value = "统计报表-单位人员信息表-导出")
92
    @PostMapping("/up_export")
93
    public void up_export(HttpServletResponse response, @RequestBody UPExportReq req) {
94
        try {
95
            if (TextUtils.isEmpty(req.exam_id)) {
96
                exportPrint(response, "exam_id不能为空");
97
            }
98
            mService.up_export(response, req);
99
        } catch (Exception e) {
100
            System.out.println(e.getMessage());
101
            exportPrint(response, e.getMessage());
102
        }
103
    }
90 104
91 105
    @ApiOperation(value = "统计报表-考点考场统计一览表")
92 106
    @GetMapping("/place_room_multi")

+ 67 - 15
oa-app/src/main/java/com/css/oa/exam/report/service/ReportService.java

@ -17,14 +17,13 @@ import com.css.oa.exam.exam.repository.Exam;
17 17
import com.css.oa.exam.exam.repository.IExamRepository;
18 18
import com.css.oa.exam.place.repository.IPlaceRepository;
19 19
import com.css.oa.exam.place.repository.Place;
20
import com.css.oa.exam.report.bean.PRPExcelEntity;
21
import com.css.oa.exam.report.bean.PRPExportReq;
22
import com.css.oa.exam.report.bean.PRPReq;
23
import com.css.oa.exam.report.bean.UPReq;
20
import com.css.oa.exam.report.bean.*;
24 21
import com.css.oa.exam.room.repository.IRoomRepository;
25 22
import com.css.oa.exam.score.bean.AnalyseColumn;
26 23
import com.css.oa.exam.student.repository.IStudentRepository;
27 24
import com.css.oa.exam.student.repository.Student;
25
import com.css.oa.exam.unit.repository.IUnitRepository;
26
import com.css.oa.exam.unit.repository.Unit;
28 27
import com.css.oa.exam.util.CopyObjTool;
29 28
import com.css.oa.exam.util.ExcelDelegate;
30 29
import com.css.oa.exam.util.ExportHelper;
@ -38,6 +37,7 @@ import org.springframework.beans.BeanUtils;
38 37
import org.springframework.beans.factory.annotation.Autowired;
39 38
import org.springframework.data.domain.Page;
40 39
import org.springframework.data.domain.PageRequest;
40
import org.springframework.data.domain.Sort;
41 41
import org.springframework.data.jpa.domain.Specification;
42 42
import org.springframework.stereotype.Service;
43 43
@ -126,7 +126,7 @@ public class ReportService extends BaseService implements IReportService {
126 126
    IPlaceRepository placeRepository;
127 127
128 128
    public void prp_export(HttpServletResponse response, PRPExportReq req) {
129
        //查询所有考点
129
        //查询这个考试里边的所有考点
130 130
        List<Place> places = placeRepository.findAllByExam_id(req.exam_id);
131 131
132 132
        List<Map<String, Object>> sheetsList = new ArrayList<>();
@ -172,20 +172,26 @@ public class ReportService extends BaseService implements IReportService {
172 172
                    Predicate exam_id = criteriaBuilder.equal(root.get("exam_id").as(String.class), req.exam_id);
173 173
                    predicateList.add(exam_id);
174 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
//                }
175
                if (stuIds.size() > 0) {
176
                    Path<String> path = root.get("student_id");//定义查询的字段
177
                    CriteriaBuilder.In<String> in = criteriaBuilder.in(path);
178
                    for (int i = 0; i < stuIds.size(); i++) {
179
                        in.value(stuIds.get(i));//存入值
180
                    }
181
                    predicateList.add(in);
182
                }
184 183
                Predicate[] pre = new Predicate[predicateList.size()];
185 184
                pre = predicateList.toArray(pre);
186
                return criteriaQuery.where(pre).getRestriction();
185
186
                Order place_order = criteriaBuilder.asc(root.get("place_id"));
187
                Order room_order = criteriaBuilder.asc(root.get("room_id"));
188
                criteriaQuery.orderBy(place_order, room_order);
189
                criteriaQuery.where(pre);
190
                return criteriaQuery.getRestriction();
187 191
            }
188 192
        };
193
//        Sort sort = Sort.by(Sort.Direction.ASC, "place_id");
194
//        PageRequest pageReques = PageRequest.of(req.curPage, req.pageSize, sort);
189 195
        PageRequest pageReques = PageRequest.of(req.curPage, req.pageSize);
190 196
        Page<Assign> pages = assignRepository.findAll(spec, pageReques);
191 197
        List<Assign> list = pages.getContent();
@ -196,4 +202,50 @@ public class ReportService extends BaseService implements IReportService {
196 202
        map.put("list", list);
197 203
        return map;
198 204
    }
205
206
    @Autowired
207
    IUnitRepository unitRepository;
208
209
    public void up_export(HttpServletResponse response, UPExportReq req) {
210
        //查询这个考试里边的所有单位
211
        List<String> stuIds = assignRepository.findStuIdsByExam_id(req.exam_id);
212
        List<String> unitIDs = studentRepository.findUnitsByUuids(stuIds);
213
        List<Unit> units = unitRepository.findAllById(unitIDs);
214
        List<Student> stus = studentRepository.findAllById(stuIds);
215
216
        List<Map<String, Object>> sheetsList = new ArrayList<>();
217
        for (int i = 0; i < units.size(); i++) {
218
            Unit unit = units.get(i);
219
            //这个考试里边,某个单位下的所有考生
220
            List<String> thisUnitStuIds = new ArrayList<>();
221
            for (int j = 0; j < stus.size(); j++) {
222
                if(stus.get(i).unit_id.equalsIgnoreCase(unit.uuid)){
223
                    thisUnitStuIds.add(stus.get(j).uuid);
224
                }
225
            }
226
            List<Assign> list = assignRepository.findByThisUnitStuIds(req.exam_id, thisUnitStuIds);
227
            setAssignProperties(list);
228
            List<PRPExcelEntity> beans = new ArrayList<>();
229
            for (Assign assign : list) {
230
                PRPExcelEntity entity = new PRPExcelEntity();
231
                BeanUtils.copyProperties(assign, entity);
232
                beans.add(entity);
233
            }
234
            ExportParams exportParams = new ExportParams();
235
            exportParams.setSheetName(unit.name);
236
            // 创建sheet1使用得map
237
            Map<String, Object> oneSheet = new HashMap<>();
238
            // title的参数为ExportParams类型,目前仅仅在ExportParams中设置了sheetName
239
            oneSheet.put("title", exportParams);
240
            // 模版导出对应得实体类型
241
            oneSheet.put("entity", PRPExcelEntity.class);
242
            // sheet中要填充得数据
243
            oneSheet.put("data", beans);
244
            sheetsList.add(oneSheet);
245
        }
246
        // 执行方法
247
        Workbook workBook = ExcelExportUtil.exportExcel(sheetsList, ExcelType.HSSF);
248
        workBook.createCellStyle().setLocked(true);
249
        ExcelDelegate.exportExcel(workBook, "单位人员信息表.xls", response);
250
    }
199 251
}

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

@ -39,4 +39,9 @@ public interface IStudentRepository extends JpaRepository<Student, String>, JpaS
39 39
    @Query("select stu.uuid from Student stu where stu.unit_id = :unit_id")
40 40
    List<String> findStuIdsByUnit_id(@Param("unit_id") String unit_id);
41 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
42 47
}