<?php

namespace app\index\controller;
use think\Db;
use think\Controller;
use think\Request;
class Dztj   extends Controller
{
public function index()
{
$b=Db::query("select count(id) y,concat(voltagegrade,'kV') name from bdz group by voltagegrade");
$b1=Db::query("select count(id) y,concat(scale,'mW') name from bdz group by scale");
foreach( $b as $k=>$v ) {
foreach( $v as $k1=>$v1 ) {
if($k1 == 'y'){
$b[$k]['y']= floatval($v1);
}
}
}
foreach( $b1 as $k=>$v ){
foreach( $v as $k1=>$v1 ){
if($k1 == 'y'){
$b1[$k]['y']=floatval($v1);
}}
}
$this->assign('dydj',json_encode($b));
$this->assign('dzgm',json_encode($b1));
return $this->fetch();
}
public function get_voltagegrade(){
$b=Db::query("select count(id) y,concat(voltagegrade,'kV') name from bdz group by voltagegrade");
$data=json_encode($b);
echo $data;
}
public function get_scale(){
$b=Db::query("select count(id) y,concat(scale,'mW') name from bdz group by scale");
$data=json_encode($b);
echo $data;
}
}
?>