licailing 4 лет назад
Родитель
Сommit
e41b9a8de1

+ 6 - 4
src/main/java/com/izouma/wenlvju/repo/performance/ProgrammeRepo.java

@@ -1,6 +1,7 @@
 package com.izouma.wenlvju.repo.performance;
 
 import com.izouma.wenlvju.domain.performance.Programme;
+import com.izouma.wenlvju.enums.ProgrammeStatus;
 import org.springframework.data.jpa.repository.JpaRepository;
 import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
 import org.springframework.data.jpa.repository.Modifying;
@@ -17,13 +18,14 @@ public interface ProgrammeRepo extends JpaRepository<Programme, Long>, JpaSpecif
 
     long countAllByPerformanceId(Long performanceId);
 
-    long countAllByPerformanceIdAndStatusGreaterThan(Long performanceId, int status);
+//    long countAllByPerformanceIdAndStatusGreaterThan(Long performanceId, int status);
 
-    List<Programme> findAllByPerformanceIdAndStatus(Long performanceId, int status);
+//    List<Programme> findAllByPerformanceIdAndStatus(Long performanceId, int status);
+    List<Programme> findAllByPerformanceIdAndProgrammeStatus(Long performanceId, ProgrammeStatus status);
 
-    List<Programme> findAllByStatusGreaterThan(int status);
+//    List<Programme> findAllByStatusGreaterThan(int status);
 
-    long countAllByArrangeIdAndStatusIsNotNull(Long arrangeId);
+    long countAllByArrangeIdAndProgrammeStatusIsNotNull(Long arrangeId);
 
     @Query("update Programme t set t.allSigned = true where t.arrangeId = ?1")
     @Modifying

+ 4 - 3
src/main/java/com/izouma/wenlvju/service/performance/ArrangeService.java

@@ -11,6 +11,7 @@ import com.izouma.wenlvju.domain.performance.Programme;
 import com.izouma.wenlvju.dto.ArrangeDTO;
 import com.izouma.wenlvju.dto.PageQuery;
 import com.izouma.wenlvju.enums.ProgrammeProcess;
+import com.izouma.wenlvju.enums.ProgrammeStatus;
 import com.izouma.wenlvju.exception.BusinessException;
 import com.izouma.wenlvju.repo.ArtTypeRepo;
 import com.izouma.wenlvju.repo.UserRepo;
