@@ -57,21 +57,97 @@ private function parseConfig(array $config)
5757 $ this ->ISTS = strtotime ($ config ['start ' ]);
5858 $ this ->list = $ this ->parseList ($ config ['list ' ]);
5959 $ this ->listPhase = $ config ['listPhase ' ];
60- $ this ->defaultDayCalendar = $ config ['calendar ' ];
60+ $ this ->defaultDayCalendar = $ this -> parseCalendar ( $ config ['calendar ' ]) ;
6161 $ this ->EDQ = $ config ['edq ' ];
62- $ this ->monthCalendar = $ config ['monthCalendar ' ];
63- $ this ->nextMonthCalendar = $ config ['nextMonthCalendar ' ];
64- $ this ->prevMonthCalendar = $ config ['prevMonthCalendar ' ];
62+ $ this ->monthCalendar = $ this -> parseCalendars ( $ config ['monthCalendar ' ]) ;
63+ $ this ->nextMonthCalendar = $ this -> parseCalendars ( $ config ['nextMonthCalendar ' ]) ;
64+ $ this ->prevMonthCalendar = $ this -> parseCalendars ( $ config ['prevMonthCalendar ' ]) ;
6565 $ this ->initialPhase = $ config ['initialPhase ' ];
6666
6767 $ this ->initialStartTimeCompute ();
6868 }
6969
70- private function parseCalendar (array $ calendar ): array
70+ private function parseCalendars (array $ calendar ): array
7171 {
72+ foreach ($ calendar as $ k => $ c ) {
73+ $ calendar [$ k ]['profile ' ] = $ this ->parseCalendar ($ c ['profile ' ])['profile ' ];
74+ }
75+
7276 return $ calendar ;
7377 }
7478
79+ private function parseCalendar (string $ calendarStr ): array
80+ {
81+ $ calendar = [];
82+ try {
83+ $ calendar = json_decode ($ calendarStr , true );
84+ $ c = $ calendar ['profile ' ];
85+ $ c ['profile ' ]['date ' ] = $ calendar ['date ' ] ?? '' ;
86+
87+ $ c ['profile ' ]['rest ' ] = [
88+ [
89+ "end " => $ c ['profile ' ]['times ' ][1 ]['start ' ],
90+ "name " => "上午 " ,
91+ "start " => $ c ['profile ' ]['times ' ][0 ]['end ' ],
92+ "duration " => 5400
93+ ],
94+ [
95+ "end " => $ c ['profile ' ]['times ' ][2 ]['start ' ],
96+ "name " => "下午 " ,
97+ "start " => $ c ['profile ' ]['times ' ][1 ]['end ' ],
98+ "duration " => 1800
99+ ],
100+ ];
101+
102+ return $ c ;
103+ } catch (\Throwable $ th ) {
104+ return [
105+ 'profile ' => [
106+ "name " => "白班 " ,
107+ "dayStart " => "07:30 " ,
108+ "dayEnd " => "20:30 " ,
109+ "dayDuration " => 14400 + 14400 + 10800 ,
110+ "times " => [
111+ [
112+ "end " => "11:30 " ,
113+ "name " => "上午 " ,
114+ "start " => "07:30 " ,
115+ "duration " => 14400
116+ ],
117+ [
118+ "end " => "17:00 " ,
119+ "name " => "下午 " ,
120+ "start " => "13:00 " ,
121+ "duration " => 14400 ,
122+ "interval " => 5400
123+ ],
124+ [
125+ "end " => "20:30 " ,
126+ "name " => "晚上 " ,
127+ "start " => "17:30 " ,
128+ "duration " => 10800 ,
129+ "interval " => 1800
130+ ]
131+ ],
132+ "rest " => [
133+ [
134+ "end " => "13:00 " ,
135+ "name " => "上午 " ,
136+ "start " => "11:30 " ,
137+ "duration " => 5400
138+ ],
139+ [
140+ "end " => "17:30 " ,
141+ "name " => "下午 " ,
142+ "start " => "17:00 " ,
143+ "duration " => 1800
144+ ],
145+ ]
146+ ]
147+ ];
148+ }
149+ }
150+
75151 private function parseList (array $ list ): array
76152 {
77153 foreach ($ list as $ k => $ item ) {
@@ -133,7 +209,9 @@ private function getDayCalendarStartTime(array $calendar): string
133209 $ dayCalendarStartTime = '' ;
134210 if (isset ($ calendar ['profile ' ]) && count ($ calendar ['profile ' ]) > 0 ) {
135211 $ profile = $ calendar ['profile ' ][0 ];
136- if (isset ($ profile ['times ' ]) && count ($ profile ['times ' ]) > 0 ) {
212+ if (isset ($ profile ['dayStart ' ])) {
213+ $ dayCalendarStartTime = $ profile ['dayStart ' ];
214+ } elseif (isset ($ profile ['times ' ]) && count ($ profile ['times ' ]) > 0 ) {
137215 if ($ profile ['times ' ][0 ]['start ' ]) {
138216 $ dayCalendarStartTime = $ profile ['times ' ][0 ]['start ' ];
139217 }
@@ -144,7 +222,9 @@ private function getDayCalendarStartTime(array $calendar): string
144222 $ defaultDayCalendar = $ this ->getDefaultDayCalendar ();
145223 if (isset ($ defaultDayCalendar ['profile ' ]) && count ($ defaultDayCalendar ['profile ' ]) > 0 ) {
146224 $ profile = $ defaultDayCalendar ['profile ' ][0 ];
147- if (isset ($ profile ['times ' ]) && count ($ profile ['times ' ]) > 0 ) {
225+ if (isset ($ profile ['dayStart ' ])) {
226+ $ dayCalendarStartTime = $ profile ['dayStart ' ];
227+ } elseif (isset ($ profile ['times ' ]) && count ($ profile ['times ' ]) > 0 ) {
148228 if ($ profile ['times ' ][0 ]['start ' ]) {
149229 $ dayCalendarStartTime = $ profile ['times ' ][0 ]['start ' ];
150230 }
@@ -265,10 +345,10 @@ public function getDayCalendar(int $ts = 0): array
265345 }
266346 }
267347
268- return $ c ;
348+ return $ c[ ' profile ' ] ;
269349 }
270350
271- return $ this ->dayCalendar ;
351+ return $ this ->defaultDayCalendar [ ' profile ' ] ;
272352 }
273353
274354 public function getNextDayCalendar (): array
0 commit comments