| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147 |
- <?php
- namespace app\api\controller;
- use app\common\controller\Api;
- /**
- * 工单核验单维护接口
- */
- class WorkOrderVerification extends Api
- {
- protected $noNeedLogin = ['*'];
- protected $noNeedRight = ['*'];
- /**
- * 首页
- *
- */
- public function index()
- {
- $this->success('请求成功');
- }
- /**
- * 获取工单核验单侧边栏
- * @ApiMethod (GET)
- */
- public function getTab()
- {
- //get请求
- if(!$this->request->isGet()){
- $this->error('请求方式错误');
- }
- $rows = db()->table('db_qczl')
- ->field('LEFT(sys_rq, 10) as date, COUNT(*) as counts')
- ->group('date')
- ->order('UniqId desc')
- ->limit(30)
- ->select();
- $arr = db()->table('db_qczl')
- ->field('LEFT(sys_rq, 10) as date, rtrim(sys_id) as sys_id, COUNT(sys_id) as count')
- ->where('sys_rq','>=',$rows[29]['date'])
- ->group('date, sys_id')
- ->select();
- foreach($rows as $key=>$value){
- $rows[$key]['sys'] = [];
- foreach($arr as $k=>$v){
- if($value['date'] == $v['date']){
- unset($v['date']);
- array_push($rows[$key]['sys'],$v);
- unset($arr[$k]);
- }
- }
- $rows[$key]['date'] = str_replace('-', '.', $rows[$key]['date']);
- }
- $this->success('成功',$rows);
- }
- /**
- * 获取工单核验单列表
- * @ApiMethod (GET)
- * @param string $date 时间
- * @param string $sys_id 用户
- */
- public function getList()
- {
- //get请求
- if(!$this->request->isGet()){
- $this->error('请求方式错误');
- }
- $req = $this->request->param();
- $page = 1;
- $limit = 15;
- if (isset($req['page']) && !empty($req['page'])) $page = $req['page'];
- if (isset($req['limit']) && !empty($req['limit'])) $limit = $req['limit'];
- $where = [];
- if (isset($req['date']) && !empty($req['date'])){
- $where['sys_rq'] = ['LIKE',$req['date'].'%'];
- }else{
- $this->error('参数错误');
- }
- if (isset($req['sys_id']) && !empty($req['sys_id'])) $where['sys_id'] = ['LIKE','%'.$req['sys_id'].'%'];
- $rows = db()->table('db_qczl')
- ->field('qczl_gdbh, qczl_yjno, LEFT(qczl_rq, 10) as qczl_rq, qczl_num, rtrim(qczl_NumDesc) as qczl_NumDesc, qczl_fp,
- fp_lb1, fp_lb2, fp_lb3, fp_lb4, fp_lb5, fp_lb6, fp_lb7, fp_lb8, fp_lb9, fp_lb10, fp_lb11, fp_lb12, fp_lb13, fp_lb14, fp_lb15, fp_lb16, fp_lb17,
- fp_sl1, fp_sl2, fp_sl3, fp_sl4, fp_sl5, fp_sl6, fp_sl7, fp_sl8, fp_sl9, fp_sl10, fp_sl11, fp_sl12, fp_sl13, fp_sl14, fp_sl15, fp_sl16, fp_sl17,
- rtrim(sys_id) as sys_id')
- ->where($where)
- ->order('UniqId desc')
- ->page($page,$limit)
- ->select();
- $gd = db()->table('工单_基本资料')->column('Gd_gdbh, Gd_cpmc');
-
- foreach ($rows as $key=>$value){
- $rows[$key]['Gd_cpmc'] = array_key_exists($value['qczl_gdbh'],$gd) ? sprintf("%02d", $value['qczl_yjno']).'-'.trim($gd[$value['qczl_gdbh']]) : '';
- for ($i=1;$i<=17;$i++){
- if ($value['fp_sl'.$i]==0){
- $rows[$key]['sl_lb'.$i] = '';
- }else{
- $rows[$key]['sl_lb'.$i] = trim($value['fp_sl'.$i].'-->'.$value['fp_lb'.$i]);
- }
- unset($rows[$key]['fp_sl'.$i]);
- unset($rows[$key]['fp_lb'.$i]);
- }
- }
- $data = [
- 'rows' => $rows,
- ];
- $this->success('成功',$data);
- }
- /**
- * 获取工单核验单信息
- * @ApiMethod (GET)
- * @param string $UniqId UniqId
- */
- public function getInfo()
- {
- //get请求
- if(!$this->request->isGet()){
- $this->error('请求方式错误');
- }
- $req = $this->request->param();
- if (isset($req['UniqId']) && !empty($req['UniqId'])){
- $UniqId = $req['UniqId'];
- }else{
- $this->error('参数错误');
- }
- $rows = db()->table('db_qczl')->alias('d')
- ->field('d.*, ')
- ->join('工单_基本资料 g', 'd.')
- ->where('d.UniqId',$UniqId)
- ->select();
- $this->success('成功',$rows);
- }
- }
|