浏览代码

剩余车辆数据model

psto 2 年之前
父节点
当前提交
4c332f303a
共有 1 个文件被更改,包括 46 次插入2 次删除
  1. 46 2
      webmain/model/renjiazhuangModel.php

+ 46 - 2
webmain/model/renjiazhuangModel.php

@@ -9,7 +9,7 @@ class renjiazhuangClassModel extends Model
 	}
 
     // 车辆管理
-    public function getCarList() 
+    public function getCarList()
     {
         $data = $this->baseCarList();
         $arr = [];
@@ -27,8 +27,52 @@ class renjiazhuangClassModel extends Model
         return $rows;
     }
 
+    public function getCarCon() {
+        $sqlStr = 'SELECT car_type, count(1) all_con, count(case when car_state = "正常" then 1 end) free_con, ';
+        $sqlStr .= ' count(case when car_state = "装车" then 1 end) loading_con,';
+        $sqlStr .= ' count(case when car_state = "卸车" then 1 end) unload_con,';
+        $sqlStr .= ' count(case when car_state = "维修中" then 1 end) repair_con,';
+        $sqlStr .= ' count(case when car_state = "停用" then 1 end) stop_con';
+        $sqlStr .= ' FROM xinhu_rjz_car_list GROUP BY car_type';
+        $rows = $this->db->getall($sqlStr);
+        $data = [];
+        for($i = 0; $i < sizeof($rows); $i++) {
+            $j=0;
+            $data[$i]['car_type'] = $rows[$i]["car_type"];
+            $data[$i]['con'][$j]['title'] = "全部";
+            $data[$i]['con'][$j]['con'] = $rows[$i]["all_con"];
+            $data[$i]['con'][$j]['is_show'] = 1;
+            $data[$i]['con'][$j++]['order'] = 0;
 
-    public function getCarCon($cartype='') {
+            $data[$i]['con'][$j]['title'] = "空闲";
+            $data[$i]['con'][$j]['con'] = $rows[$i]["free_con"];
+            $data[$i]['con'][$j]['is_show'] = 1;
+            $data[$i]['con'][$j++]['order'] = 1;
+
+            $data[$i]['con'][$j]['title'] = "装车";
+            $data[$i]['con'][$j]['con'] = $rows[$i]["loading_con"];
+            $data[$i]['con'][$j]['is_show'] = 1;
+            $data[$i]['con'][$j++]['order'] = 2;
+
+            $data[$i]['con'][$j]['title'] = "卸车";
+            $data[$i]['con'][$j]['con'] = $rows[$i]["unload_con"];
+            $data[$i]['con'][$j]['is_show'] = 1;
+            $data[$i]['con'][$j++]['order'] = 3;
+
+            $data[$i]['con'][$j]['title'] = "维修";
+            $data[$i]['con'][$j]['con'] = $rows[$i]["repair_con"];
+            $data[$i]['con'][$j]['is_show'] = 1;
+            $data[$i]['con'][$j++]['order'] = 4;
+
+            $data[$i]['con'][$j]['title'] = "停用";
+            $data[$i]['con'][$j]['con'] = $rows[$i]["stop_con"];
+            $data[$i]['con'][$j]['is_show'] = 1;
+            $data[$i]['con'][$j++]['order'] = 5;
+        }
+        return $data;
+    }
+
+    public function getOneCarCon($cartype='') {
 
         if(strlen($cartype) > 0) {
             $where = " and car_type = '" . $cartype . "'";