haogh 1 жил өмнө
parent
commit
239ef23186

+ 22 - 0
src/main/java/com/qmth/exam/reserve/bean/examsite/ExamSiteReq.java

@@ -0,0 +1,22 @@
+package com.qmth.exam.reserve.bean.examsite;
+
+import com.qmth.exam.reserve.bean.IModel;
+import com.qmth.exam.reserve.bean.PagerReq;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Getter;
+import lombok.Setter;
+
+@Getter
+@Setter
+public class ExamSiteReq extends PagerReq {
+
+    @ApiModelProperty("教学点ID")
+    private Long teachingId;
+
+    @ApiModelProperty("考点名称")
+    private String name;
+
+    @ApiModelProperty("状态:启用禁用")
+    private Boolean enable;
+}

+ 32 - 0
src/main/java/com/qmth/exam/reserve/bean/examsite/ExamSiteSaveReq.java

@@ -0,0 +1,32 @@
+package com.qmth.exam.reserve.bean.examsite;
+
+import com.qmth.exam.reserve.bean.IModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Getter;
+import lombok.Setter;
+
+@Getter
+@Setter
+public class ExamSiteSaveReq implements IModel {
+
+    @ApiModelProperty(value = "考点ID",required = false)
+    private Long id;
+
+    @ApiModelProperty(value = "考点代码",required = true)
+    private String code;
+
+    @ApiModelProperty(value = "考点名称",required = true)
+    private String name;
+
+    @ApiModelProperty(value = "考点地址",required = true)
+    private String address;
+
+    @ApiModelProperty(value = "考点所属教学点ID",required = true)
+    private Long categoryId;
+
+    @ApiModelProperty(value = "考点容量",required = false)
+    private Integer capacity;
+
+    @ApiModelProperty(value = "考点状态",required = true)
+    private Boolean enable;
+}

+ 33 - 0
src/main/java/com/qmth/exam/reserve/bean/examsite/ExamSiteVO.java

@@ -0,0 +1,33 @@
+package com.qmth.exam.reserve.bean.examsite;
+
+import com.qmth.exam.reserve.bean.IModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Getter;
+import lombok.Setter;
+
+@Getter
+@Setter
+public class ExamSiteVO implements IModel {
+
+    @ApiModelProperty("考点ID")
+    private Long id;
+
+    @ApiModelProperty("考点代码")
+    private String code;
+
+    @ApiModelProperty("考点名称")
+    private String name;
+
+    @ApiModelProperty("考点地址")
+    private String address;
+
+    @ApiModelProperty("考点所属教学点")
+    private String teachingName;
+
+    @ApiModelProperty("考点容量")
+    private Integer capacity;
+
+    @ApiModelProperty("考点状态")
+    private Boolean enable;
+}
+

+ 27 - 0
src/main/java/com/qmth/exam/reserve/bean/stdapply/AgentAndRoomVO.java

@@ -0,0 +1,27 @@
+package com.qmth.exam.reserve.bean.stdapply;
+
+import com.qmth.exam.reserve.bean.IModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Getter;
+import lombok.Setter;
+
+@Getter
+@Setter
+public class AgentAndRoomVO implements IModel {
+
+    @ApiModelProperty("考点名称")
+    private String agentName;
+
+    @ApiModelProperty("所预约教学点名称")
+    private String teachingName;
+
+    @ApiModelProperty("所预约教学点名称")
+    private String applyTeachingName;
+
+    @ApiModelProperty("考场名称")
+    private String roomName;
+
+    @ApiModelProperty("操作人名称")
+    private String userName;
+
+}

+ 15 - 0
src/main/java/com/qmth/exam/reserve/controller/admin/ExamRoomController.java

