Browse Source

优化员工获取

曹鹤洋 1 year ago
parent
commit
17d65db049
1 changed files with 24 additions and 24 deletions
  1. 24 24
      application/api/controller/PackagingCountDocument.php

+ 24 - 24
application/api/controller/PackagingCountDocument.php

@@ -346,31 +346,31 @@ class PackagingCountDocument extends Api
         }else{
             $this->error('参数错误');
         }
-        $rows = db()->table('人事_基本资料')->field('员工编号, rtrim(员工姓名) as ygxm')->where(['在职状态'=>'在职'])->select();
-        $data = [];
-        $pinyin = new Pinyin();
-        foreach ($rows as $v){
-            $sx = '';
-            for($i=0; $i<mb_strlen($v['ygxm']); $i++){
-                $str = mb_substr($v['ygxm'],$i,1);
-                $bool = $this->getChineseCharInitial($str);
-                if($bool){
-                    $sx .= $this->getChineseCharInitial($str);
-                }else{
-                    $sx .= strtoupper($pinyin->abbr($str));
-                }
-            }
-            $data[$sx][] = $v;
-        }
-        $sx = strtoupper($sczl_bh);
-        if(array_key_exists($sx,$data)){
-            $this->success('成功',$data[$sx]);
-        }
-
-        // $rs = db()->table('人事_基本资料')->field('员工编号, rtrim(员工姓名) as ygxm')->where(['pycode'=>$sczl_bh,'在职状态'=>'在职'])->find();
-        // if($rs){
-        //     $this->success('成功',$rs);
+        // $rows = db()->table('人事_基本资料')->field('员工编号, rtrim(员工姓名) as ygxm')->where(['在职状态'=>'在职'])->select();
+        // $data = [];
+        // $pinyin = new Pinyin();
+        // foreach ($rows as $v){
+        //     $sx = '';
+        //     for($i=0; $i<mb_strlen($v['ygxm']); $i++){
+        //         $str = mb_substr($v['ygxm'],$i,1);
+        //         $bool = $this->getChineseCharInitial($str);
+        //         if($bool){
+        //             $sx .= $this->getChineseCharInitial($str);
+        //         }else{
+        //             $sx .= strtoupper($pinyin->abbr($str));
+        //         }
+        //     }
+        //     $data[$sx][] = $v;
+        // }
+        // $sx = strtoupper($sczl_bh);
+        // if(array_key_exists($sx,$data)){
+        //     $this->success('成功',$data[$sx]);
         // }
+
+        $rs = db()->table('人事_基本资料')->field('员工编号, rtrim(员工姓名) as ygxm')->where(['pycode'=>$sczl_bh,'在职状态'=>'在职'])->select();
+        if($rs){
+            $this->success('成功',$rs);
+        }
         $rs = db()->table('人事_基本资料')->field('员工编号, rtrim(员工姓名) as ygxm')->where(['员工编号'=>$sczl_bh,'在职状态'=>'在职'])->select();
         if($rs===false){
             $this->error('员工编号错误');