修复bug,完成基本逻辑
This commit is contained in:
1
.idea/encodings.xml
generated
1
.idea/encodings.xml
generated
@@ -2,5 +2,6 @@
|
|||||||
<project version="4">
|
<project version="4">
|
||||||
<component name="Encoding">
|
<component name="Encoding">
|
||||||
<file url="file://$PROJECT_DIR$/src/main/java" charset="UTF-8" />
|
<file url="file://$PROJECT_DIR$/src/main/java" charset="UTF-8" />
|
||||||
|
<file url="file://$PROJECT_DIR$/src/main/resources" charset="UTF-8" />
|
||||||
</component>
|
</component>
|
||||||
</project>
|
</project>
|
2
.idea/misc.xml
generated
2
.idea/misc.xml
generated
@@ -8,5 +8,5 @@
|
|||||||
</list>
|
</list>
|
||||||
</option>
|
</option>
|
||||||
</component>
|
</component>
|
||||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_22" project-jdk-name="21" project-jdk-type="JavaSDK" />
|
<component name="ProjectRootManager" version="2" languageLevel="JDK_19" project-jdk-name="19" project-jdk-type="JavaSDK" />
|
||||||
</project>
|
</project>
|
@@ -4,6 +4,7 @@ import com.dota.domain.Doctor;
|
|||||||
import com.dota.domain.Week;
|
import com.dota.domain.Week;
|
||||||
import com.dota.domain.WorkEnum;
|
import com.dota.domain.WorkEnum;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
|
||||||
public class Main {
|
public class Main {
|
||||||
@@ -15,6 +16,11 @@ public class Main {
|
|||||||
static Doctor zh;
|
static Doctor zh;
|
||||||
static Doctor tgy;
|
static Doctor tgy;
|
||||||
|
|
||||||
|
// 日期
|
||||||
|
static int days = 0;
|
||||||
|
// 医生下标
|
||||||
|
static int idx = 0;
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
init();
|
init();
|
||||||
var doctorOrder = new Doctor[]{
|
var doctorOrder = new Doctor[]{
|
||||||
@@ -56,15 +62,9 @@ public class Main {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void schedule(Doctor[] doctors, Doctor[] outputOrder) {
|
static void schedule(Doctor[] doctors, Doctor[] outputOrder) {
|
||||||
// 日期
|
|
||||||
int days = 0;
|
|
||||||
// 医生下标
|
|
||||||
int idx = 0;
|
|
||||||
|
|
||||||
for (int k = 0; k < 2; k++) {
|
for (int k = 0; k < 2; k++) {
|
||||||
for (int i = 0; i < 7; i++) {
|
for (int i = 0; i < 7; i++) {
|
||||||
var d = doctors[idx];
|
var d = doctors[idx];
|
||||||
|
|
||||||
if (d.firstRest) {
|
if (d.firstRest) {
|
||||||
d.firstRest = false;
|
d.firstRest = false;
|
||||||
d.works[0] = WorkEnum.HOLIDAY;
|
d.works[0] = WorkEnum.HOLIDAY;
|
||||||
@@ -92,7 +92,7 @@ public class Main {
|
|||||||
}
|
}
|
||||||
|
|
||||||
days = (days + 1) % 7;
|
days = (days + 1) % 7;
|
||||||
idx = (idx + 1) % doctors.length;
|
idx = (idx + 1) % 6;
|
||||||
}
|
}
|
||||||
|
|
||||||
fix(doctors);
|
fix(doctors);
|
||||||
@@ -104,28 +104,45 @@ public class Main {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
record Rest(int day, int cnt) {
|
||||||
|
}
|
||||||
|
|
||||||
// 给有调休的安排休息
|
// 给有调休的安排休息
|
||||||
// 保证同一组必须有一个在
|
// 保证同一组必须有一个在
|
||||||
static void rest(Doctor[] doctors) {
|
static void rest(Doctor[] doctors) {
|
||||||
|
var list = new ArrayList<Rest>();
|
||||||
|
for (int i = 0; i < 5; i++) {
|
||||||
|
list.add(new Rest(i, 0));
|
||||||
|
}
|
||||||
|
|
||||||
for (Doctor doctor : doctors) {
|
for (Doctor doctor : doctors) {
|
||||||
if (doctor.lastRestCount == 0) {
|
for (int i = 0; i < 5; i++) {
|
||||||
continue;
|
if (doctor.works[i] == WorkEnum.DUTY || doctor.works[i] == WorkEnum.WORK) {
|
||||||
}
|
list.set(i, new Rest(i, list.get(i).cnt + 1));
|
||||||
|
|
||||||
int count = 0;
|
|
||||||
for (int j = 0; j < 5; j++) {
|
|
||||||
if (checkRest(j, doctor, doctors)) {
|
|
||||||
doctor.works[j] = WorkEnum.REST;
|
|
||||||
count++;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (count==doctor.lastRestCount) {
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
list.sort((a, b) -> b.cnt - a.cnt);
|
||||||
|
|
||||||
for (Doctor doctor : doctors) {
|
for (Doctor doctor : doctors) {
|
||||||
doctor.lastRestCount = doctor.restCount;
|
if (doctor.restCount == 0) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
int i = 0;
|
||||||
|
int j = 0;
|
||||||
|
while (i < doctor.restCount) {
|
||||||
|
Rest r = list.get(j++);
|
||||||
|
if (checkRest(r.day, doctor, doctors)) {
|
||||||
|
j = 0;
|
||||||
|
doctor.works[r.day] = WorkEnum.REST;
|
||||||
|
i++;
|
||||||
|
list.add(new Rest(r.day, r.cnt - 1));
|
||||||
|
list.remove(r);
|
||||||
|
list.sort((a, b) -> b.cnt - a.cnt);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -2,9 +2,7 @@ package com.dota.domain;
|
|||||||
|
|
||||||
public class Doctor {
|
public class Doctor {
|
||||||
public String name;
|
public String name;
|
||||||
// 上周的调休
|
// 周五六日值班的调休
|
||||||
public int lastRestCount;
|
|
||||||
// 下周的调休
|
|
||||||
public int restCount = 0;
|
public int restCount = 0;
|
||||||
|
|
||||||
// 门诊时间
|
// 门诊时间
|
||||||
@@ -34,6 +32,7 @@ public class Doctor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void reset() {
|
public void reset() {
|
||||||
|
this.restCount = 0;
|
||||||
for (int i = 0; i < 5; i++) {
|
for (int i = 0; i < 5; i++) {
|
||||||
works[i] = WorkEnum.WORK;
|
works[i] = WorkEnum.WORK;
|
||||||
}
|
}
|
||||||
@@ -44,8 +43,8 @@ public class Doctor {
|
|||||||
switch (name) {
|
switch (name) {
|
||||||
case "周晖" -> works[1] = WorkEnum.OPD;
|
case "周晖" -> works[1] = WorkEnum.OPD;
|
||||||
case "唐婷婷" -> works[2] = WorkEnum.OPD;
|
case "唐婷婷" -> works[2] = WorkEnum.OPD;
|
||||||
case "李宁" -> works[3] = WorkEnum.OPD;
|
case "李宁" -> works[4] = WorkEnum.OPD;
|
||||||
case "章亮" -> works[4] = WorkEnum.OPD;
|
case "章亮" -> works[3] = WorkEnum.OPD;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user