123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249 |
- <?php
- namespace app\api\controller\v1;
- use app\api\controller\Base;
- use app\hander\HelpHander;
- use think\App;
- use think\Db;
- class WasteRecord extends Base
- {
- public function __construct(App $app = null) {
- parent::__construct($app);
- $this->model = new \app\common\model\WasteRecord();
- }
- public function printRecord (){
- $id=input('id/d');
- db('waste_record')->where('id',$id)
- ->update(['is_print' =>1]);
- HelpHander::success([],'操作成功');
- }
- public function queryIsPrint(){
- $id=input('id/d');
- $ret=$this->model->queryIsPrint($id);
- if($ret){
- HelpHander::success($ret);
- }else{
- HelpHander::error('暂无数据');
- }
- }
- public function queryWasteRecordList(){
- $orgId=input('orgId/d');
- $status=input('status');
- $createTime=trim(input('createTime'));
- $page=input('page/d',1);
- $size=input('size/d',10);
- $ret=$this->model->wasteRecordList($orgId,$status,$createTime,$page,$size);
- if($ret){
- HelpHander::success($ret);
- }else{
- HelpHander::error('暂无数据');
- }
- }
- public function queryUnTransportList(){
- $orgId=input('orgId/d');
- $createTime=trim(input('createTime'));
- $ret=$this->model->unTransportList($orgId,$createTime);
- if($ret){
- HelpHander::success($ret);
- }else{
- HelpHander::error('暂无数据');
- }
- }
- // 保存医废记录
- public function saveRecord(){
- $data = [
- 'org_id' => input('orgId/d'),
- 'user_id' => $this->userId,
- 'waste_device_id' => input('wasteDeviceId'),
- 'cateid' =>input('cateId'),
- 'weight' => input('weight'),
- 'status' => 0,
- 'is_print' => 0
- ];
- if(!$data['waste_device_id']){
- HelpHander::error('未选择收取科室');
- }
- if(!$data['cateid']){
- HelpHander::error('类型不能为空');
- }
- if($data['weight'] <= 0){
- HelpHander::error('称重必须大于0');
- }
- $waste_record_id = $this->model->saverecord($data);
- if(!$waste_record_id){
- HelpHander::error($this->model->getError());
- }
- $info = $this->model->getOne($waste_record_id,$data['org_id']);
- if(!$info){
- HelpHander::error('操作失败');
- }
- $info['wasteDeviceName'] = Db::name('address')
- ->where('id',$info['waste_device_id'])
- ->value('title');
- $info['cateId']=$info['cateid'];
- $a = formatArray(['id','create_time',
- 'serial_number','wasteDeviceName','cateId','is_print'],$info);
- HelpHander::success($a,'操作成功');
- }
- public function save(){
- $json = [
- 'serialNumber'=>input('serialNumber'),
- 'weight2'=>input('weight2'),
- 'status'=>input('status'),
- 'reason'=>input('reason'),
- 'userId'=>$this->userId,
- ];
- if(!in_array($json['status'],[1,2,3])){
- HelpHander::error('参数错误');
- }
- $ret = $this->model->saveStatus($json);
- if($ret){
- HelpHander::success([],'操作成功');
- }else{
- HelpHander::error('操作失败'.$this->model->getError());
- }
- }
- public function detail(){
- $serialNum = input('serialNum');
- $orgId = $this->orgId;
- if(strlen($serialNum) == 14){ // 包编号
- $ret = $this->model->packInfo($serialNum,$orgId);
- }else{
- $ret = $this->model->recordInfo($serialNum,$orgId);
- }
- if($ret){
- HelpHander::success($ret,'操作成功');
- }else{
- HelpHander::error('操作失败');
- }
- }
- public function lists(){
- $depId = input('depId');
- $date = input('date');
- $orgId = $this->orgId;
- $page=input('page/d',1);
- $size=input('size/d',10);
- $ret=$this->model->lists($orgId,$depId,$date,$page,$size,$this->userId);
- HelpHander::success($ret);
- }
- public function sign(){
- $path = input('path');
- $wasterecordid = input('wasteRecordId');
- if(!$path || !$wasterecordid){
- HelpHander::error('参数错误');
- }
- $ids = explode(',',$wasterecordid);
- $succ = 0;
- foreach ($ids as $k=>$v){
- $info = $this->model->getOne($v,$this->orgId);
- if(!$info){
- HelpHander::error($v.'记录不存在');
- }
- if($info['sign'] == 1){
- continue;
- }
- $res = Db::name('waste_record')
- ->where('id',$v)
- ->update([
- 'sign' => 1,
- 'sign_path' => $path,
- 'sign_user_id' => $this->userId,
- 'sign_time' => getTime()
- ]);
- if($res){
- $succ++;
- }
- }
- if($succ==count($ids)){
- HelpHander::success('操作成功');
- }else{
- HelpHander::error('操作失败');
- }
- }
- // 保存医废打包
- public function savePackage(){
- $data = [
- 'org_id' =>$this->orgId,
- 'user_id' => $this->userId,
- 'ids' =>input('ids'),
- ];
- $ids = explode(',',$data['ids']);
- $nids = [];
- foreach ($ids as $k=>$v){
- if($v && !in_array($v,$nids)){
- $nids[] = $v;
- }
- }
- $data['ids'] = $nids;
- if(!$data['ids']){
- HelpHander::error('未选择医废记录');
- }
- $ret = $this->model->savePackage($data);
- if(!$ret){
- HelpHander::error($this->model->getError());
- }
- HelpHander::success(['id' => $ret],'操作成功');
- }
- // 可使用的打包医废记录
- public function yflist(){
- $ret=$this->model->yflist($this->orgId,$this->userId);
- HelpHander::success($ret);
- }
- // 删除包内医废记录
- public function delpackage(){
- $id = input('id'); // 包id
- $recordId = input('recordId'); // 记录id
- $ret=$this->model->delpackage($this->orgId,$this->userId,$id,$recordId);
- if(!$ret){
- HelpHander::error($this->model->getError());
- }
- HelpHander::success([],'操作成功');
- }
- // 交接包
- public function jjpackage(){
- $id = input('id');
- $ret=$this->model->jjpackage($this->orgId,$this->userId,$id);
- if(!$ret){
- HelpHander::error($this->model->getError());
- }
- HelpHander::success([],'操作成功');
- }
- // 转运包
- public function zypackage(){
- $id = input('id');
- $ret=$this->model->zypackage($this->orgId,$this->userId,$id);
- if(!$ret){
- HelpHander::error($this->model->getError());
- }
- HelpHander::success([],'操作成功');
- }
- public function packages(){
- $page = input('page',1);
- $size = input('size',10);
- $ret=$this->model->packagesLists($this->orgId,$page,$size,$this->userId);
- HelpHander::success($ret);
- }
- }
|