<?php


namespace app\api\controller;

use think\Db;
use app\common\controller\Api;

/**
 * 数据存储
 */
class Data extends Api
{
    protected $noNeedLogin = ['*'];
    protected $noNeedRight = ['*'];

    /**
     * @ApiTitle    (产品移动轨迹记录)
     * @ApiSummary  (产品移动轨迹记录)
     * @ApiMethod   (POST)
     * @ApiRoute    (/api/Data/BatteryWhere)
     * @ApiParams   (name="cp_xulehao", type="string", required=true, description="产品序列号")
     * @ApiParams   (name="lng", type="string", required=true, description="经度")
     * @ApiParams   (name="lat", type="string", required=true, description="纬度")
     * @ApiReturnParams   (name="code", type="integer", required=true, sample="0")
     * @ApiReturnParams   (name="msg", type="string", required=true, sample="返回成功")
     * @ApiReturn   ({
    'code':'1',
    'msg':'返回成功',
    'data':{
    })
     */
    public function BatteryWhere()
    {
        $Params = $this->request->param();
        Db::name('gis')->insert(['cp_xulehao' => $Params['cp_xulehao'], 'lng' => $Params['lng'], 'lat' => $Params['lat'], 'createtime' => time()]);
        $this->success('成功', 1);
    }


    /**
     * @ApiTitle    (动态数据记录)
     * @ApiSummary  (动态数据记录)
     * @ApiMethod   (POST)
     * @ApiRoute    (/api/Data/DynamicData)
     * @ApiParams   (name="cp_xulehao", type="string", required=true, description="产品序列号")
     * @ApiParams   (name="yydt_jb", type="string", required=true, description="警报信息")
     * @ApiParams   (name="yydt_dqdl", type="string", required=true, description="当前电量")
     * @ApiParams   (name="yydt_gfbhcs", type="string", required=true, description="过放保护次数")
     * @ApiParams   (name="yydt_gfbcsj", type="string", required=true, description="过放保护时间")
     * @ApiParams   (name="yydt_ljxhcs", type="string", required=true, description="累计循环次数")
     * @ApiParams   (name="yydt_dqrl", type="string", required=true, description="当前容量")
     * @ApiParams   (name="yydt_zfdl", type="string", required=true, description="总放电量")
     * @ApiParams   (name="yydt_zcdl", type="string", required=true, description="总充电量")
     * @ApiParams   (name="yydt_pjdy", type="string", required=true, description="平均电压")
     * @ApiParams   (name="yydt_zgdtdy", type="string", required=true, description="最高单体电压")
     * @ApiParams   (name="yydt_zddtdy", type="string", required=true, description="最低单体电压")
     * @ApiParams   (name="yydt_dqzgwd", type="string", required=true, description="当前最高温度")
     * @ApiParams   (name="yydt_dqzdwd", type="string", required=true, description="当前最低温度")
     * @ApiReturnParams   (name="code", type="integer", required=true, sample="0")
     * @ApiReturnParams   (name="msg", type="string", required=true, sample="返回成功")
     * @ApiReturn   ({
    'code':'1',
    'msg':'返回成功',
    'data':{
    })
     */
    public function DynamicData()
    {
        $Params = $this->request->param();
        $data = [
            'cp_xulehao' => $Params['cp_xulehao'],
            'yydt_jb' => $Params['yydt_jb'],
            'yydt_dqdl' => $Params['yydt_dqdl'],
            'yydt_gfbhcs' => $Params['yydt_gfbhcs'],
            'yydt_gfbcsj' => $Params['yydt_gfbcsj'],
            'yydt_ljxhcs' => $Params['yydt_ljxhcs'],
            'yydt_dqrl' => $Params['yydt_dqrl'],
            'yydt_zfdl' => $Params['yydt_zfdl'],
            'yydt_zcdl' => $Params['yydt_zcdl'],
            'yydt_pjdy' => $Params['yydt_pjdy'],
            'yydt_zgdtdy' => $Params['yydt_zgdtdy'],
            'yydt_zddtdy' => $Params['yydt_zddtdy'],
            'yydt_dqzgwd' => $Params['yydt_dqzgwd'],
            'yydt_dqzdwd' => $Params['yydt_dqzdwd'],
            'createtime' => time()
        ];
        Db::name('yydtsjb')->insert($data);
        $this->success('成功', 1);
    }
}