Răsfoiți Sursa

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

liuhairui 2 săptămâni în urmă
părinte
comite
d911fdda76
1 a modificat fișierele cu 71 adăugiri și 2 ștergeri
  1. 71 2
      application/api/controller/ReportingWork.php

+ 71 - 2
application/api/controller/ReportingWork.php

@@ -100,7 +100,7 @@ class ReportingWork extends Api
                 standard_score as 标准工分,coefficient as 系数,remark as 备注')
                 ->order('process_code')
                 ->select();
-            if (empty($process)) {
+            if (empty($data)) {
                 $this->error('未找到工艺数据');
             }
         }
@@ -346,7 +346,7 @@ class ReportingWork extends Api
             ->where('del_rq', null)
             ->where('date', $params['date'])
             ->where('machine', $params['machine'])
-            ->field('work_order,majorprocess,part_code,process_code,process_name,staff_no,staff_name,standard_hour,standard_score,coefficient,number,production_hour,production_score,machine,sys_id,sys_rq')
+            ->field('id,work_order,majorprocess,part_code,process_code,process_name,staff_no,staff_name,standard_hour,standard_score,coefficient,number,production_hour,production_score,machine,sys_id,sys_rq')
             ->order('process_code asc,staff_no asc')
             ->select();
 
@@ -377,10 +377,79 @@ class ReportingWork extends Api
                 'production_score' => $row['production_score'],
                 'sys_id' => $row['sys_id'],
                 'sys_rq' => $row['sys_rq'],
+                'id' => $row['id'],
             ];
         }
 
         $data = array_values($processMap);
         $this->success('成功', $data);
     }
+
+    /**
+     * 修改报工数据
+     * @ApiMethod (POST)
+     * @param array $list 报工数据
+     * @return array
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @throws \think\exception\DbException
+     */
+    public function UpdateReportingWork()
+    {
+        if (!$this->request->isPost()) {
+            $this->error('请求方法错误');
+        }
+        $params = $this->request->post();
+        if (empty($params['id'])) {
+            $this->error('ID不能为空');
+        }
+        if (empty($params['mod_id'])) {
+            $this->error('修改人不能为空');
+        }
+        $data = [
+            'mod_id' => $params['mod_id'],
+            'mod_rq' => date('Y-m-d H:i:s'),
+            'number' => $params['number'],
+            'production_hour' => $params['production_hour'],
+            'production_score' => $params['production_score'],
+        ];
+        $result = db('设备_工分计酬')
+            ->where('id', $params['id'])
+            ->update($data);
+        if ($result === false) {
+            $this->error('修改失败');
+        }
+        $this->success('修改成功');
+    }
+
+    /**
+     * 删除报工数据
+     * @ApiMethod (POST)
+     * @param array $id ID
+     * @return array
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @throws \think\exception\DbException
+     */
+    public function DeleteReportingWork()
+    {
+        if (!$this->request->isPost()) {
+            $this->error('请求方法错误');
+        }
+        $params = $this->request->post();
+        if (empty($params['id'])) {
+            $this->error('ID不能为空');
+        }
+        $data = [
+            'del_rq' => date('Y-m-d H:i:s'),
+        ];
+        $result = db('设备_工分计酬')
+            ->where('id', $params['id'])
+            ->update($data);
+        if ($result === false) {
+            $this->error('删除失败');
+        }
+        $this->success('删除成功');
+
+    }
 }