Compare commits

..

3 Commits

Author SHA1 Message Date
jsh
d0d9d6d18b 修复tgy周一没有门诊的bug 2025-10-12 12:06:02 +08:00
jsh
2949a48e63 使用swing 可视化 2025-10-12 12:05:23 +08:00
jsh
b5a118994a 日期格式为MM月dd日 2025-10-12 10:50:42 +08:00
4 changed files with 98 additions and 7 deletions

28
pom.xml
View File

@@ -26,4 +26,32 @@
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>3.6.0</version>
<configuration>
<archive>
<manifest>
<mainClass>com.dota.App</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

View File

@@ -0,0 +1,59 @@
package com.dota;
import javax.swing.*;
import java.awt.*;
public class App {
public static void main(String[] args) {
SwingUtilities.invokeLater(App::lanuch);
}
static String[] doctors = new String[]{"顾磊", "章亮", "唐婷婷", "杨祖怡", "李宁", "周晖"};
static void lanuch() {
JFrame jframe = new JFrame("排班系统");
jframe.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
jframe.setSize(600,400);
jframe.setLayout(new BorderLayout(10, 10));
var dateField = new JTextField("2025-10-13");
var weekNumField = new JTextField("2");
var filePathField = new JTextField("C:\\Users\\yangz\\Documents\\医生排班.xlsx");
var doctorField = new JComboBox<>(doctors);
doctorField.setSelectedIndex(0);
var resText = new JTextArea("点击确定按钮,输出执行结果");
var btn = new JButton("确定");
// 输入区域
JPanel inputPanel = new JPanel(new GridLayout(4,2,10,5));
jframe.add(inputPanel, BorderLayout.NORTH);
inputPanel.add(new JLabel("排班日期"));
inputPanel.add(dateField);
inputPanel.add(new JLabel("排班周数"));
inputPanel.add(weekNumField);
inputPanel.add(new JLabel("第一个值班的医生"));
inputPanel.add(doctorField);
inputPanel.add(new JLabel("输出文件位置"));
inputPanel.add(filePathField);
//结果区域
JPanel resPanel = new JPanel();
jframe.add(resPanel, BorderLayout.CENTER);
resPanel.add(resText);
// 按钮区域
var btnPanel = new JPanel();
jframe.add(btnPanel, BorderLayout.SOUTH);
btnPanel.add(btn);
btn.addActionListener(e->{
resText.setText("运行中,请稍等");
Main.run(dateField.getText(), Integer.parseInt(weekNumField.getText()), (String) doctorField.getSelectedItem(), filePathField.getText());
resText.setText("运行结束,请查看排班文件");
});
jframe.setLocationRelativeTo(null);
jframe.setVisible(true);
}
}

View File

@@ -8,6 +8,7 @@ import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import java.io.FileOutputStream;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.*;
public class Main {
@@ -29,6 +30,10 @@ public class Main {
static LocalDate day;
public static void main(String[] args) {
run("2025-10-13", 2, "周晖", "C:\\Users\\yangz\\Documents\\医生排班.xlsx");
}
static void run(String date, int weekNum, String name, String file){
init();
var doctorOrder = new Doctor[]{
gl, zl, ttt, zy, ln, zh
@@ -37,12 +42,8 @@ public class Main {
ln, zy, ttt, zl, zh, gl, tgy
};
// var s = new ArrayList<Doctor>();
// for (int i = -1; i < 2; i++) {
// s.addAll(schedule(doctorOrder, outputOrder));
// }
// print(s);
write("2025-10-13", 4, "顾磊", doctorOrder, outputOrder);
filePath = file;
write(date, weekNum, name, doctorOrder, outputOrder);
}
@@ -90,10 +91,12 @@ public class Main {
}
}
/**
* 写入表头,周几和日期
*/
static void writeHead(Sheet sheet, int rowNum, LocalDate day){
DateTimeFormatter mmdd = DateTimeFormatter.ofPattern("MM月dd日");
int i = 1;
var row = sheet.createRow(rowNum++);
var r2 = sheet.createRow(rowNum);
@@ -102,7 +105,7 @@ public class Main {
cell.setCellValue(w.getValue());
cell = r2.createCell(i++);
cell.setCellValue(day.toString());
cell.setCellValue(day.format(mmdd));
day = day.plusDays(1);
}
}

View File

@@ -48,6 +48,7 @@ public class Doctor {
}
switch (name) {
case "田国燕" -> works[0] = WorkEnum.OPD;
case "周晖" -> works[1] = WorkEnum.OPD;
case "唐婷婷" -> works[2] = WorkEnum.OPD;
case "李宁" -> works[4] = WorkEnum.OPD;