qiuenguang 1 gadu atpakaļ
vecāks
revīzija
62b82d49ac

+ 6 - 6
application/api/controller/Facility.php

@@ -73,7 +73,7 @@ class Facility extends Api
         if ($this->request->isGet() === false){
             $this->error('请求错误');
         }
-        $machine = input('machine').'#';
+        $machine = input('machine');
         $date = input('date');
         $where = [
             'sczl_jtbh' => $machine,
@@ -697,7 +697,7 @@ class Facility extends Api
             ->field($filed)
             ->select();
         if (empty($list)){
-            $this->error('未找到该工单当前班次巡检记录');
+            $this->success('',[]);
         }
         foreach ($list as $key=>$value){
             $number = floor((strtotime($value['提交时间'])-strtotime($value['开工时间']))/(15*60));
@@ -783,7 +783,7 @@ class Facility extends Api
             ->distinct(true)
             ->column('部件名称','部件编号');
         if (empty($list)){
-            $this->error('未找到检验项目');
+            $this->success('');
         }
         $this->success('成功',$list);
     }
@@ -811,7 +811,7 @@ class Facility extends Api
             ->field('rtrim(检验项目) as 检验项目,rtrim(判定标准) as 判定标准,rtrim(点检方法) as 点检方法')
             ->select();
         if (empty($list)){
-            $this->error('未找到检测项目');
+            $this->success('未找到检测项目');
         }
         $this->success('成功',$list);
     }
@@ -893,7 +893,7 @@ class Facility extends Api
                 WHERE a.YB_Cpdh = '{$productCode}'";
         $res = Db::query($sql);
         if (empty($res)){
-            $this->error('未找到该产品印版资料');
+            $this->success('');
         }
         $this->success('成功',$res);
     }
@@ -942,7 +942,7 @@ class Facility extends Api
                 ORDER BY a.`存货编码`";
         $list = Db::query($sql);
         if (empty($list)){
-            $this->error('未找到印版');
+            $this->success('');
         }
         $this->success('成功',$list);
     }

+ 27 - 21
application/api/controller/Manufacture.php

@@ -49,14 +49,14 @@ class Manufacture extends Api
         rtrim(接单日期) as 接单日期,rtrim(交货日期) as 交货日期,rtrim(订单数量) as 订单数量,rtrim(计量单位) as 计量单位,rtrim(Gd_khmc) as 客户名称,
         rtrim(Gd_客户代号) as 客户编号,rtrim(Gd_desc) as 备注,rtrim(客户料号) as 客户料号,rtrim(Sys_id) as 创建用户,rtrim(Sys_rq) as 创建时间,
         rtrim(Mod_rq) as 修改时间,rtrim(Uniqid) as UNIQID,rtrim(投料率) as 投料率,rtrim(销售订单号) as 销售订单号';
