Преглед изворни кода

工序调整,设备跟踪左侧菜单

qiuenguang пре 1 година
родитељ
комит
fe6c2f8198
2 измењених фајлова са 70 додато и 20 уклоњено
  1. 34 18
      application/api/controller/Facility.php
  2. 36 2
      application/api/controller/WorkOrder.php

+ 34 - 18
application/api/controller/Facility.php

@@ -31,25 +31,35 @@ class Facility extends Api
             $this->error('请求错误');
         }
         $data = [];
-        $department = \db('设备_基本资料')->distinct(true)->column('使用部门');
-        $date = date('Y-m-d H:i:s',time()-3888000);
+        $date = date('Y-m-d 00:00:00',time()-3888000);
+        $department = \db('设备_基本资料')
+            ->distinct(true)
+            ->where('使用部门','<>','研发中心')
+            ->where('设备编组','<>','')
+            ->order('设备编组')
+            ->column('rtrim(使用部门) as 使用部门');
         if (empty($department)){
-            $this->success('未获取到机台数据');
+            $this->success('为获取到机台数据');
+        }
+        $list = \db('设备_产量计酬')
+            ->field([
+                'DISTINCT(sczl_rq)' => '时间',
+                'rtrim(sczl_jtbh)' => '机台编号'
+            ])
+            ->where('sczl_rq','>',$date)
+            ->cache(true,86400)
+            ->order('sczl_rq desc')
+            ->select();
+        if (empty($list)){
+            $this->success('未找到机台生产记录');
         }
         foreach ($department as $value){
-            if (rtrim($value) !== '研发中心'){
-                $machine = \db('设备_基本资料')->where('使用部门',$value)->field('rtrim(设备编号) as 设备编号,rtrim(设备名称) as 设备名称')->select();
-                foreach ($machine as $kk=>$vv){
-                    if ($vv['设备编号'] !== 'ZH01#'){
-                        $date = \db('设备_产量计酬')
-                            ->where('sczl_jtbh',$vv['设备编号'])
-//                            ->where('sczl_rq','> time',$date)
-                            ->distinct(true)
-                            ->cache(true)
-                            ->limit(40)
-                            ->order('UniqId desc')
-                            ->column('sczl_rq');
-                        $data[rtrim($value)][$vv['设备编号'].'【'.$vv['设备名称'].'】'] = $date;
+            $machine = \db('设备_基本资料')->where('使用部门',$value)->where('使用部门',$value)->field('rtrim(设备编号) as 设备编号,rtrim(设备名称) as 设备名称')->cache(true)->select();
+            foreach ($machine as $k=>$v){
+                $data[rtrim($value)][$k]['机台'] = $v['设备编号'].'-->'.$v['设备名称'];
+                foreach ($list as $kk=>$vv){
+                    if ($v['设备编号'] === $vv['机台编号']){
+                        array_push($data[rtrim($value)][$k],date('Y-m-d',strtotime($vv['时间'])));
                     }
                 }
             }
@@ -1051,8 +1061,14 @@ class Facility extends Api
         $this->success('成功',$list);
     }
 
-    //机台当前参数展示
-
+    /**
+     * 机台当前参数展示
+     * @ApiMethod (GET)
+     * @return void
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @throws \think\exception\DbException
+     */
     public function MachineDetail()
     {
         if ($this->request->isGet() === false){

+ 36 - 2
application/api/controller/WorkOrder.php

@@ -629,8 +629,42 @@ class WorkOrder extends Api
         if (empty($param)){
             $this->error('参数错误');
         }
-
-
+        $UniqId = [];
+        $lastId = \db('工单_工艺资料')->field('rtrim(UniqId) as id')->order('UniqId desc')->find();
+        if ($lastId['id']>10000000){
+            $lastUniqId = $lastId['id'];
+        }else{
+            $lastUniqId = 10000000;
+        }
+        foreach ($param as $key=>$value){
+            $UniqId[$key] = $value['UniqId'];
+        }
+        $processList = \db('工单_工艺资料')->where('UniqId','in',$UniqId)->select();
+        if (empty($processList)){
+            $this->success('未找到工艺资料');
+        }
+        $data = [];
+        foreach ($param as $key=>$value){
+            foreach ($processList as $k=>$v){
+                if ($value['UniqId'] = $v['UniqId']){
+                    $data[$key] = $v;
+                    $data[$key]['Gy0_gxh'] = $value['gxh'];
+                    $data[$key]['Gy0_gdbh'] = $value['workOrder'];
+                    $data[$key]['UniqId'] = $lastUniqId + $key + 1;
+                }
+            }
+        }
+        $res = \db('工单_工艺资料')->where(['Gy0_gdbh'=>$param[0]['workOrder']])->delete();
+        if ($res !== false){
+            $result = \db('工单_工艺资料')->insertAll($data);
+            if ($result !== false){
+                $this->success('成功');
+            }else{
+                $this->error('失败');
+            }
+        }else{
+            $this->error('失败');
+        }
     }
 
     /**