Browse Source

空闲数量查找方式调整

psto 2 years atrás
parent
commit
4d228e63ee

+ 10 - 3
webmain/flow/input/inputjs/mode_rjz_car_apply.js

@@ -14,9 +14,12 @@ function initbodys() {
 
     var applyInfo = '';
     c.onselectdata['car_type'] = function (d) {
-        js.ajax(geturlact('getFreeCarCon'), {car_type: JSON.stringify(d)}, function (res) {
+        // 使用结束时间
+        var start_time = $("[name=end_time]").val();
+
+        js.ajax(geturlact('getFreeCarCon'), {car_type: JSON.stringify(d), start_time: start_time}, function (res) {
             var result = JSON.parse(res);
-            console.log(result);
+            // console.log(result);
             if (result.success) {
                 if (isMobile()) {
                     console.log(result.data);
@@ -109,6 +112,7 @@ function initbodys() {
             }
         }, 'get, json');
     }
+
     // $('input[name=apply_con]').change(function () {
     //     console.log($(this).val())
     //     $("input[name=apply_con]").each(function() {
@@ -118,6 +122,8 @@ function initbodys() {
     //     });
     //     form('apply_con_info').value = applyConInfo;
     // });
+
+
     if (isMobile()) {
         setTimeout(function() {
             $("#title_explain").text("调度说明");
@@ -525,4 +531,5 @@ function initbodys() {
     }
 
 
-}
+}
+

+ 3 - 1
webmain/flow/input/mode_rjz_car_applyAction.php

@@ -88,6 +88,7 @@ class mode_rjz_car_applyClassAction extends inputAction{
     // 获取空闲数量
 	public function getFreeCarConAjax() {
 		$carType = $this->get('car_type');
+        $applyStartTime = $this->get('start_time');
         if(isset($carType)) {
             $carTypeArr = [];
             $carType = json_decode($carType, true);
@@ -101,7 +102,8 @@ class mode_rjz_car_applyClassAction extends inputAction{
             }
             $carTypeStr = implode('",',$carTypeArr);
             $carTypeStr = str_replace(["[","]"],"",json_encode($carTypeArr, JSON_UNESCAPED_UNICODE));
-            $data = m('renjiazhuang')->getCarIdleCon($carTypeStr);
+            $data = m('renjiazhuang')->getCarIdleConByApplyStartTime($carTypeStr, $applyStartTime);
+//            $data = m('renjiazhuang')->getCarIdleCon($carTypeStr);
 
             return returnsuccess($data);
         } else {

+ 3 - 0
webmain/flow/page/input_rjz_car_apply.html

@@ -1,9 +1,12 @@
 <table width="100%" border="0" class="ke-zeroborder">
     <tbody>
+    <!--  车辆类型  -->
     <tr class="autoyijianview">
         <td height="34" width="15%" align="right" class="ys1">*^car_type^</td>
         <td width="35%" class="ys2" colspan="3">{car_type}{apply_con_json}</td>
     </tr>
+    <!--  申请数量  -->
+    <!--  车辆信息  -->
     <tr>
         <td height="34" align="right" class="ys1">*^apply_con_info^</td>
         <td colspan="3" class="ys2">{apply_con_info}</td>

+ 2 - 2
webmain/flow/page/input_rjz_car_list.html

@@ -9,8 +9,8 @@
     <tr>
         <td height="34" width="15%" align="right" class="ys1">*^car_type^</td>
         <td width="35%" class="ys2">{car_type}</td>
-        <td height="34" align="right" class="ys1"></td>
-        <td class="ys2"></td>
+        <td height="34" width="15%" align="right" class="ys1">^end_time^</td>
+        <td width="35%" class="ys2">{end_time}</td>
     </tr>
     <tr>
         <td height="34" align="right" class="ys1">^desc^</td>

File diff suppressed because it is too large
+ 1 - 1
webmain/flow/page/view_rjz_car_list_0.html


+ 18 - 1
webmain/model/renjiazhuangModel.php

@@ -97,7 +97,24 @@ class renjiazhuangClassModel extends Model
         $sqlStr .= ' where pid = 1146 '.$where;
         $sqlStr .= ' group by a.name';
         $rows = $this->db->getall($sqlStr);
-//        return $sqlStr;
+        return $rows;
+    }
+
+    public function getCarIdleConByApplyStartTime($car_types='', $apply_start_time = '') {
+        if(strlen($car_types) > 0) {
+            $where = " and car_type in (" . $car_types . ")";
+        }
+        # 申请使用时间大于前车空闲时间
+        if (strlen($apply_start_time) > 0) {
+            $free_where = " or (end_time <= '".$apply_start_time."' or end_time is null)";
+        }
+        $sqlStr = 'select a.name as car_type, count(b.id) car_con,';
+        $sqlStr .= ' count(case when car_state = "正常" '.$free_where.' then 1 end) car_free_con';
+        $sqlStr .= ' from xinhu_option a left join xinhu_rjz_car_list b on a.name = b.car_type';
+        $sqlStr .= ' where pid = 1146 '.$where;
+        $sqlStr .= ' group by a.name';
+        $rows = $this->db->getall($sqlStr);
+
         return $rows;
     }