智能报表

简介

项目简介

智能报表

项目功能

登陆

1.验证登陆(用户名密码和验证码正确才能登陆) 2.单点登陆(同一个账号不能多人同时登陆,第二人登陆时前一人操作时会被退出,不操作的情况下半小时需要重新登陆)

后台首页

1.可用于对外展示的数据(查询,导出) 查询结果管理

1.用于对自定义简单查询的默认显示位置(后台操作人员自定义简单查询赋权后的默认展示位置) 系统管理

1.用于对用户,角色和赋权的管理(增,删,改,查) 2.新增用户后,给用户一个角色 (列如:员工,董事长) 3.给这个角色相应的权限 (列如:员工:可以查看后台首页,管理员:可以操作自定义查询) 自定义查询

1.用于后台人员自定义报表(简单查询样式,汇总样式,子查询样式) 通过操作生成自己所需要的报表

具体操作介绍见下

项目环境

操作系统:windows 使用方式:使用浏览器,使用用户名、密码登录

使用手册

后台首页

年度里程数据 车辆里程汇总车辆 里程汇总新 车辆里程汇总新

系统管理

用户管理

用户管理页面(停用:该页面依然展示,但不能登陆进来,删除:页面不会在展示) 新增功能(填写信息提交(修改类似))

角色管理

角色管理页面(同上) 新增功能(填写信息提交(修改类似)) 新增或修改完后该角色会用不同的菜单展示(如下1:懂事长 2 :经理)

权限管理

权限管理页面(同上) 修改功能(填写信息提交(新增类似)(总菜单下为一级菜单;可以通过此改变菜单展示样式)) 其他菜单下为二级(目前只支持二级))

自定义查询

自定义简单查询

自定义简单查询页面(同上) 新增页面(单表操作如下(1,3)) 1: 新增页面(多表操作如下(2,3)) 1(填写完上面表后,填写下面关联关系(列如 表1.字段=表2.字段)(不重写上表:上表和下面就没有任何关联关系;相当于 表1 ,表2.字段=表3.字段 表1实际去其他俩表无关联关系(注意))) 2: 搜索方式(列如:(页面上的模糊查询)(只有int datatime 类型可以使用时间查询(开始时间~结束时间))) 3: 点击提交后(先去角色管理找到对应角色) 进去角色后(在查询结果管理勾选中)

查询结果管理

新增自定义查询后(刷新页面即可)(如需查看内容直接点击即可)

子查询的配置

   子查询的实质是创建一个视图,将复杂的sql语句拆分成多个视图的关联,从而简化自定义汇总的配置。当然对于简单的汇总查询无需配置子查询!

车辆模式——总里程

车辆模式总里程的查询语句如下 :

    select SUM(daycourse)as NUM1,tdate,line_name,bus_index from DayCourseRecord where %s and Event_Type is NULL  group by tdate,line_name,bus_index  
  (%s表示查询条件   包含查询日期 、线路(默认全部) 、车号(默认全部))

主要是需要显示的字段,关联的表以及筛选条件等

第一步

填写查询名称和查询编码(必填),选择需要关联的表,下拉框选中就会在下方出现一条记录,点击删除则删除这张表,也可以设置相应的别名,当设置了别名的时候,自定义的显示列可以直接使用别名来配置!

第二步

设置显示的列,这里的显示列分成两个部分:

一是直接从表里面取得字段,不需要进行任何操作的,直接点击设置显示列,勾选需要显示的字段,下方会生成相应的一行,可以进行相关操作。

二是点击自定义显示列,会生成一行显示列,由自己填写字段名,并设置相应的别名,这里的字段名称可以按照sql语句的标准自由定义

如果设置错了显示列,可以点击每行后面的删除按钮删除显示列。

第三步

勾选相应的分组字段,这一步很关键,不能设置错了分组字段,不然无法创建子查询。

第四步

设置静态的筛选条件,第一个and不需要填写

车辆模式——运营时间

查询的sql语句:
select SUM(Time_out-Time_in)as NUM,Date_Sign,bus_index   from Attendance where 1=1 and Time_out!=86400  group by Date_Sign,bus_index

车辆模式——所有事件里程、时间

查询的sql语句:
select SUM(daycourse)as NUM1,SUM(etime-stime)as NUM2,tdate,line_name,bus_index from DayCourseRecord where %s and Event_Type is NOT NULL and etime!=86400 group by tdate,line_name,bus_index

