fix: query order

This commit is contained in:
xtaodada 2024-06-06 20:03:19 +08:00
parent 73a5918f49
commit 2c2c107dad
Signed by: xtaodada
GPG Key ID: 4CBB3F4FA8C85659
8 changed files with 71 additions and 91 deletions

View File

@ -32,6 +32,4 @@ public class StuConsultController {
return "/stu/consult"; return "/stu/consult";
} }
} }

View File

@ -3,7 +3,6 @@ package cn.edu.cqwu.repair.controller.stu;
import cn.edu.cqwu.repair.dao.OrderDao; import cn.edu.cqwu.repair.dao.OrderDao;
import cn.edu.cqwu.repair.entity.Order; import cn.edu.cqwu.repair.entity.Order;
import cn.edu.cqwu.repair.entity.OrderStatus;
import cn.edu.cqwu.repair.entity.Stu; import cn.edu.cqwu.repair.entity.Stu;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
@ -25,24 +24,12 @@ public class StuCurrentController {
@GetMapping("/stu/current") @GetMapping("/stu/current")
public String current(HttpServletRequest request, @SessionAttribute Stu stu) { public String current(HttpServletRequest request, @SessionAttribute Stu stu) {
ArrayList<Order> orders = orderDao.findByStudent_id(stu.getUserid()); ArrayList<Order> orders = orderDao.findCurrent(stu.getUserid());
ArrayList<Order> orders1 = new ArrayList<>(); if (orders != null) {
for (Order order : orders) { request.setAttribute("Orders", orders);
if (order.getOrderStatus() == OrderStatus.UNASSIGNED.value || order.getOrderStatus() == OrderStatus.PROGRESS.value) {
orders1.add(order);
}
}
if (orders1 != null) {
request.setAttribute("Orders", orders1);
} else { } else {
request.setAttribute("stuCurrentMess", "订单为空"); request.setAttribute("stuCurrentMess", "订单为空");
} }
return "/stu/current"; return "/stu/current";
} }
} }

View File

