| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110 |
- <?php
- namespace app\api\controller;
- use app\common\controller\Api;
- use think\Db;
- /** 首页接口*/
- class Index extends Api{
- protected $noNeedLogin = ['*'];
- protected $noNeedRight = ['*'];
- /** 首页 **/
- public function index(){$this->success('请求成功');}
- //甲类车间作业票列表
- public function jl_workshops(){
- $result = Db::table('mn_task')->alias('t')
- ->field('
- t.name,
- t.bach,
- t.machine,
- t.number,
- t.create,
- t.kuodan,
- CASE WHEN f.bach IS NULL THEN \'未投料\' ELSE \'已投料\' END AS fedding_status
- ')
- ->join('mn_feeding f','t.bach = f.bach','LEFT')
- ->where('t.machine', 'like', '%甲类%')
- ->where('t.create', '>=', date('Y-m-d', strtotime('-7 day')))
- ->where('t.create', '<=', date('Y-m-d'))
- ->order('t.create', 'desc')
- ->select();
- // echo "<pre>";print_r($result);echo "<pre>";die;
- // 获取数据列定义
- $list['columns'] = [
- ['name' => '配方名称', 'id' => 'name', 'width' => '30', 'autoWrap' => "true", 'textAlign' => 'left'],
- ['name' => '批次号', 'id' => 'bach', 'width' => '15', 'autoWrap' => "true", 'textAlign' => 'left'],
- ['name' => '机台', 'id' => 'machine', 'width' => '15', 'autoWrap' => "true", 'textAlign' => 'left'],
- ['name' => '生产量', 'id' => 'number', 'width' => '15', 'autoWrap' => "true", 'textAlign' => 'left'],
- ['name' => '扩单重量', 'id' => 'kuodan', 'width' => '15', 'autoWrap' => "true", 'textAlign' => 'left'],
- ['name' => '创建时间', 'id' => 'create', 'width' => '20', 'autoWrap' => "true", 'textAlign' => 'left'],
- ['name' => '是否投料', 'id' => 'fedding_status', 'width' => '14', 'autoWrap' => "true", 'textAlign' => 'left'],
- ];
- foreach ($result as $v) {
- $list['rows'][] = [
- 'name' => $v['name'],
- 'bach' => $v['bach'],
- 'machine' => $v['machine'],
- 'number' => $v['number'],
- 'kuodan' => $v['kuodan'],
- 'create' => $v['create'],
- 'fedding_status' => $v['fedding_status'],
- ];
- }
- $res['status'] = 0;
- $res['msg'] = '';
- $res['data'] = $list;
- return json($res);
- }
- //丙类车间作业票列表
- public function bl_workshops(){
- $result = Db::table('mn_task')->alias('t')
- ->field('
- t.name,
- t.bach,
- t.machine,
- t.number,
- t.create,
- t.kuodan,
- CASE WHEN f.bach IS NULL THEN \'未投料\' ELSE \'已投料\' END AS fedding_status
- ')
- ->join('mn_feeding f','t.bach = f.bach','LEFT')
- ->where('t.machine', 'like', '%丙类%')
- ->where('t.create', '>=', date('Y-m-d', strtotime('-7 day')))
- ->where('t.create', '<=', date('Y-m-d'))
- ->order('t.create', 'desc')
- ->select();
- // echo "<pre>";print_r($result);echo "<pre>";die;
- // 获取数据列定义
- $list['columns'] = [
- ['name' => '配方名称', 'id' => 'name', 'width' => '30', 'autoWrap' => "true", 'textAlign' => 'left'],
- ['name' => '批次号', 'id' => 'bach', 'width' => '15', 'autoWrap' => "true", 'textAlign' => 'left'],
- ['name' => '机台', 'id' => 'machine', 'width' => '15', 'autoWrap' => "true", 'textAlign' => 'left'],
- ['name' => '生产量', 'id' => 'number', 'width' => '15', 'autoWrap' => "true", 'textAlign' => 'left'],
- ['name' => '扩单重量', 'id' => 'kuodan', 'width' => '15', 'autoWrap' => "true", 'textAlign' => 'left'],
- ['name' => '创建时间', 'id' => 'create', 'width' => '20', 'autoWrap' => "true", 'textAlign' => 'left'],
- ['name' => '是否投料', 'id' => 'fedding_status', 'width' => '14', 'autoWrap' => "true", 'textAlign' => 'left'],
- ];
- foreach ($result as $v) {
- $list['rows'][] = [
- 'name' => $v['name'],
- 'bach' => $v['bach'],
- 'machine' => $v['machine'],
- 'number' => $v['number'],
- 'kuodan' => $v['kuodan'],
- 'create' => $v['create'],
- 'fedding_status' => $v['fedding_status'],
- ];
- }
- $res['status'] = 0;
- $res['msg'] = '';
- $res['data'] = $list;
- return json($res);
- }
-
- }
|