update
This commit is contained in:
parent
993e6cbe55
commit
18b1d9474c
|
@ -101,7 +101,14 @@
|
||||||
$item['detail'] = Db::name($this->actionDetailTableName)->where('action_id','in',$item['id'])->select();
|
$item['detail'] = Db::name($this->actionDetailTableName)->where('action_id','in',$item['id'])->select();
|
||||||
return $item;
|
return $item;
|
||||||
})->toArray();
|
})->toArray();
|
||||||
|
$count = Db::name($this->actionTableName)->where($where)->count();
|
||||||
|
$result = [
|
||||||
|
'count' => $count,
|
||||||
|
'page_no' => $pageNo,
|
||||||
|
'page_size'=>$pageSize,
|
||||||
|
'lists' => $data
|
||||||
|
];
|
||||||
//返回数据
|
//返回数据
|
||||||
return $this->success('请求成功',$data);
|
return $this->success('请求成功',$result);
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -0,0 +1,128 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace app\adminapi\controller\code;
|
||||||
|
|
||||||
|
use app\adminapi\controller\BaseAdminController;
|
||||||
|
use think\facade\Db;
|
||||||
|
use think\response\Json;
|
||||||
|
|
||||||
|
class CodeController extends BaseAdminController
|
||||||
|
{
|
||||||
|
public function lists(): Json
|
||||||
|
{
|
||||||
|
//type=>1-种植户 2-家禽养殖户 3-家畜养殖户 4-水产养殖户
|
||||||
|
$params = $this->request->get(['type','page_no','page_size']);
|
||||||
|
if(empty($params['type']) || !in_array($params['type'],[1,2,3,4])){
|
||||||
|
return $this->fail('参数错误');
|
||||||
|
}
|
||||||
|
//设置分页条件
|
||||||
|
$pageNo = empty($params['page_no']) || $params['page_no'] < 0 ? 1 : $params['page_no'];
|
||||||
|
$pageSize = empty($params['page_size']) || $params['page_size'] < 0 ? 10 : $params['page_size'];
|
||||||
|
switch ($params['type']) {
|
||||||
|
case 1:
|
||||||
|
$data = Db::name('farmer_land_crop')->field('id,user_id,source_code as code,crop_variety as kind,crop_brand as breed,ripe_time,seed_time as create_time')
|
||||||
|
->where('flag',1)->page($pageNo,$pageSize)->order('seed_time desc')->select()->each(function($item){
|
||||||
|
if(!empty($item['ripe_time'])){
|
||||||
|
$item['status'] = '已成熟';
|
||||||
|
}else{
|
||||||
|
$item['status'] = '生长中';
|
||||||
|
}
|
||||||
|
$item['create_time'] = date('Y-m-d H:i:s',$item['create_time']);
|
||||||
|
unset($item['ripe_time']);
|
||||||
|
return $item;
|
||||||
|
})->toArray();
|
||||||
|
$count = Db::name('farmer_land_crop')->field('id,')->where('flag',1)->count();
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
$data = Db::name('farmer_poultry_breed')->field('id,user_id,code,kind,breed,status,create_time')
|
||||||
|
->page($pageNo,$pageSize)->order('create_time desc')->select()->each(function($item){
|
||||||
|
//状态 1-健康 2-产蛋期 3-生病隔离 4-可出栏 5-已出栏
|
||||||
|
switch ($item['status']) {
|
||||||
|
case 1:
|
||||||
|
$item['status'] = '健康';
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
$item['status'] = '产蛋期';
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
$item['status'] = '生病隔离';
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
$item['status'] = '可出栏';
|
||||||
|
break;
|
||||||
|
case 5:
|
||||||
|
$item['status'] = '已出栏';
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
$item['create_time'] = date('Y-m-d H:i:s',$item['create_time']);
|
||||||
|
return $item;
|
||||||
|
})->toArray();
|
||||||
|
$count = Db::name('farmer_poultry_breed')->field('id,')->count();
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
$data = Db::name('farmer_animal_breed')->field('id,user_id,animal_code as code,animal_kind as kind,animal_breed as breed,animal_status as status,create_time')
|
||||||
|
->page($pageNo,$pageSize)->order('create_time desc')->select()->each(function($item){
|
||||||
|
//养殖动物状态 1-健康 2-怀孕中 3-生病隔离中 4-可出栏 5-已出栏
|
||||||
|
switch ($item['status']) {
|
||||||
|
case 1:
|
||||||
|
$item['status'] = '健康';
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
$item['status'] = '怀孕中';
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
$item['status'] = '生病隔离';
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
$item['status'] = '可出栏';
|
||||||
|
break;
|
||||||
|
case 5:
|
||||||
|
$item['status'] = '已出栏';
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
$item['create_time'] = date('Y-m-d H:i:s',$item['create_time']);
|
||||||
|
return $item;
|
||||||
|
})->toArray();
|
||||||
|
$count = Db::name('farmer_animal_breed')->field('id,')->count();
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
$data = Db::name('farmer_pond_breed')->field('id,user_id,source_code as code,kind,breed,create_time')
|
||||||
|
->page($pageNo,$pageSize)->order('create_time desc')->select()->each(function($item){
|
||||||
|
$item['status'] = '生长中';
|
||||||
|
$item['create_time'] = date('Y-m-d H:i:s',$item['create_time']);
|
||||||
|
return $item;
|
||||||
|
})->toArray();
|
||||||
|
$count = Db::name('farmer_pond_breed')->field('id,')->count();
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
$data = [];
|
||||||
|
$count = 0;
|
||||||
|
}
|
||||||
|
$url = env('project.worker_domain').'/api/information/farmerInfo';
|
||||||
|
foreach($data as $k=>$v) {
|
||||||
|
$farmer = curl_post($url,[],['user_id'=>$v['user_id']]);
|
||||||
|
if(!empty($farmer) && $farmer['code'] == 1){
|
||||||
|
$data[$k]['address'] = $farmer['data']['area_name'].$farmer['data']['street_name'].$farmer['data']['village_name'].$farmer['data']['brigade_name'].$farmer['data']['address'];
|
||||||
|
$data[$k]['captain_name'] = $farmer['data']['captain_name'];
|
||||||
|
$data[$k]['group_name'] = $farmer['data']['group_name'];
|
||||||
|
$data[$k]['farmer_name'] = $farmer['data']['name'];
|
||||||
|
}
|
||||||
|
$data[$k]['type'] = $params['type'];
|
||||||
|
}
|
||||||
|
$result = [
|
||||||
|
'count'=>$count,
|
||||||
|
'page_no' => $pageNo,
|
||||||
|
'page_size' => $pageSize,
|
||||||
|
'lists' => $data
|
||||||
|
];
|
||||||
|
return $this->success('请求成功',$result);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function detail() {
|
||||||
|
//type=>1-种植户 2-家禽养殖户 3-家畜养殖户 4-水产养殖户
|
||||||
|
$params = $this->request->get(['id','type']);
|
||||||
|
if(empty($params['id']) || empty($params['type']) || !in_array($params['type'],[1,2,3,4])){
|
||||||
|
return $this->fail('参数错误');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue