Răsfoiți Sursa

考生查询和导出

xiatian 4 ani în urmă
părinte
comite
86a9a7cddc

+ 316 - 223
themis-backend/src/main/java/com/qmth/themis/backend/api/TEExamStudentController.java

@@ -1,5 +1,29 @@
 package com.qmth.themis.backend.api;
 
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+import java.util.function.Function;
+import java.util.stream.Collectors;
+
+import javax.annotation.Resource;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.commons.lang3.StringUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.transaction.annotation.Transactional;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.multipart.MultipartFile;
+
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
@@ -11,26 +35,40 @@ import com.qmth.themis.business.config.SystemConfig;
 import com.qmth.themis.business.constant.SystemConstant;
 import com.qmth.themis.business.dto.MqDto;
 import com.qmth.themis.business.dto.response.TEExamStudentDto;
-import com.qmth.themis.business.entity.*;
-import com.qmth.themis.business.enums.*;
-import com.qmth.themis.business.service.*;
+import com.qmth.themis.business.entity.TBAttachment;
+import com.qmth.themis.business.entity.TBExamInvigilateUser;
+import com.qmth.themis.business.entity.TBOrg;
+import com.qmth.themis.business.entity.TBTaskHistory;
+import com.qmth.themis.business.entity.TBUser;
+import com.qmth.themis.business.entity.TEExam;
+import com.qmth.themis.business.entity.TEExamActivity;
+import com.qmth.themis.business.entity.TEExamStudent;
+import com.qmth.themis.business.entity.TEStudent;
+import com.qmth.themis.business.enums.MqTagEnum;
+import com.qmth.themis.business.enums.MqTopicEnum;
+import com.qmth.themis.business.enums.TaskStatusEnum;
+import com.qmth.themis.business.enums.TaskTypeEnum;
+import com.qmth.themis.business.enums.UploadFileEnum;
+import com.qmth.themis.business.excel.ExportUtils;
+import com.qmth.themis.business.service.MqDtoService;
+import com.qmth.themis.business.service.TBAttachmentService;
+import com.qmth.themis.business.service.TBExamInvigilateUserService;
+import com.qmth.themis.business.service.TBTaskHistoryService;
+import com.qmth.themis.business.service.TEExamActivityService;
+import com.qmth.themis.business.service.TEExamService;
+import com.qmth.themis.business.service.TEExamStudentService;
+import com.qmth.themis.business.service.TEStudentService;
 import com.qmth.themis.business.util.ServletUtil;
 import com.qmth.themis.common.enums.ExceptionResultEnum;
 import com.qmth.themis.common.exception.BusinessException;
 import com.qmth.themis.common.util.Result;
 import com.qmth.themis.common.util.ResultUtil;
-import io.swagger.annotations.*;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.transaction.annotation.Transactional;
-import org.springframework.web.bind.annotation.*;
-import org.springframework.web.multipart.MultipartFile;
 
