Exemplo n.º 1
0
 /**
  * @param FormBuilderInterface $builder
  * @param array $options
  */
 public function buildForm(FormBuilderInterface $builder, array $options)
 {
     $builder->add('id', 'text', array('label' => 'drivingorder.field.id', 'disabled' => true, 'required' => false));
     $builder->add('pickupDate', 'text', array('label' => 'drivingorder.field.anchordate', 'disabled' => true, 'required' => false));
     $builder->add('pickupTime', 'text', array('label' => 'drivingorder.field.pickupTime', 'disabled' => true, 'required' => false));
     $builder->add('lookaheadaddressFrom', 'text', array('label' => 'drivingorder.field.lookaheadaddressFrom', 'disabled' => true, 'required' => false));
     $builder->add('lookaheadaddressTo', 'text', array('label' => 'drivingorder.field.lookaheadaddressTo', 'disabled' => true, 'required' => false));
     $builder->add('zoneName', 'text', array('label' => 'drivingorder.field.zone', 'disabled' => true, 'required' => false));
     $builder->add('additionalTime', 'text', array('required' => false, 'label' => 'drivingorder.field.additionalTime', 'disabled' => true));
     $builder->add('compagnion', 'text', array('required' => false, 'label' => 'drivingorder.field.compagnion', 'disabled' => true));
     $builder->add('orderStatus', 'choice', array('label' => 'drivingorder.field.status', 'choices' => DrivingOrder::getStatusArray(), 'disabled' => true, 'required' => false));
     $builder->add('memo', 'textarea', array('required' => false, 'label' => 'drivingorder.field.memo'));
     $builder->add('parentId', 'text', array('label' => 'drivingorder.field.parentId', 'disabled' => true, 'required' => false));
     $builder->add('notice', 'textarea', array('required' => false, 'label' => 'drivingorder.field.notice', 'disabled' => true));
 }
 private function mapDrivingOrder(DrivingOrder $drivingOrder, $mission)
 {
     /*
      * map DrivingOrder infos to body array
      */
     $body = new DrivingConfigPrinterBodyDTO();
     $body->colA = $mission;
     $body->colB = $drivingOrder->getDrivingMission()->getDirection() > 0 ? 'R' : '';
     $timeService = $this->container->get('tixi_api.datetimeservice');
     $body->colC = $timeService->convertToLocalTimeString($drivingOrder->getPickUpTime());
     $body->colD = $drivingOrder->getPassenger()->getHasMonthlyBilling() > 0 ? 'X' : '';
     $passenger = $drivingOrder->getPassenger();
     $home = $passenger->getAddress();
     $body->colE = $passenger->getTitle() . ' ' . $passenger->getFirstname() . ' ' . $passenger->getLastname();
     $body->colF = $this->getRideNodeAddress($drivingOrder->getRoute()->getStartAddress(), $home, $passenger->getTelephone());
     $body->colG = $this->getRideNodeAddress($drivingOrder->getRoute()->getTargetAddress(), $home, $passenger->getTelephone());
     $comment1 = $drivingOrder->getMemo();
     $comment2 = $passenger->getNotice();
     if (!empty($comment1) and !empty($comment1)) {
         $body->colH = $comment1 . '<br>' . $comment2;
     } else {
         $body->colH = $comment1 . $comment2;
     }
     $body->colI = $passenger->getIsInWheelChair() > 0 ? 'X' : '';
     /** @var ArrayCollection $handicaps */
     $handicaps = $passenger->getHandicaps();
     $body->colJ = $handicaps->count() > 0 ? 'X' : '';
     $body->colK = $passenger->getInsurancesAsString();
     /** @var Zone $zone */
     $zone = $drivingOrder->getZone();
     $longDistance = false;
     if ($zone instanceof Zone) {
         $body->colL = $drivingOrder->getZone()->getName();
         $longDistance = $zone->isUnclassified();
     } else {
         $body->colL = '?';
     }
     $body->colM = $drivingOrder->getCompanion();
     $body->colX = '';
     if ($longDistance) {
         /** @var DrivingOrder $returnOrder */
         $returnOrder = $drivingOrder->getCorrespondingReturnOrder();
         if ($returnOrder instanceof DrivingOrder) {
             $body->colX = $returnOrder->getPickUpDate()->format('d.m.Y') . ' ' . $returnOrder->getPickUpTime()->format('H:i');
         }
     }
     return $body->getArray();
 }
