|
@@ -1,5 +1,13 @@
|
|
package com.qmth.exam.reserve.service.impl;
|
|
package com.qmth.exam.reserve.service.impl;
|
|
|
|
|
|
|
|
+import java.util.ArrayList;
|
|
|
|
+import java.util.List;
|
|
|
|
+
|
|
|
|
+import org.springframework.beans.BeanUtils;
|
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
|
+import org.springframework.util.StringUtils;
|
|
|
|
+
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
@@ -10,24 +18,25 @@ import com.qmth.boot.core.exception.StatusException;
|
|
import com.qmth.exam.reserve.bean.applytask.CurrentApplyTaskVO;
|
|
import com.qmth.exam.reserve.bean.applytask.CurrentApplyTaskVO;
|
|
import com.qmth.exam.reserve.bean.login.LoginUser;
|
|
import com.qmth.exam.reserve.bean.login.LoginUser;
|
|
import com.qmth.exam.reserve.bean.stdapply.CategoryVO;
|
|
import com.qmth.exam.reserve.bean.stdapply.CategoryVO;
|
|
|
|
+import com.qmth.exam.reserve.bean.task.ApplyTaskPageReq;
|
|
import com.qmth.exam.reserve.bean.task.ApplyTaskReq;
|
|
import com.qmth.exam.reserve.bean.task.ApplyTaskReq;
|
|
import com.qmth.exam.reserve.bean.task.ApplyTaskRuleVO;
|
|
import com.qmth.exam.reserve.bean.task.ApplyTaskRuleVO;
|
|
import com.qmth.exam.reserve.bean.task.ApplyTaskVO;
|
|
import com.qmth.exam.reserve.bean.task.ApplyTaskVO;
|
|
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.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.util.PageUtil;
|
|
import com.qmth.exam.reserve.util.PageUtil;
|
|
-import org.springframework.stereotype.Service;
|
|
|
|
-import org.springframework.util.StringUtils;
|
|
|
|
-
|
|
|
|
-import java.util.ArrayList;
|
|
|
|
-import java.util.List;
|
|
|
|
|
|
|
|
@Service
|
|
@Service
|
|
public class ApplyTaskServiceImpl extends ServiceImpl<ApplyTaskDao, ApplyTaskEntity> implements ApplyTaskService {
|
|
public class ApplyTaskServiceImpl extends ServiceImpl<ApplyTaskDao, ApplyTaskEntity> implements ApplyTaskService {
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
+ private OperateLogService logService;
|
|
|
|
+
|
|
@Override
|
|
@Override
|
|
- public PageResult<ApplyTaskVO> page(ApplyTaskReq 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()),
|
|
req);
|
|
req);
|
|
return PageUtil.of(iPage);
|
|
return PageUtil.of(iPage);
|
|
@@ -44,17 +53,10 @@ public class ApplyTaskServiceImpl extends ServiceImpl<ApplyTaskDao, ApplyTaskEnt
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
- public void ruleSave(ApplyTaskReq req, LoginUser user) {
|
|
|
|
|
|
+ public void saveRule(ApplyTaskReq req, LoginUser user) {
|
|
checkRule(req);
|
|
checkRule(req);
|
|
ApplyTaskEntity task = new ApplyTaskEntity();
|
|
ApplyTaskEntity task = new ApplyTaskEntity();
|
|
- task.setId(req.getId());
|
|
|
|
- task.setName(req.getName());
|
|
|
|
- task.setAllowApplyDays(req.getAllowApplyDays());
|
|
|
|
- task.setAllowApplyCancelDays(req.getAllowApplyCancelDays());
|
|
|
|
- task.setSelfApplyStartTime(req.getSelfApplyStartTime());
|
|
|
|
- task.setSelfApplyEndTime(req.getSelfApplyEndTime());
|
|
|
|
- task.setOpenApplyStartTime(req.getOpenApplyStartTime());
|
|
|
|
- task.setOpenApplyEndTime(req.getOpenApplyEndTime());
|
|
|
|
|
|
+ BeanUtils.copyProperties(req, task);
|
|
task.setEnable(Boolean.FALSE);
|
|
task.setEnable(Boolean.FALSE);
|
|
task.setOrgId(user.getOrgId());
|
|
task.setOrgId(user.getOrgId());
|
|
this.saveOrUpdate(task);
|
|
this.saveOrUpdate(task);
|
|
@@ -75,6 +77,12 @@ public class ApplyTaskServiceImpl extends ServiceImpl<ApplyTaskDao, ApplyTaskEnt
|
|
throw new StatusException("请填写开放式预约起始时间");
|
|
throw new StatusException("请填写开放式预约起始时间");
|
|
if (StringUtils.isEmpty(req.getOpenApplyEndTime()))
|
|
if (StringUtils.isEmpty(req.getOpenApplyEndTime()))
|
|
throw new StatusException("请填写开放式预约截止时间");
|
|
throw new StatusException("请填写开放式预约截止时间");
|
|
|
|
+ if (req.getSelfApplyStartTime() >= req.getSelfApplyEndTime())
|
|
|
|
+ throw new StatusException("第一阶段起始时间必须小于截止时间");
|
|
|
|
+ if (req.getOpenApplyStartTime() >= req.getOpenApplyEndTime())
|
|
|
|
+ throw new StatusException("第三阶段起始时间必须小于截止时间");
|
|
|
|
+ if (req.getSelfApplyEndTime() >= req.getOpenApplyStartTime())
|
|
|
|
+ throw new StatusException("第三阶段的时间必须在第一阶段结束之后");
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
@@ -118,4 +126,34 @@ public class ApplyTaskServiceImpl extends ServiceImpl<ApplyTaskDao, ApplyTaskEnt
|
|
return baseMapper.selectOne(wrapper);
|
|
return baseMapper.selectOne(wrapper);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ @Override
|
|
|
|
+ public void saveNotice(Long userId, Long id, String notice) {
|
|
|
|
+ ApplyTaskEntity task = checkTask(id);
|
|
|
|
+ task.setNotice(notice);
|
|
|
|
+ this.updateById(task);
|
|
|
|
+ logService.insertOperateLog(userId, EventType.SAVE_NOTICE, null);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public void enable(Long userId, Long id, Boolean enable) {
|
|
|
|
+ ApplyTaskEntity task = checkTask(id);
|
|
|
|
+ if (enable) {
|
|
|
|
+ LambdaQueryWrapper<ApplyTaskEntity> query = new LambdaQueryWrapper<>();
|
|
|
|
+ query.eq(ApplyTaskEntity::getEnable, Boolean.TRUE);
|
|
|
|
+ ApplyTaskEntity existTask = this.getOne(query);
|
|
|
|
+ if (existTask != null)
|
|
|
|
+ throw new StatusException("只能有一个任务是开启状态");
|
|
|
|
+ }
|
|
|
|
+ task.setEnable(enable);
|
|
|
|
+ updateById(task);
|
|
|
|
+ logService.insertOperateLog(userId, EventType.ENABLE_APPLY_TASK, null);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private ApplyTaskEntity checkTask(Long id) {
|
|
|
|
+ ApplyTaskEntity task = getById(id);
|
|
|
|
+ if (task == null)
|
|
|
|
+ throw new StatusException("预约任务不存在");
|
|
|
|
+ return task;
|
|
|
|
+ }
|
|
|
|
+
|
|
}
|
|
}
|