@@ -0,0 +1,15 @@
+package com.qmth.exam.reserve.controller.admin;
+
+import com.qmth.boot.api.annotation.Aac;
+import com.qmth.boot.api.constant.ApiConstant;
+import com.qmth.exam.reserve.controller.BaseController;
+import io.swagger.annotations.Api;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+@RestController
+@Api(tags = "【管理端端】考场管理相关接口")
+@RequestMapping(ApiConstant.DEFAULT_URI_PREFIX + "/admin/room")
+@Aac(strict = false, auth = true)
+public class ExamRoomController extends BaseController {
+}

+ 101 - 0
src/main/java/com/qmth/exam/reserve/controller/admin/ExamSiteManageController.java

@@ -0,0 +1,101 @@
+package com.qmth.exam.reserve.controller.admin;
+
+import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
+import com.qmth.boot.api.annotation.Aac;
+import com.qmth.boot.api.constant.ApiConstant;
+import com.qmth.boot.core.collection.PageResult;
+import com.qmth.boot.core.exception.StatusException;
+import com.qmth.exam.reserve.bean.examsite.ExamSiteReq;
+import com.qmth.exam.reserve.bean.examsite.ExamSiteSaveReq;
+import com.qmth.exam.reserve.bean.examsite.ExamSiteVO;
+import com.qmth.exam.reserve.bean.login.LoginUser;
+import com.qmth.exam.reserve.controller.BaseController;
+import com.qmth.exam.reserve.entity.ExamSiteEntity;
+import com.qmth.exam.reserve.enums.Role;
+import com.qmth.exam.reserve.service.ExamSiteService;
+import com.qmth.exam.reserve.util.ResourceUtil;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import io.swagger.annotations.ApiParam;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+import org.springframework.web.multipart.MultipartFile;
+
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+@RestController
+@Api(tags = "【管理端】考点管理相关接口")
+@RequestMapping(ApiConstant.DEFAULT_URI_PREFIX + "/admin/site")
+@Aac(strict = false, auth = true)
+public class ExamSiteManageController extends BaseController {
+
+    @Autowired
+    private ExamSiteService examSiteService;
+
+    @ApiOperation(value = "考点管理分页")
+    @PostMapping(value = "/page")
+    public PageResult<ExamSiteVO> page(@RequestBody ExamSiteReq req) {
+        LoginUser user = curLoginUser();
+        if(user.getRole().equals(Role.TEACHING)) {
+            req.setTeachingId(user.getCategoryId());
+        }
+        return examSiteService.page(req);
+    }
+
+    @ApiOperation(value = "考点管理查询")
+    @PostMapping(value = "/find")
+    @Aac(strict = false, auth = false)
+    public ExamSiteEntity find(@ApiParam("考点ID") @RequestParam Long id) {
+        return examSiteService.getById(id);
+    }
+
+    @ApiOperation(value = "考点新增/编辑")
+    @PostMapping(value = "/save")
+    public void save(@RequestBody ExamSiteSaveReq req) {
+        LoginUser user = curLoginUser();
+        examSiteService.saveExamSite(user, req);
+    }
+
+    @ApiOperation(value = "考点启用/禁用")
+    @PostMapping(value = "/enable")
+    public void enable(@ApiParam("考点ID") @RequestParam Long id, @ApiParam("启用/禁用") @RequestParam Boolean enable) {
+        examSiteService.enable(id, enable);
+    }
+
+    @ApiOperation(value = "考点指引")
+    @PostMapping(value = "/guide")
+    @Aac(strict = false, auth = false)
+    public String guide(@ApiParam("考点ID") @RequestParam Long id) {
+        ExamSiteEntity examSite = examSiteService.getById(id);
+        return examSite.getGuide();
+    }
+
+
+    @ApiOperation(value = "考点模版下载")
+    @PostMapping(value = "/import/template")
+    public void download() {
+        exportFile("考点模板.xlsx", ResourceUtil.getStream("templates/examSite.xlsx"));
+    }
+
+    @ApiOperation(value = "考点导入")
+    @PostMapping(value = "/import")
+    public Map<String, Object> importExamSite(@RequestParam MultipartFile file) {
+        LoginUser user = this.curLoginUser();
+        if (!Role.ADMIN.equals(user.getRole())) {
+            throw new StatusException("没有权限");
+        }
+        List<Map<String, Object>> failRecords;
+        try {
+            failRecords = examSiteService.importExamSite(user,file.getInputStream());
+        } catch (IOException e) {
+            throw new StatusException("文件读取出错", e);
+        }
+        Map<String, Object> map = new HashMap<>();
+        map.put("hasError", CollectionUtils.isNotEmpty(failRecords));
+        map.put("failRecords", failRecords);
+        return map;
+    }
+}

