18 Commits a7ac0cdbb4 ... 415b275e1b

Autore SHA1 Messaggio Data
  superb 415b275e1b 解决冲突,但是目前存有两个bug:1.StuProfileDownload保存文件值未传进去2:StuProfileDownload文件地址生成错误类似于(.docx.docx) 1 anno fa
  superb 43b352e6be 解耦屎山代码 1 anno fa
  wuheng 9b92e69fcb Merge branch 'wheng' of wuheng/eas-system into master 1 anno fa
  wuheng e429244b8b 处理签到 1 anno fa
  wuheng d15196b5a9 分数存储为 Execl格式 1 anno fa
  wuheng 7feffe8658 规范代码 1 anno fa
  wuheng 1a9a691780 文件格式解析 1 anno fa
  wuheng b67b49f2a1 添加解码 1 anno fa
  wuheng 68bc2af473 添加解码 1 anno fa
  wuheng 00d61a1174 代码规范化 1 anno fa
  wuheng a6e4b10b8d Merge branch 'wheng' of wuheng/eas-system into master 1 anno fa
  wuheng 199e8ed583 合并曾卓越代码 1 anno fa
  wuheng 5abe70f9f8 Merge branch 'wheng' of wuheng/eas-system into master 1 anno fa
  wuheng db7c685799 合并曾卓越代码 1 anno fa
  wuheng 8adc48959b 合并曾卓越代码 1 anno fa
  wuheng 4e1b2432b5 整理文档 1 anno fa
  wuheng 888be103de 文件流处理 1 anno fa
  wuheng 5340318d4f 完善文件接口 1 anno fa
29 ha cambiato i file con 901 aggiunte e 364 eliminazioni
  1. 9 0
      common/pom.xml
  2. 46 19
      common/src/main/java/com/koobietech/eas/common/constant/FileType.java
  3. 0 31
      common/src/main/java/com/koobietech/eas/common/constant/FileTypeExt.java
  4. 33 1
      common/src/main/java/com/koobietech/eas/common/constant/Gender.java
  5. 70 0
      common/src/main/java/com/koobietech/eas/common/constant/UniversityCodeUtils.java
  6. 15 0
      common/src/main/java/com/koobietech/eas/common/pojo/ArchiveNumberInfo.java
  7. 17 0
      common/src/main/java/com/koobietech/eas/common/pojo/StudentNumberInfo.java
  8. 72 9
      common/src/main/java/com/koobietech/eas/common/utils/FileManager.java
  9. 2 2
      common/src/main/java/com/koobietech/eas/common/utils/JwtManager.java
  10. 3 1
      common/src/main/java/com/koobietech/eas/common/utils/PasswordManager.java
  11. 45 0
      common/src/main/java/com/koobietech/eas/common/utils/SecurityUtils.java
  12. 113 14
      common/src/main/java/com/koobietech/eas/common/utils/StudentArchiveGenerator.java
  13. 15 5
      common/src/test/java/com/koobietech/eas/common/utils/PasswordManagerTest.java
  14. 4 4
      controller/pom.xml
  15. 6 3
      controller/src/main/java/com/koobietech/eas/controller/EasStuProfileController.java
  16. 46 0
      dao/src/main/java/com/koobietech/eas/dao/Pojo/EasArcTlsAttendancePojo.java
  17. 0 12
      dao/src/main/java/com/koobietech/eas/dao/dto/TestDto.java
  18. 6 1
      pom.xml
  19. 1 1
      security/src/main/java/com/koobietech/eas/security/filter/EasSecurityFilter.java
  20. 0 19
      security/src/main/java/com/koobietech/eas/security/utils/SecurityUtils.java
  21. 24 0
      service/src/main/java/com/koobietech/eas/service/EasArcTlsScoresService.java
  22. 38 2
      service/src/main/java/com/koobietech/eas/service/EasArchivesFilesService.java
  23. 1 1
      service/src/main/java/com/koobietech/eas/service/EasStuProfileService.java
  24. 61 51
      service/src/main/java/com/koobietech/eas/service/impl/EasArcTlsAttendanceServiceImpl.java
  25. 92 23
      service/src/main/java/com/koobietech/eas/service/impl/EasArcTlsScoresServiceImpl.java
  26. 94 32
      service/src/main/java/com/koobietech/eas/service/impl/EasArchivesFilesServiceImpl.java
  27. 88 94
      service/src/main/java/com/koobietech/eas/service/impl/EasStuProfileServiceImpl.java
  28. 0 28
      upload/pom.xml
  29. 0 11
      upload/src/main/java/com/koobietech/eas/upload/UploadService.java

+ 9 - 0
common/pom.xml

@@ -38,6 +38,15 @@
             <groupId>name.remal.tools.test</groupId>
             <artifactId>junit4</artifactId>
         </dependency>
+        <dependency>
+            <groupId>com.koobietech.eas</groupId>
+            <artifactId>dao</artifactId>
+            <version>0.0.1-SNAPSHOT</version>
+        </dependency>
+        <dependency>
+            <groupId>org.springframework.security</groupId>
+            <artifactId>spring-security-core</artifactId>
+        </dependency>
     </dependencies>
 
     <repositories>

+ 46 - 19
common/src/main/java/com/koobietech/eas/common/constant/FileType.java

@@ -1,31 +1,58 @@
 package com.koobietech.eas.common.constant;
 
