ss 2 miesięcy temu
rodzic
commit
fbf18d3ce8
35 zmienionych plików z 1282 dodań i 168 usunięć
  1. 1 1
      .env.example
  2. 27 0
      application/admin/controller/MateCheck.php
  3. 110 9
      application/admin/controller/Orders.php
  4. 55 1
      application/admin/controller/Todo.php
  5. 8 1
      application/admin/controller/WastePackage.php
  6. 9 1
      application/admin/controller/WastePrintLog.php
  7. 89 14
      application/admin/controller/WasteRecord.php
  8. 493 41
      application/admin/controller/WasteStatistics.php
  9. 4 4
      application/admin/controller/WasteType.php
  10. 1 0
      application/admin/view/orders/index1.html
  11. 14 3
      application/admin/view/orders/index3.html
  12. 21 0
      application/admin/view/waste_apply_option/info.html
  13. 3 3
      application/admin/view/waste_package/info.html
  14. 2 2
      application/admin/view/waste_print_log/info.html
  15. 64 1
      application/admin/view/waste_record/add.html
  16. 87 0
      application/admin/view/waste_record/apply.html
  17. 1 1
      application/admin/view/waste_record/index.html
  18. 6 6
      application/admin/view/waste_record/index2.html
  19. 6 6
      application/admin/view/waste_record/index3.html
  20. 5 1
      application/admin/view/waste_record/info.html
  21. 1 1
      application/admin/view/waste_statistics/waste_day.html
  22. 4 2
      application/admin/view/waste_statistics/waste_month.html
  23. 1 1
      application/admin/view/waste_statistics/waste_years.html
  24. 1 1
      application/admin/view/waste_statistics/waste_zc.html
  25. 36 4
      application/admin/view/waste_type/add.html
  26. 25 18
      application/admin/view/waste_type/index.html
  27. 2 2
      application/api/controller/screen/Convey.php
  28. 51 19
      application/api/controller/screen/Patrol.php
  29. 3 2
      application/api/controller/screen/Waste.php
  30. 33 0
      application/api/controller/v1/ConveyCate.php
  31. 51 2
      application/api/controller/v1/WasteRecord.php
  32. 13 0
      application/common.php
  33. 47 19
      application/common/model/WasteRecord.php
  34. 1 1
      application/common/model/WasteType.php
  35. 7 1
      application/h5/controller/Statistics.php

+ 1 - 1
.env.example

@@ -1 +1 @@
-[APP]
APP_DEBUG = true
APP_HOST = https://mdyg.sdmingde.cn
[DATABASE]
HOSTNAME = 121.36.53.58
DATABASE = wy_jili2_com
USERNAME = wy_jili2_com
PASSWORD = J8FTMapBeXHsEhKd
HOSTPORT = 3306
CHARSET = utf8mb4


[APP]
APP_DEBUG = true
APP_HOST = https://mdyg.sdmingde.cn
[DATABASE]
HOSTNAME = 127.0.0.1
DATABASE = jili2
USERNAME = root
PASSWORD = 123456
HOSTPORT = 3306
CHARSET = utf8mb4










+[APP]
APP_DEBUG = true
APP_HOST = http://wy2.jiliyilian.com
[DATABASE]
HOSTNAME = 124.71.235.188
DATABASE = wy_jili2_com
USERNAME = wy_jili2_com
PASSWORD = kraXDcXEBfhzAsfn
HOSTPORT = 3306
CHARSET = utf8mb4


[APP]
APP_DEBUG = true
APP_HOST = http://wy2.jiliyilian.com
[DATABASE]
HOSTNAME = 121.36.46.135
DATABASE = wy_jili2_com
USERNAME = wy_jili2_com
PASSWORD = J8FTMapBeXHsEhKd
HOSTPORT = 3306
CHARSET = utf8mb4













+ 27 - 0
application/admin/controller/MateCheck.php

@@ -175,6 +175,33 @@ class MateCheck extends Auth
             $this->error('还有物品未盘库');
         }
         $ret = Db::name('mate_check')->where('id',$id)->update(['status'=>1,'finish_time'=>date('Y-m-d H:i:s')]);
+
+        $goodsList = Db::name('mate_check_goods')
+            ->where('check_id',$id)
+            ->where('del',0)
+            ->where('status','>',0)
+            ->select();
+
+        foreach ($goodsList as $k=>$v){
+//            $num = $v['nums'] - $v['check_nums'];
+//            if($num > 0){
+//                $save = Db::name('mate_goods')
+//                    ->where('id',$v['goods_id'])
+//                    ->setDec('nums',$num);
+//            }else{
+//                $num = abs($num);
+//                $save = Db::name('mate_goods')
+//                    ->where('id',$v['goods_id'])
+//                    ->setInc('nums',$num);
+//            }
+            $save = Db::name('mate_goods')
+                ->where('id',$v['goods_id'])
+                ->update(['nums'=>$v['check_nums']]);
+            if(!$save){
+                $this->error('数量修改失败');
+            }
+        }
+
         if(!$ret){
             $this->error('操作失败');
         }

+ 110 - 9
application/admin/controller/Orders.php