+ 5 - 0
src/main/java/com/qmth/exam/reserve/dao/ExamSiteDao.java

@@ -1,7 +1,11 @@
 package com.qmth.exam.reserve.dao;
 
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.qmth.exam.reserve.bean.examsite.ExamSiteCacheBean;
+import com.qmth.exam.reserve.bean.examsite.ExamSiteReq;
+import com.qmth.exam.reserve.bean.examsite.ExamSiteVO;
 import com.qmth.exam.reserve.entity.ExamSiteEntity;
 import org.apache.ibatis.annotations.Param;
 
@@ -11,4 +15,5 @@ public interface ExamSiteDao extends BaseMapper<ExamSiteEntity> {
 
     ExamSiteCacheBean findInfoById(@Param("examSiteId") Long examSiteId);
 
+    IPage<ExamSiteVO> page(Page<ExamSiteVO> page, @Param("req") ExamSiteReq req);
 }

+ 3 - 0
src/main/java/com/qmth/exam/reserve/dao/StudentApplyDao.java

@@ -5,10 +5,12 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.qmth.exam.reserve.bean.apply.ApplyVO;
 import com.qmth.exam.reserve.bean.apply.TicketInfo;
+import com.qmth.exam.reserve.bean.stdapply.AgentAndRoomVO;
 import com.qmth.exam.reserve.bean.stdapply.StudentApplyReq;
 import com.qmth.exam.reserve.bean.stdapply.StudentApplyVO;
 import com.qmth.exam.reserve.entity.StudentApplyEntity;
 import org.apache.ibatis.annotations.Param;
+import org.bouncycastle.its.asn1.IValue;
 
 import java.util.List;
 
@@ -36,4 +38,5 @@ public interface StudentApplyDao extends BaseMapper<StudentApplyEntity> {
 
     Integer getNoApplyCount(@Param(value = "taskId") Long taskId, @Param(value = "categoryId") Long categoryId, @Param(value = "timePeriodIds") List<Long> timePeriodIds);
 
+    AgentAndRoomVO getAgentAndRoom(@Param("id") Long id);
 }

+ 14 - 0
src/main/java/com/qmth/exam/reserve/service/ExamSiteService.java

@@ -1,11 +1,18 @@
 package com.qmth.exam.reserve.service;
 
 import com.baomidou.mybatisplus.extension.service.IService;
+import com.qmth.boot.core.collection.PageResult;
 import com.qmth.exam.reserve.bean.examsite.ExamSiteInfo;
+import com.qmth.exam.reserve.bean.examsite.ExamSiteReq;
+import com.qmth.exam.reserve.bean.examsite.ExamSiteSaveReq;
+import com.qmth.exam.reserve.bean.examsite.ExamSiteVO;
+import com.qmth.exam.reserve.bean.login.LoginUser;
 import com.qmth.exam.reserve.bean.stdapply.CategoryVO;
 import com.qmth.exam.reserve.entity.ExamSiteEntity;
 
+import java.io.InputStream;
 import java.util.List;
