YS:接口更改

master
yangsai@163.com 7 months ago
parent 9b37879070
commit ec5c1db884
  1. 1
      application/controllers/Api/Basicinfo.php
  2. 43
      application/controllers/Api/Cage.php
  3. 28
      application/controllers/Api/Squirrel.php
  4. 32
      application/controllers/Api/Sysset.php
  5. 4
      application/models/Cage.php
  6. 5
      application/models/CageSet.php
  7. 15
      application/models/Cagecolor.php
  8. 52
      application/models/ExcelSet.php
  9. 41
      application/models/Squirrel.php
  10. 24
      application/models/SquirrelSet.php

@ -10,6 +10,7 @@ class Api_BasicinfoController extends Ctrl_Api{
public $GeneModel;
public $GroupModel;
public function init(){
if(empty($_SESSION['uid'])) {Tool_Fnc::apiMsg('非法调用', '500');}
$this->StrainsModel=new StrainsModel();
$this->GeneModel=new GeneModel();
$this->GroupModel=new GroupModel();

@ -7,8 +7,11 @@
*/
class Api_CageController extends Ctrl_Api{
public $Cagemodel;
public $Cagecolormodel;
public function init() {
if(empty($_SESSION['uid'])) {Tool_Fnc::apiMsg('非法调用', '500');}
$this->Cagemodel = new CageModel();
$this->Cagecolormodel = new CagecolorModel();
}
/**
* 鼠笼列表接口
@ -52,18 +55,7 @@ class Api_CageController extends Ctrl_Api{
* {
* "errorcode": "200",
* "message": "添加成功",
* "data": {
* "username": "用户名",
* "type": "1",用户类型
* "realname": "真实姓名",
* "faculties": "1",院系
* "specialized": "1",专业
* "group": "1",课题组
* "teacher": "1",导师
* "phone": "13566987478",手机号
* "status": "1",审核状态
* "is_delete": "0"是否删除
* }
* "data": []
* }
*/
public function addAction(){
@ -88,5 +80,32 @@ class Api_CageController extends Ctrl_Api{
public function edidAction(){
}
/**
* 获取笼位号
*/
public function getCagenumAction(){
$CageNum = $this->Cagemodel->field('count(*) as num')->where("user_id={$_SESSION['uid']}")->fRow();
$CageNum = empty($CageNum)?1:(int) $CageNum['num']+1;
$data['number'] = "NO.0000".$CageNum;
if($CageNum>9) $data['number'] = "NO.000".$CageNum;
if($CageNum>99) $data['number'] = "NO.00".$CageNum;
if($CageNum>999) $data['number'] = "NO.0".$CageNum;
Tool_Fnc::apiMsg('获取笼位号成功', '200',$data);
}
/**
* 获取笼位类型接口
*/
public function getCagetypeAction(){
$data = [1=>'库存笼',2=>'繁殖笼'];
Tool_Fnc::apiMsg('获取笼位类型成功', '200',$data);
}
/**
* 获取笼位颜色接口
*/
public function getCagecolorAction(){
$params['field'] = 'color';
$data = $this->Cagecolormodel->getModelList($params);
Tool_Fnc::apiMsg('获取成功', '200',$data);
}
}

@ -7,8 +7,17 @@
*/
class Api_SquirrelController extends Ctrl_Api{
public $Squirrelmodel;
public $CageModel;
public $CageSetModel;
public $SquirrelSetModel;
public $ExcelSetModel;
public function init() {
if(empty($_SESSION['uid'])) {Tool_Fnc::apiMsg('非法调用', '500');}
$this->Squirrelmodel = new SquirrelModel();
$this->CageModel = new CageModel();
$this->CageSetModel=new CageSetModel();
$this->SquirrelSetModel=new SquirrelSetModel();
$this->ExcelSetModel=new ExcelSetModel();
}
/**
* 鼠笼列表接口
@ -34,7 +43,12 @@ class Api_SquirrelController extends Ctrl_Api{
* }
*/
public function listAction(){
$cage = empty($_POST['cage_id'])||!isset($_POST['cage_id'])?Tool_Fnc::apiMsg('缺少重要参数', '500'):Tool_Fnc::safe_string($_POST['cage_id']);
$type = empty($_POST['type'])||!isset($_POST['type'])?1:Tool_Fnc::safe_string($_POST['type']);
$params['where'] = "and cage = {$cage}";
$params['type'] =$type;
$data = $this->Squirrelmodel->getModelList($params);
Tool_Fnc::apiMsg('获取成功', '200',$data);
}
/**
* 小鼠添加接口
@ -68,6 +82,7 @@ class Api_SquirrelController extends Ctrl_Api{
//查询笼位号
$CageNum = $this->Squirrelmodel->field('count(*) as num')->fRow();
$CageNum = empty($CageNum)?1:(int) $CageNum['num']+1;
$data['type'] = $_POST['type'];
$data['number'] = "SN00000".$CageNum;
if($CageNum>9) $data['number'] = "SN0000".$CageNum;
@ -85,6 +100,17 @@ class Api_SquirrelController extends Ctrl_Api{
$data['cage'] =empty($_POST['cage'])||!isset($_POST['cage'])?Tool_Fnc::apiMsg('未找到当前笼位ID', '500'):Tool_Fnc::safe_string($_POST['cage']);
$data['created'] = date('Y-m-d H:i:s',time());
$data['c_user_id'] = $_SESSION['uid'];
//判断鼠笼鼠的数量是否可以容纳
if(!$this->Squirrelmodel->isFull($data['cage'])) Tool_Fnc::apiMsg('当前笼位已满,请重新选择笼位添加', '500');
//获取当前用户仓鼠的配置
$params['user_id'] = $_SESSION['uid'];
$squirrelSet = $this->SquirrelSetModel->getsetinfo($params);
//根据生日获取各个提醒时间
$data['weaning_time'] = date("Y-m-d",strtotime("+{$squirrelSet['weaning_time']} day",strtotime($data['birthday'])));
$data['nursing_time'] = date("Y-m-d",strtotime("+{$squirrelSet['nursing_time']} day",strtotime($data['birthday'])));
$data['grow_time'] =$data['sex']==1? date("Y-m-d",strtotime("+{$squirrelSet['male_grow_time']} days",strtotime($data['birthday']))):date("Y-m-d",strtotime("+{$squirrelSet['female_grow_time']} days",strtotime($data['birthday'])));
$data['infertility_time'] = date("Y-m-d",strtotime("+{$squirrelSet['infertility_time']} month",strtotime($data['birthday'])));
$data['dose_time'] = date("Y-m-d",strtotime("+{$squirrelSet['dose_time']} day",strtotime($data['birthday'])));
$ret = $this->Squirrelmodel->insert($data);
if(!$ret) Tool_Fnc::apiMsg('小鼠建档失败', '500');
Tool_Fnc::apiMsg('小鼠建档成功', '200');

@ -0,0 +1,32 @@
<?php
/**
* 获取设置接口
* @author YS
* @version 1.0
*/
class Api_SyssetController extends Ctrl_Api{
public $CageSetModel;
public $SquirrelSetModel;
public $ExcelSetModel;
public function init(){
if(empty($_SESSION['uid'])) {Tool_Fnc::apiMsg('非法调用', '500');}
$this->CageSetModel=new CageSetModel();
$this->SquirrelSetModel=new SquirrelSetModel();
$this->ExcelSetModel=new ExcelSetModel();
}
/**
* 获取设置接口
*/
public function getSetInfoAction(){
$params['user_id'] = $_SESSION['uid'];
//笼位设置
$data['cageSet'] = $this->CageSetModel->getsetinfo($params);
//鼠设置
$data['squirrelSet'] = $this->SquirrelSetModel->getsetinfo($params);
//excel导出设置
$data['excelSet'] = $this->ExcelSetModel->getsetinfo($params);
Tool_Fnc::apiMsg('获取成功', '200',$data);
}
}

@ -51,5 +51,9 @@ class CageModel extends Orm_Base{
$data['page'] = $params['page'];
return $data;
}
public function getOneInfo($id){
$info = $this->field('*')->where("id='{$id}'")->fRow();
return $info;
}
}

@ -14,6 +14,9 @@ class CageSetModel extends Orm_Base{
'c_user_id' => array('type' => "int(11)",'comment' => '是否删除'),
);
public $pk = 'id';
public function getsetinfo($params){
$data = $this->field('*')->where('c_user_id='.$params['user_id'])->fRow();
return $data;
}
}

@ -0,0 +1,15 @@
<?php
class CagecolorModel extends Orm_Base{
public $table = 'cage_color';
public $field = array(
'id' => array('type' => "int(11)",'comment' => ''),
'color' => array('type' => "varchar(45)",'comment' => '颜色编码'),
'is_delete' => array('type' => "varchar(45)",'comment' => '是否删除'),
'created' => array('type' => "int(11)",'comment' => '添加时间'),
);
public $pk = 'id';
public function getModelList($params){
return $this->field("{$params['field']}")->where('is_delete=0')->fList();
}
}

@ -0,0 +1,52 @@
<?php
class ExcelSetModel extends Orm_Base{
public $table = 'excel_set';
public $field = array(
'id' => array('type' => "int(11)",'comment' => 'excel设置id'),
'now_squirrel' => array('type' => "varchar(45)",'comment' => '现存鼠导出设置'),
'handle_squirrel' => array('type' => "varchar(45)",'comment' => '处理鼠导出设置'),
'user_id' => array('type' => "int(11)",'comment' => '是否删除'),
);
public $pk = 'id';
public function getsetinfo($params){
$data = $this->field('*')->where('='.$params['user_id'])->fRow();
if(empty($data)){
//现存鼠
$data['now_squirrel']['number'] = true;
$data['now_squirrel']['sex'] = true;
$data['now_squirrel']['birthday'] = true;
$data['now_squirrel']['strains_id'] = true;
$data['now_squirrel']['gene'] = true;
$data['now_squirrel']['cage_num'] = true;
$data['now_squirrel']['content'] = true;
$data['now_squirrel']['hair_color'] = true;
$data['now_squirrel']['fenlong'] = true;
$data['now_squirrel']['fanzhi'] = true;
$data['now_squirrel']['breeding_tag'] = true;
$data['now_squirrel']['see_bole_tag'] = true;
$data['now_squirrel']['give_medicine'] = true;
$data['now_squirrel']['father'] = true;
$data['now_squirrel']['mother'] = true;
$data['now_squirrel']['remark'] = true;
//处理鼠
$data['handle_squirrel']['number'] = true;
$data['handle_squirrel']['sex'] = true;
$data['handle_squirrel']['birthday'] = true;
$data['handle_squirrel']['strains_id'] = true;
$data['handle_squirrel']['gene'] = true;
$data['handle_squirrel']['cage_num'] = true;
$data['handle_squirrel']['content'] = true;
$data['handle_squirrel']['hair_color'] = true;
$data['handle_squirrel']['fenlong'] = true;
$data['handle_squirrel']['fanzhi'] = true;
$data['handle_squirrel']['breeding_tag'] = true;
$data['handle_squirrel']['see_bole_tag'] = true;
$data['handle_squirrel']['give_medicine'] = true;
$data['handle_squirrel']['father'] = true;
$data['handle_squirrel']['mother'] = true;
$data['handle_squirrel']['remark'] = true;
}
return $data;
}
}

@ -18,10 +18,47 @@ class SquirrelModel extends Orm_Base{
'type' => array('type' => "varchar(255)",'comment' => '是否为新生小鼠'),
'created' => array('type' => "varchar(255)",'comment' => '是否为新生小鼠'),
'c_user_id' => array('type' => "varchar(255)",'comment' => '是否为新生小鼠'),
'weaning_time' => array('type' => "varchar(255)",'comment' => '是否为新生小鼠'),
'nursing_time' => array('type' => "varchar(255)",'comment' => '是否为新生小鼠'),
'grow_time' => array('type' => "varchar(255)",'comment' => '是否为新生小鼠'),
'infertility_time' => array('type' => "varchar(255)",'comment' => '是否为新生小鼠'),
'dose_time' => array('type' => "varchar(255)",'comment' => '是否为新生小鼠'),
'jianwei_time' => array('type' => "varchar(255)",'comment' => '是否为新生小鼠'),
'test_time' => array('type' => "varchar(255)",'comment' => '是否为新生小鼠'),
'kill_time' => array('type' => "varchar(255)",'comment' => '是否为新生小鼠'),
'del_time' => array('type' => "varchar(255)",'comment' => '是否为新生小鼠'),
);
public $pk = 'id';
public function getModelList(){
public function getModelList($params){
//获取仓鼠信息
$data['slist']=$this->field('*')->where("is_delete=0 and is_kill=0 {$params['where']}")->fList();
//获取繁殖笼幼崽信息
$data['youzailishi'] = $params['type']==2?:[];
return $data;
}
public function isFull($cage){
$params['user_id'] = $_SESSION['uid'];
$CageSetModel = new CageSetModel();
$time = date('Y-m-d',time());
//获取鼠笼配置
$cageSet = $CageSetModel->getsetinfo($params);
//查询当前是否有幼崽
$small = $this->field('count(*) num')->where("cage={$cage} and is_delete=0 and is_kill=0 and nursing_time>'{$time}'")->fRow();
//查询当前鼠笼是否有成年鼠
$big = $this->field('count(*) num')->where("cage={$cage} and is_delete=0 and is_kill=0 and nursing_time<'{$time}'")->fRow();
$data = true;
if($small['num']>0&&$big['num']>0){
if($cageSet['big_small_num']<=$big['num']) $data = false;
}
if($small['num']>0&&$big['num']==0){
if($cageSet['small_num_max']<=$big['num']) $data = false;
}
if($small['num']==0&&$big['num']>0){
if($cageSet['big_num_max']<=$big['num']) $data = false;
}else{
$data = true;
}
return $data;
}
}

@ -0,0 +1,24 @@
<?php
class SquirrelSetModel extends Orm_Base{
public $table = 'squirrel_set';
public $field = array(
'id' => array('type' => "int(11)",'comment' => ''),
'weaning_time' => array('type' => "varchar(45)",'comment' => '笼位编号'),
'nursing_time' => array('type' => "varchar(45)",'comment' => '断奶时间'),
'male_grow_time' => array('type' => "int(11)",'comment' => '雄性鼠成长时间'),
'female_grow_time' => array('type' => "varchar(255)",'comment' => '雌性鼠成长时间'),
'infertility_time' => array('type' => "varchar(255)",'comment' => '不育鼠时间'),
'dose_time' => array('type' => "varchar(255)",'comment' => '给药后持续几天显示给药标识'),
'color_time' => array('type' => "varchar(255)",'comment' => '记住几个近期给药的颜色'),
'breeding_tag' => array('type' => "varchar(255)",'comment' => '配繁标识'),
'see_bole_tag' => array('type' => "varchar(255)",'comment' => '见栓标识'),
'user_id' => array('type' => "int(11)",'comment' => '添加用户id'),
'created' => array('type' => "int(11)",'comment' => '添加时间'),
);
public $pk = 'id';
public function getsetinfo($params){
$data = $this->field('*')->where('user_id='.$params['user_id'])->fRow();
return $data;
}
}
Loading…
Cancel
Save