-        $list = Db::table('工单_基本资料')->where($where)->field($field)->limit(500)->order('Uniqid desc')->select();
+        $list = \db('工单_基本资料')->where($where)->field($field)->limit(500)->order('Uniqid desc')->select();
         if (empty($list)){
             $this->error('失败');
         }
         foreach ($list as $key=>$value){
             $list[$key]['订单数量'] = rtrim((float)$value['订单数量']);
             $list[$key]['产品名称'] = $value['产品名称'] != '' ? $value['产品名称']:$value['成品名称'];
-            $number = Db::table('工单_工艺资料')->where('Gy0_gdbh',$value['工单编号'])->count();
+            $number = \db('工单_工艺资料')->where('Gy0_gdbh',$value['工单编号'])->count();
             if ($number === 0){
                 $list[$key]['status'] = 0;
             }else{
@@ -91,7 +91,7 @@ class Manufacture extends Api
         $filed = 'rtrim(Gy0_gdbh) as 工单编号,rtrim(重点工序) as 重点工序,Gy0_yjno,Gy0_gxh,Gy0_gxmc,Add_gxmc,rtrim(工序备注) as 工序备注,
         rtrim(Gy0_sbbh) as 机组,rtrim(Gy0_小时产能) as 小时产能,rtrim(Gy0_生产工时) as 生产工时,rtrim(Gy0_辅助工时) as 辅助工时,
         rtrim(印刷方式) as 印刷方式,rtrim(版距) as 版距,rtrim(Sys_id) as 创建用户,rtrim(Sys_rq) as 创建时间,rtrim(Mod_rq) as 修改时间,rtrim(UniqId) as UNIQID';
-        $list = Db::table('工单_工艺资料')->where($where)->field($filed)->select();
+        $list = \db('工单_工艺资料')->where($where)->field($filed)->select();
         if (empty($list)){
             $this->success('',[]);
         }
@@ -138,7 +138,7 @@ class Manufacture extends Api
         rtrim(yj_zzmc) as 纸张名称,rtrim(yj_tlgg) as 投料规格,rtrim(yj_成品数量) as 成品数量,rtrim(yj_实际投料) as 实际投料,
         rtrim(yj_Dw) as  投料单位,rtrim(yj_平张投料) as 平张投料,rtrim(yj_ls) as 联数,rtrim(yj_ks) as 开数,rtrim(Sys_id) as 创建用户,
         rtrim(Sys_rq) as 创建时间,rtrim(Mod_rq) as 修改时间,rtrim(Uniqid) as UNIQID';
-        $list = Db::table('工单_印件资料')->where($where)->field($field)->select();
+        $list = \db('工单_印件资料')->where($where)->field($field)->select();
         if (empty($list)){
             $this->error('失败');
         }
@@ -311,16 +311,16 @@ class Manufacture extends Api
             $this->error('请求错误');
         }
         $data = [];
-        $department = Db::table('设备_基本资料')->distinct(true)->cache(true)->column('使用部门');
+        $department = \db('设备_基本资料')->distinct(true)->cache(true)->column('使用部门');
         if (empty($department)){
             $this->error('为获取到机台数据');
         }
         foreach ($department as $value){
             if (rtrim($value) !== '研发中心'){
-                $benchClass = Db::table('设备_基本资料')->where('使用部门',$value)->distinct(true)->cache(true)->column('设备编组');
+                $benchClass = \db('设备_基本资料')->where('使用部门',$value)->distinct(true)->cache(true)->column('设备编组');
                 foreach ($benchClass as $v){
                     if (rtrim($v) !== ''){
-                        $machine = Db::table('设备_基本资料')->where('使用部门',$value)->where('设备编组',$v)->field('rtrim(设备编号) as 设备编号,rtrim(设备名称) as 设备名称')->cache(true)->select();
+                        $machine = \db('设备_基本资料')->where('使用部门',$value)->where('设备编组',$v)->field('rtrim(设备编号) as 设备编号,rtrim(设备名称) as 设备名称')->cache(true)->select();
                         foreach ($machine as $kk=>$vv){
                             $data[rtrim($value)][rtrim($v)][$kk] = $vv['设备编号'].'-->'.$vv['设备名称'];
                         }
@@ -351,7 +351,7 @@ class Manufacture extends Api
         if (empty($workOrder) || empty($status)){
             $this->error('参数错误');
         }
-        $sql = Db::table('工单_基本资料')->where('Gd_gdbh',$workOrder)->fetchSql(true)->update(['gd_statu'=>$status]);
+        $sql = \db('工单_基本资料')->where('Gd_gdbh',$workOrder)->fetchSql(true)->update(['gd_statu'=>$status]);
         $res = Db::query($sql);
         if ($res !== false){
             $this->success('成功');
@@ -381,7 +381,7 @@ class Manufacture extends Api
             'Gy0_gdbh' => $data['workOrder'],
             'Gy0_gxh'  => $data['processCode']
         ];
-        $sql = Db::table('工单_工艺资料')->where($where)->fetchSql(true)->update(['PD_WG'=>date('Y-m-d H:i:s',time())]);
+        $sql = \db('工单_工艺资料')->where($where)->fetchSql(true)->update(['PD_WG'=>date('Y-m-d H:i:s',time())]);
         $res = Db::query($sql);
         if ($res !== false){
             $this->success('成功');
@@ -417,12 +417,12 @@ class Manufacture extends Api
             'Gy0_yjno' => $data['printCode'],
             'Gy0_gxh'  => $data['processCode']
         ];
-        $lastTime = Db::table('工单_工艺资料')
+        $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();
-        $row = Db::table('工单_工艺资料')
+        $row = \db('工单_工艺资料')
             ->where($where)
             ->field('rtrim(Gy0_计划接货数) as 计划接货数,rtrim(Gy0_小时产能) as 小时产能,rtrim(Gy0_辅助工时) as 辅助工时')
             ->find();
@@ -430,7 +430,7 @@ class Manufacture extends Api
             $this->error('未找到该工单工艺资料');
         }
         $endTime = date('Y-m-d H:i:s',strtotime($lastTime['sj2']) + ((int)round($row['计划接货数']/$row['小时产能'])+(int)$row['辅助工时'])*3600);
-        $sql = Db::table('工单_工艺资料')
+        $sql = \db('工单_工艺资料')
             ->where($where)
             ->fetchSql(true)
             ->update(['Gy0_sj1'=>$lastTime['sj2'],'Gy0_sj2'=>$endTime,'Mod_rq'=>date('Y-m-d H:i:s',time())]);
@@ -470,18 +470,18 @@ class Manufacture extends Api
             'Gy0_gxh'  => $data['processCode']
         ];
         $machine = $where['Gy0_sbbh'];
-        $endTime = Db::table('工单_工艺资料')->where($where)->field('rtrim(Gy0_sj2) as sj2')->find()['sj2'];
+        $endTime = \db('工单_工艺资料')->where($where)->field('rtrim(Gy0_sj2) as sj2')->find()['sj2'];
         if (empty($endTime)){
             $this->error('未找到该工序');
         }
         if ($endTime <= '1900-01-01 00:00:00' || $endTime >= '2099-01-01 00:00:00'){
             $this->error('该工单不是制程中工单');
         }
-        $sql = Db::table('工单_工艺资料')
+        $sql = \db('工单_工艺资料')
             ->where($where)
             ->fetchSql(true)
             ->update(['Gy0_sj1'=>'1900-01-01 00:00:00','Gy0_sj2'=>'1900-01-01 00:00:00','Mod_rq'=>date('Y-m-d H:i:s')]);
-        $row = Db::table('工单_工艺资料')
+        $row = \db('工单_工艺资料')
             ->where($where)
             ->field('rtrim(Gy0_计划接货数) as 计划接货数,rtrim(Gy0_小时产能) as 小时产能,rtrim(Gy0_辅助工时) as 辅助工时')
             ->find();
@@ -523,7 +523,7 @@ class Manufacture extends Api
         ];
         $workOrder = $where['Gy0_gdbh'];
         $field = 'rtrim(Gy0_yjno) as yjno,rtrim(Gy0_gxh) as gxh,rtrim(Gy0_gxmc) as gxmc,rtrim(Gy0_sbbh) as 设备代号,rtrim(Gy0_计划接货数) as 计划接货数,rtrim(Gy0_ls) as ls,rtrim(PD_WG) as 完工时间,rtrim(UniqId) as UniqId';
-        $list = Db::table('工单_工艺资料')->where($where)->field($field)->order('Gy0_gxh')->select();
+        $list = \db('工单_工艺资料')->where($where)->field($field)->order('Gy0_gxh')->select();
         if (empty($list)){
             $this->error('未找到该工单工艺资料');
         }
@@ -579,7 +579,7 @@ class Manufacture extends Api
             }else{
                 $endTime = $value['PD_WG'];
             }
-            $sql = Db::table('工单_工艺资料')
+            $sql = \db('工单_工艺资料')
                 ->where('UniqId',$value['UniqId'])
                 ->fetchSql(true)
                 ->update(['PD_WG'=>$endTime]);
@@ -609,7 +609,7 @@ class Manufacture extends Api
         if ($this->request->isGet() === false){
             $this->error('请求错误');
         }
-        $list = Db::table('工单_排程班次')->field('rtrim(bcdh) as 班次代号,rtrim(desc_) as desc_,rtrim(stdtime) as stdtime')->select();
+        $list = \db('工单_排程班次')->field('rtrim(bcdh) as 班次代号,rtrim(desc_) as desc_,rtrim(stdtime) as stdtime')->select();
         if (empty($list)){
             $this->error('未找到班次数据');
         }
@@ -652,7 +652,7 @@ class Manufacture extends Api
         rtrim(Gy0_生产工时) as 生产工时,rtrim(Gy0_辅助工时) as 辅助工时,rtrim(Gy0_班次安排) as 班次安排,rtrim(工序备注) as 排单备注,
         rtrim(Gy0_最早开工时间) as 最早开工时间,rtrim(Gy0_sj1) as 计划开工时间,rtrim(Gy0_sj2) as 计划完工时间,rtrim(Gy0_yjno) as yjno,
         rtrim(Gy0_gxh) as gxh,rtrim(Gy0_gxmc) as gxmc,rtrim(Gy0_ls) as ls,rtrim(UniqId) as UniqId';
-        $list = Db::table('工单_工艺资料')->where($where)->field($filed)->cache(true)->select();
+        $list = \db('工单_工艺资料')->where($where)->field($filed)->cache(true)->select();
         if (empty($list)){
             $this->error('未找到该机台制程中产品');
         }
@@ -711,7 +711,7 @@ class Manufacture extends Api
                 'Gy0_sj1' => date('Y-m-d H:i:s',strtotime($value['projectTime'])),
                 'Gy0_sj2' => date('Y-m-d HY-m-d',strtotime(($value['projectTime'])+(ceil($value['ProductionHours'])+ceil($value['AuxiliaryHours']))*3600)),
             ];
