mirror of
https://github.com/FatttSnake/ClassroomInteraction.git
synced 2026-04-06 02:21:26 +08:00
TeacherUI:JTable completed and modify checkIn code
This commit is contained in:
@@ -28,7 +28,7 @@
|
|||||||
<tabbedpane title="已签"/>
|
<tabbedpane title="已签"/>
|
||||||
</constraints>
|
</constraints>
|
||||||
<properties>
|
<properties>
|
||||||
<enabled value="false"/>
|
<enabled value="true"/>
|
||||||
</properties>
|
</properties>
|
||||||
<border type="none"/>
|
<border type="none"/>
|
||||||
<children>
|
<children>
|
||||||
@@ -63,6 +63,7 @@
|
|||||||
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="4" fill="0" indent="0" use-parent-layout="false"/>
|
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="4" fill="0" indent="0" use-parent-layout="false"/>
|
||||||
</constraints>
|
</constraints>
|
||||||
<properties>
|
<properties>
|
||||||
|
<horizontalAlignment value="0"/>
|
||||||
<text value="刷新"/>
|
<text value="刷新"/>
|
||||||
</properties>
|
</properties>
|
||||||
</component>
|
</component>
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ public class Attend {
|
|||||||
private static final JFrame frame = new JFrame("考勤情况");
|
private static final JFrame frame = new JFrame("考勤情况");
|
||||||
private JPanel rootPanel;
|
private JPanel rootPanel;
|
||||||
private JTabbedPane tabbedPane1;
|
private JTabbedPane tabbedPane1;
|
||||||
private final Object[] t1_columnTitle = {"学号", "姓名", "签到时间"};
|
private final Object[] t1_columnTitle = {"考勤号","学号", "姓名", "签到时间","签到状态"};
|
||||||
private final Object[] t2_columnTitle = {"考勤号", "学号", "姓名", "签到状态"};
|
private final Object[] t2_columnTitle = {"考勤号", "学号", "姓名", "签到状态"};
|
||||||
private JTable table_already;
|
private JTable table_already;
|
||||||
private JTable table_undo;
|
private JTable table_undo;
|
||||||
@@ -50,25 +50,67 @@ public class Attend {
|
|||||||
teacherNet.setOnReceiveListener(new ReceiveListener() {
|
teacherNet.setOnReceiveListener(new ReceiveListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onReceive(MessageObject messageObject) {
|
public void onReceive(MessageObject messageObject) {
|
||||||
//判断该信息类型是否为签到并且签到状态是否为已签
|
if(messageObject.getStuNo()!=null){
|
||||||
if (messageObject.getMessageType() == MessageType.CheckIn && messageObject.getAttStatus() == AttStatus.signed) {
|
//判断该信息类型是否为签到并且签到状态是否为已签
|
||||||
try {
|
if (messageObject.getMessageType() == MessageType.CheckIn && messageObject.getAttStatus() == AttStatus.signed) {
|
||||||
//将学生签到状态修改进数据表中
|
try {
|
||||||
DatabaseHelper.updateAttendance(messageObject.getStuNo(), messageObject.getAttStatus(),messageObject.getLocalDateTime());
|
//将学生签到状态修改进数据表中
|
||||||
} catch (NoConfigException e) {
|
DatabaseHelper.updateAttendance(messageObject.getStuNo(), messageObject.getAttStatus(),messageObject.getLocalDateTime());
|
||||||
JOptionPane.showMessageDialog(null, "没有数据库配置文件", "警告", JOptionPane.ERROR_MESSAGE);
|
} catch (NoConfigException e) {
|
||||||
LOGGER.error("No configuration", e);
|
JOptionPane.showMessageDialog(null, "没有数据库配置文件", "警告", JOptionPane.ERROR_MESSAGE);
|
||||||
} catch (SQLException e) {
|
LOGGER.error("No configuration", e);
|
||||||
JOptionPane.showMessageDialog(null, "数据库出错", "警告", JOptionPane.ERROR_MESSAGE);
|
} catch (SQLException e) {
|
||||||
LOGGER.error("SQLException", e);
|
JOptionPane.showMessageDialog(null, "数据库出错", "警告", JOptionPane.ERROR_MESSAGE);
|
||||||
} catch (DependenciesNotFoundException e) {
|
LOGGER.error("SQLException", e);
|
||||||
LOGGER.error("DependenciesNotFoundException", e);
|
} catch (DependenciesNotFoundException e) {
|
||||||
|
LOGGER.error("DependenciesNotFoundException", e);
|
||||||
|
}
|
||||||
|
//刷新表格
|
||||||
|
bt_refresh.doClick();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//已签表格的鼠标点击事件
|
||||||
|
table_already.addMouseListener(new MouseAdapter() {
|
||||||
|
@Override
|
||||||
|
public void mouseClicked(MouseEvent e) {
|
||||||
|
//获取鼠标所点击的行和列
|
||||||
|
int row = table_already.getSelectedRow();
|
||||||
|
int col = table_already.getSelectedColumn();
|
||||||
|
//修改学生签到状态
|
||||||
|
if (col == 4) {
|
||||||
|
Object[] options = {AttStatus.absence, AttStatus.signed, AttStatus.leave_early, AttStatus.late, AttStatus.personal_leave, AttStatus.public_holiday, AttStatus.sick_leave, AttStatus.not_signed};
|
||||||
|
AttStatus attStatus = (AttStatus) JOptionPane.showInputDialog(null, "选择您所要修改的签到状态", "提示",
|
||||||
|
JOptionPane.PLAIN_MESSAGE, null, options, options[0]);
|
||||||
|
|
||||||
|
if (attStatus != null) {
|
||||||
|
String modifyStat = String.valueOf(attStatus);
|
||||||
|
//将修改后的状态显示出来
|
||||||
|
table_already.getModel().setValueAt(modifyStat, row, col);
|
||||||
|
//将修改在数据库中更改
|
||||||
|
try {
|
||||||
|
DatabaseHelper.updateAttendance(String.valueOf(table_already.getModel().getValueAt(row, 0)), attStatus, null);
|
||||||
|
} catch (NoConfigException ex) {
|
||||||
|
JOptionPane.showMessageDialog(null, "没有数据库配置文件", "警告", JOptionPane.ERROR_MESSAGE);
|
||||||
|
LOGGER.error("No configuration", e);
|
||||||
|
} catch (SQLException ex) {
|
||||||
|
JOptionPane.showMessageDialog(null, "数据库出错", "警告", JOptionPane.ERROR_MESSAGE);
|
||||||
|
LOGGER.error("SQLException", e);
|
||||||
|
} catch (DependenciesNotFoundException ex) {
|
||||||
|
JOptionPane.showMessageDialog(null, "未查询到该数据", "错误", JOptionPane.ERROR_MESSAGE);
|
||||||
|
LOGGER.error("DependenciesNotFoundException", e);
|
||||||
|
}
|
||||||
|
//刷新表格
|
||||||
|
bt_refresh.doClick();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
//未签表格的鼠标点击事件
|
//未签表格的鼠标点击事件
|
||||||
table_undo.addMouseListener(new MouseAdapter() {
|
table_undo.addMouseListener(new MouseAdapter() {
|
||||||
@Override
|
@Override
|
||||||
@@ -100,7 +142,11 @@ public class Attend {
|
|||||||
JOptionPane.showMessageDialog(null, "未查询到该数据", "错误", JOptionPane.ERROR_MESSAGE);
|
JOptionPane.showMessageDialog(null, "未查询到该数据", "错误", JOptionPane.ERROR_MESSAGE);
|
||||||
LOGGER.error("DependenciesNotFoundException", e);
|
LOGGER.error("DependenciesNotFoundException", e);
|
||||||
}
|
}
|
||||||
bt_refresh.doClick();
|
//如果修改为已签则刷新表格
|
||||||
|
if(attStatus==AttStatus.signed){
|
||||||
|
bt_refresh.doClick();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -141,11 +187,13 @@ public class Attend {
|
|||||||
};
|
};
|
||||||
if (alreadyList != null) {
|
if (alreadyList != null) {
|
||||||
for (Attendance attendance : alreadyList) {
|
for (Attendance attendance : alreadyList) {
|
||||||
|
String attID = attendance.getAttID();
|
||||||
String stuID = String.valueOf(attendance.getStudent().getStuID());
|
String stuID = String.valueOf(attendance.getStudent().getStuID());
|
||||||
String stuName = String.valueOf(attendance.getStudent().getStuName());
|
String stuName = String.valueOf(attendance.getStudent().getStuName());
|
||||||
LocalDateTime attTime = attendance.getAttTime();
|
LocalDateTime attTime = attendance.getAttTime();
|
||||||
|
AttStatus attStatus = attendance.getAttStatus();
|
||||||
String attTime1 = attTime.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
|
String attTime1 = attTime.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
|
||||||
Object row[] = {stuID, stuName, attTime1};
|
Object row[] = {attID,stuID, stuName, attTime1,String.valueOf(attStatus)};
|
||||||
alreadyTableModel.addRow(row);
|
alreadyTableModel.addRow(row);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -201,7 +249,7 @@ public class Attend {
|
|||||||
if (attendance.getAttStatus() == AttStatus.signed) { //筛选出已签到的考勤列表
|
if (attendance.getAttStatus() == AttStatus.signed) { //筛选出已签到的考勤列表
|
||||||
alreadyList.add(attendance);
|
alreadyList.add(attendance);
|
||||||
} else {
|
} else {
|
||||||
undoList.add(attendance);
|
undoList.add(attendance); //筛选出未签到成功的列表
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
LOGGER.debug("alreadyList:" + alreadyList);
|
LOGGER.debug("alreadyList:" + alreadyList);
|
||||||
@@ -222,41 +270,56 @@ public class Attend {
|
|||||||
};
|
};
|
||||||
if (alreadyList != null) {
|
if (alreadyList != null) {
|
||||||
for (Attendance attendance : alreadyList) {
|
for (Attendance attendance : alreadyList) {
|
||||||
|
String attID = attendance.getAttID();
|
||||||
String stuID = String.valueOf(attendance.getStudent().getStuID());
|
String stuID = String.valueOf(attendance.getStudent().getStuID());
|
||||||
String stuName = String.valueOf(attendance.getStudent().getStuName());
|
String stuName = String.valueOf(attendance.getStudent().getStuName());
|
||||||
LocalDateTime attTime = attendance.getAttTime();
|
LocalDateTime attTime = attendance.getAttTime();
|
||||||
|
AttStatus attStatus = attendance.getAttStatus();
|
||||||
String attTime1 = attTime.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
|
String attTime1 = attTime.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
|
||||||
Object row[] = {stuID, stuName, attTime1};
|
Object row[] = {attID,stuID, stuName, attTime1,String.valueOf(attStatus)};
|
||||||
alreadyTableModel.addRow(row);
|
alreadyTableModel.addRow(row);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
attend.table_already.setModel(alreadyTableModel);
|
attend.table_already.setModel(alreadyTableModel);
|
||||||
|
TableColumn tableColumn1 = attend.table_already.getColumnModel().getColumn(0);
|
||||||
|
tableColumn1.setWidth(0);
|
||||||
|
tableColumn1.setMinWidth(0);
|
||||||
|
tableColumn1.setPreferredWidth(0);
|
||||||
|
tableColumn1.setMaxWidth(0);
|
||||||
|
attend.table_already.getTableHeader().getColumnModel().getColumn(0).setMaxWidth(0);
|
||||||
|
attend.table_already.getTableHeader().getColumnModel().getColumn(0).setMinWidth(0);
|
||||||
|
attend.table_already.setCellSelectionEnabled(true);
|
||||||
|
|
||||||
//未签考勤表格
|
//未签考勤表格
|
||||||
undoTableModel = new DefaultTableModel(t2_columnTitle, 0){
|
if(undoList!=null){ //判断该课程是否有学生名单
|
||||||
@Override
|
undoTableModel = new DefaultTableModel(t2_columnTitle, 0){
|
||||||
public boolean isCellEditable(int row, int column) {
|
@Override
|
||||||
return false;
|
public boolean isCellEditable(int row, int column) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
for (Attendance attendance : undoList) { //遍历插入数据
|
||||||
|
String attID = attendance.getAttID();
|
||||||
|
String stuID = String.valueOf(attendance.getStudent().getStuID());
|
||||||
|
String stuName = String.valueOf(attendance.getStudent().getStuName());
|
||||||
|
AttStatus attStatus = attendance.getAttStatus();
|
||||||
|
Object row[] = {attID, stuID, stuName, String.valueOf(attStatus)};
|
||||||
|
undoTableModel.addRow(row);
|
||||||
}
|
}
|
||||||
};
|
attend.table_undo.setModel(undoTableModel);
|
||||||
for (Attendance attendance : undoList) {
|
//设置未签表格的第一列考勤号隐藏
|
||||||
String attID = attendance.getAttID();
|
TableColumn tableColumn2 = attend.table_undo.getColumnModel().getColumn(0);
|
||||||
String stuID = String.valueOf(attendance.getStudent().getStuID());
|
tableColumn2.setWidth(0);
|
||||||
String stuName = String.valueOf(attendance.getStudent().getStuName());
|
tableColumn2.setMinWidth(0);
|
||||||
AttStatus attStatus = attendance.getAttStatus();
|
tableColumn2.setPreferredWidth(0);
|
||||||
Object row[] = {attID, stuID, stuName, String.valueOf(attStatus)};
|
tableColumn2.setMaxWidth(0);
|
||||||
undoTableModel.addRow(row);
|
attend.table_undo.getTableHeader().getColumnModel().getColumn(0).setMaxWidth(0);
|
||||||
|
attend.table_undo.getTableHeader().getColumnModel().getColumn(0).setMinWidth(0);
|
||||||
|
attend.table_undo.setCellSelectionEnabled(true);
|
||||||
|
}else {
|
||||||
|
JOptionPane.showMessageDialog(null,"该课程学生名单未导入","提醒!",JOptionPane.INFORMATION_MESSAGE);
|
||||||
}
|
}
|
||||||
attend.table_undo.setModel(undoTableModel);
|
|
||||||
//设置第一列隐藏
|
|
||||||
TableColumn tableColumn = attend.table_undo.getColumnModel().getColumn(0);
|
|
||||||
tableColumn.setWidth(0);
|
|
||||||
tableColumn.setMinWidth(0);
|
|
||||||
tableColumn.setPreferredWidth(0);
|
|
||||||
tableColumn.setMaxWidth(0);
|
|
||||||
attend.table_undo.getTableHeader().getColumnModel().getColumn(0).setMaxWidth(0);
|
|
||||||
attend.table_undo.getTableHeader().getColumnModel().getColumn(0).setMinWidth(0);
|
|
||||||
attend.table_undo.setCellSelectionEnabled(true);
|
|
||||||
|
|
||||||
frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
|
frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
|
||||||
frame.setVisible(true);
|
frame.setVisible(true);
|
||||||
|
|||||||
@@ -75,10 +75,10 @@ public class CheckIn {
|
|||||||
bt_confim.addActionListener(new ActionListener() {
|
bt_confim.addActionListener(new ActionListener() {
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
number = n1 + n2 + n3 + n4;
|
//获取签到码广播出去
|
||||||
|
number = textField1.getText() + textField2.getText() + textField3.getText() + textField4.getText();
|
||||||
if (number != null) {
|
if (number != null) {
|
||||||
LOGGER.info(number);
|
teacherNet.sendAllMessage(new MessageObject(null, null, number, null, null, null, null, MessageType.CheckIn));
|
||||||
teacherNet.sendAllMessage(new MessageObject(null, null, number, null, null, null,null,MessageType.CheckIn));
|
|
||||||
JOptionPane.showMessageDialog(null, "签到码发布成功", "消息", JOptionPane.INFORMATION_MESSAGE);
|
JOptionPane.showMessageDialog(null, "签到码发布成功", "消息", JOptionPane.INFORMATION_MESSAGE);
|
||||||
frame.dispose();
|
frame.dispose();
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -34,6 +34,7 @@ public class ClassList {
|
|||||||
subName = select.substring(select.indexOf(" ") + 1);
|
subName = select.substring(select.indexOf(" ") + 1);
|
||||||
LOGGER.debug(courseID + " " + subName);
|
LOGGER.debug(courseID + " " + subName);
|
||||||
Main.start(workerNo, courseID, subName);
|
Main.start(workerNo, courseID, subName);
|
||||||
|
frame.dispose();
|
||||||
} else {
|
} else {
|
||||||
JOptionPane.showMessageDialog(null, "请选择您想要进入的课程", "温馨提示!", JOptionPane.WARNING_MESSAGE);
|
JOptionPane.showMessageDialog(null, "请选择您想要进入的课程", "温馨提示!", JOptionPane.WARNING_MESSAGE);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -156,14 +156,17 @@ public class Main {
|
|||||||
teacherNet.setOnReceiveListener(new ReceiveListener() {
|
teacherNet.setOnReceiveListener(new ReceiveListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onReceive(MessageObject messageObject) {
|
public void onReceive(MessageObject messageObject) {
|
||||||
//学生端举手监听
|
if(messageObject.getStuNo()!=null){
|
||||||
if (messageObject.getMessageType() == MessageType.RaiseHand) {
|
//学生端举手监听
|
||||||
JOptionPane.showMessageDialog(null, messageObject.getStuName() + " 举手了", "温馨提示!", JOptionPane.INFORMATION_MESSAGE);
|
if (messageObject.getMessageType() == MessageType.RaiseHand) {
|
||||||
}
|
JOptionPane.showMessageDialog(null, "学生 "+messageObject.getStuName() + " 向您举手", "温馨提示!", JOptionPane.INFORMATION_MESSAGE);
|
||||||
//学生留言监听
|
}
|
||||||
if (messageObject.getMessageType() == MessageType.Chat) {
|
//学生留言监听
|
||||||
JOptionPane.showMessageDialog(null, messageObject.getMessage(), "学生 " + messageObject.getStuName() + " 向您留言", JOptionPane.INFORMATION_MESSAGE);
|
if (messageObject.getMessageType() == MessageType.Chat) {
|
||||||
|
JOptionPane.showMessageDialog(null, messageObject.getMessage(), "学生 " + messageObject.getStuName() + " 向您留言", JOptionPane.INFORMATION_MESSAGE);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,12 +29,12 @@ public class SendMessage {
|
|||||||
teacherNet.setOnReceiveListener(new ReceiveListener() {
|
teacherNet.setOnReceiveListener(new ReceiveListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onReceive(MessageObject messageObject) {
|
public void onReceive(MessageObject messageObject) {
|
||||||
if(messageObject.getMessageType()==MessageType.Chat){
|
if(messageObject.getStuNo()!=null){
|
||||||
LocalDateTime sendTime = LocalDateTime.now();
|
if(messageObject.getMessageType()==MessageType.Chat){
|
||||||
messageShow.append("学生 "+messageObject.getStuName()+": "+sendTime.format(DateTimeFormatter.ofPattern("yyyy年MM月dd日 HH时mm分ss秒"))+'\n'+messageObject.getMessage());
|
LocalDateTime sendTime = LocalDateTime.now();
|
||||||
System.out.println();
|
messageShow.append("学生 "+messageObject.getStuName()+": "+sendTime.format(DateTimeFormatter.ofPattern("yyyy年MM月dd日 HH时mm分ss秒"))+'\n'+messageObject.getMessage()+'\n');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -50,6 +50,7 @@ public class SignIn {
|
|||||||
frame.setVisible(false);
|
frame.setVisible(false);
|
||||||
} else {
|
} else {
|
||||||
JOptionPane.showMessageDialog(null, "密码错误,请重新输入", "错误!!", JOptionPane.ERROR_MESSAGE);
|
JOptionPane.showMessageDialog(null, "密码错误,请重新输入", "错误!!", JOptionPane.ERROR_MESSAGE);
|
||||||
|
sigIn.password_input.setText(""); //清空输入框内容
|
||||||
}
|
}
|
||||||
isConnectedToDatabase = true;
|
isConnectedToDatabase = true;
|
||||||
} catch (NoConfigException ex) {
|
} catch (NoConfigException ex) {
|
||||||
|
|||||||
Reference in New Issue
Block a user