134 lines
3.6 KiB
PHP
134 lines
3.6 KiB
PHP
<?php
|
|
session_start();
|
|
if( !defined('IN') ) die('bad request!');
|
|
include_once( AROOT . 'controller' . DS . 'app.class.php');
|
|
header("Content-Type: text/html; charset=utf-8");
|
|
|
|
class simController extends appController
|
|
{
|
|
public function __construct()
|
|
{
|
|
parent::__construct();
|
|
}
|
|
|
|
// 发送错误结果集
|
|
public function send_error($number,$msg)
|
|
{
|
|
$obj = array();
|
|
$obj['code'] = intval($number);
|
|
$obj['result'] = $msg;
|
|
|
|
if( g('API_EMBED_MODE') == 1 ){
|
|
return json_encode($obj);
|
|
}else{
|
|
header("Content-Type: application/json");
|
|
die(json_encode($obj));
|
|
}
|
|
}
|
|
|
|
// 发送结果集
|
|
public function send_result($data)
|
|
{
|
|
$obj = array();
|
|
$obj['rows'] = $data;
|
|
// $obj['result'] = 'success';
|
|
$obj['total'] = 1731;
|
|
|
|
if( g('API_EMBED_MODE') == 1 ){
|
|
return json_encode($obj);
|
|
}else{
|
|
header("Content-Type: application/json");
|
|
die(json_encode($obj));
|
|
}
|
|
}
|
|
|
|
public function simDataTable(){
|
|
$module_hanyupinyin = v("id");
|
|
$project_id = $_SESSION['project_id'];
|
|
if($project_id == '0'){
|
|
if(empty($module_hanyupinyin)){
|
|
$sql ="select sim.id,project.name as project,terminal.name as terminal,iccid,device.name,sim.operator,sim.status,sim.update_time from sim,device,project,terminal where project.id=device.project_id and device.id=sim.device_id and terminal.id=device.terminal_id";
|
|
}else{
|
|
$sql =prepare("select sim.id,project.name as project,terminal.name as terminal,iccid,device.name,sim.operator,sim.status,sim.update_time from sim,device,project,terminal where project.id=device.project_id and device.id=sim.device_id and terminal.id=device.terminal_id and device.project_id=?i",array($module_hanyupinyin));
|
|
}
|
|
|
|
}else{
|
|
if(empty($module_hanyupinyin)){
|
|
$sql =prepare("select sim.id,project.name as project,terminal.name as terminal,iccid,device.name,sim.operator,sim.status,sim.update_time from sim,device,project,terminal where project.id=device.project_id and device.id=sim.device_id and terminal.id=device.terminal_id and device.project_id=?i",array($project_id));
|
|
}else{
|
|
$sql =prepare("select sim.id,project.name as project,terminal.name as terminal,iccid,device.name,sim.operator,sim.status,sim.update_time from sim,device,project,terminal where project.id=device.project_id and device.id=sim.device_id and terminal.id=device.terminal_id and device.project_id=?i",array($module_hanyupinyin));
|
|
}
|
|
}
|
|
$data = get_data($sql);
|
|
return self::send_result($data);
|
|
}
|
|
|
|
// 通过时间参数 获取区域基本医废产量
|
|
public function getAreaDashboardProductionLine()
|
|
{
|
|
|
|
$result = array(
|
|
"time"=>array("2018-08-11 00:00:00", "2018-08-12 01:30:00", "2018-08-13 02:30:00", "2018-08-14 03:30:00", "2018-08-15 04:30:00"),
|
|
"data"=>array(32, 60, 34, 46, 34)
|
|
);
|
|
|
|
return self::send_result($result);
|
|
}
|
|
|
|
// 通过时间参数 获取整个区域的医废类型分布图
|
|
public function getAreaDashboardMwTypePie()
|
|
{
|
|
$result = array(368,81);
|
|
|
|
return self::send_result($result);
|
|
}
|
|
|
|
//
|
|
public function userEdit(){
|
|
if (!empty($_SESSION)) {
|
|
render(null, 'web', 'userEdit');
|
|
|
|
} else {
|
|
|
|
header("Location:?c=index&a=index");
|
|
|
|
}
|
|
}
|
|
|
|
/**
|
|
* 获取两个指定日期之间的每一天
|
|
*/
|
|
public function getDateFromtime($starttime,$endtime)
|
|
{
|
|
|
|
$dt_start = strtotime($starttime);
|
|
$dt_end = strtotime($endtime);
|
|
|
|
while ($dt_start <= $dt_end){
|
|
|
|
$array[] = date('Y-m-d',$dt_start);
|
|
|
|
$dt_start = strtotime('+1 day',$dt_start);
|
|
}
|
|
|
|
return $array;
|
|
}
|
|
|
|
|
|
/**
|
|
* 获取本年的12个月
|
|
*/
|
|
public function getYearMonthTime()
|
|
{
|
|
|
|
for ($i=1; $i < 13; $i++) {
|
|
|
|
$month = date("Y",time())."-".$i;
|
|
|
|
$array[] = date("Y-m",strtotime($month));
|
|
|
|
}
|
|
|
|
return $array;
|
|
}
|
|
} |