123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120 |
- <?php
- /**
- * Created by PhpStorm.
- * User: Mead
- * Date: 2019/9/4
- * Time: 9:36 AM
- */
- namespace App\Models;
- use App\Maps\WarningLogMap;
- trait WarningLogTraitModel
- {
- /**
- * 电量数据包
- * @param $bike_no
- * @param $box_no
- * @param $body
- * @param $source_body
- * @param $source
- * User: Mead
- */
- public function warningLogBatteryLow($bike_no, $box_no, $body, $source_body, $source)
- {
- $this->db->insert('warning_logs')->cols([
- 'bike_no' => $bike_no,
- 'box_no' => $box_no,
- 'body' => serialize($body),
- 'source_body' => implode(' ', $source_body),
- 'type' => WarningLogMap::TYPE_BATTERY_LOW,
- 'error_grade' => WarningLogMap::ERROR_GRADE_MAJOR,
- 'source' => $source,
- 'created_at' => date('Y-m-d H:i:s')
- ])->query();
- }
- /**
- * 车辆离线
- * @param $bike_no
- * @param $box_no
- * @param $body
- * @param $source_body
- * @param $source
- * User: Mead
- */
- public function warningLogBikeOffLine($bike_no, $box_no, $source)
- {
- $body = [];
- $source_body = [];
- $this->db->insert('warning_logs')->cols([
- 'bike_no' => $bike_no,
- 'box_no' => $box_no,
- 'body' => serialize($body),
- 'source_body' => implode(' ', $source_body),
- 'type' => WarningLogMap::TYPE_BIKE_OFF_LINE,
- 'error_grade' => WarningLogMap::ERROR_GRADE_CRITICAL,
- 'source' => $source,
- 'created_at' => date('Y-m-d H:i:s')
- ])->query();
- }
- public static function warningLogBikeOffLineStatic($bike_no, $box_no, $source)
- {
- $body = [];
- $source_body = [];
- self::$db->insert('warning_logs')->cols([
- 'bike_no' => $bike_no,
- 'box_no' => $box_no,
- 'body' => serialize($body),
- 'source_body' => implode(' ', $source_body),
- 'type' => WarningLogMap::TYPE_BIKE_OFF_LINE,
- 'error_grade' => WarningLogMap::ERROR_GRADE_CRITICAL,
- 'source' => $source,
- 'created_at' => date('Y-m-d H:i:s')
- ])->query();
- }
- /**
- * 警告数据包
- * @param $bike_no
- * @param $box_no
- * @param $body
- * @param $source_body
- * @param $type
- * @param $error_grade
- * User: Mead
- */
- public function warningLog($bike_no, $box_no, $body, $source_body, $type, $error_grade)
- {
- $this->db->insert('warning_logs')->cols([
- 'bike_no' => $bike_no,
- 'box_no' => $box_no,
- 'body' => serialize($body),
- 'source_body' => implode(' ', $source_body),
- 'type' => $type,
- 'error_grade' => $error_grade,
- 'source' => 'warning',
- 'created_at' => date('Y-m-d H:i:s')
- ])->query();
- }
- public function warningFF($bike_no, $box_no, $body, $source_body)
- {
- $this->db->insert('warning_logs')->cols([
- 'bike_no' => $bike_no,
- 'box_no' => $box_no,
- 'body' => serialize($body),
- 'source_body' => implode(' ', $source_body),
- 'type' => WarningLogMap::TYPE_WARNING_BIKE_OPEN,
- 'error_grade' => WarningLogMap::ERROR_GRADE_MAJOR,
- 'source' => 'warning',
- 'created_at' => date('Y-m-d H:i:s')
- ])->query();
- }
- }
|