unknown 4 месяцев назад
Родитель
Сommit
83f1f94a7c
1 измененных файлов с 114 добавлено и 1 удалено
  1. 114 1
      application/api/controller/GluingReport.php

+ 114 - 1
application/api/controller/GluingReport.php

@@ -524,7 +524,7 @@ class GluingReport extends Api
             'a.sczl_jtbh' => $params['machine'],
             'a.sczl_rq' => ['like',$params['day'].'%']
         ];
-        $field = ['a.sczl_gdbh as 工单编号','a.sczl_yjno as 印件号','a.sczl_gxh as 工序号','a.来料数量','a.sczl_cl as 产量',
+        $field = ['a.sczl_gdbh as 工单编号','a.sczl_yjno as 印件号','a.sczl_gxh as 工序号','a.sczl_gxmc as 工序名称','a.来料数量','a.sczl_cl as 产量',
             'a.sczl_zcfp as 制程废品','a.startTime as 开始时间','a.endTime as 结束时间','a.sczl_ls as 联数','a.sczl_rq as 日期',
             'a.sczl_dedh as 定额代号','a.工价系数','a.保养工时','a.装版工时','a.异常工时','a.异常类型','a.设备运行工时','a.role',
             'a.sys_id as 创建人员','a.sys_rq as 上报时间','a.mod_rq as 修改时间','a.Uid','a.sczl_jtbh as 机台编号',
@@ -568,4 +568,117 @@ class GluingReport extends Api
         $this->success('成功',$list);
     }
 
+
+    /**
+     * 报工数据详情显示
+     * @return void
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @throws \think\exception\DbException
+     */
+
+    public function getGluingReportDataDetail()
+    {
+        if ($this->request->isGet() === false){
+            $this->error('请求错误');
+        }
+        $params = $this->request->param();
+        if(!isset($params['id']) || empty($params['id'])){
+            $this->error('参数错误');
+        }
+        $where = ['Uid'=>$params['id']];
+        $field = ['a.sczl_gdbh as 工单编号','a.sczl_yjno as 印件号','a.sczl_gxh as 工序号','a.sczl_gxmc as 工序名称','a.来料数量','a.sczl_cl as 产量',
+            'a.sczl_zcfp as 制程废品','a.startTime as 开始时间','a.endTime as 结束时间','a.sczl_ls as 联数','a.sczl_rq as 日期',
+            'a.sczl_dedh as 定额代号','a.工价系数','a.保养工时','a.装版工时','a.异常工时','a.异常类型','a.设备运行工时','a.role',
+            'a.sys_id as 创建人员','a.sys_rq as 上报时间','a.mod_rq as 修改时间','a.Uid','a.sczl_jtbh as 机台编号',
+            'b.yj_Yjdh as 产品代号','yj_yjmc as 产品名称'];
+        $list = \db('设备_糊盒报工资料')
+            ->alias('a')
+            ->join('工单_印件资料 b','a.sczl_gdbh = b.Yj_Gdbh and a.sczl_yjno = b.yj_Yjno','left')
+            ->where($where)
+            ->field($field)
+            ->find();
+
+        $list['class'] = [];
+        $idList = explode(',',$list['role']);
+        foreach ($idList as $item){
+            $class = \db('设备_糊盒班组资料')
+                ->where('id',$item)
+                ->field("role,rate,bh1,bh2,bh3,bh4,bh5,bh6,bh7,bh8,bh9,bh10,bh11,bh12,bh13,bh14,bh15")
+                ->find();
+            if (!empty($class)){
+                for ($i=1;$i<16;$i++) {
+                    if ($class['bh' . $i] != '' && $class['bh' . $i] != '000000') {
+                        $name = \db('人事_基本资料')->where('员工编号', $class['bh' . $i])->field('rtrim(员工姓名) as 姓名')->find();
+                        $list['class'][] = [
+                            '编号' => $class['bh' . $i],
+                            '姓名' => $name['姓名'],
+                            '比例' => $class['rate'],
+                            '角色' => $class['role'],
+                        ];
+                    }
+                }
+                $list['class'] = array_values($list['class']);
+            }
+        }
+        $this->success('成功',$list);
+    }
+
+
+    /**
+     * 修改糊盒班组报工资料
+     * @return void
+     * @throws \think\Exception
+     * @throws \think\db\exception\BindParamException
+     * @throws \think\exception\PDOException
+     */
+    public function getGluingReportDetailUpdate()
+    {
+        if ($this->request->isPost() === false){
+            $this->error('请求错误');
+        }
+        $params =  Request::instance()->post();
+        if(!isset($params['id']) || empty($params['id'])){
+            $this->error('参数错误');
+        }
+        $id = $params['id'];
+        unset($params['id']);
+        $params['mod_rq'] = date('Y-m-d H:i:s',time());
+        $sql = \db('设备_糊盒报工资料')
+            ->where('Uid',$id)
+            ->fetchSql(true)
+            ->update($params);
+        $res = \db()->query($sql);
+        if ($res === false) {
+            $this->error('修改成功');
+        }else{
+            $this->success('修改失败');
+        }
+    }
+
+
+    /**
+     * 修改报工数据班组
+     * @return void
+     * @throws \think\Exception
+     * @throws \think\exception\PDOException
+     */
+    public function UpdateGluingReportClass()
+    {
+        if ($this->request->isPost() === false){
+            $this->error('请求错误');
+        }
+        $params = Request::instance()->post();
+        if(!isset($params['id']) || empty($params['id'])){
+            $this->error('参数错误');
+        }
+        $id = $params['id'];
+        $data['role'] = $params['role'];
+        $res = \db('设备_糊盒报工资料')->where('Uid',$id)->update($data);
+        if ($res === false) {
+            $this->error('修改失败');
+        }else{
+            $this->success('修改成功');
+        }
+    }
 }