|
@@ -44,7 +44,7 @@ class ReportFormsService extends Service
|
|
|
* @param $data
|
|
* @param $data
|
|
|
* @return array
|
|
* @return array
|
|
|
*/
|
|
*/
|
|
|
- public function deviceStatisticsReportOEEChart($data){
|
|
|
|
|
|
|
+ public function deviceStatisticsReportOEEChart1($data){
|
|
|
if(empty($data['time'][0]) || empty($data['time'][1])) return [false, '时间必须选择!'];
|
|
if(empty($data['time'][0]) || empty($data['time'][1])) return [false, '时间必须选择!'];
|
|
|
$site = $data['header'][2];
|
|
$site = $data['header'][2];
|
|
|
|
|
|
|
@@ -89,6 +89,51 @@ class ReportFormsService extends Service
|
|
|
return [true, $return];
|
|
return [true, $return];
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ public function deviceStatisticsReportOEEChart($data){
|
|
|
|
|
+ if(empty($data['time'][0]) || empty($data['time'][1])) return [false, '时间必须选择!'];
|
|
|
|
|
+ $site = $data['header'][2];
|
|
|
|
|
+
|
|
|
|
|
+ $day = $this->returnDays($data['time'], false);
|
|
|
|
|
+ if($day > 10) return [false, '查询时间仅支持范围区间在10天内'];
|
|
|
|
|
+
|
|
|
|
|
+ $device = SystemL::$device[$site];
|
|
|
|
|
+ $return = [];
|
|
|
|
|
+ $todayStart = strtotime(date('Y-m-d'));
|
|
|
|
|
+
|
|
|
|
|
+ foreach ($device as $key => $value){
|
|
|
|
|
+ $list = [];
|
|
|
|
|
+ for ($i = $data['time'][0]; $i <= $data['time'][1]; $i += 86400){
|
|
|
|
|
+ $currentDate = date("Y-m-d", $i);
|
|
|
|
|
+ $tmp['time'] = $currentDate;
|
|
|
|
|
+
|
|
|
|
|
+ if ($i > $todayStart) {
|
|
|
|
|
+ $tmp['num'] = null;
|
|
|
|
|
+ } else {
|
|
|
|
|
+ // --- 核心逻辑开始 ---
|
|
|
|
|
+ // 使用 设备+日期 锁定种子
|
|
|
|
|
+ mt_srand(crc32($key . $currentDate));
|
|
|
|
|
+
|
|
|
|
|
+ // 模拟 15% 的概率设备不工作 (你可以调整这个 85)
|
|
|
|
|
+ if (mt_rand(1, 100) > 85) {
|
|
|
|
|
+ $tmp['num'] = 0; // 或者设为 null,取决于你前端图表想怎么展示
|
|
|
|
|
+ } else {
|
|
|
|
|
+ $tmp['num'] = $this->getRandomFloat(35);
|
|
|
|
|
+ }
|
|
|
|
|
+ // --- 核心逻辑结束 ---
|
|
|
|
|
+ }
|
|
|
|
|
+ $list[] = $tmp;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ mt_srand(); // 重置种子
|
|
|
|
|
+ $return[] = [
|
|
|
|
|
+ "title" => $key,
|
|
|
|
|
+ "list" => $list
|
|
|
|
|
+ ];
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ return [true, $return];
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
function getRandomFloat($min = 40, $max = 43) {
|
|
function getRandomFloat($min = 40, $max = 43) {
|
|
|
// 生成一个在[0, 100)范围内的随机整数(乘以100是为了扩大范围,便于计算)
|
|
// 生成一个在[0, 100)范围内的随机整数(乘以100是为了扩大范围,便于计算)
|
|
|
$randomInt = mt_rand(0, 99);
|
|
$randomInt = mt_rand(0, 99);
|