Переглянути джерело

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

曹鹤洋 1 рік тому
батько
коміт
18f6bbd658

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

@@ -232,7 +232,7 @@ class Facility extends Api
         if (empty($data)){
             $this->success('未找到生产订单');
         }
-        if (rtrim($data['工单编号']) === '' || rtrim($data['工单编号']) === null ){
+        if (empty($data['工单编号'])){
             $this->success('未找到生产订单');
         }
         $endTime = \db('工单_工艺资料')
@@ -1216,6 +1216,7 @@ class Facility extends Api
         $row = \db('设备_产量采集')
             ->where('设备编号',$param['machine'])
             ->where('开工时间',$param['start'])
+            ->where('当班产量','<>',-1)
             ->field('rtrim(时间) as 时间,rtrim(当班产量) as 产量,rtrim(当前状态) as 状态')
             ->select();
         if (empty($row)){
@@ -1972,4 +1973,141 @@ class Facility extends Api
             $this->error('删除失败');
         }
     }
+
+    /**
+     * 日产量上报添加
+     * @return void
+     * @throws \think\db\exception\BindParamException
+     * @throws \think\exception\PDOException
+     */
+    public function ChanliangAdd()
+    {
+        if (Request::instance()->isPost() === false){
+            $this->error('请求错误');
+        }
+        $params = Request::instance()->post();
+        if (empty($params['sczl_gdbh'])){
+            $this->error('参数错误');
+        }
+        $lastId = \db('设备_产量计酬')->order('UniqId desc')->value('rtrim(UniqId)');
+        $params['sczl_type'] = $params['sczl_gxmc'];
+        $params['sczl_wgsj'] = '1900-01-01 00:00:00';
+        $params['sczl_废品率系数'] = 0;
+        $params['sys_rq'] = date('Y-m-d H:i:s',time());
+        $params['mod_rq'] = date('Y-m-d H:i:s',time());
+        $params['UniqId'] = $lastId + 1;
+        $sql = \db('设备_产量计酬')->fetchSql(true)->insert($params);
+        $res = \db()->query($sql);
+        if ($res !== false){
+            $this->success('成功');
+        }else{
+            $this->error('失败');
+        }
+    }
+
+    /**
+     * 日产量上报添加获取工单信息
+     * @return void
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @throws \think\exception\DbException
+     */
+    public function ChanliangWorkorder()
+    {
+        if ($this->request->isGet() === false)
+        {
+            $this->error('请求错误');
+        }
+        $param = $this->request->param();
+        if (empty($param['machine'])){
+            $this->error('参数错误');
+        }
+        $where = [
+            'b.Gy0_sbbh' => ['like','%'.$param['machine'].'%'],
+        ];
+        if (!empty($param['search'])){
+            $where['b.Gy0_gdbh'] = ['like','%'.$param['search'].'%'];
+        }
+        $list = \db('工单_基本资料')
+            ->alias('a')
+            ->field('rtrim(Gd_gdbh) as gdbh,rtrim(成品名称) as cpmc')
+            ->join('工单_工艺资料 b','a.Gd_gdbh = b.Gy0_gdbh')
+            ->where($where)
+            ->select();
+        if (empty($list)){
+            $this->success('未找到相关工单');
+        }else{
+            $this->success('成功',$list);
+        }
+    }
+
+    /**
+     * 日产量上报工单印件资料
+     * @return void
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @throws \think\exception\DbException
+     */
+    public function ChanliangPrintDetail()
+    {
+        if ($this->request->isGet() === false){
+            $this->error('请求错误');
+        }
+        $param = $this->request->param();
+        if (empty($param['gdbh'])){
+            $this->error('参数错误');
+        }
+        $where = [
+            'Yj_Gdbh' => $param['gdbh']
+        ];
+        $list = \db('工单_印件资料')
+            ->where($where)
+            ->field('rtrim(yj_Yjno) as yjno,rtrim(yj_yjmc) as yjmc')
+            ->select();
+        if (empty($list)){
+            $this->success('未找到印件资料');
+        }else{
+            $this->success('成功',$list);
+        }
+    }
+
+    /**
+     * 日产量上报工艺资料获取
+     * @return void
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @throws \think\exception\DbException
+     */
+    public function ChanliangProcessDetail()
+    {
+        if ($this->request->isGet() === false){
+            $this->error('请求错误');
+        }
+        $param = $this->request->param();
+        if (empty($param['gdbh'])){
+            $this->error('参数错误');
+        }
+        $list = \db('工单_工艺资料')
+            ->where('Gy0_gdbh',$param['gdbh'])
+            ->where('Gy0_yjno',$param['yjno'])
+            ->where('Gy0_sbbh','like','%'.$param['machine'].'%')
+            ->field('rtrim(Gy0_gxh) as gxh,rtrim(Gy0_gxmc) as gxmc,rtrim(Add_gxmc) as add_gxmc')
+            ->select();
+        if (empty($list)){
+            $this->success('未获取工序');
+        }
+        foreach ($list as $key=>$value){
+            if ((int)$value['gxh'] < 10){
+                $value['gxh'] = '0'.$value['gxh'];
+            }
+            if (empty($value['add_gxmc'])){
+                $list[$key]['name'] = $value['gxh'].'->'.$value['gxmc'];
+            }else{
+                $list[$key]['name'] = $value['gxh'].'->'.$value['gxmc'].'【'.$value['add_gxmc'].'】';
+            }
+            unset($list[$key]['gxmc'],$list[$key]['add_gxmc']);
+        }
+        $this->success('成功',$list);
+    }
+
 }

+ 1 - 1
application/api/controller/WorkOrder.php

@@ -351,7 +351,7 @@ class WorkOrder extends Api
             $this->error('参数错误');
         }
         $field = 'rtrim(Gd_lx) as 重点工单,rtrim(Gd_gdbh) as 工单编号,rtrim(Gd_生产分类) as 生产类型,rtrim(Gd_khdh) as 客户代号,rtrim(Gd_客户名称) as 客户名称,
-        rtrim(Gd_cpdh) as 产品代号,rtrim(Gd_cpmc) as 产品名称,rtrim(接单日期) as 开单日期,rtrim(订单数量) as 订单数量,rtrim(交货日期) as 交货日期,
+        rtrim(Gd_cpdh) as 印件代号,rtrim(Gd_cpmc) as 印件名称,rtrim(成品代号) as 产品代号,rtrim(成品名称) as 产品名称,rtrim(接单日期) as 开单日期,rtrim(订单数量) as 订单数量,rtrim(交货日期) as 交货日期,
         rtrim(投料率) as 投料率,rtrim(实际投料) as 万小张,rtrim(计量单位) as 单位,rtrim(投料大箱) as 投料大箱,rtrim(排产时库存) as 库存大箱,rtrim(警语版面) as 警语版面,
         rtrim(销售订单号) as 销售订单号,rtrim(产品版本号) as 版本号,rtrim(客户ERP编码) as 客户ERP编码,rtrim(码源数量) as 码源数量,rtrim(进程备注) as 进程备注,rtrim(Gd_desc) as 备注,rtrim(Uniqid) as Uniqid';
         $list = \db('工单_基本资料')->where('Gd_gdbh',$workOrder)->field($field)->find();