roleAction.php 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. <?php
  2. declare (strict_types = 1);
  3. namespace app\command;
  4. use app\admin\model\Action;use app\admin\model\Role;use app\admin\model\UserRole;use think\console\Command;
  5. use think\console\Input;
  6. use think\console\input\Argument;
  7. use think\console\input\Option;
  8. use think\console\Output;use think\facade\Db;
  9. class roleAction extends Command
  10. {
  11. protected function configure()
  12. {
  13. // 指令配置
  14. $this->setName('roleaction')
  15. ->setDescription('the roleaction command');
  16. }
  17. protected function execute(Input $input, Output $output)
  18. {
  19. $list= Db::name("user_role")->alias("a")
  20. ->leftJoin("role_action b"," a.roleid = b.role_id ")
  21. ->where(["a.is_del"=>0])
  22. ->cursor();
  23. $data=[];
  24. $db = Db::connect('mysql_sys');
  25. foreach ($list as $item){
  26. $ti= $db->name('account_company')->where(["companyCode"=>$item['companyNo'],"is_del"=>0,
  27. "account_id"=>$item['uid']])->findOrEmpty();
  28. if(empty($ti)) continue;
  29. $temp=[];
  30. $temp[] = $db->name("user")->where("account_id",$item['uid'])->value("nickname");
  31. $temp[]= Db::name('role')->where("id",$item['roleid'])->value("role_name");
  32. $temp[] =$db->name("headquarters")->where("code",$item['companyNo'])->value("name","所有");
  33. $temp[] =$item['companyNo'];
  34. $menu=[];
  35. if($item['action_conllect']!=''){
  36. $menu = Db::name('action')->alias('a')
  37. ->leftJoin('admin_menu c','a.menuid=c.id')
  38. ->leftJoin('action_list d','a.action_code=d.action_code')
  39. ->whereIn('a.id',explode(',',$item['action_conllect']))
  40. ->field("CONCAT(menu_name,'-',action_name) as menu")->select()->toArray();
  41. }
  42. $data[]= array_merge($temp,array_column($menu,"menu"));
  43. }
  44. excelSaveFile($data,"权限采销");
  45. }
  46. public function RoleProcess(){
  47. $list = Db::name("role_process")->where(["is_del"=>0])->cursor();
  48. $data=[];
  49. $db = Db::connect('mysql_sys');
  50. foreach ($list as $item){
  51. $temp=[];
  52. $roleinfo = Db::name('role')->where('id',$item['role_id'])->findOrEmpty();
  53. $temp[] = $roleinfo['role_name']??"";
  54. $temp[] =$db->name('headquarters')->where('code',$roleinfo['companyNo'])->value('name','所有');;
  55. if($item['action_data']!=""){
  56. $prceos = Db::name("action_process")->whereIn('id',explode(',',$item['action_data']))
  57. ->field("CONCAT(order_name,'-',status_name) as proce")->select()->toArray();
  58. $data[]= array_merge($temp,array_column($prceos,'proce'));
  59. }
  60. }
  61. excelSaveFile($data,'权限流程采销');
  62. }
  63. }