当前位置:   article > 正文

(java毕业设计源码)基于java教室设备管理系统源码_java实验室设备管理系统源码

java实验室设备管理系统源码

基于java教室设备管理系统

项目获取请看文章最底下官网

教室设备管理系统是基于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 com.lmu.controller;

/**
 * 用户新增
 */

import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.ModelDriven;
import com.lmu.model.*;
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 org.springframework.context.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.net.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> {
    @Autowired
    private LaboratoryService laboratoryService;
    @Autowired
    private EquipmentService equipmentService;
    @Autowired
    private EquipmentLogService equipmentLogService;
    @Autowired
    private 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 = UserUtils.getUser();
        if (user1 == null || user1.getId() == null) {
            ActionContext.getContext().put("login", 1);
            return SUCCESS;
        }
        Pager<Equipment> pagers = null;
        Role role = user1.getRole();
        if (role.getEnName().equals("admin")) {
            pagers = equipmentService.getList(equipment);
            ActionContext.getContext().put("pagers", pagers);
            ActionContext.getContext().put("user", user1);
            Pager<Laboratory> pagers2 = laboratoryService.getList(null);
            ActionContext.getContext().put("pagers2", pagers2);
            ActionContext.getContext().put("bean", equipment);
        }
        return SUCCESS;
    }

    /**
     * list
     *
     * @return
     */
    public String dataList() {
        User user1 = UserUtils.getUser();
        if (user1 == null || user1.getId() == null) {
            ActionContext.getContext().put("login", 1);
            return SUCCESS;
        }
        Pager<Equipment> pagers = null;
        Role role = user1.getRole();
        if (role.getEnName().equals("admin")) {
            pagers = equipmentService.getList(equipment);
            ActionContext.getContext().put("pagers", pagers);
            ActionContext.getContext().put("user", user1);
            Pager<Laboratory> pagers2 = laboratoryService.getList(null);
            ActionContext.getContext().put("pagers2", pagers2);
            ActionContext.getContext().put("bean", equipment);

        }
        return SUCCESS;
    }


    /**
     * list
     *
     * @return
     */
    public String dataList2() {
        User user1 = UserUtils.getUser();
        if (user1 == null || user1.getId() == null) {
            ActionContext.getContext().put("login", 1);
            return SUCCESS;
        }
        Pager<Equipment> pagers = null;
        Role role = user1.getRole();
        if (role.getEnName().equals("admin")) {
            pagers = equipmentService.getList(equipment);
            ActionContext.getContext().put("pagers", pagers);
            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() {
        User user1 = UserUtils.getUser();
        if (user1 == null || user1.getId() == null) {
            ActionContext.getContext().put("login", 1);
            return SUCCESS;
        }
        Pager<Equipment> pagers = null;
        pagers = equipmentService.getList(equipment);
        ActionContext.getContext().put("pagers", pagers);
        ActionContext.getContext().put("user", user1);
        Pager<Laboratory> pagers2 = laboratoryService.getList(null);
        ActionContext.getContext().put("pagers2", pagers2);
        ActionContext.getContext().put("bean", equipment);
        return SUCCESS;
    }

    /**
     * 借用
     *
     * @return
     */
    public void yy() throws IOException {
        Equipment equipment1 = equipmentService.findById(equipment.getId());
        if (equipment1.getIsJy() == 0) {
            equipment.setIsJy(1);
            equipment.setJyUser(UserUtils.getUser());
            EquipmentLog log = new EquipmentLog();
            log.setUser(UserUtils.getUser());
            log.setTime(new Date());
            log.setEquipment(equipment);
            log.setIsYy(1);
            equipmentLogService.save(log);
            equipment.setJyId(log.getId());
            equipmentService.updates(equipment);
            map.put("flag", true);
            map.put("url", "equipment_dataList3.do");
            JsonUtils.toJson(map);
        } else {
            map.put("flag", false);
            map.put("url", "equipment_dataList3.do");
            JsonUtils.toJson(map);
        }

    }

    /**
     * 借用归还
     *
     * @return
     */
    public void qx() throws IOException {
        Equipment equipment1 = equipmentService.findById(equipment.getId());
        EquipmentLog equipmentLog = equipmentLogService.findById(equipment1.getJyId());
        if (equipmentLog.getUser().getId() == UserUtils.getUser().getId()) {
            equipment1.setIsJy(0);
            equipmentService.update(equipment1);
            equipmentLog.setIsYy(0);
            equipmentLog.setEndTime(new Date());
            equipmentLog.setQx(UserUtils.getUser());
            equipmentLogService.updates(equipmentLog);
            map.put("flag", true);
            map.put("url", "equipment_dataList3.do");
            JsonUtils.toJson(map);
        } else {
            map.put("flag", false);
            map.put("url", "equipment_dataList3.do");
            JsonUtils.toJson(map);
        }
    }

    /**
     * 更新
     *
     * @return
     */
    public String updateDoc() throws IOException {
        if (file != null) {
            ActionContext ac = ActionContext.getContext();
            HttpServletRequest request = (HttpServletRequest) ac.get(ServletActionContext.HTTP_REQUEST);
            String root = request.getRealPath("/upload");
            InputStream is = new FileInputStream(file);
            String f = fileFileName;
            f = UUIDUtils.create() + 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);
        ActionContext.getContext().put("url", "equipment_dataList.do");
        return "redirect";
    }

    /**
     * 更新
     *
     * @return
     */
    public void deleteDocAndPhoto() throws IOException {
        Equipment ee = equipmentService.findById(equipment.getId());
        ee.setPhoto(null);
        ee.setHt(null);
        equipmentService.updates(equipment);
        map.put("flag", true);
        map.put("url", "equipment_dataList2.do");
        JsonUtils.toJson(map);
    }

    /**
     * 更新
     *
     * @return
     */
    public String updatePhoto() throws IOException {
        if (file != null) {
            ActionContext ac = ActionContext.getContext();
            HttpServletRequest request = (HttpServletRequest) ac.get(ServletActionContext.HTTP_REQUEST);
            String root = request.getRealPath("/upload");
            InputStream is = new FileInputStream(file);
            String f = fileFileName;
            f = UUIDUtils.create() + 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);
        ActionContext.getContext().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");
        JsonUtils.toJson(map);
    }

    public void download() throws IOException {
        Equipment equipment1 = equipmentService.findById(equipment.getId());
        downloadFileName = URLEncoder.encode(equipment1.getHt(), "utf-8");
        // 1、得到要下载文件的完整路径?
        String path = ServletActionContext.getServletContext().getRealPath(equipment1.getHt());
        System.out.println("path :" + path);
        HttpServletResponse resp = ServletActionContext.getResponse();
        resp.setContentType("application/x-msdownload");// 指定响应动作是下载路径?
        resp.setHeader("Content-disposition", "attachment;filename=export.doc");
        //读取文件
        InputStream in = new FileInputStream(path);
        OutputStream out = resp.getOutputStream();
        //写文件?
        int b;
        while ((b = in.read()) != -1) {
            out.write(b);
        }
        in.close();
        out.close();
        map.put("flag", true);
        map.put("url", "equipment_dataList.do");
        JsonUtils.toJson(map);
    }


    /**
     * 保存
     *
     * @return
     */
    public String save() throws IOException {
        equipmentService.save(equipment);
        map.put("flag", true);
        map.put("url", "equipment_list.do");
        JsonUtils.toJson(map);
        return SUCCESS;
    }

    public void delete() throws IOException {
        equipment.setIsDelete(1);
        equipmentService.updates(equipment);
        map.put("flag", true);
        map.put("url", "equipment_list.do");
        JsonUtils.toJson(map);
    }

    public void export() throws IOException {
        List<Equipment> list = equipmentService.getList(equipment).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).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).getSbxlh().toString());
            Cell sj = row.createCell(4);
            if (list.get(i).getFwTime() != null && !list.get(i).getFwTime().equals("")) {
                sj.setCellValue(list.get(i).getFwTime().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();
    }

    @Override
    public 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) {
        this.exportId = exportId;
    }
}

  • 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
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • 70
  • 71
  • 72
  • 73
  • 74
  • 75
  • 76
  • 77
  • 78
  • 79
  • 80
  • 81
  • 82
  • 83
  • 84
  • 85
  • 86
  • 87
  • 88
  • 89
  • 90
  • 91
  • 92
  • 93
  • 94
  • 95
  • 96
  • 97
  • 98
  • 99
  • 100
  • 101
  • 102
  • 103
  • 104
  • 105
  • 106
  • 107
  • 108
  • 109
  • 110
  • 111
  • 112
  • 113
  • 114
  • 115
  • 116
  • 117
  • 118
  • 119
  • 120
  • 121
  • 122
  • 123
  • 124
  • 125
  • 126
  • 127
  • 128
  • 129
  • 130
  • 131
  • 132
  • 133
  • 134
  • 135
  • 136
  • 137
  • 138
  • 139
  • 140
  • 141
  • 142
  • 143
  • 144
  • 145
  • 146
  • 147
  • 148
  • 149
  • 150
  • 151
  • 152
  • 153
  • 154
  • 155
  • 156
  • 157
  • 158
  • 159
  • 160
  • 161
  • 162
  • 163
  • 164
  • 165
  • 166
  • 167
  • 168
  • 169
  • 170
  • 171
  • 172
  • 173
  • 174
  • 175
  • 176
  • 177
  • 178
  • 179
  • 180
  • 181
  • 182
  • 183
  • 184
  • 185
  • 186
  • 187
  • 188
  • 189
  • 190
  • 191
  • 192
  • 193
  • 194
  • 195
  • 196
  • 197
  • 198
  • 199
  • 200
  • 201
  • 202
  • 203
  • 204
  • 205
  • 206
  • 207
  • 208
  • 209
  • 210
  • 211
  • 212
  • 213
  • 214
  • 215
  • 216
  • 217
  • 218
  • 219
  • 220
  • 221
  • 222
  • 223
  • 224
  • 225
  • 226
  • 227
  • 228
  • 229
  • 230
  • 231
  • 232
  • 233
  • 234
  • 235
  • 236
  • 237
  • 238
  • 239
  • 240
  • 241
  • 242
  • 243
  • 244
  • 245
  • 246
  • 247
  • 248
  • 249
  • 250
  • 251
  • 252
  • 253
  • 254
  • 255
  • 256
  • 257
  • 258
  • 259
  • 260
  • 261
  • 262
  • 263
  • 264
  • 265
  • 266
  • 267
  • 268
  • 269
  • 270
  • 271
  • 272
  • 273
  • 274
  • 275
  • 276
  • 277
  • 278
  • 279
  • 280
  • 281
  • 282
  • 283
  • 284
  • 285
  • 286
  • 287
  • 288
  • 289
  • 290
  • 291
  • 292
  • 293
  • 294
  • 295
  • 296
  • 297
  • 298
  • 299
  • 300
  • 301
  • 302
  • 303
  • 304
  • 305
  • 306
  • 307
  • 308
  • 309
  • 310
  • 311
  • 312
  • 313
  • 314
  • 315
  • 316
  • 317
  • 318
  • 319
  • 320
  • 321
  • 322
  • 323
  • 324
  • 325
  • 326
  • 327
  • 328
  • 329
  • 330
  • 331
  • 332
  • 333
  • 334
  • 335
  • 336
  • 337
  • 338
  • 339
  • 340
  • 341
  • 342
  • 343
  • 344
  • 345
  • 346
  • 347
  • 348
  • 349
  • 350
  • 351
  • 352
  • 353
  • 354
  • 355
  • 356
  • 357
  • 358
  • 359
  • 360
  • 361
  • 362
  • 363
  • 364
  • 365
  • 366
  • 367
  • 368
  • 369
  • 370
  • 371
  • 372
  • 373
  • 374
  • 375
  • 376
  • 377
  • 378
  • 379
  • 380
  • 381
  • 382
  • 383
  • 384
  • 385
  • 386
  • 387
  • 388
  • 389
  • 390
  • 391
  • 392
  • 393
  • 394
  • 395
  • 396
  • 397
  • 398
  • 399
  • 400
  • 401
  • 402
  • 403
  • 404
  • 405
  • 406
  • 407
  • 408
  • 409
  • 410
  • 411
  • 412
  • 413
  • 414
  • 415
  • 416
  • 417
  • 418
  • 419
  • 420
  • 421
  • 422
  • 423
  • 424
  • 425
  • 426
  • 427
  • 428
  • 429
  • 430
  • 431
  • 432
  • 433
  • 434
  • 435
  • 436
  • 437
  • 438
  • 439
  • 440
  • 441
  • 442
  • 443
  • 444
  • 445
  • 446
  • 447
  • 448
  • 449
  • 450
  • 451
  • 452
  • 453
  • 454
  • 455
  • 456
  • 457
  • 458
  • 459
  • 460
  • 461
  • 462
  • 463
  • 464
  • 465
  • 466
  • 467
  • 468
  • 469
  • 470
  • 471
  • 472
  • 473
  • 474
  • 475
  • 476

五.项目截图

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/笔触狂放9/article/detail/753615
推荐阅读
相关标签
  

闽ICP备14008679号