no message
This commit is contained in:
parent
ac4d893f96
commit
3b9002f505
3 changed files with 227 additions and 8 deletions
|
|
@ -256,7 +256,7 @@ export class ReportController extends Controller {
|
||||||
if (tenureType != "" && tenureType == "position") {
|
if (tenureType != "" && tenureType == "position") {
|
||||||
tenureTypeCondition = "registryOfficer.Years BETWEEN :tenureMin AND :tenureMax";
|
tenureTypeCondition = "registryOfficer.Years BETWEEN :tenureMin AND :tenureMax";
|
||||||
} else if (tenureType != "" && tenureType == "level") {
|
} else if (tenureType != "" && tenureType == "level") {
|
||||||
tenureTypeCondition = "registryOfficer.Years BETWEEN :tenureMin AND :tenureMax"; //xxxxxxxxxxxx
|
tenureTypeCondition = "registryOfficer.levelYears BETWEEN :tenureMin AND :tenureMax"; //xxxxxxxxxxxx
|
||||||
}
|
}
|
||||||
|
|
||||||
const [lists, total] = await AppDataSource.getRepository(viewRegistryOfficer)
|
const [lists, total] = await AppDataSource.getRepository(viewRegistryOfficer)
|
||||||
|
|
@ -382,12 +382,9 @@ export class ReportController extends Controller {
|
||||||
Days: x.posExecutiveDays,
|
Days: x.posExecutiveDays,
|
||||||
},
|
},
|
||||||
posLevelDate: {
|
posLevelDate: {
|
||||||
// Years: x.levelYears,
|
Years: x.levelYears,
|
||||||
// Months: x.levelMonths,
|
Months: x.levelMonths,
|
||||||
// Days: x.levelDays,
|
Days: x.levelDays,
|
||||||
Years: 0,
|
|
||||||
Months: 0,
|
|
||||||
Days: 0,
|
|
||||||
},
|
},
|
||||||
}));
|
}));
|
||||||
return new HttpSuccess({
|
return new HttpSuccess({
|
||||||
|
|
|
||||||
199
src/entities/view/viewCurrentTenureLevelOfficer.ts
Normal file
199
src/entities/view/viewCurrentTenureLevelOfficer.ts
Normal file
|
|
@ -0,0 +1,199 @@
|
||||||
|
import { ViewColumn, ViewEntity } from "typeorm";
|
||||||
|
|
||||||
|
@ViewEntity({
|
||||||
|
expression: `
|
||||||
|
WITH resultData AS (
|
||||||
|
SELECT
|
||||||
|
commandDateAffect,
|
||||||
|
positionName,
|
||||||
|
positionCee,
|
||||||
|
TIMESTAMPDIFF(
|
||||||
|
DAY,
|
||||||
|
LAG(MIN(commandDateAffect)) OVER (ORDER BY commandDateAffect), MIN(commandDateAffect)) AS days_diff,
|
||||||
|
TIMESTAMPDIFF(
|
||||||
|
DAY,
|
||||||
|
LAG(MIN(commandDateAffect)) OVER (ORDER BY commandDateAffect), MIN(commandDateAffect)) / 365.2524 AS 'Years',
|
||||||
|
TIMESTAMPDIFF(
|
||||||
|
DAY,
|
||||||
|
LAG(MIN(commandDateAffect)) OVER (ORDER BY commandDateAffect), MIN(commandDateAffect)) / 30.4375 % 12 AS 'Months',
|
||||||
|
TIMESTAMPDIFF(
|
||||||
|
DAY,
|
||||||
|
LAG(MIN(commandDateAffect)) OVER (ORDER BY commandDateAffect), MIN(commandDateAffect)) % 30.4375 AS 'Days',
|
||||||
|
posNo,
|
||||||
|
positionExecutive,
|
||||||
|
positionType,
|
||||||
|
positionLevel,
|
||||||
|
orgRoot,
|
||||||
|
orgChild1,
|
||||||
|
orgChild2,
|
||||||
|
orgChild3,
|
||||||
|
orgChild4,
|
||||||
|
commandCode,
|
||||||
|
commandName,
|
||||||
|
commandNo,
|
||||||
|
commandYear,
|
||||||
|
remark,
|
||||||
|
profileId,
|
||||||
|
ROW_NUMBER() OVER (PARTITION BY profileId ORDER BY commandDateAffect ASC) AS orderNumber
|
||||||
|
FROM (
|
||||||
|
SELECT
|
||||||
|
commandDateAffect,
|
||||||
|
commandDateSign,
|
||||||
|
positionName,
|
||||||
|
positionCee,
|
||||||
|
posNo,
|
||||||
|
positionExecutive,
|
||||||
|
positionType,
|
||||||
|
positionLevel,
|
||||||
|
orgRoot,
|
||||||
|
orgChild1,
|
||||||
|
orgChild2,
|
||||||
|
orgChild3,
|
||||||
|
orgChild4,
|
||||||
|
commandCode,
|
||||||
|
commandName,
|
||||||
|
commandNo,
|
||||||
|
commandYear,
|
||||||
|
remark,
|
||||||
|
profileId/*,
|
||||||
|
LAG(commandDateSign) OVER (ORDER BY commandDateAffect ASC, commandDateSign ASC) AS prevCommandDateSign,
|
||||||
|
@group := IF(@prevPosition = positionName, @group, @group + 1) AS groupedId,
|
||||||
|
@prevPosition := positionName*/
|
||||||
|
FROM
|
||||||
|
profileSalary/*,
|
||||||
|
(SELECT @group := 0, @prevPosition := NULL) AS vars*/
|
||||||
|
WHERE
|
||||||
|
commandCode IN (1, 2, 3, 4, 8, 10, 11, 12, 15, 16)
|
||||||
|
ORDER BY
|
||||||
|
commandDateAffect ASC, commandDateSign ASC
|
||||||
|
) AS groupedPosition
|
||||||
|
/*WHERE
|
||||||
|
prevCommandDateSign IS NULL OR commandDateSign >= prevCommandDateSign*/
|
||||||
|
GROUP BY
|
||||||
|
profileId, /*groupedId,*/ positionName, positionCee, positionType, positionLevel
|
||||||
|
)
|
||||||
|
SELECT
|
||||||
|
commandDateAffect,
|
||||||
|
positionName,
|
||||||
|
positionCee,
|
||||||
|
days_diff,
|
||||||
|
Years,
|
||||||
|
Months,
|
||||||
|
Days,
|
||||||
|
posNo,
|
||||||
|
positionExecutive,
|
||||||
|
positionType,
|
||||||
|
positionLevel,
|
||||||
|
orgRoot,
|
||||||
|
orgChild1,
|
||||||
|
orgChild2,
|
||||||
|
orgChild3,
|
||||||
|
orgChild4,
|
||||||
|
commandCode,
|
||||||
|
commandName,
|
||||||
|
commandNo,
|
||||||
|
commandYear,
|
||||||
|
remark,
|
||||||
|
profileId,
|
||||||
|
orderNumber
|
||||||
|
FROM resultData
|
||||||
|
|
||||||
|
UNION ALL
|
||||||
|
|
||||||
|
SELECT
|
||||||
|
CURDATE() AS commandDateAffect,
|
||||||
|
NULL AS positionName,
|
||||||
|
NULL AS positionCee,
|
||||||
|
TIMESTAMPDIFF(DAY, MAX(commandDateAffect), CURDATE()) AS days_diff,
|
||||||
|
TIMESTAMPDIFF(DAY, MAX(commandDateAffect), CURDATE()) / 365.2524 AS 'Years',
|
||||||
|
TIMESTAMPDIFF(DAY, MAX(commandDateAffect), CURDATE()) / 30.4375 % 12 AS 'Months',
|
||||||
|
TIMESTAMPDIFF(DAY, MAX(commandDateAffect), CURDATE()) % 30.4375 AS 'Days',
|
||||||
|
NULL AS posNo,
|
||||||
|
NULL AS positionExecutive,
|
||||||
|
NULL AS positionType,
|
||||||
|
NULL AS positionLevel,
|
||||||
|
NULL AS orgRoot,
|
||||||
|
NULL AS orgChild1,
|
||||||
|
NULL AS orgChild2,
|
||||||
|
NULL AS orgChild3,
|
||||||
|
NULL AS orgChild4,
|
||||||
|
NULL AS commandCode,
|
||||||
|
NULL AS commandName,
|
||||||
|
NULL AS commandNo,
|
||||||
|
NULL AS commandYear,
|
||||||
|
NULL AS remark,
|
||||||
|
profileId,
|
||||||
|
NULL AS orderNumber
|
||||||
|
FROM resultData
|
||||||
|
`,
|
||||||
|
})
|
||||||
|
export class viewCurrentTenureLevelOfficer {
|
||||||
|
@ViewColumn()
|
||||||
|
commandDateAffect: Date;
|
||||||
|
|
||||||
|
@ViewColumn()
|
||||||
|
days_diff: number;
|
||||||
|
|
||||||
|
@ViewColumn()
|
||||||
|
Years: number;
|
||||||
|
|
||||||
|
@ViewColumn()
|
||||||
|
Months: number;
|
||||||
|
|
||||||
|
@ViewColumn()
|
||||||
|
Days: number;
|
||||||
|
|
||||||
|
@ViewColumn()
|
||||||
|
positionName: string;
|
||||||
|
|
||||||
|
@ViewColumn()
|
||||||
|
positionCee: string;
|
||||||
|
|
||||||
|
@ViewColumn()
|
||||||
|
posNo: string;
|
||||||
|
|
||||||
|
@ViewColumn()
|
||||||
|
positionExecutive: string;
|
||||||
|
|
||||||
|
@ViewColumn()
|
||||||
|
positionType: string;
|
||||||
|
|
||||||
|
@ViewColumn()
|
||||||
|
positionLevel: string;
|
||||||
|
|
||||||
|
@ViewColumn()
|
||||||
|
orgRoot: string;
|
||||||
|
|
||||||
|
@ViewColumn()
|
||||||
|
orgChild1: string;
|
||||||
|
|
||||||
|
@ViewColumn()
|
||||||
|
orgChild2: string;
|
||||||
|
|
||||||
|
@ViewColumn()
|
||||||
|
orgChild3: string;
|
||||||
|
|
||||||
|
@ViewColumn()
|
||||||
|
orgChild4: string;
|
||||||
|
|
||||||
|
@ViewColumn()
|
||||||
|
commandCode: number;
|
||||||
|
|
||||||
|
@ViewColumn()
|
||||||
|
commandName: string;
|
||||||
|
|
||||||
|
@ViewColumn()
|
||||||
|
commandNo: string;
|
||||||
|
|
||||||
|
@ViewColumn()
|
||||||
|
commandYear: number;
|
||||||
|
|
||||||
|
@ViewColumn()
|
||||||
|
remark: string;
|
||||||
|
|
||||||
|
@ViewColumn()
|
||||||
|
profileId: string;
|
||||||
|
|
||||||
|
@ViewColumn()
|
||||||
|
orderNumber: number;
|
||||||
|
}
|
||||||
|
|
@ -75,6 +75,16 @@ import { ViewColumn, ViewEntity } from "typeorm";
|
||||||
ROW_NUMBER() OVER (PARTITION BY vctoExc.profileId) AS vctoExc_number
|
ROW_NUMBER() OVER (PARTITION BY vctoExc.profileId) AS vctoExc_number
|
||||||
FROM view_current_tenure_exc_officer vctoExc
|
FROM view_current_tenure_exc_officer vctoExc
|
||||||
WHERE vctoExc.orderNumber Is Null
|
WHERE vctoExc.orderNumber Is Null
|
||||||
|
),
|
||||||
|
PositionLevelDate AS (
|
||||||
|
SELECT
|
||||||
|
vctlo.Years,
|
||||||
|
vctlo.Months,
|
||||||
|
vctlo.Days,
|
||||||
|
vctlo.profileId,
|
||||||
|
ROW_NUMBER() OVER (PARTITION BY vctlo.profileId) AS vctlo_number
|
||||||
|
FROM view_current_tenure_level_officer vctlo
|
||||||
|
WHERE vctlo.orderNumber Is Null
|
||||||
)
|
)
|
||||||
SELECT
|
SELECT
|
||||||
p.id as profileId,
|
p.id as profileId,
|
||||||
|
|
@ -123,7 +133,10 @@ import { ViewColumn, ViewEntity } from "typeorm";
|
||||||
vcto.Days,
|
vcto.Days,
|
||||||
vctoExc.Years AS posExecutiveYears,
|
vctoExc.Years AS posExecutiveYears,
|
||||||
vctoExc.Months AS posExecutiveMonths,
|
vctoExc.Months AS posExecutiveMonths,
|
||||||
vctoExc.Days AS posExecutiveDays
|
vctoExc.Days AS posExecutiveDays,
|
||||||
|
vctlo.Years AS levelYears,
|
||||||
|
vctlo.Months AS levelMonths,
|
||||||
|
vctlo.Days AS levelDays
|
||||||
FROM profile p
|
FROM profile p
|
||||||
LEFT JOIN posLevel ON p.posLevelId = posLevel.id
|
LEFT JOIN posLevel ON p.posLevelId = posLevel.id
|
||||||
LEFT JOIN posType ON p.posTypeId = posType.id
|
LEFT JOIN posType ON p.posTypeId = posType.id
|
||||||
|
|
@ -131,6 +144,7 @@ import { ViewColumn, ViewEntity } from "typeorm";
|
||||||
LEFT JOIN Education ed ON p.id = ed.profileId AND ed.ed_number = 1
|
LEFT JOIN Education ed ON p.id = ed.profileId AND ed.ed_number = 1
|
||||||
LEFT JOIN PositionDate vcto ON p.id = vcto.profileId AND vcto.vcto_number = 1
|
LEFT JOIN PositionDate vcto ON p.id = vcto.profileId AND vcto.vcto_number = 1
|
||||||
LEFT JOIN PositionExcDate vctoExc ON p.id = vctoExc.profileId AND vctoExc.vctoExc_number = 1
|
LEFT JOIN PositionExcDate vctoExc ON p.id = vctoExc.profileId AND vctoExc.vctoExc_number = 1
|
||||||
|
LEFT JOIN PositionLevelDate vctlo ON p.id = vctlo.profileId AND vctlo.vctlo_number = 1
|
||||||
`,
|
`,
|
||||||
})
|
})
|
||||||
export class viewRegistryOfficer {
|
export class viewRegistryOfficer {
|
||||||
|
|
@ -253,4 +267,13 @@ export class viewRegistryOfficer {
|
||||||
|
|
||||||
@ViewColumn()
|
@ViewColumn()
|
||||||
posExecutiveDays: number;
|
posExecutiveDays: number;
|
||||||
|
|
||||||
|
@ViewColumn()
|
||||||
|
levelYears: number;
|
||||||
|
|
||||||
|
@ViewColumn()
|
||||||
|
levelMonths: number;
|
||||||
|
|
||||||
|
@ViewColumn()
|
||||||
|
levelDays: number;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue