| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148 |
- <?php
- namespace app\api\controller;
- use app\common\controller\Api;
- use \think\Request;
- use \think\Db;
- /**
- * 检验计件单据维护接口
- */
- class Inspect extends Api
- {
- protected $noNeedLogin = ['*'];
- protected $noNeedRight = ['*'];
- /**
- * 首页
- *
- */
- public function index()
- {
- $this->success('请求成功');
- }
- /**
- * 获取手工检验左侧菜单栏
- *
- * @ApiMethod GET
- */
- public function getInspectCount(){
- if (Request::instance()->isGet() == false){
- $this->error('非法请求');
- }
- $sql = 'SELECT DISTINCT DATE(sys_rq) AS sys_rq FROM `db_手工检验` ORDER BY sys_rq DESC LIMIT 30 ';
- $list = Db::query($sql);
- foreach ($list as $key => $value){
- $where = [$value['sys_rq'].'00:00:00',$value['sys_rq'].'24:00:00'];
- $list[$key]['count'] = Db::name('db_手工检验')->where('sys_rq','between time',$where)->count();
- }
- $this->success('请求成功',$list);
- }
- /**
- * 获取某个日期手工单据
- *
- * @ApiMethod GET
- * @params string date
- */
- public function getDateList(){
- if (Request::instance()->isGet() == false){
- $this->error('非法请求');
- }
- $params = Request::instance()->param();
- $date = $params['date'];
- if (!isset($date)){
- $this->error('参数不能为空');
- }
- $limit = $params['limit'];
- if (empty($limit)){
- $limit = 15;
- }
- $pages = $params['page'];
- if (empty($pages)){
- $pages = 1;
- }
- $field = 'a.sczl_gdbh,a.sczl_yjgx,rtrim(a.sczl_gxmc) as sczl_gxmc,DATE(a.sczl_rq) as sczl_rq,a.sczl_cl,a.sczl_dedh,a.sczl_废品率系数,a.sczl_检验类别,a.sczl_bh0,
- rtrim(a.qczl_NumDesc) as qczl_NumDesc,rtrim(a.sys_id) as sys_id,a.sys_rq,a.mod_rq,a.UniqId,b.千件工价,b.日定额,rtrim(c.员工姓名) as 员工姓名,rtrim(d.yj_yjmc) as yj_yjmc';
- $where = [$date.' 00:00:00',$date.'24:00:00'];
- $list = Db::name('db_手工检验')->alias('a')
- ->join('dic_lzde b','a.sczl_dedh = b.sys_bh','left')
- ->join('人事_基本资料 c','a.sczl_bh0 = c.员工编号','left')
- ->join('工单_印件资料 d','a.sczl_gdbh = d.Yj_Gdbh','left')
- ->where('a.sys_rq','between time',$where)
- ->where('SUBSTR(a.sczl_yjgx,1,2) = d.yj_yjno')
- ->field($field)->limit($limit)->page($pages)->order('a.sczl_rq,a.UniqId asc')->select();
- $option['sys_rq'] = array('between time',[$date.' 00:00:00',$date.' 24:00:00']);
- $count = Db::name('db_手工检验')->where($option)->count();
- $data['data'] = $list;
- $data['total'] = $count;
- $this->success('请求成功',$data);
- }
- /**
- * 获取机器检验左侧菜单栏
- *
- * @ApiMethod GET
- */
- public function getMachineCount(){
- if (Request::instance()->isGet() == false){
- $this->error('非法请求');
- }
- $sql = 'SELECT DISTINCT DATE(sys_rq) AS sys_rq FROM `db_机器检验` ORDER BY sys_rq DESC LIMIT 30 ';
- $list = Db::query($sql);
- foreach ($list as $key => $value){
- $where = [$value['sys_rq'].'00:00:00',$value['sys_rq'].'24:00:00'];
- $list[$key]['count'] = Db::name('db_机器检验')->where('sys_rq','between time',$where)->count();
- }
- $this->success('请求成功',$list);
- }
- /**
- * 获取某个日期机器单据
- *
- * @ApiMethod GET
- * @params string date
- */
- public function getDateMachine(){
- if (Request::instance()->isGet() == false){
- $this->error('非法请求');
- }
- $params = Request::instance()->param();
- $date = $params['date'];
- if (!isset($date)){
- $this->error('参数不能为空');
- }
- $limit = $params['limit'];
- if (empty($limit)){
- $limit = 15;
- }
- $pages = $params['page'];
- if (empty($pages)){
- $pages = 1;
- }
- $where['a.sczl_单据类型'] = '初检单';
- $where['a.sys_rq'] = array('between time',[$date.' 00:00:00',$date.' 24:00:00']);
- $field = 'a.sczl_gdbh,trim(a.sczl_yjgx) as sczl_yjgx,rtrim(a.sczl_gxmc) as sczl_gxmc,a.sczl_jtbh,a.sczl_bzdh,DATE(a.sczl_rq) as sczl_rq,a.sczl_cl,rtrim(a.sczl_单据类型) as sczl_单据类型,
- a.sczl_设备运行工时,a.sczl_dedh,a.sczl_废品率系数,a.sczl_bh1,a.sczl_bh2,a.sczl_bh3,a.sczl_bh4,a.qczl_NumDesc,rtrim(a.sys_id) as sys_id,a.sys_rq,a.mod_rq,a.UniqId,b.千件工价,b.日定额,
- rtrim(c1.员工姓名) as sczl_bh1_name,rtrim(c2.员工姓名) as sczl_bh2_name,rtrim(c3.员工姓名) as sczl_bh3_name,rtrim(c4.员工姓名) as sczl_bh4_name,rtrim(d.yj_yjmc) as yj_yjmc';
- $list = Db::name('db_机器检验')->alias('a')
- ->join('dic_lzde b','a.sczl_dedh = b.sys_bh','left')
- ->join('人事_基本资料 c1','a.sczl_bh1 = c1.员工编号','left')
- ->join('人事_基本资料 c2','a.sczl_bh2 = c2.员工编号','left')
- ->join('人事_基本资料 c3','a.sczl_bh3 = c3.员工编号','left')
- ->join('人事_基本资料 c4','a.sczl_bh4 = c4.员工编号','left')
- ->join('工单_印件资料 d','a.sczl_gdbh = d.Yj_Gdbh','left')
- ->where($where)
- ->where('SUBSTR(a.sczl_yjgx,1,2) = d.yj_yjno')
- ->field($field)->limit($limit)->page($pages)->order('a.sczl_rq asc,a.UniqId desc')->select();
- $option['sczl_单据类型'] = '初检单';
- $option['sys_rq'] = array('between time',[$date.' 00:00:00',$date.' 24:00:00']);
- $count = Db::name('db_机器检验')->where($option)->count();
- $data['data'] = $list;
- $data['total'] = $count;
- $this->success('请求成功',$data);
- }
- }
|