数据中心表格报表实现定制统计加班请假汇总记录分享

Posted 孙忠的分享

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了数据中心表格报表实现定制统计加班请假汇总记录分享相关的知识,希望对你有一定的参考价值。

输出效果:

数据中心表格报表实现定制统计加班请假汇总记录分享_考勤报表

业务需求:

1.根据加班记录、请假记录生成加班请假汇总表;

2.输出字段机关、科室、姓名、本年年假基数、剩余年假、本年补休假应修、本年补休假已休、盛与补休假、加班、休年假、休补休假、外出、事假、病假、婚假、产假、护理假、陪产假、计生假、探亲假、丧假、产检、育儿假、育儿假期、独生子女陪护假、学习假、家长会、因公、其他

3.天数为0.5的倍数;

4.各单位考勤管理员查询本单位数据。


需求分析:

  1. 达梦数据库。
  2. 请假数据拆分表

select id,requestid,resourceid,subcompanyid,departmentid,fromdate,newleavetype,duration from kq_flow_split_leave

  1. 加班数据拆分表

select id,requestid,resourceid,subcompanyid,departmentid,fromdate,duration from kq_flow_split_overtime

  1. 假期余额数据

select id,resourceId,leaveRulesId,belongYear,baseAmount,usedAmount,extraAmount,effectiveDate,overtimeType,belongMonth from kq_balanceOfLeave

  1. 假期类型数据

select * from KQ_LeaveRules

  1. 关于0.5的倍数算法

FLOOR(round(duration,1)*2)/2

  1. 关于调休假失效判断

CASE WHEN EXPIRATIONDATE<CURDATE()

输出记录:

请假与加班SQL输出:

  1. 加班记录

select
id,
requestid ,
resourceid ,
subcompanyid ,
departmentid ,
fromdate ,
FLOOR(round(duration, 1)*2)/2 as duration
from
kq_flow_split_overtime
数据中心表格报表实现定制统计加班请假汇总记录分享_数据_02

  1. 请假记录

select
id ,
requestid ,
resourceid ,
subcompanyid,
departmentid,
fromdate ,
newleavetype,
FLOOR(round(duration, 1)*2)/2 as duration
from
kq_flow_split_leave
数据中心表格报表实现定制统计加班请假汇总记录分享_考勤报表_03

  1. 加班请假拼接拼接前统一字段:

(1)ID错开(2)加班增加类型字段。
select
id ,
requestid ,
resourceid ,
subcompanyid,
departmentid,
fromdate ,
newleavetype,
FLOOR(round(duration, 1)*2)/2 as duration
from
kq_flow_split_leave
union all
select
90000000000000000000000+id,
requestid ,
resourceid ,
subcompanyid ,
departmentid ,
fromdate ,
99 as newleavetype ,
FLOOR(round(duration, 1)*2)/2 as duration
from
kq_flow_split_overtime
数据中心表格报表实现定制统计加班请假汇总记录分享_sed_04

  1. 类型数据竖排转横排

select
t.id ,
t.requestid ,
t.resourceid ,
t.subcompanyid ,
t.departmentid ,
t.fromdate ,
case t.newleavetype when 2 then t.duration else 0 end AS newleavetype2 ,
case t.newleavetype when 3 then t.duration else 0 end AS newleavetype3 ,
case t.newleavetype when 4 then t.duration else 0 end AS newleavetype4 ,
case t.newleavetype when 5 then t.duration else 0 end AS newleavetype5 ,
case t.newleavetype when 6 then t.duration else 0 end AS newleavetype6 ,
case t.newleavetype when 7 then t.duration else 0 end AS newleavetype7 ,
case t.newleavetype when 8 then t.duration else 0 end AS newleavetype8 ,
case t.newleavetype when 9 then t.duration else 0 end AS newleavetype9 ,
case t.newleavetype when 10 then t.duration else 0 end AS newleavetype10,
case t.newleavetype when 11 then t.duration else 0 end AS newleavetype11,
case t.newleavetype when 12 then t.duration else 0 end AS newleavetype12,
case t.newleavetype when 13 then t.duration else 0 end AS newleavetype13,
case t.newleavetype when 14 then t.duration else 0 end AS newleavetype14,
case t.newleavetype when 15 then t.duration else 0 end AS newleavetype15,
case t.newleavetype when 16 then t.duration else 0 end AS newleavetype16,
case t.newleavetype when 17 then t.duration else 0 end AS newleavetype17,
case t.newleavetype when 18 then t.duration else 0 end AS newleavetype18,
case t.newleavetype when 19 then t.duration else 0 end AS newleavetype19,
case t.newleavetype when 20 then t.duration else 0 end AS newleavetype20,
case t.newleavetype when 21 then t.duration else 0 end AS newleavetype21,
case t.newleavetype when 22 then t.duration else 0 end AS newleavetype22,
case t.newleavetype when 99 then t.duration else 0 end AS newleavetype99
from
(
select
id ,
requestid ,
resourceid ,
subcompanyid,
departmentid,
fromdate ,
newleavetype,
FLOOR(round(duration, 1)*2)/2 as duration
from
kq_flow_split_leave
union all
select
90000000000000000000000+id,
requestid ,
resourceid ,
subcompanyid ,
departmentid ,
fromdate ,
99 as newleavetype ,
FLOOR(round(duration, 1)*2)/2 as duration
from
kq_flow_split_overtime
)
t
数据中心表格报表实现定制统计加班请假汇总记录分享_表格报表_05

  1. 请假与加班创建视图

