|
|
@ -6,97 +6,72 @@ |
|
|
|
* @version 1.0 |
|
|
|
* @version 1.0 |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
class Api_RemindController extends Ctrl_Api{ |
|
|
|
class Api_RemindController extends Ctrl_Api{ |
|
|
|
public $SquirrelModel; |
|
|
|
|
|
|
|
public $newSquirrelModel; |
|
|
|
|
|
|
|
public $SquirrelSetModel; |
|
|
|
|
|
|
|
public $CageModel; |
|
|
|
|
|
|
|
public function init(){ |
|
|
|
public function init(){ |
|
|
|
$SquirrelModel = new SquirrelModel(); |
|
|
|
|
|
|
|
$newSquirrelModel = new NewSquirrelModel(); |
|
|
|
|
|
|
|
$SquirrelSetModel = new SquirrelSetModel(); |
|
|
|
|
|
|
|
$CageModel = new CageModel(); |
|
|
|
|
|
|
|
$this->POST =json_decode(file_get_contents('php://input'),true); |
|
|
|
$this->POST =json_decode(file_get_contents('php://input'),true); |
|
|
|
} |
|
|
|
} |
|
|
|
public function getListAction(){ |
|
|
|
public function addAction(){ |
|
|
|
$uid = empty($this->POST['uid'])?Tool_Fnc::apiMsg('请先登录', '500'):$this->POST['uid']; |
|
|
|
$uid= empty($this->POST['uid'])?Tool_Fnc::apiMsg('请先登录', '500'):$this->POST['uid']; |
|
|
|
//查询鼠提示信息 |
|
|
|
$content = empty($this->POST['content'])?Tool_Fnc::apiMsg('未填写内容', '500'):$this->POST['content']; |
|
|
|
$Squirrel = $this->SquirrelModel->field('*')->where("c_user_id={$uid} and is_kill = 0 and is_delete=0")->fList(); |
|
|
|
$RemindModel = new RemindModel(); |
|
|
|
$newSquirrel = $this->newSquirrelModel->field('*')->where("c_user_id={$uid} and is_kill = 0 and is_delete=0")->fList(); |
|
|
|
$data['user_id'] = $uid; |
|
|
|
foreach($Squirrel as $key => $val){ |
|
|
|
$data['content'] = $content; |
|
|
|
//获取笼位号 |
|
|
|
$data['created'] = date("Y-m-d H:i:s",time()); |
|
|
|
$cage = $this->CageModel->field("number,type")->where("cage={$val['cage']}")->fRow(); |
|
|
|
if(!$RemindModel->insert($data)) Tool_Fnc::apiMsg('添加失败', '500'); |
|
|
|
$type = $cage['type']==1?"库存笼":"繁殖笼"; |
|
|
|
Tool_Fnc::apiMsg('添加成功', '200'); |
|
|
|
//断奶提醒 |
|
|
|
} |
|
|
|
if($val['weaning_time']==date("Y-m-d",time())){ |
|
|
|
public function getlistAction(){ |
|
|
|
$remind[] = "{$type}【{$cage['number']}】里{$val['number']}于{$val['weaning_time']}断奶"; |
|
|
|
$RemindModel = new RemindModel(); |
|
|
|
} |
|
|
|
$uid= empty($this->POST['uid'])?Tool_Fnc::apiMsg('请先登录', '500'):$this->POST['uid']; |
|
|
|
//护理结束提醒 |
|
|
|
$list = $RemindModel->field("*")->where("is_delete=0 and user_id='{$uid}'")->order('id desc')->fList(); |
|
|
|
if($val['weaning_time']==date("Y-m-d",time())){ |
|
|
|
foreach($list as $key => &$val){ |
|
|
|
$remind[] = "{$type}【{$cage['number']}】里{$val['number']}于{$val['weaning_time']}结束护理"; |
|
|
|
$val['created'] = $this->time_tran($val['created']); |
|
|
|
} |
|
|
|
|
|
|
|
//性成熟时间提醒 |
|
|
|
|
|
|
|
if($val['grow_time']==date("Y-m-d",time())){ |
|
|
|
|
|
|
|
$remind[] = "{$type}【{$cage['number']}】里{$val['number']}于{$val['weaning_time']}成熟"; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
//不育鼠时间提醒 |
|
|
|
|
|
|
|
if($val['infertility_time']==date("Y-m-d",time())){ |
|
|
|
|
|
|
|
$remind[] = "{$type}【{$cage['number']}】里{$val['number']}于{$val['weaning_time']}结束不育时间"; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
//处死提醒 |
|
|
|
|
|
|
|
if($val['kill_time']==date("Y-m-d",time())){ |
|
|
|
|
|
|
|
$remind[] = "{$type}【{$cage['number']}】里{$val['number']}{$val['weaning_time']}已到处死时间"; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
//删除提醒 |
|
|
|
|
|
|
|
if($val['del_time']==date("Y-m-d",time())){ |
|
|
|
|
|
|
|
$remind[] = "{$type}【{$cage['number']}】里{$val['number']}{$val['weaning_time']}已到删除时间"; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
//剪尾提醒 |
|
|
|
|
|
|
|
if($val['jianwei_time']==date("Y-m-d",time())){ |
|
|
|
|
|
|
|
$remind[] = "{$type}【{$cage['number']}】里{$val['number']}{$val['weaning_time']}改进行剪尾"; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
//实验提醒 |
|
|
|
|
|
|
|
if($val['test_time']==date("Y-m-d",time())){ |
|
|
|
|
|
|
|
$remind[] = "{$type}【{$cage['number']}】里{$val['number']}已到可实验时间{$val['weaning_time']}"; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
foreach($newSquirrel as $key => $v){ |
|
|
|
Tool_Fnc::apiMsg('获取成功', '200',$list); |
|
|
|
//获取笼位号 |
|
|
|
} |
|
|
|
$cage = $this->CageModel->field("number,type")->where("cage={$v['cage']}")->fRow(); |
|
|
|
public function delAction(){ |
|
|
|
$type = $cage['type']==1?"库存笼":"繁殖笼"; |
|
|
|
$RemindModel = new RemindModel(); |
|
|
|
//断奶提醒 |
|
|
|
$uid= empty($this->POST['uid'])?Tool_Fnc::apiMsg('请先登录', '500'):$this->POST['uid']; |
|
|
|
if($v['weaning_time']==date("Y-m-d",time())){ |
|
|
|
$id= empty($this->POST['id'])?Tool_Fnc::apiMsg('待办ID缺失', '500'):$this->POST['id']; |
|
|
|
$remind[] = "{$type}【{$cage['number']}】幼崽已到{$v['weaning_time']}断奶"; |
|
|
|
$data['id'] = $id; |
|
|
|
} |
|
|
|
$data['is_delete'] = 1; |
|
|
|
//护理结束提醒 |
|
|
|
if(!$RemindModel->update($data)) Tool_Fnc::apiMsg('删除失败', '500'); |
|
|
|
if($v['weaning_time']==date("Y-m-d",time())){ |
|
|
|
Tool_Fnc::apiMsg('已删除', '200'); |
|
|
|
$remind[] = "{$type}【{$cage['number']}】幼崽已到{$v['weaning_time']}结束护理"; |
|
|
|
} |
|
|
|
} |
|
|
|
public function readremindAction(){ |
|
|
|
//性成熟时间提醒 |
|
|
|
$RemindModel = new RemindModel(); |
|
|
|
if($v['grow_time']==date("Y-m-d",time())){ |
|
|
|
$uid= empty($this->POST['uid'])?Tool_Fnc::apiMsg('请先登录', '500'):$this->POST['uid']; |
|
|
|
$remind[] = "{$type}【{$cage['number']}】幼崽已到{$v['weaning_time']}成熟"; |
|
|
|
$id= empty($this->POST['id'])?Tool_Fnc::apiMsg('待办ID缺失', '500'):$this->POST['id']; |
|
|
|
} |
|
|
|
$data['id'] = $id; |
|
|
|
//不育鼠时间提醒 |
|
|
|
$data['status'] = 1; |
|
|
|
if($v['infertility_time']==date("Y-m-d",time())){ |
|
|
|
if(!$RemindModel->update($data)) Tool_Fnc::apiMsg('删除失败', '500'); |
|
|
|
$remind[] = "{$type}【{$cage['number']}】幼崽已到{$v['weaning_time']}结束不育时间"; |
|
|
|
Tool_Fnc::apiMsg('成功', '200'); |
|
|
|
} |
|
|
|
} |
|
|
|
//处死提醒 |
|
|
|
function time_tran($the_time) { |
|
|
|
if($v['kill_time']==date("Y-m-d",time())){ |
|
|
|
$now_time = time(); |
|
|
|
$remind[] = "{$type}【{$cage['number']}】幼崽已到{$v['weaning_time']}已到处死时间"; |
|
|
|
$show_time = strtotime($the_time); |
|
|
|
} |
|
|
|
$dur = $now_time - $show_time; |
|
|
|
//删除提醒 |
|
|
|
if ($dur < 0) { |
|
|
|
if($v['del_time']==date("Y-m-d",time())){ |
|
|
|
return date("m/d",$show_time); |
|
|
|
$remind[] = "{$type}【{$cage['number']}】幼崽已到{$v['weaning_time']}已到删除时间"; |
|
|
|
} else { |
|
|
|
} |
|
|
|
if ($dur < 60) { |
|
|
|
//剪尾提醒 |
|
|
|
//return $dur . '秒前'; |
|
|
|
if($v['jianwei_time']==date("Y-m-d",time())){ |
|
|
|
return '刚刚'; |
|
|
|
$remind[] = "{$type}【{$cage['number']}】幼崽已到{$v['weaning_time']}改进行剪尾"; |
|
|
|
} else { |
|
|
|
} |
|
|
|
if ($dur < 3600) { |
|
|
|
//实验提醒 |
|
|
|
return floor($dur / 60) . '分钟前'; |
|
|
|
if($v['test_time']==date("Y-m-d",time())){ |
|
|
|
} else { |
|
|
|
$remind[] = "{$type}【{$cage['number']}】幼崽已到可实验时间{$v['weaning_time']}"; |
|
|
|
if ($dur < 86400) { |
|
|
|
|
|
|
|
return floor($dur / 3600) . '小时前'; |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
if ($dur < 259200) { // 3天内 |
|
|
|
|
|
|
|
return floor($dur / 86400) . '天前'; |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
return date("m/d",$show_time); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
Tool_Fnc::apiMsg('获取成功', '200'); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|