|
@@ -11,6 +11,7 @@ import com.izouma.wenlvju.domain.performance.Performance;
|
|
|
import com.izouma.wenlvju.domain.performance.Programme;
|
|
import com.izouma.wenlvju.domain.performance.Programme;
|
|
|
import com.izouma.wenlvju.dto.ArrangeDTO;
|
|
import com.izouma.wenlvju.dto.ArrangeDTO;
|
|
|
import com.izouma.wenlvju.dto.PageQuery;
|
|
import com.izouma.wenlvju.dto.PageQuery;
|
|
|
|
|
+import com.izouma.wenlvju.enums.PerformanceStatus;
|
|
|
import com.izouma.wenlvju.enums.ProgrammeProcess;
|
|
import com.izouma.wenlvju.enums.ProgrammeProcess;
|
|
|
import com.izouma.wenlvju.enums.ProgrammeStatus;
|
|
import com.izouma.wenlvju.enums.ProgrammeStatus;
|
|
|
import com.izouma.wenlvju.exception.BusinessException;
|
|
import com.izouma.wenlvju.exception.BusinessException;
|
|
@@ -70,7 +71,7 @@ public class ArrangeService {
|
|
|
Map<Long, List<ArrangeJudge>> judgeMap = ajs
|
|
Map<Long, List<ArrangeJudge>> judgeMap = ajs
|
|
|
.stream()
|
|
.stream()
|
|
|
.collect(Collectors.groupingBy(ArrangeJudge::getArrangeId));
|
|
.collect(Collectors.groupingBy(ArrangeJudge::getArrangeId));
|
|
|
- Map<Long, String> userMap = userRepo.findAllById(userIds)
|
|
|
|
|
|
|
+ Map<Long, String> userMap = userRepo.findAllByIdInAndDelFalse(userIds)
|
|
|
.stream()
|
|
.stream()
|
|
|
.collect(Collectors.toMap(User::getId, User::getNickname));
|
|
.collect(Collectors.toMap(User::getId, User::getNickname));
|
|
|
return arrangeRepo.findAll(JpaUtils.toSpecification(pageQuery, Arrange.class), JpaUtils.toPageRequest(pageQuery))
|
|
return arrangeRepo.findAll(JpaUtils.toSpecification(pageQuery, Arrange.class), JpaUtils.toPageRequest(pageQuery))
|
|
@@ -91,27 +92,29 @@ public class ArrangeService {
|
|
|
});
|
|
});
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-// public void chooseGroup(ArrangeDTO dto) {
|
|
|
|
|
-// Arrange first = arrangeRepo.findFirstByPerformanceId(dto.getPerformanceId());
|
|
|
|
|
-// if (ObjectUtil.isNotNull(first) && first.isPublish()) {
|
|
|
|
|
-// throw new BusinessException("活动分组已发布");
|
|
|
|
|
-// }
|
|
|
|
|
-// Performance performance = performanceRepo.findById(dto.getPerformanceId())
|
|
|
|
|
-// .orElseThrow(new BusinessException("无展演活动"));
|
|
|
|
|
-// if (performance.isOnline()){
|
|
|
|
|
-// this.groupOnline(dto);
|
|
|
|
|
-// }
|
|
|
|
|
-// }
|
|
|
|
|
|
|
+ public void chooseGroup(ArrangeDTO dto) {
|
|
|
|
|
+ Performance performance = performanceRepo.findById(dto.getPerformanceId())
|
|
|
|
|
+ .orElseThrow(new BusinessException("无展演活动"));
|
|
|
|
|
|
|
|
- /*
|
|
|
|
|
- 分组
|
|
|
|
|
- */
|
|
|
|
|
- public void group(ArrangeDTO dto) {
|
|
|
|
|
- Arrange first = arrangeRepo.findFirstByPerformanceId(dto.getPerformanceId());
|
|
|
|
|
|
|
+ Arrange first = arrangeRepo.findFirstByPerformanceIdAndAuditTimes(dto.getPerformanceId(), performance.getAuditTimes() + 1);
|
|
|
if (ObjectUtil.isNotNull(first) && first.isPublish()) {
|
|
if (ObjectUtil.isNotNull(first) && first.isPublish()) {
|
|
|
throw new BusinessException("活动分组已发布");
|
|
throw new BusinessException("活动分组已发布");
|
|
|
}
|
|
}
|
|
|
|
|
+ boolean online = performance.isOnline();
|
|
|
|
|
+ if (performance.getAuditTimes() > 1) {
|
|
|
|
|
+ online = performance.getReviewOnline();
|
|
|
|
|
+ }
|
|
|
|
|
+ if (online) {
|
|
|
|
|
+ this.groupOnline(dto, performance.getStatus());
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ this.group(dto, performance.getStatus());
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
|
|
+ /*
|
|
|
|
|
+ 分组
|
|
|
|
|
+ */
|
|
|
|
|
+ public void group(ArrangeDTO dto, PerformanceStatus status) {
|
|
|
long total = 0;
|
|
long total = 0;
|
|
|
int days = Period.between(dto.getStartDate(), dto.getEndDate()).getDays();
|
|
int days = Period.between(dto.getStartDate(), dto.getEndDate()).getDays();
|
|
|
for (int i = 0; i <= days; i++) {
|
|
for (int i = 0; i <= days; i++) {
|
|
@@ -214,11 +217,6 @@ public class ArrangeService {
|
|
|
|
|
|
|
|
for (int i = 0; i < group; i++) {
|
|
for (int i = 0; i < group; i++) {
|
|
|
LocalTime endTime = startTime.plusMinutes(time);
|
|
LocalTime endTime = startTime.plusMinutes(time);
|
|
|
-// if (!endTime.isBefore(dto.getMorningEndTime())) {
|
|
|
|
|
-// if (Duration.between(dto.getMorningEndTime(), endTime).toMinutes() > dto.getDuration()) {
|
|
|
|
|
-//
|
|
|
|
|
-// }
|
|
|
|
|
-// }
|
|
|
|
|
String amPm = morning ? "上午" : "下午";
|
|
String amPm = morning ? "上午" : "下午";
|
|
|
String name = format1 + amPm + "第" + arr[j] + "场";
|
|
String name = format1 + amPm + "第" + arr[j] + "场";
|
|
|
Arrange arrange = Arrange.builder()
|
|
Arrange arrange = Arrange.builder()
|
|
@@ -267,6 +265,42 @@ public class ArrangeService {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ /*
|
|
|
|
|
+ 展演形式为线上进行分组
|
|
|
|
|
+ 不需要时间、上下午、地点
|
|
|
|
|
+ */
|
|
|
|
|
+ public void groupOnline(ArrangeDTO dto, PerformanceStatus status) {
|
|
|
|
|
+ List<Programme> byPerformanceId = programmeRepo.findAllByPerformanceIdAndProgrammeStatus(dto.getPerformanceId(), ProgrammeStatus.SUBMIT);
|
|
|
|
|
+ int group = (int) Math.ceil((double) byPerformanceId.size() / dto.getQuantity());
|
|
|
|
|
+
|
|
|
|
|
+ for (int i = 0; i < group; i++) {
|
|
|
|
|
+ Arrange arrange = Arrange.builder()
|
|
|
|
|
+ .performanceId(dto.getPerformanceId())
|
|
|
|
|
+ .quantity(dto.getQuantity())
|
|
|
|
|
+ .specialtyId(dto.getSpecialtyId())
|
|
|
|
|
+ .name("第" + i + 1 + "场")
|
|
|
|
|
+ .build();
|
|
|
|
|
+
|
|
|
|
|
+ Map<String, String> programmes = programmeService.group(byPerformanceId, arrange);
|
|
|
|
|
+ List<Programme> programmeList = JSONObject.parseArray(programmes.get("programmes"), Programme.class);
|
|
|
|
|
+ List<Long> ids = programmeList.stream()
|
|
|
|
|
+ .map(Programme::getSpecialtyId)
|
|
|
|
|
+ .distinct()
|
|
|
|
|
+ .collect(Collectors.toList());
|
|
|
|
|
+ arrange.setSpecialtyId(ids);
|
|
|
|
|
+ arrange.setQuantity(programmeList.size());
|
|
|
|
|
+ arrange = arrangeRepo.save(arrange);
|
|
|
|
|
+
|
|
|
|
|
+ programmeService.saveAll(programmeList, arrange.getId());
|
|
|
|
|
+
|
|
|
|
|
+ // 插入节目
|
|
|
|
|
+ if (!Boolean.parseBoolean(programmes.get("flag"))) {
|
|
|
|
|
+ //不需要这么多分组
|
|
|
|
|
+ break;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
public void publish(Long performanceId) {
|
|
public void publish(Long performanceId) {
|
|
|
// 分布发布
|
|
// 分布发布
|
|
|
arrangeRepo.publish(performanceId);
|
|
arrangeRepo.publish(performanceId);
|
|
@@ -312,45 +346,4 @@ public class ArrangeService {
|
|
|
}), JpaUtils.toPageRequest(pageQuery));
|
|
}), JpaUtils.toPageRequest(pageQuery));
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- /*
|
|
|
|
|
- 展演形式为线上进行分组
|
|
|
|
|
- 不需要时间、上下午、地点
|
|
|
|
|
- */
|
|
|
|
|
- public void groupOnline(ArrangeDTO dto) {
|
|
|
|
|
- Arrange first = arrangeRepo.findFirstByPerformanceId(dto.getPerformanceId());
|
|
|
|
|
- if (ObjectUtil.isNotNull(first) && first.isPublish()) {
|
|
|
|
|
- throw new BusinessException("活动分组已发布");
|
|
|
|
|
- }
|
|
|
|
|
- List<Programme> byPerformanceId = programmeRepo.findAllByPerformanceIdAndProgrammeStatus(dto.getPerformanceId(), ProgrammeStatus.SUBMIT);
|
|
|
|
|
- int group = (int) Math.ceil((double) byPerformanceId.size() / dto.getQuantity());
|
|
|
|
|
-
|
|
|
|
|
- for (int i = 0; i < group; i++) {
|
|
|
|
|
- Arrange arrange = Arrange.builder()
|
|
|
|
|
- .performanceId(dto.getPerformanceId())
|
|
|
|
|
- .quantity(dto.getQuantity())
|
|
|
|
|
- .specialtyId(dto.getSpecialtyId())
|
|
|
|
|
- .name("第" + i + 1 + "场")
|
|
|
|
|
- .build();
|
|
|
|
|
-
|
|
|
|
|
- Map<String, String> programmes = programmeService.group(byPerformanceId, arrange);
|
|
|
|
|
- List<Programme> programmeList = JSONObject.parseArray(programmes.get("programmes"), Programme.class);
|
|
|
|
|
- List<Long> ids = programmeList.stream()
|
|
|
|
|
- .map(Programme::getSpecialtyId)
|
|
|
|
|
- .distinct()
|
|
|
|
|
- .collect(Collectors.toList());
|
|
|
|
|
- arrange.setSpecialtyId(ids);
|
|
|
|
|
- arrange.setQuantity(programmeList.size());
|
|
|
|
|
- arrange = arrangeRepo.save(arrange);
|
|
|
|
|
-
|
|
|
|
|
- programmeService.saveAll(programmeList, arrange.getId());
|
|
|
|
|
-
|
|
|
|
|
- // 插入节目
|
|
|
|
|
- if (!Boolean.parseBoolean(programmes.get("flag"))) {
|
|
|
|
|
- //不需要这么多分组
|
|
|
|
|
- break;
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
}
|
|
}
|