Parcourir la source

电化铝领用记录

unknown il y a 10 mois
Parent
commit
8e7b107f06
1 fichiers modifiés avec 42 ajouts et 15 suppressions
  1. 42 15
      application/api/controller/AluminumElectroplated.php

+ 42 - 15
application/api/controller/AluminumElectroplated.php

@@ -30,29 +30,52 @@ class AluminumElectroplated extends Api
         if ($this->request->isGet() === false) {
             $this->error('请求错误');
         }
+        $param = $this->request->param();
         //获取最后上传日期
         $lastDay = db('物料_电化铝领用记录')
             ->order('Uniqid desc')
             ->value('st_rq');
         $nextDay = date('Y-m-d', strtotime($lastDay . ' -1 month'));
-        $list = db('物料_电化铝领用记录')
-            ->field('DATE(st_rq) as st_rq, sys_id, COUNT(*) as count')
-            ->where('st_rq', '>=', $nextDay . ' 00:00:00') // 最小值
-            ->where('st_rq', '<=', $lastDay) // 最大值
-            ->group('st_rq, sys_id')
-            ->order('st_rq DESC')
-            ->select();
+        if ($param['type'] == 1){
+            $list = db('物料_电化铝领用记录')
+                ->field('DATE(st_rq) as st_rq, sys_id, COUNT(*) as count')
+                ->where('st_rq', '>=', $nextDay . ' 00:00:00') // 最小值
+                ->where('st_rq', '<=', $lastDay) // 最大值
+                ->group('st_rq, sys_id')
+                ->order('st_rq DESC')
+                ->select();
+
+            $data = [];
+            if (!empty($list)){
+                foreach ($list as $k=>$v){
+                    if (isset($data[$v['st_rq']]) == false){
+                        $data[$v['st_rq']] = [];
+                    }
+                    $data[$v['st_rq']][] = $v['sys_id'].'【记录数'.$v['count'].'】';
 
-        $data = [];
-        if (!empty($list)){
-            foreach ($list as $k=>$v){
-                if (isset($data[$v['st_rq']]) == false){
-                    $data[$v['st_rq']] = [];
                 }
-                $data[$v['st_rq']][] = $v['sys_id'].'【记录数'.$v['count'].'】';
+            }
+        }else{
+            $list = db('物料_电化铝领用记录')
+                ->field('st_gdbh, sys_id, COUNT(*) as count')
+                ->where('st_rq', '>=', $nextDay . ' 00:00:00') // 最小值
+                ->where('st_rq', '<=', $lastDay) // 最大值
+                ->group('st_gdbh, sys_id')
+                ->order('st_rq DESC')
+                ->select();
+
+            $data = [];
+            if (!empty($list)){
+                foreach ($list as $k=>$v){
+                    if (isset($data[$v['st_gdbh']]) == false){
+                        $data[$v['st_gdbh']] = [];
+                    }
+                    $data[$v['st_gdbh']][] = $v['sys_id'].'【记录数'.$v['count'].'】';
 
+                }
             }
         }
+
         $this->success('成功',$data);
 
 
@@ -72,10 +95,14 @@ class AluminumElectroplated extends Api
             $this->error('请求错误');
         }
         $params = $this->request->param();
-        if (empty($params) || !isset($params['day'])) {
+        if (empty($params) || !isset($params['search'])) {
             $this->error('参数错误');
         }
-        $where['st_rq'] = ['like',$params['day'].'%'];
+        if ($params['type'] == 1){
+            $where['a.st_rq'] = ['like',$params['search'].'%'];
+        }else{
+            $where['a.st_gdbh'] = $params['search'];
+        }
         if (isset($params['sys_id'])) {
             $where['a.sys_id'] = $params['sys_id'];
         }