Exemplo n.º 3
0
 /**
  * @param Passenger $passenger
  * @param $pickupDate
  * @param $pickupTime
  * @param null $companion
  * @param null $memo
  * @param int $status
  * @param bool $manualRoute
  * @param null $additionalTime
  * @return DrivingOrder
  */
 public static function registerDrivingOrder(Passenger $passenger, $pickupDate, $pickupTime, $companion = null, $memo = null, $status = self::BOOKED, $manualRoute = false, $additionalTime = null)
 {
     $correctedCompanion = null !== $companion ? $companion : 0;
     $correctedAdditionalTime = null !== $additionalTime ? $additionalTime : 0;
     $drivingOrder = new DrivingOrder();
     $drivingOrder->assignPassenger($passenger);
     $drivingOrder->setPickUpDate($pickupDate);
     $drivingOrder->setPickUpTime($pickupTime);
     $drivingOrder->setSortOrder($drivingOrder->buildSortOrder($pickupDate, $pickupTime));
     $drivingOrder->setCompanion($correctedCompanion);
     $drivingOrder->setStatus($status);
     $drivingOrder->setManualRoute($manualRoute);
     $drivingOrder->setMemo($memo);
     $drivingOrder->setAdditionalTime($correctedAdditionalTime);
     return $drivingOrder;
 }
Exemplo n.º 4
0
 public function testDrivingOrderCRUD()
 {
     $addressFrom = $this->init->createTestAddressBaar();
     $addressTo = $this->init->createTestAddressGoldau();
     $passenger = Passenger::registerPassenger('m', 'Arthuro', 'Benatone', '+418182930', $addressFrom);
     $this->init->passengerRepo->store($passenger);
     $date = $this->init->dateTimeService->convertDateTimeStringToUTCDateTime('20.05.2014 00:00');
     $time = $this->init->dateTimeService->convertDateTimeStringToUTCDateTime('20.05.2014 15:05');
     $route = Route::registerRoute($addressFrom, $addressTo, 0, 0);
     $route->setDuration(15);
     $route->setDistance(6);
     $this->init->routeRepo->store($route);
     $drivingOrder = DrivingOrder::registerDrivingOrder($passenger, $date, $time, 2, 'möchte nicht hinten sitzen');
     $drivingOrder->assignRoute($route);
     $passenger->assignDrivingOrder($drivingOrder);
     $drivingOrder->assignPassenger($passenger);
     $this->init->drivingOrderRepo->store($drivingOrder);
     $this->init->em->flush();
     $this->assertNotNull($this->init->drivingOrderRepo->find($drivingOrder->getId()));
     //TimePeriod from start day of month to next start day of month
     $monthsAgo = 3;
     $monthDate = new \DateTime('today');
     $monthDate->modify('+' . $monthsAgo . ' month');
     $monthDate->format('first day of this month');
     $workingMonth = WorkingMonth::registerWorkingMonth($monthDate);
     $workingMonth->createWorkingDaysForThisMonth();
     foreach ($workingMonth->getWorkingDays() as $wd) {
         $this->init->workingDayRepo->store($wd);
     }
     $this->init->workingMonthRepo->store($workingMonth);
     $workingDays = $workingMonth->getWorkingDays();
     /**@var $shiftTypes ShiftType[] */
     $shiftTypes = $this->init->shiftTypeRepo->findAllActive();
     //create workingDays shifts, assign them drivingpools, get amount of needed drivers
     /** @var $workingDay WorkingDay */
     foreach ($workingDays as $workingDay) {
         /** @var $shiftType ShiftType */
         foreach ($shiftTypes as $shiftType) {
             $shift = Shift::registerShift($workingDay, $shiftType);
             $shift->setAmountOfDrivers(16);
             $workingDay->assignShift($shift);
             for ($i = 1; $i <= $shift->getAmountOfDrivers(); $i++) {
                 $drivingPool = DrivingPool::registerDrivingPool($shift);
                 $shift->assignDrivingPool($drivingPool);
                 $this->init->drivingPoolRepo->store($drivingPool);
             }
             $this->init->shiftRepo->store($shift);
         }
         $this->init->workingDayRepo->store($workingDay);
     }
     $this->init->em->flush();
     $this->assertNotNull($this->init->workingMonthRepo->find($workingMonth->getId()));
     $drivingAssertionPlans = $this->init->repeatedDrivingAssertionPlanRepo->findPlanForDate(new \DateTime());
     $this->assertNotNull($drivingAssertionPlans);
     $drivingPools = array();
     foreach ($workingMonth->getWorkingDays() as $wd) {
         foreach ($wd->getShifts() as $s) {
             foreach ($s->getDrivingPools() as $dp) {
                 array_push($drivingPools, $dp);
             }
         }
     }
     foreach ($drivingAssertionPlans as $drivingAssertionPlan) {
         $assertions = $drivingAssertionPlan->getRepeatedDrivingAssertions();
         foreach ($assertions as $assertion) {
             if ($assertion->matching($shift)) {
                 echo "\nmatches\n";
                 $drivingPool = DrivingPool::registerDrivingPool($shift);
                 $this->init->drivingPoolRepo->store($drivingPool);
             }
         }
     }
     $vehicles = $this->init->vehicleRepo->findAll();
     /**@var $vehicle Vehicle */
     foreach ($vehicles as $vehicle) {
         foreach ($vehicle->getServicePlans() as $sp) {
         }
     }
 }
