当前位置:网站首页>数据中心表格报表实现定制统计加班请假汇总记录分享
数据中心表格报表实现定制统计加班请假汇总记录分享
2022-06-27 15:34:00 【51CTO】
输出效果:

业务需求:
1.根据加班记录、请假记录生成加班请假汇总表;
2.输出字段机关、科室、姓名、本年年假基数、剩余年假、本年补休假应修、本年补休假已休、盛与补休假、加班、休年假、休补休假、外出、事假、病假、婚假、产假、护理假、陪产假、计生假、探亲假、丧假、产检、育儿假、育儿假期、独生子女陪护假、学习假、家长会、因公、其他
3.天数为0.5的倍数;
4.各单位考勤管理员查询本单位数据。
需求分析:
- 达梦数据库。
- 请假数据拆分表
select id,requestid,resourceid,subcompanyid,departmentid,fromdate,newleavetype,duration from kq_flow_split_leave
- 加班数据拆分表
select id,requestid,resourceid,subcompanyid,departmentid,fromdate,duration from kq_flow_split_overtime
- 假期余额数据
select id,resourceId,leaveRulesId,belongYear,baseAmount,usedAmount,extraAmount,effectiveDate,overtimeType,belongMonth from kq_balanceOfLeave
- 假期类型数据
select * from KQ_LeaveRules
- 关于0.5的倍数算法
FLOOR(round(duration,1)*2)/2
- 关于调休假失效判断
CASE WHEN EXPIRATIONDATE<CURDATE()
输出记录:
请假与加班SQL输出:
- 加班记录
select
id,
requestid ,
resourceid ,
subcompanyid ,
departmentid ,
fromdate ,
FLOOR(round(duration, 1)*2)/2 as duration
from
kq_flow_split_overtime
- 请假记录
select
id ,
requestid ,
resourceid ,
subcompanyid,
departmentid,
fromdate ,
newleavetype,
FLOOR(round(duration, 1)*2)/2 as duration
from
kq_flow_split_leave
- 加班请假拼接拼接前统一字段:
(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
- 类型数据竖排转横排
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
- 请假与加班创建视图
CREATE OR REPLACE VIEW VIEW_KQ_XTQINGJIAJIABANHUIZONG AS
- 查询测试
select * from VIEW_KQ_XTQINGJIAJIABANHUIZONG

本年假期余额SQL输出:
- 本年年假
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
- 本年调休假
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

人员基本信息SQL输出
- 人员基本信息
select
hh.id,
hh.departmentid ,
hh.subcompanyid1 ,
hh.workstartdate
from
hrmresource hh
where
hh.accounttype =0
and hh.status <4
- 增加组织排序
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

查询结果SQL拼接
- 人员基本信息+年假余额+调休余额+请假加班
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
- 创建视图
CREATE OR REPLACE VIEW VIEW_KQ_XTNIANJIATIAOXIU AS
- 查询测试
select * from VIEW_KQ_XTNIANJIATIAOXIU

报表设计
- 添加数据集合

直接把视图加到数据集合。
- 设置过滤条件

实现查询本单位数据。
- 报表设计字段-姓名

设置左父格为默认(A列)、纵向扩展、分组。
转换为人力资源浏览按钮显示。
A列为排序字段,纵向、分组、升序。
A列是辅助列,隐藏列。
- 报表设计字段-机关、科室、参加工作时间

设置姓名列为左父格、设置不扩展、分组
转换对应设置机关、科室、日期浏览按钮。
- 本年假期余额

设置姓名列为左父格、不扩展、汇总、最大值。
- 统计请假加班

设置姓名列为左父格、不扩展、汇总、求和。
附TIPS:
关于类型竖排转横排SQL输出技巧
- 获取所有假期类型

- 导出到Excel表,公式拼接
="case t.newleavetype when "&A2&" then t.duration else 0 end AS newleavetype"&A2&","
- 复制到SQL语句

边栏推荐
- 洛谷_P1003 [NOIP2011 提高组] 铺地毯_暴力枚举
- Taishan Office Technology Lecture: the first difficulty is vertical positioning
- 面试半年,上个月成功拿到阿里P7offer,全靠我啃烂了这份2020最新面试题!
- NFT双币质押流动性挖矿dapp合约定制
- The role of the symbol @ in MySQL
- Design principles and ideas: design principles
- Introduction to TTCAN brick moving
- Redis Series 2: data persistence improves availability
- sql注入原理
- [170] the PostgreSQL 10 field type is changed from string to integer, and the error column cannot be cast automatically to type integer is reported
猜你喜欢

3.2 multiple condition judgment

洛谷_P1007 独木桥_思维

Practice of constructing ten billion relationship knowledge map based on Nebula graph

鸿蒙发力!HDD杭州站·线下沙龙邀您共建生态

Bit.Store:熊市漫漫,稳定Staking产品或成主旋律

Open source 23 things shardingsphere and database mesh have to say

面试半年,上个月成功拿到阿里P7offer,全靠我啃烂了这份2020最新面试题!

基于 Nebula Graph 构建百亿关系知识图谱实践
![[pygame Games] ce jeu](/img/3c/e573106ec91441a554cba18d5b2253.png)
[pygame Games] ce jeu "eat Everything" est fantastique? Tu manges tout? (avec code source gratuit)

LeetCode每日一练(主要元素)
随机推荐
Keep valid digits; Keep n digits after the decimal point;
3.3 one of the fixed number of cycles
PSS:你距離NMS-free+提點只有兩個卷積層 | 2021論文
Expert: those who let you go to a good school with a low score are all Scams
CentOS8-postgresql初始化时报错:initdb: error: invalid locale settings; check LANG and LC_* environment
Regular matching starts with what, ends with what, starts with what, and ends with what
Indexeddb learning materials
目前PolarDB-X是不支持数据库自制服务DAS么?
VS编译遇到的问题
Use redis to automatically cancel orders within 30 minutes
If you want to use DMS to handle database permissions, can you only use Alibaba cloud ram accounts (Alibaba cloud RDS)
[170] the PostgreSQL 10 field type is changed from string to integer, and the error column cannot be cast automatically to type integer is reported
Realize simple three-D cube automatic rotation
洛谷_P1003 [NOIP2011 提高组] 铺地毯_暴力枚举
熊市慢慢,Bit.Store提供稳定Staking产品助你穿越牛熊
LeetCode每日一练(主要元素)
Luogu_ P1002 [noip2002 popularization group] crossing the river_ dp
Relation and operation of ORM table
Design of spread spectrum communication system based on FPGA (with main code)
鸿蒙发力!HDD杭州站·线下沙龙邀您共建生态