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

+ 2 - 0
src/main/java/com/izouma/wenlvju/repo/ArtTypeRepo.java

@@ -18,4 +18,6 @@ public interface ArtTypeRepo extends JpaRepository<ArtType, Long>, JpaSpecificat
     List<ArtType> findAllByParentIsNull();
 
     List<ArtType> findAllByParentIn(Iterable<Long> parent);
+
+    ArtType findByCode(String code);
 }

+ 0 - 10
src/main/java/com/izouma/wenlvju/repo/performance/ArrangeRepo.java

@@ -15,16 +15,6 @@ public interface ArrangeRepo extends JpaRepository<Arrange, Long>, JpaSpecificat
     @Transactional
     void softDelete(Long id);
 
-    @Query("update Arrange t set t.quantity = t.quantity + 1 where t.id = ?1")
-    @Modifying
-    @Transactional
-    void plusQuantity(Long id);
-
-    @Query("update Arrange t set t.quantity = t.quantity - 1 where t.id = ?1")
-    @Modifying
-    @Transactional
-    void minusQuantity(Long id);
-
     List<Arrange> findAllByPerformanceId(Long performanceId);
 
     Arrange findFirstByPerformanceId(Long performanceId);

+ 14 - 2
src/main/java/com/izouma/wenlvju/repo/performance/ProgrammeRepo.java

@@ -8,6 +8,7 @@ import org.springframework.data.jpa.repository.Modifying;
 import org.springframework.data.jpa.repository.Query;
 
 import javax.transaction.Transactional;
+import java.util.Collection;
 import java.util.List;
 
 public interface ProgrammeRepo extends JpaRepository<Programme, Long>, JpaSpecificationExecutor<Programme> {
@@ -27,6 +28,16 @@ public interface ProgrammeRepo extends JpaRepository<Programme, Long>, JpaSpecif
     @Transactional
     void allSigned(Long arrangeId);
 
+    @Query("update Programme t set t.arrangeId = ?1 where t.id in ?2")
+    @Modifying
+    @Transactional
+    void setArrangeId(Long arrangeId, Collection<Long> ids);
+
+    @Query("update Programme t set t.reviewArrangeId = ?1 where t.id in ?2")
+    @Modifying
+    @Transactional
+    void setReviewArrangeId(Long arrangeId, Collection<Long> ids);
+
     @Query("update Programme t set t.score = ?1 where t.id = ?2")
     @Modifying
     @Transactional
@@ -36,7 +47,8 @@ public interface ProgrammeRepo extends JpaRepository<Programme, Long>, JpaSpecif
 
     List<Programme> findAllByPerformanceIdAndReviewArrangeIdIsNull(Long performanceId);
 
-//    List<Programme> findAllByArrangeId(Long arrangeId);
+    List<Programme> findAllByArrangeId(Long arrangeId);
+
+    List<Programme> findAllByReviewArrangeId(Long arrangeId);
 
-//    Programme findFirstByArrangeIdOrderByShowTimeDesc(Long arrangeId);
 }

+ 22 - 0
src/main/java/com/izouma/wenlvju/service/ArtTypeService.java

@@ -3,6 +3,7 @@ package com.izouma.wenlvju.service;
 import cn.hutool.core.collection.CollUtil;
 import com.izouma.wenlvju.domain.ArtType;
 import com.izouma.wenlvju.dto.PageQuery;
+import com.izouma.wenlvju.exception.BusinessException;
 import com.izouma.wenlvju.repo.ArtTypeRepo;
 import com.izouma.wenlvju.utils.JpaUtils;
 import lombok.AllArgsConstructor;
@@ -73,4 +74,25 @@ public class ArtTypeService {
         }
         return result;
     }
+
+    public void getParent(List<Long> ids, List<Long> result) {
+        List<ArtType> all = artTypeRepo.findAll();
+        Map<Long, String> idMap = all.stream().collect(Collectors.toMap(ArtType::getId, ArtType::getCode));
+        Map<String, Long> codeMap = all.stream().collect(Collectors.toMap(ArtType::getCode, ArtType::getId));
+
+        ids.forEach(id -> {
+            String code = idMap.get(id);
+            String subCode = code.substring(0, 2);
+            result.add(codeMap.get(subCode));
+        });
+    }
+
+    public Long getParent(Long id) {
+        String code = artTypeRepo.findById(id).orElseThrow(new BusinessException("无专业")).getCode();
+        if (code.length() > 2) {
+            String subCode = code.substring(0, 2);
+            return artTypeRepo.findByCode(subCode).getId();
+        }
+        return id;
+    }
 }

+ 12 - 9
src/main/java/com/izouma/wenlvju/service/performance/ArrangeService.java

