毕业设计|SpringBoot+Vue的城市消防设备在线管理监控平台
本系统利用了SpringBoot和Vue实现了对城市消防监控设备的在线统计管理,系统具备区域管理、设备分类管理、设备管理、预警管理和报表统计五大功能,通过设备分类,将所有消防设备进行唯一编码,有效的满足了消防设备的在线统计查看,设备异常后报警更换,及对设备维修更换率生成报表在线查看。
作者简介:Java领域优质创作者、CSDN博客专家 、CSDN内容合伙人、掘金特邀作者、阿里云博客专家、51CTO特邀作者、多年架构师设计经验、腾讯课堂常驻讲师
主要内容:Java项目、Python项目、前端项目、人工智能与大数据、简历模板、学习资料、面试题库、技术互助
收藏点赞不迷路 关注作者有好处
文末获取源码
项目编号:
一,环境介绍
语言环境:Java: jdk1.8
数据库:Mysql: mysql5.7
应用服务器:Tomcat: tomcat8.5.31
开发工具:IDEA或eclipse
二,项目简介
本系统利用了SpringBoot和Vue实现了对城市消防监控设备的在线统计管理,系统具备区域管理、设备分类管理、设备管理、预警管理和报表统计五大功能,通过设备分类,将所有消防设备进行唯一编码,有效的满足了消防设备的在线统计查看,设备异常后报警更换,及对设备维修更换率生成报表在线查看。
三、技术选型
-
前后端分离,Vue实现前端模块化,后台通过 SpringBoot+Mysql,保证数据的有效性和安全性。
-
动态路由菜单栏、Element-UI、高德地图 Api 选择地理位置、Shiro权限控制、Mybatis plus。
-
满足消防设备异常及时同步处理、高并发,真正的满足城市甚至省级所用消防设备的在线管理。
四、功能列表
-
首页
-
系统管理
-
用户列表
-
角色管理
-
菜单管理 (按钮级别)
-
sql管理 (druid monitor )
-
定时任务
-
参数管理
-
文件上传
-
系统日志
-
-
地区管理
-
新增地区:vue-amap,实现模糊搜索定位选择地区,支持全国地区搜索
-
所有地区:分页,支持模糊搜索、按条件搜索,备注、禁用、恢复
-
导出:APache POI
-
-
分类管理 :el-tree,级联更新,管理设备分类
-
设备管理
-
新增设备:选择地区新增设备
-
设备列表:分页,支持模糊搜索、按条件搜索
-
-
统计管理 :
-
位置统计:按已有地区进行统计,各区系统拥有的地区数量(饼图)
-
设备统计:折线图,按小区进行分类统计,横坐标为时间,纵坐标为设备数量,可通过选择时间对数据进行筛选
-
五,系统展示
5.1 系统管理
5.2 地区管理
5.3 分类管理
5.4 设备管理
5.5 统计管理
六,核心代码展示
6.1 POI工具类
public class PoiUtils {
private static final int DEFAULT_COLUMN_SIZE = 17;
/**
* 断言Excel文件写入之前的条件
*
* @param directory 目录
* @param fileName 文件名
* @return file
* @throws IOException
*/
private static File assertFile(String directory, String fileName) throws IOException {
File tmpFile = new File(directory + File.separator + fileName + ".xls");
if (tmpFile.exists()) {
if (tmpFile.isDirectory()) {
throw new IOException("File '" + tmpFile + "' exists but is a directory");
}
if (!tmpFile.canWrite()) {
throw new IOException("File '" + tmpFile + "' cannot be written to");
}
} else {
File parent = tmpFile.getParentFile();
if (parent != null) {
if (!parent.mkdirs() && !parent.isDirectory()) {
throw new IOException("Directory '" + parent + "' could not be created");
}
}
}
return tmpFile;
}
/**
* 日期转化为字符串,格式为yyyy-MM-dd HH:mm:ss
*/
private static String getCnDate(Date date) {
String format = "yyyy-MM-dd HH:mm:ss";
SimpleDateFormat sdf = new SimpleDateFormat(format);
return sdf.format(date);
}
/**
* Excel 导出,POI实现
*
* @param fileName 文件名
* @param sheetName sheet页名称
* @param columnNames 表头列表名
* @param sheetTitle sheet页Title
* @param objects 目标数据集
*/
public static File writeExcel(String directory, String fileName, String sheetName, List<String> columnNames,
String sheetTitle, List<List<Object>> objects, boolean append) throws IOException {
File tmpFile = assertFile(directory, fileName);
return exportExcel(tmpFile, sheetName, columnNames, sheetTitle, objects, append);
}
/**
* Excel 导出,POI实现,先写入Excel标题,与writeExcelData配合使用
* 先使用writeExcelTitle再使用writeExcelData
*
* @param directory 目录
* @param fileName 文件名
* @param sheetName sheetName
* @param columnNames 列名集合
* @param sheetTitle 表格标题
* @param append 是否在现有的文件追加
* @return file
* @throws IOException
*/
public static File writeExcelTitle(String directory, String fileName, String sheetName, List<String> columnNames,
String sheetTitle, boolean append) throws IOException {
File tmpFile = assertFile(directory, fileName);
return exportExcelTitle(tmpFile, sheetName, columnNames, sheetTitle, append);
}
/**
* Excel 导出,POI实现,写入Excel数据行列,与writeExcelTitle配合使用
* 先使用writeExcelTitle再使用writeExcelData
*
* @param directory 目录
* @param fileName 文件名
* @param sheetName sheetName
* @param objects 数据信息
* @return file
* @throws IOException
*/
public static File writeExcelData(String directory, String fileName, String sheetName, List<List<Object>> objects)
throws IOException {
File tmpFile = assertFile(directory, fileName);
return exportExcelData(tmpFile, sheetName, objects);
}
/**
* 导出字符串数据
*
* @param file 文件名
* @param columnNames 表头
* @param sheetTitle sheet页Title
* @param append 是否追加写文件
* @return file
* @throws IOException
*/
private static File exportExcelTitle(File file, String sheetName, List<String> columnNames,
String sheetTitle, boolean append) throws IOException {
// 声明一个工作薄
Workbook workBook;
if (file.exists() && append) {
// 声明一个工作薄
workBook = new HSSFWorkbook(new FileInputStream(file));
} else {
workBook = new HSSFWorkbook();
}
Map<String, CellStyle> cellStyleMap = styleMap(workBook);
// 表头样式
CellStyle headStyle = cellStyleMap.get("head");
// 生成一个表格
Sheet sheet = workBook.getSheet(sheetName);
if (sheet == null) {
sheet = workBook.createSheet(sheetName);
}
//最新Excel列索引,从0开始
int lastRowIndex = sheet.getLastRowNum();
if (lastRowIndex > 0) {
lastRowIndex++;
}
// 设置表格默认列宽度
sheet.setDefaultColumnWidth(DEFAULT_COLUMN_SIZE);
// 合并单元格
sheet.addMergedRegion(new CellRangeAddress(lastRowIndex, lastRowIndex, 0, columnNames.size() - 1));
// 产生表格标题行
Row rowMerged = sheet.createRow(lastRowIndex);
lastRowIndex++;
Cell mergedCell = rowMerged.createCell(0);
mergedCell.setCellStyle(headStyle);
mergedCell.setCellValue(new HSSFRichTextString(sheetTitle));
// 产生表格表头列标题行
Row row = sheet.createRow(lastRowIndex);
for (int i = 0; i < columnNames.size(); i++) {
Cell cell = row.createCell(i);
cell.setCellStyle(headStyle);
RichTextString text = new HSSFRichTextString(columnNames.get(i));
cell.setCellValue(text);
}
try {
OutputStream ops = new FileOutputStream(file);
workBook.write(ops);
ops.flush();
ops.close();
} catch (IOException e) {
throw new IOException(e);
}
return file;
}
/**
* 导出字符串数据
*
* @param file 文件名
* @param objects 目标数据
* @return
* @throws IOException
*/
private static File exportExcelData(File file, String sheetName, List<List<Object>> objects) throws IOException {
// 声明一个工作薄
Workbook workBook;
if (file.exists()) {
// 声明一个工作薄
workBook = new HSSFWorkbook(new FileInputStream(file));
} else {
workBook = new HSSFWorkbook();
}
Map<String, CellStyle> cellStyleMap = styleMap(workBook);
// 正文样式
CellStyle contentStyle = cellStyleMap.get("content");
//正文整数样式
CellStyle contentIntegerStyle = cellStyleMap.get("integer");
//正文带小数整数样式
CellStyle contentDoubleStyle = cellStyleMap.get("double");
// 生成一个表格
Sheet sheet = workBook.getSheet(sheetName);
if (sheet == null) {
sheet = workBook.createSheet(sheetName);
}
//最新Excel列索引,从0开始
int lastRowIndex = sheet.getLastRowNum();
if (lastRowIndex > 0) {
lastRowIndex++;
}
// 设置表格默认列宽度
sheet.setDefaultColumnWidth(DEFAULT_COLUMN_SIZE);
// 遍历集合数据,产生数据行,前两行为标题行与表头行
for (List<Object> dataRow : objects) {
Row row = sheet.createRow(lastRowIndex);
lastRowIndex++;
for (int j = 0; j < dataRow.size(); j++) {
Cell contentCell = row.createCell(j);
Object dataObject = dataRow.get(j);
if (dataObject != null) {
if (dataObject instanceof Integer) {
contentCell.setCellStyle(contentIntegerStyle);
contentCell.setCellValue(Integer.parseInt(dataObject.toString()));
} else if (dataObject instanceof Double) {
contentCell.setCellStyle(contentDoubleStyle);
contentCell.setCellValue(Double.parseDouble(dataObject.toString()));
} else if (dataObject instanceof Long && dataObject.toString().length() == 13) {
contentCell.setCellStyle(contentStyle);
contentCell.setCellValue(getCnDate(new Date(Long.parseLong(dataObject.toString()))));
} else if (dataObject instanceof Date) {
contentCell.setCellStyle(contentStyle);
contentCell.setCellValue(getCnDate((Date) dataObject));
} else {
contentCell.setCellStyle(contentStyle);
contentCell.setCellValue(dataObject.toString());
}
} else {
contentCell.setCellStyle(contentStyle);
// 设置单元格内容为字符型
contentCell.setCellValue("");
}
}
}
try {
OutputStream ops = new FileOutputStream(file);
workBook.write(ops);
ops.flush();
ops.close();
} catch (IOException e) {
throw new IOException(e);
}
return file;
}
/**
* 导出字符串数据
*
* @param file 文件名
* @param columnNames 表头
* @param sheetTitle sheet页Title
* @param objects 目标数据
* @param append 是否追加写文件
* @return
* @throws IOException
*/
private static File exportExcel(File file, String sheetName, List<String> columnNames,
String sheetTitle, List<List<Object>> objects, boolean append) throws IOException {
// 声明一个工作薄
Workbook workBook;
if (file.exists() && append) {
// 声明一个工作薄
workBook = new HSSFWorkbook(new FileInputStream(file));
} else {
workBook = new HSSFWorkbook();
}
Map<String, CellStyle> cellStyleMap = styleMap(workBook);
// 表头样式
CellStyle headStyle = cellStyleMap.get("head");
// 正文样式
CellStyle contentStyle = cellStyleMap.get("content");
//正文整数样式
CellStyle contentIntegerStyle = cellStyleMap.get("integer");
//正文带小数整数样式
CellStyle contentDoubleStyle = cellStyleMap.get("double");
// 生成一个表格
Sheet sheet = workBook.getSheet(sheetName);
if (sheet == null) {
sheet = workBook.createSheet(sheetName);
}
//最新Excel列索引,从0开始
int lastRowIndex = sheet.getLastRowNum();
if (lastRowIndex > 0) {
lastRowIndex++;
}
// 设置表格默认列宽度
sheet.setDefaultColumnWidth(DEFAULT_COLUMN_SIZE);
// 合并单元格
sheet.addMergedRegion(new CellRangeAddress(lastRowIndex, lastRowIndex, 0, columnNames.size() - 1));
// 产生表格标题行
Row rowMerged = sheet.createRow(lastRowIndex);
lastRowIndex++;
Cell mergedCell = rowMerged.createCell(0);
mergedCell.setCellStyle(headStyle);
mergedCell.setCellValue(new HSSFRichTextString(sheetTitle));
// 产生表格表头列标题行
Row row = sheet.createRow(lastRowIndex);
lastRowIndex++;
for (int i = 0; i < columnNames.size(); i++) {
Cell cell = row.createCell(i);
cell.setCellStyle(headStyle);
RichTextString text = new HSSFRichTextString(columnNames.get(i));
cell.setCellValue(text);
}
// 遍历集合数据,产生数据行,前两行为标题行与表头行
for (List<Object> dataRow : objects) {
row = sheet.createRow(lastRowIndex);
lastRowIndex++;
for (int j = 0; j < dataRow.size(); j++) {
Cell contentCell = row.createCell(j);
Object dataObject = dataRow.get(j);
if (dataObject != null) {
if (dataObject instanceof Integer) {
contentCell.setCellType(HSSFCell.CELL_TYPE_NUMERIC);
contentCell.setCellStyle(contentIntegerStyle);
contentCell.setCellValue(Integer.parseInt(dataObject.toString()));
} else if (dataObject instanceof Double) {
contentCell.setCellType(HSSFCell.CELL_TYPE_NUMERIC);
contentCell.setCellStyle(contentDoubleStyle);
contentCell.setCellValue(Double.parseDouble(dataObject.toString()));
} else if (dataObject instanceof Long && dataObject.toString().length() == 13) {
contentCell.setCellType(HSSFCell.CELL_TYPE_STRING);
contentCell.setCellStyle(contentStyle);
contentCell.setCellValue(getCnDate(new Date(Long.parseLong(dataObject.toString()))));
} else if (dataObject instanceof Date) {
contentCell.setCellType(HSSFCell.CELL_TYPE_STRING);
contentCell.setCellStyle(contentStyle);
contentCell.setCellValue(getCnDate((Date) dataObject));
} else {
contentCell.setCellType(HSSFCell.CELL_TYPE_STRING);
contentCell.setCellStyle(contentStyle);
contentCell.setCellValue(dataObject.toString());
}
} else {
contentCell.setCellStyle(contentStyle);
// 设置单元格内容为字符型
contentCell.setCellValue("");
}
}
}
try {
OutputStream ops = new FileOutputStream(file);
workBook.write(ops);
ops.flush();
ops.close();
} catch (IOException e) {
throw new IOException(e);
}
return file;
}
/**
* 创建单元格表头样式
*
* @param workbook 工作薄
*/
private static CellStyle createCellHeadStyle(Workbook workbook) {
CellStyle style = workbook.createCellStyle();
// 设置边框样式
style.setBorderBottom(HSSFCellStyle.BORDER_THIN);
style.setBorderLeft(HSSFCellStyle.BORDER_THIN);
style.setBorderRight(HSSFCellStyle.BORDER_THIN);
style.setBorderTop(HSSFCellStyle.BORDER_THIN);
//设置对齐样式
style.setAlignment(HSSFCellStyle.ALIGN_CENTER);
// 生成字体
Font font = workbook.createFont();
// 表头样式
style.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND);
style.setFillForegroundColor(HSSFColor.SEA_GREEN.index);
font.setFontHeightInPoints((short) 12);
font.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
// 把字体应用到当前的样式
style.setFont(font);
return style;
}
/**
* 创建单元格正文样式
*
* @param workbook 工作薄
*/
private static CellStyle createCellContentStyle(Workbook workbook) {
CellStyle style = workbook.createCellStyle();
// 设置边框样式
style.setBorderBottom(HSSFCellStyle.BORDER_THIN);
style.setBorderLeft(HSSFCellStyle.BORDER_THIN);
style.setBorderRight(HSSFCellStyle.BORDER_THIN);
style.setBorderTop(HSSFCellStyle.BORDER_THIN);
//设置对齐样式
style.setAlignment(HSSFCellStyle.ALIGN_CENTER);
// 生成字体
Font font = workbook.createFont();
// 正文样式
style.setFillPattern(HSSFCellStyle.NO_FILL);
style.setVerticalAlignment(HSSFCellStyle.VERTICAL_CENTER);
font.setBoldweight(HSSFFont.BOLDWEIGHT_NORMAL);
// 把字体应用到当前的样式
style.setFont(font);
return style;
}
/**
* 单元格样式(Integer)列表
*/
private static CellStyle createCellContent4IntegerStyle(Workbook workbook) {
CellStyle style = workbook.createCellStyle();
// 设置边框样式
style.setBorderBottom(HSSFCellStyle.BORDER_THIN);
style.setBorderLeft(HSSFCellStyle.BORDER_THIN);
style.setBorderRight(HSSFCellStyle.BORDER_THIN);
style.setBorderTop(HSSFCellStyle.BORDER_THIN);
//设置对齐样式
style.setAlignment(HSSFCellStyle.ALIGN_CENTER);
// 生成字体
Font font = workbook.createFont();
// 正文样式
style.setFillPattern(HSSFCellStyle.NO_FILL);
style.setVerticalAlignment(HSSFCellStyle.VERTICAL_CENTER);
font.setBoldweight(HSSFFont.BOLDWEIGHT_NORMAL);
// 把字体应用到当前的样式
style.setFont(font);
style.setDataFormat(HSSFDataFormat.getBuiltinFormat("#,##0"));//数据格式只显示整数
return style;
}
/**
* 单元格样式(Double)列表
*/
private static CellStyle createCellContent4DoubleStyle(Workbook workbook) {
CellStyle style = workbook.createCellStyle();
// 设置边框样式
style.setBorderBottom(HSSFCellStyle.BORDER_THIN);
style.setBorderLeft(HSSFCellStyle.BORDER_THIN);
style.setBorderRight(HSSFCellStyle.BORDER_THIN);
style.setBorderTop(HSSFCellStyle.BORDER_THIN);
//设置对齐样式
style.setAlignment(HSSFCellStyle.ALIGN_CENTER);
// 生成字体
Font font = workbook.createFont();
// 正文样式
style.setFillPattern(HSSFCellStyle.NO_FILL);
style.setVerticalAlignment(HSSFCellStyle.VERTICAL_CENTER);
font.setBoldweight(HSSFFont.BOLDWEIGHT_NORMAL);
// 把字体应用到当前的样式
style.setFont(font);
style.setDataFormat(HSSFDataFormat.getBuiltinFormat("#,##0.00"));//保留两位小数点
return style;
}
/**
* 单元格样式列表
*/
private static Map<String, CellStyle> styleMap(Workbook workbook) {
Map<String, CellStyle> styleMap = new LinkedHashMap<>();
styleMap.put("head", createCellHeadStyle(workbook));
styleMap.put("content", createCellContentStyle(workbook));
styleMap.put("integer", createCellContent4IntegerStyle(workbook));
styleMap.put("double", createCellContent4DoubleStyle(workbook));
return styleMap;
}
}
6.2 权限相关
@Service
public class ShiroServiceImpl implements ShiroService {
@Autowired
private SysMenuDao sysMenuDao;
@Autowired
private SysUserDao sysUserDao;
@Autowired
private SysUserTokenDao sysUserTokenDao;
@Override
public Set<String> getUserPermissions(long userId) {
List<String> permsList;
//系统管理员,拥有最高权限
if(userId == Constant.SUPER_ADMIN){
List<SysMenuEntity> menuList = sysMenuDao.selectList(null);
permsList = new ArrayList<>(menuList.size());
for(SysMenuEntity menu : menuList){
permsList.add(menu.getPerms());
}
}else{
permsList = sysUserDao.queryAllPerms(userId);
}
//用户权限列表
Set<String> permsSet = new HashSet<>();
for(String perms : permsList){
if(StringUtils.isBlank(perms)){
continue;
}
permsSet.addAll(Arrays.asList(perms.trim().split(",")));
}
return permsSet;
}
@Override
public SysUserTokenEntity queryByToken(String token) {
return sysUserTokenDao.queryByToken(token);
}
@Override
public SysUserEntity queryUser(Long userId) {
return sysUserDao.selectById(userId);
}
}
七,相关作品展示
基于Java开发、Python开发、PHP开发、C#开发等相关语言开发的实战项目
基于Nodejs、Vue等前端技术开发的前端实战项目
基于微信小程序和安卓APP应用开发的相关作品
基于51单片机等嵌入式物联网开发应用
基于各类算法实现的AI智能应用
基于大数据实现的各类数据管理和推荐系统
更多推荐
所有评论(0)