Exemplo n.º 5
0
 /**
  * @param DrivingOrder $drivingOrder
  * @return DrivingMission
  */
 public static function registerDrivingMissionFromOrder(DrivingOrder $drivingOrder)
 {
     $drivingMission = new DrivingMission();
     $drivingMission->setDirection(self::SAME_START);
     $drivingMission->setServiceOrder(array($drivingOrder->getId()));
     $boardingTime = DispositionVariables::getBoardingTimes();
     $extraMinutesPassenger = $drivingOrder->getPassenger()->getExtraMinutes();
     $additionalTimesOnRide = $boardingTime + $extraMinutesPassenger;
     $serviceMinuteOfDay = DateTimeService::getMinutesOfDay($drivingOrder->getPickUpTime());
     $serviceDuration = $drivingOrder->getRoute()->getDurationInMinutes() + $additionalTimesOnRide;
     $serviceDistance = $drivingOrder->getRoute()->getDistanceInMeters();
     $drivingMission->setServiceMinuteOfDay($serviceMinuteOfDay);
     $drivingMission->setServiceDuration($serviceDuration);
     $drivingMission->setServiceDistance($serviceDistance);
     //DrivingMission <-> Order
     $drivingMission->assignDrivingOrder($drivingOrder);
     $drivingOrder->assignDrivingMission($drivingMission);
     return $drivingMission;
 }
 /** -------------------------
  * Build one driving order for one working day.
  *
  * @param RepeatedDrivingOrderPlan $drivingOrderPlan
  * @param RepeatedDrivingOrder $repeatedDrivingOrder
  * @param \DateTime $day
  * @param mixed $status
  * @return DrivingOrder
  */
 protected function handleNewDrivingOrderForDate(RepeatedDrivingOrderPlan &$drivingOrderPlan, $repeatedDrivingOrder, \DateTime $day, $status)
 {
     $drivingOrder = DrivingOrder::registerDrivingOrder($drivingOrderPlan->getPassenger(), $day, $repeatedDrivingOrder->getPickUpTime(), $drivingOrderPlan->getCompanion(), $drivingOrderPlan->getMemo(), $status, false, $drivingOrderPlan->getAdditionalTime());
     $drivingOrder->assignZone($drivingOrderPlan->getZone());
     $drivingOrder->assignRepeatedDrivingOrderPlan($drivingOrderPlan);
     $drivingOrder->assignRepeatedDrivingOrder($repeatedDrivingOrder);
     $drivingOrderPlan->assignDrivingOrder($drivingOrder);
     return $drivingOrder;
 }
 /**
  * @param InputInterface $input
  * @param OutputInterface $output
  * @return int|null|void
  */
 public function execute(InputInterface $input, OutputInterface $output)
 {
     $output->writeln('building variables...');
     $month = $input->getArgument('month');
     if (!$month) {
         $month = 1;
     }
     $em = $this->getContainer()->get('entity_manager');
     $workingMonthRepo = $this->getContainer()->get('workingmonth_repository');
     $workingDayRepo = $this->getContainer()->get('workingday_repository');
     $shiftRepo = $this->getContainer()->get('shift_repository');
     $shiftTypeRepo = $this->getContainer()->get('shifttype_repository');
     $drivingPoolRepo = $this->getContainer()->get('drivingpool_repository');
     $passengerRepo = $this->getContainer()->get('passenger_repository');
     $driverRepo = $this->getContainer()->get('driver_repository');
     $vehicleRepo = $this->getContainer()->get('vehicle_repository');
     $addressRepo = $this->getContainer()->get('address_repository');
     $poiRepo = $this->getContainer()->get('poi_repository');
     $routeRepo = $this->getContainer()->get('route_repository');
     $drivingMissionRepo = $this->getContainer()->get('drivingmission_repository');
     $drivingOrderRepo = $this->getContainer()->get('drivingorder_repository');
     $repeatedDrivingAssertionRepo = $this->getContainer()->get('repeateddrivingassertion_repository');
     $repeatedDrivingAssertionPlanRepo = $this->getContainer()->get('repeateddrivingassertionplan_repository');
     $repeatedDrivingOrderRepo = $this->getContainer()->get('repeateddrivingorder_repository.doctrine');
     $repeatedDrivingOrderPlanRepo = $this->getContainer()->get('repeateddrivingorderplan_repository.doctrine');
     $time = $this->getContainer()->get('tixi_api.datetimeservice');
     $routingMachine = $this->getContainer()->get('tixi_app.routingmachine');
     $routeManagement = $this->getContainer()->get('tixi_app.routemanagement');
     $dispoManagement = $this->getContainer()->get('tixi_app.dispomanagement');
     $this->zonePlanRepository = $this->getContainer()->get('zoneplan_repository');
     $this->zoneRepository = $this->getContainer()->get('zone_repository');
     $monthDate = new \DateTime('today');
     $monthDate->modify('+' . $month . ' month');
     // depreciated: $monthDate->modify('+ 10 year');
     $monthDate->modify('first day of this month');
     $shiftTypes = $shiftTypeRepo->findAllActive();
     $output->writeln('target date is ' . $monthDate->format('d.m.Y'));
     $output->writeln('building driver assertion plans...');
     $drivers = $driverRepo->findAllActive();
     foreach ($drivers as $driver) {
         //no other assertion for zivis
         if ($driver->getDriverCategory()->getId() == 2) {
             continue;
         }
         $reDrivingAssertionPlan = RepeatedDrivingAssertionPlan::registerRepeatedAssertionPlan('test', new \DateTime('today'), 'weekly', rand(0, 1));
         $reDrivingAssertionPlan->assignDriver($driver);
         $driver->assignRepeatedDrivingAssertionPlan($reDrivingAssertionPlan);
         $repeatedDrivingAssertionPlanRepo->store($reDrivingAssertionPlan);
         for ($i = 1; $i <= 7; $i++) {
             if (rand(0, 3) < 3) {
                 $reDrivingWeeklyAssertion = new RepeatedWeeklyDrivingAssertion();
                 $reDrivingWeeklyAssertion->addShiftType($shiftTypes[rand(0, count($shiftTypes) - 1)]);
                 $reDrivingWeeklyAssertion->addShiftType($shiftTypes[rand(0, count($shiftTypes) - 1)]);
                 $reDrivingWeeklyAssertion->addShiftType($shiftTypes[rand(0, count($shiftTypes) - 1)]);
                 $reDrivingWeeklyAssertion->setWeekday($i);
                 $reDrivingWeeklyAssertion->setAssertionPlan($reDrivingAssertionPlan);
                 $reDrivingAssertionPlan->assignRepeatedDrivingAssertion($reDrivingWeeklyAssertion);
                 $repeatedDrivingAssertionRepo->store($reDrivingWeeklyAssertion);
             }
         }
     }
     $em->flush();
     $output->writeln('building driving pools...');
     $drivingPools = 0;
     $workingMonth = $workingMonthRepo->findWorkingMonthByDate($monthDate);
     if ($workingMonth !== null) {
         $output->writeln("WorkingMonth " . $monthDate->format('m') . " already exists");
     } else {
         $workingMonth = $dispoManagement->openWorkingMonth($monthDate->format('Y'), $monthDate->format('m'));
         $workingDays = $workingMonth->getWorkingDays();
         //create workingDays shifts, assign them drivingpools, get amount of needed drivers
         /** @var $workingDay WorkingDay */
         foreach ($workingDays as $workingDay) {
             /** @var $shiftType ShiftType */
             foreach ($workingDay->getShifts() as $shift) {
                 $shift->setAmountOfDrivers(rand(12, 18));
                 for ($i = 1; $i <= $shift->getAmountOfDrivers(); $i++) {
                     $drivingPool = DrivingPool::registerDrivingPool($shift);
                     $shift->assignDrivingPool($drivingPool);
                     $drivingPoolRepo->store($drivingPool);
                     $drivingPools++;
                 }
             }
         }
     }
     $em->flush();
     $output->writeln('building unclassified zone...');
     $this->unclassifiedZone = $this->getUnclassifiedZone();
     if (is_null($this->unclassifiedZone)) {
         $output->writeln('error: cannot create unclassified zone!');
     }
     $output->writeln('building driving orders...');
     /**@var $pois POI[] */
     $pois = $poiRepo->findAll();
     $countPois = count($pois);
     $orders = array();
     $routes = array();
     //create Driving Orders
     $countOrders = 0;
     foreach ($shiftTypes as $shiftType) {
         $approxOrdersPerShift = rand(40, 60);
         for ($i = 0; $i < $approxOrdersPerShift; $i++) {
             /**@var $passenger Passenger */
             $passenger = $passengerRepo->find(rand(100, 500));
             $passenger->setIsInWheelChair(rand(0, 1));
             /**  WARNING: saving times in UTC on database, but minutesOfDay are from midnight, causing
              * wrong data if a time is UTC 23:30 but CET 00:30 (= 30 minutesOfDay)
              */
             $stStart = $time->convertToLocalDateTime($shiftType->getStart());
             $stEnd = $time->convertToLocalDateTime($shiftType->getEnd());
             $stDuration = $stStart->diff($stEnd);
             $minutes = $stDuration->h * 60 + $stDuration->i;
             $pickupTime = clone $stStart;
             $pickupTime->add(new \DateInterval('PT' . rand(1, $minutes) . 'M'));
             $order = DrivingOrder::registerDrivingOrder($passenger, $monthDate, $pickupTime, rand(0, 1), null, 0, 0, 1);
             $start = $passenger->getAddress();
             $target = $pois[rand(0, $countPois - 1)]->getAddress();
             $route = Route::registerRoute($start, $target);
             $hashKey = hash('crc32', $start->getHashFromBigIntCoordinates() . $target->getHashFromBigIntCoordinates());
             $routes[$hashKey] = $route;
             $route = $routeRepo->storeRouteIfNotExist($route);
             $order->assignRoute($route);
             $order->assignPassenger($passenger);
             $passenger->assignDrivingOrder($order);
             $drivingOrderRepo->store($order);
             array_push($orders, $order);
         }
     }
     $output->writeln('building driving missions and routes...');
     $routingMachine->fillRoutingInformationForMultipleRoutes($routes);
     /**@var $order DrivingOrder */
     foreach ($orders as $order) {
         $passenger = $order->getPassenger();
         $route = $order->getRoute();
         $boardingTime = DispositionVariables::BOARDING_TIME + DispositionVariables::DEBOARDING_TIME;
         $extraMinutesPassenger = $passenger->getExtraMinutes();
         $additionalTimesOnRide = $boardingTime + $extraMinutesPassenger;
         $serviceMinuteOfDay = $time->getMinutesOfDay($order->getPickUpTime());
         $serviceDuration = $route->getDurationInMinutes() + $additionalTimesOnRide;
         $serviceDistance = $route->getDistanceInMeters();
         //DrivingMission <-> DrivingOrder
         $drivingMission = DrivingMission::registerDrivingMission(rand(0, 1), $serviceMinuteOfDay, $serviceDuration, $serviceDistance);
         $drivingMission->assignDrivingOrder($order);
         $order->assignDrivingMission($drivingMission);
         $drivingMissionRepo->store($drivingMission);
         // DrivingOrder <-> Zone
         $cities = array($route->getStartAddress()->getCity(), $route->getTargetAddress()->getCity());
         $zone = $this->getZoneWithHighestPriorityForCities($cities);
         $order->assignZone($zone);
         $countOrders++;
     }
     $em->flush();
     $output->writeln("\n--------------------------------------------\n" . "Testdata created for month: " . $monthDate->format('m.Y') . " with:\n" . $drivingPools . " DrivingPools \n" . "And orders for one day: " . $monthDate->format('d.m.Y') . " with:\n" . $countOrders . " DrivingOrders and Routes \n");
 }
