Explorar el Código

糊盒机台报工单价下拉框

unknown hace 11 horas
padre
commit
19cf34664c

+ 35 - 0
application/api/controller/GluingReport.php

@@ -1056,4 +1056,39 @@ class GluingReport extends Api
 
 
         $this->success('获取成功', array_values($members));
         $this->success('获取成功', array_values($members));
     }
     }
+
+
+    /**
+     * 获取机台报工单价数据
+     * @return void
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @throws \think\exception\DbException
+     */
+    public function getMachinePriceData()
+    {
+        if ($this->request->isGet() === false){
+            $this->error('请求错误');
+        }
+        $params = $this->request->param();
+        if (!isset($params['machine']) || empty($params['machine'])){
+            $this->error('参数错误');
+        }
+
+        //查询机台的单价列表(仅返回有值的单价)
+        $list = db('machine_price')
+            ->where('machine_id',$params['machine'])
+            ->field('price1,price2,price3,price4,price5,price6,price7,price8,price9,price10')
+            ->select();
+
+        $result = [];
+        foreach ($list as $item) {
+            foreach ($item as $value) {
+                if ($value !== '' && $value !== null) {
+                    $result[] = $value;
+                }
+            }
+        }
+        $this->success('获取成功',$result);
+    }
 }
 }

+ 0 - 76
application/api/controller/GluingSalary.php

@@ -96,82 +96,6 @@ class GluingSalary extends Api
      * @throws \think\db\exception\ModelNotFoundException
      * @throws \think\db\exception\ModelNotFoundException
      * @throws \think\exception\DbException
      * @throws \think\exception\DbException
      */
      */
-//    public function getList()
-//    {
-//
-//        if(!$this->request->isGet()){
-//            $this->error('请求方式错误');
-//        }
-//        $req = $this->request->param();
-//        if (isset($req['search'])){
-//            $where = [
-//                'sczl_rq' => ['like',$req['date'].'%'],
-//                'bh|name' => ['like',$req['search'].'%'],
-//            ];
-//            $res = db('糊盒工资汇总')
-//                ->where($where)
-//                ->group('bh, sczl_rq')
-//                ->field('bh as 员工编号, DATE_FORMAT(sczl_rq, "%Y.%m.%d") as 日期, name as 姓名, sum(salary) as 计件工资')
-//                ->select();
-//        }else{
-//            $where = [
-//                'a.sczl_rq' => ['like',$req['date'].'%'],
-//                'b.所在部门' => ['like', $req['department'] . '%']
-//            ];
-//            $res = db('糊盒工资汇总')
-//                ->alias('a')
-//                ->join('人事_基本资料 b', 'b.员工编号 = a.bh')
-//                ->where($where)
-//                ->group('a.bh, a.sczl_rq')
-//                ->field('a.bh as 员工编号, DATE_FORMAT(a.sczl_rq, "%Y.%m.%d") as 日期, a.name as 姓名, sum(a.salary) as 计件工资')
-//                ->select();
-//        }
-//
-//        $processedData = [];
-//
-//        foreach ($res as $item) {
-//            // 用「员工编号」作为唯一分组键(编号唯一,比编号+姓名更简洁)
-//            $empNo = $item['员工编号'];
-//
-//            // 转换工资为浮点型(避免字符串拼接导致计算错误)
-//            $salary = (float)$item['计件工资'];
-//
-//            if (!isset($processedData[$empNo])) {
-//                // 初始化该员工的分组数据
-//                $processedData[$empNo] = [
-//                    '员工编号' => $empNo,
-//                    '姓名' => $item['姓名'],
-//                    '月工资总和' => 0.00, // 初始化为浮点型,保证精度
-//                    '每日明细' => []     // 存储按时间排序的每日工资
-//                ];
-//            }
-//
-//            // 累加月工资总和
-//            $processedData[$empNo]['月工资总和'] += $salary;
-//            $processedData[$empNo]['月工资总和'] = number_format($processedData[$empNo]['月工资总和'],2);
-//            // 将当前日期的工资存入明细(保留原始字段)
-//            $processedData[$empNo]['每日明细'][] = [
-//                '日期' => $item['日期'],
-//                '计件工资' => $item['计件工资'] // 保留原始字符串格式,避免精度丢失
-//            ];
-//        }
-//
-//        // 对每个员工的「每日明细」按日期升序排序
-//        foreach ($processedData as &$empData) {
-//            usort($empData['每日明细'], function($a, $b) {
-//                // 将日期字符串转换为时间戳进行比较
-//                $timeA = strtotime(str_replace('.', '-', $a['日期']));
-//                $timeB = strtotime(str_replace('.', '-', $b['日期']));
-//                return $timeA - $timeB; // 升序排序(从小到大)
-//            });
-//        }
-//        unset($empData); // 释放引用,避免后续误操作
-//
-//        // 转换为索引数组(可选,便于前端遍历)
-//        $finalData = array_values($processedData);
-//
-//        $this->success('成功',$finalData);
-//    }
     public function getList()
     public function getList()
     {
     {
         // 1. 请求验证
         // 1. 请求验证