|
@@ -5,7 +5,11 @@ import com.koobietech.eas.common.constant.FileTypeExt;
|
|
import com.koobietech.eas.common.utils.FileManager;
|
|
import com.koobietech.eas.common.utils.FileManager;
|
|
import com.koobietech.eas.common.utils.StudentArchiveGenerator;
|
|
import com.koobietech.eas.common.utils.StudentArchiveGenerator;
|
|
import com.koobietech.eas.dao.dto.ArchivesDto;
|
|
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 com.koobietech.eas.service.EasArchivesFilesService;
|
|
|
|
+import com.koobietech.eas.service.EasStuProfileService;
|
|
import org.apache.poi.xwpf.usermodel.XWPFDocument;
|
|
import org.apache.poi.xwpf.usermodel.XWPFDocument;
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
@@ -13,6 +17,7 @@ import org.springframework.stereotype.Service;
|
|
import javax.annotation.Resource;
|
|
import javax.annotation.Resource;
|
|
import java.io.*;
|
|
import java.io.*;
|
|
import java.util.Date;
|
|
import java.util.Date;
|
|
|
|
+import java.util.List;
|
|
|
|
|
|
@Service
|
|
@Service
|
|
public class EasArchivesFilesServiceImpl implements EasArchivesFilesService {
|
|
public class EasArchivesFilesServiceImpl implements EasArchivesFilesService {
|
|
@@ -23,45 +28,37 @@ public class EasArchivesFilesServiceImpl implements EasArchivesFilesService {
|
|
@Resource
|
|
@Resource
|
|
FileManager fileManager;
|
|
FileManager fileManager;
|
|
|
|
|
|
- String separator = File.separator;
|
|
|
|
|
|
+ @Resource
|
|
|
|
+ EasArcTlsStudentsMapper arcTlsStudentsMapper;
|
|
|
|
|
|
- @Override
|
|
|
|
- public ArchivesDto getArchiveStudentsFile(String studentNumber) {
|
|
|
|
- return null;
|
|
|
|
- }
|
|
|
|
|
|
+ String separator = File.separator;
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public ArchivesDto saveArchiveAttendanceFile(String studentNumber, XWPFDocument document) {
|
|
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);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- private String getArchivePath(String studentNumber, String archiveCode) {
|
|
|
|
- return archivesSavePath + separator + studentNumber
|
|
|
|
- + separator + archiveCode + FileTypeExt.XLSX.getValue();
|
|
|
|
|
|
+ return saveArchiveDocumentFile(studentNumber, document, "XLSX");
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public ArchivesDto saveArchiveScoresFile(String studentNumber, XWPFDocument document) {
|
|
public ArchivesDto saveArchiveScoresFile(String studentNumber, XWPFDocument document) {
|
|
- return null;
|
|
|
|
|
|
+ return saveArchiveDocumentFile(studentNumber, document, "XLSX");
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public ArchivesDto saveArchiveStudentsFile(String studentNumber, XWPFDocument document) {
|
|
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);
|
|
|
|
|
|
+ return saveArchiveDocumentFile(studentNumber, document, "DOCX");
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public ArchivesDto saveArchiveFile(String studentNumber, InputStream stream, String type) {
|
|
public ArchivesDto saveArchiveFile(String studentNumber, InputStream stream, String type) {
|
|
- return null;
|
|
|
|
|
|
+ String archiveCode = getArchiveCode(studentNumber, FileType.valueOf(type).getValue() );
|
|
|
|
+ String path = getArchivePath(studentNumber, archiveCode, FileTypeExt.valueOf(type).getValue());
|
|
|
|
+ boolean status = fileManager.saveFile(stream, path);
|
|
|
|
+ return new ArchivesDto(path, status, archiveCode);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public boolean deleteArchiveFile(String filePath) {
|
|
|
|
+ return fileManager.deleteFile(filePath);
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
@@ -79,7 +76,27 @@ public class EasArchivesFilesServiceImpl implements EasArchivesFilesService {
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
- public boolean deleteArchiveFile(String filePath) {
|
|
|
|
- return fileManager.deleteFile(filePath);
|
|
|
|
|
|
+ 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);
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ private ArchivesDto saveArchiveDocumentFile(String studentNumber, XWPFDocument document, String type ) {
|
|
|
|
+ String archiveCode = StudentArchiveGenerator.generateArchiveCode(studentNumber, FileType.valueOf(type).getValue());
|
|
|
|
+ String path = getArchivePath(studentNumber, archiveCode, FileTypeExt.valueOf(type).getValue());
|
|
|
|
+ boolean status = fileManager.saveDocument(document, path);
|
|
|
|
+ return new ArchivesDto(path, status, archiveCode);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private String getArchiveCode(String studentNumber, String fileCode) {
|
|
|
|
+ return StudentArchiveGenerator.generateArchiveCode(studentNumber, fileCode);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private String getArchivePath(String studentNumber, String archiveCode, String suffix) {
|
|
|
|
+ return archivesSavePath + separator + studentNumber
|
|
|
|
+ + separator + archiveCode + suffix;
|
|
|
|
+ }
|
|
|
|
+
|
|
}
|
|
}
|