haogh 1 vuosi sitten
vanhempi
commit
5c20ba8d70

+ 0 - 3
src/main/java/com/qmth/exam/reserve/bean/task/ApplyTaskReq.java

@@ -18,9 +18,6 @@ public class ApplyTaskReq implements IModel {
     @ApiModelProperty("任务ID")
     @ApiModelProperty("任务ID")
     private Long id;
     private Long id;
 
 
-    @ApiModelProperty(required = true, value = "考前多少天禁止考生预约")
-    private Integer allowApplyDays;
-
     @ApiModelProperty(required = true, value = "考前多少小天禁止考生自主取消预约")
     @ApiModelProperty(required = true, value = "考前多少小天禁止考生自主取消预约")
     private Integer allowApplyCancelDays;
     private Integer allowApplyCancelDays;
 
 

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

@@ -84,4 +84,10 @@ public class ApplyTaskController extends BaseController {
         applyTaskService.enable(user.getId(), id, enable);
         applyTaskService.enable(user.getId(), id, enable);
     }
     }
 
 
+    @ApiOperation(value = "预约时段单个删除")
+    @PostMapping(value = "/rule/delete")
+    public void deleteRule(@ApiParam("时段ID") @RequestParam Long timeId) {
+        applyTaskService.deleteRule(timeId);
+    }
+
 }
 }

+ 3 - 2
src/main/java/com/qmth/exam/reserve/controller/admin/StudentApplyController.java

