From da233c58a91f42348afaa047e76731f768abed79 Mon Sep 17 00:00:00 2001 From: "yangsai@163.com" <2624183217@qq.com> Date: Wed, 5 Jun 2024 16:18:34 +0800 Subject: [PATCH] ys --- application/controllers/Api/Squirrel.php | 13 +++++++++++++ application/models/NewSquirrel.php | 9 ++++----- application/models/Squirrel.php | 3 ++- 3 files changed, 19 insertions(+), 6 deletions(-) diff --git a/application/controllers/Api/Squirrel.php b/application/controllers/Api/Squirrel.php index 3c45758..75e59e8 100644 --- a/application/controllers/Api/Squirrel.php +++ b/application/controllers/Api/Squirrel.php @@ -405,5 +405,18 @@ class Api_SquirrelController extends Ctrl_Api{ $this->Squirrelmodel->commit(); Tool_Fnc::apiMsg('剪尾完成', '1'); } + public function setsexAction(){ + $cage = empty($this->POST['cage'])?Tool_Fnc::apiMsg('笼位号丢失', '500'):$this->POST['cage']; + $sex = empty($this->POST['sex'])?Tool_Fnc::apiMsg('请选择性别', '500'):$this->POST['sex']; + $unsex = $sex==1?2:1; + $squirrel = empty($this->POST['squirrel'])?Tool_Fnc::apiMsg('请选择幼崽', '500'):$this->POST['squirrel']; + $str = implode("','",$squirrel); + $sql = "update {$this->Squirrelmodel->table} set sex={$sex} where number in ('{$str}') and type=2 and cage={$cage}"; + $unsql = "update {$this->Squirrelmodel->table} set sex={$unsex} where number not in ('{$str}') and type=2 and cage={$cage}"; + if($this->Squirrelmodel->exec($sql)&&$this->Squirrelmodel->exec($unsql)){ + Tool_Fnc::apiMsg('设置成功', '1'); + } + Tool_Fnc::apiMsg('设置失败', '500'); + } } diff --git a/application/models/NewSquirrel.php b/application/models/NewSquirrel.php index 19ee613..510df68 100644 --- a/application/models/NewSquirrel.php +++ b/application/models/NewSquirrel.php @@ -35,8 +35,8 @@ class NewSquirrelModel extends Orm_Base{ $CageModel = new CageModel(); $SquirrelModel = new SquirrelModel(); //获取幼崽信息 - $data=$this->field('id,count,birthday,father,mother,strains,gene,remark,cage,is_fen')->where("id>0 {$params['where']}")->fList(); - foreach($data as $key => &$val){ + $data['wj']=$this->field('id,count,birthday,father,mother,strains,gene,remark,cage,is_fen')->where("id>0 {$params['where']}")->fList(); + foreach($data['wj'] as $key => &$val){ if($val['is_fen']==1){ unset($data[$key]); }else{ @@ -44,12 +44,11 @@ class NewSquirrelModel extends Orm_Base{ $val['icon'] = Yaf_Registry::get("config")->web->url->img."/public/icon/small.png"; } } - $jian = $SquirrelModel->field('id,number,birthday,father,mother,strains_id as strains,gene,remark,cage')->where("type=2 {$params['where']}")->fList(); - foreach($jian as $key => &$va){ + $data['j'] = $SquirrelModel->field('id,number,birthday,father,mother,strains_id as strains,gene,remark,cage')->where("type=2 {$params['where']}")->fList(); + foreach($data['j'] as $key => &$va){ $va['cage'] = $CageModel->field('number')->where("id={$va['cage']}")->fRow()['number']; $va['icon'] = Yaf_Registry::get("config")->web->url->img."/public/icon/small.png"; } - $data = array_merge($data,$jian); return $data; } public function getOneInfo($squirrel){ diff --git a/application/models/Squirrel.php b/application/models/Squirrel.php index b4e710f..da1530f 100644 --- a/application/models/Squirrel.php +++ b/application/models/Squirrel.php @@ -45,7 +45,8 @@ class SquirrelModel extends Orm_Base{ $val['icon'] = $this->getIcon($val['id'])['icon']; } //获取繁殖笼幼崽信息 - $data['youzailishi'] = !empty($NewSquirrel->getModelList($params))?$NewSquirrel->getModelList($params):[]; + $data['youzailishi'] = !empty($NewSquirrel->getModelList($params))?$NewSquirrel->getModelList($params)['wj']:[]; + $data['youzailishijianwei'] = !empty($NewSquirrel->getModelList($params))?$NewSquirrel->getModelList($params)['j']:[]; return $data;