使用java编写一个人事管理系统
时间: 2023-07-20 13:45:14 浏览: 111
java编写的人事管理系统
好的,人事管理系统一般包括员工信息管理、薪资管理、考勤管理、招聘管理等模块。以下是一个简单的Java实现:
1. 员工信息管理模块:
```
public class Employee {
private String name;
private int age;
private String department;
private String position;
private double salary;
//构造函数
public Employee(String name, int age, String department, String position, double salary) {
this.name = name;
this.age = age;
this.department = department;
this.position = position;
this.salary = salary;
}
//getter和setter方法
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getAge() {
return age;
}
public void setAge(int age) {
this.age = age;
}
public String getDepartment() {
return department;
}
public void setDepartment(String department) {
this.department = department;
}
public String getPosition() {
return position;
}
public void setPosition(String position) {
this.position = position;
}
public double getSalary() {
return salary;
}
public void setSalary(double salary) {
this.salary = salary;
}
}
```
2. 员工信息存储模块:
```
public class EmployeeDao {
private List<Employee> employees;
//构造函数
public EmployeeDao() {
this.employees = new ArrayList<>();
}
//添加员工
public void addEmployee(Employee employee) {
employees.add(employee);
}
//删除员工
public void deleteEmployee(Employee employee) {
employees.remove(employee);
}
//获取所有员工信息
public List<Employee> getAllEmployees() {
return employees;
}
//根据姓名查找员工信息
public List<Employee> getEmployeesByName(String name) {
List<Employee> result = new ArrayList<>();
for (Employee e : employees) {
if (e.getName().equals(name)) {
result.add(e);
}
}
return result;
}
//根据部门查找员工信息
public List<Employee> getEmployeesByDepartment(String department) {
List<Employee> result = new ArrayList<>();
for (Employee e : employees) {
if (e.getDepartment().equals(department)) {
result.add(e);
}
}
return result;
}
//根据职位查找员工信息
public List<Employee> getEmployeesByPosition(String position) {
List<Employee> result = new ArrayList<>();
for (Employee e : employees) {
if (e.getPosition().equals(position)) {
result.add(e);
}
}
return result;
}
}
```
3. 薪资管理模块:
```
public class Salary {
private Employee employee;
private double basicSalary;
private double bonus;
private double deduct;
private double totalSalary;
//构造函数
public Salary(Employee employee, double basicSalary, double bonus, double deduct) {
this.employee = employee;
this.basicSalary = basicSalary;
this.bonus = bonus;
this.deduct = deduct;
this.totalSalary = basicSalary + bonus - deduct;
}
//getter和setter方法
public Employee getEmployee() {
return employee;
}
public void setEmployee(Employee employee) {
this.employee = employee;
}
public double getBasicSalary() {
return basicSalary;
}
public void setBasicSalary(double basicSalary) {
this.basicSalary = basicSalary;
}
public double getBonus() {
return bonus;
}
public void setBonus(double bonus) {
this.bonus = bonus;
}
public double getDeduct() {
return deduct;
}
public void setDeduct(double deduct) {
this.deduct = deduct;
}
public double getTotalSalary() {
return totalSalary;
}
public void setTotalSalary(double totalSalary) {
this.totalSalary = totalSalary;
}
}
```
4. 薪资管理存储模块:
```
public class SalaryDao {
private List<Salary> salaries;
//构造函数
public SalaryDao() {
this.salaries = new ArrayList<>();
}
//添加薪资记录
public void addSalary(Salary salary) {
salaries.add(salary);
}
//删除薪资记录
public void deleteSalary(Salary salary) {
salaries.remove(salary);
}
//获取所有薪资记录
public List<Salary> getAllSalaries() {
return salaries;
}
//根据员工姓名查找薪资记录
public List<Salary> getSalariesByEmployeeName(String name) {
List<Salary> result = new ArrayList<>();
for (Salary s : salaries) {
if (s.getEmployee().getName().equals(name)) {
result.add(s);
}
}
return result;
}
}
```
5. 考勤管理模块:
```
public class Attendance {
private Employee employee;
private Date date;
private boolean isPresent;
//构造函数
public Attendance(Employee employee, Date date, boolean isPresent) {
this.employee = employee;
this.date = date;
this.isPresent = isPresent;
}
//getter和setter方法
public Employee getEmployee() {
return employee;
}
public void setEmployee(Employee employee) {
this.employee = employee;
}
public Date getDate() {
return date;
}
public void setDate(Date date) {
this.date = date;
}
public boolean isPresent() {
return isPresent;
}
public void setPresent(boolean isPresent) {
this.isPresent = isPresent;
}
}
```
6. 考勤管理存储模块:
```
public class AttendanceDao {
private List<Attendance> attendances;
//构造函数
public AttendanceDao() {
this.attendances = new ArrayList<>();
}
//添加考勤记录
public void addAttendance(Attendance attendance) {
attendances.add(attendance);
}
//删除考勤记录
public void deleteAttendance(Attendance attendance) {
attendances.remove(attendance);
}
//获取所有考勤记录
public List<Attendance> getAllAttendances() {
return attendances;
}
//根据员工姓名查找考勤记录
public List<Attendance> getAttendancesByEmployeeName(String name) {
List<Attendance> result = new ArrayList<>();
for (Attendance a : attendances) {
if (a.getEmployee().getName().equals(name)) {
result.add(a);
}
}
return result;
}
}
```
7. 招聘管理模块:
```
public class Recruitment {
private String position;
private int numberOfPositions;
private String requirement;
//构造函数
public Recruitment(String position, int numberOfPositions, String requirement) {
this.position = position;
this.numberOfPositions = numberOfPositions;
this.requirement = requirement;
}
//getter和setter方法
public String getPosition() {
return position;
}
public void setPosition(String position) {
this.position = position;
}
public int getNumberOfPositions() {
return numberOfPositions;
}
public void setNumberOfPositions(int numberOfPositions) {
this.numberOfPositions = numberOfPositions;
}
public String getRequirement() {
return requirement;
}
public void setRequirement(String requirement) {
this.requirement = requirement;
}
}
```
8. 招聘管理存储模块:
```
public class RecruitmentDao {
private List<Recruitment> recruitments;
//构造函数
public RecruitmentDao() {
this.recruitments = new ArrayList<>();
}
//添加招聘信息
public void addRecruitment(Recruitment recruitment) {
recruitments.add(recruitment);
}
//删除招聘信息
public void deleteRecruitment(Recruitment recruitment) {
recruitments.remove(recruitment);
}
//获取所有招聘信息
public List<Recruitment> getAllRecruitments() {
return recruitments;
}
//根据职位查找招聘信息
public List<Recruitment> getRecruitmentsByPosition(String position) {
List<Recruitment> result = new ArrayList<>();
for (Recruitment r : recruitments) {
if (r.getPosition().equals(position)) {
result.add(r);
}
}
return result;
}
}
```
以上就是一个简单的Java实现的人事管理系统,其中包括员工信息管理、薪资管理、考勤管理、招聘管理等模块。当然,这只是一个简单的实现,实际应用中还需要考虑更多的因素,例如安全性、性能等。
阅读全文