Merge branch 'master' of https://git.xtaolabs.com/xtaodada/java_web_repair
This commit is contained in:
commit
5f63b16145
@ -0,0 +1,74 @@
|
||||
package cn.edu.cqwu.repair.controller.admin;
|
||||
|
||||
import cn.edu.cqwu.repair.dao.OrderDao;
|
||||
import cn.edu.cqwu.repair.dao.WorkerDao;
|
||||
import cn.edu.cqwu.repair.entity.Order;
|
||||
import cn.edu.cqwu.repair.service.OrderService;
|
||||
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 AdminOrderController {
|
||||
OrderDao orderDao;
|
||||
WorkerDao workerDao;
|
||||
OrderService orderService;
|
||||
|
||||
public AdminOrderController(OrderDao orderDao, WorkerDao workerDao, OrderService orderService) {
|
||||
this.orderDao = orderDao;
|
||||
this.workerDao = workerDao;
|
||||
this.orderService = orderService;
|
||||
}
|
||||
|
||||
@RequestMapping("/admin/order_manage/manage.do")
|
||||
public String manage(
|
||||
String userNo,
|
||||
String workerNo,
|
||||
String contact,
|
||||
String phone,
|
||||
Model model) {
|
||||
model.addAttribute("userNo", userNo);
|
||||
model.addAttribute("workerNo", workerNo);
|
||||
model.addAttribute("contact", contact);
|
||||
model.addAttribute("phone", phone);
|
||||
if (userNo != null && workerNo != null && contact != null && phone != null) {
|
||||
ArrayList<Order> orders = orderDao.find(userNo, workerNo, contact, phone);
|
||||
model.addAttribute("Orders", orders);
|
||||
} else {
|
||||
model.addAttribute("stuManageMess", "* 请输入查询条件!");
|
||||
}
|
||||
return "/admin/order";
|
||||
}
|
||||
|
||||
@RequestMapping("/admin/order_manage/delete.do")
|
||||
public String delete(int id, Model model) {
|
||||
if (orderDao.delete(id) != 0) {
|
||||
model.addAttribute("orderMess", "* 订单 " + id + " 已删除!");
|
||||
} else {
|
||||
model.addAttribute("orderMess", "* 订单 " + id + " 删除失败!");
|
||||
}
|
||||
return "/admin/order";
|
||||
}
|
||||
|
||||
@RequestMapping("/admin/order_manage/choose.do")
|
||||
public String choose(int id, Model model) {
|
||||
model.addAttribute("id", id);
|
||||
model.addAttribute("workers", workerDao.findAll());
|
||||
return "/admin/order_choose";
|
||||
}
|
||||
|
||||
@RequestMapping("/admin/order_manage/chooseApply.do")
|
||||
public String chooseApply(int id, int workerNo, Model model) {
|
||||
if (orderService.modifyOrderStatus(id, workerNo) != 0) {
|
||||
model.addAttribute("orderMess", "* 订单 " + id + " 已分配给工人 " + workerNo + "!");
|
||||
} else {
|
||||
model.addAttribute("orderMess", "* 订单 " + id + " 分配失败!");
|
||||
}
|
||||
return "/admin/order_choose";
|
||||
}
|
||||
}
|
@ -8,6 +8,8 @@ public interface OrderDao {
|
||||
|
||||
int add(Order order);
|
||||
int update(Order order);
|
||||
int delete(Order order);
|
||||
int delete(int orderId);
|
||||
ArrayList<Order> findByStudent_id(int stuId);
|
||||
ArrayList<Order> findCurrent(int stuId);
|
||||
ArrayList<Order> findByWorkerId(int workerId);
|
||||
@ -17,4 +19,7 @@ public interface OrderDao {
|
||||
public Order findByOrderId(int orderId);
|
||||
|
||||
public ArrayList<Order> findHistoryList(int workerId);
|
||||
|
||||
ArrayList<Order> find(String userNo, String workerNo, String contact, String phone);
|
||||
|
||||
}
|
||||
|
@ -12,6 +12,7 @@ public interface WorkerDao {
|
||||
public ArrayList<Worker> findWorkersLikeUsername(String username);
|
||||
|
||||
ArrayList<Worker> findAll();
|
||||
Worker findByUserId(int userId);
|
||||
|
||||
int deleteByUserName(String username);
|
||||
|
||||
|
@ -13,6 +13,7 @@ import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import static cn.edu.cqwu.repair.entity.table.StuTableDef.STU;
|
||||
import static cn.edu.cqwu.repair.entity.table.WorkerTableDef.WORKER;
|
||||
import static cn.edu.cqwu.repair.entity.table.OrderTableDef.ORDER;
|
||||
|
||||
@ -33,6 +34,20 @@ public class OrderDaoImpl implements OrderDao {
|
||||
return mapper.update(order);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int delete(Order order) {
|
||||
return mapper.delete(order);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int delete(int orderId) {
|
||||
Order order = findByOrderId(orderId);
|
||||
if (order == null) {
|
||||
return 0;
|
||||
}
|
||||
return delete(order);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArrayList<Order> findByStudent_id(int stuId) {
|
||||
QueryWrapper qw = new QueryWrapper();
|
||||
@ -87,4 +102,25 @@ public class OrderDaoImpl implements OrderDao {
|
||||
return (ArrayList<Order>) mapper.selectListByQuery(qw);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArrayList<Order> find(String userNo, String workerNo, String contact, String phone) {
|
||||
QueryWrapper qw = new QueryWrapper();
|
||||
qw.select(ORDER.ALL_COLUMNS);
|
||||
if (userNo != null && !userNo.isEmpty()) {
|
||||
qw.leftJoin(STU).on(ORDER.STUDENT_ID.eq(STU.USERID));
|
||||
qw.where(STU.USER_NO.like(userNo));
|
||||
}
|
||||
if (workerNo != null && !workerNo.isEmpty()) {
|
||||
qw.leftJoin(WORKER).on(ORDER.WORKER_ID.eq(WORKER.USERID));
|
||||
qw.where(WORKER.USER_NO.like(workerNo));
|
||||
}
|
||||
if (contact != null && !contact.isEmpty()) {
|
||||
qw.where(ORDER.CONTACT.like(contact));
|
||||
}
|
||||
if (phone != null && !phone.isEmpty()) {
|
||||
qw.where(ORDER.PHONE.like(phone));
|
||||
}
|
||||
return (ArrayList<Order>) mapper.selectListByQuery(qw);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -59,6 +59,13 @@ public class WorkerDaoImpl implements WorkerDao {
|
||||
return (ArrayList<Worker>) MAPPER.selectAll();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Worker findByUserId(int userId) {
|
||||
QueryWrapper qw = new QueryWrapper();
|
||||
qw.select(WORKER.ALL_COLUMNS).where(WORKER.USERID.eq(userId));
|
||||
return MAPPER.selectOneByQuery(qw);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int deleteByUserName(String username) {
|
||||
QueryWrapper qw = new QueryWrapper();
|
||||
|
@ -1,8 +1,13 @@
|
||||
package cn.edu.cqwu.repair.service;
|
||||
|
||||
import cn.edu.cqwu.repair.entity.Order;
|
||||
import cn.edu.cqwu.repair.entity.Worker;
|
||||
|
||||
/**
|
||||
* @author xtaod
|
||||
*/
|
||||
public interface OrderService {
|
||||
void submitWorkers();
|
||||
int modifyOrderStatus(int orderId, int workerId);
|
||||
int modifyOrderStatus(Order order, Worker worker);
|
||||
}
|
||||
|
@ -42,9 +42,33 @@ public class OrderServiceImpl implements OrderService {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int modifyOrderStatus(int orderId, int workerId) {
|
||||
Order order = orderDao.findByOrderId(orderId);
|
||||
Worker worker = workerDao.findByUserId(workerId);
|
||||
return modifyOrderStatus(order, worker);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int modifyOrderStatus(Order order, Worker worker) {
|
||||
if (order.getWorkerId() != 0) {
|
||||
Worker oldWorker = workerDao.findByUserId(order.getWorkerId());
|
||||
oldWorker.setOrderStatus(WorkerStatus.FREE.value);
|
||||
workerDao.update(oldWorker);
|
||||
System.out.println("修改了 worker " + oldWorker.getUserid() + " - " + oldWorker.getOrderStatus());
|
||||
}
|
||||
order.setWorkerId(worker.getUserid());
|
||||
order.setOrderStatus(OrderStatus.PROGRESS.value);
|
||||
worker.setOrderStatus(WorkerStatus.BUSY.value);
|
||||
workerDao.update(worker);
|
||||
System.out.println("修改了 order " + order.getOrderId() + " - " + order.getOrderStatus());
|
||||
System.out.println("修改了 worker " + worker.getUserid() + " - " + worker.getOrderStatus());
|
||||
return orderDao.update(order);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Async
|
||||
@Scheduled(cron = "0 0/5 * * * ? ")
|
||||
@Scheduled(cron = "0 */5 * * * ? ")
|
||||
public void submitWorkers() {
|
||||
System.out.println("[submitWorkers] start");
|
||||
initDeviceMap();
|
||||
@ -52,13 +76,7 @@ public class OrderServiceImpl implements OrderService {
|
||||
for (Order order: orders) {
|
||||
Worker worker = getFreeWorker(deviceTypeMap.get(order.getDeviceId()));
|
||||
if (worker != null) {
|
||||
order.setWorkerId(worker.getUserid());
|
||||
order.setOrderStatus(OrderStatus.PROGRESS.value);
|
||||
orderDao.update(order);
|
||||
worker.setOrderStatus(WorkerStatus.BUSY.value);
|
||||
workerDao.update(worker);
|
||||
System.out.println("修改了 order " + order.getOrderId() + " - " + order.getOrderStatus());
|
||||
System.out.println("修改了 worker " + worker.getUserid() + " - " + worker.getOrderStatus());
|
||||
modifyOrderStatus(order, worker);
|
||||
}
|
||||
}
|
||||
System.out.println("[submitWorkers] end");
|
||||
|
@ -3,12 +3,15 @@
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:context="http://www.springframework.org/schema/context"
|
||||
xmlns:mvc="http://www.springframework.org/schema/mvc"
|
||||
xmlns:task="http://www.springframework.org/schema/task"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans
|
||||
http://www.springframework.org/schema/beans/spring-beans.xsd
|
||||
http://www.springframework.org/schema/context
|
||||
http://www.springframework.org/schema/context/spring-context.xsd
|
||||
http://www.springframework.org/schema/mvc
|
||||
http://www.springframework.org/schema/mvc/spring-mvc.xsd">
|
||||
http://www.springframework.org/schema/mvc/spring-mvc.xsd
|
||||
http://www.springframework.org/schema/task
|
||||
http://www.springframework.org/schema/task/spring-task.xsd">
|
||||
<context:component-scan base-package="cn.edu.cqwu.repair"/>
|
||||
|
||||
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
|
||||
@ -19,5 +22,15 @@
|
||||
<bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver" />
|
||||
|
||||
<mvc:annotation-driven />
|
||||
|
||||
<task:annotation-driven executor="myExecutor" />
|
||||
|
||||
<bean id="myExecutor" class="org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor">
|
||||
<property name="corePoolSize" value="5" />
|
||||
<property name="maxPoolSize" value="10" />
|
||||
<property name="queueCapacity" value="200" />
|
||||
<property name="ThreadNamePrefix" value="MyExecutor-" />
|
||||
</bean>
|
||||
|
||||
<mvc:default-servlet-handler />
|
||||
</beans>
|
||||
|
114
src/main/webapp/admin/order.jsp
Normal file
114
src/main/webapp/admin/order.jsp
Normal file
@ -0,0 +1,114 @@
|
||||
<%--
|
||||
Created by IntelliJ IDEA.
|
||||
User: xtaod
|
||||
Date: 2024/6/6
|
||||
Time: 下午9:48
|
||||
To change this template use File | Settings | File Templates.
|
||||
--%>
|
||||
<%@ page import="cn.edu.cqwu.repair.entity.Device" %>
|
||||
<%@ 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="title" value="维修单维护"/>
|
||||
<c:set var="webroot" value="${pageContext.request.contextPath}"/>
|
||||
<c:set var="repairOrder" value="${requestScope.Orders}"/>
|
||||
<html>
|
||||
<head>
|
||||
<link rel="stylesheet" href="${webroot}/styles/bootstrap.min.css">
|
||||
|
||||
|
||||
<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 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">${title}</h1>
|
||||
<c:if test="${not empty requestScope.orderMess}">
|
||||
<div class="alert alert-warning" role="alert">
|
||||
${requestScope.orderMess}
|
||||
</div>
|
||||
</c:if>
|
||||
|
||||
<form action="${webroot}/admin/order_manage/manage.do" method="post">
|
||||
<div class="input-group mb-3">
|
||||
<span class="input-group-text">学号</span>
|
||||
<input type="text" class="form-control" name="userNo" id="userNo" value="${userNo}">
|
||||
</div>
|
||||
<div class="input-group mb-3">
|
||||
<span class="input-group-text">工号</span>
|
||||
<input type="text" class="form-control" name="workerNo" id="workerNo" value="${workerNo}">
|
||||
</div>
|
||||
<div class="input-group mb-3">
|
||||
<span class="input-group-text">联系人</span>
|
||||
<input type="text" class="form-control" name="contact" id="contact" value="${contact}">
|
||||
</div>
|
||||
<div class="input-group mb-3">
|
||||
<span class="input-group-text">手机号</span>
|
||||
<input type="text" class="form-control" name="phone" id="phone" value="${phone}">
|
||||
</div>
|
||||
<input class="btn btn-primary w-100 py-2" type="submit" id="submit" value="查询">
|
||||
<br/><br/>
|
||||
</form>
|
||||
|
||||
<c:if test="${not empty 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>
|
||||
<c:forEach var="repairOrder" items="${requestScope.Orders}" varStatus="loop">
|
||||
<tr>
|
||||
<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}">
|
||||
待安排维修人员
|
||||
</c:when>
|
||||
<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}/admin/order_manage/choose.do?id=${repairOrder.orderId}">分配</a> |
|
||||
<a href="${webroot}/admin/order_manage/info.do?id=${repairOrder.orderId}">详情</a> |
|
||||
<a href="${webroot}/admin/order_manage/delete.do?id=${repairOrder.orderId}">撤销</a>
|
||||
</td>
|
||||
</tr>
|
||||
</c:forEach>
|
||||
</tbody>
|
||||
</table>
|
||||
</c:if>
|
||||
</main>
|
||||
</main>
|
||||
</body>
|
||||
</html>
|
58
src/main/webapp/admin/order_choose.jsp
Normal file
58
src/main/webapp/admin/order_choose.jsp
Normal file
@ -0,0 +1,58 @@
|
||||
<%--
|
||||
Created by IntelliJ IDEA.
|
||||
User: xtaod
|
||||
Date: 2024/6/6
|
||||
Time: 下午10:18
|
||||
To change this template use File | Settings | File Templates.
|
||||
--%>
|
||||
<%@ page import="cn.edu.cqwu.repair.entity.Device" %>
|
||||
<%@ 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="title" value="维修单维护 - 订单分配"/>
|
||||
<c:set var="webroot" value="${pageContext.request.contextPath}"/>
|
||||
<c:set var="repairOrder" value="${requestScope.Orders}"/>
|
||||
<html>
|
||||
<head>
|
||||
<link rel="stylesheet" href="${webroot}/styles/bootstrap.min.css">
|
||||
|
||||
|
||||
<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 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">${title}</h1>
|
||||
<c:if test="${not empty requestScope.orderMess}">
|
||||
<div class="alert alert-warning" role="alert">
|
||||
${requestScope.orderMess}
|
||||
</div>
|
||||
</c:if>
|
||||
|
||||
<form action="${webroot}/admin/order_manage/chooseApply.do?id=${id}" method="post">
|
||||
<div class="input-group mb-3">
|
||||
<span class="input-group-text">维修人员</span>
|
||||
<select class="form-select" name="workerNo" id="workerNo" required>
|
||||
<c:forEach items="${workers}" var="worker">
|
||||
<option value="${worker.userid}">${worker.username}</option>
|
||||
</c:forEach>
|
||||
</select>
|
||||
</div>
|
||||
<input class="btn btn-primary w-100 py-2" type="submit" id="submit" value="分配">
|
||||
<br/><br/>
|
||||
</form>
|
||||
</main>
|
||||
</main>
|
||||
</body>
|
||||
</html>
|
@ -62,7 +62,7 @@
|
||||
</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a href="${webroot}/admin/state.jsp" class="nav-link link-body-emphasis" aria-current="page">
|
||||
<a href="${webroot}/admin/order.jsp" class="nav-link link-body-emphasis" aria-current="page">
|
||||
>> 维修单管理
|
||||
</a>
|
||||
</li>
|
||||
|
Loading…
Reference in New Issue
Block a user