# 1. 同步数据

## OpenAPI Specification

```yaml
openapi: 3.0.1
info:
  title: ''
  description: ''
  version: 1.0.0
paths:
  /app_clientv1.Report/synchronization:
    post:
      summary: 1. 同步数据
      deprecated: false
      description: >-
        主动拉取数据，每同步一次数据，园区心跳监测刷新一次


        其实 `park_only_code`（必传基础参数） 就已经包含 园区id `smartpark_id` 了


        > `current_version` 为 数据行时间版本(时间戳)，这是表数据同步 的关键，类似 mysql 主从同步的 偏移点，设备端每次
        记录当前返回批次数据中最大的 那个值就行，下次同步传入，这样没有新数据时，同步接口就不会返回数据。关于同步机制的设计详见：[数据同步设计 ·
        智能停车收费管理系统API文档 ·
        看云](https://www.kancloud.cn/zuomingsheng/parkinglot/2326077)


        >[tip] **对于增量同步机制：请始终针对表使用一种同步条件，如 固定好是否传入 停车场id，不能
        一会传一会不传，这样会破坏数据同步的机制，造成漏数据等情况。**
      tags:
        - client 停车场设备端 📟/v1/Report
        - client
      parameters:
        - name: X-Client
          in: header
          description: ''
          required: true
          example: '{{x_client}}'
          schema:
            type: string
        - name: X-ApifoxUser
          in: header
          description: ''
          required: true
          example: '{{apifox_user}}'
          schema:
            type: string
        - name: X-Time
          in: header
          description: ''
          required: true
          example: '{{timestamp}}'
          schema:
            type: string
      requestBody:
        content:
          multipart/form-data:
            schema:
              type: object
              properties:
                parkinglot_id:
                  description: 停车场id，传入返回指定停车场数据，不传返回园区下表所有数据
                  example: 0
                  type: integer
                tbs[0][current_version]:
                  description: 要同步的表信息
                  example: ''
                  type: array
                tbs[0][table_name]:
                  example: t_parkinglot
                  type: string
              required:
                - tbs[0][current_version]
                - tbs[0][table_name]
      responses:
        '200':
          description: ''
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    x-apifox-orders: []
                  msg:
                    type: string
                  code:
                    type: integer
                required:
                  - data
                  - msg
                  - code
                x-apifox-orders:
                  - data
                  - msg
                  - code
              examples:
                '1':
                  summary: success
                  value: |-
                    {
                        "data": {
                            "id": 1,
                            "parkinglot_id": 0,
                            "version": "v1.0.0",
                            "data": [
                                {
                                    "table_name": "t_xxx",
                                    "data": [
                                        {...},
                                        ...
                                    ]
                                },
                                ...
                            ]
                        },
                        "msg": "",
                        "code": 1
                    }
                '2':
                  summary: error
                  value:
                    data: {}
                    msg: err msg
                    code: 0
                '3':
                  summary: tbs 字段格式实例
                  value:
                    - current_version: 0
                      table_name: t_parkinglot
                    - current_version: 0
                      table_name: t_passageway
                    - current_version: 0
                      table_name: t_parking
                    - current_version: 0
                      table_name: t_device
                    - current_version: 0
                      table_name: t_gateway
                    - current_version: 0
                      table_name: t_blackcar
                    - current_version: 0
                      table_name: t_fixcar
                    - current_version: 0
                      table_name: t_fee_rule
                    - current_version: 0
                      table_name: t_consume_orders
                    - current_version: 0
                      table_name: t_operation_log
                    - current_version: 0
                      table_name: t_del_msg_queue
          headers: {}
          x-apifox-name: ok
      security: []
      x-apifox-folder: client 停车场设备端 📟/v1/Report
      x-apifox-status: developing
      x-run-in-apifox: https://app.apifox.com/web/project/2493394/apis/api-70863833-run
components:
  schemas: {}
  securitySchemes: {}
servers:
  - url: http://admin.api.test.domain.cn
    description: 测试环境
security: []

```
