فهرست منبع

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

liuhairui 17 ساعت پیش
والد
کامیت
d1b424f0e7
1فایلهای تغییر یافته به همراه106 افزوده شده و 10 حذف شده
  1. 106 10
      application/api/controller/Facility.php

+ 106 - 10
application/api/controller/Facility.php

@@ -1451,17 +1451,17 @@ class Facility extends Api
             ->where('当班产量','<>',-1)
             ->field('rtrim(时间) as 时间,rtrim(当班产量) as 产量,rtrim(当前状态) as 状态')
             ->select();
-        if (empty($row)){
+        $outputList = db('设备_产量计酬')
+            ->where('sczl_jtbh',$param['machine'])
+            ->where('开工时间',$param['start'])
+            ->field('sys_rq,sczl_cl')
+            ->select();
+        if (empty($outputList)){
             $data['row'] = [];
         }
-        foreach ($row  as $key=>$value){
-            $data['row'][$key]['时间'] = date('Y-m-d H:i',strtotime($value['时间']));
-            $data['row'][$key]['状态'] = $value['状态'];
-            if ($key<2){
-                $data['row'][$key]['产能'] = 0;
-            }else{
-                $data['row'][$key]['产能'] = ($row[$key-1]['产量']-$row[$key-2]['产量'])*60;
-            }
+        foreach ($outputList  as $key=>$value){
+            $data['row'][$key]['时间'] = date('Y-m-d H:i',strtotime($value['sys_rq']));
+            $data['row'][$key]['产能'] = $value['sczl_cl'];
         }
         //机台状态
         $status = end($row);
@@ -1479,7 +1479,7 @@ class Facility extends Api
             ->field('rtrim(类别) as 类别,提交时间')
             ->select();
 
-        $data['首件'] = $data['自检'] = $data['IPQC'] = [];
+        $data['首件'] = $data['自检'] = $data['IPQC'] = $data['现场巡查记录'] = [];
         if (!empty($list)){
             foreach ($list as $key=>$value){
                 if ($value['类别'] == '首件与过程确认'){
@@ -1491,14 +1491,19 @@ class Facility extends Api
                 if ($value['类别'] == 'IPQC检验'){
                     array_push($data['IPQC'],$value['提交时间']);
                 }
+                if ($value['类别'] == '现场巡查记录'){
+                    array_push($data['现场巡查记录'],$value['提交时间']);
+                }
             }
             $data['首件'] = array_values(array_unique($data['首件']));
             $data['自检'] = array_values(array_unique($data['自检']));
             $data['IPQC'] = array_values(array_unique($data['IPQC']));
+            $data['现场巡查记录'] = array_values(array_unique($data['现场巡查记录']));
         }else{
             $data['首件'] = [];
             $data['自检'] = [];
             $data['IPQC'] = [];
+            $data['现场巡查记录'] = [];
         }
         $this->success('成功',$data);
     }
@@ -3113,4 +3118,95 @@ class Facility extends Api
             $this->error('未找到相关数据');
         }
     }
+
+    /**
+     * 检验记录
+     * @ApiMethod (GET)
+     * @param string $machine  机台编号
+     * @param string $workOrder  工单编号
+     * @param string $team   班次
+     * @return void
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @throws \think\exception\DbException
+     */
+    public function ProcessInspectionRecord()
+    {
+        if ($this->request->isGet() === false){
+            $this->error('请求失败');
+        }
+        $machine = input('machine');
+        $date = input('date');
+        $team = input('team');
+        if (empty($machine) || empty($team) || empty($date)){
+            $this->success('');
+        }
+        $where = [
+            '设备编号' => $machine,
+            '班组编号' => ['like',$team.'%'],
+            '开工时间' => ['like',$date.'%'],
+            '类别' => ['in',['IPQC检验','机台检验','首件与过程确认']],
+        ];
+        //检测记录详情
+        $field = 'rtrim(工单编号) as 工单编号,rtrim(印件号) as 印件号,rtrim(工序名称) as 工序名称,rtrim(类别) as 类别,rtrim(流程单号) as 流程单号,
+        rtrim(检验项目) as 检验项目,rtrim(检验结果) as 检验结果,rtrim(量测仪器) as 量测仪器,rtrim(提交时间) as 提交时间';
+        $data = \db('制程检验_记录')->where($where)->field($field)->select();
+        $this->success('成功',$data);
+    }
+
+    /**
+     * 现场管理巡查统计左侧菜单
+     */
+    public function ManagementInspectionMenu()
+    {
+        if ($this->request->isGet() === false){
+            $this->error('请求错误');
+        }
+        $param = $this->request->param();
+        $where = [
+            '类别' => '现场巡查记录'
+        ];
+        if (isset($param['machine'])){
+            $where['设备编号'] = $param['machine'];
+        }
+        
+        // 添加最近一个月的时间条件
+        $oneMonthAgo = date('Y-m-d H:i:s', strtotime('-1 month'));
+        $where['提交时间'] = ['>=', $oneMonthAgo];
+        
+        $field = '设备编号,提交时间';
+        $data = db('制程检验_记录')->where($where)->field($field)->select();
+        $result = [];
+        foreach ($data as $key=>$value){
+            $date = date('Y-m-d',strtotime($value['提交时间']));
+            if (!isset($result[$value['设备编号']])){
+                $result[$value['设备编号']] = [];
+            }
+            array_push($result[$value['设备编号']],$date);
+        }
+        $this->success('成功',$result);
+    }
+
+    /**
+     * 管理巡查统计列表
+     */
+    public function ManagementInspectionList()
+    {
+        if ($this->request->isGet() === false){
+            $this->error('请求错误');
+        }
+        $param = $this->request->param();
+        if (empty($param['machine']) || empty($param['date']))
+        {
+            $this->error('参数错误');
+        }
+        $where = [
+            '类别' => '现场巡查记录',
+            '设备编号' => $param['machine'],
+            '提交时间' => ['like',$param['date'].'%'],
+        ];
+        $field = '类别,工单编号,印件号,工序名称,流程单号,班组编号,检验项目,检验备注,提交时间';
+        $data = \db('制程检验_记录')->where($where)->field($field)->select();
+        $this->success('成功',$data);
+    }
 }