图书馆管理系统


项目要求

长期以来,人们使用传统的人工方式管理图书馆的日常业务,其操作流程比较烦琐。在借书时,读者首先将要借的书和借阅证交给工作人员,然后工作人员将每本书的信息卡片和读者的借阅证放在一个小格栏里,最后在借阅证和每本书贴的借阅条上填写借阅信息。在还书时,读者首先将要还的书交给工作人员,工作人员根据图书信息找到相应的书卡和借阅证,并填好相应的还书信息。太过于繁琐了!所以,我们需求设计一个图书管理系统来方便学生的借书和图书馆管理书籍。


一、项目结构

在这里插入图片描述

大概的运行界面:
在这里插入图片描述


二、项目内容

1.实体类

在这里插入图片描述
(省略各种构造方法)
书籍信息类:

public class Book implements Serializable {
    private String ISBN; //书号
    private String bookName;  // 书名
    private String author;  // 作者
    private String publish;   //出版社
    private String publishDate; //出版日期
    private int printTime; //库存
    private double unitPrice;  // 单价
    private BookType type; //图书类型
    private boolean state = true;
    private static final long serialVersionUID = 42L;

书籍类型类:

public class BookType implements Serializable {
    private String typeid;//图书类型编号
    private String typename;//图书类型名称
    private static final long serialVersionUID = 42L;

书籍借阅类:

public class BorrowBook {
    private String readerid;//借阅读者ID
    private String ISBN;//借阅书籍编号
    private String borrowdate;//借阅时间
    private String returndate;//归还时间
    private int fine;//逾期罚金

读者信息类:

public class Reader implements Serializable {
    private int readerId;//读者ID
    private String readerName;//读者姓名
    private String sex;//性别
    private int age;//年龄
    private String dept;//部门
    private String phone;//电话
    private String regDat;//注册时间
    private ReaderType type;//读者类型
    private static final long serialVersionUID = 42L;

读者类型:

public class ReaderType implements Serializable{
    private String typeid;//读者类型编号
    private String typename;//读者类型
    private int limit;//可借阅天数
    private int maxBorrowNum;//最大借书数量
    private static final long serialVersionUID = 42L;

管理员信息类:

public class Users {
    private String id;//id
    private String account;//账号
    private String password;//密码


2.功能设计

在这里插入图片描述

用户信息管理:

public class UsersDao {
 //查看单个账户
    public static void check() throws IOException{}

 //查看所有列表
    public static List<Users> selectUser() throws IOException {}

  //管理员注册添加
    public static boolean insertUser() throws IOException{}

//修改密码
    public static void updateUserPWD() throws IOException{}
    
  //删除指定用户
    public static void deleteUser() throws IOException{}
    
    }

读者类型:

public class ReaderTypeDao {
 //查看类别列表 
 public static List<ReaderType> allReaderType() throws IOException{}
 
  //添加类型
    public static boolean insertReaderType2() throws IOException{}

 //修改
    public static boolean updateReaderType(){}

 //删除类型
    public static boolean deleteReaderType(){}

  //通过类型编号查询
    public static void check() throws IOException {}

}

读者账户信息管理:

public class ReaderDao {
 //添加读者
    public static boolean insertReader() throws IOException{}
 //查看读者列表 
    public static void selectReader() throws IOException {}
    
  //通过ID查看读者
    public static void selectReaderById() throws IOException{}

   //通过读者姓名查看
    public static void selectReaderByName() throws IOException {}

 //通过类型编号查看
    public static void selectReaderByType() throws IOException{}

  //通过部门查看
    public static void selectReaderByDept() throws IOException{}

  //修改
    public static void updateReader() throws IOException{}
    
 //删除读者
public static void deleteReader() throws IOException{}
}

图书类别:

public class BookTypeDao {
 //查看类别列表 
    public static List<BookType> allBookType() throws IOException{}

 //添加类型
    public static boolean insertbookType() throws IOException{}

 //修改类型名称
    public static boolean updatebookType() throws IOException {}

 //删除类型
    public static void deletebookType() throws IOException {}

  //查看类别列表 
    public static void allbookType() throws IOException{}
}

书籍管理:

public class BookDao {
 //查看书籍列表
    public static boolean selectbook() throws IOException{}

//查看指定图书
    public static void selectBookByISBN() throws IOException{}
    
 public static void selectBookByName() throws IOException{}
 