CREATE OR REPLACE VIEW VIEW_KQ_XTQINGJIAJIABANHUIZONG AS

  1. 查询测试

select * from VIEW_KQ_XTQINGJIAJIABANHUIZONG

数据中心表格报表实现定制统计加班请假汇总记录分享_sed_06


本年假期余额SQL输出:

  1. 本年年假

select
resourceId ,
sum(nvl(baseAmount, 0)+nvl(extraAmount, 0)) as nj ,
sum(nvl(usedAmount, 0)) as njyx,
sum(nvl(baseAmount, 0) +nvl(extraAmount, 0)-nvl(usedAmount, 0)) as njye
from
kq_balanceOfLeave
where
leaveRulesId = 2
and belongYear =to_char(YEAR(CURDATE()))
and
(
ISDELETE is null
or ISDELETE =0
)
group by
resourceId
数据中心表格报表实现定制统计加班请假汇总记录分享_数据_07

  1. 本年调休假

select

resourceId ,

sum(nvl(TIAOXIUAMOUNT, 0)) as jb ,

sum(nvl(extraAmount, 0)) as ew ,

sum(nvl(TIAOXIUAMOUNT, 0)+nvl(baseAmount, 0)+nvl(extraAmount, 0)) as tx ,

sum(nvl(usedAmount, 0)) as txyx,

sum(CASE WHEN EXPIRATIONDATE<CURDATE() THEN nvl(TIAOXIUAMOUNT, 0) +nvl(baseAmount, 0)+nvl(extraAmount, 0)-nvl(usedAmount, 0) ELSE 0 END ) as sxye,

sum(CASE WHEN EXPIRATIONDATE<CURDATE() THEN 0 ELSE nvl(TIAOXIUAMOUNT, 0)+nvl(baseAmount, 0)+nvl(extraAmount, 0)-nvl(usedAmount, 0) END) as txye

from

kq_balanceOfLeave

where

leaveRulesId = 5

and belongYear =to_char(YEAR(CURDATE()))

and

(

ISDELETE is null

or ISDELETE =0

)

group by

resourceId

数据中心表格报表实现定制统计加班请假汇总记录分享_考勤报表_08

人员基本信息SQL输出

  1. 人员基本信息

select
hh.id,
hh.departmentid ,
hh.subcompanyid1 ,
hh.workstartdate
from
hrmresource hh
where
hh.accounttype =0
and hh.status <4

  1. 增加组织排序

select

hh.id,

trunc(10000 +s.showorder, 0)

||trunc(10000+d.showorder, 0)

||trunc(10000+hh.dsporder, 0) as showorder,

hh.departmentid ,

hh.subcompanyid1 ,

hh.workstartdate

from

hrmresource hh ,

hrmdepartment d,

hrmsubcompany s

where

hh.accounttype =0

and hh.status <4

and hh.departmentid =d.id

and hh.subcompanyid1=s.id


数据中心表格报表实现定制统计加班请假汇总记录分享_sed_09


查询结果SQL拼接

  1. 人员基本信息+年假余额+调休余额+请假加班

