223 lines
7.5 KiB
PHP
223 lines
7.5 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 tController 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['code'] = 0;
|
|
$obj['result'] = 'success';
|
|
$obj['data'] = $data;
|
|
|
|
if( g('API_EMBED_MODE') == 1 ){
|
|
return json_encode($obj);
|
|
}else{
|
|
header("Content-Type: application/json");
|
|
die(json_encode($obj));
|
|
}
|
|
}
|
|
|
|
|
|
public function rawdata()
|
|
{
|
|
|
|
render(null, 'web', 'rawdata');
|
|
|
|
}
|
|
|
|
public function device_data()
|
|
{
|
|
|
|
render(null, 'web', 'device_data');
|
|
|
|
}
|
|
|
|
public function device_set()
|
|
{
|
|
$token = $_SESSION['token'];
|
|
if(v('id')==null){
|
|
$sql = prepare("select project_id from user where token = ?s limit 1",array($token));
|
|
$project_id = get_var($sql);
|
|
|
|
if($project_id == 1){
|
|
header("Location:?c=t&a=device_set&id=1&did=1037");
|
|
}elseif($project_id == 3){
|
|
header("Location:?c=t&a=device_set&id=69&did=1043");
|
|
}elseif($project_id == 2){
|
|
header("Location:?c=t&a=device_set&id=7&did=7");
|
|
}
|
|
}else{
|
|
$role_id = $this->getUserRole($token);
|
|
if($role_id == 2) // 超级管理员账号
|
|
{
|
|
$sql = "select id,name,register_address as address,if(status=1,'在线','离线') as status,f_did,svg_type from device where status = 1 order by CONVERT(name USING gbk)";
|
|
}
|
|
elseif($role_id == 1) // 项目账号
|
|
{
|
|
$sql = prepare("select id,name,register_address as address,if(status=1,'在线','离线') as status,f_did,svg_type from device where status = 1 and project_id = (select project_id from user where token = ?s limit 1) order by CONVERT(name USING gbk)",array($token));
|
|
}
|
|
|
|
|
|
$result = get_data($sql);
|
|
$data['device_list']=$result;
|
|
render($data, 'web', 'device_set');
|
|
}
|
|
|
|
}
|
|
|
|
public function device_status()
|
|
{
|
|
|
|
render(null, 'web', 'device_status');
|
|
|
|
}
|
|
|
|
|
|
public function getRawdataList()
|
|
{
|
|
$start_time = $_GET['start_time'] == null ? date("Y-m-d ",time()) : $_GET['start_time'];
|
|
|
|
$today_start= $start_time." 00:00:00";
|
|
$today_end = $start_time." 23:59:59";
|
|
|
|
$sql = prepare("select device_id,rawdata,created_at,if(is_analysis=1,'未解析','已解析') as is_analysis,if(type=1,'工控机发上来数据','PLC发上来数据') as type from rawdata_new where created_at >= ?s and created_at <= ?s order by created_at desc limit 500",array($today_start,$today_end));
|
|
|
|
$data= get_data($sql);
|
|
|
|
return self::send_result($data);
|
|
}
|
|
|
|
|
|
public function getDeviceDataList()
|
|
{
|
|
|
|
$device_sql = "select id from device where project_id = 1";
|
|
|
|
$device_data= get_data($device_sql);
|
|
|
|
for ($i=0; $i < count($device_data); $i++)
|
|
{
|
|
$device_id = $device_data[$i]['id'];
|
|
|
|
$sql = prepare("select device.name,device.f_did,voltage_a_data,voltage_b_data,voltage_c_data,current_total_useful_power_data,elec_conductivity_tds_data,rainfall_data,rainsnow,level_data,ph_data,ammonia_data,data.created_at from data left join device on device.id = data.device_id where data.device_id = ?i order by data.created_at desc limit 1",array($device_id));
|
|
$data = get_line($sql);
|
|
|
|
$result[$i]['name'] = $data['name'];
|
|
$result[$i]['f_did'] = $data['f_did'];
|
|
$result[$i]['voltage_a_data'] = $data['voltage_a_data'];
|
|
$result[$i]['voltage_b_data'] = $data['voltage_b_data'];
|
|
$result[$i]['voltage_c_data'] = $data['voltage_c_data'];
|
|
$result[$i]['current_total_useful_power_data'] = $data['current_total_useful_power_data'];
|
|
$result[$i]['elec_conductivity_tds_data'] = $data['elec_conductivity_tds_data'];
|
|
$result[$i]['rainfall_data'] = $data['rainfall_data'];
|
|
$result[$i]['rainsnow'] = $data['rainsnow'];
|
|
$result[$i]['level_data'] = $data['level_data'];
|
|
$result[$i]['ph_data'] = $data['ph_data'];
|
|
$result[$i]['ammonia_data'] = $data['ammonia_data'];
|
|
$result[$i]['created_at'] = $data['created_at'];
|
|
}
|
|
|
|
return self::send_result($result);
|
|
}
|
|
|
|
public function getDevicStatusList()
|
|
{
|
|
$start_time = $_GET['start_time'] == null ? date("Y-m-d ",time()) : $_GET['start_time'];
|
|
|
|
$today_start= $start_time." 00:00:00";
|
|
$today_end = $start_time." 23:59:59";
|
|
|
|
$sql = "select id,name from device where project_id = 1";
|
|
$data= get_data($sql);
|
|
|
|
for ($i=0; $i < count($data); $i++)
|
|
{
|
|
$device_id = $data[$i]['id'];
|
|
$device_name = $data[$i]['name'];
|
|
|
|
$sql_1 = prepare("select device.name,if(main_sewage_pump=1,'开启','关闭') as main_sewage_pump,if(main_rain_pump=1,'开启','关闭') as main_rain_pump,if(automatic_status=1,'开启','关闭') as automatic_status,if(standby_sewage_pump=1,'开启','关闭') as standby_sewage_pump,if(gate_up=1,'上升','关闭') as gate_up,if(gate_down=1,'下降','关闭') as gate_down,main_sewage_pump_count,standby_sewage_pump_count,main_rain_pump_count,gate_up_count,gate_down_count,action_all_count,data.created_at from data left join device on device.id = data.device_id where data.device_id = ?i order by data.created_at desc limit 1",array($device_id));
|
|
$data_1 = get_line($sql_1);
|
|
|
|
$result[$i]['name'] = $data_1['name'];
|
|
$result[$i]['main_sewage_pump'] = $data_1['main_sewage_pump'];
|
|
$result[$i]['main_rain_pump'] = $data_1['main_rain_pump'];
|
|
$result[$i]['automatic_status'] = $data_1['automatic_status'];
|
|
$result[$i]['standby_sewage_pump'] = $data_1['standby_sewage_pump'];
|
|
$result[$i]['gate_up'] = $data_1['gate_up'];
|
|
$result[$i]['gate_down'] = $data_1['gate_down'];
|
|
$result[$i]['main_sewage_pump_count'] = $data_1['main_sewage_pump_count'];
|
|
$result[$i]['standby_sewage_pump_count'] = $data_1['standby_sewage_pump_count'];
|
|
$result[$i]['main_rain_pump_count'] = $data_1['main_rain_pump_count'];
|
|
$result[$i]['gate_up_count'] = $data_1['gate_up_count'];
|
|
$result[$i]['gate_down_count'] = $data_1['gate_down_count'];
|
|
$result[$i]['action_all_count'] = $data_1['action_all_count'];
|
|
$result[$i]['created_at'] = $data_1['created_at'];
|
|
}
|
|
|
|
|
|
return self::send_result($result);
|
|
}
|
|
|
|
|
|
public function test()
|
|
{
|
|
$jsonData = '{"patientCode":"TMC225888","cheCkNo":"ZYES206481","patientName":"测1","patientGender":"男","patientAge":"22","checkDate":"2024-01-18 22:52:29","endoscopeType":"","operatorDoctor":"信息科","department":"","endoscpeNo":"0613988224"}';
|
|
|
|
$ch = curl_init('http://127.0.0.1/ectms-pacs/ectms-pacs/?c=api&a=postPatientInfo');
|
|
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');
|
|
curl_setopt($ch, CURLOPT_POSTFIELDS, $jsonData);
|
|
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
|
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
|
|
'Content-Type: application/json',
|
|
'Content-Length: ' . strlen($jsonData)
|
|
));
|
|
|
|
$response = curl_exec($ch);
|
|
|
|
if($response === false) {
|
|
echo 'cURL Error: ' . curl_error($ch);
|
|
} else {
|
|
echo $response;
|
|
}
|
|
|
|
curl_close($ch);
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
*
|
|
* 获取登录用户的权限
|
|
*/
|
|
public function getUserRole($token)
|
|
{
|
|
$sql = prepare("select role_id from user where token = ?s limit 0,1",array($token));
|
|
$role_id = get_var($sql);
|
|
return $role_id;
|
|
}
|
|
} |