Forráskód Böngészése

Merge branch 'master' of https://git.7in6.com/Minong/mes-server-api

曹鹤洋 1 éve
szülő
commit
eaa6d4a15d

+ 8 - 7
application/api/controller/Manufacture.php

@@ -407,7 +407,7 @@ class Manufacture extends Api
         }
         $where = [
             'Gy0_gdbh' => $data['workOrder'],
-            'Gy0_sbbh' => $data['machine'],
+            'Gy0_sbbh' => ['like','%'.$data['machine'].'%'],
             'Gy0_yjno' => $data['printCode'],
             'Gy0_gxh'  => $data['processCode']
         ];
@@ -469,16 +469,17 @@ class Manufacture extends Api
         }
         $where = [
             'Gy0_gdbh' => $data['workOrder'],
-            'Gy0_sbbh' => $data['machine'],
+            'Gy0_sbbh' => ['like','%'.$data['machine'].'%'],
             'Gy0_yjno' => $data['printCode'],
             'Gy0_gxh'  => $data['processCode']
         ];
-        $machine = $where['Gy0_sbbh'];
-        $endTime = \db('工单_工艺资料')->where($where)->field('rtrim(Gy0_sj2) as sj2')->find()['sj2'];
+        $machine = $data['machine'];
+        $endTime = \db('工单_工艺资料')->where($where)->field('rtrim(Gy0_sj2) as sj2,rtrim(PD_WG) as wg')->find();
         if (empty($endTime)){
             $this->success('未找到该工序');
         }
-        if ($endTime <= '1900-01-01 00:00:00' || $endTime >= '2099-01-01 00:00:00'){
+        $time = $endTime['sj2'];
+        if ($endTime['sj2'] == '1900-01-01 00:00:00' || $endTime['wg'] != '1900-01-01 00:00:00'){
             $this->error('该工单不是制程中工单');
         }
         $sql = \db('工单_工艺资料')
@@ -493,9 +494,9 @@ class Manufacture extends Api
             $this->success('未找到该工序');
         }
         $number = -(int)round($row['计划接货数']/$row['小时产能'])+(int)$row['辅助工时'];
-        $res = Db::query($sql);
-        $rechSql = "UPDATE `工单_工艺资料` SET Gy0_sj1 = DATE_ADD(Gy0_sj1, INTERVAL {$number} HOUR),Gy0_sj2 = DATE_ADD(Gy0_sj2, INTERVAL {$number} HOUR) WHERE Gy0_sbbh = '{$machine}' AND Gy0_sj1 >= '{$endTime}' AND Gy0_sj1 < '2099-01-01 00:00:00'";
+        $rechSql = "UPDATE `工单_工艺资料` SET Gy0_sj1 = DATE_ADD(Gy0_sj1, INTERVAL {$number} HOUR),Gy0_sj2 = DATE_ADD(Gy0_sj2, INTERVAL {$number} HOUR) WHERE Gy0_sbbh LIKE '%{$machine}%' AND Gy0_sj1 >= '{$time}' AND Gy0_sj1 < '2099-01-01 00:00:00'";
         $rechres = Db::query($rechSql);
+        $res = Db::query($sql);
         if ($res !== false && $rechres !== false){
             $this->success('成功');
         }else{

+ 29 - 1
application/api/controller/WorkOrder.php

@@ -113,7 +113,7 @@ class WorkOrder extends Api
         $total = \db('工单_基本资料')->where($where)->count();
         $list = \db('工单_基本资料')
             ->where($where)
-            ->order('接单日期 desc')
+            ->order('Gd_statu desc')
             ->limit(($page-1)*$limit,$limit)
             ->select();
         //工单基本资料数据整理
@@ -965,6 +965,7 @@ class WorkOrder extends Api
             'Gy0_shdh' => isset($param['shdh'])?$param['shdh']:'',
             '损耗系数' => isset($param['shxs'])?$param['shxs']:'',
             '工价系数' => isset($param['ndxs'])?$param['ndxs']:'',
+            'Gy0_小时产能' => $param['xscn'],
             'Mod_rq' => date('Y-m-d H:i:s',time()),
         ];
         $sql = \db('工单_工艺资料')->where('UniqId',$param['UniqId'])->fetchSql(true)->update($data);
@@ -1175,4 +1176,31 @@ class WorkOrder extends Api
         }
         return $list;
     }
+
+    /**
+     * 获取小时产能
+     * @ApiMethod  (GET)
+     * @param  void
+     * @return void
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @throws \think\exception\DbException
+     */
+
+    public function capacityList()
+    {
+        if ($this->request->isGet() === false){
+            $this->error('请求错误');
+        }
+        $param = $this->request->param();
+        if (empty($param)){
+            $this->error('参数错误');
+        }
+        $machine = explode(' ',$param['machine'])[0];
+        $number = \db('设备_基本资料')->where('设备编号',$machine)->field('rtrim(排单小时定额) as 小时产能')->find();
+        if (empty($number)){
+            $this->error('未找到小时产能');
+        }
+        $this->success('成功',$number['小时产能']);
+    }
 }