zgg 3 týždňov pred
rodič
commit
402490ae71
94 zmenil súbory, kde vykonal 13615 pridanie a 0 odobranie
  1. 140 0
      application/admin/controller/EnergyArea.php
  2. 141 0
      application/admin/controller/EnergyDep.php
  3. 143 0
      application/admin/controller/EnergyDeviceElectricity.php
  4. 226 0
      application/admin/controller/EnergyDeviceElectricityRecord.php
  5. 211 0
      application/admin/controller/EnergyElectricity.php
  6. 250 0
      application/admin/controller/EnergyElectricityRecord.php
  7. 260 0
      application/admin/controller/EnergyElectricityRecord2.php
  8. 209 0
      application/admin/controller/EnergyGas.php
  9. 232 0
      application/admin/controller/EnergyGasRecord.php
  10. 34 0
      application/admin/controller/EnergyRecordWarning.php
  11. 111 0
      application/admin/controller/EnergySort.php
  12. 2346 0
      application/admin/controller/EnergyStatistics.php
  13. 710 0
      application/admin/controller/EnergyStatisticsOld.php
  14. 206 0
      application/admin/controller/EnergyWater.php
  15. 232 0
      application/admin/controller/EnergyWaterRecord.php
  16. 86 0
      application/admin/view/energy_area/add.html
  17. 83 0
      application/admin/view/energy_area/index.html
  18. 135 0
      application/admin/view/energy_dep/add.html
  19. 84 0
      application/admin/view/energy_dep/index.html
  20. 179 0
      application/admin/view/energy_device_electricity/add.html
  21. 216 0
      application/admin/view/energy_device_electricity/add2.html
  22. 37 0
      application/admin/view/energy_device_electricity/index.html
  23. 75 0
      application/admin/view/energy_device_electricity/split.html
  24. 32 0
      application/admin/view/energy_device_electricity/tree.html
  25. 86 0
      application/admin/view/energy_device_electricity_record/add.html
  26. 35 0
      application/admin/view/energy_device_electricity_record/import.html
  27. 151 0
      application/admin/view/energy_device_electricity_record/index.html
  28. 233 0
      application/admin/view/energy_electricity/add.html
  29. 38 0
      application/admin/view/energy_electricity/index.html
  30. 77 0
      application/admin/view/energy_electricity/split.html
  31. 46 0
      application/admin/view/energy_electricity/tree.html
  32. 86 0
      application/admin/view/energy_electricity_record/add.html
  33. 35 0
      application/admin/view/energy_electricity_record/import.html
  34. 151 0
      application/admin/view/energy_electricity_record/index.html
  35. 86 0
      application/admin/view/energy_electricity_record2/add.html
  36. 35 0
      application/admin/view/energy_electricity_record2/import.html
  37. 151 0
      application/admin/view/energy_electricity_record2/index.html
  38. 200 0
      application/admin/view/energy_gas/add.html
  39. 37 0
      application/admin/view/energy_gas/index.html
  40. 75 0
      application/admin/view/energy_gas/split.html
  41. 43 0
      application/admin/view/energy_gas/tree.html
  42. 79 0
      application/admin/view/energy_gas_record/add.html
  43. 35 0
      application/admin/view/energy_gas_record/import.html
  44. 150 0
      application/admin/view/energy_gas_record/index.html
  45. 84 0
      application/admin/view/energy_record_warning/index.html
  46. 57 0
      application/admin/view/energy_sort/add.html
  47. 75 0
      application/admin/view/energy_sort/index.html
  48. 149 0
      application/admin/view/energy_statistics/daily_electricity.html
  49. 146 0
      application/admin/view/energy_statistics/daily_gas.html
  50. 451 0
      application/admin/view/energy_statistics/daily_view.html
  51. 454 0
      application/admin/view/energy_statistics/daily_view2.html
  52. 151 0
      application/admin/view/energy_statistics/daily_water.html
  53. 151 0
      application/admin/view/energy_statistics/month_dep_electricity.html
  54. 133 0
      application/admin/view/energy_statistics/month_dep_gas.html
  55. 145 0
      application/admin/view/energy_statistics/month_dep_water.html
  56. 156 0
      application/admin/view/energy_statistics/month_dep_water2.html
  57. 136 0
      application/admin/view/energy_statistics/month_device_electricity.html
  58. 140 0
      application/admin/view/energy_statistics/month_device_electricity2.html
  59. 144 0
      application/admin/view/energy_statistics/month_electricity.html
  60. 141 0
      application/admin/view/energy_statistics/month_gas.html
  61. 456 0
      application/admin/view/energy_statistics/month_view.html
  62. 146 0
      application/admin/view/energy_statistics/month_water.html
  63. 143 0
      application/admin/view/energy_statistics/public_dep_electricity.html
  64. 226 0
      application/admin/view/energy_statistics/public_dep_total.html
  65. 137 0
      application/admin/view/energy_statistics/public_dep_water.html
  66. 218 0
      application/admin/view/energy_water/add.html
  67. 38 0
      application/admin/view/energy_water/index.html
  68. 75 0
      application/admin/view/energy_water/split.html
  69. 46 0
      application/admin/view/energy_water/tree.html
  70. 79 0
      application/admin/view/energy_water_record/add.html
  71. 35 0
      application/admin/view/energy_water_record/import.html
  72. 151 0
      application/admin/view/energy_water_record/index.html
  73. 43 0
      application/common/model/EnergyArea.php
  74. 43 0
      application/common/model/EnergyDep.php
  75. 53 0
      application/common/model/EnergyDeviceElectricity.php
  76. 51 0
      application/common/model/EnergyDeviceElectricityRecord.php
  77. 71 0
      application/common/model/EnergyElectricity.php
  78. 99 0
      application/common/model/EnergyElectricityRecord.php
  79. 63 0
      application/common/model/EnergyGas.php
  80. 57 0
      application/common/model/EnergyGasRecord.php
  81. 43 0
      application/common/model/EnergyLog.php
  82. 34 0
      application/common/model/EnergySort.php
  83. 87 0
      application/common/model/EnergyWater.php
  84. 57 0
      application/common/model/EnergyWaterRecord.php
  85. 23 0
      application/common/validate/EnergyArea.php
  86. 24 0
      application/common/validate/EnergyDep.php
  87. 23 0
      application/common/validate/EnergyDeviceElectricity.php
  88. 25 0
      application/common/validate/EnergyDeviceElectricityRecord.php
  89. 24 0
      application/common/validate/EnergyElectricity.php
  90. 25 0
      application/common/validate/EnergyElectricityRecord.php
  91. 25 0
      application/common/validate/EnergyGas.php
  92. 24 0
      application/common/validate/EnergyGasRecord.php
  93. 27 0
      application/common/validate/EnergyWater.php
  94. 24 0
      application/common/validate/EnergyWaterRecord.php

+ 140 - 0
application/admin/controller/EnergyArea.php

@@ -0,0 +1,140 @@
+<?php
+namespace app\admin\controller;
+
+class EnergyArea extends Auth
+{
+    public function index(){
+        $pid = input('pid',0,'intval');
+        if(request()->isAjax()){
+            //分页参数
+            $length = input('rows',10,'intval');   //每页条数
+            $page = input('page',1,'intval');      //第几页
+            $start = ($page - 1) * $length;     //分页开始位置
+            //排序
+            $sortRow = input('sidx','sort','trim');      //排序列
+            $sort = input('sord','asc','trim');        //排序方式
+            $order = $sortRow.' '.$sort;
+            $map['pid'] = $pid;
+            $map['del'] = 0;
+            $map['org_id'] = $this->orgId;
+            //数据查询
+            $lists = db('energy_area')->where($map)->limit($start,$length)->order($order)->select();
+            foreach ($lists as $k=>$v){
+                if($v['pid']){
+                    $lists[$k]['ptitle'] = db('energy_area')->where('id',$v['pid'])->value('title');
+                }else{
+                    $lists[$k]['ptitle'] = '无';
+                }
+            }
+            //数据返回
+            $totalCount = db('energy_area')->where($map)->count();
+            $totalPage = ceil($totalCount/$length);
+            $result['page'] = $page;
+            $result['total'] = $totalPage;
+            $result['records'] = $totalCount;
+            $result['rows'] = $lists;
+            return json($result);
+        }else{
+            if($pid){
+                $ptitle = '['.db('energy_area')->where('id',$pid)->value('title').']子区域';
+                $ppid = db('energy_area')->where('id',$pid)->value('pid');
+                $id = db('energy_area')->where('pid',$pid)->value('id');
+            }else{
+                $ptitle = '院级区域';
+                $ppid = 0;
+            }
+            $this->assign('meta_title',$ptitle);
+            $this->assign('pid',$pid);
+            $this->assign('ppid',$ppid);
+            return $this->fetch();
+        }
+    }
+
+    /**
+     * 新增/编辑
+     */
+    public function add($id=0,$pid=0){
+        if(request()->isPost()){
+            $res = model('energy_area')->updates();
+            if($res){
+                $this->success('操作成功',url('index',array('pid'=>$pid)));
+            }else{
+                $this->error(model('energy_area')->getError());
+            }
+        }else{
+            $map['del'] = 0;
+            $map['org_id'] = $this->orgId;
+            $map['enable'] = 1;
+            $meta_title = '新增';
+            if($id){
+                $info = db('energy_area')->where($map)->where('id',$id)->find();
+                $this->assign('info',$info);
+                $meta_title = '编辑';
+            }
+            $list = get_menu();
+            $this->assign('list',$list);
+            $this->assign('pid',$pid);
+            $this->assign('meta_title',$meta_title);
+            return $this->fetch();
+        }
+    }
+
+    /**
+     * 删除记录
+     * @param int $id
+     */
+    public function del($id=0){
+        if(!$id){
+            $this->error('参数错误');
+        }
+        $map['pid'] = $id;
+        $map['del'] = 0;
+        $subid = db('energy_area')->where('org_id',$this->orgId)->where($map)->value('id');
+        if($subid){
+            $this->error('有下级不能删除');
+        }
+        $res = db('energy_area')->where('org_id',$this->orgId)->where('id',$id)->update(['del'=>1]);
+        if($res){
+            $this->success('删除成功');
+        }else{
+            $this->error('删除失败');
+        }
+    }
+
+    /**
+     * 改变字段值
+     * @param int $fv
+     * @param string $fn
+     * @param int $fv
+     */
+    public function changeField($id=0,$fn='',$fv=0){
+        if(!$fn||!$id){
+            $this->error('参数错误');
+        }
+        $res = db('energy_area')->where('org_id',$this->orgId)->where('id',$id)->setField($fn,$fv);
+        if($res){
+            $this->success('操作成功');
+        }else{
+            $this->error('操作失败');
+        }
+    }
+
+    /**
+     * 排序
+     * @param int $id
+     * @param int $sort
+     */
+    public function changeSort($id=0,$sort=0){
+        if($id<0||$sort<0){
+            $this->error('参数错误');
+        }
+        $res = db('energy_area')->where('id',$id)->setField('sort',$sort);
+        if($res){
+            $this->success('操作成功');
+        }else{
+            $this->error('操作失败');
+        }
+    }
+
+
+}

+ 141 - 0
application/admin/controller/EnergyDep.php

@@ -0,0 +1,141 @@
+<?php
+namespace app\admin\controller;
+
+class EnergyDep extends Auth
+{
+    public function index(){
+        if(request()->isAjax()){
+            //分页参数
+            $length = input('rows',10,'intval');   //每页条数
+            $page = input('page',1,'intval');      //第几页
+            $start = ($page - 1) * $length;     //分页开始位置
+            //排序
+            $sortRow = input('sidx','sort','trim');      //排序列//排序方式
+            $map['del'] = 0;
+            $map['org_id'] = $this->orgId;
+            //数据查询
+            $lists = db('energy_dep')->where($map)->limit($start,$length)->select();
+            foreach ($lists as $k=>$v){
+                $address =json_decode($v['address'], true);
+                $a='';
+                foreach ($address as $kk=>$vv){
+                    $name='';
+                    foreach ($vv as $k1=>$v1){
+                        $name .= db('energy_area')->where('id',$v1)->value('title').'/';
+                    }
+                    $name = rtrim($name, '/');
+                    $a .=$name.',';
+                }
+                $lists[$k]['address'] = rtrim($a, ',');;
+            }
+            $totalCount = db('energy_dep')->where($map)->count();
+            $totalPage = ceil($totalCount/$length);
+            $result['page'] = $page;
+            $result['total'] = $totalPage;
+            $result['records'] = $totalCount;
+            $result['rows'] = $lists;
+            return json($result);
+        }else{
+            return $this->fetch();
+        }
+    }
+
+    /**
+     * 新增/编辑
+     */
+    public function add($id=0){
+        if(request()->isPost()){
+            $res = model('energy_dep')->updates();
+            if($res){
+                $this->success('操作成功',url('index'));
+            }else{
+                $this->error(model('energy_dep')->getError());
+            }
+        }else{
+            $map['del'] = 0;
+            $map['org_id'] = $this->orgId;
+            $map['enable'] = 1;
+            $meta_title = '新增';
+            if($id){
+                $info = db('energy_dep')->where($map)->where('id',$id)->find();
+                $this->assign('info',$info);
+                $meta_title = '编辑';
+            }
+            $lists = db('energy_area')
+                ->field('id,title')
+                ->where('pid',0)
+                ->where($map)
+                ->select();
+            foreach ($lists as $k=>$v) {
+                $lists[$k]['children'] = db('energy_area')
+                    ->field('id,title')
+                    ->where('pid', $v['id'])
+                    ->where($map)
+                    ->select();
+                foreach ($lists[$k]['children'] as $kk => $vv) {
+                    $lists[$k]['children'][$kk]['children'] = db('energy_area')
+                        ->field('id,title')
+                        ->where('pid', $vv['id'])
+                        ->where($map)
+                        ->select();
+                }
+            }
+            $this->assign('list',$lists);
+            $this->assign('meta_title',$meta_title);
+            return $this->fetch();
+        }
+    }
+
+    /**
+     * 删除记录
+     * @param int $id
+     */
+    public function del($id=0){
+        if(!$id){
+            $this->error('参数错误');
+        }
+        $res = db('energy_dep')->where('org_id',$this->orgId)->where('id',$id)->update(['del'=>1]);
+        if($res){
+            $this->success('删除成功');
+        }else{
+            $this->error('删除失败');
+        }
+    }
+
+    /**
+     * 改变字段值
+     * @param int $fv
+     * @param string $fn
+     * @param int $fv
+     */
+    public function changeField($id=0,$fn='',$fv=0){
+        if(!$fn||!$id){
+            $this->error('参数错误');
+        }
+        $res = db('energy_dep')->where('org_id',$this->orgId)->where('id',$id)->setField($fn,$fv);
+        if($res){
+            $this->success('操作成功');
+        }else{
+            $this->error('操作失败');
+        }
+    }
+
+    /**
+     * 排序
+     * @param int $id
+     * @param int $sort
+     */
+    public function changeSort($id=0,$sort=0){
+        if($id<0||$sort<0){
+            $this->error('参数错误');
+        }
+        $res = db('energy_dep')->where('org_id',$this->orgId)->where('id',$id)->setField('sort',$sort);
+        if($res){
+            $this->success('操作成功');
+        }else{
+            $this->error('操作失败');
+        }
+    }
+
+
+}

+ 143 - 0
application/admin/controller/EnergyDeviceElectricity.php

@@ -0,0 +1,143 @@
+<?php
+namespace app\admin\controller;
+
+use think\Db;
+use think\helper\Str;
+
+class EnergyDeviceElectricity extends Auth
+{
+
+    public function index(){
+        $tree = model('EnergyDeviceElectricity')->showAllTree();
+        $this->traverseArray($tree);
+//        halt($tree);
+        $this->assign('tree',$tree);
+        return $this->fetch();
+    }
+
+    /**
+     * 新增/编辑
+     */
+    public function add($pid=0,$t=0,$id=0){
+        if(request()->isPost()){
+            $res = model('EnergyDeviceElectricity')->updates();
+            if($res){
+                $this->success('操作成功',url('index'));
+            }else{
+                $this->error(model('EnergyDeviceElectricity')->getError());
+            }
+        }else{
+            $meta_title = '新增';
+            if($id){
+                $info = db('energy_device_electricity')->where('org_id',$this->orgId)->where('id',$id)->find();
+                $this->assign('info',$info);
+                $info['s'] = $info['share'] ? (string)$info['share'] : '';
+                $meta_title = '编辑';
+            }
+            $map[] = ['del','=',0];
+            $map[]= ['enable','=',1];
+            $map[]= ['org_id','=',$this->orgId];
+            $alists = db('energy_area')
+                ->field('id,title')
+                ->where($map)
+                ->where('pid',0)
+                ->select();
+            foreach ($alists as $k=>$v) {
+                $alists[$k]['children'] = db('energy_area')
+                    ->field('id,title')
+                    ->where('pid', $v['id'])
+                    ->where($map)
+                    ->select();
+                foreach ($alists[$k]['children'] as $kk => $vv) {
+                    $alists[$k]['children'][$kk]['children'] = db('energy_area')
+                        ->field('id,title')
+                        ->where('pid', $vv['id'])
+                        ->where($map)
+                        ->select();
+                }
+            }
+            $dlists = db('energy_dep')
+                ->field('id,name')
+                ->where($map)
+                ->select();
+            $tlists = db('energy_sort')
+                ->field('id,name')
+                ->where($map)
+                ->select();
+            $this->assign('alist',$alists);
+            $this->assign('dlist',$dlists);
+            $this->assign('tlist',$tlists);
+            $this->assign('pid',$pid);
+            $this->assign('t',$t);
+            $this->assign('meta_title',$meta_title);
+            return $this->fetch();
+        }
+    }
+
+
+    public function changeEnable($id=0,$enable=0){
+        if($id <= 0){
+            $this->error('参数错误');
+        }
+        $ret = Db::name('energy_device_electricity')->where('id',$id)->setField('enable',$enable);
+        if(!$ret){
+            $this->error('操作失败');
+        }
+        $this->success('操作成功');
+    }
+
+    /**
+     * 删除记录
+     * @param int $id
+     */
+    public function del($id=0){
+        if(!$id){
+            $this->error('参数错误');
+        }
+        // 检查是否有子级
+        $ret = Db::name('energy_device_electricity')->where('parent_id',$id)->where('del',0)->find();
+        if($ret){
+            $this->error('有子电表不能删除');
+        }
+        $res = Db::name('energy_device_electricity')->where('id',$id)->setField('del',1);
+        if($res){
+            $this->success('删除成功');
+        }else{
+            $this->error('删除失败');
+        }
+    }
+
+    /**
+     * 循环tree给字段重新赋值
+     */
+    public function traverseArray(&$array) {
+        foreach ($array as &$item) {
+            // 修改type_e的值
+            if (isset($item['type_e'])) {
+                $item['type_e'] = Db::name('energy_sort')->where('id',$item['type_e'])->value('name');
+            }
+            // 如果存在children,递归调用
+            if (isset($item['children']) && is_array($item['children'])) {
+                $this->traverseArray($item['children']);
+            }
+        }
+    }
+
+    public function getDep() {
+        $data = $this->request->param();
+        $value = $data['param'];
+        if ($value){
+            $map[] = ['address','like','%'.$value.'%'];
+        }
+        $map[] = ['del','=',0];
+        $map[]= ['enable','=',1];
+        $map[]= ['org_id','=',$this->orgId];
+        $lists = db('energy_dep')
+            ->field('id,name')
+            ->where($map)
+            ->select();
+        return json(['data'=>$lists]);
+
+    }
+
+}

+ 226 - 0
application/admin/controller/EnergyDeviceElectricityRecord.php

@@ -0,0 +1,226 @@
+<?php
+namespace app\admin\controller;
+
+use app\common\model\User;
+use think\App;
+use think\Db;
+
+class EnergyDeviceElectricityRecord extends Auth
+{
+    public function __construct(App $app = null) {
+        parent::__construct($app);
+        $this->model = new \app\common\model\EnergyDeviceElectricityRecord();
+    }
+    public function index(){
+        if(request()->isAjax()){
+            //分页参数
+            $length = input('rows',10,'intval');   //每页条数
+            $page = input('page',1,'intval');      //第几页
+            $start = ($page - 1) * $length;     //分页开始位置
+            //排序
+            $sortRow = input('sidx','sort','trim');      //排序列
+            $sort = input('sord','asc','trim');        //排序方式
+            $order = $sortRow.' '.$sort.' ,id desc';
+
+            $sn = input('sn','','trim');
+            if($sn){
+                $map[] = ['sn','=',$sn];
+            }
+            $map[] = ['org_id','=',$this->orgId];
+            $map[] = ['del','=',0];
+            $map= empty($map) ? true: $map;
+            //数据查询
+            $lists = Db::name('energy_device_electricity_record')
+                ->where($map)->limit($start,$length)
+                ->order($order)->select();
+            foreach($lists as $k=>$v){
+                $lists[$k]['user_id'] = Db::name('user')->where('id',$v['user_id'])->value('real_name');
+            }
+
+            //数据返回
+            $totalCount = db('energy_device_electricity_record')->where($map)->count();
+            $totalPage = ceil($totalCount/$length);
+            $result['page'] = $page;
+            $result['total'] = $totalPage;
+            $result['records'] = $totalCount;
+            $result['rows'] = $lists;
+            return json($result);
+        }else{
+            $this->assign('meta_title','设备电表抄表记录');
+            return $this->fetch();
+        }
+    }
+
+    /**
+     * 新增/编辑
+     */
+    public function add($id=0){
+        $model = $this->model;
+        $userId = is_login();
+        if(request()->isPost()){
+            $res = $model->updates($userId);
+            if($res){
+                $this->success('操作成功',url('index'));
+            }else{
+                $this->error($model->getError());
+            }
+        }else{
+            if($id){
+                $info = db('energy_device_electricity_record')->where('id',$id)->find();
+                $this->assign('info',$info);
+            }
+            return $this->fetch();
+        }
+    }
+
+    /**
+     * 删除记录
+     * @param int $id
+     */
+    public function del($id=0){
+        if(!$id){
+            $this->error('参数错误');
+        }
+        $res = Db::name('energy_device_electricity_record')->where('id',$id)->update(['del'=>1]);
+        if($res){
+            $this->success('删除成功');
+        }else{
+            $this->error('删除失败');
+        }
+    }
+
+    public function import(){
+        return $this->fetch();
+    }
+    /**
+     * 下载点模板
+     */
+    public function downloadtem(){
+        set_time_limit(0);
+        ini_set("memory_limit","512M");
+        include_once env('root_path').'/extend/phpexcel/Classes/PHPExcel.php';
+        $types = model('Address')->getTypes();
+        ksort($types);
+        $fileName = '设备电表抄表记录模板.xlsx';
+        $excel = new \PHPExcel();
+        $sheet = $excel->setActiveSheetIndex(0);
+        $arr = array('A','B','C','D','E','F','G');
+        foreach($arr as $k=>$v){
+            $excel->getActiveSheet()->getStyle($v)->getAlignment()->setWrapText(true);//换行
+            $excel->getActiveSheet()->getStyle($v.'1')->getFont()->setBold(true);
+            $excel->getActiveSheet()->getColumnDimension($v)->setWidth(18);
+
+        }
+        $sheet->setCellValueByColumnAndRow(0,1,'日期');
+        $sheet->setCellValueByColumnAndRow(1,1,'表号');
+        $sheet->setCellValueByColumnAndRow(2,1,'倍率');
+        $sheet->setCellValueByColumnAndRow(3,1,'抄表读数');
+        $sheet->setCellValueByColumnAndRow(4,1,'最低温度 (℃)');
+        $sheet->setCellValueByColumnAndRow(5,1,'最高温度 (℃))');
+        $sheet->setCellValueByColumnAndRow(6,1,'床位数量');
+
+        $excel->getActiveSheet()->setCellValue('A2', '2024/09/23');
+        $excel->getActiveSheet()->setCellValue('B2', '1101');
+        $excel->getActiveSheet()->setCellValue('C2', '10');
+        $excel->getActiveSheet()->setCellValue('D2', '100');
+        $excel->getActiveSheet()->setCellValue('E2', '10');
+        $excel->getActiveSheet()->setCellValue('F2', '22');
+        $excel->getActiveSheet()->setCellValue('G2', '120');
+
+        ob_end_clean();//清除缓冲区,避免乱码
+        header('Content-Type: application/vnd.ms-excel');
+        header('Content-Disposition: attachment;filename="'.$fileName.'"');
+        header('Cache-Control: max-age=0');
+
+        $objWriter = \PHPExcel_IOFactory::createWriter($excel, 'Excel2007');
+        $objWriter->save('php://output'); //文件通过浏览器下载
+
+    }
+
+
+    /**
+     * 导入
+     */
+    public function importexcel(){
+        set_time_limit(0);
+        ini_set("memory_limit", -1);
+        ob_flush();//清空缓存
+        flush();//刷新缓存
+        include_once env('root_path').'/extend/phpexcel/Classes/PHPExcel.php';
+        $orgId = $this->orgId;
+        if(request()->file()) {
+            $file = request()->file('file');
+            //获取文件后缀
+            $e = explode('.',$_FILES['file']['name']);
+            $ext = $e[count($e)-1];
+            if($ext == 'xls'){
+                \PHPExcel_IOFactory::createReader( 'Excel5');
+            }else{
+                \PHPExcel_IOFactory::createReader('Excel2007');
+            }
+            $newArr=['xls','xlsx'];
+            if(!in_array($ext,$newArr)){
+                exit('文件格式不正确');
+            }
+            // 移动到框架应用根目录/uploads/ 目录下
+            $info = $file->validate([ 'size'=>config('app.max_upload_file_size') ])
+                ->move(env('root_path') . 'public' . DIRECTORY_SEPARATOR . 'uploads'. DIRECTORY_SEPARATOR . 'files');
+            if(!$info){
+                exit('文件上传失败');
+            }
+            $img = './uploads/files/' . $info->getSaveName();
+            $filePath = str_replace('\\', '/', $img);
+            $newPath = \PHPExcel_IOFactory::load($filePath);
+
+            $excelArray = $newPath->getsheet(0)->toArray();   //转换为数组格式
+
+            array_shift($excelArray);  //删除第一个数组(标题);
+            if(empty($excelArray)){
+                exit('文件内容为空');
+            }
+
+            foreach ($excelArray as $k => $v) {
+
+                if(!$v[0] || !$v[1] || !$v[2] || !$v[3] ){
+                    echo "<font color=\"red\" style='margin-left: 20px;font-size: 17px'>第".($k+1)."行,有数据为空,未导入</font><br />";
+                    continue;
+                }
+                $Data = [
+                    'org_id'=>$this->orgId,
+                    'read_time'=>date('Y-m-d',strtotime($v[0])),
+                    'sn'=>$v[1],
+                    'rate'=>$v[2],
+                    'degree'=>$v[3],
+                    'min_temperature'=>$v[4],
+                    'max_temperature'=>$v[5],
+                    'user_id'=>is_login(),
+                    'read_yyyy'=>date('Y',strtotime($v[0])),
+                    'read_yyyymm'=>date('Ym',strtotime($v[0])),
+                    'read_yyyymmdd'=>date('Ymd',strtotime($v[0])),
+                    'create_time'=>getTime(),
+                ];
+                $ret=Db::name('energy_device_electricity_record')->insert($Data);
+
+                if(!$ret){
+                    echo "<font color=\"red\" style='margin-left: 20px;font-size: 17px'>第".($k+1)."行,导入失败</font><br />";
+                }else{
+                    echo "<font color=\"green\" style='margin-left:20px;font-size: 17px'>第".($k+1)."行,导入成功</font><br />";
+                }
+
+            }
+        }else{
+            exit('请上传文件');
+        }
+
+    }
+
+    public function multiDel() {
+        $ids = input('ids', [], 'trim');
+        if (empty($ids)) {
+            $this->error('未选择记录');
+        }
+        $res = Db::name('energy_device_electricity_record')->whereIn('id', $ids)->update(['del'=>1]);
+        if (!$res) $this->error('批量删除失败');
+        $this->success('批量删除传成功');
+    }
+}

+ 211 - 0
application/admin/controller/EnergyElectricity.php

@@ -0,0 +1,211 @@
+<?php
+namespace app\admin\controller;
+
+use think\Db;
+use think\helper\Str;
+
+class EnergyElectricity extends Auth
+{
+
+    public function index(){
+        $tree = model('EnergyElectricity')->showAllTree();
+        $this->traverseArray($tree);
+//        halt($tree);
+        $this->assign('tree',$tree);
+        return $this->fetch();
+    }
+
+    /**
+     * 新增/编辑
+     */
+    public function add($pid=0,$t=0,$id=0){
+        if(request()->isPost()){
+            $res = model('EnergyElectricity')->updates();
+            if($res){
+                $this->success('操作成功',url('index'));
+            }else{
+                $this->error(model('EnergyElectricity')->getError());
+            }
+        }else{
+            $meta_title = '新增';
+            if($id){
+                $info = db('energy_electricity')->where('org_id',$this->orgId)->where('id',$id)->find();
+                $info['dep'] = explode(',',$info['dep']);
+                $this->assign('info',$info);
+                $info['s'] = $info['share'] ? (string)$info['share'] : '';
+                $meta_title = '编辑';
+            }
+            $map[] = ['del','=',0];
+            $map[]= ['enable','=',1];
+            $map[]= ['org_id','=',$this->orgId];
+            $alists = db('energy_area')
+                ->field('id,title')
+                ->where($map)
+                ->where('pid',0)
+                ->select();
+            foreach ($alists as $k=>$v) {
+                $alists[$k]['children'] = db('energy_area')
+                    ->field('id,title')
+                    ->where('pid', $v['id'])
+                    ->where($map)
+                    ->select();
+                foreach ($alists[$k]['children'] as $kk => $vv) {
+                    $alists[$k]['children'][$kk]['children'] = db('energy_area')
+                        ->field('id,title')
+                        ->where('pid', $vv['id'])
+                        ->where($map)
+                        ->select();
+                }
+            }
+            $dlists = db('energy_dep')
+                ->field('id,name')
+                ->where($map)
+                ->select();
+            $tlists = db('energy_sort')
+                ->field('id,name')
+                ->where($map)
+                ->select();
+            $this->assign('alist',$alists);
+            $this->assign('dlist',$dlists);
+            $this->assign('tlist',$tlists);
+            $this->assign('pid',$pid);
+            $this->assign('t',$t);
+            $this->assign('meta_title',$meta_title);
+            return $this->fetch();
+        }
+    }
+    /**
+     * 拆分电表
+     */
+    public function split($id=0)
+    {
+        if(request()->isPost()){
+            $id = input('post.id');
+            $split = input('post.split');
+            $res = Db::name('energy_electricity')->where('id',$id)->setField(['split'=>$split]);
+            if($res){
+                $this->success('操作成功',url('index'));
+            }else{
+                $this->error('操作失败');
+            }
+        }else{
+            $info = db('energy_electricity')->where('id',$id)->find();
+            $this->assign('info',$info);
+
+            $map[] = ['del','=',0];
+            $map[]= ['enable','=',1];
+            $map[]= ['org_id','=',$this->orgId];
+            $map[]= ['id','<>',$id];
+            $list = Db::name('energy_electricity')
+                ->where('parent_id','>',0)
+                ->where($map)
+                ->select();
+            foreach ($list as $k=>$v) {
+                $list[$k]['number'] = $v['name'].'————'.$v['number'];
+            }
+            $this->assign('list',$list);
+            $this->assign('id',$id);
+            return $this->fetch();
+        }
+    }
+
+    public function changeEnable($id=0,$enable=0){
+        if($id <= 0){
+            $this->error('参数错误');
+        }
+        $ret = Db::name('energy_electricity')->where('id',$id)->setField('enable',$enable);
+        if(!$ret){
+            $this->error('操作失败');
+        }
+        $this->success('操作成功');
+    }
+
+    /**
+     * 删除记录
+     * @param int $id
+     */
+    public function del($id=0){
+        if(!$id){
+            $this->error('参数错误');
+        }
+        // 检查是否有子级
+        $ret = Db::name('energy_electricity')->where('org_id',$this->orgId)->where('parent_id',$id)->where('del',0)->find();
+        if($ret){
+            $this->error('有子电表不能删除');
+        }
+        $res = Db::name('energy_electricity')->where('org_id',$this->orgId)->where('id',$id)->setField('del',1);
+        if($res){
+            $this->success('删除成功');
+        }else{
+            $this->error('删除失败');
+        }
+    }
+
+    /**
+     * 换表
+     * @param string $sn
+     */
+    public function change($sn=''){
+        if(!$sn){
+            $this->error('参数错误');
+        }
+        $record = Db::name('energy_electricity_record')
+            ->where('sn',$sn)
+            ->where('del',0)
+            ->order('read_yyyymmdd desc')
+            ->field('degree,read_time')
+            ->findOrEmpty();
+        if (empty($record)){
+            $this->error('该表没有抄表记录');
+        }
+        $res = Db::name('energy_change_log')
+            ->insert([
+                'org_id'=>$this->orgId,
+                'sn'=>$sn,
+                'degree'=>$record['degree'],
+                'read_time'=>$record['read_time'],
+                'create_time'=>getTime(),
+            ]);
+        if($res){
+            $this->success('换表成功');
+        }else{
+            $this->error('换表失败');
+        }
+    }
+
+    /**
+     * 循环tree给字段重新赋值
+     */
+    public function traverseArray(&$array) {
+        foreach ($array as &$item) {
+            // 修改type_e的值
+            if (isset($item['type_e'])) {
+                $item['type_e'] = Db::name('energy_sort')->where('org_id',$this->orgId)->where('id',$item['type_e'])->value('name');
+            }
+            // 如果存在children,递归调用
+            if (isset($item['children']) && is_array($item['children'])) {
+                $this->traverseArray($item['children']);
+            }
+        }
+    }
+
+    public function getDep() {
+        $data = $this->request->param();
+        $value = $data['param'];
+        if ($value){
+            $map[] = ['address','like','%'.$value.'%'];
+        }else{
+            $map[] = ['address','=',0];
+        }
+        $map[] = ['del','=',0];
+        $map[]= ['enable','=',1];
+        $map[]= ['org_id','=',$this->orgId];
+        $lists = db('energy_dep')
+            ->field('id,name')
+            ->where($map)
+            ->select();
+        return json(['data'=>$lists]);
+
+    }
+
+}

+ 250 - 0
application/admin/controller/EnergyElectricityRecord.php

@@ -0,0 +1,250 @@
+<?php
+namespace app\admin\controller;
+
+use app\common\model\User;
+use think\App;
+use think\Db;
+
+class EnergyElectricityRecord extends Auth
+{
+    public function __construct(App $app = null) {
+        parent::__construct($app);
+        $this->model = new \app\common\model\EnergyElectricityRecord();
+    }
+    public function index(){
+        if(request()->isAjax()){
+            //分页参数
+            $length = input('rows',10,'intval');   //每页条数
+            $page = input('page',1,'intval');      //第几页
+            $start = ($page - 1) * $length;     //分页开始位置
+            //排序
+            $sortRow = input('sidx','sort','trim');      //排序列
+            $sort = input('sord','asc','trim');        //排序方式
+            $order = $sortRow.' '.$sort.' ,id desc';
+
+            $sn = input('sn','','trim');
+            if($sn){
+                $map[] = ['sn','=',$sn];
+            }
+            $ids = Db::name('energy_electricity')
+                ->where('org_id',$this->orgId)
+                ->where('del',0)
+                ->where('parent_id','>',0)
+                ->column('number');
+            if (!empty($ids)) {
+                $map[] = ['sn','in',$ids];
+            }
+            $map[] = ['org_id','=',$this->orgId];
+            $map[] = ['del','=',0];
+            $map= empty($map) ? true: $map;
+            //数据查询
+            $lists = Db::name('energy_electricity_record')
+                ->where($map)->limit($start,$length)
+                ->order($order)->select();
+            foreach($lists as $k=>$v){
+                $lists[$k]['user_id'] = Db::name('user')->where('id',$v['user_id'])->value('real_name');
+            }
+
+            //数据返回
+            $totalCount = db('energy_electricity_record')->where($map)->count();
+            $totalPage = ceil($totalCount/$length);
+            $result['page'] = $page;
+            $result['total'] = $totalPage;
+            $result['records'] = $totalCount;
+            $result['rows'] = $lists;
+            return json($result);
+        }else{
+            $this->assign('meta_title','电表抄表记录');
+            return $this->fetch();
+        }
+    }
+
+    /**
+     * 新增/编辑
+     */
+    public function add($id=0){
+        $model = $this->model;
+        $userId = is_login();
+        if(request()->isPost()){
+            $res = $model->updates($userId,1);
+            if($res){
+                $this->success('操作成功',url('index'));
+            }else{
+                $this->error($model->getError());
+            }
+        }else{
+            if($id){
+                $info = db('energy_electricity_record')->where('id',$id)->find();
+                $this->assign('info',$info);
+            }
+            return $this->fetch();
+        }
+    }
+
+    /**
+     * 删除记录
+     * @param int $id
+     */
+    public function del($id=0){
+        if(!$id){
+            $this->error('参数错误');
+        }
+        $res = Db::name('energy_electricity_record')->where('id',$id)->update(['del'=>1]);
+        if($res){
+            $this->success('删除成功');
+        }else{
+            $this->error('删除失败');
+        }
+    }
+
+    public function import(){
+        return $this->fetch();
+    }
+    /**
+     * 下载点模板
+     */
+    public function downloadtem(){
+        set_time_limit(0);
+        ini_set("memory_limit","512M");
+        include_once env('root_path').'/extend/phpexcel/Classes/PHPExcel.php';
+        $types = model('Address')->getTypes();
+        ksort($types);
+        $fileName = '电表抄表记录模板.xlsx';
+        $excel = new \PHPExcel();
+        $sheet = $excel->setActiveSheetIndex(0);
+        $arr = array('A','B','C','D','E','F','G');
+        foreach($arr as $k=>$v){
+            $excel->getActiveSheet()->getStyle($v)->getAlignment()->setWrapText(true);//换行
+            $excel->getActiveSheet()->getStyle($v.'1')->getFont()->setBold(true);
+            $excel->getActiveSheet()->getColumnDimension($v)->setWidth(18);
+
+        }
+        $sheet->setCellValueByColumnAndRow(0,1,'日期');
+        $sheet->setCellValueByColumnAndRow(1,1,'表号');
+        $sheet->setCellValueByColumnAndRow(2,1,'倍率');
+        $sheet->setCellValueByColumnAndRow(3,1,'抄表读数');
+        $sheet->setCellValueByColumnAndRow(4,1,'最低温度 (℃))');
+        $sheet->setCellValueByColumnAndRow(5,1,'最高温度 (℃))');
+        $sheet->setCellValueByColumnAndRow(6,1,'床位数量');
+
+        $excel->getActiveSheet()->setCellValue('A2', '2024/09/23');
+        $excel->getActiveSheet()->setCellValue('B2', 'D1101');
+        $excel->getActiveSheet()->setCellValue('C2', '10');
+        $excel->getActiveSheet()->setCellValue('D2', '100');
+        $excel->getActiveSheet()->setCellValue('E2', '10');
+        $excel->getActiveSheet()->setCellValue('F2', '22');
+        $excel->getActiveSheet()->setCellValue('G2', '120');
+
+        ob_end_clean();//清除缓冲区,避免乱码
+        header('Content-Type: application/vnd.ms-excel');
+        header('Content-Disposition: attachment;filename="'.$fileName.'"');
+        header('Cache-Control: max-age=0');
+
+        $objWriter = \PHPExcel_IOFactory::createWriter($excel, 'Excel2007');
+        $objWriter->save('php://output'); //文件通过浏览器下载
+
+    }
+
+
+    /**
+     * 导入
+     */
+    public function importexcel(){
+        set_time_limit(0);
+        ini_set("memory_limit", -1);
+        ob_flush();//清空缓存
+        flush();//刷新缓存
+        include_once env('root_path').'/extend/phpexcel/Classes/PHPExcel.php';
+        $orgId = $this->orgId;
+        if(request()->file()) {
+            $file = request()->file('file');
+            //获取文件后缀
+            $e = explode('.',$_FILES['file']['name']);
+            $ext = $e[count($e)-1];
+            if($ext == 'xls'){
+                \PHPExcel_IOFactory::createReader( 'Excel5');
+            }else{
+                \PHPExcel_IOFactory::createReader('Excel2007');
+            }
+            $newArr=['xls','xlsx'];
+            if(!in_array($ext,$newArr)){
+                exit('文件格式不正确');
+            }
+            // 移动到框架应用根目录/uploads/ 目录下
+            $info = $file->validate([ 'size'=>config('app.max_upload_file_size') ])
+                ->move(env('root_path') . 'public' . DIRECTORY_SEPARATOR . 'uploads'. DIRECTORY_SEPARATOR . 'files');
+            if(!$info){
+                exit('文件上传失败');
+            }
+            $img = './uploads/files/' . $info->getSaveName();
+            $filePath = str_replace('\\', '/', $img);
+            $newPath = \PHPExcel_IOFactory::load($filePath);
+
+            $excelArray = $newPath->getsheet(0)->toArray();   //转换为数组格式
+
+            array_shift($excelArray);  //删除第一个数组(标题);
+            if(empty($excelArray)){
+                exit('文件内容为空');
+            }
+            $ids = Db::name('energy_electricity')
+                ->where('org_id',$this->orgId)
+                ->where('del',0)
+                ->where('parent_id','>',0)
+                ->column('number');
+            $flag = 0;
+            foreach ($excelArray as $k => $v) {
+                if (!$v[0] || !$v[1] || !$v[2] || !$v[3]) {
+                    $flag = 1;
+                    echo "<font color=\"red\" style='margin-left: 20px;font-size: 17px'>第" . ($k + 1) . "行,有数据为空,请修改后重新导入</font><br />";
+                    continue;
+                }
+                if (!in_array($v[1], $ids)) {
+                    $flag = 1;
+                    echo "<font color=\"red\" style='margin-left: 20px;font-size: 17px'>第" . ($k + 1) . "行,表号不存在或非分表表号,请修改后重新导入</font><br />";
+                    continue;
+                }
+            }
+            if ($flag > 0) {
+                exit();
+            }
+            $data = [];
+            foreach ($excelArray as $k => $v) {
+                $data[] = [
+                    'org_id' => $this->orgId,
+                    'read_time' => date('Y-m-d', strtotime($v[0])),
+                    'sn' => $v[1],
+                    'rate' => $v[2],
+                    'degree' => $v[3],
+                    'min_temperature' => $v[4],
+                    'max_temperature' => $v[5],
+                    'user_id' => is_login(),
+                    'read_yyyy' => date('Y', strtotime($v[0])),
+                    'read_yyyymm' => date('Ym', strtotime($v[0])),
+                    'read_yyyymmdd' => date('Ymd', strtotime($v[0])),
+                    'create_time' => getTime(),
+                ];
+            }
+            $ret = Db::name('energy_electricity_record')->insertAll($data);
+
+            if(!$ret){
+                echo "<font color=\"red\" style='margin-left: 20px;font-size: 17px'>批量导入失败</font><br />";
+            }else{
+                echo "<font color=\"green\" style='margin-left:20px;font-size: 17px'>批量导入成功</font><br />";
+            }
+
+        }else{
+            exit('请上传文件');
+        }
+
+    }
+
+    public function multiDel() {
+        $ids = input('ids', [], 'trim');
+        if (empty($ids)) {
+            $this->error('未选择记录');
+        }
+        $res = Db::name('energy_electricity_record')->whereIn('id', $ids)->update(['del'=>1]);
+        if (!$res) $this->error('批量删除失败');
+        $this->success('批量删除传成功');
+    }
+}

+ 260 - 0
application/admin/controller/EnergyElectricityRecord2.php

@@ -0,0 +1,260 @@
+<?php
+namespace app\admin\controller;
+
+use app\common\model\User;
+use think\App;
+use think\Db;
+
+class EnergyElectricityRecord2 extends Auth
+{
+    public function __construct(App $app = null) {
+        parent::__construct($app);
+        $this->model = new \app\common\model\EnergyElectricityRecord();
+    }
+    public function index(){
+        if(request()->isAjax()){
+            //分页参数
+            $length = input('rows',10,'intval');   //每页条数
+            $page = input('page',1,'intval');      //第几页
+            $start = ($page - 1) * $length;     //分页开始位置
+            //排序
+            $sortRow = input('sidx','sort','trim');      //排序列
+            $sort = input('sord','asc','trim');        //排序方式
+            $order = $sortRow.' '.$sort.' ,id desc';
+
+            $sn = input('sn','','trim');
+            if($sn){
+                $map[] = ['sn','=',$sn];
+            }
+            $ids = Db::name('energy_electricity')
+                ->where('org_id',$this->orgId)
+                ->where('del',0)
+                ->where('parent_id',0)
+                ->column('number');
+            if (!empty($ids)) {
+                $map[] = ['sn','in',$ids];
+            }
+            $map[] = ['org_id','=',$this->orgId];
+            $map[] = ['del','=',0];
+            $map= empty($map) ? true: $map;
+            //数据查询
+
+            $lists = Db::name('energy_electricity_record')
+                ->where($map)->limit($start,$length)
+                ->order($order)->select();
+            foreach($lists as $k=>$v){
+                $lists[$k]['user_id'] = Db::name('user')->where('id',$v['user_id'])->value('real_name');
+            }
+
+            //数据返回
+            $totalCount = db('energy_electricity_record')->where($map)->count();
+            $totalPage = ceil($totalCount/$length);
+            $result['page'] = $page;
+            $result['total'] = $totalPage;
+            $result['records'] = $totalCount;
+            $result['rows'] = $lists;
+            return json($result);
+        }else{
+            $this->assign('meta_title','电表抄表记录');
+            return $this->fetch();
+        }
+    }
+
+    /**
+     * 新增/编辑
+     */
+    public function add($id=0){
+        $model = $this->model;
+        $userId = is_login();
+        if(request()->isPost()){
+            $res = $model->updates($userId,0);
+            if($res){
+                $this->success('操作成功',url('index'));
+            }else{
+                $this->error($model->getError());
+            }
+        }else{
+            if($id){
+                $info = db('energy_electricity_record')->where('id',$id)->find();
+                $this->assign('info',$info);
+            }
+            return $this->fetch();
+        }
+    }
+
+    /**
+     * 删除记录
+     * @param int $id
+     */
+    public function del($id=0){
+        if(!$id){
+            $this->error('参数错误');
+        }
+        $res = Db::name('energy_electricity_record')->where('id',$id)->update(['del'=>1]);
+        if($res){
+            $this->success('删除成功');
+        }else{
+            $this->error('删除失败');
+        }
+    }
+
+    public function import(){
+        return $this->fetch();
+    }
+    /**
+     * 下载点模板
+     */
+    public function downloadtem(){
+        set_time_limit(0);
+        ini_set("memory_limit","512M");
+        include_once env('root_path').'/extend/phpexcel/Classes/PHPExcel.php';
+        $types = model('Address')->getTypes();
+        ksort($types);
+        $fileName = '电表抄表记录模板.xlsx';
+        $excel = new \PHPExcel();
+        $sheet = $excel->setActiveSheetIndex(0);
+        $arr = array('A','B','C','D','E','F','G');
+        foreach($arr as $k=>$v){
+            $excel->getActiveSheet()->getStyle($v)->getAlignment()->setWrapText(true);//换行
+            $excel->getActiveSheet()->getStyle($v.'1')->getFont()->setBold(true);
+            $excel->getActiveSheet()->getColumnDimension($v)->setWidth(18);
+
+        }
+        $sheet->setCellValueByColumnAndRow(0,1,'日期');
+        $sheet->setCellValueByColumnAndRow(1,1,'表号');
+        $sheet->setCellValueByColumnAndRow(2,1,'倍率');
+        $sheet->setCellValueByColumnAndRow(3,1,'抄表读数');
+        $sheet->setCellValueByColumnAndRow(4,1,'最低温度 (℃))');
+        $sheet->setCellValueByColumnAndRow(5,1,'最高温度 (℃))');
+        $sheet->setCellValueByColumnAndRow(6,1,'床位数量');
+
+        $excel->getActiveSheet()->setCellValue('A2', '2024/09/23');
+        $excel->getActiveSheet()->setCellValue('B2', 'D1101');
+        $excel->getActiveSheet()->setCellValue('C2', '10');
+        $excel->getActiveSheet()->setCellValue('D2', '100');
+        $excel->getActiveSheet()->setCellValue('E2', '10');
+        $excel->getActiveSheet()->setCellValue('F2', '22');
+        $excel->getActiveSheet()->setCellValue('G2', '120');
+
+        ob_end_clean();//清除缓冲区,避免乱码
+        header('Content-Type: application/vnd.ms-excel');
+        header('Content-Disposition: attachment;filename="'.$fileName.'"');
+        header('Cache-Control: max-age=0');
+
+        $objWriter = \PHPExcel_IOFactory::createWriter($excel, 'Excel2007');
+        $objWriter->save('php://output'); //文件通过浏览器下载
+
+    }
+
+
+    /**
+     * 导入
+     */
+    public function importexcel(){
+        set_time_limit(0);
+        ini_set("memory_limit", -1);
+        ob_flush();//清空缓存
+        flush();//刷新缓存
+        include_once env('root_path').'/extend/phpexcel/Classes/PHPExcel.php';
+        $orgId = $this->orgId;
+        if(request()->file()) {
+            $file = request()->file('file');
+            //获取文件后缀
+            $e = explode('.',$_FILES['file']['name']);
+            $ext = $e[count($e)-1];
+            if($ext == 'xls'){
+                \PHPExcel_IOFactory::createReader( 'Excel5');
+            }else{
+                \PHPExcel_IOFactory::createReader('Excel2007');
+            }
+            $newArr=['xls','xlsx'];
+            if(!in_array($ext,$newArr)){
+                exit('文件格式不正确');
+            }
+            // 移动到框架应用根目录/uploads/ 目录下
+            $info = $file->validate([ 'size'=>config('app.max_upload_file_size') ])
+                ->move(env('root_path') . 'public' . DIRECTORY_SEPARATOR . 'uploads'. DIRECTORY_SEPARATOR . 'files');
+            if(!$info){
+                exit('文件上传失败');
+            }
+            $img = './uploads/files/' . $info->getSaveName();
+            $filePath = str_replace('\\', '/', $img);
+            $newPath = \PHPExcel_IOFactory::load($filePath);
+
+            $excelArray = $newPath->getsheet(0)->toArray();   //转换为数组格式
+
+            array_shift($excelArray);  //删除第一个数组(标题);
+            if(empty($excelArray)){
+                exit('文件内容为空');
+            }
+            $ids = Db::name('energy_electricity')
+                ->where('org_id',$this->orgId)
+                ->where('del',0)
+                ->where('parent_id',0)
+                ->column('number');
+            $flag = 0;
+            foreach ($excelArray as $k => $v) {
+                if (!$v[0] || !$v[1] || !$v[2] || !$v[3]) {
+                    $flag = 1;
+                    echo "<font color=\"red\" style='margin-left: 20px;font-size: 17px'>第" . ($k + 1) . "行,有数据为空,请修改后重新导入</font><br />";
+                    continue;
+                }
+                if (!in_array($v[1], $ids)) {
+                    $flag = 1;
+                    echo "<font color=\"red\" style='margin-left: 20px;font-size: 17px'>第" . ($k + 1) . "行,表号不存在或非总表表号,请修改后重新导入</font><br />";
+                    continue;
+                }
+            }
+            if ($flag > 0) {
+                exit();
+            }
+            $data = [];
+            foreach ($excelArray as $k => $v) {
+                $degree = trim($v[3]);
+                $change = Db::name('energy_change_log')
+                    ->where('org_id',$this->orgId)
+                    ->where('sn',$v[1])
+                    ->order('id desc')
+                    ->value('degree');
+                if ($change){
+                    $degree += $change;
+                }
+                $data[] = [
+                    'org_id'=>$this->orgId,
+                    'read_time'=>date('Y-m-d',strtotime($v[0])),
+                    'sn'=>$v[1],
+                    'rate'=>$v[2],
+                    'degree'=>$degree,
+                    'min_temperature'=>$v[4],
+                    'max_temperature'=>$v[5],
+                    'user_id'=>is_login(),
+                    'read_yyyy'=>date('Y',strtotime($v[0])),
+                    'read_yyyymm'=>date('Ym',strtotime($v[0])),
+                    'read_yyyymmdd'=>date('Ymd',strtotime($v[0])),
+                    'create_time'=>getTime(),
+                ];
+            }
+            $ret=Db::name('energy_electricity_record')->insertAll($data);
+
+            if(!$ret){
+                echo "<font color=\"red\" style='margin-left: 20px;font-size: 17px'>批量导入失败</font><br />";
+            }else{
+                echo "<font color=\"green\" style='margin-left:20px;font-size: 17px'>批量导入成功</font><br />";
+            }
+
+        }else{
+            exit('请上传文件');
+        }
+
+    }
+
+    public function multiDel() {
+        $ids = input('ids', [], 'trim');
+        if (empty($ids)) {
+            $this->error('未选择记录');
+        }
+        $res = Db::name('energy_electricity_record')->whereIn('id', $ids)->update(['del'=>1]);
+        if (!$res) $this->error('批量删除失败');
+        $this->success('批量删除传成功');
+    }
+}

+ 209 - 0
application/admin/controller/EnergyGas.php

@@ -0,0 +1,209 @@
+<?php
+namespace app\admin\controller;
+
+use think\Db;
+use think\helper\Str;
+
+class EnergyGas extends Auth
+{
+
+    public function index(){
+        $tree = model('EnergyGas')->showAllTree();
+        $this->traverseArray($tree);
+//        halt($tree);
+        $this->assign('tree',$tree);
+        return $this->fetch();
+    }
+
+    /**
+     * 新增/编辑
+     */
+    public function add($pid=0,$t=0,$id=0){
+        if(request()->isPost()){
+            $res = model('EnergyGas')->updates();
+            if($res){
+                $this->success('操作成功',url('index'));
+            }else{
+                $this->error(model('EnergyGas')->getError());
+            }
+        }else{
+            $meta_title = '新增';
+            if($id){
+                $info = db('energy_gas')->where('id',$id)->find();
+                $info['dep'] = explode(',',$info['dep']);
+                $this->assign('info',$info);
+                $info['s'] = $info['share'] ? (string)$info['share'] : '';
+                $meta_title = '编辑';
+            }
+            $map[] = ['del','=',0];
+            $map[]= ['enable','=',1];
+            $map[]= ['org_id','=',$this->orgId];
+            $alists = db('energy_area')
+                ->field('id,title')
+                ->where($map)
+                ->where('pid',0)
+                ->select();
+            foreach ($alists as $k=>$v) {
+                $alists[$k]['children'] = db('energy_area')
+                    ->field('id,title')
+                    ->where('pid', $v['id'])
+                    ->where($map)
+                    ->select();
+                foreach ($alists[$k]['children'] as $kk => $vv) {
+                    $alists[$k]['children'][$kk]['children'] = db('energy_area')
+                        ->field('id,title')
+                        ->where('pid', $vv['id'])
+                        ->where($map)
+                        ->select();
+                }
+            }
+            $dlists = db('energy_dep')
+                ->field('id,name')
+                ->where($map)
+                ->select();
+            $tlists = db('energy_sort')
+                ->field('id,name')
+                ->where($map)
+                ->select();
+            $this->assign('alist',$alists);
+            $this->assign('dlist',$dlists);
+            $this->assign('tlist',$tlists);
+            $this->assign('pid',$pid);
+            $this->assign('t',$t);
+            $this->assign('meta_title',$meta_title);
+            return $this->fetch();
+        }
+    }
+
+    /**
+     * 拆分电表
+     */
+    public function split($id=0)
+    {
+        if(request()->isPost()){
+            $id = input('post.id');
+            $split = input('post.split');
+            $res = Db::name('energy_gas')->where('id',$id)->setField(['split'=>$split]);
+            if($res){
+                $this->success('操作成功',url('index'));
+            }else{
+                $this->error('操作失败');
+            }
+        }else{
+            $info = db('energy_gas')->where('id',$id)->find();
+            $this->assign('info',$info);
+
+            $map[] = ['del','=',0];
+            $map[]= ['enable','=',1];
+            $map[]= ['org_id','=',$this->orgId];
+            $map[]= ['id','<>',$id];
+            $list = Db::name('energy_gas')
+                ->where('parent_id','>',0)
+                ->where($map)
+                ->select();
+            foreach ($list as $k=>$v) {
+                $list[$k]['number'] = $v['name'].'————'.$v['number'];
+            }
+            $this->assign('list',$list);
+            $this->assign('id',$id);
+            return $this->fetch();
+        }
+    }
+    public function changeEnable($id=0,$enable=0){
+        if($id <= 0){
+            $this->error('参数错误');
+        }
+        $ret = Db::name('energy_gas')->where('org_id',$this->orgId)->where('id',$id)->setField('enable',$enable);
+        if(!$ret){
+            $this->error('操作失败');
+        }
+        $this->success('操作成功');
+    }
+
+    /**
+     * 删除记录
+     * @param int $id
+     */
+    public function del($id=0){
+        if(!$id){
+            $this->error('参数错误');
+        }
+        // 检查是否有子级
+        $ret = Db::name('energy_gas')->where('org_id',$this->orgId)->where('parent_id',$id)->where('del',0)->find();
+        if($ret){
+            $this->error('有子燃气表不能删除');
+        }
+        $res = Db::name('energy_gas')->where('org_id',$this->orgId)->where('id',$id)->setField('del',1);
+        if($res){
+            $this->success('删除成功');
+        }else{
+            $this->error('删除失败');
+        }
+    }
+
+    /**
+     * 循环tree给字段重新赋值
+     */
+    public function traverseArray(&$array) {
+        foreach ($array as &$item) {
+            // 修改type_e的值
+            if (isset($item['type_e'])) {
+                $item['type_e'] = Db::name('energy_sort')->where('org_id',$this->orgId)->where('id',$item['type_e'])->value('name');
+            }
+            // 如果存在children,递归调用
+            if (isset($item['children']) && is_array($item['children'])) {
+                $this->traverseArray($item['children']);
+            }
+        }
+    }
+    /**
+     * 换表
+     * @param string $sn
+     */
+    public function change($sn=''){
+        if(!$sn){
+            $this->error('参数错误');
+        }
+        $record = Db::name('energy_gas_record')
+            ->where('sn',$sn)
+            ->where('del',0)
+            ->order('read_yyyymmdd desc')
+            ->field('degree,read_time')
+            ->findOrEmpty();
+        if (empty($record)){
+            $this->error('该表没有抄表记录');
+        }
+        $res = Db::name('energy_change_log')
+            ->insert([
+                'org_id'=>$this->orgId,
+                'sn'=>$sn,
+                'degree'=>$record['degree'],
+                'read_time'=>$record['read_time'],
+                'create_time'=>getTime(),
+            ]);
+        if($res){
+            $this->success('换表成功');
+        }else{
+            $this->error('换表失败');
+        }
+    }
+    public function getDep() {
+        $data = $this->request->param();
+        $value = $data['param'];
+        if ($value){
+            $map[] = ['address','like','%'.$value.'%'];
+        }else{
+            $map[] = ['address','=',0];
+        }
+        $map[] = ['del','=',0];
+        $map[]= ['enable','=',1];
+        $map[]= ['org_id','=',$this->orgId];
+        $lists = db('energy_dep')
+            ->field('id,name')
+            ->where($map)
+            ->select();
+        return json(['data'=>$lists]);
+
+    }
+
+}

+ 232 - 0
application/admin/controller/EnergyGasRecord.php

@@ -0,0 +1,232 @@
+<?php
+namespace app\admin\controller;
+
+use app\common\model\User;
+use think\App;
+use think\Db;
+
+class EnergyGasRecord extends Auth
+{
+    public function __construct(App $app = null) {
+        parent::__construct($app);
+        $this->model = new \app\common\model\EnergyGasRecord();
+    }
+    public function index(){
+        if(request()->isAjax()){
+            //分页参数
+            $length = input('rows',10,'intval');   //每页条数
+            $page = input('page',1,'intval');      //第几页
+            $start = ($page - 1) * $length;     //分页开始位置
+            //排序
+            $sortRow = input('sidx','sort','trim');      //排序列
+            $sort = input('sord','asc','trim');        //排序方式
+            $order = $sortRow.' '.$sort.' ,id desc';
+
+            $sn = input('sn','','trim');
+            if($sn){
+                $map[] = ['sn','=',$sn];
+            }
+            $map[] = ['org_id','=',$this->orgId];
+            $map[] = ['del','=',0];
+            $map= empty($map) ? true: $map;
+            //数据查询
+            $lists = Db::name('energy_gas_record')
+                ->where($map)->limit($start,$length)
+                ->order($order)->select();
+            foreach($lists as $k=>$v){
+                $lists[$k]['user_id'] = Db::name('user')->where('id',$v['user_id'])->value('real_name');
+            }
+
+            //数据返回
+            $totalCount = db('energy_gas_record')->where($map)->count();
+            $totalPage = ceil($totalCount/$length);
+            $result['page'] = $page;
+            $result['total'] = $totalPage;
+            $result['records'] = $totalCount;
+            $result['rows'] = $lists;
+            return json($result);
+        }else{
+            $this->assign('meta_title','燃气表抄表记录');
+            return $this->fetch();
+        }
+    }
+
+    /**
+     * 新增/编辑
+     */
+    public function add($id=0){
+        $model = $this->model;
+        $userId = is_login();
+        if(request()->isPost()){
+            $res = $model->updates($userId);
+            if($res){
+                $this->success('操作成功',url('index'));
+            }else{
+                $this->error($model->getError());
+            }
+        }else{
+            if($id){
+                $info = db('energy_gas_record')->where('id',$id)->find();
+                $this->assign('info',$info);
+            }
+            return $this->fetch();
+        }
+    }
+
+    /**
+     * 删除记录
+     * @param int $id
+     */
+    public function del($id=0){
+        if(!$id){
+            $this->error('参数错误');
+        }
+        $res = Db::name('energy_gas_record')->where('id',$id)->update(['del'=>1]);
+        if($res){
+            $this->success('删除成功');
+        }else{
+            $this->error('删除失败');
+        }
+    }
+
+    public function import(){
+        return $this->fetch();
+    }
+    /**
+     * 下载点模板
+     */
+    public function downloadtem(){
+        set_time_limit(0);
+        ini_set("memory_limit","512M");
+        include_once env('root_path').'/extend/phpexcel/Classes/PHPExcel.php';
+        $types = model('Address')->getTypes();
+        ksort($types);
+        $fileName = '燃气表抄表记录模板.xlsx';
+        $excel = new \PHPExcel();
+        $sheet = $excel->setActiveSheetIndex(0);
+        $arr = array('A','B','C','D','E','F');
+        foreach($arr as $k=>$v){
+            $excel->getActiveSheet()->getStyle($v)->getAlignment()->setWrapText(true);//换行
+            $excel->getActiveSheet()->getStyle($v.'1')->getFont()->setBold(true);
+            $excel->getActiveSheet()->getColumnDimension($v)->setWidth(18);
+
+        }
+        $sheet->setCellValueByColumnAndRow(0,1,'日期');
+        $sheet->setCellValueByColumnAndRow(1,1,'表号');
+        $sheet->setCellValueByColumnAndRow(2,1,'抄表读数');
+        $sheet->setCellValueByColumnAndRow(3,1,'最低温度 (℃))');
+        $sheet->setCellValueByColumnAndRow(4,1,'最高温度 (℃))');
+        $sheet->setCellValueByColumnAndRow(5,1,'床位数量');
+
+        $excel->getActiveSheet()->setCellValue('A2', '2024/09/23');
+        $excel->getActiveSheet()->setCellValue('B2', 'G1101');
+        $excel->getActiveSheet()->setCellValue('C2', '100');
+        $excel->getActiveSheet()->setCellValue('D2', '10');
+        $excel->getActiveSheet()->setCellValue('E2', '22');
+        $excel->getActiveSheet()->setCellValue('F2', '120');
+
+        ob_end_clean();//清除缓冲区,避免乱码
+        header('Content-Type: application/vnd.ms-excel');
+        header('Content-Disposition: attachment;filename="'.$fileName.'"');
+        header('Cache-Control: max-age=0');
+
+        $objWriter = \PHPExcel_IOFactory::createWriter($excel, 'Excel2007');
+        $objWriter->save('php://output'); //文件通过浏览器下载
+
+    }
+
+
+    /**
+     * 导入
+     */
+    public function importexcel(){
+        set_time_limit(0);
+        ini_set("memory_limit", -1);
+        ob_flush();//清空缓存
+        flush();//刷新缓存
+        include_once env('root_path').'/extend/phpexcel/Classes/PHPExcel.php';
+        $orgId = $this->orgId;
+        if(request()->file()) {
+            $file = request()->file('file');
+            //获取文件后缀
+            $e = explode('.',$_FILES['file']['name']);
+            $ext = $e[count($e)-1];
+            if($ext == 'xls'){
+                \PHPExcel_IOFactory::createReader( 'Excel5');
+            }else{
+                \PHPExcel_IOFactory::createReader('Excel2007');
+            }
+            $newArr=['xls','xlsx'];
+            if(!in_array($ext,$newArr)){
+                exit('文件格式不正确');
+            }
+            // 移动到框架应用根目录/uploads/ 目录下
+            $info = $file->validate([ 'size'=>config('app.max_upload_file_size') ])
+                ->move(env('root_path') . 'public' . DIRECTORY_SEPARATOR . 'uploads'. DIRECTORY_SEPARATOR . 'files');
+            if(!$info){
+                exit('文件上传失败');
+            }
+            $img = './uploads/files/' . $info->getSaveName();
+            $filePath = str_replace('\\', '/', $img);
+            $newPath = \PHPExcel_IOFactory::load($filePath);
+
+            $excelArray = $newPath->getsheet(0)->toArray();   //转换为数组格式
+
+            array_shift($excelArray);  //删除第一个数组(标题);
+            if(empty($excelArray)){
+                exit('文件内容为空');
+            }
+
+            foreach ($excelArray as $k => $v) {
+
+                if(!$v[0] || !$v[1] || !$v[2]){
+                    echo "<font color=\"red\" style='margin-left: 20px;font-size: 17px'>第".($k+1)."行,有数据为空,未导入</font><br />";
+                    continue;
+                }
+                $degree = $v[2];
+                $change = Db::name('energy_change_log')
+                    ->where('org_id',$this->orgId)
+                    ->where('sn',$v[1])
+                    ->order('id desc')
+                    ->value('degree');
+                if ($change){
+                    $degree = $change + $degree;
+                }
+                $Data = [
+                    'org_id'=>$this->orgId,
+                    'read_time'=>date('Y-m-d',strtotime($v[0])),
+                    'sn'=>$v[1],
+                    'degree'=>$degree,
+                    'min_temperature'=>$v[3],
+                    'max_temperature'=>$v[4],
+                    'user_id'=>is_login(),
+                    'read_yyyy'=>date('Y',strtotime($v[0])),
+                    'read_yyyymm'=>date('Ym',strtotime($v[0])),
+                    'read_yyyymmdd'=>date('Ymd',strtotime($v[0])),
+                    'create_time'=>getTime(),
+                ];
+                $ret=Db::name('energy_gas_record')->insert($Data);
+
+                if(!$ret){
+                    echo "<font color=\"red\" style='margin-left: 20px;font-size: 17px'>第".($k+1)."行,导入失败</font><br />";
+                }else{
+                    echo "<font color=\"green\" style='margin-left:20px;font-size: 17px'>第".($k+1)."行,导入成功</font><br />";
+                }
+
+            }
+        }else{
+            exit('请上传文件');
+        }
+
+    }
+
+    public function multiDel() {
+        $ids = input('ids', [], 'trim');
+        if (empty($ids)) {
+            $this->error('未选择记录');
+        }
+        $res = Db::name('energy_gas_record')->whereIn('id', $ids)->update(['del'=>1]);
+        if (!$res) $this->error('批量删除失败');
+        $this->success('批量删除传成功');
+    }
+}

+ 34 - 0
application/admin/controller/EnergyRecordWarning.php

@@ -0,0 +1,34 @@
+<?php
+namespace app\admin\controller;
+
+class EnergyRecordWarning extends Auth
+{
+    public function index(){
+        if(request()->isAjax()){
+            //分页参数
+            $length = input('rows',10,'intval');   //每页条数
+            $page = input('page',1,'intval');      //第几页
+            $start = ($page - 1) * $length;     //分页开始位置
+            //排序
+            $sortRow = input('sidx','sort','trim');
+            $type = input('type','','trim');
+            if ($type != '') {
+                $map['type'] = $type;
+            }
+            $map['org_id'] = $this->orgId;
+            //数据查询
+            $lists = db('energy_record_warning')->where($map)->limit($start,$length)->select();
+            $totalCount = db('energy_record_warning')->where($map)->count();
+            $totalPage = ceil($totalCount/$length);
+            $result['page'] = $page;
+            $result['total'] = $totalPage;
+            $result['records'] = $totalCount;
+            $result['rows'] = $lists;
+            return json($result);
+        }else{
+            return $this->fetch();
+        }
+    }
+
+
+}

+ 111 - 0
application/admin/controller/EnergySort.php

@@ -0,0 +1,111 @@
+<?php
+namespace app\admin\controller;
+
+class EnergySort extends Auth
+{
+    public function index(){
+        if(request()->isAjax()){
+            //分页参数
+            $length = input('rows',10,'intval');   //每页条数
+            $page = input('page',1,'intval');      //第几页
+            $start = ($page - 1) * $length;     //分页开始位置
+            //排序
+            $sortRow = input('sidx','sort','trim');      //排序列
+            $sort = input('sord','asc','trim');        //排序方式
+            $order = $sortRow.' '.$sort;
+            $map['del'] = 0;
+            $map['org_id'] = $this->orgId;
+            //数据查询
+            $lists = db('energy_sort')->where($map)->limit($start,$length)->order($order)->select();
+            //数据返回
+            $totalCount = db('energy_sort')->where($map)->count();
+            $totalPage = ceil($totalCount/$length);
+            $result['page'] = $page;
+            $result['total'] = $totalPage;
+            $result['records'] = $totalCount;
+            $result['rows'] = $lists;
+            return json($result);
+        }else{
+            return $this->fetch();
+        }
+    }
+
+    /**
+     * 新增/编辑
+     */
+    public function add($id=0,$pid=0){
+        if(request()->isPost()){
+            $res = model('energy_sort')->updates();
+            if($res){
+                $this->success('操作成功');
+            }else{
+                $this->error(model('energy_sort')->getError());
+            }
+        }else{
+            $map['del'] = 0;
+            $map['org_id'] = $this->orgId;
+            $map['enable'] = 1;
+            $meta_title = '新增';
+            if($id){
+                $info = db('energy_sort')->where($map)->where('id',$id)->find();
+                $this->assign('info',$info);
+                $meta_title = '编辑';
+            }
+            $this->assign('meta_title',$meta_title);
+            return $this->fetch();
+        }
+    }
+
+    /**
+     * 删除记录
+     * @param int $id
+     */
+    public function del($id=0){
+        if(!$id){
+            $this->error('参数错误');
+        }
+        $res = db('energy_sort')->where('org_id',$this->orgId)->where('id',$id)->update(['del'=>1]);
+        if($res){
+            $this->success('删除成功');
+        }else{
+            $this->error('删除失败');
+        }
+    }
+
+    /**
+     * 改变字段值
+     * @param int $fv
+     * @param string $fn
+     * @param int $fv
+     */
+    public function changeField($id=0,$fn='',$fv=0){
+        if(!$fn||!$id){
+            $this->error('参数错误');
+        }
+        $res = db('energy_sort')->where('org_id',$this->orgId)->where('id',$id)->setField($fn,$fv);
+        if($res){
+            $this->success('操作成功');
+        }else{
+            $this->error('操作失败');
+        }
+    }
+
+    /**
+     * 排序
+     * @param int $id
+     * @param int $sort
+     */
+    public function changeSort($id=0,$sort=0){
+        if($id<0||$sort<0){
+            $this->error('参数错误');
+        }
+        $res = db('energy_sort')->where('org_id',$this->orgId)->where('id',$id)->setField('sort',$sort);
+        if($res){
+            $this->success('操作成功');
+        }else{
+            $this->error('操作失败');
+        }
+    }
+
+
+}

Rozdielové dáta súboru neboli zobrazené, pretože súbor je príliš veľký
+ 2346 - 0
application/admin/controller/EnergyStatistics.php


+ 710 - 0
application/admin/controller/EnergyStatisticsOld.php

@@ -0,0 +1,710 @@
+<?php
+namespace app\admin\controller;
+
+use think\Db;
+
+class EnergyStatisticsOld extends Auth
+{
+    //医院每日用电电统计
+    public function dailyElectricity()
+    {
+        $month = input('start',date('Y-m'));
+
+        $data = $this->dailyElectricityData($month);
+        $this->assign('data',$data['res']);
+        $this->assign('count',$data['count']);
+        $this->assign('totalData',$data['total']);
+        $this->assign('start',$month);
+        $this->assign('date',date('Y年m月',strtotime($month)));
+        return $this->fetch();
+    }
+
+    public function dailyElectricityData($month){
+
+        $dep  = getDay(strtotime($month));
+        $lastDayOfLastMonth = date('Ymd', strtotime("-1 day", strtotime(date("Y-m-01", strtotime($month)))));
+        $map[] = ['del','=',0];
+        $map[] = ['org_id','=',$this->orgId];
+        $sn = Db::name('energy_electricity')
+            ->where($map)
+            ->where('enable',1)
+            ->where('parent_id',0)
+            ->column('number');
+        $res = [];
+        $total = 0;
+        foreach ($dep as $k=>$v){
+            $degree = 0;
+            foreach ($sn as $kk =>$vv){
+                $row = Db::name('energy_electricity_record')
+                    ->where($map)
+                    ->where('read_yyyymmdd',$v)
+                    ->where('sn',$vv)
+                    ->field('sn,rate,degree')
+                    ->find();
+                $res[$k][$kk] = $row;
+                if ($k > 0 && !empty($row)){
+//                    $res[$k][$kk]['real_degree'] = number_format(($res[$k][$kk]['degree'] - $res[$k-1][$kk]['degree']) * $res[$k][$kk]['rate'],2,'.','');
+                    $res[$k][$kk]['real_degree'] =  sprintf("%.2f", ($res[$k][$kk]['degree'] - $res[$k-1][$kk]['degree']) * $res[$k][$kk]['rate']);
+                    $degree += $res[$k][$kk]['real_degree'];
+                }
+
+                if($k == 0){
+                    $row2= Db::name('energy_electricity_record')
+                        ->where($map)
+                        ->where('read_yyyymmdd',$lastDayOfLastMonth)
+                        ->where('sn',$vv)
+                        ->field('sn,rate,degree')
+                        ->find();
+//                    $row2['degree'] = isset($row2['degree'])?$row2['degree']:0;
+                    //$res[$k][$kk]['real_degree'] = number_format(($res[$k][$kk]['degree'] - $row2['degree']) * $res[$k][$kk]['rate'],2,'.','');
+                    $res[$k][$kk]['real_degree'] =  sprintf("%.2f", ($res[$k][$kk]['degree'] - $row2['degree']) * $res[$k][$kk]['rate']);
+                    $degree += $res[$k][$kk]['real_degree'];
+                }
+
+            }
+            $res[$k]['total'] = sprintf('%.2f',$degree);
+            $total+=$degree;
+        }
+        $total = sprintf('%.2f',$total);
+
+
+        return ['res'=>$res,'total'=>$total,'count'=>count($sn)];
+    }
+
+    //科室月电度统计
+    public function monthDepElectricity()
+    {
+        $month = input('start', date('Y'));
+
+        for ($i = 1; $i < 13; $i++) {
+            $monthList[] = $i.'月份';
+        }
+            $data = $this->monthDepElectricityData($month);
+            $this->assign('data', $data);
+            $this->assign('monthList', $monthList);
+            $this->assign('start', $month);
+//            halt($data);
+            return $this->fetch();
+    }
+
+    public function monthDepElectricityData($month)
+    {
+        $month = $month.'0101';
+        for ($i = 1; $i < 13; $i++) {
+            if ($i<10){
+                $date[] = date('Y'.'0'.$i,strtotime($month));
+                if ($i==1){
+                    $time = strtotime($date[0].'01');
+                    $lastDate[] = date('Ym',strtotime('-1 month',$time));
+                }else{
+                    $lastDate[] = date('Y'.'0'.($i-1),strtotime($month));
+                }
+            }else{
+                $date[] = date('Y'.$i,strtotime($month));
+                if ($i==10){
+                    $lastDate[] = date('Y'.'0'.($i-1),strtotime($month));
+                }else{
+                    $lastDate[] = date('Y'.($i-1),strtotime($month));
+                }
+            }
+        }
+        $map[] = ['del','=',0];
+        $map[] = ['org_id','=',$this->orgId];
+        $list = [];
+        $dep = Db::name('energy_dep')
+            ->where($map)
+            ->where('enable',1)
+            ->field('id,name,area,address')
+            ->select();
+//        halt($dep);
+        foreach ($dep as $item){
+            $re = Db::name('energy_electricity')
+                ->Where($map)
+                ->where('enable',1)
+                ->Where('dep','like','%'.$item['id'].'%')
+                ->select();
+            if(!empty($re)){
+                $list[] = $re;
+            }
+
+        }
+
+        $newList = $this->getNewList($list);
+        foreach ($newList as $k => $v){
+            foreach ($v as $k2=>$v2){
+                $address = json_decode($v2['address']);
+                $dep_id = json_decode($v2['dep']);
+                $newList[$k][$k2]['info']['floor1'] = Db::name('energy_area')->where('id',$address[1])->value('title');
+                $newList[$k][$k2]['info']['floor2'] = Db::name('energy_area')->where('id',$address[2])->value('title');
+                $newList[$k][$k2]['info']['dep'] = Db::name('energy_dep')->where('id',$dep_id[0])->value('name');
+                $newList[$k][$k2]['info']['type'] = Db::name('energy_sort')->where('id',$v2['type_e'])->value('name');
+                foreach ($date as $k3=>$v3){
+                    $re = Db::name('energy_electricity_record')
+                        ->field('sn,degree,rate,read_yyyymm')
+                        ->where($map)
+                        ->where('read_yyyymm',$v3)
+                        ->where('sn',$v2['number'])
+                        ->find();
+
+                    $re2 = Db::name('energy_electricity_record')
+                        ->field('sn,degree')
+                        ->where($map)
+                        ->where('read_yyyymm',$lastDate[$k3])
+                        ->where('sn',$v2['number'])
+                        ->find();
+                    if (isset($re['sn'])){
+                        $newList[$k][$k2]['rate'] = $re['rate'];
+                    }
+                    if ($re['degree']){
+                        if ($v2['share'] == 1 || (string)$v2['share'] == '0'){
+                            $re['real_degree'] = ($re['degree'] - $re2['degree']) * $re['rate'] * $v2['percent'];
+                        }else{
+                            $re['real_degree'] =($re['degree'] - $re2['degree']) * $re['rate'];
+                        }
+                    }
+                    $newList[$k][$k2]['data'][] = $re;
+                }
+            }
+        }
+
+
+        foreach ($date as $k=>$v){
+               for($i =0;$i<count($newList);$i++){
+                   $count = 0;
+                   foreach ($newList[$i] as $k2=>$v2){
+                       $count += $v2['data'][$k]['real_degree']?$v2['data'][$k]['real_degree']:0;
+                       $total[$i][$k]=$count;
+                   }
+
+               }
+        }
+        foreach ($total as $k=>$v){
+            foreach ($v as $k2=>$v2){
+                $newList[$k][0]['data'][$k2]['total']=$v2;
+            }
+
+        }
+        return $newList;
+    }
+
+
+    //医院每日用水统计
+    public function dailyWater()
+    {
+        $month = input('start',date('Y-m'));
+
+        $data = $this->dailyWaterData($month);
+        $this->assign('data',$data['res']);
+        $this->assign('count',$data['count']);
+        $this->assign('totalData',$data['total']);
+        $this->assign('start',$month);
+        $this->assign('date',date('Y年m月',strtotime($month)));
+        return $this->fetch();
+    }
+
+    public function dailyWaterData($month){
+
+        $dep  = getDay(strtotime($month));
+        $lastDayOfLastMonth = date('Ymd', strtotime("-1 day", strtotime(date("Y-m-01", strtotime($month)))));
+        $map[] = ['del','=',0];
+        $map[] = ['org_id','=',$this->orgId];
+        $sn = Db::name('energy_water')
+            ->where($map)
+            ->where('enable',1)
+            ->where('parent_id',0)
+            ->column('number');
+        $res = [];
+        $total = 0;
+        foreach ($dep as $k=>$v){
+            $degree = 0;
+            foreach ($sn as $kk =>$vv){
+                $row = Db::name('energy_water_record')
+                    ->where($map)
+                    ->where('read_yyyymmdd',$v)
+                    ->where('sn',$vv)
+                    ->field('sn,degree')
+                    ->find();
+                $res[$k][$kk] = $row;
+                if ($k > 0 && !empty($row)){
+//                    $res[$k][$kk]['real_degree'] = number_format(($res[$k][$kk]['degree'] - $res[$k-1][$kk]['degree']) ,2,'.','');
+                    $res[$k][$kk]['real_degree'] =  sprintf("%.2f", ($res[$k][$kk]['degree'] - $res[$k-1][$kk]['degree']));
+                    $degree += $res[$k][$kk]['real_degree'];
+                }
+
+                if($k == 0){
+                    $row2= Db::name('energy_water_record')
+                        ->where($map)
+                        ->where('read_yyyymmdd',$lastDayOfLastMonth)
+                        ->where('sn',$vv)
+                        ->field('sn,degree')
+                        ->find();
+//                    $row2['degree'] = isset($row2['degree'])?$row2['degree']:0;
+                    //$res[$k][$kk]['real_degree'] = number_format(($res[$k][$kk]['degree'] - $row2['degree']) ,2,'.','');
+                    $res[$k][$kk]['real_degree'] =  sprintf("%.2f", ($res[$k][$kk]['degree'] - $row2['degree']));
+                    $degree += $res[$k][$kk]['real_degree'];
+                }
+
+            }
+            $res[$k]['total'] = sprintf('%.2f',$degree);
+            $total+=$degree;
+        }
+        $total = sprintf('%.2f',$total);
+
+        return ['res'=>$res,'total'=>$total,'count'=>count($sn)];
+    }
+
+    //科室月冷热水量统计
+    public function monthDepWater()
+    {
+        $month = input('start', date('Y'));
+
+        for ($i = 1; $i < 13; $i++) {
+            $monthList[] = $i.'月份';
+        }
+        $data = $this->monthDepWaterData($month);
+        $this->assign('data', $data);
+        $this->assign('monthList', $monthList);
+        $this->assign('start', $month);
+//            halt($data);
+        return $this->fetch();
+    }
+
+    public function monthDepWaterData($month)
+    {
+        $month = $month.'0101';
+        for ($i = 1; $i < 13; $i++) {
+            if ($i<10){
+                $date[] = date('Y'.'0'.$i,strtotime($month));
+                if ($i==1){
+                    $time = strtotime($date[0].'01');
+                    $lastDate[] = date('Ym',strtotime('-1 month',$time));
+                }else{
+                    $lastDate[] = date('Y'.'0'.($i-1),strtotime($month));
+                }
+            }else{
+                $date[] = date('Y'.$i,strtotime($month));
+                if ($i==10){
+                    $lastDate[] = date('Y'.'0'.($i-1),strtotime($month));
+                }else{
+                    $lastDate[] = date('Y'.($i-1),strtotime($month));
+                }
+            }
+        }
+        $map[] = ['del','=',0];
+        $map[] = ['org_id','=',$this->orgId];
+        $list = [];
+        $dep = Db::name('energy_dep')
+            ->where($map)
+            ->where('enable',1)
+            ->field('id,name,area,address')
+            ->select();
+        foreach ($dep as $item){
+            $re = Db::name('energy_water')
+                ->Where($map)
+                ->where('enable',1)
+                ->Where('dep','like','%'.$item['id'].'%')
+                ->select();
+            if(!empty($re)){
+                $list[] = $re;
+            }
+
+        }
+        if (empty($list)){
+            return $list;
+        }
+   $newList = $this->getNewList($list);
+        foreach ($newList as $k => $v){
+            foreach ($v as $k2=>$v2) {
+                $address = json_decode($v2['address']);
+                $dep_id = json_decode($v2['dep']);
+                $newList[$k][$k2]['info']['floor1'] = Db::name('energy_area')->where('id', $address[1])->value('title');
+                $newList[$k][$k2]['info']['floor2'] = Db::name('energy_area')->where('id', $address[2])->value('title');
+                $newList[$k][$k2]['info']['dep'] = Db::name('energy_dep')->where('id', $dep_id[0])->value('name');
+                if ($v2['type_w'] == 0) {//统计冷水
+                    foreach ($date as $k3 => $v3) {
+                        $re = Db::name('energy_water_record')
+                            ->field('sn,degree,read_yyyymm')
+                            ->where($map)
+                            ->where('read_yyyymm', $v3)
+                            ->where('sn', $v2['number'])
+                            ->find();
+
+                        $re2 = Db::name('energy_water_record')
+                            ->field('sn,degree')
+                            ->where($map)
+                            ->where('read_yyyymm', $lastDate[$k3])
+                            ->where('sn', $v2['number'])
+                            ->find();
+                        if ($re['degree']) {
+                            if ($v2['share'] == 1 || (string)$v2['share'] == '0'){
+                                $re['cold_degree'] = ($re['degree'] - $re2['degree']) * $v2 ['percent'];
+                            }else{
+                                $re['cold_degree'] = ($re['degree'] - $re2['degree']);
+                            }
+                        }
+                        $newList[$k]['sn'] = $v2['number'];
+                        $newList[$k]['cold'][] = $re;
+                    }
+                }
+                if ($v2['type_w'] == 1) {
+                    $hotIn = 0;
+                    foreach ($date as $k4 => $v4) {
+                        $hotIn = Db::name('energy_water_record')
+                            ->field('sn,degree,read_yyyymm')
+                            ->where($map)
+                            ->where('read_yyyymm', $v4)
+                            ->where('sn', $v2['number'])
+                            ->sum('degree');
+                        if ($v2['share'] == 1){
+                            $hotIn = $hotIn*$v2['percent'];
+                        }
+                        $newList[$k]['hotIn'][] = $hotIn;
+                    }
+                }
+                    if ($v2['type_w'] == 2) {
+                        $hotReturn = 0;
+                        foreach ($date as $k5 => $v5) {
+                            $hotReturn = Db::name('energy_water_record')
+                                ->field('sn,degree,read_yyyymm')
+                                ->where($map)
+                                ->where('read_yyyymm', $v5)
+                                ->where('sn', $v2['number'])
+                                ->sum('degree');
+                            if ($v2['share'] == 1){
+                                $hotReturn = $hotReturn*$v2['percent'];
+                            }
+                            $newList[$k]['hotReturn'][] = $hotReturn;
+                        }
+                    }
+
+
+            }
+        }
+
+
+        foreach ($newList as $k=> $v){
+            if (!isset($v['cold'])){
+                foreach ($date as $k1 => $v1) {
+                    $newList[$k]['cold'][] = 0;
+                }
+            }
+            if (!isset($v['hotIn'])){
+                foreach ($date as $k1 => $v1) {
+                    $newList[$k]['hotIn'][] = 0;
+                }
+            }
+            if (!isset($v['hotReturn'])){
+                foreach ($date as $k1 => $v1) {
+                    $newList[$k]['hotReturn'][] = 0;
+                }
+            }
+        }
+        return $newList;
+    }
+
+    //医院每日燃气用量统计
+    public function dailyGas()
+    {
+        $month = input('start',date('Y-m'));
+
+        $data = $this->dailyGasData($month);
+        $this->assign('data',$data['res']);
+        $this->assign('count',$data['count']);
+        $this->assign('totalData',$data['total']);
+        $this->assign('start',$month);
+        $this->assign('date',date('Y年m月',strtotime($month)));
+        return $this->fetch();
+    }
+
+    public function dailyGasData($month){
+
+        $dep  = getDay(strtotime($month));
+        $lastDayOfLastMonth = date('Ymd', strtotime("-1 day", strtotime(date("Y-m-01", strtotime($month)))));
+        $map[] = ['del','=',0];
+        $map[] = ['org_id','=',$this->orgId];
+        $sn = Db::name('energy_gas')
+            ->where($map)
+            ->where('enable',1)
+            ->where('parent_id',0)
+            ->column('number');
+        $res = [];
+        $total = 0;
+        foreach ($dep as $k=>$v){
+            $degree = 0;
+            foreach ($sn as $kk =>$vv){
+                $row = Db::name('energy_gas_record')
+                    ->where($map)
+                    ->where('read_yyyymmdd',$v)
+                    ->where('sn',$vv)
+                    ->field('sn,degree')
+                    ->find();
+                $res[$k][$kk] = $row;
+                if ($k > 0 && !empty($row)){
+                    //$res[$k][$kk]['real_degree'] = number_format(($res[$k][$kk]['degree'] - $res[$k-1][$kk]['degree']) ,2,'.','');
+                    $res[$k][$kk]['real_degree'] =sprintf("%.2f", ($res[$k][$kk]['degree'] - $res[$k-1][$kk]['degree'])) ;
+                    $degree += $res[$k][$kk]['real_degree'];
+                }
+
+                if($k == 0){
+                    $row2= Db::name('energy_gas_record')
+                        ->where($map)
+                        ->where('read_yyyymmdd',$lastDayOfLastMonth)
+                        ->where('sn',$vv)
+                        ->field('sn,degree')
+                        ->find();
+//                    $row2['degree'] = isset($row2['degree'])?$row2['degree']:0;
+                   // $res[$k][$kk]['real_degree'] = number_format(($res[$k][$kk]['degree'] - $row2['degree']) ,2,'.','');
+                    $res[$k][$kk]['real_degree'] =  sprintf("%.2f", ($res[$k][$kk]['degree'] - $row2['degree']));
+                    $degree += $res[$k][$kk]['real_degree'];
+                }
+
+            }
+            $res[$k]['total'] = sprintf('%.2f',$degree);
+            $total+=$degree;
+        }
+        $total = sprintf('%.2f',$total);
+
+        return ['res'=>$res,'total'=>$total,'count'=>count($sn)];
+    }
+
+    //科室月燃气用量统计
+    public function monthDepGas()
+    {
+        $month = input('start', date('Y'));
+
+        for ($i = 1; $i < 13; $i++) {
+            $monthList[] = $i.'月份';
+        }
+        $data = $this->monthDepGasData($month);
+        $this->assign('data', $data['newList']);
+        $this->assign('count', $data['count']);
+        $this->assign('total', $data['total']);
+        $this->assign('monthList', $monthList);
+        $this->assign('start', $month);
+//            halt($data);
+        return $this->fetch();
+    }
+
+    public function monthDepGasData($month)
+    {
+        $month = $month.'0101';
+        for ($i = 1; $i < 13; $i++) {
+            if ($i<10){
+                $date[] = date('Y'.'0'.$i,strtotime($month));
+                if ($i==1){
+                    $time = strtotime($date[0].'01');
+                    $lastDate[] = date('Ym',strtotime('-1 month',$time));
+                }else{
+                    $lastDate[] = date('Y'.'0'.($i-1),strtotime($month));
+                }
+            }else{
+                $date[] = date('Y'.$i,strtotime($month));
+                if ($i==10){
+                    $lastDate[] = date('Y'.'0'.($i-1),strtotime($month));
+                }else{
+                    $lastDate[] = date('Y'.($i-1),strtotime($month));
+                }
+
+            }
+        }
+        $map[] = ['del','=',0];
+        $map[] = ['org_id','=',$this->orgId];
+        $list = [];
+        $dep = Db::name('energy_dep')
+            ->where($map)
+            ->where('enable',1)
+            ->field('id,name,area,address')
+            ->select();
+        foreach ($dep as $item){
+            $re = Db::name('energy_gas')
+                ->Where($map)
+                ->where('enable',1)
+                ->Where('dep','like','%'.$item['id'].'%')
+                ->select();
+            if(!empty($re)){
+                $list[] = $re;
+            }
+
+        }
+        $newList = $this->getNewList($list);
+        foreach ($newList as $k => $v){
+            foreach ($v as $k2=>$v2){
+                $address = json_decode($v2['address']);
+                $dep_id = json_decode($v2['dep']);
+                $newList[$k][$k2]['info']['floor1'] = Db::name('energy_area')->where('id',$address[1])->value('title');
+                $newList[$k][$k2]['info']['floor2'] = Db::name('energy_area')->where('id',$address[2])->value('title');
+                $newList[$k][$k2]['info']['dep'] = Db::name('energy_dep')->where('id',$dep_id[0])->value('name');
+                foreach ($date as $k3=>$v3){
+                    $re = Db::name('energy_gas_record')
+                        ->field('sn,degree,read_yyyymm')
+                        ->where($map)
+                        ->where('read_yyyymm',$v3)
+                        ->where('sn',$v2['number'])
+                        ->find();
+
+                    $re2 = Db::name('energy_gas_record')
+                        ->field('sn,degree')
+                        ->where($map)
+                        ->where('read_yyyymm',$lastDate[$k3])
+                        ->where('sn',$v2['number'])
+                        ->find();
+                    if ($re['degree']){
+                        if ($v2['share'] == 1 || (string)$v2['share'] == '0'){
+                            $re['real_degree'] = $re['degree'] - $re2['degree']*$v2['percent'];
+                        }else{
+                            $re['real_degree'] = $re['degree'] - $re2['degree'];
+                        }
+
+                    }
+                    $newList[$k][$k2]['data'][] = $re;
+                }
+            }
+        }
+
+        $total = [];
+        foreach ($date as $k=>$v){
+            $degree = 0;
+            foreach ($newList as $k2 => $v2){
+                $count=0;
+                foreach ($v2 as $k3=>$v3){
+                    if (!empty($v2[0]['data'][$k])){
+                        $count = $v2[0]['data'][$k]['real_degree'];
+                    }
+                    $degree+=$count;
+                }
+                $total[$k] = $degree;
+            }
+        }
+//halt($newList);
+        return ['newList'=>$newList,'count'=>count($newList),'total'=>$total];
+    }
+
+
+    //对取到的数据进行整理,根据地址和科室进行分类整合
+    public function getNewList($list)
+    {
+        //根据number进行分组
+        $grouped_array = [];
+        foreach ($list as $group) {
+            foreach ($group as $item) {
+                $number = $item['number'];
+                // 如果这个number还没有分组,则创建一个新的分组
+                if (!isset($grouped_array[$number])) {
+                    $grouped_array[$number] = [];
+                }
+                // 添加元素到对应的分组
+                $grouped_array[$number][] = $item;
+            }
+        }
+        $grouped_array = array_values($grouped_array);
+        //分配比例
+        foreach ($grouped_array as $k => $v){
+            if (count($v)>1){
+                $index = 0;
+                foreach ($v as $k2=>$v2){
+                    if ($v2['share'] == 1){ //按比例分摊
+                        $dep = json_decode($v2['dep']);
+                        $percent = explode(':',$v2['percent']);
+                        $m = 0;  //分母
+                        foreach ($percent as $k3=>$v3){
+                            $m +=$percent[$k3];
+                        }
+                        $p = sprintf("%.2f", $percent[$index]/$m);
+                        $grouped_array[$k][$k2]['percent'] = $p ;
+                        $grouped_array[$k][$k2]['dep'] = '['.$dep[$index].']' ;
+                        $index+=1;
+                    }
+                    if ((string)$v2['share'] == '0' ){ //按面积分摊
+                        $dep = json_decode($v2['dep']);
+                        $ids = [];
+                        foreach ($dep as $v3) {
+                            $ids[] = $v3;
+                        }
+                        $areas = Db::name('energy_dep')->where('id', 'in', $ids)->column('area', 'id');
+                        $m = 0;//分母
+                        foreach ($dep as $k3 => $v3) {
+                            $m += $areas[$v3];
+                        }
+                        $area = $areas[$dep[$index]];
+                        $p = sprintf("%.2f", $area/$m);
+                        $grouped_array[$k][$k2]['percent'] = $p ;
+                        $grouped_array[$k][$k2]['dep'] = '['.$dep[$index].']' ;
+                        $index+=1;
+                    }
+                }
+            }
+        }
+
+//        $modifiedArray = [];
+//        // 遍历数组的每个子数组
+//        foreach ($grouped_array as $firstKey => $subArray) {
+//            foreach ($subArray as $secondKey => $item) {
+//                // 解析 dep 字段
+//                $deps = json_decode($item['dep'], true);
+//                if (is_array($deps) && count($deps) > 1) {
+//                    // 如果 dep 包含多个元素,为每个元素创建新的数组项
+//                    foreach ($deps as $depValue) {
+//                        $newItem = $item; // 复制原数组项
+//                        $newItem['dep'] = json_encode([$depValue]); // 更新 dep 字段
+//                        // 直接替换掉原有的数组项
+//                        $modifiedArray[$firstKey][] = $newItem;
+//
+//                    }
+//                } else {
+//                    $modifiedArray[$firstKey][] = $item;
+//                }
+//            }
+//        }
+
+// 根据相同地址和科室组合电表
+        $otherArrays = array_slice($grouped_array, 1);
+
+        // 合并数组
+        $list = array_merge($grouped_array[0], ...$otherArrays);
+
+        // 初始化新数组
+        $list2 = [];
+
+        // 遍历原始列表,将每个项目添加到对应的地址和部门组合索引下
+        foreach ($list as $item) {
+            // 创建组合键
+            $combinedKey = $item['address'] . '|' . $item['dep'];
+            if (!isset($list2[$combinedKey])) {
+                // 如果这个组合键还不存在,就创建一个新的分组
+                $list2[$combinedKey] = [];
+            }
+            // 将项目添加到新数组的对应组合键下
+            $list2[$combinedKey][] = $item;
+        }
+
+        $list2 = array_values($list2);
+
+//对数组进行去重操作
+        $newList = [];
+        foreach ($list2 as $subArray) {
+            $processedSubArray = []; // 用于存储当前子数组处理后的结果
+            $seen = []; // 用于记录已经见过的组合
+
+            // 遍历子数组的每个项目
+            foreach ($subArray as $item) {
+                // 解析 dep 字段
+                $dep = json_decode($item['dep'], true);
+                // 创建一个用于识别的唯一键
+                $uniqueKey = $item['number'] . '|' . implode(',', $dep);
+
+                // 如果这个组合还没有被处理过
+                if (!isset($seen[$uniqueKey])) {
+                    // 添加到当前处理后的子数组
+                    $processedSubArray[] = $item;
+                    // 标记这个组合为已处理
+                    $seen[$uniqueKey] = true;
+                }
+            }
+
+            // 将处理后的子数组添加到处理后的数组
+            $newList[] = $processedSubArray;
+        }
+
+        return $newList;
+    }
+}

+ 206 - 0
application/admin/controller/EnergyWater.php

@@ -0,0 +1,206 @@
+<?php
+namespace app\admin\controller;
+
+use think\Db;
+use think\helper\Str;
+
+class EnergyWater extends Auth
+{
+
+    public function index(){
+        $tree = model('EnergyWater')->showAllTree();
+        $this->traverseArray($tree);
+//        halt($tree);
+        $this->assign('tree',$tree);
+        return $this->fetch();
+    }
+
+    /**
+     * 新增/编辑
+     */
+    public function add($pid=0,$t=0,$id=0){
+        if(request()->isPost()){
+            $res = model('EnergyWater')->updates();
+            if($res){
+                $this->success('操作成功',url('index'));
+            }else{
+                $this->error(model('EnergyWater')->getError());
+            }
+        }else{
+            $meta_title = '新增';
+            if($id){
+                $info = db('energy_water')->where('id',$id)->find();
+                $info['dep'] = explode(',',$info['dep']);
+                $this->assign('info',$info);
+                $info['s'] = $info['share'] ? (string)$info['share'] : '';
+                $meta_title = '编辑';
+            }
+            $map[] = ['del','=',0];
+            $map[]= ['enable','=',1];
+            $map[]= ['org_id','=',$this->orgId];
+            $alists = db('energy_area')
+                ->field('id,title')
+                ->where($map)
+                ->where('pid',0)
+                ->select();
+            foreach ($alists as $k=>$v) {
+                $alists[$k]['children'] = db('energy_area')
+                    ->field('id,title')
+                    ->where('pid', $v['id'])
+                    ->where($map)
+                    ->select();
+                foreach ($alists[$k]['children'] as $kk => $vv) {
+                    $alists[$k]['children'][$kk]['children'] = db('energy_area')
+                        ->field('id,title')
+                        ->where('pid', $vv['id'])
+                        ->where($map)
+                        ->select();
+                }
+            }
+            $dlists = db('energy_dep')
+                ->field('id,name')
+                ->where($map)
+                ->select();
+            $this->assign('alist',$alists);
+            $this->assign('dlist',$dlists);
+            $this->assign('pid',$pid);
+            $this->assign('t',$t);
+            $this->assign('meta_title',$meta_title);
+            return $this->fetch();
+        }
+    }
+
+    /**
+     * 拆分电表
+     */
+    public function split($id=0)
+    {
+        if(request()->isPost()){
+            $id = input('post.id');
+            $split = input('post.split');
+            $res = Db::name('energy_water')->where('org_id',$this->orgId)->where('id',$id)->setField(['split'=>$split]);
+            if($res){
+                $this->success('操作成功',url('index'));
+            }else{
+                $this->error('操作失败');
+            }
+        }else{
+            $info = db('energy_water')->where('org_id',$this->orgId)->where('id',$id)->find();
+            $this->assign('info',$info);
+
+            $map[] = ['del','=',0];
+            $map[]= ['enable','=',1];
+            $map[]= ['org_id','=',$this->orgId];
+            $map[]= ['id','<>',$id];
+            $list = Db::name('energy_water')
+                ->where('parent_id','>',0)
+                ->where($map)
+                ->where('type_w',$info['type_w'])
+                ->select();
+            foreach ($list as $k=>$v) {
+                $list[$k]['number'] = $v['name'].'————'.$v['number'];
+            }
+            $this->assign('list',$list);
+            $this->assign('id',$id);
+            return $this->fetch();
+        }
+    }
+
+    public function changeEnable($id=0,$enable=0){
+        if($id <= 0){
+            $this->error('参数错误');
+        }
+        $ret = Db::name('energy_water')->where('org_id',$this->orgId)->where('id',$id)->setField('enable',$enable);
+        if(!$ret){
+            $this->error('操作失败');
+        }
+        $this->success('操作成功');
+    }
+
+    /**
+     * 删除记录
+     * @param int $id
+     */
+    public function del($id=0){
+        if(!$id){
+            $this->error('参数错误');
+        }
+        // 检查是否有子级
+        $ret = Db::name('energy_water')->where('org_id',$this->orgId)->where('parent_id',$id)->where('del',0)->find();
+        if($ret){
+            $this->error('有子水表不能删除');
+        }
+        $res = Db::name('energy_water')->where('org_id',$this->orgId)->where('id',$id)->setField('del',1);
+        if($res){
+            $this->success('删除成功');
+        }else{
+            $this->error('删除失败');
+        }
+    }
+
+    /**
+     * 循环tree给字段重新赋值
+     */
+    public function traverseArray(&$array) {
+        foreach ($array as &$item) {
+            // 修改type_e的值
+            if (isset($item['type_w'])) {
+                $item['type_w'] = $item['type_w'] == 0 ? '冷水' : ($item['type_w'] == 1 ? '热水进水' :'热水回水');
+            }
+            // 如果存在children,递归调用
+            if (isset($item['children']) && is_array($item['children'])) {
+                $this->traverseArray($item['children']);
+            }
+        }
+    }
+    /**
+     * 换表
+     * @param string $sn
+     */
+    public function change($sn=''){
+        if(!$sn){
+            $this->error('参数错误');
+        }
+        $record = Db::name('energy_water_record')
+            ->where('sn',$sn)
+            ->where('del',0)
+            ->order('read_yyyymmdd desc')
+            ->field('degree,read_time')
+            ->findOrEmpty();
+        if (empty($record)){
+            $this->error('该表没有抄表记录');
+        }
+        $res = Db::name('energy_change_log')
+            ->insert([
+                'org_id'=>$this->orgId,
+                'sn'=>$sn,
+                'degree'=>$record['degree'],
+                'read_time'=>$record['read_time'],
+                'create_time'=>getTime(),
+            ]);
+        if($res){
+            $this->success('换表成功');
+        }else{
+            $this->error('换表失败');
+        }
+    }
+    public function getDep() {
+        $data = $this->request->param();
+        $value = $data['param'];
+        if ($value){
+            $map[] = ['address','like','%'.$value.'%'];
+        }else{
+            $map[] = ['address','=',0];
+        }
+        $map[] = ['del','=',0];
+        $map[]= ['enable','=',1];
+        $map[]= ['org_id','=',$this->orgId];
+        $lists = db('energy_dep')
+            ->field('id,name')
+            ->where($map)
+            ->select();
+        return json(['data'=>$lists]);
+
+    }
+
+}

+ 232 - 0
application/admin/controller/EnergyWaterRecord.php

@@ -0,0 +1,232 @@
+<?php
+namespace app\admin\controller;
+
+use app\common\model\User;
+use think\App;
+use think\Db;
+
+class EnergyWaterRecord extends Auth
+{
+    public function __construct(App $app = null) {
+        parent::__construct($app);
+        $this->model = new \app\common\model\EnergyWaterRecord();
+    }
+    public function index(){
+        if(request()->isAjax()){
+            //分页参数
+            $length = input('rows',10,'intval');   //每页条数
+            $page = input('page',1,'intval');      //第几页
+            $start = ($page - 1) * $length;     //分页开始位置
+            //排序
+            $sortRow = input('sidx','sort','trim');      //排序列
+            $sort = input('sord','asc','trim');        //排序方式
+            $order = $sortRow.' '.$sort.' ,id desc';
+
+            $sn = input('sn','','trim');
+            if($sn){
+                $map[] = ['sn','=',$sn];
+            }
+            $map[] = ['org_id','=',$this->orgId];
+            $map[] = ['del','=',0];
+            $map= empty($map) ? true: $map;
+            //数据查询
+            $lists = Db::name('energy_water_record')
+                ->where($map)->limit($start,$length)
+                ->order($order)->select();
+            foreach($lists as $k=>$v){
+                $lists[$k]['user_id'] = Db::name('user')->where('id',$v['user_id'])->value('real_name');
+            }
+
+            //数据返回
+            $totalCount = db('energy_water_record')->where($map)->count();
+            $totalPage = ceil($totalCount/$length);
+            $result['page'] = $page;
+            $result['total'] = $totalPage;
+            $result['records'] = $totalCount;
+            $result['rows'] = $lists;
+            return json($result);
+        }else{
+            $this->assign('meta_title','水表抄表记录');
+            return $this->fetch();
+        }
+    }
+
+    /**
+     * 新增/编辑
+     */
+    public function add($id=0){
+        $model = $this->model;
+        $userId = is_login();
+        if(request()->isPost()){
+            $res = $model->updates($userId);
+            if($res){
+                $this->success('操作成功',url('index'));
+            }else{
+                $this->error($model->getError());
+            }
+        }else{
+            if($id){
+                $info = db('energy_water_record')->where('id',$id)->find();
+                $this->assign('info',$info);
+            }
+            return $this->fetch();
+        }
+    }
+
+    /**
+     * 删除记录
+     * @param int $id
+     */
+    public function del($id=0){
+        if(!$id){
+            $this->error('参数错误');
+        }
+        $res = Db::name('energy_water_record')->where('id',$id)->update(['del'=>1]);
+        if($res){
+            $this->success('删除成功');
+        }else{
+            $this->error('删除失败');
+        }
+    }
+
+    public function import(){
+        return $this->fetch();
+    }
+    /**
+     * 下载点模板
+     */
+    public function downloadtem(){
+        set_time_limit(0);
+        ini_set("memory_limit","512M");
+        include_once env('root_path').'/extend/phpexcel/Classes/PHPExcel.php';
+        $types = model('Address')->getTypes();
+        ksort($types);
+        $fileName = '水表抄表记录模板.xlsx';
+        $excel = new \PHPExcel();
+        $sheet = $excel->setActiveSheetIndex(0);
+        $arr = array('A','B','C','D','E','F');
+        foreach($arr as $k=>$v){
+            $excel->getActiveSheet()->getStyle($v)->getAlignment()->setWrapText(true);//换行
+            $excel->getActiveSheet()->getStyle($v.'1')->getFont()->setBold(true);
+            $excel->getActiveSheet()->getColumnDimension($v)->setWidth(18);
+
+        }
+        $sheet->setCellValueByColumnAndRow(0,1,'日期');
+        $sheet->setCellValueByColumnAndRow(1,1,'表号');
+        $sheet->setCellValueByColumnAndRow(2,1,'抄表读数');
+        $sheet->setCellValueByColumnAndRow(3,1,'最低温度 (℃))');
+        $sheet->setCellValueByColumnAndRow(4,1,'最高温度 (℃))');
+        $sheet->setCellValueByColumnAndRow(5,1,'床位数量');
+
+        $excel->getActiveSheet()->setCellValue('A2', '2024/09/23');
+        $excel->getActiveSheet()->setCellValue('B2', 'W1101');
+        $excel->getActiveSheet()->setCellValue('C2', '100');
+        $excel->getActiveSheet()->setCellValue('D2', '10');
+        $excel->getActiveSheet()->setCellValue('E2', '22');
+        $excel->getActiveSheet()->setCellValue('F2', '120');
+
+        ob_end_clean();//清除缓冲区,避免乱码
+        header('Content-Type: application/vnd.ms-excel');
+        header('Content-Disposition: attachment;filename="'.$fileName.'"');
+        header('Cache-Control: max-age=0');
+
+        $objWriter = \PHPExcel_IOFactory::createWriter($excel, 'Excel2007');
+        $objWriter->save('php://output'); //文件通过浏览器下载
+
+    }
+
+
+    /**
+     * 导入
+     */
+    public function importexcel(){
+        set_time_limit(0);
+        ini_set("memory_limit", -1);
+        ob_flush();//清空缓存
+        flush();//刷新缓存
+        include_once env('root_path').'/extend/phpexcel/Classes/PHPExcel.php';
+        $orgId = $this->orgId;
+        if(request()->file()) {
+            $file = request()->file('file');
+            //获取文件后缀
+            $e = explode('.',$_FILES['file']['name']);
+            $ext = $e[count($e)-1];
+            if($ext == 'xls'){
+                \PHPExcel_IOFactory::createReader( 'Excel5');
+            }else{
+                \PHPExcel_IOFactory::createReader('Excel2007');
+            }
+            $newArr=['xls','xlsx'];
+            if(!in_array($ext,$newArr)){
+                exit('文件格式不正确');
+            }
+            // 移动到框架应用根目录/uploads/ 目录下
+            $info = $file->validate([ 'size'=>config('app.max_upload_file_size') ])
+                ->move(env('root_path') . 'public' . DIRECTORY_SEPARATOR . 'uploads'. DIRECTORY_SEPARATOR . 'files');
+            if(!$info){
+                exit('文件上传失败');
+            }
+            $img = './uploads/files/' . $info->getSaveName();
+            $filePath = str_replace('\\', '/', $img);
+            $newPath = \PHPExcel_IOFactory::load($filePath);
+
+            $excelArray = $newPath->getsheet(0)->toArray();   //转换为数组格式
+
+            array_shift($excelArray);  //删除第一个数组(标题);
+            if(empty($excelArray)){
+                exit('文件内容为空');
+            }
+
+            foreach ($excelArray as $k => $v) {
+
+                if(!$v[0] || !$v[1] || !$v[2]){
+                    echo "<font color=\"red\" style='margin-left: 20px;font-size: 17px'>第".($k+1)."行,有数据为空,未导入</font><br />";
+                    continue;
+                }
+                $degree = $v[2];
+                $change = Db::name('energy_change_log')
+                    ->where('org_id',$this->orgId)
+                    ->where('sn',$v[1])
+                    ->order('id desc')
+                    ->value('degree');
+                if ($change){
+                    $degree = $change + $degree;
+                }
+                $Data = [
+                    'org_id'=>$this->orgId,
+                    'read_time'=>date('Y-m-d',strtotime($v[0])),
+                    'sn'=>$v[1],
+                    'degree'=>$degree,
+                    'min_temperature'=>$v[3],
+                    'max_temperature'=>$v[4],
+                    'user_id'=>is_login(),
+                    'read_yyyy'=>date('Y',strtotime($v[0])),
+                    'read_yyyymm'=>date('Ym',strtotime($v[0])),
+                    'read_yyyymmdd'=>date('Ymd',strtotime($v[0])),
+                    'create_time'=>getTime(),
+                ];
+                $ret=Db::name('energy_water_record')->insert($Data);
+
+                if(!$ret){
+                    echo "<font color=\"red\" style='margin-left: 20px;font-size: 17px'>第".($k+1)."行,导入失败</font><br />";
+                }else{
+                    echo "<font color=\"green\" style='margin-left:20px;font-size: 17px'>第".($k+1)."行,导入成功</font><br />";
+                }
+
+            }
+        }else{
+            exit('请上传文件');
+        }
+
+    }
+
+    public function multiDel() {
+        $ids = input('ids', [], 'trim');
+        if (empty($ids)) {
+            $this->error('未选择记录');
+        }
+        $res = Db::name('energy_water_record')->whereIn('id', $ids)->update(['del'=>1]);
+        if (!$res) $this->error('批量删除失败');
+        $this->success('批量删除传成功');
+    }
+}

+ 86 - 0
application/admin/view/energy_area/add.html

@@ -0,0 +1,86 @@
+{extend name="common/common2" /}
+{block name="main"}
+<div class="row">
+    <div class="col-sm-12">
+        <div class="ibox float-e-margins">
+            <!--<div class="ibox-title">-->
+            <!--<h5>{$meta_title}</h5>-->
+            <!--<div class="ibox-tools">-->
+            <!--<a class="toback" href="{:url('index',['pid'=>$pid])}">-->
+            <!--返回上一页-->
+            <!--</a>-->
+            <!--</div>-->
+            <!--</div>-->
+            <div class="ibox-content">
+                <form method="post" action="{:url('add')}" class="form-horizontal">
+                    <input type="hidden" name="id" value="{$info['id']|default='0'}">
+                    <input type="hidden" name="pid" value="{$info['pid']|default='0'}">
+                    <div class="form-group">
+                        <label class="col-sm-2 control-label">名称</label>
+                        <div class="col-sm-4">
+                            <input type="text" class="form-control" name="title" value="{$info.title|default=''}">
+                        </div>
+                    </div>
+
+                    <div class="form-group">
+                        <label class="col-sm-2 control-label">面积</label>
+                        <div class="col-sm-4">
+                            <input type="number" class="form-control" name="area" value="{$info.area|default=''}">
+                        </div>
+                    </div>
+
+                    <div class="form-group">
+                        <label class="col-sm-2 control-label">排序</label>
+                        <div class="col-sm-4">
+                            <input type="number" class="form-control" name="sort" value="{$info.sort|default='0'}">
+                        </div>
+                    </div>
+
+<!--                    <div class="form-group">-->
+<!--                        <label class="col-sm-2 control-label">上级区域</label>-->
+<!--                        <div class="col-sm-4">-->
+<!--                            <select class="form-control m-b" name="pid">-->
+<!--                                <option value="0">顶级菜单</option>-->
+<!--                                {volist name="list" id="vo"}-->
+<!--                                <option value="{$vo.id}">{$vo.title}</option>-->
+<!--                                {/volist}-->
+<!--                            </select>-->
+<!--                        </div>-->
+<!--                    </div>-->
+
+                    <div class="form-group">
+                        <label class="col-sm-2 control-label">状态</label>
+                        <div class="col-sm-4">
+                            <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="hr-line-dashed"></div>
+                    <div class="form-group">
+                        <div class="col-sm-4 col-sm-offset-2">
+                            <button class="btn btn-primary ajax-post"  data-layer_c="1" target-form="form-horizontal" type="submit">确 定</button>
+                            <!--<a href="{:url('index',['pid'=>$pid])}" class="btn btn-default">取 消</a>-->
+                            <button class="btn cancel-btn btn-default" type="button">取 消</button>
+
+                        </div>
+                    </div>
+                </form>
+            </div>
+        </div>
+    </div>
+</div>
+{/block}
+{block name="script"}
+<script>
+    $(document).ready(function(){
+        formSetValue("pid", {$pid|default=0});
+        formSetValue("is_btn", {$info.is_btn|default=0});
+        formSetValue("enable", {$info.enable|default=1});
+    });
+
+</script>
+{/block}

+ 83 - 0
application/admin/view/energy_area/index.html

@@ -0,0 +1,83 @@
+{extend name="common/common2" /}
+{block name="main"}
+
+<div class="ibox">
+    <div class="ibox-content">
+
+        <a url="{:url('add',array('pid'=>$pid))}"  href="javascript:;" data-title="新增" onclick="layer_open(this,1)" class="btn btn-sm btn-success">新增</a>
+        {if condition="$pid"}<a href="{:url('index',array('pid'=>$ppid))}" class="btn btn-sm btn-primary">返回上一页</a>{/if}
+    </div>
+    <div class="ibox-content">
+        <div class="jqGrid_wrapper">
+            <table id="table" style="border-collapse: collapse"></table>
+            <div id="pager"></div>
+        </div>
+    </div>
+</div>
+{/block}
+{block name="script"}
+<script>
+    $(function () {
+
+        $(window).bind("resize",function(){
+            var width=$(".jqGrid_wrapper").width();
+            $("#table").setGridWidth(width);
+        });
+
+        $.jgrid.defaults.styleUI="Bootstrap";
+        $("#table").jqGrid({
+            url:"{:url('index',array('pid'=>$pid))}",
+            datatype: "json",
+            colModel:[
+                {label:'ID',name:'id',index:'id', width:30,sortable: false},
+                {label:'名称',name:'title',index:'title',width:100,editable: false,sortable: false,formatter: function (a, b, c) {
+                        return '<a href="{:url("index",[],"")}/pid/'+c.id+'">'+c.title+'</a>';
+                    }},
+                {label:'面积',name:'area',index:'area',width:40,editable: false,sortable: false,formatter: function (a, b, c) {
+                        return a+'㎡';
+                    }},
+                {label:'上级区域',name:'ptitle',index:'ptitle',width:100,editable: false,sortable: false},
+                {label:'排序',name:'sort',index:'sort',width:60,sortable: true,formatter: function (a, b, c) {
+                        return '<input type="number" onchange="updateSort(this)" data-url="{:url('changeSort')}" class="form-control input-sm" data-id="'+c.id+'" data-old="'+a+'" value="'+a+'" />';
+                    }},
+                {label:'状态',name:'enable',index:'enable',width:20,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-success" title="正常">正常</span></a>';
+                        }
+                    }},
+                {label:'操作',width:60,sortable: false,formatter: function (a, b, c) {
+                        var editurl = "{:url('add',[],'')}/id/"+c.id+"/pid/"+c.pid;
+                        var delurl = "{:url('del',[],'')}/id/"+c.id;
+                        //var btn = '<a href="'+editurl+'"><span class="label label-primary" title="编辑">编辑</span></a>&nbsp;';
+                        var  btn= '<a url="'+editurl+'" href="javascript:;" data-title="编辑" onclick="layer_open(this,1)"><span class="label label-other" title="编辑">编辑</span></a>&nbsp;';
+
+                        btn += '<a href="'+delurl+'" class="confirm ajax-get" data-confirm="确定要删除此记录吗?" data-table="1"><span class="label label-danger" title="删除">删除</span></a>';
+                        return btn;
+                    }},
+            ],
+            rowNum:10,
+            rowList:[10,20,30,50,100],
+            pager: '#pager',
+            sortname: 'sort',
+            viewrecords: true,
+            autowidth:true,
+            mtype: 'post',
+            height: 'auto',
+            emptyrecords: "暂无数据",
+            sortorder: "asc",
+            caption:"{$meta_title}",
+            loadComplete: function (xhr) {
+                if(xhr.code==0){
+                    layer.msg(xhr.msg);
+                    return false;
+                }
+            },
+        });
+    });
+
+</script>
+{/block}

+ 135 - 0
application/admin/view/energy_dep/add.html

@@ -0,0 +1,135 @@
+{extend name="common/common2" /}
+{block name="main"}
+<div class="row" id="formApp">
+    <div class="col-sm-12">
+        <div class="ibox float-e-margins">
+            <div class="ibox-content">
+                <form method="post" action="{:url('add')}" class="form-horizontal">
+                    <input type="hidden" name="id" value="{$info['id']|default='0'}">
+                    <div class="form-group">
+                        <label class="col-sm-2 control-label">名称<span class="text-danger">*</span></label>
+                        <div class="col-sm-4">
+                            <input type="text" class="form-control" name="name" value="{$info.name|default=''}">
+                        </div>
+                    </div>
+
+                    <div class="form-group">
+                        <label class="col-sm-2 control-label">面积<span class="text-danger">*</span></label>
+                        <div class="col-sm-4">
+                            <input type="number" class="form-control" name="area" value="{$info.area|default=''}">
+                        </div>
+                    </div>
+
+                    <div class="form-group">
+                        <label class="col-sm-2 control-label">科室地点<span class="text-danger">*</span></label>
+                        <input type="hidden" name="address" :value="JSON.stringify(selectedValue)">
+                        <div class="col-sm-4">
+                            <el-cascader
+                                    v-model="selectedValue"
+                                    :options="options"
+                                    :props="props"
+                                    @change="handleChange"
+                                    style="width:100%"
+                                    filterable
+                                    clearable>
+                            </el-cascader>
+                        </div>
+                    </div>
+
+                    <div v-if="selectedValue.length>1" class="form-group">
+                        <label class="col-sm-2 control-label">面积分摊</label>
+                        <div class="col-sm-4">
+                            <el-input  placeholder="依次输入百分比,用逗号隔开,例如40%,60%" v-model="input" class="input-with-select" name="percent">
+                            </el-input>
+                        </div>
+                    </div>
+
+<!--                    <div v-if="selectedValue.length>1" class="form-group" >-->
+<!--                        <label class="col-sm-2 control-label">面积分摊</label>-->
+<!--                        <div style="display: flex;flex-direction: column;margin-left: 165px">-->
+<!--                            <div class=" col-sm-4 " v-for="item in resultArr" :key="item.label" >-->
+<!--                                <el-input placeholder="请输入面积" v-model="item.rate" class="">-->
+<!--                                    <template slot="prepend">{{ item.label }}</template>-->
+<!--                                    <input hidden type="text" name="splitKey[]" :value="item.rate">-->
+<!--                                    <input hidden type="text" name="splitValue[]" :value="item.value">-->
+<!--                                </el-input>-->
+<!--                            </div>-->
+<!--                        </div>-->
+
+<!--                    </div>-->
+
+                    <div class="form-group">
+                        <label class="col-sm-2 control-label">状态</label>
+                        <div class="col-sm-4">
+                            <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="hr-line-dashed"></div>
+                    <div class="form-group">
+                        <div class="col-sm-4 col-sm-offset-2">
+                            <button class="btn btn-primary ajax-post"  data-layer_c="1" target-form="form-horizontal" type="submit">确 定</button>
+                            <button class="btn cancel-btn btn-default" type="button">取 消</button>
+
+                        </div>
+                    </div>
+                </form>
+            </div>
+        </div>
+    </div>
+</div>
+{/block}
+{block name="script"}
+<script>
+    $('#patient').hide();
+    new Vue({
+        el: '#formApp',
+        data: function() {
+            return {
+                props: { multiple: true ,value: 'id', label: 'title' },
+                options:{:json_encode($list)},
+                selectedValue:{$info.address|default=0},
+                input: '{$info.percent|default=""}',
+                resultArr: [],
+        }
+        },
+        watch: {
+
+        },
+        methods: {
+            handleChange(value) {
+                const read =(index, arr)=>(arr[index]);
+                let opts = this.options;
+                this.resultArr = value.map((ele) => ({ label: ele.map((a,b)=> {
+                        opts=read(a, opts);
+                        return opts.title
+                    }).join('/'), rate: 0 }));
+            }
+        },
+        // methods: {
+        //     convert(arr){
+        //         let opts = this.options
+        //         let res = ''
+        //         arr.forEach((el, index) => {
+        //             const find = opts.find(val=>val.id === el)
+        //             res = find.title + '/'
+        //             opts = find.children
+        //         });
+        //         return res.slice(0, -1)
+        //     },
+        //     handleChange(value) {
+        //         this.resultArr = value.map((ele) => ({ label: this.convert(ele), rate: '' ,value:ele}));
+        //     }
+        // },
+
+    })
+    $(document).ready(function(){
+        formSetValue("enable", {$info.enable|default=1});
+    });
+
+</script>
+{/block}

+ 84 - 0
application/admin/view/energy_dep/index.html

@@ -0,0 +1,84 @@
+{extend name="common/common2" /}
+{block name="main"}
+
+<div class="ibox">
+    <div class="ibox-content">
+
+        <a url="{:url('add')}"  href="javascript:;" data-title="新增" onclick="layer_open(this,1)" class="btn btn-sm btn-success">新增</a>
+    </div>
+    <div class="ibox-content">
+        <div class="jqGrid_wrapper">
+            <table id="table" style="border-collapse: collapse"></table>
+            <div id="pager"></div>
+        </div>
+    </div>
+</div>
+{/block}
+{block name="script"}
+<script>
+    $(function () {
+
+        $(window).bind("resize",function(){
+            var width=$(".jqGrid_wrapper").width();
+            $("#table").setGridWidth(width);
+        });
+
+        $.jgrid.defaults.styleUI="Bootstrap";
+        $("#table").jqGrid({
+            url:"{:url('index')}",
+            datatype: "json",
+            colModel:[
+                {label:'ID',name:'id',index:'id', width:20,sortable: false},
+                {label:'名称',name:'name',index:'name',width:60,editable: false,sortable: false},
+                {label:'面积',name:'area',index:'area',width:40,editable: false,sortable: false,formatter: function (a, b, c) {
+                        return a+'㎡';
+                    }},
+                {label:'科室地点',name:'address',index:'address',width:200,editable: false,sortable: false,formatter:function (a,b,c){
+                        let parts = a.split(',');
+                        var span ='';
+                        for (let i = 0; i < parts.length; i++) {
+                            let address = parts[i];
+                            span+='<span>'+address+'</span><br>';
+                        }
+                        return span;
+                    }},
+                {label:'状态',name:'enable',index:'enable',width:30,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-success" title="正常">正常</span></a>';
+                        }
+                    }},
+                {label:'操作',width:60,sortable: false,formatter: function (a, b, c) {
+                        var editurl = "{:url('add',[],'')}/id/"+c.id+"/pid/"+c.pid;
+                        var delurl = "{:url('del',[],'')}/id/"+c.id;
+                        var  btn= '<a url="'+editurl+'" href="javascript:;" data-title="编辑" onclick="layer_open(this,1)"><span class="label label-other" title="编辑">编辑</span></a>&nbsp;';
+
+                        btn += '<a href="'+delurl+'" class="confirm ajax-get" data-confirm="确定要删除此记录吗?" data-table="1"><span class="label label-danger" title="删除">删除</span></a>';
+                        return btn;
+                    }},
+            ],
+            rowNum:10,
+            rowList:[10,20,30,50,100],
+            pager: '#pager',
+            sortname: 'sort',
+            viewrecords: true,
+            autowidth:true,
+            mtype: 'post',
+            height: 'auto',
+            emptyrecords: "暂无数据",
+            sortorder: "asc",
+            caption:"科室列表",
+            loadComplete: function (xhr) {
+                if(xhr.code==0){
+                    layer.msg(xhr.msg);
+                    return false;
+                }
+            },
+        });
+    });
+
+</script>
+{/block}

+ 179 - 0
application/admin/view/energy_device_electricity/add.html

@@ -0,0 +1,179 @@
+{extend name="common/common2" /}
+{block name="main"}
+<style>
+    /*.el-select .el-input {*/
+    /*    width: 130px;*/
+    /*}*/
+    .input-with-select .el-input-group__prepend {
+        background-color: #fff;
+    }
+
+</style>
+<div class="row" id="formApp">
+    <div class="col-sm-12">
+        <div class="ibox float-e-margins">
+            <div class="ibox-content">
+                <form method="post" action="{:url('add')}" class="form-horizontal">
+                    <input type="hidden" name="parent_id" value="{$pid}">
+                    <input type="hidden" name="id" value="{$info['id']|default='0'}">
+                    <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="name" value="{$info.name|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">
+                            <input type="text" class="form-control" name="number" value="{$info.number|default=''}">
+                        </div>
+                    </div>
+
+
+                    <div class="form-group">
+                        <label class="col-sm-2 control-label">用电分类<span class="text-danger">*</span></label>
+                        <input type="hidden" id="ele-type_e" name="type_e" :value="value2">
+                        <div class="col-sm-6">
+                            <el-select
+                                    v-model="value2"
+                                    filterable
+                                    size="small"
+                                    style="width:100%"
+                                    placeholder="请选择用电分类"
+                            >
+                                <el-option
+                                        v-for="item in options3"
+                                        :key="item.id"
+                                        :label="item.name"
+                                        :value="item.id.toString()">
+                                </el-option>
+                            </el-select>
+                        </div>
+                    </div>
+
+                    <div v-if="value.length>1" class="form-group">
+                        <label class="col-sm-2 control-label">用电分摊</label>
+                        <div class="col-sm-6">
+                            <el-input  placeholder="请输入分摊比例,例如2:3:5 (如按面积分摊不用填此项)" v-model="input" class="input-with-select" name="percent">
+                                <el-select
+                                        v-model="select"
+                                        slot="prepend"
+                                        placeholder="分摊方式"
+                                        style="width: 130px" >
+                                    <el-option label="按面积" value=0></el-option>
+                                    <el-option label="按比例" value=1></el-option>
+                                </el-select>
+                            </el-input>
+                            <input type="hidden" id="ele-share" name="share" :value="select">
+                        </div>
+                    </div>
+
+                    <div class="form-group">
+                        <label class="col-sm-2 control-label">备注</label>
+                        <div class="col-sm-6">
+                            <textarea name="remark" class="form-control" rows="3">{$info.remark|default=''}</textarea>
+                        </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="hr-line-dashed"></div>
+                    <div class="form-group">
+                        <div class="col-sm-6 col-sm-offset-2">
+                            <button class="btn btn-primary ajax-post" data-layer="1" target-form="form-horizontal" type="submit">确 定</button>
+                        </div>
+                    </div>
+                </form>
+            </div>
+        </div>
+    </div>
+</div>
+{/block}
+{block name="script"}
+<script>
+    $('#patient').hide();
+    new Vue({
+        el: '#formApp',
+        data: function() {
+            return {
+                props: { value: 'id', label: 'title' },
+                options:{:json_encode($alist)},
+                options2: {:json_encode($dlist)},
+                value: {$info.dep|default=0},
+                options3: {:json_encode($tlist)},
+                value2: '{$info.type_e|default=""}',
+                selectedValue:{$info.address|default=0},
+                select: '{$info.share|default=""}',
+                input: '{$info.percent|default=""}',
+        }
+        },
+        watch: {
+            // value: function (newVal, oldVal) {
+            //     $('#ele-dep').val(newVal.join(','));
+            // }
+        },
+        methods: {
+            handleChange(value) {
+                // 当级联选择器的值改变时,发送Ajax请求
+                $.ajax({
+                    url: '/admin/energy_electricity/getDep', // 后端接口地址
+                    type: 'POST',
+                    // contentType: 'application/json',
+                    data: {param:JSON.stringify(value)},
+                    success: (response) => {
+                        // 假设后端响应的数据是一个数组,并将其赋值给list
+                        this.options2 = response.data;
+                    },
+                    error: (xhr, status, error) => {
+                        console.error('请求失败:', error);
+                        // 处理错误情况
+                    }
+                });
+                        this.value='';
+            },
+        },
+        mounted(){
+            $.ajax({
+                url: '/admin/energy_electricity/getDep', // 后端接口地址
+                type: 'POST',
+                // contentType: 'application/json',
+                data: {param:JSON.stringify(this.selectedValue)},
+                success: (response) => {
+                    // 假设后端响应的数据是一个数组,并将其赋值给list
+                    this.options2 = response.data;
+                    if (this.selectedValue == 0){
+                        this.options2 = [];
+                    }
+                },
+                error: (xhr, status, error) => {
+                    console.error('请求失败:', error);
+                    // 处理错误情况
+                }
+            });
+        }
+        // created(){
+        //     const vals = this.value;
+        //     this.value = [];
+        //     vals.forEach((item) => {
+        //         this.value.push(item.toString());
+        //     })
+        // }
+
+    })
+    $(document).ready(function(){
+        formSetValue("enable", {$info.enable|default=1});
+    });
+    window.addEventListener('touchstart',function () {
+    },{ passive: false });
+</script>
+{/block}

+ 216 - 0
application/admin/view/energy_device_electricity/add2.html

@@ -0,0 +1,216 @@
+{extend name="common/common2" /}
+{block name="main"}
+<style>
+    /*.el-select .el-input {*/
+    /*    width: 130px;*/
+    /*}*/
+    .input-with-select .el-input-group__prepend {
+        background-color: #fff;
+    }
+
+</style>
+<div class="row" id="formApp">
+    <div class="col-sm-12">
+        <div class="ibox float-e-margins">
+            <div class="ibox-content">
+                <form method="post" action="{:url('add')}" class="form-horizontal">
+                    <input type="hidden" name="parent_id" value="{$pid}">
+                    <input type="hidden" name="id" value="{$info['id']|default='0'}">
+                    <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="name" value="{$info.name|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">
+                            <input type="text" class="form-control" name="number" value="{$info.number|default=''}">
+                        </div>
+                    </div>
+
+                    <div class="form-group">
+                        <label class="col-sm-2 control-label">地点<span class="text-danger">*</span></label>
+                        <input type="hidden" name="address" :value="JSON.stringify(selectedValue)">
+                        <div class="col-sm-6">
+                            <el-cascader
+                                    v-model="selectedValue"
+                                    :options="options"
+                                    :props="props"
+                                    style="width:100%"
+                                    @change="handleChange"
+                                    filterable
+                                    clearable>
+                            </el-cascader>
+                        </div>
+                    </div>
+
+                    <div class="form-group">
+                        <label class="col-sm-2 control-label">科室<span class="text-danger">*</span></label>
+                        <input type="hidden" id="ele-dep" name="dep" :value="JSON.stringify(value)">
+                        <div class="col-sm-6">
+                            <el-select
+                                    v-model="value"
+                                    multiple
+                                    filterable
+                                    size="small"
+                                    style="width:100%"
+                                    placeholder="请选择"
+                            >
+                                <el-option
+                                        v-for="item in options2"
+                                        :key="item.id"
+                                        :label="item.name"
+                                        :value="item.id">
+                                </el-option>
+                            </el-select>
+                        </div>
+                    </div>
+
+                    <div class="form-group">
+                        <label class="col-sm-2 control-label">用电分类<span class="text-danger">*</span></label>
+                        <input type="hidden" id="ele-type_e" name="type_e" :value="value2">
+                        <div class="col-sm-6">
+                            <el-select
+                                    v-model="value2"
+                                    filterable
+                                    size="small"
+                                    style="width:100%"
+                                    placeholder="请选择"
+                            >
+                                <el-option
+                                        v-for="item in options3"
+                                        :key="item.id"
+                                        :label="item.name"
+                                        :value="item.id">
+                                </el-option>
+                            </el-select>
+                        </div>
+                    </div>
+
+                    <div v-if="value.length>1" class="form-group">
+                        <label class="col-sm-2 control-label">用电分摊</label>
+                        <div class="col-sm-6">
+                            <el-input  placeholder="请输入分摊比例,例如2:3:5 (如按面积分摊不用填此项)" v-model="input" class="input-with-select" name="percent">
+                                <el-select
+                                        v-model="select"
+                                        slot="prepend"
+                                        placeholder="分摊方式"
+                                        style="width: 130px" >
+                                    <el-option label="按面积" value=0></el-option>
+                                    <el-option label="按比例" value=1></el-option>
+                                </el-select>
+                            </el-input>
+                            <input type="hidden" id="ele-share" name="share" :value="select">
+                        </div>
+                    </div>
+
+                    <div class="form-group">
+                        <label class="col-sm-2 control-label">备注</label>
+                        <div class="col-sm-6">
+                            <textarea name="remark" class="form-control" rows="3">{$info.remark|default=''}</textarea>
+                        </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="hr-line-dashed"></div>
+                    <div class="form-group">
+                        <div class="col-sm-6 col-sm-offset-2">
+                            <button class="btn btn-primary ajax-post" data-layer="1" target-form="form-horizontal" type="submit">确 定</button>
+                        </div>
+                    </div>
+                </form>
+            </div>
+        </div>
+    </div>
+</div>
+{/block}
+{block name="script"}
+<script>
+    $('#patient').hide();
+    new Vue({
+        el: '#formApp',
+        data: function() {
+            return {
+                props: { value: 'id', label: 'title' },
+                options:{:json_encode($alist)},
+                options2: {:json_encode($dlist)},
+                value: {$info.dep|default=0},
+                options3: {:json_encode($tlist)},
+                value2: {$info.type_e|default=1},
+                selectedValue:{$info.address|default=0},
+                select: '{$info.share|default=""}',
+                input: '{$info.percent|default=""}',
+        }
+        },
+        watch: {
+            // value: function (newVal, oldVal) {
+            //     $('#ele-dep').val(newVal.join(','));
+            // }
+        },
+        methods: {
+            handleChange(value) {
+                // 当级联选择器的值改变时,发送Ajax请求
+                $.ajax({
+                    url: '/admin/energy_electricity/getDep', // 后端接口地址
+                    type: 'POST',
+                    // contentType: 'application/json',
+                    data: {param:JSON.stringify(value)},
+                    success: (response) => {
+                        // 假设后端响应的数据是一个数组,并将其赋值给list
+                        this.options2 = response.data;
+                    },
+                    error: (xhr, status, error) => {
+                        console.error('请求失败:', error);
+                        // 处理错误情况
+                    }
+                });
+                        this.value='';
+            },
+        },
+        mounted(){
+            $.ajax({
+                url: '/admin/energy_electricity/getDep', // 后端接口地址
+                type: 'POST',
+                // contentType: 'application/json',
+                data: {param:JSON.stringify(this.selectedValue)},
+                success: (response) => {
+                    // 假设后端响应的数据是一个数组,并将其赋值给list
+                    this.options2 = response.data;
+                    if (this.selectedValue == 0){
+                        this.options2 = [];
+                    }
+                },
+                error: (xhr, status, error) => {
+                    console.error('请求失败:', error);
+                    // 处理错误情况
+                }
+            });
+        }
+        // created(){
+        //     const vals = this.value;
+        //     this.value = [];
+        //     vals.forEach((item) => {
+        //         this.value.push(item.toString());
+        //     })
+        // }
+
+    })
+    $(document).ready(function(){
+        formSetValue("enable", {$info.enable|default=1});
+    });
+    window.addEventListener('touchstart',function () {
+    },{ passive: false });
+</script>
+{/block}

+ 37 - 0
application/admin/view/energy_device_electricity/index.html

@@ -0,0 +1,37 @@
+{extend name="common/common2" /}
+{block name="main"}
+
+<div class="ibox">
+    <div class="ibox-title">
+        <h5>设备电表管理</h5>
+        <div  style="float: right;margin-right: 200px">
+            <a url="{:url('add',['pid'=>0])}" href="javascript:;" data-title="添加电表" onclick="layer_open(this,2)"><span class="label label-info" title="添加电表">添加电表</span></a>
+        </div>
+    </div>
+    <div class="ibox-content">
+        <table class="table table-striped">
+            <thead>
+            <tr>
+                <th>编号</th>
+                <th>表名</th>
+                <th>表号</th>
+                <th>备注</th>
+                <th>状态</th>
+                <th>用电分类</th>
+                <th>操作</th>
+            </tr>
+            </thead>
+            <tbody>
+            {if condition="$tree"}
+            {:widget_view('energy_device_electricity/tree',['data'=>$tree,'depth'=>0])}
+            {/if}
+            </tbody>
+        </table>
+    </div>
+</div>
+{/block}
+{block name="script"}
+<script>
+
+</script>
+{/block}

+ 75 - 0
application/admin/view/energy_device_electricity/split.html

@@ -0,0 +1,75 @@
+{extend name="common/common2" /}
+{block name="main"}
+<style>
+    /*.el-select .el-input {*/
+    /*    width: 130px;*/
+    /*}*/
+    .input-with-select .el-input-group__prepend {
+        background-color: #fff;
+    }
+
+</style>
+<div class="row" id="formApp">
+    <div class="col-sm-12">
+        <div class="ibox float-e-margins">
+            <div class="ibox-content">
+                <form method="post" action="{:url('split')}" class="form-horizontal">
+                    <input type="hidden" name="id" value="{$id|default='0'}">
+
+                    <div class="form-group">
+                        <label class="col-sm-2 control-label">拆分电表<span class="text-danger">*</span></label>
+                        <input type="hidden" id="ele-split" name="split" :value="value">
+                        <div class="col-sm-6">
+                            <el-select
+                                    v-model="value"
+                                    multiple
+                                    filterable
+                                    size="small"
+                                    style="width:100%"
+                                    placeholder="请选择拆分的电表"
+                            >
+                                <el-option
+                                        v-for="item in options"
+                                        :key="item.id"
+                                        :label="item.number"
+                                        :value="item.id">
+                                </el-option>
+                            </el-select>
+                        </div>
+                    </div>
+
+                    <div class="hr-line-dashed"></div>
+                    <div class="form-group">
+                        <div class="col-sm-6 col-sm-offset-2">
+                            <button class="btn btn-primary ajax-post" data-layer="1" target-form="form-horizontal" type="submit">确 定</button>
+                        </div>
+                    </div>
+                </form>
+            </div>
+        </div>
+    </div>
+</div>
+{/block}
+{block name="script"}
+<script>
+    $('#patient').hide();
+    new Vue({
+        el: '#formApp',
+        data: function() {
+            return {
+                options: {:json_encode($list)},
+            value: [{$info.split|default=''}],
+        }
+        },
+        methods: {
+
+        },
+        mounted(){
+
+        }
+
+    })
+    window.addEventListener('touchstart',function () {
+    },{ passive: false });
+</script>
+{/block}

+ 32 - 0
application/admin/view/energy_device_electricity/tree.html

@@ -0,0 +1,32 @@
+{volist name="data" id="v"}
+<tr>
+    <td style="width: 60px;">{$v.id}</td>
+    <td style="text-indent:{$depth * 2}em;">
+        {if condition="isset($v['children']) && !empty($v['children'])"}
+        <i class="glyphicon glyphicon-folder-open"></i>
+        {else /}
+        <i class="glyphicon glyphicon-list-alt"></i>
+        {/if}
+        {$v.name}
+    </td>
+    <td style="width: 110px;">{$v.number}</td>
+    <td style="width: 110px;">{$v.remark}</td>
+    <td style="width: 80px;">
+        {if condition="$v['enable'] == 0"}
+        <a href="{:url('changeEnable',['id'=>$v['id'],'enable'=>1])}" data-confirm="确定要启用该记录吗?" class="ajax-get confirm data-reload"><span class="label label-danger" title="禁用">禁用</span></a>
+        {else /}
+        <a href="{:url('changeEnable',['id'=>$v['id'],'enable'=>0])}" data-confirm="确定要禁用该记录吗?" class="ajax-get confirm data-reload"><span class="label label-warning" title="启用">启用</span></a>
+        {/if}
+    </td>
+    <td style="width: 80px;">
+        {$v.type_e}
+    </td>
+    <td style="width: 300px;">
+        <a url="{:url('add',['id'=>$v['id'],'pid'=>$v['parent_id']])}" href="javascript:;" data-title="编辑" onclick="layer_open(this,2)"><span class="label label-other" title="编辑">编辑</span></a>
+        <a href="{:url('del',['id'=>$v['id']])}" { data-confirm="确定要删除该记录吗?" class="ajax-get confirm"><span class="label label-danger" title="删除">删除</span></a>
+    </td>
+</tr>
+{if condition="isset($v['children']) && !empty($v['children'])"}
+{:widget_view('energy_device_electricity/tree',['data'=>$v['children'],'depth'=>$depth + 1])}
+{/if}
+{/volist}

+ 86 - 0
application/admin/view/energy_device_electricity_record/add.html

@@ -0,0 +1,86 @@
+{extend name="common/common2" /}
+{block name="main"}
+<div class="row">
+    <div class="col-sm-12">
+        <div class="ibox float-e-margins">
+            <div class="ibox-content">
+                <form method="post" action="{:url('add')}" class="form-horizontal">
+                    <input type="hidden" name="id" value="{$info['id']|default='0'}">
+                    <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="sn" value="{$info.sn|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">
+                            <input type="number" class="form-control" name="degree" value="{$info.degree|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">
+                            <input type="number" class="form-control" name="rate" value="{$info.rate|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">
+                           <input class="form-control " id="readTime" name="read_time" type="text" value="{$info.read_time|default=''}"  />
+                        </div>
+                    </div>
+
+                    <div class="form-group">
+                        <label class="col-sm-2 control-label">月度平均最低气温(℃)</label>
+                        <div class="col-sm-6">
+                            <input type="number" class="form-control" name="min_temperature" value="{$info.min_temperature|default=''}">
+                        </div>
+                    </div>
+
+                    <div class="form-group">
+                        <label class="col-sm-2 control-label">月度平均最高气温(℃)</label>
+                        <div class="col-sm-6">
+                            <input type="number" class="form-control" name="max_temperature" value="{$info.max_temperature|default=''}">
+                        </div>
+                    </div>
+
+                    <div class="form-group">
+                        <label class="col-sm-2 control-label">床位数量</label>
+                        <div class="col-sm-6">
+                            <input type="number" class="form-control" name="beds" value="{$info.beds|default=''}">
+                        </div>
+                    </div>
+
+                    <div class="hr-line-dashed"></div>
+                    <div class="form-group">
+                        <div class="col-sm-6 col-sm-offset-2">
+                            <button class="btn btn-primary ajax-post" data-layer="1" target-form="form-horizontal" type="submit" data-date-format="yyyy-mm-dd">确 定</button>
+                            <button  class="btn cancel-btn btn-default" type="button">取 消</button>
+                        </div>
+                    </div>
+                </form>
+            </div>
+        </div>
+    </div>
+</div>
+{/block}
+{block name="script"}
+<script>
+    $(function () {
+        laydate.render({
+            elem: '#readTime',
+            trigger: 'click',
+            theme: '#0F3A87',
+        });
+    });
+    $(document).ready(function(){
+        formSetValue("enable", {$info.enable|default=1});
+    });
+
+
+</script>
+{/block}

+ 35 - 0
application/admin/view/energy_device_electricity_record/import.html

@@ -0,0 +1,35 @@
+{extend name="common/common2" /}
+{block name="main"}
+<div class="row">
+    <div class="col-sm-12">
+        <div class="ibox float-e-margins">
+            <div class="ibox-content">
+                <form method="post"  action="importexcel"  enctype="multipart/form-data" class="form-horizontal">
+                    <div class="form-group">
+                        <label class="col-sm-2 control-label">选择文件(支持:xls,xlsx)<span class="text-danger">*</span></label>
+                        <div class="col-sm-6">
+                            <input type="file" name="file" id="file" class="form-control" value="" accept=".xls,.xlsx">
+                        </div>
+                    </div>
+
+                    <div class="hr-line-dashed"></div>
+                    <div class="form-group">
+                        <div class="col-sm-6 col-sm-offset-2">
+                            <button class="btn btn-sm btn-primary" type="submit">确定导入</button>
+                            <a href="downloadtem" class="btn btn-sm btn-danger">下载模板</a>
+                        </div>
+                    </div>
+                </form>
+            </div>
+        </div>
+    </div>
+</div>
+{/block}
+{block name="script"}
+<script>
+    $(document).ready(function(){
+        formSetValue("enable", {$info.enable|default=1});
+    });
+
+</script>
+{/block}

+ 151 - 0
application/admin/view/energy_device_electricity_record/index.html

@@ -0,0 +1,151 @@
+{extend name="common/common2" /}
+{block name="main"}
+
+<div class="ibox">
+    <div class="ibox-content">
+        <div class="row">
+            <div class="col-xs-3">
+                <a href="javascript:;" url="{:url('add')}" data-title="新增" onclick="layer_open(this,1)" class="btn btn-sm btn-success">新增</a>
+                <a  href="javascript:;" id="js" class="btn btn-sm btn-danger">批量删除</a>
+            </div>
+            <div class="col-xs-9" style="text-align: right;">
+                <form class="form-inline" id="form-search" action="{:url('index')}">
+<!--                    <div class="input-group" style="width: 200px">-->
+<!--                        <span class="input-group-addon">开始时间</span>-->
+<!--                        <input class="form-control dialog-datetime" id="startTime" name="start" type="text" data-date-format="yyyy-mm-dd" value="" placeholder="录入时间" />-->
+<!--                    </div>-->
+<!--                    <div class="input-group" style="width: 200px">-->
+<!--                        <span class="input-group-addon">结束时间</span>-->
+<!--                        <input class="form-control dialog-datetime" id="endTime" name="end" type="text" data-date-format="yyyy-mm-dd" value="" placeholder="录入时间" />-->
+<!--                    </div>-->
+                    <div class="input-group">
+                        <input type="text" class="form-control" name="sn" placeholder="电表号">
+                    </div>
+                    <div class="input-group">
+                        <span class="input-group-btn">
+                            <button class="btn-sm btn-danger" type="button" id ="search-btn" ><i class="fa fa-search"></i></button>
+                        </span>
+                        &nbsp;
+                        <span class="input-group-btn">
+                            <button class="btn-sm btn-warning " type="button" id="search-clear"><i class="fa fa-undo"></i></button>
+                        </span>
+                        &nbsp;
+                        <span class="input-group-btn">
+                        <button class="btn-sm btn-other" type="button" url="{:url('import')}" data-title="批量导入" onclick="layer_open(this,1)">批量导入</button>
+                        </span>
+                    </div>
+                </form>
+            </div>
+        </div>
+
+    </div>
+    <div class="ibox-content">
+        <div class="jqGrid_wrapper">
+            <table id="table" style="border-collapse: collapse"></table>
+            <div id="pager"></div>
+        </div>
+    </div>
+</div>
+{/block}
+{block name="script"}
+<script>
+    $(function () {
+        laydate.render({
+            elem: '#startTime',
+            trigger: 'click',
+            theme: '#0F3A87'
+        });
+        laydate.render({
+            elem: '#endTime',
+            trigger: 'click',
+            theme: '#0F3A87'
+        });
+    });
+    $(function () {
+
+        $(window).bind("resize",function(){
+            var width=$(".jqGrid_wrapper").width();
+            $("#table").setGridWidth(width);
+        });
+
+        $.jgrid.defaults.styleUI="Bootstrap";
+        $("#table").jqGrid({
+            url:"{:url('index')}",
+            datatype: "json",
+            colModel:[
+                {label:'序号',name:'id',index:'id', width:20,sortable: true},
+                {label:'表号',name:'sn',index:'sn', width:40,sortable: false},
+                {label:'倍率',name:'rate',index:'rate',width:40,sortable: false},
+                {label:'抄表读数',name:'degree',index:'degree', width:40,sortable: false},
+                {label:'抄表时间',name:'read_time',index:'read_time',width:40,sortable: true},
+                {label:'录入人',name:'user_id',index:'user_id',width:40,sortable: false},
+                {label:'录入时间',name:'create_time',index:'create_time', width:60,sortable: true},
+                {label:'月度平均最低气温(℃)',name:'min_temperature',index:'min_temperature', width:40,sortable: false},
+                {label:'月度平均最高气温(℃)',name:'max_temperature',index:'max_temperature', width:40,sortable: false},
+                {label:'床位数量',name:'beds',index:'beds', width:40,sortable: false},
+                {label:'更新时间',name:'update_time',index:'update_time', width:60,sortable: true},
+                {label:'操作',width:60,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="编辑" onclick="layer_open(this,1)"><span class="label label-other" title="编辑">编辑</span></a>&nbsp;';
+                        btn += '<a href="'+delurl+'" class="confirm ajax-get" data-confirm="确定要删除此记录吗?" data-table="1"><span class="label label-danger" title="删除">删除</span></a>';
+                        return btn;
+                    }},
+            ],
+            rowNum:10,
+            rowList:[10,20,30,50,100],
+            pager: '#pager',
+            sortname: 'id',
+            viewrecords: true,
+            autowidth:true,
+            mtype: 'post',
+            height: 'auto',
+            emptyrecords: "暂无数据",
+            sortorder: "desc",
+            caption:"{$meta_title}",
+            multiselect: true,//可多选
+            loadComplete: function (xhr) {
+                if(xhr.code==0){
+                    layer.msg(xhr.msg);
+                    return false;
+                }
+            },
+        });
+
+    });
+    $('#js').click(function () {
+        var rowIds = jQuery("#table").jqGrid('getGridParam', 'selarrrow');    //获取勾选记录的ID
+        if(rowIds.length <=0){
+            updateAlert('请选择记录','alert-danger');
+            setTimeout(function(){
+                $('#top-alert').find('button').click();
+            },1500);
+            return;
+        }
+
+        layer.confirm('确定批量删除记录?(此方法不可逆,谨慎操作)', {
+            icon: 3,
+            btn: ['确定', '取消'],
+            skin: 'layer-ext-moon'
+        }, function(index) {
+            layer.close(layer.index);
+            $.post('{:url("multiDel")}',{ids:rowIds},function (res) {
+                if(res.code==0){
+                    updateAlert(res.msg,'alert-danger');
+                    setTimeout(function(){
+                        $('#top-alert').find('button').click();
+                    },1500);
+                    // window.location.reload();
+                }else {
+                    updateAlert(res.msg,'alert-success');
+                    setTimeout(function(){
+                        $('#top-alert').find('button').click();
+                        $("#table").trigger("reloadGrid");
+                    },1500);
+
+                }
+            })
+        });
+    })
+</script>
+{/block}

+ 233 - 0
application/admin/view/energy_electricity/add.html

@@ -0,0 +1,233 @@
+{extend name="common/common2" /}
+{block name="main"}
+<style>
+    /*.el-select .el-input {*/
+    /*    width: 130px;*/
+    /*}*/
+    .input-with-select .el-input-group__prepend {
+        background-color: #fff;
+    }
+
+</style>
+<div class="row" id="formApp">
+    <div class="col-sm-12">
+        <div class="ibox float-e-margins">
+            <div class="ibox-content">
+                <form method="post" action="{:url('add')}" class="form-horizontal">
+                    <input type="hidden" name="parent_id" value="{$pid}">
+                    <input type="hidden" name="id" value="{$info['id']|default='0'}">
+                    <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="name" value="{$info.name|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">
+                            <input type="text" class="form-control" name="number" value="{$info.number|default=''}">
+                        </div>
+                    </div>
+
+                    <div class="form-group">
+                        <label class="col-sm-2 control-label">用电分类<span class="text-danger">*</span></label>
+                        <input type="hidden" id="ele-type_e" name="type_e" :value="value2">
+                        <div class="col-sm-6">
+                            <el-select
+                                    v-model="value2"
+                                    filterable
+                                    size="small"
+                                    style="width:100%"
+                                    placeholder="请选择用电分类"
+                            >
+                                <el-option
+                                        v-for="item in options3"
+                                        :key="item.id"
+                                        :label="item.name"
+                                        :value="item.id.toString()">
+                                </el-option>
+                            </el-select>
+                        </div>
+                    </div>
+
+                    {if condition="$pid != 0"}
+                    <div class="form-group">
+                        <label class="col-sm-2 control-label">地点<span class="text-danger">*</span></label>
+                        <input type="hidden" name="address" :value="JSON.stringify(selectedValue)">
+                        <div class="col-sm-6">
+                            <el-cascader
+                                    v-model="selectedValue"
+                                    :options="options"
+                                    :props="props"
+                                    style="width:100%"
+                                    @change="handleChange"
+                                    filterable
+                                    clearable>
+                            </el-cascader>
+                        </div>
+                    </div>
+
+                    <div class="form-group">
+                        <label class="col-sm-2 control-label">科室<span class="text-danger">*</span></label>
+                        <input type="hidden" id="ele-dep" name="dep" :value="value">
+                        <div class="col-sm-6">
+                            <el-select
+                                    v-model="value"
+                                    multiple
+                                    filterable
+                                    @change="handler"
+                                    size="small"
+                                    style="width:100%"
+                                    placeholder="请选择"
+                            >
+                                <el-option
+                                        v-for="item in options2"
+                                        :key="item.id"
+                                        :label="item.name"
+                                        :value="item.id.toString()">
+                                </el-option>
+                            </el-select>
+                        </div>
+                    </div>
+
+                    <div v-if="value.length>1" class="form-group">
+                        <label class="col-sm-2 control-label">用电分摊</label>
+                        <div class="col-sm-6">
+                            <el-input  placeholder="请输入分摊比例,例如2:3:5 (如按面积分摊不用填此项)" v-model="input" class="input-with-select" name="percent">
+                                <el-select
+                                        v-model="select"
+                                        slot="prepend"
+                                        placeholder="分摊方式"
+                                        style="width: 130px" >
+                                    <el-option label="按面积" value=0></el-option>
+                                    <el-option label="按比例" value=1></el-option>
+                                </el-select>
+                            </el-input>
+                            <input type="hidden" id="ele-share" name="share" :value="select">
+                        </div>
+                    </div>
+<!--                    <div v-if="value.length>1" class="form-group">-->
+<!--                        <div class=" col-sm-2 " v-for="item in resultArr" :key="item.label">-->
+<!--                            <el-input placeholder="请输入面积" v-model="item.rate" class="">-->
+<!--                                <template slot="prepend">{{ item.label }}</template>-->
+<!--                            </el-input>-->
+<!--                        </div>-->
+<!--                    </div>-->
+                    {/if}
+
+                    <div class="form-group">
+                        <label class="col-sm-2 control-label">备注</label>
+                        <div class="col-sm-6">
+                            <textarea name="remark" class="form-control" rows="3">{$info.remark|default=''}</textarea>
+                        </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="hr-line-dashed"></div>
+                    <div class="form-group">
+                        <div class="col-sm-6 col-sm-offset-2">
+                            <button class="btn btn-primary ajax-post" data-layer="1" target-form="form-horizontal" type="submit">确 定</button>
+                        </div>
+                    </div>
+                </form>
+            </div>
+        </div>
+    </div>
+</div>
+{/block}
+{block name="script"}
+<script>
+    $('#patient').hide();
+    new Vue({
+        el: '#formApp',
+        data: function() {
+            return {
+                props: { value: 'id', label: 'title' },
+                options:{:json_encode($alist)},
+                options2: {:json_encode($dlist)},
+                value: {:json_encode($info.dep ?? [])},
+                options3: {:json_encode($tlist)},
+                value2: '{$info.type_e|default=""}',
+                selectedValue:{$info.address|default=0},
+                select: '{$info.share|default="0"}',
+                input: '{$info.percent|default=""}',
+                resultArr: [],
+        }
+        },
+        watch: {
+            value: function (newVal, oldVal) {
+                $('#ele-dep').val(newVal.join(','));
+            }
+        },
+        methods: {
+            handleChange(value) {
+                // 当级联选择器的值改变时,发送Ajax请求
+                $.ajax({
+                    url: '/admin/energy_electricity/getDep', // 后端接口地址
+                    type: 'POST',
+                    // contentType: 'application/json',
+                    data: {param:JSON.stringify(value)},
+                    success: (response) => {
+                        // 假设后端响应的数据是一个数组,并将其赋值给list
+                        this.options2 = response.data;
+                    },
+                    error: (xhr, status, error) => {
+                        console.error('请求失败:', error);
+                        // 处理错误情况
+                    }
+                });
+                        this.value='';
+                        this.select = '';
+                        this.input = '';
+            },
+            handler(val){
+                this.resultArr = val.map((ele) => ({ label: ele, rate: '' }));
+            }
+        },
+        mounted(){
+            $.ajax({
+                url: '/admin/energy_electricity/getDep', // 后端接口地址
+                type: 'POST',
+                // contentType: 'application/json',
+                data: {param:JSON.stringify(this.selectedValue)},
+                success: (response) => {
+                    // 假设后端响应的数据是一个数组,并将其赋值给list
+                    this.options2 = response.data;
+                    if (this.selectedValue == 0){
+                        this.options2 = [];
+                    }
+                },
+                error: (xhr, status, error) => {
+                    console.error('请求失败:', error);
+                    // 处理错误情况
+                }
+            });
+        }
+        // created(){
+        //     const vals = this.value;
+        //     this.value = [];
+        //     vals.forEach((item) => {
+        //         this.value.push(item.toString());
+        //     })
+        // }
+
+    })
+    $(document).ready(function(){
+        formSetValue("enable", {$info.enable|default=1});
+    });
+    window.addEventListener('touchstart',function () {
+    },{ passive: false });
+</script>
+{/block}

+ 38 - 0
application/admin/view/energy_electricity/index.html

@@ -0,0 +1,38 @@
+{extend name="common/common2" /}
+{block name="main"}
+
+<div class="ibox">
+    <div class="ibox-title">
+        <h5>电表管理</h5>
+        <div  style="float: right;margin-right: 200px">
+            <a url="{:url('add',['pid'=>0])}" href="javascript:;" data-title="添加总表" onclick="layer_open(this,2)"><span class="label label-info" title="添加总表">添加总表</span></a>
+        </div>
+    </div>
+    <div class="ibox-content">
+        <table class="table table-striped">
+            <thead>
+            <tr>
+                <th>编号</th>
+                <th>表名</th>
+                <th>表号</th>
+                <th>备注</th>
+                <th>状态</th>
+                <th>电表类型</th>
+                <th>用电分类</th>
+                <th>操作</th>
+            </tr>
+            </thead>
+            <tbody>
+            {if condition="$tree"}
+            {:widget_view('energy_electricity/tree',['data'=>$tree,'depth'=>0])}
+            {/if}
+            </tbody>
+        </table>
+    </div>
+</div>
+{/block}
+{block name="script"}
+<script>
+
+</script>
+{/block}

+ 77 - 0
application/admin/view/energy_electricity/split.html

@@ -0,0 +1,77 @@
+{extend name="common/common2" /}
+{block name="main"}
+<style>
+    /*.el-select .el-input {*/
+    /*    width: 130px;*/
+    /*}*/
+    .input-with-select .el-input-group__prepend {
+        background-color: #fff;
+    }
+
+</style>
+<div class="row" id="formApp">
+    <div class="col-sm-12">
+        <div class="ibox float-e-margins">
+            <div class="ibox-content">
+                <form method="post" action="{:url('split')}" class="form-horizontal">
+                    <input type="hidden" name="id" value="{$id|default='0'}">
+
+                    <div class="form-group">
+                        <label class="col-sm-2 control-label">拆分电表<span class="text-danger">*</span></label>
+                        <input type="hidden" id="ele-split" name="split" :value="value">
+                        <div class="col-sm-6">
+                            <el-select
+                                    v-model="value"
+                                    multiple
+                                    filterable
+                                    size="small"
+                                    style="width:100%"
+                                    @change="handleChange"
+                                    placeholder="请选择拆分的电表"
+                            >
+                                <el-option
+                                        v-for="item in options"
+                                        :key="item.id"
+                                        :label="item.number"
+                                        :value="item.id">
+                                </el-option>
+                            </el-select>
+                        </div>
+                    </div>
+
+                    <div class="hr-line-dashed"></div>
+                    <div class="form-group">
+                        <div class="col-sm-6 col-sm-offset-2">
+                            <button class="btn btn-primary ajax-post" data-layer="1" target-form="form-horizontal" type="submit">确 定</button>
+                        </div>
+                    </div>
+                </form>
+            </div>
+        </div>
+    </div>
+</div>
+{/block}
+{block name="script"}
+<script>
+    $('#patient').hide();
+    new Vue({
+        el: '#formApp',
+        data: function() {
+            return {
+            options: {:json_encode($list)},
+            value: [{$info.split|default=''}],
+        }
+        },
+        methods: {
+            handleChange(value) {
+                console.log(value)
+            }
+        },
+        created(){
+        }
+
+    })
+    window.addEventListener('touchstart',function () {
+    },{ passive: false });
+</script>
+{/block}

+ 46 - 0
application/admin/view/energy_electricity/tree.html

@@ -0,0 +1,46 @@
+{volist name="data" id="v"}
+<tr>
+    <td style="width: 60px;">{$v.id}</td>
+    <td style="text-indent:{$depth * 2}em;">
+        {if condition="isset($v['children']) && !empty($v['children'])"}
+        <i class="glyphicon glyphicon-folder-open"></i>
+        {else /}
+        <i class="glyphicon glyphicon-list-alt"></i>
+        {/if}
+        {$v.name}
+    </td>
+    <td style="width: 110px;">{$v.number}</td>
+    <td style="width: 110px;">{$v.remark}</td>
+    <td style="width: 80px;">
+        {if condition="$v['enable'] == 0"}
+        <a href="{:url('changeEnable',['id'=>$v['id'],'enable'=>1])}" data-confirm="确定要启用该记录吗?" class="ajax-get confirm data-reload"><span class="label label-danger" title="禁用">禁用</span></a>
+        {else /}
+        <a href="{:url('changeEnable',['id'=>$v['id'],'enable'=>0])}" data-confirm="确定要禁用该记录吗?" class="ajax-get confirm data-reload"><span class="label label-warning" title="启用">启用</span></a>
+        {/if}
+    </td>
+    <td style="width: 80px;">
+        {if condition="$v['parent_id'] == 0"}
+            总表
+        {else/}
+            分表
+        {/if}
+    </td>
+    <td style="width: 80px;">
+        {$v.type_e}
+    </td>
+    <td style="width: 300px;">
+        <a url="{:url('add',['id'=>$v['id'],'pid'=>$v['parent_id'],'t'=>1])}" href="javascript:;" data-title="编辑" onclick="layer_open(this,2)"><span class="label label-other" title="编辑">编辑</span></a>
+        <a url="{:url('add',['pid'=>$v['id']])}" href="javascript:;" data-title="添加子电表" onclick="layer_open(this,2)"><span class="label label-info" title="添加子电表">添加子电表</span></a>
+        {if condition="$v['parent_id'] != 0"}
+        <a url="{:url('split',['id'=>$v['id']])}" href="javascript:;" data-title="拆分电表" data-width="70%" data-height="70%" onclick="layer_open(this,2)"><span class="label label-primary" title="拆分电表">拆分电表</span></a>
+        {/if}
+        {if condition="$v['parent_id'] == 0"}
+        <a href="{:url('change',['sn'=>$v['number']])}"  data-confirm="换表后新表将会自动追加旧抄表读数" class="ajax-get confirm"><span class="label label-primary" title="换表">换表</span></a>
+        {/if}
+        <a href="{:url('del',['id'=>$v['id']])}"  data-confirm="确定要删除该记录吗?" class="ajax-get confirm"><span class="label label-danger" title="删除">删除</span></a>
+    </td>
+</tr>
+{if condition="isset($v['children']) && !empty($v['children'])"}
+{:widget_view('energy_electricity/tree',['data'=>$v['children'],'depth'=>$depth + 1])}
+{/if}
+{/volist}

+ 86 - 0
application/admin/view/energy_electricity_record/add.html

@@ -0,0 +1,86 @@
+{extend name="common/common2" /}
+{block name="main"}
+<div class="row">
+    <div class="col-sm-12">
+        <div class="ibox float-e-margins">
+            <div class="ibox-content">
+                <form method="post" action="{:url('add')}" class="form-horizontal">
+                    <input type="hidden" name="id" value="{$info['id']|default='0'}">
+                    <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="sn" value="{$info.sn|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">
+                            <input type="number" class="form-control" name="degree" value="{$info.degree|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">
+                            <input type="number" class="form-control" name="rate" value="{$info.rate|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">
+                           <input class="form-control " id="readTime" name="read_time" type="text" value="{$info.read_time|default=''}"  />
+                        </div>
+                    </div>
+
+                    <div class="form-group">
+                        <label class="col-sm-2 control-label">月度平均最低气温(℃)</label>
+                        <div class="col-sm-6">
+                            <input type="number" class="form-control" name="min_temperature" value="{$info.min_temperature|default=''}">
+                        </div>
+                    </div>
+
+                    <div class="form-group">
+                        <label class="col-sm-2 control-label">月度平均最高气温(℃)</label>
+                        <div class="col-sm-6">
+                            <input type="number" class="form-control" name="max_temperature" value="{$info.max_temperature|default=''}">
+                        </div>
+                    </div>
+
+                    <div class="form-group">
+                        <label class="col-sm-2 control-label">床位数量</label>
+                        <div class="col-sm-6">
+                            <input type="number" class="form-control" name="beds" value="{$info.beds|default=''}">
+                        </div>
+                    </div>
+
+                    <div class="hr-line-dashed"></div>
+                    <div class="form-group">
+                        <div class="col-sm-6 col-sm-offset-2">
+                            <button class="btn btn-primary ajax-post" data-layer="1" target-form="form-horizontal" type="submit" data-date-format="yyyy-mm-dd">确 定</button>
+                            <button  class="btn cancel-btn btn-default" type="button">取 消</button>
+                        </div>
+                    </div>
+                </form>
+            </div>
+        </div>
+    </div>
+</div>
+{/block}
+{block name="script"}
+<script>
+    $(function () {
+        laydate.render({
+            elem: '#readTime',
+            trigger: 'click',
+            theme: '#0F3A87',
+        });
+    });
+    $(document).ready(function(){
+        formSetValue("enable", {$info.enable|default=1});
+    });
+
+
+</script>
+{/block}

+ 35 - 0
application/admin/view/energy_electricity_record/import.html

@@ -0,0 +1,35 @@
+{extend name="common/common2" /}
+{block name="main"}
+<div class="row">
+    <div class="col-sm-12">
+        <div class="ibox float-e-margins">
+            <div class="ibox-content">
+                <form method="post"  action="importexcel"  enctype="multipart/form-data" class="form-horizontal">
+                    <div class="form-group">
+                        <label class="col-sm-2 control-label">选择文件(支持:xls,xlsx)<span class="text-danger">*</span></label>
+                        <div class="col-sm-6">
+                            <input type="file" name="file" id="file" class="form-control" value="" accept=".xls,.xlsx">
+                        </div>
+                    </div>
+
+                    <div class="hr-line-dashed"></div>
+                    <div class="form-group">
+                        <div class="col-sm-6 col-sm-offset-2">
+                            <button class="btn btn-sm btn-primary" type="submit">确定导入</button>
+                            <a href="downloadtem" class="btn btn-sm btn-danger">下载模板</a>
+                        </div>
+                    </div>
+                </form>
+            </div>
+        </div>
+    </div>
+</div>
+{/block}
+{block name="script"}
+<script>
+    $(document).ready(function(){
+        formSetValue("enable", {$info.enable|default=1});
+    });
+
+</script>
+{/block}

+ 151 - 0
application/admin/view/energy_electricity_record/index.html

@@ -0,0 +1,151 @@
+{extend name="common/common2" /}
+{block name="main"}
+
+<div class="ibox">
+    <div class="ibox-content">
+        <div class="row">
+            <div class="col-xs-3">
+                <a href="javascript:;" url="{:url('add')}" data-title="新增" onclick="layer_open(this,1)" class="btn btn-sm btn-success">新增</a>
+                <a  href="javascript:;" id="js" class="btn btn-sm btn-danger">批量删除</a>
+            </div>
+            <div class="col-xs-9" style="text-align: right;">
+                <form class="form-inline" id="form-search" action="{:url('index')}">
+<!--                    <div class="input-group" style="width: 200px">-->
+<!--                        <span class="input-group-addon">开始时间</span>-->
+<!--                        <input class="form-control dialog-datetime" id="startTime" name="start" type="text" data-date-format="yyyy-mm-dd" value="" placeholder="录入时间" />-->
+<!--                    </div>-->
+<!--                    <div class="input-group" style="width: 200px">-->
+<!--                        <span class="input-group-addon">结束时间</span>-->
+<!--                        <input class="form-control dialog-datetime" id="endTime" name="end" type="text" data-date-format="yyyy-mm-dd" value="" placeholder="录入时间" />-->
+<!--                    </div>-->
+                    <div class="input-group">
+                        <input type="text" class="form-control" name="sn" placeholder="电表号">
+                    </div>
+                    <div class="input-group">
+                        <span class="input-group-btn">
+                            <button class="btn-sm btn-danger" type="button" id ="search-btn" ><i class="fa fa-search"></i></button>
+                        </span>
+                        &nbsp;
+                        <span class="input-group-btn">
+                            <button class="btn-sm btn-warning " type="button" id="search-clear"><i class="fa fa-undo"></i></button>
+                        </span>
+                        &nbsp;
+                        <span class="input-group-btn">
+                        <button class="btn-sm btn-other" type="button" url="{:url('import')}" data-title="批量导入" onclick="layer_open(this,1)">批量导入</button>
+                        </span>
+                    </div>
+                </form>
+            </div>
+        </div>
+
+    </div>
+    <div class="ibox-content">
+        <div class="jqGrid_wrapper">
+            <table id="table" style="border-collapse: collapse"></table>
+            <div id="pager"></div>
+        </div>
+    </div>
+</div>
+{/block}
+{block name="script"}
+<script>
+    $(function () {
+        laydate.render({
+            elem: '#startTime',
+            trigger: 'click',
+            theme: '#0F3A87'
+        });
+        laydate.render({
+            elem: '#endTime',
+            trigger: 'click',
+            theme: '#0F3A87'
+        });
+    });
+    $(function () {
+
+        $(window).bind("resize",function(){
+            var width=$(".jqGrid_wrapper").width();
+            $("#table").setGridWidth(width);
+        });
+
+        $.jgrid.defaults.styleUI="Bootstrap";
+        $("#table").jqGrid({
+            url:"{:url('index')}",
+            datatype: "json",
+            colModel:[
+                {label:'序号',name:'id',index:'id', width:20,sortable: true},
+                {label:'表号',name:'sn',index:'sn', width:40,sortable: false},
+                {label:'倍率',name:'rate',index:'rate',width:40,sortable: false},
+                {label:'抄表读数',name:'degree',index:'degree', width:40,sortable: false},
+                {label:'抄表时间',name:'read_time',index:'read_time',width:40,sortable: false},
+                {label:'录入人',name:'user_id',index:'user_id',width:40,sortable: false},
+                {label:'录入时间',name:'create_time',index:'create_time', width:60,sortable: false},
+                {label:'月度平均最低气温(℃)',name:'min_temperature',index:'min_temperature', width:45,sortable: false},
+                {label:'月度平均最高气温(℃)',name:'max_temperature',index:'max_temperature', width:45,sortable: false},
+                {label:'床位数量',name:'beds',index:'beds', width:30,sortable: false},
+                {label:'更新时间',name:'update_time',index:'update_time', width:60,sortable: false},
+                {label:'操作',width:60,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="编辑" onclick="layer_open(this,1)"><span class="label label-other" title="编辑">编辑</span></a>&nbsp;';
+                        btn += '<a href="'+delurl+'" class="confirm ajax-get" data-confirm="确定要删除此记录吗?" data-table="1"><span class="label label-danger" title="删除">删除</span></a>';
+                        return btn;
+                    }},
+            ],
+            rowNum:10,
+            rowList:[10,20,30,50,100],
+            pager: '#pager',
+            sortname: 'read_time',
+            viewrecords: true,
+            autowidth:true,
+            mtype: 'post',
+            height: 'auto',
+            emptyrecords: "暂无数据",
+            sortorder: "desc",
+            caption:"{$meta_title}",
+            multiselect: true,//可多选
+            loadComplete: function (xhr) {
+                if(xhr.code==0){
+                    layer.msg(xhr.msg);
+                    return false;
+                }
+            },
+        });
+
+    });
+    $('#js').click(function () {
+        var rowIds = jQuery("#table").jqGrid('getGridParam', 'selarrrow');    //获取勾选记录的ID
+        if(rowIds.length <=0){
+            updateAlert('请选择记录','alert-danger');
+            setTimeout(function(){
+                $('#top-alert').find('button').click();
+            },1500);
+            return;
+        }
+
+        layer.confirm('确定批量删除记录?(此方法不可逆,谨慎操作)', {
+            icon: 3,
+            btn: ['确定', '取消'],
+            skin: 'layer-ext-moon'
+        }, function(index) {
+            layer.close(layer.index);
+            $.post('{:url("multiDel")}',{ids:rowIds},function (res) {
+                if(res.code==0){
+                    updateAlert(res.msg,'alert-danger');
+                    setTimeout(function(){
+                        $('#top-alert').find('button').click();
+                    },1500);
+                    // window.location.reload();
+                }else {
+                    updateAlert(res.msg,'alert-success');
+                    setTimeout(function(){
+                        $('#top-alert').find('button').click();
+                        $("#table").trigger("reloadGrid");
+                    },1500);
+
+                }
+            })
+        });
+    })
+</script>
+{/block}

+ 86 - 0
application/admin/view/energy_electricity_record2/add.html

@@ -0,0 +1,86 @@
+{extend name="common/common2" /}
+{block name="main"}
+<div class="row">
+    <div class="col-sm-12">
+        <div class="ibox float-e-margins">
+            <div class="ibox-content">
+                <form method="post" action="{:url('add')}" class="form-horizontal">
+                    <input type="hidden" name="id" value="{$info['id']|default='0'}">
+                    <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="sn" value="{$info.sn|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">
+                            <input type="number" class="form-control" name="degree" value="{$info.degree|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">
+                            <input type="number" class="form-control" name="rate" value="{$info.rate|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">
+                           <input class="form-control " id="readTime" name="read_time" type="text" value="{$info.read_time|default=''}"  />
+                        </div>
+                    </div>
+
+                    <div class="form-group">
+                        <label class="col-sm-2 control-label">录入当天最低温度(℃)</label>
+                        <div class="col-sm-6">
+                            <input type="number" class="form-control" name="min_temperature" value="{$info.min_temperature|default=''}">
+                        </div>
+                    </div>
+
+                    <div class="form-group">
+                        <label class="col-sm-2 control-label">录入当天最高温度(℃)</label>
+                        <div class="col-sm-6">
+                            <input type="number" class="form-control" name="max_temperature" value="{$info.max_temperature|default=''}">
+                        </div>
+                    </div>
+
+                    <div class="form-group">
+                        <label class="col-sm-2 control-label">床位数量</label>
+                        <div class="col-sm-6">
+                            <input type="number" class="form-control" name="beds" value="{$info.beds|default=''}">
+                        </div>
+                    </div>
+
+                    <div class="hr-line-dashed"></div>
+                    <div class="form-group">
+                        <div class="col-sm-6 col-sm-offset-2">
+                            <button class="btn btn-primary ajax-post" data-layer="1" target-form="form-horizontal" type="submit" data-date-format="yyyy-mm-dd">确 定</button>
+                            <button  class="btn cancel-btn btn-default" type="button">取 消</button>
+                        </div>
+                    </div>
+                </form>
+            </div>
+        </div>
+    </div>
+</div>
+{/block}
+{block name="script"}
+<script>
+    $(function () {
+        laydate.render({
+            elem: '#readTime',
+            trigger: 'click',
+            theme: '#0F3A87',
+        });
+    });
+    $(document).ready(function(){
+        formSetValue("enable", {$info.enable|default=1});
+    });
+
+
+</script>
+{/block}

+ 35 - 0
application/admin/view/energy_electricity_record2/import.html

@@ -0,0 +1,35 @@
+{extend name="common/common2" /}
+{block name="main"}
+<div class="row">
+    <div class="col-sm-12">
+        <div class="ibox float-e-margins">
+            <div class="ibox-content">
+                <form method="post"  action="importexcel"  enctype="multipart/form-data" class="form-horizontal">
+                    <div class="form-group">
+                        <label class="col-sm-2 control-label">选择文件(支持:xls,xlsx)<span class="text-danger">*</span></label>
+                        <div class="col-sm-6">
+                            <input type="file" name="file" id="file" class="form-control" value="" accept=".xls,.xlsx">
+                        </div>
+                    </div>
+
+                    <div class="hr-line-dashed"></div>
+                    <div class="form-group">
+                        <div class="col-sm-6 col-sm-offset-2">
+                            <button class="btn btn-sm btn-primary" type="submit">确定导入</button>
+                            <a href="downloadtem" class="btn btn-sm btn-danger">下载模板</a>
+                        </div>
+                    </div>
+                </form>
+            </div>
+        </div>
+    </div>
+</div>
+{/block}
+{block name="script"}
+<script>
+    $(document).ready(function(){
+        formSetValue("enable", {$info.enable|default=1});
+    });
+
+</script>
+{/block}

+ 151 - 0
application/admin/view/energy_electricity_record2/index.html

@@ -0,0 +1,151 @@
+{extend name="common/common2" /}
+{block name="main"}
+
+<div class="ibox">
+    <div class="ibox-content">
+        <div class="row">
+            <div class="col-xs-3">
+                <a href="javascript:;" url="{:url('add')}" data-title="新增" onclick="layer_open(this,1)" class="btn btn-sm btn-success">新增</a>
+                <a  href="javascript:;" id="js" class="btn btn-sm btn-danger">批量删除</a>
+            </div>
+            <div class="col-xs-9" style="text-align: right;">
+                <form class="form-inline" id="form-search" action="{:url('index')}">
+<!--                    <div class="input-group" style="width: 200px">-->
+<!--                        <span class="input-group-addon">开始时间</span>-->
+<!--                        <input class="form-control dialog-datetime" id="startTime" name="start" type="text" data-date-format="yyyy-mm-dd" value="" placeholder="录入时间" />-->
+<!--                    </div>-->
+<!--                    <div class="input-group" style="width: 200px">-->
+<!--                        <span class="input-group-addon">结束时间</span>-->
+<!--                        <input class="form-control dialog-datetime" id="endTime" name="end" type="text" data-date-format="yyyy-mm-dd" value="" placeholder="录入时间" />-->
+<!--                    </div>-->
+                    <div class="input-group">
+                        <input type="text" class="form-control" name="sn" placeholder="电表号">
+                    </div>
+                    <div class="input-group">
+                        <span class="input-group-btn">
+                            <button class="btn-sm btn-danger" type="button" id ="search-btn" ><i class="fa fa-search"></i></button>
+                        </span>
+                        &nbsp;
+                        <span class="input-group-btn">
+                            <button class="btn-sm btn-warning " type="button" id="search-clear"><i class="fa fa-undo"></i></button>
+                        </span>
+                        &nbsp;
+                        <span class="input-group-btn">
+                        <button class="btn-sm btn-other" type="button" url="{:url('import')}" data-title="批量导入" onclick="layer_open(this,1)">批量导入</button>
+                        </span>
+                    </div>
+                </form>
+            </div>
+        </div>
+
+    </div>
+    <div class="ibox-content">
+        <div class="jqGrid_wrapper">
+            <table id="table" style="border-collapse: collapse"></table>
+            <div id="pager"></div>
+        </div>
+    </div>
+</div>
+{/block}
+{block name="script"}
+<script>
+    $(function () {
+        laydate.render({
+            elem: '#startTime',
+            trigger: 'click',
+            theme: '#0F3A87'
+        });
+        laydate.render({
+            elem: '#endTime',
+            trigger: 'click',
+            theme: '#0F3A87'
+        });
+    });
+    $(function () {
+
+        $(window).bind("resize",function(){
+            var width=$(".jqGrid_wrapper").width();
+            $("#table").setGridWidth(width);
+        });
+
+        $.jgrid.defaults.styleUI="Bootstrap";
+        $("#table").jqGrid({
+            url:"{:url('index')}",
+            datatype: "json",
+            colModel:[
+                {label:'序号',name:'id',index:'id', width:20,sortable: true},
+                {label:'表号',name:'sn',index:'sn', width:40,sortable: false},
+                {label:'倍率',name:'rate',index:'rate',width:40,sortable: false},
+                {label:'抄表读数',name:'degree',index:'degree', width:40,sortable: false},
+                {label:'抄表时间',name:'read_time',index:'read_time',width:40,sortable: false},
+                {label:'录入人',name:'user_id',index:'user_id',width:40,sortable: false},
+                {label:'录入时间',name:'create_time',index:'create_time', width:60,sortable: false},
+                {label:'最低温度(℃)',name:'min_temperature',index:'min_temperature', width:40,sortable: false},
+                {label:'最高温度(℃)',name:'max_temperature',index:'max_temperature', width:40,sortable: false},
+                {label:'床位数量',name:'beds',index:'beds', width:40,sortable: false},
+                {label:'更新时间',name:'update_time',index:'update_time', width:60,sortable: false},
+                {label:'操作',width:60,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="编辑" onclick="layer_open(this,1)"><span class="label label-other" title="编辑">编辑</span></a>&nbsp;';
+                        btn += '<a href="'+delurl+'" class="confirm ajax-get" data-confirm="确定要删除此记录吗?" data-table="1"><span class="label label-danger" title="删除">删除</span></a>';
+                        return btn;
+                    }},
+            ],
+            rowNum:10,
+            rowList:[10,20,30,50,100],
+            pager: '#pager',
+            sortname: 'read_time',
+            viewrecords: true,
+            autowidth:true,
+            mtype: 'post',
+            height: 'auto',
+            emptyrecords: "暂无数据",
+            sortorder: "desc",
+            caption:"{$meta_title}",
+            multiselect: true,//可多选
+            loadComplete: function (xhr) {
+                if(xhr.code==0){
+                    layer.msg(xhr.msg);
+                    return false;
+                }
+            },
+        });
+
+    });
+    $('#js').click(function () {
+        var rowIds = jQuery("#table").jqGrid('getGridParam', 'selarrrow');    //获取勾选记录的ID
+        if(rowIds.length <=0){
+            updateAlert('请选择记录','alert-danger');
+            setTimeout(function(){
+                $('#top-alert').find('button').click();
+            },1500);
+            return;
+        }
+
+        layer.confirm('确定批量删除记录?(此方法不可逆,谨慎操作)', {
+            icon: 3,
+            btn: ['确定', '取消'],
+            skin: 'layer-ext-moon'
+        }, function(index) {
+            layer.close(layer.index);
+            $.post('{:url("multiDel")}',{ids:rowIds},function (res) {
+                if(res.code==0){
+                    updateAlert(res.msg,'alert-danger');
+                    setTimeout(function(){
+                        $('#top-alert').find('button').click();
+                    },1500);
+                    // window.location.reload();
+                }else {
+                    updateAlert(res.msg,'alert-success');
+                    setTimeout(function(){
+                        $('#top-alert').find('button').click();
+                        $("#table").trigger("reloadGrid");
+                    },1500);
+
+                }
+            })
+        });
+    })
+</script>
+{/block}

+ 200 - 0
application/admin/view/energy_gas/add.html

@@ -0,0 +1,200 @@
+{extend name="common/common2" /}
+{block name="main"}
+<style>
+    /*.el-select .el-input {*/
+    /*    width: 130px;*/
+    /*}*/
+    .input-with-select .el-input-group__prepend {
+        background-color: #fff;
+    }
+
+</style>
+<div class="row" id="formApp">
+    <div class="col-sm-12">
+        <div class="ibox float-e-margins">
+            <div class="ibox-content">
+                <form method="post" action="{:url('add')}" class="form-horizontal">
+                    <input type="hidden" name="parent_id" value="{$pid}">
+                    <input type="hidden" name="id" value="{$info['id']|default='0'}">
+                    <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="name" value="{$info.name|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">
+                            <input type="text" class="form-control" name="number" value="{$info.number|default=''}">
+                        </div>
+                    </div>
+
+                    {if condition="$pid != 0"}
+                    <div class="form-group">
+                        <label class="col-sm-2 control-label">地点<span class="text-danger">*</span></label>
+                        <input type="hidden" name="address" :value="JSON.stringify(selectedValue)">
+                        <div class="col-sm-6">
+                            <el-cascader
+                                    v-model="selectedValue"
+                                    :options="options"
+                                    :props="props"
+                                    style="width:100%"
+                                    @change="handleChange"
+                                    filterable
+                                    clearable>
+                            </el-cascader>
+                        </div>
+                    </div>
+
+                    <div class="form-group">
+                        <label class="col-sm-2 control-label">科室<span class="text-danger">*</span></label>
+                        <input type="hidden" id="ele-dep" name="dep" :value="value">
+                        <div class="col-sm-6">
+                            <el-select
+                                    v-model="value"
+                                    multiple
+                                    filterable
+                                    size="small"
+                                    style="width:100%"
+                                    placeholder="请选择"
+                            >
+                                <el-option
+                                        v-for="item in options2"
+                                        :key="item.id"
+                                        :label="item.name"
+                                        :value="item.id.toString()">
+                                </el-option>
+                            </el-select>
+                        </div>
+                    </div>
+
+                    <div v-if="value.length>1" class="form-group">
+                        <label class="col-sm-2 control-label">燃气分摊</label>
+                        <div class="col-sm-6">
+                            <el-input  placeholder="请输入分摊比例,例如2:3:5 (如按面积分摊不用填此项)" v-model="input" class="input-with-select" name="percent">
+                                <el-select
+                                        v-model="select"
+                                        slot="prepend"
+                                        placeholder="分摊方式"
+                                        style="width: 130px" >
+                                    <el-option label="按面积" value=0></el-option>
+                                    <el-option label="按比例" value=1></el-option>
+                                </el-select>
+                            </el-input>
+                            <input type="hidden" id="ele-share" name="share" :value="select">
+                        </div>
+                    </div>
+                    {/if}
+
+                    <div class="form-group">
+                        <label class="col-sm-2 control-label">备注</label>
+                        <div class="col-sm-6">
+                            <textarea name="remark" class="form-control" rows="3">{$info.remark|default=''}</textarea>
+                        </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="hr-line-dashed"></div>
+                    <div class="form-group">
+                        <div class="col-sm-6 col-sm-offset-2">
+                            <button class="btn btn-primary ajax-post" data-layer="1" target-form="form-horizontal" type="submit">确 定</button>
+                        </div>
+                    </div>
+                </form>
+            </div>
+        </div>
+    </div>
+</div>
+{/block}
+{block name="script"}
+<script>
+    $('#patient').hide();
+    new Vue({
+        el: '#formApp',
+        data: function() {
+            return {
+                props: { value: 'id', label: 'title' },
+                options:{:json_encode($alist)},
+                options2: {:json_encode($dlist)},
+                value: {:json_encode($info.dep ?? [])},
+                options3: {:json_encode($tlist)},
+                value2: {$info.type_e|default=1},
+                selectedValue:{$info.address|default=0},
+                select: '{$info.share|default="0"}',
+                input: '{$info.percent|default=""}',
+        }
+        },
+        watch: {
+            value: function (newVal, oldVal) {
+                $('#ele-dep').val(newVal.join(','));
+            }
+        },
+        methods: {
+            handleChange(value) {
+                // 当级联选择器的值改变时,发送Ajax请求
+                $.ajax({
+                    url: '/admin/energy_electricity/getDep', // 后端接口地址
+                    type: 'POST',
+                    // contentType: 'application/json',
+                    data: {param:JSON.stringify(value)},
+                    success: (response) => {
+                        // 假设后端响应的数据是一个数组,并将其赋值给list
+                        this.options2 = response.data;
+                    },
+                    error: (xhr, status, error) => {
+                        console.error('请求失败:', error);
+                        // 处理错误情况
+                    }
+                });
+                        this.value='';
+                        this.select = '';
+                        this.input = '';
+            },
+        },
+        mounted(){
+            $.ajax({
+                url: '/admin/energy_electricity/getDep', // 后端接口地址
+                type: 'POST',
+                // contentType: 'application/json',
+                data: {param:JSON.stringify(this.selectedValue)},
+                success: (response) => {
+                    // 假设后端响应的数据是一个数组,并将其赋值给list
+                    this.options2 = response.data;
+                    if (this.selectedValue == 0){
+                        this.options2 = [];
+                    }
+                },
+                error: (xhr, status, error) => {
+                    console.error('请求失败:', error);
+                    // 处理错误情况
+                }
+            });
+        }
+        // created(){
+        //     const vals = this.value;
+        //     this.value = [];
+        //     vals.forEach((item) => {
+        //         this.value.push(item.toString());
+        //     })
+        // }
+
+    })
+    $(document).ready(function(){
+        formSetValue("enable", {$info.enable|default=1});
+    });
+    window.addEventListener('touchstart',function () {
+    },{ passive: false });
+</script>
+{/block}

+ 37 - 0
application/admin/view/energy_gas/index.html

@@ -0,0 +1,37 @@
+{extend name="common/common2" /}
+{block name="main"}
+
+<div class="ibox">
+    <div class="ibox-title">
+        <h5>燃气表管理</h5>
+        <div  style="float: right;margin-right: 200px">
+            <a url="{:url('add',['pid'=>0])}" href="javascript:;" data-title="添加总表" onclick="layer_open(this,2)"><span class="label label-info" title="添加总表">添加总表</span></a>
+        </div>
+    </div>
+    <div class="ibox-content">
+        <table class="table table-striped">
+            <thead>
+            <tr>
+                <th>编号</th>
+                <th>表名</th>
+                <th>表号</th>
+                <th>备注</th>
+                <th>状态</th>
+                <th>燃气表类型</th>
+                <th>操作</th>
+            </tr>
+            </thead>
+            <tbody>
+            {if condition="$tree"}
+            {:widget_view('energy_gas/tree',['data'=>$tree,'depth'=>0])}
+            {/if}
+            </tbody>
+        </table>
+    </div>
+</div>
+{/block}
+{block name="script"}
+<script>
+
+</script>
+{/block}

+ 75 - 0
application/admin/view/energy_gas/split.html

@@ -0,0 +1,75 @@
+{extend name="common/common2" /}
+{block name="main"}
+<style>
+    /*.el-select .el-input {*/
+    /*    width: 130px;*/
+    /*}*/
+    .input-with-select .el-input-group__prepend {
+        background-color: #fff;
+    }
+
+</style>
+<div class="row" id="formApp">
+    <div class="col-sm-12">
+        <div class="ibox float-e-margins">
+            <div class="ibox-content">
+                <form method="post" action="{:url('split')}" class="form-horizontal">
+                    <input type="hidden" name="id" value="{$id|default='0'}">
+
+                    <div class="form-group">
+                        <label class="col-sm-2 control-label">拆分燃气表<span class="text-danger">*</span></label>
+                        <input type="hidden" id="ele-split" name="split" :value="value">
+                        <div class="col-sm-6">
+                            <el-select
+                                    v-model="value"
+                                    multiple
+                                    filterable
+                                    size="small"
+                                    style="width:100%"
+                                    placeholder="请选择拆分的燃气表"
+                            >
+                                <el-option
+                                        v-for="item in options"
+                                        :key="item.id"
+                                        :label="item.number"
+                                        :value="item.id">
+                                </el-option>
+                            </el-select>
+                        </div>
+                    </div>
+
+                    <div class="hr-line-dashed"></div>
+                    <div class="form-group">
+                        <div class="col-sm-6 col-sm-offset-2">
+                            <button class="btn btn-primary ajax-post" data-layer="1" target-form="form-horizontal" type="submit">确 定</button>
+                        </div>
+                    </div>
+                </form>
+            </div>
+        </div>
+    </div>
+</div>
+{/block}
+{block name="script"}
+<script>
+    $('#patient').hide();
+    new Vue({
+        el: '#formApp',
+        data: function() {
+            return {
+                options: {:json_encode($list)},
+            value: [{$info.split|default=''}],
+        }
+        },
+        methods: {
+
+        },
+        mounted(){
+
+        }
+
+    })
+    window.addEventListener('touchstart',function () {
+    },{ passive: false });
+</script>
+{/block}

+ 43 - 0
application/admin/view/energy_gas/tree.html

@@ -0,0 +1,43 @@
+{volist name="data" id="v"}
+<tr>
+    <td style="width: 60px;">{$v.id}</td>
+    <td style="text-indent:{$depth * 2}em;">
+        {if condition="isset($v['children']) && !empty($v['children'])"}
+        <i class="glyphicon glyphicon-folder-open"></i>
+        {else /}
+        <i class="glyphicon glyphicon-list-alt"></i>
+        {/if}
+        {$v.name}
+    </td>
+    <td style="width: 110px;">{$v.number}</td>
+    <td style="width: 110px;">{$v.remark}</td>
+    <td style="width: 80px;">
+        {if condition="$v['enable'] == 0"}
+        <a href="{:url('changeEnable',['id'=>$v['id'],'enable'=>1])}" data-confirm="确定要启用该记录吗?" class="ajax-get confirm data-reload"><span class="label label-danger" title="禁用">禁用</span></a>
+        {else /}
+        <a href="{:url('changeEnable',['id'=>$v['id'],'enable'=>0])}" data-confirm="确定要禁用该记录吗?" class="ajax-get confirm data-reload"><span class="label label-warning" title="启用">启用</span></a>
+        {/if}
+    </td>
+    <td style="width: 80px;">
+        {if condition="$v['parent_id'] == 0"}
+            总表
+        {else/}
+            分表
+        {/if}
+    </td>
+    <td style="width: 300px;">
+        <a url="{:url('add',['id'=>$v['id'],'pid'=>$v['parent_id'],'t'=>1])}" href="javascript:;" data-title="编辑" onclick="layer_open(this,2)"><span class="label label-other" title="编辑">编辑</span></a>
+        <a url="{:url('add',['pid'=>$v['id']])}" href="javascript:;" data-title="添加子燃气表" onclick="layer_open(this,2)"><span class="label label-info" title="添加子燃气表">添加子燃气表</span></a>
+        {if condition="$v['parent_id'] != 0"}
+        <a url="{:url('split',['id'=>$v['id']])}" href="javascript:;" data-title="拆分燃气表" data-width="70%" data-height="70%" onclick="layer_open(this,2)"><span class="label label-primary" title="拆分燃气表">拆分燃气表</span></a>
+        {/if}
+        {if condition="$v['parent_id'] == 0"}
+        <a href="{:url('change',['sn'=>$v['number']])}"  data-confirm="换表后新表将会自动追加旧抄表读数" class="ajax-get confirm"><span class="label label-primary" title="换表">换表</span></a>
+        {/if}
+        <a href="{:url('del',['id'=>$v['id']])}" { data-confirm="确定要删除该记录吗?" class="ajax-get confirm"><span class="label label-danger" title="删除">删除</span></a>
+    </td>
+</tr>
+{if condition="isset($v['children']) && !empty($v['children'])"}
+{:widget_view('energy_gas/tree',['data'=>$v['children'],'depth'=>$depth + 1])}
+{/if}
+{/volist}

+ 79 - 0
application/admin/view/energy_gas_record/add.html

@@ -0,0 +1,79 @@
+{extend name="common/common2" /}
+{block name="main"}
+<div class="row">
+    <div class="col-sm-12">
+        <div class="ibox float-e-margins">
+            <div class="ibox-content">
+                <form method="post" action="{:url('add')}" class="form-horizontal">
+                    <input type="hidden" name="id" value="{$info['id']|default='0'}">
+                    <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="sn" value="{$info.sn|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">
+                            <input type="number" class="form-control" name="degree" value="{$info.degree|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">
+                           <input class="form-control " id="readTime" name="read_time" type="text" value="{$info.read_time|default=''}"  />
+                        </div>
+                    </div>
+
+                    <div class="form-group">
+                        <label class="col-sm-2 control-label">录入当天最低温度(℃)</label>
+                        <div class="col-sm-6">
+                            <input type="number" class="form-control" name="min_temperature" value="{$info.min_temperature|default=''}">
+                        </div>
+                    </div>
+
+                    <div class="form-group">
+                        <label class="col-sm-2 control-label">录入当天最高温度(℃)</label>
+                        <div class="col-sm-6">
+                            <input type="number" class="form-control" name="max_temperature" value="{$info.max_temperature|default=''}">
+                        </div>
+                    </div>
+
+                    <div class="form-group">
+                        <label class="col-sm-2 control-label">床位数量</label>
+                        <div class="col-sm-6">
+                            <input type="number" class="form-control" name="beds" value="{$info.beds|default=''}">
+                        </div>
+                    </div>
+
+                    <div class="hr-line-dashed"></div>
+                    <div class="form-group">
+                        <div class="col-sm-6 col-sm-offset-2">
+                            <button class="btn btn-primary ajax-post" data-layer="1" target-form="form-horizontal" type="submit" data-date-format="yyyy-mm-dd">确 定</button>
+                            <button  class="btn cancel-btn btn-default" type="button">取 消</button>
+                        </div>
+                    </div>
+                </form>
+            </div>
+        </div>
+    </div>
+</div>
+{/block}
+{block name="script"}
+<script>
+    $(function () {
+        laydate.render({
+            elem: '#readTime',
+            trigger: 'click',
+            theme: '#0F3A87',
+        });
+    });
+    $(document).ready(function(){
+        formSetValue("enable", {$info.enable|default=1});
+    });
+
+
+</script>
+{/block}

+ 35 - 0
application/admin/view/energy_gas_record/import.html

@@ -0,0 +1,35 @@
+{extend name="common/common2" /}
+{block name="main"}
+<div class="row">
+    <div class="col-sm-12">
+        <div class="ibox float-e-margins">
+            <div class="ibox-content">
+                <form method="post"  action="importexcel"  enctype="multipart/form-data" class="form-horizontal">
+                    <div class="form-group">
+                        <label class="col-sm-2 control-label">选择文件(支持:xls,xlsx)<span class="text-danger">*</span></label>
+                        <div class="col-sm-6">
+                            <input type="file" name="file" id="file" class="form-control" value="" accept=".xls,.xlsx">
+                        </div>
+                    </div>
+
+                    <div class="hr-line-dashed"></div>
+                    <div class="form-group">
+                        <div class="col-sm-6 col-sm-offset-2">
+                            <button class="btn btn-sm btn-primary" type="submit">确定导入</button>
+                            <a href="downloadtem" class="btn btn-sm btn-danger">下载模板</a>
+                        </div>
+                    </div>
+                </form>
+            </div>
+        </div>
+    </div>
+</div>
+{/block}
+{block name="script"}
+<script>
+    $(document).ready(function(){
+        formSetValue("enable", {$info.enable|default=1});
+    });
+
+</script>
+{/block}

+ 150 - 0
application/admin/view/energy_gas_record/index.html

@@ -0,0 +1,150 @@
+{extend name="common/common2" /}
+{block name="main"}
+
+<div class="ibox">
+    <div class="ibox-content">
+        <div class="row">
+            <div class="col-xs-3">
+                <a href="javascript:;" url="{:url('add')}" data-title="新增" onclick="layer_open(this,1)" class="btn btn-sm btn-success">新增</a>
+                <a  href="javascript:;" id="js" class="btn btn-sm btn-danger">批量删除</a>
+            </div>
+            <div class="col-xs-9" style="text-align: right;">
+                <form class="form-inline" id="form-search" action="{:url('index')}">
+<!--                    <div class="input-group" style="width: 200px">-->
+<!--                        <span class="input-group-addon">开始时间</span>-->
+<!--                        <input class="form-control dialog-datetime" id="startTime" name="start" type="text" data-date-format="yyyy-mm-dd" value="" placeholder="录入时间" />-->
+<!--                    </div>-->
+<!--                    <div class="input-group" style="width: 200px">-->
+<!--                        <span class="input-group-addon">结束时间</span>-->
+<!--                        <input class="form-control dialog-datetime" id="endTime" name="end" type="text" data-date-format="yyyy-mm-dd" value="" placeholder="录入时间" />-->
+<!--                    </div>-->
+                    <div class="input-group">
+                        <input type="text" class="form-control" name="sn" placeholder="燃气表号">
+                    </div>
+                    <div class="input-group">
+                        <span class="input-group-btn">
+                            <button class="btn-sm btn-danger" type="button" id ="search-btn" ><i class="fa fa-search"></i></button>
+                        </span>
+                        &nbsp;
+                        <span class="input-group-btn">
+                            <button class="btn-sm btn-warning " type="button" id="search-clear"><i class="fa fa-undo"></i></button>
+                        </span>
+                        &nbsp;
+                        <span class="input-group-btn">
+                        <button class="btn-sm btn-other" type="button" url="{:url('import')}" data-title="批量导入" onclick="layer_open(this,1)">批量导入</button>
+                        </span>
+                    </div>
+                </form>
+            </div>
+        </div>
+
+    </div>
+    <div class="ibox-content">
+        <div class="jqGrid_wrapper">
+            <table id="table" style="border-collapse: collapse"></table>
+            <div id="pager"></div>
+        </div>
+    </div>
+</div>
+{/block}
+{block name="script"}
+<script>
+    $(function () {
+        laydate.render({
+            elem: '#startTime',
+            trigger: 'click',
+            theme: '#0F3A87'
+        });
+        laydate.render({
+            elem: '#endTime',
+            trigger: 'click',
+            theme: '#0F3A87'
+        });
+    });
+    $(function () {
+
+        $(window).bind("resize",function(){
+            var width=$(".jqGrid_wrapper").width();
+            $("#table").setGridWidth(width);
+        });
+
+        $.jgrid.defaults.styleUI="Bootstrap";
+        $("#table").jqGrid({
+            url:"{:url('index')}",
+            datatype: "json",
+            colModel:[
+                {label:'序号',name:'id',index:'id', width:20,sortable: true},
+                {label:'表号',name:'sn',index:'sn', width:40,sortable: false},
+                {label:'抄表读数',name:'degree',index:'degree', width:40,sortable: false},
+                {label:'抄表时间',name:'read_time',index:'read_time',width:40,sortable: true},
+                {label:'录入人',name:'user_id',index:'user_id',width:40,sortable: false},
+                {label:'录入时间',name:'create_time',index:'create_time', width:60,sortable: true},
+                {label:'最低温度(℃)',name:'min_temperature',index:'min_temperature', width:40,sortable: false},
+                {label:'最高温度(℃)',name:'max_temperature',index:'max_temperature', width:40,sortable: false},
+                {label:'床位数量',name:'beds',index:'beds', width:40,sortable: false},
+                {label:'更新时间',name:'update_time',index:'update_time', width:60,sortable: true},
+                {label:'操作',width:60,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="编辑" onclick="layer_open(this,1)"><span class="label label-other" title="编辑">编辑</span></a>&nbsp;';
+                        btn += '<a 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;
+                    }},
+            ],
+            rowNum:10,
+            rowList:[10,20,30,50,100],
+            pager: '#pager',
+            sortname: 'id',
+            viewrecords: true,
+            autowidth:true,
+            mtype: 'post',
+            height: 'auto',
+            emptyrecords: "暂无数据",
+            sortorder: "desc",
+            caption:"{$meta_title}",
+            multiselect: true,//可多选
+            loadComplete: function (xhr) {
+                if(xhr.code==0){
+                    layer.msg(xhr.msg);
+                    return false;
+                }
+            },
+        });
+
+    });
+    $('#js').click(function () {
+        var rowIds = jQuery("#table").jqGrid('getGridParam', 'selarrrow');    //获取勾选记录的ID
+        if(rowIds.length <=0){
+            updateAlert('请选择记录','alert-danger');
+            setTimeout(function(){
+                $('#top-alert').find('button').click();
+            },1500);
+            return;
+        }
+
+        layer.confirm('确定批量删除记录?(此方法不可逆,谨慎操作)', {
+            icon: 3,
+            btn: ['确定', '取消'],
+            skin: 'layer-ext-moon'
+        }, function(index) {
+            layer.close(layer.index);
+            $.post('{:url("multiDel")}',{ids:rowIds},function (res) {
+                if(res.code==0){
+                    updateAlert(res.msg,'alert-danger');
+                    setTimeout(function(){
+                        $('#top-alert').find('button').click();
+                    },1500);
+                    // window.location.reload();
+                }else {
+                    updateAlert(res.msg,'alert-success');
+                    setTimeout(function(){
+                        $('#top-alert').find('button').click();
+                        $("#table").trigger("reloadGrid");
+                    },1500);
+
+                }
+            })
+        });
+    })
+</script>
+{/block}

+ 84 - 0
application/admin/view/energy_record_warning/index.html

@@ -0,0 +1,84 @@
+{extend name="common/common2" /}
+{block name="main"}
+
+<div class="ibox">
+    <div class="ibox-content">
+        <div class="row">
+            <div class="col-xs-3">
+                <form class="form-inline" id="form-search" action="{:url('index')}">
+                    <div class="input-group ">
+                        <select name="type" class="form-control">
+                            <option value="">预警类型</option>
+                            <option value="0">低值预警</option>
+                            <option value="1">高值预警</option>
+                        </select>
+                    </div>
+                    <div class="input-group">
+                    <span class="input-group-btn">
+                        <button class="btn-sm btn-danger" type="button" id ="search-btn" ><i class="fa fa-search"></i></button>
+                    </span> &nbsp;
+                        <span class="input-group-btn">
+                        <button class="btn-sm btn-warning" type="button" id="search-clear"><i class="fa fa-undo"></i></button>
+                    </span>
+                    </div>
+                </form>
+            </div>
+        </div>
+    </div>
+    <div class="ibox-content">
+        <div class="jqGrid_wrapper">
+            <table id="table" style="border-collapse: collapse"></table>
+            <div id="pager"></div>
+        </div>
+    </div>
+</div>
+{/block}
+{block name="script"}
+<script>
+    $(function () {
+
+        $(window).bind("resize",function(){
+            var width=$(".jqGrid_wrapper").width();
+            $("#table").setGridWidth(width);
+        });
+
+        $.jgrid.defaults.styleUI="Bootstrap";
+        $("#table").jqGrid({
+            url:"{:url('index')}",
+            datatype: "json",
+            colModel:[
+                {label:'ID',name:'id',index:'id', width:20,sortable: false},
+                {label:'表号',name:'sn',index:'sn',width:60,editable: false,sortable: false},
+                {label:'预警信息',name:'content',index:'content',width:100,editable: false,sortable: false},
+                {label:'预警类型',name:'type',index:'type',width:30,editable: false,sortable: false,formatter:function (a,b,c){
+                        if(a == 0){
+                            return '<span class="label label-warning ">低值预警</span>';
+                        } else{
+                            return '<span class="label label-danger" >高值预警</span>';
+                        }
+                    }},
+                {label:'抄表时间',name:'read_time',index:'read_time',width:40,editable: false,sortable: false},
+                {label:'预警时间',name:'create_time',index:'create_time',width:40,editable: false,sortable: false},
+            ],
+            rowNum:10,
+            rowList:[10,20,30,50,100],
+            pager: '#pager',
+            sortname: 'sort',
+            viewrecords: true,
+            autowidth:true,
+            mtype: 'post',
+            height: 'auto',
+            emptyrecords: "暂无数据",
+            sortorder: "asc",
+            caption:"抄表记录预警",
+            loadComplete: function (xhr) {
+                if(xhr.code==0){
+                    layer.msg(xhr.msg);
+                    return false;
+                }
+            },
+        });
+    });
+
+</script>
+{/block}

+ 57 - 0
application/admin/view/energy_sort/add.html

@@ -0,0 +1,57 @@
+{extend name="common/common2" /}
+{block name="main"}
+<div class="row">
+    <div class="col-sm-12">
+        <div class="ibox float-e-margins">
+            <div class="ibox-content">
+                <form method="post" action="{:url('add')}" class="form-horizontal">
+                    <input type="hidden" name="id" value="{$info['id']|default='0'}">
+                    <div class="form-group">
+                        <label class="col-sm-2 control-label">名称</label>
+                        <div class="col-sm-4">
+                            <input type="text" class="form-control" name="name" value="{$info.name|default=''}">
+                        </div>
+                    </div>
+
+                    <div class="form-group">
+                        <label class="col-sm-2 control-label">排序</label>
+                        <div class="col-sm-4">
+                            <input type="number" class="form-control" name="sort" value="{$info.sort|default='0'}">
+                        </div>
+                    </div>
+
+                    <div class="form-group">
+                        <label class="col-sm-2 control-label">状态</label>
+                        <div class="col-sm-4">
+                            <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="hr-line-dashed"></div>
+                    <div class="form-group">
+                        <div class="col-sm-4 col-sm-offset-2">
+                            <button class="btn btn-primary ajax-post"  data-layer_c="1" target-form="form-horizontal" type="submit">确 定</button>
+                            <button class="btn cancel-btn btn-default" type="button">取 消</button>
+
+                        </div>
+                    </div>
+                </form>
+            </div>
+        </div>
+    </div>
+</div>
+{/block}
+{block name="script"}
+<script>
+    $(document).ready(function(){
+        formSetValue("pid", {$pid|default=0});
+        formSetValue("is_btn", {$info.is_btn|default=0});
+        formSetValue("enable", {$info.enable|default=1});
+    });
+
+</script>
+{/block}

+ 75 - 0
application/admin/view/energy_sort/index.html

@@ -0,0 +1,75 @@
+{extend name="common/common2" /}
+{block name="main"}
+
+<div class="ibox">
+    <div class="ibox-content">
+
+        <a url="{:url('add')}"  href="javascript:;" data-title="新增" onclick="layer_open(this,1)" class="btn btn-sm btn-success">新增</a>
+    </div>
+    <div class="ibox-content">
+        <div class="jqGrid_wrapper">
+            <table id="table" style="border-collapse: collapse"></table>
+            <div id="pager"></div>
+        </div>
+    </div>
+</div>
+{/block}
+{block name="script"}
+<script>
+    $(function () {
+
+        $(window).bind("resize",function(){
+            var width=$(".jqGrid_wrapper").width();
+            $("#table").setGridWidth(width);
+        });
+
+        $.jgrid.defaults.styleUI="Bootstrap";
+        $("#table").jqGrid({
+            url:"{:url('index')}",
+            datatype: "json",
+            colModel:[
+                {label:'ID',name:'id',index:'id', width:30,sortable: false},
+                {label:'名称',name:'name',index:'name',width:80,editable: false,sortable: false},
+                {label:'排序',name:'sort',index:'sort',width:40,sortable: true,formatter: function (a, b, c) {
+                        return '<input type="number" onchange="updateSort(this)" data-url="{:url('changeSort')}" class="form-control input-sm" data-id="'+c.id+'" data-old="'+a+'" value="'+a+'" />';
+                    }},
+                {label:'状态',name:'enable',index:'enable',width:50,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-success" title="正常">正常</span></a>';
+                        }
+                    }},
+                {label:'操作',width:100,sortable: false,formatter: function (a, b, c) {
+                        var editurl = "{:url('add',[],'')}/id/"+c.id+"/pid/"+c.pid;
+                        var delurl = "{:url('del',[],'')}/id/"+c.id;
+                        var  btn= '<a url="'+editurl+'" href="javascript:;" data-title="编辑" onclick="layer_open(this,1)"><span class="label label-other" title="编辑">编辑</span></a>&nbsp;';
+
+                        btn += '<a href="'+delurl+'" class="confirm ajax-get" data-confirm="确定要删除此记录吗?" data-table="1"><span class="label label-danger" title="删除">删除</span></a>';
+                        return btn;
+                    }},
+            ],
+            rowNum:10,
+            rowList:[10,20,30,50,100],
+            pager: '#pager',
+            sortname: 'sort',
+            viewrecords: true,
+            autowidth:true,
+            mtype: 'post',
+            height: 'auto',
+            emptyrecords: "暂无数据",
+            sortorder: "asc",
+            caption:"用电分类列表",
+            loadComplete: function (xhr) {
+                if(xhr.code==0){
+                    layer.msg(xhr.msg);
+                    return false;
+                }
+            },
+        });
+    });
+
+</script>
+{/block}

+ 149 - 0
application/admin/view/energy_statistics/daily_electricity.html

@@ -0,0 +1,149 @@
+{extend name="common/common2" /}
+{block name="main"}
+<style>
+    .table th{
+        text-align: center;
+        background: #ffffff;
+    }
+    .table tr{
+        background: #ffffff;
+    }
+    .table td{
+        text-align: center;
+    }
+</style>
+<div class="ibox-content">
+<div class="ibox">
+
+    <div class="alert">
+        <form action="dailyElectricity" method="GET" id='search_form' class="form-inline">
+            <div class="input-group" style="width: 200px">
+                <span class="input-group-addon">选择日期</span>
+                <input class="form-control dialog-datetime" id="startTime" name="start" type="text" data-date-format="yyyy-mm-dd" value="{$start}" placeholder="" readonly/>
+            </div>
+
+            <div class="input-group">
+            <span class="input-group-btn">
+                <button class="btn-sm btn-danger" type="submit"  ><i class="fa fa-search"></i></button>
+			</span>&nbsp;
+                <span class="input-group-btn">
+                     <button class="btn-sm btn-warning" type="reset" onclick="empty_search()"><i class="fa fa-undo"></i></button>
+            </span>
+            </div>
+        </form>
+    </div>
+
+    <div class="panel-group">
+        <div class="panel panel-default">
+            <div class="panel-heading clearfix">
+                <div class="btn-group pull-left">
+                    医院每日总电表数据统计
+                </div>
+                <div class="btn-group pull-right">
+                    <a href="javascript:;" onclick="printer()" class="btn btn-sm btn btn-primary"><i class="glyphicon glyphicon-print"></i>打印</a>
+                    <a href="javascript:;" onclick="excel_download(this)" class="btn btn-other btn-sm"><i class="glyphicon glyphicon-download"></i>导出</a>
+                </div>
+            </div>
+            <div class="panel-body" id="printer">
+                <table class="table table-bordered">
+
+                    <thead>
+                    <tr hidden><td colspan="5"><h1  style="text-align: center">医院每日总电表数据统计</h1></td></tr>
+                    <tr hidden><td colspan="5"><h3 style="float: right">{$date}</h3></td></tr>
+                        <tr>
+                            <th >日期</th>
+                            <th >表号</th>
+                            <th >倍率</th>
+                            <th >使用量</th>
+                            <th >合计使用量</th>
+                        </tr>
+                    </thead>
+                    {if $totalData == 0}
+                    <tbody>
+                        <tr>
+                            <td colspan="5">暂无数据</td>
+                        </tr>
+                    </tbody>
+                    {else/}
+                    <tbody>
+                        <!-- 下面注释不能删除!!! -->
+<!--                        {$rowNumber = 1}-->
+                        {foreach $data as $k=>$v}
+                        {for start="0" end="$count"}
+                        {if $rowNumber % $count == 1 || $count == 1}
+                        <tr>
+                            <td rowspan="{$count}">{$k+1}</td>
+                            <td>{$v[$i]['sn']|default=''}</td>
+                            <td>{$v[$i]['rate']|default=''}</td>
+                            <td>{$v[$i]['real_degree']|default=''}</td>
+                            <td rowspan="{$count}">
+                                {$v.total}
+                            </td>
+                            {else /}
+                        <tr>
+                            <td>{$v[$i]['sn']|default=''}</td>
+                            <td>{$v[$i]['rate']|default=''}</td>
+                            <td>{$v[$i]['real_degree']|default=''}</td>
+                            {/if}
+                            <!-- 下面注释不能删除!!! -->
+<!--                            {$rowNumber = $rowNumber + 1}-->
+                        </tr>
+                        {if $rowNumber % $count == 0}
+                        <!-- 重置总使用量 -->
+                        {/if}
+                        {/for}
+                        {/foreach}
+                            <tr>
+                                <td>共计:</td>
+                                <td colspan="4">{$totalData}</td>
+                            </tr>
+                    </tbody>
+                    {/if}
+                </table>
+            </div>
+        </div>
+    </div>
+</div>
+</div>
+{/block}
+{block name="script"}
+<script src="/static/layDate-v5.0.9/laydate.js"></script>
+<script src="/static/browser.js"></script>
+<script src="/static/jquery.jqprint-0.3.js"></script>
+<script>
+    $(function () {
+        laydate.render({
+            elem: '#startTime',
+            trigger: 'click',
+            theme: '#0F3A87',
+            type:'month'
+        });
+        laydate.render({
+            elem: '#endTime',
+            trigger: 'click',
+            theme: '#0F3A87'
+        });
+    });
+    function empty_search(){
+        window.location.href = 'dailyElectricity';
+    }
+    function printer(){
+        $('#printer').jqprint();
+    }
+
+    function excel_download(_self){
+        $("#printer").table2excel({
+            //      table2excel插件的可用配置参数有:
+            exclude: ".noExl",//   exclude:不被导出的表格行的CSS class类。
+            name: "医院每日总电表数据",//   name:导出的Excel文档的名称
+            filename: "医院每日总电表数据",//   filename:Excel文件的名称。
+            exclude_img: true,//   exclude_img:是否导出图片。
+            exclude_links: true,//   exclude_links:是否导出超链接
+            exclude_inputs: true//    exclude_inputs:是否导出输入框中的内容
+
+
+        });
+    }
+
+</script>
+{/block}

+ 146 - 0
application/admin/view/energy_statistics/daily_gas.html

@@ -0,0 +1,146 @@
+{extend name="common/common2" /}
+{block name="main"}
+<style>
+    .table th{
+        text-align: center;
+        background: #ffffff;
+    }
+    .table tr{
+        background: #ffffff;
+    }
+    .table td{
+        text-align: center;
+    }
+</style>
+<div class="ibox-content">
+<div class="ibox">
+
+    <div class="alert">
+        <form action="dailyGas" method="GET" id='search_form' class="form-inline">
+            <div class="input-group" style="width: 200px">
+                <span class="input-group-addon">选择日期</span>
+                <input class="form-control dialog-datetime" id="startTime" name="start" type="text" data-date-format="yyyy-mm-dd" value="{$start}" placeholder="" readonly/>
+            </div>
+
+            <div class="input-group">
+            <span class="input-group-btn">
+                <button class="btn-sm btn-danger" type="submit"  ><i class="fa fa-search"></i></button>
+			</span>&nbsp;
+                <span class="input-group-btn">
+                     <button class="btn-sm btn-warning" type="reset" onclick="empty_search()"><i class="fa fa-undo"></i></button>
+            </span>
+            </div>
+        </form>
+    </div>
+
+    <div class="panel-group">
+        <div class="panel panel-default">
+            <div class="panel-heading clearfix">
+                <div class="btn-group pull-left">
+                    医院每日总气体数据统计
+                </div>
+                <div class="btn-group pull-right">
+                    <a href="javascript:;" onclick="printer()" class="btn btn-sm btn btn-primary"><i class="glyphicon glyphicon-print"></i>打印</a>
+                    <a href="javascript:;" onclick="excel_download(this)" class="btn btn-other btn-sm"><i class="glyphicon glyphicon-download"></i>导出</a>
+                </div>
+            </div>
+            <div class="panel-body" id="printer">
+                <table class="table table-bordered">
+
+                    <thead>
+                    <tr hidden><td colspan="5"><h1  style="text-align: center">医院每日总电表数据统计</h1></td></tr>
+                    <tr hidden><td colspan="5"><h3 style="float: right">{$date}</h3></td></tr>
+                        <tr>
+                            <th >日期</th>
+                            <th >表号</th>
+                            <th >使用量</th>
+                            <th >合计使用量</th>
+                        </tr>
+                    </thead>
+                    {if $totalData == 0}
+                    <tbody>
+                        <tr>
+                            <td colspan="5">暂无数据</td>
+                        </tr>
+                    </tbody>
+                    {else/}
+                    <tbody>
+                        <!-- 下面注释不能删除!!! -->
+<!--                        {$rowNumber = 1}-->
+                        {foreach $data as $k=>$v}
+                        {for start="0" end="$count"}
+                        {if $rowNumber % $count == 1 || $count == 1}
+                        <tr>
+                            <td rowspan="{$count}">{$k+1}</td>
+                            <td>{$v[$i]['sn']|default=''}</td>
+                            <td>{$v[$i]['real_degree']|default=''}</td>
+                            <td rowspan="{$count}">
+                                {$v.total}
+                            </td>
+                            {else /}
+                        <tr>
+                            <td>{$v[$i]['sn']|default=''}</td>
+                            <td>{$v[$i]['real_degree']|default=''}</td>
+                            {/if}
+                            <!-- 下面注释不能删除!!! -->
+<!--                            {$rowNumber = $rowNumber + 1}-->
+                        </tr>
+                        {if $rowNumber % $count == 0}
+                        <!-- 重置总使用量 -->
+                        {/if}
+                        {/for}
+                        {/foreach}
+                            <tr>
+                                <td>共计:</td>
+                                <td colspan="4">{$totalData}</td>
+                            </tr>
+                    </tbody>
+                    {/if}
+                </table>
+            </div>
+        </div>
+    </div>
+</div>
+</div>
+{/block}
+{block name="script"}
+<script src="/static/layDate-v5.0.9/laydate.js"></script>
+<script src="/static/browser.js"></script>
+<script src="/static/jquery.jqprint-0.3.js"></script>
+<script>
+    $(function () {
+        laydate.render({
+            elem: '#startTime',
+            trigger: 'click',
+            theme: '#0F3A87',
+            type:'month'
+        });
+        laydate.render({
+            elem: '#endTime',
+            trigger: 'click',
+            theme: '#0F3A87'
+        });
+    });
+    function empty_search(){
+        window.location.href = 'dailyGas';
+    }
+    function printer(){
+        $('#printer').jqprint();
+    }
+
+    function excel_download(_self){
+        $("#printer").table2excel({
+            //      table2excel插件的可用配置参数有:
+            exclude: ".noExl",//   exclude:不被导出的表格行的CSS class类。
+            name: "医院每日总水表数据",//   name:导出的Excel文档的名称
+            filename: "医院每日总水表数据",//   filename:Excel文件的名称。
+            exclude_img: true,//   exclude_img:是否导出图片。
+            exclude_links: true,//   exclude_links:是否导出超链接
+            exclude_inputs: true//    exclude_inputs:是否导出输入框中的内容
+
+
+        });
+    }
+
+</script>
+{/block}

+ 451 - 0
application/admin/view/energy_statistics/daily_view.html

@@ -0,0 +1,451 @@
+{extend name="common/common2" /}
+{block name="main"}
+<div class="ibox-content">
+    <div class="row">
+        <div class="col-xs-12" >
+            <form action="{:url('energyStatistics/dailyView')}" method="POST" id='search_form' class="form-inline">
+
+                <div class="input-group" style="width: 200px">
+                    <span class="input-group-addon">月份</span>
+                    <input class="form-control dialog-datetime" id="start" name="month" type="text" data-date-format="yyyy-mm" value="{$month}" placeholder="" readonly/>
+                </div>
+                <div class="input-group">
+                    <span class="input-group-btn">
+                        <button class="btn-sm btn-danger" type="submit"  ><i class="fa fa-search"></i></button>
+                    </span>&nbsp;
+                        <span class="input-group-btn">
+                         <button class="btn-sm btn-warning" type="reset" onclick="empty_search()"><i class="fa fa-undo"></i></button>
+                    </span>
+                </div>
+            </form>
+        </div>
+    </div>
+    <br>
+<div class="ibox">
+    <div class="panel-group">
+        <div class="panel panel-default">
+            <div class="panel-heading clearfix">
+                <div class="btn-group pull-left">
+                    医院每日能耗数据分析
+                </div>
+                <div class="btn-group pull-right">
+<!--                    <a href="javascript:;" onclick="printer()" class="btn btn-sm btn btn-primary"><i class="glyphicon glyphicon-print"></i>打印</a>-->
+                </div>
+            </div>
+            <div class="panel-body" id="printer">
+
+                <div id="echarts1" style="width: 100%;height: 350px">
+
+                </div>
+                <div id="echarts2" style="width: 100%;height: 350px">
+
+                </div>
+                <div id="echarts3" style="width: 100%;height: 350px">
+
+                </div>
+
+            </div>
+        </div>
+    </div>
+</div>
+</div>
+{/block}
+{block name="script"}
+<script src="/static/browser.js"></script>
+<script src="/static/jquery.jqprint-0.3.js"></script>
+<script src="/static/data/js/echarts.js"></script>
+<script>
+    $(function () {
+        laydate.render({
+            elem: '#start',
+            trigger: 'click',
+            theme: '#1d519c',
+            type: 'month',
+        });
+    });
+    function printer(){
+        $('#printer').jqprint();
+    }
+
+    function empty_search(){
+        window.location.href = "{:url('energyStatistics/dailyView')}";
+    }
+
+    var colors = [ '#d14a61','#5793f3', '#91c7ae'];
+
+    var option = {
+        // dataZoom: [{
+        //     type: 'slider',
+        //     start: 0,
+        //     end: 100
+        // }, {
+        //     type: 'inside',
+        //     start: 0,
+        //     end: 100
+        // }],
+        tooltip: {
+            trigger: 'axis',
+            axisPointer: {
+                type: 'cross',
+                crossStyle: {
+                    color: '#999'
+                }
+            }
+        },
+        legend: {
+            data: ['{$year-1}用电量', '{$year}用电量', '{$year}最高温度','{$year}最低温度','{$year-1}最高温度','{$year-1}最低温度','床位数量']
+        },
+        xAxis: [
+            {
+                type: 'category',
+                data: {:json_encode($date['md'])},
+        axisPointer: {
+            type: 'shadow'
+        }
+    }
+    ],
+    yAxis: [
+        {
+            type: 'value',
+            name: '使用量',
+            offset: 5,
+            splitLine:{
+                show:false
+            },
+            axisLine: {
+                show: true,
+                lineStyle: {
+                    color: colors[0],
+                }
+            },
+            axisLabel: {
+                formatter: '{value} kWh'
+            }
+        },
+        {
+            type: 'value',
+            name: '温度',
+            splitLine:{
+                show:false
+            },
+            axisLine: {
+                show: true,
+                lineStyle: {
+                    color: colors[1],
+                }
+            },
+            axisLabel: {
+                formatter: '{value} ℃'
+            }
+        },
+        {
+            type: 'value',
+            name: '床位数量',
+            position: 'right',
+            alignTicks: true,
+            offset: 60,
+            splitLine:{
+                show:false
+            },
+            axisLine: {
+                show: true,
+                lineStyle: {
+                    color: colors[2],
+                }
+            },
+            axisLabel: {
+                formatter: '{value} 个'
+            }
+        }
+    ],
+        series: [
+        {
+            name: '{$year-1}用电量',
+            type: 'bar',
+            barWidth: 12,
+            data: {:json_encode($data['lastElectricity'])},
+    },
+    {
+        name: '{$year}用电量',
+        type: 'bar',
+        barWidth: 12,
+        data: {:json_encode($data['electricity'])},
+    },
+    {
+        name: '{$year}最高温度',
+        type: 'line',
+        yAxisIndex: 1,
+        data: {:json_encode($data['electricityTempMax'])},
+    },
+    {
+        name: '{$year}最低温度',
+        type: 'line',
+        yAxisIndex: 1,
+        data: {:json_encode($data['electricityTempMin'])},
+    },
+    {
+        name: '{$year-1}最高温度',
+            type: 'line',
+        yAxisIndex: 1,
+        data: {:json_encode($data['LastElectricityTempMax'])},
+        lineStyle: {
+            type: 'dashed'
+        },
+    },
+    {
+        name: '{$year-1}最低温度',
+        type: 'line',
+        yAxisIndex: 1,
+        data: {:json_encode($data['LastElectricityTempMin'])},
+        lineStyle: {
+            type: 'dashed'
+        },
+        itemStyle: {
+            color: '#5470C6' // 绿色
+        }
+    },
+    {
+        name: '床位数量',
+        type: 'line',
+        yAxisIndex: 2,
+        data: {:json_encode($data['electricityBeds'])},
+        itemStyle: {
+            color: '#ee6666' // 绿色
+        }
+    },
+    ]
+    };
+
+    var myChart = echarts.init(document.getElementById('echarts1'));
+    myChart.setOption(option);
+
+
+    var option2 = {
+        tooltip: {
+            trigger: 'axis',
+            axisPointer: {
+                type: 'cross',
+                crossStyle: {
+                    color: '#999'
+                }
+            }
+        },
+        legend: {
+            data: ['{$year-1}用水量', '{$year}用水量', '最高温度','最低温度','床位数量']
+        },
+        xAxis: [
+            {
+                type: 'category',
+                data: {:json_encode($date['md'])},
+        axisPointer: {
+            type: 'shadow'
+        }
+    }
+    ],
+    yAxis: [
+        {
+            type: 'value',
+            name: '使用量',
+            offset: 5,
+            splitLine:{
+                show:false
+            },
+            axisLine: {
+                show: true,
+                lineStyle: {
+                    color: colors[0],
+                }
+            },
+            axisLabel: {
+                formatter: '{value} m³'
+            }
+        },
+        {
+            type: 'value',
+            name: '温度',
+            splitLine:{
+                show:false
+            },
+            axisLine: {
+                show: true,
+                lineStyle: {
+                    color: colors[1],
+                }
+            },
+            axisLabel: {
+                formatter: '{value} ℃'
+            }
+        },
+        {
+            type: 'value',
+            name: '床位数量',
+            position: 'right',
+            alignTicks: true,
+            offset: 60,
+            splitLine:{
+                show:false
+            },
+            axisLine: {
+                show: true,
+                lineStyle: {
+                    color: colors[2],
+                }
+            },
+            axisLabel: {
+                formatter: '{value} 个'
+            }
+        }
+    ],
+        series: [
+        {
+            name: '{$year-1}用水量',
+            type: 'bar',
+            barWidth: 12,
+            data: {:json_encode($data['lastWater'])},
+    },
+    {
+        name: '{$year}用水量',
+            type: 'bar',
+        barWidth: 12,
+        data: {:json_encode($data['water'])},
+    },
+    {
+        name: '最高温度',
+        type: 'line',
+        yAxisIndex: 1,
+        data: {:json_encode($data['waterTempMax'])}
+    },
+    {
+        name: '最低温度',
+        type: 'line',
+        yAxisIndex: 1,
+        data: {:json_encode($data['waterTempMin'])}
+    },
+    {
+        name: '床位数量',
+            type: 'line',
+        yAxisIndex: 2,
+        data: {:json_encode($data['waterBeds'])}
+    },
+    ]
+    };
+
+    var myChart2 = echarts.init(document.getElementById('echarts2'));
+    myChart2.setOption(option2);
+
+
+    var option3 = {
+        tooltip: {
+            trigger: 'axis',
+            axisPointer: {
+                type: 'cross',
+                crossStyle: {
+                    color: '#999'
+                }
+            }
+        },
+        legend: {
+            data: ['{$year-1}燃气用量', '{$year}燃气用量', '最高温度','最低温度','床位数量']
+        },
+        xAxis: [
+            {
+                type: 'category',
+                data: {:json_encode($date['md'])},
+                axisPointer: {
+                    type: 'shadow'
+                }
+            }
+        ],
+        yAxis: [
+            {
+                type: 'value',
+                name: '使用量 ',
+                offset: 5,
+                splitLine:{
+                    show:false
+                },
+                axisLine: {
+                    show: true,
+                    lineStyle: {
+                        color: colors[0],
+                    }
+                },
+                axisLabel: {
+                    formatter: '{value} m³'
+                }
+            },
+            {
+                type: 'value',
+                name: '温度',
+                splitLine:{
+                    show:false
+                },
+                axisLine: {
+                    show: true,
+                    lineStyle: {
+                        color: colors[1],
+                    }
+                },
+                axisLabel: {
+                    formatter: '{value} ℃'
+                }
+            },
+            {
+                type: 'value',
+                name: '床位数量',
+                position: 'right',
+                alignTicks: true,
+                offset: 60,
+                splitLine:{
+                    show:false
+                },
+                axisLine: {
+                    show: true,
+                    lineStyle: {
+                        color: colors[2],
+                    }
+                },
+                axisLabel: {
+                    formatter: '{value} 个'
+                }
+            }
+        ],
+        series: [
+            {
+                name: '{$year-1}燃气用量',
+                type: 'bar',
+                barWidth: 12,
+                data: {:json_encode($data['lastGas'])},
+            },
+        {
+            name: '{$year}燃气用量',
+                type: 'bar',
+            barWidth: 12,
+            data: {:json_encode($data['gas'])},
+        },
+        {
+            name: '最高温度',
+            type: 'line',
+            yAxisIndex: 1,
+            data: {:json_encode($data['gasTempMax'])},
+        },
+        {
+            name: '最低温度',
+            type: 'line',
+            yAxisIndex: 1,
+            data: {:json_encode($data['gasTempMin'])},
+        },
+        {
+            name: '床位数量',
+            type: 'line',
+            yAxisIndex: 2,
+            data: {:json_encode($data['gasBeds'])},
+        },
+        ]
+    };
+
+    var myChart3 = echarts.init(document.getElementById('echarts3'));
+    myChart3.setOption(option3);
+
+</script>
+{/block}

+ 454 - 0
application/admin/view/energy_statistics/daily_view2.html

@@ -0,0 +1,454 @@
+{extend name="common/common2" /}
+{block name="main"}
+<div class="ibox-content">
+    <div class="row">
+        <div class="col-xs-12" >
+            <form action="{:url('energyStatistics/dailyView2')}" method="POST" id='search_form' class="form-inline">
+
+                <div class="input-group" style="width: 200px">
+                    <span class="input-group-addon">年份</span>
+                    <input class="form-control dialog-datetime" id="start" name="month" type="text"  value="{$month}" placeholder="" readonly/>
+                </div>
+                <div class="input-group">
+                    <span class="input-group-btn">
+                        <button class="btn-sm btn-danger" type="submit"  ><i class="fa fa-search"></i></button>
+                    </span>&nbsp;
+                        <span class="input-group-btn">
+                         <button class="btn-sm btn-warning" type="reset" onclick="empty_search()"><i class="fa fa-undo"></i></button>
+                    </span>
+                </div>
+            </form>
+        </div>
+    </div>
+    <br>
+<div class="ibox">
+    <div class="panel-group">
+        <div class="panel panel-default">
+            <div class="panel-heading clearfix">
+                <div class="btn-group pull-left">
+                    医院每月能耗数据分析
+                </div>
+                <div class="btn-group pull-right">
+<!--                    <a href="javascript:;" onclick="printer()" class="btn btn-sm btn btn-primary"><i class="glyphicon glyphicon-print"></i>打印</a>-->
+                </div>
+            </div>
+            <div class="panel-body" id="printer">
+
+                <div id="echarts1" style="width: 100%;height: 350px">
+
+                </div>
+                <div id="echarts2" style="width: 100%;height: 350px">
+
+                </div>
+                <div id="echarts3" style="width: 100%;height: 350px">
+
+                </div>
+
+            </div>
+        </div>
+    </div>
+</div>
+</div>
+{/block}
+{block name="script"}
+<script src="/static/browser.js"></script>
+<script src="/static/jquery.jqprint-0.3.js"></script>
+<script src="/static/data/js/echarts.js"></script>
+<script>
+    $(function () {
+        laydate.render({
+            elem: '#start',
+            trigger: 'click',
+            theme: '#1d519c',
+            type: 'year',
+        });
+    });
+    function printer(){
+        $('#printer').jqprint();
+    }
+
+    function empty_search(){
+        window.location.href = "{:url('energyStatistics/dailyView2')}";
+    }
+
+    var colors = [ '#d14a61','#5793f3', '#91c7ae'];
+
+    var option = {
+        tooltip: {
+            trigger: 'axis',
+            axisPointer: {
+                type: 'cross',
+                crossStyle: {
+                    color: '#999'
+                }
+            }
+        },
+        legend: {
+            data: ['{$year-3}用电量','{$year-2}用电量','{$year-1}用电量', '{$year}用电量', '月度平均最高温度','月度平均最低温度','床位数量']
+        },
+        xAxis: [
+            {
+                type: 'category',
+                data: {:json_encode($date)},
+        axisPointer: {
+            type: 'shadow'
+        }
+    }
+    ],
+    yAxis: [
+        {
+            type: 'value',
+            name: '使用量',
+            offset: 5,
+            splitLine:{
+                show:false
+            },
+            axisLine: {
+                show: true,
+                lineStyle: {
+                    color: colors[0],
+                }
+            },
+            axisLabel: {
+                formatter: '{value} kWh'
+            }
+        },
+        {
+            type: 'value',
+            name: '温度',
+            splitLine:{
+                show:false
+            },
+            axisLine: {
+                show: true,
+                lineStyle: {
+                    color: colors[1],
+                }
+            },
+            axisLabel: {
+                formatter: '{value} ℃'
+            }
+        },
+        {
+            type: 'value',
+            name: '床位数量',
+            position: 'right',
+            alignTicks: true,
+            offset: 60,
+            splitLine:{
+                show:false
+            },
+            axisLine: {
+                show: true,
+                lineStyle: {
+                    color: colors[2],
+                }
+            },
+            axisLabel: {
+                formatter: '{value} 个'
+            }
+        }
+    ],
+        series: [
+        {
+            name: '{$year-3}用电量',
+            type: 'bar',
+            barWidth: 12,
+            data: {:json_encode($data['lastElectricity3'])},
+    },
+    {
+        name: '{$year-2}用电量',
+            type: 'bar',
+        barWidth: 12,
+        data: {:json_encode($data['lastElectricity2'])},
+    },
+        {
+            name: '{$year-1}用电量',
+            type: 'bar',
+            barWidth: 12,
+            data: {:json_encode($data['lastElectricity'])},
+    },
+    {
+        name: '{$year}用电量',
+        type: 'bar',
+        barWidth: 12,
+        data: {:json_encode($data['electricity'])},
+    },
+    {
+        name: '月度平均最高温度',
+        type: 'line',
+        yAxisIndex: 1,
+        data: {:json_encode($data['electricityTempMax'])},
+    },
+    {
+        name: '月度平均最低温度',
+        type: 'line',
+        yAxisIndex: 1,
+        data: {:json_encode($data['electricityTempMin'])},
+    },
+    {
+        name: '床位数量',
+        type: 'line',
+        yAxisIndex: 2,
+        data: {:json_encode($data['electricityBeds'])},
+    },
+    ]
+    };
+
+    var myChart = echarts.init(document.getElementById('echarts1'));
+    myChart.setOption(option);
+
+
+    var option2 = {
+        tooltip: {
+            trigger: 'axis',
+            axisPointer: {
+                type: 'cross',
+                crossStyle: {
+                    color: '#999'
+                }
+            }
+        },
+        legend: {
+            data: ['{$year-3}用水量','{$year-2}用水量','{$year-1}用水量', '{$year}用水量', '月度平均最高温度','月度平均最低温度','床位数量']
+        },
+        xAxis: [
+            {
+                type: 'category',
+                data: {:json_encode($date)},
+        axisPointer: {
+            type: 'shadow'
+        }
+    }
+    ],
+    yAxis: [
+        {
+            type: 'value',
+            name: '使用量',
+            offset: 5,
+            splitLine:{
+                show:false
+            },
+            axisLine: {
+                show: true,
+                lineStyle: {
+                    color: colors[0],
+                }
+            },
+            axisLabel: {
+                formatter: '{value} m³'
+            }
+        },
+        {
+            type: 'value',
+            name: '温度',
+            splitLine:{
+                show:false
+            },
+            axisLine: {
+                show: true,
+                lineStyle: {
+                    color: colors[1],
+                }
+            },
+            axisLabel: {
+                formatter: '{value} ℃'
+            }
+        },
+        {
+            type: 'value',
+            name: '床位数量',
+            position: 'right',
+            alignTicks: true,
+            offset: 60,
+            splitLine:{
+                show:false
+            },
+            axisLine: {
+                show: true,
+                lineStyle: {
+                    color: colors[2],
+                }
+            },
+            axisLabel: {
+                formatter: '{value} 个'
+            }
+        }
+    ],
+        series: [
+        {
+            name: '{$year-3}用水量',
+            type: 'bar',
+            barWidth: 12,
+            data: {:json_encode($data['lastWater3'])},
+    },
+    {
+        name: '{$year-2}用水量',
+            type: 'bar',
+        barWidth: 12,
+        data: {:json_encode($data['lastWater2'])},
+    },
+        {
+            name: '{$year-1}用水量',
+            type: 'bar',
+            barWidth: 12,
+            data: {:json_encode($data['lastWater'])},
+    },
+    {
+        name: '{$year}用水量',
+            type: 'bar',
+        barWidth: 12,
+        data: {:json_encode($data['water'])},
+    },
+    {
+        name: '月度平均最高温度',
+        type: 'line',
+        yAxisIndex: 1,
+        data: {:json_encode($data['waterTempMax'])}
+    },
+    {
+        name: '月度平均最低温度',
+        type: 'line',
+        yAxisIndex: 1,
+        data: {:json_encode($data['waterTempMin'])}
+    },
+    {
+        name: '床位数量',
+            type: 'line',
+        yAxisIndex: 2,
+        data: {:json_encode($data['waterBeds'])}
+    },
+    ]
+    };
+
+    var myChart2 = echarts.init(document.getElementById('echarts2'));
+    myChart2.setOption(option2);
+
+
+    var option3 = {
+        tooltip: {
+            trigger: 'axis',
+            axisPointer: {
+                type: 'cross',
+                crossStyle: {
+                    color: '#999'
+                }
+            }
+        },
+        legend: {
+            data: ['{$year-3}燃气用量', '{$year-2}燃气用量','{$year-1}燃气用量', '{$year}燃气用量', '月度平均最高温度','月度平均最低温度','床位数量']
+        },
+        xAxis: [
+            {
+                type: 'category',
+                data: {:json_encode($date)},
+                axisPointer: {
+                    type: 'shadow'
+                }
+            }
+        ],
+        yAxis: [
+            {
+                type: 'value',
+                name: '使用量 ',
+                offset: 5,
+                splitLine:{
+                    show:false
+                },
+                axisLine: {
+                    show: true,
+                    lineStyle: {
+                        color: colors[0],
+                    }
+                },
+                axisLabel: {
+                    formatter: '{value} m³'
+                }
+            },
+            {
+                type: 'value',
+                name: '温度',
+                splitLine:{
+                    show:false
+                },
+                axisLine: {
+                    show: true,
+                    lineStyle: {
+                        color: colors[1],
+                    }
+                },
+                axisLabel: {
+                    formatter: '{value} ℃'
+                }
+            },
+            {
+                type: 'value',
+                name: '床位数量',
+                position: 'right',
+                alignTicks: true,
+                offset: 60,
+                splitLine:{
+                    show:false
+                },
+                axisLine: {
+                    show: true,
+                    lineStyle: {
+                        color: colors[2],
+                    }
+                },
+                axisLabel: {
+                    formatter: '{value} 个'
+                }
+            }
+        ],
+        series: [
+        {
+            name: '{$year-3}燃气用量',
+            type: 'bar',
+            barWidth: 12,
+            data: {:json_encode($data['lastGas3'])},
+    },
+    {
+        name: '{$year-2}燃气用量',
+            type: 'bar',
+        barWidth: 12,
+        data: {:json_encode($data['lastGas2'])},
+    },
+            {
+                name: '{$year-1}燃气用量',
+                type: 'bar',
+                barWidth: 12,
+                data: {:json_encode($data['lastGas'])},
+            },
+        {
+            name: '{$year}燃气用量',
+                type: 'bar',
+            barWidth: 12,
+            data: {:json_encode($data['gas'])},
+        },
+        {
+            name: '月度平均最高温度',
+            type: 'line',
+            yAxisIndex: 1,
+            data: {:json_encode($data['gasTempMax'])},
+        },
+        {
+            name: '月度平均最低温度',
+            type: 'line',
+            yAxisIndex: 1,
+            data: {:json_encode($data['gasTempMin'])},
+        },
+        {
+            name: '床位数量',
+            type: 'line',
+            yAxisIndex: 2,
+            data: {:json_encode($data['gasBeds'])},
+        },
+        ]
+    };
+
+    var myChart3 = echarts.init(document.getElementById('echarts3'));
+    myChart3.setOption(option3);
+
+</script>
+{/block}

+ 151 - 0
application/admin/view/energy_statistics/daily_water.html

@@ -0,0 +1,151 @@
+{extend name="common/common2" /}
+{block name="main"}
+<style>
+    .table th{
+        text-align: center;
+        background: #ffffff;
+    }
+    .table tr{
+        background: #ffffff;
+    }
+    .table td{
+        text-align: center;
+    }
+</style>
+<div class="ibox-content">
+<div class="ibox">
+
+    <div class="alert">
+        <form action="dailyWater" method="GET" id='search_form' class="form-inline">
+            <div class="input-group" style="width: 200px">
+                <span class="input-group-addon">选择日期</span>
+                <input class="form-control dialog-datetime" id="startTime" name="start" type="text" data-date-format="yyyy-mm-dd" value="{$start}" placeholder="" readonly/>
+            </div>
+
+            <div class="input-group">
+            <span class="input-group-btn">
+                <button class="btn-sm btn-danger" type="submit"  ><i class="fa fa-search"></i></button>
+			</span>&nbsp;
+                <span class="input-group-btn">
+                     <button class="btn-sm btn-warning" type="reset" onclick="empty_search()"><i class="fa fa-undo"></i></button>
+            </span>
+            </div>
+        </form>
+    </div>
+
+    <div class="panel-group">
+        <div class="panel panel-default">
+            <div class="panel-heading clearfix">
+                <div class="btn-group pull-left">
+                    医院每日总水表数据统计
+                </div>
+                <div class="btn-group pull-right">
+                    <a href="javascript:;" onclick="printer()" class="btn btn-sm btn btn-primary"><i class="glyphicon glyphicon-print"></i>打印</a>
+                    <a href="javascript:;" onclick="excel_download(this)" class="btn btn-other btn-sm"><i class="glyphicon glyphicon-download"></i>导出</a>
+                </div>
+            </div>
+            <div class="panel-body" id="printer">
+                <table class="table table-bordered">
+
+                    <thead>
+                    <tr hidden><td colspan="5"><h1  style="text-align: center">医院每日总电表数据统计</h1></td></tr>
+                    <tr hidden><td colspan="5"><h3 style="float: right">{$date}</h3></td></tr>
+                        <tr>
+                            <th >日期</th>
+                            <th >表号</th>
+                            <th >使用量</th>
+                            <th >合计使用量</th>
+                        </tr>
+                    </thead>
+                    {if $totalData == 0}
+                    <tbody>
+                        <tr>
+                            <td colspan="5">暂无数据</td>
+                        </tr>
+                    </tbody>
+                    {else/}
+                    <tbody>
+                        <!-- 下面注释不能删除!!! -->
+<!--                        {$rowNumber = 1}-->
+                        {foreach $data as $k=>$v}
+                        {for start="0" end="$count"}
+                        {if $rowNumber % $count == 1}
+                        <tr>
+                            <td rowspan="{$count}">{$k+1}</td>
+                            <td>{$v[$i]['sn']|default=''}</td>
+                            <td>{$v[$i]['real_degree']|default=''}</td>
+                            <td rowspan="{$count}">
+                                {$v.total}
+                            </td>
+                            {else /}
+                            {if $i == $count-1}
+                        <tr>
+                            <td>实际热水用量</td>
+                            <td>{$v['hot_degree']}</td>
+                        {else/}
+                        <tr>
+                            <td>{$v[$i]['sn']|default=''}</td>
+                            <td>{$v[$i]['real_degree']|default=''}</td>
+                            {/if}
+                            {/if}
+                            <!-- 下面注释不能删除!!! -->
+<!--                            {$rowNumber = $rowNumber + 1}-->
+                        {if $rowNumber % $count == 0}
+                        <!-- 重置总使用量 -->
+                        {/if}
+                        {/for}
+                        {/foreach}
+                            <tr>
+                                <td>共计:</td>
+                                <td colspan="4">{$totalData}</td>
+                            </tr>
+                    </tbody>
+                    {/if}
+                </table>
+            </div>
+        </div>
+    </div>
+</div>
+</div>
+{/block}
+{block name="script"}
+<script src="/static/layDate-v5.0.9/laydate.js"></script>
+<script src="/static/browser.js"></script>
+<script src="/static/jquery.jqprint-0.3.js"></script>
+<script>
+    $(function () {
+        laydate.render({
+            elem: '#startTime',
+            trigger: 'click',
+            theme: '#0F3A87',
+            type:'month'
+        });
+        laydate.render({
+            elem: '#endTime',
+            trigger: 'click',
+            theme: '#0F3A87'
+        });
+    });
+    function empty_search(){
+        window.location.href = 'dailyWater';
+    }
+    function printer(){
+        $('#printer').jqprint();
+    }
+
+    function excel_download(_self){
+        $("#printer").table2excel({
+            //      table2excel插件的可用配置参数有:
+            exclude: ".noExl",//   exclude:不被导出的表格行的CSS class类。
+            name: "医院每日总水表数据",//   name:导出的Excel文档的名称
+            filename: "医院每日总水表数据",//   filename:Excel文件的名称。
+            exclude_img: true,//   exclude_img:是否导出图片。
+            exclude_links: true,//   exclude_links:是否导出超链接
+            exclude_inputs: true//    exclude_inputs:是否导出输入框中的内容
+
+
+        });
+    }
+
+</script>
+{/block}

+ 151 - 0
application/admin/view/energy_statistics/month_dep_electricity.html

@@ -0,0 +1,151 @@
+{extend name="common/common2" /}
+{block name="main"}
+<style>
+    .table th{
+        text-align: center;
+        background: #ffffff;
+    }
+    /*.table tr{*/
+    /*    background: #ffffff;*/
+    /*}*/
+    .table td{
+        text-align: center;
+    }
+</style>
+<div class="ibox-content">
+    <div class="ibox">
+
+        <div class="alert">
+            <form action="monthDepElectricity" method="GET" id='search_form' class="form-inline">
+                <div class="input-group" style="width: 200px">
+                    <span class="input-group-addon">选择日期</span>
+                    <input class="form-control dialog-datetime" id="startTime" name="start" type="text"  value="{$start}" placeholder="" readonly/>
+                </div>
+                <div class="input-group " style="width: 200px">
+                    <span class="input-group-addon">科室</span>
+                    <select name="depId" class="form-control">
+                        <option value="">选择科室</option>
+                        {foreach $dep as $k => $v}
+                        <option value="{$v.id}" {if $depId == $v.id} selected {/if}>{$v.name}</option>
+                        {/foreach}
+                    </select>
+                </div>
+                <div class="input-group">
+            <span class="input-group-btn">
+                <button class="btn-sm btn-danger" type="submit"  ><i class="fa fa-search"></i></button>
+			</span>&nbsp;
+                    <span class="input-group-btn">
+                     <button class="btn-sm btn-warning" type="reset" onclick="empty_search()"><i class="fa fa-undo"></i></button>
+            </span>
+                </div>
+            </form>
+        </div>
+
+        <div class="panel-group">
+            <div class="panel panel-default">
+                <div class="panel-heading clearfix">
+                    <div class="btn-group pull-left">
+                        科室月电度统计
+                    </div>
+                    <div class="btn-group pull-right">
+                        <a href="javascript:;" onclick="printer()" class="btn btn-sm btn btn-primary"><i class="glyphicon glyphicon-print"></i>打印</a>
+                        <a href="javascript:;" onclick="excel_download(this)" class="btn btn-other btn-sm"><i class="glyphicon glyphicon-download"></i>导出</a>
+                    </div>
+                </div>
+                <div class="panel-body" id="printer">
+                    <table class="table table-bordered">
+                        <thead>
+                        <tr>
+                            <th rowspan="2">序号</th>
+                            <th rowspan="2">楼号</th>
+                            <th rowspan="2">楼层</th>
+                            <th rowspan="2">科室</th>
+                            <th rowspan="2">用电设备</th>
+                            <th rowspan="2">表号</th>
+                            <th rowspan="2">倍率</th>
+                            {foreach $monthList as $k=>$v}
+                            <th colspan="2">{$v}</th>
+                            {/foreach}
+                        </tr>
+                        <tr>
+                            {foreach $monthList as $k=>$v}
+                            <th>使用量</th>
+                            <th>合计</th>
+                            {/foreach}
+                        </tr>
+                        </thead>
+                        <tbody>
+                        {if empty($data)}
+                        <tr>
+                            <td colspan="30">
+                                暂无数据
+                            </td>
+                        </tr>
+                        {/if}
+                        {foreach $data as $k => $v}
+<!--                    {$count = count($v)}-->
+                        <tr>
+                            <td rowspan="{$count}">{$k + 1}</td>
+                            <td rowspan="{$count}">{$v[0]['info']['floor1']|default=''}</td>
+                            <td rowspan="{$count}">{$v[0]['info']['floor2']|default=''}</td>
+                            <td rowspan="{$count}">{$v[0]['info']['dep']|default=''}</td>
+                            {for start="0" end="$count"}
+                            <td>{$v[$i]['info']['type']}</td>
+                            <td>{$v[$i]['number']}</td>
+                            <td>{$v[$i]['rate']|default=0}</td>
+                            {foreach $v[$i]['data'] as $k3 => $v3}
+                            <td>{$v3['real_degree']|default=0}</td>
+                            {if $i == 0}
+                            <td rowspan="{$count}">{$v3['total']|default=0}</td>
+                            {/if}
+                            {/foreach}
+                        </tr>
+                        {/for}
+                        {/foreach}
+                        <tr>
+                            <td colspan="31">合计:{$txt}</td>
+                        </tr>
+                        </tbody>
+                    </table>
+                </div>
+            </div>
+        </div>
+    </div>
+</div>
+{/block}
+{block name="script"}
+<script src="/static/layDate-v5.0.9/laydate.js"></script>
+<script src="/static/browser.js"></script>
+<script src="/static/jquery.jqprint-0.3.js"></script>
+<script>
+    $(function () {
+        laydate.render({
+            elem: '#startTime',
+            trigger: 'click',
+            theme: '#0F3A87',
+            type:'year'
+        });
+    });
+    function empty_search(){
+        window.location.href = 'monthDepElectricity';
+    }
+    function printer(){
+        $('#printer').jqprint();
+    }
+
+    function excel_download(_self){
+        $("#printer").table2excel({
+            //      table2excel插件的可用配置参数有:
+            exclude: ".noExl",//   exclude:不被导出的表格行的CSS class类。
+            name: "科室月电度统计",//   name:导出的Excel文档的名称
+            filename: "科室月电度统计",//   filename:Excel文件的名称。
+            exclude_img: true,//   exclude_img:是否导出图片。
+            exclude_links: true,//   exclude_links:是否导出超链接
+            exclude_inputs: true//    exclude_inputs:是否导出输入框中的内容
+
+
+        });
+    }
+
+</script>
+{/block}

+ 133 - 0
application/admin/view/energy_statistics/month_dep_gas.html

@@ -0,0 +1,133 @@
+{extend name="common/common2" /}
+{block name="main"}
+<style>
+    .table th{
+        text-align: center;
+        background: #ffffff;
+    }
+    /*.table tr{*/
+    /*    background: #ffffff;*/
+    /*}*/
+    .table td{
+        text-align: center;
+    }
+</style>
+<div class="ibox-content">
+    <div class="ibox">
+
+        <div class="alert">
+            <form action="monthDepGas" method="GET" id='search_form' class="form-inline">
+                <div class="input-group" style="width: 200px">
+                    <span class="input-group-addon">选择日期</span>
+                    <input class="form-control dialog-datetime" id="startTime" name="start" type="text"  value="{$start}" placeholder="" readonly/>
+                </div>
+
+                <div class="input-group">
+            <span class="input-group-btn">
+                <button class="btn-sm btn-danger" type="submit"  ><i class="fa fa-search"></i></button>
+			</span>&nbsp;
+                    <span class="input-group-btn">
+                     <button class="btn-sm btn-warning" type="reset" onclick="empty_search()"><i class="fa fa-undo"></i></button>
+            </span>
+                </div>
+            </form>
+        </div>
+
+        <div class="panel-group">
+            <div class="panel panel-default">
+                <div class="panel-heading clearfix">
+                    <div class="btn-group pull-left">
+                        科室月度燃气用量统计
+                    </div>
+                    <div class="btn-group pull-right">
+                        <a href="javascript:;" onclick="printer()" class="btn btn-sm btn btn-primary"><i class="glyphicon glyphicon-print"></i>打印</a>
+                        <a href="javascript:;" onclick="excel_download(this)" class="btn btn-other btn-sm"><i class="glyphicon glyphicon-download"></i>导出</a>
+                    </div>
+                </div>
+                <div class="panel-body" id="printer">
+                    <table class="table table-bordered">
+                        <thead>
+                        <tr>
+                            <th rowspan="2">序号</th>
+                            <th rowspan="2">楼号</th>
+                            <th rowspan="2">楼层</th>
+                            <th rowspan="2">科室</th>
+                            <th rowspan="2">表号</th>
+                            {foreach $monthList as $k=>$v}
+                            <th colspan="2">{$v}</th>
+                            {/foreach}
+                        </tr>
+                        <tr>
+                            {foreach $monthList as $k=>$v}
+                            <th>使用量</th>
+                            <th>合计</th>
+                            {/foreach}
+                        </tr>
+                        </thead>
+                        <tbody>
+                        {if empty($data)}
+                        <tr>
+                            <td colspan="30">
+                                暂无数据
+                            </td>
+                        </tr>
+                        {/if}
+                        {foreach $data as $k => $v}
+                        <tr>
+                            <td >{$k + 1}</td>
+                            <td >{$v[0]['info']['floor1']|default=''}</td>
+                            <td >{$v[0]['info']['floor2']|default=''}</td>
+                            <td >{$v[0]['info']['dep']|default=''}</td>
+                            <td>{$v[0]['number']}</td>
+                            {foreach $v[0]['data'] as $k3 => $v3}
+                            <td>{$v3['real_degree']|default=0}</td>
+                            {if $k == 0}
+                            <td rowspan="{$count}">{$total[$k3]|default=0}</td>
+                            {/if}
+                            {/foreach}
+                        </tr>
+                        {/foreach}
+                        </tbody>
+                    </table>
+                </div>
+            </div>
+        </div>
+    </div>
+</div>
+{/block}
+{block name="script"}
+<script src="/static/layDate-v5.0.9/laydate.js"></script>
+<script src="/static/browser.js"></script>
+<script src="/static/jquery.jqprint-0.3.js"></script>
+<script>
+    $(function () {
+        laydate.render({
+            elem: '#startTime',
+            trigger: 'click',
+            theme: '#0F3A87',
+            type:'year'
+        });
+    });
+    function empty_search(){
+        window.location.href = 'monthDepGas';
+    }
+    function printer(){
+        $('#printer').jqprint();
+    }
+
+    function excel_download(_self){
+        $("#printer").table2excel({
+            //      table2excel插件的可用配置参数有:
+            exclude: ".noExl",//   exclude:不被导出的表格行的CSS class类。
+            name: "科室月冷热水量统计",//   name:导出的Excel文档的名称
+            filename: "科室月冷热水量统计",//   filename:Excel文件的名称。
+            exclude_img: true,//   exclude_img:是否导出图片。
+            exclude_links: true,//   exclude_links:是否导出超链接
+            exclude_inputs: true//    exclude_inputs:是否导出输入框中的内容
+
+
+        });
+    }
+
+</script>
+{/block}

+ 145 - 0
application/admin/view/energy_statistics/month_dep_water.html

@@ -0,0 +1,145 @@
+{extend name="common/common2" /}
+{block name="main"}
+<style>
+    .table th{
+        text-align: center;
+        background: #ffffff;
+    }
+    /*.table tr{*/
+    /*    background: #ffffff;*/
+    /*}*/
+    .table td{
+        text-align: center;
+    }
+</style>
+<div class="ibox-content">
+    <div class="ibox">
+
+        <div class="alert">
+            <form action="monthDepWater" method="GET" id='search_form' class="form-inline">
+                <div class="input-group" style="width: 200px">
+                    <span class="input-group-addon">选择日期</span>
+                    <input class="form-control dialog-datetime" id="startTime" name="start" type="text"  value="{$start}" placeholder="" readonly/>
+                </div>
+
+                <div class="input-group">
+            <span class="input-group-btn">
+                <button class="btn-sm btn-danger" type="submit"  ><i class="fa fa-search"></i></button>
+			</span>&nbsp;
+                    <span class="input-group-btn">
+                     <button class="btn-sm btn-warning" type="reset" onclick="empty_search()"><i class="fa fa-undo"></i></button>
+            </span>
+                </div>
+            </form>
+        </div>
+
+        <div class="panel-group">
+            <div class="panel panel-default">
+                <div class="panel-heading clearfix">
+                    <div class="btn-group pull-left">
+                        科室月冷热水量统计
+                    </div>
+                    <div class="btn-group pull-right">
+                        <a href="javascript:;" onclick="printer()" class="btn btn-sm btn btn-primary"><i class="glyphicon glyphicon-print"></i>打印</a>
+                        <a href="javascript:;" onclick="excel_download(this)" class="btn btn-other btn-sm"><i class="glyphicon glyphicon-download"></i>导出</a>
+                    </div>
+                </div>
+                <div class="panel-body" id="printer">
+                    <table class="table table-bordered">
+                        <thead>
+                        <tr>
+                            <th rowspan="2">序号</th>
+                            <th rowspan="2">楼号</th>
+                            <th rowspan="2">楼层</th>
+                            <th rowspan="2">科室</th>
+                            <th rowspan="2">性质</th>
+                            <th rowspan="2">表号</th>
+                            {foreach $monthList as $k=>$v}
+                            <th colspan="2">{$v}</th>
+                            {/foreach}
+                        </tr>
+                        <tr>
+                            {foreach $monthList as $k=>$v}
+                            <th>使用量</th>
+                            <th>合计</th>
+                            {/foreach}
+                        </tr>
+                        </thead>
+                        <tbody>
+                        {if empty($data)}
+                        <tr>
+                            <td colspan="30">
+                                暂无数据
+                            </td>
+                        </tr>
+                        {/if}
+                        <!-- 下面注释不能删除!!! -->
+                        {foreach $data as $k => $v}
+<!--                    {$count = count($v['sn'])}-->
+                        <tr>
+                            <td rowspan="{$count+1}">{$k + 1}</td>
+                            <td rowspan="{$count+1}">{$v[0]['info']['floor1']|default=''}</td>
+                            <td rowspan="{$count+1}">{$v[0]['info']['floor2']|default=''}</td>
+                            <td rowspan="{$count+1}">{$v[0]['info']['dep']|default=''}</td>
+                            <td rowspan="{$count}">冷水</td>
+                            {for start="0" end="$count"}
+                            <td>{$v['sn'][$i]|default=''}</td>
+                            {foreach $v['cold'][$i] as $k3 => $v3}
+                            <td>{$v3['cold_degree']|default=0}</td>
+                            {if  $i == 0}
+                            <td rowspan="{$count+1}">{$v['totalCold'][$k3]+$v['totalHotIn'][$k3]-$v['totalHotReturn'][$k3] }</td>
+                            {/if}
+                            {/foreach}
+                        </tr>
+                        {/for}
+                        <tr>
+                            <td colspan="2">实际热水用量</td>
+                            {foreach $monthList as $k4 => $v4}
+                            <td>{$v['totalHotIn'][$k4]-$v['totalHotReturn'][$k4]}</td>
+                            {/foreach}
+                        </tr>
+                        {/foreach}
+                        </tbody>
+                    </table>
+                </div>
+            </div>
+        </div>
+    </div>
+</div>
+{/block}
+{block name="script"}
+<script src="/static/layDate-v5.0.9/laydate.js"></script>
+<script src="/static/browser.js"></script>
+<script src="/static/jquery.jqprint-0.3.js"></script>
+<script>
+    $(function () {
+        laydate.render({
+            elem: '#startTime',
+            trigger: 'click',
+            theme: '#0F3A87',
+            type:'year'
+        });
+    });
+    function empty_search(){
+        window.location.href = 'monthDepWater';
+    }
+    function printer(){
+        $('#printer').jqprint();
+    }
+
+    function excel_download(_self){
+        $("#printer").table2excel({
+            //      table2excel插件的可用配置参数有:
+            exclude: ".noExl",//   exclude:不被导出的表格行的CSS class类。
+            name: "科室月冷热水量统计",//   name:导出的Excel文档的名称
+            filename: "科室月冷热水量统计",//   filename:Excel文件的名称。
+            exclude_img: true,//   exclude_img:是否导出图片。
+            exclude_links: true,//   exclude_links:是否导出超链接
+            exclude_inputs: true//    exclude_inputs:是否导出输入框中的内容
+
+
+        });
+    }
+
+</script>
+{/block}

+ 156 - 0
application/admin/view/energy_statistics/month_dep_water2.html

@@ -0,0 +1,156 @@
+{extend name="common/common2" /}
+{block name="main"}
+<style>
+    .table th{
+        text-align: center;
+        background: #ffffff;
+    }
+    /*.table tr{*/
+    /*    background: #ffffff;*/
+    /*}*/
+    .table td{
+        text-align: center;
+    }
+</style>
+<div class="ibox-content">
+    <div class="ibox">
+
+        <div class="alert">
+            <form action="monthDepWater" method="GET" id='search_form' class="form-inline">
+                <div class="input-group" style="width: 200px">
+                    <span class="input-group-addon">选择日期</span>
+                    <input class="form-control dialog-datetime" id="startTime" name="start" type="text"  value="{$start}" placeholder="" readonly/>
+                </div>
+
+                <div class="input-group">
+            <span class="input-group-btn">
+                <button class="btn-sm btn-danger" type="submit"  ><i class="fa fa-search"></i></button>
+			</span>&nbsp;
+                    <span class="input-group-btn">
+                     <button class="btn-sm btn-warning" type="reset" onclick="empty_search()"><i class="fa fa-undo"></i></button>
+            </span>
+                </div>
+            </form>
+        </div>
+
+        <div class="panel-group">
+            <div class="panel panel-default">
+                <div class="panel-heading clearfix">
+                    <div class="btn-group pull-left">
+                        科室月冷热水量统计
+                    </div>
+                    <div class="btn-group pull-right">
+                        <a href="javascript:;" onclick="printer()" class="btn btn-sm btn btn-primary"><i class="glyphicon glyphicon-print"></i>打印</a>
+                        <a href="javascript:;" onclick="excel_download(this)" class="btn btn-other btn-sm"><i class="glyphicon glyphicon-download"></i>导出</a>
+                    </div>
+                </div>
+                <div class="panel-body" id="printer">
+                    <table class="table table-bordered">
+                        <thead>
+                        <tr>
+                            <th rowspan="2">序号</th>
+                            <th rowspan="2">楼号</th>
+                            <th rowspan="2">楼层</th>
+                            <th rowspan="2">科室</th>
+                            <th rowspan="2">性质</th>
+                            <th rowspan="2">表号</th>
+                            {foreach $monthList as $k=>$v}
+                            <th colspan="2">{$v}</th>
+                            {/foreach}
+                        </tr>
+                        <tr>
+                            {foreach $monthList as $k=>$v}
+                            <th>使用量</th>
+                            <th>合计</th>
+                            {/foreach}
+                        </tr>
+                        </thead>
+                        <tbody>
+                        {if empty($data)}
+                        <tr>
+                            <td colspan="30">
+                                暂无数据
+                            </td>
+                        </tr>
+                        {/if}
+                        {foreach $data as $k => $v}
+                        {if count($v['sn']) >1}
+                        <tr>
+                            <td rowspan="4">{$k + 1}</td>
+                            <td rowspan="4">{$v[0]['info']['floor1']|default=''}</td>
+                            <td rowspan="4">{$v[0]['info']['floor2']|default=''}</td>
+                            <td rowspan="4">{$v[0]['info']['dep']|default=''}</td>
+                        </tr>
+                        {else/}
+                        <tr>
+                            <td rowspan="3">{$k + 1}</td>
+                            <td rowspan="3">{$v[0]['info']['floor1']|default=''}</td>
+                            <td rowspan="3">{$v[0]['info']['floor2']|default=''}</td>
+                            <td rowspan="3">{$v[0]['info']['dep']|default=''}</td>
+                        </tr>
+                        {/if}
+                        {foreach $v['sn'] as $k2 => $v2}
+                        <tr>
+                            {if count($v['sn']) >1 && $k2 == 0}
+                            <td rowspan="2">冷水</td>
+                            {/if}
+                            <td>{$v2|default=''}</td>
+                            {foreach $v['cold'][$k2] as $k3 => $v3}
+                            <td>{$v3['cold_degree']|default=0}</td>
+                            {if $k2 == 0}
+                            <td rowspan="3">{$v3['cold_degree']+$v['hotIn'][$k3]-$v['hotReturn'][$k3] }</td>
+                            {/if}
+                            {/foreach}
+                        </tr>
+                        {/foreach}
+                        <tr>
+                            <td colspan="2">实际热水用量</td>
+                            {foreach $monthList as $k4 => $v4}
+                            <td>{$v['hotIn'][$k4]-$v['hotReturn'][$k4]}</td>
+                            {/foreach}
+                        </tr>
+                        {/foreach}
+                        </tbody>
+                    </table>
+                </div>
+            </div>
+        </div>
+    </div>
+</div>
+{/block}
+{block name="script"}
+<script src="/static/layDate-v5.0.9/laydate.js"></script>
+<script src="/static/browser.js"></script>
+<script src="/static/jquery.jqprint-0.3.js"></script>
+<script>
+    $(function () {
+        laydate.render({
+            elem: '#startTime',
+            trigger: 'click',
+            theme: '#0F3A87',
+            type:'year'
+        });
+    });
+    function empty_search(){
+        window.location.href = 'monthDepWater';
+    }
+    function printer(){
+        $('#printer').jqprint();
+    }
+
+    function excel_download(_self){
+        $("#printer").table2excel({
+            //      table2excel插件的可用配置参数有:
+            exclude: ".noExl",//   exclude:不被导出的表格行的CSS class类。
+            name: "科室月冷热水量统计",//   name:导出的Excel文档的名称
+            filename: "科室月冷热水量统计",//   filename:Excel文件的名称。
+            exclude_img: true,//   exclude_img:是否导出图片。
+            exclude_links: true,//   exclude_links:是否导出超链接
+            exclude_inputs: true//    exclude_inputs:是否导出输入框中的内容
+
+
+        });
+    }
+
+</script>
+{/block}

+ 136 - 0
application/admin/view/energy_statistics/month_device_electricity.html

@@ -0,0 +1,136 @@
+{extend name="common/common2" /}
+{block name="main"}
+<style>
+    .table th{
+        text-align: center;
+        background: #ffffff;
+    }
+    /*.table tr{*/
+    /*    background: #ffffff;*/
+    /*}*/
+    .table td{
+        text-align: center;
+    }
+</style>
+<div class="ibox-content">
+    <div class="ibox">
+
+        <div class="alert">
+            <form action="monthDeviceElectricity" method="GET" id='search_form' class="form-inline">
+                <div class="input-group" style="width: 200px">
+                    <span class="input-group-addon">选择日期</span>
+                    <input class="form-control dialog-datetime" id="startTime" name="start" type="text"  value="{$start}" placeholder="" readonly/>
+                </div>
+
+                <div class="input-group">
+            <span class="input-group-btn">
+                <button class="btn-sm btn-danger" type="submit"  ><i class="fa fa-search"></i></button>
+			</span>&nbsp;
+                    <span class="input-group-btn">
+                     <button class="btn-sm btn-warning" type="reset" onclick="empty_search()"><i class="fa fa-undo"></i></button>
+            </span>
+                </div>
+            </form>
+        </div>
+
+        <div class="panel-group">
+            <div class="panel panel-default">
+                <div class="panel-heading clearfix">
+                    <div class="btn-group pull-left">
+                        医院月度设备用电量统计
+                    </div>
+                    <div class="btn-group pull-right">
+                        <a href="javascript:;" onclick="printer()" class="btn btn-sm btn btn-primary"><i class="glyphicon glyphicon-print"></i>打印</a>
+                        <a href="javascript:;" onclick="excel_download(this)" class="btn btn-other btn-sm"><i class="glyphicon glyphicon-download"></i>导出</a>
+                    </div>
+                </div>
+                <div class="panel-body" id="printer">
+                    <table class="table table-bordered">
+                        <thead>
+                        <tr>
+                            <th rowspan="2">序号</th>
+                            <th rowspan="2">设备名称</th>
+                            <th rowspan="2">用电设备</th>
+                            <th rowspan="2">表号</th>
+                            <th rowspan="2">倍率</th>
+                            {foreach $monthList as $k=>$v}
+                            <th colspan="2">{$v}</th>
+                            {/foreach}
+                        </tr>
+                        <tr>
+                            {foreach $monthList as $k=>$v}
+                            <th>使用量</th>
+                            <th>合计</th>
+                            {/foreach}
+                        </tr>
+                        </thead>
+                        <tbody>
+                        {if empty($data)}
+                        <tr>
+                            <td colspan="30">
+                                暂无数据
+                            </td>
+                        </tr>
+                        {/if}
+                        {foreach $data as $k => $v}
+<!--                    {$count = count($v)}-->
+                        <tr>
+                            <td rowspan="{$count}">{$k + 1}</td>
+                            <td rowspan="{$count}">{$v[0]['name']|default=''}</td>
+                            {for start="0" end="$count"}
+                            <td>{$v[$i]['type_e']}</td>
+                            <td>{$v[$i]['number']}</td>
+                            <td>{$v[$i]['rate']|default=0}</td>
+                            {foreach $v[$i]['data'] as $k3 => $v3}
+                            <td>{$v3['real_degree']|default=0}</td>
+                            {if $i == 0}
+                            <td rowspan="{$count}">{$v3['total']|default=0}</td>
+                            {/if}
+                            {/foreach}
+                        </tr>
+                        {/for}
+                        {/foreach}
+                        </tbody>
+                    </table>
+                </div>
+            </div>
+        </div>
+    </div>
+</div>
+{/block}
+{block name="script"}
+<script src="/static/layDate-v5.0.9/laydate.js"></script>
+<script src="/static/browser.js"></script>
+<script src="/static/jquery.jqprint-0.3.js"></script>
+<script>
+    $(function () {
+        laydate.render({
+            elem: '#startTime',
+            trigger: 'click',
+            theme: '#0F3A87',
+            type:'year'
+        });
+    });
+    function empty_search(){
+        window.location.href = 'monthDeviceElectricity';
+    }
+    function printer(){
+        $('#printer').jqprint();
+    }
+
+    function excel_download(_self){
+        $("#printer").table2excel({
+            //      table2excel插件的可用配置参数有:
+            exclude: ".noExl",//   exclude:不被导出的表格行的CSS class类。
+            name: "医院月度设备用电量统计",//   name:导出的Excel文档的名称
+            filename: "医院月度设备用电量统计",//   filename:Excel文件的名称。
+            exclude_img: true,//   exclude_img:是否导出图片。
+            exclude_links: true,//   exclude_links:是否导出超链接
+            exclude_inputs: true//    exclude_inputs:是否导出输入框中的内容
+
+
+        });
+    }
+
+</script>
+{/block}

+ 140 - 0
application/admin/view/energy_statistics/month_device_electricity2.html

@@ -0,0 +1,140 @@
+{extend name="common/common2" /}
+{block name="main"}
+<style>
+    .table th{
+        text-align: center;
+        background: #ffffff;
+    }
+    /*.table tr{*/
+    /*    background: #ffffff;*/
+    /*}*/
+    .table td{
+        text-align: center;
+    }
+</style>
+<div class="ibox-content">
+    <div class="ibox">
+
+        <div class="alert">
+            <form action="monthDeviceElectricity" method="GET" id='search_form' class="form-inline">
+                <div class="input-group" style="width: 200px">
+                    <span class="input-group-addon">选择日期</span>
+                    <input class="form-control dialog-datetime" id="startTime" name="start" type="text"  value="{$start}" placeholder="" readonly/>
+                </div>
+
+                <div class="input-group">
+            <span class="input-group-btn">
+                <button class="btn-sm btn-danger" type="submit"  ><i class="fa fa-search"></i></button>
+			</span>&nbsp;
+                    <span class="input-group-btn">
+                     <button class="btn-sm btn-warning" type="reset" onclick="empty_search()"><i class="fa fa-undo"></i></button>
+            </span>
+                </div>
+            </form>
+        </div>
+
+        <div class="panel-group">
+            <div class="panel panel-default">
+                <div class="panel-heading clearfix">
+                    <div class="btn-group pull-left">
+                        医院月度设备用电量统计
+                    </div>
+                    <div class="btn-group pull-right">
+                        <a href="javascript:;" onclick="printer()" class="btn btn-sm btn btn-primary"><i class="glyphicon glyphicon-print"></i>打印</a>
+                        <a href="javascript:;" onclick="excel_download(this)" class="btn btn-other btn-sm"><i class="glyphicon glyphicon-download"></i>导出</a>
+                    </div>
+                </div>
+                <div class="panel-body" id="printer">
+                    <table class="table table-bordered">
+                        <thead>
+                        <tr>
+                            <th rowspan="2">序号</th>
+                            <th rowspan="2">楼号</th>
+                            <th rowspan="2">楼层</th>
+                            <th rowspan="2">设备名称</th>
+                            <th rowspan="2">用电设备</th>
+                            <th rowspan="2">表号</th>
+                            <th rowspan="2">倍率</th>
+                            {foreach $monthList as $k=>$v}
+                            <th colspan="2">{$v}</th>
+                            {/foreach}
+                        </tr>
+                        <tr>
+                            {foreach $monthList as $k=>$v}
+                            <th>使用量</th>
+                            <th>合计</th>
+                            {/foreach}
+                        </tr>
+                        </thead>
+                        <tbody>
+                        {if empty($data)}
+                        <tr>
+                            <td colspan="30">
+                                暂无数据
+                            </td>
+                        </tr>
+                        {/if}
+                        {foreach $data as $k => $v}
+<!--                    {$count = count($v)}-->
+                        <tr>
+                            <td rowspan="{$count}">{$k + 1}</td>
+                            <td rowspan="{$count}">{$v[0]['info']['floor1']|default=''}</td>
+                            <td rowspan="{$count}">{$v[0]['info']['floor2']|default=''}</td>
+                            <td rowspan="{$count}">{$v[0]['info']['name']|default=''}</td>
+                            {for start="0" end="$count"}
+                            <td>{$v[$i]['info']['type']}</td>
+                            <td>{$v[$i]['number']}</td>
+                            <td>{$v[$i]['rate']|default=0}</td>
+                            {foreach $v[$i]['data'] as $k3 => $v3}
+                            <td>{$v3['real_degree']|default=0}</td>
+                            {if $i == 0}
+                            <td rowspan="{$count}">{$v3['total']|default=0}</td>
+                            {/if}
+                            {/foreach}
+                        </tr>
+                        {/for}
+                        {/foreach}
+                        </tbody>
+                    </table>
+                </div>
+            </div>
+        </div>
+    </div>
+</div>
+{/block}
+{block name="script"}
+<script src="/static/layDate-v5.0.9/laydate.js"></script>
+<script src="/static/browser.js"></script>
+<script src="/static/jquery.jqprint-0.3.js"></script>
+<script>
+    $(function () {
+        laydate.render({
+            elem: '#startTime',
+            trigger: 'click',
+            theme: '#0F3A87',
+            type:'year'
+        });
+    });
+    function empty_search(){
+        window.location.href = 'monthDeviceElectricity';
+    }
+    function printer(){
+        $('#printer').jqprint();
+    }
+
+    function excel_download(_self){
+        $("#printer").table2excel({
+            //      table2excel插件的可用配置参数有:
+            exclude: ".noExl",//   exclude:不被导出的表格行的CSS class类。
+            name: "医院月度设备用电量统计",//   name:导出的Excel文档的名称
+            filename: "医院月度设备用电量统计",//   filename:Excel文件的名称。
+            exclude_img: true,//   exclude_img:是否导出图片。
+            exclude_links: true,//   exclude_links:是否导出超链接
+            exclude_inputs: true//    exclude_inputs:是否导出输入框中的内容
+
+
+        });
+    }
+
+</script>
+{/block}

+ 144 - 0
application/admin/view/energy_statistics/month_electricity.html

@@ -0,0 +1,144 @@
+{extend name="common/common2" /}
+{block name="main"}
+<style>
+    .table th{
+        text-align: center;
+        background: #ffffff;
+    }
+    .table tr{
+        background: #ffffff;
+    }
+    .table td{
+        text-align: center;
+    }
+</style>
+<div class="ibox-content">
+<div class="ibox">
+
+    <div class="alert">
+        <form action="monthElectricity" method="GET" id='search_form' class="form-inline">
+            <div class="input-group" style="width: 200px">
+                <span class="input-group-addon">选择日期</span>
+                <input class="form-control dialog-datetime" id="startTime" name="start" type="text"  value="{$start}" placeholder="" readonly/>
+            </div>
+
+            <div class="input-group">
+            <span class="input-group-btn">
+                <button class="btn-sm btn-danger" type="submit"  ><i class="fa fa-search"></i></button>
+			</span>&nbsp;
+                <span class="input-group-btn">
+                     <button class="btn-sm btn-warning" type="reset" onclick="empty_search()"><i class="fa fa-undo"></i></button>
+            </span>
+            </div>
+        </form>
+    </div>
+
+    <div class="panel-group">
+        <div class="panel panel-default">
+            <div class="panel-heading clearfix">
+                <div class="btn-group pull-left">
+                    医院每月总电表数据统计
+                </div>
+                <div class="btn-group pull-right">
+                    <a href="javascript:;" onclick="printer()" class="btn btn-sm btn btn-primary"><i class="glyphicon glyphicon-print"></i>打印</a>
+                    <a href="javascript:;" onclick="excel_download(this)" class="btn btn-other btn-sm"><i class="glyphicon glyphicon-download"></i>导出</a>
+                </div>
+            </div>
+            <div class="panel-body" id="printer">
+                <table class="table table-bordered">
+
+                    <thead>
+                    <tr hidden><td colspan="5"><h1  style="text-align: center">医院每日总电表数据统计</h1></td></tr>
+                    <tr hidden><td colspan="5"><h3 style="float: right">{$date}</h3></td></tr>
+                        <tr>
+                            <th >月份</th>
+                            <th >表号</th>
+                            <th >倍率</th>
+                            <th >使用量</th>
+                            <th >合计使用量</th>
+                        </tr>
+                    </thead>
+                    {if $totalData == 0}
+                    <tbody>
+                        <tr>
+                            <td colspan="5">暂无数据</td>
+                        </tr>
+                    </tbody>
+                    {else/}
+                    <tbody>
+                        <!-- 下面注释不能删除!!! -->
+<!--                        {$rowNumber = 1}-->
+                        {foreach $data as $k=>$v}
+                        {for start="0" end="$count"}
+                        {if $rowNumber % $count == 1 || $count == 1 }
+                        <tr>
+                            <td rowspan="{$count}">{$k+1}</td>
+                            <td>{$v[$i]['sn']|default=''}</td>
+                            <td>{$v[$i]['rate']|default=''}</td>
+                            <td>{$v[$i]['real_degree']|default=''}</td>
+                            <td rowspan="{$count}">
+                                {$v.total}
+                            </td>
+                            {else /}
+                        <tr>
+                            <td>{$v[$i]['sn']|default=''}</td>
+                            <td>{$v[$i]['rate']|default=''}</td>
+                            <td>{$v[$i]['real_degree']|default=''}</td>
+                            {/if}
+                            <!-- 下面注释不能删除!!! -->
+<!--                            {$rowNumber = $rowNumber + 1}-->
+                        </tr>
+                        {if $rowNumber % $count == 0}
+                        <!-- 重置总使用量 -->
+                        {/if}
+                        {/for}
+                        {/foreach}
+                            <tr>
+                                <td>共计:</td>
+                                <td colspan="4">{$totalData}</td>
+                            </tr>
+                    </tbody>
+                    {/if}
+                </table>
+            </div>
+        </div>
+    </div>
+</div>
+</div>
+{/block}
+{block name="script"}
+<script src="/static/layDate-v5.0.9/laydate.js"></script>
+<script src="/static/browser.js"></script>
+<script src="/static/jquery.jqprint-0.3.js"></script>
+<script>
+    $(function () {
+        laydate.render({
+            elem: '#startTime',
+            trigger: 'click',
+            theme: '#0F3A87',
+            type:'year'
+        });
+    });
+    function empty_search(){
+        window.location.href = 'monthElectricity';
+    }
+    function printer(){
+        $('#printer').jqprint();
+    }
+
+    function excel_download(_self){
+        $("#printer").table2excel({
+            //      table2excel插件的可用配置参数有:
+            exclude: ".noExl",//   exclude:不被导出的表格行的CSS class类。
+            name: "医院每月总电表数据",//   name:导出的Excel文档的名称
+            filename: "医院每月总电表数据",//   filename:Excel文件的名称。
+            exclude_img: true,//   exclude_img:是否导出图片。
+            exclude_links: true,//   exclude_links:是否导出超链接
+            exclude_inputs: true//    exclude_inputs:是否导出输入框中的内容
+
+
+        });
+    }
+
+</script>
+{/block}

+ 141 - 0
application/admin/view/energy_statistics/month_gas.html

@@ -0,0 +1,141 @@
+{extend name="common/common2" /}
+{block name="main"}
+<style>
+    .table th{
+        text-align: center;
+        background: #ffffff;
+    }
+    .table tr{
+        background: #ffffff;
+    }
+    .table td{
+        text-align: center;
+    }
+</style>
+<div class="ibox-content">
+<div class="ibox">
+
+    <div class="alert">
+        <form action="monthGas" method="GET" id='search_form' class="form-inline">
+            <div class="input-group" style="width: 200px">
+                <span class="input-group-addon">选择日期</span>
+                <input class="form-control dialog-datetime" id="startTime" name="start" type="text"  value="{$start}" placeholder="" readonly/>
+            </div>
+
+            <div class="input-group">
+            <span class="input-group-btn">
+                <button class="btn-sm btn-danger" type="submit"  ><i class="fa fa-search"></i></button>
+			</span>&nbsp;
+                <span class="input-group-btn">
+                     <button class="btn-sm btn-warning" type="reset" onclick="empty_search()"><i class="fa fa-undo"></i></button>
+            </span>
+            </div>
+        </form>
+    </div>
+
+    <div class="panel-group">
+        <div class="panel panel-default">
+            <div class="panel-heading clearfix">
+                <div class="btn-group pull-left">
+                    医院每月总气体数据统计
+                </div>
+                <div class="btn-group pull-right">
+                    <a href="javascript:;" onclick="printer()" class="btn btn-sm btn btn-primary"><i class="glyphicon glyphicon-print"></i>打印</a>
+                    <a href="javascript:;" onclick="excel_download(this)" class="btn btn-other btn-sm"><i class="glyphicon glyphicon-download"></i>导出</a>
+                </div>
+            </div>
+            <div class="panel-body" id="printer">
+                <table class="table table-bordered">
+
+                    <thead>
+                    <tr hidden><td colspan="5"><h1  style="text-align: center">医院每日总气体数据统计</h1></td></tr>
+                    <tr hidden><td colspan="5"><h3 style="float: right">{$date}</h3></td></tr>
+                        <tr>
+                            <th >月份</th>
+                            <th >表号</th>
+                            <th >使用量</th>
+                            <th >合计使用量</th>
+                        </tr>
+                    </thead>
+                    {if $totalData == 0}
+                    <tbody>
+                        <tr>
+                            <td colspan="5">暂无数据</td>
+                        </tr>
+                    </tbody>
+                    {else/}
+                    <tbody>
+                        <!-- 下面注释不能删除!!! -->
+<!--                        {$rowNumber = 1}-->
+                        {foreach $data as $k=>$v}
+                        {for start="0" end="$count"}
+                        {if $rowNumber % $count == 1 || $count == 1}
+                        <tr>
+                            <td rowspan="{$count}">{$k+1}</td>
+                            <td>{$v[$i]['sn']|default=''}</td>
+                            <td>{$v[$i]['real_degree']|default=''}</td>
+                            <td rowspan="{$count}">
+                                {$v.total}
+                            </td>
+                            {else /}
+                        <tr>
+                            <td>{$v[$i]['sn']|default=''}</td>
+                            <td>{$v[$i]['real_degree']|default=''}</td>
+                            {/if}
+                            <!-- 下面注释不能删除!!! -->
+<!--                            {$rowNumber = $rowNumber + 1}-->
+                        </tr>
+                        {if $rowNumber % $count == 0}
+                        <!-- 重置总使用量 -->
+                        {/if}
+                        {/for}
+                        {/foreach}
+                            <tr>
+                                <td>共计:</td>
+                                <td colspan="4">{$totalData}</td>
+                            </tr>
+                    </tbody>
+                    {/if}
+                </table>
+            </div>
+        </div>
+    </div>
+</div>
+</div>
+{/block}
+{block name="script"}
+<script src="/static/layDate-v5.0.9/laydate.js"></script>
+<script src="/static/browser.js"></script>
+<script src="/static/jquery.jqprint-0.3.js"></script>
+<script>
+    $(function () {
+        laydate.render({
+            elem: '#startTime',
+            trigger: 'click',
+            theme: '#0F3A87',
+            type:'year'
+        });
+    });
+    function empty_search(){
+        window.location.href = 'monthGas';
+    }
+    function printer(){
+        $('#printer').jqprint();
+    }
+
+    function excel_download(_self){
+        $("#printer").table2excel({
+            //      table2excel插件的可用配置参数有:
+            exclude: ".noExl",//   exclude:不被导出的表格行的CSS class类。
+            name: "医院每月总气体数据",//   name:导出的Excel文档的名称
+            filename: "医院每月总气体数据",//   filename:Excel文件的名称。
+            exclude_img: true,//   exclude_img:是否导出图片。
+            exclude_links: true,//   exclude_links:是否导出超链接
+            exclude_inputs: true//    exclude_inputs:是否导出输入框中的内容
+
+
+        });
+    }
+
+</script>
+{/block}

+ 456 - 0
application/admin/view/energy_statistics/month_view.html

@@ -0,0 +1,456 @@
+
+{extend name="common/common2" /}
+{block name="main"}
+<div class="ibox-content">
+    <div class="row">
+        <div class="col-xs-12" >
+            <form action="{:url('energyStatistics/monthView')}" method="POST" id='search_form' class="form-inline">
+
+                <div class="input-group" style="width: 200px">
+                    <span class="input-group-addon">年份</span>
+                    <input class="form-control dialog-datetime" id="start" name="month" type="text" data-date-format="yyyy-mm" value="{$month}" placeholder="" readonly/>
+                </div>
+
+                <div class="input-group " style="width: 200px">
+                    <span class="input-group-addon">科室</span>
+                    <select name="depId" class="form-control">
+                        {foreach $dep as $k => $v}
+                        <option value="{$v.id}" {if $depId == $v.id} selected {/if}>{$v.name}</option>
+                        {/foreach}
+                    </select>
+                </div>
+                <div class="input-group">
+                    <span class="input-group-btn">
+                        <button class="btn-sm btn-danger" type="submit"  ><i class="fa fa-search"></i></button>
+                    </span>&nbsp;
+                        <span class="input-group-btn">
+                         <button class="btn-sm btn-warning" type="reset" onclick="empty_search()"><i class="fa fa-undo"></i></button>
+                    </span>
+                </div>
+            </form>
+        </div>
+    </div>
+    <br>
+<div class="ibox">
+    <div class="panel-group">
+        <div class="panel panel-default">
+            <div class="panel-heading clearfix">
+                <div class="btn-group pull-left">
+                    {$depName}每月能耗数据分析
+                </div>
+                <div class="btn-group pull-right">
+                </div>
+            </div>
+            <div class="panel-body" id="printer">
+
+                <div id="echarts1" style="width: 100%;height: 350px">
+
+                </div>
+                <div id="echarts2" style="width: 100%;height: 350px">
+
+                </div>
+                <div id="echarts3" style="width: 100%;height: 350px">
+
+                </div>
+
+            </div>
+        </div>
+    </div>
+</div>
+</div>
+{/block}
+{block name="script"}
+<script src="/static/browser.js"></script>
+<script src="/static/jquery.jqprint-0.3.js"></script>
+<script src="/static/data/js/echarts.js"></script>
+<script>
+    $(function () {
+        laydate.render({
+            elem: '#start',
+            trigger: 'click',
+            theme: '#1d519c',
+            type: 'year',
+        });
+    });
+    function printer(){
+        $('#printer').jqprint();
+    }
+
+    function empty_search(){
+        window.location.href = "{:url('energyStatistics/monthView')}";
+    }
+
+    var colors = [ '#d14a61','#5793f3', '#91c7ae'];
+
+    var option = {
+        tooltip: {
+            trigger: 'axis',
+            axisPointer: {
+                type: 'cross',
+                crossStyle: {
+                    color: '#999'
+                }
+            }
+        },
+        legend: {
+            data: [
+                '{$month-1}用电量', '{$month}用电量',
+                '{$month}月度平均最高温度','{$month}月度平均最低温度',
+                '{$month-1}月度平均最高温度','{$month-1}月度平均最低温度',
+                '床位数量'
+            ]
+        },
+        xAxis: [
+            {
+                type: 'category',
+                data: {:json_encode($monthList)},
+        axisPointer: {
+            type: 'shadow'
+        }
+    }
+    ],
+    yAxis: [
+        {
+            type: 'value',
+            name: '使用量',
+            offset: 5,
+            splitLine:{
+                show:false
+            },
+            axisLine: {
+                show: true,
+                lineStyle: {
+                    color: colors[0],
+                }
+            },
+            axisLabel: {
+                formatter: '{value} kWh'
+            }
+        },
+        {
+            type: 'value',
+            name: '温度',
+            splitLine:{
+                show:false
+            },
+            axisLine: {
+                show: true,
+                lineStyle: {
+                    color: colors[1],
+                }
+            },
+            axisLabel: {
+                formatter: '{value} ℃'
+            }
+        },
+        {
+            type: 'value',
+            name: '床位数量',
+            position: 'right',
+            alignTicks: true,
+            offset: 60,
+            splitLine:{
+                show:false
+            },
+            axisLine: {
+                show: true,
+                lineStyle: {
+                    color: colors[2],
+                }
+            },
+            axisLabel: {
+                formatter: '{value} 个'
+            }
+        }
+    ],
+        series: [
+        {
+            name: '{$month-1}用电量',
+            type: 'bar',
+            barWidth: 12,
+            data: {:json_encode($data['lastElectricity'])},
+    },
+    {
+        name: '{$month}用电量',
+        type: 'bar',
+        barWidth: 12,
+        data: {:json_encode($data['electricity'])},
+    },
+    {
+        name: '{$month}月度平均最高温度',
+        type: 'line',
+        yAxisIndex: 1,
+        data: {:json_encode($data['tempMax'])},
+    },
+    {
+        name: '{$month}月度平均最低温度',
+        type: 'line',
+        yAxisIndex: 1,
+        data: {:json_encode($data['tempMin'])},
+    },
+    {
+        name: '{$month-1}月度平均最高温度',
+            type: 'line',
+        yAxisIndex: 1,
+        data: {:json_encode($data['LastTempMax'])},
+        lineStyle: {
+            type: 'dashed'
+        },
+    },
+    {
+        name: '{$month-1}月度平均最低温度',
+            type: 'line',
+        yAxisIndex: 1,
+        data: {:json_encode($data['LastTempMin'])},
+        lineStyle: {
+            type: 'dashed'
+        },
+        itemStyle: {
+            color: '#5470C6' // 绿色
+        }
+    },
+    {
+        name: '床位数量',
+        type: 'line',
+        yAxisIndex: 2,
+        data: {:json_encode($data['beds'])},
+        itemStyle: {
+            color: '#ee6666'
+        }
+    },
+    ]
+    };
+
+    var myChart = echarts.init(document.getElementById('echarts1'));
+    myChart.setOption(option);
+
+
+    var option2 = {
+        tooltip: {
+            trigger: 'axis',
+            axisPointer: {
+                type: 'cross',
+                crossStyle: {
+                    color: '#999'
+                }
+            }
+        },
+        legend: {
+            data: ['{$month-1}用水量', '{$month-1}用水量', '{$month}月度平均最高温度','{$month}月度平均最低温度','床位数量']
+        },
+        xAxis: [
+            {
+                type: 'category',
+                data: {:json_encode($monthList)},
+        axisPointer: {
+            type: 'shadow'
+        }
+    }
+    ],
+    yAxis: [
+        {
+            type: 'value',
+            name: '使用量',
+            offset: 5,
+            splitLine:{
+                show:false
+            },
+            axisLine: {
+                show: true,
+                lineStyle: {
+                    color: colors[0],
+                }
+            },
+            axisLabel: {
+                formatter: '{value} m³'
+            }
+        },
+        {
+            type: 'value',
+            name: '温度',
+            splitLine:{
+                show:false
+            },
+            axisLine: {
+                show: true,
+                lineStyle: {
+                    color: colors[1],
+                }
+            },
+            axisLabel: {
+                formatter: '{value} ℃'
+            }
+        },
+        {
+            type: 'value',
+            name: '床位数量',
+            position: 'right',
+            alignTicks: true,
+            offset: 60,
+            splitLine:{
+                show:false
+            },
+            axisLine: {
+                show: true,
+                lineStyle: {
+                    color: colors[2],
+                }
+            },
+            axisLabel: {
+                formatter: '{value} 个'
+            }
+        }
+    ],
+        series: [
+        {
+            name: '{$month-1}用水量',
+            type: 'bar',
+            barWidth: 12,
+            data: {:json_encode($data['lastWater'])},
+    },
+    {
+        name: '{$month}用水量',
+            type: 'bar',
+        barWidth: 12,
+        data: {:json_encode($data['water'])},
+    },
+    {
+        name: '{$month}月度平均最高温度',
+        type: 'line',
+        yAxisIndex: 1,
+        data: {:json_encode($data['tempMax'])},
+    },
+    {
+        name: '{$month}月度平均最低温度',
+        type: 'line',
+        yAxisIndex: 1,
+        data: {:json_encode($data['tempMin'])},
+    },
+    {
+        name: '床位数量',
+            type: 'line',
+        yAxisIndex: 2,
+        data: {:json_encode($data['beds'])},
+    },
+    ]
+    };
+
+    var myChart2 = echarts.init(document.getElementById('echarts2'));
+    myChart2.setOption(option2);
+
+
+    var option3 = {
+        tooltip: {
+            trigger: 'axis',
+            axisPointer: {
+                type: 'cross',
+                crossStyle: {
+                    color: '#999'
+                }
+            }
+        },
+        legend: {
+            data: ['{$month-1}燃气用量', '{$month}燃气用量', '{$month}月度平均最高温度','{$month}月度平均最低温度','床位数量']
+        },
+        xAxis: [
+            {
+                type: 'category',
+                data: {:json_encode($monthList)},
+                axisPointer: {
+                    type: 'shadow'
+                }
+            }
+        ],
+        yAxis: [
+            {
+                type: 'value',
+                name: '使用量 ',
+                offset: 5,
+                splitLine:{
+                    show:false
+                },
+                axisLine: {
+                    show: true,
+                    lineStyle: {
+                        color: colors[0],
+                    }
+                },
+                axisLabel: {
+                    formatter: '{value} m³'
+                }
+            },
+            {
+                type: 'value',
+                name: '温度',
+                splitLine:{
+                    show:false
+                },
+                axisLine: {
+                    show: true,
+                    lineStyle: {
+                        color: colors[1],
+                    }
+                },
+                axisLabel: {
+                    formatter: '{value} ℃'
+                }
+            },
+            {
+                type: 'value',
+                name: '床位数量',
+                position: 'right',
+                alignTicks: true,
+                offset: 60,
+                splitLine:{
+                    show:false
+                },
+                axisLine: {
+                    show: true,
+                    lineStyle: {
+                        color: colors[2],
+                    }
+                },
+                axisLabel: {
+                    formatter: '{value} 个'
+                }
+            }
+        ],
+        series: [
+            {
+                name: '{$month-1}燃气用量',
+                type: 'bar',
+                barWidth: 12,
+                data: {:json_encode($data['lastGas'])},
+            },
+        {
+            name: '{$month}燃气用量',
+                type: 'bar',
+            barWidth: 12,
+            data: {:json_encode($data['gas'])},
+        },
+        {
+            name: '{$month}月度平均最高温度',
+            type: 'line',
+            yAxisIndex: 1,
+            data: {:json_encode($data['tempMax'])},
+        },
+        {
+            name: '{$month}月度平均最低温度',
+            type: 'line',
+            yAxisIndex: 1,
+            data: {:json_encode($data['tempMin'])},
+        },
+        {
+            name: '床位数量',
+            type: 'line',
+            yAxisIndex: 2,
+            data: {:json_encode($data['beds'])},
+        },
+        ]
+    };
+
+    var myChart3 = echarts.init(document.getElementById('echarts3'));
+    myChart3.setOption(option3);
+
+</script>
+{/block}

+ 146 - 0
application/admin/view/energy_statistics/month_water.html

@@ -0,0 +1,146 @@
+{extend name="common/common2" /}
+{block name="main"}
+<style>
+    .table th{
+        text-align: center;
+        background: #ffffff;
+    }
+    .table tr{
+        background: #ffffff;
+    }
+    .table td{
+        text-align: center;
+    }
+</style>
+<div class="ibox-content">
+<div class="ibox">
+
+    <div class="alert">
+        <form action="monthWater" method="GET" id='search_form' class="form-inline">
+            <div class="input-group" style="width: 200px">
+                <span class="input-group-addon">选择日期</span>
+                <input class="form-control dialog-datetime" id="startTime" name="start" type="text"  value="{$start}" placeholder="" readonly/>
+            </div>
+
+            <div class="input-group">
+            <span class="input-group-btn">
+                <button class="btn-sm btn-danger" type="submit"  ><i class="fa fa-search"></i></button>
+			</span>&nbsp;
+                <span class="input-group-btn">
+                     <button class="btn-sm btn-warning" type="reset" onclick="empty_search()"><i class="fa fa-undo"></i></button>
+            </span>
+            </div>
+        </form>
+    </div>
+
+    <div class="panel-group">
+        <div class="panel panel-default">
+            <div class="panel-heading clearfix">
+                <div class="btn-group pull-left">
+                    医院每月总水表数据统计
+                </div>
+                <div class="btn-group pull-right">
+                    <a href="javascript:;" onclick="printer()" class="btn btn-sm btn btn-primary"><i class="glyphicon glyphicon-print"></i>打印</a>
+                    <a href="javascript:;" onclick="excel_download(this)" class="btn btn-other btn-sm"><i class="glyphicon glyphicon-download"></i>导出</a>
+                </div>
+            </div>
+            <div class="panel-body" id="printer">
+                <table class="table table-bordered">
+
+                    <thead>
+                    <tr hidden><td colspan="5"><h1  style="text-align: center">医院每日总水表数据统计</h1></td></tr>
+                    <tr hidden><td colspan="5"><h3 style="float: right">{$date}</h3></td></tr>
+                        <tr>
+                            <th >日期</th>
+                            <th >表号</th>
+                            <th >使用量</th>
+                            <th >合计使用量</th>
+                        </tr>
+                    </thead>
+                    {if $totalData == 0}
+                    <tbody>
+                        <tr>
+                            <td colspan="5">暂无数据</td>
+                        </tr>
+                    </tbody>
+                    {else/}
+                    <tbody>
+                        <!-- 下面注释不能删除!!! -->
+<!--                        {$rowNumber = 1}-->
+                        {foreach $data as $k=>$v}
+                        {for start="0" end="$count"}
+                        {if $rowNumber % $count == 1}
+                        <tr>
+                            <td rowspan="{$count}">{$k+1}</td>
+                            <td>{$v[$i]['sn']|default=''}</td>
+                            <td>{$v[$i]['real_degree']|default=''}</td>
+                            <td rowspan="{$count}">
+                                {$v.total}
+                            </td>
+                            {else /}
+                            {if $i == $count-1}
+                        <tr>
+                            <td>实际热水用量</td>
+                            <td>{$v['hot_degree']}</td>
+                        {else/}
+                        <tr>
+                            <td>{$v[$i]['sn']|default=''}</td>
+                            <td>{$v[$i]['real_degree']|default=''}</td>
+                            {/if}
+                            {/if}
+                            <!-- 下面注释不能删除!!! -->
+<!--                            {$rowNumber = $rowNumber + 1}-->
+                        {if $rowNumber % $count == 0}
+                        <!-- 重置总使用量 -->
+                        {/if}
+                        {/for}
+                        {/foreach}
+                            <tr>
+                                <td>共计:</td>
+                                <td colspan="4">{$totalData}</td>
+                            </tr>
+                    </tbody>
+                    {/if}
+                </table>
+            </div>
+        </div>
+    </div>
+</div>
+</div>
+{/block}
+{block name="script"}
+<script src="/static/layDate-v5.0.9/laydate.js"></script>
+<script src="/static/browser.js"></script>
+<script src="/static/jquery.jqprint-0.3.js"></script>
+<script>
+    $(function () {
+        laydate.render({
+            elem: '#startTime',
+            trigger: 'click',
+            theme: '#0F3A87',
+            type:'year'
+        });
+    });
+    function empty_search(){
+        window.location.href = 'monthWater';
+    }
+    function printer(){
+        $('#printer').jqprint();
+    }
+
+    function excel_download(_self){
+        $("#printer").table2excel({
+            //      table2excel插件的可用配置参数有:
+            exclude: ".noExl",//   exclude:不被导出的表格行的CSS class类。
+            name: "医院每月总水表数据",//   name:导出的Excel文档的名称
+            filename: "医院每月总水表数据",//   filename:Excel文件的名称。
+            exclude_img: true,//   exclude_img:是否导出图片。
+            exclude_links: true,//   exclude_links:是否导出超链接
+            exclude_inputs: true//    exclude_inputs:是否导出输入框中的内容
+
+
+        });
+    }
+
+</script>
+{/block}

+ 143 - 0
application/admin/view/energy_statistics/public_dep_electricity.html

@@ -0,0 +1,143 @@
+{extend name="common/common2" /}
+{block name="main"}
+<style>
+    .table th{
+        text-align: center;
+        background: #ffffff;
+    }
+    .table tr{
+        background: #ffffff;
+    }
+    .table td{
+        text-align: center;
+    }
+</style>
+<div class="ibox-content">
+<div class="ibox">
+    <div class="alert">
+        <form action="publicDepElectricity" method="GET" id='search_form' class="form-inline">
+            <div class="input-group" style="width: 200px">
+                <span class="input-group-addon">选择日期</span>
+                <input class="form-control dialog-datetime" id="startTime" name="start" type="text" data-date-format="yyyy-mm-dd" value="{$start}" placeholder="" readonly/>
+            </div>
+
+            <div class="input-group" style="width: 200px">
+                <span class="input-group-addon">分摊方式</span>
+                <select name="type" class="form-control">
+                    <option value="0" {if $type =='0'}selected {/if}>面积占比</option>
+                    <option value="1" {if $type =='1'}selected {/if}>电量能耗占比</option>
+                </select>
+            </div>
+
+            <div class="input-group">
+            <span class="input-group-btn">
+                <button class="btn-sm btn-danger" type="submit"  ><i class="fa fa-search"></i></button>
+			</span>&nbsp;
+                <span class="input-group-btn">
+                     <button class="btn-sm btn-warning" type="reset" onclick="empty_search()"><i class="fa fa-undo"></i></button>
+            </span>
+            </div>
+        </form>
+    </div>
+
+    <div class="panel-group">
+        <div class="panel panel-default">
+            <div class="panel-heading clearfix">
+                <div class="btn-group pull-left">
+                    {if $type == '0'}
+                    月度科室公用设备电量面积占比分摊表
+                    {else/}
+                    月度科室公用设备电量量能耗占比分摊表
+                    {/if}
+                </div>
+                <div class="btn-group pull-right">
+                    <a href="javascript:;" onclick="printer()" class="btn btn-sm btn btn-primary"><i class="glyphicon glyphicon-print"></i>打印</a>
+                    <a href="javascript:;" onclick="excel_download(this)" class="btn btn-other btn-sm"><i class="glyphicon glyphicon-download"></i>导出</a>
+                </div>
+            </div>
+            <div class="panel-body" id="printer">
+                <table class="table table-bordered">
+
+                    <thead>
+                        <th>序号</th>
+                        <th>楼号</th>
+                        <th>楼层</th>
+                        <th>科室</th>
+                        {if $type == '0'}
+                        <th>面积占比</th>
+                        {else/}
+                        <th>能耗占比</th>
+                        {/if}
+                        {foreach $device as $k => $v}
+                        <th>{$v}</th>
+                        {/foreach}
+                        <th>分摊合计</th>
+                    </thead>
+                   <tbody>
+                   {if empty($data)}
+                   <tr>
+                       <td colspan="6">暂无数据</td>
+                   </tr>
+                   {/if}
+                   {foreach $data as $k => $v}
+                   <tr>
+                       <td>{$k+1}</td>
+                       <td>{$v['floor1']}</td>
+                       <td>{$v['floor2']}</td>
+                       <td>{$v['name']}</td>
+                       <td>{$v['publicPercent']*100}%</td>
+                       {foreach $device as $k2 =>$v2}
+                           <td>{$v['data'][$k2]|default=0}</td>
+                       {/foreach}
+                       <td>{$v['total']|default=0}</td>
+                   </tr>
+                   {/foreach}
+                   </tbody>
+                </table>
+            </div>
+        </div>
+    </div>
+</div>
+</div>
+{/block}
+{block name="script"}
+<script src="/static/layDate-v5.0.9/laydate.js"></script>
+<script src="/static/browser.js"></script>
+<script src="/static/jquery.jqprint-0.3.js"></script>
+<script>
+    $(function () {
+        laydate.render({
+            elem: '#startTime',
+            trigger: 'click',
+            theme: '#0F3A87',
+            type:'month'
+        });
+        laydate.render({
+            elem: '#endTime',
+            trigger: 'click',
+            theme: '#0F3A87'
+        });
+    });
+    function empty_search(){
+        window.location.href = 'publicDepElectricity';
+    }
+    function printer(){
+        $('#printer').jqprint();
+    }
+
+    function excel_download(_self){
+        $("#printer").table2excel({
+            //      table2excel插件的可用配置参数有:
+            exclude: ".noExl",//   exclude:不被导出的表格行的CSS class类。
+            name: "科室公用设备电量分摊",//   name:导出的Excel文档的名称
+            filename: "科室公用设备电量分摊",//   filename:Excel文件的名称。
+            exclude_img: true,//   exclude_img:是否导出图片。
+            exclude_links: true,//   exclude_links:是否导出超链接
+            exclude_inputs: true//    exclude_inputs:是否导出输入框中的内容
+
+
+        });
+    }
+
+</script>
+{/block}

+ 226 - 0
application/admin/view/energy_statistics/public_dep_total.html

@@ -0,0 +1,226 @@
+{extend name="common/common2" /}
+{block name="main"}
+<style>
+    .table th{
+        text-align: center;
+        background: #ffffff;
+    }
+    .table tr{
+        background: #ffffff;
+    }
+    .table td{
+        text-align: center;
+        max-width:100px ;
+    }
+    /* 基本表格元素 */
+    table {
+        border-collapse: collapse;
+    }
+    th,td {
+        border: 1px solid #666;
+        padding: 5px;
+    }
+    .split {
+        height: 50px;
+     }
+
+    /* th单元格 */
+    .slash-wrap {
+        position: relative;
+        box-sizing: border-box;
+        width: 150px;
+        height: 80px;
+    }
+
+    /* 斜线 */
+    .slash {
+        position: absolute;
+        display: block;
+        top: 0;
+        left: 0;
+        /* 斜边边长 */
+        /* Math.sqrt(Math.pow(width, 2) + Math.pow(height, 2)) */
+        /* Math.sqrt(Math.pow(150, 2) + Math.pow(80, 2)) = 170 */
+        width: 234px;
+        height: 1px;
+        background-color:#666;
+        /* 旋转角度计算公式 */
+        /*  Math.atan(height / width) * 180 / Math.PI  */
+        /*  Math.atan(80 / 150) * 180 / Math.PI  = 28.072486935852954 */
+        transform: rotate(12.072486935852954deg);
+        transform-origin: top left;
+    }
+    .slash2 {
+        position: absolute;
+        display: block;
+        top: 0;
+        left: 0;
+        width: 158px;
+        height: 1px;
+        background-color:#666;
+        transform: rotate(30.5deg);
+        transform-origin: top left;
+    }
+
+    /* 左下角文字 */
+    .left {
+        position: absolute;
+        /* 左下角 left:0; bottom: 0; */
+        left: 15px;
+        bottom: 15px;
+    }
+    /* 中间文字 */
+    .middle {
+        position: absolute;
+        /* 左下角 left:0; bottom: 0; */
+        left: 148px;
+        bottom: 10px;
+    }
+
+    /* 右上角文字 */
+    .right {
+        position: absolute;
+        /* 右上角 right:0; top: 0; */
+        right: 15px;
+        top: 15px;
+    }
+</style>
+<div class="ibox-content">
+<div class="ibox">
+    <div class="alert">
+        <form action="publicDepTotal" method="GET" id='search_form' class="form-inline">
+            <div class="input-group" style="width: 200px">
+                <span class="input-group-addon">选择日期</span>
+                <input class="form-control dialog-datetime" id="startTime" name="start" type="text" data-date-format="yyyy-mm-dd" value="{$start}" placeholder="" readonly/>
+            </div>
+
+            <div class="input-group" style="width: 200px">
+                <span class="input-group-addon">分摊方式</span>
+                <select name="type" class="form-control">
+                    <option value="0" {if $type =='0'}selected {/if}>面积占比</option>
+                    <option value="1" {if $type =='1'}selected {/if}>电量能耗占比</option>
+                </select>
+            </div>
+
+            <div class="input-group">
+            <span class="input-group-btn">
+                <button class="btn-sm btn-danger" type="submit"  ><i class="fa fa-search"></i></button>
+			</span>&nbsp;
+                <span class="input-group-btn">
+                     <button class="btn-sm btn-warning" type="reset" onclick="empty_search()"><i class="fa fa-undo"></i></button>
+            </span>
+            </div>
+        </form>
+    </div>
+
+    <div class="panel-group">
+        <div class="panel panel-default">
+            <div class="panel-heading clearfix">
+                <div class="btn-group pull-left">
+                    科室水、电总使用量
+                </div>
+                <div class="btn-group pull-right">
+                    <a href="javascript:;" onclick="printer()" class="btn btn-sm btn btn-primary"><i class="glyphicon glyphicon-print"></i>打印</a>
+                    <a href="javascript:;" onclick="excel_download(this)" class="btn btn-other btn-sm"><i class="glyphicon glyphicon-download"></i>导出</a>
+                </div>
+            </div>
+            <div class="panel-body" id="printer">
+                <table class="table table-bordered">
+
+                    <thead>
+                    <th class="slash-wrap" colspan="2">
+                        <span class="left">科室</span>
+                        <span class="slash"></span>
+                        <span class="middle">水、电量</span>
+                        <span class="slash2"></span>
+                        <span class="right">月份</span>
+                    </th>
+                        {foreach $monthList as $v}
+                        <th>{$v}</th>
+                        {/foreach}
+                        <th>总计</th>
+                    </thead>
+                   <tbody>
+                   {if empty($data)}
+                   <tr>
+                       <td colspan="15">暂无数据</td>
+                   </tr>
+                   {/if}
+                   {foreach $data as $k=>$v}
+                   <tr>
+                       <td rowspan="4">{$v['name']}</td>
+                       <td>合计水量</td>
+                       {foreach $monthList as $k2 =>$v2}
+                       <td>{$v['water'][$k2]|default=0}</td>
+                       {/foreach}
+                       <td rowspan="2">{$v['totalWater']}</td>
+                   </tr>
+                   <tr>
+                       <td>分摊水量</td>
+                       {foreach $monthList as $k3 =>$v3}
+                       <td>{$v['splitWater'][$k3]|default=0}</td>
+                       {/foreach}
+                   </tr>
+                   <tr>
+                       <td>合计电量</td>
+                       {foreach $monthList as $k4=>$v4}
+                       <td>{$v['electricity'][$k4]|default=0}</td>
+                       {/foreach}
+                       <td rowspan="2">{$v['totalElectricity']}</td>
+                   </tr>
+                   <tr>
+                       <td>分摊电量</td>
+                       {foreach $monthList as $k5 => $v5}
+                       <td>{$v['splitElectricity'][$k5]|default=0}</td>
+                       {/foreach}
+                   </tr>
+                   {/foreach}
+                   </tbody>
+                </table>
+            </div>
+        </div>
+    </div>
+</div>
+</div>
+{/block}
+{block name="script"}
+<script src="/static/layDate-v5.0.9/laydate.js"></script>
+<script src="/static/browser.js"></script>
+<script src="/static/jquery.jqprint-0.3.js"></script>
+<script>
+    $(function () {
+        laydate.render({
+            elem: '#startTime',
+            trigger: 'click',
+            theme: '#0F3A87',
+            type:'year'
+        });
+        laydate.render({
+            elem: '#endTime',
+            trigger: 'click',
+            theme: '#0F3A87'
+        });
+    });
+    function empty_search(){
+        window.location.href = 'publicDepTotal';
+    }
+    function printer(){
+        $('#printer').jqprint();
+    }
+
+    function excel_download(_self){
+        $("#printer").table2excel({
+            //      table2excel插件的可用配置参数有:
+            exclude: ".noExl",//   exclude:不被导出的表格行的CSS class类。
+            name: "科室水、电总使用量",//   name:导出的Excel文档的名称
+            filename: "科室水、电总使用量",//   filename:Excel文件的名称。
+            exclude_img: true,//   exclude_img:是否导出图片。
+            exclude_links: true,//   exclude_links:是否导出超链接
+            exclude_inputs: true//    exclude_inputs:是否导出输入框中的内容
+
+
+        });
+    }
+
+</script>
+{/block}

+ 137 - 0
application/admin/view/energy_statistics/public_dep_water.html

@@ -0,0 +1,137 @@
+{extend name="common/common2" /}
+{block name="main"}
+<style>
+    .table th{
+        text-align: center;
+        background: #ffffff;
+    }
+    .table tr{
+        background: #ffffff;
+    }
+    .table td{
+        text-align: center;
+    }
+</style>
+<div class="ibox-content">
+<div class="ibox">
+    <div class="alert">
+        <form action="publicDepWater" method="GET" id='search_form' class="form-inline">
+            <div class="input-group" style="width: 200px">
+                <span class="input-group-addon">选择日期</span>
+                <input class="form-control dialog-datetime" id="startTime" name="start" type="text" data-date-format="yyyy-mm-dd" value="{$start}" placeholder="" readonly/>
+            </div>
+
+            <div class="input-group" style="width: 200px">
+                <span class="input-group-addon">分摊方式</span>
+                <select name="type" class="form-control">
+                    <option value="0" {if $type =='0'}selected {/if}>面积占比</option>
+                    <option value="1" {if $type =='1'}selected {/if}>电量能耗占比</option>
+                </select>
+            </div>
+
+            <div class="input-group">
+            <span class="input-group-btn">
+                <button class="btn-sm btn-danger" type="submit"  ><i class="fa fa-search"></i></button>
+			</span>&nbsp;
+                <span class="input-group-btn">
+                     <button class="btn-sm btn-warning" type="reset" onclick="empty_search()"><i class="fa fa-undo"></i></button>
+            </span>
+            </div>
+        </form>
+    </div>
+
+    <div class="panel-group">
+        <div class="panel panel-default">
+            <div class="panel-heading clearfix">
+                <div class="btn-group pull-left">
+                    {if $type == '0'}
+                    月度科室公用水量面积占比分摊表
+                    {else/}
+                    月度科室公用水量能耗占比分摊表
+                    {/if}
+                </div>
+                <div class="btn-group pull-right">
+                    <a href="javascript:;" onclick="printer()" class="btn btn-sm btn btn-primary"><i class="glyphicon glyphicon-print"></i>打印</a>
+                    <a href="javascript:;" onclick="excel_download(this)" class="btn btn-other btn-sm"><i class="glyphicon glyphicon-download"></i>导出</a>
+                </div>
+            </div>
+            <div class="panel-body" id="printer">
+                <table class="table table-bordered">
+
+                    <thead>
+                        <th>序号</th>
+                        <th>楼号</th>
+                        <th>楼层</th>
+                        <th>科室</th>
+                        {if $type == '0'}
+                        <th>面积占比</th>
+                        {else/}
+                        <th>能耗占比</th>
+                        {/if}
+                        <th>分摊水量(m³)</th>
+                    </thead>
+                   <tbody>
+                   {if empty($data)}
+                   <tr>
+                       <td colspan="6">暂无数据</td>
+                   </tr>
+                   {/if}
+                        {foreach $data as $k => $v}
+                        <tr>
+                            <td>{$k+1}</td>
+                            <td>{$v['floor1']}</td>
+                            <td>{$v['floor2']}</td>
+                            <td>{$v['name']}</td>
+                            <td>{$v['publicPercent']*100}%</td>
+                            <td>{$v['splitDegree']}</td>
+                        </tr>
+                        {/foreach}
+                   </tbody>
+                </table>
+            </div>
+        </div>
+    </div>
+</div>
+</div>
+{/block}
+{block name="script"}
+<script src="/static/layDate-v5.0.9/laydate.js"></script>
+<script src="/static/browser.js"></script>
+<script src="/static/jquery.jqprint-0.3.js"></script>
+<script>
+    $(function () {
+        laydate.render({
+            elem: '#startTime',
+            trigger: 'click',
+            theme: '#0F3A87',
+            type:'month'
+        });
+        laydate.render({
+            elem: '#endTime',
+            trigger: 'click',
+            theme: '#0F3A87'
+        });
+    });
+    function empty_search(){
+        window.location.href = 'publicDepWater';
+    }
+    function printer(){
+        $('#printer').jqprint();
+    }
+
+    function excel_download(_self){
+        $("#printer").table2excel({
+            //      table2excel插件的可用配置参数有:
+            exclude: ".noExl",//   exclude:不被导出的表格行的CSS class类。
+            name: "科室公用水量分摊",//   name:导出的Excel文档的名称
+            filename: "科室公用水量分摊",//   filename:Excel文件的名称。
+            exclude_img: true,//   exclude_img:是否导出图片。
+            exclude_links: true,//   exclude_links:是否导出超链接
+            exclude_inputs: true//    exclude_inputs:是否导出输入框中的内容
+
+
+        });
+    }
+
+</script>
+{/block}

+ 218 - 0
application/admin/view/energy_water/add.html

@@ -0,0 +1,218 @@
+{extend name="common/common2" /}
+{block name="main"}
+<style>
+    /*.el-select .el-input {*/
+    /*    width: 130px;*/
+    /*}*/
+    .input-with-select .el-input-group__prepend {
+        background-color: #fff;
+    }
+
+</style>
+<div class="row" id="formApp">
+    <div class="col-sm-12">
+        <div class="ibox float-e-margins">
+            <div class="ibox-content">
+                <form method="post" action="{:url('add')}" class="form-horizontal">
+                    <input type="hidden" name="parent_id" value="{$pid}">
+                    <input type="hidden" name="id" value="{$info['id']|default='0'}">
+                    <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="name" value="{$info.name|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">
+                            <input type="text" class="form-control" name="number" value="{$info.number|default=''}">
+                        </div>
+                    </div>
+
+                    <div class="form-group">
+                        <label class="col-sm-2 control-label">分类<span class="text-danger">*</span></label>
+                        <input type="hidden" id="ele-type_e" name="type_w" :value="value2">
+                        <div class="col-sm-6">
+                            <el-select
+                                    v-model="value2"
+                                    filterable
+                                    size="small"
+                                    style="width:100%"
+                                    placeholder="请选择"
+                            >
+                                <el-option label="冷水" value=0></el-option>
+                                <el-option label="热水进水" value=1></el-option>
+                                <el-option label="热水回水" value=2></el-option>
+                            </el-select>
+                        </div>
+                    </div>
+
+                    {if condition="$pid != 0"}
+                    <div class="form-group">
+                        <label class="col-sm-2 control-label">地点<span class="text-danger">*</span></label>
+                        <input type="hidden" name="address" :value="JSON.stringify(selectedValue)">
+                        <div class="col-sm-6">
+                            <el-cascader
+                                    v-model="selectedValue"
+                                    :options="options"
+                                    :props="props"
+                                    style="width:100%"
+                                    @change="handleChange"
+                                    filterable
+                                    clearable>
+                            </el-cascader>
+                        </div>
+                    </div>
+
+                    <div class="form-group">
+                        <label class="col-sm-2 control-label">科室<span class="text-danger">*</span></label>
+                        <input type="hidden" id="ele-dep" name="dep" :value="value">
+                        <div class="col-sm-6">
+                            <el-select
+                                    v-model="value"
+                                    multiple
+                                    filterable
+                                    size="small"
+                                    style="width:100%"
+                                    placeholder="请选择"
+                            >
+                                <el-option
+                                        v-for="item in options2"
+                                        :key="item.id"
+                                        :label="item.name"
+                                        :value="item.id.toString()">
+                                </el-option>
+                            </el-select>
+                        </div>
+                    </div>
+
+                    <div v-if="value.length>1" class="form-group">
+                        <label class="col-sm-2 control-label">用水分摊</label>
+                        <div class="col-sm-6">
+                            <el-input  placeholder="请输入分摊比例,例如2:3:5 (如按面积分摊不用填此项)" v-model="input" class="input-with-select" name="percent">
+                                <el-select
+                                        v-model="select"
+                                        slot="prepend"
+                                        placeholder="分摊方式"
+                                        style="width: 130px" >
+                                    <el-option label="按面积" value=0></el-option>
+                                    <el-option label="按比例" value=1></el-option>
+                                </el-select>
+                            </el-input>
+                            <input type="hidden" id="ele-share" name="share" :value="select">
+                        </div>
+                    </div>
+                    {/if}
+
+                    <div class="form-group">
+                        <label class="col-sm-2 control-label">备注</label>
+                        <div class="col-sm-6">
+                            <textarea name="remark" class="form-control" rows="3">{$info.remark|default=''}</textarea>
+                        </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="hr-line-dashed"></div>
+                    <div class="form-group">
+                        <div class="col-sm-6 col-sm-offset-2">
+                            <button class="btn btn-primary ajax-post" data-layer="1" target-form="form-horizontal" type="submit">确 定</button>
+                        </div>
+                    </div>
+                </form>
+            </div>
+        </div>
+    </div>
+</div>
+{/block}
+{block name="script"}
+<script>
+    $('#patient').hide();
+    new Vue({
+        el: '#formApp',
+        data: function() {
+            return {
+                props: { value: 'id', label: 'title' },
+                options:{:json_encode($alist)},
+                options2: {:json_encode($dlist)},
+                value: {:json_encode($info.dep ?? [])},
+                value2: '{$info.type_w|default=""}',
+                selectedValue:{$info.address|default=0},
+                select: '{$info.share|default="0"}',
+                input: '{$info.percent|default=""}',
+        }
+        },
+        watch: {
+            value: function (newVal, oldVal) {
+                $('#ele-dep').val(newVal.join(','));
+            }
+        },
+        methods: {
+            handleChange(value) {
+                // 当级联选择器的值改变时,发送Ajax请求
+                $.ajax({
+                    url: '/admin/energy_electricity/getDep', // 后端接口地址
+                    type: 'POST',
+                    // contentType: 'application/json',
+                    data: {param:JSON.stringify(value)},
+                    success: (response) => {
+                        // 假设后端响应的数据是一个数组,并将其赋值给list
+                        this.options2 = response.data;
+                    },
+                    error: (xhr, status, error) => {
+                        console.error('请求失败:', error);
+                        // 处理错误情况
+                    }
+                });
+                        this.value='';
+                        this.select = '';
+                        this.input = '';
+            },
+
+        },
+        mounted(){
+            $.ajax({
+                url: '/admin/energy_electricity/getDep', // 后端接口地址
+                type: 'POST',
+                // contentType: 'application/json',
+                data: {param:JSON.stringify(this.selectedValue)},
+                success: (response) => {
+                    // 假设后端响应的数据是一个数组,并将其赋值给list
+                    this.options2 = response.data;
+                    if (this.selectedValue == 0){
+                        this.options2 = [];
+                    }
+                },
+                error: (xhr, status, error) => {
+                    console.error('请求失败:', error);
+                    // 处理错误情况
+                }
+            });
+        }
+        // created(){
+        //     const vals = this.value;
+        //     this.value = [];
+        //     vals.forEach((item) => {
+        //         this.value.push(item.toString());
+        //     })
+        // }
+
+    })
+    $(document).ready(function(){
+        formSetValue("enable", {$info.enable|default=1});
+    });
+    window.addEventListener('touchstart',function () {
+    },{ passive: false });
+</script>
+{/block}

+ 38 - 0
application/admin/view/energy_water/index.html

@@ -0,0 +1,38 @@
+{extend name="common/common2" /}
+{block name="main"}
+
+<div class="ibox">
+    <div class="ibox-title">
+        <h5>水表管理</h5>
+        <div  style="float: right;margin-right: 200px">
+            <a url="{:url('add',['pid'=>0])}" href="javascript:;" data-title="添加总表" onclick="layer_open(this,2)"><span class="label label-info" title="添加总表">添加总表</span></a>
+        </div>
+    </div>
+    <div class="ibox-content">
+        <table class="table table-striped">
+            <thead>
+            <tr>
+                <th>编号</th>
+                <th>表名</th>
+                <th>表号</th>
+                <th>备注</th>
+                <th>状态</th>
+                <th>水表类型</th>
+                <th>分类</th>
+                <th>操作</th>
+            </tr>
+            </thead>
+            <tbody>
+            {if condition="$tree"}
+            {:widget_view('energy_water/tree',['data'=>$tree,'depth'=>0])}
+            {/if}
+            </tbody>
+        </table>
+    </div>
+</div>
+{/block}
+{block name="script"}
+<script>
+
+</script>
+{/block}

+ 75 - 0
application/admin/view/energy_water/split.html

@@ -0,0 +1,75 @@
+{extend name="common/common2" /}
+{block name="main"}
+<style>
+    /*.el-select .el-input {*/
+    /*    width: 130px;*/
+    /*}*/
+    .input-with-select .el-input-group__prepend {
+        background-color: #fff;
+    }
+
+</style>
+<div class="row" id="formApp">
+    <div class="col-sm-12">
+        <div class="ibox float-e-margins">
+            <div class="ibox-content">
+                <form method="post" action="{:url('split')}" class="form-horizontal">
+                    <input type="hidden" name="id" value="{$id|default='0'}">
+
+                    <div class="form-group">
+                        <label class="col-sm-2 control-label">拆分水表<span class="text-danger">*</span></label>
+                        <input type="hidden" id="ele-split" name="split" :value="value">
+                        <div class="col-sm-6">
+                            <el-select
+                                    v-model="value"
+                                    multiple
+                                    filterable
+                                    size="small"
+                                    style="width:100%"
+                                    placeholder="请选择拆分的水表"
+                            >
+                                <el-option
+                                        v-for="item in options"
+                                        :key="item.id"
+                                        :label="item.number"
+                                        :value="item.id">
+                                </el-option>
+                            </el-select>
+                        </div>
+                    </div>
+
+                    <div class="hr-line-dashed"></div>
+                    <div class="form-group">
+                        <div class="col-sm-6 col-sm-offset-2">
+                            <button class="btn btn-primary ajax-post" data-layer="1" target-form="form-horizontal" type="submit">确 定</button>
+                        </div>
+                    </div>
+                </form>
+            </div>
+        </div>
+    </div>
+</div>
+{/block}
+{block name="script"}
+<script>
+    $('#patient').hide();
+    new Vue({
+        el: '#formApp',
+        data: function() {
+            return {
+                options: {:json_encode($list)},
+            value: [{$info.split|default=''}],
+        }
+        },
+        methods: {
+
+        },
+        mounted(){
+
+        }
+
+    })
+    window.addEventListener('touchstart',function () {
+    },{ passive: false });
+</script>
+{/block}

+ 46 - 0
application/admin/view/energy_water/tree.html

@@ -0,0 +1,46 @@
+{volist name="data" id="v"}
+<tr>
+    <td style="width: 60px;">{$v.id}</td>
+    <td style="text-indent:{$depth * 2}em;">
+        {if condition="isset($v['children']) && !empty($v['children'])"}
+        <i class="glyphicon glyphicon-folder-open"></i>
+        {else /}
+        <i class="glyphicon glyphicon-list-alt"></i>
+        {/if}
+        {$v.name}
+    </td>
+    <td style="width: 110px;">{$v.number}</td>
+    <td style="width: 110px;">{$v.remark}</td>
+    <td style="width: 80px;">
+        {if condition="$v['enable'] == 0"}
+        <a href="{:url('changeEnable',['id'=>$v['id'],'enable'=>1])}" data-confirm="确定要启用该记录吗?" class="ajax-get confirm data-reload"><span class="label label-danger" title="禁用">禁用</span></a>
+        {else /}
+        <a href="{:url('changeEnable',['id'=>$v['id'],'enable'=>0])}" data-confirm="确定要禁用该记录吗?" class="ajax-get confirm data-reload"><span class="label label-warning" title="启用">启用</span></a>
+        {/if}
+    </td>
+    <td style="width: 80px;">
+        {if condition="$v['parent_id'] == 0"}
+            总表
+        {else/}
+            分表
+        {/if}
+    </td>
+    <td style="width: 80px;">
+        {$v.type_w}
+    </td>
+    <td style="width: 300px;">
+        <a url="{:url('add',['id'=>$v['id'],'pid'=>$v['parent_id'],'t'=>1])}" href="javascript:;" data-title="编辑" onclick="layer_open(this,2)"><span class="label label-other" title="编辑">编辑</span></a>
+        <a url="{:url('add',['pid'=>$v['id'],'t'=>1])}" href="javascript:;" data-title="添加子水表" onclick="layer_open(this,2)"><span class="label label-info" title="添加子水表">添加子水表</span></a>
+        {if $v['parent_id'] != 0 && $v['type_w'] == '冷水'}
+        <a url="{:url('split',['id'=>$v['id']])}" href="javascript:;" data-title="拆分水表" data-width="70%" data-height="70%" onclick="layer_open(this,2)"><span class="label label-primary" title="拆分水表">拆分水表</span></a>
+        {/if}
+        {if condition="$v['parent_id'] == 0"}
+        <a href="{:url('change',['sn'=>$v['number']])}"  data-confirm="换表后新表将会自动追加旧抄表读数" class="ajax-get confirm"><span class="label label-primary" title="换表">换表</span></a>
+        {/if}
+        <a href="{:url('del',['id'=>$v['id']])}" { data-confirm="确定要删除该记录吗?" class="ajax-get confirm"><span class="label label-danger" title="删除">删除</span></a>
+    </td>
+</tr>
+{if condition="isset($v['children']) && !empty($v['children'])"}
+{:widget_view('energy_water/tree',['data'=>$v['children'],'depth'=>$depth + 1])}
+{/if}
+{/volist}

+ 79 - 0
application/admin/view/energy_water_record/add.html

@@ -0,0 +1,79 @@
+{extend name="common/common2" /}
+{block name="main"}
+<div class="row">
+    <div class="col-sm-12">
+        <div class="ibox float-e-margins">
+            <div class="ibox-content">
+                <form method="post" action="{:url('add')}" class="form-horizontal">
+                    <input type="hidden" name="id" value="{$info['id']|default='0'}">
+                    <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="sn" value="{$info.sn|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">
+                            <input type="number" class="form-control" name="degree" value="{$info.degree|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">
+                           <input class="form-control " id="readTime" name="read_time" type="text" value="{$info.read_time|default=''}"  />
+                        </div>
+                    </div>
+
+                    <div class="form-group">
+                        <label class="col-sm-2 control-label">录入当天最低温度(℃)</label>
+                        <div class="col-sm-6">
+                            <input type="number" class="form-control" name="min_temperature" value="{$info.min_temperature|default=''}">
+                        </div>
+                    </div>
+
+                    <div class="form-group">
+                        <label class="col-sm-2 control-label">录入当天最高温度(℃)</label>
+                        <div class="col-sm-6">
+                            <input type="number" class="form-control" name="max_temperature" value="{$info.max_temperature|default=''}">
+                        </div>
+                    </div>
+
+                    <div class="form-group">
+                        <label class="col-sm-2 control-label">床位数量</label>
+                        <div class="col-sm-6">
+                            <input type="number" class="form-control" name="beds" value="{$info.beds|default=''}">
+                        </div>
+                    </div>
+
+                    <div class="hr-line-dashed"></div>
+                    <div class="form-group">
+                        <div class="col-sm-6 col-sm-offset-2">
+                            <button class="btn btn-primary ajax-post" data-layer="1" target-form="form-horizontal" type="submit" data-date-format="yyyy-mm-dd">确 定</button>
+                            <button  class="btn cancel-btn btn-default" type="button">取 消</button>
+                        </div>
+                    </div>
+                </form>
+            </div>
+        </div>
+    </div>
+</div>
+{/block}
+{block name="script"}
+<script>
+    $(function () {
+        laydate.render({
+            elem: '#readTime',
+            trigger: 'click',
+            theme: '#0F3A87',
+        });
+    });
+    $(document).ready(function(){
+        formSetValue("enable", {$info.enable|default=1});
+    });
+
+
+</script>
+{/block}

+ 35 - 0
application/admin/view/energy_water_record/import.html

@@ -0,0 +1,35 @@
+{extend name="common/common2" /}
+{block name="main"}
+<div class="row">
+    <div class="col-sm-12">
+        <div class="ibox float-e-margins">
+            <div class="ibox-content">
+                <form method="post"  action="importexcel"  enctype="multipart/form-data" class="form-horizontal">
+                    <div class="form-group">
+                        <label class="col-sm-2 control-label">选择文件(支持:xls,xlsx)<span class="text-danger">*</span></label>
+                        <div class="col-sm-6">
+                            <input type="file" name="file" id="file" class="form-control" value="" accept=".xls,.xlsx">
+                        </div>
+                    </div>
+
+                    <div class="hr-line-dashed"></div>
+                    <div class="form-group">
+                        <div class="col-sm-6 col-sm-offset-2">
+                            <button class="btn btn-sm btn-primary" type="submit">确定导入</button>
+                            <a href="downloadtem" class="btn btn-sm btn-danger">下载模板</a>
+                        </div>
+                    </div>
+                </form>
+            </div>
+        </div>
+    </div>
+</div>
+{/block}
+{block name="script"}
+<script>
+    $(document).ready(function(){
+        formSetValue("enable", {$info.enable|default=1});
+    });
+
+</script>
+{/block}

+ 151 - 0
application/admin/view/energy_water_record/index.html

@@ -0,0 +1,151 @@
+{extend name="common/common2" /}
+{block name="main"}
+
+<div class="ibox">
+    <div class="ibox-content">
+        <div class="row">
+            <div class="col-xs-3">
+                <a href="javascript:;" url="{:url('add')}" data-title="新增" onclick="layer_open(this,1)" class="btn btn-sm btn-success">新增</a>
+                <a  href="javascript:;" id="js" class="btn btn-sm btn-danger">批量删除</a>
+
+            </div>
+            <div class="col-xs-9" style="text-align: right;">
+                <form class="form-inline" id="form-search" action="{:url('index')}">
+<!--                    <div class="input-group" style="width: 200px">-->
+<!--                        <span class="input-group-addon">开始时间</span>-->
+<!--                        <input class="form-control dialog-datetime" id="startTime" name="start" type="text" data-date-format="yyyy-mm-dd" value="" placeholder="录入时间" />-->
+<!--                    </div>-->
+<!--                    <div class="input-group" style="width: 200px">-->
+<!--                        <span class="input-group-addon">结束时间</span>-->
+<!--                        <input class="form-control dialog-datetime" id="endTime" name="end" type="text" data-date-format="yyyy-mm-dd" value="" placeholder="录入时间" />-->
+<!--                    </div>-->
+                    <div class="input-group">
+                        <input type="text" class="form-control" name="sn" placeholder="水表号">
+                    </div>
+                    <div class="input-group">
+                        <span class="input-group-btn">
+                            <button class="btn-sm btn-danger" type="button" id ="search-btn" ><i class="fa fa-search"></i></button>
+                        </span>
+                        &nbsp;
+                        <span class="input-group-btn">
+                            <button class="btn-sm btn-warning " type="button" id="search-clear"><i class="fa fa-undo"></i></button>
+                        </span>
+                        &nbsp;
+                        <span class="input-group-btn">
+                        <button class="btn-sm btn-other" type="button" url="{:url('import')}" data-title="批量导入" onclick="layer_open(this,1)">批量导入</button>
+                        </span>
+                    </div>
+                </form>
+            </div>
+        </div>
+
+    </div>
+    <div class="ibox-content">
+        <div class="jqGrid_wrapper">
+            <table id="table" style="border-collapse: collapse"></table>
+            <div id="pager"></div>
+        </div>
+    </div>
+</div>
+{/block}
+{block name="script"}
+<script>
+    $(function () {
+        laydate.render({
+            elem: '#startTime',
+            trigger: 'click',
+            theme: '#0F3A87'
+        });
+        laydate.render({
+            elem: '#endTime',
+            trigger: 'click',
+            theme: '#0F3A87'
+        });
+    });
+    $(function () {
+
+        $(window).bind("resize",function(){
+            var width=$(".jqGrid_wrapper").width();
+            $("#table").setGridWidth(width);
+        });
+
+        $.jgrid.defaults.styleUI="Bootstrap";
+        $("#table").jqGrid({
+            url:"{:url('index')}",
+            datatype: "json",
+            colModel:[
+                {label:'序号',name:'id',index:'id', width:20,sortable: true},
+                {label:'表号',name:'sn',index:'sn', width:40,sortable: false},
+                {label:'抄表读数',name:'degree',index:'degree', width:40,sortable: false},
+                {label:'抄表时间',name:'read_time',index:'read_time',width:40,sortable: true},
+                {label:'录入人',name:'user_id',index:'user_id',width:40,sortable: false},
+                {label:'录入时间',name:'create_time',index:'create_time', width:60,sortable: true},
+                {label:'最低温度(℃)',name:'min_temperature',index:'min_temperature', width:40,sortable: false},
+                {label:'最高温度(℃)',name:'max_temperature',index:'max_temperature', width:40,sortable: false},
+                {label:'床位数量',name:'beds',index:'beds', width:40,sortable: false},
+                {label:'更新时间',name:'update_time',index:'update_time', width:60,sortable: true},
+                {label:'操作',width:60,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="编辑" onclick="layer_open(this,1)"><span class="label label-other" title="编辑">编辑</span></a>&nbsp;';
+                        btn += '<a href="'+delurl+'" class="confirm ajax-get" data-confirm="确定要删除此记录吗?" data-table="1"><span class="label label-danger" title="删除">删除</span></a>';
+                        return btn;
+                    }},
+            ],
+            rowNum:10,
+            rowList:[10,20,30,50,100],
+            pager: '#pager',
+            sortname: 'id',
+            viewrecords: true,
+            autowidth:true,
+            mtype: 'post',
+            height: 'auto',
+            emptyrecords: "暂无数据",
+            sortorder: "desc",
+            caption:"{$meta_title}",
+            multiselect: true,//可多选
+            loadComplete: function (xhr) {
+                if(xhr.code==0){
+                    layer.msg(xhr.msg);
+                    return false;
+                }
+            },
+        });
+
+    });
+    $('#js').click(function () {
+        var rowIds = jQuery("#table").jqGrid('getGridParam', 'selarrrow');    //获取勾选记录的ID
+        if(rowIds.length <=0){
+            updateAlert('请选择记录','alert-danger');
+            setTimeout(function(){
+                $('#top-alert').find('button').click();
+            },1500);
+            return;
+        }
+
+        layer.confirm('确定批量删除记录?(此方法不可逆,谨慎操作)', {
+            icon: 3,
+            btn: ['确定', '取消'],
+            skin: 'layer-ext-moon'
+        }, function(index) {
+            layer.close(layer.index);
+            $.post('{:url("multiDel")}',{ids:rowIds},function (res) {
+                if(res.code==0){
+                    updateAlert(res.msg,'alert-danger');
+                    setTimeout(function(){
+                        $('#top-alert').find('button').click();
+                    },1500);
+                    // window.location.reload();
+                }else {
+                    updateAlert(res.msg,'alert-success');
+                    setTimeout(function(){
+                        $('#top-alert').find('button').click();
+                        $("#table").trigger("reloadGrid");
+                    },1500);
+
+                }
+            })
+        });
+    })
+</script>
+{/block}

+ 43 - 0
application/common/model/EnergyArea.php

@@ -0,0 +1,43 @@
+<?php
+namespace app\common\model;
+
+use think\Db;
+use tools\Phptree;
+
+class EnergyArea extends Base
+{
+
+    public function updates(){
+        $data = request()->post();
+        $data['org_id'] = cur_org_id();
+        $data['pid'] = intval($data['pid']);
+        $result = validate('EnergyArea')->check($data,[],'');
+        if(true !== $result){
+            $this->error = validate('EnergyArea')->getError();
+            return false;
+        }
+        $id = $data['id'];
+        unset($data['id']);
+        if($id > 0){
+            $ret = $this->allowField(true)->save($data,['id'=>$id]);
+        }else{
+            if($data['pid'] == 0){
+                $re = $this->where(['org_id'=>cur_org_id(),'del'=>0,'enable'=>1,'pid'=>0])->find();
+                if ($re){
+                    $this->error = '单个组织下只能添加一个院级信息';
+                    return false;
+                }
+            }
+            $data['create_time'] = date('Y-m-d H:i:s');
+            $ret = $this->allowField(true)->save($data);
+        }
+        if(!$ret){
+            $this->error = '操作失败';
+            return false;
+        }
+        return true;
+    }
+
+
+
+}

+ 43 - 0
application/common/model/EnergyDep.php

@@ -0,0 +1,43 @@
+<?php
+namespace app\common\model;
+
+use think\Db;
+use tools\Phptree;
+
+class EnergyDep extends Base
+{
+
+    public function updates(){
+        $data = request()->post();
+        $data['org_id'] = cur_org_id();
+        if (isset($data['address'])){
+            if ($data['address'] == '0' || $data['address'] == '[]'){
+                $data['address'] = '';
+            }
+        }
+        $result = validate('EnergyDep')->check($data,[],'');
+        if(true !== $result){
+            $this->error = validate('EnergyDep')->getError();
+            return false;
+        }
+        if (isset($data['percent']) && $data['percent']){
+            $data['percent'] = str_replace(',',',',$data['percent']);
+        }
+        $id = $data['id'];
+        unset($data['id']);
+        if($id > 0){
+            $ret = $this->allowField(true)->save($data,['id'=>$id]);
+        }else{
+            $data['create_time'] = date('Y-m-d H:i:s');
+            $ret = $this->allowField(true)->save($data);
+        }
+        if(!$ret){
+            $this->error = '操作失败';
+            return false;
+        }
+        return true;
+    }
+
+
+
+}

+ 53 - 0
application/common/model/EnergyDeviceElectricity.php

@@ -0,0 +1,53 @@
+<?php
+namespace app\common\model;
+
+
+use think\Db;
+use tools\Phptree;
+
+class EnergyDeviceElectricity extends Base
+{
+    public function updates(){
+        $data = request()->post();
+        $data['org_id'] = cur_org_id();
+        $result = validate('EnergyDeviceElectricity')->check($data,[],'');
+        if(true !== $result){
+            $this->error = validate('EnergyDeviceElectricity')->getError();
+            return false;
+        }
+        if (isset($data['percent']) &&  $data['percent']){
+            $data['percent'] = str_replace(':',':',$data['percent']);
+        }
+        $id = $data['id'];
+        unset($data['id']);
+        if($id > 0){
+            $ret = $this->allowField(true)->save($data,['id'=>$id]);
+        }else{
+            $data['create_time'] = date('Y-m-d H:i:s');
+            $ret = $this->allowField(true)->save($data);
+        }
+        if(!$ret){
+            $this->error = '操作失败';
+            return false;
+        }
+        return true;
+    }
+
+    public function showAllTree(){
+        $map['enable'] = 1;
+        $map['del'] = 0;
+        $map['org_id'] = cur_org_id();
+        //部门的就不显示了
+        $lists = Db::name('energy_device_electricity')->where($map)->where('del',0)->order('id asc')->select();
+        if (empty($lists)) {
+            return array();
+        }
+        $tree = Phptree::makeTree(($lists), array(
+            'primary_key'=>'id',
+            'parent_key'=>'parent_id',
+            'expanded' => true
+        ));
+        return $tree;
+    }
+
+}

+ 51 - 0
application/common/model/EnergyDeviceElectricityRecord.php

@@ -0,0 +1,51 @@
+<?php
+namespace app\common\model;
+use app\common\util\AppAuth;
+use think\Db;
+use think\Exception;
+
+class EnergyDeviceElectricityRecord extends Base {
+
+    public function updates($userId){
+        $data = request()->post();
+        $data['org_id'] = cur_org_id();
+        $result = validate('EnergyDeviceElectricityRecord')->check($data,[],'');
+        if(true !== $result){
+            $this->error = validate('EnergyDeviceElectricityRecord')->getError();
+            return false;
+        }
+        $id = $data['id'];
+        unset($data['id']);
+        $data['read_yyyy'] = date('Y',strtotime($data['read_time']));
+        $data['read_yyyymm'] = date('Ym',strtotime($data['read_time']));
+        $data['read_yyyymmdd'] = date('Ymd',strtotime($data['read_time']));
+        if($id > 0){
+            $data['update_time'] = date('Y-m-d H:i:s');
+
+            $ret = $this->allowField(true)->save($data,['id'=>$id]);
+        }else{
+            //        查询上次录入
+            $re = $this->where('sn',$data['sn'])
+                ->order('read_time','desc')
+                ->where('del',0)
+                ->limit(1)
+                ->find();
+            if ($re){
+                if (intval($data['degree']) < intval($re['degree'])){
+                    $this->error ='本次抄表度数小于上次录入数据,请检查后重新录入';
+                    return false;
+                }
+            }
+            $warning =model('EnergyElectricityRecord')->warning('energy_device_electricity_record',$data);
+            $data['create_time'] = date('Y-m-d H:i:s');
+            $data['user_id'] = $userId;
+            $ret = $this->allowField(true)->save($data);
+        }
+        if(!$ret){
+            $this->error = '操作失败';
+            return false;
+        }
+        return true;
+    }
+
+}

+ 71 - 0
application/common/model/EnergyElectricity.php

@@ -0,0 +1,71 @@
+<?php
+namespace app\common\model;
+
+
+use think\Db;
+use tools\Phptree;
+
+class EnergyElectricity extends Base
+{
+    public function updates(){
+        $data = request()->post();
+        $data['org_id'] = cur_org_id();
+//        if (isset($data['dep'])){
+//            if ($data['dep'] == '[]'||$data['dep'] == '""')
+//            {
+//                $data['dep'] = '';
+//            }
+//        }
+//
+        if (isset($data['address'])){
+            if ($data['address'] == '0' || $data['address'] == '[]'){
+                $data['address'] = '';
+            }
+        }
+
+        if (($data['parent_id'] != '0')){
+            $result = validate('EnergyElectricity')->check($data,[],'add1');
+        }else{
+            $result = validate('EnergyElectricity')->check($data,[],'add2');
+        }
+
+        if(true !== $result){
+            $this->error = validate('EnergyElectricity')->getError();
+            return false;
+        }
+        if (isset($data['percent']) && $data['percent']){
+            $data['percent'] = str_replace(':',':',$data['percent']);
+        }
+        $id = $data['id'];
+        unset($data['id']);
+        if($id > 0){
+            $ret = $this->allowField(true)->save($data,['id'=>$id]);
+        }else{
+            $data['create_time'] = date('Y-m-d H:i:s');
+            $ret = $this->allowField(true)->save($data);
+        }
+        if(!$ret){
+            $this->error = '操作失败';
+            return false;
+        }
+        return true;
+    }
+
+    public function showAllTree(){
+        $map['enable'] = 1;
+        $map['del'] = 0;
+        $map['org_id'] = cur_org_id();
+        //部门的就不显示了
+        $lists = Db::name('energy_electricity')->where($map)->where('del',0)->order('id asc')->select();
+        if (empty($lists)) {
+            return array();
+        }
+        $tree = Phptree::makeTree(($lists), array(
+            'primary_key'=>'id',
+            'parent_key'=>'parent_id',
+            'expanded' => true
+        ));
+        return $tree;
+    }
+
+}

+ 99 - 0
application/common/model/EnergyElectricityRecord.php

@@ -0,0 +1,99 @@
+<?php
+namespace app\common\model;
+use app\common\util\AppAuth;
+use think\Db;
+use think\Exception;
+
+class EnergyElectricityRecord extends Base {
+
+    public function updates($userId,$type){  //0-总表,1-分表
+        $data = request()->post();
+        $data['org_id'] = cur_org_id();
+
+        $map[] = $type == 0?['parent_id','=',0]:['parent_id','>',0];
+        $ids = Db::name('energy_electricity')
+            ->where('org_id',$data['org_id'])
+            ->where('del',0)
+            ->where($map)
+            ->column('number');
+        if (!in_array($data['sn'],$ids)){
+            $this->error =$type == 0?'表号不存在或非总表表号':'表号不存在或非分表表号';
+            return false;
+        }
+        $result = validate('EnergyElectricityRecord')->check($data,[],'');
+        if(true !== $result){
+            $this->error = validate('EnergyElectricityRecord')->getError();
+            return false;
+        }
+        $id = $data['id'];
+        unset($data['id']);
+        $data['read_yyyy'] = date('Y',strtotime($data['read_time']));
+        $data['read_yyyymm'] = date('Ym',strtotime($data['read_time']));
+        $data['read_yyyymmdd'] = date('Ymd',strtotime($data['read_time']));
+        if($id > 0){
+            $data['update_time'] = date('Y-m-d H:i:s');
+            $ret = $this->allowField(true)->save($data,['id'=>$id]);
+        }else{
+            $change = Db::name('energy_change_log')
+                ->where('org_id',$data['org_id'])
+                ->where('sn',$data['sn'])
+                ->order('id desc')
+                ->value('degree');
+            if ($change){
+                $data['degree'] = $change + $data['degree'];
+            }
+            //        查询上次录入
+            $re = $this->where('sn',$data['sn'])
+                ->order('read_time','desc')
+                ->where('del',0)
+                ->limit(1)
+                ->find();
+            if ($re){
+                if (intval($data['degree']) < intval($re['degree'])){
+                    $this->error ='本次抄表度数小于上次录入数据,请检查后重新录入';
+                    return false;
+                }
+            }
+            $warning = $this->warning('energy_electricity_record',$data);
+            $data['create_time'] = date('Y-m-d H:i:s');
+            $data['user_id'] = $userId;
+            $ret = $this->allowField(true)->save($data);
+        }
+        if(!$ret){
+            $this->error = '操作失败';
+            return false;
+        }
+        return true;
+    }
+    public function warning ($table,$data){
+        $re = Db::name($table)->where('sn',$data['sn'])
+            ->order('read_time','desc')
+            ->limit(4)
+            ->column('degree');
+        if (count($re) == 4){
+            $degree = array_reverse($re);
+            $differences = [];
+            foreach ($degree as $index => $value) {
+                if ($index < count($degree) - 1) {
+                    $differences[] = floatval($degree[$index + 1]) - floatval($value);
+                }
+            }
+            $sumOfDifferences = array_sum($differences);
+            $averageDifference = sprintf('%.2f',$sumOfDifferences / count($differences));
+            $max = ($data['degree']-$re[0]) > $averageDifference * 1.3;
+            $min = ($data['degree']-$re[0]) < $averageDifference * 0.7;
+            $info= [
+                'sn'=>$data['sn'],
+                'org_id'=>$data['org_id'],
+                'content'=>$max ? '本次录入数据差值高于前三次平均值130%' : '本次录入数据差值低于前三次平均值70%',
+                'read_time'=>$data['read_time'],
+                'type'=>$max ? 1 : 0,
+                'create_time'=>date('Y-m-d H:i:s'),
+            ];
+            if ($max || $min){
+                Db::name('energy_record_warning')->insert($info);
+            }
+        }
+    }
+
+}

+ 63 - 0
application/common/model/EnergyGas.php

@@ -0,0 +1,63 @@
+<?php
+namespace app\common\model;
+
+
+use think\Db;
+use tools\Phptree;
+
+class EnergyGas extends Base
+{
+    public function updates(){
+        $data = request()->post();
+        $data['org_id'] = cur_org_id();
+        if (isset($data['address'])){
+            if ($data['address'] == '0' || $data['address'] == '[]'){
+                $data['address'] = '';
+            }
+        }
+        if ($data['parent_id'] != '0'){
+            $result = validate('EnergyGas')->check($data,[],'add1');
+        }else{
+            $result = validate('EnergyGas')->check($data,[],'add2');
+        }
+
+        if(true !== $result){
+            $this->error = validate('EnergyGas')->getError();
+            return false;
+        }
+        if (isset($data['percent']) &&  $data['percent']){
+            $data['percent'] = str_replace(':',':',$data['percent']);
+        }
+        $id = $data['id'];
+        unset($data['id']);
+        if($id > 0){
+            $ret = $this->allowField(true)->save($data,['id'=>$id]);
+        }else{
+            $data['create_time'] = date('Y-m-d H:i:s');
+            $ret = $this->allowField(true)->save($data);
+        }
+        if(!$ret){
+            $this->error = '操作失败';
+            return false;
+        }
+        return true;
+    }
+
+    public function showAllTree(){
+        $map['enable'] = 1;
+        $map['del'] = 0;
+        $map['org_id'] = cur_org_id();
+        //部门的就不显示了
+        $lists = Db::name('energy_gas')->where($map)->where('del',0)->order('id asc')->select();
+        if (empty($lists)) {
+            return array();
+        }
+        $tree = Phptree::makeTree(($lists), array(
+            'primary_key'=>'id',
+            'parent_key'=>'parent_id',
+            'expanded' => true
+        ));
+        return $tree;
+    }
+
+}

+ 57 - 0
application/common/model/EnergyGasRecord.php

@@ -0,0 +1,57 @@
+<?php
+namespace app\common\model;
+use app\common\util\AppAuth;
+use think\Db;
+
+class EnergyGasRecord extends Base {
+
+    public function updates($userId){
+        $data = request()->post();
+        $data['org_id'] = cur_org_id();
+        $result = validate('EnergyGasRecord')->check($data,[],'');
+        if(true !== $result){
+            $this->error = validate('EnergyGasRecord')->getError();
+            return false;
+        }
+        $id = $data['id'];
+        unset($data['id']);
+        $data['read_yyyy'] = date('Y',strtotime($data['read_time']));
+        $data['read_yyyymm'] = date('Ym',strtotime($data['read_time']));
+        $data['read_yyyymmdd'] = date('Ymd',strtotime($data['read_time']));
+        if($id > 0){
+            $data['update_time'] = date('Y-m-d H:i:s');
+            $ret = $this->allowField(true)->save($data,['id'=>$id]);
+        }else{
+            $change = Db::name('energy_change_log')
+                ->where('org_id',$data['org_id'])
+                ->where('sn',$data['sn'])
+                ->order('id desc')
+                ->value('degree');
+            if ($change){
+                $data['degree'] = $change + $data['degree'];
+            }
+            //        查询昨天录入
+            $re = $this->where('sn',$data['sn'])
+                ->order('read_time','desc')
+                ->where('del',0)
+                ->limit(1)
+                ->find();
+            if ($re){
+                if (intval($data['degree']) < intval($re['degree'])){
+                    $this->error ='本次抄表度数小于上次录入数据,请检查后重新录入';
+                    return false;
+                }
+            }
+            $data['create_time'] = date('Y-m-d H:i:s');
+            $warning =model('EnergyElectricityRecord')->warning('energy_gas_record',$data);
+            $data['user_id'] = $userId;
+            $ret = $this->allowField(true)->save($data);
+        }
+        if(!$ret){
+            $this->error = '操作失败';
+            return false;
+        }
+        return true;
+    }
+
+}

+ 43 - 0
application/common/model/EnergyLog.php

@@ -0,0 +1,43 @@
+<?php
+namespace app\common\model;
+
+use think\Db;
+
+class EnergyLog extends Base
+{
+    protected $createTime = 'create_time';
+    protected $updateTime = 'update_time';
+    protected $table = 'energy_log';
+    protected $validateName = 'EnergyLog';
+    public function updates($deviceId){
+        $data = request()->post();
+        $data['org_id'] =cur_org_id();
+        $data['device_id'] =$deviceId;
+        $data['create_y'] =date('Y');
+        $data['create_ym'] =date('Ym');
+        $data['create_ymd'] =date('Ymd');
+        $data['create_ymdh'] =date('Ymdh');
+        $data['create_ymdhi'] =date('Ymdhi');
+        $result = validate($this->validateName)->check($data,[],'');
+        if(true !== $result){
+            $this->error = validate($this->validateName)->getError();
+            return false;
+        }
+        $id = $data['id'];
+        unset($data['id']);
+        if($id > 0){
+            $data['update_time'] = date('Y-m-d H:i:s');
+            $ret = $this->allowField(true)->save($data,['id'=>$id]);
+        }else{
+            $data['create_time'] = date('Y-m-d H:i:s');
+            $ret = $this->allowField(true)->save($data);
+        }
+        if(!$ret){
+            $this->error = '操作失败';
+            return false;
+        }
+        return true;
+    }
+
+
+}

+ 34 - 0
application/common/model/EnergySort.php

@@ -0,0 +1,34 @@
+<?php
+namespace app\common\model;
+
+use think\Db;
+use tools\Phptree;
+
+class EnergySort extends Base
+{
+
+    public function updates(){
+        $data = request()->post();
+        $data['org_id'] = cur_org_id();
+        if (!$data['name']){
+            $this->error = '名称不能为空';
+            return false;
+        }
+        $id = $data['id'];
+        unset($data['id']);
+        if($id > 0){
+            $ret = $this->allowField(true)->save($data,['id'=>$id]);
+        }else{
+            $data['create_time'] = date('Y-m-d H:i:s');
+            $ret = $this->allowField(true)->save($data);
+        }
+        if(!$ret){
+            $this->error = '操作失败';
+            return false;
+        }
+        return true;
+    }
+
+
+
+}

+ 87 - 0
application/common/model/EnergyWater.php

@@ -0,0 +1,87 @@
+<?php
+namespace app\common\model;
+
+
+use think\Db;
+use tools\Phptree;
+
+class EnergyWater extends Base
+{
+    public function updates(){
+        $data = request()->post();
+        $data['org_id'] = cur_org_id();
+        if (isset($data['address'])){
+            if ($data['address'] == '0' || $data['address'] == '[]'){
+                $data['address'] = '';
+            }
+        }
+
+        if (($data['parent_id'] != '0')){
+            $result = validate('EnergyWater')->check($data,[],'add1');
+        }else{
+            $result = validate('EnergyWater')->check($data,[],'add2');
+        }
+
+        if(true !== $result){
+            $this->error = validate('EnergyWater')->getError();
+            return false;
+        }
+//        if (isset($data['dep'])){
+//            //一个科室只能有一个冷热水表
+//            $info=$this->where('type_w',$data['type_w'])
+//                ->where('org_id',cur_org_id())
+//                ->where('dep','like','%'.$data['dep'].'%')
+//                ->where('del',0)
+//                ->where('parent_id','>',0)
+//                ->limit(1)
+//                ->value('id');
+//            if ($info && $data['id'] != $info){
+//                if ($data['type_w'] == '0'){
+//                    $this->error='该科室已绑定冷水表,不可重复添加';
+//                    return false;
+//                }else if ($data['type_w'] == '1'){
+//                    $this->error='该科室已绑定冷水进水表,不可重复添加';
+//                    return false;
+//                }else{
+//                    $this->error='该科室已绑定冷水回水表,不可重复添加';
+//                    return false;
+//                }
+//            }
+//        }
+
+        if (isset($data['percent']) && $data['percent']){
+            $data['percent'] = str_replace(':',':',$data['percent']);
+        }
+        $id = $data['id'];
+        unset($data['id']);
+        if($id > 0){
+            $ret = $this->allowField(true)->save($data,['id'=>$id]);
+        }else{
+            $data['create_time'] = date('Y-m-d H:i:s');
+            $ret = $this->allowField(true)->save($data);
+        }
+        if(!$ret){
+            $this->error = '操作失败';
+            return false;
+        }
+        return true;
+    }
+
+    public function showAllTree(){
+        $map['enable'] = 1;
+        $map['del'] = 0;
+        $map['org_id'] = cur_org_id();
+        //部门的就不显示了
+        $lists = Db::name('EnergyWater')->where($map)->where('del',0)->order('id asc')->select();
+        if (empty($lists)) {
+            return array();
+        }
+        $tree = Phptree::makeTree(($lists), array(
+            'primary_key'=>'id',
+            'parent_key'=>'parent_id',
+            'expanded' => true
+        ));
+        return $tree;
+    }
+
+}

+ 57 - 0
application/common/model/EnergyWaterRecord.php

@@ -0,0 +1,57 @@
+<?php
+namespace app\common\model;
+use app\common\util\AppAuth;
+use think\Db;
+
+class EnergyWaterRecord extends Base {
+
+    public function updates($userId){
+        $data = request()->post();
+        $data['org_id'] = cur_org_id();
+        $result = validate('EnergyWaterRecord')->check($data,[],'');
+        if(true !== $result){
+            $this->error = validate('EnergyWaterRecord')->getError();
+            return false;
+        }
+        $id = $data['id'];
+        unset($data['id']);
+        $data['read_yyyy'] = date('Y',strtotime($data['read_time']));
+        $data['read_yyyymm'] = date('Ym',strtotime($data['read_time']));
+        $data['read_yyyymmdd'] = date('Ymd',strtotime($data['read_time']));
+        if($id > 0){
+            $data['update_time'] = date('Y-m-d H:i:s');
+            $ret = $this->allowField(true)->save($data,['id'=>$id]);
+        }else{
+            $change = Db::name('energy_change_log')
+                ->where('org_id',$data['org_id'])
+                ->where('sn',$data['sn'])
+                ->order('id desc')
+                ->value('degree');
+            if ($change){
+                $data['degree'] = $change + $data['degree'];
+            }
+            //        查询昨天录入
+            $re = $this->where('sn',$data['sn'])
+                ->order('read_time','desc')
+                ->where('del',0)
+                ->limit(1)
+                ->find();
+            if ($re){
+                if (intval($data['degree']) < intval($re['degree'])){
+                    $this->error ='本次抄表度数小于上次录入数据,请检查后重新录入';
+                    return false;
+                }
+            }
+            $data['create_time'] = date('Y-m-d H:i:s');
+            $warning =model('EnergyElectricityRecord')->warning('energy_water_record',$data);
+            $data['user_id'] = $userId;
+            $ret = $this->allowField(true)->save($data);
+        }
+        if(!$ret){
+            $this->error = '操作失败';
+            return false;
+        }
+        return true;
+    }
+
+}

+ 23 - 0
application/common/validate/EnergyArea.php

@@ -0,0 +1,23 @@
+<?php
+namespace app\common\validate;
+
+use think\Db;
+use think\Validate;
+
+class EnergyArea extends Validate{
+
+    protected $rule = [
+        'title|名称'  =>  'require',
+        'area|面积'  =>  'require',
+    ];
+
+    protected $message = [
+
+    ];
+
+    protected $scene = [
+
+    ];
+
+
+}

+ 24 - 0
application/common/validate/EnergyDep.php

@@ -0,0 +1,24 @@
+<?php
+namespace app\common\validate;
+
+use think\Db;
+use think\Validate;
+
+class EnergyDep extends Validate{
+
+    protected $rule = [
+        'name|名称'  =>  'require',
+        'area|面积'  =>  'require',
+        'address|科室地点'  =>  'require',
+    ];
+
+    protected $message = [
+
+    ];
+
+    protected $scene = [
+
+    ];
+
+
+}

+ 23 - 0
application/common/validate/EnergyDeviceElectricity.php

@@ -0,0 +1,23 @@
+<?php
+namespace app\common\validate;
+
+use think\Validate;
+
+class EnergyDeviceElectricity extends Validate{
+
+    protected $rule = [
+        'name|名称'  =>  'require',
+        'parent_id'  =>  'require',
+        'type_e|用电分类'  =>  'require',
+    ];
+
+    protected $message = [
+
+    ];
+
+    protected $scene = [
+//        'add' => ['name','parent_id','type'],
+//        'edit' => ['name']
+    ];
+
+}

+ 25 - 0
application/common/validate/EnergyDeviceElectricityRecord.php

@@ -0,0 +1,25 @@
+<?php
+namespace app\common\validate;
+
+use think\Db;
+use think\Validate;
+
+class EnergyDeviceElectricityRecord extends Validate{
+
+    protected $rule = [
+        'sn|电表号'  =>  'require',
+        'degree|抄表数'  =>  'require',
+        'rate|倍率'  =>  'require',
+        'read_time|抄表时间'  =>  'require',
+    ];
+
+    protected $message = [
+
+    ];
+
+    protected $scene = [
+
+    ];
+
+
+}

+ 24 - 0
application/common/validate/EnergyElectricity.php

@@ -0,0 +1,24 @@
+<?php
+namespace app\common\validate;
+
+use think\Validate;
+
+class EnergyElectricity extends Validate{
+
+    protected $rule = [
+        'name|名称'  =>  'require',
+        'number|表号'  =>  'require',
+        'address|地点'  =>  'require',
+        'dep|科室'  =>  'require',
+    ];
+
+    protected $message = [
+
+    ];
+
+    protected $scene = [
+        'add1' => ['name','number','address','dep'],
+        'add2' => ['name','number'],
+    ];
+
+}

+ 25 - 0
application/common/validate/EnergyElectricityRecord.php

@@ -0,0 +1,25 @@
+<?php
+namespace app\common\validate;
+
+use think\Db;
+use think\Validate;
+
+class EnergyElectricityRecord extends Validate{
+
+    protected $rule = [
+        'sn|电表号'  =>  'require',
+        'degree|抄表数'  =>  'require',
+        'rate|倍率'  =>  'require',
+        'read_time|抄表时间'  =>  'require',
+    ];
+
+    protected $message = [
+
+    ];
+
+    protected $scene = [
+
+    ];
+
+
+}

+ 25 - 0
application/common/validate/EnergyGas.php

@@ -0,0 +1,25 @@
+<?php
+namespace app\common\validate;
+
+use think\Validate;
+
+class EnergyGas extends Validate{
+
+    protected $rule = [
+        'name|名称'  =>  'require',
+        'number|表号'  =>  'require',
+        'address|地点'  =>  'require',
+        'dep|科室'  =>  'require',
+    ];
+
+    protected $message = [
+
+    ];
+
+    protected $scene = [
+        'add1' => ['name','number','address','dep'],
+        'add2' => ['name','number'],
+//        'edit' => ['name']
+    ];
+
+}

+ 24 - 0
application/common/validate/EnergyGasRecord.php

@@ -0,0 +1,24 @@
+<?php
+namespace app\common\validate;
+
+use think\Db;
+use think\Validate;
+
+class EnergyGasRecord extends Validate{
+
+    protected $rule = [
+        'sn|电表号'  =>  'require',
+        'degree|抄表数'  =>  'require',
+        'read_time|抄表时间'  =>  'require',
+    ];
+
+    protected $message = [
+
+    ];
+
+    protected $scene = [
+
+    ];
+
+
+}

+ 27 - 0
application/common/validate/EnergyWater.php

@@ -0,0 +1,27 @@
+<?php
+namespace app\common\validate;
+
+use think\Validate;
+
+class EnergyWater extends Validate{
+
+    protected $rule = [
+        'name|名称'  =>  'require',
+        'number|表号'  =>  'require',
+        'address|地点'  =>  'require',
+        'dep|科室'  =>  'require',
+        'type_w|分类'  =>  'require',
+    ];
+
+    protected $message = [
+
+    ];
+
+    protected $scene = [
+        'add1' => ['name','number','address','dep','type_w'],
+        'add2' => ['name','number','type_w'],
+//        'edit' => ['name']
+    ];
+
+
+}

+ 24 - 0
application/common/validate/EnergyWaterRecord.php

@@ -0,0 +1,24 @@
+<?php
+namespace app\common\validate;
+
+use think\Db;
+use think\Validate;
+
+class EnergyWaterRecord extends Validate{
+
+    protected $rule = [
+        'sn|电表号'  =>  'require',
+        'degree|抄表数'  =>  'require',
+        'read_time|抄表时间'  =>  'require',
+    ];
+
+    protected $message = [
+
+    ];
+
+    protected $scene = [
+
+    ];
+
+
+}