Browse Source

日产量上报优化

qiuenguang 1 year ago
parent
commit
e4403e8b45
1 changed files with 21 additions and 13 deletions
  1. 21 13
      application/api/controller/Facility.php

+ 21 - 13
application/api/controller/Facility.php

@@ -270,18 +270,6 @@ class Facility extends Api
             $code = \db('工单_基本资料')->where('Gd_Gdbh',$data['工单编号'])->value('成品代号');
             $list['产品名称'] = rtrim($name);
             $list['产品代号'] = rtrim($code);
-//            $where['Gy0_gdbh'] = $data['工单编号'];
-//            $where['Gy0_yjno'] = $data['印件号'];
-//            $where['Gy0_gxh'] = $data['工序号'];
-//            $gxmc = \db('工单_工艺资料')->where($where)->find();
-//            if ((int)$gxmc['Gy0_gxh']<10){
-//                $gxmc['Gy0_gxh'] = '0'.rtrim($gxmc['Gy0_gxh']);
-//            }
-//            if ($gxmc['Add_gxmc'] !== ''){
-//                $printName = rtrim($gxmc['Gy0_gxh']).'-'.rtrim($gxmc['Gy0_gxmc']).'【'.rtrim($gxmc['Add_gxmc']).'】';
-//            }else{
-//                $printName = rtrim($gxmc['Gy0_gxh']).'-'.rtrim($gxmc['Gy0_gxmc']);
-//            }
             $list['工序名称'] = $data['工序名称'];
         }else{
             $list['工单编号'] = '';
@@ -368,7 +356,7 @@ class Facility extends Api
                 AND a.Gy0_sj1 <> '1900-01-01 00:00:00'
                 AND a.Gy0_sj1 < '2099-01-01 00:00:00' 
             GROUP BY a.Gy0_gdbh,a.Gy0_yjno,a.Gy0_gxh
-            ORDER BY a.Gy0_sj1";
+            ORDER BY a.UniqId desc";
         $orderList = Db::query($sql);
         if (empty($orderList)){
             $this->success('未找到排产工单');
@@ -515,11 +503,18 @@ class Facility extends Api
         if (empty($machine) || empty($workOrder) || empty($team)){
             $this->success('');
         }
+        $newTime = date('Y-m-d H:i:s',time());
+        if ($newTime < date('Y-m-d 08:30:00')) {
+            $sczlTime = date('Y-m-d 00:00:00', time() - 86400);
+        }else{
+            $sczlTime = date('Y-m-d 00:00:00');
+        }
         $name = \db('工单_基本资料')->where('Gd_gdbh',$workOrder)->field('rtrim(Gd_cpmc) as productName')->find();
         $where = [
             'sczl_gdbh' => $workOrder,
             'sczl_jtbh' => $machine,
             'sczl_bzdh' => $team,
+            'sczl_rq' => $sczlTime,
         ];
         $field = 'rtrim(sczl_gdbh) as 工单编号,rtrim(sczl_yjno) as yjno,rtrim(sczl_num) as 流程单号,rtrim(sczl_dedh) as dedh,rtrim(sczl_gxmc) as gxmc,rtrim(sczl_num) as 标牌号,rtrim(sczl_cl) as 产量,
         rtrim(sczl_zcfp) as 制程废品,rtrim(sczl_zccp) as 制程次品,rtrim(sczl_前工序废) as 前工序废,rtrim(sczl_来料少数) as 来料异常,rtrim(sczl_装版工时) as 装版工时,
@@ -2149,6 +2144,18 @@ class Facility extends Api
         if (empty($list)){
             $this->success('未获取工序');
         }
+        $time = \db('设备_产量计酬')
+            ->where('sczl_gdbh',$param['gdbh'])
+            ->where('sczl_yjno',$param['yjno'])
+            ->where('sczl_jtbh','like','%'.$param['machine'].'%')
+            ->order('UniqId desc')
+            ->value('sczl_sj2');
+        $newTime = date('Y-m-d H:i:s');
+        if ($newTime > date('Y-m-d 08:30:00') && $newTime < date('Y-m-d 20:30:00') && $time < date('Y-m-d 08:30:00')){
+            $time = date('Y-m-d 08:30:00');
+        }elseif ($newTime > date('Y-m-d 20:30:00') && $time < date('Y-m-d 20:30:00')){
+            $time = date('Y-m-d 20:30:00');
+        }
         foreach ($list as $key=>$value){
             if ((int)$value['gxh'] < 10){
                 $value['gxh'] = '0'.$value['gxh'];
@@ -2159,6 +2166,7 @@ class Facility extends Api
                 $list[$key]['name'] = $value['gxh'].'-'.$value['gxmc'].'【'.$value['add_gxmc'].'】';
             }
             unset($list[$key]['gxmc'],$list[$key]['add_gxmc']);
+            $list[$key]['time'] = $time;
         }
         $this->success('成功',$list);
     }