array('type' => "int(11)",'comment' => ''), 'number' => array('type' => "varchar(45)",'comment' => '笼位编号'), 'sex' => array('type' => "varchar(45)",'comment' => '性别'), 'birthday' => array('type' => "int(11)",'comment' => '小鼠生日'), 'father' => array('type' => "varchar(255)",'comment' => '小鼠父亲'), 'mother' => array('type' => "varchar(255)",'comment' => '小鼠母亲'), 'strains_id' => array('type' => "varchar(255)",'comment' => '小鼠品系'), 'gene' => array('type' => "varchar(255)",'comment' => '小鼠基因'), 'hair_color' => array('type' => "varchar(255)",'comment' => '小鼠毛色'), 'remark' => array('type' => "int(11)",'comment' => '备注'), 'is_kill' => array('type' => "varchar(255)",'comment' => '是否杀死'), 'is_delete' => array('type' => "varchar(255)",'comment' => '是否删除'), 'cage' => array('type' => "varchar(255)",'comment' => '笼位id'), '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' => '是否为新生小鼠'), 'jianwei_show' => array('type' => "varchar(255)",'comment' => '是否为新生小鼠'), 'test_show' => array('type' => "varchar(255)",'comment' => '是否为新生小鼠'), 'kill_show' => array('type' => "varchar(255)",'comment' => '是否为新生小鼠'), 'del_show' => array('type' => "varchar(255)",'comment' => '是否为新生小鼠'), ); public $pk = 'id'; public function getModelList($params){ $sex = array("1"=>"雄","2"=>"雌","3"=>"其他","0"=>"其他"); $cageModel = new CageModel(); $NewSquirrel = new NewSquirrelModel(); //获取仓鼠信息 $data['slist']=$this->field('id,number,sex,birthday,father,mother,strains_id as strains,gene,hair_color,cage,remark')->where("is_delete=0 and type=1 and is_kill=0 {$params['where']}")->fList(); foreach($data['slist'] as $key => &$val){ $val['sex'] = $sex[$val['sex']]; //获取笼位号 $val['cage'] =$cageModel->getOneInfo($val['cage'])['number']; $val['icon'] = $this->getIcon($val['id'])['icon']; } //获取繁殖笼幼崽信息 $data['youzailishi'] = !empty($NewSquirrel->getModelList($params))?$NewSquirrel->getModelList($params)['wj']:[]; $data['youzailishijianwei'] = !empty($NewSquirrel->getModelList($params))?$NewSquirrel->getModelList($params)['j']:[]; return $data; } public function isFull($cage,$uid,$numbj=0){ $params['user_id'] = $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'] || ($cageSet['big_small_num']-$big['num'])<$numbj) $data = false; } if($small['num']>0&&$big['num']==0){ if($cageSet['small_num_max']<=$big['num'] || ($cageSet['small_num_max']-$big['num'])<$numbj) $data = false; } if($small['num']==0&&$big['num']>0){ if($cageSet['big_num_max']<=$big['num'] || ($cageSet['big_num_max']-$big['num'])<$numbj ) $data = false; }else{ if(($cageSet['big_num_max']-$big['num'])<$numbj){ $data = false; }else{ $data = true; } } return $data; } public function getOneInfo($squirrel){ return $this->field('id,number,sex,birthday,father,mother,strains_id as strains,gene,hair_color,cage,remark,c_user_id')->where("id={$squirrel}")->fRow(); } public function partent($cage){ $time = date('Y-m-d',time()); $exec=$this->field('id,number,sex')->where("is_delete=0 and is_kill=0 and grow_time<'{$time}'"); if(!empty($cage)){ $CageModel = new CageModel(); $cageinfo = $CageModel->field("type")->where("id={$cage}")->fRow(); if($cageinfo['type']==2) $exec->where("cage={$cage}"); } $data = $exec->fList(); $data[] = ['id'=>0,'number'=>"未知",'sex'=>2]; $data[] = ['id'=>0,'number'=>"未知",'sex'=>1]; return $data; } public function getIcon($squirrel){ $date = strtotime(date('Y-m-d',time())); $info = $this->field('nursing_time')->where("id={$squirrel}")->fRow(); if(empty($info)){ $data['icon'] = Yaf_Registry::get("config")->cangshu->url->small; }else{ if(strtotime($info['nursing_time'])<$date){ $data['icon'] = Yaf_Registry::get("config")->web->url->img.Yaf_Registry::get("config")->cangshu->url->big; }else{ $data['icon'] = Yaf_Registry::get("config")->web->url->img.Yaf_Registry::get("config")->cangshu->url->small; } } return $data; } public function operate($params){ $remind = array('test_time'=>"已到可实验时间","jianwei_time"=>"已到可剪尾时间","kill_time"=>"已到可处死时间","del_time"=>"已到可删除时间"); //获取小鼠信息 $info = $this->getOneInfo($params['id']); $remindarray = []; foreach($params as $key => $val){ if(empty($val)){ unset($params[$key]); }else{ if(isset($remind[$key])){ $item['content'] = $info['number'].$remind[$key]; $item['user_id'] = $info['c_user_id']; $item['created'] = $val." ".date("H:i:s"); $remindarray[] = $item; } } } $remindModel = new RemindModel(); $remindModel->inserts($remindarray); //更新待办 if(!$this->update($params)) return false; return true; } }