Compare commits

..

2 Commits

Author SHA1 Message Date
7083a0cbb0 add histroy list
add doing list
2024-05-13 21:33:36 +08:00
14774b67c7 add histroy list
add doing list
2024-05-13 21:33:00 +08:00
10 changed files with 411 additions and 93 deletions

View File

@ -7,6 +7,7 @@
<option value="$PROJECT_DIR$/pom.xml" /> <option value="$PROJECT_DIR$/pom.xml" />
</list> </list>
</option> </option>
<option name="workspaceImportForciblyTurnedOn" value="true" />
</component> </component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" project-jdk-name="1.8" project-jdk-type="JavaSDK"> <component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/out" /> <output url="file://$PROJECT_DIR$/out" />

View File

@ -8,16 +8,11 @@ import cn.edu.cqwu.repair.dao.OrderDao;
import javax.servlet.http.*; import javax.servlet.http.*;
import cn.edu.cqwu.repair.entity.*; import cn.edu.cqwu.repair.entity.*;
import cn.edu.cqwu.repair.service.RecordService;
import cn.edu.cqwu.repair.util.Encrypt;
import cn.edu.cqwu.repair.util.Verify;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model; import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping; import java.util.List;
import java.util.List;import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession; import javax.servlet.http.HttpSession;

View File

@ -0,0 +1,45 @@
package cn.edu.cqwu.repair.controller.worker;
import cn.edu.cqwu.repair.dao.WorkerDao;
import org.springframework.stereotype.Controller;
import cn.edu.cqwu.repair.dao.OrderDao;
import javax.servlet.http.*;
import cn.edu.cqwu.repair.entity.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
@Controller
public class WorkerHistoryListController extends HttpServlet{
private OrderDao orderDao;
private WorkerDao workerDao;
@Autowired
public WorkerHistoryListController(WorkerDao workerDao, OrderDao orderDao) {
this.workerDao = workerDao;
this.orderDao = orderDao;
}
@GetMapping("/workerHistoryList.do")
public String getOrders(Model model, HttpSession session,
HttpServletRequest request){
// 获取Session对象
session = request.getSession();
// 从Session中获取ID数据
Worker workerUser = (Worker) session.getAttribute("workerUser");
// 调用DAO的方法来获取数据库中的历史订单数据
List<Order> orders = (List<Order>) orderDao.findHistoryList(workerUser.getUserid());
// 将订单数据添加到Model中以便在JSP页面中使用
model.addAttribute("orders", orders);
// 返回到展示订单列表的JSP页面
return "/worker/worker_history_fixList";
}
}

View File

@ -0,0 +1,43 @@
package cn.edu.cqwu.repair.controller.worker;
import cn.edu.cqwu.repair.dao.OrderDao;
import javax.servlet.http.*;
import cn.edu.cqwu.repair.util.Encrypt;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@Controller
public class WorkerOrderStatusController {
private OrderDao orderDao;
@Autowired
public WorkerOrderStatusController(OrderDao orderDao){
this.orderDao = orderDao;
}
@RequestMapping("/updateOrderStatus")
public String updateOrderStatus(HttpServletRequest request,Model model) {
int orderId = Integer.parseInt(request.getParameter("orderId"));
if(orderDao.statusModify(orderId) != 0){
model.addAttribute("workerListStatusMes", "* 状态更新成功!");
}else {
model.addAttribute("workerListStatusMes", "* 状态更新失败!");
}
return "forward:/workerFixList.do";
}
}

View File

@ -10,4 +10,9 @@ public interface OrderDao {
Order findByStudent_id(int id); Order findByStudent_id(int id);
ArrayList<Order> findByWorkerId(int workerId); ArrayList<Order> findByWorkerId(int workerId);
public int statusModify(int orderId);
public Order findByOrderId(int orderId);
public ArrayList<Order> findHistoryList(int workerId);
} }

View File

