添加Download页面
This commit is contained in:
parent
276a5c4047
commit
baa0efdc1f
|
|
@ -0,0 +1,15 @@
|
|||
<?php
|
||||
|
||||
namespace app\admin\controller;
|
||||
|
||||
use think\Controller;
|
||||
use think\Db;
|
||||
use app\bj\controller\Common;
|
||||
use think\Log;
|
||||
use \think\Validate;
|
||||
|
||||
class Download extends Controller{
|
||||
public function demo(){
|
||||
echo '你好';
|
||||
}
|
||||
}
|
||||
|
|
@ -24,18 +24,19 @@ class Skip extends Base{
|
|||
|
||||
// 查找设备
|
||||
// $data = ['device_code'=>'asdkljiouoi']
|
||||
public function device_check($data = ['device_code'=>'asdkljiouoi']){
|
||||
$data = input();
|
||||
public function skip_device_check($data = ['device_code'=>'asdkljiouoi']){
|
||||
// $data = input();
|
||||
$result = Db::query("
|
||||
select
|
||||
adcd.id,
|
||||
adcd.state as activation_state,
|
||||
add.state as device_state,
|
||||
adcd.bind_account_id as activation_state,
|
||||
adds.is_del as device_state
|
||||
from app_device_code_data as adcd
|
||||
left join app_device_data as add on add.id = adcd.add_id
|
||||
left join app_device_data as adds on adds.id = adcd.add_id
|
||||
where
|
||||
adcd.machine_code = '{$data['device_code']}'
|
||||
adcd.machine_code = '".$data['device_code']."'
|
||||
");
|
||||
|
||||
if(count($result) == 1){
|
||||
return $this->msg(0,'success',['device_state'=>$result[0]['device_state'],'activation_state'=>$result[0]['activation_state']]);
|
||||
}else if(count($result) < 1){
|
||||
|
|
@ -46,6 +47,88 @@ class Skip extends Base{
|
|||
}
|
||||
}
|
||||
|
||||
// 绑定设备
|
||||
public function skip_bind_device(){
|
||||
|
||||
}
|
||||
|
||||
// 今日数据
|
||||
public function skip_today_data($data = ['aud_id'=>11]){
|
||||
$result = Db::query("
|
||||
select
|
||||
jump_num,
|
||||
jump_time,
|
||||
jump_kcal,
|
||||
aud_id,
|
||||
CAST(GETDATE() AS DATE) as today_date
|
||||
from app_card_skip_data
|
||||
where
|
||||
CAST(record_time AS DATE) = CAST(GETDATE() AS DATE)
|
||||
and aud_id = ".$data['aud_id']."
|
||||
");
|
||||
|
||||
$return_data = ['jump_num'=>0,'jump_time'=>0,'jump_kcal'=>0];
|
||||
foreach ($result as $key => $value) {
|
||||
$return_data['jump_num'] = $value['jump_num']+$return_data['jump_num'];
|
||||
$return_data['jump_time'] = $value['jump_time']+$return_data['jump_time'];
|
||||
$return_data['jump_kcal'] = $value['jump_kcal']+$return_data['jump_kcal'];
|
||||
}
|
||||
|
||||
return $this->msg(0,'success',$return_data);
|
||||
}
|
||||
|
||||
// 数据记录
|
||||
public function skip_record_data($data = ['aud_id'=>11,'num'=>50,'time'=>60,'kcal'=>150,'record_time'=>'','jump_type'=>'free']){
|
||||
|
||||
if($data['record_time'] == ''){
|
||||
$data['record_time'] = date('Y-m-d H:i:s');
|
||||
}
|
||||
|
||||
$user_data = Db::table('app_card_skip_data')->insert([
|
||||
'create_time' => date('Y-m-d H:i:s'),
|
||||
'record_time' => $data['record_time'],
|
||||
'jump_num' => $data['num'],
|
||||
'jump_time' => $data['time'],
|
||||
'jump_kcal' => $data['kcal'],
|
||||
'aud_id' => $data['aud_id'],
|
||||
'acd_id' => 5,
|
||||
'jump_type' => $data['num']
|
||||
]);
|
||||
|
||||
if($user_data){
|
||||
return $this->msg(0,'success');
|
||||
}else {
|
||||
return $this->msg(10001,'数据记录失败');
|
||||
}
|
||||
}
|
||||
|
||||
// 运动曲线
|
||||
public function skip_motion_curve($data = ['aud_id'=>'','record_time'=>'','type'=>'year']){
|
||||
$time_data = '';
|
||||
if($data['type'] == 'year'){
|
||||
$time_data = date('Y-m',strtotime($data['record_time']));
|
||||
}else if($data['type'] == 'month'){
|
||||
$time_data = date('Y-m-d',strtotime($data['record_time']));
|
||||
}else if($data['type'] == 'day'){
|
||||
$time_data = date('Y-m-d H:i:s',strtotime($data['record_time']));
|
||||
}else{
|
||||
return $this->msg(10001,'type参数错误');
|
||||
}
|
||||
$user_data = Db::table('app_card_skip_data')->where([
|
||||
'CONVERT(varchar(10), record_time, 120)' => "",
|
||||
'jump_num' => $data['num'],
|
||||
'jump_time' => $data['time'],
|
||||
'jump_kcal' => $data['kcal'],
|
||||
'aud_id' => $data['aud_id'],
|
||||
'acd_id' => 5,
|
||||
'jump_type' => $data['num']
|
||||
]);
|
||||
|
||||
dump()
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -58,6 +141,54 @@ class Skip extends Base{
|
|||
################################################################other################################################################
|
||||
################################################################other################################################################
|
||||
|
||||
// 数据记录
|
||||
function generateRandomJumpData($n = 666) {
|
||||
$return_data = [];
|
||||
$startDate = new \DateTime('2022-01-01 00:00:00');
|
||||
$endDate = new \DateTime('2024-12-31 23:59:59');
|
||||
|
||||
// 为了保证在$startDate和$endDate之间随机生成日期,先确定两个日期之间的天数差
|
||||
$diff = $endDate->diff($startDate)->format('%a');
|
||||
|
||||
for ($i = 0; $i < $n; $i++) {
|
||||
// 生成随机日期
|
||||
$randomDateTime = $startDate->modify(sprintf('+%d seconds', rand(0, $endDate->getTimestamp() - $startDate->getTimestamp())))->format('Y-m-d H:i:s');
|
||||
// $randomDate = $startDate->modify(sprintf('+%d days', rand(0, $diff)))->format('Y-m-d');
|
||||
|
||||
// 生成随机jump_num
|
||||
$jump_num = rand(30, 70);
|
||||
|
||||
// 生成随机jump_time
|
||||
$jump_time = rand(60, 200);
|
||||
|
||||
// 生成随机jump_kcal
|
||||
$jump_kcal = rand(100, 400);
|
||||
|
||||
// 生成随机jump_type
|
||||
$jump_types = ['free', 'time', 'num'];
|
||||
$jump_type = $jump_types[array_rand($jump_types)];
|
||||
|
||||
// 固定的aud_id和acd_id
|
||||
$aud_id = 11;
|
||||
$acd_id = 5;
|
||||
|
||||
// 将生成的数据存入数组
|
||||
$return_data[] = [
|
||||
'create_time' => date('Y-m-d H:i:s'),
|
||||
'record_time' => $randomDateTime,
|
||||
'jump_num' => $jump_num,
|
||||
'jump_time' => $jump_time,
|
||||
'jump_kcal' => $jump_kcal,
|
||||
'aud_id' => $aud_id,
|
||||
'acd_id' => $acd_id,
|
||||
'jump_type' => $jump_type
|
||||
];
|
||||
}
|
||||
$user_data = Db::table('app_card_skip_data')->insertAll($return_data);
|
||||
dump($user_data);
|
||||
dump($return_data);
|
||||
die;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -87,7 +87,7 @@ return [
|
|||
// URL参数方式 0 按名称成对解析 1 按顺序解析
|
||||
'url_param_type' => 0,
|
||||
// 是否开启路由
|
||||
'url_route_on' => false,
|
||||
'url_route_on' => true,
|
||||
// 路由使用完整匹配
|
||||
'route_complete_match' => false,
|
||||
// 路由配置文件(支持配置多个)
|
||||
|
|
|
|||
Loading…
Reference in New Issue