|
@@ -4,6 +4,8 @@ import cn.hutool.core.collection.CollUtil;
|
|
|
import cn.hutool.core.convert.Convert;
|
|
import cn.hutool.core.convert.Convert;
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
|
|
+import com.alibaba.excel.EasyExcel;
|
|
|
|
|
+import com.alibaba.excel.ExcelReader;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.izouma.wenlvju.domain.ArtType;
|
|
import com.izouma.wenlvju.domain.ArtType;
|
|
|
import com.izouma.wenlvju.domain.GradingOrganization;
|
|
import com.izouma.wenlvju.domain.GradingOrganization;
|
|
@@ -24,7 +26,9 @@ import com.izouma.wenlvju.repo.SettingRepo;
|
|
|
import com.izouma.wenlvju.repo.performance.*;
|
|
import com.izouma.wenlvju.repo.performance.*;
|
|
|
import com.izouma.wenlvju.service.ArtTypeService;
|
|
import com.izouma.wenlvju.service.ArtTypeService;
|
|
|
import com.izouma.wenlvju.utils.JpaUtils;
|
|
import com.izouma.wenlvju.utils.JpaUtils;
|
|
|
|
|
+import com.izouma.wenlvju.utils.excel.ExcelListener;
|
|
|
import com.izouma.wenlvju.utils.excel.ExcelUtils;
|
|
import com.izouma.wenlvju.utils.excel.ExcelUtils;
|
|
|
|
|
+import com.izouma.wenlvju.utils.excel.UploadDataListener;
|
|
|
import lombok.AllArgsConstructor;
|
|
import lombok.AllArgsConstructor;
|
|
|
import org.springframework.data.domain.Page;
|
|
import org.springframework.data.domain.Page;
|
|
|
import org.springframework.data.domain.PageImpl;
|
|
import org.springframework.data.domain.PageImpl;
|
|
@@ -110,24 +114,11 @@ public class ProgrammeService {
|
|
|
.stream()
|
|
.stream()
|
|
|
.collect(Collectors.toMap(Setting::getId, Setting::getName));
|
|
.collect(Collectors.toMap(Setting::getId, Setting::getName));
|
|
|
|
|
|
|
|
-// Map<Long, Long> participantMap = participantRepo.findAllByProgrammeIdIn(ids)
|
|
|
|
|
-// .stream()
|
|
|
|
|
-// .collect(Collectors.groupingBy(Participant::getProgrammeId, Collectors.counting()));
|
|
|
|
|
- return all.map(programme -> {
|
|
|
|
|
-// if (participantMap.containsKey(programme.getId())) {
|
|
|
|
|
-// return toDTO(programme, performanceMap.get(programme.getPerformanceId()),
|
|
|
|
|
-// organizationMap.get(programme.getOrganizationId()),
|
|
|
|
|
-// gradingOrganizationMap.get(programme.getGradingOrganizationId()),
|
|
|
|
|
-// artTypeMap.get(programme.getSpecialtyId()),
|
|
|
|
|
-// settingMap.get(programme.getLevelSettingId()),
|
|
|
|
|
-// participantMap.get(programme.getId()));
|
|
|
|
|
-// }
|
|
|
|
|
- return toDTO(programme, performanceMap.get(programme.getPerformanceId()),
|
|
|
|
|
- organizationMap.get(programme.getOrganizationId()),
|
|
|
|
|
- gradingOrganizationMap.get(programme.getGradingOrganizationId()),
|
|
|
|
|
- artTypeMap.get(programme.getSpecialtyId()),
|
|
|
|
|
- settingMap.get(programme.getLevelSettingId()));
|
|
|
|
|
- });
|
|
|
|
|
|
|
+ return all.map(programme -> toDTO(programme, performanceMap.get(programme.getPerformanceId()),
|
|
|
|
|
+ organizationMap.get(programme.getOrganizationId()),
|
|
|
|
|
+ gradingOrganizationMap.get(programme.getGradingOrganizationId()),
|
|
|
|
|
+ artTypeMap.get(programme.getSpecialtyId()),
|
|
|
|
|
+ settingMap.get(programme.getLevelSettingId())));
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
public ProgrammeDTO toDTO(Programme programme, String performance, String organization, String gradingOrganization, String artType,
|
|
public ProgrammeDTO toDTO(Programme programme, String performance, String organization, String gradingOrganization, String artType,
|
|
@@ -144,7 +135,7 @@ public class ProgrammeService {
|
|
|
|
|
|
|
|
public List<ProgrammeDTO> toDTOList(List<Programme> programmes) {
|
|
public List<ProgrammeDTO> toDTOList(List<Programme> programmes) {
|
|
|
|
|
|
|
|
-// List<Long> ids = programmes.stream().map(Programme::getId).collect(Collectors.toList());
|
|
|
|
|
|
|
+ List<Long> ids = programmes.stream().map(Programme::getId).collect(Collectors.toList());
|
|
|
|
|
|
|
|
Map<Long, String> performanceMap = performanceRepo.findAll()
|
|
Map<Long, String> performanceMap = performanceRepo.findAll()
|
|
|
.stream()
|
|
.stream()
|
|
@@ -163,24 +154,19 @@ public class ProgrammeService {
|
|
|
.stream()
|
|
.stream()
|
|
|
.collect(Collectors.toMap(Setting::getId, Setting::getName));
|
|
.collect(Collectors.toMap(Setting::getId, Setting::getName));
|
|
|
|
|
|
|
|
-// Map<Long, Long> participantMap = participantRepo.findAllByProgrammeIdIn(ids)
|
|
|
|
|
-// .stream()
|
|
|
|
|
-// .collect(Collectors.groupingBy(Participant::getProgrammeId, Collectors.counting()));
|
|
|
|
|
|
|
+ Map<Long, List<Participant>> participantMap = participantRepo.findAllByProgrammeIdIn(ids)
|
|
|
|
|
+ .stream()
|
|
|
|
|
+ .collect(Collectors.groupingBy(Participant::getProgrammeId));
|
|
|
|
|
|
|
|
return programmes.stream().map(programme -> {
|
|
return programmes.stream().map(programme -> {
|
|
|
-// if (participantMap.containsKey(programme.getId())) {
|
|
|
|
|
-// return toDTO(programme, performanceMap.get(programme.getPerformanceId()),
|
|
|
|
|
-// organizationMap.get(programme.getOrganizationId()),
|
|
|
|
|
-// gradingOrganizationMap.get(programme.getGradingOrganizationId()),
|
|
|
|
|
-// artTypeMap.get(programme.getSpecialtyId()),
|
|
|
|
|
-// settingMap.get(programme.getLevelSettingId()),
|
|
|
|
|
-// participantMap.get(programme.getId()));
|
|
|
|
|
-// }
|
|
|
|
|
- return toDTO(programme, performanceMap.get(programme.getPerformanceId()),
|
|
|
|
|
|
|
+ List<Participant> participants = participantMap.get(programme.getId());
|
|
|
|
|
+ ProgrammeDTO programmeDTO = toDTO(programme, performanceMap.get(programme.getPerformanceId()),
|
|
|
organizationMap.get(programme.getOrganizationId()),
|
|
organizationMap.get(programme.getOrganizationId()),
|
|
|
gradingOrganizationMap.get(programme.getGradingOrganizationId()),
|
|
gradingOrganizationMap.get(programme.getGradingOrganizationId()),
|
|
|
artTypeMap.get(programme.getSpecialtyId()),
|
|
artTypeMap.get(programme.getSpecialtyId()),
|
|
|
settingMap.get(programme.getLevelSettingId()));
|
|
settingMap.get(programme.getLevelSettingId()));
|
|
|
|
|
+ participants.forEach(programmeDTO::setParticipant);
|
|
|
|
|
+ return programmeDTO;
|
|
|
}).collect(Collectors.toList());
|
|
}).collect(Collectors.toList());
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -198,7 +184,8 @@ public class ProgrammeService {
|
|
|
baos.flush();
|
|
baos.flush();
|
|
|
|
|
|
|
|
InputStream indicatorStream = new ByteArrayInputStream(baos.toByteArray());
|
|
InputStream indicatorStream = new ByteArrayInputStream(baos.toByteArray());
|
|
|
- List<ProgrammeDTO> dtos = ExcelUtils.readExcel(indicatorStream, ProgrammeDTO.class, 1, 1);
|
|
|
|
|
|
|
+ UploadDataListener<ProgrammeDTO> listener = new UploadDataListener<>();
|
|
|
|
|
+ List<ProgrammeDTO> dtos = EasyExcel.read(indicatorStream, ProgrammeDTO.class, listener).sheet().doReadSync();
|
|
|
|
|
|
|
|
Map<String, Long> performanceMap = performanceRepo.findAll()
|
|
Map<String, Long> performanceMap = performanceRepo.findAll()
|
|
|
.stream()
|
|
.stream()
|
|
@@ -287,12 +274,7 @@ public class ProgrammeService {
|
|
|
programmes.sort((a, b) -> {
|
|
programmes.sort((a, b) -> {
|
|
|
if (a.getOrganizationId().equals(b.getOrganizationId())) {
|
|
if (a.getOrganizationId().equals(b.getOrganizationId())) {
|
|
|
if (a.getOrganizationId().equals(b.getOrganizationId())) {
|
|
if (a.getOrganizationId().equals(b.getOrganizationId())) {
|
|
|
-// if (StrUtil.isNotBlank(a.getExamPoint()) && StrUtil.isNotBlank(b.getExamPoint()) && a.getExamPoint()
|
|
|
|
|
-// .equals(b.getExamPoint())) {
|
|
|
|
|
return a.getSpecialtyId().compareTo(b.getSpecialtyId());
|
|
return a.getSpecialtyId().compareTo(b.getSpecialtyId());
|
|
|
-// } else {
|
|
|
|
|
-// return a.getExamPoint().compareTo(b.getExamPoint());
|
|
|
|
|
-// }
|
|
|
|
|
} else {
|
|
} else {
|
|
|
return a.getOrganizationId().compareTo(b.getOrganizationId());
|
|
return a.getOrganizationId().compareTo(b.getOrganizationId());
|
|
|
}
|
|
}
|