Преглед на файлове

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

曹鹤洋 преди 1 година
родител
ревизия
10b42e8f41
променени са 2 файла, в които са добавени 109 реда и са изтрити 43 реда
  1. 72 36
      application/api/controller/Facility.php
  2. 37 7
      application/api/controller/WorkOrder.php

+ 72 - 36
application/api/controller/Facility.php

@@ -222,6 +222,7 @@ class Facility extends Api
         $data = \db('设备_产量采集')->where('设备编号',$machine)->order('UniqId desc')->find();
         $endTime = \db('工单_工艺资料')
             ->where('Gy0_gdbh',$data['工单编号'])
+            ->where('Gy0_gxh',$data['工序号'])
             ->where('Gy0_sbbh','like','%'.$machine.'%')
             ->find();
         $list = [];
@@ -1556,44 +1557,79 @@ class Facility extends Api
         }
     }
 
-    //首页数据
-
+    /**
+     * 首页数据
+     * @return void
+     * @throws \think\Exception
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @throws \think\exception\DbException
+     */
     public function index()
     {
-        $data = [
-            'workOrderData' => [
-                '计划中' => 100,
-                '排程中' => 100,
-                '制程中' => 100,
-                '已完工' => 100,
-            ],
-            'MonthlyData' => [
-                '1' => 100,
-                '2' => 100,
-                '3' => 100,
-                '4' => 100,
-                '5' => 100,
-                '6' => 100,
-                '7' => 100,
-                '8' => 100,
-                '9' => 100,
-                '10' => 100,
-                '11' => 100,
-                '12' => 100,
-            ],
-            'customer' => [
-                '0' => ['包装用牛皮纸松,无法上高速机,烟厂手动加纸','2024-02-26'],
-                '1' => ['包装用牛皮纸松,无法上高速机,烟厂手动加纸','2024-02-26'],
-                '2' => ['包装用牛皮纸松,无法上高速机,烟厂手动加纸','2024-02-26'],
-                '3' => ['包装用牛皮纸松,无法上高速机,烟厂手动加纸','2024-02-26'],
-                '4' => ['包装用牛皮纸松,无法上高速机,烟厂手动加纸','2024-02-26'],
-                '5' => ['包装用牛皮纸松,无法上高速机,烟厂手动加纸','2024-02-26'],
-                '6' => ['包装用牛皮纸松,无法上高速机,烟厂手动加纸','2024-02-26'],
-                '7' => ['包装用牛皮纸松,无法上高速机,烟厂手动加纸','2024-02-26'],
-                '8' => ['包装用牛皮纸松,无法上高速机,烟厂手动加纸','2024-02-26'],
-                '9' => ['包装用牛皮纸松,无法上高速机,烟厂手动加纸','2024-02-26'],
-            ],
+        if ($this->request->isGet() === false){
+            $this->error('请求错误');
+        }
+        $nowTime = date('Y-m-d H:i:s',time());
+        $oldTime = (date('Y')-1).'-'.date('m-d H:i:s');
+        $where =[
+            'Mod_rq' => ['between',[$oldTime,$nowTime]],
+            '行号' => '1'
         ];
-        return json($data);
+        $data = [];
+        //按状态查询工单信息
+        $orderList = \db('工单_基本资料')
+            ->where($where)
+            ->field('count(Gd_gdbh) as 数量,rtrim(gd_statu) as 状态')
+            ->group('gd_statu')
+            ->select();
+        foreach ($orderList as $value){
+            if ($value['状态'] === '1-已完工'){
+                $data['workOrderData']['已完工'] = $value['数量'];
+            }
+            if ($value['状态'] === '3-计划中'){
+                $data['workOrderData']['计划中'] = $value['数量'];
+            }
+        }
+        $data['workOrderData']['排程中'] = db('工单_基本资料')->alias('a')
+            ->join('工单_工艺资料 b', 'a.Gd_gdbh = b.Gy0_gdbh')
+            ->join('产品_基本资料 c', 'a.Gd_cpdh = c.产品编号')
+            ->where([
+                'a.gd_statu' => '2-生产中',
+                'a.行号' => '1',
+                'a.Mod_rq' => ['between',[$oldTime,$nowTime]],
+                'b.PD_WG' => '1900-01-01 00:00:00',
+                'b.Gy0_sj1' => '1900-01-01 00:00:00',
+                'c.状态' => '',
+            ])
+            ->group('a.Gd_gdbh')
+            ->count();
+        $data['workOrderData']['制程中'] = db('工单_基本资料')->alias('a')
+            ->join('工单_工艺资料 b', 'a.Gd_gdbh = b.Gy0_gdbh')
+            ->join('产品_基本资料 c', 'a.Gd_cpdh = c.产品编号')
+            ->where([
+                'a.gd_statu' => '2-生产中',
+                'a.行号' => '1',
+                'a.Mod_rq' => ['between',[$oldTime,$nowTime]],
+                'b.PD_WG' => '1900-01-01 00:00:00',
+                'b.Gy0_sj1' => ['<>', '1900-01-01 00:00:00'],
+                'c.状态' => '',
+            ])
+            ->group('a.Gd_gdbh')
+            ->count();
+        //按月份查询工单信息
+        $data['monthData'] = \db('工单_基本资料')
+            ->where('Mod_rq', 'between', [$oldTime, $nowTime])
+            ->field('DATE_FORMAT(Mod_rq, "%Y-%m") as month, COUNT(*) as count')
+            ->group('month')
+            ->order('month')
+            ->select();
+        //查询最近十条客诉信息
+        $data['customer'] = \db('db_客诉记录')
+            ->field('rtrim(客诉描述) as 客诉描述,DATE_FORMAT(客诉日期, "%Y-%m-%d") as 日期,rtrim(UniqID) as UniqId')
+            ->limit(10)
+            ->order('Sys_rq desc')
+            ->select();
+        $this->success('成功',$data);
     }
 }

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