-import javax.annotation.Resource;
-import java.io.IOException;
-import java.util.*;
-import java.util.function.Function;
-import java.util.stream.Collectors;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import io.swagger.annotations.ApiParam;
+import io.swagger.annotations.ApiResponse;
+import io.swagger.annotations.ApiResponses;
 
 /**
  * @Description: 考生库 前端控制器
@@ -43,213 +81,268 @@ import java.util.stream.Collectors;
 @RestController
 @RequestMapping("/${prefix.url.admin}/examStudent")
 public class TEExamStudentController {
-    private final static Logger log = LoggerFactory.getLogger(TEExamStudentController.class);
-
-    @Resource
-    TEExamStudentService teExamStudentService;
-
-    @Resource
-    TBAttachmentService tbAttachmentService;
-
-    @Resource
-    TBTaskHistoryService taskHistoryService;
-
-    @Resource
-    TEExamService teExamService;
-
-    @Resource
-    TEExamActivityService teExamActivityService;
-
-    @Resource
-    TBExamInvigilateUserService tbExamInvigilateUserService;
-
-    @Resource
-    MqDtoService mqDtoService;
-
-    @Resource
-    SystemConfig systemConfig;
-
-    @Resource
-    TEStudentService teStudentService;
-
-    @ApiOperation(value = "考生查询接口")
-    @RequestMapping(value = "/query", method = RequestMethod.POST)
-    @ApiResponses({@ApiResponse(code = 200, message = "考生信息", response = TEExamStudentDto.class)})
-    public Result query(@ApiParam(value = "考试批次id", required = true) @RequestParam Long examId, @ApiParam(value = "考试场次id", required = false) @RequestParam(required = false) Long activityId, @ApiParam(value = "证件号", required = false) @RequestParam(required = false) String identity, @ApiParam(value = "姓名", required = false) @RequestParam(required = false) String name, @ApiParam(value = "考场代码", required = false) @RequestParam(required = false) String roomCode, @ApiParam(value = "科目代码", required = false) @RequestParam(required = false) String courseCode, @ApiParam(value = "年级", required = false) @RequestParam(required = false) String grade, @ApiParam(value = "是否启用", required = false) @RequestParam(required = false) Integer enable, @ApiParam(value = "教学班级", required = false) @RequestParam(required = false) String classNo, @ApiParam(value = "分页页码", required = true) @RequestParam int pageNumber, @ApiParam(value = "分页数", required = true) @RequestParam int pageSize) {
-        if (Objects.isNull(examId) || Objects.equals(examId, "")) {
-            throw new BusinessException(ExceptionResultEnum.EXAM_ID_IS_NULL);
-        }
-        IPage<TEExamStudentDto> teExamStudentIPage = teExamStudentService.examStudentQuery(new Page<>(pageNumber, pageSize), examId, activityId, identity, name, roomCode, courseCode, grade, enable, classNo);
-        BasePage basePage = new BasePage(teExamStudentIPage.getRecords(), teExamStudentIPage.getCurrent(), teExamStudentIPage.getSize(), teExamStudentIPage.getTotal());
-        return ResultUtil.ok(basePage);
-    }
-
-    @ApiOperation(value = "考生停用/启用接口")
-    @RequestMapping(value = "/toggle", method = RequestMethod.POST)
-    @ApiResponses({@ApiResponse(code = 200, message = "{\"success\":true}", response = Result.class)})
-    @Transactional
-    public Result examStudentToggle(@ApiJsonObject(name = "examStudentToggle", value = {
-            @ApiJsonProperty(key = "id", type = "long", example = "1", description = "考生ID"),
-            @ApiJsonProperty(key = "enable", type = "int", example = "1", description = "是否启用")
-    }) @ApiParam(value = "考生信息", required = true) @RequestBody List<Map<String, Object>> mapParameter) {
-        if (Objects.isNull(mapParameter) || mapParameter.size() == 0) {
-            throw new BusinessException(ExceptionResultEnum.EXAM_STUDENT_INFO_IS_NULL);
-        }
-        TBUser tbUser = (TBUser) ServletUtil.getRequestAccount();
-        List<TEExamStudent> teExamStudentList = new ArrayList<>();
-        for (int i = 0; i < mapParameter.size(); i++) {
-            Map map = mapParameter.get(i);
-            TEExamStudent teExamStudent = teExamStudentService.getById(Long.parseLong(String.valueOf(map.get("id"))));
-            if (Objects.isNull(teExamStudent)) {
-                throw new BusinessException(ExceptionResultEnum.EXAM_STUDENT_NO);
-            }
-            teExamStudent.setEnable(Integer.parseInt(String.valueOf(map.get("enable"))));
-            teExamStudent.setUpdateId(tbUser.getId());
-            teExamStudentList.add(teExamStudent);
-        }
-        teExamStudentService.updateBatchById(teExamStudentList);
-        teExamStudentList.forEach(s -> {
-            teExamStudentService.updateExamStudentCacheBean(s.getId());
-        });
-        return ResultUtil.ok(Collections.singletonMap("success", true));
-    }
-
-    @ApiOperation(value = "考生修改接口")
-    @RequestMapping(value = "/save", method = RequestMethod.POST)
-    @ApiResponses({@ApiResponse(code = 200, message = "{\"success\":true}", response = Result.class)})
-    @Transactional
-    public Result save(@ApiParam(value = "考生信息", required = true) @RequestBody List<TEExamStudent> teExamStudentList) {
-        if (Objects.isNull(teExamStudentList) || teExamStudentList.size() == 0) {
-            throw new BusinessException(ExceptionResultEnum.EXAM_STUDENT_INFO_IS_NULL);
-        }
-        TBUser tbUser = (TBUser) ServletUtil.getRequestAccount();
-        TBOrg tbOrg = (TBOrg) ServletUtil.getRequestOrg();
-        teExamStudentList.forEach(s -> {
-            if (Objects.isNull(s.getId())) {
-                QueryWrapper<TEStudent> teExamStudentQueryWrapper = new QueryWrapper<>();
-                teExamStudentQueryWrapper.lambda().eq(TEStudent::getName, s.getName())
-                        .eq(TEStudent::getIdentity, s.getIdentity())
-                        .eq(TEStudent::getOrgId, tbOrg.getId());
-                int count = teStudentService.count(teExamStudentQueryWrapper);
-                if (count == 0) {
-                    TEStudent teStudent = new TEStudent(tbOrg.getId(), s.getIdentity(), s.getName(), tbUser.getId());
-                    teStudentService.save(teStudent);
-                    s.setStudentId(teStudent.getId());
-                    s.setCreateId(tbUser.getId());
-                }
-            } else {
-                UpdateWrapper<TEExamStudent> teExamStudentUpdateWrapper = new UpdateWrapper<>();
-                teExamStudentUpdateWrapper.lambda().set(TEExamStudent::getName, s.getName())
-                        .eq(TEExamStudent::getIdentity, s.getIdentity());
-                teExamStudentService.update(teExamStudentUpdateWrapper);
-
-                UpdateWrapper<TEStudent> teStudentUpdateWrapper = new UpdateWrapper<>();
-                teStudentUpdateWrapper.lambda().set(TEStudent::getName, s.getName())
-                        .eq(TEStudent::getIdentity, s.getIdentity());
-                teStudentService.update(teStudentUpdateWrapper);
-
-                s.setUpdateId(tbUser.getId());
-            }
-        });
-        teExamStudentService.saveOrUpdateBatch(teExamStudentList);
-        teExamStudentList.forEach(s -> {
-            teExamStudentService.updateExamStudentCacheBean(s.getId());
-        });
-        return ResultUtil.ok(Collections.singletonMap("success", true));
-    }
-
-    @ApiOperation(value = "考生删除接口")
-    @RequestMapping(value = "/delete", method = RequestMethod.POST)
-    @ApiResponses({@ApiResponse(code = 200, message = "{\"success\":true}", response = Result.class)})
-    @Transactional
-    public Result delete(@ApiParam(value = "考生id", required = true) @RequestBody List<Long> ids) {
-        if (Objects.isNull(ids) || ids.size() == 0) {
-            throw new BusinessException(ExceptionResultEnum.EXAM_STUDENT_ID_IS_NULL);
-        }
-        teExamStudentService.removeByIds(ids);
-        ids.forEach(s -> {
-            teExamStudentService.deleteExamStudentCacheBean(s);
-        });
-        return ResultUtil.ok(Collections.singletonMap("success", true));
-    }
-
-    @ApiOperation(value = "考生导入接口")
-    @RequestMapping(value = "/import", method = RequestMethod.POST)
-    @Transactional
-    @ApiResponses({@ApiResponse(code = 200, message = "{\"taskId\":0}", response = Result.class)})
-    public Result importData(@ApiParam(value = "上传文件", required = true) @RequestParam MultipartFile file, @ApiParam(value = "考试批次id", required = true) @RequestParam Long examId) throws IOException {
-        if (Objects.isNull(file) || Objects.equals(file, "")) {
-            throw new BusinessException(ExceptionResultEnum.ATTACHMENT_IS_NULL);
-        }
-        if (Objects.isNull(examId) || Objects.equals(examId, "")) {
-            throw new BusinessException(ExceptionResultEnum.EXAM_ID_IS_NULL);
-        }
-        Map<String, Object> mapParameter = systemConfig.getOssEnv(UploadFileEnum.file.getId());
-        TBAttachment tbAttachment = null;
-        TBTaskHistory tbTaskHistory = null;
-        Map transMap = new HashMap();
-        try {
-            TBUser tbUser = (TBUser) ServletUtil.getRequestAccount();
-            tbAttachment = tbAttachmentService.saveAttachment(file, ServletUtil.getRequestMd5(), ServletUtil.getRequestPath(), mapParameter, tbUser.getOrgId(), tbUser.getId());
-            if (Objects.isNull(tbAttachment)) {
-                throw new BusinessException(ExceptionResultEnum.ATTACHMENT_ERROR);
-            } else {
-                //往任务表里插一条数据
-                tbTaskHistory = new TBTaskHistory(TaskTypeEnum.IMPORT_EXAM_STUDENT, examId, TaskStatusEnum.INIT, SystemConstant.IMPORT_INIT, 0d, tbAttachment.getName(), tbAttachment.getRemark(), tbUser.getId());
-                taskHistoryService.save(tbTaskHistory);
-                transMap.put("tbTaskHistory", tbTaskHistory);
-            }
-            transMap.put("examId", examId);
-            transMap.put("createId", tbUser.getId());
-
-            //先查询考试相关信息
-            TEExam teExam = teExamService.getById(examId);
-            if (Objects.isNull(teExam)) {
-                throw new BusinessException(ExceptionResultEnum.EXAM_NO);
-            }
-            transMap.put("mode", teExam.getMode());
-            transMap.put("orgId", teExam.getOrgId());
-            transMap.put("examCount", teExam.getExamCount());
-
-            //获取该批次下的所有考场,校验考场id是否存在
-            QueryWrapper<TEExamActivity> teExamActivityQueryWrapper = new QueryWrapper<>();
-            teExamActivityQueryWrapper.lambda().eq(TEExamActivity::getExamId, examId);
-            List<TEExamActivity> teExamActivityList = teExamActivityService.list(teExamActivityQueryWrapper);
-            if (Objects.isNull(teExamActivityList) || teExamActivityList.size() == 0) {
-                throw new BusinessException(ExceptionResultEnum.EXAM_ACTIVITY_NO);
-            }
-            Map<String, TEExamActivity> teExamActivityMap = teExamActivityList.stream().collect(Collectors.toMap(TEExamActivity::getCode, Function.identity(), (dto1, dto2) -> dto1));
-            transMap.put("teExamActivityMap", teExamActivityMap);
-
-            //获取考场代码和考场名称
-            QueryWrapper<TBExamInvigilateUser> tbExamInvigilateUserQueryWrapper = new QueryWrapper<>();
-            tbExamInvigilateUserQueryWrapper.lambda().eq(TBExamInvigilateUser::getOrgId, teExam.getOrgId());
-            List<TBExamInvigilateUser> tbExamInvigilateUserList = tbExamInvigilateUserService.list(tbExamInvigilateUserQueryWrapper);
-            if (Objects.nonNull(tbExamInvigilateUserList) && tbExamInvigilateUserList.size() > 0) {
-                Map<String, String> tbExamInvigilateUserMap = new HashMap();
-                tbExamInvigilateUserList.forEach(s -> {
-                    tbExamInvigilateUserMap.put(s.getExamId() + ":" + s.getRoomCode() + ":" + s.getRoomName(), s.getRoomCode() + ":" + s.getRoomName());
-                });
-                transMap.put("tbExamInvigilateUserMap", tbExamInvigilateUserMap);
-            }
-            transMap.put("remark", tbAttachment.getRemark());
-            //mq发送消息start
-            MqDto mqDto = new MqDto(MqTopicEnum.themisTopic.getCode(), MqTagEnum.EXAM_STUDENT_IMPORT.name(), transMap, MqTagEnum.EXAM_STUDENT_IMPORT, String.valueOf(tbTaskHistory.getId()), tbUser.getName());
-            mqDtoService.assembleSendOneWayMsg(mqDto);
-            //mq发送消息end
-        } catch (Exception e) {
-            log.error("请求出错", e);
-            if (Objects.nonNull(tbAttachment)) {
-                tbAttachmentService.deleteAttachment(mapParameter, tbAttachment);
-            }
-            if (e instanceof BusinessException) {
-                throw new BusinessException(e.getMessage());
-            } else {
-                throw new RuntimeException(e);
-            }
-        }
-        Map map = new HashMap();
-        map.put(SystemConstant.TASK_ID, tbTaskHistory.getId());
-        return ResultUtil.ok(map);
-    }
+	private final static Logger log = LoggerFactory.getLogger(TEExamStudentController.class);
+
+	@Resource
+	TEExamStudentService teExamStudentService;
+
+	@Resource
+	TBAttachmentService tbAttachmentService;
+
+	@Resource
+	TBTaskHistoryService taskHistoryService;
+
+	@Resource
+	TEExamService teExamService;
+
+	@Resource
+	TEExamActivityService teExamActivityService;
+
+	@Resource
+	TBExamInvigilateUserService tbExamInvigilateUserService;
+
+	@Resource
+	MqDtoService mqDtoService;
+
+	@Resource
+	SystemConfig systemConfig;
+
+	@Resource
+	TEStudentService teStudentService;
+	
+    @ApiOperation(value = "考生导出")
+	@RequestMapping(value = "/export", method = RequestMethod.POST)
+    public void export(@ApiParam(value = "考试批次id", required = true) @RequestParam Long examId,
+			@ApiParam(value = "考试场次id", required = false) @RequestParam(required = false) Long activityId,
+			@ApiParam(value = "证件号", required = false) @RequestParam(required = false) String identity,
+			@ApiParam(value = "姓名", required = false) @RequestParam(required = false) String name,
+			@ApiParam(value = "考场代码", required = false) @RequestParam(required = false) String roomCode,
+			@ApiParam(value = "科目代码", required = false) @RequestParam(required = false) String courseCode,
+			@ApiParam(value = "年级", required = false) @RequestParam(required = false) String grade,
+			@ApiParam(value = "是否启用", required = false) @RequestParam(required = false) Integer enable,
+			@ApiParam(value = "教学班级", required = false) @RequestParam(required = false) String classNo,
+			@ApiParam(value = "底照是否上传", required = false) @RequestParam(required = false) Integer hasPhoto,
+			HttpServletResponse response) throws Exception {
+		if (Objects.isNull(examId) || Objects.equals(examId, "")) {
+			throw new BusinessException(ExceptionResultEnum.EXAM_ID_IS_NULL);
+		}
+		List<TEExamStudentDto> list = teExamStudentService.examStudentList(examId, activityId, identity, name, roomCode, courseCode, grade,
+				enable, classNo,hasPhoto);
+		if(list!=null&&list.size()>0) {
+			for(TEExamStudentDto dto:list) {
+				if(StringUtils.isNotBlank(dto.getBasePhotoUrl())) {
+					dto.setBasePhotoUrl(systemConfig.getProperty("aliyun.oss.url") + "/" +dto.getBasePhotoUrl());
+				}
+			}
+		}
+		ExportUtils.exportEXCEL("考生信息", TEExamStudentDto.class, list, response);
+	}
+
+	@ApiOperation(value = "考生查询接口")
+	@RequestMapping(value = "/query", method = RequestMethod.POST)
+	@ApiResponses({ @ApiResponse(code = 200, message = "考生信息", response = TEExamStudentDto.class) })
+	public Result query(@ApiParam(value = "考试批次id", required = true) @RequestParam Long examId,
+			@ApiParam(value = "考试场次id", required = false) @RequestParam(required = false) Long activityId,
+			@ApiParam(value = "证件号", required = false) @RequestParam(required = false) String identity,
+			@ApiParam(value = "姓名", required = false) @RequestParam(required = false) String name,
+			@ApiParam(value = "考场代码", required = false) @RequestParam(required = false) String roomCode,
+			@ApiParam(value = "科目代码", required = false) @RequestParam(required = false) String courseCode,
+			@ApiParam(value = "年级", required = false) @RequestParam(required = false) String grade,
+			@ApiParam(value = "是否启用", required = false) @RequestParam(required = false) Integer enable,
+			@ApiParam(value = "教学班级", required = false) @RequestParam(required = false) String classNo,
+			@ApiParam(value = "底照是否上传", required = false) @RequestParam(required = false) Integer hasPhoto,
+			@ApiParam(value = "分页页码", required = true) @RequestParam int pageNumber,
+			@ApiParam(value = "分页数", required = true) @RequestParam int pageSize) {
+		if (Objects.isNull(examId) || Objects.equals(examId, "")) {
+			throw new BusinessException(ExceptionResultEnum.EXAM_ID_IS_NULL);
+		}
+		IPage<TEExamStudentDto> teExamStudentIPage = teExamStudentService.examStudentQuery(
+				new Page<>(pageNumber, pageSize), examId, activityId, identity, name, roomCode, courseCode, grade,
+				enable, classNo,hasPhoto);
+		if(teExamStudentIPage.getRecords()!=null&&teExamStudentIPage.getRecords().size()>0) {
+			for(TEExamStudentDto dto:teExamStudentIPage.getRecords()) {
+				if(StringUtils.isNotBlank(dto.getBasePhotoUrl())) {
+					dto.setBasePhotoUrl(systemConfig.getProperty("aliyun.oss.url") + "/" +dto.getBasePhotoUrl());
+				}
+			}
+		}
+		BasePage basePage = new BasePage(teExamStudentIPage.getRecords(), teExamStudentIPage.getCurrent(),
+				teExamStudentIPage.getSize(), teExamStudentIPage.getTotal());
+		return ResultUtil.ok(basePage);
+	}
+
+	@ApiOperation(value = "考生停用/启用接口")
+	@RequestMapping(value = "/toggle", method = RequestMethod.POST)
+	@ApiResponses({ @ApiResponse(code = 200, message = "{\"success\":true}", response = Result.class) })
+	@Transactional
+	public Result examStudentToggle(@ApiJsonObject(name = "examStudentToggle", value = {
+			@ApiJsonProperty(key = "id", type = "long", example = "1", description = "考生ID"),
+			@ApiJsonProperty(key = "enable", type = "int", example = "1", description = "是否启用") }) @ApiParam(value = "考生信息", required = true) @RequestBody List<Map<String, Object>> mapParameter) {
+		if (Objects.isNull(mapParameter) || mapParameter.size() == 0) {
+			throw new BusinessException(ExceptionResultEnum.EXAM_STUDENT_INFO_IS_NULL);
+		}
+		TBUser tbUser = (TBUser) ServletUtil.getRequestAccount();
+		List<TEExamStudent> teExamStudentList = new ArrayList<>();
+		for (int i = 0; i < mapParameter.size(); i++) {
+			Map map = mapParameter.get(i);
+			TEExamStudent teExamStudent = teExamStudentService.getById(Long.parseLong(String.valueOf(map.get("id"))));
+			if (Objects.isNull(teExamStudent)) {
+				throw new BusinessException(ExceptionResultEnum.EXAM_STUDENT_NO);
+			}
+			teExamStudent.setEnable(Integer.parseInt(String.valueOf(map.get("enable"))));
+			teExamStudent.setUpdateId(tbUser.getId());
+			teExamStudentList.add(teExamStudent);
+		}
+		teExamStudentService.updateBatchById(teExamStudentList);
+		teExamStudentList.forEach(s -> {
+			teExamStudentService.updateExamStudentCacheBean(s.getId());
+		});
+		return ResultUtil.ok(Collections.singletonMap("success", true));
+	}
+
+	@ApiOperation(value = "考生修改接口")
+	@RequestMapping(value = "/save", method = RequestMethod.POST)
+	@ApiResponses({ @ApiResponse(code = 200, message = "{\"success\":true}", response = Result.class) })
+	@Transactional
+	public Result save(@ApiParam(value = "考生信息", required = true) @RequestBody List<TEExamStudent> teExamStudentList) {
+		if (Objects.isNull(teExamStudentList) || teExamStudentList.size() == 0) {
+			throw new BusinessException(ExceptionResultEnum.EXAM_STUDENT_INFO_IS_NULL);
+		}
+		TBUser tbUser = (TBUser) ServletUtil.getRequestAccount();
+		TBOrg tbOrg = (TBOrg) ServletUtil.getRequestOrg();
+		teExamStudentList.forEach(s -> {
+			if (Objects.isNull(s.getId())) {
+				QueryWrapper<TEStudent> teExamStudentQueryWrapper = new QueryWrapper<>();
+				teExamStudentQueryWrapper.lambda().eq(TEStudent::getName, s.getName())
+						.eq(TEStudent::getIdentity, s.getIdentity()).eq(TEStudent::getOrgId, tbOrg.getId());
+				int count = teStudentService.count(teExamStudentQueryWrapper);
+				if (count == 0) {
+					TEStudent teStudent = new TEStudent(tbOrg.getId(), s.getIdentity(), s.getName(), tbUser.getId());
+					teStudentService.save(teStudent);
+					s.setStudentId(teStudent.getId());
+					s.setCreateId(tbUser.getId());
+				}
+			} else {
+				UpdateWrapper<TEExamStudent> teExamStudentUpdateWrapper = new UpdateWrapper<>();
+				teExamStudentUpdateWrapper.lambda().set(TEExamStudent::getName, s.getName())
+						.eq(TEExamStudent::getIdentity, s.getIdentity());
+				teExamStudentService.update(teExamStudentUpdateWrapper);
+
+				UpdateWrapper<TEStudent> teStudentUpdateWrapper = new UpdateWrapper<>();
+				teStudentUpdateWrapper.lambda().set(TEStudent::getName, s.getName()).eq(TEStudent::getIdentity,
+						s.getIdentity());
+				teStudentService.update(teStudentUpdateWrapper);
+
+				s.setUpdateId(tbUser.getId());
+			}
+		});
+		teExamStudentService.saveOrUpdateBatch(teExamStudentList);
+		teExamStudentList.forEach(s -> {
+			teExamStudentService.updateExamStudentCacheBean(s.getId());
+		});
+		return ResultUtil.ok(Collections.singletonMap("success", true));
+	}
+
+	@ApiOperation(value = "考生删除接口")
+	@RequestMapping(value = "/delete", method = RequestMethod.POST)
+	@ApiResponses({ @ApiResponse(code = 200, message = "{\"success\":true}", response = Result.class) })
+	@Transactional
+	public Result delete(@ApiParam(value = "考生id", required = true) @RequestBody List<Long> ids) {
+		if (Objects.isNull(ids) || ids.size() == 0) {
+			throw new BusinessException(ExceptionResultEnum.EXAM_STUDENT_ID_IS_NULL);
+		}
+		teExamStudentService.removeByIds(ids);
+		ids.forEach(s -> {
+			teExamStudentService.deleteExamStudentCacheBean(s);
+		});
+		return ResultUtil.ok(Collections.singletonMap("success", true));
+	}
+
+	@ApiOperation(value = "考生导入接口")
+	@RequestMapping(value = "/import", method = RequestMethod.POST)
+	@Transactional
+	@ApiResponses({ @ApiResponse(code = 200, message = "{\"taskId\":0}", response = Result.class) })
+	public Result importData(@ApiParam(value = "上传文件", required = true) @RequestParam MultipartFile file,
+			@ApiParam(value = "考试批次id", required = true) @RequestParam Long examId) throws IOException {
+		if (Objects.isNull(file) || Objects.equals(file, "")) {
+			throw new BusinessException(ExceptionResultEnum.ATTACHMENT_IS_NULL);
+		}
+		if (Objects.isNull(examId) || Objects.equals(examId, "")) {
+			throw new BusinessException(ExceptionResultEnum.EXAM_ID_IS_NULL);
+		}
+		Map<String, Object> mapParameter = systemConfig.getOssEnv(UploadFileEnum.file.getId());
+		TBAttachment tbAttachment = null;
+		TBTaskHistory tbTaskHistory = null;
+		Map transMap = new HashMap();
+		try {
+			TBUser tbUser = (TBUser) ServletUtil.getRequestAccount();
+			tbAttachment = tbAttachmentService.saveAttachment(file, ServletUtil.getRequestMd5(),
+					ServletUtil.getRequestPath(), mapParameter, tbUser.getOrgId(), tbUser.getId());
+			if (Objects.isNull(tbAttachment)) {
+				throw new BusinessException(ExceptionResultEnum.ATTACHMENT_ERROR);
+			} else {
+				// 往任务表里插一条数据
+				tbTaskHistory = new TBTaskHistory(TaskTypeEnum.IMPORT_EXAM_STUDENT, examId, TaskStatusEnum.INIT,
+						SystemConstant.IMPORT_INIT, 0d, tbAttachment.getName(), tbAttachment.getRemark(),
+						tbUser.getId());
+				taskHistoryService.save(tbTaskHistory);
+				transMap.put("tbTaskHistory", tbTaskHistory);
+			}
+			transMap.put("examId", examId);
+			transMap.put("createId", tbUser.getId());
+
+			// 先查询考试相关信息
+			TEExam teExam = teExamService.getById(examId);
+			if (Objects.isNull(teExam)) {
+				throw new BusinessException(ExceptionResultEnum.EXAM_NO);
+			}
+			transMap.put("mode", teExam.getMode());
+			transMap.put("orgId", teExam.getOrgId());
+			transMap.put("examCount", teExam.getExamCount());
+
+			// 获取该批次下的所有考场,校验考场id是否存在
+			QueryWrapper<TEExamActivity> teExamActivityQueryWrapper = new QueryWrapper<>();
+			teExamActivityQueryWrapper.lambda().eq(TEExamActivity::getExamId, examId);
+			List<TEExamActivity> teExamActivityList = teExamActivityService.list(teExamActivityQueryWrapper);
+			if (Objects.isNull(teExamActivityList) || teExamActivityList.size() == 0) {
+				throw new BusinessException(ExceptionResultEnum.EXAM_ACTIVITY_NO);
+			}
+			Map<String, TEExamActivity> teExamActivityMap = teExamActivityList.stream()
+					.collect(Collectors.toMap(TEExamActivity::getCode, Function.identity(), (dto1, dto2) -> dto1));
+			transMap.put("teExamActivityMap", teExamActivityMap);
+
+			// 获取考场代码和考场名称
+			QueryWrapper<TBExamInvigilateUser> tbExamInvigilateUserQueryWrapper = new QueryWrapper<>();
+			tbExamInvigilateUserQueryWrapper.lambda().eq(TBExamInvigilateUser::getOrgId, teExam.getOrgId());
+			List<TBExamInvigilateUser> tbExamInvigilateUserList = tbExamInvigilateUserService
+					.list(tbExamInvigilateUserQueryWrapper);
+			if (Objects.nonNull(tbExamInvigilateUserList) && tbExamInvigilateUserList.size() > 0) {
+				Map<String, String> tbExamInvigilateUserMap = new HashMap();
+				tbExamInvigilateUserList.forEach(s -> {
+					tbExamInvigilateUserMap.put(s.getExamId() + ":" + s.getRoomCode() + ":" + s.getRoomName(),
+							s.getRoomCode() + ":" + s.getRoomName());
+				});
+				transMap.put("tbExamInvigilateUserMap", tbExamInvigilateUserMap);
+			}
+			transMap.put("remark", tbAttachment.getRemark());
+			// mq发送消息start
+			MqDto mqDto = new MqDto(MqTopicEnum.themisTopic.getCode(), MqTagEnum.EXAM_STUDENT_IMPORT.name(), transMap,
+					MqTagEnum.EXAM_STUDENT_IMPORT, String.valueOf(tbTaskHistory.getId()), tbUser.getName());
+			mqDtoService.assembleSendOneWayMsg(mqDto);
+			// mq发送消息end
+		} catch (Exception e) {
+			log.error("请求出错", e);
+			if (Objects.nonNull(tbAttachment)) {
+				tbAttachmentService.deleteAttachment(mapParameter, tbAttachment);
+			}
+			if (e instanceof BusinessException) {
+				throw new BusinessException(e.getMessage());
+			} else {
+				throw new RuntimeException(e);
+			}
+		}
+		Map map = new HashMap();
+		map.put(SystemConstant.TASK_ID, tbTaskHistory.getId());
+		return ResultUtil.ok(map);
+	}
 }

+ 8 - 1
themis-business/src/main/java/com/qmth/themis/business/dao/TEExamStudentMapper.java

@@ -43,7 +43,7 @@ public interface TEExamStudentMapper extends BaseMapper<TEExamStudent> {
     public IPage<TEExamStudentDto> examStudentQuery(IPage<Map> iPage, @Param("examId") Long examId,
                                                     @Param("activityId") Long activityId, @Param("identity") String identity, @Param("name") String name,
                                                     @Param("roomCode") String roomCode, @Param("courseCode") String courseCode, @Param("grade") String grade,
-                                                    @Param("enable") Integer enable, @Param("classNo") String classNo);
+                                                    @Param("enable") Integer enable, @Param("classNo") String classNo, @Param("hasPhoto")Integer hasPhoto);
 
     public List<Map<String, Object>> getTotalCount(@Param("examId") Long examId, @Param("activityId") Long activityId,
                                                    @Param("roomCode") String roomCode, @Param("courseCode") String courseCode);
@@ -70,4 +70,11 @@ public interface TEExamStudentMapper extends BaseMapper<TEExamStudent> {
     public IPage<ExamStudentLogListBean> getPageForStudentLog(IPage<ExamStudentLogListBean> iPage, @Param("examId") Long examId,
 			@Param("activityId") Long activityId, @Param("roomCode") String roomCode,
 			@Param("courseCode") String courseCode, @Param("name") String name, @Param("identity") String identity);
+
+	
+    public List<TEExamStudentDto> examStudentList(@Param("examId") Long examId,
+            @Param("activityId") Long activityId, @Param("identity") String identity, @Param("name") String name,
+            @Param("roomCode") String roomCode, @Param("courseCode") String courseCode, @Param("grade") String grade,
+            @Param("enable") Integer enable, @Param("classNo") String classNo, @Param("hasPhoto")Integer hasPhoto);
+
 }

+ 37 - 0
themis-business/src/main/java/com/qmth/themis/business/dto/response/TEExamStudentDto.java

@@ -4,6 +4,8 @@ import io.swagger.annotations.ApiModelProperty;
 
 import java.io.Serializable;
 
+import com.qmth.themis.business.excel.ExcelProperty;
+
 /** 
 * @Description: 考生dto
 * @Param:  
@@ -19,44 +21,59 @@ public class TEExamStudentDto implements Serializable {
     @ApiModelProperty(name = "考试批次名称")
     private String examName;//考试批次名称
 
+    @ExcelProperty(name = "姓名", width = 30, index = 2)
     @ApiModelProperty(name = "考生姓名")
     private String name;//考生姓名
 
+    @ExcelProperty(name = "证件号", width = 30, index = 3)
     @ApiModelProperty(name = "证件号")
     private String identity;//证件号
 
     @ApiModelProperty(name = "考试场次代码")
     private String code;//考试场次代码
 
+    @ExcelProperty(name = "科目代码", width = 30, index = 5)
     @ApiModelProperty(name = "科目代码")
     private String courseCode;//科目代码
 
+    @ExcelProperty(name = "科目名称", width = 30, index = 4)
     @ApiModelProperty(name = "科目名称")
     private String courseName;//科目名称
 
+    @ExcelProperty(name = "状态", width = 30, index = 6)
+    private String enableText;
+    
     @ApiModelProperty(name = "考生是否启用,0:停用,1:启用")
     private Integer enable;//考生是否启用
 
+    @ExcelProperty(name = "考场代码", width = 30, index = 7)
     @ApiModelProperty(name = "考场代码")
     private String roomCode;//考场代码
 
+    @ExcelProperty(name = "考场名称", width = 30, index = 8)
     @ApiModelProperty(name = "考场名称")
     private String roomName;//考场名称
 
+    @ExcelProperty(name = "年级", width = 30, index = 9)
     @ApiModelProperty(name = "年级")
     private String grade;//年级
 
+    @ExcelProperty(name = "教学班级", width = 30, index = 10)
     @ApiModelProperty(name = "教学班级")
     private String classNo;//教学班级
 
     @ApiModelProperty(name = "场次id")
     private Long examActivityId;//场次id
 
+    @ExcelProperty(name = "场次代码", width = 30, index = 1)
     @ApiModelProperty(name = "场次代码")
     private String activityCode;//场次代码
 
     @ApiModelProperty(name = "考试批次id")
     private Long examId;//考试批次id
+    
+    @ApiModelProperty(name = "底照url")
+    private String basePhotoUrl;
 
     public Long getExamId() {
         return examId;
@@ -177,4 +194,24 @@ public class TEExamStudentDto implements Serializable {
     public void setClassNo(String classNo) {
         this.classNo = classNo;
     }
+
+	public String getBasePhotoUrl() {
+		return basePhotoUrl;
+	}
+
+	public void setBasePhotoUrl(String basePhotoUrl) {
+		this.basePhotoUrl = basePhotoUrl;
+	}
+
+	public String getEnableText() {
+		if(enable!=null&&enable.intValue()==1) {
+			return "启用";
+		}else {
+			return "停用";
+		}
+		
+	}
+    
+	
+    
 }

+ 58 - 0
themis-business/src/main/java/com/qmth/themis/business/excel/ColumnSetting.java

@@ -0,0 +1,58 @@
+package com.qmth.themis.business.excel;
+
+public class ColumnSetting implements Comparable<ColumnSetting> {
+
+    private String header;
+    private String getMethodName;
+    private int width;
+    private int index;
+
+    public ColumnSetting(String header, String getMethodName, int width, int index) {
+        this.header = header;
+        this.getMethodName = getMethodName;
+        this.width = width;
+        this.index = index;
+    }
+
+    public String getHeader() {
+        return header;
+    }
+
+    public void setHeader(String header) {
+        this.header = header;
+    }
+
+    public String getGetMethodName() {
+        return getMethodName;
+    }
+
+    public void setGetMethodName(String getMethodName) {
+        this.getMethodName = getMethodName;
+    }
+
+    public int getWidth() {
+        return width;
+    }
+
+    public void setWidth(int width) {
+        this.width = width;
+    }
+
+    public int getIndex() {
+        return index;
+    }
+
+    public void setIndex(int index) {
+        this.index = index;
+    }
+
+
+    @Override
+    public int compareTo(ColumnSetting columnSetting) {
+        if (index < columnSetting.getIndex())
+            return - 1 ;
+        if (index > columnSetting.getIndex())
+            return 1 ;
+        return 0 ;
+    }
+}

+ 31 - 0
themis-business/src/main/java/com/qmth/themis/business/excel/ExcelProperty.java

@@ -0,0 +1,31 @@
+package com.qmth.themis.business.excel;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+@Target(ElementType.FIELD)
+@Retention(RetentionPolicy.RUNTIME)
+public @interface ExcelProperty {
+	/**
+	 * 导出时列名
+	 */
+    String name() default "";
+    
+	/**
+	 * 导出时列宽
+	 */
+    int width() default 0;
+	/**
+	 * 排序
+	 */
+    int index();
+    /**
+     * 类型
+     * 0:导入(读excel)
+     * 1:导出(写excel)
+     * 2:导入&导出
+     */
+    int type() default 2;
+}