+import java.util.Map;
 
 public interface ExamSiteService extends IService<ExamSiteEntity> {
 
@@ -15,4 +22,11 @@ public interface ExamSiteService extends IService<ExamSiteEntity> {
 
     int countExamSiteCapacityById(Long examSiteId);
 
+    PageResult<ExamSiteVO> page(ExamSiteReq req);
+
+    void saveExamSite(LoginUser user, ExamSiteSaveReq req);
+
+    void enable(Long id, Boolean enable);
+
+    List<Map<String, Object>> importExamSite(LoginUser user, InputStream inputStream);
 }

+ 187 - 2
src/main/java/com/qmth/exam/reserve/service/impl/ExamSiteServiceImpl.java

@@ -2,21 +2,44 @@ package com.qmth.exam.reserve.service.impl;
 
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.qmth.boot.core.collection.PageResult;
+import com.qmth.boot.core.exception.StatusException;
+import com.qmth.boot.tools.excel.ExcelReader;
+import com.qmth.boot.tools.excel.enums.ExcelType;
+import com.qmth.boot.tools.excel.model.DataMap;
 import com.qmth.exam.reserve.bean.examsite.ExamSiteInfo;
+import com.qmth.exam.reserve.bean.examsite.ExamSiteReq;
+import com.qmth.exam.reserve.bean.examsite.ExamSiteSaveReq;
+import com.qmth.exam.reserve.bean.examsite.ExamSiteVO;
+import com.qmth.exam.reserve.bean.login.LoginUser;
 import com.qmth.exam.reserve.bean.stdapply.CategoryVO;
 import com.qmth.exam.reserve.dao.ExamSiteDao;
+import com.qmth.exam.reserve.entity.CategoryEntity;
 import com.qmth.exam.reserve.entity.ExamSiteEntity;
+import com.qmth.exam.reserve.service.CategoryService;
 import com.qmth.exam.reserve.service.ExamSiteService;
+import com.qmth.exam.reserve.util.PageUtil;
 import org.apache.commons.collections4.CollectionUtils;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.BeanUtils;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
+import org.springframework.transaction.interceptor.TransactionAspectSupport;
 
-import java.util.ArrayList;
-import java.util.List;
+import java.io.InputStream;
+import java.util.*;
 
 @Service
 public class ExamSiteServiceImpl extends ServiceImpl<ExamSiteDao, ExamSiteEntity> implements ExamSiteService {
 
+    private static final String[] EXCEL_HEADER = new String[]{"考点代码", "考点名称", "所属教学点", "考点地址"};
+
+    @Autowired
+    private CategoryService categoryService;
+
     @Override
     public List<CategoryVO> listExamSite(Long teachingId) {
         QueryWrapper<ExamSiteEntity> wrapper = new QueryWrapper<>();
@@ -66,4 +89,166 @@ public class ExamSiteServiceImpl extends ServiceImpl<ExamSiteDao, ExamSiteEntity
         return capacity != null ? capacity : 0;
     }
 
+    @Override
+    public PageResult<ExamSiteVO> page(ExamSiteReq req) {
+        IPage<ExamSiteVO> iPage = baseMapper.page(new Page<>(req.getPageNumber(), req.getPageSize()),
+                req);
+        return PageUtil.of(iPage);
+    }
+
+    @Override
+    public void saveExamSite(LoginUser user, ExamSiteSaveReq req) {
+        checkExamSite(req);
+        ExamSiteEntity site = new ExamSiteEntity();
+        BeanUtils.copyProperties(req, site);
+        if(req.getId() == null) {
+            LambdaQueryWrapper<ExamSiteEntity> wrapper = new LambdaQueryWrapper<>();
+            wrapper.eq(ExamSiteEntity::getCategoryId, req.getCategoryId());
+            wrapper.eq(ExamSiteEntity::getCode, req.getCode());
+            ExamSiteEntity existSite = baseMapper.selectOne(wrapper);
+            if (existSite != null) {
+                throw new StatusException("code:" + req.getCode() + "已经存在");
+            }
+            save(site);
+        } else {
+            updateById(site);
+        }
+    }
+
+    @Override
+    public void enable(Long id, Boolean enable) {
+        ExamSiteEntity examSite = getById(id);
+        examSite.setEnable(enable);
+        baseMapper.updateById(examSite);
+    }
+
+    @Override
+    public List<Map<String, Object>> importExamSite(LoginUser user, InputStream inputStream) {
+        List<DataMap> lineList = null;
+        ExcelReader reader = ExcelReader.create(ExcelType.XLSX, inputStream, 0);
+        try {
+            lineList = reader.getDataMapList();
+        } catch (Exception e) {
+            throw new StatusException("Excel 解析失败");
+        }
+        if (com.baomidou.mybatisplus.core.toolkit.CollectionUtils.isEmpty(lineList)) {
+            throw new StatusException("Excel无内容");
+        }
+        List<Map<String, Object>> failRecords = new ArrayList<Map<String, Object>>();
+        List<ExamSiteEntity> examSiteList = new ArrayList<>();
+        for (int i = 0; i < lineList.size(); i++) {
+            DataMap line = lineList.get(i);
+            ExamSiteEntity site = new ExamSiteEntity();
+            StringBuilder msg = new StringBuilder();
+            String code = trimAndNullIfBlank(line.get(EXCEL_HEADER[0]));
+            if (StringUtils.isBlank(code)) {
+                msg.append(" 考点代码不能为空");
+            } else {
+                site.setCode(code);
+            }
+            String name = trimAndNullIfBlank(line.get(EXCEL_HEADER[1]));
+            if (StringUtils.isBlank(name)) {
+                msg.append(" 考点名称不能为空");
+            } else {
+                site.setName(name);
+            }
+            String teachingName = trimAndNullIfBlank(line.get(EXCEL_HEADER[2]));
+            if (StringUtils.isBlank(teachingName)) {
+                msg.append(" 所属教学点不能为空");
+            } else {
+                LambdaQueryWrapper<CategoryEntity> wrapper = new LambdaQueryWrapper<>();
+                wrapper.eq(CategoryEntity::getName, teachingName);
+                wrapper.eq(CategoryEntity::getEnable, Boolean.TRUE);
+                wrapper.eq(CategoryEntity::getOrgId, user.getOrgId());
+                List<CategoryEntity> list = categoryService.list(wrapper);
+                if(list.isEmpty()) {
+                    msg.append(" 所属教学点不存在");
+                } else if(list.size() > 1) {
+                    msg.append(" 所属教学点,查询到多条相同名称的数据");
+                } else {
+                    site.setCategoryId(list.get(0).getId());
+                }
+            }
+
+            String address = trimAndNullIfBlank(line.get(EXCEL_HEADER[3]));
+            if (StringUtils.isBlank(address)) {
+                msg.append(" 考点地址不能为空");
+            } else {
+                site.setAddress(address);
+            }
+            if (msg.length() > 0) {
+                failRecords.add(newError(i + 1, msg.toString()));
+            } else {
+                site.setEnable(Boolean.TRUE);
+                examSiteList.add(site);
+            }
+        }
+
+        if (CollectionUtils.isNotEmpty(failRecords)) {
+            return failRecords;
+        }
+
+        for (int i = 0; i < examSiteList.size(); i++) {
+            ExamSiteEntity examSite = examSiteList.get(i);
+            try {
+                saveExamSite(examSite);
+            } catch (Exception e) {
+                failRecords.add(newError(i + 1, " 系统异常"));
+                log.error("导入异常", e);
+            }
+        }
+        if (CollectionUtils.isNotEmpty(failRecords)) {
+            TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
+            return failRecords;
+        }
+        return failRecords;
+    }
+
+    private void saveExamSite(ExamSiteEntity examSite) {
+        LambdaQueryWrapper<ExamSiteEntity> wrapper = new LambdaQueryWrapper<>();
+        wrapper.eq(ExamSiteEntity::getCode, examSite.getCode());
+        wrapper.eq(ExamSiteEntity::getCategoryId, examSite.getCategoryId());
+        ExamSiteEntity existSite = baseMapper.selectOne(wrapper);
+        if (existSite != null) {
+            existSite.setEnable(Boolean.TRUE);
+            existSite.setName(examSite.getName());
+            existSite.setAddress(examSite.getAddress());
+            baseMapper.updateById(existSite);
+        } else {
+            baseMapper.insert(examSite);
+        }
+    }
+
+    private void checkExamSite(ExamSiteSaveReq req) {
+        if(StringUtils.isEmpty(req.getCode())) {
+            throw new StatusException("考点代码不能为空");
+        }
+        if(StringUtils.isEmpty(req.getName())) {
+            throw new StatusException("考点名称不能为空");
+        }
+        if(StringUtils.isEmpty(req.getAddress())) {
+            throw new StatusException("考点地址不能为空");
+        }
+        if(req.getCategoryId() == null) {
+            throw new StatusException("请选择考点所属教学点");
+        }
+        if(req.getEnable() == null) {
+            throw new StatusException("请选择考点状态");
+        }
+    }
+
+    private String trimAndNullIfBlank(String s) {
+        if (StringUtils.isBlank(s)) {
+            return null;
+        }
+        return s.trim();
+    }
+
+    private Map<String, Object> newError(int lineNum, String msg) {
+        Map<String, Object> map = new HashMap<>();
+        map.put("lineNum", lineNum);
+        map.put("msg", msg);
+        return map;
+    }
+
 }

+ 11 - 8
src/main/java/com/qmth/exam/reserve/service/impl/StudentApplyServiceImpl.java

@@ -17,6 +17,7 @@ import java.util.Map;
 import java.util.stream.Collectors;
 
 import com.qmth.exam.reserve.bean.applytask.CurrentApplyTaskVO;
+import com.qmth.exam.reserve.bean.stdapply.*;
 import com.qmth.exam.reserve.entity.base.BaseEntity;
 import com.qmth.exam.reserve.enums.Role;
 import com.qmth.exam.reserve.service.*;
@@ -44,13 +45,6 @@ import com.qmth.boot.tools.io.ZipWriter;
 import com.qmth.exam.reserve.bean.Constants;
 import com.qmth.exam.reserve.bean.apply.ApplyRecordCacheBean;
 import com.qmth.exam.reserve.bean.login.LoginUser;
-import com.qmth.exam.reserve.bean.stdapply.AgentAndTimeVO;
-import com.qmth.exam.reserve.bean.stdapply.CategoryVO;
-import com.qmth.exam.reserve.bean.stdapply.MaterialTitleInfo;
-import com.qmth.exam.reserve.bean.stdapply.SignInVO;
-import com.qmth.exam.reserve.bean.stdapply.StudentApplyReq;
-import com.qmth.exam.reserve.bean.stdapply.StudentApplyVO;
-import com.qmth.exam.reserve.bean.stdapply.StudentImportVO;
 import com.qmth.exam.reserve.cache.CacheConstants;
 import com.qmth.exam.reserve.cache.impl.ApplyTaskCacheService;
 import com.qmth.exam.reserve.dao.StudentApplyDao;
@@ -125,7 +119,16 @@ public class StudentApplyServiceImpl extends ServiceImpl<StudentApplyDao, Studen
             }
         }
         IPage<StudentApplyVO> iPage = this.baseMapper
