success('请求成功'); } /** * 获取员工列表信息 * * @ApiMethod (GET) * @param string * */ public function getStaffList(){ if (Request::instance()->isGet() == false){ $this->error('非法请求'); } $params = Request::instance()->param(); $where = []; if (!empty($params['department_code'])){ $where['部门编码'] = $params['department_code']; } $where['在职状态'] = '在职'; if (isset($params['mes_online'])){ $where['在职状态'] = $params['mes_online'] > 1 ? '离职':'在职'; } $where['U8在职'] = '在职'; if (isset($params['u8_online'])){ $where['U8在职'] = $params['u8_online'] > 1 ? '离职':'在职'; } $limit = $params['limit']; if (empty($limit)){ $limit = 15; } $pages = $params['page']; if (empty($pages)){ $pages = 1; } $field = '员工编号,员工姓名,性别,聘用日期,转正日期,所在部门,职称职务,身份证号,出生日期,人员性质,人员类别,班次类型,工资表类别,薪酬核算分组,在职状态,U8在职,U8离职日期,sys_id,sys_rq,mod_rq'; $list = Db::name('人事_基本资料')->where($where)->field($field)->page($pages)->limit($limit)->order('UniqID asc')->select(); $total = Db::name('人事_基本资料')->where($where)->count(); $data['list'] = $list; $data['total'] = $total; $this->success('请求成功',$data); } /** * 获取部门列表 * * @ApiMethod (GET) * */ public function getDepartment(){ if (Request::instance()->isGet() == false){ $this->error('非法请求'); } $sql = "select 编号,名称 from 人事_组织结构 where 状态 = '' "; $list = Db::query($sql); $data = []; foreach ($list as $key => $value){ $number = trim($value['编号']); if (strlen($number) == 1 ){//一级菜单 $sql = "select count(*) as total from 人事_基本资料 where SUBSTRING(部门编码,1,1)='{$number}' and 在职状态 = '在职' and U8在职 = '在职'"; $res = Db::query($sql); $value['num'] = $res[0]['total']; $list[$key] = $value; $data[$number] = $value; }else { //二级菜单 $sql = "select count(*) as total from 人事_基本资料 where 部门编码='{$number}' and 在职状态 = '在职' and U8在职 = '在职'"; $res = Db::query($sql); $value['num'] = $res[0]['total']; $list[$key] = $value; } } foreach ($data as $k=>$v){ $i = 0; $data[$k]['children'] = []; foreach ($list as $item){ $num = trim($item['编号']); if (strlen($num) >= 3 && substr($num,0,1) == $k){ if ($item['num'] > 0){ $data[$k]['children'][$i] = $item; $i++; } } } } $data = array_values($data); $this->success('请求成功',$data); } }