+ 76 - 0
themis-business/src/main/java/com/qmth/themis/business/excel/ExcelUtils.java

@@ -0,0 +1,76 @@
+package com.qmth.themis.business.excel;
+
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+public abstract class ExcelUtils {
+
+	private Class<?> dataClass;
+	private List<ColumnSetting> columnSettings;
+
+	public ExcelUtils(Class<?> dataClass) {
+		this.dataClass = dataClass;
+		this.columnSettings = getColumnSettings(dataClass);
+	}
+
+	public Class<?> getDataClass() {
+		return dataClass;
+	}
+
+	public void setDataClass(Class<?> dataClass) {
+		this.dataClass = dataClass;
+	}
+
+	public List<ColumnSetting> getColumnSettings() {
+		return columnSettings;
+	}
+
+	public void setColumnSettings(List<ColumnSetting> columnSettings) {
+		this.columnSettings = columnSettings;
+	}
+
+	/**
+	 * 提取ExcelProperty注解类的字段信息
+	 * 
+	 * @param dataClass 需要解析 写入excel的数据类型
+	 * @return
+	 */
+	protected List<ColumnSetting> getColumnSettings(Class<?> dataClass) {
+		List<ColumnSetting> columnSettings = new ArrayList<>();
+		// 先在方法上找ExcelProperty注解
+		Method[] methods = dataClass.getDeclaredMethods();
+		for (Method method : methods) {
+			ExcelProperty exportProperty = method.getAnnotation(ExcelProperty.class);
+			if (exportProperty != null && exportProperty.name().trim().length() > 0) {
+				ColumnSetting columnSetting = new ColumnSetting(exportProperty.name(), method.getName(),
+						exportProperty.width(), exportProperty.index());
+				columnSettings.add(columnSetting);
+			}
+		}
+		// 如果方法上找不到注解,再到属性上找
+		if (columnSettings.size() == 0) {
+			Field[] fields = dataClass.getDeclaredFields();
+			for (Field field : fields) {
+				ExcelProperty exportProperty = field.getAnnotation(ExcelProperty.class);
+				if (exportProperty != null && exportProperty.name().trim().length() > 0) {
+					ColumnSetting columnSetting = new ColumnSetting(exportProperty.name(),
+							"get" + toUpperCaseFirstOne(field.getName()), exportProperty.width(),
+							exportProperty.index());
+					columnSettings.add(columnSetting);
+				}
+			}
+		}
+		Collections.sort(columnSettings);
+		return columnSettings;
+	}
+
+	private static String toUpperCaseFirstOne(String s) {
+		if (Character.isUpperCase(s.charAt(0)))
+			return s;
+		else
+			return (new StringBuilder()).append(Character.toUpperCase(s.charAt(0))).append(s.substring(1)).toString();
+	}
+}

