|
@@ -1,5 +1,6 @@
|
|
package com.koobietech.eas.common.utils;
|
|
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.constant.UniversityCodeUtils;
|
|
import com.koobietech.eas.common.pojo.ArchiveNumberInfo;
|
|
import com.koobietech.eas.common.pojo.ArchiveNumberInfo;
|
|
import com.koobietech.eas.common.pojo.StudentNumberInfo;
|
|
import com.koobietech.eas.common.pojo.StudentNumberInfo;
|
|
@@ -27,10 +28,10 @@ public class StudentArchiveGenerator {
|
|
* 生成文件档案编号
|
|
* 生成文件档案编号
|
|
* @param generateStudentCode
|
|
* @param generateStudentCode
|
|
* @param fileTypeCode
|
|
* @param fileTypeCode
|
|
- * @return
|
|
|
|
|
|
+ * @return SA911X3B98723081544551720
|
|
*/
|
|
*/
|
|
public static String generateArchiveCode(String generateStudentCode, String fileTypeCode) {
|
|
public static String generateArchiveCode(String generateStudentCode, String fileTypeCode) {
|
|
- String studentNum = generateStudentCode.substring(2, STUDENT_NUM_LENGTH + 2);
|
|
|
|
|
|
+ String studentNum = generateStudentCode.substring(2, STUDENT_NUM_LENGTH + 3);
|
|
String nowDate = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyMMddHhmmss", Locale.CHINA));
|
|
String nowDate = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyMMddHhmmss", Locale.CHINA));
|
|
String archiveCode = ARCHIVE_CODE_PREFIX + studentNum + nowDate + fileTypeCode;
|
|
String archiveCode = ARCHIVE_CODE_PREFIX + studentNum + nowDate + fileTypeCode;
|
|
if (archiveCode.length() < ARCHIVE_CODE_LENGTH) {
|
|
if (archiveCode.length() < ARCHIVE_CODE_LENGTH) {
|
|
@@ -48,13 +49,15 @@ public class StudentArchiveGenerator {
|
|
*/
|
|
*/
|
|
public static ArchiveNumberInfo parseArchiveNumber(String archiveNumber) {
|
|
public static ArchiveNumberInfo parseArchiveNumber(String archiveNumber) {
|
|
ArchiveNumberInfo archiveInfo = new ArchiveNumberInfo();
|
|
ArchiveNumberInfo archiveInfo = new ArchiveNumberInfo();
|
|
- String studentCode = archiveNumber.substring(2, STUDENT_NUM_LENGTH);
|
|
|
|
|
|
+ String studentCode = archiveNumber.substring(2, STUDENT_NUM_LENGTH + 3);
|
|
String studentId = studentCode.split("X")[0];
|
|
String studentId = studentCode.split("X")[0];
|
|
- String createTime = archiveNumber.substring(STUDENT_NUM_LENGTH + 2, 13);
|
|
|
|
|
|
+ String createTime = archiveNumber.substring(STUDENT_NUM_LENGTH + 3, STUDENT_NUM_LENGTH + 15);
|
|
String fileTypeCode = archiveNumber.substring(ARCHIVE_CODE_LENGTH - 2);
|
|
String fileTypeCode = archiveNumber.substring(ARCHIVE_CODE_LENGTH - 2);
|
|
archiveInfo.setStudentId(Integer.parseInt(studentId));
|
|
archiveInfo.setStudentId(Integer.parseInt(studentId));
|
|
|
|
+ archiveInfo.setStudentCode(studentCode);
|
|
archiveInfo.setCreateTime(Long.parseLong(createTime));
|
|
archiveInfo.setCreateTime(Long.parseLong(createTime));
|
|
archiveInfo.setFileTypeCode(Integer.parseInt(fileTypeCode));
|
|
archiveInfo.setFileTypeCode(Integer.parseInt(fileTypeCode));
|
|
|
|
+ archiveInfo.setFileSuffix(FileType.getSuffix(Integer.parseInt(fileTypeCode)));
|
|
return archiveInfo;
|
|
return archiveInfo;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -63,17 +66,17 @@ public class StudentArchiveGenerator {
|
|
/**
|
|
/**
|
|
* 生成学生档案编码
|
|
* 生成学生档案编码
|
|
* @param studentNumber
|
|
* @param studentNumber
|
|
- * @param studentId
|
|
|
|
|
|
+ * @param studentCardId
|
|
* @param schoolName
|
|
* @param schoolName
|
|
* @param enrollmentDate
|
|
* @param enrollmentDate
|
|
- * @return
|
|
|
|
|
|
+ * @return ST911X3B98736M20251021273
|
|
*/
|
|
*/
|
|
- public static String generateStudentCode(String studentNumber, String studentId, String schoolName, String enrollmentDate) {
|
|
|
|
|
|
+ public static String generateStudentCode(String studentNumber, String studentCardId, String schoolName, String enrollmentDate) {
|
|
LocalDate localDateEnrollmentDate = LocalDate.of(Integer.parseInt(enrollmentDate), 1, 1);
|
|
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 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 graduationDate = String.valueOf(getStudentGraduationDate(localDateEnrollmentDate).getYear());
|
|
|
|
|
|
String studentCode = STUDENT_CODE_PEREFIX + studentNum + studentAge +
|
|
String studentCode = STUDENT_CODE_PEREFIX + studentNum + studentAge +
|
|
@@ -97,12 +100,12 @@ public class StudentArchiveGenerator {
|
|
if (studentNumber == null) {
|
|
if (studentNumber == null) {
|
|
return null;
|
|
return null;
|
|
}
|
|
}
|
|
- String studentNum = studentNumber.substring(2, STUDENT_CODE_LENGTH);
|
|
|
|
|
|
+ String studentNum = studentNumber.substring(2, STUDENT_NUM_LENGTH + 3);
|
|
String studentId = studentNum.split("X")[0];
|
|
String studentId = studentNum.split("X")[0];
|
|
- String studentAge = studentNumber.substring(STUDENT_CODE_LENGTH + 2, 2);
|
|
|
|
- String studentGender = studentNumber.substring(STUDENT_CODE_LENGTH + 4, 1);
|
|
|
|
- String graduationDate = studentNumber.substring(STUDENT_CODE_LENGTH + 5, 4);
|
|
|
|
- String schoolCode = studentNumber.substring(STUDENT_CODE_LENGTH + 9);
|
|
|
|
|
|
+ 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();
|
|
StudentNumberInfo info = new StudentNumberInfo();
|
|
info.setStudentNum(studentNum);
|
|
info.setStudentNum(studentNum);
|
|
info.setStudentId(Long.valueOf(studentId));
|
|
info.setStudentId(Long.valueOf(studentId));
|
|
@@ -130,24 +133,24 @@ public class StudentArchiveGenerator {
|
|
|
|
|
|
/**
|
|
/**
|
|
* 获取学生年龄
|
|
* 获取学生年龄
|
|
- * @param studentId
|
|
|
|
|
|
+ * @param studentCardId
|
|
* @return
|
|
* @return
|
|
*/
|
|
*/
|
|
- private static int getStudentAge(String studentId) {
|
|
|
|
|
|
+ private static int getStudentAge(String studentCardId) {
|
|
LocalDate currentDate = LocalDate.now();
|
|
LocalDate currentDate = LocalDate.now();
|
|
- LocalDate birthDateirthDate = extractBirthDate(studentId);
|
|
|
|
|
|
+ LocalDate birthDateirthDate = extractBirthDate(studentCardId);
|
|
Period period = Period.between(birthDateirthDate, currentDate);
|
|
Period period = Period.between(birthDateirthDate, currentDate);
|
|
return period.getYears();
|
|
return period.getYears();
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
* 获取学生性别
|
|
* 获取学生性别
|
|
- * @param studentId
|
|
|
|
|
|
+ * @param studentCardId
|
|
* @return
|
|
* @return
|
|
*/
|
|
*/
|
|
- private static String getStudentGender(String studentId) {
|
|
|
|
|
|
+ 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";
|
|
return genderCode % 2 == 0 ? "F" : "M";
|
|
}
|
|
}
|
|
|
|
|