|
|
@@ -11,10 +11,7 @@ import com.izouma.wenlvju.config.DateConfig;
|
|
|
import com.izouma.wenlvju.domain.*;
|
|
|
import com.izouma.wenlvju.domain.performance.*;
|
|
|
import com.izouma.wenlvju.dto.*;
|
|
|
-import com.izouma.wenlvju.enums.CompetitionGroup;
|
|
|
-import com.izouma.wenlvju.enums.ProgrammeProcess;
|
|
|
-import com.izouma.wenlvju.enums.ProgrammeStatus;
|
|
|
-import com.izouma.wenlvju.enums.SignedIn;
|
|
|
+import com.izouma.wenlvju.enums.*;
|
|
|
import com.izouma.wenlvju.exception.BusinessException;
|
|
|
import com.izouma.wenlvju.repo.*;
|
|
|
import com.izouma.wenlvju.repo.performance.*;
|
|
|
@@ -331,7 +328,6 @@ public class ProgrammeService {
|
|
|
public Map<String, String> group(List<Programme> byPerformanceId, Arrange arrange) {
|
|
|
boolean flag = true;
|
|
|
|
|
|
-
|
|
|
int quantity = arrange.getQuantity();
|
|
|
if (byPerformanceId.size() < quantity) {
|
|
|
flag = false;
|
|
|
@@ -367,11 +363,10 @@ public class ProgrammeService {
|
|
|
}
|
|
|
|
|
|
@Transactional(rollbackOn = Exception.class)
|
|
|
- public Map<String, String> group1(Arrange arrange) {
|
|
|
+ public Map<String, String> group1(List<Programme> byPerformanceId, Arrange arrange) {
|
|
|
// 是否继续分组
|
|
|
boolean flag = true;
|
|
|
|
|
|
- List<Programme> byPerformanceId = programmeRepo.findAllByPerformanceIdAndProgrammeStatus(arrange.getPerformanceId(), ProgrammeStatus.SUBMIT);
|
|
|
int quantity = arrange.getQuantity();
|
|
|
if (byPerformanceId.size() < quantity) {
|
|
|
flag = false;
|
|
|
@@ -379,8 +374,6 @@ public class ProgrammeService {
|
|
|
|
|
|
List<Programme> result = new ArrayList<>(quantity);
|
|
|
if (CollUtil.isNotEmpty(arrange.getSpecialtyId())) {
|
|
|
-
|
|
|
-// List<Long> artTypeChild = artTypeService.getChild(arrange.getSpecialtyId(), new ArrayList<>(arrange.getSpecialtyId()));
|
|
|
List<Programme> programmeList = byPerformanceId.stream()
|
|
|
.filter(programme -> arrange.getSpecialtyId().contains(programme.getParentSpecialtyId()))
|
|
|
.collect(Collectors.toList());
|
|
|
@@ -388,7 +381,7 @@ public class ProgrammeService {
|
|
|
int size = programmeList.size();
|
|
|
if (size < quantity) {
|
|
|
programmeList.addAll(byPerformanceId.stream()
|
|
|
- .filter(programme -> !arrange.getSpecialtyId().contains(programme.getSpecialtyId()))
|
|
|
+ .filter(programme -> !arrange.getSpecialtyId().contains(programme.getParentSpecialtyId()))
|
|
|
.limit(quantity - size)
|
|
|
.collect(Collectors.toList()));
|
|
|
flag = false;
|
|
|
@@ -406,13 +399,13 @@ public class ProgrammeService {
|
|
|
return map;
|
|
|
}
|
|
|
|
|
|
- public void saveAll(List<Programme> programmes, Long arrangeId) {
|
|
|
- programmes.forEach(programme -> {
|
|
|
- programme.setArrangeId(arrangeId);
|
|
|
- programme.setProgrammeProcess(ProgrammeProcess.ARRANGE);
|
|
|
-// programme.setStatus(4);
|
|
|
- });
|
|
|
- programmeRepo.saveAll(programmes);
|
|
|
+ public void saveAll(List<Programme> programmes, Long arrangeId, int times) {
|
|
|
+ List<Long> ids = programmes.stream().map(Programme::getId).collect(Collectors.toList());
|
|
|
+ if (times > 1) {
|
|
|
+ programmeRepo.setReviewArrangeId(arrangeId, ids);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ programmeRepo.setArrangeId(arrangeId, ids);
|
|
|
}
|
|
|
|
|
|
public void sort(List<Programme> programmes) {
|
|
|
@@ -433,40 +426,105 @@ public class ProgrammeService {
|
|
|
/*
|
|
|
移除分组
|
|
|
*/
|
|
|
- public void removeArrange(Long id) {
|
|
|
+ public void removeArrange(Long id, Long arrangeId) {
|
|
|
Programme programme = programmeRepo.findById(id).orElseThrow(new BusinessException("无记录"));
|
|
|
- Long arrangeId = programme.getArrangeId();
|
|
|
-// programme.setStatus(0);
|
|
|
- programme.setProgrammeStatus(ProgrammeStatus.INITIAL);
|
|
|
+ Arrange arrange = arrangeRepo.findById(arrangeId).orElseThrow(new BusinessException("无分组"));
|
|
|
+ if (arrange.getAuditTimes() > 1) {
|
|
|
+ programme.setReviewArrangeId(null);
|
|
|
+ programmeRepo.save(programme);
|
|
|
+ // 此分组的专业,是否要移除专业
|
|
|
+ List<Long> specialtyIds = programmeRepo.findAllByReviewArrangeId(id)
|
|
|
+ .stream()
|
|
|
+ .map(Programme::getParentSpecialtyId)
|
|
|
+ .distinct()
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ arrange.setSpecialtyId(specialtyIds);
|
|
|
+ arrange.setQuantity(arrange.getQuantity() - 1);
|
|
|
+ arrangeRepo.save(arrange);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
programme.setArrangeId(null);
|
|
|
programmeRepo.save(programme);
|
|
|
- arrangeRepo.minusQuantity(arrangeId);
|
|
|
+ // 此分组的专业,是否要移除专业
|
|
|
+ List<Long> specialtyIds = programmeRepo.findAllByArrangeId(arrangeId)
|
|
|
+ .stream()
|
|
|
+ .map(Programme::getParentSpecialtyId)
|
|
|
+ .distinct()
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ arrange.setSpecialtyId(specialtyIds);
|
|
|
+ arrange.setQuantity(arrange.getQuantity() - 1);
|
|
|
+ arrangeRepo.save(arrange);
|
|
|
}
|
|
|
|
|
|
/*
|
|
|
增加节目
|
|
|
*/
|
|
|
public void add(Long id, Long arrangeId) {
|
|
|
-// LocalDateTime showTime = programmeRepo.findFirstByArrangeIdOrderByShowTimeDesc(arrangeId).getShowTime();
|
|
|
Arrange arrange = arrangeRepo.findById(arrangeId).orElseThrow(new BusinessException("无记录"));
|
|
|
Programme programme = programmeRepo.findById(id).orElseThrow(new BusinessException("无记录"));
|
|
|
-// programme.setShowTime(showTime.plusMinutes(arrange.getDuration()));
|
|
|
- programme.setArrangeId(arrangeId);
|
|
|
-// programme.setStatus(4);
|
|
|
- programme.setProgrammeProcess(ProgrammeProcess.ARRANGE);
|
|
|
+ if (arrange.getAuditTimes() > 1) {
|
|
|
+ programme.setReviewArrangeId(arrangeId);
|
|
|
+ } else {
|
|
|
+ programme.setArrangeId(arrangeId);
|
|
|
+ }
|
|
|
programmeRepo.save(programme);
|
|
|
|
|
|
arrange.setQuantity(arrange.getQuantity() + 1);
|
|
|
+ List<Long> specialtyId = arrange.getSpecialtyId();
|
|
|
+ if (!specialtyId.contains(programme.getParentSpecialtyId())) {
|
|
|
+ specialtyId.add(programme.getParentSpecialtyId());
|
|
|
+ }
|
|
|
arrangeRepo.save(arrange);
|
|
|
}
|
|
|
|
|
|
/*
|
|
|
未分组节目
|
|
|
*/
|
|
|
- public List<Programme> ungrouped(Long performanceId) {
|
|
|
- List<Programme> programmes = programmeRepo.findAllByPerformanceIdAndProgrammeStatus(performanceId, ProgrammeStatus.SUBMIT);
|
|
|
- this.sort(programmes);
|
|
|
- return programmes;
|
|
|
+ public List<ProgrammeShowDTO> ungrouped(Long performanceId) {
|
|
|
+ Performance performance = performanceRepo.findById(performanceId).orElseThrow(new BusinessException("无展演"));
|
|
|
+ if (performance.getAuditTimes() > 1) {
|
|
|
+ List<Programme> programmes = programmeRepo.findAllByPerformanceIdAndReviewArrangeIdIsNull(performanceId);
|
|
|
+ if (CollUtil.isNotEmpty(programmes)) {
|
|
|
+ this.sort(programmes);
|
|
|
+ return this.toShowDTOList(programmes, performance.getName());
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ List<Programme> programmes = programmeRepo.findAllByPerformanceIdAndArrangeIdIsNull(performanceId);
|
|
|
+ if (CollUtil.isNotEmpty(programmes)) {
|
|
|
+ this.sort(programmes);
|
|
|
+ return this.toShowDTOList(programmes, performance.getName());
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ private List<ProgrammeShowDTO> toShowDTOList(List<Programme> programmes, String name) {
|
|
|
+ Map<Long, String> settingMap = settingRepo.findAllByFlagIn(CollUtil.newArrayList(3, 4))
|
|
|
+ .stream()
|
|
|
+ .collect(Collectors.toMap(Setting::getId, Setting::getName));
|
|
|
+
|
|
|
+ Map<Long, String> gradeMap = gradingOrganizationRepo.findAll()
|
|
|
+ .stream()
|
|
|
+ .collect(Collectors.toMap(GradingOrganization::getId, GradingOrganization::getName));
|
|
|
+
|
|
|
+ Map<Long, String> artTypeMap = artTypeRepo.findAll()
|
|
|
+ .stream()
|
|
|
+ .collect(Collectors.toMap(ArtType::getId, ArtType::getName));
|
|
|
+
|
|
|
+ Set<Long> ids = programmes.stream().map(Programme::getOrganizationId).collect(Collectors.toSet());
|
|
|
+ Map<Long, String> organizationMap = organizationRepo.findAllById(ids)
|
|
|
+ .stream()
|
|
|
+ .collect(Collectors.toMap(Organization::getId, Organization::getName));
|
|
|
+
|
|
|
+ return programmes.stream().map(programme -> {
|
|
|
+ ProgrammeShowDTO dto = new ProgrammeShowDTO(programme);
|
|
|
+ dto.setLevel(settingMap.get(programme.getLevelSettingId()));
|
|
|
+ dto.setGradingOrganization(gradeMap.get(programme.getGradingOrganizationId()));
|
|
|
+ dto.setOrganization(organizationMap.get(programme.getOrganizationId()));
|
|
|
+ dto.setSpecialty(artTypeMap.get(programme.getSpecialtyId()));
|
|
|
+ return dto;
|
|
|
+ }).collect(Collectors.toList());
|
|
|
}
|
|
|
|
|
|
/*
|
|
|
@@ -505,17 +563,25 @@ public class ProgrammeService {
|
|
|
/*
|
|
|
签到
|
|
|
*/
|
|
|
- public void signIn(Long id, SignedIn signedIn, String description) {
|
|
|
+ public void signIn(Long id, SignedIn signedIn, String description, Long userId) {
|
|
|
Programme programme = programmeRepo.findById(id).orElseThrow(new BusinessException("无节目"));
|
|
|
programme.setSignedIn(signedIn);
|
|
|
- programme.setDescription(description);
|
|
|
- programme.setSignedAt(LocalDateTime.now());
|
|
|
+// programme.setDescription(description);
|
|
|
+// programme.setSignedAt(LocalDateTime.now());
|
|
|
programmeRepo.save(programme);
|
|
|
|
|
|
long unSigned = programmeRepo.countAllByArrangeIdAndProgrammeStatusIsNotNull(programme.getArrangeId());
|
|
|
if (unSigned == 0) {
|
|
|
programmeRepo.allSigned(programme.getArrangeId());
|
|
|
}
|
|
|
+ if (SignedIn.SIGNED_IN.equals(signedIn) && StrUtil.isEmpty(description)) {
|
|
|
+ description = "已签到";
|
|
|
+ }
|
|
|
+ rateAuditRepo.save(RateAudit.builder()
|
|
|
+ .userId(userId)
|
|
|
+ .status(PerformanceStatus.SIGN_IN.toString())
|
|
|
+ .remark(description)
|
|
|
+ .build());
|
|
|
}
|
|
|
|
|
|
public ProgrammeScoreDTO getDTO(Long id, Long userId) {
|
|
|
@@ -621,6 +687,11 @@ public class ProgrammeService {
|
|
|
.map(ParticipantDTO::new)
|
|
|
.collect(Collectors.toList());
|
|
|
dto.setParticipants(participants);
|
|
|
+ organizationRepo.findById(programme.getOrganizationId()).ifPresent(og -> dto.setOrganization(og.getName()));
|
|
|
+ gradingOrganizationRepo.findById(programme.getGradingOrganizationId())
|
|
|
+ .ifPresent(go -> dto.setGradingOrganization(go.getName()));
|
|
|
+ artTypeRepo.findById(programme.getSpecialtyId()).ifPresent(at -> dto.setSpecialty(at.getName()));
|
|
|
+ settingRepo.findById(programme.getLevelSettingId()).ifPresent(st -> dto.setLevel(st.getName()));
|
|
|
return dto;
|
|
|
}
|
|
|
}
|