项目获取请看文章最底下官网
教室设备管理系统是基于java编程语言和mysql数据库,ssh框架,bs的架构开发,系统主要分为学生,教师,管理员三个角色,其中学生可以登录系统,查看个人信息,在线借用教室设备;教师可以预约教师和借用教室设备;管理员可以对用户,教室,设备,通知信息进行管理,查看用户的预约信息。本设计适合作为java毕业设计和java课程设计来参考和学习。
JDK版本:1.8
IDE工具:eclipse
数据库: mysql 5.6
编程语言: Java
tomcat: 8.0
框架:ssh
详细技术:HTML+CSS+JS+JSP+JAVA+SSH+MYSQL
package ller;/*** 用户新增*/import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.ModelDriven;
import del.*;
import com.lmu.service.*;
import com.lmu.utils.*;import org.apache.poi.hssf.usermodel.HSSFRichTextString;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.hwpf.HWPFDocument;
import org.apache.poi.hwpf.usermodel.*;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.struts2.ServletActionContext;
import org.springframework.beans.factory.annotation.Autowired;
import t.annotation.Scope;
import org.springframework.stereotype.Controller;import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.*;
import java.math.BigDecimal;
import java.URLEncoder;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;@Controller("equipmentController")
@Scope("prototype")/*** 继承ActionSupport类方便实现验证和开发,继承ActionSupport的情况下,必须有无参构造函数* 实现modelDriven是把实体类当成页面数据的收集对象*/
public class EquipmentController extends ActionSupport implements ModelDriven<Equipment> {@Autowiredprivate LaboratoryService laboratoryService;@Autowiredprivate EquipmentService equipmentService;@Autowiredprivate EquipmentLogService equipmentLogService;@Autowiredprivate RepairLogService repairLogService;private Equipment equipment;private Map<String, Object> map = new HashMap();private File file;private String fileFileName;private String fileContentType;private String downloadFileName;private Integer exportId;/*** list** @return*/public String list() {User user1 = User();if (user1 == null || Id() == null) {Context().put("login", 1);return SUCCESS;}Pager<Equipment> pagers = null;Role role = Role();if (EnName().equals("admin")) {pagers = List(equipment);Context().put("pagers", pagers);Context().put("user", user1);Pager<Laboratory> pagers2 = List(null);Context().put("pagers2", pagers2);Context().put("bean", equipment);}return SUCCESS;}/*** list** @return*/public String dataList() {User user1 = User();if (user1 == null || Id() == null) {Context().put("login", 1);return SUCCESS;}Pager<Equipment> pagers = null;Role role = Role();if (EnName().equals("admin")) {pagers = List(equipment);Context().put("pagers", pagers);Context().put("user", user1);Pager<Laboratory> pagers2 = List(null);Context().put("pagers2", pagers2);Context().put("bean", equipment);}return SUCCESS;}/*** list** @return*/public String dataList2() {User user1 = User();if (user1 == null || Id() == null) {Context().put("login", 1);return SUCCESS;}Pager<Equipment> pagers = null;Role role = Role();if (EnName().equals("admin")) {pagers = List(equipment);Context().put("pagers", pagers);Context().put("user", user1);Pager<Laboratory> pagers2 = List(null);Context().put("pagers2", pagers2);Context().put("bean", equipment);}return SUCCESS;}/*** 跳转add** @return*/public String add() {User user1 = User();Context().put("bean", user1);return SUCCESS;}/*** 查询修改** @return*/public String edit() {Equipment bean = equipmentService.Id());Pager<Laboratory> pagers2 = List(null);Context().put("pagers2", pagers2);Context().put("bean", bean);return SUCCESS;}/*** 使用** @return*/public void updateSh() throws IOException {equipment.setFwTime(new Date());equipment.setIsFw(1);equipmentService.updates(equipment);map.put("flag", true);map.put("url", "equipment_dataList.do");Json(map);}/*** 借用list** @return*/public String dataList3() {User user1 = User();if (user1 == null || Id() == null) {Context().put("login", 1);return SUCCESS;}Pager<Equipment> pagers = null;pagers = List(equipment);Context().put("pagers", pagers);Context().put("user", user1);Pager<Laboratory> pagers2 = List(null);Context().put("pagers2", pagers2);Context().put("bean", equipment);return SUCCESS;}/*** 借用** @return*/public void yy() throws IOException {Equipment equipment1 = equipmentService.Id());if (IsJy() == 0) {equipment.setIsJy(1);equipment.User());EquipmentLog log = new EquipmentLog();log.User());log.setTime(new Date());log.setEquipment(equipment);log.setIsYy(1);equipmentLogService.save(log);equipment.Id());equipmentService.updates(equipment);map.put("flag", true);map.put("url", "equipment_dataList3.do");Json(map);} else {map.put("flag", false);map.put("url", "equipment_dataList3.do");Json(map);}}/*** 借用归还** @return*/public void qx() throws IOException {Equipment equipment1 = equipmentService.Id());EquipmentLog equipmentLog = equipmentLogService.JyId());if (User().getId() == User().getId()) {equipment1.setIsJy(0);equipmentService.update(equipment1);equipmentLog.setIsYy(0);equipmentLog.setEndTime(new Date());equipmentLog.User());equipmentLogService.updates(equipmentLog);map.put("flag", true);map.put("url", "equipment_dataList3.do");Json(map);} else {map.put("flag", false);map.put("url", "equipment_dataList3.do");Json(map);}}/*** 更新** @return*/public String updateDoc() throws IOException {if (file != null) {ActionContext ac = Context();HttpServletRequest request = (HttpServletRequest) ac.get(ServletActionContext.HTTP_REQUEST);String root = RealPath("/upload");InputStream is = new FileInputStream(file);String f = fileFileName;f = ate() + fileFileName;OutputStream os = new FileOutputStream(new File(root, f));byte[] buffer = new byte[500];int length = 0;while (-1 != (length = is.read(buffer, 0, buffer.length))) {os.write(buffer);}os.close();is.close();equipment.setHt("\upload\" + f);}equipmentService.updates(equipment);Context().put("url", "equipment_dataList.do");return "redirect";}/*** 更新** @return*/public void deleteDocAndPhoto() throws IOException {Equipment ee = equipmentService.Id());ee.setPhoto(null);ee.setHt(null);equipmentService.updates(equipment);map.put("flag", true);map.put("url", "equipment_dataList2.do");Json(map);}/*** 更新** @return*/public String updatePhoto() throws IOException {if (file != null) {ActionContext ac = Context();HttpServletRequest request = (HttpServletRequest) ac.get(ServletActionContext.HTTP_REQUEST);String root = RealPath("/upload");InputStream is = new FileInputStream(file);String f = fileFileName;f = ate() + fileFileName;OutputStream os = new FileOutputStream(new File(root, f));byte[] buffer = new byte[500];int length = 0;while (-1 != (length = is.read(buffer, 0, buffer.length))) {os.write(buffer);}os.close();is.close();equipment.setPhoto("\upload\" + f);}equipmentService.updates(equipment);Context().put("url", "equipment_dataList2.do");return "redirect";}/*** 更新** @return*/public void update() throws IOException {equipmentService.updates(equipment);map.put("flag", true);map.put("url", "equipment_dataList.do");Json(map);}public void download() throws IOException {Equipment equipment1 = equipmentService.Id());downloadFileName = Ht(), "utf-8");// 1、得到要下载文件的完整路径?String path = ServletContext().Ht());System.out.println("path :" + path);HttpServletResponse resp = Response();resp.setContentType("application/x-msdownload");// 指定响应动作是下载路径?resp.setHeader("Content-disposition", "attachment;filename=export.doc");//读取文件InputStream in = new FileInputStream(path);OutputStream out = OutputStream();//写文件?int b;while ((b = in.read()) != -1) {out.write(b);}in.close();out.close();map.put("flag", true);map.put("url", "equipment_dataList.do");Json(map);}/*** 保存** @return*/public String save() throws IOException {equipmentService.save(equipment);map.put("flag", true);map.put("url", "equipment_list.do");Json(map);return SUCCESS;}public void delete() throws IOException {equipment.setIsDelete(1);equipmentService.updates(equipment);map.put("flag", true);map.put("url", "equipment_list.do");Json(map);}public void export() throws IOException {List<Equipment> list = List(equipment).getDatas();// 生成WorkbookHSSFWorkbook wb = new HSSFWorkbook();// 追加SheetSheet sheet = wb.createSheet("Sheet");// 总列表?Integer CountColumnNum = 6;Cell[] firstCell = new Cell[CountColumnNum];String[] firstCellNames = new String[CountColumnNum];firstCellNames[0] = "设备型号";firstCellNames[1] = "设备价格";firstCellNames[2] = "设备制制造商";firstCellNames[3] = "设备序列号";firstCellNames[4] = "服务开始时时间";// 插入Row firstRow = ateRow(0);for (int j = 0; j < CountColumnNum; j++) {firstCell[j] = ateCell(j);firstCell[j].setCellValue(new HSSFRichTextString(firstCellNames[j]));}BigDecimal bd;for (int i = 0; i < list.size(); i++) {// 创建Row row = ateRow(i + 1);Cell id = ateCell(0);id.(i).getXh().toString());bd = new (i).getJg().toString());bd = bd.setScale(2, BigDecimal.ROUND_HALF_UP);Cell by = ateCell(1);by.String());Cell zzs = ateCell(2);zzs.(i).getZzs().toString());Cell xh = ateCell(3);xh.(i).getSbxlh().toString());Cell sj = ateCell(4);if ((i).getFwTime() != null && !(i).getFwTime().equals("")) {sj.(i).getFwTime().toString());}}// 创建文件输出流,准备输出电子表格HttpServletResponse response = Response();response.setContentType("application/vnd.ms-excel");//response.setContentType("application/vnd.ms-excel");response.setHeader("Content-disposition", "attachment;filename=export.xls");OutputStream out = OutputStream();wb.write(out);out.flush();out.close();}@Overridepublic Equipment getModel() {if (equipment == null) {equipment = new Equipment();}return equipment;}public File getFile() {return file;}public void setFile(File file) {this.file = file;}public String getFileFileName() {return fileFileName;}public void setFileFileName(String fileFileName) {this.fileFileName = fileFileName;}public String getFileContentType() {return fileContentType;}public void setFileContentType(String fileContentType) {this.fileContentType = fileContentType;}public String getDownloadFileName() {return downloadFileName;}public void setDownloadFileName(String downloadFileName) {this.downloadFileName = downloadFileName;}public Integer getExportId() {return exportId;}public void setExportId(Integer exportId) {portId = exportId;}
}
本文发布于:2024-02-08 20:04:17,感谢您对本站的认可!
本文链接:https://www.4u4v.net/it/170739410568670.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
留言与评论(共有 0 条评论) |