|
|
/**
|
|
|
* 员工培训系统主应用类
|
|
|
* 演示整个培训系统的功能
|
|
|
*/
|
|
|
package com.employeetraining;
|
|
|
|
|
|
import com.employeetraining.model.Employee;
|
|
|
import com.employeetraining.history.EmployeeHistory;
|
|
|
import com.employeetraining.course.Course;
|
|
|
import com.employeetraining.course.CourseManager;
|
|
|
import com.employeetraining.course.CourseManagerImpl;
|
|
|
import com.employeetraining.training.TrainingRecord;
|
|
|
import com.employeetraining.training.TrainingManager;
|
|
|
import com.employeetraining.training.TrainingManagerImpl;
|
|
|
import com.employeetraining.certificate.Certificate;
|
|
|
import com.employeetraining.certificate.CertificateManager;
|
|
|
import com.employeetraining.certificate.CertificateManagerImpl;
|
|
|
import com.employeetraining.util.IdGenerator;
|
|
|
|
|
|
import java.time.LocalDate;
|
|
|
import java.time.format.DateTimeFormatter;
|
|
|
import java.util.List;
|
|
|
|
|
|
public class EmployeeTrainingSystemApp {
|
|
|
|
|
|
private static final IdGenerator idGenerator = IdGenerator.getInstance();
|
|
|
private static final CourseManager courseManager = new CourseManagerImpl();
|
|
|
private static final TrainingManager trainingManager = new TrainingManagerImpl();
|
|
|
private static final CertificateManager certificateManager = new CertificateManagerImpl();
|
|
|
|
|
|
public static void main(String[] args) {
|
|
|
System.out.println("===== 员工培训系统演示 =====");
|
|
|
|
|
|
// 创建员工
|
|
|
Employee employee1 = new Employee(
|
|
|
"EMP001",
|
|
|
"张三",
|
|
|
"技术部",
|
|
|
"软件工程师",
|
|
|
12000.0,
|
|
|
"zhangsan@company.com"
|
|
|
);
|
|
|
|
|
|
// 记录员工历史变更
|
|
|
EmployeeHistory employeeHistory = new EmployeeHistory(employee1.getEmployeeId());
|
|
|
employeeHistory.recordPositionChange("助理工程师", employee1.getPosition());
|
|
|
employeeHistory.recordSalaryChange(8000.0, employee1.getSalary());
|
|
|
|
|
|
// 创建课程
|
|
|
createCourses();
|
|
|
|
|
|
// 显示所有课程
|
|
|
System.out.println("\n所有课程:");
|
|
|
List<Course> allCourses = courseManager.getAllCourses();
|
|
|
for (Course course : allCourses) {
|
|
|
System.out.println(course);
|
|
|
}
|
|
|
|
|
|
// 创建培训记录
|
|
|
createTrainingRecords(employee1.getEmployeeId());
|
|
|
|
|
|
// 显示员工的培训记录
|
|
|
System.out.println("\n张三的培训记录:");
|
|
|
List<TrainingRecord> employeeTrainings = trainingManager.findTrainingRecordsByEmployeeId(employee1.getEmployeeId());
|
|
|
for (TrainingRecord record : employeeTrainings) {
|
|
|
System.out.println(record);
|
|
|
}
|
|
|
|
|
|
// 颁发证书
|
|
|
issueCertificates(employee1.getEmployeeId());
|
|
|
|
|
|
// 显示员工的证书
|
|
|
System.out.println("\n张三的证书:");
|
|
|
List<Certificate> employeeCertificates = certificateManager.findCertificatesByEmployeeId(employee1.getEmployeeId());
|
|
|
for (Certificate cert : employeeCertificates) {
|
|
|
System.out.println(cert);
|
|
|
}
|
|
|
|
|
|
// 显示员工历史记录
|
|
|
System.out.println("\n张三的历史记录:");
|
|
|
List<EmployeeHistory.HistoryRecord> historyRecords = employeeHistory.getAllRecords();
|
|
|
for (EmployeeHistory.HistoryRecord record : historyRecords) {
|
|
|
System.out.println(record);
|
|
|
}
|
|
|
|
|
|
System.out.println("\n===== 演示完成 =====");
|
|
|
}
|
|
|
|
|
|
private static void createCourses() {
|
|
|
Course course1 = new Course(
|
|
|
"CSE001",
|
|
|
"Java编程基础",
|
|
|
"Java语言的基础知识和核心概念",
|
|
|
40,
|
|
|
"李老师",
|
|
|
"编程语言",
|
|
|
true
|
|
|
);
|
|
|
|
|
|
Course course2 = new Course(
|
|
|
"CSE002",
|
|
|
"Spring Boot框架",
|
|
|
"Spring Boot的核心特性和实践应用",
|
|
|
30,
|
|
|
"王老师",
|
|
|
"框架",
|
|
|
true
|
|
|
);
|
|
|
|
|
|
Course course3 = new Course(
|
|
|
"CSE003",
|
|
|
"项目管理基础",
|
|
|
"项目管理的基本理论和方法",
|
|
|
20,
|
|
|
"张老师",
|
|
|
"管理",
|
|
|
false
|
|
|
);
|
|
|
|
|
|
courseManager.addCourse(course1);
|
|
|
courseManager.addCourse(course2);
|
|
|
courseManager.addCourse(course3);
|
|
|
}
|
|
|
|
|
|
private static void createTrainingRecords(String employeeId) {
|
|
|
TrainingRecord record1 = new TrainingRecord(
|
|
|
idGenerator.generateTrainingRecordId(),
|
|
|
employeeId,
|
|
|
"CSE001",
|
|
|
LocalDate.now().minusDays(10),
|
|
|
95.0,
|
|
|
TrainingRecord.TrainingStatus.COMPLETED,
|
|
|
"学习认真,表现优异"
|
|
|
);
|
|
|
|
|
|
TrainingRecord record2 = new TrainingRecord(
|
|
|
idGenerator.generateTrainingRecordId(),
|
|
|
employeeId,
|
|
|
"CSE002",
|
|
|
LocalDate.now().minusDays(5),
|
|
|
92.0,
|
|
|
TrainingRecord.TrainingStatus.COMPLETED,
|
|
|
"理解透彻,能举一反三"
|
|
|
);
|
|
|
|
|
|
TrainingRecord record3 = new TrainingRecord(
|
|
|
idGenerator.generateTrainingRecordId(),
|
|
|
employeeId,
|
|
|
"CSE003",
|
|
|
null,
|
|
|
0.0,
|
|
|
TrainingRecord.TrainingStatus.IN_PROGRESS,
|
|
|
null
|
|
|
);
|
|
|
|
|
|
trainingManager.createTrainingRecord(record1);
|
|
|
trainingManager.createTrainingRecord(record2);
|
|
|
trainingManager.createTrainingRecord(record3);
|
|
|
}
|
|
|
|
|
|
private static void issueCertificates(String employeeId) {
|
|
|
Certificate cert1 = new Certificate(
|
|
|
idGenerator.generateCertificateId(),
|
|
|
employeeId,
|
|
|
"CSE001",
|
|
|
"Java编程基础认证",
|
|
|
LocalDate.now().minusDays(9),
|
|
|
LocalDate.now().plusYears(3),
|
|
|
"技术培训部",
|
|
|
Certificate.CertificateStatus.ACTIVE
|
|
|
);
|
|
|
|
|
|
Certificate cert2 = new Certificate(
|
|
|
idGenerator.generateCertificateId(),
|
|
|
employeeId,
|
|
|
"CSE002",
|
|
|
"Spring Boot框架认证",
|
|
|
LocalDate.now().minusDays(4),
|
|
|
LocalDate.now().plusYears(3),
|
|
|
"技术培训部",
|
|
|
Certificate.CertificateStatus.ACTIVE
|
|
|
);
|
|
|
|
|
|
certificateManager.issueCertificate(cert1);
|
|
|
certificateManager.issueCertificate(cert2);
|
|
|
}
|
|
|
} |