当前位置:网站首页>Data center table reports realize customized statistics, overtime leave summary record sharing
Data center table reports realize customized statistics, overtime leave summary record sharing
2022-06-27 16:22:00 【51CTO】
Output effect :

Business needs :
1. According to the overtime record 、 Leave records generate overtime leave summary ;
2. Output field mechanism 、 department 、 full name 、 Annual leave base of this year 、 Remaining annual leave 、 This year's compensatory leave should be taken 、 This year's compensatory leave has been taken 、 Sheng and compensatory leave 、 Work overtime 、 Take annual leave 、 Take compensatory leave 、 Go out 、 Compassionate leave 、 sick leave 、 marriage holiday 、 maternity leave 、 Nursing leave 、 Paternity leave 、 Family planning leave 、 Home leave 、 Bereavement leave 、 Production inspection 、 Parental leave 、 Parental leave 、 Only child care leave 、 Study leave 、 parents ' meeting 、 On business 、 other
3. The number of days is 0.5 Multiple ;
4. The attendance administrator of each company queries the data of this company .
Demand analysis :
- Daydream database .
- Leave data split table
select id,requestid,resourceid,subcompanyid,departmentid,fromdate,newleavetype,duration from kq_flow_split_leave
- Overtime data split table
select id,requestid,resourceid,subcompanyid,departmentid,fromdate,duration from kq_flow_split_overtime
- Leave balance data
select id,resourceId,leaveRulesId,belongYear,baseAmount,usedAmount,extraAmount,effectiveDate,overtimeType,belongMonth from kq_balanceOfLeave
- Leave type data
select * from KQ_LeaveRules
- About 0.5 Multiple algorithm of
FLOOR(round(duration,1)*2)/2
- Judgment on invalidation of compensatory leave
CASE WHEN EXPIRATIONDATE<CURDATE()
Output record :
Leave and overtime SQL Output :
- Overtime record
select
id,
requestid ,
resourceid ,
subcompanyid ,
departmentid ,
fromdate ,
FLOOR(round(duration, 1)*2)/2 as duration
from
kq_flow_split_overtime
- Leave record
select
id ,
requestid ,
resourceid ,
subcompanyid,
departmentid,
fromdate ,
newleavetype,
FLOOR(round(duration, 1)*2)/2 as duration
from
kq_flow_split_leave
- Overtime leave splicing Unify fields before splicing :
(1)ID Stagger (2) Overtime increase type field .
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
- Type data vertical to horizontal
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
- Leave and overtime create views
CREATE OR REPLACE VIEW VIEW_KQ_XTQINGJIAJIABANHUIZONG AS
- Query test
select * from VIEW_KQ_XTQINGJIAJIABANHUIZONG

Leave balance of the current year SQL Output :
- Annual leave this year
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
- Leave this year
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

Basic information of personnel SQL Output
- Basic information of personnel
select
hh.id,
hh.departmentid ,
hh.subcompanyid1 ,
hh.workstartdate
from
hrmresource hh
where
hh.accounttype =0
and hh.status <4
- Add organization sorting
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

Query results SQL Splicing
- Basic information of personnel + Annual leave balance + Compensatory leave balance + Ask for leave to work overtime
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 view
CREATE OR REPLACE VIEW VIEW_KQ_XTNIANJIATIAOXIU AS
- Query test
select * from VIEW_KQ_XTNIANJIATIAOXIU

Report design
- Add data set

Add the view directly to the data set .
- Set filter conditions

To query the data of the company .
- Report design fields - full name

Set the left parent cell as the default (A Column )、 Vertical expansion 、 grouping .
The convert to HR Browse button displays .
A Column as sort field , The longitudinal 、 grouping 、 Ascending .
A Columns are auxiliary columns , Hide columns .
- Report design fields - office 、 department 、 Working hours

Set name column as left parent 、 Set not to extend 、 grouping
Switch the corresponding setting mechanism 、 department 、 Date Browse button .
- Leave balance of the current year

Set name column as left parent 、 No expansion 、 Summary 、 Maximum .
- Statistics of overtime leave

Set name column as left parent 、 No expansion 、 Summary 、 Sum up .
attach TIPS:
About type vertical to horizontal SQL Output skills
- Get all holiday types

- Export to Excel surface , Formula splicing
="case t.newleavetype when "&A2&" then t.duration else 0 end AS newleavetype"&A2&","
- Copied to the SQL sentence

边栏推荐
- Logstash excludes specific files or folders from collecting report log data
- 正则匹配以什么开头、以什么结尾,以非什么开头,以非什么结尾
- Google Earth Engine(GEE)——Export. image. The difference and mixing of toasset/todrive, correctly export classification sample data to asset assets and references
- Scrapy framework (I): basic use
- 基于 Nebula Graph 构建百亿关系知识图谱实践
- Design of FIR digital filter
- QT5 之信号与槽机制(演示控件自带的信号与槽函数关联)
- 开源二三事|ShardingSphere 与 Database Mesh 之间不得不说的那些事
- 熊市慢慢,Bit.Store提供稳定Staking产品助你穿越牛熊
- 【Pygame小游戏】这款“吃掉一切”游戏简直奇葩了?通通都吃掉嘛?(附源码免费领)
猜你喜欢

智慧风电 | 图扑软件数字孪生风机设备,3D 可视化智能运维

Leetcode daily practice (Yanghui triangle)

守护雪山之王:这些AI研究者找到了技术的新「用武之地」

Redis Series 2: data persistence improves availability

# Cesium实现卫星在轨绕行

The latest development course of grain college in 2022: 8 - foreground login function

Bit.Store:熊市漫漫,稳定Staking产品或成主旋律
![[Niuke's questions] nowcoder claims to have remembered all Fibonacci numbers between 1 and 100000. To test him, we gave him a random number N and asked him to say the nth Fibonacci number. If the nth](/img/70/fa79ba38e28c41ed28bce2ec73cd79.png)
[Niuke's questions] nowcoder claims to have remembered all Fibonacci numbers between 1 and 100000. To test him, we gave him a random number N and asked him to say the nth Fibonacci number. If the nth

Open source 23 things shardingsphere and database mesh have to say

Introduce you to ldbc SNB, a powerful tool for database performance and scenario testing
随机推荐
Scrapy framework (I): basic use
智慧风电 | 图扑软件数字孪生风机设备,3D 可视化智能运维
数据中心表格报表实现定制统计加班请假汇总记录分享
Jialichuang EDA professional edition all offline client release
Annual comprehensive analysis of China's audio market in 2022
关于#mysql#的问题:问题遇到的现象和发生背景
NFT dual currency pledge liquidity mining DAPP contract customization
等保三级密码复杂度是多少?多久更换一次?
Principle Comparison and analysis of mechanical hard disk and SSD solid state disk
Yyds dry inventory solution sword finger offer: a path with a certain value in the binary tree (3)
# Cesium实现卫星在轨绕行
Practice of constructing ten billion relationship knowledge map based on Nebula graph
特殊函数计算器
Introduce you to ldbc SNB, a powerful tool for database performance and scenario testing
Bit.Store:熊市漫漫,稳定Staking产品或成主旋律
Condom giants' sales have fallen by 40% in the past two years. What are the reasons for the decline?
LeetCode每日一练(两数之和)
[Niuke's questions] nowcoder claims to have remembered all Fibonacci numbers between 1 and 100000. To test him, we gave him a random number N and asked him to say the nth Fibonacci number. If the nth
Open source 23 things shardingsphere and database mesh have to say
Julia constructs diagonal matrix