@@ -189,17 +189,18 @@ public class ArrangeService {
                         .auditTimes(times)
                         .build();
 
-                Map<String, String> programmes = programmeService.group(byPerformanceId, arrange);
+                Map<String, String> programmes = programmeService.group1(byPerformanceId, arrange);
                 List<Programme> programmeList = JSONObject.parseArray(programmes.get("programmes"), Programme.class);
                 List<Long> ids = programmeList.stream()
-                        .map(Programme::getSpecialtyId)
+                        .map(Programme::getParentSpecialtyId)
                         .distinct()
                         .collect(Collectors.toList());
                 arrange.setSpecialtyId(ids);
                 arrange.setQuantity(programmeList.size());
                 arrange = arrangeRepo.save(arrange);
 
-                programmeService.saveAll(programmeList, arrange.getId());
+                programmeService.saveAll(programmeList, arrange.getId(), times);
+                byPerformanceId.removeAll(programmeList);
 
                 // 插入节目
                 if (!Boolean.parseBoolean(programmes.get("flag"))) {
@@ -246,17 +247,18 @@ public class ArrangeService {
                     .auditTimes(times)
                     .build();
 
-            Map<String, String> programmes = programmeService.group(byPerformanceId, arrange);
+            Map<String, String> programmes = programmeService.group1(byPerformanceId, arrange);
             List<Programme> programmeList = JSONObject.parseArray(programmes.get("programmes"), Programme.class);
             List<Long> ids = programmeList.stream()
-                    .map(Programme::getSpecialtyId)
+                    .map(Programme::getParentSpecialtyId)
                     .distinct()
                     .collect(Collectors.toList());
             arrange.setSpecialtyId(ids);
             arrange.setQuantity(programmeList.size());
             arrange = arrangeRepo.save(arrange);
 
-            programmeService.saveAll(programmeList, arrange.getId());
+            programmeService.saveAll(programmeList, arrange.getId(), times);
+            byPerformanceId.removeAll(programmeList);
 
             // 插入节目
             if (!Boolean.parseBoolean(programmes.get("flag"))) {
@@ -295,18 +297,19 @@ public class ArrangeService {
                     .auditTimes(times)
                     .build();
 
-            Map<String, String> programmes = programmeService.group(byPerformanceId, arrange);
+            Map<String, String> programmes = programmeService.group1(byPerformanceId, arrange);
             List<Programme> programmeList = JSONObject.parseArray(programmes.get("programmes"), Programme.class);
             List<Long> ids = programmeList.stream()
-                    .map(Programme::getSpecialtyId)
+                    .map(Programme::getParentSpecialtyId)
                     .distinct()
                     .collect(Collectors.toList());
             arrange.setSpecialtyId(ids);
             arrange.setQuantity(programmeList.size());
             arrange = arrangeRepo.save(arrange);
 
-            programmeService.saveAll(programmeList, arrange.getId());
+            programmeService.saveAll(programmeList, arrange.getId(), times);
 
+            byPerformanceId.removeAll(programmeList);
             // 插入节目
             if (!Boolean.parseBoolean(programmes.get("flag"))) {
                 //不需要这么多分组

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

@@ -328,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;
@@ -364,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;
@@ -376,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());
@@ -385,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;
@@ -403,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) {
@@ -431,13 +427,32 @@ public class ProgrammeService {
     移除分组
      */
     public void removeArrange(Long id) {
+        Arrange arrange = arrangeRepo.findById(id).orElseThrow(new BusinessException("无分组"));
         Programme programme = programmeRepo.findById(id).orElseThrow(new BusinessException("无记录"));
-        Long arrangeId = programme.getArrangeId();
-//        programme.setStatus(0);
-        programme.setProgrammeStatus(ProgrammeStatus.INITIAL);
+        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);
+            arrangeRepo.save(arrange);
+            return;
+        }
+
         programme.setArrangeId(null);
         programmeRepo.save(programme);
-        arrangeRepo.minusQuantity(arrangeId);
+        // 此分组的专业,是否要移除专业
+        List<Long> specialtyIds = programmeRepo.findAllByArrangeId(id)
+                .stream()
+                .map(Programme::getParentSpecialtyId)
+                .distinct()
+                .collect(Collectors.toList());
+        arrange.setSpecialtyId(specialtyIds);
+        arrangeRepo.save(arrange);
     }
 
     /*
@@ -446,10 +461,18 @@ public class ProgrammeService {
     public void add(Long id, Long arrangeId) {
         Arrange arrange = arrangeRepo.findById(arrangeId).orElseThrow(new BusinessException("无记录"));
         Programme programme = programmeRepo.findById(id).orElseThrow(new BusinessException("无记录"));
-        programme.setArrangeId(arrangeId);
+        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);
     }
 
@@ -492,7 +515,7 @@ public class ProgrammeService {
                 .stream()
                 .collect(Collectors.toMap(Organization::getId, Organization::getName));
 
-       return programmes.stream().map(programme -> {
+        return programmes.stream().map(programme -> {
             ProgrammeShowDTO dto = new ProgrammeShowDTO(programme);
             dto.setLevel(settingMap.get(programme.getLevelSettingId()));
             dto.setGradingOrganization(gradeMap.get(programme.getGradingOrganizationId()));

+ 5 - 2
src/main/java/com/izouma/wenlvju/web/performance/ProgrammeController.java

@@ -12,6 +12,7 @@ import com.izouma.wenlvju.exception.BusinessException;
 import com.izouma.wenlvju.repo.ArtTypeRepo;
 import com.izouma.wenlvju.repo.performance.PerformanceRepo;
 import com.izouma.wenlvju.repo.performance.ProgrammeRepo;
+import com.izouma.wenlvju.service.ArtTypeService;
 import com.izouma.wenlvju.service.UserService;
 import com.izouma.wenlvju.service.performance.ProgrammeService;
 import com.izouma.wenlvju.utils.ObjUtils;
@@ -39,6 +40,7 @@ public class ProgrammeController extends BaseController {
     private ProgrammeService programmeService;
     private ProgrammeRepo    programmeRepo;
     private ArtTypeRepo      artTypeRepo;
+    private ArtTypeService   artTypeService;
     private UserService      userService;
     private PerformanceRepo  performanceRepo;
 
@@ -55,6 +57,7 @@ public class ProgrammeController extends BaseController {
                 }
             }
             ObjUtils.merge(orig, record);
+            orig.setParentSpecialtyId(artTypeService.getParent(orig.getSpecialtyId()));
             return programmeRepo.save(orig);
         }
         Performance performance = performanceRepo.findById(record.getPerformanceId())
@@ -62,6 +65,7 @@ public class ProgrammeController extends BaseController {
         if (LocalDate.now().isAfter(performance.getEndDate())) {
             throw new BusinessException("活动已报名结束!");
         }
+        record.setParentSpecialtyId(artTypeService.getParent(record.getSpecialtyId()));
         return programmeRepo.save(record);
     }
 
@@ -132,8 +136,6 @@ public class ProgrammeController extends BaseController {
     @PostMapping("/byArrange")
     public Page<ArrangeProgrammeDTO> byArrange(@RequestBody PageQuery pageQuery) {
         pageQuery.setSort("allSigned,asc;arrangeId,desc;gradingOrganizationId,asc;organizationId,asc;");
-//        Map<String, Object> query = pageQuery.getQuery();
-//        query.put("status", 2);
         return programmeService.byArrange(pageQuery);
     }
 
@@ -181,6 +183,7 @@ public class ProgrammeController extends BaseController {
         return userService.getAuth(id, phone, apply.getPhone());
     }
 
+    @ApiOperation("查分数登录  ")
     @GetMapping("/getScore/{id}")
     public Programme get(@PathVariable Long id, String phone) {
         Programme apply = programmeRepo.findById(id).orElseThrow(new BusinessException("无记录"));

+ 10 - 6
src/main/vue/src/views/performance/ArrangeList.vue

@@ -1,7 +1,7 @@
 <template>
     <div class="list-view">
         <div class="filters-container">
-            <el-form :model="form" :rules="rules" size="mini" ref="form" inline label-width="120px">
+            <el-form :model="form" :rules="rules" size="mini" ref="form" inline label-width="100px">
                 <el-form-item label="活动名称" prop="performanceId">
                     <el-select
                         v-model="form.performanceId"
@@ -215,14 +215,17 @@
             </el-table-column>
             <el-table-column prop="writerDirector" label="编导姓名"> </el-table-column>
             <el-table-column prop="phone" label="联系电话"> </el-table-column>
-            <el-table-column label="操作" align="center" fixed="right" min-width="320">
+            <el-table-column label="操作" align="center" fixed="right" :min-width="performance.online ? 100 : 320">
                 <template slot-scope="{ row, $index }">
                     <el-button @click="editRow(row)" type="primary" size="mini" plain>编辑</el-button>
                     <el-button @click="programme(row)" size="mini" plain>查看节目</el-button>
-                    <!-- <el-button @click="editRow(row)" type="warning" size="mini" plain>上移</el-button>
-                    <el-button @click="editRow(row)" type="warning" size="mini" plain>下移</el-button> -->
-
-                    <el-button @click="move($index, -1)" :disabled="$index == 0" type="success" size="mini" plain
+                    <el-button
+                        @click="move($index, -1)"
+                        :disabled="$index == 0"
+                        type="success"
+                        size="mini"
+                        plain
+                        v-if="!performance.online"
                         >上移</el-button
                     >
                     <el-button
@@ -231,6 +234,7 @@
                         type="warning"
                         size="mini"
                         plain
+                        v-if="!performance.online"
                         >下移</el-button
                     >
                 </template>