+ 93 - 0
themis-business/src/main/java/com/qmth/themis/business/excel/ExcelWriter.java

@@ -0,0 +1,93 @@
+package com.qmth.themis.business.excel;
+
+import org.apache.poi.ss.usermodel.Cell;
+import org.apache.poi.ss.usermodel.FillPatternType;
+import org.apache.poi.ss.usermodel.Row;
+import org.apache.poi.ss.usermodel.Sheet;
+import org.apache.poi.xssf.usermodel.XSSFCellStyle;
+import org.apache.poi.xssf.usermodel.XSSFColor;
+import org.apache.poi.xssf.usermodel.XSSFRichTextString;
+import org.apache.poi.xssf.usermodel.XSSFWorkbook;
+
+import java.awt.Color;
+import java.io.OutputStream;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.util.Collection;
+import java.util.List;
+
+public class ExcelWriter extends ExcelUtils {
+
+	private XSSFWorkbook workbook;// 工作簿
+
+	private Sheet sheet; // 工作表
+
+	private Row row = null;// 创建一行
+
+	private Cell cell = null;
+
+	private XSSFCellStyle style;
+
+	private XSSFCellStyle style2;
+
+	public ExcelWriter(Class<?> dataClass, String sheetName) {
+		super(dataClass);
+		// 声明一个工作薄
+		// workbook = new SXSSFWorkbook(100);//使用该方法会有权限问题
+		workbook = new XSSFWorkbook();
+		// 生成一个表格
+		sheet = workbook.createSheet(sheetName);
+		// 设置表格默认列宽度为15个字节
+		sheet.setDefaultColumnWidth((short) 15);
+	}
+
+	private List<ColumnSetting> createColumnSettings() {
+		List<ColumnSetting> columnSettings = this.getColumnSettings();
+		// 产生表格标题行
+		row = sheet.createRow(0);
+		for (short i = 0; i < columnSettings.size(); i++) {
+			cell = row.createCell(i);
+			style = workbook.createCellStyle();
+			style.setFillForegroundColor(new XSSFColor(new Color(227, 239, 217)));
+			style.setFillPattern(FillPatternType.SOLID_FOREGROUND);
+			cell.setCellStyle(style);
+			XSSFRichTextString text = new XSSFRichTextString(columnSettings.get(i).getHeader());
+			cell.setCellValue(text);
+			if (columnSettings.get(i).getWidth() > 0) {
+				sheet.setColumnWidth(i, columnSettings.get(i).getWidth() * 256);
+			}
+		}
+		return columnSettings;
+	}
+
+	/**
+	 * 写入excel
+	 *
+	 * @param dataset 数据集合
+	 * @param out     输出流
+	 * @throws SecurityException
+	 * @throws NoSuchMethodException
+	 * @throws InvocationTargetException
+	 * @throws IllegalArgumentException
+	 * @throws IllegalAccessException
+	 */
+	public void write(Collection<?> dataset, OutputStream out) throws Exception {
+		List<ColumnSetting> columnSettings = this.createColumnSettings();
+		int index = 0;
+		for (Object obj : dataset) {
+			index++;
+			row = sheet.createRow(index);// 创建行
+			// 利用反射,根据javabean属性的先后顺序,动态调用getXxx()方法得到属性值
+			for (short i = 0; i < columnSettings.size(); i++) {
+				cell = row.createCell(i);// 创建列
+				cell.setCellStyle(style2);
+				String methodName = columnSettings.get(i).getGetMethodName();
+				Method method = this.getDataClass().getMethod(methodName, new Class[] {});
+				Object value = method.invoke(obj, new Object[] {});
+				cell.setCellValue(value == null ? "" : value.toString());
+			}
+		}
+		workbook.write(out);
+	}
+
+}

