Quellcode durchsuchen

修改工艺重新排序

qiuenguang vor 1 Jahr
Ursprung
Commit
b1fcdc0244
1 geänderte Dateien mit 51 neuen und 11 gelöschten Zeilen
  1. 51 11
      application/api/controller/Facility.php

+ 51 - 11
application/api/controller/Facility.php

@@ -217,13 +217,32 @@ class Facility extends Api
             $this->error('请求错误');
         }
         $machine = input('machine');
-        $date = input('date');
-        if (empty($machine) || empty($date)){
+//        $date = input('date');
+        // 获取当前时间
+        $current_time = time();
+        // 设置时间范围
+        $start_time1 = strtotime(date('Y-m-d') . ' 08:30:00');
+        $end_time1 = strtotime(date('Y-m-d') . ' 20:30:00');
+        $end_time2 = strtotime(date('Y-m-d') . ' 24:00:00');
+        $start_time3 = strtotime(date('Y-m-d', strtotime('+1 day')) . ' 08:30:00');
+        $start_time4 = strtotime(date('Y-m-d', strtotime('+1 day')) . ' 00:00:00');
+        // 判断当前时间属于哪个时间范围
+        if ($current_time >= $start_time1 && $current_time <= $end_time1) {
+            $startTime = date('Y-m-d') . ' 08:30:00';
+        } elseif ($current_time > $end_time1 && $current_time <= $end_time2) {
+            $startTime = date('Y-m-d') . ' 20:30:00';
+
+        } elseif ($current_time > $end_time1 && $current_time <= $start_time3) {
+            $startTime = date('Y-m-d', strtotime('+1 day')) . ' 08:30:00';
+        }elseif ($current_time > $start_time4 && $current_time <= $start_time3){
+            $startTime = date('Y-m-d') . ' 20:30:00';
+        }
+        if (empty($machine)){
             $this->error('参数错误');
         }
         $where = [
             '设备编号' => $machine,
-            '开工时间' => ['between',[date('Y-m-d 08:00:00',strtotime($date)),date('Y-m-d 08:00:00',strtotime($date)+86400)]],
+            '开工时间' => $startTime,
             '类别' => ['in',['IPQC检验','机台检验']],
         ];
         $field = 'rtrim(工单编号) as 工单编号,rtrim(印件号) as 印件号,rtrim(工序名称) as 工序名称,提交时间,rtrim(检验项目) as 检验项目';
@@ -306,6 +325,7 @@ class Facility extends Api
                     $list['工序名称'] = $data['工序名称'];
             }
             $list['状态'] = rtrim($data['当前状态']);
+            $list['开工时间'] = $data['开工时间'];
         }else{
             $list['工单编号'] = '';
             $list['印件号'] = 0;
@@ -313,6 +333,7 @@ class Facility extends Api
             $list['工序名称'] = '';
             $list['产品代号'] = '';
             $list['状态'] = '';
+            $list['开工时间'] = '';
         }
         $list['班组编号'] = rtrim($data['班组编号']);
         $list['班组Id'] = rtrim($data['班组ID']);
@@ -772,14 +793,33 @@ class Facility extends Api
         if (empty($param)){
             $this->error('参数错误');
         }
-        $date = date('Y-m-d H:i:s',time());
-        if (empty($param['start'])){
-            $startTime = date('Y-m-d 08:30:00',time());
-        }else{
-            $startTime = date('Y-m-d H:i:s',strtotime($param['start']));
-        }
-        if ($date<$startTime){
-            $startTime = date('Y-m-d H:i:s',strtotime($startTime)-86400);
+//        $date = date('Y-m-d H:i:s',time());
+//        if (empty($param['start'])){
+//            $startTime = date('Y-m-d 08:30:00',time());
+//        }else{
+//            $startTime = date('Y-m-d H:i:s',strtotime($param['start']));
+//        }
+//        if ($date<$startTime){
+//            $startTime = date('Y-m-d H:i:s',strtotime($startTime)-86400);
+//        }
+        // 获取当前时间
+        $current_time = time();
+        // 设置时间范围
+        $start_time1 = strtotime(date('Y-m-d') . ' 08:30:00');
+        $end_time1 = strtotime(date('Y-m-d') . ' 20:30:00');
+        $end_time2 = strtotime(date('Y-m-d') . ' 24:00:00');
+        $start_time3 = strtotime(date('Y-m-d', strtotime('+1 day')) . ' 08:30:00');
+        $start_time4 = strtotime(date('Y-m-d', strtotime('+1 day')) . ' 00:00:00');
+        // 判断当前时间属于哪个时间范围
+        if ($current_time >= $start_time1 && $current_time <= $end_time1) {
+            $startTime = date('Y-m-d') . ' 08:30:00';
+        } elseif ($current_time > $end_time1 && $current_time <= $end_time2) {
+            $startTime = date('Y-m-d') . ' 20:30:00';
+
+        } elseif ($current_time > $end_time1 && $current_time <= $start_time3) {
+            $startTime = date('Y-m-d', strtotime('+1 day')) . ' 08:30:00';
+        }elseif ($current_time > $start_time4 && $current_time <= $start_time3){
+            $startTime = date('Y-m-d') . ' 20:30:00';
         }
         $where = [
             '工单编号' => $param['workOrder'],