车辆模式——包车事件里程、时间

查询的sql语句:
select SUM(daycourse)as NUM1,SUM(etime-stime)as NUM2,tdate,line_name,bus_index from DayCourseRecord where %s and Event_Type ='包车' and etime!=86400 group by tdate,line_name,bus_index 

车辆模式——总里程(带有车辆名称)

查询的sql语句:
select DayCourseRecord.TDate,DayCourseRecord.Line_Name,DayCourseRecord.Bus_Index,BusInfo.BusName,SUM(daycourse) as NUM1 from DayCourseRecord,BusInfo
where 1=1  and DayCourseRecord.Bus_Index = BusInfo.BusIndex and Bus_Index !='' and Event_Type is NULL 
group by DayCourseRecord.TDate,DayCourseRecord.Line_Name,DayCourseRecord.Bus_Index,BusInfo.BusName

相应配置如下:

注意增加相应的关联关系

司机模式——总里程

查询的sql语句:
select SUM(daycourse)as NUM1,tdate,line_name, Driver_Num from DayCourseRecord where %s  and Driver_Num !='' and Event_Type is  NULL  group by tdate,line_name ,Driver_Num 
(%s表示查询条件   包含查询日期 、线路(默认全部) 、司机(所选线路下的))

司机模式——运营时间

查询的sql语句:
select SUM(Time_out-Time_in)as NUM,Date_Sign,EmpNum   from Attendance where %s and Time_out!=86400 group by Date_Sign,EmpNum

司机模式——所有事件里程、时间

查询的sql语句:
select SUM(daycourse)as NUM1,SUM(etime-stime)as NUM2,tdate,line_name,Driver_Num from DayCourseRecord where %s and  Event_Type is NOT NULL and etime!=86400 group by tdate,line_name,Driver_Num

司机模式——包车事件里程、时间

查询的sql语句:
select SUM(daycourse)as NUM1,SUM(etime-stime)as NUM2,tdate,line_name, Driver_Num from DayCourseRecord where 1=1 and Event_Type ='包车' and etime!=86400 group by tdate,line_name,Driver_Num 

司机模式——总里程(带司机名称)

查询的sql语句:
select DayCourseRecord.TDate,DayCourseRecord.Line_Name,DayCourseRecord.Driver_Num,Employee.Employee_Name, SUM(daycourse) as NUM1
from DayCourseRecord,Employee where 1=1  and DayCourseRecord.Driver_Num = Employee.Employee_Num and Driver_Num !='' and Event_Type is  NULL
group by DayCourseRecord.TDate,DayCourseRecord.Line_Name,DayCourseRecord.Driver_Num,Employee.Employee_Name

自定义汇总的配置

车辆模式——汇总查询

查询的sql语句:

    select a.NUM1 as Daycourse,a.TDate,a.Line_Name,a.Bus_Index,b.NUM as iTime,c.NUM1 as EventCourse,c.NUM2 as EventTime,d.NUM1 as BaoCheCourse,d.NUM2 as BaoCheTime from
                (select SUM(daycourse)as NUM1,tdate,line_name,bus_index from DayCourseRecord where  1=1     and Event_Type is NULL  group by tdate,line_name,bus_index  )a
                left join
                (select SUM(Time_out-Time_in)as NUM,Date_Sign,bus_index   from Attendance where Time_out!=86400  group by Date_Sign,bus_index)b
                on 1=1 and a.tdate = b.Date_Sign and a.bus_index = b.bus_index
                left join
                (select SUM(daycourse)as NUM1,SUM(etime-stime)as NUM2,tdate,line_name,bus_index from DayCourseRecord where  Event_Type is NOT NULL and etime!=86400 group by tdate,line_name,bus_index 
                )c on a.TDate = c.TDate and a.Bus_Index = c.Bus_Index
                left join
                (select SUM(daycourse)as NUM1,SUM(etime-stime)as NUM2,tdate,line_name,bus_index from DayCourseRecord where  Event_Type ='包车' and etime!=86400 group by tdate,line_name,bus_index )d
                on a.TDate = d.TDate and a.Bus_Index = d.Bus_Index
        where  a. tdate = '20180603'        
    (%s表示查询条件   包含查询日期 、线路(默认全部) 、司机(所选线路下的))    

第一步