+ 44 - 0
themis-business/src/main/java/com/qmth/themis/business/excel/ExportUtils.java

@@ -0,0 +1,44 @@
+package com.qmth.themis.business.excel;
+
+import java.io.OutputStream;
+import java.net.URLEncoder;
+import java.util.Collection;
+
+import javax.servlet.ServletOutputStream;
+import javax.servlet.http.HttpServletResponse;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/*
+ * excel导出工具
+ */
+public class ExportUtils {
+
+	private static final Logger log = LoggerFactory.getLogger(ExportUtils.class);
+	
+    private static final String DEFALUT_CONTENT_TYPE = "application/vnd.ms-excel";
+
+    private static final String DEFALUT_EXT = ".xlsx";
+
+    public static void exportEXCEL(String fileName,Class<?> dataClass,
+                             Collection<?> dataset,HttpServletResponse response) throws Exception {
+    	log.debug("导出Excel开始...");
+        response.setHeader("Content-Disposition","inline;filename="+URLEncoder.encode(fileName, "UTF-8")+DEFALUT_EXT);
+        response.setContentType(DEFALUT_CONTENT_TYPE);
+        ServletOutputStream outputStream = response.getOutputStream();
+    	
+        ExcelWriter excelExporter = new ExcelWriter(dataClass,"sheet1");
+        excelExporter.write(dataset,outputStream);
+        outputStream.flush();
+        outputStream.close();
+        log.debug("导出Excel结束");
+    }
+    
+    public static void makeExcel(Class<?> dataClass,Collection<?> dataset,OutputStream outputStream ) throws Exception {
+		log.debug("生成Excel开始...");
+		ExcelWriter excelExporter = new ExcelWriter(dataClass,"sheet1");
+		excelExporter.write(dataset,outputStream);
+		log.debug("生成Excel结束");
+	}
+}

