Browse Source

糊盒班组计时报工详情

unknown 5 days ago
parent
commit
3c193c323e
1 changed files with 60 additions and 0 deletions
  1. 60 0
      application/api/controller/GluChronographSheet.php

+ 60 - 0
application/api/controller/GluChronographSheet.php

@@ -630,4 +630,64 @@ class GluChronographSheet extends Api
 
         return $employeeFields;
     }
+
+
+    /**
+     * 糊盒报工数据详情
+     * @return void
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @throws \think\exception\DbException
+     * @throws \think\exception\PDOException
+     */
+    public function getGluingReportClockDataDetail()
+    {
+        if (!$this->request->isGet()) {
+            $this->error('请求错误');
+        }
+        $params = $this->request->param();
+        if (!isset($params['id']) || empty($params['id'])) {
+            $this->error('参数错误');
+        }
+
+        $detail = \db('糊盒班组计时')
+            ->where('id', $params['id'])
+            ->find();
+
+        if (empty($detail)) {
+            $this->error('未找到报工数据');
+        }
+
+        $employeeIds = [];
+        for ($i = 1; $i <= 20; $i++) {
+            $bh = isset($detail['bh' . $i]) ? trim($detail['bh' . $i]) : '';
+            if ($bh !== '' && $bh !== '000000') {
+                $employeeIds[$bh] = true;
+            }
+        }
+
+        $employeeNames = [];
+        if (!empty($employeeIds)) {
+            $employees = \db('人事_基本资料')
+                ->whereIn('员工编号', array_keys($employeeIds))
+                ->field('员工编号, rtrim(员工姓名) as 姓名')
+                ->select();
+            foreach ($employees as $employee) {
+                $employeeNames[$employee['员工编号']] = $employee['姓名'];
+            }
+        }
+
+        $detail['class'] = [];
+        for ($i = 1; $i <= 20; $i++) {
+            $bh = isset($detail['bh' . $i]) ? trim($detail['bh' . $i]) : '';
+            if ($bh !== '' && $bh !== '000000') {
+                $detail['class'][] = [
+                    '编号' => $bh,
+                    '姓名' => $employeeNames[$bh] ?? '',
+                ];
+            }
+        }
+
+        $this->success('获取成功', $detail);
+    }
 }