Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
79 / 79 |
|
100.00% |
3 / 3 |
CRAP | |
100.00% |
1 / 1 |
| ExchangeWaitingdepartment | |
100.00% |
79 / 79 |
|
100.00% |
3 / 3 |
10 | |
100.00% |
1 / 1 |
| readEntity | |
100.00% |
44 / 44 |
|
100.00% |
1 / 1 |
4 | |||
| readSubjectList | |
100.00% |
12 / 12 |
|
100.00% |
1 / 1 |
2 | |||
| readPeriodList | |
100.00% |
23 / 23 |
|
100.00% |
1 / 1 |
4 | |||
| 1 | <?php |
| 2 | |
| 3 | namespace BO\Zmsdb; |
| 4 | |
| 5 | use BO\Zmsentities\Exchange; |
| 6 | |
| 7 | class ExchangeWaitingdepartment extends Base implements Interfaces\ExchangeSubject |
| 8 | { |
| 9 | public function readEntity( |
| 10 | $subjectid, |
| 11 | \DateTimeInterface $datestart, |
| 12 | \DateTimeInterface $dateend, |
| 13 | $period = 'day' |
| 14 | ) { |
| 15 | $department = (new Department())->readEntity($subjectid); |
| 16 | $organisation = (new Organisation())->readByDepartmentId($subjectid); |
| 17 | $entity = new Exchange(); |
| 18 | $entity['title'] = "Wartestatistik $organisation->name -> $department->name"; |
| 19 | $entity->setPeriod($datestart, $dateend, $period); |
| 20 | $entity->addDictionaryEntry('subjectid', 'string', 'ID of a department', 'department.id'); |
| 21 | $entity->addDictionaryEntry('date', 'string', 'date of report entry'); |
| 22 | $entity->addDictionaryEntry('hour', 'string', 'hour of report entry'); |
| 23 | $entity->addDictionaryEntry('waitingcount', 'number', 'amount of waiting spontaneous clients'); |
| 24 | $entity->addDictionaryEntry('waitingtime', 'number', 'real waitingtime for spontaneous clients'); |
| 25 | $entity->addDictionaryEntry('waytime', 'number', 'real waytime for spontaneous clients'); |
| 26 | $entity->addDictionaryEntry('waitingcalculated', 'number', 'calculated waitingtime for spontaneous clients'); |
| 27 | $entity->addDictionaryEntry('waitingcount_termin', 'number', 'amount of waiting clients with termin'); |
| 28 | $entity->addDictionaryEntry('waitingtime_termin', 'number', 'real waitingtime with termin'); |
| 29 | $entity->addDictionaryEntry('waytime_termin', 'number', 'real waytime with appointment'); |
| 30 | $entity->addDictionaryEntry('waitingcalculated_termin', 'number', 'calculated waitingtime with termin'); |
| 31 | $subjectIdList = explode(',', $subjectid); |
| 32 | foreach ($subjectIdList as $subjectid) { |
| 33 | $raw = $this |
| 34 | ->getReader() |
| 35 | ->fetchAll( |
| 36 | constant("\BO\Zmsdb\Query\ExchangeWaitingdepartment::QUERY_READ_" . strtoupper($period)), |
| 37 | [ |
| 38 | 'departmentid' => $subjectid, |
| 39 | 'datestart' => $datestart->format('Y-m-d'), |
| 40 | 'dateend' => $dateend->format('Y-m-d'), |
| 41 | ] |
| 42 | ); |
| 43 | |
| 44 | foreach ($raw as $entry) { |
| 45 | foreach (range(0, 23) as $hour) { |
| 46 | $entity->addDataSet([ |
| 47 | $subjectid, |
| 48 | $entry['datum'], |
| 49 | $hour, |
| 50 | $entry[sprintf('wartende_ab_%02s_spontan', $hour)], |
| 51 | $entry[sprintf('echte_zeit_ab_%02s_spontan', $hour)], |
| 52 | $entry[sprintf('zeit_ab_%02s_spontan', $hour)], |
| 53 | $entry[sprintf('wegezeit_ab_%02s_spontan', $hour)], |
| 54 | $entry[sprintf('wartende_ab_%02s_termin', $hour)], |
| 55 | $entry[sprintf('echte_zeit_ab_%02s_termin', $hour)], |
| 56 | $entry[sprintf('zeit_ab_%02s_termin', $hour)], |
| 57 | $entry[sprintf('wegezeit_ab_%02s_termin', $hour)], |
| 58 | ]); |
| 59 | } |
| 60 | } |
| 61 | } |
| 62 | return $entity; |
| 63 | } |
| 64 | |
| 65 | public function readSubjectList() |
| 66 | { |
| 67 | $raw = $this->getReader()->fetchAll(Query\ExchangeWaitingdepartment::QUERY_SUBJECTS, []); |
| 68 | $entity = new Exchange(); |
| 69 | $entity['title'] = "Wartestatistik"; |
| 70 | $entity->setPeriod(new \DateTimeImmutable(), new \DateTimeImmutable()); |
| 71 | $entity->addDictionaryEntry('subject', 'string', 'Behörde ID', 'department.id'); |
| 72 | $entity->addDictionaryEntry('periodstart', 'string', 'Datum von'); |
| 73 | $entity->addDictionaryEntry('periodend', 'string', 'Datum bis'); |
| 74 | $entity->addDictionaryEntry('organisationname', 'string', 'Name der Organisation'); |
| 75 | $entity->addDictionaryEntry('description', 'string', 'Name der Behörde'); |
| 76 | foreach ($raw as $entry) { |
| 77 | $entity->addDataSet(array_values($entry)); |
| 78 | } |
| 79 | return $entity; |
| 80 | } |
| 81 | |
| 82 | public function readPeriodList($subjectid, $period = 'day') |
| 83 | { |
| 84 | $department = (new Department())->readEntity($subjectid); |
| 85 | $organisation = (new Organisation())->readByDepartmentId($subjectid); |
| 86 | $entity = new Exchange(); |
| 87 | $entity['title'] = "Wartestatistik $organisation->name -> $department->name"; |
| 88 | $entity->setPeriod(new \DateTimeImmutable(), new \DateTimeImmutable(), $period); |
| 89 | $entity->addDictionaryEntry('period'); |
| 90 | |
| 91 | $montsList = $this->getReader()->fetchAll( |
| 92 | constant("\BO\Zmsdb\Query\ExchangeWaitingdepartment::QUERY_PERIODLIST_MONTH"), |
| 93 | [ |
| 94 | 'departmentid' => $subjectid, |
| 95 | ] |
| 96 | ); |
| 97 | $raw = []; |
| 98 | foreach ($montsList as $month) { |
| 99 | $date = new \DateTimeImmutable($month['date']); |
| 100 | $raw[$date->format('Y')][] = $month['date']; |
| 101 | rsort($raw[$date->format('Y')]); |
| 102 | } |
| 103 | krsort($raw); |
| 104 | |
| 105 | foreach ($raw as $year => $months) { |
| 106 | $entity->addDataSet([$year]); |
| 107 | foreach ($months as $month) { |
| 108 | $entity->addDataSet([$month]); |
| 109 | } |
| 110 | } |
| 111 | return $entity; |
| 112 | } |
| 113 | } |