@ -35,7 +35,31 @@ public class OrderDaoImpl implements OrderDao {
@Override @Override
public ArrayList<Order> findByWorkerId(int workerId){ public ArrayList<Order> findByWorkerId(int workerId){
QueryWrapper qw = new QueryWrapper(); QueryWrapper qw = new QueryWrapper();
qw.select(ORDER.ALL_COLUMNS).where(ORDER.WORKER_ID.eq(workerId)); qw.select(ORDER.ALL_COLUMNS).where(ORDER.WORKER_ID.eq(workerId)).where(ORDER.ORDER_STATUS.eq(1));
return (ArrayList<Order>) mapper.selectListByQuery(qw); return (ArrayList<Order>) mapper.selectListByQuery(qw);
} }
@Override
public Order findByOrderId(int orderId){
QueryWrapper qw = new QueryWrapper();
qw.select(ORDER.ALL_COLUMNS).where(ORDER.ORDER_ID.eq(orderId)).where(ORDER.ORDER_STATUS.eq(1));
return mapper.selectOneByQuery(qw);
}
@Override
public int statusModify(int orderId){
Order order = findByOrderId(orderId);
if(order == null){
return 0;
}
order.setOrderStatus(0);
return mapper.update(order);
}
@Override
public ArrayList<Order> findHistoryList(int workerId){
QueryWrapper qw = new QueryWrapper();
qw.select(ORDER.ALL_COLUMNS).where(ORDER.WORKER_ID.eq(workerId)).where(ORDER.ORDER_STATUS.eq(0));
return (ArrayList<Order>) mapper.selectListByQuery(qw);
}
} }

View File

@ -72,10 +72,10 @@
<a href="${webroot}/worker/worker_center_index.jsp" class="nav-link link-body-emphasis" aria-current="page"> <a href="${webroot}/worker/worker_center_index.jsp" class="nav-link link-body-emphasis" aria-current="page">
>> 个人中心 >> 个人中心
</a> </a>
<a href="${webroot}/worker/worker_fixList.jsp" class="nav-link link-body-emphasis" aria-current="page"> <a href="${webroot}/workerFixList.do" class="nav-link link-body-emphasis" aria-current="page">
>> 维修列表 >> 维修列表
</a> </a>
<a href="${webroot}/worker/worker_history_fixList.jsp" class="nav-link link-body-emphasis" aria-current="page"> <a href="${webroot}/workerHistoryList.do" class="nav-link link-body-emphasis" aria-current="page">
>> 历史维修记录 >> 历史维修记录
</a> </a>
<a href="${webroot}/worker/worker_history_loginList.jsp" class="nav-link link-body-emphasis" aria-current="page"> <a href="${webroot}/worker/worker_history_loginList.jsp" class="nav-link link-body-emphasis" aria-current="page">

View File

@ -10,9 +10,8 @@
<%@ 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="webroot" value="${pageContext.request.contextPath}"/> <c:set var="webroot" value="${pageContext.request.contextPath}"/>
<%@ page contentType="text/html;charset=UTF-8" language="java" %> <c:set var="title" value="用户中心"/>
<html> <html>
<head> <head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8"> <meta http-equiv="content-type" content="text/html; charset=UTF-8">
@ -21,56 +20,20 @@
<script src="${webroot}/js/bootstrap.bundle.min.js"></script> <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/sidebar.css" crossorigin="anonymous">
<link rel="stylesheet" href="${webroot}/styles/index.css" crossorigin="anonymous"> <link rel="stylesheet" href="${webroot}/styles/index.css" crossorigin="anonymous">
<style>
/* 添加一个红色边框 */
.highlight {
border: 2px solid red;
padding: 10px;
}
</style>
</head> </head>
<body> <body>
<header> <main class="d-flex flex-nowrap">
<!-- 导航栏部分 --> <%@ include file="../includes/header.jsp" %>
<div class="d-flex flex-column flex-shrink-0 p-3 bg-body-tertiary" style="width: 280px;">
<a href="${webroot}/" <main class="form-signin w-100 m-auto">
class="d-flex align-items-center mb-3 mb-md-0 me-md-auto link-body-emphasis text-decoration-none"> <img class="mb-4" src="${webroot}/images/logo.jpg" alt="" width="72" height="72">
<img src="${webroot}/images/logo.jpg" alt="" width="32" height="32" class="rounded-circle me-2"> <h1 class="h3 mb-3 fw-normal">个人中心</h1>
<span class="fs-4">工人个人中心</span>
</a> <p>${sessionScope.workerUser.getUsername()},欢迎你!</p>
<hr>
<%@ include file="../includes/menu.jsp" %>
</div> </main>
</header>
<main>
<div class="container">
<div class="row">
<div class="col-md-8 offset-md-2">
<!-- 工人个人中心主页内容 -->
<div class="highlight"> <!-- 添加了红色边框的容器 -->
<div class="card">
<div class="card-body">
<h5 class="card-title">个人信息</h5>
<p class="card-text">这里显示工人的个人信息,比如姓名、联系方式等。</p>
</div>
</div>
<div class="card mt-3">
<div class="card-body">
<h5 class="card-title">订单信息</h5>
<p class="card-text">这里显示工人的订单信息,比如已接订单、待处理订单等。</p>
</div>
</div>
<div class="card mt-3">
<div class="card-body">
<h5 class="card-title">服务记录</h5>
<p class="card-text">这里显示工人的服务记录,包括服务评价、历史订单等。</p>
</div>
</div>
</div>
</div>
</div>
</div>
</main> </main>
<%@ include file="../includes/footer.jsp" %>
</body> </body>
</html> </html>