@ -17,6 +17,9 @@ import javax.servlet.http.HttpServletRequest;
import java.io.File; import java.io.File;
import java.util.ArrayList; import java.util.ArrayList;
/**
* @author xtaod
*/
@Controller @Controller
public class StuUploadController { public class StuUploadController {
@ -73,7 +76,7 @@ public class StuUploadController {
if (myfile != null) { if (myfile != null) {
for (int i = 0; i < myfile.length; i++) { for (int i = 0; i < myfile.length; i++) {
String filepath = saveFile(myfile[i], path, path2, time + "", i); String filepath = saveFile(myfile[i], path, path2, time + "", i);
if (filepath.equals("图片格式不正确")) { if ("图片格式不正确".equals(filepath)) {
req.setAttribute("stuUploadMess", "图片格式不正确"); req.setAttribute("stuUploadMess", "图片格式不正确");
return "/stu/upload"; return "/stu/upload";
} else { } else {

View File

@ -8,6 +8,7 @@ public interface OrderDao {
int add(Order order); int add(Order order);
ArrayList<Order> findByStudent_id(int stuId); ArrayList<Order> findByStudent_id(int stuId);
ArrayList<Order> findCurrent(int stuId);
ArrayList<Order> findByWorkerId(int workerId); ArrayList<Order> findByWorkerId(int workerId);
public int statusModify(int orderId); public int statusModify(int orderId);

View File

@ -3,6 +3,7 @@ package cn.edu.cqwu.repair.dao.impl;
import cn.edu.cqwu.repair.dao.OrderDao; import cn.edu.cqwu.repair.dao.OrderDao;
import cn.edu.cqwu.repair.db.ConnectionFactory; import cn.edu.cqwu.repair.db.ConnectionFactory;
import cn.edu.cqwu.repair.entity.Order; import cn.edu.cqwu.repair.entity.Order;
import cn.edu.cqwu.repair.entity.OrderStatus;
import cn.edu.cqwu.repair.entity.Worker; import cn.edu.cqwu.repair.entity.Worker;
import cn.edu.cqwu.repair.entity.mapper.DeviceMapper; import cn.edu.cqwu.repair.entity.mapper.DeviceMapper;
import cn.edu.cqwu.repair.entity.mapper.OrderMapper; import cn.edu.cqwu.repair.entity.mapper.OrderMapper;
@ -34,6 +35,15 @@ public class OrderDaoImpl implements OrderDao {
return (ArrayList<Order>) mapper.selectListByQuery(qw); return (ArrayList<Order>) mapper.selectListByQuery(qw);
} }
@Override
public ArrayList<Order> findCurrent(int stuId) {
QueryWrapper qw = new QueryWrapper();
qw.select(ORDER.ALL_COLUMNS)
.where(ORDER.STUDENT_ID.eq(stuId))
.where(ORDER.ORDER_STATUS.in(OrderStatus.getCurrent()));
return (ArrayList<Order>) mapper.selectListByQuery(qw);
}
@Override @Override
public ArrayList<Order> findByWorkerId(int workerId){ public ArrayList<Order> findByWorkerId(int workerId){
QueryWrapper qw = new QueryWrapper(); QueryWrapper qw = new QueryWrapper();

View File

@ -16,4 +16,7 @@ public enum OrderStatus {
this.value = value; this.value = value;
} }
public static int[] getCurrent() {
return new int[]{0, 1, 2};
}
} }

View File

@ -4,7 +4,7 @@
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %> <%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %> <%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ page isELIgnored="false" %> <%@ page isELIgnored="false" %>
<c:set var="title" value="上传表单"/> <c:set var="title" value="历史维修单"/>
<c:set var="webroot" value="${pageContext.request.contextPath}"/> <c:set var="webroot" value="${pageContext.request.contextPath}"/>
<c:set var="repairOrder" value="${requestScope.Orders}"/> <c:set var="repairOrder" value="${requestScope.Orders}"/>
<html> <html>
@ -23,31 +23,28 @@
<main class="d-flex flex-nowrap"> <main class="d-flex flex-nowrap">
<%@ include file="../includes/header.jsp" %> <%@ include file="../includes/header.jsp" %>
<main class=" w-100 m-auto"> <main class="form-signin w-100 m-auto scrollspy" style="min-width: 800px">
<img class="mb-4" src="${webroot}/images/logo.jpg" alt="" width="72" height="72"> <img class="mb-4" src="${webroot}/images/logo.jpg" alt="" width="72" height="72">
<h1 class="h3 mb-3 fw-normal">查看订单</h1> <h1 class="h3 mb-3 fw-normal">${title}</h1>
<c:if test="${not empty requestScope.stuConsultMess}"> <c:if test="${not empty requestScope.stuConsultMess}">
<div class="alert alert-warning" role="alert"> <div class="alert alert-warning" role="alert">
${requestScope.stuConsultMess} ${requestScope.stuConsultMess}
</div> </div>
</c:if> </c:if>
<div class="form-floating"> <table class="table">
<thead>
<c:if test="${not empty requestScope.Orders}"> <tr>
<table class="table"> <th scope="col">序号</th>
<thead> <th scope="col">联系人名称</th>
<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> <th scope="col">处理状态</th>
<th scope="col">详细地点</th> <th scope="col">操作</th>
<th scope="col">故障描述</th> </tr>
<th scope="col">故障图片</th> </thead>
<th scope="col">处理状态</th> <tbody>
</tr>
</thead>
<tbody>
<c:forEach var="repairOrder" items="${requestScope.Orders}" varStatus="loop"> <c:forEach var="repairOrder" items="${requestScope.Orders}" varStatus="loop">
<tr> <tr>
<td>${loop.index + 1}</td> <td>${loop.index + 1}</td>
@ -55,7 +52,6 @@
<td>${repairOrder.phone}</td> <td>${repairOrder.phone}</td>
<td>${repairOrder.address}</td> <td>${repairOrder.address}</td>
<td>${repairOrder.faultDesc}</td> <td>${repairOrder.faultDesc}</td>
<td><img src="${repairOrder.faultImg}" alt="故障图片"></td>
<td> <td>
<c:choose> <c:choose>
<c:when test="${repairOrder.orderStatus==0}"> <c:when test="${repairOrder.orderStatus==0}">
@ -64,30 +60,22 @@
<c:when test="${repairOrder.orderStatus==1}"> <c:when test="${repairOrder.orderStatus==1}">
正在维修中 正在维修中
</c:when> </c:when>
<c:when test="${repairOrder.orderStatus==2}">
等待评价
</c:when>
<c:otherwise> <c:otherwise>
维修已完成 维修已完成
</c:otherwise> </c:otherwise>
</c:choose> </c:choose>
</td> </td>
<td>
<a href="${webroot}/stu/detail.do?id=${repairOrder.orderId}">详情</a>
</td>
</tr> </tr>
</c:forEach> </c:forEach>
</tbody> </tbody>
</table> </table>
</c:if>
</div>
</main> </main>
</main> </main>
<%--<script src="${webroot}/js/pass.js" type="javascript"></script>--%>
<%--<script>--%>
<%-- const toastLiveExample = document.getElementById('liveToast')--%>
<%-- const toastBootstrap = bootstrap.Toast.getOrCreateInstance(toastLiveExample)--%>
<%-- toastBootstrap.show()--%>
<%--</script>--%>
<%--<script src="${webroot}/js/pass.js"></script>--%>
</body> </body>
</html> </html>

View File

@ -10,7 +10,7 @@
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %> <%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %> <%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ page isELIgnored="false" %> <%@ page isELIgnored="false" %>
<c:set var="title" value="上传表单"/> <c:set var="title" value="当前维修单"/>
<c:set var="webroot" value="${pageContext.request.contextPath}"/> <c:set var="webroot" value="${pageContext.request.contextPath}"/>
<c:set var="repairOrder" value="${requestScope.Orders}"/> <c:set var="repairOrder" value="${requestScope.Orders}"/>
<html> <html>
@ -30,47 +30,38 @@
<main class="d-flex flex-nowrap"> <main class="d-flex flex-nowrap">
<%@ include file="../includes/header.jsp" %> <%@ include file="../includes/header.jsp" %>
<main class=" w-100 m-auto"> <main class="form-signin w-100 m-auto scrollspy" style="min-width: 800px">
<img class="mb-4" src="${webroot}/images/logo.jpg" alt="" width="72" height="72"> <img class="mb-4" src="${webroot}/images/logo.jpg" alt="" width="72" height="72">
<h1 class="h3 mb-3 fw-normal">查看订单</h1> <h1 class="h3 mb-3 fw-normal">${title}</h1>
<c:if test="${not empty requestScope.stuCurrentMess}"> <c:if test="${not empty requestScope.stuCurrentMess}">
<div class="alert alert-warning" role="alert"> <div class="alert alert-warning" role="alert">
${requestScope.stuCurrentMess} ${requestScope.stuCurrentMess}
</div> </div>
</c:if> </c:if>
<div class="form-floating">
<c:if test="${not empty requestScope.Orders}">
<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>
<th scope="col">处理状态</th>
</tr>
</thead>
<tbody>
<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>
<th scope="col">操作</th>
</tr>
</thead>
<c:forEach var="repairOrder" items="${requestScope.Orders}" varStatus="loop"> <c:forEach var="repairOrder" items="${requestScope.Orders}" varStatus="loop">
<tr> <tr>
<td>第 ${loop.index + 1} 项订单</td> <td>${loop.index + 1}</td>
<td><strong>联系人名称:</strong>${repairOrder.contact}</td>
<td><strong>联系人名称:</strong>${repairOrder.contact}</td>
<td><strong>联系人电话:</strong>${repairOrder.phone}</td>
<td><strong>详细地点:</strong>${repairOrder.address}</td>
<td><strong>故障描述:</strong>${repairOrder.faultDesc}</td>
<td><strong>故障图片:</strong><img src="${repairOrder.faultImg}" alt="故障图片"></td>
<td><strong>处理状态:</strong>
<td>${repairOrder.contact}</td>
<td>${repairOrder.phone}</td>
<td>${repairOrder.address}</td>
<td>${repairOrder.faultDesc}</td>
<td>
<c:choose> <c:choose>
<c:when test="${repairOrder.orderStatus==0}"> <c:when test="${repairOrder.orderStatus==0}">
待安排维修人员 待安排维修人员
@ -78,21 +69,20 @@
<c:when test="${repairOrder.orderStatus==1}"> <c:when test="${repairOrder.orderStatus==1}">
正在维修中 正在维修中
</c:when> </c:when>
<c:when test="${repairOrder.orderStatus==2}">
等待评价
</c:when>
<c:otherwise> <c:otherwise>
维修已完成 维修已完成
</c:otherwise> </c:otherwise>
</c:choose> </c:choose>
</td> </td>
<td>
<a href="${webroot}/stu/detail.do?id=${repairOrder.orderId}">详情</a>
</td>
</tr> </tr>
</c:forEach> </c:forEach>
</c:if>
</tbody>
</table> </table>
</div>
</main> </main>
</main> </main>
</body> </body>