select
h.id as resourceid,
h.showorder ,
h.id
||-
||v.id as id ,
h.departmentid ,
h.subcompanyid1 ,
h.workstartdate ,
n.nj ,
n.njyx ,
n.njye ,
t.jb ,
t.ew ,
t.tx ,
t.txyx ,
t.sxye ,
t.txye ,
v.fromdate ,
v.newleavetype2 ,
v.newleavetype3 ,
v.newleavetype4 ,
v.newleavetype5 ,
v.newleavetype6 ,
v.newleavetype7 ,
v.newleavetype8 ,
v.newleavetype9 ,
v.newleavetype10,
v.newleavetype11,
v.newleavetype12,
v.newleavetype13,
v.newleavetype14,
v.newleavetype15,
v.newleavetype16,
v.newleavetype17,
v.newleavetype18,
v.newleavetype19,
v.newleavetype20,
v.newleavetype21,
v.newleavetype22,
v. newleavetype99
from
(
select
hh.id,
trunc(10000 +s.showorder, 0)
||trunc(10000+d.showorder, 0)
||trunc(10000+hh.dsporder, 0) as showorder,
hh.departmentid ,
hh.subcompanyid1 ,
hh.workstartdate
from
hrmresource hh ,
hrmdepartment d,
hrmsubcompany s
where
hh.accounttype =0
and hh.status <4
and hh.departmentid =d.id
and hh.subcompanyid1=s.id
)
h
left join
(
select
resourceId ,
sum(nvl(baseAmount, 0)+nvl(extraAmount, 0)) as nj ,
sum(nvl(usedAmount, 0)) as njyx,
sum(nvl(baseAmount, 0) +nvl(extraAmount, 0)-nvl(usedAmount, 0)) as njye
from
kq_balanceOfLeave
where
leaveRulesId = 2
and belongYear =to_char(YEAR(CURDATE()))
and
(
ISDELETE is null
or ISDELETE =0
)
group by
resourceId
)
n
on
h.id=n.resourceId
left join
(
select
resourceId ,
sum(nvl(TIAOXIUAMOUNT, 0)) as jb ,
sum(nvl(extraAmount, 0)) as ew ,
sum(nvl(TIAOXIUAMOUNT, 0)+nvl(baseAmount, 0)+nvl(extraAmount, 0)) as tx ,
sum(nvl(usedAmount, 0)) as txyx,
sum(CASE WHEN EXPIRATIONDATE<CURDATE() THEN nvl(TIAOXIUAMOUNT, 0) +nvl(baseAmount, 0)+nvl(extraAmount, 0)-nvl(usedAmount, 0) ELSE 0 END ) as sxye,
sum(CASE WHEN EXPIRATIONDATE<CURDATE() THEN 0 ELSE nvl(TIAOXIUAMOUNT, 0)+nvl(baseAmount, 0)+nvl(extraAmount, 0)-nvl(usedAmount, 0) END) as txye
from
kq_balanceOfLeave
where
leaveRulesId = 5
and belongYear =to_char(YEAR(CURDATE()))
and
(
ISDELETE is null
or ISDELETE =0
)
group by
resourceId
)
t
on
h.id=t.resourceId
left join view_kq_xtqingjiajiabanhuizong v
on
h.id=v.resourceId
数据中心表格报表实现定制统计加班请假汇总记录分享_sed_10

  1. 创建视图

CREATE OR REPLACE VIEW VIEW_KQ_XTNIANJIATIAOXIU AS

  1. 查询测试

select * from VIEW_KQ_XTNIANJIATIAOXIU

数据中心表格报表实现定制统计加班请假汇总记录分享_数据_11

报表设计

  1. 添加数据集合

数据中心表格报表实现定制统计加班请假汇总记录分享_表格报表_12
直接把视图加到数据集合。

  1. 设置过滤条件

数据中心表格报表实现定制统计加班请假汇总记录分享_考勤报表_13
实现查询本单位数据。

  1. 报表设计字段-姓名

数据中心表格报表实现定制统计加班请假汇总记录分享_sed_14
设置左父格为默认(A列)、纵向扩展、分组。
数据中心表格报表实现定制统计加班请假汇总记录分享_sed_15
转换为人力资源浏览按钮显示。
数据中心表格报表实现定制统计加班请假汇总记录分享_数据_16
A列为排序字段,纵向、分组、升序。
A列是辅助列,隐藏列。

  1. 报表设计字段-机关、科室、参加工作时间

数据中心表格报表实现定制统计加班请假汇总记录分享_字段_17
设置姓名列为左父格、设置不扩展、分组
转换对应设置机关、科室、日期浏览按钮。

  1. 本年假期余额

数据中心表格报表实现定制统计加班请假汇总记录分享_字段_18
设置姓名列为左父格、不扩展、汇总、最大值。

  1. 统计请假加班

数据中心表格报表实现定制统计加班请假汇总记录分享_考勤报表_19

设置姓名列为左父格、不扩展、汇总、求和。




附TIPS:

关于类型竖排转横排SQL输出技巧

  1. 获取所有假期类型

数据中心表格报表实现定制统计加班请假汇总记录分享_数据_20

  1. 导出到Excel表,公式拼接

="case t.newleavetype when "&A2&" then t.duration else 0 end AS newleavetype"&A2&","
数据中心表格报表实现定制统计加班请假汇总记录分享_考勤报表_21

  1. 复制到SQL语句

数据中心表格报表实现定制统计加班请假汇总记录分享_数据_22













以上是关于数据中心表格报表实现定制统计加班请假汇总记录分享的主要内容,如果未能解决你的问题,请参考以下文章

别再花时间统计考勤数据了,这个报表统计神器才是你最后出路

dingding

葡萄城报表案例分享项目施工进度报告 – 树形报表

如何实现在网络上由各单位填写excle表格以方便汇总。

案例分享电力设备生产数据的多层分组统计报表实现

Stimulsoft报表操作笔记:统计