Kaynağa Gözat

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

曹鹤洋 1 yıl önce
ebeveyn
işleme
8eba576b35

+ 20 - 3
application/api/controller/Manufacture.php

@@ -411,11 +411,21 @@ class Manufacture extends Api
             'Gy0_yjno' => $data['printCode'],
             'Gy0_gxh'  => $data['processCode']
         ];
+        $result = \db('工单_工艺资料')->where($where)->field('rtrim(Gy0_sj1) as sj1')->find();
+        if ($result['sj1'] != '1900-01-01 00:00:00'){
+            $this->error('该工单已经是制程中');
+        }
         $lastTime = \db('工单_工艺资料')
             ->where(['Gy0_sbbh'=>$where['Gy0_sbbh'],'Gy0_sj2'=>['<>','1900-01-01 00:00:00'],'Gy0_sj2'=>['<','2099-01-01 00:00:00']])
             ->field('rtrim(Gy0_sj2) as sj2')
             ->order('Gy0_sj2 desc')
             ->find();
+        $date = date('Y-m-d H:i:s',time());
+        if ($lastTime['sj2'] < $date){
+            $newTime = $date;
+        }else{
+            $newTime = $lastTime['sj2'];
+        }
         $row = \db('工单_工艺资料')
             ->where($where)
             ->field('rtrim(Gy0_计划接货数) as 计划接货数,rtrim(Gy0_小时产能) as 小时产能,rtrim(Gy0_辅助工时) as 辅助工时')
@@ -423,11 +433,11 @@ class Manufacture extends Api
         if (empty($row)){
             $this->success('未找到该工单工艺资料');
         }
-        $endTime = date('Y-m-d H:i:s',strtotime($lastTime['sj2']) + ((int)round($row['计划接货数']/$row['小时产能'])+(int)$row['辅助工时'])*3600);
+        $endTime = date('Y-m-d H:i:s',strtotime($newTime) + ((int)round($row['计划接货数']/$row['小时产能'])+(int)$row['辅助工时'])*3600);
         $sql = \db('工单_工艺资料')
             ->where($where)
             ->fetchSql(true)
-            ->update(['Gy0_sj1'=>$lastTime['sj2'],'Gy0_sj2'=>$endTime,'Mod_rq'=>date('Y-m-d H:i:s',time())]);
+            ->update(['Gy0_sj1'=>$newTime,'Gy0_sj2'=>$endTime,'Mod_rq'=>date('Y-m-d H:i:s',time())]);
         $res = Db::query($sql);
         if ($res !== false){
             $this->success('成功');
@@ -738,6 +748,13 @@ class Manufacture extends Api
         if (empty($param)){
             $this->error('参数错误');
         }
+        $where = '';
+        if (isset($param['search'])){
+            $where = "
+                        a.Gd_gdbh LIKE '%{$param['search']}%' 
+                        OR a.`成品名称` LIKE '%{$param['search']}%' 
+                    ";
+        }
         $list = \db('工单_基本资料')
             ->alias('a')
             ->field([
@@ -780,8 +797,8 @@ class Manufacture extends Api
                 'b.Gy0_sbbh' => ['LIKE','%'.$param['machine'].'%'],
                 'b.PD_WG' => '1900-01-01 00:00:00'
             ])
+            ->where($where)
             ->group('a.Gd_gdbh')
-            ->cache(true,720)
             ->select();
         if (empty($list)){
             $this->success('',[]);

+ 2 - 2
application/api/controller/Product.php

@@ -35,10 +35,10 @@ class Product extends Api
         }
         $params = Request::instance()->param();
         $limit = $params['limit'];
-        if (!isset($limit) == false){
+        if (!isset($limit)){
             $limit = 15;
         }
-        if (!isset($pages) == false){
+        if (!isset($pages)){
             $pages = 0;
         }else{
             $pages = ($params['page']-1) * $limit;

+ 12 - 12
application/api/controller/ReportingWork.php

@@ -389,18 +389,18 @@ class ReportingWork extends Api
             $newData[$key]['sys_rq'] = $data['sys_rq'];
             $newData[$key]['UniqID'] = $batchUniqId;
         }
-        $res = true;
-        $batch_res = true;
-        Db::startTrans();
-        try {
-            $sql = \db('设备_产量计酬')->fetchSql(true)->insert($data);
-            $res = Db::query($sql);
-            $batch_sql = \db('物料_批次跟踪')->fetchSql(true)->insertAll($newData);
-            $batch_res = Db::query($batch_sql);
-            Db::commit();
-        }catch (\Exception $e){
-            Db::rollback();
-        }
+        $sql = \db('设备_产量计酬')->fetchSql(true)->insert($data);
+        $res = Db::query($sql);
+        $batch_sql = \db('物料_批次跟踪')->fetchSql(true)->insertAll($newData);
+        $batch_res = Db::query($batch_sql);
+//        $res = true;
+//        $batch_res = true;
+//        Db::startTrans();
+//        try {
+//            Db::commit();
+//        }catch (\Exception $e){
+//            Db::rollback();
+//        }
         if ($res === false || $batch_res === false){
             $this->error('报工失败');
         }else{

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

@@ -229,6 +229,11 @@ class WorkOrder extends Api
                 }else{
                     $number = 0;
                 }
+                if ($value['PD_WG'] !== '1900-01-01 00:00:00'){
+                    $status = '已完工';
+                }else{
+                    $status = '未完工';
+                }
                 $data['processList'][$key] = [
                     '重点工序' => rtrim($value['重点工序']),
                     '印件-工序' => rtrim($value['Gy0_yjno']).'-'.rtrim($value['Gy0_gxh']),
@@ -261,7 +266,8 @@ class WorkOrder extends Api
                     'UniqId' => rtrim($value['UniqId']),
                     'shdh' => rtrim($value['Gy0_shdh']),
                     '辅助工时' => rtrim($value['Gy0_辅助工时']),
-                    '小时产能' => rtrim($value['Gy0_小时产能'])
+                    '小时产能' => rtrim($value['Gy0_小时产能']),
+                    'status' => $status
                 ];
             }
         }else{