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

+ 2 - 0
src/main/java/com/izouma/wenlvju/domain/performance/Participant.java

@@ -21,6 +21,8 @@ import java.time.LocalDate;
 @ApiModel(value = "参演人员")
 @Where(clause = "del = 0")
 public class Participant extends BaseEntity {
+    private Long performanceId;
+
     private Long programmeId;
 
     @ApiModelProperty(value = "姓名")

+ 7 - 0
src/main/java/com/izouma/wenlvju/repo/performance/ParticipantRepo.java

@@ -16,7 +16,14 @@ public interface ParticipantRepo extends JpaRepository<Participant, Long>, JpaSp
     @Transactional
     void softDelete(Long id);
 
+    @Query("update Participant t set t.del = true where t.programmeId = ?1")
+    @Modifying
+    @Transactional
+    void softDeleteProgrammeId(Long programmeId);
+
     List<Participant> findAllByProgrammeIdIn(Collection<Long> ids);
 
     List<Participant> findAllByProgrammeId(Long id);
+
+    List<Participant> findByIdNoAndPerformanceId(String idNo, Long performanceId);
 }

+ 0 - 6
src/main/java/com/izouma/wenlvju/service/RateExpertAuditService.java

@@ -2,16 +2,12 @@ package com.izouma.wenlvju.service;
 
 import cn.hutool.core.util.ObjectUtil;
 import com.izouma.wenlvju.domain.Rate;
-import com.izouma.wenlvju.domain.RateAudit;
 import com.izouma.wenlvju.domain.RateExpertAudit;
 import com.izouma.wenlvju.dto.PageQuery;
-import com.izouma.wenlvju.enums.OrganizationGrade;
 import com.izouma.wenlvju.enums.RateStatus;
 import com.izouma.wenlvju.exception.BusinessException;
-import com.izouma.wenlvju.repo.RateAuditRepo;
 import com.izouma.wenlvju.repo.RateExpertAuditRepo;
 import com.izouma.wenlvju.repo.RateRepo;
-import com.izouma.wenlvju.service.sms.NjwlSmsService;
 import com.izouma.wenlvju.utils.JpaUtils;
 import com.izouma.wenlvju.utils.ObjUtils;
 import lombok.AllArgsConstructor;