View File

@ -6,41 +6,146 @@
To change this template use File | Settings | File Templates. To change this template use File | Settings | File Templates.
--%> --%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %> <%@ 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="订单列表"/>
<html> <html>
<head> <head>
<title>订单列表</title> <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">
<style>
.aButton{
cursor: pointer;
display: inline-block;
text-align: center;
white-space: nowrap;
background: #0071e3;
color: #fff;
border-radius: 980px;
font-size: 12px;
line-height: 1.33337;
font-weight: 400;
letter-spacing: -.01em;
font-family: "SF Pro Text","SF Pro Icons","Helvetica Neue","Helvetica","Arial",sans-serif;
min-width: 23px;
padding-left: 11px;
padding-right: 11px;
padding-top: 4px;
padding-bottom: 4px;
}
.alert{
text-align: center;
}
</style>
</head> </head>
<body> <body>
<h1>订单列表</h1> <main class="d-flex flex-nowrap">
<table border="1"> <%@ include file="../includes/header.jsp" %>
<main class="w-100 m-auto">
<c:choose>
<c:when test="${not empty requestScope.orders}">
${requestScope.workerListStatusMes}
<div class="table-responsive">
<table class="table align-middle">
<thead>
<tr> <tr>
<th>订单ID</th> <th scope="col">订单ID</th>
<th>设备ID</th> <th scope="col">设备ID</th>
<th>联系人ID</th> <th scope="col">联系人ID</th>
<th>联系电话</th> <th scope="col">联系人</th>
<th>维修地址</th> <th scope="col">联系电话</th>
<th>故障描述</th> <th scope="col">维修地址</th>
<th>故障图片</th> <th scope="col">故障描述</th>
<th>订单状态</th> <th scope="col">故障图片</th>
<th>创建时间</th> <th scope="col">订单状态</th>
<th>完成时间</th> <th scope="col">创建时间</th>
<th scope="col">完成时间</th>
</tr> </tr>
<!-- 使用forEach循环来遍历订单列表 --> </thead>
<tbody>
<c:forEach items="${orders}" var="order"> <c:forEach items="${orders}" var="order">
<tr> <tr>
<td>${order.orderId}</td> <td>${order.orderId}</td>
<td>${order.deviceId}</td> <td>${order.deviceId}</td>
<td>${order.studentId}</td> <td>${order.studentId}</td>
<td>${order.contact}</td>
<td>${order.phone}</td> <td>${order.phone}</td>
<td>${order.address}</td> <td>${order.address}</td>
<td>${order.contact}</td> <td>${order.faultDesc}</td>
<td>${order.faultImg}</td> <td>${order.faultImg}</td>
<td>${order.orderStatus}</td> <td>
<a class="aButton" href="${webroot}/updateOrderStatus?orderId=${order.orderId}">
${order.orderStatus == 1 ? '未完成' : '已完成'}
</a>
</td>
<td>${order.createTime}</td> <td>${order.createTime}</td>
<td>${order.finishTime}</td> <td>${order.finishTime}</td>
<!-- 添加其他订单信息的列 -->
</tr> </tr>
</c:forEach> </c:forEach>
</tbody>
</table> </table>
</c:when>
<c:otherwise>
<div class="alert alert-primary square-alert" role="alert">
现在还没有维修任务,好好休息吧!!!
</div>
</c:otherwise>
</c:choose>
</div>
</main>
</main>
<%--<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>--%>
<%--<script>--%>
<%-- $(document).ready(function () {--%>
<%-- $('.status-btn').click(function () {--%>
<%-- var orderId = $(this).data('order-id');--%>
<%-- var currentStatus = $(this).data('current-status');--%>
<%-- var newStatus = currentStatus === 0 ? 1 : 0; // 切换状态0表示未完成1表示已完成--%>
<%-- var requestData = {--%>
<%-- orderId: orderId,--%>
<%-- newStatus: newStatus--%>
<%-- };--%>
<%-- $.ajax({--%>
<%-- type: 'POST',--%>
<%-- url: '/updateOrderStatus', // 替换成你的后端处理更新订单状态的接口地址--%>
<%-- data: requestData,--%>
<%-- success: function (response) {--%>
<%-- // 更新按钮文本和数据属性--%>
<%-- if (newStatus === 1) {--%>
<%-- $(this).text('未完成').data('current-status', 1);--%>
<%-- } else {--%>
<%-- $(this).text('已完成').data('current-status', 1);--%>
<%-- }--%>
<%-- },--%>
<%-- error: function () {--%>
<%-- alert('更新订单状态失败');--%>
<%-- }--%>
<%-- });--%>
<%-- });--%>
<%-- });--%>
<%--</script>--%>
</body> </body>
</html> </html>

