源码获取:博客首页 "资源" 里下载!
项目介绍
ssm实验室设备管理系统。前台jsp+layui+easyui等框架渲染数据、后台java语言搭配ssm(spring、springmvc、mybatis、maven) 数据库mysql5.7、8.0版本均可。该系统主要分三种角色:管理员、教师、学生。主要功能学校实验设备的借、还、修以及实验课程的发布等等;
管理员主要功能:
实验室管理:实验室基本信息管理;
系统管理:系统日志查看;
权限中心:用户组信息管理、用户组权限控制、菜单管理;
信息管理-管理员:教师信息管理、学生信息管理、用户账号管理、班级信息管理、专业信息管理、实验室类型管理、信息通告管理、实验设备管理、实验室使用审批、设备借用审批;
教师主要功能:
实验管理:实验课程管理;
信息管理-教师:个人信息维护、学生信息管理、借用设备管理、设备损坏登记、设备维修登记、信息通告浏览、借用实验室管理。
学生主要功能:
信息管理-学生:个人信息维护;
信息浏览:实验课程浏览、实验设备浏览、信息通告浏览;
环境需要
1.运行环境:最好是java jdk 1.8,我们在这个平台上运行的。其他版本理论上也可以。
2.IDE环境:IDEA,Eclipse,Myeclipse都可以。推荐IDEA;
3.tomcat环境:Tomcat 7.x,8.x,9.x版本均可
4.硬件环境:windows 7/8/10 1G内存以上;或者 Mac OS;
5.是否Maven项目: 是;查看源码目录中是否包含pom.xml;若包含,则为maven项目,否则为非maven项目
6.数据库:MySql 5.7/8.0 版本均可;
技术栈
1. 后端:Spring SpringMVC MyBatis
2. 前端:jsp+layui+easyui
使用说明
1. 使用IDEA/Eclipse/MyEclipse导入项目,Eclipse/MyEclipse导入时,若为maven项目请选择maven;
若为maven项目,导入成功后请执行maven clean;maven install命令,下载所需jar包;
2. 使用Navicat或者其它工具,在mysql中创建对应名称的数据库,并导入项目的sql文件;
3. 将项目中jdbc.properties配置文件中的数据库配置改为自己的配置
4. 配置tomcat,然后运行项目,输入localhost:8080/xxx 登录
设备管理控制层:
@Controller
@RequestMapping("/baseInfos")
public class BaseInfoController {
@Autowired
private BaseInfoService baseInfoService;
@Autowired
private LogService logService;
/**
* 获取所有设备类型信息
* @param map
* @return
*/
@RequestMapping("/type/list")
public String listDeviceType(ModelMap map){
List<DeviceType> typeList = baseInfoService.listDeviceType();
map.put("typeList",typeList);
return "deviceTypes::table-refresh";
}
/**
* 添加设备类型
* @param deviceType
* @return
*/
@PostMapping("/type")
@ResponseBody
public int addtDeviceType(DeviceType deviceType){
return baseInfoService.addtDeviceType(deviceType);
}
/**
* 删除设备类型
* @param typeId
* @return
*/
@DeleteMapping("/type/{typeId}")
@ResponseBody
public int delteDeviceTypByid(@PathVariable("typeId") String typeId){
return baseInfoService.deleteDeviceTypeById(typeId);
}
/**
* 修改设备类型
* @param deviceType
* @return
*/
@PutMapping("/type")
@ResponseBody
public int updateDeviceType(DeviceType deviceType){
return baseInfoService.updateDeviceType(deviceType);
}
/**
* 获取所有设备品牌信息
* @param map
* @return
*/
@RequestMapping("/brand/list")
public String listDeviceBrand(ModelMap map){
List<DeviceBrand> brandList = baseInfoService.listDeviceBrand();
map.put("brandList",brandList);
return "deviceBrands::table-refresh";
}
/**
* 添加设备品牌
* @param deviceBrand
* @return
*/
@PostMapping("/brand")
@ResponseBody
public int addtDeviceBrand(DeviceBrand deviceBrand){
return baseInfoService.addtDeviceBrand(deviceBrand);
}
/**
* 删除设备品牌
* @param brandId
* @return
*/
@DeleteMapping("/brand/{brandId}")
@ResponseBody
public int delteDeviceBrandByid(@PathVariable("brandId") String brandId){
return baseInfoService.deleteDeviceBrandById(brandId);
}
/**
* 修改品牌
* @param deviceBrand
* @return
*/
@PutMapping("/brand")
@ResponseBody
public int updateDeviceBrand(DeviceBrand deviceBrand){
return baseInfoService.updateDeviceBrand(deviceBrand);
}
/**
* 获取系统日志
* @param map
* @return
*/
@RequestMapping("/log")
public String listLog(ModelMap map, HttpServletRequest request){
String startTime = request.getParameter("startTime");
String endTime = request.getParameter("endTime");
List<SystemLog> logs = logService.listLogsByDate(startTime,endTime);
map.put("logList",logs);
return "system::logList-refresh";
}
}
设备维护管理控制层:
@Controller
@RequestMapping("/device")
public class DeviceController {
@Autowired
private DeviceService deviceService;
/**
* 获取所有设备信息
* @param map
* @return
*/
@GetMapping("/list/{pageName}")
public String listDevices(ModelMap map,@PathVariable("pageName") String pageName){
List<DeviceDTO> deviceDTOList = deviceService.listDeviceDto();
map.put("dtoList", deviceDTOList);
return pageName+"::table-refresh";
}
/**
* 按条件查询设备
* @param map
* @param pageName
* @return
*/
@PostMapping("/list")
public String listDeviceDTOByExample(ModelMap map,DeviceDTO example,String pageName,String userName){
List<DeviceDTO> deviceDTOList = deviceService.listDeviceDTOByexample(example);
if(!StringUtils.isEmpty(userName)){
deviceDTOList = deviceService.selectDeviceDTObyUserName(deviceDTOList,userName);
}
map.put("dtoList", deviceDTOList);
return pageName+"::table-refresh";
};
/**
* 根据id获取设备信息
* @param map
* @return
*/
@GetMapping("/{devId}")
public String getDeviceById(ModelMap map,@PathVariable("devId") String devId){
DeviceDTO dto = deviceService.getDeviceDtoById(devId);
map.put("detailDTO", dto);
return "deviceList::modal-refresh";
}
/**
* 新增设备
* @param request
* @return
* @throws ParseException
*/
@PostMapping
public String addDevice(HttpServletRequest request) throws ParseException {
Device device = new Device();
device.setDevId(request.getParameter("devId"));
device.setTypeId(request.getParameter("typeId"));
device.setBrandId(request.getParameter("brandId"));
device.setDevModel(request.getParameter("devModel"));
device.setErpCode(request.getParameter("erpCode"));
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
device.setPurchaseTime(sdf.parse(request.getParameter("purchaseTime")));
device.setLastUpate(new Date());
//新增设备基本信息时,触发器会自动新增设备使用信息和运行信息
deviceService.addDevice(device);
return "deviceManage";
}
/**
* 检查设备id是否重复
* @param devId
* @return
*/
@GetMapping("/checkDevId")
@ResponseBody
public int checkDevId(String devId){
DeviceDTO deviceDTO = deviceService.getDeviceDtoById(devId);
if (deviceDTO != null )
return 0;
else
return 1;
}
/**
* 修改设备基础信息
* @param request
* @return
* @throws ParseException
*/
@PutMapping("/baseInfo")
public String updateDevicveBaseInfo(HttpServletRequest request) throws ParseException {
Device device = new Device();
device.setDevId(request.getParameter("devId"));
device.setTypeId(request.getParameter("typeId"));
device.setBrandId(request.getParameter("brandId"));
device.setDevModel(request.getParameter("devModel"));
device.setErpCode(request.getParameter("erpCode"));
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
device.setPurchaseTime(sdf.parse(request.getParameter("purchaseTime")));
device.setLastUpate(new Date());
deviceService.updateDevice(device);
return "deviceManage";
}
/**
* 根据id删除设备
* @param devId
* @return
*/
@DeleteMapping
@ResponseBody
public int deleteDeviceById(@RequestBody String devId){
return deviceService.deleteDeviceById(devId);
}
/**
* 修改设备状态
* @param devId
* @param status
* @return
*/
@PutMapping("/status")
@ResponseBody
public int updateStatus(String devId,int status){
return deviceService.updateStatusByid(devId,status);
}
/**
* 分配设备持有者
* @return
*/
@PutMapping("/owner")
@ResponseBody
public int updateDevOwner(HttpServletRequest request){
String devId = request.getParameter("devId");
String[] groups = request.getParameter("groups").split(",");
return deviceService.updateDevOwnersByDevId(devId,groups);
};
/**
* 分配设备使用部门
* @param request
* @return
*/
@PutMapping("/org")
@ResponseBody
public int updateDevOrg(HttpServletRequest request){
String devId = request.getParameter("devId");
String fri_org = request.getParameter("fri_org");
String sec_org = request.getParameter("sec_org");
String orgid_addr = request.getParameter("orgid_addr");
return deviceService.updateDevOrgsByDevId(devId,fri_org,sec_org,orgid_addr);
};
/**
* 刷新使用信息模块
* @param map
* @param devId
* @return
*/
@GetMapping("/useage_info")
public String allotDevice(ModelMap map,String devId){
DeviceDTO deviceDTO = deviceService.getDeviceDtoById(devId);
map.put("deviceDTO",deviceDTO);
return "allotDevice::useage_info";
}
/**
* 导出报表
* @param response
* @param request
*/
@GetMapping("/exportExcel")
public void exportExcel(HttpServletRequest request,HttpServletResponse response){
String pageName = request.getParameter("pageName");
String[] headers = request.getParameter("headers").split(",");
deviceService.exportExcel(response,pageName,headers);
}
/**
* 下载模板
* @param request
* @param response
* @throws ServletException
* @throws IOException
*/
@GetMapping("/template")
public void downloadServlet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setCharacterEncoding("UTF-8");
//设置ContentType字段值
response.setContentType("text/html;charset=utf-8");
//获取所要下载的文件名称
String filename = request.getParameter("filename");
//下载文件所在目录
String folder = request.getServletContext().getRealPath("/WEB-INF/statics/file/");
//通知浏览器以下载的方式打开
response.addHeader("Content-type", "appllication/octet-stream");
response.addHeader("Content-Disposition", "attachment;filename="+filename);
//通知文件流读取文件
// InputStream in = request.getServletContext().getResourceAsStream(folder+filename);
InputStream in = new FileInputStream(folder+filename);
//获取response对象的输出流
OutputStream out = response.getOutputStream();
byte[] buffer = new byte[1024];
int len;
//循环取出流中的数据
while((len = in.read(buffer)) != -1){
out.write(buffer,0,len);
}
}
/**
* 获取图表统计数据
* @param request
* @return
* @throws ParseException
*/
@GetMapping("/statistics")
@ResponseBody
public Map<String, Object> reloadChart(HttpServletRequest request) throws ParseException {
String monthStr = request.getParameter("monthStr");
monthStr = subMonth(monthStr);
Map resultMap = new HashMap();
//设备类型统计
Map typeMap = deviceService.staDeviceByType(monthStr);
resultMap.put("typeMap",typeMap);
//设备品牌统计
Map brandMap = deviceService.staDeviceByBrand(monthStr);
resultMap.put("brandMap",brandMap);
//设备部门统计
Map orgMap = deviceService.staDeviceByOrg(monthStr);
resultMap.put("orgMap",orgMap);
//设备状态统计
Map statusMap = deviceService.staDeviceByStatus(monthStr);
resultMap.put("statusMap",statusMap);
return resultMap;
}
/**
* 传入具体日期 ,返回具体日期增加一个月。
* @param date 日期
* @return 2017-05-13
* @throws ParseException
*/
private String subMonth(String date) throws ParseException {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM");
Date dt = sdf.parse(date);
Calendar rightNow = Calendar.getInstance();
rightNow.setTime(dt);
rightNow.add(Calendar.MONTH, 1);
Date dt1 = rightNow.getTime();
String reStr = sdf.format(dt1);
return reStr;
}
@PostMapping("/file")
@ResponseBody
public Map uploadFile(HttpServletRequest request) throws Exception {
System.out.println("文件上传");
//文件上传的位置
String path = request.getSession().getServletContext().getRealPath("/upload");
File file = new File(path);
if(!file.exists()){
file.mkdirs();
}
//解析request对象,获取文件上传项
DiskFileItemFactory factory = new DiskFileItemFactory();
ServletFileUpload fileUpload = new ServletFileUpload(factory);
//解析
List<FileItem> list = fileUpload.parseRequest(request);
//遍历
for (FileItem item:list
) {
if(item.isFormField()){//普通表单项
} else{
String fileName = item.getName()+UUID.randomUUID();
//完成文件上传
item.write(new File(path,fileName));
//删除临时文件
item.delete();
return deviceService.fileRead(path+"/"+fileName);
}
}
return null;
}
}
用户管理控制层:
@Controller
@RequestMapping("/account")
public class AccountController {
//自动注入服务类
@Autowired
private AccountService accountService;
/**
* 管理员账户信息
* @return
*/
@GetMapping("/admins")
public String listAdmins(ModelMap map){
List<AccountDTO> adminList = accountService.listAccountByLevel(2);
List<AccountDTO> superAdminList = accountService.listAccountByLevel(1);
adminList.addAll(superAdminList);
map.put("adminsList", adminList);
return "system::table-refresh";
}
/**
* 获取所有账户信息
* @param map
* @return
*/
@GetMapping("/list")
public String listAccounts(ModelMap map){
List<AccountDTO> accountList = accountService.listAccount();
map.put("accountDTOList", accountList);
return "account::table-refresh";
}
/**
* 通过用户名称搜索用户
* @param map
* @param userName
* @return
*/
@GetMapping("/list/{userName}")
public String listAccountsByUserName(ModelMap map,@PathVariable("userName")String userName){
List<AccountDTO> accountList = accountService.listAccountByName(userName);
map.put("accountDTOList", accountList);
return "account::table-refresh";
}
/**
* 添加管理员页面
* @param map
* @return
*/
@GetMapping("/users")
public String listUsers(ModelMap map){
List<AccountDTO> accountList = accountService.listAccountByLevel(3);
map.put("usersDTOList", accountList);
return "system::list-refresh";
}
/**
* 获取设备使用人信息
* @param map
* @param devId
* @return
*/
@GetMapping("/ownerList")
public String getOwnerList(ModelMap map, String devId){
Map resMap = accountService.listOwenrByDevId(devId);
map.put("ownerMap", resMap);
return "allotDevice::list-refresh";
}
/**
* 添加账户
* @param account
* @return
*/
@PostMapping
@ResponseBody
public int addAccount(Account account){
return accountService.addAccount(account);
}
/**
* 根据uuid删除账户
* @param uuid
* @return
*/
@DeleteMapping("/{uuid}")
@ResponseBody
public int deleteAccount(@PathVariable("uuid")String uuid){
return accountService.deleteAccountById(uuid);
}
/**
* 修改账户密码
* @param uuid
* @param password
* @return
*/
@PutMapping("/password")
@ResponseBody
public int updatePassword(String uuid, String password){
return accountService.updatePasswordByid(uuid,password);
}
/**
* 修改账户状态
* @param uuid
* @param status
* @return
*/
@PutMapping("/status")
@ResponseBody
public int updateStatus(String uuid,int status){
return accountService.updateStatusByid(uuid,status);
}
/**
* 更改管理员
* @return
*/
@PutMapping("/admins")
@ResponseBody
public int updateDevOwner(HttpServletRequest request){
String[] groups = request.getParameter("groups").split(",");
int level = Integer.parseInt(request.getParameter("level"));
return accountService.updateAccountLevel(level,groups);
};
}
源码获取:博客首页 "资源" 里下载!