|
|
@@ -1,17 +1,20 @@
|
|
|
package com.izouma.wenlvju.service;
|
|
|
|
|
|
+import cn.hutool.core.collection.CollUtil;
|
|
|
+import com.izouma.wenlvju.domain.Performance;
|
|
|
import com.izouma.wenlvju.domain.PerformanceApply;
|
|
|
import com.izouma.wenlvju.dto.PageQuery;
|
|
|
import com.izouma.wenlvju.enums.ApplyStatus;
|
|
|
import com.izouma.wenlvju.exception.BusinessException;
|
|
|
import com.izouma.wenlvju.repo.PerformanceApplyRepo;
|
|
|
+import com.izouma.wenlvju.repo.PerformanceRepo;
|
|
|
import com.izouma.wenlvju.utils.JpaUtils;
|
|
|
import lombok.AllArgsConstructor;
|
|
|
import org.springframework.data.domain.Page;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import java.time.LocalDateTime;
|
|
|
-import java.util.Comparator;
|
|
|
+import java.time.LocalTime;
|
|
|
import java.util.List;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
@@ -20,6 +23,7 @@ import java.util.stream.Collectors;
|
|
|
public class PerformanceApplyService {
|
|
|
|
|
|
private PerformanceApplyRepo performanceApplyRepo;
|
|
|
+ private PerformanceRepo performanceRepo;
|
|
|
|
|
|
public Page<PerformanceApply> all(PageQuery pageQuery) {
|
|
|
return performanceApplyRepo.findAll(JpaUtils.toSpecification(pageQuery, PerformanceApply.class), JpaUtils.toPageRequest(pageQuery));
|
|
|
@@ -46,10 +50,25 @@ public class PerformanceApplyService {
|
|
|
.filter(apply -> apply.showTime != null)
|
|
|
.sorted((a, b) -> b.showTime.compareTo(a.getShowTime()))
|
|
|
.collect(Collectors.toList());
|
|
|
- final LocalDateTime[] time = {showTime.get(0).getShowTime().plusMinutes(10)};
|
|
|
List<PerformanceApply> showTimeNull = applyList.stream()
|
|
|
.filter(apply -> apply.showTime == null)
|
|
|
.collect(Collectors.toList());
|
|
|
+
|
|
|
+ if (CollUtil.isEmpty(showTimeNull)) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (CollUtil.isEmpty(showTime)) {
|
|
|
+ Performance performance = performanceRepo.findById(performanceId).orElseThrow(new BusinessException("无记录"));
|
|
|
+ final LocalDateTime[] time = {LocalDateTime.of(performance.getStartTime().plusDays(3), LocalTime.now())};
|
|
|
+ showTimeNull.forEach(apply -> {
|
|
|
+ apply.setShowTime(time[0]);
|
|
|
+ performanceApplyRepo.save(apply);
|
|
|
+ time[0] = time[0].plusMinutes(10);
|
|
|
+ });
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ final LocalDateTime[] time = {showTime.get(0).getShowTime().plusMinutes(10)};
|
|
|
showTimeNull.forEach(apply -> {
|
|
|
apply.setShowTime(time[0]);
|
|
|
performanceApplyRepo.save(apply);
|