-            $sql = Db::table('工单_工艺资料')
+            $sql = \db('工单_工艺资料')
                 ->where('UniqId',$value['UniqId'])
                 ->fetchSql(true)
                 ->update($data);
@@ -727,8 +727,14 @@ class Manufacture extends Api
         }
     }
 
-    //机台显示工单
 
+    /**
+     * 机台工单展示
+     * @ApiMethod ()
+     * @return void
+     * @throws \think\db\exception\BindParamException
+     * @throws \think\exception\PDOException
+     */
     public function MachineWorkOrderList()
     {
         if ($this->request->isGet() === false){

+ 6 - 4
application/api/controller/WorkOrder.php

@@ -29,8 +29,8 @@ class WorkOrder extends Api
             $this->error('请求错误');
         }
         //获取总计划中数量和总生产中数量
-        $productingAll = \db('工单_基本资料')->where('成品代号','<>','')->where('gd_statu','2-生产中')->cache(true)->count();
-        $progressAll = \db('工单_基本资料')->where('成品代号','<>','')->where('gd_statu','3-计划中')->cache(true)->count();
+        $productingAll = \db('工单_基本资料')->where('成品代号','<>','')->where('行号','1')->where('gd_statu','2-生产中')->cache(true)->count();
+        $progressAll = \db('工单_基本资料')->where('成品代号','<>','')->where('行号','1')->where('gd_statu','3-计划中')->cache(true)->count();
         $data = [
             'productingAll' => $productingAll,
             'progressAll' => $progressAll
@@ -53,8 +53,8 @@ class WorkOrder extends Api
             $this->success('',[]);
         }
         foreach ($list as $key=>$value){
-            $productIng = \db('工单_基本资料')->where('成品代号','LIKE',$value['prefix'].'%')->where('gd_statu','2-生产中')->count();
-            $proGress = \db('工单_基本资料')->where('成品代号','LIKE',$value['prefix'].'%')->where('gd_statu','3-计划中')->count();
+            $productIng = \db('工单_基本资料')->where('行号','1')->where('成品代号','LIKE',$value['prefix'].'%')->where('gd_statu','2-生产中')->count();
+            $proGress = \db('工单_基本资料')->where('行号','1')->where('成品代号','LIKE',$value['prefix'].'%')->where('gd_statu','3-计划中')->count();
             $string = '';
             if ($productIng != 0){
                 $string = $string."生产中:".$productIng;
@@ -64,6 +64,8 @@ class WorkOrder extends Api
             }
             if ($string !== ''){
                 $data[$key] = $value['prefix'].'【'.$string.'】'.($value['客户名称']!==''?$value['客户名称']:$value['khmc']);
+            }else{
+                $data[$key] = $value['prefix'].($value['客户名称']!==''?$value['客户名称']:$value['khmc']);
             }
         }
         $this->success('成功',$data);