|
@@ -8,27 +8,62 @@ use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
|
|
|
use Symfony\Component\HttpFoundation\Request;
|
|
|
use Symfony\Component\HttpFoundation\Response;
|
|
|
use Sonata\AdminBundle\Admin\Pool;
|
|
|
+use StatsBundle\Admin\OltAdmin;
|
|
|
|
|
|
class OltReportController extends Controller
|
|
|
{
|
|
|
|
|
|
/**
|
|
|
- * @Route("/olt/{deviceId}/report", name="admin_stats_olt_list")
|
|
|
+ * @Route("admin/stats/olt/{oltServerId}/{oltDeviceId}/report", name="admin_stats_olt_report")
|
|
|
*/
|
|
|
- public function mapReport($mapId) {
|
|
|
+ public function oltReport($oltServerId, $oltDeviceId) {
|
|
|
|
|
|
$adminPool = $this->get('sonata.admin.pool');
|
|
|
|
|
|
+ $filter = array('deviceId' => $oltDeviceId, 'deviceServer' => $oltServerId, 'deviceType' => 'FTTHBundle\Entity\OLT');
|
|
|
$em = $this->get('doctrine')->getManager();
|
|
|
- $map = $em->getRepository('MapBundle:Map')->findOneById($mapId);
|
|
|
+ $device = $em->getRepository('StatsBundle:Device')->findOneBy($filter);
|
|
|
+ $data = $device->jsonExtraData();
|
|
|
|
|
|
- return $this->render('MapBundle:Map:report.html.twig', array(
|
|
|
+ return $this->render('StatsBundle:Device:report.html.twig', array(
|
|
|
'base_template' => $adminPool->getTemplate('layout'),
|
|
|
'admin_pool' => $adminPool,
|
|
|
- 'admin' => $adminPool->getAdminByClass("StatsBundle\Entity\Device"),
|
|
|
- 'map' => $map
|
|
|
+ 'admin' => $adminPool->getAdminByAdminCode("stats.admin.olt"),
|
|
|
+ 'device' => $device,
|
|
|
+ 'data' => $data
|
|
|
));
|
|
|
}
|
|
|
|
|
|
+ public function onuStateCountAction($oltServerId, $oltDeviceId) {
|
|
|
+
|
|
|
+ $em = $this->get('doctrine')->getManager();
|
|
|
+ $onuStateCount = array();
|
|
|
+ $count = $em->getRepository('StatsBundle:Onu')->createQueryBuilder('o')
|
|
|
+ ->select('o.status','COUNT(o)')
|
|
|
+ ->where('o.deviceServer = :oltServerId')
|
|
|
+ ->andWhere('o.oltDeviceId = :oltDeviceId')
|
|
|
+ ->setParameter('oltServerId', $oltServerId)
|
|
|
+ ->setParameter('oltDeviceId', $oltDeviceId)
|
|
|
+ ->groupBy('o.status')
|
|
|
+ ->getQuery()->getScalarResult();
|
|
|
+
|
|
|
+ foreach($count as $c) {
|
|
|
+ $status = "Offline";
|
|
|
+ $color = "#F82929";
|
|
|
+ if($c['status']) {
|
|
|
+ $status = "Online";
|
|
|
+ $color = "#53D356";
|
|
|
+ }
|
|
|
+ $onuStateCount[$status] = array('count' => $c[1], 'color' => $color);
|
|
|
+ //$onuStateCount[$status] = $c[1];
|
|
|
+ }
|
|
|
+
|
|
|
+ //print_r($onuStateCount);die;
|
|
|
+
|
|
|
+ return $this->render('StatsBundle:Device:Report/onuStateCount.html.twig', array(
|
|
|
+ 'onuStateCount' => $onuStateCount
|
|
|
+ ));
|
|
|
+
|
|
|
+ }
|
|
|
|
|
|
}
|