├── Screenshots
├── Login.PNG
├── doctor1.PNG
├── doctor2.PNG
└── patient.PNG
├── src
├── main
│ ├── resources
│ │ ├── css
│ │ │ ├── MainWindow_Doctor.css
│ │ │ └── Login.css
│ │ ├── image
│ │ │ ├── Icon.png
│ │ │ ├── User.png
│ │ │ ├── avatar.jpg
│ │ │ ├── search.gif
│ │ │ ├── LoginTitleIcon.png
│ │ │ ├── patient_avatar.png
│ │ │ └── if_Safety01_928417.png
│ │ ├── model
│ │ │ ├── TKsxxEntity.hbm.xml
│ │ │ ├── TBrxxEntity.hbm.xml
│ │ │ ├── THzxxEntity.hbm.xml
│ │ │ ├── TKsysEntity.hbm.xml
│ │ │ ├── TGhxxEntity.hbm.xml
│ │ │ ├── TKsxxEntity.java
│ │ │ ├── TBrxxEntity.java
│ │ │ ├── THzxxEntity.java
│ │ │ ├── TKsysEntity.java
│ │ │ └── TGhxxEntity.java
│ │ └── view
│ │ │ ├── Login.fxml
│ │ │ ├── MainWindow_Doctor.fxml
│ │ │ └── MainWindow_Patient.fxml
│ └── java
│ │ ├── Main.java
│ │ ├── layout
│ │ └── AutoCompleteComboBox.java
│ │ └── controllers
│ │ ├── Login.java
│ │ ├── MainWindow_Doctor.java
│ │ └── MainWindow_Patient.java
└── hibernate.cfg.xml
├── out
└── production
│ └── Hospital
│ ├── main
│ └── resources
│ │ ├── css
│ │ ├── MainWindow_Doctor.css
│ │ └── Login.css
│ │ ├── image
│ │ ├── Icon.png
│ │ ├── User.png
│ │ ├── avatar.jpg
│ │ ├── search.gif
│ │ ├── LoginTitleIcon.png
│ │ ├── patient_avatar.png
│ │ └── if_Safety01_928417.png
│ │ ├── model
│ │ ├── TKsxxEntity.hbm.xml
│ │ ├── TBrxxEntity.hbm.xml
│ │ ├── THzxxEntity.hbm.xml
│ │ ├── TKsysEntity.hbm.xml
│ │ └── TGhxxEntity.hbm.xml
│ │ └── view
│ │ ├── Login.fxml
│ │ ├── MainWindow_Doctor.fxml
│ │ └── MainWindow_Patient.fxml
│ └── hibernate.cfg.xml
├── .gitignore
├── README.md
├── LICENSE
└── Hospital.iml
/Screenshots/Login.PNG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/huieric/HospitalRegistration/HEAD/Screenshots/Login.PNG
--------------------------------------------------------------------------------
/Screenshots/doctor1.PNG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/huieric/HospitalRegistration/HEAD/Screenshots/doctor1.PNG
--------------------------------------------------------------------------------
/Screenshots/doctor2.PNG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/huieric/HospitalRegistration/HEAD/Screenshots/doctor2.PNG
--------------------------------------------------------------------------------
/Screenshots/patient.PNG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/huieric/HospitalRegistration/HEAD/Screenshots/patient.PNG
--------------------------------------------------------------------------------
/src/main/resources/css/MainWindow_Doctor.css:
--------------------------------------------------------------------------------
1 | #tablePatient .table-column {
2 | -fx-alignment: center;
3 | }
--------------------------------------------------------------------------------
/src/main/resources/css/Login.css:
--------------------------------------------------------------------------------
1 | .root {
2 | /* -fx-background-image: url("../image/LoginBackground.jpg"); */
3 | }
--------------------------------------------------------------------------------
/out/production/Hospital/main/resources/css/MainWindow_Doctor.css:
--------------------------------------------------------------------------------
1 | #tablePatient .table-column {
2 | -fx-alignment: center;
3 | }
--------------------------------------------------------------------------------
/src/main/resources/image/Icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/huieric/HospitalRegistration/HEAD/src/main/resources/image/Icon.png
--------------------------------------------------------------------------------
/src/main/resources/image/User.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/huieric/HospitalRegistration/HEAD/src/main/resources/image/User.png
--------------------------------------------------------------------------------
/out/production/Hospital/main/resources/css/Login.css:
--------------------------------------------------------------------------------
1 | .root {
2 | /* -fx-background-image: url("../image/LoginBackground.jpg"); */
3 | }
--------------------------------------------------------------------------------
/src/main/resources/image/avatar.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/huieric/HospitalRegistration/HEAD/src/main/resources/image/avatar.jpg
--------------------------------------------------------------------------------
/src/main/resources/image/search.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/huieric/HospitalRegistration/HEAD/src/main/resources/image/search.gif
--------------------------------------------------------------------------------
/src/main/resources/image/LoginTitleIcon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/huieric/HospitalRegistration/HEAD/src/main/resources/image/LoginTitleIcon.png
--------------------------------------------------------------------------------
/src/main/resources/image/patient_avatar.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/huieric/HospitalRegistration/HEAD/src/main/resources/image/patient_avatar.png
--------------------------------------------------------------------------------
/src/main/resources/image/if_Safety01_928417.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/huieric/HospitalRegistration/HEAD/src/main/resources/image/if_Safety01_928417.png
--------------------------------------------------------------------------------
/out/production/Hospital/main/resources/image/Icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/huieric/HospitalRegistration/HEAD/out/production/Hospital/main/resources/image/Icon.png
--------------------------------------------------------------------------------
/out/production/Hospital/main/resources/image/User.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/huieric/HospitalRegistration/HEAD/out/production/Hospital/main/resources/image/User.png
--------------------------------------------------------------------------------
/out/production/Hospital/main/resources/image/avatar.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/huieric/HospitalRegistration/HEAD/out/production/Hospital/main/resources/image/avatar.jpg
--------------------------------------------------------------------------------
/out/production/Hospital/main/resources/image/search.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/huieric/HospitalRegistration/HEAD/out/production/Hospital/main/resources/image/search.gif
--------------------------------------------------------------------------------
/out/production/Hospital/main/resources/image/LoginTitleIcon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/huieric/HospitalRegistration/HEAD/out/production/Hospital/main/resources/image/LoginTitleIcon.png
--------------------------------------------------------------------------------
/out/production/Hospital/main/resources/image/patient_avatar.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/huieric/HospitalRegistration/HEAD/out/production/Hospital/main/resources/image/patient_avatar.png
--------------------------------------------------------------------------------
/out/production/Hospital/main/resources/image/if_Safety01_928417.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/huieric/HospitalRegistration/HEAD/out/production/Hospital/main/resources/image/if_Safety01_928417.png
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Compiled class file
2 | *.class
3 |
4 | # Log file
5 | *.log
6 |
7 | # BlueJ files
8 | *.ctxt
9 |
10 | # Mobile Tools for Java (J2ME)
11 | .mtj.tmp/
12 |
13 | # Package Files #
14 | *.jar
15 | *.war
16 | *.nar
17 | *.ear
18 | *.zip
19 | *.tar.gz
20 | *.rar
21 |
22 | # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
23 | hs_err_pid*
24 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # HospitalRegistration
2 | 医院挂号管理系统 - 华中科技大学java实验
3 |
4 | ## 运行截图
5 |
6 | 
7 |
8 |
9 |
10 | 
11 |
12 |
13 |
14 | 
15 |
16 |
17 |
18 | 
19 |
20 | ## 开发环境
21 |
22 | 前端基于javafx,并使用了一些优秀的javafx组件库,例如JFoenix、controlsfx进行图形界面的开发;
23 |
24 | 后台使用mysql数据库,并利用Hibernate进行数据库的维护和查询。
25 |
26 | * Jetbrains Intellij 2018.1 Ultamate Edition
27 | * JavaSE-10
28 | * JFoenix 9.0.4
29 | * controlsfx 9.0
30 | * Hibernate 5.3.0
31 |
32 |
--------------------------------------------------------------------------------
/src/main/resources/model/TKsxxEntity.hbm.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/out/production/Hospital/main/resources/model/TKsxxEntity.hbm.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/src/main/resources/model/TBrxxEntity.hbm.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/out/production/Hospital/main/resources/model/TBrxxEntity.hbm.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2018 朱锦辉
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/src/main/resources/model/THzxxEntity.hbm.xml:
--------------------------------------------------------------------------------
1 |
2 |
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 |
--------------------------------------------------------------------------------
/src/main/resources/model/TKsysEntity.hbm.xml:
--------------------------------------------------------------------------------
1 |
2 |
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 |
--------------------------------------------------------------------------------
/out/production/Hospital/main/resources/model/THzxxEntity.hbm.xml:
--------------------------------------------------------------------------------
1 |
2 |
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 |
--------------------------------------------------------------------------------
/out/production/Hospital/main/resources/model/TKsysEntity.hbm.xml:
--------------------------------------------------------------------------------
1 |
2 |
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 |
--------------------------------------------------------------------------------
/src/main/resources/model/TGhxxEntity.hbm.xml:
--------------------------------------------------------------------------------
1 |
2 |
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 |
--------------------------------------------------------------------------------
/out/production/Hospital/main/resources/model/TGhxxEntity.hbm.xml:
--------------------------------------------------------------------------------
1 |
2 |
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 |
--------------------------------------------------------------------------------
/src/main/resources/model/TKsxxEntity.java:
--------------------------------------------------------------------------------
1 | package main.resources.model;
2 |
3 | import javax.persistence.*;
4 | import java.util.Objects;
5 |
6 | @Entity
7 | @Table(name = "t_ksxx", schema = "hospital", catalog = "")
8 | public class TKsxxEntity {
9 | private String ksbh;
10 | private String ksmc;
11 | private String pyzs;
12 |
13 | @Id
14 | @Column(name = "KSBH", nullable = false, length = 6)
15 | public String getKsbh() {
16 | return ksbh;
17 | }
18 |
19 | public void setKsbh(String ksbh) {
20 | this.ksbh = ksbh;
21 | }
22 |
23 | @Basic
24 | @Column(name = "KSMC", nullable = false, length = 10)
25 | public String getKsmc() {
26 | return ksmc;
27 | }
28 |
29 | public void setKsmc(String ksmc) {
30 | this.ksmc = ksmc;
31 | }
32 |
33 | @Basic
34 | @Column(name = "PYZS", nullable = false, length = 8)
35 | public String getPyzs() {
36 | return pyzs;
37 | }
38 |
39 | public void setPyzs(String pyzs) {
40 | this.pyzs = pyzs;
41 | }
42 |
43 | @Override
44 | public boolean equals(Object o) {
45 | if (this == o) return true;
46 | if (o == null || getClass() != o.getClass()) return false;
47 | TKsxxEntity that = (TKsxxEntity) o;
48 | return Objects.equals(ksbh, that.ksbh) &&
49 | Objects.equals(ksmc, that.ksmc) &&
50 | Objects.equals(pyzs, that.pyzs);
51 | }
52 |
53 | @Override
54 | public int hashCode() {
55 |
56 | return Objects.hash(ksbh, ksmc, pyzs);
57 | }
58 | }
59 |
--------------------------------------------------------------------------------
/src/hibernate.cfg.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
7 | jdbc:mysql://localhost:3306/hospital
8 | com.mysql.jdbc.Driver
9 | huieric
10 | zjh2416256HG
11 | false
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/out/production/Hospital/hibernate.cfg.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
7 | jdbc:mysql://localhost:3306/hospital
8 | com.mysql.jdbc.Driver
9 | huieric
10 | zjh2416256HG
11 | false
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/Hospital.iml:
--------------------------------------------------------------------------------
1 |
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 |
--------------------------------------------------------------------------------
/src/main/resources/model/TBrxxEntity.java:
--------------------------------------------------------------------------------
1 | package main.resources.model;
2 |
3 | import javax.persistence.*;
4 | import java.math.BigDecimal;
5 | import java.sql.Timestamp;
6 | import java.util.Objects;
7 |
8 | @Entity
9 | @Table(name = "t_brxx", schema = "hospital", catalog = "")
10 | public class TBrxxEntity {
11 | private String brbh;
12 | private String brmc;
13 | private String dlkl;
14 | private BigDecimal ycje;
15 | private Timestamp dlrq;
16 |
17 | @Id
18 | @Column(name = "BRBH", nullable = false, length = 6)
19 | public String getBrbh() {
20 | return brbh;
21 | }
22 |
23 | public void setBrbh(String brbh) {
24 | this.brbh = brbh;
25 | }
26 |
27 | @Basic
28 | @Column(name = "BRMC", nullable = false, length = 10)
29 | public String getBrmc() {
30 | return brmc;
31 | }
32 |
33 | public void setBrmc(String brmc) {
34 | this.brmc = brmc;
35 | }
36 |
37 | @Basic
38 | @Column(name = "DLKL", nullable = false, length = 8)
39 | public String getDlkl() {
40 | return dlkl;
41 | }
42 |
43 | public void setDlkl(String dlkl) {
44 | this.dlkl = dlkl;
45 | }
46 |
47 | @Basic
48 | @Column(name = "YCJE", nullable = false, precision = 2)
49 | public BigDecimal getYcje() {
50 | return ycje;
51 | }
52 |
53 | public void setYcje(BigDecimal ycje) {
54 | this.ycje = ycje;
55 | }
56 |
57 | @Basic
58 | @Column(name = "DLRQ", nullable = true)
59 | public Timestamp getDlrq() {
60 | return dlrq;
61 | }
62 |
63 | public void setDlrq(Timestamp dlrq) {
64 | this.dlrq = dlrq;
65 | }
66 |
67 | @Override
68 | public boolean equals(Object o) {
69 | if (this == o) return true;
70 | if (o == null || getClass() != o.getClass()) return false;
71 | TBrxxEntity that = (TBrxxEntity) o;
72 | return Objects.equals(brbh, that.brbh) &&
73 | Objects.equals(brmc, that.brmc) &&
74 | Objects.equals(dlkl, that.dlkl) &&
75 | Objects.equals(ycje, that.ycje) &&
76 | Objects.equals(dlrq, that.dlrq);
77 | }
78 |
79 | @Override
80 | public int hashCode() {
81 |
82 | return Objects.hash(brbh, brmc, dlkl, ycje, dlrq);
83 | }
84 | }
85 |
--------------------------------------------------------------------------------
/src/main/resources/view/Login.fxml:
--------------------------------------------------------------------------------
1 |
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 |
--------------------------------------------------------------------------------
/out/production/Hospital/main/resources/view/Login.fxml:
--------------------------------------------------------------------------------
1 |
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 |
--------------------------------------------------------------------------------
/src/main/java/Main.java:
--------------------------------------------------------------------------------
1 | package main.java;
2 |
3 | import javafx.application.Application;
4 | import javafx.fxml.FXMLLoader;
5 | import javafx.scene.Scene;
6 | import javafx.scene.image.Image;
7 | import javafx.scene.layout.Pane;
8 | import javafx.stage.Stage;
9 | import main.resources.model.TBrxxEntity;
10 | import org.hibernate.HibernateException;
11 | import org.hibernate.Session;
12 | import org.hibernate.SessionFactory;
13 | import org.hibernate.Transaction;
14 | import org.hibernate.cfg.Configuration;
15 | import org.hibernate.query.Query;
16 |
17 | import java.sql.Timestamp;
18 |
19 | public class Main extends Application {
20 | public static Stage curStage;
21 | public static SessionFactory factory;
22 | public static String id;
23 | public static boolean isPatient = false;
24 |
25 | @Override
26 | public void start(Stage primaryStage) throws Exception{
27 | try {
28 | factory = new Configuration().configure().buildSessionFactory();
29 | }
30 | catch (Throwable ex) {
31 | System.err.println("Failed to create sessionFactory object." + ex);
32 | throw new ExceptionInInitializerError(ex);
33 | }
34 |
35 | FXMLLoader loader = new FXMLLoader(getClass().getResource("../resources/view/Login.fxml"));
36 | // TabPane tabPane = loader.load();
37 | Pane pane = loader.load();
38 | Scene scene = new Scene(pane, pane.getPrefWidth(), pane.getPrefHeight());
39 | // scene.getStylesheets().add(getClass().getResource("../resources/css/Login.css").toExternalForm());
40 |
41 | curStage = primaryStage;
42 | primaryStage.setTitle("Hospital");
43 | primaryStage.getIcons().add(new Image(getClass().getResourceAsStream("../resources/image/Icon.png")));
44 | primaryStage.setScene(scene);
45 | primaryStage.setResizable(false);
46 | primaryStage.show();
47 | }
48 |
49 | public static void main(String[] args) {
50 | launch(args);
51 | if (isPatient) {
52 | Session session = factory.openSession();
53 | Transaction transaction = null;
54 | try {
55 | transaction = session.beginTransaction();
56 | Query query = session.createQuery("from TBrxxEntity where brbh=:brbh");
57 | query.setParameter("brbh", id);
58 | TBrxxEntity tBrxxEntity = (TBrxxEntity) query.list().get(0);
59 | tBrxxEntity.setDlrq(new Timestamp(System.currentTimeMillis()));
60 | session.update(tBrxxEntity);
61 | transaction.commit();
62 | }
63 | catch (HibernateException e) {
64 | System.out.println(e.toString());
65 | if (transaction!=null)
66 | transaction.rollback();
67 | }
68 | finally {
69 | session.close();
70 | }
71 | }
72 | factory.close();
73 | }
74 | }
75 |
--------------------------------------------------------------------------------
/src/main/resources/model/THzxxEntity.java:
--------------------------------------------------------------------------------
1 | package main.resources.model;
2 |
3 | import javax.persistence.*;
4 | import java.math.BigDecimal;
5 | import java.util.Objects;
6 |
7 | @Entity
8 | @Table(name = "t_hzxx", schema = "hospital", catalog = "")
9 | public class THzxxEntity {
10 | private String hzbh;
11 | private String hzmc;
12 | private String pyzs;
13 | private String ksbh;
14 | private byte sfzj;
15 | private int ghrs;
16 | private BigDecimal ghfy;
17 |
18 | @Id
19 | @Column(name = "HZBH", nullable = false, length = 6)
20 | public String getHzbh() {
21 | return hzbh;
22 | }
23 |
24 | public void setHzbh(String hzbh) {
25 | this.hzbh = hzbh;
26 | }
27 |
28 | @Basic
29 | @Column(name = "HZMC", nullable = false, length = 12)
30 | public String getHzmc() {
31 | return hzmc;
32 | }
33 |
34 | public void setHzmc(String hzmc) {
35 | this.hzmc = hzmc;
36 | }
37 |
38 | @Basic
39 | @Column(name = "PYZS", nullable = false, length = 4)
40 | public String getPyzs() {
41 | return pyzs;
42 | }
43 |
44 | public void setPyzs(String pyzs) {
45 | this.pyzs = pyzs;
46 | }
47 |
48 | @Basic
49 | @Column(name = "KSBH", nullable = false, length = 6)
50 | public String getKsbh() {
51 | return ksbh;
52 | }
53 |
54 | public void setKsbh(String ksbh) {
55 | this.ksbh = ksbh;
56 | }
57 |
58 | @Basic
59 | @Column(name = "SFZJ", nullable = false)
60 | public byte getSfzj() {
61 | return sfzj;
62 | }
63 |
64 | public void setSfzj(byte sfzj) {
65 | this.sfzj = sfzj;
66 | }
67 |
68 | @Basic
69 | @Column(name = "GHRS", nullable = false)
70 | public int getGhrs() {
71 | return ghrs;
72 | }
73 |
74 | public void setGhrs(int ghrs) {
75 | this.ghrs = ghrs;
76 | }
77 |
78 | @Basic
79 | @Column(name = "GHFY", nullable = false, precision = 2)
80 | public BigDecimal getGhfy() {
81 | return ghfy;
82 | }
83 |
84 | public void setGhfy(BigDecimal ghfy) {
85 | this.ghfy = ghfy;
86 | }
87 |
88 | @Override
89 | public boolean equals(Object o) {
90 | if (this == o) return true;
91 | if (o == null || getClass() != o.getClass()) return false;
92 | THzxxEntity that = (THzxxEntity) o;
93 | return sfzj == that.sfzj &&
94 | ghrs == that.ghrs &&
95 | Objects.equals(hzbh, that.hzbh) &&
96 | Objects.equals(hzmc, that.hzmc) &&
97 | Objects.equals(pyzs, that.pyzs) &&
98 | Objects.equals(ksbh, that.ksbh) &&
99 | Objects.equals(ghfy, that.ghfy);
100 | }
101 |
102 | @Override
103 | public int hashCode() {
104 |
105 | return Objects.hash(hzbh, hzmc, pyzs, ksbh, sfzj, ghrs, ghfy);
106 | }
107 | }
108 |
--------------------------------------------------------------------------------
/src/main/resources/model/TKsysEntity.java:
--------------------------------------------------------------------------------
1 | package main.resources.model;
2 |
3 | import javax.persistence.*;
4 | import java.sql.Timestamp;
5 | import java.util.Objects;
6 |
7 | @Entity
8 | @Table(name = "t_ksys", schema = "hospital", catalog = "")
9 | public class TKsysEntity {
10 | private String ysbh;
11 | private String ksbh;
12 | private String ysmc;
13 | private String ptzs;
14 | private String dlkl;
15 | private byte sfzj;
16 | private Timestamp dlrq;
17 |
18 | @Id
19 | @Column(name = "YSBH", nullable = false, length = 6)
20 | public String getYsbh() {
21 | return ysbh;
22 | }
23 |
24 | public void setYsbh(String ysbh) {
25 | this.ysbh = ysbh;
26 | }
27 |
28 | @Basic
29 | @Column(name = "KSBH", nullable = false, length = 6)
30 | public String getKsbh() {
31 | return ksbh;
32 | }
33 |
34 | public void setKsbh(String ksbh) {
35 | this.ksbh = ksbh;
36 | }
37 |
38 | @Basic
39 | @Column(name = "YSMC", nullable = false, length = 10)
40 | public String getYsmc() {
41 | return ysmc;
42 | }
43 |
44 | public void setYsmc(String ysmc) {
45 | this.ysmc = ysmc;
46 | }
47 |
48 | @Basic
49 | @Column(name = "PTZS", nullable = false, length = 4)
50 | public String getPtzs() {
51 | return ptzs;
52 | }
53 |
54 | public void setPtzs(String ptzs) {
55 | this.ptzs = ptzs;
56 | }
57 |
58 | @Basic
59 | @Column(name = "DLKL", nullable = false, length = 8)
60 | public String getDlkl() {
61 | return dlkl;
62 | }
63 |
64 | public void setDlkl(String dlkl) {
65 | this.dlkl = dlkl;
66 | }
67 |
68 | @Basic
69 | @Column(name = "SFZJ", nullable = false)
70 | public byte getSfzj() {
71 | return sfzj;
72 | }
73 |
74 | public void setSfzj(byte sfzj) {
75 | this.sfzj = sfzj;
76 | }
77 |
78 | @Basic
79 | @Column(name = "DLRQ", nullable = true)
80 | public Timestamp getDlrq() {
81 | return dlrq;
82 | }
83 |
84 | public void setDlrq(Timestamp dlrq) {
85 | this.dlrq = dlrq;
86 | }
87 |
88 | @Override
89 | public boolean equals(Object o) {
90 | if (this == o) return true;
91 | if (o == null || getClass() != o.getClass()) return false;
92 | TKsysEntity that = (TKsysEntity) o;
93 | return sfzj == that.sfzj &&
94 | Objects.equals(ysbh, that.ysbh) &&
95 | Objects.equals(ksbh, that.ksbh) &&
96 | Objects.equals(ysmc, that.ysmc) &&
97 | Objects.equals(ptzs, that.ptzs) &&
98 | Objects.equals(dlkl, that.dlkl) &&
99 | Objects.equals(dlrq, that.dlrq);
100 | }
101 |
102 | @Override
103 | public int hashCode() {
104 |
105 | return Objects.hash(ysbh, ksbh, ysmc, ptzs, dlkl, sfzj, dlrq);
106 | }
107 | }
108 |
--------------------------------------------------------------------------------
/src/main/resources/model/TGhxxEntity.java:
--------------------------------------------------------------------------------
1 | package main.resources.model;
2 |
3 | import javax.persistence.*;
4 | import java.math.BigDecimal;
5 | import java.sql.Timestamp;
6 | import java.util.Objects;
7 |
8 | @Entity
9 | @Table(name = "t_ghxx", schema = "hospital", catalog = "")
10 | public class TGhxxEntity {
11 | private String ghbh;
12 | private String hzbh;
13 | private String ysbh;
14 | private String brbh;
15 | private int ghrc;
16 | private byte thbz;
17 | private BigDecimal ghfy;
18 | private Timestamp rqsj;
19 |
20 | @Id
21 | @Column(name = "GHBH", nullable = false, length = 6)
22 | public String getGhbh() {
23 | return ghbh;
24 | }
25 |
26 | public void setGhbh(String ghbh) {
27 | this.ghbh = ghbh;
28 | }
29 |
30 | @Basic
31 | @Column(name = "HZBH", nullable = false, length = 6)
32 | public String getHzbh() {
33 | return hzbh;
34 | }
35 |
36 | public void setHzbh(String hzbh) {
37 | this.hzbh = hzbh;
38 | }
39 |
40 | @Basic
41 | @Column(name = "YSBH", nullable = false, length = 6)
42 | public String getYsbh() {
43 | return ysbh;
44 | }
45 |
46 | public void setYsbh(String ysbh) {
47 | this.ysbh = ysbh;
48 | }
49 |
50 | @Basic
51 | @Column(name = "BRBH", nullable = false, length = 6)
52 | public String getBrbh() {
53 | return brbh;
54 | }
55 |
56 | public void setBrbh(String brbh) {
57 | this.brbh = brbh;
58 | }
59 |
60 | @Basic
61 | @Column(name = "GHRC", nullable = false)
62 | public int getGhrc() {
63 | return ghrc;
64 | }
65 |
66 | public void setGhrc(int ghrc) {
67 | this.ghrc = ghrc;
68 | }
69 |
70 | @Basic
71 | @Column(name = "THBZ", nullable = false)
72 | public byte getThbz() {
73 | return thbz;
74 | }
75 |
76 | public void setThbz(byte thbz) {
77 | this.thbz = thbz;
78 | }
79 |
80 | @Basic
81 | @Column(name = "GHFY", nullable = false, precision = 2)
82 | public BigDecimal getGhfy() {
83 | return ghfy;
84 | }
85 |
86 | public void setGhfy(BigDecimal ghfy) {
87 | this.ghfy = ghfy;
88 | }
89 |
90 | @Basic
91 | @Column(name = "RQSJ", nullable = false)
92 | public Timestamp getRqsj() {
93 | return rqsj;
94 | }
95 |
96 | public void setRqsj(Timestamp rqsj) {
97 | this.rqsj = rqsj;
98 | }
99 |
100 | @Override
101 | public boolean equals(Object o) {
102 | if (this == o) return true;
103 | if (o == null || getClass() != o.getClass()) return false;
104 | TGhxxEntity that = (TGhxxEntity) o;
105 | return ghrc == that.ghrc &&
106 | thbz == that.thbz &&
107 | Objects.equals(ghbh, that.ghbh) &&
108 | Objects.equals(hzbh, that.hzbh) &&
109 | Objects.equals(ysbh, that.ysbh) &&
110 | Objects.equals(brbh, that.brbh) &&
111 | Objects.equals(ghfy, that.ghfy) &&
112 | Objects.equals(rqsj, that.rqsj);
113 | }
114 |
115 | @Override
116 | public int hashCode() {
117 |
118 | return Objects.hash(ghbh, hzbh, ysbh, brbh, ghrc, thbz, ghfy, rqsj);
119 | }
120 | }
121 |
--------------------------------------------------------------------------------
/src/main/resources/view/MainWindow_Doctor.fxml:
--------------------------------------------------------------------------------
1 |
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 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
--------------------------------------------------------------------------------
/out/production/Hospital/main/resources/view/MainWindow_Doctor.fxml:
--------------------------------------------------------------------------------
1 |
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 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
--------------------------------------------------------------------------------
/src/main/resources/view/MainWindow_Patient.fxml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
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 |
--------------------------------------------------------------------------------
/out/production/Hospital/main/resources/view/MainWindow_Patient.fxml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
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 |
--------------------------------------------------------------------------------
/src/main/java/layout/AutoCompleteComboBox.java:
--------------------------------------------------------------------------------
1 | package main.java.layout;
2 |
3 | import com.jfoenix.controls.JFXAutoCompletePopup;
4 | import javafx.scene.control.ComboBox;
5 | import javafx.scene.control.TextField;
6 |
7 | public class AutoCompleteComboBox {
8 | public AutoCompleteComboBox(final ComboBox comboBox) {
9 | JFXAutoCompletePopup autoCompletePopup = new JFXAutoCompletePopup<>();
10 | autoCompletePopup.setSelectionHandler(e -> {
11 | comboBox.setValue(e.getObject());
12 | });
13 | TextField editor = comboBox.getEditor();
14 | editor.textProperty().addListener((o, oldVal, newVal) -> {
15 | autoCompletePopup.filter(item -> item.toString().toLowerCase().contains(editor.getText().toLowerCase()));
16 | if (autoCompletePopup.getFilteredSuggestions().isEmpty()
17 | || comboBox.showingProperty().get())
18 | autoCompletePopup.hide();
19 | else
20 | autoCompletePopup.show(editor);
21 | });
22 | // editor.focusedProperty().addListener((o, oldVal, newVal) -> {
23 | // if (comboBox.showingProperty().get()) {
24 | // autoCompletePopup.hide();
25 | // return;
26 | // }
27 | // if (newVal) {
28 | // autoCompletePopup.getSuggestions().clear();
29 | // autoCompletePopup.getSuggestions().addAll(comboBox.getItems());
30 | // autoCompletePopup.show(editor);
31 | // }
32 | // });
33 | comboBox.getSelectionModel().selectedItemProperty().addListener((o, oldVal, newVal) -> {
34 | autoCompletePopup.hide();
35 | });
36 | }
37 | }
38 |
39 | //import javafx.collections.FXCollections;
40 | //import javafx.collections.ObservableList;
41 | //import javafx.event.EventHandler;
42 | //import javafx.scene.control.ComboBox;
43 | //import javafx.scene.input.KeyCode;
44 | //import javafx.scene.input.KeyEvent;
45 | //import javafx.scene.input.MouseEvent;
46 | //
47 | //public class AutoCompleteComboBoxListener implements EventHandler {
48 | //
49 | // private ComboBox comboBox;
50 | // private StringBuilder sb;
51 | // private ObservableList data;
52 | // private boolean moveCaretToPos = false;
53 | // private int caretPos;
54 | //
55 | // public AutoCompleteComboBoxListener(final ComboBox comboBox) {
56 | // this.comboBox = comboBox;
57 | // sb = new StringBuilder();
58 | // data = comboBox.getItems();
59 | //
60 | // this.comboBox.setEditable(true);
61 | // this.comboBox.getEditor().setOnMouseClicked(new EventHandler() {
62 | // @Override
63 | // public void handle(MouseEvent event) {
64 | // System.out.println("Clicked!");
65 | //// comboBox.show();
66 | // ObservableList list = FXCollections.observableArrayList();
67 | // for (int i=0; i() {
81 | //
82 | // @Override
83 | // public void handle(KeyEvent t) {
84 | // comboBox.hide();
85 | // }
86 | // });
87 | // this.comboBox.setOnKeyReleased(AutoCompleteComboBoxListener.this);
88 | // }
89 | //
90 | // @Override
91 | // public void handle(KeyEvent event) {
92 | //
93 | // if(event.getCode() == KeyCode.UP) {
94 | // caretPos = -1;
95 | // moveCaret(comboBox.getEditor().getText().length());
96 | // return;
97 | // } else if(event.getCode() == KeyCode.DOWN) {
98 | // if(!comboBox.isShowing()) {
99 | // comboBox.show();
100 | // }
101 | // caretPos = -1;
102 | // moveCaret(comboBox.getEditor().getText().length());
103 | // return;
104 | // } else if(event.getCode() == KeyCode.BACK_SPACE) {
105 | // moveCaretToPos = true;
106 | // caretPos = comboBox.getEditor().getCaretPosition();
107 | // } else if(event.getCode() == KeyCode.DELETE) {
108 | // moveCaretToPos = true;
109 | // caretPos = comboBox.getEditor().getCaretPosition();
110 | // }
111 | //
112 | // if (event.getCode() == KeyCode.ENTER) {
113 | // Object selectedItemText = comboBox.getValue();
114 | // if (selectedItemText!=null)
115 | // comboBox.getEditor().setText(selectedItemText.toString());
116 | // return;
117 | // }
118 | // if (event.getCode() == KeyCode.RIGHT || event.getCode() == KeyCode.LEFT
119 | // || event.isControlDown() || event.getCode() == KeyCode.HOME
120 | // || event.getCode() == KeyCode.END || event.getCode() == KeyCode.TAB) {
121 | // return;
122 | // }
123 | //
124 | // ObservableList list = FXCollections.observableArrayList();
125 | // for (int i=0; i {
53 | if (newVal)
54 | doctorRadioButton.setSelected(false);
55 | else
56 | doctorRadioButton.setSelected(true);
57 | });
58 | doctorRadioButton.selectedProperty().addListener((o, oldVal, newVal) -> {
59 | if (newVal)
60 | patientRadioButton.setSelected(false);
61 | else
62 | patientRadioButton.setSelected(true);
63 | });
64 | idInput.textProperty().addListener(new ChangeListener() {
65 | @Override
66 | public void changed(ObservableValue extends String> observable, String oldValue, String newValue) {
67 | if (!passwordInput.getText().isEmpty()) {
68 | passwordInput.clear();
69 | }
70 | }
71 | });
72 | idInput.focusedProperty().addListener(new ChangeListener() {
73 | @Override
74 | public void changed(ObservableValue extends Boolean> observable, Boolean oldValue, Boolean newValue) {
75 | Platform.runLater(new Runnable() {
76 | @Override
77 | public void run() {
78 | if (idInput.isFocused()) {
79 | userLabel.setVisible(false);
80 | }
81 | if (idInput.isFocused() && !idInput.getText().isEmpty()) {
82 | idInput.selectAll();
83 | }
84 | }
85 | });
86 | }
87 | });
88 | passwordInput.focusedProperty().addListener(new ChangeListener() {
89 | @Override
90 | public void changed(ObservableValue extends Boolean> observable, Boolean oldValue, Boolean newValue) {
91 | if (passwordInput.isFocused()) {
92 | passwordLabel.setVisible(false);
93 | }
94 | }
95 | });
96 | button.setOnAction(new EventHandler() {
97 | @Override
98 | public void handle(ActionEvent event) {
99 | if (idInput.getText().isEmpty()) {
100 | userLabel.setVisible(true);
101 | userLabel.setText("User id empty");
102 | }
103 | else if (passwordInput.getText().isEmpty()) {
104 | passwordLabel.setVisible(true);
105 | passwordLabel.setText("Password empty");
106 | }
107 | else {
108 | String id = idInput.getText();
109 | String password = passwordInput.getText();
110 | Session session = Main.factory.openSession();
111 | Transaction tx = null;
112 | try {
113 | tx = session.beginTransaction();
114 | Query query = session.createQuery("select count(*) from TBrxxEntity where brbh=:brbh and dlkl=:dlkl");
115 | query.setParameter("brbh", id);
116 | query.setParameter("dlkl", password);
117 | Long exists = (Long) query.list().get(0);
118 | if (exists==0) {
119 | System.out.println("User not exists or incorrect password");
120 | Alert alert = new Alert(Alert.AlertType.WARNING, "User not exists or incorrect password", ButtonType.OK);
121 | alert.getDialogPane().setMinHeight(Region.USE_PREF_SIZE);
122 | alert.initStyle(StageStyle.UNDECORATED);
123 | alert.setHeaderText(null);
124 | alert.setGraphic(null);
125 | alert.show();
126 | return;
127 | }
128 | Main.id = idInput.getText();
129 | if (Main.curStage != null)
130 | Main.curStage.close();
131 | if (patientRadioButton.isSelected()) {
132 | Main.isPatient = true;
133 | try {
134 | FXMLLoader loader = new FXMLLoader(getClass().getResource("../../resources/view/MainWindow_Patient.fxml"));
135 | BorderPane borderPane = loader.load();
136 | Main.curStage.setScene(new Scene(borderPane, borderPane.getPrefWidth(), borderPane.getPrefHeight()));
137 | Main.curStage.show();
138 | }
139 | catch (IOException ioexception) {
140 | System.out.print(ioexception.toString());
141 | System.exit(1);
142 | }
143 | }
144 | else {
145 | Main.isPatient = false;
146 | try {
147 | FXMLLoader loader = new FXMLLoader(getClass().getResource("../../resources/view/MainWindow_Doctor.fxml"));
148 | BorderPane borderPane = loader.load();
149 | Main.curStage.setScene(new Scene(borderPane, borderPane.getPrefWidth(), borderPane.getPrefHeight()));
150 | Main.curStage.show();
151 | }
152 | catch (IOException ioexception) {
153 | System.out.print(ioexception.toString());
154 | System.exit(1);
155 | }
156 | }
157 | }
158 | catch (HibernateException e) {
159 | if (tx!=null)
160 | tx.rollback();
161 | e.printStackTrace();
162 | }
163 | finally {
164 | session.close();
165 | }
166 | }
167 | }
168 | });
169 | }
170 | }
171 |
--------------------------------------------------------------------------------
/src/main/java/controllers/MainWindow_Doctor.java:
--------------------------------------------------------------------------------
1 | package main.java.controllers;
2 |
3 | import com.jfoenix.controls.*;
4 | import com.jfoenix.controls.datamodels.treetable.RecursiveTreeObject;
5 | import javafx.animation.Animation;
6 | import javafx.animation.KeyFrame;
7 | import javafx.animation.Timeline;
8 | import javafx.beans.property.*;
9 | import javafx.collections.FXCollections;
10 | import javafx.collections.ObservableList;
11 | import javafx.fxml.Initializable;
12 | import javafx.scene.control.DatePicker;
13 | import javafx.scene.control.Label;
14 | import javafx.scene.control.TreeItem;
15 | import javafx.scene.control.TreeTableColumn;
16 | import javafx.scene.layout.Pane;
17 | import javafx.util.Duration;
18 | import main.java.Main;
19 | import main.resources.model.*;
20 | import org.hibernate.HibernateException;
21 | import org.hibernate.Session;
22 | import org.hibernate.Transaction;
23 | import org.hibernate.query.Query;
24 |
25 | import java.net.URL;
26 | import java.sql.Timestamp;
27 | import java.text.DateFormat;
28 | import java.text.SimpleDateFormat;
29 | import java.time.LocalDate;
30 | import java.time.LocalDateTime;
31 | import java.time.LocalTime;
32 | import java.util.ArrayList;
33 | import java.util.Iterator;
34 | import java.util.List;
35 | import java.util.ResourceBundle;
36 |
37 | public class MainWindow_Doctor implements Initializable {
38 | public JFXTreeTableView patientTable;
39 | public JFXTreeTableView incomeTable;
40 | public DatePicker startDatePicker;
41 | public DatePicker endDatePicker;
42 | public JFXTimePicker startTimePicker;
43 | public JFXTimePicker endTimePicker;
44 | public Label timeLabel2;
45 | public JFXTextField filterField;
46 | public Label welcomeLabel;
47 | public Pane titlePane;
48 |
49 | private LocalDateTime startDateTime;
50 | private LocalDateTime endDateTime;
51 |
52 | class Delta { double x,y; }
53 | private final Delta dragDelta = new Delta();
54 |
55 | @Override
56 | public void initialize(URL location, ResourceBundle resources) {
57 | // set titlePane drag event
58 | titlePane.setOnMousePressed(e -> {
59 | dragDelta.x = Main.curStage.getX() - e.getScreenX();
60 | dragDelta.y = Main.curStage.getY() - e.getScreenY();
61 | });
62 | titlePane.setOnMouseDragged(e -> {
63 | Main.curStage.setX(e.getScreenX()+dragDelta.x);
64 | Main.curStage.setY(e.getScreenY()+dragDelta.y);
65 | });
66 |
67 | // Create tables
68 | JFXTreeTableColumn idColumn = new JFXTreeTableColumn<>("挂号编号");
69 | idColumn.setCellValueFactory((TreeTableColumn.CellDataFeatures param) -> {
70 | if (idColumn.validateValue(param)) {
71 | return param.getValue().getValue().id;
72 | } else {
73 | return idColumn.getComputedValue(param);
74 | }
75 | });
76 | JFXTreeTableColumn nameColumn = new JFXTreeTableColumn<>("病人名称");
77 | nameColumn.setCellValueFactory((TreeTableColumn.CellDataFeatures param) -> {
78 | if (nameColumn.validateValue(param)) {
79 | return param.getValue().getValue().name;
80 | } else {
81 | return nameColumn.getComputedValue(param);
82 | }
83 | });
84 | JFXTreeTableColumn timeColumn = new JFXTreeTableColumn<>("挂号日期时间");
85 | timeColumn.setCellValueFactory((TreeTableColumn.CellDataFeatures param) -> {
86 | if (timeColumn.validateValue(param)) {
87 | return param.getValue().getValue().time;
88 | } else {
89 | return timeColumn.getComputedValue(param);
90 | }
91 | });
92 | JFXTreeTableColumn typeColumn = new JFXTreeTableColumn<>("号种类别");
93 | typeColumn.setCellValueFactory((TreeTableColumn.CellDataFeatures param) -> {
94 | if (typeColumn.validateValue(param)) {
95 | return param.getValue().getValue().type;
96 | } else {
97 | return typeColumn.getComputedValue(param);
98 | }
99 | });
100 | patientTable.setId("tablePatient");
101 |
102 | JFXTreeTableColumn departmentColumn = new JFXTreeTableColumn<>("科室名称");
103 | departmentColumn.setCellValueFactory((TreeTableColumn.CellDataFeatures param) -> {
104 | if (departmentColumn.validateValue(param)) {
105 | return param.getValue().getValue().department;
106 | } else {
107 | return departmentColumn.getComputedValue(param);
108 | }
109 | });
110 | JFXTreeTableColumn idColumn2 = new JFXTreeTableColumn<>("医生编号");
111 | idColumn2.setCellValueFactory((TreeTableColumn.CellDataFeatures param) -> {
112 | if (idColumn2.validateValue(param)) {
113 | return param.getValue().getValue().id;
114 | } else {
115 | return idColumn2.getComputedValue(param);
116 | }
117 | });
118 | JFXTreeTableColumn nameColumn2 = new JFXTreeTableColumn<>("医生名称");
119 | nameColumn2.setCellValueFactory((TreeTableColumn.CellDataFeatures param) -> {
120 | if (nameColumn2.validateValue(param)) {
121 | return param.getValue().getValue().name;
122 | } else {
123 | return nameColumn2.getComputedValue(param);
124 | }
125 | });
126 | JFXTreeTableColumn typeColumn2 = new JFXTreeTableColumn<>("号种类别");
127 | typeColumn2.setCellValueFactory((TreeTableColumn.CellDataFeatures param) -> {
128 | if (typeColumn2.validateValue(param)) {
129 | return param.getValue().getValue().type;
130 | } else {
131 | return typeColumn2.getComputedValue(param);
132 | }
133 | });
134 | JFXTreeTableColumn numberColumn = new JFXTreeTableColumn<>("挂号人次");
135 | numberColumn.setCellValueFactory((TreeTableColumn.CellDataFeatures param) -> {
136 | if (numberColumn.validateValue(param)) {
137 | return param.getValue().getValue().number;
138 | } else {
139 | return numberColumn.getComputedValue(param);
140 | }
141 | });
142 | JFXTreeTableColumn incomeColumn = new JFXTreeTableColumn<>("收入合计");
143 | incomeColumn.setCellValueFactory((TreeTableColumn.CellDataFeatures param) -> {
144 | if (incomeColumn.validateValue(param)) {
145 | return param.getValue().getValue().income;
146 | } else {
147 | return incomeColumn.getComputedValue(param);
148 | }
149 | });
150 | incomeTable.setId("tableIncome");
151 |
152 | patientTable.setShowRoot(false);
153 | patientTable.setEditable(false);
154 | patientTable.getColumns().setAll(idColumn, nameColumn, timeColumn, typeColumn);
155 | patientTable.setColumnResizePolicy(JFXTreeTableView.CONSTRAINED_RESIZE_POLICY);
156 |
157 | incomeTable.setShowRoot(false);
158 | incomeTable.setEditable(false);
159 | incomeTable.getColumns().setAll(departmentColumn, idColumn2, nameColumn2, typeColumn2, numberColumn, incomeColumn);
160 | incomeTable.setColumnResizePolicy(JFXTreeTableView.CONSTRAINED_RESIZE_POLICY);
161 |
162 | //Create data
163 | ObservableList patients = FXCollections.observableArrayList();
164 | Session session = Main.factory.openSession();
165 | Transaction tx = null;
166 | try {
167 | tx = session.beginTransaction();
168 | // set welcome text
169 | Query query = session.createQuery("from TKsysEntity where ysbh=:ysbh");
170 | query.setParameter("ysbh", Main.id);
171 | TKsysEntity tKsysEntity = (TKsysEntity) query.list().get(0);
172 | welcomeLabel.setText(tKsysEntity.getYsmc().substring(0, 1)+"医生, 您好");
173 | query = session.createQuery("from TGhxxEntity where ysbh=:ysbh and thbz=0");
174 | query.setParameter("ysbh", Main.id);
175 | List ghxxs = query.list();
176 | for (Iterator it = ghxxs.iterator(); it.hasNext(); ) {
177 | TGhxxEntity tGhxxEntity = (TGhxxEntity) it.next();
178 | query = session.createQuery("from TBrxxEntity where brbh=:brbh");
179 | query.setParameter("brbh", tGhxxEntity.getBrbh());
180 | TBrxxEntity tBrxxEntity = (TBrxxEntity) query.list().get(0);
181 | query = session.createQuery("from THzxxEntity where hzbh=:hzbh");
182 | query.setParameter("hzbh", tGhxxEntity.getHzbh());
183 | THzxxEntity tHzxxEntity = (THzxxEntity) query.list().get(0);
184 | String type = tHzxxEntity.getSfzj()==1?"专家号":"普通号";
185 | DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
186 | Patient patient = new Patient(tGhxxEntity.getGhbh(), tBrxxEntity.getBrmc(), dateFormat.format(tGhxxEntity.getRqsj()).toString(), type);
187 | patients.add(patient);
188 | }
189 | }
190 | catch (HibernateException e) {
191 | if (tx!=null)
192 | tx.rollback();
193 | e.printStackTrace();
194 | }
195 | finally {
196 | session.close();
197 | }
198 | final TreeItem patientRoot = new RecursiveTreeItem<>(patients, RecursiveTreeObject::getChildren);
199 | patientTable.setRoot(patientRoot);
200 | updateIncome(Timestamp.valueOf(LocalDate.EPOCH.atStartOfDay()), new Timestamp(System.currentTimeMillis()));
201 |
202 | DateFormat datetimeFormat = new SimpleDateFormat("yyyy年MM月dd日 HH:mm:ss");
203 | final Timeline timeline = new Timeline(
204 | new KeyFrame(
205 | Duration.millis(500),
206 | event -> {
207 | // Dispaly current time and refresh in every second
208 | Timestamp timestamp = new Timestamp(System.currentTimeMillis());
209 | String curTimeStr = datetimeFormat.format(timestamp);
210 | timeLabel2.setText(curTimeStr);
211 | }
212 | )
213 | );
214 | timeline.setCycleCount(Animation.INDEFINITE);
215 | timeline.play();
216 |
217 | // Text search
218 | filterField.textProperty().addListener((o, oldVal, newVal) -> {
219 | patientTable.setPredicate(patientProp -> {
220 | final Patient patient = patientProp.getValue();
221 | return patient.getId().contains(newVal)
222 | || patient.getName().contains(newVal)
223 | || patient.getType().contains(newVal);
224 | });
225 | incomeTable.setPredicate(incomeProp -> {
226 | final Income income = incomeProp.getValue();
227 | return income.getDepartment().contains(newVal)
228 | || income.getId().contains(newVal)
229 | || income.getName().contains(newVal)
230 | || income.getType().contains(newVal);
231 | });
232 | });
233 |
234 | // Time search
235 | startDatePicker.valueProperty().addListener((o, oldVal, newVal) -> {
236 | LocalDate startDate = LocalDate.EPOCH;
237 | if (newVal!=null)
238 | startDate = newVal;
239 | startDateTime = startDate.atStartOfDay();
240 | LocalTime startTime = startTimePicker.getValue();
241 | if (startTime!=null)
242 | startDateTime = startDate.atTime(startTime.getHour(), startTime.getMinute());
243 | if (endDateTime!=null)
244 | updateIncome(Timestamp.valueOf(startDateTime), Timestamp.valueOf(endDateTime));
245 | else
246 | updateIncome(Timestamp.valueOf(startDateTime), new Timestamp(System.currentTimeMillis()));
247 | });
248 | startTimePicker.valueProperty().addListener((o, oldVal, newVal) -> {
249 | LocalTime startTime = LocalTime.MIN;
250 | if (newVal!=null)
251 | startTime = newVal;
252 | LocalDate startDate = startDatePicker.getValue();
253 | if (startDate!=null)
254 | startDateTime = startTime.atDate(startDate);
255 | else
256 | startDateTime = startTime.atDate(LocalDate.EPOCH);
257 | if (endDateTime!=null)
258 | updateIncome(Timestamp.valueOf(startDateTime), Timestamp.valueOf(endDateTime));
259 | else
260 | updateIncome(Timestamp.valueOf(startDateTime), new Timestamp(System.currentTimeMillis()));
261 | });
262 | endDatePicker.valueProperty().addListener((o, oldVal, newVal) -> {
263 | LocalDate endDate = LocalDate.now();
264 | if (newVal!=null)
265 | endDate = newVal;
266 | endDateTime = endDate.atStartOfDay();
267 | LocalTime endTime = endTimePicker.getValue();
268 | if (endTime!=null)
269 | endDateTime = endDate.atTime(endTime);
270 | if (startDateTime!=null)
271 | updateIncome(Timestamp.valueOf(startDateTime), Timestamp.valueOf(endDateTime));
272 | else
273 | updateIncome(Timestamp.valueOf(LocalDate.EPOCH.atStartOfDay()), Timestamp.valueOf(endDateTime));
274 | });
275 | endTimePicker.valueProperty().addListener((o, oldVal, newVal) -> {
276 | LocalTime endTime = LocalTime.MAX;
277 | if (newVal!=null)
278 | endTime = newVal;
279 | LocalDate endDate = endDatePicker.getValue();
280 | if (endDate!=null)
281 | endDateTime = endTime.atDate(endDate);
282 | else
283 | endDateTime = endTime.atDate(LocalDate.now());
284 | if (startDateTime!=null)
285 | updateIncome(Timestamp.valueOf(startDateTime), Timestamp.valueOf(endDateTime));
286 | else
287 | updateIncome(Timestamp.valueOf(LocalDate.EPOCH.atStartOfDay()), Timestamp.valueOf(endDateTime));
288 | });
289 | }
290 |
291 | private void updateIncome(Timestamp startTime, Timestamp endTime) {
292 | ObservableList incomes = FXCollections.observableArrayList();
293 | Session session = Main.factory.openSession();
294 | Transaction tx = null;
295 | try {
296 | Query query = session.createQuery("from TGhxxEntity where rqsj>=:startTime and rqsj<=:endTime and thbz=0 order by ysbh");
297 | query.setParameter("startTime", startTime);
298 | query.setParameter("endTime", endTime);
299 | List ghList = query.list();
300 | ArrayList incomeArrayList = new ArrayList();
301 | int i=0;
302 | for (Iterator it=ghList.iterator(); it.hasNext(); ) {
303 | TGhxxEntity tGhxxEntity = (TGhxxEntity) it.next();
304 | query = session.createQuery("from TKsysEntity where ysbh=:ysbh");
305 | query.setParameter("ysbh", tGhxxEntity.getYsbh());
306 | TKsysEntity tKsysEntity = (TKsysEntity) query.list().get(0);
307 | query = session.createQuery("from TKsxxEntity where ksbh=:ksbh");
308 | query.setParameter("ksbh", tKsysEntity.getKsbh());
309 | TKsxxEntity tKsxxEntity = (TKsxxEntity) query.list().get(0);
310 | query = session.createQuery("from THzxxEntity where hzbh=:hzbh");
311 | query.setParameter("hzbh", tGhxxEntity.getHzbh());
312 | THzxxEntity tHzxxEntity = (THzxxEntity) query.list().get(0);
313 | if (incomeArrayList.isEmpty() || !tGhxxEntity.getYsbh().equals(incomeArrayList.get(i-1).getId())) {
314 | if (!incomeArrayList.isEmpty()) {
315 | if (incomeArrayList.get(i-1).getNumber()!=0)
316 | incomes.add(incomeArrayList.get(i-1));
317 | if (incomeArrayList.get(i-2).getNumber()!=0)
318 | incomes.add(incomeArrayList.get(i-2));
319 | }
320 | incomeArrayList.add(new Income(
321 | tKsxxEntity.getKsmc(),
322 | tGhxxEntity.getYsbh(),
323 | tKsysEntity.getYsmc(),
324 | "普通号",
325 | 0,
326 | 0.
327 | ));
328 | incomeArrayList.add(new Income(
329 | tKsxxEntity.getKsmc(),
330 | tGhxxEntity.getYsbh(),
331 | tKsysEntity.getYsmc(),
332 | "专家号",
333 | 0,
334 | 0.
335 | ));
336 | i+=2;
337 | if (tHzxxEntity.getSfzj()==1) {
338 | incomeArrayList.get(i-1).setNumber(1);
339 | incomeArrayList.get(i-1).setIncome(tGhxxEntity.getGhfy().doubleValue());
340 | }
341 | else {
342 | incomeArrayList.get(i-2).setNumber(1);
343 | incomeArrayList.get(i-2).setIncome(tGhxxEntity.getGhfy().doubleValue());
344 | }
345 | }
346 | else {
347 | if (tHzxxEntity.getSfzj()==1) {
348 | incomeArrayList.get(i-1).setNumber(incomeArrayList.get(i-1).getNumber()+1);
349 | incomeArrayList.get(i-1).setIncome(incomeArrayList.get(i-1).getIncome()+tGhxxEntity.getGhfy().intValue());
350 | }
351 | else {
352 | incomeArrayList.get(i-2).setNumber(incomeArrayList.get(i-2).getNumber()+1);
353 | incomeArrayList.get(i-2).setIncome(incomeArrayList.get(i-2).getIncome()+tGhxxEntity.getGhfy().intValue());
354 | }
355 | }
356 | }
357 | if (!incomeArrayList.isEmpty()) {
358 | if (incomeArrayList.get(i-1).getNumber()!=0)
359 | incomes.add(incomeArrayList.get(i-1));
360 | if (incomeArrayList.get(i-2).getNumber()!=0)
361 | incomes.add(incomeArrayList.get(i-2));
362 | }
363 | // build tree
364 | }
365 | catch (HibernateException e) {
366 | System.out.println(e.toString());
367 | tx.rollback();
368 | }
369 | finally {
370 | session.close();
371 | }
372 | final TreeItem incomeRoot = new RecursiveTreeItem<>(incomes, RecursiveTreeObject::getChildren);
373 | incomeTable.setRoot(incomeRoot);
374 | }
375 |
376 | private static final class Income extends RecursiveTreeObject {
377 | public StringProperty department;
378 | public StringProperty id;
379 | public StringProperty name;
380 | public StringProperty type;
381 | public IntegerProperty number;
382 | public DoubleProperty income;
383 |
384 | public Income() {
385 |
386 | }
387 | public Income(String department, String id, String name, String type, Integer number, Double income) {
388 | this.department = new SimpleStringProperty(department);
389 | this.id = new SimpleStringProperty(id);
390 | this.name = new SimpleStringProperty(name);
391 | this.type = new SimpleStringProperty(type);
392 | this.number = new SimpleIntegerProperty(number);
393 | this.income = new SimpleDoubleProperty(income);
394 | }
395 |
396 | public String getDepartment() {
397 | return department.get();
398 | }
399 |
400 | public String getId() {
401 | return id.get();
402 | }
403 |
404 | public String getName() {
405 | return name.get();
406 | }
407 |
408 | public String getType() {
409 | return type.get();
410 | }
411 |
412 | public Integer getNumber() {
413 | return number.get();
414 | }
415 |
416 | public Double getIncome() {
417 | return income.get();
418 | }
419 |
420 | public void setDepartment(String department) {
421 | this.department.set(department);
422 | }
423 |
424 | public void setId(String id) {
425 | this.id.set(id);
426 | }
427 |
428 | public void setName(String name) {
429 | this.name.set(name);
430 | }
431 |
432 | public void setType(String type) {
433 | this.type.set(type);
434 | }
435 |
436 | public void setNumber(Integer number) {
437 | this.number.set(number);
438 | }
439 |
440 | public void setIncome(Double income) {
441 | this.income.set(income);
442 | }
443 | }
444 |
445 | private static final class Patient extends RecursiveTreeObject {
446 | public StringProperty id;
447 | public StringProperty name;
448 | public StringProperty time;
449 | public StringProperty type;
450 |
451 | public Patient() {
452 |
453 | }
454 | public Patient(String id, String name, String time, String type) {
455 | this.id = new SimpleStringProperty(id);
456 | this.name = new SimpleStringProperty(name);
457 | this.time = new SimpleStringProperty(time);
458 | this.type = new SimpleStringProperty(type);
459 | }
460 |
461 | public String getId() { return id.get(); }
462 |
463 | public String getName() {
464 | return name.get();
465 | }
466 |
467 | public String getTime() {
468 | return time.get();
469 | }
470 |
471 | public String getType() {
472 | return type.get();
473 | }
474 |
475 | public void setId(String id) {
476 | this.id.set(id);
477 | }
478 |
479 | public void setName(String name) {
480 | this.name.set(name);
481 | }
482 |
483 | public void setTime(String time) {
484 | this.time.set(time);
485 | }
486 |
487 | public void setType(String type) {
488 | this.type.set(type);
489 | }
490 | }
491 | }
--------------------------------------------------------------------------------
/src/main/java/controllers/MainWindow_Patient.java:
--------------------------------------------------------------------------------
1 | package main.java.controllers;
2 |
3 | import com.jfoenix.controls.*;
4 | import com.jfoenix.controls.datamodels.treetable.RecursiveTreeObject;
5 | import javafx.animation.Animation;
6 | import javafx.animation.KeyFrame;
7 | import javafx.animation.Timeline;
8 | import javafx.application.Platform;
9 | import javafx.beans.binding.Bindings;
10 | import javafx.beans.property.*;
11 | import javafx.beans.value.ChangeListener;
12 | import javafx.beans.value.ObservableValue;
13 | import javafx.collections.FXCollections;
14 | import javafx.collections.ObservableList;
15 | import javafx.event.ActionEvent;
16 | import javafx.event.EventHandler;
17 | import javafx.fxml.FXML;
18 | import javafx.fxml.Initializable;
19 | import javafx.scene.control.*;
20 | import javafx.scene.input.MouseEvent;
21 | import javafx.util.Callback;
22 | import javafx.util.Duration;
23 | import main.java.layout.AutoCompleteComboBox;
24 | import main.java.Main;
25 | import main.resources.model.*;
26 | import org.controlsfx.control.StatusBar;
27 | import org.hibernate.HibernateException;
28 | import org.hibernate.Query;
29 | import org.hibernate.Session;
30 | import org.hibernate.Transaction;
31 |
32 | import java.math.BigDecimal;
33 | import java.net.URL;
34 | import java.sql.Timestamp;
35 | import java.text.DateFormat;
36 | import java.text.SimpleDateFormat;
37 | import java.util.Iterator;
38 | import java.util.List;
39 | import java.util.ResourceBundle;
40 | import java.util.concurrent.TimeUnit;
41 |
42 | @SuppressWarnings("deprecation")
43 | public class MainWindow_Patient implements Initializable {
44 |
45 | public Label feeLabel;
46 | public Label accountLabel;
47 | public JFXComboBox deptBox;
48 | public JFXComboBox doctBox;
49 | public JFXComboBox typeBox;
50 | public JFXComboBox nameBox;
51 | public StatusBar statusBar;
52 | public JFXButton confirmButton;
53 | public JFXButton resetButton;
54 | public Label timeLabel;
55 | public JFXTreeTableView recordTable;
56 | public JFXTextField filterField;
57 | public Label welcomeLabel;
58 | public JFXSpinner spinner;
59 |
60 | private TGhxxEntity tGhxxEntity;
61 |
62 | @FXML
63 | private void handleExit(ActionEvent event) {
64 | Session session = Main.factory.openSession();
65 | Transaction tx = null;
66 | try {
67 | tx = session.beginTransaction();
68 | TBrxxEntity tBrxxEntity = (TBrxxEntity) session.get(TBrxxEntity.class, Main.id);
69 | tBrxxEntity.setDlrq(new Timestamp(System.currentTimeMillis()));
70 | session.update(tBrxxEntity);
71 | tx.commit();
72 | }
73 | catch (HibernateException e) {
74 | if (tx!=null)
75 | tx.rollback();
76 | e.printStackTrace();
77 | }
78 | finally {
79 | session.close();
80 | }
81 | if (Main.curStage!=null)
82 | Main.curStage.close();
83 | }
84 |
85 | @Override
86 | public void initialize(URL location, ResourceBundle resources) {
87 | spinner.setVisible(false);
88 | // set patient id
89 | tGhxxEntity = new TGhxxEntity();
90 | tGhxxEntity.setBrbh(Main.id);
91 | // get dept list
92 | Session session = Main.factory.openSession();
93 | Transaction tx = session.beginTransaction();
94 | try {
95 | List ksxxs = session.createQuery("from TKsxxEntity").list();
96 | deptBox.getItems().clear();
97 | for (Iterator it=ksxxs.iterator(); it.hasNext(); ) {
98 | TKsxxEntity ksxx = (TKsxxEntity)it.next();
99 | deptBox.getItems().add(ksxx.getKsbh() + " " + ksxx.getKsmc() + " " + ksxx.getPyzs());
100 | }
101 | tx.commit();
102 | }
103 | catch (HibernateException e) {
104 | if (tx!=null)
105 | tx.rollback();
106 | e.printStackTrace();
107 | }
108 | finally {
109 | session.close();
110 | }
111 | /*
112 | comboBox列表中的值被选中时,去除编号和拼音字首,只留下名称。
113 | */
114 | deptBox.getSelectionModel().selectedItemProperty().addListener(new ChangeListener() {
115 | @Override
116 | public void changed(ObservableValue extends String> observable, String oldValue, String newValue) {
117 | if (newValue!=null) {
118 | String[] colList = newValue.split(" ");
119 | if (colList.length==3)
120 | Platform.runLater(()->deptBox.getEditor().setText(colList[1]));
121 | }
122 | }
123 | });
124 | doctBox.getSelectionModel().selectedItemProperty().addListener(new ChangeListener() {
125 | @Override
126 | public void changed(ObservableValue extends String> observable, String oldValue, String newValue) {
127 | if (newValue!=null) {
128 | String[] colList = newValue.split(" ");
129 | if (colList.length==3)
130 | Platform.runLater(()->doctBox.getEditor().setText(colList[1]));
131 | }
132 | }
133 | });
134 | nameBox.getSelectionModel().selectedItemProperty().addListener(new ChangeListener() {
135 | @Override
136 | public void changed(ObservableValue extends String> observable, String oldValue, String newValue) {
137 | if (newValue!=null) {
138 | String[] colList = newValue.split(" ");
139 | if (colList.length==3)
140 | Platform.runLater(()->nameBox.getEditor().setText(colList[1]));
141 | }
142 | }
143 | });
144 |
145 | /*
146 | deptBox的值改变(从列表中选中或编辑完成)时,清空后续comboBox,检查当前comboBox的值是否合法,不合法则清空。
147 | */
148 | deptBox.valueProperty().addListener(new ChangeListener() {
149 | @Override
150 | public void changed(ObservableValue extends String> observable, String oldValue, String newValue) {
151 | if (newValue!=null && !newValue.equals(oldValue)) {
152 | doctBox.getEditor().clear();
153 | typeBox.getEditor().clear();
154 | nameBox.getEditor().clear();
155 | feeLabel.setText("") ;
156 | statusBar.setText("");
157 | List itemList = deptBox.getItems();
158 | int i;
159 | for (i=0; i() {
170 | @Override
171 | public void changed(ObservableValue extends Boolean> observable, Boolean oldValue, Boolean newValue) {
172 | if (oldValue==false && newValue==true) {
173 | if (deptBox.getEditor().getText().isEmpty()) {
174 | Session session = Main.factory.openSession();
175 | Transaction tx = session.beginTransaction();
176 | try {
177 | List ksyss = session.createQuery("from TKsysEntity ").list();
178 | doctBox.getItems().clear();
179 | for (Iterator it=ksyss.iterator(); it.hasNext(); ) {
180 | TKsysEntity ksys = (TKsysEntity)it.next();
181 | doctBox.getItems().add(ksys.getYsbh() + " " + ksys.getYsmc() + " " + ksys.getPtzs());
182 | }
183 | }
184 | catch (HibernateException e) {
185 | if (tx!=null)
186 | tx.rollback();
187 | e.printStackTrace();
188 | }
189 | finally {
190 | session.close();
191 | }
192 | }
193 | else {
194 | Session session = Main.factory.openSession();
195 | Transaction tx = session.beginTransaction();
196 | try {
197 | Query query = session.createQuery("from TKsysEntity where ksbh in (from TKsxxEntity where ksmc = :ksmc)");
198 | query.setParameter("ksmc", deptBox.getEditor().getText());
199 | List ksyss = query.list();
200 | doctBox.getItems().clear();
201 | for (Iterator it=ksyss.iterator(); it.hasNext(); ) {
202 | TKsysEntity ksys = (TKsysEntity)it.next();
203 | doctBox.getItems().add(ksys.getYsbh() + " " + ksys.getYsmc() + " " + ksys.getPtzs());
204 | }
205 | }
206 | catch (HibernateException e) {
207 | if (tx!=null)
208 | tx.rollback();
209 | e.printStackTrace();
210 | }
211 | finally {
212 | session.close();
213 | }
214 | }
215 | }
216 | }
217 | });
218 | doctBox.valueProperty().addListener(new ChangeListener() {
219 | @Override
220 | public void changed(ObservableValue extends String> observable, String oldValue, String newValue) {
221 | if (newValue!=null && !newValue.equals(oldValue)) {
222 | typeBox.getEditor().clear();
223 | nameBox.getEditor().clear();
224 | feeLabel.setText("");
225 | statusBar.setText("");
226 | List itemList = doctBox.getItems();
227 | int i;
228 | String ysbh=null;
229 | for (i=0; i() {
268 | @Override
269 | public void changed(ObservableValue extends String> observable, String oldValue, String newValue) {
270 | if (newValue!=null && !newValue.equals(oldValue)) {
271 | List itemList = typeBox.getItems();
272 | int i;
273 | for (i=0; i() {
290 | @Override
291 | public void changed(ObservableValue extends String> observable, String oldValue, String newValue) {
292 | if (newValue==null) {
293 | feeLabel.setText("");
294 | return;
295 | }
296 | if (newValue.isEmpty()) {
297 | feeLabel.setText("");
298 | }
299 | else {
300 | byte isExpert = typeBox.getValue().equals("专家号")?(byte)1:(byte)0;
301 | Session session = Main.factory.openSession();
302 | Transaction tx = session.beginTransaction();
303 | try {
304 | Query query = session.createQuery("from THzxxEntity where sfzj=:sfzj and ksbh in (select ksbh from TKsxxEntity where ksmc=:ksmc)");
305 | query.setParameter("sfzj", isExpert);
306 | query.setParameter("ksmc", deptBox.getValue());
307 | THzxxEntity hzxx = (THzxxEntity)query.list().get(0);
308 | feeLabel.setText(hzxx.getGhfy().toString()+"元");
309 | tGhxxEntity.setGhfy(hzxx.getGhfy());
310 | tGhxxEntity.setHzbh(hzxx.getHzbh());
311 | tx.commit();
312 | }
313 | catch (HibernateException e) {
314 | if (tx!=null)
315 | tx.rollback();
316 | e.printStackTrace();
317 | }
318 | finally {
319 | session.close();
320 | }
321 | }
322 | }
323 | });
324 | // Customize combobox to autocomplete
325 | new AutoCompleteComboBox(deptBox);
326 | new AutoCompleteComboBox(doctBox);
327 | new AutoCompleteComboBox(typeBox);
328 | new AutoCompleteComboBox(nameBox);
329 |
330 | // Confirm button clicked
331 | confirmButton.setOnMouseClicked(new EventHandler() {
332 | @Override
333 | public void handle(MouseEvent event) {
334 | // recharge
335 | if (confirmButton.getText().equals("充值")) {
336 | spinner.setVisible(true);
337 | try {
338 | TimeUnit.SECONDS.sleep(3);
339 | }
340 | catch (InterruptedException e) {
341 | System.out.println(e.toString());
342 | return;
343 | // System.exit(1);
344 | }
345 | Session session = Main.factory.openSession();
346 | Transaction tx = session.beginTransaction();
347 | try {
348 | Query query = session.createQuery("from TBrxxEntity where brbh=:brbh");
349 | query.setParameter("brbh", Main.id);
350 | TBrxxEntity tBrxxEntity = (TBrxxEntity) query.list().get(0);
351 | tBrxxEntity.setYcje(tBrxxEntity.getYcje().add(BigDecimal.valueOf(50)));
352 | session.update(tBrxxEntity);
353 | tx.commit();
354 | accountLabel.setText(tBrxxEntity.getYcje()+"元");
355 | }
356 | catch (HibernateException e) {
357 | System.out.println(e.toString());
358 | if (tx==null)
359 | tx.rollback();
360 | }
361 | finally {
362 | session.close();
363 | }
364 | spinner.setVisible(false);
365 | statusBar.setText("充值成功!");
366 | confirmButton.setText("确定");
367 | return;
368 | }
369 | // Check
370 | if (deptBox.getValue()==null
371 | || doctBox.getValue()==null
372 | || typeBox.getValue()==null
373 | || nameBox.getValue()==null) {
374 | JFXAlert alert = new JFXAlert<>(Main.curStage);
375 | alert.show();
376 | statusBar.setText("挂号失败!请完善挂号信息");
377 | return;
378 | }
379 | long id = 0;
380 | Session session = Main.factory.openSession();
381 | Transaction tx = session.beginTransaction();
382 | try {
383 | Query query = session.createQuery("from TKsxxEntity where ksmc=:ksmc");
384 | query.setParameter("ksmc", deptBox.getValue());
385 | if (query.list().size()==0) {
386 | JFXAlert alert = new JFXAlert<>(Main.curStage);
387 | alert.show();
388 | statusBar.setText("挂号失败!科室不存在");
389 | return;
390 | }
391 | TKsxxEntity tKsxxEntity = (TKsxxEntity) query.list().get(0);
392 | query = session.createQuery("from TKsysEntity where ksbh=:ksbh and ysmc=:ysmc");
393 | query.setParameter("ksbh", tKsxxEntity.getKsbh());
394 | query.setParameter("ysmc", doctBox.getValue());
395 | if (query.list().size()==0) {
396 | JFXAlert alert = new JFXAlert<>(Main.curStage);
397 | alert.show();
398 | statusBar.setText("挂号失败!医生不存在");
399 | return;
400 | }
401 | TKsysEntity tKsysEntity = (TKsysEntity) query.list().get(0);
402 | String type = typeBox.getValue();
403 | if (!type.equals("专家号") && !type.equals("普通号")) {
404 | JFXAlert alert = new JFXAlert<>(Main.curStage);
405 | alert.show();
406 | statusBar.setText("挂号失败!号种类别不存在");
407 | return;
408 | }
409 | if (type.equals("专家号") && tKsysEntity.getSfzj()==0) {
410 | JFXAlert alert = new JFXAlert<>(Main.curStage);
411 | alert.show();
412 | statusBar.setText("挂号失败!该医生不是专家");
413 | return;
414 | }
415 | if (!nameBox.getValue().equals(deptBox.getValue()+type)) {
416 | JFXAlert alert = new JFXAlert<>(Main.curStage);
417 | alert.show();
418 | statusBar.setText("挂号失败!号种名称不存在");
419 | return;
420 | }
421 | // check ok
422 | query = session.createQuery("select count(*) from TGhxxEntity ");
423 | id = (Long) query.list().get(0) + 1;
424 | query = session.createQuery("select count(*) from TGhxxEntity where hzbh=:hzbh");
425 | query.setParameter("hzbh", tGhxxEntity.getHzbh());
426 | Long num = (Long) query.list().get(0)+1;
427 | tGhxxEntity.setGhbh(String.format("%6d", id).replace(" ", "0"));
428 | tGhxxEntity.setGhrc(Math.toIntExact(num));
429 | tGhxxEntity.setThbz((byte)0);
430 | tGhxxEntity.setRqsj(new Timestamp(System.currentTimeMillis()));
431 | session.save(tGhxxEntity);
432 | query = session.createQuery("from TBrxxEntity where brbh=:brbh");
433 | query.setParameter("brbh", Main.id);
434 | TBrxxEntity tBrxxEntity = (TBrxxEntity) query.list().get(0);
435 | if (tBrxxEntity.getYcje().compareTo(tGhxxEntity.getGhfy())<0) {
436 | statusBar.setText("余额不足!请充值");
437 | confirmButton.setText("充值");
438 | return;
439 | }
440 | tBrxxEntity.setYcje(tBrxxEntity.getYcje().subtract(tGhxxEntity.getGhfy()));
441 | session.save(tBrxxEntity);
442 | tx.commit();
443 | }
444 | catch (HibernateException e) {
445 | if (tx!=null)
446 | tx.rollback();
447 | e.printStackTrace();
448 | }
449 | finally {
450 | session.close();
451 | }
452 | statusBar.setText("挂号成功!挂号编号:"+id);
453 | updateRecordTable();
454 | }
455 | });
456 | // Reset button clicked
457 | resetButton.setOnMouseClicked(new EventHandler() {
458 | @Override
459 | public void handle(MouseEvent event) {
460 | deptBox.getEditor().clear();
461 | doctBox.getEditor().clear();
462 | typeBox.getEditor().clear();
463 | nameBox.getEditor().clear();
464 | feeLabel.setText("");
465 | statusBar.setText("");
466 | }
467 | });
468 | // Display up-center timeLabel and refresh in every one second
469 | DateFormat datetimeFormat = new SimpleDateFormat("yyyy年MM月dd日 HH:mm:ss");
470 | final Timeline timeline = new Timeline(
471 | new KeyFrame(
472 | Duration.millis(500),
473 | event -> {
474 | // Dispaly current time and refresh in every second
475 | Timestamp timestamp = new Timestamp(System.currentTimeMillis());
476 | String curTimeStr = datetimeFormat.format(timestamp);
477 | timeLabel.setText(curTimeStr);
478 | }
479 | )
480 | );
481 | timeline.setCycleCount(Animation.INDEFINITE);
482 | timeline.play();
483 | // Display table
484 | JFXTreeTableColumn idColumn = new JFXTreeTableColumn<>("挂号编号");
485 | idColumn.setPrefWidth(70);
486 | idColumn.setCellValueFactory((TreeTableColumn.CellDataFeatures param) -> {
487 | if (idColumn.validateValue(param)) {
488 | return param.getValue().getValue().id;
489 | } else {
490 | return idColumn.getComputedValue(param);
491 | }
492 | });
493 | JFXTreeTableColumn patientColumn = new JFXTreeTableColumn<>("病人姓名");
494 | patientColumn.setPrefWidth(70);
495 | patientColumn.setCellValueFactory((TreeTableColumn.CellDataFeatures param) -> {
496 | if (patientColumn.validateValue(param)) {
497 | return param.getValue().getValue().patientName;
498 | } else {
499 | return patientColumn.getComputedValue(param);
500 | }
501 | });
502 | JFXTreeTableColumn deptColumn = new JFXTreeTableColumn<>("科室名称");
503 | deptColumn.setPrefWidth(70);
504 | deptColumn.setCellValueFactory((TreeTableColumn.CellDataFeatures param) -> {
505 | if (deptColumn.validateValue(param)) {
506 | return param.getValue().getValue().departName;
507 | } else {
508 | return deptColumn.getComputedValue(param);
509 | }
510 | });
511 | JFXTreeTableColumn doctorColumn = new JFXTreeTableColumn<>("医生姓名");
512 | doctorColumn.setPrefWidth(70);
513 | doctorColumn.setCellValueFactory((TreeTableColumn.CellDataFeatures param) -> {
514 | if (doctorColumn.validateValue(param)) {
515 | return param.getValue().getValue().doctorName;
516 | } else {
517 | return doctorColumn.getComputedValue(param);
518 | }
519 | });
520 | JFXTreeTableColumn typeColumn = new JFXTreeTableColumn<>("号种类别");
521 | typeColumn.setPrefWidth(70);
522 | typeColumn.setCellValueFactory((TreeTableColumn.CellDataFeatures param) -> {
523 | if (typeColumn.validateValue(param)) {
524 | return param.getValue().getValue().type;
525 | } else {
526 | return typeColumn.getComputedValue(param);
527 | }
528 | });
529 | JFXTreeTableColumn numberColumn = new JFXTreeTableColumn<>("挂号人次");
530 | numberColumn.setPrefWidth(70);
531 | numberColumn.setCellValueFactory((TreeTableColumn.CellDataFeatures param) -> {
532 | if (numberColumn.validateValue(param)) {
533 | return param.getValue().getValue().number;
534 | } else {
535 | return numberColumn.getComputedValue(param);
536 | }
537 | });
538 | JFXTreeTableColumn feeColumn = new JFXTreeTableColumn<>("挂号费用");
539 | feeColumn.setPrefWidth(70);
540 | feeColumn.setCellValueFactory((TreeTableColumn.CellDataFeatures param) -> {
541 | if (feeColumn.validateValue(param)) {
542 | return param.getValue().getValue().fee;
543 | } else {
544 | return feeColumn.getComputedValue(param);
545 | }
546 | });
547 | JFXTreeTableColumn timeColumn = new JFXTreeTableColumn<>("挂号时间");
548 | timeColumn.setPrefWidth(150);
549 | timeColumn.setCellValueFactory((TreeTableColumn.CellDataFeatures param) -> {
550 | if (timeColumn.validateValue(param)) {
551 | return param.getValue().getValue().time;
552 | } else {
553 | return timeColumn.getComputedValue(param);
554 | }
555 | });
556 | recordTable.setShowRoot(false);
557 | recordTable.setEditable(true);
558 | recordTable.getColumns().setAll(idColumn, patientColumn, deptColumn, doctorColumn, typeColumn, numberColumn, feeColumn, timeColumn);
559 | recordTable.setColumnResizePolicy(JFXTreeTableView.UNCONSTRAINED_RESIZE_POLICY);
560 | updateRecordTable();
561 | // Text search
562 | filterField.textProperty().addListener((o, oldVal, newVal) -> {
563 | recordTable.setPredicate(recordProp -> {
564 | final Record record = recordProp.getValue();
565 | return record.getId().contains(newVal)
566 | || record.getPatientName().contains(newVal)
567 | || record.getDepartName().contains(newVal)
568 | || record.getDoctorName().contains(newVal)
569 | || record.getType().contains(newVal)
570 | || record.getTime().contains(newVal);
571 | });
572 | });
573 |
574 | recordTable.setRowFactory(new Callback, TreeTableRow>() {
575 | @Override
576 | public TreeTableRow call(TreeTableView param) {
577 | final TreeTableRow row = new TreeTableRow<>();
578 | // cancel record
579 | final ContextMenu menu = new ContextMenu();
580 | MenuItem cancelItem = new MenuItem("退号");
581 | menu.getItems().add(cancelItem);
582 | cancelItem.setOnAction(new EventHandler() {
583 | @Override
584 | public void handle(ActionEvent event) {
585 | TreeItem item = recordTable.getSelectionModel().getSelectedItem();
586 | Session session = Main.factory.openSession();
587 | Transaction tx = null;
588 | try {
589 | tx = session.beginTransaction();
590 | Query query = session.createQuery("from TGhxxEntity where ghbh=:ghbh");
591 | query.setParameter("ghbh", item.getValue().getId());
592 | TGhxxEntity tGhxxEntity = (TGhxxEntity) query.list().get(0);
593 | tGhxxEntity.setThbz((byte)1);
594 | session.update(tGhxxEntity);
595 | tx.commit();
596 | recordTable.getRoot().getChildren().remove(item);
597 | statusBar.setText("退号成功!");
598 | }
599 | catch (HibernateException e) {
600 | System.out.println(e.toString());
601 | if (tx!=null)
602 | tx.rollback();
603 | }
604 | finally {
605 | session.close();
606 | }
607 | }
608 | });
609 | // Only display context menu for non-null items
610 | row.contextMenuProperty().bind(
611 | Bindings.when(javafx.beans.binding.Bindings.isNotNull(row.itemProperty()))
612 | .then(menu)
613 | .otherwise((ContextMenu)null));
614 | return row;
615 | }
616 | });
617 | }
618 |
619 | private static final class Record extends RecursiveTreeObject {
620 | final StringProperty id;
621 | final StringProperty patientName;
622 | final StringProperty departName;
623 | final StringProperty doctorName;
624 | final StringProperty type;
625 | final IntegerProperty number;
626 | final DoubleProperty fee;
627 | final StringProperty time;
628 |
629 | Record(String id, String patientName, String departName, String doctorName, String type, Integer number, Double fee, String time) {
630 | this.id = new SimpleStringProperty(id);
631 | this.patientName = new SimpleStringProperty(patientName);
632 | this.departName = new SimpleStringProperty(departName);
633 | this.doctorName = new SimpleStringProperty(doctorName);
634 | this.type = new SimpleStringProperty(type);
635 | this.number = new SimpleIntegerProperty(number);
636 | this.fee = new SimpleDoubleProperty(fee);
637 | this.time = new SimpleStringProperty(time);
638 | }
639 |
640 | public String getId() {
641 | return id.get();
642 | }
643 |
644 | public String getPatientName() {
645 | return patientName.get();
646 | }
647 |
648 | public String getDepartName() {
649 | return departName.get();
650 | }
651 |
652 | public String getDoctorName() {
653 | return doctorName.get();
654 | }
655 |
656 | public String getType() {
657 | return type.get();
658 | }
659 |
660 | public Integer getNumber() {
661 | return number.get();
662 | }
663 |
664 | public Double getFee() {
665 | return fee.get();
666 | }
667 |
668 | public String getTime() {
669 | return time.get();
670 | }
671 | }
672 |
673 | private void updateRecordTable() {
674 | ObservableList records = FXCollections.observableArrayList();
675 | Session session = Main.factory.openSession();
676 | Transaction tx = null;
677 | try {
678 | tx = session.beginTransaction();
679 | Query query = session.createQuery("from TGhxxEntity where brbh=:brbh and thbz=0");
680 | query.setParameter("brbh", Main.id);
681 | List recordList = query.list();
682 | query = session.createQuery("from TBrxxEntity where brbh=:brbh");
683 | query.setParameter("brbh", Main.id);
684 | TBrxxEntity tBrxxEntity = (TBrxxEntity) query.list().get(0);
685 | welcomeLabel.setText(tBrxxEntity.getBrmc()+",您好");
686 | accountLabel.setText(String.valueOf(tBrxxEntity.getYcje())+"元");
687 | for (Iterator it=recordList.iterator(); it.hasNext(); ) {
688 | TGhxxEntity tGhxxEntity = (TGhxxEntity) it.next();
689 | query = session.createQuery("from TKsysEntity where ysbh=:ysbh");
690 | query.setParameter("ysbh", tGhxxEntity.getYsbh());
691 | TKsysEntity tKsysEntity = (TKsysEntity) query.list().get(0);
692 | query = session.createQuery("from TKsxxEntity where ksbh=:ksbh");
693 | query.setParameter("ksbh", tKsysEntity.getKsbh());
694 | TKsxxEntity tKsxxEntity = (TKsxxEntity) query.list().get(0);
695 | query = session.createQuery("from THzxxEntity where hzbh=:hzbh");
696 | query.setParameter("hzbh", tGhxxEntity.getHzbh());
697 | THzxxEntity tHzxxEntity = (THzxxEntity) query.list().get(0);
698 | DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
699 | Record record = new Record(
700 | tGhxxEntity.getGhbh(),
701 | tBrxxEntity.getBrmc(),
702 | tKsxxEntity.getKsmc(),
703 | tKsysEntity.getYsmc(),
704 | tHzxxEntity.getSfzj()==1?"专家号":"普通号",
705 | tGhxxEntity.getGhrc(),
706 | tGhxxEntity.getGhfy().doubleValue(),
707 | dateFormat.format(tGhxxEntity.getRqsj())
708 | );
709 | records.add(record);
710 | }
711 | }
712 | catch (HibernateException e) {
713 | System.out.println(e.toString());
714 | if (tx!=null)
715 | tx.rollback();
716 | }
717 | finally {
718 | session.close();
719 | }
720 | final TreeItem incomeRoot = new RecursiveTreeItem<>(records, RecursiveTreeObject::getChildren);
721 | recordTable.setRoot(incomeRoot);
722 | }
723 | }
--------------------------------------------------------------------------------