-                .page(new Page<StudentApplyVO>(req.getPageNumber(), req.getPageSize()), req);
+                .page(new Page<>(req.getPageNumber(), req.getPageSize()), req);
+        List<StudentApplyVO> records = iPage.getRecords();
+        for (StudentApplyVO vo : records) {
+            AgentAndRoomVO agentRoom = baseMapper.getAgentAndRoom(vo.getId());
+            vo.setAgentName(agentRoom.getAgentName());
+            vo.setTeachingName(agentRoom.getTeachingName());
+            vo.setApplyTeachingName(agentRoom.getApplyTeachingName());
+            vo.setRoomName(agentRoom.getRoomName());
+            vo.setUserName(agentRoom.getUserName());
+        }
         return PageUtil.of(iPage);
     }
 

+ 25 - 0
src/main/resources/mapper/ExamSiteMapper.xml

@@ -20,4 +20,29 @@
         where es.id = #{examSiteId}
     </select>
 
+    <select id="page" resultType="com.qmth.exam.reserve.bean.examsite.ExamSiteVO">
+        SELECT
+            s.id,
+            s.NAME,
+            s.CODE,
+            g.NAME teachingName,
+            s.address,
+            s.capacity,
+            s.enable
+        FROM
+            t_exam_site s,
+            t_category g
+        WHERE
+            s.category_id = g.id
+        <if test="req.teachingId != null">
+            and s.category_id=#{req.teachingId}
+        </if>
+        <if test="req.name != null and req.name !=''">
+            and s.name like concat('%',#{req.name}, '%')
+        </if>
+        <if test="req.enable != null">
+            and s.enable=#{req.enable}
+        </if>
+    </select>
+
 </mapper>

+ 43 - 17
src/main/resources/mapper/StudentApplyMapper.xml

@@ -1,24 +1,27 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.qmth.exam.reserve.dao.StudentApplyDao">
-    <select id="page"
-            resultType="com.qmth.exam.reserve.bean.stdapply.StudentApplyVO">
-        select a.id,s.name,s.identity_number
-        identityNumber,s.student_code
-        studentCode,o.name teachingName,cat.name applyTeachingName,es.name
-        agentName, p.start_time
-        startTime,p.end_time endTime,
-        r.name roomName, a.cancel,a.update_time updateTime,u.name userName,a.seat_number seatNumber
-        from t_student s,t_category o,t_student_apply a
-        left join t_exam_site es on es.id=a.exam_site_id
-		left join t_category cat on cat.id= es.category_id
-        left join t_time_period p on p.id=a.time_period_id
-        left join t_exam_room r on r.id=a.exam_room_id
-        left join t_user u on u.id=a.operate_id 
-        where a.student_id=s.id and s.category_id=o.id and a.cancel=0
+    <select id="page"  resultType="com.qmth.exam.reserve.bean.stdapply.StudentApplyVO">
+        SELECT
+        a.id,
+        s.NAME,
+        s.identity_number identityNumber,
+        s.student_code studentCode,
+        p.start_time startTime,
+        p.end_time endTime,
+        a.cancel,
+        a.update_time updateTime,
+        a.seat_number seatNumber
+        FROM
+        t_student_apply a,
+        t_student s,
+        t_time_period p
+        WHERE
+        a.cancel = 0
+        AND a.student_id = s.id
+        AND a.time_period_id = p.id
         <if test="req.teachingId != null">
-            <!-- and s.category_id=#{req.teachingId} -->
-            and a.exam_site_id in 
+            and a.exam_site_id in
             <foreach collection="req.examSiteIds" item="item" index="index" separator="," open="(" close=")">
            	 	#{item}
         	</foreach>
@@ -159,4 +162,27 @@
 
     </select>
 
+    <select id="getAgentAndRoom" resultType="com.qmth.exam.reserve.bean.stdapply.AgentAndRoomVO">
+        SELECT
+            s.NAME agentName,
+            g.NAME applyTeachingName,
+            cat.name teachingName,
+            r.NAME roomName,
+            u.NAME userName
+        FROM
+            t_exam_site s,
+            t_category g,
+            t_student stu,
+            t_category cat,
+            t_student_apply a
+            LEFT JOIN t_exam_room r ON r.id = a.exam_room_id
+            LEFT JOIN t_user u ON u.id = a.operate_id
+        WHERE
+            a.exam_site_id = s.id
+          AND g.id = s.category_id
+          AND a.student_id = stu.id
+          AND cat.id = stu.category_id
+          AND a.id = #{id}
+    </select>
+
 </mapper>

BIN
src/main/resources/templates/examSite.xlsx