|
@@ -1,6 +1,8 @@
|
|
|
<?php
|
|
|
|
|
|
namespace app\admin\controller;
|
|
|
+use app\common\model\User;
|
|
|
+use app\hander\HelpHander;
|
|
|
use think\App;
|
|
|
use think\Db;
|
|
|
use think\Exception;
|
|
@@ -88,13 +90,257 @@ class WasteRecord extends Auth {
|
|
|
return json($result);
|
|
|
}
|
|
|
else {
|
|
|
- $type = (new \app\common\model\WasteType())->getList();
|
|
|
+ $type = (new \app\common\model\WasteType())->getList($this->orgId);
|
|
|
$this->assign('m_name', '医废类型');
|
|
|
$this->assign('type', $type);
|
|
|
$this->assign('status', $this->model->status);
|
|
|
return $this->fetch();
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ // 科室医废
|
|
|
+ public function index2() {
|
|
|
+ if (request()->isAjax()) {
|
|
|
+ $depId = Db::name('user_dep')->where("user_id",$this->userId)->value('dep_id');
|
|
|
+ $addrs = [];
|
|
|
+ $alists = model("Address")->getListByType(7,$this->orgId);
|
|
|
+ foreach ($alists as $k=>$v){
|
|
|
+ if($v['dep_id'] == $depId){
|
|
|
+ $addrs[] = $v['id'];
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //分页参数
|
|
|
+ $length = input('rows', 10, 'intval'); //每页条数
|
|
|
+ $page = input('page', 1, 'intval'); //第几页
|
|
|
+ $start = ($page - 1) * $length; //分页开始位置
|
|
|
+ //排序
|
|
|
+ $sortRow = input('sidx', 'id', 'trim'); //排序列
|
|
|
+ $sort = input('sord', 'desc', 'trim'); //排序方式
|
|
|
+ $order = $sortRow . ' ' . $sort;
|
|
|
+ $cateid = input('cateid', '', 'trim');
|
|
|
+ if ($cateid) {
|
|
|
+ $map[] = ['cateid', 'like', '%' . $cateid . '%'];
|
|
|
+ }
|
|
|
+ $start_time = input('start', '', 'trim');
|
|
|
+ $end_time = input('end', '', 'trim');
|
|
|
+ if ($start_time !== '' && $end_time !== '') {
|
|
|
+ if ($start_time <= $end_time) {
|
|
|
+ $start_time = date('Ymd', strtotime($start_time));
|
|
|
+ $end_time = date('Ymd', strtotime($end_time));
|
|
|
+ $map[] = ['create_yyyymmdd', 'between', [$start_time, $end_time]];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if ($start_time !== '' && $end_time == '') {
|
|
|
+ $start_time = date('Ymd', strtotime($start_time));
|
|
|
+ $map[] = ['create_yyyymmdd', '>=', $start_time];
|
|
|
+ }
|
|
|
+ if ($start_time == '' && $end_time !== '') {
|
|
|
+ $end_time = date('Ymd', strtotime($end_time));
|
|
|
+ $map[] = ['create_yyyymmdd', '<=', $end_time];
|
|
|
+ }
|
|
|
+ $status = input('status', '', 'trim');
|
|
|
+ if ($status != '') {
|
|
|
+ if ($status == 4) {
|
|
|
+ $map[] = ['status', 'in', [0, 1]];
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ if (in_array($status, array(0, 1, 2, 3))) {
|
|
|
+ $map[] = ['status', '=', $status];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ $post = request()->post();
|
|
|
+ if (!isset($post['status'])) {
|
|
|
+ $map[] = ['status', 'in', [0, 1]];
|
|
|
+ }
|
|
|
+ $map[] = ['waste_device_id', 'in', $addrs];
|
|
|
+ $map[] = ['del', '=', 0];
|
|
|
+ $map[] = ['org_id', '=', $this->orgId];
|
|
|
+ $map = empty($map) ? true : $map;
|
|
|
+ //数据查询
|
|
|
+ $lists = db($this->table)->where($map)
|
|
|
+ ->limit($start, $length)
|
|
|
+ ->order($order)->select();
|
|
|
+ foreach ($lists as $k => $v) {
|
|
|
+ $lists[$k]['waste_device'] = db('address')
|
|
|
+ ->where('id', $v['waste_device_id'])
|
|
|
+ ->value('title');
|
|
|
+ $lists[$k]['real_name'] = db('user')
|
|
|
+ ->where('id', $v['user_id'])
|
|
|
+ ->value('real_name');
|
|
|
+ $lists[$k]['cate'] = db('waste_type')
|
|
|
+ ->where('id', $v['cateid'])
|
|
|
+ ->value('title');
|
|
|
+ $lists[$k]['weight'] = round($v['weight'] / 1000, 2);
|
|
|
+ $lists[$k]['serial_number_path'] = url('Qrcode/qrcode') . '?code=' . $v['serial_number'];
|
|
|
+ $lists[$k]['status'] = $this->model->status[$v['status']];
|
|
|
+ }
|
|
|
+ //数据返回
|
|
|
+ $totalCount = db($this->table)->where($map)->count();
|
|
|
+
|
|
|
+ $totalPage = ceil($totalCount / $length);
|
|
|
+ $result['page'] = $page;
|
|
|
+ $result['total'] = $totalPage;
|
|
|
+ $result['records'] = $totalCount;
|
|
|
+ $result['rows'] = $lists;
|
|
|
+ $types = (new \app\common\model\WasteType())->getList($this->orgId);
|
|
|
+ foreach ($types as $k=>$v){
|
|
|
+ $weight = db($this->table)->where($map)->where('cateid',$v['id'])->sum('weight');
|
|
|
+ $types[$k]['weight'] = round($weight/1000,2);
|
|
|
+ }
|
|
|
+ $result['types'] = $types;
|
|
|
+ return json($result);
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ $type = (new \app\common\model\WasteType())->getList($this->orgId);
|
|
|
+ $this->assign('m_name', '医废类型');
|
|
|
+ $this->assign('type', $type);
|
|
|
+ $this->assign('status', $this->model->status);
|
|
|
+ return $this->fetch();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 所有科室医废
|
|
|
+ public function index3() {
|
|
|
+ if (request()->isAjax()) {
|
|
|
+ //分页参数
|
|
|
+ $length = input('rows', 10, 'intval'); //每页条数
|
|
|
+ $page = input('page', 1, 'intval'); //第几页
|
|
|
+ $start = ($page - 1) * $length; //分页开始位置
|
|
|
+ //排序
|
|
|
+ $sortRow = input('sidx', 'id', 'trim'); //排序列
|
|
|
+ $sort = input('sord', 'desc', 'trim'); //排序方式
|
|
|
+ $order = $sortRow . ' ' . $sort;
|
|
|
+ $cateid = input('cateid', '', 'trim');
|
|
|
+ if ($cateid) {
|
|
|
+ $map[] = ['cateid', 'like', '%' . $cateid . '%'];
|
|
|
+ }
|
|
|
+ $start_time = input('start', '', 'trim');
|
|
|
+ $end_time = input('end', '', 'trim');
|
|
|
+ if ($start_time !== '' && $end_time !== '') {
|
|
|
+ if ($start_time <= $end_time) {
|
|
|
+ $start_time = date('Ymd', strtotime($start_time));
|
|
|
+ $end_time = date('Ymd', strtotime($end_time));
|
|
|
+ $map[] = ['create_yyyymmdd', 'between', [$start_time, $end_time]];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if ($start_time !== '' && $end_time == '') {
|
|
|
+ $start_time = date('Ymd', strtotime($start_time));
|
|
|
+ $map[] = ['create_yyyymmdd', '>=', $start_time];
|
|
|
+ }
|
|
|
+ if ($start_time == '' && $end_time !== '') {
|
|
|
+ $end_time = date('Ymd', strtotime($end_time));
|
|
|
+ $map[] = ['create_yyyymmdd', '<=', $end_time];
|
|
|
+ }
|
|
|
+ $status = input('status', '', 'trim');
|
|
|
+ if ($status != '') {
|
|
|
+ if ($status == 4) {
|
|
|
+ $map[] = ['status', 'in', [0, 1]];
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ if (in_array($status, array(0, 1, 2, 3))) {
|
|
|
+ $map[] = ['status', '=', $status];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ $post = request()->post();
|
|
|
+ if (!isset($post['status'])) {
|
|
|
+ $map[] = ['status', 'in', [0, 1]];
|
|
|
+ }
|
|
|
+ $map[] = ['del', '=', 0];
|
|
|
+ $map[] = ['org_id', '=', $this->orgId];
|
|
|
+ $map = empty($map) ? true : $map;
|
|
|
+ //数据查询
|
|
|
+ $lists = db($this->table)->where($map)
|
|
|
+ ->limit($start, $length)
|
|
|
+ ->order($order)->select();
|
|
|
+ foreach ($lists as $k => $v) {
|
|
|
+ $lists[$k]['waste_device'] = db('address')
|
|
|
+ ->where('id', $v['waste_device_id'])
|
|
|
+ ->value('title');
|
|
|
+ $lists[$k]['real_name'] = db('user')
|
|
|
+ ->where('id', $v['user_id'])
|
|
|
+ ->value('real_name');
|
|
|
+ $lists[$k]['cate'] = db('waste_type')
|
|
|
+ ->where('id', $v['cateid'])
|
|
|
+ ->value('title');
|
|
|
+ $lists[$k]['weight'] = round($v['weight'] / 1000, 2);
|
|
|
+ $lists[$k]['serial_number_path'] = url('Qrcode/qrcode') . '?code=' . $v['serial_number'];
|
|
|
+ $lists[$k]['status'] = $this->model->status[$v['status']];
|
|
|
+ }
|
|
|
+ //数据返回
|
|
|
+ $totalCount = db($this->table)->where($map)->count();
|
|
|
+ $totalPage = ceil($totalCount / $length);
|
|
|
+ $result['page'] = $page;
|
|
|
+ $result['total'] = $totalPage;
|
|
|
+ $result['records'] = $totalCount;
|
|
|
+ $result['rows'] = $lists;
|
|
|
+// $weight = db($this->table)->where($map)->sum('weight');
|
|
|
+// $result['weight'] = round($weight/1000,2);
|
|
|
+
|
|
|
+
|
|
|
+ $types = (new \app\common\model\WasteType())->getList($this->orgId);
|
|
|
+ foreach ($types as $k=>$v){
|
|
|
+ $weight = db($this->table)->where($map)->where('cateid',$v['id'])->sum('weight');
|
|
|
+ $types[$k]['weight'] = round($weight/1000,2);
|
|
|
+ }
|
|
|
+ $result['types'] = $types;
|
|
|
+
|
|
|
+ return json($result);
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ $type = (new \app\common\model\WasteType())->getList($this->orgId);
|
|
|
+ $this->assign('m_name', '医废类型');
|
|
|
+ $this->assign('type', $type);
|
|
|
+ $this->assign('status', $this->model->status);
|
|
|
+ return $this->fetch();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public function add($id=0){
|
|
|
+ if(request()->isPost()){
|
|
|
+
|
|
|
+ $data = [
|
|
|
+ 'org_id' => $this->orgId,
|
|
|
+ 'user_id' => input('user_id/d',0),
|
|
|
+ 'waste_device_id' => input('waste_device_id/d',0),
|
|
|
+ 'cateid' =>input('cateid/d',0),
|
|
|
+ 'weight' => input('weight'),
|
|
|
+ 'create_time' => input('create_time'),
|
|
|
+ 'status' => 0,
|
|
|
+ 'is_print' => 0
|
|
|
+ ];
|
|
|
+ if(!$data['waste_device_id']){
|
|
|
+ $this->error('未选择收取科室');
|
|
|
+ }
|
|
|
+ if(!$data['cateid']){
|
|
|
+ $this->error('类型不能为空');
|
|
|
+ }
|
|
|
+
|
|
|
+ if($data['weight'] <= 0){
|
|
|
+ $this->error('称重必须大于0');
|
|
|
+ }
|
|
|
+ if(!$data['create_time']){
|
|
|
+ $this->error('未选择收取时间');
|
|
|
+ }
|
|
|
+
|
|
|
+ $waste_record_id = $this->model->saverecord($data);
|
|
|
+ if(!$waste_record_id){
|
|
|
+ HelpHander::error($this->model->getError());
|
|
|
+ }
|
|
|
+
|
|
|
+ $this->success('操作成功',url('index'));
|
|
|
+ }else{
|
|
|
+ $addrs = model("Address")->getListByType(7,$this->orgId);
|
|
|
+ $this->assign('addrs', $addrs);
|
|
|
+ $type = (new \app\common\model\WasteType())->getList($this->orgId);
|
|
|
+ $this->assign('type', $type);
|
|
|
+ $this->assign('user',(new User())->getWasteWorker());
|
|
|
+ return $this->fetch();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 详情
|
|
|
*
|