View File

@ -5,12 +5,149 @@
Time: 21:41 Time: 21:41
To change this template use File | Settings | File Templates. To change this template use File | Settings | File Templates.
--%> --%>
<%--
Created by IntelliJ IDEA.
User: sobear
Date: 2024/5/12
Time: 21:41
To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %> <%@ 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="历史订单列表"/>
<html> <html>
<head> <head>
<title>Title</title> <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">
<style>
.aButton{
cursor: pointer;
display: inline-block;
text-align: center;
white-space: nowrap;
background: #0071e3;
color: #fff;
border-radius: 980px;
font-size: 12px;
line-height: 1.33337;
font-weight: 400;
letter-spacing: -.01em;
font-family: "SF Pro Text","SF Pro Icons","Helvetica Neue","Helvetica","Arial",sans-serif;
min-width: 23px;
padding-left: 11px;
padding-right: 11px;
padding-top: 4px;
padding-bottom: 4px;
}
.alert{
text-align: center;
}
</style>
</head> </head>
<body> <body>
<p>这是历史维修记录</p> <main class="d-flex flex-nowrap">
<%@ include file="../includes/header.jsp" %>
<main class="w-100 m-auto">
<c:choose>
<c:when test="${not empty requestScope.orders}">
${requestScope.workerListStatusMes}
<div class="table-responsive">
<table class="table align-middle">
<thead>
<tr>
<th scope="col">订单ID</th>
<th scope="col">设备ID</th>
<th scope="col">联系人ID</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>
</thead>
<tbody>
<c:forEach items="${orders}" var="order">
<tr>
<td>${order.orderId}</td>
<td>${order.deviceId}</td>
<td>${order.studentId}</td>
<td>${order.contact}</td>
<td>${order.phone}</td>
<td>${order.address}</td>
<td>${order.faultDesc}</td>
<td>${order.faultImg}</td>
<td>已完成</td>
<td>${order.createTime}</td>
<td>${order.finishTime}</td>
<!-- 添加其他订单信息的列 -->
</tr>
</c:forEach>
</tbody>
</table>
</c:when>
<c:otherwise>
<div class="alert alert-primary square-alert" role="alert">
继续加油吧,你还没有完成维修任务!!!
</div>
</c:otherwise>
</c:choose>
</div>
</main>
</main>
<%--<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>--%>
<%--<script>--%>
<%-- $(document).ready(function () {--%>
<%-- $('.status-btn').click(function () {--%>
<%-- var orderId = $(this).data('order-id');--%>
<%-- var currentStatus = $(this).data('current-status');--%>
<%-- var newStatus = currentStatus === 0 ? 1 : 0; // 切换状态0表示未完成1表示已完成--%>
<%-- var requestData = {--%>
<%-- orderId: orderId,--%>
<%-- newStatus: newStatus--%>
<%-- };--%>
<%-- $.ajax({--%>
<%-- type: 'POST',--%>
<%-- url: '/updateOrderStatus', // 替换成你的后端处理更新订单状态的接口地址--%>
<%-- data: requestData,--%>
<%-- success: function (response) {--%>
<%-- // 更新按钮文本和数据属性--%>
<%-- if (newStatus === 1) {--%>
<%-- $(this).text('未完成').data('current-status', 1);--%>
<%-- } else {--%>
<%-- $(this).text('已完成').data('current-status', 1);--%>
<%-- }--%>
<%-- },--%>
<%-- error: function () {--%>
<%-- alert('更新订单状态失败');--%>
<%-- }--%>
<%-- });--%>
<%-- });--%>
<%-- });--%>
<%--</script>--%>
</body> </body>
</html> </html>