 public static void selectBookByType() throws IOException{}

 public static void selectBookByAuthor() throws IOException{}

 public static void selectBookByPublish() throws IOException{}

   //添加书籍 
    public static boolean bookadd() throws IOException, ClassNotFoundException, ParseException{}

  //删除指定ISBN书籍 
    public static void bookdelete() throws IOException, ClassNotFoundException{}

  //修改
    public static void bookrevise() throws IOException {}

}

书籍借还:

public class BookBorrowDao {
//查询指定读者借阅信息
 public static void selectBorrowByReaderId() throws IOException{}
  //借书
    public static void borrowBook1() throws IOException{}

 //查询所有读者借阅信息
    public static void allBorrowBook() throws IOException{}

 // 图书归还,还书者的编号,图书编号,借阅日期
    public static void returnBook1() throws IOException, ParseException{}

}

罚金设置:

 public static void file() throws IOException, ParseException {
        File rtfile = new File(address1);
        Properties readerpop = new Properties();
        if (rtfile.exists() && rtfile.length() != 0) {
            FileReader fr = new FileReader(rtfile);
            readerpop.load(fr);
            fr.close();
        }
        List<BorrowBook> list = new ArrayList<>();
        try {
            BufferedReader br = new BufferedReader(new FileReader(address));
            String line;
            while ((line = br.readLine()) != null) {
                String[] strArray = line.split(",");
                BorrowBook borrowBook = new BorrowBook();
                borrowBook.setReaderid(strArray[0]);
                borrowBook.setISBN(strArray[1]);
                borrowBook.setBorrowdate(strArray[2]);
                borrowBook.setReturndate(strArray[3]);
                borrowBook.setFine(Integer.parseInt(strArray[4]));
                list.add(borrowBook);
            }
            br.close();
        } catch (FileNotFoundException e) {
            System.out.println("列表为空!!");
        } catch (IOException e) {
        }
        Set<String> rtset = readerpop.stringPropertyNames();
        for (String readerkey : rtset) {
            String[] split = readerpop.getProperty(readerkey).split(",");
            for (int i = 0; i < list.size(); i++) {
                try {
                    SimpleDateFormat sfd = new SimpleDateFormat("yyyy年MM月dd日");
                    if (!list.get(i).getReturndate().equals(null)) {
                        Date parse = sfd.parse(list.get(i).getReturndate());
                        Date parse1 = sfd.parse(list.get(i).getBorrowdate());
                        long intervals = ((parse.getTime() - parse1.getTime()) / (1000 * 60 * 60 * 24));
                        int time = (int) intervals;
                        if (list.get(i).getReaderid().equals(readerkey)) {
                            if (time <= Integer.parseInt(split[8])) {
                                list.get(i).setFine(0);
                            } else if (time > Integer.parseInt(split[8])) {
                                fine = (time - Integer.parseInt(split[8])) * 2;
                                System.out.println("¥罚金为:" + fine + "元");
                                list.get(i).setFine(fine);
                            }
                        }
                        BufferedWriter bw = new BufferedWriter(new FileWriter(address));
                        for (BorrowBook v : list) {
                            StringBuilder sb = new StringBuilder();
                            sb.append(v.getReaderid()).append(",").append(v.getISBN()).append(",").append(v.getBorrowdate()).append(",").append(v.getReturndate()).append(",").append(v.getFine());
                            bw.write(sb.toString());
                            bw.newLine();
                            bw.flush();
                        }
                        bw.close();
                    }

                } catch (ParseException e) {
                    list.get(i).setFine(0);
                }
            }
        }
    }

日志:

   public static void saveLog(String time, String ID, String name, String dowhat) throws IOException {
        File file = new File(filepath);
        if (!file.exists()) {
            file.createNewFile();
        }
        BufferedWriter bw = null;
        try {
            bw = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(file, true)));
            bw.write("时间:" + time + ",ID:  " + ID + ",用户名为:  " + name + ",进行了 " + dowhat + " 操作\n");
            bw.flush();
        } catch (FileNotFoundException e) {
            System.out.println("文件未找到");
        } catch (IOException e) {
            // 待办自动生成的捕获块
            e.printStackTrace();
        } finally {
            if (null != bw) {
                try {
                    bw.close();
                } catch (IOException e) {
                    System.out.println("流操作异常");
                }
            }
        }
    }

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值