+ 3 - 1
themis-business/src/main/java/com/qmth/themis/business/service/TEExamStudentService.java

@@ -34,8 +34,10 @@ public interface TEExamStudentService extends IService<TEExamStudent> {
      * @param classNo
      * @return
      */
-    public IPage<TEExamStudentDto> examStudentQuery(IPage<Map> iPage, Long examId, Long activityId, String identity, String name, String roomCode, String courseCode, String grade, Integer enable, String classNo);
+    public IPage<TEExamStudentDto> examStudentQuery(IPage<Map> iPage, Long examId, Long activityId, String identity, String name, String roomCode, String courseCode, String grade, Integer enable, String classNo,Integer hasPhoto);
 
+    public List<TEExamStudentDto> examStudentList(Long examId, Long activityId, String identity, String name, String roomCode, String courseCode, String grade, Integer enable, String classNo,Integer hasPhoto);
+    
     ExamStudentCacheBean getExamStudentCacheBean(Long examStudentId);
 
     /**

+ 8 - 2
themis-business/src/main/java/com/qmth/themis/business/service/impl/TEExamStudentServiceImpl.java

@@ -47,8 +47,8 @@ public class TEExamStudentServiceImpl extends ServiceImpl<TEExamStudentMapper, T
      * @return
      */
     @Override
-    public IPage<TEExamStudentDto> examStudentQuery(IPage<Map> iPage, Long examId, Long activityId, String identity, String name, String roomCode, String courseCode, String grade, Integer enable, String classNo) {
-        return teExamStudentMapper.examStudentQuery(iPage, examId, activityId, identity, name, roomCode, courseCode, grade, enable, classNo);
+    public IPage<TEExamStudentDto> examStudentQuery(IPage<Map> iPage, Long examId, Long activityId, String identity, String name, String roomCode, String courseCode, String grade, Integer enable, String classNo,Integer hasPhoto) {
+        return teExamStudentMapper.examStudentQuery(iPage, examId, activityId, identity, name, roomCode, courseCode, grade, enable, classNo,hasPhoto);
     }
 
     @Cacheable(value = "exam_student", key = "#examStudentId", unless = "#result == null")
@@ -124,4 +124,10 @@ public class TEExamStudentServiceImpl extends ServiceImpl<TEExamStudentMapper, T
         ret.setName(es.getName());
         return ret;
     }
+
+	@Override
+	public List<TEExamStudentDto> examStudentList(Long examId, Long activityId, String identity, String name,
+			String roomCode, String courseCode, String grade, Integer enable, String classNo, Integer hasPhoto) {
+		return teExamStudentMapper.examStudentList(examId, activityId, identity, name, roomCode, courseCode, grade, enable, classNo,hasPhoto);
+	}
 }

