|
@@ -9,12 +9,11 @@ import com.izouma.wenlvju.domain.ArtType;
|
|
|
import com.izouma.wenlvju.domain.GradingOrganization;
|
|
import com.izouma.wenlvju.domain.GradingOrganization;
|
|
|
import com.izouma.wenlvju.domain.Organization;
|
|
import com.izouma.wenlvju.domain.Organization;
|
|
|
import com.izouma.wenlvju.domain.Setting;
|
|
import com.izouma.wenlvju.domain.Setting;
|
|
|
-import com.izouma.wenlvju.domain.performance.Arrange;
|
|
|
|
|
-import com.izouma.wenlvju.domain.performance.Performance;
|
|
|
|
|
-import com.izouma.wenlvju.domain.performance.Programme;
|
|
|
|
|
|
|
+import com.izouma.wenlvju.domain.performance.*;
|
|
|
import com.izouma.wenlvju.dto.ArrangeProgrammeDTO;
|
|
import com.izouma.wenlvju.dto.ArrangeProgrammeDTO;
|
|
|
import com.izouma.wenlvju.dto.PageQuery;
|
|
import com.izouma.wenlvju.dto.PageQuery;
|
|
|
import com.izouma.wenlvju.dto.ProgrammeDTO;
|
|
import com.izouma.wenlvju.dto.ProgrammeDTO;
|
|
|
|
|
+import com.izouma.wenlvju.dto.ProgrammeScoreDTO;
|
|
|
import com.izouma.wenlvju.enums.CompetitionGroup;
|
|
import com.izouma.wenlvju.enums.CompetitionGroup;
|
|
|
import com.izouma.wenlvju.enums.SignedIn;
|
|
import com.izouma.wenlvju.enums.SignedIn;
|
|
|
import com.izouma.wenlvju.exception.BusinessException;
|
|
import com.izouma.wenlvju.exception.BusinessException;
|
|
@@ -22,14 +21,13 @@ import com.izouma.wenlvju.repo.ArtTypeRepo;
|
|
|
import com.izouma.wenlvju.repo.GradingOrganizationRepo;
|
|
import com.izouma.wenlvju.repo.GradingOrganizationRepo;
|
|
|
import com.izouma.wenlvju.repo.OrganizationRepo;
|
|
import com.izouma.wenlvju.repo.OrganizationRepo;
|
|
|
import com.izouma.wenlvju.repo.SettingRepo;
|
|
import com.izouma.wenlvju.repo.SettingRepo;
|
|
|
-import com.izouma.wenlvju.repo.performance.ArrangeRepo;
|
|
|
|
|
-import com.izouma.wenlvju.repo.performance.PerformanceRepo;
|
|
|
|
|
-import com.izouma.wenlvju.repo.performance.ProgrammeRepo;
|
|
|
|
|
|
|
+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.ExcelUtils;
|
|
import com.izouma.wenlvju.utils.excel.ExcelUtils;
|
|
|
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.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
import javax.persistence.criteria.Predicate;
|
|
import javax.persistence.criteria.Predicate;
|
|
@@ -47,7 +45,7 @@ import java.util.stream.Collectors;
|
|
|
public class ProgrammeService {
|
|
public class ProgrammeService {
|
|
|
|
|
|
|
|
private ProgrammeRepo programmeRepo;
|
|
private ProgrammeRepo programmeRepo;
|
|
|
- // private ParticipantRepo participantRepo;
|
|
|
|
|
|
|
+ private ParticipantRepo participantRepo;
|
|
|
private GradingOrganizationRepo gradingOrganizationRepo;
|
|
private GradingOrganizationRepo gradingOrganizationRepo;
|
|
|
private OrganizationRepo organizationRepo;
|
|
private OrganizationRepo organizationRepo;
|
|
|
private ArtTypeRepo artTypeRepo;
|
|
private ArtTypeRepo artTypeRepo;
|
|
@@ -55,6 +53,9 @@ public class ProgrammeService {
|
|
|
private ArtTypeService artTypeService;
|
|
private ArtTypeService artTypeService;
|
|
|
private PerformanceRepo performanceRepo;
|
|
private PerformanceRepo performanceRepo;
|
|
|
private ArrangeRepo arrangeRepo;
|
|
private ArrangeRepo arrangeRepo;
|
|
|
|
|
+ private ProgrammeScoreRepo programmeScoreRepo;
|
|
|
|
|
+ private ArrangeJudgeRepo arrangeJudgeRepo;
|
|
|
|
|
+
|
|
|
|
|
|
|
|
public Page<Programme> all(PageQuery pageQuery) {
|
|
public Page<Programme> all(PageQuery pageQuery) {
|
|
|
return programmeRepo.findAll(JpaUtils.toSpecification(pageQuery, Programme.class), JpaUtils.toPageRequest(pageQuery));
|
|
return programmeRepo.findAll(JpaUtils.toSpecification(pageQuery, Programme.class), JpaUtils.toPageRequest(pageQuery));
|
|
@@ -366,6 +367,9 @@ public class ProgrammeService {
|
|
|
});
|
|
});
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ /*
|
|
|
|
|
+ 签到
|
|
|
|
|
+ */
|
|
|
public void signIn(Long id, SignedIn signedIn, String description) {
|
|
public void signIn(Long id, SignedIn signedIn, String description) {
|
|
|
Programme programme = programmeRepo.findById(id).orElseThrow(new BusinessException("无节目"));
|
|
Programme programme = programmeRepo.findById(id).orElseThrow(new BusinessException("无节目"));
|
|
|
programme.setSignedIn(signedIn);
|
|
programme.setSignedIn(signedIn);
|
|
@@ -378,4 +382,80 @@ public class ProgrammeService {
|
|
|
programmeRepo.allSigned(programme.getArrangeId());
|
|
programmeRepo.allSigned(programme.getArrangeId());
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ public ProgrammeScoreDTO getDTO(Long id, Long userId) {
|
|
|
|
|
+ Programme programme = programmeRepo.findById(id).orElseThrow(new BusinessException("无节目"));
|
|
|
|
|
+ ProgrammeScoreDTO dto = new ProgrammeScoreDTO(programme);
|
|
|
|
|
+ artTypeRepo.findById(programme.getSpecialtyId()).ifPresent(at -> dto.setSpecialty(at.getName()));
|
|
|
|
|
+ arrangeRepo.findById(programme.getArrangeId()).ifPresent(arr -> dto.setArrangeName(arr.getName()));
|
|
|
|
|
+ ProgrammeScore programmeScore = programmeScoreRepo.findByProgrammeIdAndExpertId(programme.getId(), userId);
|
|
|
|
|
+ if (ObjectUtil.isNotNull(programmeScore)) {
|
|
|
|
|
+ dto.setMyScore(programmeScore.getScore());
|
|
|
|
|
+ dto.setRemark(programmeScore.getRemark());
|
|
|
|
|
+ dto.setSecond(programmeScore.isSecond());
|
|
|
|
|
+ }
|
|
|
|
|
+ List<String> participants = participantRepo.findAllByProgrammeId(programme.getId())
|
|
|
|
|
+ .stream()
|
|
|
|
|
+ .map(Participant::getName)
|
|
|
|
|
+ .collect(Collectors.toList());
|
|
|
|
|
+ dto.setParticipant(participants);
|
|
|
|
|
+ return dto;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public Page<ProgrammeScoreDTO> byExpert(PageQuery pageQuery, Long userId) {
|
|
|
|
|
+ pageQuery.setSort("showBegin,asc;");
|
|
|
|
|
+ Long arrangeId = Convert.convert(Long.class, pageQuery.getQuery().get("arrangeId"));
|
|
|
|
|
+ return this.toDTOPage(this.all(pageQuery), Collections.singletonList(arrangeId), userId);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public Page<ProgrammeScoreDTO> byScore(PageQuery pageQuery, Long userId) {
|
|
|
|
|
+ List<Long> arrangeId = arrangeJudgeRepo.findArrangeIdByExpertId(userId);
|
|
|
|
|
+ if (CollUtil.isEmpty(arrangeId)) {
|
|
|
|
|
+ return new PageImpl<>(new ArrayList<>(), JpaUtils.toPageRequest(pageQuery), 0);
|
|
|
|
|
+ }
|
|
|
|
|
+ pageQuery.setSort("allScore,asc;showBegin,asc;arrangeId,asc;");
|
|
|
|
|
+ Page<Programme> all = programmeRepo.findAll(((root, criteriaQuery, criteriaBuilder) -> {
|
|
|
|
|
+ List<Predicate> and = JpaUtils.toPredicates(pageQuery, Programme.class, root, criteriaQuery, criteriaBuilder);
|
|
|
|
|
+ and.add(root.get("arrangeId").in(arrangeId));
|
|
|
|
|
+ return criteriaBuilder.and(and.toArray(new Predicate[0]));
|
|
|
|
|
+ }), JpaUtils.toPageRequest(pageQuery));
|
|
|
|
|
+
|
|
|
|
|
+ return this.toDTOPage(all, arrangeId, userId);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private Page<ProgrammeScoreDTO> toDTOPage(Page<Programme> all, Collection<Long> arrangeId, Long userId) {
|
|
|
|
|
+ List<Long> ids = all.getContent().stream().map(Programme::getId).distinct().collect(Collectors.toList());
|
|
|
|
|
+ Map<Long, List<Participant>> participantMap = participantRepo.findAllByProgrammeIdIn(ids)
|
|
|
|
|
+ .stream()
|
|
|
|
|
+ .collect(Collectors.groupingBy(Participant::getProgrammeId));
|
|
|
|
|
+ Map<Long, String> artTypeMap = artTypeRepo.findAll()
|
|
|
|
|
+ .stream()
|
|
|
|
|
+ .collect(Collectors.toMap(ArtType::getId, ArtType::getName));
|
|
|
|
|
+
|
|
|
|
|
+ Map<Long, String> arrangeMap = arrangeRepo.findAllById(arrangeId)
|
|
|
|
|
+ .stream()
|
|
|
|
|
+ .collect(Collectors.toMap(Arrange::getId, Arrange::getName));
|
|
|
|
|
+
|
|
|
|
|
+ Map<Long, ProgrammeScore> scoreMap = programmeScoreRepo.findByProgrammeIdInAndExpertId(ids, userId)
|
|
|
|
|
+ .stream()
|
|
|
|
|
+ .collect(Collectors.toMap(ProgrammeScore::getProgrammeId, programmeScore -> programmeScore));
|
|
|
|
|
+
|
|
|
|
|
+ return all.map(programme -> {
|
|
|
|
|
+ ProgrammeScoreDTO dto = new ProgrammeScoreDTO(programme);
|
|
|
|
|
+ dto.setSpecialty(artTypeMap.get(programme.getSpecialtyId()));
|
|
|
|
|
+ dto.setArrangeName(arrangeMap.get(programme.getArrangeId()));
|
|
|
|
|
+ ProgrammeScore programmeScore = scoreMap.get(programme.getId());
|
|
|
|
|
+ if (ObjectUtil.isNotNull(programmeScore)) {
|
|
|
|
|
+ dto.setMyScore(programmeScore.getScore());
|
|
|
|
|
+ dto.setRemark(programmeScore.getRemark());
|
|
|
|
|
+ dto.setSecond(programmeScore.isSecond());
|
|
|
|
|
+ }
|
|
|
|
|
+ List<String> participants = participantMap.get(programme.getId())
|
|
|
|
|
+ .stream()
|
|
|
|
|
+ .map(Participant::getName)
|
|
|
|
|
+ .collect(Collectors.toList());
|
|
|
|
|
+ dto.setParticipant(participants);
|
|
|
|
|
+ return dto;
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|