利用springboot怎么搭建一个访客管理系统?很多新手对此不是很清楚,为了帮助大家解决这个难题,下面小编将为大家详细讲解,有这方面需求的人可以来学习下,希望你能有所收获。
jdk 8
intellij idea
tomcat 8.5.40
mysql 5.7
springboot
mybatis
layUi
JSP
http://localhost:8090
帐号:admin 密码:admin
登录
子账号管理
新增成员
预约列表
历史预约
出入影像记录
表格导出
访客预约申请
用户信息
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;
}
添加访客记录
@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.过期预约做定时清理
@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()));
}
}
}
}
预约地址需要有管理端分享地址给房主,由房主分享给到访的做预约登记
后期增加房主端,新增房主查看记录
看完上述内容是否对您有帮助呢?如果还想对相关知识有进一步的了解或阅读更多相关文章,请关注亿速云行业资讯频道,感谢您对亿速云的支持。
亿速云「云服务器」,即开即用、新一代英特尔至强铂金CPU、三副本存储NVMe SSD云盘,价格低至29元/月。点击查看>>
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。