@@ -26,8 +22,6 @@ public class RateExpertAuditService {
 
     private final RateExpertAuditRepo rateExpertAuditRepo;
     private final RateRepo            rateRepo;
-    private final NjwlSmsService      njwlSmsService;
-    private final RateAuditRepo       rateAuditRepo;
 
     public Page<RateExpertAudit> all(PageQuery pageQuery) {
         return rateExpertAuditRepo.findAll(JpaUtils.toSpecification(pageQuery, RateExpertAudit.class), JpaUtils.toPageRequest(pageQuery));

+ 23 - 0
src/main/java/com/izouma/wenlvju/service/performance/ParticipantService.java

@@ -1,5 +1,7 @@
 package com.izouma.wenlvju.service.performance;
 
+import cn.hutool.core.collection.CollUtil;
+import cn.hutool.core.util.StrUtil;
 import com.izouma.wenlvju.domain.performance.Participant;
 import com.izouma.wenlvju.dto.PageQuery;
 import com.izouma.wenlvju.exception.BusinessException;
@@ -27,9 +29,30 @@ public class ParticipantService {
             if (participant.getId() != null) {
                 Participant orig = participantRepo.findById(participant.getId())
                         .orElseThrow(new BusinessException("无记录"));
+
+                if (StrUtil.isNotEmpty(participant.getIdNo())) {
+                    List<Participant> byIdNo = participantRepo.findByIdNoAndPerformanceId(participant.getIdNo(), participant.getPerformanceId());
+                    if (CollUtil.isNotEmpty(byIdNo)) {
+                        if (byIdNo.size() > 1) {
+                            throw new BusinessException("一人只能报一个节目");
+                        } else {
+                            if (!byIdNo.get(0).getId().equals(participant.getId())) {
+                                throw new BusinessException("一人只能报一个节目");
+                            }
+                        }
+                    }
+                }
+
                 ObjUtils.merge(orig, participant);
                 participantRepo.save(orig);
             } else {
+                if (StrUtil.isNotEmpty(participant.getIdNo())) {
+                    List<Participant> byIdNo = participantRepo.findByIdNoAndPerformanceId(participant.getIdNo(), participant.getPerformanceId());
+                    if (CollUtil.isNotEmpty(byIdNo)) {
+                        throw new BusinessException("一人只能报一个节目");
+                    }
+                }
+
                 participantRepo.save(participant);
             }
         });

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

@@ -46,6 +46,7 @@ import java.text.SimpleDateFormat;
 import java.time.LocalDate;
 import java.time.format.DateTimeFormatter;
 import java.util.*;
+import java.util.regex.Pattern;
 import java.util.stream.Collectors;
 
 @Service
@@ -249,18 +250,23 @@ public class ProgrammeService {
         }
 
         File destDir = TempFile.createTempDirectory("import");
-//        String originalFilename = file.getOriginalFilename();
-//        boolean zip = Pattern.matches(".zip", FilenameUtils.getExtension(file.getName()));
-//        boolean rar = Pattern.matches(".rar", FilenameUtils.getExtension(file.getName()));
-//        if (rar) {
-
-//        } else if (zip) {
+        String originalFilename = file.getOriginalFilename();
+        boolean zip = Pattern.matches("zip", FilenameUtils.getExtension(originalFilename));
+        boolean rar = false;
+        if (!zip) {
+            rar = Pattern.matches("rar", FilenameUtils.getExtension(originalFilename));
+        }
+        if (rar) {
+            FileUtils.unrar(file.getInputStream(), destDir);
+        } else if (zip) {
             try {
                 ZipUtil.unzip(file.getInputStream(), destDir, StandardCharsets.UTF_8);
             } catch (Exception e) {
                 ZipUtil.unzip(file.getInputStream(), destDir, Charset.forName("gbk"));
             }
-//        }
+        } else {
+            throw new BusinessException("最能上传zip或者rar压缩包");
+        }
 
 
         File xlsxFile = FileUtils.findInDir(destDir, null);

+ 65 - 39
src/main/java/com/izouma/wenlvju/utils/FileUtils.java

@@ -2,6 +2,10 @@ package com.izouma.wenlvju.utils;
 
 import cn.hutool.core.collection.CollUtil;
 import cn.hutool.core.util.StrUtil;
+import com.github.junrar.Archive;
+import com.github.junrar.exception.RarException;
+import com.github.junrar.rarfile.FileHeader;
+import com.izouma.wenlvju.exception.BusinessException;
 import org.apache.commons.io.FilenameUtils;
 import org.apache.commons.lang3.StringUtils;
 
@@ -13,6 +17,7 @@ import java.nio.file.attribute.PosixFileAttributes;
 import java.nio.file.attribute.PosixFilePermission;
 import java.nio.file.attribute.PosixFilePermissions;
 import java.util.*;
+import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
 public class FileUtils {
@@ -204,45 +209,6 @@ public class FileUtils {
 
     }
 
-
-    public static Map<String, File> findExcel(File dir) {
-        if (!(dir.exists() && dir.isDirectory())) return null;
-        for (File file : dir.listFiles()) {
-            String name = file.getName().toLowerCase();
-            if ((name.endsWith(".xlsx") || name.endsWith(".xls")) && !name.startsWith(".") && !file.isHidden()) {
-                Map<String, File> fileMap = new HashMap<>();
-                fileMap.put("file", file);
-                fileMap.put("destDir", dir);
-                return fileMap;
-            } else if (file.isDirectory() && !file.isHidden()) {
-                return findExcel(file);
-            }
-        }
-        return null;
-    }
-
-    public static File findByName(File dir, String fileName) {
-        if (!(dir.exists() && dir.isDirectory())) return null;
-        for (File file : dir.listFiles()) {
-            String name = file.getName().toLowerCase();
-            if (name.contains(fileName)) {
-                return file;
-            }
-        }
-        return null;
-    }
-
-    public static File findExcel1(File dir) {
-        if (!(dir.exists() && dir.isDirectory())) return null;
-        for (File file : dir.listFiles()) {
-            String name = file.getName().toLowerCase();
-            if ((name.endsWith(".xlsx") || name.endsWith(".xls")) && !name.startsWith(".") && !file.isHidden()) {
-                return file;
-            }
-        }
-        return null;
-    }
-
     public static File findInDir(File dir, String fileName) {
         if (dir.isDirectory()) {
             for (File file : dir.listFiles()) {
@@ -309,4 +275,64 @@ public class FileUtils {
         }
         return null;
     }
+
+    public static void unrar(InputStream sourceRar, File destDir) throws Exception {
+        Archive archive = null;
+        FileOutputStream fos = null;
+        System.out.println("Starting 开始解压...");
+        try {
+            archive = new Archive(sourceRar);
+            FileHeader fh = archive.nextFileHeader();
+            File destFileName;
+            while (fh != null) {
+
+                //中文名称乱码
+                String fileName = fh.getFileNameW().replaceAll("/", File.separator).replaceAll("\\\\", File.separator);
+                if (StringUtils.isBlank(fileName)) {
+                    fileName = fh.getFileNameString()
+                            .replaceAll("/", File.separator)
+                            .replaceAll("\\\\", File.separator);
+                }
+
+//                String compressFileName = fh.getFileNameString().trim();
+                destFileName = new File(destDir.getAbsolutePath() + "/" + fileName);
+                if (fh.isDirectory()) {
+                    if (!destFileName.exists()) {
+                        destFileName.mkdirs();
+                    }
+                    fh = archive.nextFileHeader();
+                    continue;
+                }
+                if (!destFileName.getParentFile().exists()) {
+                    destFileName.getParentFile().mkdirs();
+                }
+
+                fos = new FileOutputStream(destFileName);
+                archive.extractFile(fh, fos);
+                fos.close();
+                fos = null;
+                fh = archive.nextFileHeader();
+            }
+
+            archive.close();
+            archive = null;
+            System.out.println("解压完毕...");
+        } catch (Exception e) {
+            throw e;
+        } finally {
+            if (fos != null) {
+                try {
+                    fos.close();
+                } catch (Exception e) {
+                }
+            }
+            if (archive != null) {
+                try {
+                    archive.close();
+                } catch (Exception e) {
+                }
+            }
+        }
+    }
+
 }

+ 4 - 0
src/main/java/com/izouma/wenlvju/web/performance/ProgrammeController.java

@@ -7,6 +7,7 @@ import com.izouma.wenlvju.dto.*;
 import com.izouma.wenlvju.enums.ProgrammeStatus;
 import com.izouma.wenlvju.enums.SignedIn;
 import com.izouma.wenlvju.exception.BusinessException;
+import com.izouma.wenlvju.repo.performance.ParticipantRepo;
 import com.izouma.wenlvju.repo.performance.PerformanceRepo;
 import com.izouma.wenlvju.repo.performance.ProgrammeRepo;
 import com.izouma.wenlvju.service.UserService;
@@ -37,6 +38,7 @@ public class ProgrammeController extends BaseController {
     private ProgrammeRepo    programmeRepo;
     private UserService      userService;
     private PerformanceRepo  performanceRepo;
+    private ParticipantRepo  participantRepo;
 
     //@PreAuthorize("hasRole('ADMIN')")
     @PostMapping("/save")
@@ -82,6 +84,8 @@ public class ProgrammeController extends BaseController {
     @PostMapping("/del/{id}")
     public void del(@PathVariable Long id) {
         programmeRepo.softDelete(id);
+        // 删除参演人员
+        participantRepo.softDeleteProgrammeId(id);
     }
 
     @GetMapping("/excel")

+ 3 - 0
src/main/vue/src/components/ProgrammeLog.vue

@@ -83,6 +83,9 @@
                             <el-form-item prop="instructor" label="指导老师">
                                 <el-input v-model="formData.instructor" class="width" readonly></el-input>
                             </el-form-item>
+                            <el-form-item prop="instructorPhone" label="联系方式">
+                                <el-input v-model="formData.instructorPhone" class="width" readonly></el-input>
+                            </el-form-item>
                             <div
                                 v-if="
                                     formData.specialty == '中国画' ||

+ 11 - 3
src/main/vue/src/views/performance/ProgrammeEdit.vue

@@ -587,10 +587,18 @@ export default {
 
                     this.programmeId = res.id;
                     this.$nextTick(() => {
-                        this.$http.post('/participant/batchSave', this.saveOtherJson, { body: 'json' });
+                        this.$http
+                            .post('/participant/batchSave', this.saveOtherJson, { body: 'json' })
+                            .then(() => {
+                                this.$message.success('成功');
+                                this.$router.go(-1);
+                            })
+                            .catch(e => {
+                                console.log(e);
+                                this.saving = false;
+                                this.$message.error(e.error);
+                            });
                     });
-                    this.$message.success('成功');
-                    this.$router.go(-1);
                 })
                 .catch(e => {
                     console.log(e);

+ 1 - 1
src/main/vue/src/views/performance/ProgrammeOrgList.vue

@@ -177,7 +177,7 @@
             :height="tableHeight"
         >
             <el-table-column v-if="multipleMode" align="center" type="selection" width="50"> </el-table-column>
-            <el-table-column prop="id" label="编号" width="80"> </el-table-column>
+            <el-table-column prop="id" label="编号" width="80" fixed="left"> </el-table-column>
             <el-table-column prop="name" label="节目名称" fixed="left"> </el-table-column>
             <el-table-column prop="specialty" label="参赛专业"> </el-table-column>
             <el-table-column