|
@@ -18,9 +18,9 @@ import com.qmth.exam.reserve.cache.impl.ApplyTaskCacheService;
|
|
import com.qmth.exam.reserve.dao.ExamRoomDao;
|
|
import com.qmth.exam.reserve.dao.ExamRoomDao;
|
|
import com.qmth.exam.reserve.entity.ExamRoomEntity;
|
|
import com.qmth.exam.reserve.entity.ExamRoomEntity;
|
|
import com.qmth.exam.reserve.entity.ExamSiteEntity;
|
|
import com.qmth.exam.reserve.entity.ExamSiteEntity;
|
|
-import com.qmth.exam.reserve.service.CategoryService;
|
|
|
|
-import com.qmth.exam.reserve.service.ExamRoomService;
|
|
|
|
-import com.qmth.exam.reserve.service.ExamSiteService;
|
|
|
|
|
|
+import com.qmth.exam.reserve.entity.TimePeriodEntity;
|
|
|
|
+import com.qmth.exam.reserve.entity.TimePeriodExamRoomEntity;
|
|
|
|
+import com.qmth.exam.reserve.service.*;
|
|
import com.qmth.exam.reserve.util.PageUtil;
|
|
import com.qmth.exam.reserve.util.PageUtil;
|
|
import org.apache.commons.collections4.CollectionUtils;
|
|
import org.apache.commons.collections4.CollectionUtils;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
@@ -34,6 +34,8 @@ import org.springframework.transaction.interceptor.TransactionAspectSupport;
|
|
|
|
|
|
import java.io.InputStream;
|
|
import java.io.InputStream;
|
|
import java.util.*;
|
|
import java.util.*;
|
|
|
|
+import java.util.function.Function;
|
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
@Service
|
|
@Service
|
|
public class ExamRoomServiceImpl extends ServiceImpl<ExamRoomDao, ExamRoomEntity> implements ExamRoomService {
|
|
public class ExamRoomServiceImpl extends ServiceImpl<ExamRoomDao, ExamRoomEntity> implements ExamRoomService {
|
|
@@ -50,6 +52,12 @@ public class ExamRoomServiceImpl extends ServiceImpl<ExamRoomDao, ExamRoomEntity
|
|
@Autowired
|
|
@Autowired
|
|
private ApplyTaskCacheService cacheService;
|
|
private ApplyTaskCacheService cacheService;
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
+ private TimePeriodService timePeriodService;
|
|
|
|
+
|
|
|
|
+ @Autowired
|
|
|
|
+ private TimePeriodExamRoomService timePeriodExamRoomService;
|
|
|
|
+
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public PageResult<ExamRoomVO> pageExamRoom(ExamRoomReq req) {
|
|
public PageResult<ExamRoomVO> pageExamRoom(ExamRoomReq req) {
|
|
@@ -68,12 +76,17 @@ public class ExamRoomServiceImpl extends ServiceImpl<ExamRoomDao, ExamRoomEntity
|
|
if (req.getId() == null) {
|
|
if (req.getId() == null) {
|
|
examRoomEntity.setEnable(Boolean.TRUE);
|
|
examRoomEntity.setEnable(Boolean.TRUE);
|
|
save(examRoomEntity);
|
|
save(examRoomEntity);
|
|
|
|
+ //刷新缓存
|
|
|
|
+ refreshApplyCountCache(examRoomEntity.getId(), examRoomEntity.getExamSiteId(), 0, examRoomEntity.getCapacity());
|
|
} else {
|
|
} else {
|
|
beforeUpdateRoom = getById(req.getId());
|
|
beforeUpdateRoom = getById(req.getId());
|
|
updateById(examRoomEntity);
|
|
updateById(examRoomEntity);
|
|
|
|
+ //刷新缓存
|
|
|
|
+ refreshApplyCountCache(examRoomEntity.getId(), examRoomEntity.getExamSiteId(), beforeUpdateRoom.getCapacity(), examRoomEntity.getCapacity());
|
|
}
|
|
}
|
|
//更新考点容量和教学点容量
|
|
//更新考点容量和教学点容量
|
|
updateExamSiteAndTeachingCapacity(req.getExamSiteId());
|
|
updateExamSiteAndTeachingCapacity(req.getExamSiteId());
|
|
|
|
+ //考场更换考点
|
|
if(req.getId() != null && !req.getExamSiteId().equals(beforeUpdateRoom.getExamSiteId())) {
|
|
if(req.getId() != null && !req.getExamSiteId().equals(beforeUpdateRoom.getExamSiteId())) {
|
|
updateExamSiteAndTeachingCapacity(beforeUpdateRoom.getExamSiteId());
|
|
updateExamSiteAndTeachingCapacity(beforeUpdateRoom.getExamSiteId());
|
|
}
|
|
}
|
|
@@ -89,6 +102,8 @@ public class ExamRoomServiceImpl extends ServiceImpl<ExamRoomDao, ExamRoomEntity
|
|
update(null, wrapper);
|
|
update(null, wrapper);
|
|
|
|
|
|
updateExamSiteAndTeachingCapacity(examRoom.getExamSiteId());
|
|
updateExamSiteAndTeachingCapacity(examRoom.getExamSiteId());
|
|
|
|
+
|
|
|
|
+ refreshApplyCountCache(id, examRoom.getExamSiteId(), enable ? 0 : examRoom.getCapacity(), enable ? examRoom.getCapacity() : 0);
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
@@ -209,7 +224,9 @@ public class ExamRoomServiceImpl extends ServiceImpl<ExamRoomDao, ExamRoomEntity
|
|
|
|
|
|
private void saveRoom(ExamRoomEntity room) {
|
|
private void saveRoom(ExamRoomEntity room) {
|
|
ExamRoomEntity examRoom = getExamRoom(room.getExamSiteId(), room.getCode());
|
|
ExamRoomEntity examRoom = getExamRoom(room.getExamSiteId(), room.getCode());
|
|
|
|
+ int capacity;
|
|
if (examRoom != null) {
|
|
if (examRoom != null) {
|
|
|
|
+ capacity = examRoom.getCapacity();
|
|
examRoom.setCapacity(room.getCapacity());
|
|
examRoom.setCapacity(room.getCapacity());
|
|
LambdaUpdateWrapper<ExamRoomEntity> wrapper = new LambdaUpdateWrapper<>();
|
|
LambdaUpdateWrapper<ExamRoomEntity> wrapper = new LambdaUpdateWrapper<>();
|
|
wrapper.set(ExamRoomEntity::getName, room.getName());
|
|
wrapper.set(ExamRoomEntity::getName, room.getName());
|
|
@@ -218,8 +235,13 @@ public class ExamRoomServiceImpl extends ServiceImpl<ExamRoomDao, ExamRoomEntity
|
|
wrapper.set(ExamRoomEntity::getEnable, Boolean.TRUE);
|
|
wrapper.set(ExamRoomEntity::getEnable, Boolean.TRUE);
|
|
wrapper.eq(ExamRoomEntity::getId, examRoom.getId());
|
|
wrapper.eq(ExamRoomEntity::getId, examRoom.getId());
|
|
update(null, wrapper);
|
|
update(null, wrapper);
|
|
|
|
+ if(capacity != room.getCapacity()) {
|
|
|
|
+ refreshApplyCountCache(room.getId(), room.getExamSiteId(), capacity, room.getCapacity());
|
|
|
|
+ }
|
|
} else {
|
|
} else {
|
|
save(room);
|
|
save(room);
|
|
|
|
+ refreshApplyCountCache(room.getId(), room.getExamSiteId(), 0, room.getCapacity());
|
|
|
|
+
|
|
}
|
|
}
|
|
updateExamSiteAndTeachingCapacity(room.getExamSiteId());
|
|
updateExamSiteAndTeachingCapacity(room.getExamSiteId());
|
|
}
|
|
}
|
|
@@ -233,7 +255,7 @@ public class ExamRoomServiceImpl extends ServiceImpl<ExamRoomDao, ExamRoomEntity
|
|
}
|
|
}
|
|
|
|
|
|
private void updateExamSiteAndTeachingCapacity(Long examSiteId) {
|
|
private void updateExamSiteAndTeachingCapacity(Long examSiteId) {
|
|
- ExamSiteEntity oldExamSite = examSiteService.getById(examSiteId);
|
|
|
|
|
|
+// ExamSiteEntity oldExamSite = examSiteService.getById(examSiteId);
|
|
// 更新考点容量
|
|
// 更新考点容量
|
|
examSiteService.updateExamSiteCapacity(examSiteId);
|
|
examSiteService.updateExamSiteCapacity(examSiteId);
|
|
|
|
|
|
@@ -241,16 +263,33 @@ public class ExamRoomServiceImpl extends ServiceImpl<ExamRoomDao, ExamRoomEntity
|
|
//更新教学点容量
|
|
//更新教学点容量
|
|
categoryService.updateTeachingCapacity(newExamSite.getCategoryId());
|
|
categoryService.updateTeachingCapacity(newExamSite.getCategoryId());
|
|
|
|
|
|
- // 考点下没有启用的考场,容量设置为0
|
|
|
|
|
|
+ /* // 考点下没有启用的考场,容量设置为0
|
|
if (oldExamSite.getCapacity() == null) {
|
|
if (oldExamSite.getCapacity() == null) {
|
|
oldExamSite.setCapacity(0);
|
|
oldExamSite.setCapacity(0);
|
|
}
|
|
}
|
|
if (newExamSite.getCapacity() == null) {
|
|
if (newExamSite.getCapacity() == null) {
|
|
newExamSite.setCapacity(0);
|
|
newExamSite.setCapacity(0);
|
|
- }
|
|
|
|
|
|
+ }*/
|
|
|
|
+
|
|
|
|
+ //刷新考点容量缓存(以前的逻辑)
|
|
|
|
+ //cacheService.refreshApplyAvailableCountCache(examSiteId, oldExamSite.getCapacity(), newExamSite.getCapacity());
|
|
|
|
+ }
|
|
|
|
|
|
- //刷新考点容量缓存
|
|
|
|
- cacheService.refreshApplyAvailableCountCache(examSiteId, oldExamSite.getCapacity(), newExamSite.getCapacity());
|
|
|
|
|
|
+ private void refreshApplyCountCache(Long examRoomId,Long examSiteId, int oldCapacity, int newCapacity) {
|
|
|
|
+ List<TimePeriodEntity> timePeriods = timePeriodService.list(new LambdaQueryWrapper<TimePeriodEntity>().select(TimePeriodEntity::getId));
|
|
|
|
+ //考场时段列表
|
|
|
|
+ List<TimePeriodExamRoomEntity> timePeriodExamRooms = timePeriodExamRoomService.listExamRoom(examRoomId);
|
|
|
|
+ //将timePeriodExamRooms转Map
|
|
|
|
+ Map<Long, TimePeriodExamRoomEntity> timePeriodExamRoomMap = timePeriodExamRooms.stream().collect(
|
|
|
|
+ Collectors.toMap(TimePeriodExamRoomEntity::getTimePeriodId, Function.identity()));
|
|
|
|
+
|
|
|
|
+ for(TimePeriodEntity timePeriod : timePeriods) {
|
|
|
|
+ //刷新缓存
|
|
|
|
+ TimePeriodExamRoomEntity timePeriodExamRoomEntity = timePeriodExamRoomMap.get(timePeriod.getId());
|
|
|
|
+ if(timePeriodExamRoomEntity == null || timePeriodExamRoomEntity.getEnable()) {
|
|
|
|
+ cacheService.refreshApplyAvailableCountCache(examSiteId, timePeriod.getId(), oldCapacity, newCapacity);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
private void checkExamRoom(ExamRoomSaveReq req) {
|
|
private void checkExamRoom(ExamRoomSaveReq req) {
|