出勤表java代码 java打卡考勤系统
java考勤表,查询结果没有周末记录,没有请假记录,想补全结果和当月天数相同
在外层迭代日期,
创新互联是一家专业提供宜君企业网站建设,专注与做网站、成都网站建设、H5场景定制、小程序制作等业务。10年已为宜君众多企业、政府机构等服务。创新互联专业的建站公司优惠进行中。
在Action中声明一个冲御MapString,Object map
写好getter,setter
每条考勤记录都put进map中,把考勤记录的日期字符串yyyy-MM-dd作为key
将key和迭帆判烂代的当前日期比较,如果一致就输出内容。态漏
jsp页面如下代码:
有疑问再联系我!
java,添加一个类,显示考勤信息的。
public class Test06 {
static ListStudent_Status list_Student_Status = new ArrayListStudent_Status();
static ListStudent list_Student = new ArrayListStudent();
static ListStatus list_Studus = new ArrayListStatus();
static Scanner scanner = new Scanner(System.in);
public Test06() {
list_Studus.add(new Status("001", "病假"));
list_Studus.add(new Status("002", "产假"));
list_Studus.add(new Status("003", "事假"));
list_Studus.add(new Status("004", "婚假"));
list_Student.add(new Student("001", "张三"));
list_Student.add(new Student("002", "李四"));
list_Student.add(new Student("003", "王五"));
list_Student.add(new Student("004", "刘杰"));
list_Student.add(new Student("005", "陈朋"));
list_Student.add(new Student("006", "赵明明"));
list_Student.add(new Student("007", "罗四海"));
list_Student.add(new Student("008", "谢一刀"));
list_Student_Status.add(new Student_Status("001", list_Student.get(0),
list_Studus.get(0)));
list_Student_Status.add(new Student_Status("002", list_Student.get(1),
list_Studus.get(0)));
铅纤 list_Student_Status.add(new Student_Status("003", list_Student.get(2),
list_Studus.get(1)));
list_Student_Status.add(new Student_Status("004", list_Student.get(3),
陆雹 list_Studus.get(0)));
list_Student_Status.add(new Student_Status("005", list_Student.get(4),
list_Studus.get(2)));
list_Student_Status.add(new Student_Status("006", list_Student.get(5),
list_Studus.get(0)));
list_Student_Status.add(new Student_Status("007", list_Student.get(6),
list_Studus.get(3)));
list_Student_Status.add(new Student_Status("008", list_Student.get(7),
list_Studus.get(0)));
}
public static void main(String[] args) {
new Test06();
showHelp();
doMothed();
}
public static void doMothed() {
System.out.println("请选择你要操作的类型 1-按学号查询考勤 2-按考勤态早激帆度id杳学生");
System.out.println("请输入...");
int num = scanner.nextInt();
switch (num) {
case 1:
Find_1();
break;
case 2:
Find_2();
break;
default:
showHelp();
break;
}
doMothed();
}
public static void Find_2() {
System.out.println("请输考勤类型代号:");
String ids2 = scanner.next();
ListStudent list_temp = findStudentsByStatusID(ids2);
System.out.println("当前请 " + findByStatusID(ids2).status + " 的人员有:");
for (Student student : list_temp) {
System.out.println(student.getName());
}
}
public static void Find_1() {
System.out.println("请输入学生学号:");
String ids = scanner.next();
ListStudent_Status list_ss = GetByStudentID(ids);
System.out.println("当前学生为: " + FindByid(ids).getName());
for (Student_Status student_Status : list_ss) {
System.out.println("时间: " + student_Status.getDate() + " 姓名: "
+ student_Status.getStudent().getName() + " 事由: "
+ student_Status.getStatus().status);
}
}
public static void showHelp() {
System.out.println(" 学生信息列表");
System.out.println("********************************");
System.out.println("ID 姓名");
for (Student student : list_Student) {
System.out.println(student.getId() + " "
+ student.getName());
}
System.out.println("********************************");
System.out.println("考勤状态表");
System.out.println("********************************");
System.out.println("ID 状态");
for (Status status : list_Studus) {
System.out.println(status.id + " " + status.status);
}
System.out.println("********************************");
}
public static Status findByStatusID(String ids) {
for (Status status : list_Studus) {
if (status.id.equals(ids))
return status;
}
return null;
}
public static Student FindByid(String id) {
for (Student ss : list_Student) {
if (ss.getId().equals(id)) {
return ss;
}
}
return null;
}
// 添加考勤
public void Add_Student_Status(Student_Status ss) {
list_Student_Status.add(ss);
}
// 按考勤类型查人员
public static ListStudent findStudentsByStatusID(String id) {
ListStudent list = new ArrayListStudent();
for (Student_Status ss : list_Student_Status) {
if (ss.getStatus().id.equals(id)) {
list.add(ss.getStudent());
}
}
return list;
}
// 按学号查询考勤
public static ListStudent_Status GetByStudentID(String id) {
Student student = FindByid(id);
return student.getStudent_Status();
}
// 学生对象
class Student {
String id;
String name;
public Student(String id, String name) {
this.name = name;
this.id = id;
}
public String getId() {
return id;
}
public String getName() {
return name;
}
public ListStudent_Status getStudent_Status() {
ListStudent_Status list1 = new ArrayListStudent_Status();
for (Student_Status ss : list_Student_Status) {
if (ss.getStudent().getId().equals(getId())) {
list1.add(ss);
}
}
return list1;
}
}
// 考勤对象
class Status {
String id;
String status;
public Status(String id, String status) {
this.status = status;
this.id = id;
}
}
class Student_Status {
String id;
Date date;
Student student;
Status status;
public Student_Status(String id, Student student, Status status) {
this.id = id;
this.date = new Date();
this.student = student;
this.status = status;
}
public String getId() {
return id;
}
public Date getDate() {
return date;
}
public Student getStudent() {
return student;
}
public Status getStatus() {
return status;
}
}
}
java员工考勤表
简单,第一步:写一个员工类 第二步:写一个员工操作类 第三步:写一个测试主函数 第四步:写一个数据库操作类给你一个写过的代码,你自己参照着看看吧:在不行加我qq:1464388632 (给我分在加,否则不加)=================================测试类Application.java=================================import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.InputStreamReader;
import java.io.ObjectInputStream;public class Application { public static void main(String[] args) throws Exception{
EmpManage em=new EmpManage();
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
String EmpNo;
String name;
double salary;
while(true)
{
String optype;
System.out.println("请输入你选的操作");
System.out.println("1:创察咐建用胡顷户");
System.out.println("2:查找用户信息");
System.out.println("3:显示所裤没陆有用户信息");
System.out.println("4: 保存到文件");
optype=br.readLine();
if(optype.equals("1"))
{
System.out.println("请输入用户ID");
EmpNo=br.readLine();
System.out.println("请输入用户名");
name=br.readLine();
System.out.println("请输入用户工资");
salary=Double.parseDouble( br.readLine());
Employee ee=new Employee(EmpNo,name,salary);
em.addEmployee(ee);
}else if(optype.equals("2"))
{
System.out.println("请输入用户ID");
EmpNo=br.readLine();
em.findEmployee(EmpNo);
}else if(optype.equals("3"))
{
em.allDisplay();
}else if(optype.equals("4")){
em.saveFile();
}
} }}
=================================员工类。Employee.java=================================import java.io.*;
public class Employee implements Serializable{
private String EmpNo;
private String name;
private double salary;
public Employee(String EmpNo,String name,double salary)
{
this.EmpNo=EmpNo;
this.name=name;
this.salary=salary;
} public String getEmpNo() {
return EmpNo;
} public void setEmpNo(String empNo) {
EmpNo = empNo;
} public String getName() {
return name;
} public void setName(String name) {
this.name = name;
} public double getSalary() {
return salary;
} public void setSalary(double salary) {
this.salary = salary;
}
}
=================================员工操作类。EmpManage.java================================= import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.util.ArrayList;public class EmpManage {
ArrayList al=new ArrayList();
//创建添加一个新用户
Employee ee=null;
public EmpManage()
{
try {
FileInputStream fis=new FileInputStream("data.ser");
ObjectInputStream ois=new ObjectInputStream(fis);
ee= (Employee)ois.readObject();
while(ee!=null)
{
al.add(ee);
System.out.println(al.size());
ee= (Employee)ois.readObject();
System.out.println("此处安全");
}
System.out.println("此处安全");
ois.close();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public void addEmployee(Employee ee)
{
al.add(ee);
}
//通过员工号查找员工对应信息
public void findEmployee(String EmpNo)
{
for(int i=0;ial.size();i++)
{
if(((Employee)al.get(i)).getEmpNo().equals(EmpNo))
{
System.out.println("你所查找的用户已经查到 信息如下:");
System.out.println("姓名:"+((Employee)al.get(i)).getName());
System.out.println("工号:"+((Employee)al.get(i)).getEmpNo());
System.out.println("工资:"+((Employee)al.get(i)).getSalary());
}
}
}
public void saveFile() throws Exception
{
FileOutputStream fos=new FileOutputStream("data.ser");
ObjectOutputStream oos=new ObjectOutputStream(fos);
for(int i=0;ial.size();i++)
{
Employee ee=(Employee) al.get(i);
oos.writeObject(ee);
System.out.println("保存成功");
}
oos.close();
}
//显示所有用户信息
public void allDisplay()
{
for(int i=0;ial.size();i++)
{
Employee ee=(Employee) al.get(i);
System.out.println("====================");
System.out.println("工号:"+ee.getEmpNo());
System.out.println("名字:"+ee.getName());
System.out.println("工资:"+ee.getSalary());
System.out.println("====================");
}
}
}
分享题目:出勤表java代码 java打卡考勤系统
分享URL:http://myzitong.com/article/ddpdghc.html