Browse Source

师傅端检测下发

lizhen_gitee 6 months ago
parent
commit
05bc559a34
1 changed files with 172 additions and 0 deletions
  1. 172 0
      application/api/controller/worker/Jiance.php

+ 172 - 0
application/api/controller/worker/Jiance.php

@@ -0,0 +1,172 @@
+<?php
+
+namespace app\api\controller\worker;
+
+use app\common\controller\Apiw;
+use think\Db;
+/**
+ * 检测下发
+ */
+class Jiance extends Apiw
+{
+    protected $noNeedLogin = [];
+    protected $noNeedRight = [];
+
+    protected $table = 'jiance';
+
+    //首页列表
+    public function index(){
+        $map = [];
+
+        $status = input('status',0);
+        if(!empty($status)){
+            $map['jiance.status'] = $status;
+        }
+
+        $list = Db::name('jiance')
+            ->field('jiance.id,jiance.bianhao,jiance.status,jiance_number,uc.projectname')
+            ->join('user_company uc','jiance.uc_id = uc.id','LEFT')
+            ->where('jiance.worker_id',$this->auth->id)
+            ->where('jiance.deletetime',NULL)
+            ->where($map)
+            ->autopage()
+            ->select();
+
+        $this->success(1,$list);
+    }
+
+    //详情页
+    public function info(){
+        $id = input('id',0);
+
+        $info = Db::name('jiance')->field('id,bianhao,status,project_ids')->where('id',$id)->find();
+
+        //所有项目
+        $lists = Db::name('jiance_project')->field('id,pid,title,type,info')
+            ->where('company_id',$this->auth->company_id)
+            ->where('deletetime',NULL)
+            ->where('id','IN',$info['project_ids'])
+            ->order('weigh asc')->select();
+
+
+    }
+
+    //提交
+    public function submit(){
+
+    }
+
+    //记录列表
+    public function job_list(){
+        $jiance_id   = input('jiance_id',0);
+        $project_id  = input('project_id',0);
+
+        $jiance = Db::name('jiance')->field('id,bianhao,status,project_ids')->where('id',$jiance_id)->find();
+
+        $list = Db::name('jiance_joblog')->alias('joblog')
+            ->field('joblog.*,project.title as project_title')
+            ->join('jiance_project project','joblog.project_id = project.id','LEFT')
+            ->where('joblog.jiance_id',$jiance_id)
+            ->where('joblog.project_id',$project_id)
+            ->select();
+
+        $rs = [
+            '',
+            '',
+        ];
+
+        $this->success(1,$list);
+    }
+
+    //新增记录
+    public function job_add(){
+
+        $data = [
+            'jiance_id'   => input('jiance_id',0),
+            'project_id'  => input('project_id',0),
+            'worker_id'   => $this->auth->id,
+            'weizhi'      => input('weizhi',''),
+            'number'      => input('number',1),
+            'hege_status' => input('hege_status',1),
+            'result'      => input('result',''),
+            'images'      => input('images',''),
+            'createtime'  => time(),
+        ];
+        Db::name('jiance_joblog')->insertGetId($data);
+
+        //检测位置历史
+        $this->weizhi_history($data['weizhi']);
+
+        $this->success();
+    }
+
+    //编辑详情
+    public function job_info(){
+        $id = input('id',0);
+        $info = Db::name('jiance_joblog')->where('id',$id)->find();
+
+        $this->success(1,$info);
+    }
+
+    //编辑记录
+    public function job_edit(){
+        $id = input('id',0);
+        $data = [
+            'weizhi'      => input('weizhi',''),
+            'number'      => input('number',1),
+            'hege_status' => input('hege_status',1),
+            'result'      => input('result',''),
+            'images'      => input('images',''),
+        ];
+        Db::name('jiance_joblog')->where('id',$id)->update($data);
+
+        //检测位置历史
+        $this->weizhi_history($data['weizhi']);
+
+        $this->success();
+    }
+
+    //检测搜索历史,新增一个
+    private function weizhi_history($weizhi){
+        if(empty($weizhi)){ return true;}
+
+        //查重
+        $check = Db::name('worker_weizhi_history')->where('worker_id',$this->auth->id)->where('weizhi',$weizhi)->find();
+        if($check){ return true;}
+
+        //新增
+        $data = [
+            'worker_id' => $this->auth->id,
+            'weizhi'    => $weizhi,
+        ];
+        Db::name('worker_weizhi_history')->insertGetId($data);
+
+        //只留20个
+        $count = Db::name('worker_weizhi_history')->where('worker_id',$this->auth->id)->count();
+        if($count > 10){
+            Db::name('worker_weizhi_history')->where('worker_id',$this->auth->id)->order('id asc')->limit($count - 10)->delete();
+        }
+
+    }
+
+    //删除记录
+    public function job_del(){
+        $id = input('id',0);
+        Db::name('jiance_joblog')->where('id',$id)->delete();
+
+        $this->success();
+    }
+
+    //检测位置历史记录
+    public function history_list(){
+
+    }
+
+
+
+
+
+
+
+
+}