admin device query
This commit is contained in:
parent
387ed61777
commit
42799908a0
@ -3,6 +3,7 @@
|
|||||||
<component name="WebContextManager">
|
<component name="WebContextManager">
|
||||||
<option name="state">
|
<option name="state">
|
||||||
<map>
|
<map>
|
||||||
|
<entry key="file://$PROJECT_DIR$/src/main/webapp/admin/device.jsp" value="file://$PROJECT_DIR$/src/main/webapp/admin" />
|
||||||
<entry key="file://$PROJECT_DIR$/src/main/webapp/student/register.jsp" value="file://$PROJECT_DIR$/src/main/webapp/student" />
|
<entry key="file://$PROJECT_DIR$/src/main/webapp/student/register.jsp" value="file://$PROJECT_DIR$/src/main/webapp/student" />
|
||||||
<entry key="file://$PROJECT_DIR$/src/main/webapp/worker/worker_center_index.jsp" value="file://$PROJECT_DIR$/src/main/webapp/worker" />
|
<entry key="file://$PROJECT_DIR$/src/main/webapp/worker/worker_center_index.jsp" value="file://$PROJECT_DIR$/src/main/webapp/worker" />
|
||||||
</map>
|
</map>
|
||||||
|
@ -0,0 +1,36 @@
|
|||||||
|
package cn.edu.cqwu.repair.controller.admin;
|
||||||
|
|
||||||
|
import cn.edu.cqwu.repair.dao.DeviceDao;
|
||||||
|
import cn.edu.cqwu.repair.entity.Device;
|
||||||
|
import org.springframework.stereotype.Controller;
|
||||||
|
import org.springframework.ui.Model;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author xtaod
|
||||||
|
*/
|
||||||
|
@Controller
|
||||||
|
public class AdminDeviceController {
|
||||||
|
private final DeviceDao deviceDao;
|
||||||
|
|
||||||
|
public AdminDeviceController(DeviceDao deviceDao) {
|
||||||
|
this.deviceDao = deviceDao;
|
||||||
|
}
|
||||||
|
|
||||||
|
@RequestMapping("/admin/device/query.do")
|
||||||
|
public String query(int deviceTypeId, int deviceAddressId, int deviceStatus, Model model) {
|
||||||
|
model.addAttribute("deviceTypeId", deviceTypeId);
|
||||||
|
model.addAttribute("deviceAddressId", deviceAddressId);
|
||||||
|
model.addAttribute("deviceStatus", deviceStatus);
|
||||||
|
ArrayList<Device> deviceList = deviceDao.findAllDevice(deviceTypeId, deviceAddressId, deviceStatus);
|
||||||
|
if (deviceList == null || deviceList.isEmpty()) {
|
||||||
|
model.addAttribute("deviceMess", "没有查询到设备信息");
|
||||||
|
} else {
|
||||||
|
model.addAttribute("deviceMess", "查询到" + deviceList.size() + "条设备信息");
|
||||||
|
}
|
||||||
|
model.addAttribute("devices", deviceList);
|
||||||
|
return "/admin/device";
|
||||||
|
}
|
||||||
|
}
|
@ -1,12 +1,16 @@
|
|||||||
package cn.edu.cqwu.repair.dao;
|
package cn.edu.cqwu.repair.dao;
|
||||||
|
|
||||||
import cn.edu.cqwu.repair.entity.Device;
|
import cn.edu.cqwu.repair.entity.Device;
|
||||||
import cn.edu.cqwu.repair.entity.Stu;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author wobeitaoleshigexuruo
|
||||||
|
*/
|
||||||
public interface DeviceDao {
|
public interface DeviceDao {
|
||||||
|
|
||||||
public ArrayList<Device> findAllDevice();
|
ArrayList<Device> findAllDevice();
|
||||||
|
|
||||||
|
ArrayList<Device> findAllDevice(int deviceTypeId, int deviceAddressId, int deviceStatus);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,17 +1,19 @@
|
|||||||
package cn.edu.cqwu.repair.dao.impl;
|
package cn.edu.cqwu.repair.dao.impl;
|
||||||
|
|
||||||
import cn.edu.cqwu.repair.dao.DeviceDao;
|
import cn.edu.cqwu.repair.dao.DeviceDao;
|
||||||
import cn.edu.cqwu.repair.dao.StuDao;
|
|
||||||
import cn.edu.cqwu.repair.db.ConnectionFactory;
|
import cn.edu.cqwu.repair.db.ConnectionFactory;
|
||||||
import cn.edu.cqwu.repair.entity.Device;
|
import cn.edu.cqwu.repair.entity.Device;
|
||||||
import cn.edu.cqwu.repair.entity.Stu;
|
|
||||||
import cn.edu.cqwu.repair.entity.mapper.AdminUserMapper;
|
|
||||||
import cn.edu.cqwu.repair.entity.mapper.DeviceMapper;
|
import cn.edu.cqwu.repair.entity.mapper.DeviceMapper;
|
||||||
import cn.edu.cqwu.repair.service.RecordService;
|
import com.mybatisflex.core.query.QueryWrapper;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
import static cn.edu.cqwu.repair.entity.table.DeviceTableDef.DEVICE;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author wobeitaoleshigexuruo
|
||||||
|
*/
|
||||||
@Component
|
@Component
|
||||||
public class DeviceDaoImpl implements DeviceDao {
|
public class DeviceDaoImpl implements DeviceDao {
|
||||||
private static final DeviceMapper mapper = ConnectionFactory.getMapper(DeviceMapper.class);
|
private static final DeviceMapper mapper = ConnectionFactory.getMapper(DeviceMapper.class);
|
||||||
@ -20,4 +22,19 @@ public class DeviceDaoImpl implements DeviceDao {
|
|||||||
public ArrayList<Device> findAllDevice() {
|
public ArrayList<Device> findAllDevice() {
|
||||||
return (ArrayList<Device>) mapper.selectAll();
|
return (ArrayList<Device>) mapper.selectAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ArrayList<Device> findAllDevice(int deviceTypeId, int deviceAddressId, int deviceStatus) {
|
||||||
|
QueryWrapper qw = new QueryWrapper();
|
||||||
|
if (deviceTypeId > 0) {
|
||||||
|
qw.where(DEVICE.DEVICE_TYPE_ID.eq(deviceTypeId));
|
||||||
|
}
|
||||||
|
if (deviceAddressId > 0) {
|
||||||
|
qw.where(DEVICE.DEVICE_ADDRESS_ID.eq(deviceAddressId));
|
||||||
|
}
|
||||||
|
if (deviceStatus >= 0) {
|
||||||
|
qw.where(DEVICE.DEVICE_STATUS.eq(deviceStatus));
|
||||||
|
}
|
||||||
|
return (ArrayList<Device>) mapper.selectListByQuery(qw);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
107
src/main/webapp/admin/device.jsp
Normal file
107
src/main/webapp/admin/device.jsp
Normal file
@ -0,0 +1,107 @@
|
|||||||
|
<%--
|
||||||
|
Created by IntelliJ IDEA.
|
||||||
|
User: xtaod
|
||||||
|
Date: 2024/5/16
|
||||||
|
Time: 上午8:29
|
||||||
|
To change this template use File | Settings | File Templates.
|
||||||
|
--%>
|
||||||
|
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
|
||||||
|
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
|
||||||
|
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
|
||||||
|
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
|
||||||
|
<%@ page isELIgnored="false" %>
|
||||||
|
<c:set var="webroot" value="${pageContext.request.contextPath}"/>
|
||||||
|
<c:set var="title" value="设备维护"/>
|
||||||
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
|
||||||
|
<title>${title}</title>
|
||||||
|
<link rel="stylesheet" href="${webroot}/styles/bootstrap.min.css" crossorigin="anonymous">
|
||||||
|
<script src="${webroot}/js/bootstrap.bundle.min.js"></script>
|
||||||
|
<link rel="stylesheet" href="${webroot}/styles/sidebar.css" crossorigin="anonymous">
|
||||||
|
<link rel="stylesheet" href="${webroot}/styles/index.css" crossorigin="anonymous">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<main class="d-flex flex-nowrap">
|
||||||
|
<%@ include file="../includes/header.jsp" %>
|
||||||
|
|
||||||
|
<main class="form-signin w-100 m-auto" style="max-width: 800px;">
|
||||||
|
<img class="mb-4" src="${webroot}/images/logo.jpg" alt="" width="72" height="72">
|
||||||
|
<h1 class="h3 mb-3 fw-normal">${title}</h1>
|
||||||
|
<c:if test="${not empty deviceMess}">
|
||||||
|
<div class="alert alert-warning" role="alert">
|
||||||
|
${deviceMess}
|
||||||
|
</div>
|
||||||
|
</c:if>
|
||||||
|
|
||||||
|
<form action="${webroot}/admin/device/query.do" method="post">
|
||||||
|
<div class="input-group mb-3">
|
||||||
|
<span class="input-group-text">设备类型</span>
|
||||||
|
<select class="form-select" name="deviceTypeId" id="deviceTypeId" required>
|
||||||
|
<option value="0">所有</option>
|
||||||
|
<c:forEach items="${applicationScope.faults}" var="deviceType">
|
||||||
|
<option value="${deviceType.faultId}" <c:if test="${deviceType.faultId == deviceTypeId}">selected</c:if>>
|
||||||
|
${deviceType.faultName}
|
||||||
|
</c:forEach>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
<div class="input-group mb-3">
|
||||||
|
<span class="input-group-text">设备区域</span>
|
||||||
|
<select class="form-select" name="deviceAddressId" id="deviceAddressId" required>
|
||||||
|
<option value="0">所有</option>
|
||||||
|
<c:forEach items="${applicationScope.addresses0}" var="address">
|
||||||
|
<option value="${address.addressId}" <c:if test="${address.addressId == deviceAddressId}">selected</c:if>>
|
||||||
|
${address.addressName}
|
||||||
|
</c:forEach>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
<div class="input-group mb-3">
|
||||||
|
<span class="input-group-text">设备状态</span>
|
||||||
|
<select class="form-select" name="deviceStatus" id="deviceStatus" required>
|
||||||
|
<option value="-1" <c:if test="${deviceStatus == -1}">selected</c:if>>所有</option>
|
||||||
|
<option value="0" <c:if test="${deviceStatus == 0}">selected</c:if>>正常</option>
|
||||||
|
<option value="1" <c:if test="${deviceStatus == 1}">selected</c:if>>维修中</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
<input class="btn btn-primary w-100 py-2" type="submit" id="submit" value="查询">
|
||||||
|
<br/><br/>
|
||||||
|
</form>
|
||||||
|
|
||||||
|
<c:if test="${not empty devices}">
|
||||||
|
<h5>查询到的设备列表</h5>
|
||||||
|
<table class="table">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th scope="col">序号</th>
|
||||||
|
<th scope="col">设备名称</th>
|
||||||
|
<th scope="col">设备状态</th>
|
||||||
|
<th scope="col">详细地址</th>
|
||||||
|
<th scope="col">创建时间</th>
|
||||||
|
<th scope="col">操作</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<c:forEach items="${devices}" var="device" varStatus="rows">
|
||||||
|
<tr>
|
||||||
|
<td>${rows.count}</td>
|
||||||
|
<td>${device.deviceName}</td>
|
||||||
|
<td>
|
||||||
|
<c:if test="${device.deviceStatus == 0}">正常</c:if>
|
||||||
|
<c:if test="${device.deviceStatus == 1}">维修中</c:if>
|
||||||
|
</td>
|
||||||
|
<td>${device.deviceAddressDetail}</td>
|
||||||
|
<td>${device.createTime}</td>
|
||||||
|
<td>
|
||||||
|
<a href="${webroot}/admin/device/queryEdit.do?deviceId=${device.deviceId}">编辑</a><br/>
|
||||||
|
<a href="${webroot}/admin/device/delete.do?deviceId=${device.deviceId}">删除</a>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</c:forEach>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</c:if>
|
||||||
|
</main>
|
||||||
|
</main>
|
||||||
|
</body>
|
||||||
|
</html>
|
@ -57,7 +57,7 @@
|
|||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
<li class="nav-item">
|
<li class="nav-item">
|
||||||
<a href="${webroot}/admin/state.jsp" class="nav-link link-body-emphasis" aria-current="page">
|
<a href="${webroot}/admin/device.jsp" class="nav-link link-body-emphasis" aria-current="page">
|
||||||
>> 设备管理
|
>> 设备管理
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
|
Loading…
Reference in New Issue
Block a user