ソースを参照

设置机台班组信息

qiuenguang 1 年間 前
コミット
12fe062917
1 ファイル変更69 行追加0 行削除
  1. 69 0
      application/api/controller/Facility.php

+ 69 - 0
application/api/controller/Facility.php

@@ -250,6 +250,7 @@ class Facility extends Api
             $list['产品名称'] = '';
             $list['工序名称'] = '';
         }
+        $list['状态'] = rtrim($data['当前状态']);
         $list['班组编号'] = rtrim($data['班组编号']);
         $class = \db('设备_班组资料')->where('UniqId',$data['班组ID'])->field("rtrim(sczl_bh1) as bh1,rtrim(sczl_bh2) as bh2,rtrim(sczl_bh3) as bh3,rtrim(sczl_bh4) as bh4,
         rtrim(sczl_bh5) as bh5,rtrim(sczl_bh6) as bh6,rtrim(sczl_bh7) as bh7,rtrim(sczl_bh8) as bh8,rtrim(sczl_bh9) as bh9,
@@ -1481,4 +1482,72 @@ class Facility extends Api
          }
          $this->success('成功',$list);
      }
+
+    /**
+     * 设置机台班组信息
+     * @return void
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @throws \think\exception\DbException
+     */
+
+    public function setMachineTeam()
+    {
+        if (Request::instance()->isPost() == false) {
+            $this->error('非法请求');
+        }
+        $params = Request::instance()->post();
+        if (!isset($params['machine']) || empty($params['machine'])) {
+            $this->error('参数不能为空');
+        }
+        $machine = $params['machine'] . '#';
+        $data = [];
+        $lastData = \db('设备_产量采集')
+            ->order('UniqId desc')
+            ->find();
+        if ($lastData['UniqId'] < 160000000) {
+            $id = 160000000;
+        } else {
+            $id = $lastData['UniqId'] + 1;
+        }
+        $data['当前状态'] = $params['status'];
+        $data['时间'] = date('Y-m-d H:i:s');
+        $data['设备编号'] = $machine;
+        $data['工单编号'] = $params['order'];
+        $data['印件号'] = $params['yjno'];
+        $data['工序号'] = (int)substr($params['gy_name'], 0, 2);
+        $data['工序名称'] = $params['gy_name'];
+        $data['当班产量'] = $params['production_now'];
+        $data['累计产量'] = $params['production_all'];
+        $data['班组编号'] = $params['sczl_bzdh'];
+        $data['班组ID'] = $params['team_id'];
+        // 获取当前时间
+        $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');
+        // 判断当前时间属于哪个时间范围
+        if ($current_time >= $start_time1 && $current_time <= $end_time1) {
+            $data['开工时间'] = date('Y-m-d') . ' 08:30:00';
+        } elseif ($current_time > $end_time1 && $current_time <= $end_time2) {
+            $data['开工时间'] = date('Y-m-d') . ' 20:30:00';
+
+        } elseif ($current_time > $end_time1 && $current_time <= $start_time3) {
+            $data['开工时间'] = date('Y-m-d', strtotime('+1 day')) . ' 08:30:00';
+        }
+        $option['Gy0_gdbh'] = $params['order'];
+        $option['Gy0_yjno'] = $params['yjno'];
+        $option['Gy0_gxh'] = $data['工序号'];
+        $data['任务ID'] = \db('工单_工艺资料')->where($option)->value('UniqId');
+        $data['UniqId'] = $id;
+        $sql = \db('设备_产量采集')->fetchSql(true)->insert($data);
+        $res = Db::query($sql);
+        if ($res === false) {
+            $this->error('设置失败');
+        } else {
+            $this->success('设置成功');
+        }
+    }
 }