|
@@ -517,14 +517,11 @@ class ReportFormsService extends Service
|
|
|
if(empty($result)) return [true,[]];
|
|
|
$device_name = array_values(array_unique(array_column($result,'device_name')));
|
|
|
|
|
|
- //急停 故障
|
|
|
- //压机上升 运行
|
|
|
- //小车前进 工作
|
|
|
- //待机 运行-工作
|
|
|
+ //运行时间 工作时间 故障
|
|
|
$run_time = $process_time = $fault = [];
|
|
|
foreach ($result as $value){
|
|
|
- //运行
|
|
|
if($value['data_point_name'] == SystemL::run){
|
|
|
+ //运行次数
|
|
|
if(isset($run_time[$value['device_name']])){
|
|
|
$run_time[$value['device_name']] += 1;
|
|
|
}else{
|
|
@@ -532,7 +529,7 @@ class ReportFormsService extends Service
|
|
|
}
|
|
|
}
|
|
|
if($value['data_point_name'] == SystemL::work){
|
|
|
- //加工 工作 运行次数
|
|
|
+ //工作次数
|
|
|
if(isset($process_time[$value['device_name']])){
|
|
|
$process_time[$value['device_name']] += 1;
|
|
|
}else{
|
|
@@ -550,40 +547,46 @@ class ReportFormsService extends Service
|
|
|
}
|
|
|
|
|
|
foreach ($device_name as $key => $value){
|
|
|
- //工作(加工)次数
|
|
|
+ //运行次数
|
|
|
+ $run_num = $run_time[$value] ?? 0;
|
|
|
+ //工作次数
|
|
|
$process_num = $process_time[$value] ?? 0;
|
|
|
-
|
|
|
- //运行时间
|
|
|
- $run_time_tmp = number_format(($run_time[$value] ?? 0) * 1.5 / 60,2);
|
|
|
- //工作/加工 时间
|
|
|
- $process_time_tmp = number_format($process_num * 1.5 / 60,2);
|
|
|
//故障次数
|
|
|
$fault_tmp = $fault[$value] ?? 0;
|
|
|
+
|
|
|
+ //运行时间
|
|
|
+ $run_time_tmp = $this->calTimeReturnMin($run_num);
|
|
|
+ //工作时间
|
|
|
+ $process_time_tmp = $this->calTimeReturnMin($process_num);
|
|
|
//故障时间
|
|
|
- $fault_time_tmp = number_format($fault_tmp * 1.5 / 60,2);
|
|
|
+ $fault_time_tmp = $this->calTimeReturnMin($fault_tmp);
|
|
|
+ //待机时间
|
|
|
+ $standby_time_tmp = number_format($run_time_tmp - $process_time_tmp,2);
|
|
|
|
|
|
- //计划运行时间 工作时间 - 计划停机 目前就是 $process_time_tmp
|
|
|
- //实际运行时间 计划运行时间 -故障停机 - 设备调整
|
|
|
+ //计划运行时间 工作时间 - 计划停机 (没有计划停机)
|
|
|
+ //实际运行时间 计划运行时间 -故障停机 - 设备调整(没有设备调整
|
|
|
$true_process_time = $process_time_tmp - $fault_time_tmp;
|
|
|
//有效率 实际/计划运行 时间
|
|
|
$efficient = $process_time_tmp > 0 ? number_format($true_process_time / $process_time_tmp,2) : 0;
|
|
|
- //表现性 加工数量/实际运行实际
|
|
|
+ //表现性 加工数量/实际运行时间
|
|
|
$expressive = $true_process_time > 0 ? number_format($process_num / $true_process_time,2) : 0;
|
|
|
//质量指数 加工数量- 废品数量 / 加工数量
|
|
|
- $quality_index = $process_num > 0 ? ($process_num - $fault_tmp) / $process_num : 0;
|
|
|
+ $quality_index = $process_num > 0 ? number_format(($process_num - $fault_tmp) / $process_num,2) : 0;
|
|
|
+ //OEE
|
|
|
+ $oee = number_format($efficient * $expressive * $quality_index,2);
|
|
|
|
|
|
$device_name[$key] = [
|
|
|
'device_name' => $value,
|
|
|
'run_time' => $run_time_tmp,
|
|
|
'process_time' => $process_time_tmp,
|
|
|
- 'standby_time' => number_format($run_time_tmp - $process_time_tmp,2),
|
|
|
+ 'standby_time' => $standby_time_tmp,
|
|
|
'process_num' => $process_num,
|
|
|
'fault_num' => $fault_tmp,
|
|
|
+ 'oee' => $oee,
|
|
|
// 'e' => $efficient,
|
|
|
// 'ex' => $expressive,
|
|
|
// 'true_process_time' => $true_process_time,
|
|
|
-// 'qua' => $quality_index,
|
|
|
- 'oee' => number_format($efficient * $expressive * $quality_index,2)
|
|
|
+// 'qua' => $quality_index
|
|
|
];
|
|
|
}
|
|
|
|
|
@@ -650,6 +653,7 @@ class ReportFormsService extends Service
|
|
|
|
|
|
date_default_timezone_set("PRC");
|
|
|
|
|
|
+ //所有的时间
|
|
|
$time_all = [];
|
|
|
foreach ($result as $value){
|
|
|
$time = date('Y-m-d',$value['time'] / 1000);
|
|
@@ -663,6 +667,7 @@ class ReportFormsService extends Service
|
|
|
}
|
|
|
sort($time_all);
|
|
|
|
|
|
+ //数据结构模型
|
|
|
foreach (SystemL::$device as $k => $v){
|
|
|
if(isset($process_time[$k])){
|
|
|
foreach ($time_all as $t){
|
|
@@ -710,8 +715,8 @@ class ReportFormsService extends Service
|
|
|
$run_time = $process_time = $fault = $time_all = [];
|
|
|
foreach ($result as $value){
|
|
|
$time = date("Y-m-d",$value['time'] / 1000);
|
|
|
- //运行
|
|
|
if($value['data_point_name'] == SystemL::run){
|
|
|
+ //运行次数
|
|
|
if(isset($run_time[$value['device_name']][$time])){
|
|
|
$run_time[$value['device_name']][$time] += 1;
|
|
|
}else{
|
|
@@ -719,7 +724,7 @@ class ReportFormsService extends Service
|
|
|
}
|
|
|
}
|
|
|
if($value['data_point_name'] == SystemL::work){
|
|
|
- //加工 工作 运行次数
|
|
|
+ //工作次数
|
|
|
if(isset($process_time[$value['device_name']][$time])){
|
|
|
$process_time[$value['device_name']][$time] += 1;
|
|
|
}else{
|
|
@@ -727,7 +732,7 @@ class ReportFormsService extends Service
|
|
|
}
|
|
|
}
|
|
|
if($value['data_point_name'] == SystemL::stop){
|
|
|
- //设备故障次数
|
|
|
+ //故障次数
|
|
|
if(isset($fault[$value['device_name']][$time])){
|
|
|
$fault[$value['device_name']][$time] += 1;
|
|
|
}else{
|
|
@@ -750,48 +755,36 @@ class ReportFormsService extends Service
|
|
|
//填充模型里的数据
|
|
|
foreach ($device_name as $value){//设备名
|
|
|
foreach ($time_all as $d_val){
|
|
|
-//工作(加工)次数
|
|
|
+ //运行次数
|
|
|
+ $run_num = $run_time[$value][$d_val] ?? 0;
|
|
|
+ //工作次数
|
|
|
$process_num = $process_time[$value][$d_val] ?? 0;
|
|
|
-
|
|
|
- //运行时间
|
|
|
- $run_time_tmp = number_format(($run_time[$value][$d_val] ?? 0) * 1.5 / 60,2);
|
|
|
- //工作/加工 时间
|
|
|
- $process_time_tmp = number_format($process_num * 1.5 / 60,2);
|
|
|
//故障次数
|
|
|
$fault_tmp = $fault[$value][$d_val] ?? 0;
|
|
|
+
|
|
|
+ //运行时间
|
|
|
+ $run_time_tmp = $this->calTimeReturnMin($run_num);
|
|
|
+ //工作时间
|
|
|
+ $process_time_tmp = $this->calTimeReturnMin($process_num);
|
|
|
//故障时间
|
|
|
- $fault_time_tmp = number_format($fault_tmp * 1.5 / 60,2);
|
|
|
+ $fault_time_tmp = $this->calTimeReturnMin($fault_tmp);
|
|
|
|
|
|
- //计划运行时间 工作时间 - 计划停机 目前就是 $process_time_tmp
|
|
|
+ //计划运行时间 工作时间 - 计划停机
|
|
|
//实际运行时间 计划运行时间 -故障停机 - 设备调整
|
|
|
$true_process_time = $process_time_tmp - $fault_time_tmp;
|
|
|
//有效率 实际/计划运行 时间
|
|
|
$efficient = $process_time_tmp > 0 ? number_format($true_process_time / $process_time_tmp,2) : 0;
|
|
|
- //表现性 加工数量/实际运行实际
|
|
|
+ //表现性 加工数量/实际运行时间
|
|
|
$expressive = $true_process_time > 0 ? number_format($process_num / $true_process_time,2) : 0;
|
|
|
//质量指数 加工数量- 废品数量 / 加工数量
|
|
|
- $quality_index = $process_num > 0 ? ($process_num - $fault_tmp) / $process_num : 0;
|
|
|
-
|
|
|
+ $quality_index = $process_num > 0 ? number_format(($process_num - $fault_tmp) / $process_num,2) : 0;
|
|
|
+ //OEE
|
|
|
+ $oee = number_format($efficient * $expressive * $quality_index,2);
|
|
|
+ //模型里赋值
|
|
|
if(isset($models[$value][$d_val])){
|
|
|
- $models[$value][$d_val] = number_format($efficient * $expressive * $quality_index,2);
|
|
|
+ $models[$value][$d_val] = $oee;
|
|
|
}
|
|
|
-
|
|
|
-// $return[$value][] = [
|
|
|
-// 'time' => $d_val,
|
|
|
-// 'device_name' => $d_val,
|
|
|
-// 'run_time' => $run_time_tmp,
|
|
|
-// 'process_time' => $process_time_tmp,
|
|
|
-// 'standby_time' => number_format($run_time_tmp - $process_time_tmp,2),
|
|
|
-// 'process_num' => $process_num,
|
|
|
-// 'fault_num' => $fault_tmp,
|
|
|
-// 'e' => $efficient,
|
|
|
-// 'ex' => $expressive,
|
|
|
-// 'true_process_time' => $true_process_time,
|
|
|
-// 'qua' => $quality_index,
|
|
|
-// 'oee' => number_format($efficient * $expressive * $quality_index,2)
|
|
|
-// ];
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
|
|
|
//返回结果
|
|
@@ -810,4 +803,9 @@ class ReportFormsService extends Service
|
|
|
|
|
|
return [true,$final];
|
|
|
}
|
|
|
+
|
|
|
+ //用于计算时间
|
|
|
+ private function calTimeReturnMin($minute){
|
|
|
+ return number_format($minute * 1.5 / 60,2);
|
|
|
+ }
|
|
|
}
|