Browse Source

tianjia tongji

lgy 6 năm trước cách đây
mục cha
commit
3125b00d6d

+ 197 - 0
application/manage/controller/Statistics.php

@@ -0,0 +1,197 @@
+<?php
+
+namespace app\manage\controller;
+
+use think\Controller;
+use think\Db;
+use think\Session;
+use think\Config;
+use think\Cookie;
+use think\Request;
+use app\common\library\SysLogs;
+use app\common\library\UUIDs;
+
+class Statistics extends Base {
+
+    public function index() {
+
+        return $this->fetch('index');
+    }
+
+
+    public function datas(){
+        $admin = Session::get('session_manager');
+        $institution_id = $admin['institution_id'];
+        $doctor = DB::table('doctors')->where('institution_id',$institution_id)->field('realname,id')->select();
+        $request = Request::instance();
+        $params = $request->param();
+        $where = array();
+        foreach ($params as $k=>$v) {
+            switch($k){
+                case 'upload1':
+                    if($params['upload1'] == null){
+                        continue;
+                    }
+                    $where[] = ' report_datetime > \''.$params['upload1'].' 00:00:00\' ';
+                    break;
+                case 'upload2':
+                    if($params['upload2'] == null){
+                        continue;
+                    }
+                    $where[] = ' report_datetime < \''.$params['upload2'].' 23:59:59\' ';
+                    break;
+            }
+        }
+        if(count($where) <= 1){
+            $where1  =  implode('',$where);
+            $search = $where1;
+        }else{
+            $where1 = implode(' and ',$where);
+            $search = $where1;
+        }
+        if($search == ''){
+            $time1 = date('Y-m-d 00:00:00',time());
+            $time2 = date('Y-m-d 23:59:59',time());
+            $search = 'report_datetime >\''.$time1.'\' and report_datetime < \''.$time2.'\'';
+        }
+        $report_num = 0;
+        $review_num = 0;
+        $list = [];
+        foreach($doctor as $k=>$v){
+            $report = DB::table('report')->where('report_doctor_id',$v['id'])->where($search)->count();
+            $review = DB::table('report')->where('review_doctor_id',$v['id'])->where($search)->count();
+            $list[$k]['name'] = $v['realname'];
+            $list[$k]['report'] = $report;
+            $list[$k]['review'] = $review;
+            $report_num = $report_num + $report;
+            $review_num = $review_num + $review;
+        }
+        $num = count($doctor);
+        $list[$num]['name'] = '统计';
+        $list[$num]['report'] = $report_num;
+        $list[$num]['review']  = $review_num;
+        echo json_encode($list);
+
+    }
+
+    public function out() {
+        $admin = Session::get('session_manager');
+        $institution_id = $admin['institution_id'];
+        $doctor = DB::table('doctors')->where('institution_id',$institution_id)->field('realname,id')->select();
+        $request = Request::instance();
+        $params = $request->param();
+        $where = array();
+        $begin = '';
+        $finish = '';
+        foreach ($params as $k=>$v) {
+            switch($k){
+                case 'upload1':
+                    if($params['upload1'] == null){
+                        continue;
+                    }
+                    $where[] = ' report_datetime > \''.$params['upload1'].' 00:00:00\' ';
+                    $begin = $params['upload1'];
+                    break;
+                case 'upload2':
+                    if($params['upload2'] == null){
+                        continue;
+                    }
+                    $where[] = ' report_datetime < \''.$params['upload2'].' 23:59:59\' ';
+                    $finish = $params['upload2'];
+                    break;
+            }
+        }
+        if(count($where) <= 1){
+            $where1  =  implode('',$where);
+            $search = $where1;
+        }else{
+            $where1 = implode(' and ',$where);
+            $search = $where1;
+        }
+        if($search == ''){
+            $time1 = date('Y-m-d 00:00:00',time());
+            $time2 = date('Y-m-d 23:59:59',time());
+            $search = 'report_datetime >\''.$time1.'\' and report_datetime < \''.$time2.'\'';
+            $begin = date('Y-m-d',time());
+            $finish = date('Y-m-d',time());
+        }
+        $report_num = 0;
+        $review_num = 0;
+        $list = [];
+        foreach($doctor as $k=>$v){
+            $report = DB::table('report')->where('report_doctor_id',$v['id'])->where($search)->count();
+            $review = DB::table('report')->where('review_doctor_id',$v['id'])->where($search)->count();
+            $list[$k]['name'] = $v['realname'];
+            $list[$k]['report'] = $report;
+            $list[$k]['review'] = $review;
+            $report_num = $report_num + $report;
+            $review_num = $review_num + $review;
+        }
+        $num = count($doctor);
+        $list[$num]['name'] = '统计';
+        $list[$num]['report'] = $report_num;
+        $list[$num]['review']  = $review_num;
+        if($begin == $finish){
+            $filename = $begin."数据统计表";
+        }else{
+            $filename = $begin.'至'.$finish."数据统计表";
+        }
+        $headArr = array("医生姓名","已书写报告数量", "已审核报告数量");
+        $this->getExcel($filename, $headArr, $list);
+    }
+
+    public function getExcel($fileName, $headArr, $data) {
+        //对数据进行检验
+        if (empty($data) || !is_array($data)) {
+            die("data must be a array");
+        }
+        //检查文件名
+        if (empty($fileName)) {
+            exit;
+        }
+
+        $date = date("Y_m_d", time());
+        $fileName .= ".xls";
+
+        //创建PHPExcel对象,注意,不能少了\
+        $objPHPExcel = new \PHPExcel();
+        $objProps = $objPHPExcel->getProperties();
+
+        $objPHPExcel->getActiveSheet()->getColumnDimension('A')->setWidth(15);
+        $objPHPExcel->getActiveSheet()->getColumnDimension('B')->setWidth(25);
+        $objPHPExcel->getActiveSheet()->getColumnDimension('C')->setWidth(25);
+        //设置表头
+        $key = ord("A");
+        foreach ($headArr as $v) {
+            $colum = chr($key);
+            $objPHPExcel->setActiveSheetIndex(0)->setCellValue($colum . '1', $v);
+            $key += 1;
+        }
+
+        $column = 2;
+        $objActSheet = $objPHPExcel->getActiveSheet();
+        foreach ($data as $key => $rows) { //行写入
+            $span = ord("A");
+            foreach ($rows as $keyName => $value) {// 列写入
+                $j = chr($span);
+                $objActSheet->setCellValue($j . $column, $value);
+                $span++;
+            }
+            $column++;
+        }
+
+        $fileName = iconv("utf-8", "gb2312", $fileName);
+        //重命名表
+        // $objPHPExcel->getActiveSheet()->setTitle('test');
+        //设置活动单指数到第一个表,所以Excel打开这是第一个表
+        $objPHPExcel->setActiveSheetIndex(0);
+        header('Content-Type: application/vnd.ms-excel');
+        header("Content-Disposition: attachment;filename=\"$fileName\"");
+        header('Cache-Control: max-age=0');
+
+        $objWriter = \PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5');
+        $objWriter->save('php://output'); //文件通过浏览器下载
+        exit;
+    }
+
+}

