Skip to content

Commit d954e7a

Browse files
committed
feat: implement scheduler interface
1 parent cae0355 commit d954e7a

File tree

5 files changed

+208
-16
lines changed

5 files changed

+208
-16
lines changed

src/ProdScheduler/AbstractScheduler.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,15 @@
44

55
abstract class AbstractScheduler
66
{
7+
use SchedulerComputeTrait;
8+
9+
public function schedule()
10+
{
11+
return $this->compute();
12+
}
13+
14+
public function getMonthSchedule(): array
15+
{
16+
return $this->scheduledList;
17+
}
718
}

src/ProdScheduler/Scheduler.php

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,19 @@
44

55
class Scheduler extends AbstractScheduler implements SchedulerInterface
66
{
7-
use SchedulerComputeTrait;
87

9-
public function __construct()
8+
public function __construct(array $config)
109
{
10+
$this->init($config);
11+
}
12+
13+
public function getSchedule(): array
14+
{
15+
return $this->getMonthSchedule();
16+
}
17+
18+
public function getDaySchedule(int $timestamp): array
19+
{
20+
return $this->getSchedule();
1121
}
1222
}

src/ProdScheduler/SchedulerComputeTrait.php

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,35 @@
44

55
trait SchedulerComputeTrait
66
{
7+
public array $scheduledList;
8+
79
use SchedulerConfigTrait;
10+
11+
public function compute()
12+
{
13+
}
14+
15+
private function initialStartTimeCompute(): int
16+
{
17+
return 0;
18+
}
19+
20+
private function adjustPhasePosition(bool $isAdjust = false)
21+
{
22+
}
23+
24+
private function phaseCostTime(): int
25+
{
26+
return 0;
27+
}
28+
29+
private function phaseStartedTimeCompute(bool $isReverse = false): int
30+
{
31+
return 0;
32+
}
33+
34+
private function phaseCompletedTimeCompute(): int
35+
{
36+
return 0;
37+
}
838
}

src/ProdScheduler/SchedulerConfigTrait.php

Lines changed: 145 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,149 @@
44

55
trait SchedulerConfigTrait
66
{
7+
public const SCHEDULER_DAY_SECONDS = 60 * 60 * 24; // 86400
8+
protected const SCHEDULER_DATETIME_FORMAT = 'Y-m-d H:i:s';
9+
protected const SCHEDULER_DATE_FORMAT = 'Y-m-d';
10+
11+
public string $year;
12+
public string $month;
13+
public AssemblelyGroups $group;
14+
public string $groupName;
15+
public array $defaultDayCalendar;
16+
// Equal division quantity
17+
public int $EDQ;
18+
// Max cost time compute
19+
public bool $MCTC;
20+
// Sup phase compute first
21+
public bool $SPCF;
22+
public string $initialPhase;
23+
public bool $singlePhase;
24+
// Initial schedule datetime
25+
public string $ISDT;
26+
// Initial schedule timestamp
27+
public int $ISTS;
28+
public bool $isUseCalendar;
29+
public bool $isUseTPMCalendar;
30+
// is use multiple shifts compute
31+
public bool $isUseMSC;
32+
public array $monthCalendar;
33+
public array $nextMonthCalendar;
34+
public array $prevMonthCalendar;
35+
public array $dayCalendar;
36+
public array $nextDayCalendar;
37+
public array $prevDayCalendar;
38+
39+
public function init(array $config)
40+
{
41+
$this->parseConfig($config);
42+
}
43+
44+
private function parseConfig(array $config)
45+
{
46+
}
47+
48+
public function getConfig(): array
49+
{
50+
return [];
51+
}
52+
53+
public function getGroup(): AssemblelyGroups
54+
{
55+
return $this->group;
56+
}
57+
58+
public function getGroupName(): string
59+
{
60+
return $this->groupName;
61+
}
62+
63+
public function getDefaultDayCalendar(): array
64+
{
65+
return $this->defaultDayCalendar;
66+
}
67+
68+
public function getEDQ(): int
69+
{
70+
return $this->EDQ;
71+
}
72+
73+
public function getMCTC(): bool
74+
{
75+
return $this->MCTC;
76+
}
77+
78+
public function getSPCF(): bool
79+
{
80+
return $this->SPCF;
81+
}
82+
83+
public function getISDT(): bool
84+
{
85+
return $this->ISDT;
86+
}
87+
88+
public function getISTS(): bool
89+
{
90+
return $this->ISTS;
91+
}
92+
93+
public function getSinglePhase(): bool
94+
{
95+
return $this->singlePhase;
96+
}
97+
98+
public function getUseMSC(): bool
99+
{
100+
return $this->isUseMSC;
101+
}
102+
103+
public function getUseCalendar(): bool
104+
{
105+
return $this->isUseCalendar;
106+
}
107+
108+
public function getUseTPMS(): bool
109+
{
110+
return $this->isUseTPMCalendar;
111+
}
112+
113+
public function getInitialPhase(): string
114+
{
115+
return $this->initialPhase;
116+
}
117+
118+
public function getInitialPhaseInfo(): array
119+
{
120+
return [];
121+
}
122+
123+
public function getDayCalendar(): array
124+
{
125+
return [];
126+
}
127+
128+
public function getNextDayCalendar(): array
129+
{
130+
return [];
131+
}
132+
133+
public function getPreviousDayCalendar(): array
134+
{
135+
return [];
136+
}
137+
138+
public function getMonthCalendar(): array
139+
{
140+
return [];
141+
}
142+
143+
public function getNextMonthCalendar(): array
144+
{
145+
return [];
146+
}
147+
148+
public function getPreviousMonthCalendar(): array
149+
{
150+
return [];
151+
}
7152
}

src/ProdScheduler/SchedulerInterface.php

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -18,23 +18,15 @@ enum AssemblelyGroups: int
1818

1919
interface SchedulerInterface
2020
{
21-
public function init(): void;
21+
public function init(array $config): void;
2222

23-
public function schedule(): bool;
23+
public function schedule(): void;
2424

2525
// =============> output result <============ \\
26-
public function getDaySchedule(): array;
27-
28-
public function getNextDaySchedule(): array;
29-
30-
public function getPreviousDaySchedule(): array;
26+
public function getDaySchedule(int $timestamp): array;
3127

3228
public function getMonthSchedule(): array;
3329

34-
public function getNextMonthSchedule(): array;
35-
36-
public function getPreviousMonthSchedule(): array;
37-
3830
public function getSchedule(): array;
3931
// =============> output result <============ \\
4032

@@ -53,10 +45,14 @@ public function getEDQ(): int;
5345
// Max cost time compute
5446
public function getMCTC(): bool;
5547

56-
// Sup phase first compute
57-
public function getSPFC(): bool;
48+
// Sup phase compute first
49+
public function getSPCF(): bool;
50+
51+
public function getInitialPhase(): string;
52+
53+
public function getInitialPhaseInfo(): array;
5854

59-
public function getInitialPhase(): array;
55+
public function getSinglePhase(): bool;
6056

6157
// Initial schedule datetime
6258
public function getISDT(): string;

0 commit comments

Comments
 (0)