Ver código fonte

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

曹鹤洋 1 ano atrás
pai
commit
4c05896366

+ 129 - 0
application/api/controller/Course.php

@@ -0,0 +1,129 @@
+<?php
+
+namespace app\api\controller;
+
+
+use app\common\controller\Api;
+use think\Db;
+use think\Request;
+use function fast\e;
+
+/**
+ * 生产进程管理
+ */
+
+class Course extends Api
+{
+    protected $noNeedLogin = ['*'];
+    protected $noNeedRight = ['*'];
+
+    /**
+     * 左侧菜单
+     * @return void
+     * @throws \think\Exception
+     * @throws \think\db\exception\BindParamException
+     * @throws \think\exception\PDOException
+     */
+    public function getTab()
+    {
+        if ($this->request->isGet() === false){
+            $this->error('请求错误');
+        }
+        //获取总计划中数量和总生产中数量
+        $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 = [
+            '印刷工单' => [],
+            '糊盒工单' => []
+        ];
+        $sql = "SELECT DISTINCT
+                    (客户编号),rtrim(客户名称 ) as 客户名称
+                FROM
+                    `产品_基本资料` 
+                WHERE 
+                    客户编号 <> ''
+                GROUP BY
+                    客户编号
+                order by 
+                    客户编号";
+        $list = \db()->query($sql);
+        if (empty($list)){
+            $this->success('',[]);
+        }
+        foreach ($list as $key=>$value){
+            $value['客户编号'] = rtrim($value['客户编号']);
+            $productIng = \db('工单_基本资料')->where('行号','1')->where('成品代号','LIKE',rtrim($value['客户编号']).'%')->where('gd_statu','2-生产中')->count();
+            $proGress = \db('工单_基本资料')->where('行号','1')->where('成品代号','LIKE',rtrim($value['客户编号']).'%')->where('gd_statu','3-计划中')->count();
+            $string = '';
+            if ($productIng != 0){
+                $string = $string."生产中:".$productIng;
+            }
+            if ($proGress != 0){
+                $string = $string."计划中:".$proGress;
+            }
+            if ($string !== ''){
+                $name = $value['客户编号'].$value['客户名称'];
+                if (strpos($value['客户编号'],'J') !== false){
+                    array_push($data['糊盒工单'],$name);
+                }else{
+                    array_push($data['印刷工单'],$name);
+                }
+            }
+        }
+        $this->success('成功',$data);
+    }
+
+
+    /**
+     * 右侧工单详情
+     * @return void
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @throws \think\exception\DbException
+     */
+    public function workOrderDetail()
+    {
+        if ($this->request->isGet() === false){
+            $this->error('请求错误');
+        }
+        $param = $this->request->param();
+        $where = [];
+        if (!empty($param['order'])){
+            $where['a.Gd_cpdh|a.成品代号'] = ['like',$param['order'].'%'];
+        }
+        if (!empty($param['search'])){
+            $where['a.Gd_gdbh'] = ['like','%'.$param['search'].'%'];
+        }
+        $list = \db('工单_基本资料')
+            ->alias('a')
+            ->join('工单_印件资料 b','a.Gd_gdbh = b.Yj_Gdbh')
+            ->field('b.Yj_Gdbh as 工单编号,b.yj_Yjno,b.yj_Yjdh as 印件代号,b.yj_yjmc as 印件名称,b.yj_ls as 联数,a.投料大箱 as 投料大箱,b.yj_平张投料 as 计划投料')
+            ->where($where)
+            ->where('gd_statu','2-生产中')
+            ->group('b.Yj_Gdbh,b.yj_Yjno')
+            ->select();
+        if (empty($list)){
+            $this->success('');
+        }
+        foreach ($list as $key=>$value){
+            $process = \db('工单_工艺资料')
+                ->alias('a')
+                ->join('设备_产量计酬 b','a.Gy0_gdbh = b.sczl_gdbh AND a.Gy0_yjno = b.sczl_yjno AND a.Gy0_gxh = b.sczl_gxh','left')
+                ->where('a.Gy0_gdbh',$value['工单编号'])
+                ->where('a.Gy0_yjno',$value['yj_Yjno'])
+                ->field('a.Gy0_gxh,a.Gy0_gxmc,a.PD_WG,SUM(b.sczl_cl) as 产量')
+                ->group('a.Gy0_gxh')
+                ->select();
+            foreach ($process as $k=>$v){
+                $status = '';
+                if ($v['PD_WG'] !== '1900-01-01 00:00:00'){
+                    $status = '完工';
+                }
+                $k++;
+                $list[$key]['工序'.$k] = $value['yj_Yjno'].'-'.$v['Gy0_gxh'].'-'.rtrim($v['Gy0_gxmc']).'['.$v['产量'].'/'.']'.$status;
+            }
+            unset($list[$key]['yj_Yjno']);
+        }
+        $this->success('成功',$list);
+    }
+}

+ 13 - 5
application/api/controller/Decision.php

@@ -60,12 +60,16 @@ class Decision extends Api
             $this->error('请求错误');
         }
         $param = $this->request->param();
-        if (empty($param['mouth']) || empty($param['sist'])){
+        if (empty($param['mouth'])){
             $this->error('参数错误');
         }
+        $where = [];
+        if(!empty($param['sist'])){
+            $where['设备编组'] = $param['sist'];
+        }
         $mouth = date('Y-m',strtotime($param['mouth']));
         $machine = \db('设备_基本资料')
-            ->where('设备编组',$param['sist'])
+            ->where($where)
             ->field('设备编号')
             ->select();
         $day = \db('设备_产量计酬')
@@ -165,9 +169,13 @@ class Decision extends Api
             $this->error('请求错误');
         }
         $param = $this->request->param();
