From 37e539727da6fa5ddd716df77e7ac5f4f2275325 Mon Sep 17 00:00:00 2001 From: sobear <410731299@qq.com> Date: Fri, 7 Jun 2024 00:02:35 +0800 Subject: [PATCH] add worker evalueReport --- .../worker/WorkerEvalueReportController.java | 70 ++++++++++++++++ .../java/cn/edu/cqwu/repair/dao/OrderDao.java | 2 + .../cqwu/repair/dao/impl/OrderDaoImpl.java | 7 ++ .../cqwu/repair/dao/impl/WorkerDaoImpl.java | 2 + .../cn/edu/cqwu/repair/entity/ScoreDates.java | 74 ++++++++++++++++ src/main/webapp/includes/menu.jsp | 3 + .../webapp/worker/worker_evalue_report.jsp | 84 +++++++++++++++++++ 7 files changed, 242 insertions(+) create mode 100644 src/main/java/cn/edu/cqwu/repair/controller/worker/WorkerEvalueReportController.java create mode 100644 src/main/java/cn/edu/cqwu/repair/entity/ScoreDates.java create mode 100644 src/main/webapp/worker/worker_evalue_report.jsp diff --git a/src/main/java/cn/edu/cqwu/repair/controller/worker/WorkerEvalueReportController.java b/src/main/java/cn/edu/cqwu/repair/controller/worker/WorkerEvalueReportController.java new file mode 100644 index 0000000..4fee378 --- /dev/null +++ b/src/main/java/cn/edu/cqwu/repair/controller/worker/WorkerEvalueReportController.java @@ -0,0 +1,70 @@ +package cn.edu.cqwu.repair.controller.worker; + +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.entity.ScoreDates; +import cn.edu.cqwu.repair.entity.Worker; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; +import org.springframework.web.bind.annotation.RequestMapping; + +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpSession; +import java.util.List; + + + +/** + * @author sobear + */ +@Controller +public class WorkerEvalueReportController extends HttpServlet{ + private final OrderDao orderDao; + private final WorkerDao workerDao; + + @Autowired + public WorkerEvalueReportController(OrderDao orderDao,WorkerDao workerDao){ + this.orderDao = orderDao; + this.workerDao = workerDao; + } + + @RequestMapping ("/worker/EvalueReport.do") + public String getScore(Model model, HttpSession session, + HttpServletRequest request){ + // 获取Session对象 + session = request.getSession(); + + // 从Session中获取ID数据 + Worker workerUser = (Worker) session.getAttribute("workerUser"); + // 调用DAO的方法来获取数据库中的该员工的历史订单数据 + List orders = (List) orderDao.findByWorkerNoStatus(workerUser.getUserid()); + + int num12 = 0; // 记录score为1~2之间的数量 + int num3 = 0; // 记录score为3之间的数量 + int num45 = 0; // 记录score为4~5之间的数量 + int numTotal = orders.size(); // 记录总数 + int totalScore = 0; // 记录总分数 + + for (Order order : orders) { + int score = order.getScore(); + totalScore += score; + if (score >= 1 && score <= 2) { + num12++; + } else if (score == 3) { + num3++; + } else if (score >= 4 && score <= 5) { + num45++; + } + } + + double numAverage = (double) totalScore / numTotal; // 平均数 + ScoreDates scDatas = new ScoreDates(num12,num3,num45,numTotal,totalScore,numAverage); + model.addAttribute("scDatas",scDatas); + + return "/worker/worker_evalue_report"; + } + +} diff --git a/src/main/java/cn/edu/cqwu/repair/dao/OrderDao.java b/src/main/java/cn/edu/cqwu/repair/dao/OrderDao.java index d5b0fa1..2a4edd2 100644 --- a/src/main/java/cn/edu/cqwu/repair/dao/OrderDao.java +++ b/src/main/java/cn/edu/cqwu/repair/dao/OrderDao.java @@ -15,6 +15,8 @@ public interface OrderDao { ArrayList findByWorkerId(int workerId); ArrayList findByStatus(int status); + ArrayList findByWorkerNoStatus(int status); + public int statusModify(int orderId); public Order findByOrderId(int orderId); diff --git a/src/main/java/cn/edu/cqwu/repair/dao/impl/OrderDaoImpl.java b/src/main/java/cn/edu/cqwu/repair/dao/impl/OrderDaoImpl.java index f19b956..2a46856 100644 --- a/src/main/java/cn/edu/cqwu/repair/dao/impl/OrderDaoImpl.java +++ b/src/main/java/cn/edu/cqwu/repair/dao/impl/OrderDaoImpl.java @@ -71,6 +71,13 @@ public class OrderDaoImpl implements OrderDao { return (ArrayList) mapper.selectListByQuery(qw); } + @Override + public ArrayList findByWorkerNoStatus(int workerId){ + QueryWrapper qw = new QueryWrapper(); + qw.select(ORDER.ALL_COLUMNS).where(ORDER.WORKER_ID.eq(workerId)); + return (ArrayList) mapper.selectListByQuery(qw); + } + @Override public ArrayList findByStatus(int status) { QueryWrapper qw = new QueryWrapper(); diff --git a/src/main/java/cn/edu/cqwu/repair/dao/impl/WorkerDaoImpl.java b/src/main/java/cn/edu/cqwu/repair/dao/impl/WorkerDaoImpl.java index cc16ba8..6bac312 100644 --- a/src/main/java/cn/edu/cqwu/repair/dao/impl/WorkerDaoImpl.java +++ b/src/main/java/cn/edu/cqwu/repair/dao/impl/WorkerDaoImpl.java @@ -89,4 +89,6 @@ public class WorkerDaoImpl implements WorkerDao { qw.where(WORKER.ORDER_STATUS.eq(WorkerStatus.FREE.value)).where(WORKER.TYPE_ID.eq(typeId)); return MAPPER.selectOneByQuery(qw); } + + } diff --git a/src/main/java/cn/edu/cqwu/repair/entity/ScoreDates.java b/src/main/java/cn/edu/cqwu/repair/entity/ScoreDates.java new file mode 100644 index 0000000..439c547 --- /dev/null +++ b/src/main/java/cn/edu/cqwu/repair/entity/ScoreDates.java @@ -0,0 +1,74 @@ +package cn.edu.cqwu.repair.entity; + +public class ScoreDates { + private int num12; // 记录score为1~2之间的数量 + private int num3; // 记录score为3之间的数量 + private int num45; // 记录score为4~5之间的数量 + private int numTotal; // 记录总数 + private int totalScore; // 记录总分数 + + private double numAverage;//记录平均数 + + // 构造函数 + public ScoreDates(int num12, int num3, int num45, int numTotal, int totalScore,double numAverage) { + this.num12 = num12; + this.num3 = num3; + this.num45 = num45; + this.numTotal = numTotal; + this.totalScore = totalScore; + this.numAverage = numAverage; + } + + // Getter 和 Setter 方法 + public double getnumAverage() { + return numAverage; + } + + public void setnumAverage(double numAverage) { + this.numAverage = numAverage; + } + public int getNum12() { + return num12; + } + + public void setNum12(int num12) { + this.num12 = num12; + } + + public int getNum3() { + return num3; + } + + public void setNum3(int num3) { + this.num3 = num3; + } + + public int getNum45() { + return num45; + } + + public void setNum45(int num45) { + this.num45 = num45; + } + + public int getNumTotal() { + return numTotal; + } + + public void setNumTotal(int numTotal) { + this.numTotal = numTotal; + } + + public int getTotalScore() { + return totalScore; + } + + public void setTotalScore(int totalScore) { + this.totalScore = totalScore; + } + + @Override + public String toString() { + return "{num12: "+num12 + ",num3:" + num3 + ",num45:" + num45 + ",numAverage: " + numAverage + ",}"; + } +} diff --git a/src/main/webapp/includes/menu.jsp b/src/main/webapp/includes/menu.jsp index da82859..cfb4868 100644 --- a/src/main/webapp/includes/menu.jsp +++ b/src/main/webapp/includes/menu.jsp @@ -100,6 +100,9 @@ >> 维修列表 + + >> 订单满意度 + >> 历史维修记录 diff --git a/src/main/webapp/worker/worker_evalue_report.jsp b/src/main/webapp/worker/worker_evalue_report.jsp new file mode 100644 index 0000000..0ca85c8 --- /dev/null +++ b/src/main/webapp/worker/worker_evalue_report.jsp @@ -0,0 +1,84 @@ +<%-- + Created by IntelliJ IDEA. + User: sobear + Date: 2024/6/6 + Time: 21:58 + 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" %> + + + + + + ${title} + + + + + + + +
+ <%@ include file="../includes/header.jsp" %> + +
+ + + +
+ +
+ + + + + + +