畢設、實戰練習——springboot 搭建訪客管理系統 項目介紹 項目適用人羣 開發環境 所用技術 項目訪問地址 項目截圖 關鍵代碼: 注意事項

項目介紹

springboot搭建的訪客管理系統,針對高端基地做嚴格把控來訪人員信息管理,用戶後端可以設置多個管理員帳號,給予不同部門的管理層使用,用戶管理可以增加/修改內部成員的基本信息,需要到訪的人員必須通過進入程序,在訪客預約裏面提交預約申請,預約後管理員可查詢預約記錄以及訪客出入記錄。

項目適用人羣

正在做畢設的學生,或者需要項目實戰練習的Java學習者

開發環境

  1. jdk 8
  2. intellij idea
  3. tomcat 8.5.40
  4. mysql 5.7

所用技術

  1. springboot
  2. mybatis
  3. layUi
  4. JSP

項目訪問地址

http://localhost:8090
帳號:admin 密碼:admin

項目截圖

  • 登錄
  • 子賬號管理
  • 新增成員
  • 預約列表
  • 歷史預約
  • 出入影像記錄
  • 表格導出
  • 訪客預約申請

關鍵代碼:

  1. 用戶信息
public class SmartUser {
    @ApiModelProperty(value="用戶編號",dataType="String",name="password")
    private Long id;
    @ApiModelProperty(value="登錄帳號",dataType="String",name="account")
    private String account;
    @ApiModelProperty(value="用戶名稱",dataType="String",name="name")
    private String name;
    @ApiModelProperty(value="用戶年齡",dataType="Integer",name="age")
    private int age;
    @ApiModelProperty(value="手機號",dataType="String",name="phone")
    private String phone;
    @ApiModelProperty(value="密碼",dataType="String",name="password")
    private String password;
    @ApiModelProperty(value="mac",dataType="String",name="mac")
    private String mac;
    @ApiModelProperty(value="備註",dataType="String",name="remark")
    private String remark ;
    @ApiModelProperty(value="創建時間",dataType="String",name="createTime")
    private String createTime;
    private String headPic;
}
  1. 添加訪客記錄
@ApiOperation(value="添加預約",notes="添加預約")
@ResponseBody
@PostMapping("/addVisitor")
public Response<String> addVisitor(Visitor visitor){
    SmartUser smartUser=new SmartUser();
    smartUser.setPhone(visitor.getUserPhone());
    smartUser.setName(visitor.getUserName());
    smartUser=smartUserService.login(smartUser);
    if(null!=smartUser){
        return visitorService.saveOrUpdate(visitor);
    }else{
        return Response.error(300);//查無一人
    }
}
  1. 訪客記錄導出
@GetMapping("/exportExcel")
public void exportExcel(HttpServletResponse response) {
    try{
        List<List<String>> rows =new ArrayList<>();
        List<String> row1 = CollUtil.newArrayList("訪客姓名", "訪客手機號", "被訪人姓名", "被訪人電話", "預約日期", "訪問事由");
        rows.add(row1);
        List<VisitorRecord>    list=smartUserService.getAll();
        for(VisitorRecord vr:list){
            rows.add(CollUtil.newArrayList(vr.getVisitorName(),  vr.getPhone(),vr.getUserPhone(),vr.getUserName(),vr.getAppointmentTime(),vr.getReasons()));
        }
        ExcelWriter writer = ExcelUtil.getWriter();
        writer.write(rows);
        response.setContentType("application/vnd.ms-excel;charset=utf-8");
        response.setHeader("Content-Disposition","attachment;filename="+ DateUtils.getTime3()+"visitorRecord.xls");
        ServletOutputStream out=response.getOutputStream();
        writer.flush(out);
        writer.close();
        IoUtil.close(out);
    }catch (Exception e){
        e.printStackTrace();
    }
}

4.過期預約做定時清理

@Scheduled(cron = "0 0/1 * * * ?")
private void configureTasks() {
    List<Visitor>  list=visitorService.findVisitorList("");
    if(list.size()>0){
        for(Visitor v:list){
            Long now=Long.valueOf(DateUtils.getTime2());
            Long appointmentTime=Long.valueOf(v.getAppointmentTime().replaceAll("-","").replaceAll(" ",""));
            if(appointmentTime-now<=0){
                VisitorRecord visitorRecord=new VisitorRecord();
                BeanUtils.copyProperties(v,visitorRecord);
                visitorRecordService.save(visitorRecord);
                visitorService.deleteUserById(Long.valueOf(v.getId()));
            }
        }
    }
}

注意事項

  1. 預約地址需要有管理端分享地址給房主,由房主分享給到訪的做預約登記
  2. 後期增加房主端,新增房主查看記錄

來源:https://www.tuicool.com/articles/viAN7fA

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章