|
- <?php
-
- namespace backend\modules\api\models;
-
- use yii\db\ActiveRecord;
-
- /**
- * This is the model class for table "base_bus".
- *
- * @property integer $BUS_ID
- * @property integer $CREATE_USER_ID
- * @property string $CREATE_TIME
- * @property integer $UPDATE_USER_ID
- * @property string $UPDATE_TIME
- * @property integer $CANCEL_FLAG
- * @property string $BUS_NO
- * @property integer $BUS_TYPE_RES_ID
- * @property integer $BRAND_ID
- * @property integer $MAIN_CORP_ID
- * @property integer $ORG_ID
- * @property string $SEAT_DESC
- * @property string $BUY_DATE
- * @property string $BUS_LICENSE
- * @property integer $SEAT_COUNT
- * @property string $DRIVER_COUNT
- * @property string $TOUR_COUNT
- * @property string $EXTRA_COUNT
- * @property string $MPG
- * @property string $COST
- * @property integer $BUS_STATE
- * @property integer $SEAT_TYPE
- * @property integer $BUS_COLOR
- * @property string $BUS_IMG_PATH
- * @property string $BUS_IMG_TYPE
- * @property string $REGISTER_TIME
- * @property string $BUS_IMG_PATH_ORI
- * @property integer $FUEL_FORM
- * @property string $OIL_PRICE
- *
- * @property BusOrder[] $busOrders
- */
- class BaseBus extends ActiveRecord
- {
- /**
- * @inheritdoc
- */
- public static function tableName()
- {
- return 'base_bus';
- }
-
- /**
- * @inheritdoc
- */
- public function rules()
- {
- return [
- [['CREATE_USER_ID', 'UPDATE_USER_ID', 'CANCEL_FLAG', 'BUS_TYPE_RES_ID','SEAT_MATRIX_ID', 'BRAND_ID', 'MAIN_CORP_ID', 'ORG_ID', 'SEAT_COUNT', 'BUS_STATE', 'SEAT_TYPE', 'BUS_COLOR', 'FUEL_FORM'], 'integer'],
- [['UPDATE_TIME'], 'safe'],
- [['BUS_NO', 'REGISTER_TIME', 'FUEL_FORM'], 'required'],
- [['OIL_PRICE'], 'number'],
- [['CREATE_TIME', 'BUS_NO', 'BUY_DATE', 'REGISTER_TIME'], 'string', 'max' => 20],
- [['SEAT_DESC', 'BUS_LICENSE'], 'string', 'max' => 50],
- [['DRIVER_COUNT', 'TOUR_COUNT', 'MPG', 'COST'], 'string', 'max' => 10],
- [['EXTRA_COUNT'], 'string', 'max' => 11],
- [['BUS_IMG_PATH', 'BUS_IMG_PATH_ORI'], 'string', 'max' => 1024],
- [['BUS_IMG_TYPE'], 'string', 'max' => 64],
- ];
- }
-
- /**
- * @inheritdoc
- */
- public function attributeLabels()
- {
- return [
- 'BUS_ID' => 'Bus ID',
- 'CREATE_USER_ID' => '记录创建用户ID',
- 'CREATE_TIME' => '记录创建时间',
- 'UPDATE_USER_ID' => '记录最后更新用户ID',
- 'UPDATE_TIME' => '记录最后更新时间',
- 'CANCEL_FLAG' => '记录有效性标记,CANCEL_FLAG=0记录有效;CANCEL_FLAG=1,记录已删除',
- 'BUS_NO' => '车牌号',
- 'BUS_TYPE_RES_ID' => '车型',
- 'SEAT_MATRIX_ID' => '新版座位图ID',
- 'BRAND_ID' => '品牌ID',
- 'MAIN_CORP_ID' => '运营主体ID',
- 'ORG_ID' => '所属公司ID',
- 'SEAT_DESC' => '座位描述',
- 'BUY_DATE' => '购置日期',
- 'BUS_LICENSE' => '型号',
- 'SEAT_COUNT' => ' 座位数',
- 'DRIVER_COUNT' => ' 司机座位数',
- 'TOUR_COUNT' => '导游座位数',
- 'EXTRA_COUNT' => '辅座数',
- 'MPG' => '油耗',
- 'COST' => ' 固定成本,单位元/天',
- 'BUS_STATE' => '车辆状态',
- 'SEAT_TYPE' => '座位类型',
- 'BUS_COLOR' => 'Bus Color',
- 'BUS_IMG_PATH' => '图片路径(cs1) 对应的图片类型为BUS_IMG_TYPE里相应数字',
- 'BUS_IMG_TYPE' => '图片对应的类型,dict_type 360',
- 'REGISTER_TIME' => '注册登记日期',
- 'BUS_IMG_PATH_ORI' => '图片路径 对应的图片类型为BUS_IMG_TYPE里相应数字',
- 'FUEL_FORM' => '燃料形式 對應dict_type',
- 'OIL_PRICE' => '油价 元/升',
- ];
- }
-
- /**
- * @return \yii\db\ActiveQuery
- */
- public function getBusOrders()
- {
- return $this->hasMany(BusOrder::className(), ['send_bus_res_id' => 'BUS_ID']);
- }
-
- /**
- * Function Description:通过车牌号获取蓝牙地址
- * Function Name: getAddressByBusNo
- * @param string $bus_no 车牌号
- *
- * @return array|\yii\db\ActiveRecord[]
- *
- * @author 张帅
- */
- public function getAddressByBusNo($bus_no)
- {
- $address = self::find()
- ->select([
- 'res_id'=>'bus_id',
- 'blueToothAddress' => 'SCANNER_ID'//地址
- ])
- ->from(self::tableName())
- ->where([
- 'and',
- ['=', 'bus_no', $bus_no],
- ['=', 'cancel_flag', 0],
- ])
- ->asArray()->all();
-
- return $address;
- }
- }
|