基于javaweb的SSH实验室设备管理系统(java+ssh+jsp+mysql+tomcat)

运行环境

Java≥8、MySQL≥5.7、Tomcat≥8

开发工具

eclipse/idea/myeclipse/sts等均可配置运行

适用

课程设计,大作业,毕业设计,项目练习,学习演示等

功能说明

171923492708

181923492708

191923492708

201923492708

211923492708

231923492708

241923492708

251923492708

基于javaweb的SSH实验室设备管理系统(java+ssh+jsp+mysql+tomcat)

管理员
admin 123456

学生
xs 123456

教师:
js 123456

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 {
// 生成Workbook
HSSFWorkbook wb = new HSSFWorkbook();
// 追加Sheet
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;
}

/**
* 跳转add
*
* @return
*/
public String add() {
User user1 = UserUtils.getUser();
ActionContext.getContext().put("bean", user1);
return SUCCESS;
}

/**
* 查询修改
*
* @return
*/
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;
}


/**
* 使用
*
* @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");
JsonUtils.toJson(map);
}

/**
* 借用list
*
* @return
*/
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();
// 生成Workbook
HSSFWorkbook wb = new HSSFWorkbook();
// 追加Sheet
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.setContentType("application/vnd.ms-excel");
response.setHeader("Content-disposition", "attachment;filename=export.xls");
OutputStream out = response.getOutputStream();
wb.write(out);
out.flush();
out.close();


项目链接:
https://javayms.github.io?id=161923492708201cl
https://javayms.pages.dev?id=161923492708201cl