Browse Source

大屏api接口

liuhairui 1 year ago
parent
commit
11b43b3b0d
3 changed files with 111 additions and 14 deletions
  1. 10 0
      .idea/sshConfigs.xml
  2. 2 2
      application/admin/view/task/show.html
  3. 99 12
      application/api/controller/Index.php

+ 10 - 0
.idea/sshConfigs.xml

@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="SshConfigs">
+    <configs>
+      <sshConfig authType="PASSWORD" connectionConfig="{&quot;serverAliveInterval&quot;:300}" host="8.142.28.209" id="01903b68-058c-45a7-b471-df06633c2d5d" port="22" customName="minnong" nameFormat="CUSTOM">
+        <option name="customName" value="minnong" />
+      </sshConfig>
+    </configs>
+  </component>
+</project>

+ 2 - 2
application/admin/view/task/show.html

@@ -162,7 +162,7 @@
                     {/foreach}
                     <tr>
                         <td style="width: 100px;text-align: center">总计</td>
-                        <td class="total" style="width: 100px;text-align: center">{$task.number + $task.kuodan}</td>
+                        <td class="total" style="width: 100px;text-align: center">{isset($task.kuodan) ? $task.number + $task.kuodan : $task.number}</td>
                         <td></td>
                         <td></td>
                     </tr>
@@ -240,4 +240,4 @@
             });
         }
     });
-</script>
+</script>

+ 99 - 12
application/api/controller/Index.php

@@ -3,21 +3,108 @@
 namespace app\api\controller;
 
 use app\common\controller\Api;
+use think\Db;
 
-/**
- * 首页接口
- */
-class Index extends Api
-{
+/** 首页接口*/
+class Index extends Api{
     protected $noNeedLogin = ['*'];
     protected $noNeedRight = ['*'];
 
-    /**
-     * 首页
-     *
-     */
-    public function index()
-    {
-        $this->success('请求成功');
+    /** 首页 **/
+    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);
     }
+    
 }