Browse Source

机台日报表切换显示方式

曹鹤洋 1 year ago
parent
commit
1ab4bf6a3f
1 changed files with 22 additions and 13 deletions
  1. 22 13
      application/api/controller/MachineProductionReport.php

+ 22 - 13
application/api/controller/MachineProductionReport.php

@@ -44,7 +44,17 @@ class MachineProductionReport extends Api
             ->order('UniqId desc')
             ->limit(40)
             ->column('LEFT(sys_rq, 10) as date, COUNT(*) as counts');
-
+//        $sql = 'SELECT date, COUNT(*) as counts
+//FROM (
+//    SELECT LEFT(sys_rq, 10) as date FROM db_sczl
+//    UNION ALL
+//    SELECT LEFT(sys_rq, 10) as date FROM 设备_产量计酬
+//) AS t1
+//GROUP BY date
+//ORDER BY date DESC
+//LIMIT 30';
+//        $rows = db()->query($sql);
+//halt($rows);
         $arr2 = db('设备_产量计酬')->cache(true,300)
             ->field('LEFT(sys_rq, 10) as date, rtrim(sys_id) as sys_id, COUNT(sys_id) as count')
             ->where('sys_rq','>=',$rows[29]['date'])
@@ -121,23 +131,22 @@ class MachineProductionReport extends Api
         }
 
         $sql = 'SELECT t1.`sczl_gdbh`,t2.`yj_yjmc`
-            FROM (
-                SELECT `sczl_gdbh`, sczl_yjno FROM `db_sczl`
-                UNION
-                SELECT `sczl_gdbh`, sczl_yjno FROM `设备_产量计酬`
-                GROUP BY `sczl_gdbh`
-            ) AS t1
-            JOIN `工单_印件资料` AS t2 ON t1.`sczl_gdbh` = t2.`Yj_Gdbh`
-            WHERE t1.sczl_yjno = t2.yj_Yjno
-            ORDER BY t1.`sczl_gdbh` DESC
-            LIMIT 65';
+        FROM (
+            SELECT DISTINCT `sczl_gdbh`, sczl_yjno FROM `db_sczl`
+            UNION
+            SELECT  DISTINCT `sczl_gdbh`, sczl_yjno FROM `设备_产量计酬` where sys_rq >"2023-01-01"
+        ) AS t1
+        JOIN `工单_印件资料` AS t2 ON t1.`sczl_gdbh` = t2.`Yj_Gdbh`
+        WHERE t1.sczl_yjno = t2.yj_Yjno
+        ORDER BY t1.`sczl_gdbh` DESC
+        LIMIT 65';
         $rows = db()->query($sql);
-        $arr1 = db('设备_产量计酬')->cache(true,300)
+        $arr1 = db('设备_产量计酬')->cache(true,3600)
             ->field('sczl_gdbh,rtrim(sys_id) as sys_id')
             ->where('sczl_gdbh','>=',$rows[64]['sczl_gdbh'])
             ->select();
 
-        $arr2 = db('db_sczl')->cache(true,300)
+        $arr2 = db('db_sczl')->cache(true,3600)
             ->field('sczl_gdbh,rtrim(sys_id) as sys_id')
             ->where('sczl_gdbh','>=',$rows[64]['sczl_gdbh'])
             ->select();