@@ -480,17 +480,53 @@ class Orders extends Auth {
             if($eddr !=''){
                 $map[] = ['b.end','=',$eddr];
             }
+            $toUserName = input('toUserName','','trim');
+            if($toUserName !=''){
+                $ooids = Db::name('user')
+                    ->alias('u')
+                    ->join('todo t','t.to_user_id=u.id')
+                    ->where('t.del',0)
+                    ->where('t.org_id',$this->orgId)
+                    ->where('u.real_name',$toUserName)
+                    ->column('t.order_id');
+                if($ooids){
+                    $map[] = ['a.id','in',$ooids];
+                }else{
+                    $map[] = ['a.id','=',-1];
+                }
+            }
+
+            $conveyCateId = input('conveyCateId','','trim');
+            if($conveyCateId !=''){
+                $typeNameId = Db::name('convey_cate')
+                    ->alias('a')
+                    ->join('order_convey b','a.id=b.type')
+                    ->where('a.org_id', $this->orgId)
+                    ->where('a.enable', 1)
+                    ->where('a.del', 0)
+                    ->where('a.id', $conveyCateId)
+                    ->column('b.order_id');
+                if (!empty($typeNameId)) {
+                    $map[] = ['a.id', 'in', $typeNameId];
+                }else {
+                    $map[] = ['a.id', '=', -1];
+                }
+            }
 
             $map = empty($map) ? true : $map;
 
             //数据查询
-            $lists = db($this->table)->where($map)
+            $lists = db($this->table)
+                ->where($map)
                 ->alias('a')
                 ->leftJoin('order_convey b','a.id=b.order_id')
                 ->field('a.*,b.priority')
                 ->whereOr($map6)
-                ->limit($start, $length)->order($order)->select();
-
+                ->limit($start, $length)
+                ->order($order)
+//                ->fetchSql()
+                ->select();
+          //  halt($lists);
             foreach ($lists as $k => $v) {
                 $lists[$k] = $this->model->formatOrder($v);
                 $lists[$k]['priority'] = isset($this->model->priority[$v['priority']])?$this->model->priority[$v['priority']]:"";
@@ -505,6 +541,15 @@ class Orders extends Auth {
                    ->where('pause',1)
                    ->find();
                 $lists[$k]['gq'] = $gq?'存在挂起':'';
+
+                $toUserNames = Db::name('todo')
+                    ->alias('t')
+                    ->join('user u','u.id=t.to_user_id')
+                    ->where('t.order_id',$v['id'])
+                    ->where('t.del',0)
+                    ->column('u.real_name');
+
+                $lists[$k]['to_user_names'] = $toUserNames ? implode(',',$toUserNames):'';
             }
 
             //数据返回
@@ -558,6 +603,12 @@ class Orders extends Auth {
             $dep_cate = model('DepCate')->getList();
             $this->assign('dep_cate',$dep_cate);
 
+            $conveyCate = Db::name('convey_cate')
+                ->where('org_id',$this->orgId)
+                ->where('del',0)
+                ->where('enable',1)
+                ->select();
+            $this->assign('convey_cate',$conveyCate);
             $addrList = (new \app\common\model\Address())->getListByTypes([],2,$this->orgId);
             $this->assign('addrList',$addrList);
             //抢单开关
@@ -2212,6 +2263,38 @@ class Orders extends Auth {
             if($eddr !=''){
                 $map[] = ['b.end','=',$eddr];
             }
+            $toUserName = input('toUserName','','trim');
+            if($toUserName !=''){
+                $ooids = Db::name('user')
+                    ->alias('u')
+                    ->join('todo t','t.to_user_id=u.id')
+                    ->where('t.del',0)
+                    ->where('t.org_id',$this->orgId)
+                    ->where('u.real_name',$toUserName)
+                    ->column('t.order_id');
+                if($ooids){
+                    $map[] = ['a.id','in',$ooids];
+                }else{
+                    $map[] = ['a.id','=',-1];
+                }
+            }
+
+            $conveyCateId = input('conveyCateId','','trim');
+            if($conveyCateId !=''){
+                $typeNameId = Db::name('convey_cate')
+                    ->alias('a')
+                    ->join('order_convey b','a.id=b.type')
+                    ->where('a.org_id', $this->orgId)
+                    ->where('a.enable', 1)
+                    ->where('a.del', 0)
+                    ->where('a.id', $conveyCateId)
+                    ->column('b.order_id');
+                if (!empty($typeNameId)) {
+                    $map[] = ['a.id', 'in', $typeNameId];
+                }else {
+                    $map[] = ['a.id', '=', -1];
+                }
+            }
 
             $map = empty($map) ? true : $map;
             //数据查询
@@ -2228,7 +2311,8 @@ class Orders extends Auth {
                     ->leftJoin('order_mode om','a.order_mode=om.id')
                     ->field('a.*,om.in_content as order_mode_text,dp.title as dep,cd.title as device_name,cc.title as type_name,b.priority,ad.title as start_name,ade.title as end_name')
                     ->whereOr($map6)
-                    ->order($order)->select();
+                    ->order($order)
+                    ->select();
                 foreach ($lists as $k => $v) {
                     // $lists[$k] = $this->model->newFormatOrder($v);
                     $lists[$k]['priority'] = isset($this->model->priority[$v['priority']])?$this->model->priority[$v['priority']]:"";
@@ -2270,7 +2354,10 @@ class Orders extends Auth {
                     ->setCellValue('F1', '状态')
                     ->setCellValue('G1', '紧急程度')
                     ->setCellValue('H1', '来源')
-                    ->setCellValue('I1', '物料');
+                    ->setCellValue('I1', '物料名称')
+                    ->setCellValue('J1', '单价')
+                    ->setCellValue('K1', '数量')
+                    ->setCellValue('L1', '总价');
             }
             else {
                 if ($mode == 3) {
@@ -2375,15 +2462,29 @@ class Orders extends Auth {
                     $objPHPExcel->getActiveSheet()->setCellValue('F' . ($i + 2), $lists[$i]['order_mode_text']);
                     $objPHPExcel->getActiveSheet()->setCellValue('G' . ($i + 2), $lists[$i]['repair_priority']);
                     $objPHPExcel->getActiveSheet()->setCellValue('H' . ($i + 2), $lists[$i]['source_type_text']);
-
+                    $goodsName = $goodsPrice = $goodsNum = $goodsTotal  = '';
                     if(empty($lists[$i]['cons'])){
                         $objPHPExcel->getActiveSheet()->setCellValue('I' . ($i + 2), "");
+                        $objPHPExcel->getActiveSheet()->setCellValue('J' . ($i + 2), "");
+                        $objPHPExcel->getActiveSheet()->setCellValue('K' . ($i + 2), "");
+                        $objPHPExcel->getActiveSheet()->setCellValue('L' . ($i + 2), "");
                     }else{
-                        $consstr = [];
+
+                        $objPHPExcel->getActiveSheet()->getStyle('I'.($i + 2))->getAlignment()->setWrapText(true);
+                        $objPHPExcel->getActiveSheet()->getStyle('J'.($i + 2))->getAlignment()->setWrapText(true);
+                        $objPHPExcel->getActiveSheet()->getStyle('K'.($i + 2))->getAlignment()->setWrapText(true);
+                        $objPHPExcel->getActiveSheet()->getStyle('L'.($i + 2))->getAlignment()->setWrapText(true);
                         foreach ($lists[$i]['cons'] as $kk=>$vv){
-                            $consstr[] = $vv['title'].'_'.$vv['total'].'_'.$vv['money']."_".$vv['total_money']."_".$vv['realName'];
+//                            $consstr[] = $vv['title'].'_'.$vv['total'].'_'.$vv['money']."_".$vv['total_money']."_".$vv['realName'];
+                            $goodsName.= $vv['title']."\r\n";
+                            $goodsPrice.= $vv['total']."\r\n";
+                            $goodsNum.= $vv['money']."\r\n";
+                            $goodsTotal.= $vv['total_money']."\r\n";
                         }
-                        $objPHPExcel->getActiveSheet()->setCellValue('I' . ($i + 2), implode(";",$consstr));
+                        $objPHPExcel->getActiveSheet()->setCellValue('I' . ($i + 2), $goodsName);
+                        $objPHPExcel->getActiveSheet()->setCellValue('J' . ($i + 2), $goodsPrice);
+                        $objPHPExcel->getActiveSheet()->setCellValue('K' . ($i + 2), $goodsNum);
+                        $objPHPExcel->getActiveSheet()->setCellValue('L' . ($i + 2), $goodsTotal);
                     }
                 }
             }

+ 55 - 1
application/admin/controller/Todo.php

@@ -445,6 +445,31 @@ class Todo extends Auth
                 $lists[$k] = $this->model->newFormatTodo($v);
                 $lists[$k]['content'] = $this->removeEmojiChar($v['content']);
                 $lists[$k]['priority'] = isset(model('Orders')->priority[$v['priority']])?model('Orders')->priority[$v['priority']]:"";
+                $lists[$k]['cons'] = [];
+                if($v['work_type_mode'] == 1){
+                    $todo_mate = Db::name('todo_mate')
+                        ->where('todo_id',$v['id'])
+                        ->select();
+                    if(!empty($todo_mate)){
+                        $cons = Db::name('todo_mate_item')
+                            ->alias('a')
+                            ->join('mate_goods b','b.id = a.items_id')
+                            ->where('a.todo_mate_id','in',array_column($todo_mate,'id'))
+                            ->field('a.*,b.title')
+                            ->select();
+                        foreach ($cons as $k1=>$v1){
+                            $lists[$k]['cons'][] = [
+                                'title' =>$v1['title'],
+                                'total' =>$v1['total'],
+                                'money' =>$v1['money'],
+                                'total_money' =>$v1['total_money'],
+                            ];
+
+                        }
+                    }
+                }
+
+
             }
 
             include_once env('root_path') . '/extend/phpexcel/Classes/PHPExcel.php';
@@ -477,7 +502,11 @@ class Todo extends Auth
                     ->setCellValue('T1', '所在科室/部门')
                     ->setCellValue('U1', '来源')
                     ->setCellValue('V1', '部门分类')
-                    ->setCellValue('w1', '签名图');
+                    ->setCellValue('W1', '签名图')
+                    ->setCellValue('X1', '物品名称')
+                    ->setCellValue('Y1', '单价')
+                    ->setCellValue('Z1', '数量')
+                    ->setCellValue('AA1', '总价');
             }
             else {
                 if ($mode == 3) {
@@ -652,6 +681,31 @@ class Todo extends Auth
                     }
                     $objActSheet->getRowDimension($i + 2)->setRowHeight(40); // 行高
 
+
+                    $goodsName = $goodsPrice = $goodsNum = $goodsTotal  = '';
+                    if(empty($lists[$i]['cons'])){
+                        $objPHPExcel->getActiveSheet()->setCellValue('X' . ($i + 2), "");
+                        $objPHPExcel->getActiveSheet()->setCellValue('Y' . ($i + 2), "");
+                        $objPHPExcel->getActiveSheet()->setCellValue('Z' . ($i + 2), "");
+                        $objPHPExcel->getActiveSheet()->setCellValue('AA' . ($i + 2), "");
+                    }else{
+                        $objPHPExcel->getActiveSheet()->getStyle('X'.($i + 2))->getAlignment()->setWrapText(true);
+                        $objPHPExcel->getActiveSheet()->getStyle('Y'.($i + 2))->getAlignment()->setWrapText(true);
+                        $objPHPExcel->getActiveSheet()->getStyle('Z'.($i + 2))->getAlignment()->setWrapText(true);
+                        $objPHPExcel->getActiveSheet()->getStyle('AA'.($i + 2))->getAlignment()->setWrapText(true);
+
+                        foreach ($lists[$i]['cons'] as $kk=>$vv){
+                            $goodsName.= $vv['title']."\r\n";
+                            $goodsPrice.= $vv['total']."\r\n";
+                            $goodsNum.= $vv['money']."\r\n";
+                            $goodsTotal.= $vv['total_money']."\r\n";
+                        }
+                        $objPHPExcel->getActiveSheet()->setCellValue('X' . ($i + 2), $goodsName);
+                        $objPHPExcel->getActiveSheet()->setCellValue('Y' . ($i + 2), $goodsPrice);
+                        $objPHPExcel->getActiveSheet()->setCellValue('Z' . ($i + 2), $goodsNum);
+                        $objPHPExcel->getActiveSheet()->setCellValue('AA' . ($i + 2), $goodsTotal);
+                    }
+
                 }
             }
             else {

+ 8 - 1
application/admin/controller/WastePackage.php

@@ -63,9 +63,16 @@ class WastePackage extends Auth {
                     ->where('org_id',$this->orgId)
                     ->sum('weight');
 
-                $lists[$k]['weight'] = round($weight / 1000, 2);
+                $num = Db::name('waste_record')
+                    ->where('id','in',$ids)
+                    ->where('del',0)
+                    ->where('org_id',$this->orgId)
+                    ->sum('num');
+                $kg = round($weight / 1000, 2);
+                $lists[$k]['weight'] = $kg;
                 $lists[$k]['count'] = $record?$record:0;
                 $lists[$k]['qrcode'] = url('Qrcode/qrcode') . '?code=' . $v['sn'];
+
             }
             //数据返回
             $totalCount = db($this->table)->where($map)->count();

+ 9 - 1
application/admin/controller/WastePrintLog.php

@@ -87,7 +87,7 @@ class WastePrintLog extends Auth {
             ->alias('wr')
             ->where('wr.del',0)
             ->where('wr.id','in',$recordId)
-            ->field('wr.waste_device_id,wr.cateid,wr.create_time,wr.is_print,wr.serial_number,wr.id,wr.weight,wr.sign,wr.sign_path')
+            ->field('wr.waste_device_id,wr.cateid,wr.create_time,wr.is_print,wr.serial_number,wr.id,wr.weight,wr.sign,wr.sign_path,wr.num')
             ->order('wr.id desc')
             ->select();
 
@@ -101,7 +101,15 @@ class WastePrintLog extends Auth {
                 ->where('id',$v['cateid'])->value('title');
             $record[$k]['weight'] = sprintf("%.2f",$v['weight']/1000);
 
+            $cate = Db::name('waste_type')->where('id',$v['cateid'])->find();
+
+            $tnum = round($v['weight'] / 1000, 2).'kg';
+            if($cate['type'] == 1 && $v['num'] > 0){
+                $tnum = round($v['weight'] / 1000, 2).'kg'.'('.$cate['unit'].')';
+            }
+            $record[$k]['tum'] = $tnum;
         }
+
         $info['record'] = $record;
         $this->assign('info',$info);
         return $this->fetch();

+ 89 - 14
application/admin/controller/WasteRecord.php

@@ -63,9 +63,11 @@ class WasteRecord extends Auth {
             $map[] = ['org_id', '=', $this->orgId];
             $map = empty($map) ? true : $map;
             //数据查询
-            $lists = db($this->table)->where($map)
+            $lists = db($this->table)
+                ->where($map)
                 ->limit($start, $length)
-                ->order($order)->select();
+                ->order($order)
+                ->select();
             foreach ($lists as $k => $v) {
                 $lists[$k]['waste_device'] = db('address')
                     ->where('id', $v['waste_device_id'])
@@ -76,9 +78,18 @@ class WasteRecord extends Auth {
                 $lists[$k]['cate'] = db('waste_type')
                     ->where('id', $v['cateid'])
                     ->value('title');
-                $lists[$k]['weight'] = round($v['weight'] / 1000, 2);
+//                $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']];
+
+                $type = Db::name('waste_type')
+                    ->where('id', $v['cateid'])
+                    ->find();
+                $num = '';
+                if($type['type'] == 1 && $v['num'] > 0){
+                    $num = ' ('.$v['num'].$type['unit'].')';
+                }
+                $lists[$k]['weight'] = round($v['weight'] / 1000, 2).$num;
             }
             //数据返回
             $totalCount = db($this->table)->where($map)->count();
@@ -172,9 +183,18 @@ class WasteRecord extends Auth {
                 $lists[$k]['cate'] = db('waste_type')
                     ->where('id', $v['cateid'])
                     ->value('title');
-                $lists[$k]['weight'] = round($v['weight'] / 1000, 2);
+             //   $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']];
+
+                $type = Db::name('waste_type')
+                    ->where('id', $v['cateid'])
+                    ->find();
+                $num = '';
+                if($type['type'] == 1 && $v['num'] > 0){
+                    $num = ' ('.$v['num'].$type['unit'].')';
+                }
+                $lists[$k]['weight'] = round($v['weight'] / 1000, 2).$num;
             }
             //数据返回
             $totalCount = db($this->table)->where($map)->count();
@@ -185,11 +205,19 @@ class WasteRecord extends Auth {
             $result['records'] = $totalCount;
             $result['rows'] = $lists;
             $types = (new \app\common\model\WasteType())->getList($this->orgId);
+            $tname = '';
+
             foreach ($types as $k=>$v){
                 $weight = db($this->table)->where($map)->where('cateid',$v['id'])->sum('weight');
-                $types[$k]['weight'] = round($weight/1000,2);
+                $tname .= $v['title'].':'.round($weight/1000,2).'kg'.' ';
+                if($v['type'] == 1){
+                    $num = db($this->table)->where($map)->where('cateid',$v['id'])->sum('num');
+                    $tname .=  $v['title'].':'.round($weight/1000,2).'kg'.'('.$num.$v['unit'].' ) ';
+                }
+
+              //  $types[$k]['weight'] = round($weight/1000,2);
             }
-            $result['types'] = $types;
+            $result['tnames'] = $tname;
             return json($result);
         }
         else {
@@ -268,6 +296,15 @@ class WasteRecord extends Auth {
                 $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']];
+
+                $type = Db::name('waste_type')
+                    ->where('id', $v['cateid'])
+                    ->find();
+                $num = '';
+                if($type['type'] == 1 && $v['num'] > 0){
+                    $num = ' ('.$v['num'].$type['unit'].')';
+                }
+                $lists[$k]['weight'] = round($v['weight'] / 1000, 2).$num;
             }
             //数据返回
             $totalCount = db($this->table)->where($map)->count();
@@ -281,10 +318,23 @@ class WasteRecord extends Auth {
 
 
             $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);
+//            }
+            $tname = '';
+
             foreach ($types as $k=>$v){
                 $weight = db($this->table)->where($map)->where('cateid',$v['id'])->sum('weight');
-                $types[$k]['weight'] = round($weight/1000,2);
+                $tname .= $v['title'].':'.round($weight/1000,2).'kg'.' ';
+                if($v['type'] == 1){
+                    $num = db($this->table)->where($map)->where('cateid',$v['id'])->sum('num');
+                    $tname .=  $v['title'].':'.round($weight/1000,2).'kg'.'('.$num.$v['unit'].' ) ';
+                }
+
+                //  $types[$k]['weight'] = round($weight/1000,2);
             }
+            $result['tnames'] = $tname;
             $result['types'] = $types;
 
             return json($result);
@@ -300,16 +350,16 @@ class WasteRecord extends Auth {
 
     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'),
+                'weight' => input('weight',0),
                 'create_time' => input('create_time'),
                 'status' => 0,
-                'is_print' => 0
+                'is_print' => 0,
+                'num'=>input('num',0)
             ];
             if(!$data['waste_device_id']){
                 $this->error('未选择收取科室');
@@ -318,9 +368,19 @@ class WasteRecord extends Auth {
                 $this->error('类型不能为空');
             }
 
-            if($data['weight'] <= 0){
-                $this->error('称重必须大于0');
+            $type = Db::name('waste_type')->where('id',$data['cateid'])->find();
+            if(!$type){
+                $this->error('类型不存在');
+            }
+
+            if($type['type'] == 0 && $data['weight'] <= 0){
+                $this->error('重量不能为空');
             }
+
+            if($type['type'] == 1 && $data['num'] <= 0){
+                HelpHander::error('数量不能为空');
+            }
+
             if(!$data['create_time']){
                 $this->error('未选择收取时间');
             }
@@ -481,9 +541,17 @@ class WasteRecord extends Auth {
                 $lists[$k]['cate'] = db('waste_type')
                     ->where('id', $v['cateid'])
                     ->value('title');
-                $lists[$k]['weight'] = round($v['weight'] / 1000, 2);
+               // $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']];
+                $type = Db::name('waste_type')
+                    ->where('id', $v['cateid'])
+                    ->find();
+                $num = '';
+                if($type['type'] == 1 && $v['num'] > 0){
+                    $num = ' ('.$v['num'].$type['unit'].')';
+                }
+                $lists[$k]['weight'] = round($v['weight'] / 1000, 2).$num;
             }
             include_once env('root_path').'/extend/phpexcel/Classes/PHPExcel.php';
             //实例化PHPExcel类
@@ -670,6 +738,7 @@ class WasteRecord extends Auth {
             $this->error('未选择记录');
         }
         $info = $this->model->getOne($id,cur_org_id());
+        $info['type'] = Db::name('waste_type')->where('id',$info['cateid'])->value('type');
         if (!$info) {
             $this->error('医废记录不存在');
         }
@@ -686,7 +755,7 @@ class WasteRecord extends Auth {
             $old = Db::name('waste_record')
                 ->where('id',$info['id'])
                 ->find();
-            $key = ['user_id','cateid','weight','waste_device_id'];
+            $key = ['user_id','cateid','weight','waste_device_id','num'];
             $su = 0;
             foreach ($key as $kk=>$vv){
                 if($data[$vv]!=$old[$vv]){
@@ -736,4 +805,10 @@ class WasteRecord extends Auth {
         }
     }
 
+    public function wasteType(){
+        $id = input('id');
+        $info  = Db::name('waste_type')->where('id',$id)->find();
+        $this->success('操作成功','',$info);
+    }
+
 }

+ 493 - 41
application/admin/controller/WasteStatistics.php

@@ -640,17 +640,20 @@ class WasteStatistics extends Auth {
             $tMap[] = ['id','in',explode(',',$type_id)];
             $typeList = Db::name('waste_type')
                 ->where($tMap)
-                ->field('id,title')
+                ->field('id,title,type')
                 ->select();
+
         }else{
             $typeList = Db::name('waste_type')
                 ->where($tMap)
-                ->field('id,title')
+                ->field('id,title,type')
                 ->select();
+
         }
 
         $data = $this->wasteDataDay($month,$addr_id,$type_id);
-        $this->assign('data',$data);
+
+        $this->assign('data',$data['list']);
         $this->assign('typeList',$typeList);
         $this->assign('typeList1',$typeList1);
         $this->assign('addressList',$addressList);
@@ -679,6 +682,144 @@ class WasteStatistics extends Auth {
         if($type_id!=''){
             $tMap[] = ['id','in',explode(',',$type_id)];
         }
+
+        $type = Db::name('waste_type')
+            ->where($tMap)
+            ->where('enable',1)
+            ->where('del',0)
+            ->select();
+
+
+        $date = date('Ymd',strtotime($month));
+        $tnum = $tkg = 0;
+
+        $records = Db::name('waste_record')
+            ->where('org_id',$org_id)
+            ->where('del',0)
+            ->where('create_yyyymmdd',$date)
+            ->field('waste_device_id,cateid,weight,num')
+            ->select();
+
+        foreach ($dep as $k=>$v){
+            $ttkg = $ttnums = 0;
+            foreach ($type as $k1=>$v1){
+
+                $datas = 0;
+                $totals = 0;
+                $weight = 0;
+                $weight2 = 0;
+                $ttnums = 0;
+                $totalkg = 0;
+                $num = '';
+                $totalNum = 0;
+                $num2 = '';
+                $totalNum2 = 0;
+                foreach ($records as $rk=>$rv){
+                    if($rv['waste_device_id'] == $v['id'] && $rv['cateid'] == $v1['id']){
+                        $datas++;
+                        $weight += $rv['weight'];
+//                        $weight2 += $rv['weight'];
+
+                        if($v1['type'] == 1){
+                            $totalNum += $rv['num'];
+                        }
+                    }
+
+                    if($rv['cateid'] == $v1['id']){
+                        if($addr_id!=''){
+                            $addr_ids = explode(',',$addr_id);
+                            if(in_array($rv['waste_device_id'],$addr_ids)){
+                                $totals++;
+                                $weight2 += $rv['weight'];
+                                if($v1['type'] == 1){
+                                    $totalNum2 += $rv['num'];
+                                }
+                            }
+                        }else{
+                            $totals++;
+                            $weight2 += $rv['weight'];
+                            if($v1['type'] == 1){
+                                $totalNum2 += $rv['num'];
+                            }
+                        }
+                    }
+
+                    if($rv['waste_device_id'] == $v['id']){
+                        if($addr_id!=''){
+                            $addr_ids = explode(',',$addr_id);
+                            if(in_array($rv['waste_device_id'],$addr_ids)){
+                                $ttnums++;
+                                $totalkg += $rv['weight'];
+                                if($v1['type'] == 1){
+                                    $totalNum2 += $rv['num'];
+                                }
+                            }
+                        }else{
+                            $ttnums++;
+                            $totalkg += $rv['weight'];
+                            if($v1['type'] == 1){
+                                $totalNum2 += $rv['num'];
+                            }
+                        }
+                    }
+                }
+
+                $dep[$k]['data'][] = $datas;
+                $dep[$k]['total'][] = $totals;
+//                $dep[$k]['data'][] = $weight?round($weight/1000,2):0;
+//                $dep[$k]['total'][] = $weight2?round($weight2/1000,2):0;
+                $dep[$k]['nums']  = $ttnums;
+                $ttkg = $totalkg?round($totalkg/1000,3):0;
+                $dep[$k]['totalkg'] = $ttkg;
+
+
+                $we =  $weight?round($weight/1000,3):0;
+
+                if($totalNum > 0){
+                    $num = '('.$totalNum.$v1['unit'].')';
+                }
+                $dep[$k]['data'][] = $we.$num;
+
+                $we2 =  $weight2?round($weight2/1000,3):0;
+                if($totalNum2 > 0){
+                    $num2 = '('.$totalNum2.$v1['unit'].')';
+                }
+                $dep[$k]['total'][] =$we2.$num2;
+
+              //  $dep[$k]['total'][] = $we2 > 0 ? $we2 : $totalNum2.$v1['unit'];
+            }
+            $tnum += $ttnums;
+            $tkg += $ttkg;
+        }
+
+        $data = [
+            'list'=>$dep,
+            'tnum'=>$tnum,
+            'tkg'=>$tkg,
+        ];
+
+        return $data;
+    }
+
+    public function wasteDataDayOld($month,$addr_id,$type_id){
+
+        $org_id = $this->orgId;
+        $aMap = [];
+        if($addr_id!=''){
+            $aMap[] = ['id','in',explode(',',$addr_id)];
+        }
+        $aMap[]=['','exp',Db::raw("FIND_IN_SET(7,types)")];
+        $dep = Db::name('address')
+            ->where('org_id',$org_id)
+            ->where('enable',1)
+            ->where('del',0)
+            ->where($aMap)
+            ->select();
+
+        $tMap = [];
+        if($type_id!=''){
+            $tMap[] = ['id','in',explode(',',$type_id)];
+        }
         $type = Db::name('waste_type')
             ->where('enable',1)
             ->where('del',0)
@@ -745,6 +886,7 @@ class WasteStatistics extends Auth {
         $addr_id = input('addr_id','');
         $type_id = input('type_id','');
         $data = $this->wasteDataDay($month,$addr_id,$type_id);
+        $data = $data['list'];
         $tMap[] = ['del','=',0];
         $tMap[] = ['enable','=',1];
         //$tMap[] = ['org_id','=',$this->orgId];
@@ -752,12 +894,13 @@ class WasteStatistics extends Auth {
             $tMap[] = ['id','in',explode(',',$type_id)];
             $type = Db::name('waste_type')
                 ->where($tMap)
-                ->field('id,title')
+                ->field('id,title,type')
                 ->select();
+
         }else{
             $type = Db::name('waste_type')
                 ->where($tMap)
-                ->field('id,title')
+                ->field('id,title,type')
                 ->select();
         }
 
@@ -783,7 +926,7 @@ class WasteStatistics extends Auth {
         $res.='<tr style="background: #ffffff;">';
         foreach ($type as $v){
             $res.=' <th style="text-align: center;background: #ffffff;border-bottom: 1px solid #ddd;border-right: 1px solid #ddd">件数/包</th>
-            <th style="text-align: center;background: #ffffff;border-bottom: 1px solid #ddd;border-right: 1px solid #ddd">重量/kg</th>';
+            <th style="text-align: center;background: #ffffff;border-bottom: 1px solid #ddd;border-right: 1px solid #ddd">重量kg</th>';
         }
         foreach ($data as $k=>$v){
             $res.='<tr style="background: #ffffff;">';
@@ -829,16 +972,19 @@ class WasteStatistics extends Auth {
             $tMap[] = ['id','in',explode(',',$type_id)];
             $typeList = Db::name('waste_type')
                 ->where($tMap)
-                ->field('id,title')
+                ->field('id,title,type')
                 ->select();
+
         }else{
             $typeList = Db::name('waste_type')
                 ->where($tMap)
-                ->field('id,title')
+                ->field('id,title,type')
                 ->select();
+
         }
 
         $data = $this->wasteMonthData($month,$addr_id,$type_id);
+
         $this->assign('data',$data['res']);
         $this->assign('totalData',$data['total']);
         $this->assign('typeList',$typeList);
@@ -850,6 +996,7 @@ class WasteStatistics extends Auth {
         return $this->fetch();
     }
 
+
     public function wasteMonthData($month,$addr_id,$type_id){
 
         $org_id = $this->orgId;
@@ -859,6 +1006,149 @@ class WasteStatistics extends Auth {
         if($type_id!=''){
             $tMap[] = ['id','in',explode(',',$type_id)];
         }
+//        $type = Db::name('waste_type')
+//            ->where('enable',1)
+//            ->where('del',0)
+//            ->where($tMap)
+//            ->select();
+
+        $type = Db::name('waste_type')
+            ->where($tMap)
+            ->where('enable',1)
+            ->where('del',0)
+            ->select();
+
+        $newTypeIds = array_column($type,'id');
+
+        $res = [];
+        $total = [];
+        $records = Db::name('waste_record')
+            ->alias('wr')
+            ->join('address a','a.id=wr.waste_device_id')
+            ->join('waste_type wt','wt.id=wr.cateid')
+            ->where('wr.org_id',$org_id)
+            ->where('wr.del',0)
+            ->where('wr.cateid','in',$newTypeIds)
+            ->where('wr.create_yyyymm',date('Ym',strtotime($month)))
+            ->field('wr.waste_device_id,wr.cateid,wr.weight,wr.create_yyyymmdd,wr.num')
+            ->select();
+        $tnum = $tkg = 0;
+        foreach ($dep as $k=>$v){
+            $ttkg = $ttnums = 0;
+            foreach ($type as $k1=>$v1){
+                $row = 0;
+                $row2 = 0;
+                $kg = 0;
+                $kg2 = 0;
+                $num = '';
+                $totalNum = 0;
+                $num2 = '';
+                $totalNum2 = 0;
+
+                $ttnums = 0;
+                $totalkg  = 0;
+
+                foreach ($records as $rk=>$rv){
+                    if($rv['cateid'] == $v1['id'] && $rv['create_yyyymmdd'] == $v){
+                        if($addr_id!=''){
+                            $addr_ids = explode(',',$addr_id);
+                            if(in_array($rv['waste_device_id'],$addr_ids)){
+                                $row++;
+                                $kg += $rv['weight'];
+
+                                if($v1['type'] == 1){
+                                    $totalNum += $rv['num'];
+                                }
+                            }
+                        }else{
+                            $row++;
+                            $kg += $rv['weight'];
+                            if($v1['type'] == 1){
+                                $totalNum += $rv['num'];
+                            }
+                        }
+                    }
+
+                    if($rv['create_yyyymmdd'] == $v){
+                        if($addr_id!=''){
+                            $addr_ids = explode(',',$addr_id);
+                            if(in_array($rv['waste_device_id'],$addr_ids)){
+                                $ttnums +=1;
+                                $totalkg += $rv['weight'];
+                            }
+                        }else{
+                            $ttnums +=1;
+                            $totalkg += $rv['weight'];
+                        }
+
+                    }
+
+                    if($rv['cateid'] == $v1['id']){
+                        if($addr_id!=''){
+                            $addr_ids = explode(',',$addr_id);
+                            if(in_array($rv['waste_device_id'],$addr_ids)){
+                                $row2++;
+                                $kg2 += $rv['weight'];
+                                if($v1['type'] == 1){
+                                    $totalNum2 += $rv['num'];
+                                }
+                            }
+                        }else{
+                            $row2++;
+                            $kg2 += $rv['weight'];
+                            if($v1['type'] == 1){
+                                $totalNum2 += $rv['num'];
+                            }
+                        }
+                    }
+                }
+                $res[$k]['list'][] = $row;
+                $total[$k][] = $row2;
+
+                $res[$k]['nums']  = $ttnums;
+                $ttkg = $totalkg?round($totalkg/1000,3):0;
+                $res[$k]['totalkg'] = $ttkg;
+
+                $we =  $kg?round($kg/1000,2):0;
+             //   $res[$k]['list'][] = $we > 0 ? $we : $totalNum.$v1['unit'];
+
+                $we2 =  $kg2?round($kg2/1000,2):0;
+
+
+                if($totalNum > 0){
+                    $num = '('.$totalNum.$v1['unit'].')';
+                }
+                $res[$k]['list'][] = $we.$num;
+
+                if($totalNum2 > 0){
+                    $num2 = '('.$totalNum2.$v1['unit'].')';
+                }
+                $total[$k][] =$we2.$num2;
+
+               // $total[$k][] = $we2 > 0 ? $we2 : $totalNum2.$v1['unit'];
+
+//                $we =  $kg?round($kg/1000,2):0;
+//                $res[$k][] = $we;
+//
+//                $we =  $kg2?round($kg2/1000,2):0;
+//                $total[$k][] =$we;
+            }
+            $tnum += $ttnums;
+            $tkg += $ttkg;
+        }
+
+        return ['res'=>$res,'total'=>$total,'tnum'=>$tnum,'tkg'=>$tkg];
+    }
+
+    public function wasteMonthDataOld($month,$addr_id,$type_id){
+
+        $org_id = $this->orgId;
+        $dep  = getDay(strtotime($month));
+
+        $tMap = [];
+        if($type_id!=''){
+            $tMap[] = ['id','in',explode(',',$type_id)];
+        }
         $type = Db::name('waste_type')
             ->where('enable',1)
             ->where('del',0)
@@ -934,15 +1224,17 @@ class WasteStatistics extends Auth {
             $tMap[] = ['id','in',explode(',',$type_id)];
             $typeList = Db::name('waste_type')
                 ->where($tMap)
-                ->field('id,title')
+                ->field('id,title,type')
                 ->select();
         }else{
             $typeList = Db::name('waste_type')
                 ->where($tMap)
-                ->field('id,title')
+                ->field('id,title,type')
                 ->select();
         }
+
         $data = $this->wasteMonthData($month,$addr_id,$type_id);
+        $lists = $data['res'];
         $title = '医废月统计';
         if(!empty($month)){
             $title = $month.'医废月统计';
@@ -965,19 +1257,22 @@ class WasteStatistics extends Auth {
         $res.='<tr style="background: #ffffff;">';
         foreach ($typeList as $v){
             $res.=' <th style="text-align: center;background: #ffffff;border-bottom: 1px solid #ddd;border-right: 1px solid #ddd">件数/包</th>
-            <th style="text-align: center;background: #ffffff;border-bottom: 1px solid #ddd;border-right: 1px solid #ddd">重量/kg</th>';
+            <th style="text-align: center;background: #ffffff;border-bottom: 1px solid #ddd;border-right: 1px solid #ddd">重量kg</th>';
         }
-        foreach ($data['res'] as $k=>$v){
-            $res.='<tr style="background: #ffffff;">';
-            $kk = $k+1;
-            $res.='<td style="text-align: center;border-bottom: 1px solid #ddd;border-right: 1px solid #ddd">'.$kk.'</td>';
-            foreach ($v as $k1=>$v1){
-                $res.='<td style="text-align: center;border-bottom: 1px solid #ddd;border-right: 1px solid #ddd">'.$v1.'</td>';
-            }
-            $res.='<td style="text-align: center;border-bottom: 1px solid #ddd;border-right: 1px solid #ddd"></td>';
-            $res.='</tr>';
+        if(isset($lists['list'])){
+            foreach ($lists['list'] as $k=>$v){
+                $res.='<tr style="background: #ffffff;">';
+                $kk = $k+1;
+                $res.='<td style="text-align: center;border-bottom: 1px solid #ddd;border-right: 1px solid #ddd">'.$kk.'</td>';
+                foreach ($v as $k1=>$v1){
+                    $res.='<td style="text-align: center;border-bottom: 1px solid #ddd;border-right: 1px solid #ddd">'.$v1.'</td>';
+                }
+                $res.='<td style="text-align: center;border-bottom: 1px solid #ddd;border-right: 1px solid #ddd"></td>';
+                $res.='</tr>';
 
+            }
         }
+
         $res.='<tr style="background: #ffffff;">
                <td style="text-align: center;border-bottom: 1px solid #ddd;border-right: 1px solid #ddd">共计:</td>';
         if(!empty($data['total'])){
@@ -1009,17 +1304,19 @@ class WasteStatistics extends Auth {
             $tMap[] = ['id','in',explode(',',$type_id)];
             $typeList = Db::name('waste_type')
                 ->where($tMap)
-                ->field('id,title')
+                ->field('id,title,type')
                 ->select();
+
         }else{
             $typeList = Db::name('waste_type')
                 ->where($tMap)
-                ->field('id,title')
+                ->field('id,title,type')
                 ->select();
+
         }
 
         $data = $this->wasteYearsData($month,$addr_id,$type_id);
-        $this->assign('data',$data);
+        $this->assign('data',$data['list']);
         $this->assign('typeList',$typeList);
         $this->assign('typeList1',$typeList1);
         $this->assign('addressList',$addressList);
@@ -1032,6 +1329,131 @@ class WasteStatistics extends Auth {
     public function wasteYearsData($month,$addr_id,$type_id){
 
         $org_id = $this->orgId;
+        $dep  = get_month1($month);
+
+        $tMap = [];
+        if($type_id!=''){
+            $tMap[] = ['id','in',explode(',',$type_id)];
+        }
+
+
+        $type = Db::name('waste_type')
+            ->where($tMap)
+            ->where('enable',1)
+            ->where('del',0)
+            ->select();
+
+        $records = Db::name('waste_record')
+            ->where('org_id',$org_id)
+            ->where('del',0)
+            ->where('create_yyyy',$month)
+            ->field('waste_device_id,cateid,weight,create_yyyymm,num')
+            ->select();
+        $tnum = $tkg = 0;
+        foreach ($dep as $k=>$v){
+            $ttkg = $ttnums = 0;
+            foreach ($type as $k1=>$v1){
+                $row = 0;
+                $row2 = 0;
+                $kg = 0;
+                $kg2 = 0;
+                $num = '';
+                $totalNum = 0;
+                $num2 = '';
+                $totalNum2 = 0;
+
+                $ttnums = 0;
+                $totalkg = 0;
+
+                foreach ($records as $rk=>$rv){
+                    if($rv['cateid'] == $v1['id'] && $rv['create_yyyymm'] == $v['date']){
+                        if($addr_id!=''){
+                            $addr_ids = explode(',',$addr_id);
+                            if(in_array($rv['waste_device_id'],$addr_ids)){
+                                $row++;
+                                $kg += $rv['weight'];
+                                if($v1['type'] == 1){
+                                    $totalNum += $rv['num'];
+                                }
+                            }
+                        }else{
+                            $row++;
+                            $kg += $rv['weight'];
+                            if($v1['type'] == 1){
+                                $totalNum += $rv['num'];
+                            }
+                        }
+                    }
+
+                    if($rv['create_yyyymm'] == $v['date']){
+                        if($addr_id!=''){
+                            $addr_ids = explode(',',$addr_id);
+                            if(in_array($rv['waste_device_id'],$addr_ids)){
+                                $ttnums++;
+                                $totalkg += $rv['weight'];
+                            }
+                        }else{
+                            $ttnums++;
+                            $totalkg += $rv['weight'];
+                        }
+
+                    }
+
+                    if($rv['cateid'] == $v1['id']){
+                        if($addr_id!=''){
+                            $addr_ids = explode(',',$addr_id);
+                            if(in_array($rv['waste_device_id'],$addr_ids)){
+                                $row2++;
+                                $kg2 += $rv['weight'];
+                                if($v1['type'] == 1){
+                                    $totalNum2 += $rv['num'];
+                                }
+                            }
+                        }else{
+                            $row2++;
+                            $kg2 += $rv['weight'];
+                            if($v1['type'] == 1){
+                                $totalNum2 += $rv['num'];
+                            }
+                        }
+                    }
+                }
+                $dep[$k]['list'][] = $row;
+                $dep[$k]['total'][] = $row2;
+
+                $dep[$k]['nums']  = $ttnums;
+                $ttkg = $totalkg?round($totalkg/1000,3):0;
+                $dep[$k]['totalkg'] = $ttkg;
+
+
+                $we =  $kg?round($kg/1000,2):0;
+                $we2 =  $kg2?round($kg2/1000,2):0;
+
+                if($totalNum > 0){
+                    $num = '('.$totalNum.$v1['unit'].')';
+                }
+                $dep[$k]['list'][] = $we.$num;
+
+                if($totalNum2 > 0){
+                    $num2 = '('.$totalNum2.$v1['unit'].')';
+                }
+                $dep[$k]['total'][] =$we2.$num2;
+            }
+            $tnum += $ttnums;
+            $tkg += $ttkg;
+        }
+
+        $data = [
+            'list'=>$dep,
+            'tnum'=>$tnum,
+            'tkg'=>$tkg,
+        ];
+        return $data;
+    }
+
+    public function wasteYearsDataOld($month,$addr_id,$type_id){
+
+        $org_id = $this->orgId;
         $dep  = get_month($month);
 
         $tMap = [];
@@ -1110,15 +1532,17 @@ class WasteStatistics extends Auth {
             $tMap[] = ['id','in',explode(',',$type_id)];
             $typeList = Db::name('waste_type')
                 ->where($tMap)
-                ->field('id,title')
+                ->field('id,title,type')
                 ->select();
         }else{
             $typeList = Db::name('waste_type')
                 ->where($tMap)
-                ->field('id,title')
+                ->field('id,title,type')
                 ->select();
         }
+
         $data = $this->wasteYearsData($month,$addr_id,$type_id);
+        $list = $data['list'];
         $title = '医废年统计';
         if(!empty($month)){
             $title = $month.'医废年统计';
@@ -1141,27 +1565,34 @@ class WasteStatistics extends Auth {
         $res.='<tr style="background: #ffffff;">';
         foreach ($typeList as $v){
             $res.=' <th style="text-align: center;background: #ffffff;border-bottom: 1px solid #ddd;border-right: 1px solid #ddd">件数/包</th>
-            <th style="text-align: center;background: #ffffff;border-bottom: 1px solid #ddd;border-right: 1px solid #ddd">重量/kg</th>';
+            <th style="text-align: center;background: #ffffff;border-bottom: 1px solid #ddd;border-right: 1px solid #ddd">重量kg</th>';
         }
         $res.='</tr>';
 
-        foreach ($data as $k=>$v){
-            $res.='<tr style="background: #ffffff;">';
-            $res.='<td style="text-align: center;border-bottom: 1px solid #ddd;border-right: 1px solid #ddd">'.$v['key'].'</td>';
-            foreach ($v['list'] as $k1=>$v1){
-                $res.='<td style="text-align: center;border-bottom: 1px solid #ddd;border-right: 1px solid #ddd">'.$v1.'</td>';
-            }
-            $res.='<td style="text-align: center;border-bottom: 1px solid #ddd;border-right: 1px solid #ddd"></td>';
-            $res.='</tr>';
+        if(isset($list[0]['list'])){
+            foreach ($list as $k=>$v){
+                $res.='<tr style="background: #ffffff;">';
+                $res.='<td style="text-align: center;border-bottom: 1px solid #ddd;border-right: 1px solid #ddd">'.$v['key'].'</td>';
+                if(isset($v['list'])){
+                    foreach ($v['list'] as $k1=>$v1){
+                        $res.='<td style="text-align: center;border-bottom: 1px solid #ddd;border-right: 1px solid #ddd">'.$v1.'</td>';
+                    }
+                }
 
+                $res.='<td style="text-align: center;border-bottom: 1px solid #ddd;border-right: 1px solid #ddd"></td>';
+                $res.='</tr>';
+            }
         }
+
         $res.='<tr style="background: #ffffff;">
                <td style="text-align: center;border-bottom: 1px solid #ddd;border-right: 1px solid #ddd">共计:</td>';
-        if(!empty($data)){
-            foreach ($data[1]['total'] as $k1=>$v1){
+
+        if(isset($list[1]['total'])){
+            foreach ($list[1]['total'] as $k1=>$v1){
                 $res.=' <td style="text-align: center;border-bottom: 1px solid #ddd;border-right: 1px solid #ddd">'.$v1.'</td>';
             }
         }
+
         $res.='<td style="border-bottom: 1px solid #ddd;border-right: 1px solid #ddd"></td>
        </tr>';
         echo $res;
@@ -1185,15 +1616,16 @@ class WasteStatistics extends Auth {
             $tMap[] = ['id','in',explode(',',$type_id)];
             $typeList = Db::name('waste_type')
                 ->where($tMap)
-                ->field('id,title')
+                ->field('id,title,type')
                 ->select();
         }else{
             $typeList = Db::name('waste_type')
                 ->where($tMap)
-                ->field('id,title')
+                ->field('id,title,type')
                 ->select();
         }
 
+
         $data = $this->wasteZcData($addr_id,$type_id);
 
         $this->assign('data',$data);
@@ -1234,6 +1666,7 @@ class WasteStatistics extends Auth {
                 })
                 ->count();
             $res[]= $row;
+
             $kg = Db::name('waste_record')
                 ->where('cateid',$v1['id'])
                 ->where('org_id',$org_id)
@@ -1244,10 +1677,28 @@ class WasteStatistics extends Auth {
                     $query->where('status', 1)->whereor('status', 2);
                 })
                 ->sum('weight');
+
             $we =  $kg?round($kg/1000,2):0;
+
+            $num = Db::name('waste_record')
+                ->where('cateid',$v1['id'])
+                ->where('org_id',$org_id)
+                ->where('del',0)
+                ->where($map1)
+                ->where(function ($query)
+                {
+                    $query->where('status', 1)->whereor('status', 2);
+                })
+                ->sum('num');
+
+            if($num > 0){
+                $we = $we.'kg'.'('.$num.$v1['unit'].')';
+            }
+
             $res[]= $we;
 
         }
+
         return $res;
     }
 
@@ -1265,15 +1716,16 @@ class WasteStatistics extends Auth {
             $tMap[] = ['id','in',explode(',',$type_id)];
             $typeList = Db::name('waste_type')
                 ->where($tMap)
-                ->field('id,title')
+                ->field('id,title,type')
                 ->select();
         }else{
             $typeList = Db::name('waste_type')
                 ->where($tMap)
-                ->field('id,title')
+                ->field('id,title,type')
                 ->select();
         }
 
+
         $data = $this->wasteZcData($addr_id,$type_id);
         $title = '医废暂存统计';
         header("Content-type: application/vnd.ms-excel");
@@ -1292,7 +1744,7 @@ class WasteStatistics extends Auth {
         $res.='<tr style="background: #ffffff;">';
         foreach ($typeList as $v){
             $res.=' <th style="text-align: center;background: #ffffff;border-bottom: 1px solid #ddd;border-right: 1px solid #ddd">件数/包</th>
-            <th style="text-align: center;background: #ffffff;border-bottom: 1px solid #ddd;border-right: 1px solid #ddd">重量/kg</th>';
+            <th style="text-align: center;background: #ffffff;border-bottom: 1px solid #ddd;border-right: 1px solid #ddd">重量kg</th>';
         }
         $res.='</tr>';
         $res.='<tr style="background: #ffffff;">';

+ 4 - 4
application/admin/controller/WasteType.php

@@ -33,7 +33,7 @@ class WasteType extends Auth
             }
 
             $map[] = ['del','=',0];
-            $map[] = ['org_id','in',[0,$this->orgId]];
+//            $map[] = ['org_id','in',[0,$this->orgId]];
             $map= empty($map) ? true: $map;
             //数据查询
             $lists = db($this->table)->where($map)->limit($start,$length)->order($order)->select();
@@ -61,9 +61,9 @@ class WasteType extends Auth
                 if(!$info){
                     $this->error('参数错误');
                 }
-                if($info['org_id'] <= 0){
-                    $this->error('共有类型无法修改');
-                }
+//                if($info['org_id'] <= 0){
+//                    $this->error('共有类型无法修改');
+//                }
             }
             $res = $this->model->updates();
             if($res){

+ 1 - 0
application/admin/view/orders/index1.html

@@ -133,6 +133,7 @@
                 {label:'申请时间',name:'create_time',index:'create_time',width:50,sortable: true},
                 {label:'内容',name:'content',index:'content',width:60,sortable: true},
                 {label:'所在科室/部门',name:'dep',index:'dep',width:60,sortable: true},
+                {label:'执行人',name:'to_user_names',index:'to_user_names',width:60,sortable: true},
                 // {label:'部门分类',name:'dep_cate_name',index:'dep_cate_name',width:60,sortable: true},
                 {label:'报修类型',name:'order_type',index:'order_type',width:60,sortable: true},
                 {label:'优先级',name:'repair_priority',index:'repair_priority',width:60,editable: false,sortable: false,formatter: function (a, b, c) {

+ 14 - 3
application/admin/view/orders/index3.html

@@ -27,6 +27,9 @@
                         <input type="text" class="form-control" name="content" placeholder="内容">
                     </div>
                     <div class="input-group">
+                        <input type="text" class="form-control" name="toUserName" placeholder="执行人">
+                    </div>
+                    <div class="input-group">
                         <input class="form-control" style="width: 155px !important;" id="start" readonly placeholder="申请开始时间" name="start" >
                     </div>
                     <div class="input-group">
@@ -49,6 +52,8 @@
                             {/foreach}
                         </select>
                     </div>
+                    <br/>
+                    <br/>
                     <div class="input-group">
                         <select name="from" class="form-control">
                             <option value="">来源</option>
@@ -61,8 +66,7 @@
                             <option value="3">投诉</option>
                         </select>
                     </div>
-                    <br/>
-                    <br/>
+
                     <div class="input-group">
                         <select name="saddr" class="form-control">
                             <option value="">开始地点</option>
@@ -80,7 +84,13 @@
                         </select>
                     </div>
                     <div class="input-group">
-                        <input type="text" class="form-control" name="typeName" placeholder="运送类型">
+<!--                        <input type="text" class="form-control" name="typeName" placeholder="运送类型">-->
+                        <select name="conveyCateId" class="form-control">
+                            <option value="">运送类型</option>
+                            {foreach $convey_cate as $k=>$v}
+                            <option value="{$v['id']}">{$v['title']}</option>
+                            {/foreach}
+                        </select>
                     </div>
                     <div class="input-group">
                         <select name="priority" class="form-control">
@@ -163,6 +173,7 @@
                 {label:'运送类型',name:'type_name',index:'type_name',width:40,sortable: true},
                 {label:'任务备注',name:'content',index:'content',width:60,sortable: true},
                 {label:'所在科室/部门',name:'dep',index:'dep',width:60,sortable: true},
+                {label:'执行人',name:'to_user_names',index:'to_user_names',width:60,sortable: true},
                 // {label:'部门分类',name:'dep_cate_name',index:'dep_cate_name',width:60,sortable: true},
                 {label:'来源',name:'source_type_text',index:'source_type_text',width:60,sortable: true},
                 {label:'联系方式',name:'mobile',index:'mobile',width:60,sortable: true},

+ 21 - 0
application/admin/view/waste_apply_option/info.html

@@ -102,6 +102,27 @@
                         </div>
                     </div>
                     {/if}
+
+                    {if $info.num !=$old.num}
+                    <div class="col-sm-6">
+                        <div class="form-group">
+                            <label class="control-label">数量(修改前)<span class="text-danger">*</span></label></br>
+                            <div style="padding-right: 10px">
+                                <input type="text" class="form-control" readonly value="{$old.num|default=''}">
+
+                            </div>
+                        </div>
+                    </div>
+                    <div class="col-sm-6">
+                        <div class="form-group">
+                            <label class="control-label">数量(修改后)<span class="text-danger">*</span></label></br>
+                            <div style="padding-right: 10px">
+                                <input type="text" class="form-control" readonly value="{$info.num|default=''}">
+
+                            </div>
+                        </div>
+                    </div>
+                    {/if}
                     <div class="col-sm-6">
                         <div class="form-group">
                             <label class="control-label">申请人<span class="text-danger">*</span></label></br>

+ 3 - 3
application/admin/view/waste_package/info.html

@@ -34,7 +34,7 @@
                         <th>收取人</th><td>{$info['real_name']}</td>
                     </tr>
                     <tr>
-                        <th>重量</th><td>{$info['weight']}/kg</td>
+                        <th>重量kg</th><td>{$info['kg']}</td>
                     </tr>
                     <tr>
                         <th>医废记录数</th><td>{$info['count']}</td>
@@ -64,7 +64,7 @@
                         <th class="text-center">收取科室</th>
                         <th class="text-center">称重序列号</th>
                         <th class="text-center">类别</th>
-                        <th class="text-center">重量(kg)</th>
+                        <th class="text-center">重量</th>
                         <th class="text-center">收取时间</th>
                     </tr>
                     {foreach $record as $key => $value}
@@ -74,7 +74,7 @@
                         <td>
                            {$value['cate_name']}
                         </td>
-                        <td>{$value['weight']}/kg</td>
+                        <td>{$value['tum']}</td>
                         <td>{$value['create_time']}</td>
                     </tr>
                     {/foreach}

+ 2 - 2
application/admin/view/waste_print_log/info.html

@@ -59,7 +59,7 @@
                         <th class="text-center">收取科室</th>
                         <th class="text-center">称重序列号</th>
                         <th class="text-center">类别</th>
-                        <th class="text-center">重量(kg)</th>
+                        <th class="text-center">数量/重量</th>
                         <th class="text-center">收取时间</th>
                     </tr>
                     {foreach $info['record'] as $key => $value}
@@ -69,7 +69,7 @@
                         <td>
                            {$value['cate_name']}
                         </td>
-                        <td>{$value['weight']}/kg</td>
+                        <td>{$value['tum']}</td>
                         <td>{$value['create_time']}</td>
                     </tr>
                     {/foreach}

+ 64 - 1
application/admin/view/waste_record/add.html

@@ -24,12 +24,38 @@
                             {:widget('common/select',['name'=>'cateid','lists'=>$type,'value'=>isset($info['cateid'])?$info['cateid']:''])}
                         </div>
                     </div>
-                    <div class="form-group">
+
+                 <!--   <div id="vueapp">
+                        <div class="form-group">
+                            <label class="col-sm-2 control-label">类型<span class="text-danger">*</span></label>
+                            <input type="hidden" name="cateid" :value="value">
+                            <div class="col-sm-6">
+                            <el-select clearable filterable v-model="value" placeholder="请选择" style="width: 100%;">
+                                <el-option
+                                        v-for="item in options"
+                                        :key="item.id"
+                                        :label="item.title"
+                                        :value="item.id.toString()">
+                                </el-option>
+                            </el-select>
+                            </div>
+                        </div>
+                    </div>-->
+
+                    <div class="form-group" id="typeWeight">
                         <label class="col-sm-2 control-label">重量(单位:克)<span class="text-danger">*</span></label>
                         <div class="col-sm-6">
                             <input type="text" class="form-control" name="weight" value="{$info.weight|default=''}">
                         </div>
                     </div>
+
+                    <div class="form-group" id="typeNum" >
+                        <label class="col-sm-2 control-label"> <text id="typeNumName">数量</text></label>
+                        <div class="col-sm-6">
+                            <input type="number" class="form-control" name="num" value="{$info.num|default=''}">
+                        </div>
+                    </div>
+
                     <div class="form-group">
                         <label class="col-sm-2 control-label">收取时间<span class="text-danger">*</span></label>
                         <div class="col-sm-6">
@@ -55,5 +81,42 @@
         formSetValue("enable", {$info.enable|default=1});
     });
 
+
+    // new Vue({
+    //     el: '#vueapp',
+    //     data: function() {
+    //         return {
+    //             options: {:json_encode($type)},
+    //             value:''
+    //     }
+    //     },
+    //     watch: {
+    //         value: function (newVal, oldVal) {
+    //             $('input[name=cateid]').val(newVal);
+    //             var that = this;
+    //             $.post('{:url("wasteType")}',{id:newVal},function (res) {
+    //                 let info = res.data;
+    //                 if(info){
+    //                    if(info.type == 0){
+    //                        $('#typeWeight').css('display','block');
+    //                        $('#typeNum').css('display','none');
+    //                    }else{
+    //                        $('#typeWeight').css('display','none');
+    //                        $('#typeNum').css('display','block');
+    //                        var unitname = info.unit;
+    //                        if(unitname){
+    //                            var ttname = '数量(单位:'+unitname+')';
+    //                        }else{
+    //                            var ttname = '数量';
+    //                        }
+    //                        $('#typeNumName').html(ttname);
+    //                    }
+    //                 }
+    //             })
+    //
+    //         }
+    //     }
+    // })
+
 </script>
 {/block}

+ 87 - 0
application/admin/view/waste_record/apply.html

@@ -30,6 +30,39 @@
                             <input type="text" class="form-control" name="weight" value="{$info.weight|default=''}">
                         </div>
                     </div>
+
+          <!--          <div id="vueapp">
+                        <div class="form-group">
+                            <label class="col-sm-2 control-label">类型<span class="text-danger">*</span></label>
+                            <input type="hidden" name="cateid" :value="value">
+                            <div class="col-sm-6">
+                                <el-select clearable filterable v-model="value" placeholder="请选择" style="width: 100%;">
+                                    <el-option
+                                            v-for="item in options"
+                                            :key="item.id"
+                                            :label="item.title"
+                                            :value="item.id.toString()">
+                                    </el-option>
+                                </el-select>
+                            </div>
+                        </div>
+                    </div>-->
+
+                <!--    <div class="form-group" id="typeWeight">
+                        <label class="col-sm-2 control-label">重量(单位:克)<span class="text-danger">*</span></label>
+                        <div class="col-sm-6">
+                            <input type="text" class="form-control" name="weight" value="{$info.weight|default=''}">
+                        </div>
+                    </div>
+-->
+                    <div class="form-group" id="typeNum">
+                        <label class="col-sm-2 control-label"> <text id="typeNumName">数量</text></label>
+                        <div class="col-sm-6">
+                            <input type="number" class="form-control" name="num" value="{$info.num|default=''}">
+                        </div>
+                    </div>
+
+
                     <div class="form-group">
                         <label class="col-sm-2 control-label">申请人<span class="text-danger">*</span></label>
                         <div class="col-sm-6">
@@ -63,5 +96,59 @@
     $(document).ready(function(){
     });
 
+    // var info = {:json_encode($info)};
+    // new Vue({
+    //     el: '#vueapp',
+    //     data: function() {
+    //         return {
+    //             options: {:json_encode($type)},
+    //             value:info ?info.cateid.toString():"0"
+    //     }
+    //     },
+    //     watch: {
+    //         value: function (newVal, oldVal) {
+    //             $('input[name=cateid]').val(newVal);
+    //             var that = this;
+    //             $.post('{:url("wasteType")}',{id:newVal},function (res) {
+    //                 let info1 = res.data;
+    //                 if(info1){
+    //                     if(info1.type == 0){
+    //                         $('#typeWeight').css('display','block');
+    //                         $('#typeNum').css('display','none');
+    //                     }else{
+    //                         $('#typeWeight').css('display','none');
+    //                         $('#typeNum').css('display','block');
+    //                         var unitname = info1.unit;
+    //                         if(unitname){
+    //                             var ttname = '数量(单位:'+unitname+')';
+    //                         }else{
+    //                             var ttname = '数量';
+    //                         }
+    //                         $('#typeNumName').html(ttname);
+    //                     }
+    //                 }
+    //             })
+    //
+    //         }
+    //     },
+    //
+    //     created(){
+    //        if(info.type === 0){
+    //            $('#typeWeight').css('display','block');
+    //            $('#typeNum').css('display','none');
+    //        }else{
+    //            $('#typeWeight').css('display','none');
+    //            $('#typeNum').css('display','block');
+    //            var unitname = info.unit;
+    //            if(unitname){
+    //                var ttname = '数量(单位:'+unitname+')';
+    //            }else{
+    //                var ttname = '数量';
+    //            }
+    //            $('#typeNumName').html(ttname);
+    //        }
+    //     }
+    // })
+
 </script>
 {/block}

+ 1 - 1
application/admin/view/waste_record/index.html

@@ -114,7 +114,7 @@
                 {label:'收取人',name:'real_name',index:'real_name',width:40,sortable: true},
                 {label:'称重序列号',name:'serial_number',index:'serial_number',width:80,sortable: true},
                 {label:'类别',name:'cate',index:'cate',width:40,sortable: true},
-                {label:'重量(kg)',name:'weight',index:'weight',width:40,sortable: true},
+                {label:'重量kg',name:'weight',index:'weight',width:40,sortable: true},
                 {label:'收取时间',name:'create_time',index:'create_time',width:80,sortable: true},
                 {label:'二维码',name:'serial_number_path',index:'serial_number_path',width:80,editable: false,sortable: false,formatter: function (a, b, c) {
                         return '<img src="'+a+'" width="60" onclick="open_img(this)"></img>';

+ 6 - 6
application/admin/view/waste_record/index2.html

@@ -101,7 +101,7 @@
                 {label:'收取人',name:'real_name',index:'real_name',width:40,sortable: true},
                 {label:'称重序列号',name:'serial_number',index:'serial_number',width:80,sortable: true},
                 {label:'类别',name:'cate',index:'cate',width:40,sortable: true},
-                {label:'重量(kg)',name:'weight',index:'weight',width:40,sortable: true},
+                {label:'重量kg',name:'weight',index:'weight',width:40,sortable: true},
                 {label:'收取时间',name:'create_time',index:'create_time',width:80,sortable: true},
                 {label:'二维码',name:'serial_number_path',index:'serial_number_path',width:80,editable: false,sortable: false,formatter: function (a, b, c) {
                         return '<img src="'+a+'" width="60" onclick="open_img(this)"></img>';
@@ -143,12 +143,12 @@
                     layer.msg(xhr.msg);
                     return false;
                 }
-                var types = xhr.types;
+                var types = xhr.tnames;
                 var str = "";
-                for (let o in types){
-                    str += types[o].title+":"+types[o].weight+"kg; ";
-                }
-                $('#wastetj').html(str);
+                // for (let o in types){
+                //     str += types[o].title+":"+types[o].weight+"kg; ";
+                // }
+                $('#wastetj').html(types);
             },
         });
         $('.batch-finish').click(function () {

+ 6 - 6
application/admin/view/waste_record/index3.html

@@ -101,7 +101,7 @@
                 {label:'收取人',name:'real_name',index:'real_name',width:40,sortable: true},
                 {label:'称重序列号',name:'serial_number',index:'serial_number',width:80,sortable: true},
                 {label:'类别',name:'cate',index:'cate',width:40,sortable: true},
-                {label:'重量(kg)',name:'weight',index:'weight',width:40,sortable: true},
+                {label:'重量kg',name:'weight',index:'weight',width:40,sortable: true},
                 {label:'收取时间',name:'create_time',index:'create_time',width:80,sortable: true},
                 {label:'二维码',name:'serial_number_path',index:'serial_number_path',width:80,editable: false,sortable: false,formatter: function (a, b, c) {
                         return '<img src="'+a+'" width="60" onclick="open_img(this)"></img>';
@@ -144,12 +144,12 @@
                     return false;
                 }
 
-                var types = xhr.types;
+                var types = xhr.tnames;
                 var str = "";
-                for (let o in types){
-                    str += types[o].title+":"+types[o].weight+"kg; ";
-                }
-                $('#wastetj').html(str);
+                // for (let o in types){
+                //     str += types[o].title+":"+types[o].weight+"kg; ";
+                // }
+                $('#wastetj').html(types);
 
             },
         });

+ 5 - 1
application/admin/view/waste_record/info.html

@@ -120,9 +120,13 @@
                            {$info['cate']}
                         </td>
                     </tr>
+<!--                    <tr>-->
+<!--                        <th>重量</th><td>{$info['weight']}kg</td>-->
+<!--                    </tr>-->
                     <tr>
-                        <th>重量</th><td>{$info['weight']}kg</td>
+                        <th>重量</th><td>{$info['tum']}</td>
                     </tr>
+
                     <tr>
                         <th>收取时间</th><td>{$info['create_time']}</td>
                     </tr>

+ 1 - 1
application/admin/view/waste_statistics/waste_day.html

@@ -65,7 +65,7 @@
                     <tr>
                         {foreach $typeList as $k=>$v}
                         <th>件数/包</th>
-                        <th>重量/kg</th>
+                        <th>重量kg</th>
                         {/foreach}
                     </tr>
 

+ 4 - 2
application/admin/view/waste_statistics/waste_month.html

@@ -65,7 +65,7 @@
                     <tr>
                         {foreach $typeList as $k=>$v}
                         <th>件数/包</th>
-                        <th>重量/kg</th>
+                        <th>重量kg</th>
                        {/foreach}
                     </tr>
 
@@ -74,9 +74,11 @@
                     {foreach $data as $k=>$v}
                     <tr>
                         <td>{$k+1}</td>
-                        {foreach $v as $k1=>$v1}
+                        {if isset($v['list'])}
+                        {foreach $v['list'] as $k1=>$v1}
                         <td>{$v1}</td>
                         {/foreach}
+                        {/if}
                         <td></td>
                     </tr>
                     {/foreach}

+ 1 - 1
application/admin/view/waste_statistics/waste_years.html

@@ -65,7 +65,7 @@
                     <tr>
                         {foreach $typeList as $k=>$v}
                         <th>件数/包</th>
-                        <th>重量/kg</th>
+                        <th>重量kg</th>
                         {/foreach}
                     </tr>
 

+ 1 - 1
application/admin/view/waste_statistics/waste_zc.html

@@ -59,7 +59,7 @@
                     <tr>
                         {foreach  $typeList as $k=>$v}
                         <th>件数/包</th>
-                        <th>重量/kg</th>
+                        <th>重量kg</th>
                         {/foreach}
                     </tr>
 

+ 36 - 4
application/admin/view/waste_type/add.html

@@ -9,20 +9,40 @@
                     <div class="form-group">
                         <label class="col-sm-2 control-label">名称<span class="text-danger">*</span></label>
                         <div class="col-sm-6">
-                            <input type="text" class="form-control" name="title" value="{$info.title|default=''}">
+                            <input type="text" class="form-control" name="title" readonly value="{$info.title|default=''}">
                         </div>
                     </div>
+<!--                    <div class="form-group">-->
+<!--                        <label class="col-sm-2 control-label">状态</label>-->
+<!--                        <div class="col-sm-6">-->
+<!--                            <label class="cr-inline">-->
+<!--                                <input type="radio" value="1" name="enable">正常&nbsp;&nbsp;-->
+<!--                            </label>-->
+<!--                            <label class="cr-inline">-->
+<!--                                <input type="radio" value="0" name="enable">禁用-->
+<!--                            </label>-->
+<!--                        </div>-->
+<!--                    </div>-->
                     <div class="form-group">
-                        <label class="col-sm-2 control-label">状态</label>
+                        <label class="col-sm-2 control-label">模式<span class="text-danger">*</span></label>
                         <div class="col-sm-6">
                             <label class="cr-inline">
-                                <input type="radio" value="1" name="enable">正常&nbsp;&nbsp;
+                                <input type="radio" value="0" name="type" onclick="clickType(0)">重量模式&nbsp;&nbsp;
                             </label>
                             <label class="cr-inline">
-                                <input type="radio" value="0" name="enable">禁用
+                                <input type="radio" value="1" name="type" onclick="clickType(1)">计数模式
                             </label>
+
+                        </div>
+                    </div>
+
+                    <div class="form-group" id="unit" style="display: none">
+                        <label class="col-sm-2 control-label">单位</label>
+                        <div class="col-sm-6">
+                            <input type="text" class="form-control" name="unit"  value="{$info.unit|default=''}">
                         </div>
                     </div>
+
                     <div class="hr-line-dashed"></div>
                     <div class="form-group">
                         <div class="col-sm-6 col-sm-offset-2">
@@ -40,7 +60,19 @@
 <script>
     $(document).ready(function(){
         formSetValue("enable", {$info.enable|default=1});
+        formSetValue("type", {$info.type|default=0});
+
+        clickType({$info.type|default=0});
     });
 
+    function clickType(type){
+        if(type == 0){
+            $('#unit').css('display','none');
+        }else{
+            $('#unit').css('display','block');
+        }
+
+    }
+
 </script>
 {/block}

+ 25 - 18
application/admin/view/waste_type/index.html

@@ -4,10 +4,10 @@
 <div class="ibox">
     <div class="ibox-content">
         <div class="row">
-            <div class="col-xs-3">
-                <a href="javascript:;" url="{:url('add')}" data-title="新增{$m_name}" onclick="layer_open(this,1)" class="btn btn-sm btn-primary">新增</a>
-            </div>
-            <div class="col-xs-9" style="text-align: right;">
+<!--            <div class="col-xs-3">-->
+<!--                <a href="javascript:;" url="{:url('add')}" data-title="新增{$m_name}" onclick="layer_open(this,1)" class="btn btn-sm btn-primary">新增</a>-->
+<!--            </div>-->
+            <div class="col-xs-12" style="text-align: right;">
             <form class="form-inline" id="form-search" action="{:url('index')}">
                 <div class="input-group">
                     <input type="text" class="form-control" name="title" placeholder="名称">
@@ -57,27 +57,34 @@
                 {label:'名称',name:'title',index:'title',width:80,editable: false,sortable: false},
 
                 {label:'创建时间',name:'create_time',index:'create_time',width:40,sortable: true},
-                {label:'状态',name:'enable',index:'enable',width:40,editable: false,sortable: false,formatter:function (a,b,c){
-                    if(a == 0){
-                        var url = "{:url('changeField',[],'')}/fn/enable/fv/1/id/"+c.id;
-                        return '<a href="'+url+'" class="ajax-get" data-table="1"><span class="label label-danger" title="禁用">禁用</span></a>';
-                    } else{
-                        var url = "{:url('changeField',[],'')}/fn/enable/fv/0/id/"+c.id;
-                        return '<a href="'+url+'" class="ajax-get" data-table="1"><span class="label label-primary" title="正常">正常</span></a>';
-                    }
-                }},
-                {label:'类型',name:'enable',index:'enable',width:40,editable: false,sortable: false,formatter:function (a,b,c){
-                        if(c.org_id > 0){
-                            return '私有';
+                // {label:'状态',name:'enable',index:'enable',width:40,editable: false,sortable: false,formatter:function (a,b,c){
+                //     if(a == 0){
+                //         var url = "{:url('changeField',[],'')}/fn/enable/fv/1/id/"+c.id;
+                //         return '<a href="'+url+'" class="ajax-get" data-table="1"><span class="label label-danger" title="禁用">禁用</span></a>';
+                //     } else{
+                //         var url = "{:url('changeField',[],'')}/fn/enable/fv/0/id/"+c.id;
+                //         return '<a href="'+url+'" class="ajax-get" data-table="1"><span class="label label-primary" title="正常">正常</span></a>';
+                //     }
+                // }},
+                // {label:'类型',name:'enable',index:'enable',width:40,editable: false,sortable: false,formatter:function (a,b,c){
+                //         if(c.org_id > 0){
+                //             return '私有';
+                //         } else{
+                //             return '共有';
+                //         }
+                //     }},
+                {label:'类型',name:'type',index:'type',width:40,editable: false,sortable: false,formatter:function (a,b,c){
+                        if(a == 0){
+                            return '重量模式';
                         } else{
-                            return '共有';
+                            return '计数模式';
                         }
                     }},
                 {label:'操作',width:50,sortable: false,formatter: function (a, b, c) {
                     var editurl = "{:url('add',[],'')}/id/"+c.id;
                     var delurl = "{:url('del',[],'')}/id/"+c.id;
                     var btn = '<a url="'+editurl+'" href="javascript:;" data-title="编辑{$m_name}" onclick="layer_open(this,1)"><span class="label label-primary" title="编辑">编辑</span></a>&nbsp;';
-                    btn += '<a {if !btnAuth(session("user_auth.id"),"WasteType/del")} style="display:none"{/if} href="'+delurl+'" class="confirm ajax-get" data-confirm="确定要删除此记录吗?" data-table="1"><span class="label label-danger" title="删除">删除</span></a>';
+                    // btn += '<a {if !btnAuth(session("user_auth.id"),"WasteType/del")} style="display:none"{/if} href="'+delurl+'" class="confirm ajax-get" data-confirm="确定要删除此记录吗?" data-table="1"><span class="label label-danger" title="删除">删除</span></a>';
                     return btn;
                 }},
             ],

+ 2 - 2
application/api/controller/screen/Convey.php

@@ -624,8 +624,8 @@ class Convey extends Index
         $data = [
             'title'=>$dlist,
             'list'=>[
-                'list1'=>$list,
-                'list2'=>$list1,
+                'list1'=>$list1,
+                'list2'=>$list,
             ]
         ];
         HelpHander::success($data);

+ 51 - 19
application/api/controller/screen/Patrol.php

@@ -1,6 +1,7 @@
 <?php
 namespace app\api\controller\screen;
 
+use app\common\model\User;
 use app\hander\HelpHander;
 use app\api\controller\screen\Index;
 
@@ -33,12 +34,16 @@ class Patrol extends Index
         $user = Db::name('patrol_task_user')
             ->alias('ptu')
             ->join('patrol_task pt','pt.id=ptu.patrol_task_id')
+            ->join('user u','u.id=ptu.user_id')
             ->where('pt.del',0)
             ->where('pt.org_id',$this->orgId)
             ->where('pt.patrol_mode',$mode)
+            ->where('pt.status','in',[0,1,2,3])
+            ->where('u.del',0)
             ->group('ptu.user_id')
             ->count();
 
+
         $task = Db::name('patrol_task')->where('org_id',$this->orgId)->where('del',0)->where('patrol_mode',$mode)->count();
         $data = [
            'addrCount'=>$addr,
@@ -119,10 +124,10 @@ class Patrol extends Index
             HelpHander::error('参数错误');
         }
         $lists = Db::name('patrol_record')
-            ->field('create_time,user_id,patrol_addr_form_id,patrol_mode,is_normal')
             ->where('patrol_mode',$mode)
             ->where('org_id',$this->orgId)
             ->order('id desc')
+            ->limit(20)
             ->select();
 
         $data = [];
@@ -137,8 +142,21 @@ class Patrol extends Index
                 ->value('name');
             $user = Db::name('user')->where('id',$v['user_id'])->value('real_name');
             $is_normal = '无异常' ;
-            if($v['is_normal'] == 1){
-                $is_normal = '有异常' ;
+//            if($v['is_normal'] == 1){
+//                $is_normal = '有异常' ;
+//            }
+            $isno = 1;
+            $checkJson = json_decode($v['check_json'],true);
+            foreach ($checkJson as $kk=>$vv) {
+                if (isset($vv['forms'])) {
+                    foreach ($vv['forms'] as $kkk => $vvv) {
+                        if (isset($vvv['status']) && $vvv['status'] == 0 && $isno == 1) {
+                            $is_normal = '有异常';
+                            $isno = 0;
+                            break;
+                        }
+                    }
+                }
             }
             $time = date('Y-m-d H:i',strtotime($v['create_time']));
             $content = '员工-'.$user.'完成'.$addrForm.$mode.','.$is_normal;
@@ -156,9 +174,10 @@ class Patrol extends Index
         }
         $lists = Db::name('patrol_record')
             ->where('org_id',$this->orgId)
-            ->where('is_normal',1)
+           // ->where('is_normal',1)
             ->where('patrol_mode',$mode)
             ->order('id desc')
+            ->limit(20)
             ->select();
         $data = [];
         foreach ($lists as $k=>$v){
@@ -167,8 +186,21 @@ class Patrol extends Index
 
             $user = Db::name('user')->where('id',$v['user_id'])->value('real_name');
             $is_normal = '正常' ;
-            if($v['is_normal'] == 1){
-                $is_normal = '异常' ;
+//            if($v['is_normal'] == 1){
+//                $is_normal = '异常' ;
+//            }
+            $isno = 1;
+            $checkJson = json_decode($v['check_json'],true);
+            foreach ($checkJson as $kk=>$vv) {
+                if (isset($vv['forms'])) {
+                    foreach ($vv['forms'] as $kkk => $vvv) {
+                        if (isset($vvv['status']) && $vvv['status'] == 0 && $isno == 1) {
+                            $is_normal = '异常';
+                            $isno = 0;
+                            break;
+                        }
+                    }
+                }
             }
             $data[$k][] = $addr;
             $data[$k][] = $user;
@@ -528,18 +560,18 @@ class Patrol extends Index
                 $time = time();
                 $xctime = $etime - $time;
                 $fz = round($xctime/60);
-                if($fz > 0 && $fz < 10){
-                    $remark =  '<span style="color:#FF3939 ">'.$fz.'分钟后超时</span>';
-                }
-                if($fz > 10 && $fz < 30){
-                    $remark =  '<span style="color:#FF9600 ">'.$fz.'分钟后超时</span>';
-                }
-                if($fz > 30){
-                    $remark =  '<span style="color:#FFFC1E ">'.$fz.'分钟后超时</span>';
-                }
-                if($fz <0){
-                    $remark =  '<span style="color: red">已超时</span>';
-                }
+//                if($fz > 0 && $fz < 10){
+//                    $remark =  '<span style="color:#FF3939 ">'.$fz.'分钟后超时</span>';
+//                }
+//                if($fz > 10 && $fz < 30){
+//                    $remark =  '<span style="color:#FF9600 ">'.$fz.'分钟后超时</span>';
+//                }
+//                if($fz > 30){
+//                    $remark =  '<span style="color:#FFFC1E ">'.$fz.'分钟后超时</span>';
+//                }
+//                if($fz <0){
+//                    $remark =  '<span style="color: red">已超时</span>';
+//                }
 
             }elseif ($v['status'] == 1){
                 $statusTxt = '执行中';
@@ -548,7 +580,7 @@ class Patrol extends Index
             }elseif ($v['status'] == 3){
                 $statusTxt = '未完成';
             }
-            $tList[] = [$v['id'],$v['title'],$userNames,$st,$et,$statusTxt,$remark];
+            $tList[] = [$v['id'],$v['title'],$userNames,$st,$et,$statusTxt];
         }
 
         $wzz = Db::name('patrol_task')

+ 3 - 2
application/api/controller/screen/Waste.php

@@ -81,7 +81,7 @@ class Waste extends Index
             }
             $lists[$k]['list'] = $aa;
         }
-        $title = array_column($device,'title');
+        $title = array_column($newList,'title');
 //        $cc = [];
 //        foreach ($cateTitle as $k=>$v){
 //            $cc[$k]['title'] = $v;
@@ -102,6 +102,7 @@ class Waste extends Index
         $record = Db::name('waste_record')
             ->where('org_id',$this->orgId)
             ->where('del',0)
+            ->where('weight','>',0)
             ->where('create_yyyymmdd',date('Ymd'))
             ->group('user_id')
             ->column('user_id');
@@ -149,7 +150,7 @@ class Waste extends Index
             }else{
                 $list[$k]['status'] = '医废异常';
             }
-            $list[$k]['create_time'] = date('m-d H:i');
+            $list[$k]['create_time'] = date('m-d H:i',strtotime($v['create_time']));
         }
         $data = [];
         foreach ($list as $k=>$v){

+ 33 - 0
application/api/controller/v1/ConveyCate.php

@@ -0,0 +1,33 @@
+<?php
+namespace app\api\controller\v1;
+use app\api\controller\Base;
+use app\common\model\Config;
+use app\hander\HelpHander;
+use think\App;
+use think\Db;
+
+class ConveyCate extends Base
+{
+
+    public function getTime(){
+        $type = input('type');
+        $start = input('start');
+        $info = Db::name('convey_cate')
+            ->where('id',$type)
+            ->where('enable',1)
+            ->where('del',0)
+            ->find();
+        if($info['time_id'] > 0){
+            $time = Db::name('time')
+                ->where('id',$info['time_id'])
+                ->find();
+            $info['xq_time'] = $start?$start:date('Y-m-d H:i');
+            $info['ywc_time'] = date('Y-m-d H:i',strtotime($info['xq_time']) + 60*$time['bz_time']);
+        }else{
+            $info['xq_time'] = $start?$start:date('Y-m-d H:i');
+            $info['ywc_time'] = '';
+        }
+        HelpHander::success($info,'操作成功');
+    }
+
+}

+ 51 - 2
application/api/controller/v1/WasteRecord.php

@@ -1,6 +1,7 @@
 <?php
 namespace app\api\controller\v1;
 use app\api\controller\Base;
+use app\common\model\User;
 use app\hander\HelpHander;
 use think\App;
 use think\Db;
@@ -59,7 +60,8 @@ class WasteRecord extends Base
             'cateid' =>input('cateId'),
             'weight' => input('weight'),
             'status' => 0,
-            'is_print' => 0
+            'is_print' => 0,
+            'num'=>input('num')
         ];
         if(!$data['waste_device_id']){
             HelpHander::error('未选择收取科室');
@@ -68,6 +70,7 @@ class WasteRecord extends Base
             HelpHander::error('类型不能为空');
         }
 
+
         if($data['weight'] <= 0){
             HelpHander::error('称重必须大于0');
         }
@@ -79,12 +82,13 @@ class WasteRecord extends Base
         if(!$info){
             HelpHander::error('操作失败');
         }
+        $info['unit'] = Db::name('waste_type')->where('id',$info['cateid'])->value('unit');
         $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);
+            'serial_number','wasteDeviceName','cateId','is_print','num','unit'],$info);
         HelpHander::success($a,'操作成功');
     }
 
@@ -273,4 +277,49 @@ class WasteRecord extends Base
         $ret = $this->model->print($ids,$this->orgId,$this->userId);
         $ret?HelpHander::success($ret):HelpHander::error($this->model->getError());
     }
+
+    //补录
+    public function addRecord(){
+        $data = [
+            'org_id' => $this->orgId,
+            'user_id' => input('uid/d',0),
+            'waste_device_id' => input('wasteDeviceId/d',0),
+            'cateid' =>input('cateid/d',0),
+            'weight' => input('weight'),
+            'create_time' => input('createTime'),
+            'status' => 0,
+            'is_print' => 0,
+            'num'=>input('num',0),
+        ];
+        if(!$data['waste_device_id']){
+            HelpHander::error('未选择收取科室');
+        }
+        if(!$data['cateid']){
+            HelpHander::error('类型不能为空');
+        }
+
+        if($data['weight'] <= 0){
+            HelpHander::error('重量不能为空');
+        }
+
+
+
+        if(!$data['create_time']){
+            HelpHander::error('未选择收取时间');
+        }
+
+        $waste_record_id = model('WsateRecord')->saverecord($data);
+        if(!$waste_record_id){
+            HelpHander::error(model('WsateRecord')->getError());
+        }
+
+        HelpHander::success([],'操作成功');
+    }
+
+    public function getWasteUserList(){
+
+        $lists = (new User())->getWasteWorker();
+        HelpHander::success($lists);
+    }
+
 }

+ 13 - 0
application/common.php

@@ -1077,6 +1077,19 @@ function get_month($time){
     return $yeararr;
 }
 
+//本年所有月份        开始和结束
+function get_month1($time){
+    $year = $time;
+    $yeararr = [];
+    for ($i=1; $i <=12 ; $i++) {
+        $yeararr[$i-1] = [
+            'key'=>$year.'年'.$i.'月份',
+            'date'=>date('Ym',strtotime($year.'-'.$i))
+        ];
+    }
+    return $yeararr;
+}
+
 /**
  * 本月的开始日期
  *

+ 47 - 19
application/common/model/WasteRecord.php

@@ -47,6 +47,13 @@ class WasteRecord extends Base {
 
             $info['rlist'] = $rlist?$rlist:array();
             $info = json_decode(json_encode($info),true);
+
+            $cate = Db::name('waste_type')->where('id',$info['cateid'])->find();
+
+            if($cate['type'] == 1 && $info['num'] > 0){
+                $tnum = round($info['weight'] / 1000, 2).'kg'.'('.$info['num'].$cate['unit'].')';
+            }
+            $info['tum'] = $tnum;
         }
         return $info;
     }
@@ -93,7 +100,7 @@ class WasteRecord extends Base {
         $map[] = ['serial_number','=',$serialNum];
         $map[] = ['org_id','=',$orgId];
         $map[] = ['del','=',0];
-        $info = $this->field('id,serial_number,org_id,waste_device_id,user_id,cateid,weight,status,create_time,reason,is_print,weight2')
+        $info = $this->field('id,serial_number,org_id,waste_device_id,user_id,cateid,weight,status,create_time,reason,is_print,weight2,num')
            ->where($map)->find();
 
         $info = $info?$info->toArray():[];
@@ -116,8 +123,9 @@ class WasteRecord extends Base {
             ->find();
         $info['title'] = $wasteDevice?$wasteDevice['title']:'';
         $info['cate_id'] = $info['cateid'];
-        $info['cate_name'] =Db::name('waste_type')
-        ->where('id',$info['cateid'])->value('title');
+        $info['cate_name'] =Db::name('waste_type')->where('id',$info['cateid'])->value('title');
+        $info['unit'] =Db::name('waste_type')->where('id',$info['cateid'])->value('unit');
+
         unset($info['cateid']);
 
 
@@ -150,7 +158,7 @@ class WasteRecord extends Base {
         $endtime=$createTime.' 23:59:59';
         $where[] = ['create_time','between',[$starttime,$endtime]];
         $list=$this
-            ->field('waste_device_id,cateid,create_time,is_print,serial_number,id,weight')
+            ->field('waste_device_id,cateid,create_time,is_print,serial_number,id,weight,num')
             ->where([
                 'org_id'=>$orgId,
                 'status'=>$status,
@@ -159,7 +167,8 @@ class WasteRecord extends Base {
             ->where($where)
             ->order('id desc')
             ->limit($offset,$size)
-             ->select()->toArray();
+             ->select()
+            ->toArray();
         $ret['list']=$list;
         foreach ($list as $k=>$v){
             $title=Db::name('address')
@@ -173,6 +182,9 @@ class WasteRecord extends Base {
                 ->where('id',$v['cateid'])
                 ->value('title');
             $ret['list'][$k]['cate_title']= $cate;
+            $ret['list'][$k]['unit']= Db::name('waste_type')
+                ->where('id',$v['cateid'])
+                ->value('unit');
         }
         return $ret;
     }
@@ -185,7 +197,7 @@ class WasteRecord extends Base {
           }
 
         $list=$this
-            ->field('waste_device_id,cateid,create_time,is_print,serial_number,id,weight')
+            ->field('waste_device_id,cateid,create_time,is_print,serial_number,id,weight,num')
             ->where('org_id',$orgId)
             ->where('del',0)
             ->where($where)
@@ -204,8 +216,11 @@ class WasteRecord extends Base {
             $ret['list'][$k]['title']= $title;
             $cate =Db::name('waste_type')
                 ->where('id',$v['cateid'])
-                ->value('title');;
+                ->value('title');
             $ret['list'][$k]['cate_title']= $cate;
+            $ret['list'][$k]['unit']= Db::name('waste_type')
+                ->where('id',$v['cateid'])
+                ->value('unit');
         }
 
         return $ret;
@@ -327,7 +342,7 @@ class WasteRecord extends Base {
             ->join('address wd','wd.id = wr.waste_device_id')
             ->where(function ($query) use ($map1) {
                 $query->whereOr($map1);
-            })->where($map)->field('wr.waste_device_id,wr.cateid,wr.create_time,wr.is_print,wr.serial_number,wr.id,wr.weight,wr.sign')
+            })->where($map)->field('wr.waste_device_id,wr.cateid,wr.create_time,wr.is_print,wr.serial_number,wr.id,wr.weight,wr.sign,wr.num')
             ->order('wr.id','desc')
             ->limit($offset,$size)->select();
         $list = $list?$list->toArray():[];
@@ -337,9 +352,9 @@ class WasteRecord extends Base {
                 ->where('id',$v['waste_device_id'])
                 ->value('title');
             $list[$k]['waste_device_name'] = $title;
-            $cate = Db::name('waste_type')->
-             where('id',$v['cateid'])->value('title');
+            $cate = Db::name('waste_type')->where('id',$v['cateid'])->value('title');
             $list[$k]['cate_title']= $cate?$cate:'';
+            $list[$k]['unit']= Db::name('waste_type')->where('id',$v['cateid'])->value('unit');
         }
 
         $ret['list']=$list?$list:[];
@@ -438,8 +453,10 @@ class WasteRecord extends Base {
             ->where('package_id',$info['id'])
             ->sum('weight');
 //        $info['weight'] = $weight?round($weight/1000,2):0;
+        $info['kg'] = $weight?round($weight/1000,2):0;
         $info['weight'] = $weight;
 
+
         $count = $this->where('package_id',$info['id'])
           ->count();
         $info['count'] = $count?$count:0;
@@ -448,11 +465,12 @@ class WasteRecord extends Base {
             ->alias('wr')
             ->where('wr.del',0)
             ->where('wr.package_id',$info['id'])
-            ->field('wr.waste_device_id,wr.cateid,wr.create_time,wr.is_print,wr.serial_number,wr.id,wr.weight,wr.sign')
+            ->field('wr.waste_device_id,wr.cateid,wr.create_time,wr.is_print,wr.serial_number,wr.id,wr.weight,wr.sign,wr.num')
             ->order('wr.id desc')
             ->select();
 
         foreach ($record as $k=>$v){
+
             $title=Db::name('address')
                 ->field('title')
                 ->where('id',$v['waste_device_id'])
@@ -462,6 +480,15 @@ class WasteRecord extends Base {
                 ->where('id',$v['cateid'])->value('title');
 //            $record[$k]['weight'] = $v['weight']?round($v['weight']/1000,2):0;
             $record[$k]['weight'] = $v['weight']?$v['weight']:0;
+            $record[$k]['kg'] = $v['weight']?round($v['weight']/1000,2):0;
+
+            $cate = Db::name('waste_type')->where('id',$v['cateid'])->find();
+            $record[$k]['unit'] = $cate ? $cate['unit']:'';
+            $tnum = round($v['weight'] / 1000, 2).'kg';
+            if($v['num'] >0){
+                $tnum = round($v['weight'] / 1000, 2).'kg'.'('.$v['num'].$cate['unit'].')';
+            }
+            $record[$k]['tum'] = $tnum;
 
         }
         $data = [
@@ -711,7 +738,7 @@ class WasteRecord extends Base {
         $map[] = ['wr.status','=',0];
         $list=$this->alias('wr')
              ->where($map)
-            ->field('wr.waste_device_id,wr.cateid,wr.create_time,wr.is_print,wr.serial_number,wr.id,wr.weight,wr.sign')
+            ->field('wr.waste_device_id,wr.cateid,wr.create_time,wr.is_print,wr.serial_number,wr.id,wr.weight,wr.sign,wr.num')
             ->order('wr.id desc')
             ->select();
         $list = $list?$list->toArray():[];
@@ -721,8 +748,8 @@ class WasteRecord extends Base {
                 ->where('id',$v['waste_device_id'])
                 ->find();
             $list[$k]['title'] = $title?$title['title']:'';
-            $list[$k]['cate_name'] =Db::name('waste_type')
-                ->where('id',$v['cateid'])->value('title');
+            $list[$k]['cate_name'] =Db::name('waste_type')->where('id',$v['cateid'])->value('title');
+            $list[$k]['unit'] =Db::name('waste_type')->where('id',$v['cateid'])->value('unit');
         }
         return $list?$list:[];
     }
@@ -753,7 +780,7 @@ class WasteRecord extends Base {
         $map[] = ['wr.create_yyyymmdd','=',date('Ymd')];
         $list=$this->alias('wr')
             ->where($map)
-            ->field('wr.waste_device_id,wr.cateid,wr.create_time,wr.is_print,wr.serial_number,wr.id,wr.weight,wr.sign')
+            ->field('wr.waste_device_id,wr.cateid,wr.create_time,wr.is_print,wr.serial_number,wr.id,wr.weight,wr.sign,wr.num')
             ->order('wr.id desc')
             ->limit(1000)
             ->select();
@@ -764,8 +791,8 @@ class WasteRecord extends Base {
                 ->where('id',$v['waste_device_id'])
                 ->find();
             $list[$k]['title'] = $title?$title['title']:'';
-            $list[$k]['cate_name'] =Db::name('waste_type')
-                ->where('id',$v['cateid'])->value('title');
+            $list[$k]['cate_name'] =Db::name('waste_type')->where('id',$v['cateid'])->value('title');
+            $list[$k]['unit'] =Db::name('waste_type')->where('id',$v['cateid'])->value('unit');
         }
         return $list?$list:[];
     }
@@ -792,7 +819,7 @@ class WasteRecord extends Base {
         }
         $list=db('waste_record')
             ->alias('wr')
-            ->field('wr.waste_device_id,wr.status,wr.cateid,wr.create_time,wr.is_print,wr.serial_number,wr.id,wr.weight,wr.sign')
+            ->field('wr.waste_device_id,wr.status,wr.cateid,wr.create_time,wr.is_print,wr.serial_number,wr.id,wr.weight,wr.sign,wr.num')
             ->order('wr.id','desc')
             ->where($map)
             ->limit($offset,$size)
@@ -800,12 +827,13 @@ class WasteRecord extends Base {
 
 
         foreach ($list as $k=>$v){
-            $title=db('address')
+            $title= Db::name('address')
                 ->field('title')
                 ->where('id',$v['waste_device_id'])
                 ->find();
             $list[$k]['title'] = $title?$title['title']:'';
             $list[$k]['cate_title'] = $this->getTableField('waste_type',['id'=>$v['cateid']],'title');
+            $list[$k]['unit'] = $this->getTableField('waste_type',['id'=>$v['cateid']],'unit');
         }
         $ret=$list?$list:[];
         return $ret;

+ 1 - 1
application/common/model/WasteType.php

@@ -54,7 +54,7 @@ class WasteType extends Base
     public function list1($orgId){
         $list =$this
             ->where('org_id','in',[0,$orgId])
-            ->field('id as waste_id,title')
+            ->field('id as waste_id,title,type,unit')
             ->where('del',0)
             ->where('enable',1)
             ->select()

+ 7 - 1
application/h5/controller/Statistics.php

@@ -1257,11 +1257,17 @@ class Statistics extends Controller
         } else if($type == 1){ //月统计
             $map[] = ['create_yyyymm','=',date('Ym')];
         }
-
+        $map[] = ['del','=',0];
         $wasteTypes = model("WasteType")->list1($this->orgId);
         foreach ($wasteTypes as $k=>$v){
             $count = Db::name('waste_record')->where($map)->where('cateid',$v['waste_id'])->sum('weight');
             $wasteTypes[$k]['count'] = round($count/1000,2)."kg";
+            if($v['type'] == 1){
+                $count = Db::name('waste_record')->where($map)->where('cateid',$v['waste_id'])->sum('num');
+                $wasteTypes[$k]['count'] = round($count/1000,2)."kg".'('.$count.$v['unit'].')';
+            }
+
+
         }
 
         $this->assign('wasteTypes',$wasteTypes);