qiuenguang 1 жил өмнө
parent
commit
d735b6989b

+ 218 - 4
application/api/controller/Facility.php

@@ -54,7 +54,7 @@ class Facility extends Api
             $this->success('未找到机台生产记录');
         }
         foreach ($department as $value){
-            $machine = \db('设备_基本资料')->where('使用部门',$value)->where('使用部门',$value)->field('rtrim(设备编号) as 设备编号,rtrim(设备名称) as 设备名称')->cache(true)->select();
+            $machine = \db('设备_基本资料')->where('使用部门',$value)->where('sys_sbID','<>','')->where('使用部门',$value)->field('rtrim(设备编号) as 设备编号,rtrim(设备名称) as 设备名称')->cache(true)->select();
             foreach ($machine as $k=>$v){
                 $data[rtrim($value)][$v['设备编号'].'-->'.$v['设备名称']] = [];
                 foreach ($list as $kk=>$vv){
@@ -230,8 +230,16 @@ class Facility extends Api
         $where['Gy0_gdbh'] = $data['工单编号'];
         $where['Gy0_yjno'] = $data['印件号'];
         $where['Gy0_gxh'] = $data['工序号'];
-        $gxmc = \db('工单_工艺资料')->where($where)->value('Gy0_gxmc');
-        $list['工序名称'] = rtrim($gxmc);
+        $gxmc = \db('工单_工艺资料')->where($where)->find();
+        if ((int)$gxmc['Gy0_gxh']<10){
+            $gxmc['Gy0_gxh'] = '0'.rtrim($gxmc['Gy0_gxh']);
+        }
+        if ($gxmc['Add_gxmc'] !== ''){
+            $printName = rtrim($gxmc['Gy0_gxh']).'-'.rtrim($gxmc['Gy0_gxmc']).'【'.rtrim($gxmc['Add_gxmc']).'】';
+        }else{
+            $printName = rtrim($gxmc['Gy0_gxh']).'-'.rtrim($gxmc['Gy0_gxmc']);
+        }
+        $list['工序名称'] = $printName;
         $class = \db('设备_班组资料')->where('UniqId',$data['班组ID'])->field("rtrim(sczl_bh1) as bh1,rtrim(sczl_bh2) as bh2,rtrim(sczl_bh3) as bh3,rtrim(sczl_bh4) as bh4,
         rtrim(sczl_bh5) as bh5,rtrim(sczl_bh6) as bh6,rtrim(sczl_bh7) as bh7,rtrim(sczl_bh8) as bh8,rtrim(sczl_bh9) as bh9,
         rtrim(sczl_bh10) as bh10")->find();
@@ -1172,5 +1180,211 @@ class Facility extends Api
         $this->success('成功',$data);
     }
 
-    //换型清场
+    /**
+     * 制程检验记录->检验项目
+     * @ApiMethod (GET)
+     * @param void
+     * @return void
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @throws \think\exception\DbException
+     */
+    public function ProcessInspectionRecordsItem()
+    {
+        if ($this->request->isGet() === false){
+            $this->error('请求错误');
+        }
+        $param = $this->request->param();
+        if (empty($param)){
+            $this->error('参数错误');
+        }
+        $list = \db('制程检验_项目')
+            ->where('工序','like','%'.$param['process'].'%')
+            ->select();
+        if (empty($list)){
+            $this->success('未找到检测项目');
+        }
+        $data = [];
+        foreach ($list as $key=>$value){
+            $data['首件']['指标检验'][$key] = [
+                '检验项目' => rtrim($value['检测项目']),
+                '检测方法' => rtrim($value['检测方法']),
+                '检验频率' => rtrim($value['首件签样要求']),
+                '相关标准' => rtrim($value['技术要求'])
+            ];
+            $data['机台检验']['指标检验'][$key] = [
+                '检验项目' => rtrim($value['检测项目']),
+                '检测方法' => rtrim($value['检测方法']),
+                '检验频率' => rtrim($value['机台自检频率']),
+                '相关标准' => rtrim($value['技术要求'])
+            ];
+            $data['IPQC']['指标检验'][$key] = [
+                '检验项目' => rtrim($value['检测项目']),
+                '检测方法' => rtrim($value['检测方法']),
+                '检验频率' => rtrim($value['IPQC检验频率']),
+                '相关标准' => rtrim($value['技术要求'])
+            ];
+        }
+        $row = \db('制程检验_项目附加')
+            ->where('工序','like','%'.$param['process'].'%')
+            ->select();
+        foreach ($row as $key=>$value){
+            $data['首件']['附加'][$key] = [
+                '缺陷备注' => rtrim($value['缺陷备注']),
+                '编号' => rtrim($value['编号'])
+            ];
+            $data['机台检验']['附加'][$key] = [
+                '缺陷备注' => rtrim($value['缺陷备注']),
+                '编号' => rtrim($value['编号'])
+            ];
+            $data['IPQC']['附加'][$key] = [
+                '缺陷备注' => rtrim($value['缺陷备注']),
+                '编号' => rtrim($value['编号'])
+            ];
+        }
+        $this->success('成功',$data);
+    }
+
+    /**
+     * 制程检验记录->检测记录添加
+     * @ApiMethod (POST)
+     * @param void
+     * @return void
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @throws \think\exception\DbException
+     */
+    public function ProcessInspectionRecordsItemAdd()
+    {
+        if (Request::instance()->isPost() === false){
+            $this->error('请求错误');
+        }
+        $param = Request::instance()->post();
+        if (empty($param)){
+            $this->error('参数错误');
+        }
+        $startID = \db('制程检验_记录')->order('UniqId desc')->value('UniqId');
+        if ($startID<100000000){
+            $startID = 100000000;
+        }
+        $process = \db('工单_工艺资料')
+            ->where('Gy0_gdbh',$param[0]['workOrder'])
+            ->where('Gy0_sbbh','like','%'.$param[0]['machine'].'#'.'%')
+            ->field('rtrim(Gy0_gxh) as gxh,rtrim(Gy0_gxmc) as gxmc,rtrim(Add_gxmc) as add_gxmc')
+            ->find();
+        $startTime = \db('设备_产量采集')
+            ->where('设备编号','like','%'.$param[0]['machine'].'#%')
+            ->where('工单编号',$param[0]['workOrder'])
+            ->order('UniqId desc')
+            ->find();
+        if ((int)$process['gxh']<10){
+            $process['gxh'] = '0'.$process['gxh'];
+        }
+        if ($process['add_gxmc'] !== ''){
+            $printName = $process['gxh'].'-'.$process['gxmc'].'【'.$process['add_gxmc'].'】';
+        }else{
+            $printName = $process['gxh'].'-'.$process['gxmc'];
+        }
+        if (empty($process)){
+            $this->success('数据错误');
+        }
+        $data = [];
+        foreach ($param as $key=>$value){
+            $data[$key] = [
+                '类别' => $value['category'],
+                '工单编号' => $value['workOrder'],
+                '印件号' => $value['yjno'],
+                '工序名称' => $printName,
+                '流程单号' => $value['flow'],
+                '设备编号' => $value['machine'],
+                '班组编号' => $startTime['班组编号'],
+                '检验项目' => $value['item'],
+                '相关标准' => $value['standard'],
+                '量测仪器' => $value['instrument'],
+                '检验结果' => $value['result'],
+                '检验备注' => $value['remark'],
+                '提交时间' => date('Y-m-d H:i:s',time()),
+                '开工时间' => rtrim($startTime['开工时间']),
+                'sys_id' => '',
+                'sys_rq' => date('Y-m-d H:i:s',time()),
+                'mod_rq' => '0000-00-00 00:00:00',
+                'UniqId' => $startID + $key +1
+            ];
+        }
+        $res = \db('制程检验_记录')->insertAll($data);
+        if ($res !== false){
+            $this->success('成功');
+        }else{
+            $this->error('失败');
+        }
+    }
+
+    /**
+     * 制程检验记录->附加检验记录添加
+     * @ApiMethod (POST)
+     * @param  void
+     * @return void
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @throws \think\exception\DbException
+     */
+    public function AdditionalInspectionRecordAdd()
+    {
+        if (Request::instance()->isPost() === false){
+            $this->error('请求错误');
+        }
+        $param = Request::instance()->post();
+        if (empty($param)){
+            $this->error('参数错误');
+        }
+        $startID = \db('制程检验_记录附加')->order('UniqId desc')->value('UniqId');
+        if ($startID<100000000){
+            $startID = 100000000;
+        }
+        $process = \db('工单_工艺资料')
+            ->where('Gy0_gdbh',$param[0]['workOrder'])
+            ->where('Gy0_sbbh','like','%'.$param[0]['machine'].'#'.'%')
+            ->field('rtrim(Gy0_gxh) as gxh,rtrim(Gy0_gxmc) as gxmc,rtrim(Add_gxmc) as add_gxmc')
+            ->find();
+        $startTime = \db('设备_产量采集')
+            ->where('设备编号','like','%'.$param[0]['machine'].'#%')
+            ->where('工单编号',$param[0]['workOrder'])
+            ->order('UniqId desc')
+            ->find();
+        if ((int)$process['gxh']<10){
+            $process['gxh'] = '0'.$process['gxh'];
+        }
+        if ($process['add_gxmc'] !== ''){
+            $printName = $process['gxh'].'-'.$process['gxmc'].'【'.$process['add_gxmc'].'】';
+        }else{
+            $printName = $process['gxh'].'-'.$process['gxmc'];
+        }
+        if (empty($process)){
+            $this->success('数据错误');
+        }
+        $data = [];
+        foreach ($param as $key=>$value){
+            $data[$key] = [
+                '工单编号' => $value['workOrder'],
+                '印件号' => $value['yjno'],
+                '工序名称' => $printName,
+                '流程单号' => $value['flow'],
+                '设备编号' => $value['machine'],
+                '班组编号' => $startTime['班组编号'],
+                '缺陷备注' => $value['remark'],
+                '提交时间' => date('Y-m-d H:i:s',time()),
+                '开工时间' => rtrim($startTime['开工时间']),
+                'sys_id' => '',
+                'sys_rq' => date('Y-m-d H:i:s',time()),
+                'mod_rq' => '0000-00-00 00:00:00',
+                'UniqId' => $startID + $key +1
+            ];
+        }
+        $res = \db('制程检验_记录附加')->insertAll($data);
+        if ($res !== false){
+            $this->success('成功');
+        }else{
+            $this->error('失败');
+        }
+    }
 }