|
@@ -11,151 +11,86 @@ use Modules\OpcData\Entities\OpcDataDict;
|
|
|
|
|
|
class OpcDataController extends Controller
|
|
class OpcDataController extends Controller
|
|
{
|
|
{
|
|
- protected $opcDB;
|
|
|
|
- // private $opcDictArr = array();
|
|
|
|
- protected $opcConnectName = 'mysql_opc_jinjiaqu';
|
|
|
|
- // private $dictTableName = 'tb_dev_dict_list';
|
|
|
|
- // private $dataTableName = 'equipment';
|
|
|
|
-
|
|
|
|
- public function __construct() {
|
|
|
|
- $this->opcDB = DB::connection($this->opcConnectName);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * Display a listing of the resource.
|
|
|
|
- * @return Renderable
|
|
|
|
- */
|
|
|
|
- public function index()
|
|
|
|
- {
|
|
|
|
- return view('opcdata::index');
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * Show the form for creating a new resource.
|
|
|
|
- * @return Renderable
|
|
|
|
- */
|
|
|
|
- public function create()
|
|
|
|
- {
|
|
|
|
- return view('opcdata::create');
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * Store a newly created resource in storage.
|
|
|
|
- * @param Request $request
|
|
|
|
- * @return Renderable
|
|
|
|
- */
|
|
|
|
- public function store(Request $request)
|
|
|
|
- {
|
|
|
|
- //
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * Show the specified resource.
|
|
|
|
- * @param int $id
|
|
|
|
- * @return Renderable
|
|
|
|
- */
|
|
|
|
- public function show($id)
|
|
|
|
- {
|
|
|
|
- return view('opcdata::show');
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * Show the form for editing the specified resource.
|
|
|
|
- * @param int $id
|
|
|
|
- * @return Renderable
|
|
|
|
- */
|
|
|
|
- public function edit($id)
|
|
|
|
- {
|
|
|
|
- return view('opcdata::edit');
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * Update the specified resource in storage.
|
|
|
|
- * @param Request $request
|
|
|
|
- * @param int $id
|
|
|
|
- * @return Renderable
|
|
|
|
- */
|
|
|
|
- public function update(Request $request, $id)
|
|
|
|
- {
|
|
|
|
- //
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * Remove the specified resource from storage.
|
|
|
|
- * @param int $id
|
|
|
|
- * @return Renderable
|
|
|
|
- */
|
|
|
|
- public function destroy($id)
|
|
|
|
- {
|
|
|
|
- //
|
|
|
|
- }
|
|
|
|
|
|
+ protected $opcConf = [
|
|
|
|
+ 'ventilation_zb' => 1,
|
|
|
|
+ 'ventilation_bb' => 2,
|
|
|
|
+ 'pump_zy' => 3,
|
|
|
|
+ 'pump_690' => 4,
|
|
|
|
+ 'compressed_air' => 5,
|
|
|
|
+ 'belt_13' => 6,
|
|
|
|
+ 'hoist' => 7
|
|
|
|
+ ];
|
|
|
|
|
|
public function getData(Request $request)
|
|
public function getData(Request $request)
|
|
{
|
|
{
|
|
$getDataType = $request->system_type; // 获取需要的数据
|
|
$getDataType = $request->system_type; // 获取需要的数据
|
|
|
|
+ $getMineCode = $request->mine_code; // 矿分类
|
|
$dataArr = array(); // 返回数据数组
|
|
$dataArr = array(); // 返回数据数组
|
|
- $result;
|
|
|
|
|
|
+
|
|
|
|
+ $opcConnectName = 'mysql_opc_jinjiaqu';
|
|
|
|
+
|
|
|
|
+ $opcDB = DB::connection($opcConnectName);
|
|
|
|
|
|
- if ($getDataType == 'ventilation_zb'){
|
|
|
|
- // 中部风机
|
|
|
|
- $groupId = 1;
|
|
|
|
- $result = $this->getFanData($groupId);
|
|
|
|
- } else if ($getDataType == 'ventilation_bb') {
|
|
|
|
- // 北部风机
|
|
|
|
- $groupId = 2;
|
|
|
|
- $result = $this->getFanData($groupId);
|
|
|
|
- } else if ($getDataType == 'pump_zy') {
|
|
|
|
- // 中央水泵
|
|
|
|
- $groupId = 3;
|
|
|
|
- $result = $this->getPumpData($groupId);
|
|
|
|
- } else if ($getDataType == 'pump_690') {
|
|
|
|
- // 609水泵
|
|
|
|
- $groupId = 4;
|
|
|
|
- $result = $this->getPumpData($groupId);
|
|
|
|
- } else if ($getDataType == 'compressed_air') {
|
|
|
|
- // 压风
|
|
|
|
- $groupId = 5;
|
|
|
|
- $result = $this->getCompressedAirData($groupId);
|
|
|
|
- } else if ($getDataType == 'belt_13') {
|
|
|
|
- // 13采区胶带运输机系统
|
|
|
|
- $groupId = 6;
|
|
|
|
- $result = $this->getBeltData($groupId);
|
|
|
|
- } else if ($getDataType == 'hoist') {
|
|
|
|
- // 提升机
|
|
|
|
- $groupId = 7;
|
|
|
|
- $result = $this->getHoistData($groupId);
|
|
|
|
- } else {
|
|
|
|
- return;
|
|
|
|
|
|
+ if (array_key_exists($getDataType, $this->opcConf)) {
|
|
|
|
+ $groupId = $this->opcConf[$getDataType];
|
|
|
|
+ $sqlStr = "
|
|
|
|
+ select t1.dev_type_id,
|
|
|
|
+ t1.dev_type_name,
|
|
|
|
+ t1.device_num,
|
|
|
|
+ t1.device_name,
|
|
|
|
+ case t.val
|
|
|
|
+ when 'True' then 1
|
|
|
|
+ when 'False' then 2
|
|
|
|
+ else t.val
|
|
|
|
+ end val,
|
|
|
|
+ t1.json_key,
|
|
|
|
+ t1.row_number,
|
|
|
|
+ t1.unit
|
|
|
|
+ from equipment t
|
|
|
|
+ join tb_dev_dict_list t1 on t.selItem = t1.selItem
|
|
|
|
+ where t1.group_id = ".$groupId."
|
|
|
|
+ and t1.is_show = 1
|
|
|
|
+ order by t1.dev_type_id, t1.row_number, t1.device_num, t1.device_name
|
|
|
|
+ ";
|
|
|
|
+ $dbResult = $opcDB->select($sqlStr);
|
|
|
|
+ switch($getDataType) {
|
|
|
|
+ // 中部风机
|
|
|
|
+ case 'ventilation_zb':
|
|
|
|
+ $result = $this->getFanData($dbResult);
|
|
|
|
+ break;
|
|
|
|
+ // 北部风机
|
|
|
|
+ case 'ventilation_bb':
|
|
|
|
+ $result = $this->getFanData($dbResult);
|
|
|
|
+ break;
|
|
|
|
+ case 'pump_zy':
|
|
|
|
+ // 中央水泵
|
|
|
|
+ $result = $this->getPumpData($dbResult);
|
|
|
|
+ break;
|
|
|
|
+ case 'pump_690':
|
|
|
|
+ // 609水泵
|
|
|
|
+ $result = $this->getPumpData($dbResult);
|
|
|
|
+ break;
|
|
|
|
+ case 'compressed_air':
|
|
|
|
+ // 压风
|
|
|
|
+ $result = $this->getCompressedAirData($dbResult);
|
|
|
|
+ break;
|
|
|
|
+ case 'belt_13':
|
|
|
|
+ // 13采区胶带运输机系统
|
|
|
|
+ $result = $this->getBeltData($dbResult);
|
|
|
|
+ break;
|
|
|
|
+ case 'hoist':
|
|
|
|
+ // 提升机
|
|
|
|
+ $result = $this->getHoistData($dbResult);
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ return response()->json($result);
|
|
}
|
|
}
|
|
- return response()->json($result);
|
|
|
|
|
|
+ return;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ // 风机
|
|
|
|
+ public function getFanData($dbResult) {
|
|
|
|
|
|
- // 水泵
|
|
|
|
- public function getFanData($groupId) {
|
|
|
|
-
|
|
|
|
- $sqlStr = "
|
|
|
|
- select t1.dev_type_id,
|
|
|
|
- t1.dev_type_name,
|
|
|
|
- t1.device_num,
|
|
|
|
- t1.device_name,
|
|
|
|
- case t.val
|
|
|
|
- when 'True' then 1
|
|
|
|
- when 'False' then 2
|
|
|
|
- else t.val
|
|
|
|
- end val,
|
|
|
|
- t1.json_key,
|
|
|
|
- t1.row_number,
|
|
|
|
- t1.unit
|
|
|
|
- from equipment t
|
|
|
|
- join tb_dev_dict_list t1 on t.selItem = t1.selItem
|
|
|
|
- where t1.group_id = ".$groupId."
|
|
|
|
- and t1.is_show = 1
|
|
|
|
- order by t1.dev_type_id, t1.row_number, t1.device_num, t1.device_name
|
|
|
|
- ";
|
|
|
|
-
|
|
|
|
- $dbResult = $this->opcDB->select($sqlStr);
|
|
|
|
- // dd($dbResult);
|
|
|
|
foreach ($dbResult as $key => $val) {
|
|
foreach ($dbResult as $key => $val) {
|
|
$fanNum = $val->dev_type_id - 1; // 风机号
|
|
$fanNum = $val->dev_type_id - 1; // 风机号
|
|
$label = $val->device_name; // 设备名
|
|
$label = $val->device_name; // 设备名
|
|
@@ -188,29 +123,9 @@ class OpcDataController extends Controller
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
- public function getPumpData($groupId) {
|
|
|
|
-
|
|
|
|
- $sqlStr = "
|
|
|
|
- select t1.dev_type_id,
|
|
|
|
- t1.dev_type_name,
|
|
|
|
- t1.device_num,
|
|
|
|
- t1.device_name,
|
|
|
|
- case t.val
|
|
|
|
- when 'True' then 1
|
|
|
|
- when 'False' then 2
|
|
|
|
- else t.val
|
|
|
|
- end val,
|
|
|
|
- t1.json_key,
|
|
|
|
- t1.row_number,
|
|
|
|
- t1.unit
|
|
|
|
- from equipment t
|
|
|
|
- join tb_dev_dict_list t1 on t.selItem = t1.selItem
|
|
|
|
- where t1.group_id = ".$groupId."
|
|
|
|
- and t1.is_show = 1
|
|
|
|
- order by t1.dev_type_id, t1.row_number, t1.device_num, t1.device_name
|
|
|
|
- ";
|
|
|
|
-
|
|
|
|
- $dbResult = $this->opcDB->select($sqlStr);
|
|
|
|
|
|
+ // 水泵
|
|
|
|
+ public function getPumpData($dbResult) {
|
|
|
|
+
|
|
$timeArr = array(); // 用于拼接时分秒
|
|
$timeArr = array(); // 用于拼接时分秒
|
|
$timeJsonKey; // 记录time字段key名
|
|
$timeJsonKey; // 记录time字段key名
|
|
// dd($dbResult);
|
|
// dd($dbResult);
|
|
@@ -223,8 +138,8 @@ class OpcDataController extends Controller
|
|
$unit = $val->unit; // 单位
|
|
$unit = $val->unit; // 单位
|
|
$devVal = $val->val; // 数值
|
|
$devVal = $val->val; // 数值
|
|
|
|
|
|
- if ($rowNumber <= 4) {
|
|
|
|
-
|
|
|
|
|
|
+ if ($jsonKey == 'common') {
|
|
|
|
+ // 公共数据
|
|
$valArr = [
|
|
$valArr = [
|
|
'label' => $label, // 标题
|
|
'label' => $label, // 标题
|
|
'value' => $devVal, // 值
|
|
'value' => $devVal, // 值
|
|
@@ -232,32 +147,22 @@ class OpcDataController extends Controller
|
|
];
|
|
];
|
|
$dataArr[$jsonKey][] = $valArr;
|
|
$dataArr[$jsonKey][] = $valArr;
|
|
|
|
|
|
- } else if ($rowNumber == 5) {
|
|
|
|
- if ($groupId == 4) {
|
|
|
|
- // 609水泵房单独处理状态
|
|
|
|
- $dataArr['water_pump'][$devNum]['name'] = $devName;
|
|
|
|
- if (array_key_exists($jsonKey, $dataArr['water_pump'][$devNum])) {
|
|
|
|
- $state = $dataArr['water_pump'][$devNum][$jsonKey];
|
|
|
|
- $dataArr['water_pump'][$devNum][$jsonKey] = max($devVal, $state);
|
|
|
|
- } else {
|
|
|
|
- $dataArr['water_pump'][$devNum][$jsonKey] = $devVal;
|
|
|
|
- }
|
|
|
|
|
|
+ } else if ($jsonKey == 'water_pump') {
|
|
|
|
+ // 水泵、状态
|
|
|
|
+ $dataArr[$jsonKey][$devNum]['label'] = $devName;
|
|
|
|
+ if (array_key_exists($jsonKey, $dataArr[$jsonKey][$devNum])) {
|
|
|
|
+ $state = $dataArr[$jsonKey][$devNum]['state'];
|
|
|
|
+ $dataArr[$jsonKey][$devNum]['state'] = max($devVal, $state);
|
|
} else {
|
|
} else {
|
|
- // 中央水泵房电机开启状态处理
|
|
|
|
- $valArr = [
|
|
|
|
- 'label' => $devName, // 标题
|
|
|
|
- 'state' => $devVal // 值
|
|
|
|
- ];
|
|
|
|
- $dataArr[$jsonKey][] = $valArr;
|
|
|
|
|
|
+ $dataArr[$jsonKey][$devNum]['state'] = $devVal;
|
|
}
|
|
}
|
|
-
|
|
|
|
- } else if ($rowNumber == 10 or $rowNumber == 11) {
|
|
|
|
-
|
|
|
|
|
|
+ } else if ($jsonKey == 'parameter' && $unit == 'HH' && $unit == 'MM' && $unit == 'SS') {
|
|
|
|
+ // 处理时长
|
|
$timeArr[$label][$devNum][$unit] = $devVal;
|
|
$timeArr[$label][$devNum][$unit] = $devVal;
|
|
$timeJsonKey = $jsonKey;
|
|
$timeJsonKey = $jsonKey;
|
|
|
|
|
|
- } else if ($rowNumber > 5) {
|
|
|
|
-
|
|
|
|
|
|
+ } else {
|
|
|
|
+ // 水泵参数
|
|
$valArr = [
|
|
$valArr = [
|
|
'label' => $label, // 标题
|
|
'label' => $label, // 标题
|
|
'value' => $devVal, // 值
|
|
'value' => $devVal, // 值
|
|
@@ -286,29 +191,8 @@ class OpcDataController extends Controller
|
|
|
|
|
|
|
|
|
|
// 压风
|
|
// 压风
|
|
- public function getCompressedAirData($groupId) {
|
|
|
|
-
|
|
|
|
- $sqlStr = "
|
|
|
|
- select t1.dev_type_id,
|
|
|
|
- t1.dev_type_name,
|
|
|
|
- t1.device_num,
|
|
|
|
- t1.device_name,
|
|
|
|
- case t.val
|
|
|
|
- when 'True' then 1
|
|
|
|
- when 'False' then 2
|
|
|
|
- else t.val
|
|
|
|
- end val,
|
|
|
|
- t1.json_key,
|
|
|
|
- t1.row_number,
|
|
|
|
- t1.unit
|
|
|
|
- from equipment t
|
|
|
|
- join tb_dev_dict_list t1 on t.selItem = t1.selItem
|
|
|
|
- where t1.group_id = ".$groupId."
|
|
|
|
- and t1.is_show = 1
|
|
|
|
- order by t1.dev_type_id, t1.row_number, t1.device_num, t1.device_name
|
|
|
|
- ";
|
|
|
|
-
|
|
|
|
- $dbResult = $this->opcDB->select($sqlStr);
|
|
|
|
|
|
+ public function getCompressedAirData($dbResult) {
|
|
|
|
+
|
|
$timeArr = array(); // 用于拼接时分秒
|
|
$timeArr = array(); // 用于拼接时分秒
|
|
$timeJsonKey; // 记录time字段key名
|
|
$timeJsonKey; // 记录time字段key名
|
|
// dd($dbResult);
|
|
// dd($dbResult);
|
|
@@ -374,29 +258,8 @@ class OpcDataController extends Controller
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- public function getBeltData($groupId) {
|
|
|
|
-
|
|
|
|
- $sqlStr = "
|
|
|
|
- select t1.dev_type_id,
|
|
|
|
- t1.dev_type_name,
|
|
|
|
- t1.device_num,
|
|
|
|
- t1.device_name,
|
|
|
|
- case t.val
|
|
|
|
- when 'True' then 1
|
|
|
|
- when 'False' then 2
|
|
|
|
- else t.val
|
|
|
|
- end val,
|
|
|
|
- t1.json_key,
|
|
|
|
- t1.row_number,
|
|
|
|
- t1.unit
|
|
|
|
- from equipment t
|
|
|
|
- join tb_dev_dict_list t1 on t.selItem = t1.selItem
|
|
|
|
- where t1.group_id = ".$groupId."
|
|
|
|
- and t1.is_show = 1
|
|
|
|
- order by t1.dev_type_id, t1.row_number, t1.device_num, t1.device_name
|
|
|
|
- ";
|
|
|
|
-
|
|
|
|
- $dbResult = $this->opcDB->select($sqlStr);
|
|
|
|
|
|
+ public function getBeltData($dbResult) {
|
|
|
|
+
|
|
$valDict = array();
|
|
$valDict = array();
|
|
foreach ($dbResult as $key => $val) {
|
|
foreach ($dbResult as $key => $val) {
|
|
$devName = $val->dev_type_name; // 泵名
|
|
$devName = $val->dev_type_name; // 泵名
|
|
@@ -452,29 +315,8 @@ class OpcDataController extends Controller
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- public function getHoistData($groupId) {
|
|
|
|
-
|
|
|
|
- $sqlStr = "
|
|
|
|
- select t1.dev_type_id,
|
|
|
|
- t1.dev_type_name,
|
|
|
|
- t1.device_num,
|
|
|
|
- t1.device_name,
|
|
|
|
- case t.val
|
|
|
|
- when 'True' then 1
|
|
|
|
- when 'False' then 2
|
|
|
|
- else t.val
|
|
|
|
- end val,
|
|
|
|
- t1.json_key,
|
|
|
|
- t1.row_number,
|
|
|
|
- t1.unit
|
|
|
|
- from equipment t
|
|
|
|
- join tb_dev_dict_list t1 on t.selItem = t1.selItem
|
|
|
|
- where t1.group_id = ".$groupId."
|
|
|
|
- and t1.is_show = 1
|
|
|
|
- order by t1.dev_type_id, t1.row_number, t1.device_num, t1.dev_type_name, t1.device_name
|
|
|
|
- ";
|
|
|
|
-
|
|
|
|
- $dbResult = $this->opcDB->select($sqlStr);
|
|
|
|
|
|
+ public function getHoistData($dbResult) {
|
|
|
|
+
|
|
$valDict = array();
|
|
$valDict = array();
|
|
$state = 2;
|
|
$state = 2;
|
|
// dd($dbResult);
|
|
// dd($dbResult);
|