+ 76 - 1
themis-business/src/main/resources/mapper/TEExamStudentMapper.xml

@@ -20,9 +20,11 @@
 		tees.grade,
 		tees.class_no as classNo,
 		teea.id as examActivityId,
-		teea.code as activityCode
+		teea.code as activityCode,
+		stu.base_photo_path basePhotoUrl
 		from
 		t_e_exam_student tees
+		left join t_e_student stu on tees.student_id=stu.id
 		left join t_e_exam tee on
 		tees.exam_id = tee.id
 		left join t_e_exam_activity teea on
@@ -55,8 +57,81 @@
 			<if test="classNo != null and classNo != ''">
 				and tees.class_no like concat('%', #{classNo}, '%')
 			</if>
+			<if test="hasPhoto != null and hasPhoto != ''">
+				<if test="hasPhoto == 0">
+					and stu.base_photo_path is null
+				</if>
+				<if test="hasPhoto == 1">
+					and stu.base_photo_path is not null
+				</if>
+			</if>
 		</where>
 	</select>
+	<select id="examStudentList"
+		resultType="com.qmth.themis.business.dto.response.TEExamStudentDto">
+		select
+		tees.id,
+		tee.id as examId,
+		tee.name as examName,
+		tees.name,
+		tees.`identity`,
+		teea.code,
+		tees.course_code as courseCode,
+		tees.course_name as courseName,
+		tees.enable,
+		tees.room_code as roomCode,
+		tees.room_name as roomName,
+		tees.grade,
+		tees.class_no as classNo,
+		teea.id as examActivityId,
+		teea.code as activityCode,
+		stu.base_photo_path basePhotoUrl
+		from
+		t_e_exam_student tees
+		left join t_e_student stu on tees.student_id=stu.id
+		left join t_e_exam tee on
+		tees.exam_id = tee.id
+		left join t_e_exam_activity teea on
+		tees.exam_activity_id = teea.id
+		<where>
+			<if test="examId != null and examId != ''">
+				and tees.exam_id = #{examId}
+			</if>
+			<if test="activityId != null and activityId != ''">
+				and tees.exam_activity_id = #{activityId}
+			</if>
+			<if test="identity != null and identity != ''">
+				and tees.identity like concat('%', #{identity}, '%')
+			</if>
+			<if test="name != null and name != ''">
+				and tees.name like concat('%', #{name}, '%')
+			</if>
+			<if test="roomCode != null and roomCode != ''">
+				and tees.room_code like concat('%', #{roomCode}, '%')
+			</if>
+			<if test="courseCode != null and courseCode != ''">
+				and tees.course_code = #{courseCode}
+			</if>
+			<if test="enable != null and enable != '' or enable == 0">
+				and tees.enable = #{enable}
+			</if>
+			<if test="grade != null and grade != ''">
+				and tees.grade like concat('%', #{grade}, '%')
+			</if>
+			<if test="classNo != null and classNo != ''">
+				and tees.class_no like concat('%', #{classNo}, '%')
+			</if>
+			<if test="hasPhoto != null and hasPhoto != ''">
+				<if test="hasPhoto == 0">
+					and stu.base_photo_path is null
+				</if>
+				<if test="hasPhoto == 1">
+					and stu.base_photo_path is not null
+				</if>
+			</if>
+		</where>
+	</select>
+	
 	<select id="getTotalCount" resultType="java.util.Map">
 		select t.exam_activity_id activityId,count(1) cc from t_e_exam_student
 		t