-        if (empty($param['mouth']) || empty($param['sist'])){
+        if (empty($param['mouth'])){
             $this->error('参数错误');
         }
+        $where = [];
+        if(!empty($param['sist'])){
+            $where['设备编组'] = $param['sist'];
+        }
         $mouth = date('Y-m',strtotime($param['mouth']));
         $list = \db('设备_基本资料')
             ->alias('a')
@@ -184,7 +192,7 @@ class Decision extends Api
                 'SUM(b.sczl_装版工时)' => '装板补产工时',
                 'SUM(b.sczl_异常停机工时)' => '异常停机工时'
             ])
-            ->where('a.设备编组',$param['sist'])
+            ->where($where)
             ->whereTime('b.sczl_rq',$mouth)
             ->group('a.设备编号')
             ->order('a.设备编号')
@@ -201,7 +209,7 @@ class Decision extends Api
                 'SUM(b.sczl_装版工时)' => '装板补产工时',
                 'SUM(b.sczl_异常停机工时)' => '异常停机工时'
             ])
-            ->where('a.设备编组',$param['sist'])
+            ->where($where)
             ->whereTime('b.sczl_rq',$mouth)
             ->find();
         $list['total'] = $total;

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

@@ -268,6 +268,7 @@ class Facility extends Api
         }
         $endTime = \db('工单_工艺资料')
             ->where('UniqId',$data['任务ID'])
+//            ->where('Gy0_sj1','>','1900-01-01 00:00:00')
             ->find();
         if (empty($endTime)){
             $this->error('未找到');

+ 6 - 0
application/api/controller/Product.php

@@ -1120,6 +1120,12 @@ class Product extends Api
             ->where('yj_yjno',$param['yjno'])
             ->field('rtrim(yj_ks) as 开数,rtrim(yj_ls) as 联数')
             ->find();
+        $process = \db('产品_工艺资料')
+            ->where('Gy0_cpdh',$param['product'])
+            ->where('Gy0_yjno',$param['yjno'])
+            ->order('Gy0_gxh desc')
+            ->value('Gy0_gxh');
+        $list['工序号'] = $process + 1;
         $this->success('成功',$list);
     }
 }

+ 2 - 1
application/api/controller/StaffSalary.php

@@ -395,6 +395,7 @@ class StaffSalary extends Api
             ->join('工单_基本资料 e5','a.sczl_gdbh5 = e5.Gd_gdbh AND a.sczl_gdbh5 IS NOT NULL','LEFT')
             ->join('工单_基本资料 e6','a.sczl_gdbh6 = e6.Gd_gdbh AND a.sczl_gdbh6 IS NOT NULL','LEFT')
             ->where($where)
+            ->group('a.UniqId')
             ->select();
 //        halt($result);
         foreach ($result as $value){
@@ -416,7 +417,7 @@ class StaffSalary extends Api
                 if (!empty($value[$gdbhKey])){
                     $item['sczl_gdbh'] = $value[$gdbhKey];
                     $item['sczl_yjno'] = ltrim(substr($value[$yjgxKey],0,2), '0');
-                    $item['sczl_gxh'] = substr($value[$yjgxKey],-2);
+                    $item['sczl_gxh'] = abs((int)substr($value[$yjgxKey],-2));
 //                    $item['sczl_type'] = substr($value[$gxmcKey],0,30);
                     $item['sczl_type'] = $value[$gxmcKey];
                     if (!empty($value[$reworkKey])  && $value[$reworkKey] > 0){

+ 20 - 13
application/api/controller/WorkOrder.php

@@ -72,14 +72,15 @@ class WorkOrder extends Api
                 }else{
                     array_push($data['印刷工单'],$name);
                 }
-            }else{
-                $name = $value['客户编号'].$value['客户名称'];
-                if (strpos($value['客户编号'],'J') !== false){
-                    array_push($data['糊盒工单'],$name);
-                }else{
-                    array_push($data['印刷工单'],$name);
-                }
             }
+//            else{
+//                $name = $value['客户编号'].$value['客户名称'];
+//                if (strpos($value['客户编号'],'J') !== false){
+//                    array_push($data['糊盒工单'],$name);
+//                }else{
+//                    array_push($data['印刷工单'],$name);
+//                }
+//            }
         }
         $this->success('成功',$data);
     }
@@ -940,12 +941,12 @@ class WorkOrder extends Api
         }
         $i = 0;
         foreach ($param as $key=>$value){
-            $data = [
-                'rate0' => 0,
-                'rate1' => 0,
-            ];
-            if (!empty($value['loss'])){
-                $data = \db('dic_lzsh')->where('sys_bh',$value['loss'])->field('rtrim(sys_rate0) as rate0,rtrim(sys_rate1) as rate1')->find();
+            $data['rate0'] = 0;
+            $data['rate1'] = 0;
+            $rate = \db('dic_lzsh')->where('sys_bh',$value['loss'])->field('rtrim(sys_rate0) as rate0,rtrim(sys_rate1) as rate1')->find();
+            if (!empty($rate)){
+                $data['rate0'] = $rate['rate0'];
+                $data['rate1'] = $rate['rate1'];
             }
             $row = [
                 '工价系数' => $value['difficulty']?:'',
@@ -2420,6 +2421,12 @@ class WorkOrder extends Api
             ->where('yj_Yjno',$param['yjno'])
             ->field('rtrim(yj_ks) as 开数,rtrim(yj_ls) as 联数')
             ->find();
+        $process = \db('工单_工艺资料')
+            ->where('Gy0_gdbh',$param['gdbh'])
+            ->where('Gy0_yjno',$param['yjno'])
+            ->order('Gy0_gxh desc')
+            ->value('Gy0_gxh');
+        $list['工序号'] = $process + 1;
         $this->success('成功',$list);
     }
 }