@@ -187,7 +187,6 @@ class WorkOrder extends Api
         //印件资料
         $printList = \db('工单_印件资料')
             ->where('Yj_Gdbh',$Gd_gdbh)
-//            ->cache(true,84600)
             ->select();
         if (!empty($printList)){
             foreach ($printList as $key=>$value){
@@ -228,7 +227,7 @@ class WorkOrder extends Api
         //工艺资料
         $processList = \db('工单_工艺资料')
             ->where('Gy0_gdbh',$Gd_gdbh)
-//            ->cache(true,84600)
+            ->order('Gy0_yjno,Gy0_gxh')
             ->select();
         if (!empty($processList)){
             foreach ($processList as $key=>$value){
@@ -342,12 +341,16 @@ class WorkOrder extends Api
             ->cache(true,84600)
             ->find();
         if (empty($printData)){
-            $this->error('未找到该工单印件资料');
+            $list['印件名称'] = '';
+            $list['印件代号'] = '';
+            $list['平张投料'] = '';
+            $list['印件ID'] = '';
+        }else{
+            $list['印件名称'] = $printData['印件名称'];
+            $list['印件代号'] = $printData['印件代号'];
+            $list['平张投料'] = $printData['平张投料'];
+            $list['印件ID'] = $printData['id'];
         }
-        $list['印件名称'] = $printData['印件名称'];
-        $list['印件代号'] = $printData['印件代号'];
-        $list['平张投料'] = $printData['平张投料'];
-        $list['印件ID'] = $printData['id'];
         $this->success('成功',$list);
     }
 
@@ -1648,4 +1651,31 @@ class WorkOrder extends Api
             $this->error('删除失败');
         }
     }
+
+    /**
+     * 工艺资料添加->工序损耗代码
+     * @return void
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @throws \think\exception\DbException
+     */
+    public function WastageList()
+    {
+        if ($this->request->isGet() === false){
+            $this->error('请求错误');
+        }
+        $param = $this->request->param();
+        if (isset($param['search']) === false){
+            $this->error('参数错误');
+        }
+        $order = \db('dic_lzsh')
+            ->where('sys_mc','like',substr($param['search'],0,6).'%')
+            ->value('rtrim(sys_bh) as 编号');
+        $list = \db('dic_lzsh')
+            ->where('sys_bh','like',$order.'%')
+            ->where('sys_bh','<>',$order)
+            ->field('rtrim(sys_bh) as 编号,rtrim(sys_mc) as 名称,rtrim(UniqId) as UniqId')
+            ->select();
+        $this->success('成功',$list);
+    }
 }