填写汇总名称和汇总编码(非必填)

第二步

选择需要关联的表和视图,不一定必须都是表或者视图,可以相互关联。可删除选中的表或者视图,也可以设置相应别名,如果没有重复的表名也可以不设置别名。

第三步

设置关联关系,点击增加关联关系按钮,可以增加关联关系,关联关系如若对应多个字段,设置的顺序要一致

第四步

设置需要显示的列,同样分成两个部分:

一是 从表中直接取的的字段,如果有重复的字段名需要设置别名

二是 自己定义的字段,按照sql标准进行定义,需要设置别名

设置的显示列如下:

注意

这样设置的里程和时间的格式不是自己想要的,这里有增加两个函数toKm 和 toTime

使用方式: dbo.toKm(数值,保留位数) dbo.toTime(秒数)

设置如下

第五步

设置排序的方式,如若没有按照年份或者月份汇总,则不需要设置汇总的类型以及汇总列,设置如下

第六步

设置查询条件,点击上方导航的右侧——>查询条件

点击自定义查询条件,可以新增查询条件,查询条件的设置规则如下:

查询条件的显示名称,匹配哪张表的哪个字段以及匹配方式,在页面展示的类型。

然后点击提交

第七步

查看

设置了参数格式的,我这里只设置了一部分,其他的也可以设置

司机模式——汇总查询

查询的sql语句:

select a.NUM1 as Daycourse,a.TDate,a.Line_Name,a.Driver_Num,b.NUM as iTime,c.NUM1 as EventCourse,c.NUM2 as EventTime,d.NUM1 as BaoCheCourse,d.NUM2 as BaoCheTime from
            (select SUM(daycourse)as NUM1,tdate,line_name, Driver_Num from DayCourseRecord where %s  and Driver_Num !='' and Event_Type is  NULL  group by tdate,line_name ,Driver_Num )a
            left join
            (select SUM(Time_out-Time_in)as NUM,Date_Sign,EmpNum   from Attendance where Time_out!=86400 group by Date_Sign,EmpNum)b
            on a.tdate = b.Date_Sign and a.Driver_Num = b.EmpNum
            left join
            (select SUM(daycourse)as NUM1,SUM(etime-stime)as NUM2,tdate,line_name,Driver_Num from DayCourseRecord where  Event_Type is NOT NULL and etime!=86400 group by tdate,line_name,Driver_Num 
            )c on a.TDate = c.TDate and a.Driver_Num = c.Driver_Num 
            left join
            (select SUM(daycourse)as NUM1,SUM(etime-stime)as NUM2,tdate,line_name, Driver_Num from DayCourseRecord where  Event_Type ='包车' and etime!=86400 group by tdate,line_name,Driver_Num )d
            on a.TDate = d.TDate and a.Driver_Num = d.Driver_Num

配置如下:

  1. 选择关联表

2. 设置显示列

  1. 设置查询条件

车辆模式——总里程(月份汇总)

查询的sql语句:

select Row_Number() OVER(order by [v_carName_zonglicheng].Line_Name) as RowId , [v_carName_zonglicheng].Line_Name,[v_carName_zonglicheng].Bus_Index,[v_carName_zonglicheng].BusName,sum(NUM1) as hz,LEFT(tdate,6) as riqi,max(case 't'+RIGHT(tdate,2) when 't01' then ISNULL(NUM1,0) else 0 end) 't01' ,max(case 't'+RIGHT(tdate,2) when 't02' then ISNULL(NUM1,0) else 0 end) 't02' ,max(case 't'+RIGHT(tdate,2) when 't03' then ISNULL(NUM1,0) else 0 end) 't03' ,max(case 't'+RIGHT(tdate,2) when 't04' then ISNULL(NUM1,0) else 0 end) 't04' ,max(case 't'+RIGHT(tdate,2) when 't05' then ISNULL(NUM1,0) else 0 end) 't05' ,max(case 't'+RIGHT(tdate,2) when 't06' then ISNULL(NUM1,0) else 0 end) 't06' ,max(case 't'+RIGHT(tdate,2) when 't07' then ISNULL(NUM1,0) else 0 end) 't07' ,max(case 't'+RIGHT(tdate,2) when 't08' then ISNULL(NUM1,0) else 0 end) 't08' ,max(case 't'+RIGHT(tdate,2) when 't09' then ISNULL(NUM1,0) else 0 end) 't09' ,max(case 't'+RIGHT(tdate,2) when 't10' then ISNULL(NUM1,0) else 0 end) 't10' ,max(case 't'+RIGHT(tdate,2) when 't11' then ISNULL(NUM1,0) else 0 end) 't11' ,max(case 't'+RIGHT(tdate,2) when 't12' then ISNULL(NUM1,0) else 0 end) 't12' ,max(case 't'+RIGHT(tdate,2) when 't13' then ISNULL(NUM1,0) else 0 end) 't13' ,max(case 't'+RIGHT(tdate,2) when 't14' then ISNULL(NUM1,0) else 0 end) 't14' ,max(case 't'+RIGHT(tdate,2) when 't15' then ISNULL(NUM1,0) else 0 end) 't15' ,max(case 't'+RIGHT(tdate,2) when 't16' then ISNULL(NUM1,0) else 0 end) 't16' ,max(case 't'+RIGHT(tdate,2) when 't17' then ISNULL(NUM1,0) else 0 end) 't17' ,max(case 't'+RIGHT(tdate,2) when 't18' then ISNULL(NUM1,0) else 0 end) 't18' ,max(case 't'+RIGHT(tdate,2) when 't19' then ISNULL(NUM1,0) else 0 end) 't19' ,max(case 't'+RIGHT(tdate,2) when 't20' then ISNULL(NUM1,0) else 0 end) 't20' ,max(case 't'+RIGHT(tdate,2) when 't21' then ISNULL(NUM1,0) else 0 end) 't21' ,max(case 't'+RIGHT(tdate,2) when 't22' then ISNULL(NUM1,0) else 0 end) 't22' ,max(case 't'+RIGHT(tdate,2) when 't23' then ISNULL(NUM1,0) else 0 end) 't23' ,max(case 't'+RIGHT(tdate,2) when 't24' then ISNULL(NUM1,0) else 0 end) 't24' ,max(case 't'+RIGHT(tdate,2) when 't25' then ISNULL(NUM1,0) else 0 end) 't25' ,max(case 't'+RIGHT(tdate,2) when 't26' then ISNULL(NUM1,0) else 0 end) 't26' ,max(case 't'+RIGHT(tdate,2) when 't27' then ISNULL(NUM1,0) else 0 end) 't27' ,max(case 't'+RIGHT(tdate,2) when 't28' then ISNULL(NUM1,0) else 0 end) 't28' ,max(case 't'+RIGHT(tdate,2) when 't29' then ISNULL(NUM1,0) else 0 end) 't29' ,max(case 't'+RIGHT(tdate,2) when 't30' then ISNULL(NUM1,0) else 0 end) 't30' ,max(case 't'+RIGHT(tdate,2) when 't31' then ISNULL(NUM1,0) else 0 end) 't31' from [v_carName_zonglicheng] where 1=1 group by [v_carName_zonglicheng].Line_Name,[v_carName_zonglicheng].Bus_Index,[v_carName_zonglicheng].BusName,LEFT(tdate,6)

第一步

设置汇总名称和汇总编码

第二步

选择关联的表或者视图,单表不需要设置关联关系!

第三步

设置显示的列,注意日期的选取,既然是按照月份汇总,则只取年月

第四步

选择汇总类型,设置汇总列以及日期列,按照每日横向统计

第五步

设置查询条件,不再赘述

司机模式——总里程(月份汇总)

第一步

设置汇总名称和汇总编码

第二步

选择关联的表或者视图,单表不需要设置关联关系!

第三步

设置显示的列,注意日期的选取,既然是按照月份汇总,则只取年月

第四步

选择汇总类型,设置汇总列以及日期列,按照每日横向统计

第五步

设置查询条件,不再赘述

车辆模式——总里程(年份汇总)

第一步

设置汇总名称和汇总编码,选择相应的子查询

第二步

设置显示的列,注意日期的选取,既然是按照年份汇总,则只取年

选择汇总类型,设置汇总列以及日期列,按照每月横向统计

第三步

设置查询条件,不再赘述

司机模式——总里程(年份汇总)

第一步

设置汇总名称和汇总编码,选择相应的子查询

第二步

设置显示的列,注意日期的选取,既然是按照年份汇总,则只取年

选择汇总类型,设置汇总列以及日期列,按照每月横向统计

第三步

设置查询条件,不再赘述

Last updated