12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970 |
- <?php
- declare (strict_types = 1);
- namespace app\command;
- use app\admin\model\Action;use app\admin\model\Role;use app\admin\model\UserRole;use think\console\Command;
- use think\console\Input;
- use think\console\input\Argument;
- use think\console\input\Option;
- use think\console\Output;use think\facade\Db;
- class roleAction extends Command
- {
- protected function configure()
- {
- // 指令配置
- $this->setName('roleaction')
- ->setDescription('the roleaction command');
- }
- protected function execute(Input $input, Output $output)
- {
- $list= Db::name("user_role")->alias("a")
- ->leftJoin("role_action b"," a.roleid = b.role_id ")
- ->where(["a.is_del"=>0])
- ->cursor();
- $data=[];
- $db = Db::connect('mysql_sys');
- foreach ($list as $item){
- $ti= $db->name('account_company')->where(["companyCode"=>$item['companyNo'],"is_del"=>0,
- "account_id"=>$item['uid']])->findOrEmpty();
- if(empty($ti)) continue;
- $temp=[];
- $temp[] = $db->name("user")->where("account_id",$item['uid'])->value("nickname");
- $temp[]= Db::name('role')->where("id",$item['roleid'])->value("role_name");
- $temp[] =$db->name("headquarters")->where("code",$item['companyNo'])->value("name","所有");
- $temp[] =$item['companyNo'];
- $menu=[];
- if($item['action_conllect']!=''){
- $menu = Db::name('action')->alias('a')
- ->leftJoin('admin_menu c','a.menuid=c.id')
- ->leftJoin('action_list d','a.action_code=d.action_code')
- ->whereIn('a.id',explode(',',$item['action_conllect']))
- ->field("CONCAT(menu_name,'-',action_name) as menu")->select()->toArray();
- }
-
- $data[]= array_merge($temp,array_column($menu,"menu"));
- }
- excelSaveFile($data,"权限采销");
- }
- public function RoleProcess(){
- $list = Db::name("role_process")->where(["is_del"=>0])->cursor();
- $data=[];
- $db = Db::connect('mysql_sys');
- foreach ($list as $item){
- $temp=[];
- $roleinfo = Db::name('role')->where('id',$item['role_id'])->findOrEmpty();
- $temp[] = $roleinfo['role_name']??"";
- $temp[] =$db->name('headquarters')->where('code',$roleinfo['companyNo'])->value('name','所有');;
- if($item['action_data']!=""){
- $prceos = Db::name("action_process")->whereIn('id',explode(',',$item['action_data']))
- ->field("CONCAT(order_name,'-',status_name) as proce")->select()->toArray();
- $data[]= array_merge($temp,array_column($prceos,'proce'));
- }
- }
- excelSaveFile($data,'权限流程采销');
- }
- }
|