+ 1 - 0
application/manage/view/index/ins.html

@@ -92,6 +92,7 @@
             urls[1]={"name":"科室管理","url":"/manage/insdoctors/deptview"};
             urls[2]={"name":"数据统计","url":"/manage/insdoctors/stats"};
             urls[3]={"name":"数据统计信息","url":"/manage/counts/index"};
+            urls[4]={"name":"医院报告统计","url":"/manage/statistics/index"};
             var intV=null;
             
             function openUserPanels(){

+ 140 - 0
application/manage/view/statistics/index.html

@@ -0,0 +1,140 @@
+<!DOCTYPE html>
+<html>
+    <head>
+        <title>TODO supply a title</title>
+        {include file="../application/manage/view/commons/headers.html" }
+        <script >
+            
+            // 编辑窗口
+            var $editWin;
+            var editWinHeight=$(window).height()-35;
+            var editWinWidth=$(window).width()*0.98;
+            
+            $(function(){
+                    $editWin = $('#edit-window').window({
+                        title: '医院报告统计',
+                        width: editWinWidth,height: editWinHeight,
+                        top: ($(window).height() -editWinHeight ) /2 ,
+                        left: ($(window).width() -editWinWidth ) /2 ,
+                        shadow: true,modal: true,
+                        iconCls: 'icon-edit',closed: true,resizable:true,
+                        minimizable: false,maximizable: true,collapsible: false
+                    });
+
+            });
+
+            $(window).resize(function() {
+                editWinWidth=$(window).width()*0.98;
+                $('#edit-window').window('resize',{
+                    width: editWinWidth,height: editWinHeight
+                });
+            });
+            
+            function dateFormatter(date){
+	    	if(typeof date=="undefined"){ return "--"; }
+	    	return new Date(date).format("yy-MM-dd hh:mm");
+	    }
+            
+            function statusFormatter(status){
+                if(status=="1"){
+                    return "正常";
+                }else if(status=="0"){
+                    return "屏蔽";
+                }else{
+                    return "非正常";
+                }
+            }
+            
+            function insFormatter(id,row){
+                for(var i=0;i<institutionsData.length;i++){
+                    var row=institutionsData[i];
+                    if(row.id==id){
+                        return row.name;
+                    }
+                }
+	    	return "<font color='#ccc' >顶级机构<font>";
+            }
+            
+            function commandsFormatter(id,row){
+	    	var cmdEdit="<a href='#' onclick=\"javascript:showEditWin('"+row.id+"');\" >编辑</a>&nbsp;";
+                cmdEdit+="<a href='#' onclick=\"javascript:deleteRow('"+row.id+"');\" >删除</a>";
+	    	return cmdEdit;
+	    }
+            
+            
+            
+            function statusFormatter(status){
+                if(status=="0"){
+                    return "屏蔽";
+                }else if(status=="1"){
+                    return "正常";
+                }else{
+                    return status;
+                }
+            }
+
+
+
+
+            $(function(){
+                
+                var height=$(document).height();
+                $("#dg").height(height);
+                                
+                $('#dg').datagrid({
+                    url:'/manage/statistics/datas',
+                    idField:'id',method: 'get',rownumbers: true,showFooter: true,singleSelect:true,selectOnCheck:false,
+                    toolbar: '#tb',pageList: [dgRowSize,dgRowSize*2,50,100],pagination:true,pageSize:dgRowSize,
+                    columns:[[
+                            {field:'name',title:'患者姓名',width:"120",align:'left'},
+                            {field:'report',title:'已写报告数量',width:100 },
+                            {field:'review',title:'已审报告数量', width:115  }
+                    ]],
+                    onDblClickRow :function(rowIndex,rowData){
+                        showEditWin(rowData.id);
+                    },
+                });
+
+
+            });
+            
+            function reload(){
+                var upload1 = $("#upload1").val();
+                var upload2 = $("#upload2").val();
+                var url="/manage/Statistics/datas?upload1="+(upload1==null?"":upload1)+"&upload2="+(upload2==null?"":upload2);
+                $('#dg').datagrid("reload",url);
+            }
+
+            function derive(){
+                var form = $("#form");
+                var upload1 = $("#upload1").val();
+                var upload2 = $("#upload2").val();
+                var url="/manage/Statistics/out?upload1="+(upload1==null?"":upload1)+"&upload2="+(upload2==null?"":upload2);
+                form.attr('action',url);
+                form.submit();
+            }
+            
+            $(function(){
+                $('#institution_id').combotree({
+                    required:true,multiple:false,editable:false,
+                    valueField:'id',textField:'name',panelWidth:550,
+                    url:"/manage/institution/insCombobox"
+                });
+            });
+            
+        </script>
+        
+    </head>
+    <body>
+        <div id="dg" class="easyui-datagrid" style="width:100%;height:auto;" ></div>
+        <div id="tb" class="editform" style="display: none; padding-top: 1px;">&nbsp;
+            <form id="form">
+                统计报告时间:<input type="text" id="upload1"  name="upload1" class="easyui-datebox" style="width: 120px;" />----<input type="text" id="upload2"  name="upload2" class="easyui-datebox" style="width: 120px;" />&nbsp;&nbsp;&nbsp;
+                <a id="submit" href="#" class="easyui-linkbutton" data-options="iconCls:'icon-search'" style="width: 80px" onclick="reload()" >查询</a>&nbsp;&nbsp;&nbsp;
+                <a id="excel" href="#" class="easyui-linkbutton" data-options="iconCls:'icon-search'" style="width: 140px" onclick="derive()" >导出excel</a>
+            </form>
+        </div>
+        <div id="edit-window" class="easyui-window" style="overflow: hidden" ><iframe src="about:blank" id="editFrame" style="width:100%;height:100%" frameborder="0" scrolling="yes" ></iframe></div>
+        
+    </body>
+</html>