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";
}
}

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

View File

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

View File

@ -8,6 +8,7 @@ public interface OrderDao {
int add(Order order);
ArrayList<Order> findByStudent_id(int stuId);
ArrayList<Order> findCurrent(int stuId);
ArrayList<Order> findByWorkerId(int workerId);
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.db.ConnectionFactory;
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.mapper.DeviceMapper;
import cn.edu.cqwu.repair.entity.mapper.OrderMapper;
@ -34,6 +35,15 @@ public class OrderDaoImpl implements OrderDao {
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
public ArrayList<Order> findByWorkerId(int workerId){
QueryWrapper qw = new QueryWrapper();

View File

@ -16,4 +16,7 @@ public enum OrderStatus {
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="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ page isELIgnored="false" %>
<c:set var="title" value="上传表单"/>
<c:set var="title" value="历史维修单"/>
<c:set var="webroot" value="${pageContext.request.contextPath}"/>
<c:set var="repairOrder" value="${requestScope.Orders}"/>
<html>
@ -23,18 +23,15 @@
<main class="d-flex flex-nowrap">
<%@ 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">
<h1 class="h3 mb-3 fw-normal">查看订单</h1>
<h1 class="h3 mb-3 fw-normal">${title}</h1>
<c:if test="${not empty requestScope.stuConsultMess}">
<div class="alert alert-warning" role="alert">
${requestScope.stuConsultMess}
</div>
</c:if>
<div class="form-floating">
<c:if test="${not empty requestScope.Orders}">
<table class="table">
<thead>
<tr>
@ -43,8 +40,8 @@
<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>
@ -55,7 +52,6 @@
<td>${repairOrder.phone}</td>
<td>${repairOrder.address}</td>
<td>${repairOrder.faultDesc}</td>
<td><img src="${repairOrder.faultImg}" alt="故障图片"></td>
<td>
<c:choose>
<c:when test="${repairOrder.orderStatus==0}">
@ -64,30 +60,22 @@
<c:when test="${repairOrder.orderStatus==1}">
正在维修中
</c:when>
<c:when test="${repairOrder.orderStatus==2}">
等待评价
</c:when>
<c:otherwise>
维修已完成
</c:otherwise>
</c:choose>
</td>
<td>
<a href="${webroot}/stu/detail.do?id=${repairOrder.orderId}">详情</a>
</td>
</tr>
</c:forEach>
</tbody>
</table>
</c:if>
</div>
</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>
</html>

View File

@ -10,7 +10,7 @@
<%@ 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="title" value="上传表单"/>
<c:set var="title" value="当前维修单"/>
<c:set var="webroot" value="${pageContext.request.contextPath}"/>
<c:set var="repairOrder" value="${requestScope.Orders}"/>
<html>
@ -30,18 +30,17 @@
<main class="d-flex flex-nowrap">
<%@ 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">
<h1 class="h3 mb-3 fw-normal">查看订单</h1>
<h1 class="h3 mb-3 fw-normal">${title}</h1>
<c:if test="${not empty requestScope.stuCurrentMess}">
<div class="alert alert-warning" role="alert">
${requestScope.stuCurrentMess}
</div>
</c:if>
<div class="form-floating">
<c:if test="${not empty requestScope.Orders}">
<table class="table">
<thead>
<tr>
@ -50,27 +49,19 @@
<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 var="repairOrder" items="${requestScope.Orders}" varStatus="loop">
<tr>
<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>${loop.index + 1}</td>
<td>${repairOrder.contact}</td>
<td>${repairOrder.phone}</td>
<td>${repairOrder.address}</td>
<td>${repairOrder.faultDesc}</td>
<td>
<c:choose>
<c:when test="${repairOrder.orderStatus==0}">
待安排维修人员
@ -78,21 +69,20 @@
<c:when test="${repairOrder.orderStatus==1}">
正在维修中
</c:when>
<c:when test="${repairOrder.orderStatus==2}">
等待评价
</c:when>
<c:otherwise>
维修已完成
</c:otherwise>
</c:choose>
</td>
<td>
<a href="${webroot}/stu/detail.do?id=${repairOrder.orderId}">详情</a>
</td>
</tr>
</c:forEach>
</c:if>
</tbody>
</table>
</div>
</main>
</main>
</body>