+/**
+ * @author lc
+ */
+
 public enum FileType {
-    IMAGE("20"),
-    VIDEO("30"),
-    AUDIO("40"),
-    XLSX("50"),
-    DOCX("51"),
-    PNG("21"),
-    JPEG("22"),
-    ZIP("60"),
-    RAR("61"),
-    MP4("41"),
-    MP3("42"),
-    PDF("80"),
-    FILE("70");
+    //OFFICE 文件
+    DOC(".doc", 11),
+    XLS(".xls", 12),
+    PPT(".ppt", 13),
+    XLSX(".xlsx", 14),
+    DOCX(".docx", 15),
+    PDF(".pdf", 16),
+    //文本文件
+    TXT(".txt", 21),
+    HTML(".html", 22),
+    CSS(".css", 23),
+    JS(".js", 24),
+    //媒体文件
+    JPG(".jpg", 31),
+    JPEG(".jpeg", 36),
+    GIF(".gif", 32),
+    MP4(".mp4", 33),
+    MP3(".mp3", 34),
+    PNG(".png", 35),
+    //压缩文件
+    GZ(".gz", 41),
+    ZIP(".zip", 42),
+    RAR(".rar", 43),
+    //其他文件
+    FILE(".file", 51);
 
-    private String value;
+    private String suffix;
+    private int value;
 
-    FileType(String value) {
+    FileType(String suffix, int value) {
+        this.suffix = suffix;
         this.value = value;
     }
 
-    public String getValue() {
-        return value;
+    public static String getSuffix(int fileTypeCode) {
+        for (FileType fileType : FileType.values()) {
+            if (fileType.getValue() == fileTypeCode) {
+                return fileType.getSuffix();
+            }
+        }
+        return null;
     }
 
-    public void setValue(String value) {
-        this.value = value;
+    public String getSuffix() {
+        return suffix;
+    }
+
+    public int getValue() {
+        return value;
     }
 }

+ 0 - 31
common/src/main/java/com/koobietech/eas/common/constant/FileTypeExt.java

@@ -1,31 +0,0 @@
-package com.koobietech.eas.common.constant;
-
-public enum FileTypeExt {
-    IMAGE(".jpeg"),
-    VIDEO(".mp4"),
-    AUDIO(".mp3"),
-    XLSX(".xlsx"),
-    DOCX(".docx"),
-    PNG(".png"),
-    JPEG(".jpeg"),
-    ZIP(".zip"),
-    RAR(".rar"),
-    MP4(".mp4"),
-    MP3(".mp3"),
-    PDF(".pdf"),
-    FILE(".file");
-
-    private String value;
-
-    FileTypeExt(String value) {
-        this.value = value;
-    }
-
-    public String getValue() {
-        return value;
-    }
-
-    public void setValue(String value) {
-        this.value = value;
-    }
-}

+ 33 - 1
common/src/main/java/com/koobietech/eas/common/constant/Gender.java

@@ -1,5 +1,37 @@
 package com.koobietech.eas.common.constant;
 
 public enum Gender {
-    MALE, FEMALE
+    MALE("男", "M" ), FEMALE("女", "F");
+
+
+
+    private String key;
+
+    private String value;
+
+    public static String getkeyByString(String key){
+        return Gender.FEMALE.getKey().equals(key) ? Gender.FEMALE.getValue() : Gender.MALE.getValue();
+    }
+
+    Gender(String value, String key) {
+        this.key = key;
+        this.value = value;
+    }
+
+    public String getKey() {
+        return key;
+    }
+
+    public void setKey(String key) {
+        this.key = key;
+    }
+
+    public String getValue() {
+        return value;
+    }
+
+    public void setValue(String value) {
+        this.value = value;
+    }
+
 }

+ 70 - 0
common/src/main/java/com/koobietech/eas/common/constant/UniversityCodeUtils.java

@@ -0,0 +1,70 @@
+package com.koobietech.eas.common.constant;
+
+/**
+ * @author lc
+ */
+
+public enum UniversityCodeUtils {
+    //学校编码
+    c10212(10212, "黑龙江大学"),
+    c10213(10213, "哈尔滨工业大学"),
+    c10214(10214, "哈尔滨理工大学"),
+    c10215(10215, "哈尔滨工程大学"),
+    c10218(10218, "黑龙江科技大学"),
+    c10222(10222, "东北石油大学 "),
+    c10230(10230, "佳木斯大学"),
+    c10233(10233, "黑龙江八一农垦大学"),
+    c10234(10234, "东北农业大学"),
+    c10235(10235, "东北林业大学"),
+    c10236(10236, "哈尔滨医科大学"),
+    c10240(10240, "黑龙江中医药大学"),
+    c10241(10241, "牡丹江医学院"),
+    c10243(10243, "齐齐哈尔医学院"),
+    c10244(10244, "牡丹江师范学院"),
+    c10245(10245, "哈尔滨师范大学"),
+    c10246(10246, "齐齐哈尔大学"),
+    c10247(10247, "黑龙江工程学院"),
+    c10248(10248, "哈尔滨商业大学"),
+    c10255(10255, "哈尔滨金融学院"),
+    c10278(10278, "哈尔滨体育学院"),
+    c10859(10859, "哈尔滨音乐学院"),
+    c10865(10865, "黑龙江东方学院"),
+    c13722(13722, "黑龙江外国语学院"),
+    c13731(13731, "哈尔滨信息工程学院");
+
+    private int code;
+    private String name;
+
+    UniversityCodeUtils(int code, String name) {
+        this.code = code;
+        this.name = name;
+    }
+
+    public int getCode() {
+        return code;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public static String getName(int code) {
+        for (UniversityCodeUtils universityCodeUtils : UniversityCodeUtils.values()) {
+            if (universityCodeUtils.getCode() == code) {
+                return universityCodeUtils.getName();
+            }
+        }
+        return null;
+    }
+
+    public static int getCode(String name) {
+        for (UniversityCodeUtils universityCodeUtils : UniversityCodeUtils.values()) {
+            if (universityCodeUtils.getName().equals(name)) {
+                return universityCodeUtils.getCode();
+            }
+        }
+        return -1;
+    }
+}
+
+

+ 15 - 0
common/src/main/java/com/koobietech/eas/common/pojo/ArchiveNumberInfo.java

@@ -0,0 +1,15 @@
+package com.koobietech.eas.common.pojo;
+
+import lombok.Data;
+
+/**
+ * @author lc
+ */
+@Data
+public class ArchiveNumberInfo {
+    int studentId;
+    String studentCode;
+    long createTime;
+    int fileTypeCode;
+    String fileSuffix;
+}

+ 17 - 0
common/src/main/java/com/koobietech/eas/common/pojo/StudentNumberInfo.java

@@ -0,0 +1,17 @@
+package com.koobietech.eas.common.pojo;
+
+import lombok.Data;
+
+/**
+ * @author lc
+ */
+@Data
+public class StudentNumberInfo {
+    private String studentNum;
+    private Long studentId;
+    private int studentAge;
+    private String studentGender;
+    private String graduationDate;
+    private String schoolName;
+    private int schoolCode;
+}

+ 72 - 9
common/src/main/java/com/koobietech/eas/common/utils/FileManager.java

@@ -1,5 +1,6 @@
 package com.koobietech.eas.common.utils;
 
+import org.apache.poi.ss.usermodel.Workbook;
 import org.apache.poi.xwpf.usermodel.XWPFDocument;
 import org.springframework.stereotype.Component;
 
@@ -7,6 +8,7 @@ import java.io.*;
 import java.nio.channels.FileChannel;
 import java.nio.file.*;
 import java.text.DecimalFormat;
+import java.util.Objects;
 
 @Component
 public class FileManager {
@@ -23,8 +25,9 @@ public class FileManager {
     public Double getFolderSize(String sizePath) {
         Double size = 0.0;
         Path folderPath = Paths.get(sizePath);
+        DirectoryStream<Path> stream = null;
         try {
-            DirectoryStream<Path> stream = Files.newDirectoryStream(folderPath);
+            stream = Files.newDirectoryStream(folderPath);
             for (Path path : stream) {
                 if (Files.isRegularFile(path)) {
                     size += Files.size(path);
@@ -32,7 +35,12 @@ public class FileManager {
                     size += getFolderSize(path.toFile().getAbsolutePath());
                 }
             }
-        } catch (IOException e) {}
+        } catch (IOException e) {}finally {
+            try {
+                if (Objects.nonNull(stream))
+                    stream.close();
+            } catch (IOException e) {}
+        }
         if ( size > 0  ) {
             size = size / 1024 / 1024 ;
             DecimalFormat df = new DecimalFormat("#.####");
@@ -63,14 +71,21 @@ public class FileManager {
             if (files != null) {
                 for (File file : files) {
                     if ( file.isFile() ) {
+                        FileChannel sourceChannel = null;
+                        FileChannel destChannel = null;
                         try {
-                            FileChannel sourceChannel = new FileInputStream(file).getChannel();
-                            FileChannel destChannel = new FileOutputStream(new File(targetFolder.getPath(), file.getName())).getChannel();
+                            sourceChannel = new FileInputStream(file).getChannel();
+                            destChannel = new FileOutputStream(new File(targetFolder.getPath(), file.getName())).getChannel();
                             destChannel.transferFrom(sourceChannel, 0, sourceChannel.size());
                             sourceChannel.close();
                             file.delete();
-                        } catch (IOException e) {
-                            e.printStackTrace();
+                        } catch (IOException e) {}finally {
+                            try {
+                                if (Objects.nonNull(sourceChannel))
+                                    sourceChannel.close();
+                                if (Objects.nonNull(destChannel))
+                                    destChannel.close();
+                            } catch (IOException e) {}
                         }
                     } else {
                         moveFolder(file.getPath(), new File(targetFolder.getPath(), file.getName()).getPath());
@@ -181,7 +196,12 @@ public class FileManager {
             ret = false;
         } finally {
             try {
-                fileOutputStream.close();
+                if (Objects.nonNull(fileOutputStream)) {
+                    fileOutputStream.close();
+                }
+                if (Objects.nonNull(document)) {
+                    document.close();
+                }
             } catch (IOException e) {}
         }
         return ret;
@@ -195,7 +215,7 @@ public class FileManager {
      * @return
      */
     public boolean saveDocument(XWPFDocument document, String savePath, String fileName){
-        return saveDocument(document, savePath + fileName);
+        return saveDocument(document, savePath + separator + fileName);
     }
 
     /**********************************
@@ -240,7 +260,7 @@ public class FileManager {
      * @return
      */
     public boolean saveFile(InputStream  stream, String savePath, String fileName) {
-        return saveFile(stream, savePath + fileName);
+        return saveFile(stream, savePath + separator + fileName);
     }
 
     /**
@@ -262,6 +282,7 @@ public class FileManager {
             return  false;
         } finally {
             try {
+                if (Objects.nonNull(fileOutputStream))
                 fileOutputStream.close();
             }catch (IOException e){}
         }
@@ -342,4 +363,46 @@ public class FileManager {
             return  0.0;
         }
     }
+
+    /**
+     * 获取文件流  注意关闭文件流
+     * @param filePath
+     * @return
+     */
+    public FileInputStream getArchiveFile(String filePath) {
+        FileInputStream fileOutputStream = null;
+        try {
+            fileOutputStream = new FileInputStream(filePath);
+        } catch (FileNotFoundException e) {}
+        return fileOutputStream;
+    }
+
+    /**
+     * 保存表格文件为档案
+     * @param workbook
+     * @param savePath
+     * @return
+     */
+    public boolean saveWorkbook(Workbook workbook, String savePath) {
+        FileOutputStream fileOutputStream = null;
+        boolean result = true;
+        try {
+            fileOutputStream = new FileOutputStream(savePath);
+            workbook.write(fileOutputStream);
+        } catch (IOException e) {
+            result = false;
+        } finally {
+            if (Objects.nonNull(fileOutputStream)) {
+                try {
+                    fileOutputStream.close();
+                } catch (IOException e) { result = false; }
+            }
+            if (Objects.nonNull(workbook)) {
+                try {
+                    workbook.close();
+                } catch (IOException e) {result = false; }
+            }
+        }
+        return result;
+    }
 }

+ 2 - 2
common/src/main/java/com/koobietech/eas/common/utils/JwtManager.java

@@ -29,7 +29,7 @@ public class JwtManager {
      */
     public String createJwt(JwtUserDto userDto){
         Calendar calendar = Calendar.getInstance();
-        calendar.add(calendar.DATE, expires);
+        calendar.add(Calendar.DATE, expires);
         String sign = JWT.create()
                 .withClaim("user", userDto.getUsername())
                 .withClaim("id", userDto.getId())
@@ -46,7 +46,7 @@ public class JwtManager {
      */
     public String createJwt(JwtUserDto userDto, Integer expires){
         Calendar calendar = Calendar.getInstance();
-        calendar.add(calendar.DATE, expires);
+        calendar.add(Calendar.DATE, expires);
         String sign = JWT.create()
                 .withClaim("user", userDto.getUsername())
                 .withClaim("id", userDto.getId())

+ 3 - 1
common/src/main/java/com/koobietech/eas/common/utils/PasswordManager.java

@@ -9,6 +9,9 @@ import org.springframework.stereotype.Component;
 
 import java.nio.charset.StandardCharsets;
 
+/**
+ * @author lc
+ */
 @Component
 public class PasswordManager {
 
@@ -31,5 +34,4 @@ public class PasswordManager {
     }
 
 
-
 }

+ 45 - 0
common/src/main/java/com/koobietech/eas/common/utils/SecurityUtils.java

@@ -0,0 +1,45 @@
+package com.koobietech.eas.common.utils;
+
+import com.koobietech.eas.dao.adminLoginPojo.UserDetail;
+import org.springframework.security.core.context.SecurityContextHolder;
+
+import java.util.Objects;
+
+/**
+ * @author lc
+ */
+public class SecurityUtils {
+
+    public static String getLoginUserName() {
+        UserDetail principal = getPrincipal();
+        if (Objects.nonNull(principal)) {
+            return principal.getUsername();
+        }
+        return "anonymousUser";
+    }
+
+    public static Long getLoginUid() {
+        UserDetail principal = getPrincipal();
+        if (Objects.nonNull(principal)) {
+            return principal.getId();
+        }
+        return 0L;
+    }
+
+    public static boolean isLogged() {
+        UserDetail principal = getPrincipal();
+        return Objects.nonNull(principal);
+    }
+
+    private static UserDetail getPrincipal() {
+        Object principal = SecurityContextHolder.getContext().getAuthentication().getPrincipal();
+        if (Objects.nonNull(principal)) {
+            if (principal instanceof UserDetail) {
+                return (UserDetail) principal;
+            } else {
+                return null;
+            }
+        }
+        return null;
+    }
+}

+ 113 - 14
common/src/main/java/com/koobietech/eas/common/utils/StudentArchiveGenerator.java

@@ -1,11 +1,20 @@
 package com.koobietech.eas.common.utils;
 
+import com.koobietech.eas.common.constant.FileType;
+import com.koobietech.eas.common.constant.UniversityCodeUtils;
+import com.koobietech.eas.common.pojo.ArchiveNumberInfo;
+import com.koobietech.eas.common.pojo.StudentNumberInfo;
+
 import java.time.LocalDate;
 import java.time.LocalDateTime;
 import java.time.Period;
 import java.time.format.DateTimeFormatter;
 import java.util.Locale;
 import java.util.UUID;
+
+/**
+ * @author lc
+ */
 public class StudentArchiveGenerator {
 
     private static final String ARCHIVE_CODE_PREFIX = "SA";
@@ -15,8 +24,14 @@ public class StudentArchiveGenerator {
     private static final int STUDENT_CODE_LENGTH = 25;
     private static final int STUDENT_NUM_LENGTH = 8;
 
-    public  static String generateArchiveCode(String generateStudentCode, String fileTypeCode) {
-        String studentNum = generateStudentCode.substring(2, STUDENT_NUM_LENGTH + 3).replace("X", "");
+    /**
+     * 生成文件档案编号
+     * @param generateStudentCode
+     * @param fileTypeCode
+     * @return SA911X3B98723081544551720
+     */
+    public static String generateArchiveCode(String generateStudentCode, String fileTypeCode) {
+        String studentNum = generateStudentCode.substring(2, STUDENT_NUM_LENGTH + 3);
         String nowDate = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyMMddHhmmss", Locale.CHINA));
         String archiveCode = ARCHIVE_CODE_PREFIX + studentNum + nowDate + fileTypeCode;
         if (archiveCode.length() < ARCHIVE_CODE_LENGTH) {
@@ -26,11 +41,42 @@ public class StudentArchiveGenerator {
         return archiveCode;
     }
 
-    public static String generateStudentCode(String studentNumber, String studentId, String schoolName, String enrollmentDate) {
+    /**
+     *解析档案编号信息
+     *
+     * @param archiveNumber
+     * @return
+     */
+    public static ArchiveNumberInfo parseArchiveNumber(String archiveNumber) {
+        ArchiveNumberInfo archiveInfo = new ArchiveNumberInfo();
+        String studentCode = archiveNumber.substring(2, STUDENT_NUM_LENGTH + 3);
+        String studentId = studentCode.split("X")[0];
+        String createTime = archiveNumber.substring(STUDENT_NUM_LENGTH + 3, STUDENT_NUM_LENGTH + 15);
+        String fileTypeCode = archiveNumber.substring(ARCHIVE_CODE_LENGTH - 2);
+        archiveInfo.setStudentId(Integer.parseInt(studentId));
+        archiveInfo.setStudentCode(studentCode);
+        archiveInfo.setCreateTime(Long.parseLong(createTime));
+        archiveInfo.setFileTypeCode(Integer.parseInt(fileTypeCode));
+        archiveInfo.setFileSuffix(FileType.getSuffix(Integer.parseInt(fileTypeCode)));
+        return archiveInfo;
+    }
+
+
+
+    /**
+     * 生成学生档案编码
+     * @param studentNumber
+     * @param studentCardId
+     * @param schoolName
+     * @param enrollmentDate
+     * @return  ST911X3B98736M20251021273
+     */
+    public static String generateStudentCode(String studentNumber, String studentCardId, String schoolName, String enrollmentDate) {
         LocalDate localDateEnrollmentDate = LocalDate.of(Integer.parseInt(enrollmentDate), 1, 1);
-        String studentAge = String.valueOf(getStudentAge(studentId));
+        String studentAge = String.valueOf(getStudentAge(studentCardId));
         String studentNum = getStudentNum(studentNumber);
-        String studentGender = getStudentGender(studentId).substring(0, 1); // 取性别代码的首字母
+        // 取性别代码的首字母
+        String studentGender = getStudentGender(studentCardId).substring(0, 1);
         String graduationDate = String.valueOf(getStudentGraduationDate(localDateEnrollmentDate).getYear());
 
         String studentCode = STUDENT_CODE_PEREFIX + studentNum + studentAge +
@@ -44,34 +90,87 @@ public class StudentArchiveGenerator {
         return studentCode;
     }
 
+    /**
+     * 解析学生档案编号信息
+     *
+     * @param studentNumber 学生档案编号
+     * @return 学生档案编号信息
+     */
+    public static StudentNumberInfo parseStudentNumber(String studentNumber) {
+        if (studentNumber == null) {
+            return null;
+        }
+        String studentNum = studentNumber.substring(2, STUDENT_NUM_LENGTH + 3);
+        String studentId = studentNum.split("X")[0];
+        String studentAge = studentNumber.substring(STUDENT_NUM_LENGTH + 3, STUDENT_NUM_LENGTH + 5);
+        String studentGender = studentNumber.substring(STUDENT_NUM_LENGTH + 5, STUDENT_NUM_LENGTH + 6);
+        String graduationDate = studentNumber.substring(STUDENT_NUM_LENGTH + 6, STUDENT_NUM_LENGTH + 10);
+        String schoolCode = studentNumber.substring(STUDENT_NUM_LENGTH + 10, STUDENT_NUM_LENGTH + 15);
+        StudentNumberInfo info = new StudentNumberInfo();
+        info.setStudentNum(studentNum);
+        info.setStudentId(Long.valueOf(studentId));
+        info.setStudentAge(Integer.parseInt(studentAge));
+        info.setStudentGender(studentGender);
+        info.setGraduationDate(graduationDate);
+        info.setSchoolName(UniversityCodeUtils.getName(Integer.parseInt(schoolCode)));
+        info.setSchoolCode(Integer.parseInt(schoolCode));
+        return info;
+    }
+
+    /**
+     * 获取学生编号,自动补齐
+     * @param studentNumber
+     * @return
+     */
     private static String getStudentNum(String studentNumber) {
         if (studentNumber.length() < STUDENT_NUM_LENGTH) {
-            studentNumber = studentNumber + "X" + UUID.randomUUID().toString()
+            studentNumber = studentNumber + "X" +
+                    (UUID.randomUUID().toString().replace("-", "").replace("X", ""))
                     .toUpperCase(Locale.ROOT).substring(0, STUDENT_NUM_LENGTH - studentNumber.length());
         }
         return studentNumber;
     }
 
-    private static int getStudentAge(String studentId) {
+    /**
+     * 获取学生年龄
+     * @param studentCardId
+     * @return
+     */
+    private static int getStudentAge(String studentCardId) {
         LocalDate currentDate = LocalDate.now();
-        LocalDate birthDateirthDate = extractBirthDate(studentId);
-        Period period = Period.between(birthDateirthDate, currentDate);
+        LocalDate birthDateWithDate = extractBirthDate(studentCardId);
+        Period period = Period.between(birthDateWithDate, currentDate);
         return period.getYears();
     }
 
-    private static String getStudentGender(String studentId) {
+    /**
+     * 获取学生性别
+     * @param studentCardId
+     * @return
+     */
+    private static String getStudentGender(String studentCardId) {
         // 根据身份证号获取性别,这里只取身份证号的倒数第二位判断性别,假设性别代码为奇数表示男性,偶数表示女性
-        int genderCode = Integer.parseInt(studentId.substring(16, 17));
+        int genderCode = Integer.parseInt(studentCardId.substring(16, 17));
         return genderCode % 2 == 0 ? "F" : "M";
     }
 
+    /**
+     * 获取学生毕业日期
+     * @param enrollmentDate
+     * @return
+     */
     private static LocalDate getStudentGraduationDate(LocalDate enrollmentDate) {
         // 假设毕业时间为入学时间的四年后
-        LocalDate graduationDate = enrollmentDate.plusYears(4);
-        return graduationDate;
+        return enrollmentDate.plusYears(4);
     }
-    // 提取身份证号码中的出生日期部分
+
+    /**
+     * 提取身份证号码的出生日期部分
+     * @param idCard
+     * @return
+     */
     private static LocalDate extractBirthDate(String idCard) {
+        // 提取身份证号码中的出生日期部分
         String birthdate = idCard.substring(6, 14);
         DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyyMMdd");
         return LocalDate.parse(birthdate, formatter);

+ 15 - 5
common/src/test/java/com/koobietech/eas/common/utils/PasswordManagerTest.java

@@ -1,18 +1,28 @@
 package com.koobietech.eas.common.utils;
 
 
-import java.util.Date;
-
 class PasswordManagerTest {
 
 
 
     public static void main(String[] args) {
 
-        String property = System.getProperty("user.dir");
-        System.out.println( property );
 
-    }
+        //ST911X3B98736M20251021273
+//        System.out.println(StudentArchiveGenerator.generateStudentCode(
+//                "911", "232126198703194770", "10212", "2021"
+//        ));
+
+ //       System.out.println(StudentArchiveGenerator.parseStudentNumber("ST911X3B98736M20251021273"));
+
+   //     System.out.println(StudentArchiveGenerator.parseArchiveNumber("SA911X3B98723081544551711"));
 
+        //SA911X3B98723081544551720
+//        System.out.println(StudentArchiveGenerator.generateArchiveCode(
+//                "ST911X3B98736M20251021273", "20"
+//        ));
+
+
+    }
 
 }

+ 4 - 4
controller/pom.xml

@@ -81,8 +81,8 @@
     </dependencyManagement>
 
     <build>
-        <resources>
-            <resource>
+<!--        <resources>-->
+<!--            <resource>-->
 <!--                <directory>src/main/resources</directory>-->
 <!--                <filtering>true</filtering>-->
 <!--                <includes>-->
@@ -94,8 +94,8 @@
 <!--                    <include>**/*.yaml</include>-->
 <!--                    <include>**/*.properties</include>-->
 <!--                </includes>-->
-            </resource>
-        </resources>
+<!--            </resource>-->
+<!--        </resources>-->
         <plugins>
             <plugin>
                 <groupId>org.apache.maven.plugins</groupId>

+ 6 - 3
controller/src/main/java/com/koobietech/eas/controller/EasStuProfileController.java

@@ -16,10 +16,13 @@ public class EasStuProfileController {
     private EasStuProfileService easStuProfileService;
 
     @PostMapping("/StuProfileDownload")
-    public JsonResult StuProfileDownload(@RequestBody  EasArcTlsStudents easArcTlsStudents,@RequestParam Integer manager_id) throws FileNotFoundException {
 
-        return easStuProfileService.StuProfileDownload(easArcTlsStudents,manager_id);
+    public JsonResult StuProfileDownload(@RequestBody EasArcTlsStudents easArcTlsStudents, @RequestParam Integer manager_id) throws FileNotFoundException {
+        //StuProfileDownload返回值是boolean,这里用JsonResult包装一下 加上if判断
+        if (easStuProfileService.StuProfileDownload(easArcTlsStudents, manager_id)) {
+            return JsonResult.ok("下载成功");
+        }
+        return JsonResult.fail("下载失败");
     }
 
-
 }

+ 46 - 0
dao/src/main/java/com/koobietech/eas/dao/Pojo/EasArcTlsAttendancePojo.java

@@ -0,0 +1,46 @@
+package com.koobietech.eas.dao.Pojo;
+
+import cn.afterturn.easypoi.excel.annotation.Excel;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Data;
+
+import java.io.Serializable;
+import java.math.BigDecimal;
+import java.util.Date;
+
+/**
+ * @author lc
+ */
+@Data
+public class EasArcTlsAttendancePojo implements Serializable {
+
+    @Excel(name = "签到日期")
+    private Date checkinDate;
+
+    @Excel(name = "学员档案号")
+    private String studentNumber;
+
+    //a表示正常出勤, b表示迟到、早退, c表示旷课, d表示请假, e表示无效
+    @Excel(name = "上午出勤状态")
+    private String morning;
+
+    //a表示正常出勤,   b表示迟到、早退, c 表示旷课, d 表示请假, e表示无效"
+    @Excel(name = "下午出勤状态")
+    private String afternoon;
+
+    @Excel(name = "学员姓名")
+    private String studentName;
+
+    @Excel(name = "类别" )
+    private Integer category;
+
+    @Excel(name = "科目" )
+    private Integer subject;
+
+    @Excel(name = "创建时间" )
+    private Date createTime;
+
+    private static final long serialVersionUID = 1L;
+
+}

+ 0 - 12
dao/src/main/java/com/koobietech/eas/dao/dto/TestDto.java

@@ -1,12 +0,0 @@
-package com.koobietech.eas.dao.dto;
-
-import io.swagger.v3.oas.annotations.media.Schema;
-import lombok.Data;
-
-@Data
-public class TestDto {
-    @Schema(description = "学员ID")
-    int id;
-    @Schema(description = "学员名字")
-    String name;
-}

+ 6 - 1
pom.xml

@@ -38,9 +38,15 @@
         <maven.compiler.plugin.version>3.8.1</maven.compiler.plugin.version>
         <captcha.version>1.3.0</captcha.version>
         <xerces.version>2.9.1</xerces.version>
+        <security.version>5.7.5</security.version>
     </properties>
     <dependencyManagement>
         <dependencies>
+            <dependency>
+                <groupId>org.springframework.security</groupId>
+                <artifactId>spring-security-core</artifactId>
+                <version>${security.version}</version>
+            </dependency>
             <dependency>
                 <groupId>xerces</groupId>
                 <artifactId>xercesImpl</artifactId>
@@ -144,7 +150,6 @@
         <module>mbg</module>
         <module>service</module>
         <module>security</module>
-        <module>upload</module>
     </modules>
 
     <repositories>

+ 1 - 1
security/src/main/java/com/koobietech/eas/security/filter/EasSecurityFilter.java

@@ -80,7 +80,7 @@ public class EasSecurityFilter extends OncePerRequestFilter {
                     }
 
                     // 使用用户的用户名、空凭证参数和权限对象集合创建一个 UsernamePasswordAuthenticationToken 身份验证令牌
-                    UsernamePasswordAuthenticationToken authenticationToken = new UsernamePasswordAuthenticationToken(userDetail.getUsername(), null, objects);
+                    UsernamePasswordAuthenticationToken authenticationToken = new UsernamePasswordAuthenticationToken(userDetail, null, objects);
 
                     // 将身份验证令牌设置到当前的 SecurityContext 中
                     context.setAuthentication(authenticationToken);

+ 0 - 19
security/src/main/java/com/koobietech/eas/security/utils/SecurityUtils.java

@@ -1,19 +0,0 @@
-package com.koobietech.eas.security.utils;
-import org.springframework.security.core.context.SecurityContextHolder;
-public class SecurityUtils {
-
-    public static String getLoginUserName(){
-        Object principal = getPrincipal();
-        return principal.toString().equals("anonymousUser") ? "" : principal.toString();
-    }
-
-    public static boolean isLogged(){
-        Object principal = getPrincipal();
-        return principal.toString().equals("anonymousUser");
-    }
-
-    private static Object getPrincipal(){
-        return SecurityContextHolder.getContext().getAuthentication().getPrincipal();
-    }
-
-}

+ 24 - 0
service/src/main/java/com/koobietech/eas/service/EasArcTlsScoresService.java

@@ -9,14 +9,38 @@ import java.util.List;
 
 public interface EasArcTlsScoresService {
 
+    /**
+     * 添加学员分数
+     * @param easArcTlsScores
+     * @return
+     */
     int addStudentScore(EasArcTlsScores easArcTlsScores);
 
+    /**
+     * 修改学员分数
+     * @param easArcTlsScores
+     * @return
+     */
     int updateStudentScore(EasArcTlsScores easArcTlsScores);
 
+    /**
+     * 查询学员分数
+     * @return
+     */
     List<EasArcTlsScores> selectAllStudentScores();
 
+    /**
+     * 主键查询
+     * @param easArcTlsScores
+     * @return
+     */
     PageData selectScoreByExample(EasArcTlsScores easArcTlsScores);
 
+    /**
+     * 导入学员分数
+     * @param inputStream
+     * @return
+     */
     Boolean importExcelScores(InputStream inputStream);
 
 }

+ 38 - 2
service/src/main/java/com/koobietech/eas/service/EasArchivesFilesService.java

@@ -1,18 +1,24 @@
 package com.koobietech.eas.service;
 
 import com.koobietech.eas.dao.dto.ArchivesDto;
+import com.koobietech.eas.mbg.model.EasArcTlsStudents;
+import org.apache.poi.ss.usermodel.Workbook;
 import org.apache.poi.xwpf.usermodel.XWPFDocument;
 
+import java.io.FileInputStream;
 import java.io.InputStream;
 import java.io.OutputStream;
 
+/**
+ * @author lc
+ */
 public interface EasArchivesFilesService {
     /**
      * 获取学生档案文件
      * @param studentNumber 学号
      * @return 学生档案文件
      */
-    ArchivesDto getArchiveStudentsFile(String studentNumber);
+    EasArcTlsStudents getArchiveStudentsFile(String studentNumber);
 
     /**
      * 保存学生考勤文件
@@ -46,12 +52,27 @@ public interface EasArchivesFilesService {
      */
     ArchivesDto saveArchiveFile(String studentNumber, InputStream stream, String type);
 
+    /**
+     * 保存 Excel
+     * @param studentNumber
+     * @param workbook
+     * @return
+     */
+    ArchivesDto saveArchiveFile(String studentNumber, Workbook workbook);
+
     /**
      * 获取文件
      * @param filePath
      * @return
      */
-    OutputStream getArchiveFile(String filePath);
+    FileInputStream getArchiveFile(String filePath);
+
+    /**
+     * 获取Resource文件
+     * @param filePath
+     * @return
+     */
+    InputStream getResourceStream(String filePath);
 
     /**
      * 删除文件
@@ -59,4 +80,19 @@ public interface EasArchivesFilesService {
      * @return
      */
     boolean deleteArchiveFile(String filePath);
+
+    /**
+     * 备份档案文件
+     * @param filePath
+     * @return
+     */
+    boolean backupArchiveFile(String filePath);
+
+    /**
+     * 获取档案连接Url地址
+     * @param filePath
+     * @return
+     */
+    String getArchiveUrl(String filePath);
+
 }

+ 1 - 1
service/src/main/java/com/koobietech/eas/service/EasStuProfileService.java

@@ -6,5 +6,5 @@ import com.koobietech.eas.mbg.model.EasArcTlsStudents;
 import java.io.FileNotFoundException;
 
 public interface EasStuProfileService {
-    JsonResult StuProfileDownload(EasArcTlsStudents easArcTlsStudents,Integer manager_id) throws FileNotFoundException;
+    boolean StuProfileDownload(EasArcTlsStudents easArcTlsStudents,Integer manager_id) throws FileNotFoundException;
 }

+ 61 - 51
service/src/main/java/com/koobietech/eas/service/impl/EasArcTlsAttendanceServiceImpl.java

@@ -1,20 +1,32 @@
 package com.koobietech.eas.service.impl;
 
+import cn.afterturn.easypoi.excel.ExcelExportUtil;
+import cn.afterturn.easypoi.excel.entity.ExportParams;
+import cn.hutool.core.bean.BeanUtil;
+import com.koobietech.eas.common.constant.FileType;
 import com.koobietech.eas.common.exception.EasException;
 import com.koobietech.eas.common.result.PageData;
-import com.koobietech.eas.mbg.mapper.EasArcTlsAttendanceMapper;
-import com.koobietech.eas.mbg.mapper.EasEduCltRelationMapper;
-import com.koobietech.eas.mbg.mapper.EasEduScheduleMapper;
-import com.koobietech.eas.mbg.mapper.EasSysStudentMapper;
+import com.koobietech.eas.common.utils.SecurityUtils;
+import com.koobietech.eas.dao.Pojo.EasArcTlsAttendancePojo;
+import com.koobietech.eas.dao.Pojo.EasArcTlsScoresPojo;
+import com.koobietech.eas.dao.dto.ArchivesDto;
+import com.koobietech.eas.mbg.mapper.*;
 import com.koobietech.eas.mbg.model.*;
 import com.koobietech.eas.service.EasArcTlsAttendanceService;
+import com.koobietech.eas.service.EasArchivesFilesService;
+import org.apache.poi.ss.usermodel.Workbook;
 import org.springframework.stereotype.Service;
 import org.springframework.util.StringUtils;
 
 import javax.annotation.Resource;
+import java.time.LocalDate;
+import java.time.ZoneOffset;
 import java.util.*;
 import java.util.stream.Collectors;
 
+/**
+ * @author lc
+ */
 @Service
 public class EasArcTlsAttendanceServiceImpl implements EasArcTlsAttendanceService {
 
@@ -30,6 +42,11 @@ public class EasArcTlsAttendanceServiceImpl implements EasArcTlsAttendanceServic
     @Resource
     private EasEduScheduleMapper easEduScheduleMapper;
 
+    @Resource
+    EasArchivesFilesService easArchivesFilesService;
+
+    @Resource
+    EasArcArchivesMapper arcArchivesMapper;
 
     @Override
     public PageData query(EasArcTlsAttendance attendance) {
@@ -84,8 +101,9 @@ public class EasArcTlsAttendanceServiceImpl implements EasArcTlsAttendanceServic
         //签到日期前端会自己传 所以就不需要再写一次了
         attendance.setCreateTime(new Date());
         attendance.setModifyTime(new Date());
-        return easArcTlsAttendanceMapper.insert(attendance) == 1;
-
+        int insert = easArcTlsAttendanceMapper.insert(attendance);
+        saveStudentAttendanceArchive(attendance);
+        return insert == 1;
     }
 
     @Override
@@ -107,7 +125,9 @@ public class EasArcTlsAttendanceServiceImpl implements EasArcTlsAttendanceServic
     @Override
     public Boolean update(EasArcTlsAttendance attendance) {
         attendance.setModifyTime(new Date());
-        return easArcTlsAttendanceMapper.updateByPrimaryKey(attendance) == 1;
+        int i = easArcTlsAttendanceMapper.updateByPrimaryKey(attendance);
+        saveStudentAttendanceArchive(attendance);
+        return i == 1;
     }
 
     @Override
@@ -159,51 +179,41 @@ public class EasArcTlsAttendanceServiceImpl implements EasArcTlsAttendanceServic
                 .collect(Collectors.toList());
     }
 
+    public boolean saveStudentAttendanceArchive(EasArcTlsAttendance attendance){
+        EasArcTlsAttendanceExample easArcTlsAttendanceExample = new EasArcTlsAttendanceExample();
+        EasArcTlsAttendanceExample.Criteria criteria = easArcTlsAttendanceExample.createCriteria();
+        criteria.andStudentNumberEqualTo(attendance.getStudentNumber());
+        //criteria.andScheduleIdEqualTo(attendance.getScheduleId());
+        List<EasArcTlsAttendance> easArcTlsAttendances = easArcTlsAttendanceMapper.selectByExample(easArcTlsAttendanceExample);
+        ArchivesDto archivesDto = saveEasArcTlsAttendanceToExcel(easArcTlsAttendances, attendance.getStudentNumber());
+        EasArcArchives easArcArchives = new EasArcArchives();
+        easArcArchives.setStudentNumber(attendance.getStudentNumber());
+        easArcArchives.setArchiveNumber(archivesDto.getArchiveCode());
+        easArcArchives.setFilePath(archivesDto.getPath());
+        easArcArchives.setCreateTime(new Date());
+        easArcArchives.setCreateUid( SecurityUtils.getLoginUid().intValue() );
+        easArcArchives.setModifyTime(new Date());
+        easArcArchives.setArctype(FileType.XLSX.name());
+        easArcArchives.setManagerId( SecurityUtils.getLoginUid().intValue() );
+        easArcArchives.setValidityTime( new Date(LocalDate.now().plusMonths(20)
+                .atStartOfDay().toInstant(ZoneOffset.UTC).toEpochMilli()) );
+        int insert = arcArchivesMapper.insert(easArcArchives);
+        return insert == 1;
+    }
 
-//    @Override
-//    public List<EasArcTlsAttendance> getStudentList(Long scheduleId) {
-//        // 创建查询条件,根据课表ID查找EasEduSchedule表,获取班级ID
-//        EasEduSchedule easEduSchedule = easEduScheduleMapper.selectByPrimaryKey(scheduleId);
-//        if (Objects.nonNull(easEduSchedule)) {
-//            Long classId = Long.valueOf(easEduSchedule.getClassId()); // 将班级ID赋值给classId变量
-//            System.out.println("!!!!查出来的对应scheduleId的classId = " + classId);
-//
-//            // 创建查询条件,根据班级ID查找EasEduCltRelation表,获取学生ID
-//            EasEduCltRelationExample easEduCltRelationExample = new EasEduCltRelationExample();
-//            EasEduCltRelationExample.Criteria criteriaFindStuId = easEduCltRelationExample.createCriteria();
-//            criteriaFindStuId.andClassIdEqualTo(classId); // 设置班级ID作为查询条件
-//
-//            // 查询EasEduCltRelation表,获取符合条件的学生ID列表
-//            List<EasEduCltRelation> easEduCltRelations = easEduCltRelationMapper.selectByExample(easEduCltRelationExample);
-//            List<Long> studentIds = new ArrayList<>();
-//            for (EasEduCltRelation easEduCltRelation : easEduCltRelations) {
-//                studentIds.add(Long.valueOf(easEduCltRelation.getStudentId())); // 将学生ID添加到列表中
-//            }
-//
-//            // 根据学生ID列表查询EasSysStudent表,获取学生信息
-//            EasSysStudentExample easSysStudentExample = new EasSysStudentExample();
-//            EasSysStudentExample.Criteria criteriaFindStu = easSysStudentExample.createCriteria();
-//            if (!studentIds.isEmpty()) {
-//                criteriaFindStu.andIdIn(studentIds); // 设置学生ID列表作为查询条件
-//            }
-//            List<EasSysStudent> easSysStudents = easSysStudentMapper.selectByExample(easSysStudentExample);
-//
-//            // 封装查询结果到PageData对象并返回
-//            PageData ret = new PageData();
-//            ret.setData(easSysStudents);
-//            List<EasArcTlsAttendance> list = new ArrayList<>();
-//            easSysStudents.forEach(easSysStudent -> {
-//                EasArcTlsAttendance easArcTlsAttendance = new EasArcTlsAttendance();
-//                easArcTlsAttendance.setStudentNumber(easSysStudent.getStudentNumber());
-//                easArcTlsAttendance.setStudentName(easSysStudent.getStudentName());
-//                list.add(easArcTlsAttendance);
-//            });
-//            return list;
-//        } else {
-//            throw new EasException("未查询到对应课表,请检查数据库", 9595); // 如果查询不到课表,则返回空列表
-//        }
-//    }
-
+    private ArchivesDto saveEasArcTlsAttendanceToExcel(List<EasArcTlsAttendance> easArcTlsAttendances, String studentNumber) {
+        List<EasArcTlsAttendancePojo> arcTlsAttendanceList = new ArrayList<>();
+        for (EasArcTlsAttendance tlsAttendance: easArcTlsAttendances) {
+            EasArcTlsAttendancePojo easArcTlsAttendancePojo = new EasArcTlsAttendancePojo();
+            BeanUtil.copyProperties(tlsAttendance, easArcTlsAttendancePojo);
+            arcTlsAttendanceList.add(easArcTlsAttendancePojo);
+        }
+        ExportParams params   = new ExportParams("学员签到表", "签到");
+        Workbook workbook = ExcelExportUtil.exportExcel(params,
+                EasArcTlsScoresPojo.class, arcTlsAttendanceList);
+        ArchivesDto archivesDto = easArchivesFilesService.saveArchiveFile(studentNumber, workbook);
+        return archivesDto;
+    }
 
 }
 

+ 92 - 23
service/src/main/java/com/koobietech/eas/service/impl/EasArcTlsScoresServiceImpl.java

@@ -1,41 +1,86 @@
 package com.koobietech.eas.service.impl;
 
+import cn.afterturn.easypoi.excel.ExcelExportUtil;
 import cn.afterturn.easypoi.excel.ExcelImportUtil;
+import cn.afterturn.easypoi.excel.entity.ExportParams;
 import cn.afterturn.easypoi.excel.entity.ImportParams;
+import cn.afterturn.easypoi.handler.inter.IExcelExportServer;
 import cn.hutool.core.bean.BeanUtil;
+import com.koobietech.eas.common.constant.FileType;
+import com.koobietech.eas.common.exception.EasException;
 import com.koobietech.eas.common.result.PageData;
+import com.koobietech.eas.common.utils.FileManager;
+import com.koobietech.eas.common.utils.SecurityUtils;
+import com.koobietech.eas.common.utils.StudentArchiveGenerator;
 import com.koobietech.eas.dao.Pojo.EasArcTlsScoresPojo;
+import com.koobietech.eas.dao.dto.ArchivesDto;
+import com.koobietech.eas.mbg.mapper.EasArcArchivesMapper;
 import com.koobietech.eas.mbg.mapper.EasArcTlsScoresMapper;
+import com.koobietech.eas.mbg.model.EasArcArchives;
 import com.koobietech.eas.mbg.model.EasArcTlsScores;
 import com.koobietech.eas.mbg.model.EasArcTlsScoresExample;
 import com.koobietech.eas.service.EasArcTlsScoresService;
+import com.koobietech.eas.service.EasArchivesFilesService;
+import org.apache.poi.ss.usermodel.Workbook;
 import org.springframework.stereotype.Service;
 import org.springframework.util.StringUtils;
 
 import javax.annotation.Resource;
 import java.io.FileNotFoundException;
 import java.io.InputStream;
+import java.time.LocalDate;
+import java.time.ZoneOffset;
+import java.util.ArrayList;
 import java.util.Date;
 import java.util.List;
 import java.util.Objects;
 
+/**
+ * @author lc
+ */
 @Service
 public class EasArcTlsScoresServiceImpl implements EasArcTlsScoresService {
 
     @Resource
     EasArcTlsScoresMapper easArcTlsScoresMapper;
 
+    @Resource
+    EasArchivesFilesService easArchivesFilesService;
+
+    @Resource
+    EasArcArchivesMapper arcArchivesMapper;
 
     @Override
     public int addStudentScore(EasArcTlsScores easArcTlsScores) {
         easArcTlsScores.setCreateTime(new Date());
         easArcTlsScores.setModifyTime(new Date());
-        return easArcTlsScoresMapper.insert(easArcTlsScores);
+        easArcTlsScoresMapper.insert(easArcTlsScores);
+        return saveStudentScoreArchive(easArcTlsScores) ? 1: 0;
+    }
+
+    private boolean saveStudentScoreArchive(EasArcTlsScores easArcTlsScores){
+        EasArcTlsScoresExample easArcTlsScoresExample = new EasArcTlsScoresExample();
+        List<EasArcTlsScores> easArcTlsScoresList = easArcTlsScoresMapper.selectByExample(easArcTlsScoresExample);
+        ArchivesDto archivesDto = saveEasArcTlsScoresToExcel(easArcTlsScoresList, easArcTlsScores.getStudentNumber());
+        EasArcArchives easArcArchives = new EasArcArchives();
+        easArcArchives.setStudentNumber(easArcTlsScores.getStudentNumber());
+        easArcArchives.setArchiveNumber(archivesDto.getArchiveCode());
+        easArcArchives.setFilePath(archivesDto.getPath());
+        easArcArchives.setCreateTime(new Date());
+        easArcArchives.setCreateUid( SecurityUtils.getLoginUid().intValue() );
+        easArcArchives.setModifyTime(new Date());
+        easArcArchives.setArctype(FileType.XLSX.name());
+        easArcArchives.setManagerId( SecurityUtils.getLoginUid().intValue() );
+        easArcArchives.setValidityTime( new Date(LocalDate.now().plusMonths(20)
+                .atStartOfDay().toInstant(ZoneOffset.UTC).toEpochMilli()) );
+        int insert = arcArchivesMapper.insert(easArcArchives);
+        return insert == 1;
     }
 
     @Override
     public int updateStudentScore(EasArcTlsScores easArcTlsScores) {
-        return easArcTlsScoresMapper.updateByPrimaryKey(easArcTlsScores);
+        easArcTlsScoresMapper.updateByPrimaryKey(easArcTlsScores);
+        return saveStudentScoreArchive(easArcTlsScores) ? 1: 0;
     }
 
     @Override
@@ -84,30 +129,54 @@ public class EasArcTlsScoresServiceImpl implements EasArcTlsScoresService {
         return PageData.init(easArcTlsScores1,l);
     }
 
-        @Override
+    @Override
     public Boolean importExcelScores(InputStream inputStream) {
-            ImportParams params = new ImportParams();
-            params.setTitleRows(1);
-            params.setHeadRows(1);
-            try {
-                List<EasArcTlsScoresPojo> score = ExcelImportUtil.importExcel(
-                        inputStream, EasArcTlsScoresPojo.class, params);
-                for ( EasArcTlsScoresPojo easArcTlsScoresPojo : score) {
-                    if ( easArcTlsScoresPojo.getScore() == null
-                            || easArcTlsScoresPojo.getScore().equals("") ) {
-                        continue;
-                    }
-                    easArcTlsScoresPojo.setCreateTime(new Date());
-                    EasArcTlsScores easArcTlsScores = new EasArcTlsScores();
-                    BeanUtil.copyProperties(easArcTlsScoresPojo, easArcTlsScores);
-                    easArcTlsScoresMapper.insert(easArcTlsScores);
+        ImportParams params = new ImportParams();
+        params.setTitleRows(1);
+        params.setHeadRows(1);
+        try {
+            List<EasArcTlsScoresPojo> score = ExcelImportUtil.importExcel(
+                    inputStream, EasArcTlsScoresPojo.class, params);
+            for ( EasArcTlsScoresPojo easArcTlsScoresPojo : score) {
+                if ( easArcTlsScoresPojo.getScore() == null
+                        || easArcTlsScoresPojo.getScore().equals("") ) {
+                    continue;
                 }
-            } catch (FileNotFoundException e) {
-                e.printStackTrace();
-            } catch (Exception e) {
-                throw new RuntimeException(e);
+                easArcTlsScoresPojo.setCreateTime(new Date());
+                EasArcTlsScores easArcTlsScores = new EasArcTlsScores();
+                BeanUtil.copyProperties(easArcTlsScoresPojo, easArcTlsScores);
+                easArcTlsScoresMapper.insert(easArcTlsScores);
+                saveStudentScoreArchive(easArcTlsScores);
             }
-            return true;
+        } catch (FileNotFoundException e) {
+            throw new EasException(e.getMessage());
+        } catch (Exception e) {
+            throw new EasException(e.getMessage());
+        } finally {
+            try {
+                if (inputStream != null) {
+                    inputStream.close();
+                }
+            } catch (Exception e) {}
+        }
+        return true;
     }
 
+    /**
+     * 将学员考试分数保存为Execl文件
+     */
+    public ArchivesDto saveEasArcTlsScoresToExcel(List<EasArcTlsScores> easArcTlsScoresList,
+                                              String studentNumber) {
+        List<EasArcTlsScoresPojo> easArcTlsScoresPojoList = new ArrayList<>();
+        for (EasArcTlsScores easArcTlsScores: easArcTlsScoresList) {
+            EasArcTlsScoresPojo easArcTlsScoresPojo = new EasArcTlsScoresPojo();
+            BeanUtil.copyProperties(easArcTlsScores, easArcTlsScoresPojo);
+            easArcTlsScoresPojoList.add(easArcTlsScoresPojo);
+        }
+        ExportParams params   = new ExportParams("考试成绩表", "考试成绩");
+        Workbook workbook = ExcelExportUtil.exportExcel(params,
+                EasArcTlsScoresPojo.class, easArcTlsScoresPojoList);
+        ArchivesDto archivesDto = easArchivesFilesService.saveArchiveFile(studentNumber, workbook);
+        return archivesDto;
+    }
 }

+ 94 - 32
service/src/main/java/com/koobietech/eas/service/impl/EasArchivesFilesServiceImpl.java

@@ -1,79 +1,141 @@
 package com.koobietech.eas.service.impl;
 
 import com.koobietech.eas.common.constant.FileType;
-import com.koobietech.eas.common.constant.FileTypeExt;
 import com.koobietech.eas.common.utils.FileManager;
 import com.koobietech.eas.common.utils.StudentArchiveGenerator;
 import com.koobietech.eas.dao.dto.ArchivesDto;
+import com.koobietech.eas.mbg.mapper.EasArcTlsStudentsMapper;
+import com.koobietech.eas.mbg.model.EasArcTlsStudents;
+import com.koobietech.eas.mbg.model.EasArcTlsStudentsExample;
 import com.koobietech.eas.service.EasArchivesFilesService;
+import org.apache.poi.ss.usermodel.Workbook;
 import org.apache.poi.xwpf.usermodel.XWPFDocument;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
-import java.io.File;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.util.Date;
+import java.io.*;
+import java.util.List;
 
+/**
+ * @author lc
+ */
 @Service
 public class EasArchivesFilesServiceImpl implements EasArchivesFilesService {
 
     @Value("${project.path}")
     String archivesSavePath;
 
+    final String BAKUP_SUFFIX =  ".bak";
+
     @Resource
     FileManager fileManager;
 
+    @Resource
+    EasArcTlsStudentsMapper arcTlsStudentsMapper;
+
     String separator = File.separator;
 
     @Override
-    public ArchivesDto getArchiveStudentsFile(String studentNumber) {
-        return null;
+    public ArchivesDto saveArchiveAttendanceFile(String studentNumber, XWPFDocument document) {
+        return saveArchiveDocumentFile(studentNumber, document, FileType.XLSX.name());
     }
 
     @Override
-    public ArchivesDto saveArchiveAttendanceFile(String studentNumber, XWPFDocument document) {
-        String archiveCode = StudentArchiveGenerator.generateArchiveCode(studentNumber, FileType.XLSX.getValue());
-        String path = getArchivePath(studentNumber, archiveCode);
-        if ( fileManager.isFileExists(path) ) {
-            fileManager.moveFile( path,  path + (new Date()).getTime() + ".back", true );
-        }
-        boolean status = fileManager.saveDocument(document, path);
-        return new ArchivesDto(path, status, archiveCode, FileType.XLSX.getValue());
+    public ArchivesDto saveArchiveScoresFile(String studentNumber, XWPFDocument document) {
+        return saveArchiveDocumentFile(studentNumber, document, FileType.XLSX.name());
     }
 
-    private String getArchivePath(String studentNumber, String archiveCode) {
-        String path = archivesSavePath + separator + studentNumber;
-        fileManager.createPath(path);
-        return path + separator + archiveCode + FileTypeExt.DOCX.getValue();
+    @Override
+    public ArchivesDto saveArchiveStudentsFile(String studentNumber, XWPFDocument document) {
+        return saveArchiveDocumentFile(studentNumber, document, FileType.DOCX.name());
     }
 
     @Override
-    public ArchivesDto saveArchiveScoresFile(String studentNumber, XWPFDocument document) {
-        return null;
+    public ArchivesDto saveArchiveFile(String studentNumber, Workbook workbook) {
+        return saveArchiveWorkbookFile(studentNumber, workbook, FileType.XLSX.name());
     }
 
     @Override
-    public ArchivesDto saveArchiveStudentsFile(String studentNumber, XWPFDocument document) {
-        String archiveCode = StudentArchiveGenerator.generateArchiveCode(studentNumber, FileType.DOCX.getValue());
-        String path = getArchivePath(studentNumber, archiveCode);
-        boolean status = fileManager.saveDocument(document, path);
-        return new ArchivesDto(path, status, archiveCode, FileType.DOCX.getValue());
+    public ArchivesDto saveArchiveFile(String studentNumber, InputStream stream, String type) {
+        String archiveCode = getArchiveCode(studentNumber, FileType.valueOf(type).getSuffix());
+        String path = getArchivePath(studentNumber, archiveCode, FileType.valueOf(type).getSuffix());
+        boolean status = fileManager.saveFile(stream, path);
+        return new ArchivesDto(path, status, archiveCode, type);
     }
 
     @Override
-    public ArchivesDto saveArchiveFile(String studentNumber, InputStream stream, String type) {
-        return null;
+    public boolean deleteArchiveFile(String filePath) {
+        return fileManager.deleteFile(filePath);
     }
 
     @Override
-    public OutputStream getArchiveFile(String filePath) {
-        return null;
+    public FileInputStream getArchiveFile(String filePath) {
+        return fileManager.getArchiveFile(filePath);
     }
 
     @Override
-    public boolean deleteArchiveFile(String filePath) {
-        return false;
+    public InputStream getResourceStream(String filePath) {
+        InputStream resourceAsStream = null;
+        try {
+            resourceAsStream = this.getClass().getClassLoader().getResourceAsStream(filePath);
+        } catch (Exception e) {
+        }
+        return resourceAsStream;
     }
+
+    @Override
+    public EasArcTlsStudents getArchiveStudentsFile(String studentNumber) {
+        EasArcTlsStudentsExample easArcTlsStudentsExample = new EasArcTlsStudentsExample();
+        easArcTlsStudentsExample.createCriteria().andStudentNumberEqualTo(studentNumber);
+        List<EasArcTlsStudents> easArcTlsStudents = arcTlsStudentsMapper.selectByExample(easArcTlsStudentsExample);
+        return easArcTlsStudents.stream().findFirst().orElse(null);
+    }
+
+    @Override
+    public boolean backupArchiveFile(String filePath) {
+        boolean ret = false;
+        if (filePath == null || filePath.isEmpty()) {
+            return ret;
+        }
+        if ( fileManager.isFileExists(filePath) ) {
+            long time = System.currentTimeMillis();
+            ret = fileManager.moveFile(filePath, filePath + time + BAKUP_SUFFIX, true);
+        }
+        return ret;
+    }
+
+    @Override
+    public String getArchiveUrl(String filePath) {
+        String url = null;
+        if (filePath == null || filePath.isEmpty()) {
+            return url;
+        }
+        return null;
+    }
+
+    private ArchivesDto saveArchiveDocumentFile(String studentNumber, XWPFDocument document, String type) {
+        String archiveCode = StudentArchiveGenerator.generateArchiveCode(studentNumber, FileType.valueOf(type).getSuffix());
+        String path = getArchivePath(studentNumber, archiveCode, FileType.valueOf(type).getSuffix());
+        boolean status = fileManager.saveDocument(document, path);
+        return new ArchivesDto(path, status, archiveCode, type);
+    }
+
+    private ArchivesDto saveArchiveWorkbookFile(String studentNumber, Workbook workbook, String type) {
+        String archiveCode = StudentArchiveGenerator.generateArchiveCode(studentNumber, FileType.valueOf(type).getSuffix());
+        String path = getArchivePath(studentNumber, archiveCode, FileType.valueOf(type).getSuffix());
+        boolean status = fileManager.saveWorkbook(workbook, path);
+        return new ArchivesDto(path, status, archiveCode, type);
+    }
+
+    private String getArchiveCode(String studentNumber, String fileCode) {
+        return StudentArchiveGenerator.generateArchiveCode(studentNumber, fileCode);
+    }
+
+    private String getArchivePath(String studentNumber, String archiveCode, String suffix) {
+        String path = archivesSavePath + separator + studentNumber;
+        fileManager.createPath(path);
+        return path + separator + archiveCode + suffix;
+    }
+
 }

+ 88 - 94
service/src/main/java/com/koobietech/eas/service/impl/EasStuProfileServiceImpl.java

@@ -1,7 +1,8 @@
 package com.koobietech.eas.service.impl;
 
 import com.koobietech.eas.common.constant.FileType;
-import com.koobietech.eas.common.result.JsonResult;
+import com.koobietech.eas.common.constant.Gender;
+import com.koobietech.eas.common.exception.EasException;
 import com.koobietech.eas.common.utils.DateUtils;
 import com.koobietech.eas.common.utils.StudentArchiveGenerator;
 import com.koobietech.eas.dao.dto.ArchivesDto;
@@ -19,8 +20,6 @@ import org.apache.poi.xwpf.usermodel.XWPFDocument;
 import org.apache.poi.xwpf.usermodel.XWPFTable;
 import org.apache.poi.xwpf.usermodel.XWPFTableCell;
 import org.apache.poi.xwpf.usermodel.XWPFTableRow;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 import org.springframework.beans.BeanUtils;
 import org.springframework.security.crypto.password.PasswordEncoder;
 import org.springframework.stereotype.Service;
@@ -33,125 +32,127 @@ import java.util.*;
 @Service
 public class EasStuProfileServiceImpl implements EasStuProfileService {
 
-    private static final Logger LOGGER = LoggerFactory.getLogger(EasStuProfileServiceImpl.class);
     private static final String TEMPLATE_PATH = "temp/StuRegistTemp.docx";
     private static final String PHOTO_PATH = "temp/kun.jpeg";
 
     @Resource
     private EasArcTlsStudentsMapper easArcTlsStudentsMapper;
-
     @Resource
     private PasswordEncoder passwordEncoder;
-
     @Resource
     private EasSysStudentMapper easSysStudentMapper;
-
     @Resource
     private EasArcArchivesMapper easArcArchivesMapper;
-
     @Resource
     private EasArchivesFilesService easArchivesFilesService;
-
     @Override
-    public JsonResult StuProfileDownload(EasArcTlsStudents easArcTlsStudents,Integer manager_id) {
-        LOGGER.info("开始学员档案导出:{}", easArcTlsStudents);
+
+    public boolean StuProfileDownload(EasArcTlsStudents easArcTlsStudents, Integer manager_id) {
 
         try (InputStream wordStream = getClass().getClassLoader().getResourceAsStream(TEMPLATE_PATH)) {
             assert wordStream != null;
             try (XWPFDocument doc = new XWPFDocument(wordStream)) {
-
-                Map<String, Object> map = new HashMap<>();
-                map.put("student_name", easArcTlsStudents.getStudentName());
-
-                //调用内部类方法 把MF转换成 男女
-                map.put("gender", convertToGender(easArcTlsStudents.getGender()));
-
-                map.put("major", easArcTlsStudents.getMajor());
-                map.put("grade", easArcTlsStudents.getGrade());
-
-                //调用自定义的时间格式转换器 把前端传过来的带时分秒时间转换成 2019年12月12日
-                map.put("enrollment_date", DateUtils.convertToYearMonthDay(easArcTlsStudents.getEnrollmentDate()));
-
-                map.put("phone", easArcTlsStudents.getPhone());
-                map.put("university", easArcTlsStudents.getUniversity());
-                map.put("student_idnumber", easArcTlsStudents.getStudentIdnumber());
-                map.put("avatar", getClass().getClassLoader().getResourceAsStream(PHOTO_PATH));
-
                 //调用内部类方法 生成学号
                 String studentNumber = generateStudentNumber(easArcTlsStudents);
-                map.put("student_number", studentNumber);
 
+                Map<String, Object> map = generateDataMap(easArcTlsStudents, studentNumber);
                 replacePlaceholders(doc, map);
-                //saveDocument(doc);
-
                 //将easArcTlsStudents 保存到数据库
-                easArcTlsStudentsMapper.insert(easArcTlsStudents);
-
-                //使用BeanUtils 将easArcTlsStudents 转换成 eassysstudent
-                EasSysStudent easSysStudents = new EasSysStudent();
-                BeanUtils.copyProperties(easArcTlsStudents,easSysStudents);
-                //设置初始密码 使用 passwordEncoder 设置初始密码为123456
-                easSysStudents.setPasswd(passwordEncoder.encode("123456"));
-                easSysStudents.setDisabled("N");
-
-                easSysStudentMapper.insert(easSysStudents);
-
-                //组合成档案对象 保存到数据库
-                /**
-                 CREATE TABLE `eas_arc_archives` (
-            1     `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
-            1     `archive_number` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '文件电子档案号',
-            1     `student_number` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '当前电子档案归属那一个学员档案下',
-            1     `file_path` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '文件存储的路径',
-            1     `arctype` int(11) DEFAULT NULL COMMENT '文件类型Id',
-            1     `create_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
-            1     `modify_time` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间',
-            1     `validity_time` datetime DEFAULT NULL COMMENT '档案有效期截至时间',
-            1     `manager_id` int(11) DEFAULT NULL COMMENT '档案归属负责人',
-            ?     `create_date` date DEFAULT NULL COMMENT '档案创建时间, 用于文件归档用',
-            ?     `create_uid` int(11) DEFAULT NULL COMMENT '创建用户ID',
-                 PRIMARY KEY (`id`) USING BTREE
-                 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin COMMENT='文件档案表';
-                 */
+                boolean isTlsStudentsInsert = insertEasArcTlsStudents(easArcTlsStudents);
+                if (!isTlsStudentsInsert) {
+                    throw new EasException("EasArcTlsStudents保存失败", 8000);
+                }
+                boolean isSysStudentsInsert = insertEasSysStudents(easArcTlsStudents);
+                if (!isSysStudentsInsert) {
+                    throw new EasException("EasSysStudents保存失败", 8001);
+                }
+                //这里会生成一个学生档案保存本地 目前这里有bug保存不成功 而且文件后缀有错误
+                boolean isEasArcArchives = insertEasArcArchives(easArcTlsStudents, studentNumber, manager_id);
+                if (!isEasArcArchives) {
+                    throw new EasException("EasArcArchives保存失败", 8002);
+                }
+            }
+        } catch (IOException e) {
+            return false;
+        }
+        return true;
+    }
+
+
+    private Map<String, Object> generateDataMap(EasArcTlsStudents easArcTlsStudents, String studentNumber) {
+        Map<String, Object> map = new HashMap<>();
+        map.put("student_name", easArcTlsStudents.getStudentName());
+        map.put("gender", convertToGender(easArcTlsStudents.getGender()));
+        map.put("major", easArcTlsStudents.getMajor());
+        map.put("grade", easArcTlsStudents.getGrade());
+        map.put("enrollment_date", DateUtils.convertToYearMonthDay(easArcTlsStudents.getEnrollmentDate()));
+        map.put("phone", easArcTlsStudents.getPhone());
+        map.put("university", easArcTlsStudents.getUniversity());
+        map.put("student_idnumber", easArcTlsStudents.getStudentIdnumber());
+        map.put("avatar", getClass().getClassLoader().getResourceAsStream(PHOTO_PATH));
+        map.put("student_number", studentNumber);
+        return map;
+    }
+
+    public boolean insertEasArcArchives(EasArcTlsStudents easArcTlsStudents, String studentNumber, Integer managerId) {
+        try (InputStream wordStream = getClass().getClassLoader().getResourceAsStream(TEMPLATE_PATH)) {
+            assert wordStream != null;
+            try (XWPFDocument doc = new XWPFDocument(wordStream)) {
+                // 生成档案号
                 String archiveCode = StudentArchiveGenerator.generateArchiveCode(studentNumber, String.valueOf(FileType.DOCX));
+
+                // 保存学员档案文件
                 ArchivesDto archivesDto = easArchivesFilesService.saveArchiveStudentsFile(easArcTlsStudents.getStudentIdnumber(), doc);
                 String filePath = archivesDto.getPath();
-                String arctype = archivesDto.getFileType();
-                Date creat_time = DateUtils.convertToYearMonthDayToDate(new Date());
-                Date modify_time = new Date();
+                String arcType = archivesDto.getFileType();
 
-                //validity_time 暂且设置成create_date + 1年
+                // 设置时间和有效期
+                Date createTime = DateUtils.convertToYearMonthDayToDate(new Date());
+                Date modifyTime = new Date();
                 Calendar calendar = Calendar.getInstance();
-                calendar.setTime(creat_time);
+                assert createTime != null;
+                calendar.setTime(createTime);
                 calendar.add(Calendar.YEAR, 1);
-                Date create_date = calendar.getTime();
-
-                int create_uid = 0;
+                Date validityTime = calendar.getTime();
 
+                // 创建 EasArcArchives 对象并设置属性
                 EasArcArchives easArcArchives = new EasArcArchives();
                 easArcArchives.setArchiveNumber(archiveCode);
                 easArcArchives.setStudentNumber(studentNumber);
                 easArcArchives.setFilePath(filePath);
-                easArcArchives.setArctype(arctype);
-                easArcArchives.setCreateTime(creat_time);
-                easArcArchives.setModifyTime(modify_time);
-                easArcArchives.setValidityTime(create_date);
-                easArcArchives.setManagerId(manager_id);
-                easArcArchives.setCreateUid(create_uid);
+                easArcArchives.setArctype(arcType);
+                easArcArchives.setCreateTime(createTime);
+                easArcArchives.setModifyTime(modifyTime);
+                easArcArchives.setValidityTime(validityTime);
+                easArcArchives.setManagerId(managerId);
+                easArcArchives.setCreateUid(1);
                 easArcArchives.setCreateDate(new Date());
 
-                easArcArchivesMapper.insert(easArcArchives);
-
-
+                // 插入到数据库
+                int result = easArcArchivesMapper.insert(easArcArchives);
 
+                // 返回是否成功插入数据库
+                return result > 0;
             }
         } catch (IOException e) {
-            LOGGER.error("学员档案导出失败:{}", e.getMessage(), e);
-            return JsonResult.fail("学员档案导出失败!");
+            return false;
         }
+    }
+
+
+    private boolean insertEasSysStudents(EasArcTlsStudents easArcTlsStudents) {
+        EasSysStudent easSysStudents = new EasSysStudent();
+        BeanUtils.copyProperties(easArcTlsStudents, easSysStudents);
+        //设置初始密码 使用 passwordEncoder 设置初始密码为123456
+        easSysStudents.setPasswd(passwordEncoder.encode("123456"));
+        easSysStudents.setDisabled("N");
+        easSysStudents.setAvatar("占位图片.jpg");
+        return easSysStudentMapper.insert(easSysStudents) == 1;
+    }
 
-        LOGGER.info("学员档案导出成功!");
-        return JsonResult.ok("学员档案导出成功!");
+    private boolean insertEasArcTlsStudents(EasArcTlsStudents easArcTlsStudents) {
+        //判断是否插入成功 成功的话返回true 不成功的话返回false
+        return easArcTlsStudentsMapper.insert(easArcTlsStudents) == 1;
     }
 
     private String generateStudentNumber(EasArcTlsStudents easArcTlsStudents) {
@@ -159,18 +160,12 @@ public class EasStuProfileServiceImpl implements EasStuProfileService {
         calendar.setTime(easArcTlsStudents.getEnrollmentDate());
         String year = String.valueOf(calendar.get(Calendar.YEAR));
 
-        return StudentArchiveGenerator.generateStudentCode(
-                "", easArcTlsStudents.getStudentIdnumber(), easArcTlsStudents.getUniversity(), year);
+        return StudentArchiveGenerator.generateStudentCode("",
+                easArcTlsStudents.getStudentIdnumber(), easArcTlsStudents.getUniversity(), year);
     }
 
     private String convertToGender(String gender) {
-        if (gender.equals("M")) {
-            return "男";
-        } else if (gender.equals("F")) {
-            return "女";
-        } else {
-            return "未知";
-        }
+        return Gender.getkeyByString(gender);
     }
 
     private void replacePlaceholders(XWPFDocument document, Map<String, Object> map) {
@@ -194,7 +189,8 @@ public class EasStuProfileServiceImpl implements EasStuProfileService {
                                     cell.setText(cellText.replace(placeholder, value.toString()));
                                 }
                             } catch (IOException | InvalidFormatException e) {
-                                throw new RuntimeException(e);
+                                throw new EasException("学员导入失败");
+
                             }
                         }
                     });
@@ -202,6 +198,4 @@ public class EasStuProfileServiceImpl implements EasStuProfileService {
             }
         }
     }
-}
-
-
+}

+ 0 - 28
upload/pom.xml

@@ -1,28 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
-
-    <modelVersion>4.0.0</modelVersion>
-    <artifactId>upload</artifactId>
-    <name>upload</name>
-    <description>upload</description>
-
-    <parent>
-        <artifactId>eas-system</artifactId>
-        <groupId>com.koobietech.eas</groupId>
-        <version>0.0.1-SNAPSHOT</version>
-    </parent>
-    <repositories>
-        <repository>
-            <id>aliyun</id>
-            <name>aliyun</name>
-            <url>https://maven.aliyun.com/repository/public</url>
-            <releases>
-                <enabled>true</enabled>
-            </releases>
-            <snapshots>
-                <enabled>false</enabled>
-            </snapshots>
-        </repository>
-    </repositories>
-</project>

+ 0 - 11
upload/src/main/java/com/koobietech/eas/upload/UploadService.java

@@ -1,11 +0,0 @@
-package com.koobietech.eas.upload;
-
-public class UploadService {
-    public boolean uploadFile(){
-        return false;
-    }
-
-    public boolean moveFile(){
-        return false;
-    }
-}