Exemplo n.º 8
0
 /**
  * Convert one driving order to one embedded list DTO
  *
  * @param DrivingOrder $drivingOrder
  * @return DrivingOrderEmbeddedListDTO
  */
 public function drivingOrderToDrivingOrderEmbeddedListDTO(DrivingOrder $drivingOrder)
 {
     $listDTO = new DrivingOrderEmbeddedListDTO();
     $listDTO->id = $drivingOrder->getId();
     $listDTO->passengerId = $drivingOrder->getPassenger()->getId();
     $listDTO->isDeleted = !$drivingOrder->isActive();
     $listDTO->sortOrder = $drivingOrder->getSortOrder();
     $listDTO->pickupDate = $this->dateTimeService->convertToLocalDateTime($drivingOrder->getPickUpDate())->format('d.m.Y');
     $listDTO->pickupTime = $this->dateTimeService->convertToLocalDateTime($drivingOrder->getPickUpTime())->format('H:i');
     $listDTO->addressFromString = $drivingOrder->getRoute()->getStartAddress()->toString();
     $listDTO->addressToString = $drivingOrder->getRoute()->getTargetAddress()->toString();
     return $listDTO;
 }
 /**
  * Converts an overbooked driving order to a human readable string.
  *
  * @param DrivingOrder $drivingOrder
  * @return string
  */
 private function getDrivingOrderString(DrivingOrder $drivingOrder)
 {
     /** @var DateTimeService $timeService */
     $timeService = $this->container->get('tixi_api.datetimeservice');
     $tr = $this->container->get('translator');
     $body = $tr->trans('drivingorder.issue.body');
     $dateStr = $drivingOrder->getPickUpDate()->format('d.m.Y');
     $timeStr = $timeService->convertToLocalTimeString($drivingOrder->getPickUpTime());
     $adr = $drivingOrder->getRoute()->getStartAddress();
     $location = $adr->getStreet() . ', ' . $adr->getCity();
     return $body . ' ' . $drivingOrder->getPassenger()->getNameStringForContact() . ' : ' . $dateStr . ' ' . $timeStr . ', ' . $location;
 }