@@ -116,7 +117,7 @@ public class ArrangeService {
         String[] arr = {"一", "二", "三", "四", "五", "六", "七", "八", "九", "十"};
         String format1 = format.format(date);
 
-        List<Programme> byPerformanceId = programmeRepo.findAllByPerformanceIdAndStatus(dto.getPerformanceId(), 1);
+        List<Programme> byPerformanceId = programmeRepo.findAllByPerformanceIdAndProgrammeStatus(dto.getPerformanceId(), ProgrammeStatus.SUBMIT);
 
         if (dto.isMorning() && dto.isAfternoon()) {
             this.saveArrange(byPerformanceId, dto, group, time, format1, arr);
@@ -257,7 +258,7 @@ public class ArrangeService {
         Map<Long, Arrange> arranges = arrangeRepo.findAllByPerformanceId(performanceId)
                 .stream()
                 .collect(Collectors.toMap(Arrange::getId, arrange -> arrange));
-        List<Programme> programmeList = programmeRepo.findAllByPerformanceIdAndStatus(performanceId, 1);
+        List<Programme> programmeList = programmeRepo.findAllByPerformanceIdAndProgrammeStatus(performanceId, ProgrammeStatus.SUBMIT);
         Map<Long, List<Programme>> programmes = programmeList
                 .stream()
                 .collect(Collectors.groupingBy(Programme::getArrangeId));
@@ -305,7 +306,7 @@ public class ArrangeService {
         if (ObjectUtil.isNotNull(first) && first.isPublish()) {
             throw new BusinessException("活动分组已发布");
         }
-        List<Programme> byPerformanceId = programmeRepo.findAllByPerformanceIdAndStatus(dto.getPerformanceId(), 1);
+        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++) {

+ 8 - 7
src/main/java/com/izouma/wenlvju/service/performance/ProgrammeAwardService.java

@@ -9,6 +9,7 @@ import com.izouma.wenlvju.domain.performance.ProgrammeAward;
 import com.izouma.wenlvju.dto.AwardDTO;
 import com.izouma.wenlvju.dto.PageQuery;
 import com.izouma.wenlvju.dto.ProgrammeAwardDTO;
+import com.izouma.wenlvju.enums.ProgrammeStatus;
 import com.izouma.wenlvju.repo.ArtTypeRepo;
 import com.izouma.wenlvju.repo.AwardRepo;
 import com.izouma.wenlvju.repo.performance.ProgrammeAwardRepo;
@@ -65,7 +66,7 @@ public class ProgrammeAwardService {
         }
 
         //总节目
-        List<Programme> programmeList = programmeRepo.findAllByPerformanceIdAndStatus(performanceId, 2);
+        List<Programme> programmeList = programmeRepo.findAllByPerformanceIdAndProgrammeStatus(performanceId, ProgrammeStatus.AWARD);
         List<ArtType> artTypes = all.stream()
                 .filter(artType -> ObjectUtil.isNull(artType.getParent()))
                 .collect(Collectors.toList());
@@ -126,7 +127,7 @@ public class ProgrammeAwardService {
         }
 
         //总节目
-        List<Programme> programmeList = programmeRepo.findAllByPerformanceIdAndStatus(performanceId, 2);
+        List<Programme> programmeList =  programmeRepo.findAllByPerformanceIdAndProgrammeStatus(performanceId, ProgrammeStatus.AWARD);
         List<ArtType> artTypes = all.stream()
                 .filter(artType -> ObjectUtil.isNull(artType.getParent()))
                 .collect(Collectors.toList());
@@ -187,7 +188,7 @@ public class ProgrammeAwardService {
             return dtos;
         }
 
-        List<Programme> programmeList = programmeRepo.findAllByPerformanceIdAndStatus(performanceId, 2);
+        List<Programme> programmeList = programmeRepo.findAllByPerformanceIdAndProgrammeStatus(performanceId, ProgrammeStatus.AWARD);
         List<ArtType> artParents = artTypes.stream()
                 .filter(artType -> ObjectUtil.isNull(artType.getParent()))
                 .collect(Collectors.toList());
@@ -221,8 +222,8 @@ public class ProgrammeAwardService {
     }
 
     public void saveProgramme(List<ProgrammeAwardDTO> dtos) {
-        List<Programme> programmeList = programmeRepo.findAllByPerformanceIdAndStatus(dtos.get(0)
-                .getPerformanceId(), 2);
+        List<Programme> programmeList = programmeRepo.findAllByPerformanceIdAndProgrammeStatus(dtos.get(0)
+                .getPerformanceId(), ProgrammeStatus.AWARD);
 
         List<ArtType> artTypes = artTypeRepo.findAll();
         List<ArtType> artParents = artTypes.stream()
@@ -271,8 +272,8 @@ public class ProgrammeAwardService {
     }
 
     public void saveProgramme1(List<ProgrammeAwardDTO> dtos) {
-        List<Programme> programmeList = programmeRepo.findAllByPerformanceIdAndStatus(dtos.get(0)
-                .getPerformanceId(), 2);
+        List<Programme> programmeList =  programmeRepo.findAllByPerformanceIdAndProgrammeStatus(dtos.get(0)
+                .getPerformanceId(), ProgrammeStatus.AWARD);
 
         Map<Long, List<Programme>> programmeMap = programmeList.stream()
                 .sorted(Comparator.comparingDouble(Programme::getScore))

+ 3 - 3
src/main/java/com/izouma/wenlvju/service/performance/ProgrammeService.java

@@ -376,7 +376,7 @@ public class ProgrammeService {
         // 是否继续分组
         boolean flag = true;
 
-        List<Programme> byPerformanceId = programmeRepo.findAllByPerformanceIdAndStatus(arrange.getPerformanceId(), 1);
+        List<Programme> byPerformanceId = programmeRepo.findAllByPerformanceIdAndProgrammeStatus(arrange.getPerformanceId(), ProgrammeStatus.SUBMIT);
         int quantity = arrange.getQuantity();
         if (byPerformanceId.size() < quantity) {
             flag = false;
@@ -469,7 +469,7 @@ public class ProgrammeService {
     未分组节目
      */
     public List<Programme> ungrouped(Long performanceId) {
-        List<Programme> programmes = programmeRepo.findAllByPerformanceIdAndStatus(performanceId, 3);
+        List<Programme> programmes = programmeRepo.findAllByPerformanceIdAndProgrammeStatus(performanceId, ProgrammeStatus.SUBMIT);
         this.sort(programmes);
         return programmes;
     }
@@ -517,7 +517,7 @@ public class ProgrammeService {
         programme.setSignedAt(LocalDateTime.now());
         programmeRepo.save(programme);
 
-        long unSigned = programmeRepo.countAllByArrangeIdAndStatusIsNotNull(programme.getArrangeId());
+        long unSigned = programmeRepo.countAllByArrangeIdAndProgrammeStatusIsNotNull(programme.getArrangeId());
         if (unSigned == 0) {
             programmeRepo.allSigned(programme.getArrangeId());
         }

+ 2 - 3
src/main/java/com/izouma/wenlvju/web/performance/PerformanceController.java

@@ -78,9 +78,8 @@ public class PerformanceController extends BaseController {
 
     @GetMapping("/backGet/{id}")
     public Performance backGet(@PathVariable Long id) {
-        Performance performance = performanceRepo.findById(id).orElseThrow(new BusinessException("无记录"));
-        performance.setProgrammeNum(programmeRepo.countAllByPerformanceIdAndStatusGreaterThan(id, 0));
-        return performance;
+        //        performance.setProgrammeNum(programmeRepo.countAllByPerformanceIdAndStatusGreaterThan(id, 0));
+        return performanceRepo.findById(id).orElseThrow(new BusinessException("无记录"));
     }