|
@@ -10,6 +10,100 @@ use think\Db;
|
|
|
class Patrol extends Index
|
|
|
{
|
|
|
|
|
|
+ public function patrolImg3(){
|
|
|
+ $data = Db::name('patrol_record')
|
|
|
+ ->field('images,patrol_addr_id')
|
|
|
+ ->where('images','<>','')
|
|
|
+ ->where('org_id',$this->orgId)
|
|
|
+ ->where('patrol_mode',1)
|
|
|
+ ->whereTime('create_time','today')
|
|
|
+ ->order('create_time desc')
|
|
|
+ ->select();
|
|
|
+
|
|
|
+ foreach ($data as $k=>$v){
|
|
|
+ $img = explode(',',$v['images']);
|
|
|
+ if($img){
|
|
|
+ $data[$k]['images'] = $img[0];
|
|
|
+ }
|
|
|
+ $data[$k]['addr'] = Db::name('address')->where('id',$v['patrol_addr_id'])->value('title');
|
|
|
+ }
|
|
|
+ if(count($data)>12){
|
|
|
+ $key = array_rand($data,12);
|
|
|
+ for ($i = 0; $i < 12; $i++) {
|
|
|
+ $list[] = $data[$key[$i]];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ $eList = isset($list)?$list:$data;
|
|
|
+ HelpHander::success($eList);
|
|
|
+ }
|
|
|
+ public function patrolRoutes(){
|
|
|
+ $lists = $this->getInfo();
|
|
|
+ $title = array_unique(array_column($lists,'title'));
|
|
|
+ $mappedArray = array_map(function ($item) {
|
|
|
+ $time = $this->getInfo($item,1);
|
|
|
+ $count = $this->getInfo($item);
|
|
|
+ $id = $this->getInfo($item,1);
|
|
|
+ $info = $this->getInfo($this->orgId, $item);
|
|
|
+ return [
|
|
|
+ 'title' => $item,
|
|
|
+ 'count' => count($count),
|
|
|
+ 'time' =>date('H:i:s',strtotime($time[0]['create_time'])),
|
|
|
+ 'name' =>Db::name('user')->where('id', $id[0]['user_id'])->value('real_name')
|
|
|
+ ];
|
|
|
+ }, $title);
|
|
|
+
|
|
|
+ HelpHander::success(array_reverse($mappedArray));
|
|
|
+ }
|
|
|
+ public function getInfo($item='',$param=''){
|
|
|
+ $map[] = ['pr.create_yyyymmdd','=',date('Ymd')];
|
|
|
+ $map[] = ['pr.org_id','=',$this->orgId];
|
|
|
+ $map[] = ['pr.patrol_mode', '=',1];
|
|
|
+ if ($item) {
|
|
|
+ $map[] = ['pa.title','=',$item];
|
|
|
+ }
|
|
|
+ if ($param) {
|
|
|
+ $lists = Db::name('patrol_record')
|
|
|
+ ->alias('pr')
|
|
|
+ ->field('pr.id,pr.user_id,pr.order_id,pr.create_time,pa.title,pt.title as task_title')
|
|
|
+ ->join('patrol_task pt','pt.id = pr.patrol_task_id')
|
|
|
+ ->Leftjoin('address pa', 'pa.id=pr.patrol_addr_id')
|
|
|
+ ->where($map)
|
|
|
+ ->order('pr.create_time','desc')
|
|
|
+ ->limit(1)
|
|
|
+ ->select();
|
|
|
+ }
|
|
|
+ $lists = Db::name('patrol_record')
|
|
|
+ ->alias('pr')
|
|
|
+ ->field('pr.id,pr.user_id,pr.order_id,pr.create_time,pa.title,pt.title as task_title')
|
|
|
+ ->join('patrol_task pt','pt.id = pr.patrol_task_id')
|
|
|
+ ->Leftjoin('address pa', 'pa.id=pr.patrol_addr_id')
|
|
|
+ ->where($map)
|
|
|
+ ->order('pr.create_time','desc')
|
|
|
+ ->select();
|
|
|
+ foreach ($lists as $k => $v) {
|
|
|
+ $lists[$k]['task_user'] = Db::name('user')
|
|
|
+ ->where('id', $v['user_id'])->value('real_name');
|
|
|
+ $status = 0;
|
|
|
+ if($v['order_id'] > 0 ){
|
|
|
+ $order = Db::name('orders')
|
|
|
+ ->where('id',$v['order_id'])
|
|
|
+ ->where('quality_type',$v['patrol_mode']+1)
|
|
|
+ ->whereIn('order_mode',[5,6])->where('del',0)->find();
|
|
|
+
|
|
|
+ if($order){
|
|
|
+ $status = 2;
|
|
|
+ }else{
|
|
|
+ $status = 1;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ $lists[$k]['zg_type'] = $status;
|
|
|
+
|
|
|
+ $lists[$k]['exception'] = 1;
|
|
|
+ }
|
|
|
+
|
|
|
+ return $lists;
|
|
|
+ }
|
|
|
+
|
|
|
public function patrolNums(){
|
|
|
$mode = input('mode');
|
|
|
if(!in_array($mode,[1,2,3,4])){
|