├── data.xls ├── data1.xls ├── data2.xls ├── images ├── 添加.png ├── E-R图.jpg ├── 多选修改.png ├── 多选删除.png ├── 数据库表.jpg ├── 登录注册.jpg ├── 多选项高级查询.png ├── 导入Excel.png ├── 导出Excel.png └── 动态折线图数据分析.png ├── 学生健康档案管理系统.rp ├── HealthArchivesManagementSystem.iml ├── target └── classes │ ├── util │ ├── MD5.class │ ├── FileChooser.class │ ├── JDBCUtils.class │ ├── DataToObject.class │ ├── StudentTable.class │ ├── ExcelOperation.class │ ├── HealthCheckupTable.class │ └── MedicalRecordTable.class │ ├── pojo │ ├── Users.class │ ├── Student.class │ ├── StudentHealthCheckup.class │ └── StudentMedicalRecord.class │ ├── dao │ ├── UsersDao.class │ ├── StudentDao.class │ ├── HealthCheckupDao.class │ └── MedicalRecordDao.class │ ├── view │ ├── DataView.class │ ├── IndexView.class │ ├── LoginView$1.class │ ├── LoginView$2.class │ ├── LoginView.class │ ├── QueryResView.class │ ├── DynamicChartView.class │ ├── UpdateDataView.class │ ├── AddCheckupDataView.class │ ├── AddMedicalDataView.class │ ├── LoginView$MyPanel.class │ ├── AddCheckupDataView$1.class │ ├── AddCheckupDataView$2.class │ ├── AddMedicalDataView$1.class │ ├── AddMedicalDataView$2.class │ └── dataOperationView │ │ ├── QueryBySidView.class │ │ ├── QueryBySidView$1.class │ │ ├── CheckupQueryResView.class │ │ └── MedicalQueryResView.class │ ├── images │ └── dandelion.jpg │ ├── service │ ├── DataService.class │ ├── UserService.class │ └── StudentsService.class │ ├── com │ └── intellij │ │ └── uiDesigner │ │ └── core │ │ ├── Util.class │ │ ├── Spacer.class │ │ ├── LayoutState.class │ │ ├── SupportCode.class │ │ ├── VerticalInfo.class │ │ ├── AbstractLayout.class │ │ ├── DimensionInfo.class │ │ ├── HorizontalInfo.class │ │ ├── GridConstraints.class │ │ ├── GridLayoutManager.class │ │ └── SupportCode$TextWithMnemonic.class │ └── JdbcConfig.properties ├── src └── main │ ├── resources │ ├── images │ │ └── dandelion.jpg │ └── JdbcConfig.properties │ └── java │ ├── pojo │ ├── Users.java │ ├── StudentMedicalRecord.java │ ├── Student.java │ └── StudentHealthCheckup.java │ ├── service │ ├── UserService.java │ ├── StudentsService.java │ └── DataService.java │ ├── view │ ├── QueryResView.java │ ├── dataOperationView │ │ ├── MedicalQueryResView.java │ │ ├── CheckupQueryResView.java │ │ └── QueryBySidView.java │ ├── IndexView.java │ ├── UpdateDataView.java │ ├── AddMedicalDataView.java │ ├── LoginView.java │ ├── AddCheckupDataView.java │ ├── DynamicChartView.java │ └── DataView.java │ ├── util │ ├── FileChooser.java │ ├── MD5.java │ ├── StudentTable.java │ ├── MedicalRecordTable.java │ ├── HealthCheckupTable.java │ ├── JDBCUtils.java │ ├── DataToObject.java │ └── ExcelOperation.java │ └── dao │ ├── UsersDao.java │ ├── MedicalRecordDao.java │ ├── StudentDao.java │ └── HealthCheckupDao.java ├── .gitignore ├── .gitattributes ├── .idea ├── misc.xml ├── compiler.xml ├── uiDesigner.xml └── workspace.xml ├── 数据表.txt ├── README.md └── pom.xml /data.xls: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YuRacle/HealthArchivesManagementSystem/HEAD/data.xls -------------------------------------------------------------------------------- /data1.xls: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YuRacle/HealthArchivesManagementSystem/HEAD/data1.xls -------------------------------------------------------------------------------- /data2.xls: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YuRacle/HealthArchivesManagementSystem/HEAD/data2.xls -------------------------------------------------------------------------------- /images/添加.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YuRacle/HealthArchivesManagementSystem/HEAD/images/添加.png -------------------------------------------------------------------------------- /学生健康档案管理系统.rp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YuRacle/HealthArchivesManagementSystem/HEAD/学生健康档案管理系统.rp -------------------------------------------------------------------------------- /images/E-R图.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YuRacle/HealthArchivesManagementSystem/HEAD/images/E-R图.jpg -------------------------------------------------------------------------------- /images/多选修改.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YuRacle/HealthArchivesManagementSystem/HEAD/images/多选修改.png -------------------------------------------------------------------------------- /images/多选删除.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YuRacle/HealthArchivesManagementSystem/HEAD/images/多选删除.png -------------------------------------------------------------------------------- /images/数据库表.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YuRacle/HealthArchivesManagementSystem/HEAD/images/数据库表.jpg -------------------------------------------------------------------------------- /images/登录注册.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YuRacle/HealthArchivesManagementSystem/HEAD/images/登录注册.jpg -------------------------------------------------------------------------------- /images/多选项高级查询.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YuRacle/HealthArchivesManagementSystem/HEAD/images/多选项高级查询.png -------------------------------------------------------------------------------- /images/导入Excel.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YuRacle/HealthArchivesManagementSystem/HEAD/images/导入Excel.png -------------------------------------------------------------------------------- /images/导出Excel.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YuRacle/HealthArchivesManagementSystem/HEAD/images/导出Excel.png -------------------------------------------------------------------------------- /HealthArchivesManagementSystem.iml: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /images/动态折线图数据分析.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YuRacle/HealthArchivesManagementSystem/HEAD/images/动态折线图数据分析.png -------------------------------------------------------------------------------- /target/classes/util/MD5.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YuRacle/HealthArchivesManagementSystem/HEAD/target/classes/util/MD5.class -------------------------------------------------------------------------------- /target/classes/pojo/Users.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YuRacle/HealthArchivesManagementSystem/HEAD/target/classes/pojo/Users.class -------------------------------------------------------------------------------- /target/classes/dao/UsersDao.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YuRacle/HealthArchivesManagementSystem/HEAD/target/classes/dao/UsersDao.class -------------------------------------------------------------------------------- /target/classes/pojo/Student.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YuRacle/HealthArchivesManagementSystem/HEAD/target/classes/pojo/Student.class -------------------------------------------------------------------------------- /target/classes/view/DataView.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YuRacle/HealthArchivesManagementSystem/HEAD/target/classes/view/DataView.class -------------------------------------------------------------------------------- /target/classes/dao/StudentDao.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YuRacle/HealthArchivesManagementSystem/HEAD/target/classes/dao/StudentDao.class -------------------------------------------------------------------------------- /target/classes/images/dandelion.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YuRacle/HealthArchivesManagementSystem/HEAD/target/classes/images/dandelion.jpg -------------------------------------------------------------------------------- /target/classes/util/FileChooser.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YuRacle/HealthArchivesManagementSystem/HEAD/target/classes/util/FileChooser.class -------------------------------------------------------------------------------- /target/classes/util/JDBCUtils.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YuRacle/HealthArchivesManagementSystem/HEAD/target/classes/util/JDBCUtils.class -------------------------------------------------------------------------------- /target/classes/view/IndexView.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YuRacle/HealthArchivesManagementSystem/HEAD/target/classes/view/IndexView.class -------------------------------------------------------------------------------- /target/classes/view/LoginView$1.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YuRacle/HealthArchivesManagementSystem/HEAD/target/classes/view/LoginView$1.class -------------------------------------------------------------------------------- /target/classes/view/LoginView$2.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YuRacle/HealthArchivesManagementSystem/HEAD/target/classes/view/LoginView$2.class -------------------------------------------------------------------------------- /target/classes/view/LoginView.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YuRacle/HealthArchivesManagementSystem/HEAD/target/classes/view/LoginView.class -------------------------------------------------------------------------------- /src/main/resources/images/dandelion.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YuRacle/HealthArchivesManagementSystem/HEAD/src/main/resources/images/dandelion.jpg -------------------------------------------------------------------------------- /target/classes/util/DataToObject.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YuRacle/HealthArchivesManagementSystem/HEAD/target/classes/util/DataToObject.class -------------------------------------------------------------------------------- /target/classes/util/StudentTable.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YuRacle/HealthArchivesManagementSystem/HEAD/target/classes/util/StudentTable.class -------------------------------------------------------------------------------- /target/classes/view/QueryResView.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YuRacle/HealthArchivesManagementSystem/HEAD/target/classes/view/QueryResView.class -------------------------------------------------------------------------------- /target/classes/dao/HealthCheckupDao.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YuRacle/HealthArchivesManagementSystem/HEAD/target/classes/dao/HealthCheckupDao.class -------------------------------------------------------------------------------- /target/classes/dao/MedicalRecordDao.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YuRacle/HealthArchivesManagementSystem/HEAD/target/classes/dao/MedicalRecordDao.class -------------------------------------------------------------------------------- /target/classes/service/DataService.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YuRacle/HealthArchivesManagementSystem/HEAD/target/classes/service/DataService.class -------------------------------------------------------------------------------- /target/classes/service/UserService.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YuRacle/HealthArchivesManagementSystem/HEAD/target/classes/service/UserService.class -------------------------------------------------------------------------------- /target/classes/util/ExcelOperation.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YuRacle/HealthArchivesManagementSystem/HEAD/target/classes/util/ExcelOperation.class -------------------------------------------------------------------------------- /target/classes/view/DynamicChartView.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YuRacle/HealthArchivesManagementSystem/HEAD/target/classes/view/DynamicChartView.class -------------------------------------------------------------------------------- /target/classes/view/UpdateDataView.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YuRacle/HealthArchivesManagementSystem/HEAD/target/classes/view/UpdateDataView.class -------------------------------------------------------------------------------- /target/classes/service/StudentsService.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YuRacle/HealthArchivesManagementSystem/HEAD/target/classes/service/StudentsService.class -------------------------------------------------------------------------------- /target/classes/util/HealthCheckupTable.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YuRacle/HealthArchivesManagementSystem/HEAD/target/classes/util/HealthCheckupTable.class -------------------------------------------------------------------------------- /target/classes/util/MedicalRecordTable.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YuRacle/HealthArchivesManagementSystem/HEAD/target/classes/util/MedicalRecordTable.class -------------------------------------------------------------------------------- /target/classes/view/AddCheckupDataView.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YuRacle/HealthArchivesManagementSystem/HEAD/target/classes/view/AddCheckupDataView.class -------------------------------------------------------------------------------- /target/classes/view/AddMedicalDataView.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YuRacle/HealthArchivesManagementSystem/HEAD/target/classes/view/AddMedicalDataView.class -------------------------------------------------------------------------------- /target/classes/view/LoginView$MyPanel.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YuRacle/HealthArchivesManagementSystem/HEAD/target/classes/view/LoginView$MyPanel.class -------------------------------------------------------------------------------- /target/classes/pojo/StudentHealthCheckup.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YuRacle/HealthArchivesManagementSystem/HEAD/target/classes/pojo/StudentHealthCheckup.class -------------------------------------------------------------------------------- /target/classes/pojo/StudentMedicalRecord.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YuRacle/HealthArchivesManagementSystem/HEAD/target/classes/pojo/StudentMedicalRecord.class -------------------------------------------------------------------------------- /target/classes/view/AddCheckupDataView$1.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YuRacle/HealthArchivesManagementSystem/HEAD/target/classes/view/AddCheckupDataView$1.class -------------------------------------------------------------------------------- /target/classes/view/AddCheckupDataView$2.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YuRacle/HealthArchivesManagementSystem/HEAD/target/classes/view/AddCheckupDataView$2.class -------------------------------------------------------------------------------- /target/classes/view/AddMedicalDataView$1.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YuRacle/HealthArchivesManagementSystem/HEAD/target/classes/view/AddMedicalDataView$1.class -------------------------------------------------------------------------------- /target/classes/view/AddMedicalDataView$2.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YuRacle/HealthArchivesManagementSystem/HEAD/target/classes/view/AddMedicalDataView$2.class -------------------------------------------------------------------------------- /target/classes/com/intellij/uiDesigner/core/Util.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YuRacle/HealthArchivesManagementSystem/HEAD/target/classes/com/intellij/uiDesigner/core/Util.class -------------------------------------------------------------------------------- /target/classes/com/intellij/uiDesigner/core/Spacer.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YuRacle/HealthArchivesManagementSystem/HEAD/target/classes/com/intellij/uiDesigner/core/Spacer.class -------------------------------------------------------------------------------- /target/classes/view/dataOperationView/QueryBySidView.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YuRacle/HealthArchivesManagementSystem/HEAD/target/classes/view/dataOperationView/QueryBySidView.class -------------------------------------------------------------------------------- /target/classes/com/intellij/uiDesigner/core/LayoutState.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YuRacle/HealthArchivesManagementSystem/HEAD/target/classes/com/intellij/uiDesigner/core/LayoutState.class -------------------------------------------------------------------------------- /target/classes/com/intellij/uiDesigner/core/SupportCode.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YuRacle/HealthArchivesManagementSystem/HEAD/target/classes/com/intellij/uiDesigner/core/SupportCode.class -------------------------------------------------------------------------------- /target/classes/com/intellij/uiDesigner/core/VerticalInfo.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YuRacle/HealthArchivesManagementSystem/HEAD/target/classes/com/intellij/uiDesigner/core/VerticalInfo.class -------------------------------------------------------------------------------- /target/classes/view/dataOperationView/QueryBySidView$1.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YuRacle/HealthArchivesManagementSystem/HEAD/target/classes/view/dataOperationView/QueryBySidView$1.class -------------------------------------------------------------------------------- /target/classes/com/intellij/uiDesigner/core/AbstractLayout.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YuRacle/HealthArchivesManagementSystem/HEAD/target/classes/com/intellij/uiDesigner/core/AbstractLayout.class -------------------------------------------------------------------------------- /target/classes/com/intellij/uiDesigner/core/DimensionInfo.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YuRacle/HealthArchivesManagementSystem/HEAD/target/classes/com/intellij/uiDesigner/core/DimensionInfo.class -------------------------------------------------------------------------------- /target/classes/com/intellij/uiDesigner/core/HorizontalInfo.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YuRacle/HealthArchivesManagementSystem/HEAD/target/classes/com/intellij/uiDesigner/core/HorizontalInfo.class -------------------------------------------------------------------------------- /target/classes/view/dataOperationView/CheckupQueryResView.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YuRacle/HealthArchivesManagementSystem/HEAD/target/classes/view/dataOperationView/CheckupQueryResView.class -------------------------------------------------------------------------------- /target/classes/view/dataOperationView/MedicalQueryResView.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YuRacle/HealthArchivesManagementSystem/HEAD/target/classes/view/dataOperationView/MedicalQueryResView.class -------------------------------------------------------------------------------- /target/classes/com/intellij/uiDesigner/core/GridConstraints.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YuRacle/HealthArchivesManagementSystem/HEAD/target/classes/com/intellij/uiDesigner/core/GridConstraints.class -------------------------------------------------------------------------------- /target/classes/com/intellij/uiDesigner/core/GridLayoutManager.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YuRacle/HealthArchivesManagementSystem/HEAD/target/classes/com/intellij/uiDesigner/core/GridLayoutManager.class -------------------------------------------------------------------------------- /target/classes/JdbcConfig.properties: -------------------------------------------------------------------------------- 1 | driver=com.mysql.cj.jdbc.Driver 2 | url=jdbc:mysql://localhost:3306/dbstuhealth?useUnicode=true&characterEncoding=utf-8&serverTimezone=UTC&useSSL=false 3 | name=Test 4 | password=123456 5 | -------------------------------------------------------------------------------- /src/main/resources/JdbcConfig.properties: -------------------------------------------------------------------------------- 1 | driver=com.mysql.cj.jdbc.Driver 2 | url=jdbc:mysql://localhost:3306/dbstuhealth?useUnicode=true&characterEncoding=utf-8&serverTimezone=UTC&useSSL=false 3 | name=Test 4 | password=123456 5 | -------------------------------------------------------------------------------- /target/classes/com/intellij/uiDesigner/core/SupportCode$TextWithMnemonic.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YuRacle/HealthArchivesManagementSystem/HEAD/target/classes/com/intellij/uiDesigner/core/SupportCode$TextWithMnemonic.class -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Windows thumbnail cache files 2 | Thumbs.db 3 | ehthumbs.db 4 | ehthumbs_vista.db 5 | 6 | # Folder config file 7 | Desktop.ini 8 | 9 | # Recycle Bin used on file shares 10 | $RECYCLE.BIN/ 11 | 12 | # Windows Installer files 13 | *.cab 14 | *.msi 15 | *.msm 16 | *.msp 17 | 18 | # Windows shortcuts 19 | *.lnk 20 | 21 | # ========================= 22 | # Operating System Files 23 | # ========================= 24 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | 4 | # Custom for Visual Studio 5 | *.cs diff=csharp 6 | 7 | # Standard to msysgit 8 | *.doc diff=astextplain 9 | *.DOC diff=astextplain 10 | *.docx diff=astextplain 11 | *.DOCX diff=astextplain 12 | *.dot diff=astextplain 13 | *.DOT diff=astextplain 14 | *.pdf diff=astextplain 15 | *.PDF diff=astextplain 16 | *.rtf diff=astextplain 17 | *.RTF diff=astextplain 18 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /.idea/compiler.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /src/main/java/pojo/Users.java: -------------------------------------------------------------------------------- 1 | package pojo; 2 | 3 | import util.MD5; 4 | 5 | public class Users { 6 | 7 | private String username; 8 | private String password; 9 | 10 | 11 | public Users() { 12 | } 13 | 14 | public Users(String username, String password) { 15 | this.username = username; 16 | this.password = MD5.MD5Encode(password); 17 | } 18 | 19 | public void setUsername(String username) { 20 | this.username = username; 21 | } 22 | 23 | public void setPassword(String password) { 24 | this.password = password; 25 | } 26 | 27 | public String getUsername() { 28 | return username; 29 | } 30 | 31 | public String getPassword() { 32 | return password; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/main/java/service/UserService.java: -------------------------------------------------------------------------------- 1 | package service; 2 | 3 | import dao.UsersDao; 4 | import pojo.Users; 5 | 6 | public class UserService { 7 | 8 | private UsersDao usersDao = new UsersDao(); 9 | 10 | /** 11 | * 注册用户 12 | */ 13 | public Boolean signUp(Users users) { 14 | 15 | int i = usersDao.addUser(users); 16 | if (i == 1) { 17 | return true; 18 | } 19 | return false; 20 | } 21 | 22 | /** 23 | * 用户登录 24 | */ 25 | public Boolean signIn(Users user) { 26 | 27 | Users u = usersDao.findUserByName(user.getUsername()); 28 | if (u.getPassword().equals(user.getPassword())) { 29 | return true; 30 | } 31 | 32 | return false; 33 | } 34 | 35 | 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/service/StudentsService.java: -------------------------------------------------------------------------------- 1 | package service; 2 | 3 | import dao.StudentDao; 4 | import pojo.Student; 5 | import util.DataToObject; 6 | 7 | import java.util.ArrayList; 8 | 9 | public class StudentsService { 10 | 11 | private StudentDao studentDao = new StudentDao(); 12 | 13 | /** 14 | * 获取所有学生信息 15 | * @return 16 | */ 17 | public Object[][] getAllStudents() { 18 | ArrayList students = studentDao.getStudents(); 19 | Object[][] objects = DataToObject.studentsDataToObject(students); 20 | return objects; 21 | } 22 | 23 | /** 24 | * 可多选,删除学生信息 25 | * @param sidList 26 | */ 27 | public void deleteStudents(ArrayList sidList) { 28 | for (String sid : sidList) { 29 | studentDao.deleteStuBySid(sid); 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /数据表.txt: -------------------------------------------------------------------------------- 1 | create table student( 2 | sid varchar(8) primary key, 3 | name varchar(8) not null, 4 | sex varchar(2) not null, 5 | dept varchar(24) not null 6 | ); 7 | 8 | create table medical_record( 9 | id int primary key auto_increment, 10 | sid varchar(8), 11 | result varchar(128), 12 | record_date date 13 | ); 14 | 15 | alter table medical_record add constraint FK_SID1 foreign key(sid) references student(sid) on delete cascade on update cascade; 16 | 17 | create table health_checkup( 18 | id int primary key auto_increment, 19 | sid varchar(8), 20 | height int, 21 | weight int, 22 | bust int, 23 | age int, 24 | checkup_date date 25 | ); 26 | alter table health_checkup add constraint FK_SID2 foreign key(sid) references student(sid) on delete cascade on update cascade; 27 | 28 | 29 | test: 30 | insert into student values("123",123,1,123); 31 | insert into medical_record values(null,"123","456",null); 32 | update student set sid = "233" where sid = "123"; 33 | -------------------------------------------------------------------------------- /src/main/java/view/QueryResView.java: -------------------------------------------------------------------------------- 1 | package view; 2 | 3 | import javax.swing.*; 4 | import javax.swing.table.AbstractTableModel; 5 | import java.awt.*; 6 | 7 | public class QueryResView extends JFrame{ 8 | 9 | //数据列表 10 | private JScrollPane dataScrollPane = null; 11 | 12 | public QueryResView(AbstractTableModel tableModel) { 13 | this.setLayout(null); 14 | this.setSize(750,320); 15 | //只关闭当前小窗口 16 | this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); 17 | this.setLocationRelativeTo(null); 18 | setLayout(new BorderLayout()); 19 | this.setTitle("添加体检数据"); 20 | this.setResizable(false); 21 | 22 | // 利用MyTable来建立JTable 23 | JTable t = new JTable(tableModel); 24 | 25 | // t1.setPreferredScrollableViewportSize(new Dimension(550, 30)); 26 | dataScrollPane = new JScrollPane(t); 27 | 28 | this.setContentPane(dataScrollPane); 29 | this.setVisible(true); 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/pojo/StudentMedicalRecord.java: -------------------------------------------------------------------------------- 1 | package pojo; 2 | 3 | import java.sql.Date; 4 | 5 | /** 6 | * 学生病历数据对象 7 | */ 8 | public class StudentMedicalRecord{ 9 | 10 | private String sid;//学生学号 11 | private String diagnosis;//诊断结果 12 | private Date recordDate;//诊断日期 13 | 14 | public StudentMedicalRecord() { 15 | } 16 | 17 | public StudentMedicalRecord(String sid, String diagnosis, Date recordDate) { 18 | this.sid = sid; 19 | this.diagnosis = diagnosis; 20 | this.recordDate = recordDate; 21 | } 22 | 23 | public void setSid(String sid) { 24 | this.sid = sid; 25 | } 26 | 27 | public void setDiagnosis(String diagnosis) { 28 | this.diagnosis = diagnosis; 29 | } 30 | 31 | public void setRecordDate(Date recordDate) { 32 | this.recordDate = recordDate; 33 | } 34 | 35 | public String getSid() { 36 | return sid; 37 | } 38 | 39 | public String getDiagnosis() { 40 | return diagnosis; 41 | } 42 | 43 | public Date getRecordDate() { 44 | return recordDate; 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/main/java/pojo/Student.java: -------------------------------------------------------------------------------- 1 | package pojo; 2 | 3 | /** 4 | * 学生对象 5 | */ 6 | public class Student { 7 | private String sid;//学号 8 | private String name;//姓名 9 | private String sex;//性别 10 | private String dept;//专业系别 11 | 12 | public Student() { 13 | } 14 | 15 | public Student(String sid, String name, String sex, String dept) { 16 | this.sid = sid; 17 | this.name = name; 18 | this.sex = sex; 19 | this.dept = dept; 20 | } 21 | 22 | public void setSid(String sid) { 23 | this.sid = sid; 24 | } 25 | 26 | public void setName(String name) { 27 | this.name = name; 28 | } 29 | 30 | public void setSex(String sex) { 31 | this.sex = sex; 32 | } 33 | 34 | public void setDept(String dept) { 35 | this.dept = dept; 36 | } 37 | 38 | public String getSid() { 39 | return sid; 40 | } 41 | 42 | public String getName() { 43 | return name; 44 | } 45 | 46 | public String getSex() { 47 | return sex; 48 | } 49 | 50 | public String getDept() { 51 | return dept; 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # 健康档案管理系统 2 | ### 整个信息管理系统由上而下分解为学生信息管理、体检信息管理、病历信息管理,其中健康数据包含病历数据和体检数据。病历数据要求有学号、姓名、性别、系别、 诊断、日期,而体检数据要求有学号、姓名、性别、系别、年龄、身高、体重、胸围、日期。 3 | ## 数据库设计 4 | ### E-R图 5 | ![图片](https://github.com/YuRacle/HealthArchivesManagementSystem/blob/master/images/E-R图.jpg) 6 | ### 数据表 7 | ![图片](https://github.com/YuRacle/HealthArchivesManagementSystem/blob/master/images/数据库表.jpg) 8 | ## 界面 9 | ### 登录注册界面(MD5加密密码) 10 | ![图片](https://github.com/YuRacle/HealthArchivesManagementSystem/blob/master/images/登录注册.jpg) 11 | ### 添加数据 12 | ![图片](https://github.com/YuRacle/HealthArchivesManagementSystem/blob/master/images/添加.png) 13 | ### 多选删除 14 | ![图片](https://github.com/YuRacle/HealthArchivesManagementSystem/blob/master/images/多选删除.png) 15 | ### 多选修改 16 | ![图片](https://github.com/YuRacle/HealthArchivesManagementSystem/blob/master/images/多选修改.png) 17 | ### 多选项高级查询 18 | ![图片](https://github.com/YuRacle/HealthArchivesManagementSystem/blob/master/images/多选项高级查询.png) 19 | ### 导入导出Excel 20 | ![图片](https://github.com/YuRacle/HealthArchivesManagementSystem/blob/master/images/导出Excel.png) 21 | ![图片](https://github.com/YuRacle/HealthArchivesManagementSystem/blob/master/images/导入Excel.png) 22 | ### 动态折线图数据分析 23 | ![图片](https://github.com/YuRacle/HealthArchivesManagementSystem/blob/master/images/动态折线图数据分析.png) -------------------------------------------------------------------------------- /src/main/java/util/FileChooser.java: -------------------------------------------------------------------------------- 1 | package util; 2 | 3 | import java.awt.*; 4 | 5 | /** 6 | * Created by YuRacle on 2017/12/12. 7 | * 文件选择器 8 | * 调用系统的文件对话框 9 | */ 10 | public class FileChooser { 11 | //测试 12 | public static void main(String[] args) { 13 | new FileChooser(); 14 | } 15 | 16 | private Frame Frame;//文件对话框依赖的窗口对象 17 | private FileDialog fileDialog;//文件对话框 18 | private String filePath;//文件路径 19 | private String fileName;//文件名 20 | 21 | public FileChooser() { 22 | 23 | fileDialog = new FileDialog(new Frame(),"选择电子书",FileDialog.LOAD); 24 | fileDialog.setVisible(true); 25 | 26 | filePath = fileDialog.getDirectory(); 27 | fileName = fileDialog.getFile(); 28 | if (filePath == null || fileName == null) { 29 | System.out.println("文件不存在!"); 30 | fileDialog.dispose(); 31 | } else { 32 | filePath=filePath+fileName; 33 | System.out.println(filePath); 34 | System.out.println(fileName); 35 | fileDialog.dispose(); 36 | } 37 | 38 | fileDialog.dispose(); 39 | } 40 | 41 | public String getFilePath() { 42 | return filePath; 43 | } 44 | 45 | public String getFileName() { 46 | return fileName; 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /src/main/java/view/dataOperationView/MedicalQueryResView.java: -------------------------------------------------------------------------------- 1 | package view.dataOperationView; 2 | 3 | import service.DataService; 4 | import util.MedicalRecordTable; 5 | 6 | import javax.swing.*; 7 | import java.awt.*; 8 | 9 | public class MedicalQueryResView extends JFrame{ 10 | 11 | public static void main(String[] args) { 12 | new MedicalQueryResView("123"); 13 | } 14 | 15 | //数据列表 16 | private JScrollPane dataScrollPane = null; 17 | 18 | public MedicalQueryResView(String sid) { 19 | this.setLayout(null); 20 | this.setSize(750,320); 21 | //只关闭当前小窗口 22 | this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); 23 | this.setLocationRelativeTo(null); 24 | setLayout(new BorderLayout()); 25 | this.setTitle("添加体检数据"); 26 | this.setResizable(false); 27 | 28 | MedicalRecordTable table = new MedicalRecordTable(); 29 | Object[][] medicalDataBySid = new DataService().findMedicalDataBySid(sid); 30 | table.setP(medicalDataBySid); 31 | // 利用MyTable来建立JTable 32 | JTable t = new JTable(table); 33 | 34 | // t1.setPreferredScrollableViewportSize(new Dimension(550, 30)); 35 | dataScrollPane = new JScrollPane(t); 36 | 37 | this.setContentPane(dataScrollPane); 38 | this.setVisible(true); 39 | } 40 | 41 | } 42 | -------------------------------------------------------------------------------- /src/main/java/view/dataOperationView/CheckupQueryResView.java: -------------------------------------------------------------------------------- 1 | package view.dataOperationView; 2 | 3 | import service.DataService; 4 | import util.HealthCheckupTable; 5 | 6 | import javax.swing.*; 7 | import java.awt.*; 8 | 9 | public class CheckupQueryResView extends JFrame { 10 | 11 | public static void main(String[] args) { 12 | new CheckupQueryResView("111"); 13 | } 14 | 15 | 16 | //数据列表 17 | private JScrollPane dataScrollPane = null; 18 | 19 | 20 | public CheckupQueryResView(String sid) { 21 | this.setLayout(null); 22 | this.setSize(750,320); 23 | //只关闭当前小窗口 24 | this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); 25 | this.setLocationRelativeTo(null); 26 | setLayout(new BorderLayout()); 27 | this.setTitle("添加体检数据"); 28 | this.setResizable(false); 29 | 30 | HealthCheckupTable table = new HealthCheckupTable(); 31 | Object[][] checkupDataBySid = new DataService().findCheckupDataBySid(sid); 32 | table.setP(checkupDataBySid); 33 | // 利用MyTable来建立JTable 34 | JTable t = new JTable(table); 35 | 36 | // t1.setPreferredScrollableViewportSize(new Dimension(550, 30)); 37 | dataScrollPane = new JScrollPane(t); 38 | 39 | this.setContentPane(dataScrollPane); 40 | this.setVisible(true); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/main/java/util/MD5.java: -------------------------------------------------------------------------------- 1 | package util; 2 | 3 | import java.security.MessageDigest; 4 | 5 | public class MD5 { 6 | 7 | public MD5() {} 8 | 9 | private static String[] hexDigits = { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "a", "b", "c", "d", "e", "f" }; 10 | 11 | /** 12 | * 转换字节数组为16进制字串 13 | * 14 | * @param b 15 | * 字节数组 16 | * @return 16进制字串 17 | */ 18 | private static String byteArrayToHexString(byte[] b) { 19 | StringBuffer resultSb = new StringBuffer(); 20 | for (int i = 0; i < b.length; i++) { 21 | resultSb.append(byteToHexString(b[i])); 22 | } 23 | return resultSb.toString(); 24 | } 25 | 26 | private static String byteToHexString(byte b) { 27 | int n = b; 28 | if (n < 0) n += 256; 29 | int d1 = n / 16; 30 | int d2 = n % 16; 31 | return hexDigits[d1] + hexDigits[d2]; 32 | } 33 | 34 | public static String MD5Encode(String origin) { 35 | String resultString = null; 36 | try { 37 | resultString = new String(origin); 38 | MessageDigest md = MessageDigest.getInstance("MD5"); 39 | resultString = byteArrayToHexString(md.digest(resultString.getBytes())); 40 | } 41 | catch (Exception ex) { 42 | ex.printStackTrace(); 43 | } 44 | return resultString; 45 | } 46 | } -------------------------------------------------------------------------------- /pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 4.0.0 6 | 7 | com.feliz 8 | HealthArchivesManagementSystem 9 | 1.0-SNAPSHOT 10 | 11 | 12 | 13 | org.apache.maven.plugins 14 | maven-compiler-plugin 15 | 16 | 8 17 | 8 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | mysql 26 | mysql-connector-java 27 | 8.0.11 28 | 29 | 30 | 31 | jfreechart 32 | jfreechart 33 | 1.0.0 34 | 35 | 36 | 37 | org.apache.poi 38 | poi 39 | 3.9 40 | 41 | 42 | org.apache.poi 43 | poi-ooxml 44 | 3.9 45 | 46 | 47 | 48 | 49 | 50 | -------------------------------------------------------------------------------- /src/main/java/util/StudentTable.java: -------------------------------------------------------------------------------- 1 | package util; 2 | 3 | import service.StudentsService; 4 | 5 | import javax.swing.table.AbstractTableModel; 6 | 7 | public class StudentTable extends AbstractTableModel{ 8 | 9 | private static final long serialVersionUID = 1L; 10 | 11 | private Object[][] p = {}; 12 | 13 | /* Object[][] p = { 14 | { "王鹏", "江西省九江市", new Integer(66), new Integer(32), new Integer(98), 1,1,1,1}, 15 | { "宋兵", "浙江省杭州市", new Integer(85), new Integer(69), 16 | new Integer(154), 1,1,1,1}, };*/ 17 | 18 | String[] n = { "学号", "系别", "姓名", "性别" }; 19 | 20 | public StudentTable() { 21 | Object[][] students = new StudentsService().getAllStudents(); 22 | if (students != null) { 23 | p = students; 24 | } 25 | } 26 | 27 | @Override 28 | public int getRowCount() { 29 | return p.length; 30 | } 31 | 32 | @Override 33 | public int getColumnCount() { 34 | return n.length; 35 | } 36 | 37 | @Override 38 | public Object getValueAt(int row, int col) { 39 | return p[row][col]; 40 | } 41 | 42 | @Override 43 | public String getColumnName(int column) { 44 | return n[column]; 45 | } 46 | 47 | @Override 48 | public boolean isCellEditable(int rowIndex, int columnIndex) { 49 | return false; 50 | } 51 | 52 | @Override 53 | public void setValueAt(Object value, int rowIndex, int columnIndex) { 54 | p[rowIndex][columnIndex] = value; 55 | fireTableCellUpdated(rowIndex, columnIndex); 56 | } 57 | 58 | public void setP(Object[][] p) { 59 | this.p = p; 60 | } 61 | 62 | public Object[][] getP() { 63 | return p; 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /src/main/java/pojo/StudentHealthCheckup.java: -------------------------------------------------------------------------------- 1 | package pojo; 2 | 3 | import java.sql.Date; 4 | 5 | /** 6 | * 学生体检数据对象 7 | */ 8 | public class StudentHealthCheckup{ 9 | 10 | private String sid;//学生学号 11 | private int age;//年龄 12 | private int height;//身高 13 | private int weight;//体重 14 | private int bust;//胸围 15 | private Date checkupDate;//体检日期 16 | 17 | public StudentHealthCheckup() { 18 | } 19 | 20 | public StudentHealthCheckup(String sid, int age, int height, int weight, int bust, Date checkupDate) { 21 | this.sid = sid; 22 | this.age = age; 23 | this.height = height; 24 | this.weight = weight; 25 | this.bust = bust; 26 | this.checkupDate = checkupDate; 27 | } 28 | 29 | public void setSid(String sid) { 30 | this.sid = sid; 31 | } 32 | 33 | public void setAge(int age) { 34 | this.age = age; 35 | } 36 | 37 | public void setHeight(int height) { 38 | this.height = height; 39 | } 40 | 41 | public void setWeight(int weight) { 42 | this.weight = weight; 43 | } 44 | 45 | public void setBust(int bust) { 46 | this.bust = bust; 47 | } 48 | 49 | public void setCheckupDate(Date checkupDate) { 50 | this.checkupDate = checkupDate; 51 | } 52 | 53 | public String getSid() { 54 | return sid; 55 | } 56 | 57 | public int getAge() { 58 | return age; 59 | } 60 | 61 | public int getHeight() { 62 | return height; 63 | } 64 | 65 | public int getWeight() { 66 | return weight; 67 | } 68 | 69 | public int getBust() { 70 | return bust; 71 | } 72 | 73 | public Date getCheckupDate() { 74 | return checkupDate; 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /src/main/java/view/IndexView.java: -------------------------------------------------------------------------------- 1 | package view; 2 | 3 | import javax.swing.*; 4 | import java.awt.*; 5 | 6 | public class IndexView extends JFrame implements Runnable{ 7 | 8 | public static void main(String[] args) { 9 | new Thread(IndexView.instance()); 10 | indexView.open(); 11 | } 12 | 13 | public static JPanel p1; 14 | public static JPanel p2; 15 | // public static JPanel p3; 16 | public static IndexView indexView; 17 | 18 | private JMenu menu; //菜单 19 | private JMenuBar jMenuBar; //菜单条 20 | 21 | public static IndexView instance() { 22 | if (indexView == null) { 23 | indexView = new IndexView(); 24 | } 25 | return indexView; 26 | } 27 | 28 | private IndexView() { 29 | 30 | this.setSize(1280,720); 31 | this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 32 | this.setLocationRelativeTo(null); 33 | setLayout(new BorderLayout()); 34 | this.setTitle("首页"); 35 | this.setResizable(false); 36 | 37 | // menu = new JMenu("My Creation");//创建菜单 38 | // jMenuBar = new JMenuBar() ; //创建菜单工具栏 39 | // jMenuBar.add(menu) ; //将菜单增加到菜单栏 40 | // this.setJMenuBar(jMenuBar) ; //为窗体设置菜单工具栏 41 | 42 | JTabbedPane jp=new JTabbedPane(JTabbedPane.TOP) ; //设置选项卡的坐标 43 | //创建多个容器 44 | p1 = new DataView(); 45 | p2 = new DynamicChartView(); 46 | 47 | //添加子容器 并且为选项卡添加名字 48 | jp.add("健康数据", p1); 49 | jp.add("健康分析", p2); 50 | //将选项卡窗体添加到 主窗体上去 51 | this.add(jp,BorderLayout.CENTER); 52 | 53 | } 54 | 55 | public void open() { 56 | this.setVisible(true); 57 | } 58 | public void run() { 59 | IndexView.instance(); 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /src/main/java/util/MedicalRecordTable.java: -------------------------------------------------------------------------------- 1 | package util; 2 | 3 | import service.DataService; 4 | 5 | import javax.swing.table.AbstractTableModel; 6 | 7 | public class MedicalRecordTable extends AbstractTableModel { 8 | private static final long serialVersionUID = 1L; 9 | 10 | private Object[][] p = {}; 11 | 12 | /*Object[][] p = { 13 | { "王鹏", "江西省九江市", new Integer(66), new Integer(32), new Integer(98), 1}, 14 | { "宋兵", "浙江省杭州市", new Integer(85), new Integer(69), 15 | new Integer(154), 1}, };*/ 16 | 17 | String[] n = { "日期", "学号", "姓名", "性别", "系别", "诊断" }; 18 | 19 | public MedicalRecordTable() { 20 | Object[][] allMedicalData = new DataService().getAllMedicalData(); 21 | if (allMedicalData != null) { 22 | p = allMedicalData; 23 | } 24 | } 25 | 26 | @Override 27 | public int getRowCount() { 28 | return p.length; 29 | } 30 | 31 | @Override 32 | public int getColumnCount() { 33 | return n.length; 34 | } 35 | 36 | @Override 37 | public Object getValueAt(int row, int col) { 38 | return p[row][col]; 39 | } 40 | 41 | @Override 42 | public String getColumnName(int column) { 43 | return n[column]; 44 | } 45 | 46 | @Override 47 | public boolean isCellEditable(int rowIndex, int columnIndex) { 48 | if (columnIndex == 5) { 49 | return true; 50 | }else { 51 | return false; 52 | } 53 | } 54 | 55 | @Override 56 | public void setValueAt(Object value, int rowIndex, int columnIndex) { 57 | p[rowIndex][columnIndex] = value; 58 | fireTableCellUpdated(rowIndex, columnIndex); 59 | } 60 | 61 | public void setP(Object[][] p) { 62 | this.p = p; 63 | } 64 | 65 | public Object[][] getP() { 66 | return p; 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /src/main/java/util/HealthCheckupTable.java: -------------------------------------------------------------------------------- 1 | package util; 2 | 3 | import service.DataService; 4 | 5 | import javax.swing.table.AbstractTableModel; 6 | 7 | public class HealthCheckupTable extends AbstractTableModel { 8 | private static final long serialVersionUID = 1L; 9 | 10 | private Object[][] p = {}; 11 | 12 | /* Object[][] p = { 13 | { "王鹏", "江西省九江市", new Integer(66), new Integer(32), new Integer(98), 1,1,1,1}, 14 | { "宋兵", "浙江省杭州市", new Integer(85), new Integer(69), 15 | new Integer(154), 1,1,1,1}, };*/ 16 | 17 | String[] n = { "日期", "学号", "姓名", "性别", "系别", "年龄", "身高", "体重", "胸围"}; 18 | 19 | public HealthCheckupTable() { 20 | Object[][] allCheckupData = new DataService().getAllCheckupData(); 21 | if (allCheckupData != null) { 22 | p = allCheckupData; 23 | } 24 | } 25 | 26 | @Override 27 | public int getRowCount() { 28 | return p.length; 29 | } 30 | 31 | @Override 32 | public int getColumnCount() { 33 | return n.length; 34 | } 35 | 36 | @Override 37 | public Object getValueAt(int row, int col) { 38 | return p[row][col]; 39 | } 40 | 41 | @Override 42 | public String getColumnName(int column) { 43 | return n[column]; 44 | } 45 | 46 | @Override 47 | public boolean isCellEditable(int rowIndex, int columnIndex) { 48 | if (columnIndex == 5 || columnIndex == 6 || columnIndex == 7 || columnIndex == 8) { 49 | return true; 50 | }else { 51 | return false; 52 | } 53 | } 54 | 55 | @Override 56 | public void setValueAt(Object value, int rowIndex, int columnIndex) { 57 | p[rowIndex][columnIndex] = value; 58 | fireTableCellUpdated(rowIndex, columnIndex); 59 | } 60 | 61 | 62 | public void setP(Object[][] p) { 63 | this.p = p; 64 | } 65 | 66 | public Object[][] getP() { 67 | return p; 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /src/main/java/dao/UsersDao.java: -------------------------------------------------------------------------------- 1 | package dao; 2 | 3 | import pojo.Users; 4 | import util.JDBCUtils; 5 | 6 | import java.sql.ResultSet; 7 | 8 | public class UsersDao { 9 | 10 | /** 11 | * 添加用户 12 | * @param user 13 | * @return 1:成功 0:失败 14 | */ 15 | public int addUser(Users user) { 16 | String username = user.getUsername(); 17 | String password = user.getPassword(); 18 | 19 | String sql = "insert into users values(?,?,?)"; 20 | if (findUserByName(username) == null) { 21 | try { 22 | JDBCUtils.execSQL(sql, null, username, password); 23 | return 1; 24 | } catch (Exception e) { 25 | e.printStackTrace(); 26 | } 27 | } 28 | return 0; 29 | } 30 | 31 | /** 32 | * 删除用户 33 | * @param user 34 | * @return 1:成功 0:失败 35 | */ 36 | public int deleteUser(Users user) { 37 | 38 | String sql = "delete from users where username = ?"; 39 | if (findUserByName(user.getUsername()) != null) { 40 | try { 41 | JDBCUtils.execSQL(sql, user.getUsername()); 42 | return 1; 43 | } catch (Exception e) { 44 | e.printStackTrace(); 45 | } 46 | } 47 | 48 | return 0; 49 | } 50 | 51 | /** 52 | * 根据用户名查询用户 53 | * @param username 54 | * @return 55 | */ 56 | public Users findUserByName(String username) { 57 | String sql = "select * from users where username = ?"; 58 | 59 | Users user = new Users(); 60 | try { 61 | ResultSet rs = JDBCUtils.execSQL(sql, username); 62 | if (rs.next()) { 63 | user.setUsername(rs.getString("username")); 64 | user.setPassword(rs.getString("password")); 65 | } else { 66 | user = null; 67 | } 68 | } catch (Exception e) { 69 | e.printStackTrace(); 70 | } 71 | return user; 72 | } 73 | 74 | } 75 | -------------------------------------------------------------------------------- /src/main/java/view/dataOperationView/QueryBySidView.java: -------------------------------------------------------------------------------- 1 | package view.dataOperationView; 2 | 3 | import util.HealthCheckupTable; 4 | import view.DataView; 5 | 6 | import javax.swing.*; 7 | import java.awt.*; 8 | import java.awt.event.ActionEvent; 9 | import java.awt.event.ActionListener; 10 | 11 | public class QueryBySidView extends JFrame { 12 | 13 | public static void main(String[] args) { 14 | QueryBySidView.instance(); 15 | } 16 | 17 | public static QueryBySidView queryBySidView; 18 | 19 | private JPanel panel = new JPanel(); 20 | private JLabel label = new JLabel("学生学号"); 21 | private JTextPane textPane = new JTextPane(); 22 | private JButton button = new JButton("查询"); 23 | 24 | public static QueryBySidView instance() { 25 | if (queryBySidView == null) { 26 | queryBySidView = new QueryBySidView(); 27 | } 28 | return queryBySidView; 29 | } 30 | 31 | public QueryBySidView() { 32 | 33 | this.setLayout(null); 34 | this.setSize(640,290); 35 | //只关闭当前小窗口 36 | this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); 37 | this.setLocationRelativeTo(null); 38 | setLayout(new BorderLayout()); 39 | this.setTitle("查询"); 40 | this.setResizable(false); 41 | 42 | panel.setLayout(null); 43 | panel.add(label); 44 | panel.add(textPane); 45 | panel.add(button); 46 | 47 | label.setBounds(270,30,100,50); 48 | label.setFont(new Font("微软雅黑",1, 20)); 49 | textPane.setBounds(160,100,320,30); 50 | textPane.setFont(new Font("微软雅黑",1, 16)); 51 | button.setBounds(270,165,100,40); 52 | button.setBackground(Color.WHITE); 53 | 54 | button.addActionListener(new ActionListener() { 55 | @Override 56 | public void actionPerformed(ActionEvent e) { 57 | queryBySidView.dispose(); 58 | if (DataView.isMedicalData) { 59 | new MedicalQueryResView(queryBySidView.getSid()).setVisible(true); 60 | }else if (DataView.isCheckupData) { 61 | new CheckupQueryResView(queryBySidView.getSid()).setVisible(true); 62 | } 63 | } 64 | }); 65 | 66 | this.setContentPane(panel); 67 | this.setVisible(true); 68 | } 69 | 70 | private String getSid() { 71 | String sid = textPane.getText(); 72 | textPane.setText(""); 73 | return sid; 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /src/main/java/util/JDBCUtils.java: -------------------------------------------------------------------------------- 1 | package util; 2 | 3 | import com.sun.rowset.CachedRowSetImpl; 4 | 5 | import java.io.IOException; 6 | import java.sql.*; 7 | import java.util.Properties; 8 | 9 | public class JDBCUtils { 10 | 11 | private static Properties prop = null; 12 | 13 | public JDBCUtils() { 14 | } 15 | 16 | /** 17 | * 静态代码块,加载数据库配置文件 18 | */ 19 | static { 20 | prop = new Properties(); 21 | try { 22 | prop.load(JDBCUtils.class.getClassLoader().getResourceAsStream("JdbcConfig.properties")); 23 | // prop.load(new FileInputStream("/resources/JdbcConfig.properties")); 24 | } catch (IOException e) { 25 | e.printStackTrace(); 26 | } 27 | } 28 | 29 | /** 30 | * 获取连接 31 | * 32 | * @return mysql数据库连接 33 | * @throws Exception 34 | */ 35 | private static Connection getConn() throws Exception { 36 | Class.forName(prop.getProperty("driver")); 37 | Connection conn = DriverManager.getConnection(prop.getProperty("url"), prop.getProperty("name"), 38 | prop.getProperty("password")); 39 | return conn; 40 | } 41 | 42 | /** 43 | * 执行sql语句 44 | * @param sql 45 | * @param args 动态sql可变参数 46 | * @return 结果集 47 | * @throws Exception 48 | */ 49 | public static CachedRowSetImpl execSQL(String sql, Object... args) throws Exception { 50 | //获取Connection对象 51 | Connection conn = JDBCUtils.getConn(); 52 | //建立PreparedStatement对象 53 | PreparedStatement pstm = conn.prepareStatement(sql); 54 | //为pstm对象设置SQL参数值 55 | for (int i = 0; i < args.length; i++) { 56 | pstm.setObject(i + 1, args[i]); 57 | } 58 | //执行sql语句 59 | pstm.execute(); 60 | //返回结果集,如果执行的SQL语句不返会结果集,则返回null 61 | ResultSet resultSet = pstm.getResultSet(); 62 | // 如果一定要传递ResultSet,应该使用RowSet,RowSet可以不依赖于Connection和Statement。Java传递的是引用, 63 | // 所以如果传递ResultSet,你会不知道Statement和Connection何时关闭,不知道ResultSet何时有效。 64 | CachedRowSetImpl rowSet = new CachedRowSetImpl(); 65 | if (resultSet != null) { 66 | rowSet.populate(resultSet); 67 | close(resultSet, pstm, conn); 68 | }else { 69 | rowSet = null; 70 | } 71 | return rowSet; 72 | } 73 | 74 | private static void close(ResultSet rs, Statement stat, Connection conn) { 75 | 76 | try { 77 | if (rs != null) { 78 | rs.close(); 79 | } 80 | } catch (SQLException e) { 81 | e.printStackTrace(); 82 | } 83 | 84 | try { 85 | if (stat != null) { 86 | stat.close(); 87 | } 88 | } catch (SQLException e) { 89 | e.printStackTrace(); 90 | } 91 | 92 | try { 93 | if (conn != null) { 94 | conn.close(); 95 | } 96 | } catch (SQLException e) { 97 | e.printStackTrace(); 98 | } 99 | } 100 | 101 | } 102 | -------------------------------------------------------------------------------- /src/main/java/dao/MedicalRecordDao.java: -------------------------------------------------------------------------------- 1 | package dao; 2 | 3 | import com.sun.rowset.CachedRowSetImpl; 4 | import pojo.StudentMedicalRecord; 5 | import util.JDBCUtils; 6 | 7 | import java.sql.Date; 8 | import java.util.ArrayList; 9 | 10 | public class MedicalRecordDao { 11 | 12 | private ArrayList medicalRecords = new ArrayList(); 13 | 14 | 15 | /** 16 | * 添加学生病历信息 17 | * 18 | * @return 1:成功 0:失败 19 | */ 20 | public int addMedicalData(String sid, StudentMedicalRecord smr) { 21 | String diagnosis = smr.getDiagnosis(); 22 | Date recordDate = smr.getRecordDate(); 23 | String sql = "insert into medical_record values(?,?,?,?)"; 24 | try { 25 | JDBCUtils.execSQL(sql, null, sid, diagnosis, recordDate); 26 | return 1; 27 | } catch (Exception e) { 28 | e.printStackTrace(); 29 | } 30 | return 0; 31 | } 32 | 33 | /** 34 | * 根据sid修改病历信息 35 | * 36 | * @param oldSid 旧学生学号 37 | * @param smr 新病历信息 38 | * @return 1: 成功 0:失败 39 | */ 40 | public int updateMsgBySid(String oldSid, Date date,StudentMedicalRecord smr) { 41 | 42 | String sid = smr.getSid(); 43 | String diagnosis = smr.getDiagnosis(); 44 | Date recordDate = smr.getRecordDate(); 45 | 46 | String sql = "update medical_record set sid=?,diagnosis=?,record_date=? where sid=? and record_date = ?"; 47 | try { 48 | JDBCUtils.execSQL(sql, sid, diagnosis, recordDate, oldSid,date); 49 | return 1; 50 | } catch (Exception e) { 51 | e.printStackTrace(); 52 | } 53 | return 0; 54 | } 55 | 56 | /** 57 | * 根据日期删除病历信息 58 | * 59 | * @param date 信息日期 60 | * @return 1:成功 0:失败 61 | */ 62 | public int deleteMsg(String sid, Date date) { 63 | String sql = "delete from medical_record where sid = ? and record_date = ?"; 64 | try { 65 | JDBCUtils.execSQL(sql, sid, date); 66 | return 1; 67 | } catch (Exception e) { 68 | e.printStackTrace(); 69 | } 70 | return 0; 71 | } 72 | 73 | /** 74 | * 根据学生学号查找病历记录 75 | * 76 | * @param sid 学生学号 77 | * @return 病历数据对象集合 78 | */ 79 | public ArrayList findRecordsBySid(String sid) { 80 | String sql = "select * from medical_record where sid = ?"; 81 | 82 | return getMedicalRecords(sql, sid); 83 | } 84 | 85 | /** 86 | * 获取所有病历记录 87 | * 88 | * @return 所有病历数据对象集合 89 | */ 90 | public ArrayList getAllRecords() { 91 | String sql = "select * from medical_record"; 92 | 93 | return getMedicalRecords(sql); 94 | } 95 | 96 | /** 97 | * 获取多条数据结果集 98 | * 99 | * @param sql 100 | * @return 101 | */ 102 | private ArrayList getMedicalRecords(String sql, String... args) { 103 | try { 104 | CachedRowSetImpl rs = JDBCUtils.execSQL(sql, args); 105 | if (rs != null) { 106 | while (rs.next()) { 107 | StudentMedicalRecord smr = new StudentMedicalRecord(); 108 | smr.setSid(rs.getString("sid")); 109 | smr.setDiagnosis(rs.getString("diagnosis")); 110 | smr.setRecordDate(rs.getDate("record_date")); 111 | medicalRecords.add(smr); 112 | } 113 | } 114 | } catch (Exception e) { 115 | e.printStackTrace(); 116 | } 117 | return medicalRecords; 118 | } 119 | } 120 | -------------------------------------------------------------------------------- /src/main/java/dao/StudentDao.java: -------------------------------------------------------------------------------- 1 | package dao; 2 | 3 | import com.sun.rowset.CachedRowSetImpl; 4 | import pojo.Student; 5 | import util.JDBCUtils; 6 | 7 | import java.sql.ResultSet; 8 | import java.util.ArrayList; 9 | 10 | public class StudentDao { 11 | 12 | private ArrayList students = new ArrayList(); 13 | 14 | /** 15 | * 根据sid寻找学生 16 | * @param sid 学生学号 17 | * @return 学生对象 18 | */ 19 | public Student findStuBySid(String sid) { 20 | String sql = "select * from students where sid = ?"; 21 | 22 | Student student = new Student(); 23 | try { 24 | ResultSet rs = JDBCUtils.execSQL(sql, sid); 25 | if (rs.next()) { 26 | student.setSid(rs.getString("sid")); 27 | student.setName(rs.getString("name")); 28 | student.setSex(rs.getString("sex")); 29 | student.setDept(rs.getString("dept")); 30 | } else { 31 | student = null; 32 | } 33 | } catch (Exception e) { 34 | e.printStackTrace(); 35 | } 36 | return student; 37 | } 38 | 39 | /** 40 | * 添加用户 41 | * @param s 42 | * @return 1:成功 0:失败 43 | */ 44 | public int addStu(Student s) { 45 | String sid = s.getSid(); 46 | String name = s.getName(); 47 | String sex = s.getSex(); 48 | String dept = s.getDept(); 49 | 50 | String sql = "insert into students values(?,?,?,?)"; 51 | if (findStuBySid(sid) == null) { 52 | try { 53 | JDBCUtils.execSQL(sql, sid, name, sex, dept); 54 | return 1; 55 | } catch (Exception e) { 56 | e.printStackTrace(); 57 | } 58 | } 59 | return 0; 60 | } 61 | 62 | /** 63 | * 根据学生学号删除学生信息 64 | * @param sid 学生学号 65 | * @return 1:成功 0:失败 66 | */ 67 | public int deleteStuBySid(String sid) { 68 | String sql = "delete from students where sid = ?"; 69 | if (findStuBySid(sid) != null) { 70 | try { 71 | JDBCUtils.execSQL(sql, sid); 72 | return 1; 73 | } catch (Exception e) { 74 | e.printStackTrace(); 75 | } 76 | } 77 | 78 | return 0; 79 | } 80 | 81 | /** 82 | * 根据sid修改学生信息 83 | * @param oldSid 旧学生学号 84 | * @param student 85 | * @return 1: 成功 0:失败 86 | */ 87 | public int updateMsgBySid(String oldSid,Student student) { 88 | String sid = student.getSid(); 89 | String name =student.getName(); 90 | String sex =student.getSex(); 91 | String dept = student.getDept(); 92 | String sql = "update students set sid=?,name=?,sex=?,dept=? where sid=?"; 93 | try { 94 | JDBCUtils.execSQL(sql,sid,name,sex,dept,oldSid); 95 | return 1; 96 | } catch (Exception e) { 97 | e.printStackTrace(); 98 | } 99 | return 0; 100 | } 101 | 102 | /** 103 | * 获取所有学生信息 104 | * @return 所有学生对象集合 105 | */ 106 | public ArrayList getStudents() { 107 | String sql = "select * from students"; 108 | try { 109 | CachedRowSetImpl rs = JDBCUtils.execSQL(sql); 110 | if (rs != null) { 111 | while (rs.next()) { 112 | Student student = new Student(); 113 | student.setSid(rs.getString("sid")); 114 | student.setName(rs.getString("name")); 115 | student.setSex(rs.getString("sex")); 116 | student.setDept(rs.getString("dept")); 117 | students.add(student); 118 | } 119 | } 120 | } catch (Exception e) { 121 | e.printStackTrace(); 122 | } 123 | return students; 124 | } 125 | } 126 | -------------------------------------------------------------------------------- /src/main/java/dao/HealthCheckupDao.java: -------------------------------------------------------------------------------- 1 | package dao; 2 | 3 | import com.sun.rowset.CachedRowSetImpl; 4 | import pojo.StudentHealthCheckup; 5 | import util.JDBCUtils; 6 | 7 | import java.sql.Date; 8 | import java.util.ArrayList; 9 | 10 | public class HealthCheckupDao { 11 | 12 | private ArrayList healthCheckups = new ArrayList(); 13 | 14 | /** 15 | * 添加学生体检信息 16 | * 17 | * @return 1:成功 0:失败 18 | */ 19 | public int addCheckupData(String sid, StudentHealthCheckup shc) { 20 | int height = shc.getHeight(); 21 | int weight = shc.getWeight(); 22 | int bust = shc.getBust(); 23 | int age = shc.getAge(); 24 | Date checkupDate = shc.getCheckupDate(); 25 | 26 | String sql = "insert into health_checkup values(null,?,?,?,?,?,?)"; 27 | try { 28 | JDBCUtils.execSQL(sql, sid, height, weight, bust, age, checkupDate); 29 | return 1; 30 | } catch (Exception e) { 31 | e.printStackTrace(); 32 | } 33 | return 0; 34 | } 35 | 36 | /** 37 | * 根据sid修改体检信息 38 | * 39 | * @param oldSid 旧学生学号 40 | * @param shc 新体检信息 41 | * @return 1: 成功 0:失败 42 | */ 43 | public int updateMsgBySid(String oldSid, Date date, StudentHealthCheckup shc) { 44 | 45 | String sid = shc.getSid(); 46 | int height = shc.getHeight();//身高 47 | int weight = shc.getWeight();//体重 48 | int bust = shc.getBust();//胸围 49 | int age = shc.getAge();//年龄 50 | Date checkupDate = shc.getCheckupDate();//体检日期 51 | 52 | String sql = "update health_checkup set sid=?,height=?,weight=?,bust=?,age=?,checkup_date=? where sid=? and checkup_date=?"; 53 | try { 54 | JDBCUtils.execSQL(sql, sid, height, weight, bust, age, checkupDate, oldSid, date); 55 | return 1; 56 | } catch (Exception e) { 57 | e.printStackTrace(); 58 | } 59 | return 0; 60 | } 61 | 62 | /** 63 | * 根据学生学号删除体检信息 64 | * 65 | * @param date 信息日期 66 | * @return 1:成功 0:失败 67 | */ 68 | public int deleteMsg(String sid, Date date) { 69 | String sql = "delete from health_checkup where sid = ? and checkup_date = ?"; 70 | try { 71 | JDBCUtils.execSQL(sql, sid, date); 72 | return 1; 73 | } catch (Exception e) { 74 | e.printStackTrace(); 75 | } 76 | return 0; 77 | } 78 | 79 | /** 80 | * 根据学生学号查找体检记录 81 | * 82 | * @param sid 学生学号 83 | * @return 体检数据对象集合 84 | */ 85 | public ArrayList findCheckupsBySid(String sid) { 86 | String sql = "select * from health_checkup where sid = ?"; 87 | 88 | return getHealthCheckups(sql, sid); 89 | } 90 | 91 | /** 92 | * 获取所有体检记录 93 | * 94 | * @return 所有体检数据对象集合 95 | */ 96 | public ArrayList getAllCheckups() { 97 | String sql = "select * from health_checkup"; 98 | 99 | return getHealthCheckups(sql); 100 | } 101 | 102 | /** 103 | * 获取多条数据结果集 104 | * 105 | * @param sql 106 | * @return 107 | */ 108 | private ArrayList getHealthCheckups(String sql, String... args) { 109 | try { 110 | CachedRowSetImpl rs = JDBCUtils.execSQL(sql, args); 111 | if (rs != null) { 112 | while (rs.next()) { 113 | StudentHealthCheckup shc = new StudentHealthCheckup(); 114 | shc.setSid(rs.getString("sid")); 115 | shc.setAge(rs.getInt("age")); 116 | shc.setHeight(rs.getInt("height")); 117 | shc.setWeight(rs.getInt("weight")); 118 | shc.setBust(rs.getInt("bust")); 119 | shc.setCheckupDate(rs.getDate("checkup_date")); 120 | healthCheckups.add(shc); 121 | } 122 | } 123 | } catch (Exception e) { 124 | e.printStackTrace(); 125 | } 126 | return healthCheckups; 127 | } 128 | } 129 | -------------------------------------------------------------------------------- /src/main/java/service/DataService.java: -------------------------------------------------------------------------------- 1 | package service; 2 | 3 | import dao.HealthCheckupDao; 4 | import dao.MedicalRecordDao; 5 | import dao.StudentDao; 6 | import pojo.Student; 7 | import pojo.StudentHealthCheckup; 8 | import pojo.StudentMedicalRecord; 9 | import util.DataToObject; 10 | 11 | import java.sql.Date; 12 | import java.util.ArrayList; 13 | 14 | public class DataService { 15 | 16 | private StudentDao studentDao = new StudentDao(); 17 | private MedicalRecordDao medicalRecordDao = new MedicalRecordDao(); 18 | private HealthCheckupDao healthCheckupDao = new HealthCheckupDao(); 19 | 20 | /** 21 | * 返回所有病历数据 22 | * 23 | * @return 24 | */ 25 | public Object[][] getAllMedicalData() { 26 | ArrayList allRecords = medicalRecordDao.getAllRecords(); 27 | Object[][] medicalDataObject = DataToObject.MedicalDataToObject(allRecords); 28 | return medicalDataObject; 29 | } 30 | 31 | /** 32 | * 返回所有体检数据 33 | * 34 | * @return 35 | */ 36 | public Object[][] getAllCheckupData() { 37 | ArrayList allCheckups = healthCheckupDao.getAllCheckups(); 38 | Object[][] checkupDataObject = DataToObject.CheckupDataToObject(allCheckups); 39 | return checkupDataObject; 40 | } 41 | 42 | /** 43 | * 根据学号查询病历信息 44 | * 45 | * @param sid 学生学号 46 | * @return 包含该学生所有病历信息的二维数组对象 47 | */ 48 | public Object[][] findMedicalDataBySid(String sid) { 49 | 50 | ArrayList medicalRecords = medicalRecordDao.findRecordsBySid(sid); 51 | 52 | Object[][] medicalDataObject = DataToObject.MedicalDataToObject(medicalRecords); 53 | 54 | return medicalDataObject; 55 | } 56 | 57 | /** 58 | * 根据学号查询体检信息 59 | * 60 | * @param sid 学生学号 61 | * @return 包含该学生所有体检信息的二维数组对象 62 | */ 63 | public Object[][] findCheckupDataBySid(String sid) { 64 | 65 | ArrayList checkupRecords = healthCheckupDao.findCheckupsBySid(sid); 66 | 67 | Object[][] checkupDataObject = DataToObject.CheckupDataToObject(checkupRecords); 68 | 69 | return checkupDataObject; 70 | } 71 | 72 | /** 73 | * 添加病历信息 74 | * 75 | * @param student 学生 76 | * @param smr 病历数据 77 | */ 78 | public void addMedicalData(Student student, StudentMedicalRecord smr) { 79 | studentDao.addStu(student); 80 | medicalRecordDao.addMedicalData(smr.getSid(), smr); 81 | System.out.println("添加成功"); 82 | } 83 | 84 | /** 85 | * 添加体检信息 86 | * 87 | * @param student 学生 88 | * @param shc 体检数据 89 | */ 90 | public void addCheckupData(Student student, StudentHealthCheckup shc) { 91 | studentDao.addStu(student); 92 | healthCheckupDao.addCheckupData(shc.getSid(), shc); 93 | System.out.println("添加成功"); 94 | } 95 | 96 | /** 97 | * 修改多条,根据oldsid更改(学生信息 + 病历信息) 98 | * 99 | * @param oldsidList 旧学号列表 100 | * @param smrList 新病历数据列表 101 | */ 102 | public void updateMedicalData(ArrayList oldsidList, ArrayList dates, ArrayList smrList) { 103 | for (int i = 0; i < smrList.size(); i++) { 104 | medicalRecordDao.updateMsgBySid(oldsidList.get(i), dates.get(i),smrList.get(i)); 105 | } 106 | } 107 | 108 | /** 109 | * 修改多条,根据oldsid更改(学生信息 + 体检信息) 110 | * 111 | * @param oldsidList 旧学号列表 112 | * @param shcList 新体检数据列表 113 | */ 114 | public void updateCheckupData(ArrayList oldsidList, ArrayList dates, ArrayList shcList) { 115 | for (int i = 0; i < shcList.size(); i++) { 116 | healthCheckupDao.updateMsgBySid(oldsidList.get(i), dates.get(i), shcList.get(i)); 117 | } 118 | } 119 | 120 | /** 121 | * 删除多条病历信息(学号+日期)索引 122 | * @param dateList 123 | */ 124 | public void deleteMedicalData(ArrayList sidList, ArrayList dateList) { 125 | for (int i = 0; i < sidList.size(); i++) { 126 | medicalRecordDao.deleteMsg(sidList.get(i), dateList.get(i)); 127 | } 128 | } 129 | 130 | /** 131 | * 删除多条体检信息(学号+日期)索引 132 | * @param dateList 133 | */ 134 | public void deleteCheckupData(ArrayList sidList, ArrayList dateList) { 135 | for (int i = 0; i < sidList.size(); i++) { 136 | healthCheckupDao.deleteMsg(sidList.get(i), dateList.get(i)); 137 | } 138 | } 139 | 140 | 141 | } 142 | -------------------------------------------------------------------------------- /src/main/java/util/DataToObject.java: -------------------------------------------------------------------------------- 1 | package util; 2 | 3 | import dao.HealthCheckupDao; 4 | import dao.MedicalRecordDao; 5 | import dao.StudentDao; 6 | import pojo.Student; 7 | import pojo.StudentHealthCheckup; 8 | import pojo.StudentMedicalRecord; 9 | 10 | import java.util.ArrayList; 11 | 12 | public class DataToObject { 13 | 14 | private static StudentDao studentDao = new StudentDao(); 15 | private static MedicalRecordDao medicalRecordDao = new MedicalRecordDao(); 16 | private static HealthCheckupDao healthCheckupDao = new HealthCheckupDao(); 17 | 18 | 19 | /** 20 | * 将病历数据集合转化成2维数组对象 21 | * @param medicalRecords 22 | * @return 23 | */ 24 | public static Object[][] MedicalDataToObject(ArrayList medicalRecords) { 25 | Object[][] medicalDataObject = new Object[medicalRecords.size()][6]; 26 | Student student = null; 27 | 28 | int rowCount = 0;//行 29 | int columnCount = 0;//列 30 | for (StudentMedicalRecord smr : medicalRecords) { 31 | student = studentDao.findStuBySid(smr.getSid()); 32 | if (student != null) { 33 | columnCount = 0; 34 | //日期 35 | medicalDataObject[rowCount][columnCount++] = smr.getRecordDate(); 36 | //学号 37 | medicalDataObject[rowCount][columnCount++] = student.getSid(); 38 | //姓名 39 | medicalDataObject[rowCount][columnCount++] = student.getName(); 40 | //性别 41 | medicalDataObject[rowCount][columnCount++] = student.getSex(); 42 | //系别 43 | medicalDataObject[rowCount][columnCount++] = student.getDept(); 44 | //诊断 45 | medicalDataObject[rowCount][columnCount++] = smr.getDiagnosis(); 46 | 47 | rowCount++; 48 | } 49 | } 50 | return medicalDataObject; 51 | } 52 | 53 | /** 54 | * 将体检数据集合转化成2维数组对象 55 | * @param checkupRecords 56 | * @return 57 | */ 58 | public static Object[][] CheckupDataToObject(ArrayList checkupRecords) { 59 | Object[][] checkupDataObject = new Object[checkupRecords.size()][9]; 60 | Student student = null; 61 | 62 | int rowCount = 0;//行 63 | int columnCount = 0;//列 64 | for (StudentHealthCheckup shc : checkupRecords) { 65 | student = studentDao.findStuBySid(shc.getSid()); 66 | if (student != null) { 67 | columnCount = 0; 68 | //日期 69 | checkupDataObject[rowCount][columnCount++] = shc.getCheckupDate(); 70 | //学号 71 | checkupDataObject[rowCount][columnCount++] = student.getSid(); 72 | //姓名 73 | checkupDataObject[rowCount][columnCount++] = student.getName(); 74 | //性别 75 | checkupDataObject[rowCount][columnCount++] = student.getSex(); 76 | //系别 77 | checkupDataObject[rowCount][columnCount++] = student.getDept(); 78 | //年龄 79 | checkupDataObject[rowCount][columnCount++] = shc.getAge(); 80 | //身高 81 | checkupDataObject[rowCount][columnCount++] = shc.getHeight(); 82 | //体重 83 | checkupDataObject[rowCount][columnCount++] = shc.getWeight(); 84 | //胸围 85 | checkupDataObject[rowCount][columnCount++] = shc.getBust(); 86 | 87 | rowCount++; 88 | } 89 | } 90 | return checkupDataObject; 91 | } 92 | 93 | /** 94 | * 将学生数据集合转化成2维数组对象 95 | * @param students 96 | * @return 97 | */ 98 | public static Object[][] studentsDataToObject(ArrayList students) { 99 | Object[][] studentsObject = new Object[students.size()][4]; 100 | Student student = null; 101 | 102 | int rowCount = 0;//行 103 | int columnCount = 0;//列 104 | for (Student s : students) { 105 | student = studentDao.findStuBySid(s.getSid()); 106 | if (student != null) { 107 | columnCount = 0; 108 | //学号 109 | studentsObject[rowCount][columnCount++] = student.getSid(); 110 | //系别 111 | studentsObject[rowCount][columnCount++] = student.getDept(); 112 | //姓名 113 | studentsObject[rowCount][columnCount++] = student.getName(); 114 | //性别 115 | studentsObject[rowCount][columnCount++] = student.getSex(); 116 | rowCount++; 117 | } 118 | } 119 | return studentsObject; 120 | } 121 | } 122 | -------------------------------------------------------------------------------- /src/main/java/view/UpdateDataView.java: -------------------------------------------------------------------------------- 1 | package view; 2 | 3 | import pojo.StudentHealthCheckup; 4 | import pojo.StudentMedicalRecord; 5 | import service.DataService; 6 | import util.HealthCheckupTable; 7 | import util.MedicalRecordTable; 8 | 9 | import javax.swing.*; 10 | import java.awt.*; 11 | import java.sql.Date; 12 | import java.text.ParseException; 13 | import java.util.ArrayList; 14 | 15 | public class UpdateDataView extends JFrame { 16 | 17 | private JPanel panel = new JPanel(); 18 | private JScrollPane jScrollPane; 19 | private JTable table; 20 | private JButton button1 = new JButton("修改"); 21 | private JButton button2 = new JButton("取消"); 22 | private ArrayList oldsids = new ArrayList(); 23 | ArrayList oldDates = new ArrayList<>(); 24 | 25 | 26 | /** 27 | * @param objects 28 | * @param type 数据类型 1:病历数据 2:体检数据 29 | */ 30 | public UpdateDataView(Object[][] objects, int type) { 31 | this.setLayout(null); 32 | this.setSize(640,350); 33 | //只关闭当前小窗口 34 | this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); 35 | this.setLocationRelativeTo(null); 36 | setLayout(new BorderLayout()); 37 | this.setTitle("修改数据"); 38 | this.setResizable(false); 39 | 40 | //获取旧sid 41 | for (int i=0;i { 65 | try { 66 | updateDate(type); 67 | } catch (ParseException e1) { 68 | e1.printStackTrace(); 69 | } 70 | }); 71 | 72 | button2.addActionListener(e -> { 73 | this.dispose(); 74 | }); 75 | 76 | JPanel buttonPanel = new JPanel(); 77 | 78 | panel.setLayout(new BorderLayout()); 79 | panel.add(jScrollPane, BorderLayout.CENTER); 80 | panel.add(buttonPanel, BorderLayout.SOUTH); 81 | 82 | buttonPanel.setLayout(null); 83 | buttonPanel.setPreferredSize(new Dimension(640,50)); 84 | buttonPanel.add(button1); 85 | buttonPanel.add(button2); 86 | 87 | button1.setBounds(160,10,100,30); 88 | button2.setBounds(380,10,100,30); 89 | button1.setBackground(Color.WHITE); 90 | button2.setBackground(Color.WHITE); 91 | 92 | this.setContentPane(panel); 93 | this.setVisible(true); 94 | } 95 | 96 | private void updateDate(int type) throws ParseException { 97 | if (type == 1) { 98 | ArrayList medicalRecords = new ArrayList<>(); 99 | int rowCount = table.getRowCount(); 100 | 101 | for (int i=0;i healthCheckups = new ArrayList<>(); 121 | int rowCount = table.getRowCount(); 122 | 123 | for (int i=0;i 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 127 | -------------------------------------------------------------------------------- /src/main/java/view/DynamicChartView.java: -------------------------------------------------------------------------------- 1 | package view; 2 | 3 | import org.jfree.chart.ChartFactory; 4 | import org.jfree.chart.ChartPanel; 5 | import org.jfree.chart.JFreeChart; 6 | import org.jfree.chart.axis.DateAxis; 7 | import org.jfree.chart.axis.ValueAxis; 8 | import org.jfree.chart.plot.XYPlot; 9 | import org.jfree.data.time.Day; 10 | import org.jfree.data.time.TimeSeries; 11 | import org.jfree.data.time.TimeSeriesCollection; 12 | import org.jfree.data.xy.XYDataset; 13 | import service.DataService; 14 | 15 | import javax.swing.*; 16 | import java.awt.*; 17 | import java.sql.Date; 18 | import java.text.SimpleDateFormat; 19 | import java.util.Calendar; 20 | 21 | public class DynamicChartView extends JPanel { 22 | 23 | private Thread thread; 24 | private Boolean isStarting = false; 25 | 26 | private JSplitPane splitPane = new JSplitPane(); 27 | private JPanel leftPanel = new JPanel(); 28 | private JPanel rightPanel = new JPanel(); 29 | //数据类别单选按钮组 30 | private JPanel radioPanel = new JPanel(); 31 | private ButtonGroup radioGroup = new ButtonGroup(); 32 | private JRadioButton radioButton1 = new JRadioButton("健康指数", true); 33 | private JRadioButton radioButton2 = new JRadioButton("身高"); 34 | private JRadioButton radioButton3 = new JRadioButton("体重"); 35 | private JRadioButton radioButton4 = new JRadioButton("胸围"); 36 | 37 | private JLabel label1 = new JLabel("学生学号:"); 38 | private JEditorPane sid = new JEditorPane(); 39 | private JLabel label2 = new JLabel("平均数:"); 40 | private JLabel aver = new JLabel("0"); 41 | private JLabel label3 = new JLabel("增长值:"); 42 | private JLabel value = new JLabel("0"); 43 | private JLabel label4 = new JLabel("增长率:"); 44 | private JLabel rate = new JLabel("0 %"); 45 | 46 | private JButton button1 = new JButton("分析"); 47 | private JButton button2 = new JButton("停止"); 48 | 49 | private JFreeChart jFreeChart; 50 | private TimeSeries series; 51 | 52 | /** 53 | * 构造 54 | */ 55 | public DynamicChartView() { 56 | 57 | this.createUI(); 58 | this.setLayout(new BorderLayout()); 59 | 60 | splitPane.setDividerLocation(250); 61 | splitPane.setDividerSize(2); 62 | splitPane.setLeftComponent(leftPanel); 63 | splitPane.setEnabled(false);//设置分隔条禁止拖动 64 | 65 | radioGroup.add(radioButton1); 66 | radioGroup.add(radioButton2); 67 | radioGroup.add(radioButton3); 68 | radioGroup.add(radioButton4); 69 | radioPanel.add(radioButton1); 70 | radioPanel.add(radioButton2); 71 | radioPanel.add(radioButton3); 72 | radioPanel.add(radioButton4); 73 | radioPanel.setLayout(null); 74 | radioButton1.setBounds(12, 25, 80, 25); 75 | radioButton2.setBounds(12, 55, 80, 25); 76 | radioButton3.setBounds(110, 25, 80, 25); 77 | radioButton4.setBounds(110, 55, 80, 25); 78 | radioPanel.setBorder(BorderFactory.createTitledBorder("数据类型")); 79 | radioPanel.setBounds(10, 20, 200, 90); 80 | 81 | label1.setBounds(20, 120, 100, 25); 82 | label1.setFont(new Font("微软雅黑", 1, 16)); 83 | sid.setBounds(20, 150, 150, 25); 84 | sid.setBorder(BorderFactory.createTitledBorder("")); 85 | 86 | label2.setBounds(20, 220, 100, 25); 87 | label2.setFont(new Font("微软雅黑", 1, 16)); 88 | aver.setBounds(120, 220, 100, 25); 89 | aver.setBorder(BorderFactory.createTitledBorder("")); 90 | label3.setBounds(20, 260, 100, 25); 91 | label3.setFont(new Font("微软雅黑", 1, 16)); 92 | value.setBounds(120, 260, 100, 25); 93 | value.setBorder(BorderFactory.createTitledBorder("")); 94 | label4.setBounds(20, 300, 100, 25); 95 | label4.setFont(new Font("微软雅黑", 1, 16)); 96 | rate.setBounds(120, 300, 100, 25); 97 | rate.setBorder(BorderFactory.createTitledBorder("")); 98 | 99 | button1.setBackground(Color.WHITE); 100 | button1.setFont(new Font("微软雅黑", 1, 20)); 101 | button1.setBounds(20, 400, 100, 30); 102 | button2.setBackground(Color.WHITE); 103 | button2.setFont(new Font("微软雅黑", 1, 20)); 104 | button2.setBounds(130, 400, 100, 30); 105 | 106 | leftPanel.setBorder(BorderFactory.createTitledBorder("Dynamic")); 107 | leftPanel.setLayout(null); 108 | 109 | leftPanel.add(radioPanel); 110 | leftPanel.add(label1); 111 | leftPanel.add(label2); 112 | leftPanel.add(label3); 113 | leftPanel.add(label4); 114 | leftPanel.add(sid); 115 | leftPanel.add(aver); 116 | leftPanel.add(value); 117 | leftPanel.add(rate); 118 | leftPanel.add(button1); 119 | leftPanel.add(button2); 120 | 121 | this.add(splitPane, BorderLayout.CENTER); 122 | this.setVisible(true); 123 | } 124 | 125 | /** 126 | * 创建应用程序界面 127 | */ 128 | private void createUI() { 129 | this.series = new TimeSeries("健康指数", Day.class); 130 | TimeSeriesCollection dataset = new TimeSeriesCollection(this.series); 131 | ChartPanel chartPanel = new ChartPanel(createChart(dataset)); 132 | 133 | //底部留空 134 | JPanel buttonPanel = new JPanel(); 135 | buttonPanel.setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4)); 136 | 137 | rightPanel.setLayout(new BorderLayout()); 138 | rightPanel.add(chartPanel, BorderLayout.CENTER); 139 | rightPanel.add(buttonPanel, BorderLayout.SOUTH); 140 | 141 | splitPane.setRightComponent(rightPanel); 142 | 143 | button1.addActionListener(e -> { 144 | isStarting = true; 145 | thread = new Thread(() -> dynamicRun()); 146 | thread.start(); 147 | }); 148 | 149 | button2.addActionListener(e -> { 150 | isStarting = false; 151 | thread = null; 152 | }); 153 | } 154 | 155 | /** 156 | * 根据结果集构造JFreechart报表对象 157 | */ 158 | private JFreeChart createChart(XYDataset dataset) { 159 | jFreeChart = ChartFactory.createTimeSeriesChart("动态折线图", "时间 ", 160 | "动态数值变化", dataset, true, true, false); 161 | XYPlot plot = (XYPlot) jFreeChart.getPlot(); 162 | DateAxis dateaxis = (DateAxis) plot.getDomainAxis(); 163 | dateaxis.setDateFormatOverride(new SimpleDateFormat("yyyy-MM-dd")); 164 | // dateaxis.setTickUnit(new DateTickUnit(DateTickUnit.MONTH, 1)); 165 | ValueAxis axis = plot.getDomainAxis(); 166 | axis.setAutoRange(true); 167 | // axis.setFixedAutoRange(60000.0); 168 | axis = plot.getRangeAxis(); 169 | axis.setRange(0.0, 200.0); 170 | 171 | return jFreeChart; 172 | } 173 | 174 | private void updateDate() { 175 | 176 | int type = 0; 177 | if (radioButton1.isSelected()) { 178 | type = 1; 179 | } else if (radioButton2.isSelected()) { 180 | type = 2; 181 | } else if (radioButton3.isSelected()) { 182 | type = 3; 183 | } else if (radioButton4.isSelected()) { 184 | type = 4; 185 | } 186 | String id = sid.getText(); 187 | //获取jFreeChart y轴对象 188 | XYPlot plot = (XYPlot) jFreeChart.getPlot(); 189 | ValueAxis axis = plot.getRangeAxis(); 190 | int valueSum , increase, firstValue, index; 191 | 192 | switch (type) { 193 | case 1: 194 | series.clear(); 195 | //设置y值 196 | axis.setRange(0.0, 100.0); 197 | 198 | Object[][] objects1 = new DataService().getAllMedicalData(); 199 | valueSum = 0;increase=0;firstValue=0;index = 0; 200 | for (int i = 0; i < objects1.length; i++) { 201 | if (id.equals(objects1[i][1])) { 202 | index++; 203 | Date date = (Date) objects1[i][0]; 204 | //获取年、月、日 205 | int year, month, day; 206 | Calendar now = Calendar.getInstance(); 207 | now.setTime(date); 208 | year = now.get(Calendar.YEAR); 209 | month = now.get(Calendar.MONTH) + 1; 210 | day = now.get(Calendar.DATE); 211 | 212 | // System.out.println(year + " " + month + " " + day); 213 | int health = Integer.parseInt(objects1[i][5].toString()); 214 | if (index == 1) { 215 | firstValue = health; 216 | } 217 | 218 | valueSum += health; 219 | increase = health - firstValue; 220 | 221 | aver.setText(String.valueOf(valueSum/(i+1))); 222 | value.setText(String.valueOf(increase)); 223 | if (firstValue != 0) { 224 | rate.setText(String.valueOf(increase*100/firstValue)+" %"); 225 | }else { 226 | rate.setText("0 %"); 227 | } 228 | 229 | if (isStarting) { 230 | this.series.add(new Day(day, month, year), health); 231 | }else { 232 | return; 233 | } 234 | try { 235 | thread.sleep(1000); 236 | } catch (InterruptedException e) { 237 | e.printStackTrace(); 238 | } 239 | System.out.println("第"+series.getItemCount()+"个数据节点"); 240 | } 241 | } 242 | break; 243 | case 2: 244 | series.clear(); 245 | //设置y值 246 | axis.setRange(140.0, 200.0); 247 | 248 | Object[][] objects2 = new DataService().getAllCheckupData(); 249 | valueSum = 0;increase=0;firstValue=0;index = 0; 250 | for (int i = 0; i < objects2.length; i++) { 251 | if (id.equals(objects2[i][1])) { 252 | index++; 253 | Date date = (Date) objects2[i][0]; 254 | //获取年、月、日 255 | int year, month, day; 256 | Calendar now = Calendar.getInstance(); 257 | now.setTime(date); 258 | year = now.get(Calendar.YEAR); 259 | month = now.get(Calendar.MONTH) + 1; 260 | day = now.get(Calendar.DATE); 261 | 262 | // System.out.println(year + " " + month + " " + day); 263 | int height = Integer.parseInt(objects2[i][6].toString()); 264 | if (index == 1) { 265 | firstValue = height; 266 | } 267 | 268 | valueSum += height; 269 | increase = height - firstValue; 270 | 271 | aver.setText(String.valueOf(valueSum/(i+1))); 272 | value.setText(String.valueOf(increase)); 273 | if (firstValue != 0) { 274 | rate.setText(String.valueOf(increase*100/firstValue)+" %"); 275 | }else { 276 | rate.setText("0 %"); 277 | } 278 | 279 | if (isStarting) { 280 | this.series.add(new Day(day, month, year), height); 281 | }else { 282 | return; 283 | } 284 | try { 285 | thread.sleep(1000); 286 | } catch (InterruptedException e) { 287 | e.printStackTrace(); 288 | } 289 | System.out.println("第"+series.getItemCount()+"个数据节点"); 290 | } 291 | } 292 | break; 293 | case 3: 294 | series.clear(); 295 | //设置y值 296 | axis.setRange(70.0, 160.0); 297 | 298 | Object[][] objects3 = new DataService().getAllCheckupData(); 299 | valueSum = 0;increase=0;firstValue=0;index = 0; 300 | for (int i = 0; i < objects3.length; i++) { 301 | if (id.equals(objects3[i][1])) { 302 | index++; 303 | Date date = (Date) objects3[i][0]; 304 | //获取年、月、日 305 | int year, month, day; 306 | Calendar now = Calendar.getInstance(); 307 | now.setTime(date); 308 | year = now.get(Calendar.YEAR); 309 | month = now.get(Calendar.MONTH) + 1; 310 | day = now.get(Calendar.DATE); 311 | 312 | // System.out.println(year + " " + month + " " + day); 313 | int weight = Integer.parseInt(objects3[i][7].toString()); 314 | if (index == 1) { 315 | firstValue = weight; 316 | } 317 | 318 | valueSum += weight; 319 | increase = weight - firstValue; 320 | 321 | aver.setText(String.valueOf(valueSum/(i+1))); 322 | value.setText(String.valueOf(increase)); 323 | if (firstValue != 0) { 324 | rate.setText(String.valueOf(increase*100/firstValue)+" %"); 325 | }else { 326 | rate.setText("0 %"); 327 | } 328 | 329 | if (isStarting) { 330 | this.series.add(new Day(day, month, year), weight); 331 | }else { 332 | return; 333 | } 334 | try { 335 | thread.sleep(1000); 336 | } catch (InterruptedException e) { 337 | e.printStackTrace(); 338 | } 339 | System.out.println("第"+series.getItemCount()+"个数据节点"); 340 | } 341 | } 342 | break; 343 | case 4: 344 | series.clear(); 345 | //设置y值 346 | axis.setRange(40.0, 120.0); 347 | 348 | Object[][] objects4 = new DataService().getAllCheckupData(); 349 | valueSum = 0;increase=0;firstValue=0;index = 0; 350 | for (int i = 0; i < objects4.length; i++) { 351 | if (id.equals(objects4[i][1])) { 352 | index++; 353 | Date date = (Date) objects4[i][0]; 354 | //获取年、月、日 355 | int year, month, day; 356 | Calendar now = Calendar.getInstance(); 357 | now.setTime(date); 358 | year = now.get(Calendar.YEAR); 359 | month = now.get(Calendar.MONTH) + 1; 360 | day = now.get(Calendar.DATE); 361 | 362 | // System.out.println(year + " " + month + " " + day); 363 | int bust = Integer.parseInt(objects4[i][8].toString()); 364 | if (index == 1) { 365 | firstValue = bust; 366 | } 367 | 368 | valueSum += bust; 369 | increase = bust - firstValue; 370 | 371 | aver.setText(String.valueOf(valueSum/(i+1))); 372 | value.setText(String.valueOf(increase)); 373 | if (firstValue != 0) { 374 | rate.setText(String.valueOf(increase*100/firstValue)+" %"); 375 | }else { 376 | rate.setText("0 %"); 377 | } 378 | 379 | if (isStarting) { 380 | this.series.add(new Day(day, month, year), bust); 381 | }else { 382 | return; 383 | } 384 | try { 385 | thread.sleep(1000); 386 | } catch (InterruptedException e) { 387 | e.printStackTrace(); 388 | } 389 | System.out.println("第"+series.getItemCount()+"个数据节点"); 390 | } 391 | } 392 | break; 393 | } 394 | 395 | } 396 | 397 | /** 398 | * 动态运行 399 | */ 400 | private void dynamicRun() { 401 | try { 402 | updateDate(); 403 | } catch (Exception e) { 404 | e.printStackTrace(); 405 | return; 406 | } 407 | } 408 | } 409 | 410 | 411 | -------------------------------------------------------------------------------- /src/main/java/view/DataView.java: -------------------------------------------------------------------------------- 1 | package view; 2 | 3 | import service.DataService; 4 | import service.StudentsService; 5 | import util.ExcelOperation; 6 | import util.HealthCheckupTable; 7 | import util.MedicalRecordTable; 8 | import util.StudentTable; 9 | 10 | import javax.swing.*; 11 | import java.awt.*; 12 | import java.text.SimpleDateFormat; 13 | import java.util.ArrayList; 14 | import java.util.Date; 15 | 16 | import static view.IndexView.indexView; 17 | 18 | 19 | public class DataView extends JPanel { 20 | 21 | public static void main(String[] args) { 22 | } 23 | 24 | private JSplitPane textSplitPane = new JSplitPane(); 25 | private JSplitPane dataSplitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT); 26 | private JSplitPane splitPane = new JSplitPane(); 27 | //table列表 28 | public static JTable medicalRecordTable; 29 | public static JTable healthCheckupTable; 30 | public static JTable studentTable; 31 | 32 | //查询组件 33 | private JCheckBox checkBox1 = new JCheckBox("学号"); 34 | private JEditorPane editorPane1 = new JEditorPane(); 35 | private JCheckBox checkBox2 = new JCheckBox("系别"); 36 | private JComboBox comboBox2 = new JComboBox();//系别 37 | private JCheckBox checkBox3 = new JCheckBox("姓名"); 38 | private JEditorPane editorPane3 = new JEditorPane(); 39 | private JCheckBox checkBox4 = new JCheckBox("性别"); 40 | private JComboBox comboBox4 = new JComboBox();//性别 41 | private JCheckBox checkBox5 = new JCheckBox("日期"); 42 | private JSpinner date5 = null; 43 | 44 | //数据类别单选按钮组 45 | private JPanel radioPanel = new JPanel(); 46 | private ButtonGroup radioGroup = new ButtonGroup(); 47 | private JRadioButton radioButton1 = new JRadioButton("病历数据", true); 48 | private JRadioButton radioButton2 = new JRadioButton("体检数据"); 49 | //操作选项按钮 50 | private JPanel operationPanel = new JPanel(); 51 | private JButton operationbutton1 = new JButton("查询"); 52 | private JButton operationbutton2 = new JButton("添加"); 53 | private JButton operationbutton3 = new JButton("刷新"); 54 | private JButton operationbutton4 = new JButton("导入"); 55 | private JButton operationbutton5 = new JButton("导出"); 56 | private JButton operationbutton6 = new JButton("修改"); 57 | private JButton operationbutton7 = new JButton("删除"); 58 | private JButton operationbutton8 = new JButton("删除学生"); 59 | //数据列表 60 | private JScrollPane dataScrollPane1 = null; 61 | private JScrollPane dataScrollPane2 = null; 62 | //学生列表 63 | private JScrollPane stuPanel = null; 64 | public static Boolean isMedicalData = true; 65 | public static Boolean isCheckupData = false; 66 | 67 | 68 | public DataView() { 69 | 70 | /** 71 | * 由于MyTable类继承了AbstractTableModel 72 | * 并且实现了getColumnCount(),getRowCount()、getValueAt 73 | * ()方法,因此可以通过MyTable来禅城TableModel的实体 74 | * 利用JTable所提供的getTableColumnModel()方法取得TableColumnModel对象 75 | * 再由TableColumnModel类所提供的getColumn()方法取得TableColumn对象 76 | * TableColumn类可针对表格中的每一行做具体的设置 例如设置字段的宽度,某行的标头,设置输入较复杂的数据类型等。 77 | * 在这里利用TableColumn类所提供的setCellEditor()方法,将JComboBox作为第二行的默认编辑组件 78 | */ 79 | MedicalRecordTable t1 = new MedicalRecordTable(); 80 | // 利用MyTable来建立JTable 81 | medicalRecordTable = new JTable(t1); 82 | HealthCheckupTable t2 = new HealthCheckupTable(); 83 | healthCheckupTable = new JTable(t2); 84 | StudentTable t3 = new StudentTable(); 85 | studentTable = new JTable(t3); 86 | dataScrollPane1 = new JScrollPane(medicalRecordTable); 87 | dataScrollPane2 = new JScrollPane(healthCheckupTable); 88 | stuPanel = new JScrollPane(studentTable); 89 | 90 | 91 | comboBox4.addItem("男"); 92 | comboBox4.addItem("女"); 93 | 94 | comboBox2.addItem("信工学院"); 95 | comboBox2.addItem("药学院"); 96 | comboBox2.addItem("外语学院"); 97 | 98 | //获得时间日期模型 99 | SpinnerDateModel model = new SpinnerDateModel(); 100 | //获得JSPinner对象 101 | date5 = new JSpinner(model); 102 | date5.setValue(new java.util.Date()); 103 | //设置时间格式 104 | JSpinner.DateEditor editor = new JSpinner.DateEditor(date5, 105 | "yyyy-MM-dd"); 106 | date5.setEditor(editor); 107 | 108 | radioGroup.add(radioButton1); 109 | radioGroup.add(radioButton2); 110 | radioPanel.add(radioButton1); 111 | radioPanel.add(radioButton2); 112 | radioPanel.setLayout(null); 113 | radioButton1.setBounds(7, 40, 80, 20); 114 | radioButton2.setBounds(7, 90, 80, 20); 115 | 116 | operationPanel.setLayout(null); 117 | operationPanel.add(checkBox1); 118 | operationPanel.add(editorPane1); 119 | operationPanel.add(checkBox2); 120 | operationPanel.add(comboBox2); 121 | operationPanel.add(checkBox3); 122 | operationPanel.add(editorPane3); 123 | operationPanel.add(checkBox4); 124 | operationPanel.add(comboBox4); 125 | operationPanel.add(checkBox5); 126 | operationPanel.add(date5); 127 | 128 | operationPanel.add(operationbutton1); 129 | operationPanel.add(operationbutton2); 130 | operationPanel.add(operationbutton3); 131 | operationPanel.add(operationbutton4); 132 | operationPanel.add(operationbutton5); 133 | operationPanel.add(operationbutton6); 134 | operationPanel.add(operationbutton7); 135 | operationPanel.add(operationbutton8); 136 | 137 | checkBox1.setBounds(35, 35, 60, 20); 138 | editorPane1.setBounds(95, 35, 100, 20); 139 | checkBox2.setBounds(235, 85, 60, 20); 140 | comboBox2.setBounds(295, 85, 100, 20); 141 | checkBox3.setBounds(35, 85, 60, 20); 142 | editorPane3.setBounds(95, 85, 100, 20); 143 | checkBox4.setBounds(235, 35, 60, 20); 144 | comboBox4.setBounds(295, 35, 100, 20); 145 | checkBox5.setBounds(35, 135, 60, 20); 146 | date5.setBounds(95, 135, 150, 20); 147 | 148 | operationbutton1.setBounds(495, 30, 100, 30); 149 | operationbutton2.setBounds(635, 30, 100, 30); 150 | operationbutton3.setBounds(495, 130, 100, 30); 151 | operationbutton4.setBounds(635, 130, 100, 30); 152 | operationbutton5.setBounds(775, 130, 100, 30); 153 | operationbutton6.setBounds(495, 80, 100, 30); 154 | operationbutton7.setBounds(635, 80, 100, 30); 155 | operationbutton8.setBounds(775, 80, 100, 30); 156 | operationbutton1.setBackground(Color.WHITE); 157 | operationbutton2.setBackground(Color.WHITE); 158 | operationbutton3.setBackground(Color.WHITE); 159 | operationbutton4.setBackground(Color.WHITE); 160 | operationbutton5.setBackground(Color.WHITE); 161 | operationbutton6.setBackground(Color.WHITE); 162 | operationbutton7.setBackground(Color.WHITE); 163 | operationbutton8.setBackground(Color.WHITE); 164 | 165 | radioPanel.setBorder(BorderFactory.createTitledBorder("数据类别:")); 166 | operationPanel.setBorder(BorderFactory.createTitledBorder("查询:")); 167 | stuPanel.setBorder(BorderFactory.createTitledBorder("学生列表:")); 168 | 169 | 170 | this.setLayout(new BorderLayout()); 171 | 172 | splitPane.setDividerLocation(250); 173 | splitPane.setDividerSize(2); 174 | splitPane.setLeftComponent(stuPanel); 175 | splitPane.setRightComponent(dataSplitPane); 176 | splitPane.setEnabled(false);//设置分隔条禁止拖动 177 | 178 | textSplitPane.setDividerLocation(120); 179 | textSplitPane.setDividerSize(2); 180 | textSplitPane.setLeftComponent(radioPanel); 181 | textSplitPane.setRightComponent(operationPanel); 182 | textSplitPane.setEnabled(false);//设置分隔条禁止拖动 183 | 184 | dataSplitPane.setDividerLocation(480); 185 | dataSplitPane.setDividerSize(2); 186 | dataSplitPane.setLeftComponent(dataScrollPane1); 187 | dataSplitPane.setRightComponent(textSplitPane); 188 | dataSplitPane.setEnabled(false);//设置分隔条禁止拖动 189 | this.add(splitPane, BorderLayout.CENTER); 190 | 191 | radioButton1.addActionListener(event -> { 192 | isMedicalData = true; 193 | isCheckupData = false; 194 | changeDataPane(); 195 | }); 196 | radioButton2.addActionListener(event -> { 197 | isCheckupData = true; 198 | isMedicalData = false; 199 | changeDataPane(); 200 | }); 201 | 202 | operationbutton1.addActionListener(e -> { 203 | queryData(); 204 | }); 205 | 206 | operationbutton2.addActionListener(event -> { 207 | if (isMedicalData) { 208 | AddMedicalDataView.instance().setVisible(true); 209 | } else if (isCheckupData) { 210 | AddCheckupDataView.instance().setVisible(true); 211 | } 212 | }); 213 | 214 | operationbutton3.addActionListener(e -> { 215 | refresh(); 216 | }); 217 | //导入 218 | operationbutton4.addActionListener(e -> { 219 | importDate(); 220 | refresh(); 221 | }); 222 | //导出 223 | operationbutton5.addActionListener(e -> { 224 | exportDate(); 225 | }); 226 | 227 | operationbutton6.addActionListener(e -> { 228 | updateDate(); 229 | refresh(); 230 | }); 231 | 232 | operationbutton7.addActionListener(e -> { 233 | deleteDate(); 234 | refresh(); 235 | }); 236 | 237 | operationbutton8.addActionListener(e -> { 238 | deleteStuDate(); 239 | refresh(); 240 | }); 241 | 242 | this.setVisible(true); 243 | } 244 | 245 | /** 246 | * 根据数据类型变换数据列表 247 | */ 248 | private void changeDataPane() { 249 | splitPane.setDividerLocation(250); 250 | splitPane.setDividerSize(2); 251 | splitPane.setLeftComponent(stuPanel); 252 | 253 | if (isMedicalData) { 254 | dataSplitPane.setDividerLocation(480); 255 | dataSplitPane.setDividerSize(2); 256 | dataSplitPane.setLeftComponent(dataScrollPane1); 257 | } else if (isCheckupData) { 258 | dataSplitPane.setDividerLocation(480); 259 | dataSplitPane.setDividerSize(2); 260 | dataSplitPane.setLeftComponent(dataScrollPane2); 261 | } 262 | } 263 | 264 | /** 265 | * 刷新信息 266 | */ 267 | private void refresh() { 268 | StudentTable st = new StudentTable(); 269 | studentTable = new JTable(st); 270 | stuPanel = new JScrollPane(studentTable); 271 | 272 | if (isMedicalData) { 273 | MedicalRecordTable table = new MedicalRecordTable(); 274 | // 利用MyTable来建立JTable 275 | medicalRecordTable = new JTable(table); 276 | dataScrollPane1 = new JScrollPane(medicalRecordTable); 277 | changeDataPane(); 278 | // JOptionPane.showMessageDialog(indexView, "刷新成功", "提示", JOptionPane.WARNING_MESSAGE); 279 | } else if (isCheckupData) { 280 | HealthCheckupTable table = new HealthCheckupTable(); 281 | healthCheckupTable = new JTable(table); 282 | dataScrollPane2 = new JScrollPane(healthCheckupTable); 283 | changeDataPane(); 284 | // JOptionPane.showMessageDialog(indexView, "刷新成功", "提示", JOptionPane.WARNING_MESSAGE); 285 | } 286 | } 287 | 288 | /** 289 | * 多选删除多条信息 290 | */ 291 | private void deleteDate() { 292 | if (isMedicalData) { 293 | int[] selectedRows = medicalRecordTable.getSelectedRows(); 294 | ArrayList sids = new ArrayList(); 295 | ArrayList dates = new ArrayList(); 296 | for (int i : selectedRows) { 297 | String s = (String) medicalRecordTable.getValueAt(i, 1); 298 | sids.add(s); 299 | java.sql.Date d = (java.sql.Date) medicalRecordTable.getValueAt(i, 0); 300 | dates.add(d); 301 | } 302 | new DataService().deleteMedicalData(sids, dates); 303 | JOptionPane.showMessageDialog(indexView, "删除成功", "提示", JOptionPane.WARNING_MESSAGE); 304 | } else if (isCheckupData) { 305 | int[] selectedRows = healthCheckupTable.getSelectedRows(); 306 | ArrayList sids = new ArrayList(); 307 | ArrayList dates = new ArrayList(); 308 | for (int i : selectedRows) { 309 | String s = (String) healthCheckupTable.getValueAt(i, 1); 310 | sids.add(s); 311 | java.sql.Date d = (java.sql.Date) healthCheckupTable.getValueAt(i, 0); 312 | dates.add(d); 313 | } 314 | new DataService().deleteCheckupData(sids, dates); 315 | JOptionPane.showMessageDialog(indexView, "删除成功", "提示", JOptionPane.WARNING_MESSAGE); 316 | } else { 317 | JOptionPane.showMessageDialog(indexView, "删除失败:没有数据可删除", "提示", JOptionPane.WARNING_MESSAGE); 318 | } 319 | } 320 | 321 | /** 322 | * 修改数据 323 | */ 324 | private void updateDate() { 325 | if (isMedicalData) { 326 | int[] selectedRows = medicalRecordTable.getSelectedRows(); 327 | Object[][] objects = new Object[selectedRows.length][6]; 328 | int row = 0; 329 | for (int i : selectedRows) { 330 | for (int j = 0; j < 6; j++) { 331 | objects[row][j] = medicalRecordTable.getValueAt(i, j); 332 | } 333 | row++; 334 | } 335 | 336 | new UpdateDataView(objects, 1); 337 | } else if (isCheckupData) { 338 | int[] selectedRows = healthCheckupTable.getSelectedRows(); 339 | Object[][] objects = new Object[selectedRows.length][9]; 340 | int row = 0; 341 | for (int i : selectedRows) { 342 | for (int j = 0; j < 9; j++) { 343 | objects[row][j] = healthCheckupTable.getValueAt(i, j); 344 | } 345 | row++; 346 | } 347 | 348 | new UpdateDataView(objects, 2); 349 | } 350 | } 351 | //查询数据 352 | private void queryData() { 353 | 354 | boolean isSelectedSid = checkBox1.isSelected(); 355 | boolean isSelectedDept = checkBox2.isSelected(); 356 | boolean isSelectedName = checkBox3.isSelected(); 357 | boolean isSelectedSex = checkBox4.isSelected(); 358 | boolean isSelectedDate = checkBox5.isSelected(); 359 | 360 | String sid = editorPane1.getText(); 361 | String dept = comboBox2.getSelectedItem().toString(); 362 | String name = editorPane3.getText(); 363 | String sex = comboBox4.getSelectedItem().toString(); 364 | Date date = (Date) date5.getValue(); 365 | //没有勾选不进行查询 366 | if (isSelectedDate && isSelectedDept && isSelectedName && isSelectedSex && isSelectedSid) { 367 | JOptionPane.showMessageDialog(indexView, "查询失败:没有勾选条件", "提示", JOptionPane.WARNING_MESSAGE); 368 | return; 369 | } 370 | 371 | if (isMedicalData) { 372 | int row = 0; 373 | int rowCount = medicalRecordTable.getRowCount(); 374 | Object[][] objects = new Object[rowCount][6]; 375 | for (int i = 0; i < rowCount; i++) { 376 | if (isSelectedSid) { 377 | if (!sid.equals(medicalRecordTable.getValueAt(i, 1))) 378 | continue; 379 | System.out.println("sid--------"); 380 | } 381 | if (isSelectedName) { 382 | if (!name.equals(medicalRecordTable.getValueAt(i, 2))) 383 | continue; 384 | System.out.println("name--------"); 385 | } 386 | if (isSelectedSex) { 387 | if (!sex.equals(medicalRecordTable.getValueAt(i, 3))) 388 | continue; 389 | System.out.println("sex--------"); 390 | } 391 | if (isSelectedDept) { 392 | if (!dept.equals(medicalRecordTable.getValueAt(i, 4))) 393 | continue; 394 | System.out.println("dept--------"); 395 | } 396 | if (isSelectedDate) { 397 | Date d = (Date) medicalRecordTable.getValueAt(i, 0); 398 | SimpleDateFormat fmt = new SimpleDateFormat("yyyyMMdd"); 399 | if (!(fmt.format(date)).equals(fmt.format(medicalRecordTable.getValueAt(i, 0)))) 400 | continue; 401 | System.out.println("date--------"); 402 | } 403 | 404 | for (int j = 0; j < 6; j++) { 405 | objects[row][j] = medicalRecordTable.getValueAt(i, j); 406 | } 407 | row++; 408 | } 409 | MedicalRecordTable table = new MedicalRecordTable(); 410 | table.setP(objects); 411 | 412 | new QueryResView(table).setVisible(true); 413 | System.out.println("ok--------"); 414 | } else if (isCheckupData) { 415 | int row = 0; 416 | int rowCount = healthCheckupTable.getRowCount(); 417 | Object[][] objects = new Object[rowCount][9]; 418 | for (int i = 0; i < rowCount; i++) { 419 | if (isSelectedSid) { 420 | if (!sid.equals(healthCheckupTable.getValueAt(i, 1))) 421 | continue; 422 | System.out.println("sid--------"); 423 | } 424 | if (isSelectedName) { 425 | if (!name.equals(healthCheckupTable.getValueAt(i, 2))) 426 | continue; 427 | System.out.println("name--------"); 428 | } 429 | if (isSelectedSex) { 430 | if (!sex.equals(healthCheckupTable.getValueAt(i, 3))) 431 | continue; 432 | System.out.println("sex--------"); 433 | } 434 | if (isSelectedDept) { 435 | if (!dept.equals(healthCheckupTable.getValueAt(i, 4))) 436 | continue; 437 | System.out.println("dept--------"); 438 | } 439 | if (isSelectedDate) { 440 | Date d = (Date) healthCheckupTable.getValueAt(i, 0); 441 | SimpleDateFormat fmt = new SimpleDateFormat("yyyyMMdd"); 442 | if (!(fmt.format(date)).equals(fmt.format(healthCheckupTable.getValueAt(i, 0)))) 443 | continue; 444 | System.out.println("date--------"); 445 | } 446 | 447 | for (int j = 0; j < 9; j++) { 448 | objects[row][j] = healthCheckupTable.getValueAt(i, j); 449 | } 450 | row++; 451 | } 452 | HealthCheckupTable table = new HealthCheckupTable(); 453 | table.setP(objects); 454 | 455 | new QueryResView(table).setVisible(true); 456 | System.out.println("ok--------"); 457 | } 458 | } 459 | //删除学生 460 | private void deleteStuDate() { 461 | int[] selectedRows = studentTable.getSelectedRows(); 462 | ArrayList sids = new ArrayList(); 463 | for (int i : selectedRows) { 464 | String sid = (String) studentTable.getValueAt(i, 0); 465 | sids.add(sid); 466 | } 467 | new StudentsService().deleteStudents(sids); 468 | JOptionPane.showMessageDialog(indexView, "删除成功", "提示", JOptionPane.WARNING_MESSAGE); 469 | } 470 | 471 | //导出Excel 472 | private void exportDate() { 473 | if (isMedicalData) { 474 | MedicalRecordTable model = (MedicalRecordTable) medicalRecordTable.getModel(); 475 | Object[][] p = model.getP(); 476 | String path = new ExcelOperation().exportExcel(p, 1); 477 | 478 | JOptionPane.showMessageDialog(indexView, "导出成功,文件已保存:"+path, "提示", JOptionPane.WARNING_MESSAGE); 479 | }else if (isCheckupData) { 480 | HealthCheckupTable model = (HealthCheckupTable) healthCheckupTable.getModel(); 481 | Object[][] p = model.getP(); 482 | String path = new ExcelOperation().exportExcel(p, 2); 483 | 484 | JOptionPane.showMessageDialog(indexView, "导出成功,文件已保存:"+path, "提示", JOptionPane.WARNING_MESSAGE); 485 | } 486 | } 487 | //导入Excel 488 | private void importDate() { 489 | if (isMedicalData) { 490 | try { 491 | new ExcelOperation().importExcel(1); 492 | refresh(); 493 | 494 | JOptionPane.showMessageDialog(indexView, "导入成功", "提示", JOptionPane.WARNING_MESSAGE); 495 | } catch (Exception e) { 496 | e.printStackTrace(); 497 | } 498 | 499 | }else if (isCheckupData) { 500 | 501 | try { 502 | new ExcelOperation().importExcel(2); 503 | refresh(); 504 | 505 | JOptionPane.showMessageDialog(indexView, "导入成功", "提示", JOptionPane.WARNING_MESSAGE); 506 | } catch (Exception e) { 507 | e.printStackTrace(); 508 | } 509 | } 510 | } 511 | 512 | 513 | 514 | } 515 | -------------------------------------------------------------------------------- /.idea/workspace.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 13 | 14 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 135 | 136 | 137 | 138 | Calendar 139 | 140 | 141 | 142 | 193 | 194 | 195 | 196 | 197 | true 198 | DEFINITION_ORDER 199 | 200 | 201 | 207 | 212 | 213 | 214 | 217 | 218 | 223 | 224 | 225 | 226 | 227 | 228 | 229 | 230 | 231 | 232 | 233 | 234 | 235 | 236 | 237 | 238 | 239 | 240 | 241 | 242 | 243 | 244 | 245 | 246 | 247 | 248 | 249 | 250 | 251 | 252 | 253 | 254 | 255 | 256 | 257 | 258 | 259 | 260 | 261 | 262 | 263 | 264 | 265 | 266 | 267 | 268 | 269 | 270 | 271 | 272 | 273 | 274 | 275 | 276 | 277 | 278 | 279 | 280 | 281 | 282 | 283 | 284 | 285 | 286 | 287 | 288 | 289 | 290 | 291 | 292 | 293 | 294 | 295 | 296 | 297 | 298 | 299 | 300 | 301 | 302 | 303 | 304 | 305 | 306 | 307 | 308 | 309 | 310 | 311 | 312 | 313 | 314 |