@@ -141,7 +141,8 @@ public class StudentApplyController extends BaseController {
     @ApiOperation(value = "打印签到表")
     @ApiOperation(value = "打印签到表")
     @PostMapping(value = "/std/auto/sign/in/print")
     @PostMapping(value = "/std/auto/sign/in/print")
     public void printSignIn(@ApiParam("教学点ID") @RequestParam(required = false) Long teachingId,
     public void printSignIn(@ApiParam("教学点ID") @RequestParam(required = false) Long teachingId,
-            @ApiParam("考点ID") @RequestParam(required = false) Long agentId) {
+            @ApiParam("考点ID") @RequestParam(required = false) Long agentId,
+            @ApiParam("考试日期") @RequestParam(required = true) Long examDate) {
         LoginUser user = this.curLoginUser();
         LoginUser user = this.curLoginUser();
         if (Role.ADMIN.equals(user.getRole()) && teachingId == null) {
         if (Role.ADMIN.equals(user.getRole()) && teachingId == null) {
             throw new StatusException("请选择教学点");
             throw new StatusException("请选择教学点");
@@ -149,7 +150,7 @@ public class StudentApplyController extends BaseController {
         if (Role.TEACHING.equals(user.getRole())) {
         if (Role.TEACHING.equals(user.getRole())) {
             teachingId = user.getCategoryId();
             teachingId = user.getCategoryId();
         }
         }
-        File signInZip = studentApplyService.downloadSignIn(teachingId, agentId);
+        File signInZip = studentApplyService.downloadSignIn(teachingId, agentId, examDate);
         exportFile(signInZip.getName(), signInZip);
         exportFile(signInZip.getName(), signInZip);
         signInZip.delete();
         signInZip.delete();
     }
     }

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

@@ -32,4 +32,6 @@ public interface ApplyTaskService extends IService<ApplyTaskEntity> {
 
 
     void enable(Long userId, Long id, Boolean enable);
     void enable(Long userId, Long id, Boolean enable);
 
 
+    void deleteRule(Long timeId);
+
 }
 }

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

@@ -25,7 +25,7 @@ public interface StudentApplyService extends IService<StudentApplyEntity> {
 
 
     void autoLayout(Long teachingId);
     void autoLayout(Long teachingId);
 
 
-    File downloadSignIn(Long teachingId, Long agentId);
+    File downloadSignIn(Long teachingId, Long agentId, Long examDate);
 
 
     int countApplyFinishForExamSiteAndTimePeriod(Long examSiteId, Long timePeriodId);
     int countApplyFinishForExamSiteAndTimePeriod(Long examSiteId, Long timePeriodId);
 
 

+ 27 - 4
src/main/java/com/qmth/exam/reserve/service/impl/ApplyTaskServiceImpl.java

@@ -25,9 +25,12 @@ import com.qmth.exam.reserve.bean.task.ApplyTaskVO;
 import com.qmth.exam.reserve.cache.impl.ApplyTaskCacheService;
 import com.qmth.exam.reserve.cache.impl.ApplyTaskCacheService;
 import com.qmth.exam.reserve.dao.ApplyTaskDao;
 import com.qmth.exam.reserve.dao.ApplyTaskDao;
 import com.qmth.exam.reserve.entity.ApplyTaskEntity;
 import com.qmth.exam.reserve.entity.ApplyTaskEntity;
+import com.qmth.exam.reserve.entity.StudentApplyEntity;
 import com.qmth.exam.reserve.enums.EventType;
 import com.qmth.exam.reserve.enums.EventType;
 import com.qmth.exam.reserve.service.ApplyTaskService;
 import com.qmth.exam.reserve.service.ApplyTaskService;
 import com.qmth.exam.reserve.service.OperateLogService;
 import com.qmth.exam.reserve.service.OperateLogService;
+import com.qmth.exam.reserve.service.StudentApplyService;
+import com.qmth.exam.reserve.service.TimePeriodService;
 import com.qmth.exam.reserve.util.PageUtil;
 import com.qmth.exam.reserve.util.PageUtil;
 
 
 @Service
 @Service
@@ -39,6 +42,12 @@ public class ApplyTaskServiceImpl extends ServiceImpl<ApplyTaskDao, ApplyTaskEnt
     @Autowired
     @Autowired
     private ApplyTaskCacheService cacheService;
     private ApplyTaskCacheService cacheService;
 
 
+    @Autowired
+    private StudentApplyService studentApplyService;
+
+    @Autowired
+    private TimePeriodService timePeriodService;
+
     @Override
     @Override
     public PageResult<ApplyTaskVO> page(ApplyTaskPageReq req) {
     public PageResult<ApplyTaskVO> page(ApplyTaskPageReq req) {
         IPage<ApplyTaskVO> iPage = this.baseMapper.page(new Page<ApplyTaskVO>(req.getPageNumber(), req.getPageSize()),
         IPage<ApplyTaskVO> iPage = this.baseMapper.page(new Page<ApplyTaskVO>(req.getPageNumber(), req.getPageSize()),
@@ -61,7 +70,10 @@ public class ApplyTaskServiceImpl extends ServiceImpl<ApplyTaskDao, ApplyTaskEnt
         checkRule(req);
         checkRule(req);
         ApplyTaskEntity task = new ApplyTaskEntity();
         ApplyTaskEntity task = new ApplyTaskEntity();
         BeanUtils.copyProperties(req, task);
         BeanUtils.copyProperties(req, task);
-        task.setEnable(Boolean.FALSE);
+        task.setAllowApplyDays(task.getAllowApplyCancelDays());
+        if (req.getId() == null) {
+            task.setEnable(Boolean.FALSE);
+        }
         task.setOrgId(user.getOrgId());
         task.setOrgId(user.getOrgId());
         this.saveOrUpdate(task);
         this.saveOrUpdate(task);
     }
     }
@@ -69,10 +81,8 @@ public class ApplyTaskServiceImpl extends ServiceImpl<ApplyTaskDao, ApplyTaskEnt
     private void checkRule(ApplyTaskReq req) {
     private void checkRule(ApplyTaskReq req) {
         if (StringUtils.isEmpty(req.getName()))
         if (StringUtils.isEmpty(req.getName()))
             throw new StatusException("请填写任务名称");
             throw new StatusException("请填写任务名称");
-        if (StringUtils.isEmpty(req.getAllowApplyDays()))
-            throw new StatusException("请填写禁止考生预约的天数");
         if (StringUtils.isEmpty(req.getAllowApplyCancelDays()))
         if (StringUtils.isEmpty(req.getAllowApplyCancelDays()))
-            throw new StatusException("请填写禁止考生取消预约的天数");
+            throw new StatusException("请填写学生自主操作限制的天数");
         if (StringUtils.isEmpty(req.getSelfApplyStartTime()))
         if (StringUtils.isEmpty(req.getSelfApplyStartTime()))
             throw new StatusException("请填写自主预约起始时间");
             throw new StatusException("请填写自主预约起始时间");
         if (StringUtils.isEmpty(req.getSelfApplyEndTime()))
         if (StringUtils.isEmpty(req.getSelfApplyEndTime()))
@@ -164,4 +174,17 @@ public class ApplyTaskServiceImpl extends ServiceImpl<ApplyTaskDao, ApplyTaskEnt
         return task;
         return task;
     }
     }
 
 
+    @Override
+    public void deleteRule(Long timeId) {
+        if (timeId == null)
+            return;
+        LambdaQueryWrapper<StudentApplyEntity> lm = new LambdaQueryWrapper<>();
+        lm.eq(StudentApplyEntity::getTimePeriodId, timeId);
+        List<StudentApplyEntity> applyList = studentApplyService.list(lm);
+        if (applyList != null && applyList.size() > 0) {
+            throw new StatusException("考生已经预约,不能删除预约时段");
+        }
+        timePeriodService.removeById(timeId);
+    }
+
 }
 }

+ 10 - 6
src/main/java/com/qmth/exam/reserve/service/impl/StudentApplyServiceImpl.java

@@ -513,8 +513,8 @@ public class StudentApplyServiceImpl extends ServiceImpl<StudentApplyDao, Studen
             for (Long key : map.keySet()) {
             for (Long key : map.keySet()) {
                 List<ExamSiteEntity> siteList = listExamSite(key, null);
                 List<ExamSiteEntity> siteList = listExamSite(key, null);
                 List<StudentEntity> teachingStudentList = map.get(key);
                 List<StudentEntity> teachingStudentList = map.get(key);
-                for (TimePeriodEntity time : timeList) {
-                    for (ExamSiteEntity site : siteList) {
+                for (ExamSiteEntity site : siteList) {
+                    for (TimePeriodEntity time : timeList) {
                         // 该时段已预约的考生
                         // 该时段已预约的考生
                         Integer haveApplyNum = getHaveApplyNum(site.getId(), time.getId());
                         Integer haveApplyNum = getHaveApplyNum(site.getId(), time.getId());
                         // 剩余的考位
                         // 剩余的考位
@@ -791,11 +791,10 @@ public class StudentApplyServiceImpl extends ServiceImpl<StudentApplyDao, Studen
     }
     }
 
 
     @Override
     @Override
-    public File downloadSignIn(Long teachingId, Long agentId) {
+    public File downloadSignIn(Long teachingId, Long agentId, Long examDate) {
         ApplyTaskEntity applyTask = getApplyTask();
         ApplyTaskEntity applyTask = getApplyTask();
         List<TimePeriodEntity> timePeriodList = listTimePeroid(applyTask.getId());
         List<TimePeriodEntity> timePeriodList = listTimePeroid(applyTask.getId());
-        List<TimePeriodEntity> noCancelTimePeroidList = listNoCancelApplyTimePeroid(timePeriodList,
-                applyTask.getAllowApplyCancelDays());
+        List<TimePeriodEntity> noCancelTimePeroidList = listSameDayTimePeroid(timePeriodList, examDate);
         if (noCancelTimePeroidList.isEmpty()) {
         if (noCancelTimePeroidList.isEmpty()) {
             throw new StatusException("当前时间没有可下载的签到表");
             throw new StatusException("当前时间没有可下载的签到表");
         }
         }
@@ -811,8 +810,12 @@ public class StudentApplyServiceImpl extends ServiceImpl<StudentApplyDao, Studen
         File zipFile = new File(tempFolder, category.getName() + "签到表.zip");
         File zipFile = new File(tempFolder, category.getName() + "签到表.zip");
         try {
         try {
             writer = ZipWriter.create(zipFile);
             writer = ZipWriter.create(zipFile);
+            List<File> fileList = new ArrayList<>();
             for (ExamSiteEntity site : siteList) {
             for (ExamSiteEntity site : siteList) {
-                downloadByExamSite(writer, applyTask.getName(), site, noCancelTimePeroidList);
+                fileList.addAll(downloadByExamSite(writer, applyTask.getName(), site, noCancelTimePeroidList));
+            }
+            if (fileList.isEmpty()) {
+                throw new StatusException("暂未排考,请等待排考后下载");
             }
             }
         } catch (IOException e) {
         } catch (IOException e) {
             e.printStackTrace();
             e.printStackTrace();
@@ -837,6 +840,7 @@ public class StudentApplyServiceImpl extends ServiceImpl<StudentApplyDao, Studen
                 List<StudentApplyVO> studentList = baseMapper.listStudentApply(time.getId(), room.getId());
                 List<StudentApplyVO> studentList = baseMapper.listStudentApply(time.getId(), room.getId());
                 if (!studentList.isEmpty()) {
                 if (!studentList.isEmpty()) {
                     File file = materialService.generateSignInForm(title, studentList);
                     File file = materialService.generateSignInForm(title, studentList);
+                    fileList.add(file);
                     writer.write(file, title.getSiteName(),
                     writer.write(file, title.getSiteName(),
                             title.getTimePeriod() + " 第【" + title.getRoomCode() + "】考场" + ".pdf");
                             title.getTimePeriod() + " 第【" + title.getRoomCode() + "】考场" + ".pdf");
                 }
                 }

+ 1 - 2
src/main/java/com/qmth/exam/reserve/util/DateUtil.java

@@ -93,8 +93,7 @@ public class DateUtil {
         // Date date = new Date(1715749200000l);
         // Date date = new Date(1715749200000l);
         // String result = format(date, "yyyy-MM-dd HH:mm:ss");
         // String result = format(date, "yyyy-MM-dd HH:mm:ss");
         // System.out.println(result);
         // System.out.println(result);
-
-        System.out.println(getLongTimeByDate("2024-05-15 12:00:00"));
+        System.out.println(getLongDateByLongTime(1713888000000l));
     }
     }
 
 
     public static Date addValues(int filed, int value) {
     public static Date addValues(int filed, int value) {