排队叫号系统

arr); $array = array ( 'id' => $con+1, 'name' => $name, 'moblie' => $moblie, 'sfz' => $sfz, 'addtime' => time() ); array_push($this->arr,$array); //打印 $arr = array ( '排号凭证', '您的号码是'=>$con+1, '姓 名' => $name, '手机号码'=>$moblie, '证件号码'=>$sfz, '排号时间'=>date('Y-m-d h:i:s'), ); return 'code:1,info:已成功排上号'.json_encode($arr,JSON_UNESCAPED_UNICODE); } //设置柜台数 public function qt($int) { if (!is_int($int)) { return '请输入正整数'; } for ($i = 1; $i <= $int; $i++) { $array = array ( //状态1 正常0休息2忙碌 'pid' => $i, 'status' => 0, ); $this->qt[]=$array; } return 'msg:新增成功,请在前台打印凭证.'; } //开始叫号 public function del($del=null,$qs) { if ($qs===$del) { return '错误'; } $min = min($this->arr); $info = "请".$min['id']."号到".$this->qt[$del]['pid']."号窗口办理"; $min = $min['id']-1; sleep(3); $this->arr[$min]['deltime']=time(); //回收数据 array_push($this->hssd,$this->arr[$min]); for ($i = 0; $i < count($this->qt); $i++) { if ($del == $i) { $this->qt[$i]['info'] = $info; $this->qt[$i]['status'] = 2; }else{ $this->qt[$i]['status'] = 1; } } if (empty($qs)||$qs) { $this->qt[$qs]['status'] = 0; } unset($this->arr[$min]); return "code:1,info:delete ok,\ndelete_time:".date('Y/m/d h:i:s',time()); } public function run() { $add = $this->add('城里人',13811112222,431111111111111111); $bdd = $this->add('老郭',18666786543,432222222222222222); $qt = $this->qt(4); $del = $this->del(1,2);//1柜台号发起事件2柜台号 从0开始 echo ($add)?$add:$bdd."\n"; echo "$qt\n"; echo str_repeat('_',12)."自动生成柜台数".str_repeat('_',12)."\n"; echo str_repeat('_',6)."3种工作状态(休息,忙碌,正常)".str_repeat('_',6)."\n"; print_r($this->qt); echo str_repeat('_',12)."在队列中的数据".str_repeat('_',12)."\n"; print_r($this->arr)."\n"; echo str_repeat('_',12)."被回收的数据".str_repeat('_',12)."\n"; print_r($this->hssd); echo "$del\n"; echo str_repeat('_',40); } } $data = new Data(); $data->run();
posted @ 2021-04-15 10:27  Yu环上的黑影  阅读(98)  评论(0编辑  收藏  举报