Compare commits
9 Commits
06d68a46fe
...
main
Author | SHA1 | Date | |
---|---|---|---|
6495f56e25 | |||
d0d9d6d18b | |||
2949a48e63 | |||
b5a118994a | |||
043c1b71a1 | |||
cc687b9536 | |||
5d9a5dda10 | |||
674de604e8 | |||
84f5f5e676 |
3
.idea/.gitignore
generated
vendored
Normal file
3
.idea/.gitignore
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
# 默认忽略的文件
|
||||
/shelf/
|
||||
/workspace.xml
|
4
.idea/misc.xml
generated
4
.idea/misc.xml
generated
@@ -8,7 +8,5 @@
|
||||
</list>
|
||||
</option>
|
||||
</component>
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_21" default="true" project-jdk-name="21" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/out" />
|
||||
</component>
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_19" project-jdk-name="19" project-jdk-type="JavaSDK" />
|
||||
</project>
|
124
.idea/uiDesigner.xml
generated
124
.idea/uiDesigner.xml
generated
@@ -1,124 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="Palette2">
|
||||
<group name="Swing">
|
||||
<item class="com.intellij.uiDesigner.HSpacer" tooltip-text="Horizontal Spacer" icon="/com/intellij/uiDesigner/icons/hspacer.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="1" hsize-policy="6" anchor="0" fill="1" />
|
||||
</item>
|
||||
<item class="com.intellij.uiDesigner.VSpacer" tooltip-text="Vertical Spacer" icon="/com/intellij/uiDesigner/icons/vspacer.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="1" anchor="0" fill="2" />
|
||||
</item>
|
||||
<item class="javax.swing.JPanel" icon="/com/intellij/uiDesigner/icons/panel.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3" />
|
||||
</item>
|
||||
<item class="javax.swing.JScrollPane" icon="/com/intellij/uiDesigner/icons/scrollPane.svg" removable="false" auto-create-binding="false" can-attach-label="true">
|
||||
<default-constraints vsize-policy="7" hsize-policy="7" anchor="0" fill="3" />
|
||||
</item>
|
||||
<item class="javax.swing.JButton" icon="/com/intellij/uiDesigner/icons/button.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="3" anchor="0" fill="1" />
|
||||
<initial-values>
|
||||
<property name="text" value="Button" />
|
||||
</initial-values>
|
||||
</item>
|
||||
<item class="javax.swing.JRadioButton" icon="/com/intellij/uiDesigner/icons/radioButton.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
|
||||
<initial-values>
|
||||
<property name="text" value="RadioButton" />
|
||||
</initial-values>
|
||||
</item>
|
||||
<item class="javax.swing.JCheckBox" icon="/com/intellij/uiDesigner/icons/checkBox.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
|
||||
<initial-values>
|
||||
<property name="text" value="CheckBox" />
|
||||
</initial-values>
|
||||
</item>
|
||||
<item class="javax.swing.JLabel" icon="/com/intellij/uiDesigner/icons/label.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="0" anchor="8" fill="0" />
|
||||
<initial-values>
|
||||
<property name="text" value="Label" />
|
||||
</initial-values>
|
||||
</item>
|
||||
<item class="javax.swing.JTextField" icon="/com/intellij/uiDesigner/icons/textField.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
|
||||
<preferred-size width="150" height="-1" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JPasswordField" icon="/com/intellij/uiDesigner/icons/passwordField.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
|
||||
<preferred-size width="150" height="-1" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JFormattedTextField" icon="/com/intellij/uiDesigner/icons/formattedTextField.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
|
||||
<preferred-size width="150" height="-1" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JTextArea" icon="/com/intellij/uiDesigner/icons/textArea.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JTextPane" icon="/com/intellij/uiDesigner/icons/textPane.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JEditorPane" icon="/com/intellij/uiDesigner/icons/editorPane.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JComboBox" icon="/com/intellij/uiDesigner/icons/comboBox.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="0" hsize-policy="2" anchor="8" fill="1" />
|
||||
</item>
|
||||
<item class="javax.swing.JTable" icon="/com/intellij/uiDesigner/icons/table.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JList" icon="/com/intellij/uiDesigner/icons/list.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="2" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JTree" icon="/com/intellij/uiDesigner/icons/tree.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JTabbedPane" icon="/com/intellij/uiDesigner/icons/tabbedPane.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
|
||||
<preferred-size width="200" height="200" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JSplitPane" icon="/com/intellij/uiDesigner/icons/splitPane.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
|
||||
<preferred-size width="200" height="200" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JSpinner" icon="/com/intellij/uiDesigner/icons/spinner.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
|
||||
</item>
|
||||
<item class="javax.swing.JSlider" icon="/com/intellij/uiDesigner/icons/slider.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
|
||||
</item>
|
||||
<item class="javax.swing.JSeparator" icon="/com/intellij/uiDesigner/icons/separator.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3" />
|
||||
</item>
|
||||
<item class="javax.swing.JProgressBar" icon="/com/intellij/uiDesigner/icons/progressbar.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1" />
|
||||
</item>
|
||||
<item class="javax.swing.JToolBar" icon="/com/intellij/uiDesigner/icons/toolbar.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1">
|
||||
<preferred-size width="-1" height="20" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JToolBar$Separator" icon="/com/intellij/uiDesigner/icons/toolbarSeparator.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="0" anchor="0" fill="1" />
|
||||
</item>
|
||||
<item class="javax.swing.JScrollBar" icon="/com/intellij/uiDesigner/icons/scrollbar.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="0" anchor="0" fill="2" />
|
||||
</item>
|
||||
</group>
|
||||
</component>
|
||||
</project>
|
97
.idea/workspace.xml
generated
97
.idea/workspace.xml
generated
@@ -1,97 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="AutoImportSettings">
|
||||
<option name="autoReloadType" value="SELECTIVE" />
|
||||
</component>
|
||||
<component name="ChangeListManager">
|
||||
<list default="true" id="e5c0ab69-86a1-48cc-bc4b-2a4ed3402ae8" name="更改" comment="">
|
||||
<change afterPath="$PROJECT_DIR$/.gitignore" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/.idea/encodings.xml" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/.idea/misc.xml" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/.idea/vcs.xml" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/pom.xml" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/src/main/java/com/dota/Main.java" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/src/main/java/com/dota/domain/Doctor.java" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/src/main/java/com/dota/domain/Week.java" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/src/main/java/com/dota/domain/WorkEnum.java" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/src/main/java/com/dota/domain/doctors/GuLei.java" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/src/main/java/com/dota/domain/doctors/LiNing.java" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/src/main/java/com/dota/domain/doctors/TangTingTing.java" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/src/main/java/com/dota/domain/doctors/TianGuoYan.java" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/src/main/java/com/dota/domain/doctors/ZhangLiang.java" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/src/main/java/com/dota/domain/doctors/ZhouHui.java" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/src/main/java/com/dota/domain/doctors/ZuYi.java" afterDir="false" />
|
||||
</list>
|
||||
<option name="SHOW_DIALOG" value="false" />
|
||||
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
|
||||
<option name="LAST_RESOLUTION" value="IGNORE" />
|
||||
</component>
|
||||
<component name="FileTemplateManagerImpl">
|
||||
<option name="RECENT_TEMPLATES">
|
||||
<list>
|
||||
<option value="package-info" />
|
||||
<option value="Class" />
|
||||
</list>
|
||||
</option>
|
||||
</component>
|
||||
<component name="Git.Settings">
|
||||
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
|
||||
</component>
|
||||
<component name="ProjectColorInfo"><![CDATA[{
|
||||
"associatedIndex": 0
|
||||
}]]></component>
|
||||
<component name="ProjectId" id="33Vj0xgzBGBHJYDWFyxFxHyYhjn" />
|
||||
<component name="ProjectLevelVcsManager" settingsEditedManually="true">
|
||||
<ConfirmationsSetting value="2" id="Add" />
|
||||
</component>
|
||||
<component name="ProjectViewState">
|
||||
<option name="hideEmptyMiddlePackages" value="true" />
|
||||
<option name="showLibraryContents" value="true" />
|
||||
</component>
|
||||
<component name="PropertiesComponent"><![CDATA[{
|
||||
"keyToString": {
|
||||
"RunOnceActivity.ShowReadmeOnStart": "true",
|
||||
"git-widget-placeholder": "master",
|
||||
"kotlin-language-version-configured": "true",
|
||||
"应用程序.Main.executor": "Run"
|
||||
}
|
||||
}]]></component>
|
||||
<component name="RecentsManager">
|
||||
<key name="CopyClassDialog.RECENTS_KEY">
|
||||
<recent name="com.dota.domain" />
|
||||
</key>
|
||||
</component>
|
||||
<component name="RunManager">
|
||||
<configuration name="Main" type="Application" factoryName="Application" temporary="true" nameIsGenerated="true">
|
||||
<option name="MAIN_CLASS_NAME" value="com.dota.Main" />
|
||||
<module name="zy-schedult" />
|
||||
<extension name="coverage">
|
||||
<pattern>
|
||||
<option name="PATTERN" value="com.dota.*" />
|
||||
<option name="ENABLED" value="true" />
|
||||
</pattern>
|
||||
</extension>
|
||||
<method v="2">
|
||||
<option name="Make" enabled="true" />
|
||||
</method>
|
||||
</configuration>
|
||||
<recent_temporary>
|
||||
<list>
|
||||
<item itemvalue="应用程序.Main" />
|
||||
</list>
|
||||
</recent_temporary>
|
||||
</component>
|
||||
<component name="SpellCheckerSettings" RuntimeDictionaries="0" Folders="0" CustomDictionaries="0" DefaultDictionary="应用程序级" UseSingleDictionary="true" transferred="true" />
|
||||
<component name="TaskManager">
|
||||
<task active="true" id="Default" summary="默认任务">
|
||||
<changelist id="e5c0ab69-86a1-48cc-bc4b-2a4ed3402ae8" name="更改" comment="" />
|
||||
<created>1759408913305</created>
|
||||
<option name="number" value="Default" />
|
||||
<option name="presentableId" value="Default" />
|
||||
<updated>1759408913305</updated>
|
||||
</task>
|
||||
<servers />
|
||||
</component>
|
||||
</project>
|
47
pom.xml
47
pom.xml
@@ -9,9 +9,52 @@
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>21</maven.compiler.source>
|
||||
<maven.compiler.target>21</maven.compiler.target>
|
||||
<maven.compiler.source>17</maven.compiler.source>
|
||||
<maven.compiler.target>17</maven.compiler.target>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.apache.poi</groupId>
|
||||
<artifactId>poi</artifactId>
|
||||
<version>5.2.3</version> </dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.poi</groupId>
|
||||
<artifactId>poi-ooxml</artifactId>
|
||||
<version>5.2.3</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
||||
<finalName>schedule</finalName>
|
||||
|
||||
<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>
|
59
src/main/java/com/dota/App.java
Normal file
59
src/main/java/com/dota/App.java
Normal 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);
|
||||
}
|
||||
}
|
@@ -2,36 +2,397 @@ package com.dota;
|
||||
|
||||
import com.dota.domain.Doctor;
|
||||
import com.dota.domain.Week;
|
||||
import com.dota.domain.doctors.*;
|
||||
import com.dota.domain.WorkEnum;
|
||||
import org.apache.poi.ss.usermodel.Sheet;
|
||||
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 {
|
||||
static String filePath = "C:\\Users\\yangz\\Documents\\医生排班.xlsx";
|
||||
static Doctor gl;
|
||||
static Doctor zl;
|
||||
static Doctor ttt;
|
||||
static Doctor zy;
|
||||
static Doctor ln;
|
||||
static Doctor zh;
|
||||
static Doctor tgy;
|
||||
|
||||
// 日期
|
||||
static int days = 0;
|
||||
// 医生下标
|
||||
static int idx = 0;
|
||||
|
||||
//开始日期
|
||||
static LocalDate day;
|
||||
|
||||
public static void main(String[] args) {
|
||||
var gl = new GuLei();
|
||||
var zl = new ZhangLiang();
|
||||
var ttt = new TangTingTing();
|
||||
var zy = new ZuYi();
|
||||
var ln = new LiNing();
|
||||
var zh = new ZhouHui();
|
||||
var tgy = new TianGuoYan();
|
||||
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
|
||||
gl, zl, ttt, zy, ln, zh
|
||||
};
|
||||
var outputOrder = new Doctor[] {
|
||||
ln,zy,ttt,zl,zh,gl,tgy
|
||||
var outputOrder = new Doctor[]{
|
||||
ln, zy, ttt, zl, zh, gl, tgy
|
||||
};
|
||||
schedule(doctorOrder);
|
||||
print(2, outputOrder);
|
||||
|
||||
filePath = file;
|
||||
write(date, weekNum, name, doctorOrder, outputOrder);
|
||||
}
|
||||
|
||||
static void schedule(Doctor[] doctorOrder) {
|
||||
|
||||
/**
|
||||
* @param startDay 开始第一天
|
||||
* @param weekNum 输出周数
|
||||
* @param name 第一周第一天值班的医生名字
|
||||
*/
|
||||
static void write(String startDay, int weekNum, String name, Doctor[] doctors, Doctor[] outputDoctors) {
|
||||
day = LocalDate.parse(startDay);
|
||||
for (int i = 0; i < doctors.length; i++) {
|
||||
if (doctors[i].name.equals(name)) {
|
||||
idx = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
var list = new ArrayList<Doctor>();
|
||||
for (int i = 0; i < weekNum; i++) {
|
||||
list.addAll(schedule(doctors, outputDoctors));
|
||||
}
|
||||
|
||||
try(var workbook = new XSSFWorkbook()) {
|
||||
var sheet = workbook.createSheet();
|
||||
int rowNum = 0;
|
||||
|
||||
for (int i = 0; i < weekNum; i++) {
|
||||
writeHead(sheet, rowNum, day);
|
||||
day = day.plusDays(7);
|
||||
rowNum += 2;
|
||||
writeSchedult(sheet, rowNum, list.subList(i * 7, (i+1) * 7));
|
||||
rowNum += 8;
|
||||
}
|
||||
|
||||
for (int i = 0; i < 8; i++) {
|
||||
sheet.autoSizeColumn(i);
|
||||
}
|
||||
|
||||
try(var output = new FileOutputStream(filePath)) {
|
||||
workbook.write(output);
|
||||
}
|
||||
|
||||
}catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
static void print(int weeks, Doctor[] outputOrder) {
|
||||
for (int i = 0; i < weeks; i++) {
|
||||
|
||||
/**
|
||||
* 写入表头,周几和日期
|
||||
*/
|
||||
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);
|
||||
for (Week w:Week.values()) {
|
||||
var cell = row.createCell(i);
|
||||
cell.setCellValue(w.getValue());
|
||||
|
||||
cell = r2.createCell(i++);
|
||||
cell.setCellValue(day.format(mmdd));
|
||||
day = day.plusDays(1);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 写入医生排班
|
||||
*/
|
||||
static void writeSchedult(Sheet sheet, int rowNum, List<Doctor> doctors){
|
||||
for (Doctor doctor : doctors) {
|
||||
var row = sheet.createRow(rowNum++);
|
||||
int colNum = 0;
|
||||
var cell = row.createCell(colNum++);
|
||||
cell.setCellValue(doctor.name);
|
||||
for (WorkEnum work : doctor.works) {
|
||||
cell = row.createCell(colNum++);
|
||||
cell.setCellValue(work.getName());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void init() {
|
||||
gl = new Doctor("顾磊");
|
||||
gl.group = 1;
|
||||
zl = new Doctor("章亮");
|
||||
zl.opd = 3;
|
||||
zl.works[3] = WorkEnum.OPD;
|
||||
ttt = new Doctor("唐婷婷");
|
||||
ttt.opd = 2;
|
||||
ttt.works[2] = WorkEnum.OPD;
|
||||
zy = new Doctor("杨祖怡");
|
||||
zy.group = 1;
|
||||
ln = new Doctor("李宁");
|
||||
ln.opd = 4;
|
||||
ln.works[4] = WorkEnum.OPD;
|
||||
zh = new Doctor("周晖");
|
||||
zh.opd = 1;
|
||||
zh.works[1] = WorkEnum.OPD;
|
||||
tgy = new Doctor("田国燕");
|
||||
tgy.opd = 0;
|
||||
tgy.group = 0;
|
||||
tgy.works[0] = WorkEnum.OPD;
|
||||
|
||||
zh.swap = gl;
|
||||
ttt.swap = zl;
|
||||
}
|
||||
|
||||
//生成一周的排班
|
||||
static List<Doctor> schedule(Doctor[] doctors, Doctor[] outputOrder) {
|
||||
var res = new ArrayList<Doctor>();
|
||||
for (int i = 0; i < 7; i++) {
|
||||
var d = doctors[idx];
|
||||
if (d.firstRest) {
|
||||
d.firstRest = false;
|
||||
d.works[0] = WorkEnum.HOLIDAY;
|
||||
}
|
||||
|
||||
// 值班第二天是值休
|
||||
// 周六值班有两天额外休息
|
||||
if (i == 5) {
|
||||
d.restCount = 2;
|
||||
d.works[6] = WorkEnum.HOLIDAY;
|
||||
} else if (i == 4) { //周五值班有额外一天休息
|
||||
d.works[5] = WorkEnum.HOLIDAY;
|
||||
d.restCount = 1;
|
||||
} else if (i == 6) { // 周日值班有一天额外休息
|
||||
d.restCount = 1;
|
||||
d.firstRest = true;
|
||||
} else {
|
||||
d.works[days + 1] = WorkEnum.HOLIDAY;
|
||||
}
|
||||
|
||||
if (d.works[days] == WorkEnum.OPD) {
|
||||
d.works[days] = WorkEnum.OPD_AND_DUTY;
|
||||
} else {
|
||||
d.works[days] = WorkEnum.DUTY;
|
||||
}
|
||||
|
||||
days = (days + 1) % 7;
|
||||
idx = (idx + 1) % 6;
|
||||
}
|
||||
fix(doctors);
|
||||
rest(doctors);
|
||||
for (Doctor d : outputOrder) {
|
||||
res.add(d.clone());
|
||||
d.reset();
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
static class Rest {
|
||||
int day;
|
||||
int cnt;
|
||||
public Rest(int day, int cnt){
|
||||
this.day = day;
|
||||
this.cnt = cnt;
|
||||
}
|
||||
}
|
||||
|
||||
// 给有调休的安排休息
|
||||
// 保证同一组必须有一个在
|
||||
static void rest(Doctor[] doctors) {
|
||||
var list = new Rest[5];
|
||||
for (int i = 0; i < 5; i++) {
|
||||
list[i] = new Rest(i, 0);
|
||||
}
|
||||
|
||||
for (Doctor doctor : doctors) {
|
||||
for (int i = 0; i < 5; i++) {
|
||||
if (doctor.works[i] == WorkEnum.DUTY || doctor.works[i] == WorkEnum.WORK) {
|
||||
list[i].cnt++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var queue = new PriorityQueue<Rest>((a,b)->b.cnt-a.cnt);
|
||||
for (Rest rest : list) {
|
||||
queue.offer(rest);
|
||||
}
|
||||
|
||||
for (Doctor doctor : doctors) {
|
||||
if (doctor.restCount == 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
int i = 0;
|
||||
var temp = new ArrayList<Rest>();
|
||||
while (i < doctor.restCount) {
|
||||
Rest r = queue.poll();
|
||||
if (checkRest(r.day, doctor, doctors)) {
|
||||
doctor.works[r.day] = WorkEnum.REST;
|
||||
i++;
|
||||
}
|
||||
temp.add(r);
|
||||
}
|
||||
queue.addAll(temp);
|
||||
}
|
||||
}
|
||||
|
||||
// 判断是否有门诊和值班冲突,有的话调整一下
|
||||
// 冲突的情况是前一天值班,门诊那天变调休了,因此没有门诊或者门诊值班的安排
|
||||
static void fix(Doctor[] doctors) {
|
||||
for (Doctor d : doctors) {
|
||||
if (d.name.equals("杨祖怡") || d.name.equals("顾磊")) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (Arrays.stream(d.works).anyMatch(workEnum ->
|
||||
workEnum == WorkEnum.OPD || workEnum == WorkEnum.OPD_AND_DUTY)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (d == ln) {
|
||||
ln.works[3] = WorkEnum.OPD_AND_DUTY;
|
||||
zl.works[3] = WorkEnum.WORK;
|
||||
zl.works[4] = WorkEnum.OPD;
|
||||
}
|
||||
|
||||
if (d == zl) {
|
||||
ln.works[3] = WorkEnum.OPD;
|
||||
zl.works[4] = WorkEnum.OPD;
|
||||
}
|
||||
|
||||
// 周晖固定周二门诊,所以不能周一值班
|
||||
if (d == zh) {
|
||||
zh.works[0] = WorkEnum.WORK;
|
||||
zh.works[1] = WorkEnum.OPD;
|
||||
// 和顾磊换值班
|
||||
int t = getDuty(gl);
|
||||
zh.works[t] = gl.works[t];
|
||||
if (t < 6) {
|
||||
zh.works[t + 1] = gl.works[t + 1];
|
||||
}
|
||||
|
||||
if (t < 4) {
|
||||
gl.works[t] = WorkEnum.WORK;
|
||||
gl.works[t + 1] = WorkEnum.WORK;
|
||||
}
|
||||
if (t == 4) {
|
||||
zh.restCount = 1;
|
||||
gl.restCount = 0;
|
||||
gl.works[4] = WorkEnum.WORK;
|
||||
gl.works[5] = WorkEnum.REST;
|
||||
}
|
||||
if (t == 5) {
|
||||
zh.restCount = 2;
|
||||
gl.restCount = 0;
|
||||
gl.works[5] = WorkEnum.REST;
|
||||
gl.works[6] = WorkEnum.REST;
|
||||
}
|
||||
if (t == 6) {
|
||||
zh.restCount = 1;
|
||||
zh.firstRest = true;
|
||||
gl.restCount = 0;
|
||||
gl.firstRest = false;
|
||||
gl.works[6] = WorkEnum.REST;
|
||||
}
|
||||
|
||||
gl.works[0] = WorkEnum.DUTY;
|
||||
gl.works[1] = WorkEnum.HOLIDAY;
|
||||
}
|
||||
|
||||
// 唐婷婷固定周三门诊,周二值班的话和章亮换一下
|
||||
if (d == ttt) {
|
||||
ttt.works[1] = WorkEnum.WORK;
|
||||
ttt.works[2] = WorkEnum.OPD;
|
||||
//和章亮换值班
|
||||
int t = getDuty(zl);
|
||||
ttt.works[t] = zl.works[t];
|
||||
if (t < 6) {
|
||||
ttt.works[t + 1] = zl.works[t + 1];
|
||||
}
|
||||
|
||||
if (t < 4) {
|
||||
zl.works[t] = WorkEnum.WORK;
|
||||
zl.works[t + 1] = WorkEnum.WORK;
|
||||
} else if (t == 4) {
|
||||
ttt.restCount = 1;
|
||||
zl.restCount = 0;
|
||||
zl.works[4] = WorkEnum.WORK;
|
||||
zl.works[5] = WorkEnum.REST;
|
||||
} else if (t == 5) {
|
||||
ttt.restCount = 2;
|
||||
zl.restCount = 0;
|
||||
zl.works[5] = WorkEnum.REST;
|
||||
zl.works[6] = WorkEnum.REST;
|
||||
} else if (t == 6) {
|
||||
ttt.restCount = 1;
|
||||
ttt.firstRest = true;
|
||||
zl.restCount = 0;
|
||||
zl.firstRest = false;
|
||||
zl.works[6] = WorkEnum.REST;
|
||||
}
|
||||
|
||||
zl.works[1] = WorkEnum.DUTY;
|
||||
zl.works[2] = WorkEnum.HOLIDAY;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static int getDuty(Doctor d) {
|
||||
for (int i = 0; i < d.works.length; i++) {
|
||||
if (d.works[i] == WorkEnum.DUTY) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
//判断某天是否可以休息
|
||||
//祖怡和顾磊是一组,其他人是一组
|
||||
static boolean checkRest(int day, Doctor doctor, Doctor[] doctors) {
|
||||
// 只有日班才会安排休息
|
||||
if (doctor.works[day] != WorkEnum.WORK) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (Doctor d : doctors) {
|
||||
if (doctor.group == d.group) {
|
||||
var w = d.works[day];
|
||||
if (w == WorkEnum.WORK ||
|
||||
w == WorkEnum.OPD ||
|
||||
w == WorkEnum.DUTY ||
|
||||
w == WorkEnum.OPD_AND_DUTY) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
static void print(List<Doctor> outputOrder) {
|
||||
var size = outputOrder.size() / 7;
|
||||
int idx = 0;
|
||||
for (int i = 0; i < size; i++) {
|
||||
System.out.printf("%10s", " ");
|
||||
for (Week value : Week.values()) {
|
||||
System.out.print(value.getValue());
|
||||
System.out.printf("%10s", value.getValue());
|
||||
}
|
||||
|
||||
System.out.println(" ");
|
||||
for (int j = 0;j<7;j++) {
|
||||
var doctor = outputOrder.get(idx++);
|
||||
System.out.printf("%10s", doctor.name);
|
||||
for (WorkEnum work : doctor.works) {
|
||||
System.out.printf("%10s", work.getName());
|
||||
}
|
||||
System.out.println(" ");
|
||||
}
|
||||
System.out.println(" ");
|
||||
}
|
||||
|
@@ -1,14 +1,21 @@
|
||||
package com.dota.domain;
|
||||
|
||||
public class Doctor {
|
||||
// 有多少调休
|
||||
public String name;
|
||||
// 周五六日值班的调休
|
||||
public int restCount = 0;
|
||||
|
||||
// 门诊时间
|
||||
public Week opd;
|
||||
public int opd;
|
||||
|
||||
// 值班
|
||||
public Week duty;
|
||||
//值班和门诊冲突时换班的医生
|
||||
public Doctor swap;
|
||||
|
||||
//周一是否有值休
|
||||
public boolean firstRest;
|
||||
|
||||
//所属分组
|
||||
public int group = 2;
|
||||
|
||||
public WorkEnum[] works = new WorkEnum[]{
|
||||
WorkEnum.WORK,
|
||||
@@ -19,4 +26,34 @@ public class Doctor {
|
||||
WorkEnum.REST,
|
||||
WorkEnum.REST,
|
||||
};
|
||||
|
||||
public Doctor(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Doctor clone() {
|
||||
var d = new Doctor(this.name);
|
||||
System.arraycopy(this.works, 0, d.works, 0, this.works.length);
|
||||
return d;
|
||||
}
|
||||
|
||||
public void reset() {
|
||||
this.restCount = 0;
|
||||
for (int i = 0; i < 5; i++) {
|
||||
works[i] = WorkEnum.WORK;
|
||||
}
|
||||
for (int i = 5; i < 7; i++) {
|
||||
works[i] = WorkEnum.REST;
|
||||
}
|
||||
|
||||
switch (name) {
|
||||
case "田国燕" -> works[0] = WorkEnum.OPD;
|
||||
case "周晖" -> works[1] = WorkEnum.OPD;
|
||||
case "唐婷婷" -> works[2] = WorkEnum.OPD;
|
||||
case "李宁" -> works[4] = WorkEnum.OPD;
|
||||
case "章亮" -> works[3] = WorkEnum.OPD;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -8,7 +8,7 @@ public enum Week {
|
||||
FRI("周五"),
|
||||
SAT("周六"),
|
||||
SUM("周日");
|
||||
private String value;
|
||||
private final String value;
|
||||
|
||||
Week(String value) {
|
||||
this.value= value;
|
||||
|
@@ -4,10 +4,18 @@ public enum WorkEnum {
|
||||
|
||||
OPD("门诊"),
|
||||
REST("休息"),
|
||||
WORK("白班"),
|
||||
WORK("日班"),
|
||||
DUTY("值班"),
|
||||
HOLIDAY("调休"),
|
||||
OPD_AND_WORK("门诊值班");
|
||||
HOLIDAY("值休"),
|
||||
OPD_AND_DUTY("门诊值班");
|
||||
|
||||
WorkEnum(String name){}
|
||||
private final String name;
|
||||
|
||||
WorkEnum(String name){
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getName(){
|
||||
return name;
|
||||
}
|
||||
}
|
||||
|
@@ -1,8 +0,0 @@
|
||||
package com.dota.domain.doctors;
|
||||
|
||||
import com.dota.domain.Doctor;
|
||||
|
||||
public class GuLei extends Doctor {
|
||||
public GuLei(){
|
||||
}
|
||||
}
|
@@ -1,10 +0,0 @@
|
||||
package com.dota.domain.doctors;
|
||||
|
||||
import com.dota.domain.Doctor;
|
||||
import com.dota.domain.WorkEnum;
|
||||
|
||||
public class LiNing extends Doctor {
|
||||
public LiNing(){
|
||||
this.works[4] = WorkEnum.OPD;
|
||||
}
|
||||
}
|
@@ -1,10 +0,0 @@
|
||||
package com.dota.domain.doctors;
|
||||
|
||||
import com.dota.domain.Doctor;
|
||||
import com.dota.domain.WorkEnum;
|
||||
|
||||
public class TangTingTing extends Doctor {
|
||||
public TangTingTing(){
|
||||
this.works[2] = WorkEnum.OPD;
|
||||
}
|
||||
}
|
@@ -1,10 +0,0 @@
|
||||
package com.dota.domain.doctors;
|
||||
|
||||
import com.dota.domain.Doctor;
|
||||
import com.dota.domain.WorkEnum;
|
||||
|
||||
public class TianGuoYan extends Doctor {
|
||||
public TianGuoYan(){
|
||||
this.works[0] = WorkEnum.OPD;
|
||||
}
|
||||
}
|
@@ -1,10 +0,0 @@
|
||||
package com.dota.domain.doctors;
|
||||
|
||||
import com.dota.domain.Doctor;
|
||||
import com.dota.domain.WorkEnum;
|
||||
|
||||
public class ZhangLiang extends Doctor {
|
||||
public ZhangLiang(){
|
||||
this.works[3] = WorkEnum.OPD;
|
||||
}
|
||||
}
|
@@ -1,10 +0,0 @@
|
||||
package com.dota.domain.doctors;
|
||||
|
||||
import com.dota.domain.Doctor;
|
||||
import com.dota.domain.WorkEnum;
|
||||
|
||||
public class ZhouHui extends Doctor {
|
||||
public ZhouHui(){
|
||||
this.works[1] = WorkEnum.OPD;
|
||||
}
|
||||
}
|
@@ -1,6 +0,0 @@
|
||||
package com.dota.domain.doctors;
|
||||
|
||||
import com.dota.domain.Doctor;
|
||||
|
||||
public class ZuYi extends Doctor {
|
||||
}
|
Reference in New Issue
Block a user