| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143 |
- <?php
- namespace app\api\controller;
- use app\common\controller\Api;
- /**
- * 机台生产日报表维护附加接口
- */
- class MachineProductionReportAdd 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_sczladd')
- ->field('LEFT(sys_rq, 10) as date, COUNT(*) as counts')
- ->group('date')
- ->order('UniqId desc')
- ->limit(60)
- ->select();
- $arr = db()->table('db_sczladd')
- ->field('LEFT(sys_rq, 10) as date, rtrim(sys_id) as sys_id, COUNT(sys_id) as count')
- ->where('sys_rq','>=',$rows[59]['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_sczladd')
- ->field('LEFT(sczl_rq, 10) as sczl_rq, sczl_jtbh,
- sczl_bzdh, CAST(sczl_设备运行工时 AS SIGNED) as sczl_设备运行工时, sczl_desc,
- rtrim(sys_id) as sys_id, sys_rq, mod_rq, UniqId')
- ->where($where)
- ->order('UniqId desc')
- ->page($page,$limit)
- ->select();
- $total = db()->table('db_sczladd')->where($where)->count();
- $sb = db()->table('设备_基本资料')->column('设备编号, 设备名称');
- foreach ($rows as $key=>$value){
- $rows[$key]['mod_rq'] = $value['mod_rq']=='1900-01-01 00:00:00' ? '' :$value['mod_rq'];
- $rows[$key]['sczl_sbmc'] = trim($sb[$value['sczl_jtbh']]);
- $rows[$key]['sczl_设备运行工时'] = $value['sczl_设备运行工时'] == 0 ? '' : $value['sczl_设备运行工时'];
- }
- $data = [
- 'total' => $total,
- '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_sczl')->alias('d')
- ->field('d.*, ')
- ->join('工单_基本资料 g', 'd.')
- ->where('d.UniqId',$UniqId)
- ->select();
- $this->success('成功',$rows);
- }
- }
|