wuheng 1 рік тому
батько
коміт
2f7fb19cb8

+ 1 - 1
controller/pom.xml

@@ -76,7 +76,7 @@
         <resources>
             <resource>
                 <directory>src/main/resources</directory>
-                <filtering>true</filtering>
+                <filtering>false</filtering>
                 <includes>
                     <include>**/*.png</include>
                     <include>**/*.jpeg</include>

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

@@ -58,7 +58,7 @@ public class EasArchivesFilesServiceImpl implements EasArchivesFilesService {
 
     @Override
     public ArchivesDto saveArchiveFile(String studentNumber, InputStream stream, String type) {
-        String archiveCode = getArchiveCode(studentNumber, FileType.valueOf(type).getSuffix());
+        String archiveCode = getArchiveCode(studentNumber, String.valueOf(FileType.valueOf(type).getValue()));
         String path = getArchivePath(studentNumber, archiveCode, FileType.valueOf(type).getSuffix());
         boolean status = fileManager.saveFile(stream, path);
         return new ArchivesDto(path, status, archiveCode, type);
@@ -115,14 +115,14 @@ public class EasArchivesFilesServiceImpl implements EasArchivesFilesService {
     }
 
     private ArchivesDto saveArchiveDocumentFile(String studentNumber, XWPFDocument document, String type) {
-        String archiveCode = ArchiveManager.generateArchiveCode(studentNumber, FileType.valueOf(type).getSuffix());
+        String archiveCode = ArchiveManager.generateArchiveCode(studentNumber, String.valueOf(FileType.valueOf(type).getValue()));
         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 = ArchiveManager.generateArchiveCode(studentNumber, FileType.valueOf(type).getSuffix());
+        String archiveCode = ArchiveManager.generateArchiveCode(studentNumber, String.valueOf(FileType.valueOf(type).getValue()));
         String path = getArchivePath(studentNumber, archiveCode, FileType.valueOf(type).getSuffix());
         boolean status = fileManager.saveWorkbook(workbook, path);
         return new ArchivesDto(path, status, archiveCode, type);

+ 14 - 8
service/src/main/java/com/koobietech/eas/service/impl/EasStuProfileServiceImpl.java

@@ -5,6 +5,7 @@ import cn.afterturn.easypoi.excel.entity.ImportParams;
 import com.github.pagehelper.PageHelper;
 import com.koobietech.eas.common.constant.FileType;
 import com.koobietech.eas.common.constant.Gender;
+import com.koobietech.eas.common.constant.UniversityCode;
 import com.koobietech.eas.common.exception.EasException;
 import com.koobietech.eas.common.utils.ArchiveManager;
 import com.koobietech.eas.common.utils.DateManager;
@@ -26,6 +27,8 @@ 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;
@@ -39,6 +42,8 @@ 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
@@ -84,7 +89,8 @@ public class EasStuProfileServiceImpl implements EasStuProfileService {
 
             }
         } catch (IOException e) {
-            return false;
+            logger.error(e.getMessage());
+            throw new EasException("生成档案失败", 8003);
         }
         return true;
     }
@@ -153,12 +159,14 @@ public class EasStuProfileServiceImpl implements EasStuProfileService {
             }
             return true;
         } catch (Exception ignored){
-            ignored.printStackTrace();
+            logger.error(ignored.getMessage());
         } finally {
             if (inputStream != null) {
                 try {
                     inputStream.close();
-                } catch (IOException ignored) {}
+                } catch (IOException ignored) {
+                    logger.error(ignored.getMessage());
+                }
             }
         }
         return false;
@@ -185,8 +193,6 @@ public class EasStuProfileServiceImpl implements EasStuProfileService {
 
         // 保存学员档案文件
         ArchivesDto archivesDto = easArchivesFilesService.saveArchiveStudentsFile(easArcTlsStudents.getStudentIdnumber(), doc);
-        String filePath = archivesDto.getPath();
-        String arcType = archivesDto.getFileType();
 
         // 设置时间和有效期
         Date createTime = DateManager.convertToYearMonthDayToDate(new Date());
@@ -201,8 +207,8 @@ public class EasStuProfileServiceImpl implements EasStuProfileService {
         EasArcArchives easArcArchives = new EasArcArchives();
         easArcArchives.setArchiveNumber(archiveCode);
         easArcArchives.setStudentNumber(easArcTlsStudents.getStudentNumber());
-        easArcArchives.setFilePath(filePath);
-        easArcArchives.setArctype(arcType);
+        easArcArchives.setFilePath(archivesDto.getPath());
+        easArcArchives.setArctype(archivesDto.getFileType());
         easArcArchives.setCreateTime(createTime);
         easArcArchives.setModifyTime(modifyTime);
         easArcArchives.setValidityTime(validityTime);
@@ -239,7 +245,7 @@ public class EasStuProfileServiceImpl implements EasStuProfileService {
         String year = String.valueOf(calendar.get(Calendar.YEAR));
 
         return ArchiveManager.generateStudentCode("",
-                easArcTlsStudents.getStudentIdnumber(), easArcTlsStudents.getUniversity(), year);
+                easArcTlsStudents.getStudentIdnumber(), String.valueOf(UniversityCode.getCode(easArcTlsStudents.getUniversity().trim())), year);
     }
 
     private String convertToGender(String gender) {