haogh 1 سال پیش
والد
کامیت
4d8671cfe0

+ 3 - 0
src/main/java/com/qmth/exam/reserve/bean/stdapply/CategoryVO.java

@@ -17,4 +17,7 @@ public class CategoryVO implements IModel {
 
     @ApiModelProperty("类别名称")
     private String name;
+
+    @ApiModelProperty("容量")
+    private Integer capacity;
 }

+ 1 - 1
src/main/java/com/qmth/exam/reserve/controller/admin/ApplyTaskController.java

@@ -30,7 +30,7 @@ import io.swagger.annotations.ApiOperation;
 import io.swagger.annotations.ApiParam;
 
 @RestController
-@Api(tags = "预约任务相关接口")
+@Api(tags = "【管理端】预约任务相关接口")
 @RequestMapping(ApiConstant.DEFAULT_URI_PREFIX + "/admin/apply/task")
 @Aac(strict = false, auth = true)
 public class ApplyTaskController extends BaseController {

+ 28 - 32
src/main/java/com/qmth/exam/reserve/controller/admin/StudentApplyController.java

@@ -7,13 +7,13 @@ import java.util.*;
 
 import javax.servlet.http.HttpServletResponse;
 
+import com.qmth.boot.core.cache.service.CacheService;
 import com.qmth.boot.tools.excel.ExcelWriter;
 import com.qmth.boot.tools.excel.enums.ExcelType;
 import com.qmth.exam.reserve.bean.stdapply.*;
-import com.qmth.exam.reserve.bean.studentimport.StudentImportTaskExport;
-import com.qmth.exam.reserve.entity.ExamRoomEntity;
 import com.qmth.exam.reserve.service.*;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Qualifier;
 import org.springframework.web.bind.annotation.*;
 import org.springframework.web.multipart.MultipartFile;
 
@@ -32,7 +32,7 @@ import io.swagger.annotations.ApiOperation;
 import io.swagger.annotations.ApiParam;
 
 @RestController
-@Api(tags = "考生预约明细相关接口")
+@Api(tags = "【管理端】考生预约明细相关接口")
 @RequestMapping(ApiConstant.DEFAULT_URI_PREFIX + "/admin/apply")
 @Aac(strict = false, auth = true)
 public class StudentApplyController extends BaseController {
@@ -49,8 +49,6 @@ public class StudentApplyController extends BaseController {
     @Autowired
     private ExamSiteService examSiteService;
 
-    @Autowired
-    private ExamRoomService examRoomService;
 
     @ApiOperation(value = "预约任务列表")
     @PostMapping(value = "/task/list")
@@ -164,48 +162,46 @@ public class StudentApplyController extends BaseController {
 
 
     @ApiOperation(value = "导出考场预约情况表")
-    @GetMapping(value = "/export/site/available")
-    public void exportApplyAvailable(@ApiParam("考点ID") @RequestParam Long examSiteId, HttpServletResponse response) {
+    @GetMapping(value = "/export/teaching/available")
+    public void exportApplyAvailable(@ApiParam("教学点ID") @RequestParam Long teachingId, HttpServletResponse response) {
         try {
-            String fileName = URLEncoder.encode("考预约情况表", "UTF-8");
+            String fileName = URLEncoder.encode("考预约情况表", "UTF-8");
             response.setHeader("Content-Disposition", "inline; filename=" + fileName + ".xlsx");
             response.setContentType("application/vnd.ms-excel");
             ExcelWriter writer = ExcelWriter.create(ExcelType.XLSX);
-            List<ExamRoomEntity> examRoomList = examRoomService.listExamRoom(examSiteId);
-            if(examRoomList == null || examRoomList.isEmpty()) {
-                throw new StatusException("当前考点下没有考场");
+            List<CategoryVO> examSiteList = examSiteService.listExamSite(teachingId);
+            if(examSiteList == null || examSiteList.isEmpty()) {
+                throw new StatusException("当前教学点下没有考点");
             }
-            String[] columnNames = getColumnNames(examRoomList);
-            String[] firstLineContents = getFirstLineContents(examRoomList);
-            List<SiteApplyExportVO> exportList = studentApplyService.exportPage(examSiteId);
-            String [] titles= {"测试1" ,"测试2", "测试3"};
-            List<String[]> list = new ArrayList<>();
-            list.add(titles);
-            list.add(titles);
-            list.add(titles);
-            writer.writeDataArrays("考场预约情况表", null, columnNames, list.iterator());
+            String[] columnNames = getColumnNames(examSiteList);
+            String[] firstLineContents = getFirstLineContents(examSiteList);
+            List<String[]> exportList = new ArrayList<>();
+            exportList.add(firstLineContents);
+            List<String[]> avaiableList = studentApplyService.listExamSiteAvailable(examSiteList);
+            exportList.addAll(avaiableList);
+            writer.writeDataArrays("考点预约情况表", null, columnNames, exportList.iterator());
             writer.output(response.getOutputStream());
         } catch (IOException e) {
-            e.printStackTrace();
+            throw new StatusException(e.getMessage());
         }
     }
 
-    private String[] getFirstLineContents(List<ExamRoomEntity> examRoomList) {
-        String[] result = new String[examRoomList.size()+1];
-        result[0] = "考容量";
-        for (int i = 0; i < examRoomList.size(); i++) {
-            ExamRoomEntity examRoom = examRoomList.get(i);
-            result[i+1] = String.valueOf(examRoom.getCapacity());
+    private String[] getFirstLineContents(List<CategoryVO> examSiteList) {
+        String[] result = new String[examSiteList.size()+1];
+        result[0] = "考容量";
+        for (int i = 0; i < examSiteList.size(); i++) {
+            CategoryVO category = examSiteList.get(i);
+            result[i+1] = String.valueOf(category.getCapacity());
         }
         return result;
     }
 
-    private String[] getColumnNames(List<ExamRoomEntity> examRoomList) {
-        String[] columnNames = new String[examRoomList.size()+1];
+    private String[] getColumnNames(List<CategoryVO> examSiteList) {
+        String[] columnNames = new String[examSiteList.size()+1];
         columnNames[0] = "时段";
-        for (int i = 0; i < examRoomList.size(); i++) {
-            ExamRoomEntity examRoom = examRoomList.get(i);
-            columnNames[i+1] = examRoom.getName();
+        for (int i = 0; i < examSiteList.size(); i++) {
+            CategoryVO category = examSiteList.get(i);
+            columnNames[i+1] = category.getName();
         }
         return columnNames;
     }

+ 1 - 1
src/main/java/com/qmth/exam/reserve/controller/admin/StudentImportTaskController.java

@@ -38,7 +38,7 @@ import io.swagger.annotations.ApiOperation;
 import io.swagger.annotations.ApiParam;
 
 @RestController
-@Api(tags = "考生信息导入相关接口")
+@Api(tags = "【管理端】考生信息导入相关接口")
 @RequestMapping(ApiConstant.DEFAULT_URI_PREFIX + "/admin/std")
 @Aac(strict = false, auth = true)
 public class StudentImportTaskController extends BaseController {

+ 2 - 5
src/main/java/com/qmth/exam/reserve/service/StudentApplyService.java

@@ -8,10 +8,7 @@ import java.util.Map;
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.qmth.boot.core.collection.PageResult;
 import com.qmth.exam.reserve.bean.login.LoginUser;
-import com.qmth.exam.reserve.bean.stdapply.SiteApplyExportVO;
-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.*;
 import com.qmth.exam.reserve.entity.StudentApplyEntity;
 
 public interface StudentApplyService extends IService<StudentApplyEntity> {
@@ -32,5 +29,5 @@ public interface StudentApplyService extends IService<StudentApplyEntity> {
 
     List<SignInVO> listSignInDate(Long taskId);
 
-    List<SiteApplyExportVO> exportPage(Long examSiteId);
+    List<String[]> listExamSiteAvailable(List<CategoryVO> examSiteList);
 }

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

@@ -49,12 +49,14 @@ public class ExamSiteServiceImpl extends ServiceImpl<ExamSiteDao, ExamSiteEntity
         LambdaQueryWrapper<ExamSiteEntity> lw = wrapper.lambda();
         lw.eq(ExamSiteEntity::getEnable, Boolean.TRUE);
         lw.eq(ExamSiteEntity::getCategoryId, teachingId);
+        lw.orderByAsc(ExamSiteEntity::getCode);
         List<ExamSiteEntity> list = this.baseMapper.selectList(wrapper);
         List<CategoryVO> categoryList = new ArrayList<>();
         for (ExamSiteEntity site : list) {
             CategoryVO vo = new CategoryVO();
             vo.setId(site.getId());
             vo.setName(site.getName());
+            vo.setCapacity(site.getCapacity());
             categoryList.add(vo);
         }
         return categoryList;

+ 21 - 3
src/main/java/com/qmth/exam/reserve/service/impl/StudentApplyServiceImpl.java

@@ -677,7 +677,7 @@ public class StudentApplyServiceImpl extends ServiceImpl<StudentApplyDao, Studen
             List<Long> timePeriodIds = timeList.stream().map(BaseEntity::getId).collect(Collectors.toList());
             Integer haveApplyNum = baseMapper.getHaveApplyCount(examSiteIds, timePeriodIds, Boolean.FALSE);
             // 未预约的数量
-            Integer noApplyNum = baseMapper.getNoApplyCount(taskId,vo.getId(),timePeriodIds);
+            Integer noApplyNum = baseMapper.getNoApplyCount(taskId, vo.getId(), timePeriodIds);
             if (noApplyNum > total - haveApplyNum) {
                 CategoryEntity category = categoryService.getById(vo.getId());
                 throw new StatusException("【" + category.getName() + "】教学点考位不足!剩余的考位数量:【" + (total - haveApplyNum) + "】,实际需要的考位数量:【" + noApplyNum + "】");
@@ -990,10 +990,28 @@ public class StudentApplyServiceImpl extends ServiceImpl<StudentApplyDao, Studen
     }
 
     @Override
-    public List<SiteApplyExportVO> exportPage(Long examSiteId) {
-        return Collections.emptyList();
+    public List<String[]> listExamSiteAvailable(List<CategoryVO> examSiteList) {
+        List<String[]> availableList = new ArrayList<>();
+        ApplyTaskEntity task = getApplyTask();
+        List<TimePeriodEntity> timePeriodList = listTimePeriod(task.getId());
+        for (TimePeriodEntity timePeriod : timePeriodList) {
+            String[] availableArr = getAvailableArr(examSiteList, timePeriod);
+            availableList.add(availableArr);
+        }
+        return availableList;
     }
 
+    private String[] getAvailableArr(List<CategoryVO> examSiteList, TimePeriodEntity timePeriod) {
+        String[] availableArr = new String[examSiteList.size() + 1];
+        availableArr[0] = DateUtil.getStartAndEndTime(timePeriod.getStartTime(), timePeriod.getEndTime());
+        for (int i = 0; i < examSiteList.size(); i++) {
+            CategoryVO category = examSiteList.get(i);
+            //int applyFinishCount = cacheService.getApplyFinishCount(category.getId(), timePeriod.getId());
+            int applyFinishCount = countApplyFinishForExamSiteAndTimePeriod(category.getId(), timePeriod.getId());
+            availableArr[i + 1] = String.valueOf(category.getCapacity() - applyFinishCount);
+        }
+        return availableArr;
+    }
 
 
     private boolean isInTimePeriod(Date date, List<TimePeriodEntity> timePeriodList) {