From a27c053a00bcd6468dc88d01d9f5bc0dff97d5c1 Mon Sep 17 00:00:00 2001 From: pd <2776455882@qq.com> Date: Fri, 14 Aug 2020 14:32:39 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=9E=E9=AA=8C=E7=8F=AD=E7=BA=A7=E6=9F=A5?= =?UTF-8?q?=E8=AF=A2=E8=80=83=E5=8B=A4=E6=AC=A1=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mapper/ExperimentalClassMapper.java | 6 +-- .../service/ExperimentalClassService.java | 4 +- .../service/ExperimentallearningService.java | 4 ++ src/test/java/com/yipin/liuwanr/Mian.java | 52 +++++++++++++++++++ 4 files changed, 61 insertions(+), 5 deletions(-) create mode 100644 src/test/java/com/yipin/liuwanr/Mian.java diff --git a/src/main/java/com/yipin/liuwanr/mapper/ExperimentalClassMapper.java b/src/main/java/com/yipin/liuwanr/mapper/ExperimentalClassMapper.java index 2debfb9..016c618 100644 --- a/src/main/java/com/yipin/liuwanr/mapper/ExperimentalClassMapper.java +++ b/src/main/java/com/yipin/liuwanr/mapper/ExperimentalClassMapper.java @@ -103,9 +103,9 @@ public interface ExperimentalClassMapper { * 学生签到次数 * @return */ - @Select("select COUNT(a.experimentId) from attendance a,hr_project_management p,hr_course_tc tc where p.projectId=tc.projectId and p.projectId=a.experimentId and a.courseId=tc.courseId \n" + - "and p.isdel=0 and p.projectPermissions=0 and p.isAttendance=0 and tc.courseId=#{courseId} and a.studentId=#{studentId}") - Integer getAttendance(@Param("studentId")Integer studentId,@Param("courseId")Integer courseId); + @Select("select count(a.id) from attendance a left join teacher_project tp on (a.experimentalClassId=tp.experimentalClassId and a.experimentId=tp.projectId) " + + " where a.studentId=#{studentId} and a.experimentalClassId=#{experimentalClassId} and tp.courseId=#{courseId} and tp.isAttendance=1") + Integer getAttendance(@Param("studentId")Integer studentId,@Param("courseId")Integer courseId,@Param("experimentalClassId") Integer experimentalClassId); /** diff --git a/src/main/java/com/yipin/liuwanr/service/ExperimentalClassService.java b/src/main/java/com/yipin/liuwanr/service/ExperimentalClassService.java index e517af5..56c1d3e 100644 --- a/src/main/java/com/yipin/liuwanr/service/ExperimentalClassService.java +++ b/src/main/java/com/yipin/liuwanr/service/ExperimentalClassService.java @@ -157,13 +157,13 @@ public class ExperimentalClassService { Integer experimentalClassId = Integer.parseInt(student.getExperimentalClassId()); //学生信息 List students = experimentalClassMapper.getExperimentalClassDetails(student); - //考勤数量 + //考勤总数量数量 List project = projectAndCourseMapper.getBySystemId(courseId, experimentalClassId); int denominator = project.size(); for (int i = 0; i < students.size(); i++) { Student stu = students.get(i); Integer studentId = stu.getStudentId(); - int molecule = experimentalClassMapper.getAttendance(studentId, courseId); + int molecule = experimentalClassMapper.getAttendance(studentId, courseId,experimentalClassId); stu.setAttendance(molecule + "/" + denominator); } resp.put("retvalue", students); diff --git a/src/main/java/com/yipin/liuwanr/service/ExperimentallearningService.java b/src/main/java/com/yipin/liuwanr/service/ExperimentallearningService.java index d82bd64..0c06874 100644 --- a/src/main/java/com/yipin/liuwanr/service/ExperimentallearningService.java +++ b/src/main/java/com/yipin/liuwanr/service/ExperimentallearningService.java @@ -77,6 +77,10 @@ public class ExperimentallearningService { HashMap resp = new HashMap(); try { Attendance attendance2 = mapper.getByProjectIdAndStudentId(attendance); + Integer courseId = attendance.getCourseId(); + Integer studentId = attendance.getStudentId(); + Integer experimentalClassId=mapper.queryExperimentalClassId(courseId,studentId); + attendance.setExperimentalClassId(experimentalClassId); if (null != attendance2 && attendance2.getSignIn() == 1) { // 修改考勤状态 attendance2.setSignIn(attendance.getSignIn()); diff --git a/src/test/java/com/yipin/liuwanr/Mian.java b/src/test/java/com/yipin/liuwanr/Mian.java new file mode 100644 index 0000000..e18c8fc --- /dev/null +++ b/src/test/java/com/yipin/liuwanr/Mian.java @@ -0,0 +1,52 @@ +package com.yipin.liuwanr; + +import org.apache.commons.lang3.StringUtils; + +import java.util.ArrayList; +import java.util.List; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +public class Mian { + + public static void main(String[] args) { + //将字符串与正式表达式进行匹配 + //start()返回匹配到的子字符串在字符串中的索引位置. + //end()返回匹配到的子字符串的最后一个字符在字符串中的索引位置. + //group()返回匹配到的子字符串 + + String[] arg = {"5"};//前端【输入框输入的数据】 + + //【代码】 + String str="i = input(\"请输入\")\n" + + "b = input(\"请输入\")"; + + StringBuilder builder = new StringBuilder(str); + String regex = "input\\((.*?)\\)"; + Pattern pattern = Pattern.compile(regex); + Matcher m = pattern.matcher(builder); + int j = 0; + while (m.find()) { + if(j