|
|
@@ -7,18 +7,16 @@ import com.alibaba.fastjson.JSONObject;
|
|
|
import com.github.kevinsawicki.http.HttpRequest;
|
|
|
import com.izouma.wenlvju.domain.ExamRoom;
|
|
|
import com.izouma.wenlvju.domain.Record;
|
|
|
+import com.izouma.wenlvju.dto.ExamRoomDTO;
|
|
|
import com.izouma.wenlvju.dto.PageQuery;
|
|
|
import com.izouma.wenlvju.exception.BusinessException;
|
|
|
import com.izouma.wenlvju.repo.ExamRoomRepo;
|
|
|
-import com.izouma.wenlvju.repo.OrganizationRepo;
|
|
|
import com.izouma.wenlvju.utils.JpaUtils;
|
|
|
import lombok.AllArgsConstructor;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.data.domain.Page;
|
|
|
-import org.springframework.data.domain.PageImpl;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
-import javax.persistence.criteria.Predicate;
|
|
|
import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
@@ -27,10 +25,9 @@ import java.util.stream.Collectors;
|
|
|
@AllArgsConstructor
|
|
|
public class ExamRoomService {
|
|
|
|
|
|
- private final ExamRoomRepo examRoomRepo;
|
|
|
- private final EzvizTokenService ezvizTokenService;
|
|
|
- private final RecordService recordService;
|
|
|
- private final OrganizationRepo organizationRepo;
|
|
|
+ private final ExamRoomRepo examRoomRepo;
|
|
|
+ private final EzvizTokenService ezvizTokenService;
|
|
|
+ private final RecordService recordService;
|
|
|
|
|
|
public Page<ExamRoom> all(PageQuery pageQuery) {
|
|
|
return examRoomRepo.findAll(JpaUtils.toSpecification(pageQuery, ExamRoom.class), JpaUtils.toPageRequest(pageQuery));
|
|
|
@@ -150,30 +147,26 @@ public class ExamRoomService {
|
|
|
/*
|
|
|
展示今天备案中的所有考场信息
|
|
|
*/
|
|
|
- public List<ExamRoom> byToday(PageQuery pageQuery, boolean status) {
|
|
|
- List<Long> ids = new ArrayList<>();
|
|
|
+ public List<ExamRoomDTO> byToday(PageQuery pageQuery, Integer status) {
|
|
|
|
|
|
List<Record> all = recordService.all2(pageQuery).getContent();
|
|
|
+ Map<Long, Record> recordMap = all.stream().collect(Collectors.toMap(Record::getId, record -> record));
|
|
|
|
|
|
List<Long> rids = all.stream().map(Record::getId).collect(Collectors.toList());
|
|
|
if (CollUtil.isEmpty(rids)) {
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
-// ids.addAll(recordExamRoomRepo.findExamRoomIdByRecordIdIn(rids));
|
|
|
-
|
|
|
-
|
|
|
- if (CollUtil.isEmpty(ids)) {
|
|
|
- return null;
|
|
|
+ List<ExamRoom> examRooms = examRoomRepo.findAllByRecordIdIn(rids);
|
|
|
+ if (ObjectUtil.isNotEmpty(status)) {
|
|
|
+ Map<String, Integer> device = this.showDevice();
|
|
|
+ return examRooms.stream()
|
|
|
+ .filter(examRoom -> status.equals(device.get(examRoom.getDeviceSerial())))
|
|
|
+ .map(examRoom -> new ExamRoomDTO(examRoom, recordMap.get(examRoom.getRecordId())))
|
|
|
+ .collect(Collectors.toList());
|
|
|
}
|
|
|
- List<ExamRoom> rooms = examRoomRepo.findAllById(ids);
|
|
|
-// Set<Long> organizationIds = rooms.stream().map(ExamRoom::getOrganizationId).collect(Collectors.toSet());
|
|
|
-// Map<Long, String> organizationMap = organizationRepo.findAllById(organizationIds)
|
|
|
-// .stream()
|
|
|
-// .collect(Collectors.toMap(Organization::getId, Organization::getName));
|
|
|
-
|
|
|
-
|
|
|
-// rooms.forEach(room -> room.setRecord(null));
|
|
|
- return rooms;
|
|
|
+ return examRooms.stream()
|
|
|
+ .map(examRoom -> new ExamRoomDTO(examRoom, recordMap.get(examRoom.getRecordId())))
|
|
|
+ .collect(Collectors.toList());
|
|
|
}
|
|
|
}
|