mirror of
https://github.com/FatttSnake/ClassroomInteraction.git
synced 2026-04-06 05:31:26 +08:00
TeacherUI:The test of selectStudent and modify teacherPassword was completed
MessageObject: Adding attStat
This commit is contained in:
@@ -1,5 +1,7 @@
|
|||||||
package com.cfive.classroom.library.net.util;
|
package com.cfive.classroom.library.net.util;
|
||||||
|
|
||||||
|
import com.cfive.classroom.library.database.bean.AttStatus;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
|
||||||
public class MessageObject implements Serializable {
|
public class MessageObject implements Serializable {
|
||||||
@@ -8,14 +10,16 @@ public class MessageObject implements Serializable {
|
|||||||
private String code;
|
private String code;
|
||||||
private String count;
|
private String count;
|
||||||
private String message;
|
private String message;
|
||||||
|
private AttStatus attStatus;
|
||||||
private MessageType messageType;
|
private MessageType messageType;
|
||||||
|
|
||||||
public MessageObject(String stuNo, String name, String code, String message,String count,MessageType messageType) {
|
public MessageObject(String stuNo, String name, String code, String message,String count,AttStatus attStatus,MessageType messageType) {
|
||||||
this.stuNo = stuNo;
|
this.stuNo = stuNo;
|
||||||
this.stuName = name;
|
this.stuName = name;
|
||||||
this.code = code;
|
this.code = code;
|
||||||
this.message = message;
|
this.message = message;
|
||||||
this.count = count;
|
this.count = count;
|
||||||
|
this.attStatus=attStatus;
|
||||||
this.messageType=messageType;
|
this.messageType=messageType;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -51,6 +55,14 @@ public class MessageObject implements Serializable {
|
|||||||
this.count = count;
|
this.count = count;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public AttStatus getAttStatus() {
|
||||||
|
return attStatus;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAttStatus(AttStatus attStatus) {
|
||||||
|
this.attStatus = attStatus;
|
||||||
|
}
|
||||||
|
|
||||||
public String getMessage() {
|
public String getMessage() {
|
||||||
return message;
|
return message;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,15 @@
|
|||||||
package com.cfive.classroom.teacher;
|
package com.cfive.classroom.teacher;
|
||||||
|
|
||||||
|
import com.cfive.classroom.library.database.DatabaseHelper;
|
||||||
|
import com.cfive.classroom.library.database.bean.AttStatus;
|
||||||
|
import com.cfive.classroom.library.database.bean.Course;
|
||||||
|
import com.cfive.classroom.library.database.bean.Student;
|
||||||
|
import com.cfive.classroom.library.database.util.DependenciesNotFoundException;
|
||||||
|
import com.cfive.classroom.library.database.util.NoConfigException;
|
||||||
import com.cfive.classroom.library.net.TeacherNet;
|
import com.cfive.classroom.library.net.TeacherNet;
|
||||||
|
import com.cfive.classroom.library.net.util.MessageObject;
|
||||||
|
import com.cfive.classroom.library.net.util.MessageType;
|
||||||
|
import com.cfive.classroom.library.net.util.ReceiveListener;
|
||||||
import org.apache.logging.log4j.LogManager;
|
import org.apache.logging.log4j.LogManager;
|
||||||
import org.apache.logging.log4j.Logger;
|
import org.apache.logging.log4j.Logger;
|
||||||
|
|
||||||
@@ -11,6 +20,9 @@ import javax.swing.event.TableModelEvent;
|
|||||||
import javax.swing.event.TableModelListener;
|
import javax.swing.event.TableModelListener;
|
||||||
import javax.swing.table.*;
|
import javax.swing.table.*;
|
||||||
import java.awt.event.ComponentAdapter;
|
import java.awt.event.ComponentAdapter;
|
||||||
|
import java.sql.SQLException;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public class Attendance {
|
public class Attendance {
|
||||||
private static final Attendance attendance=new Attendance();
|
private static final Attendance attendance=new Attendance();
|
||||||
@@ -24,9 +36,32 @@ public class Attendance {
|
|||||||
private JTable table_undo;
|
private JTable table_undo;
|
||||||
private JLabel test;
|
private JLabel test;
|
||||||
private TeacherNet teacherNet;
|
private TeacherNet teacherNet;
|
||||||
|
private String courseID;
|
||||||
|
private final List<Student> studentList = new ArrayList<>();
|
||||||
private static final Logger LOGGER= LogManager.getLogger();
|
private static final Logger LOGGER= LogManager.getLogger();
|
||||||
|
|
||||||
public Attendance() {
|
public Attendance() {
|
||||||
|
//学生签到信息监听
|
||||||
|
teacherNet.setOnReceiveListener(new ReceiveListener() {
|
||||||
|
@Override
|
||||||
|
public void onReceive(MessageObject messageObject) {
|
||||||
|
//判断该信息类型是否为签到并且签到状态是否为已签
|
||||||
|
if(messageObject.getMessageType()== MessageType.CheckIn&&messageObject.getAttStatus()==AttStatus.signed){
|
||||||
|
try {
|
||||||
|
//将学生签到状态修改进数据表中
|
||||||
|
DatabaseHelper.updateAttendance(messageObject.getStuNo(), messageObject.getAttStatus());
|
||||||
|
} catch (NoConfigException e) {
|
||||||
|
JOptionPane.showMessageDialog(null,"没有数据库配置文件","警告",JOptionPane.ERROR_MESSAGE);
|
||||||
|
LOGGER.error("No configuration", e);
|
||||||
|
} catch (SQLException e) {
|
||||||
|
JOptionPane.showMessageDialog(null,"数据库出错","警告",JOptionPane.ERROR_MESSAGE);
|
||||||
|
LOGGER.error("SQLException",e);
|
||||||
|
} catch (DependenciesNotFoundException e) {
|
||||||
|
LOGGER.error("DependenciesNotFoundException",e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
table_undo.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
|
table_undo.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
|
||||||
@@ -37,10 +72,6 @@ public class Attendance {
|
|||||||
String newString=table_undo.getValueAt(row,2).toString();
|
String newString=table_undo.getValueAt(row,2).toString();
|
||||||
attendance.test.setText(newString);
|
attendance.test.setText(newString);
|
||||||
LOGGER.info(newString);
|
LOGGER.info(newString);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -54,15 +85,27 @@ public class Attendance {
|
|||||||
frame.setVisible(false);
|
frame.setVisible(false);
|
||||||
|
|
||||||
}
|
}
|
||||||
public void start(TeacherNet teacherNet1){
|
public void start(TeacherNet teacherNet1,String courseID){
|
||||||
frame.setContentPane(attendance.rootPanel);
|
frame.setContentPane(attendance.rootPanel);
|
||||||
frame.setSize(600,400);
|
frame.setSize(600,400);
|
||||||
frame.setLocationRelativeTo(null);
|
frame.setLocationRelativeTo(null);
|
||||||
frame.setResizable(false);
|
frame.setResizable(false);
|
||||||
attendance.teacherNet=teacherNet1;
|
attendance.teacherNet=teacherNet1;
|
||||||
|
attendance.courseID=courseID;
|
||||||
|
try {
|
||||||
|
studentList.addAll(DatabaseHelper.selectStudentsFromCourse(Long.parseLong(courseID))); //导入该课程学生名单
|
||||||
|
} catch (DependenciesNotFoundException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
} catch (NoConfigException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
} catch (SQLException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
//已签考勤表格
|
||||||
DefaultTableModel alreadyTableModel=new DefaultTableModel(data,t1_columnTitle);
|
DefaultTableModel alreadyTableModel=new DefaultTableModel(data,t1_columnTitle);
|
||||||
alreadyTableModel.setColumnCount(3);
|
alreadyTableModel.setColumnCount(3);
|
||||||
attendance.table_already.setModel(alreadyTableModel);
|
attendance.table_already.setModel(alreadyTableModel);
|
||||||
|
//未签考勤表格
|
||||||
DefaultTableModel undoTableModel=new DefaultTableModel(data,t2_columnTitle);
|
DefaultTableModel undoTableModel=new DefaultTableModel(data,t2_columnTitle);
|
||||||
undoTableModel.setColumnCount(3);
|
undoTableModel.setColumnCount(3);
|
||||||
attendance.table_undo.setModel(undoTableModel);
|
attendance.table_undo.setModel(undoTableModel);
|
||||||
|
|||||||
@@ -29,7 +29,8 @@ public class ChangePassword {
|
|||||||
if(check()){
|
if(check()){
|
||||||
//将修改后的密码在数据表修改
|
//将修改后的密码在数据表修改
|
||||||
try {
|
try {
|
||||||
DatabaseHelper.changePasswdInTeacher(Long.valueOf(workNo_input.getText()),newPw_ok.getPassword().toString());
|
DatabaseHelper.changePasswdInTeacher(Long.valueOf(workNo_input.getText()),String.valueOf(newPw_ok.getPassword()));
|
||||||
|
LOGGER.debug(String.valueOf(newPw_ok.getPassword()));
|
||||||
} catch (NoConfigException ex) {
|
} catch (NoConfigException ex) {
|
||||||
JOptionPane.showMessageDialog(null,"没有数据库配置文件","警告",JOptionPane.ERROR_MESSAGE);
|
JOptionPane.showMessageDialog(null,"没有数据库配置文件","警告",JOptionPane.ERROR_MESSAGE);
|
||||||
LOGGER.error("No configuration", e);
|
LOGGER.error("No configuration", e);
|
||||||
|
|||||||
@@ -18,10 +18,7 @@ import java.awt.event.ActionEvent;
|
|||||||
import java.awt.event.ActionListener;
|
import java.awt.event.ActionListener;
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.util.Arrays;
|
import java.util.*;
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Properties;
|
|
||||||
|
|
||||||
public class Main {
|
public class Main {
|
||||||
private static final Main main = new Main();
|
private static final Main main = new Main();
|
||||||
@@ -36,7 +33,7 @@ public class Main {
|
|||||||
private JTextField workNo_show;
|
private JTextField workNo_show;
|
||||||
private JTextField subName_show;
|
private JTextField subName_show;
|
||||||
private String workNo,courseID;
|
private String workNo,courseID;
|
||||||
private List<Student> studentList;
|
private final List<Student> studentList = new ArrayList<>();;
|
||||||
private String[] student;
|
private String[] student;
|
||||||
private TeacherNet teacherNet;
|
private TeacherNet teacherNet;
|
||||||
private final Logger LOGGER = LogManager.getLogger();
|
private final Logger LOGGER = LogManager.getLogger();
|
||||||
@@ -82,7 +79,7 @@ public class Main {
|
|||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
Attendance attendance = new Attendance();
|
Attendance attendance = new Attendance();
|
||||||
attendance.start(teacherNet);
|
attendance.start(teacherNet,courseID);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -100,7 +97,7 @@ public class Main {
|
|||||||
String[] arr = new String[i]; //new一个该数长度的String数组
|
String[] arr = new String[i]; //new一个该数长度的String数组
|
||||||
|
|
||||||
try {
|
try {
|
||||||
studentList = DatabaseHelper.selectStudentsFromCourse(Long.parseLong(courseID));
|
studentList.addAll(DatabaseHelper.selectStudentsFromCourse(Long.parseLong(courseID)));
|
||||||
if (!studentList.isEmpty()) { //判断是否获取到学生名单
|
if (!studentList.isEmpty()) { //判断是否获取到学生名单
|
||||||
LOGGER.info("学生列表" + studentList);
|
LOGGER.info("学生列表" + studentList);
|
||||||
for (int j = 0; j < i; ) {
|
for (int j = 0; j < i; ) {
|
||||||
@@ -128,7 +125,7 @@ public class Main {
|
|||||||
}
|
}
|
||||||
JOptionPane.showMessageDialog(null, "恭喜以下同学被选中:\n\t\n" + count);
|
JOptionPane.showMessageDialog(null, "恭喜以下同学被选中:\n\t\n" + count);
|
||||||
//将选人结果群发出去
|
//将选人结果群发出去
|
||||||
teacherNet.sendAllMessage(new MessageObject(null, null, null, null, count, MessageType.Select));
|
teacherNet.sendAllMessage(new MessageObject(null, null, null, null, count, null,MessageType.Select));
|
||||||
}else {
|
}else {
|
||||||
JOptionPane.showMessageDialog(null, "学生名单未导入", "错误", JOptionPane.ERROR_MESSAGE);
|
JOptionPane.showMessageDialog(null, "学生名单未导入", "错误", JOptionPane.ERROR_MESSAGE);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ public class SendMessage {
|
|||||||
if(messageToAll!=null){
|
if(messageToAll!=null){
|
||||||
SimpleDateFormat sendTime = new SimpleDateFormat("yyyy年MM月dd日 HH时mm分ss秒");
|
SimpleDateFormat sendTime = new SimpleDateFormat("yyyy年MM月dd日 HH时mm分ss秒");
|
||||||
messageShow.append("@所有人: "+sendTime.format(System.currentTimeMillis())+'\n'+messageToAll+'\n');
|
messageShow.append("@所有人: "+sendTime.format(System.currentTimeMillis())+'\n'+messageToAll+'\n');
|
||||||
MessageObject messageObject = new MessageObject(null,null,null,"@所有人:"+messageToAll,null, MessageType.ChatToAll);
|
MessageObject messageObject = new MessageObject(null,null,null,"@所有人:"+messageToAll,null,null,MessageType.ChatToAll);
|
||||||
teacherNet.sendAllMessage(messageObject);
|
teacherNet.sendAllMessage(messageObject);
|
||||||
messageInput.setText("");
|
messageInput.setText("");
|
||||||
}else {
|
}else {
|
||||||
|
|||||||
Reference in New Issue
Block a user