springboot搭建的訪客管理系統,針對高端基地作嚴格把控來訪人員信息管理,用戶後端能夠設置多個管理員賬號,給予不一樣部門的管理層使用,用戶管理能夠增長/修改內部成員的基本信息,須要到訪的人員必須經過進入程序,在訪客預定裏面提交預定申請,預定後管理員可查詢預定記錄以及訪客出入記錄。mysql
正在作畢設的學生,或者須要項目實戰練習的Java學習者spring
http://localhost:8090 賬號:admin 密碼:admin
登陸sql
子帳號管理後端
用戶信息tomcat
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; }
添加訪客記錄springboot
@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);//查無一人 } }
@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.過時預定作定時清理 ```diff @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())); } } } }