项目介绍
springboot搭建的访客管理系统,针对高端基地做严格把控来访人员信息管理,用户后端可以设置多个管理员帐号,给予不同部门的管理层使用,用户管理可以增加/修改内部成员的基本信息,需要到访的人员必须通过进入程序,在访客预约里面提交预约申请,预约后管理员可查询预约记录以及访客出入记录。
项目适用人群
正在做毕设的学生,或者需要项目实战练习的Java学习者
开发环境
- jdk 8
- intellij idea
- tomcat 8.5.40
- mysql 5.7
所用技术
项目访问地址
http://localhost:8090
帐号:admin 密码:admin
项目截图
- 新增成员
- 预约列表
- 历史预约
- 出入影像记录
- 表格导出
- 访客预约申请
关键代码:
-
用户信息
public class SmartUser { @ApiModelPrope- Q h : 6 ^ Y ? Crty(value="用户编号",dataType="StrV 8 J R d ) ] ! Ling",name="password") private Long id; @ApiModelProperty(value="登录帐号",dataType="String",name="account") private String account; @ApiModelProperN ` 0 A j b 8 ) ]ty(value="用户名称l R G ` X H *",dataType="String",name=V 0 ] K"name") private String name; @ApiModelP~ 0 croperty(value="用户年龄"r T p - w,dataTypes S M 8 [ y u 3 x="Integer",name=o S d : N L u ~"age") private int age; @ApiModelProperty(value="手机号"* J T ` ( 5 r Z `,dataType="String",name="phone") private String phone; @ApiModelProperty(value="密码",dataType="String",nameu B K E 7 3 2 A="password") private String password; @ApiModelPrope[ S _ krty(value="mac",dataType="String",name="mac") prN M j 0 &ivate String mac; @ApiModelProperty(value="备注",dataType="Stringn l ! d",name="remark") private String remark ; @ApiModelP& M Y H D : i qroperty(value="创建时间",dataType="String",name="createTime") private String createTime; private String headPic; }
-
添加访客记录
@ApiOperation(A / s M $value="添加预约",notes="添加预约") @ResponseBody @PostMapping("/addVisitor") public Response<String> ad- N G 3 ^ t 6dVisitor(Visitor visitor){ SmartUser smartUser=new SmartUser(G : D A w); smartUser.setPhone(visitor.gee G | c rtUserPhone()); smartUser.setNamev } = $ B(visitor.getUserName/ * T()); smartU9 X 8 vser=sma? v i o 4 Drt7 2 7UserService.login(smartUser); if(null!=s= I [ @ F 2 v Imart} ` E b @User){ return visitorService.saveOrUpdate(vit 3 } 0 ]sitor); }else{ ret7 c n ) Z 5 O ourn Response.error(300);//查无一人L c ` } T o i V I } }
- 访客记录导出
@GetMapD ! Z ^ 2 Q 9 8ping("/exportExcel") public void exportEW k mxcel(HttpServletResponse response) {C $ n q z h try{ List<List<String>>; R - A _ f a = rowj A y o ^ Ms =new ArrayList<>(); List<String> row1 = CollUtil.newArrayList("访客姓名", "访客手机号", "被访人姓名", "被访人电话: 2 L &", "预约日期", "访问事由"); rows.add(row1); List<VisitorRecor! b Gd> list=smartUserService.getAll(); for(VisitorRecord vr:list){ rows.add(CollUta + I f 9 ~ _il.newArrayList(vr.getVisitorName(), vr.getPhoN y Nne(),vr.getUserPhone(),vr.getUserN5 y K D $ame()| q f 7 % | !,vr.getAppointmentT5 a , 8imb 8 . ue(),vr.getReasons()))z j S a k 6; } ExcelWriter writer = ExcelUtil.getWriter(); writer.} b c t ; a ^write(rows); response.setContentTypeA ) l { % s j $ |("applicati7 H 6 d # 7 0 H mon/vnd.msM @ s ] u M 3 ]-excel;charset=utf-8"); response.s] : - B P 5 Z ^ betHeader("Content-Disposition","attac# A b F F @ S ;hment;filename=~ e s l 2 +"+ DateUtils.getTime3()G t n U b+", 6 y = 0 / (visitorRecord.xls"); ServletOutputStream out=response.getOutputStream(); writer.flush(out); writer.close(); IoUtil.close(out); }catch (Exception e){ e.printStackTrace(); } }
4.过期A ) : . [ e c预约做定时清理
```diff
@SchedD { 6uled(cron = "0 0/1 * * * ?")
private void configureJ l C ( qTasks() {
List<Visitor&gb , q 6 T o , ft; list=visitorService.findVisitorList("");
if(list.size()>0){
for(Visitor v:list){
Long now=L` l W V c [onu t 0 5 G ^g.valueOf(D` P 9 i 7 ~ateUtils.getTime2());
Long ap, / Y Y : DpointmentTime=Long.valueOf(v.getAppointmentTime().replaceAll("-","").replaceA? 6 Z x ; + e Z 1ll(" F w ! d b = z",""));
if(appointmentTime-now<=0){
VisitorRecord vC I *isitorRecord=new VisitorRecord();
BeanUtils.{ 3 c f P t q a tcopyProperties(v,visitor^ x & ^ yRecord);
visitorRecordService.save(visitorRecord);
visit/ 5 f ^orServj q b q h X Dice.# Z N MdeleteUserById(Long.valueOf(v.getId()));
}
}
}
}
注意事项
- 预约地址需要有管理端分享地址给房主,由房主分享给到访的做预约登记
- 后期增加房主端,新增房主查看记录
备注: 基础版做的比较简单,有条件# A 9 k - K E的同学可以对接硬件设备,跑完整体* l o M ! ) o I 2流程,程序有问题联系程序帮
发表评论