——————————DescriptionStart——————————
运行环境
Java≥8、MySQL≥5.7、Tomcat≥8
开发工具
eclipse/idea/myeclipse/sts等均可配置运行
适用
课程设计,大作业,毕业设计,项目练习,学习演示等
功能说明








基于javaweb的SSH实验室设备管理系统(java+ssh+jsp+mysql+tomcat)
管理员
admin 123456
学生
xs 123456
教师:
js 123456
——————————CodeStart——————————
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
| public Integer getLaboratoryId() { return laboratoryId; }
public void setLaboratoryId(Integer laboratoryId) { this.laboratoryId = laboratoryId; }
}
@Controller("equipmentlogAction") @Scope("prototype") public class EquipmentLogAction extends ActionSupport implements ModelDriven<EquipmentLog> { @Autowired private EquipmentService equipmentService;
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
| public class ExportUtils {
public static String export(List<Equipment> list, HttpServletRequest request) throws IOException { HSSFWorkbook wb = new HSSFWorkbook(); Sheet 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 = sheet.createRow(0); for (int j = 0; j < CountColumnNum; j++) { firstCell[j] = firstRow.createCell(j); firstCell[j].setCellValue(new HSSFRichTextString(firstCellNames[j])); } BigDecimal bd; for (int i = 0; i < list.size(); i++) { Row row = sheet.createRow(i + 1); Cell id = row.createCell(0); id.setCellValue(list.get(i).getXh().toString()); bd = new BigDecimal(list.get(i).getJg().toString()); bd = bd.setScale(2, BigDecimal.ROUND_HALF_UP); Cell by = row.createCell(1); by.setCellValue(bd.toString()); Cell zzs = row.createCell(2); zzs.setCellValue(list.get(i).getZzs().toString()); Cell xh = row.createCell(3); xh.setCellValue(list.get(i).getXh().toString()); Cell sj = row.createCell(4); sj.setCellValue(list.get(i).getFwTime().toString()); }
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
| String realPath = request.getServletContext().getRealPath("excel"); FileOutputStream out = null; String fileName = "sorry:导出异常"; try { fileName = System.currentTimeMillis() + ".xls"; out = new FileOutputStream(realPath + "/" + fileName); wb.write(out); } catch (IOException e) { System.out.println(e.toString()); } finally { try { out.close(); } catch (IOException e) { System.out.println(e.toString()); } } return "excel/" + fileName; } }
@Controller("loginAction")
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
| ActionContext.getContext().put("user", user1); Pager<Laboratory> pagers2 = laboratoryService.getList(null); ActionContext.getContext().put("pagers2", pagers2); ActionContext.getContext().put("bean", equipment); } return SUCCESS; }
public String add() { User user1 = UserUtils.getUser(); ActionContext.getContext().put("bean", user1); return SUCCESS; }
public String edit() { Equipment bean = equipmentService.findById(equipment.getId()); Pager<Laboratory> pagers2 = laboratoryService.getList(null); ActionContext.getContext().put("pagers2", pagers2); ActionContext.getContext().put("bean", bean); return SUCCESS; }
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"); JsonUtils.toJson(map); }
public String dataList3() {
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
| private Date bxTime;
private Date endTime;
private String wz; private Equipment equipment;
public void export() throws IOException { List<RepairLog> list = repairLogService.getList(repairLog).getDatas(); HSSFWorkbook wb = new HSSFWorkbook(); Sheet 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 = sheet.createRow(0); for (int j = 0; j < CountColumnNum; j++) { firstCell[j] = firstRow.createCell(j); firstCell[j].setCellValue(new HSSFRichTextString(firstCellNames[j])); } BigDecimal bd; for (int i = 0; i < list.size(); i++) { Row row = sheet.createRow(i + 1); Cell id = row.createCell(0); id.setCellValue(list.get(i).getEquipment().getXh().toString());
Cell zzs = row.createCell(1); zzs.setCellValue(list.get(i).getTitle().toString());
Cell xh = row.createCell(2); xh.setCellValue(list.get(i).getBxTime().toString()); Cell gh = row.createCell(3); gh.setCellValue(list.get(i).getEndTime().toString()); Cell t = row.createCell(4); t.setCellValue(list.get(i).getWz().toString()); } HttpServletResponse response = ServletActionContext.getResponse(); response.setContentType("application/vnd.ms-excel"); response.setHeader("Content-disposition", "attachment;filename=export.xls"); OutputStream out = response.getOutputStream(); wb.write(out); out.flush(); out.close();
|
——————————PayStart——————————
项目链接:
https://javayms.github.io?id=161923492708201cl
https://javayms.pages.dev?id=161923492708201cl