add posexcutive date
This commit is contained in:
parent
180cdd225e
commit
f781af3151
7 changed files with 984 additions and 155 deletions
|
|
@ -1269,7 +1269,9 @@ export class ImportDataController extends Controller {
|
||||||
|
|
||||||
education.level = educationLevel == null ? 1 : educationLevel.level + 1;
|
education.level = educationLevel == null ? 1 : educationLevel.level + 1;
|
||||||
education.profileId = _item.id;
|
education.profileId = _item.id;
|
||||||
education.degree = educationCode ? educationCode.EDUCATION_NAME : "";
|
education.degree = educationCode ? educationCode.EDUCATION_ABB_NAME : "";
|
||||||
|
// education.degree = educationCode ? educationCode.MAJOR_NAME: "";
|
||||||
|
// education.degree = educationCode ? educationCode.FUND_COURSE_CODE: "";
|
||||||
education.institute = item.INSTITUE;
|
education.institute = item.INSTITUE;
|
||||||
education.level = item.EDUCATION_SEQ ? null_ : Number(item.EDUCATION_SEQ);
|
education.level = item.EDUCATION_SEQ ? null_ : Number(item.EDUCATION_SEQ);
|
||||||
education.startDate = startDate;
|
education.startDate = startDate;
|
||||||
|
|
|
||||||
|
|
@ -82,53 +82,48 @@ export class ProfileSalaryController extends Controller {
|
||||||
|
|
||||||
@Get("tenure/{profileId}")
|
@Get("tenure/{profileId}")
|
||||||
public async getPositionTenure(@Path() profileId: string, @Request() req: RequestWithUser) {
|
public async getPositionTenure(@Path() profileId: string, @Request() req: RequestWithUser) {
|
||||||
const position = await AppDataSource.query(
|
const position = await AppDataSource.query("CALL GetProfileSalaryPosition(?)", [profileId]);
|
||||||
"CALL GetProfileSalaryPosition(?)",
|
const _position = position.length > 0 ? position[0] : [];
|
||||||
[profileId]
|
const mapPosition =
|
||||||
);
|
_position.length > 1
|
||||||
const _position = position.length > 0 ? position[0] : []
|
? _position.slice(1).map((curr: any, index: number) => ({
|
||||||
const mapPosition = _position.length > 1
|
year: curr.Years ? Math.floor(Number(curr.Years)) : 0,
|
||||||
? _position
|
month: curr.Months ? Math.floor(Number(curr.Months)) : 0,
|
||||||
.slice(1)
|
day: curr.Days ? Math.floor(Number(curr.Days)) : 0,
|
||||||
.map((curr: any, index: number) => ({
|
name: _position[index]?.positionName,
|
||||||
year: curr.Years ? Math.floor(Number(curr.Years)) : 0,
|
}))
|
||||||
month: curr.Months ? Math.floor(Number(curr.Months)) : 0,
|
: [];
|
||||||
day: curr.Days ? Math.floor(Number(curr.Days)) : 0,
|
|
||||||
name: _position[index]?.positionName
|
|
||||||
}))
|
|
||||||
: [];
|
|
||||||
|
|
||||||
const posLevel = [{
|
const posLevel: any = [
|
||||||
year: 1,
|
// {
|
||||||
month: 0,
|
// year: 1,
|
||||||
day: 0,
|
// month: 0,
|
||||||
name: "ต้น",
|
// day: 0,
|
||||||
}];
|
// name: "ต้น",
|
||||||
|
// }
|
||||||
|
];
|
||||||
|
|
||||||
const posExecutive = await AppDataSource.query(
|
const posExecutive = await AppDataSource.query("CALL GetProfileSalaryExecutive(?)", [
|
||||||
"CALL GetProfileSalaryExecutive(?)",
|
profileId,
|
||||||
[profileId]
|
]);
|
||||||
);
|
const _posExecutive = posExecutive.length > 0 ? posExecutive[0] : [];
|
||||||
const _posExecutive = posExecutive.length > 0 ? posExecutive[0] : []
|
const mapPosExecutive =
|
||||||
const mapPosExecutive = _posExecutive.length > 1
|
_posExecutive.length > 1
|
||||||
? _posExecutive
|
? _posExecutive.slice(1).map((curr: any, index: number) => ({
|
||||||
.slice(1)
|
year: curr.Years ? Math.floor(Number(curr.Years)) : 0,
|
||||||
.map((curr: any, index: number) => ({
|
month: curr.Months ? Math.floor(Number(curr.Months)) : 0,
|
||||||
year: curr.Years ? Math.floor(Number(curr.Years)) : 0,
|
day: curr.Days ? Math.floor(Number(curr.Days)) : 0,
|
||||||
month: curr.Months ? Math.floor(Number(curr.Months)) : 0,
|
name: _posExecutive[index]?.positionName,
|
||||||
day: curr.Days ? Math.floor(Number(curr.Days)) : 0,
|
}))
|
||||||
name: _posExecutive[index]?.positionName
|
: [];
|
||||||
}))
|
|
||||||
: [];
|
|
||||||
|
|
||||||
return new HttpSuccess({
|
return new HttpSuccess({
|
||||||
position: mapPosition,
|
position: mapPosition,
|
||||||
posLevel: posLevel,
|
posLevel: posLevel,
|
||||||
posExecutive: mapPosExecutive
|
posExecutive: mapPosExecutive,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Get("admin/{profileId}")
|
@Get("admin/{profileId}")
|
||||||
public async getSalaryAdmin(@Path() profileId: string, @Request() req: RequestWithUser) {
|
public async getSalaryAdmin(@Path() profileId: string, @Request() req: RequestWithUser) {
|
||||||
let _workflow = await new permission().Workflow(req, profileId, "SYS_SALARY_OFFICER");
|
let _workflow = await new permission().Workflow(req, profileId, "SYS_SALARY_OFFICER");
|
||||||
|
|
|
||||||
|
|
@ -89,32 +89,31 @@ export class ProfileSalaryEmployeeController extends Controller {
|
||||||
|
|
||||||
@Get("tenure/{profileId}")
|
@Get("tenure/{profileId}")
|
||||||
public async getPositionTenure(@Path() profileId: string, @Request() req: RequestWithUser) {
|
public async getPositionTenure(@Path() profileId: string, @Request() req: RequestWithUser) {
|
||||||
const position = await AppDataSource.query(
|
const position = await AppDataSource.query("CALL GetProfileEmployeeSalaryPosition(?)", [
|
||||||
"CALL GetProfileEmployeeSalaryPosition(?)",
|
profileId,
|
||||||
[profileId]
|
]);
|
||||||
);
|
const _position = position.length > 0 ? position[0] : [];
|
||||||
const _position = position.length > 0 ? position[0] : []
|
const mapPosition =
|
||||||
const mapPosition = _position.length > 1
|
_position.length > 1
|
||||||
? _position
|
? _position.slice(1).map((curr: any, index: number) => ({
|
||||||
.slice(1)
|
year: curr.Years ? Math.floor(Number(curr.Years)) : 0,
|
||||||
.map((curr: any, index: number) => ({
|
month: curr.Months ? Math.floor(Number(curr.Months)) : 0,
|
||||||
year: curr.Years ? Math.floor(Number(curr.Years)) : 0,
|
day: curr.Days ? Math.floor(Number(curr.Days)) : 0,
|
||||||
month: curr.Months ? Math.floor(Number(curr.Months)) : 0,
|
name: _position[index]?.positionName,
|
||||||
day: curr.Days ? Math.floor(Number(curr.Days)) : 0,
|
}))
|
||||||
name: _position[index]?.positionName
|
: [];
|
||||||
}))
|
|
||||||
: [];
|
|
||||||
|
|
||||||
const posLevel = [{
|
|
||||||
year: 3,
|
|
||||||
month: 0,
|
|
||||||
day: 0,
|
|
||||||
name: "ส 1",
|
|
||||||
}];
|
|
||||||
|
|
||||||
|
const posLevel: any = [
|
||||||
|
// {
|
||||||
|
// year: 3,
|
||||||
|
// month: 0,
|
||||||
|
// day: 0,
|
||||||
|
// name: "ส 1",
|
||||||
|
// }
|
||||||
|
];
|
||||||
return new HttpSuccess({
|
return new HttpSuccess({
|
||||||
position: mapPosition,
|
position: mapPosition,
|
||||||
posLevel: posLevel
|
posLevel: posLevel,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -196,11 +196,11 @@ export class ReportController extends Controller {
|
||||||
@Query() sort: "ASC" | "DESC" = "ASC",
|
@Query() sort: "ASC" | "DESC" = "ASC",
|
||||||
) {
|
) {
|
||||||
const _null: any = null;
|
const _null: any = null;
|
||||||
if(!dateStart) {
|
if (!dateStart) {
|
||||||
dateStart = _null
|
dateStart = _null;
|
||||||
}
|
}
|
||||||
if(!dateEnd) {
|
if (!dateEnd) {
|
||||||
dateEnd = _null
|
dateEnd = _null;
|
||||||
}
|
}
|
||||||
if (ageMin && (ageMin < 18 || ageMin > 60)) {
|
if (ageMin && (ageMin < 18 || ageMin > 60)) {
|
||||||
throw new HttpError(HttpStatus.NOT_FOUND, "ageMin must be between 18 and 60");
|
throw new HttpError(HttpStatus.NOT_FOUND, "ageMin must be between 18 and 60");
|
||||||
|
|
@ -247,17 +247,16 @@ export class ReportController extends Controller {
|
||||||
}
|
}
|
||||||
|
|
||||||
let retireLawCondition = "1=1";
|
let retireLawCondition = "1=1";
|
||||||
if(isRetireLaw) {
|
if (isRetireLaw) {
|
||||||
retireLawCondition =
|
retireLawCondition =
|
||||||
"DATE(registryOfficer.dateRetireLaw) >= :startDateRetireLaw AND DATE(registryOfficer.dateRetireLaw) <= :endDateRetireLaw";
|
"DATE(registryOfficer.dateRetireLaw) >= :startDateRetireLaw AND DATE(registryOfficer.dateRetireLaw) <= :endDateRetireLaw";
|
||||||
}
|
}
|
||||||
|
|
||||||
let tenureTypeCondition = "1=1";
|
let tenureTypeCondition = "1=1";
|
||||||
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.posxecutiveYears BETWEEN :tenureMin AND :tenureMax";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const [lists, total] = await AppDataSource.getRepository(viewRegistryOfficer)
|
const [lists, total] = await AppDataSource.getRepository(viewRegistryOfficer)
|
||||||
|
|
@ -278,20 +277,22 @@ export class ReportController extends Controller {
|
||||||
endDateAppoint: dateEnd?.toISOString().split("T")[0],
|
endDateAppoint: dateEnd?.toISOString().split("T")[0],
|
||||||
})
|
})
|
||||||
.andWhere(retireLawCondition, {
|
.andWhere(retireLawCondition, {
|
||||||
startDateRetireLaw: new Date(new Date().getFullYear() - 1, 9, 1, 0, 0, 0, 0)?.toISOString().split("T")[0],
|
startDateRetireLaw: new Date(new Date().getFullYear() - 1, 9, 1, 0, 0, 0, 0)
|
||||||
endDateRetireLaw: new Date(new Date().getFullYear(), 8, 30, 23, 59, 59, 999).toISOString().split("T")[0],
|
?.toISOString()
|
||||||
|
.split("T")[0],
|
||||||
|
endDateRetireLaw: new Date(new Date().getFullYear(), 8, 30, 23, 59, 59, 999)
|
||||||
|
.toISOString()
|
||||||
|
.split("T")[0],
|
||||||
})
|
})
|
||||||
.andWhere("registryOfficer.isProbation = :isProbation", {
|
.andWhere("registryOfficer.isProbation = :isProbation", {
|
||||||
isProbation: isProbation,
|
isProbation: isProbation,
|
||||||
})
|
})
|
||||||
.andWhere(IsLeavecondition.join(" AND "), parameters)
|
.andWhere(IsLeavecondition.join(" AND "), parameters)
|
||||||
.andWhere(
|
.andWhere(
|
||||||
posType != null && posType != ""
|
posType != null && posType != "" ? "registryOfficer.posTypeName LIKE :posTypeName" : "1=1",
|
||||||
? "registryOfficer.posTypeName LIKE :posTypeName"
|
|
||||||
: "1=1",
|
|
||||||
{
|
{
|
||||||
posTypeName: `%${posType}%`,
|
posTypeName: `%${posType}%`,
|
||||||
}
|
},
|
||||||
)
|
)
|
||||||
.andWhere(
|
.andWhere(
|
||||||
posLevel != null && posLevel != ""
|
posLevel != null && posLevel != ""
|
||||||
|
|
@ -299,15 +300,13 @@ export class ReportController extends Controller {
|
||||||
: "1=1",
|
: "1=1",
|
||||||
{
|
{
|
||||||
posLevelName: `%${posLevel}%`,
|
posLevelName: `%${posLevel}%`,
|
||||||
}
|
},
|
||||||
)
|
)
|
||||||
.andWhere(
|
.andWhere(
|
||||||
position != null && position != ""
|
position != null && position != "" ? "registryOfficer.position LIKE :position" : "1=1",
|
||||||
? "registryOfficer.position LIKE :position"
|
|
||||||
: "1=1",
|
|
||||||
{
|
{
|
||||||
position: `%${position}%`,
|
position: `%${position}%`,
|
||||||
}
|
},
|
||||||
)
|
)
|
||||||
.andWhere(
|
.andWhere(
|
||||||
positionExecutive != null && positionExecutive != ""
|
positionExecutive != null && positionExecutive != ""
|
||||||
|
|
@ -315,31 +314,22 @@ export class ReportController extends Controller {
|
||||||
: "1=1",
|
: "1=1",
|
||||||
{
|
{
|
||||||
posExecutiveName: `%${positionExecutive}%`,
|
posExecutiveName: `%${positionExecutive}%`,
|
||||||
}
|
},
|
||||||
)
|
)
|
||||||
|
.andWhere(gender != null && gender != "" ? "registryOfficer.gender LIKE :gender" : "1=1", {
|
||||||
|
gender: `%${gender}%`,
|
||||||
|
})
|
||||||
.andWhere(
|
.andWhere(
|
||||||
gender != null && gender != ""
|
status != null && status != "" ? "registryOfficer.relationship LIKE :relationship" : "1=1",
|
||||||
? "registryOfficer.gender LIKE :gender"
|
|
||||||
: "1=1",
|
|
||||||
{
|
|
||||||
gender: `%${gender}%`,
|
|
||||||
}
|
|
||||||
)
|
|
||||||
.andWhere(
|
|
||||||
status != null && status != ""
|
|
||||||
? "registryOfficer.relationship LIKE :relationship"
|
|
||||||
: "1=1",
|
|
||||||
{
|
{
|
||||||
relationship: `%${status}%`,
|
relationship: `%${status}%`,
|
||||||
}
|
},
|
||||||
)
|
)
|
||||||
.andWhere(
|
.andWhere(
|
||||||
education != null && education != ""
|
education != null && education != "" ? "registryOfficer.degree LIKE :degree" : "1=1",
|
||||||
? "registryOfficer.degree LIKE :degree"
|
|
||||||
: "1=1",
|
|
||||||
{
|
{
|
||||||
degree: `%${education}%`,
|
degree: `%${education}%`,
|
||||||
}
|
},
|
||||||
)
|
)
|
||||||
.orderBy(`registryOfficer.${sortBy}`, sort)
|
.orderBy(`registryOfficer.${sortBy}`, sort)
|
||||||
.getManyAndCount();
|
.getManyAndCount();
|
||||||
|
|
@ -381,12 +371,24 @@ export class ReportController extends Controller {
|
||||||
age: x.age,
|
age: x.age,
|
||||||
currentPosition: null,
|
currentPosition: null,
|
||||||
lengthPosition: null,
|
lengthPosition: null,
|
||||||
Years: x.Years,
|
positionDate: {
|
||||||
Months: x.Months,
|
Years: x.Years,
|
||||||
Days: x.Days,
|
Months: x.Months,
|
||||||
// posExecutiveYears: x.posExecutiveYears,
|
Days: x.Days,
|
||||||
// posExecutiveMonths: x.posExecutiveMonths,
|
},
|
||||||
// posExecutiveDays: x.posExecutiveDays
|
posExcutiveDate: {
|
||||||
|
Years: x.posExecutiveYears,
|
||||||
|
Months: x.posExecutiveMonths,
|
||||||
|
Days: x.posExecutiveDays,
|
||||||
|
},
|
||||||
|
posLevelDate: {
|
||||||
|
// Years: x.levelYears,
|
||||||
|
// Months: x.levelMonths,
|
||||||
|
// Days: x.levelDays,
|
||||||
|
Years: 0,
|
||||||
|
Months: 0,
|
||||||
|
Days: 0,
|
||||||
|
},
|
||||||
}));
|
}));
|
||||||
return new HttpSuccess({
|
return new HttpSuccess({
|
||||||
data: mapData,
|
data: mapData,
|
||||||
|
|
@ -536,11 +538,11 @@ export class ReportController extends Controller {
|
||||||
@Query() sort: "ASC" | "DESC" = "ASC",
|
@Query() sort: "ASC" | "DESC" = "ASC",
|
||||||
) {
|
) {
|
||||||
const _null: any = null;
|
const _null: any = null;
|
||||||
if(!dateStart) {
|
if (!dateStart) {
|
||||||
dateStart = _null
|
dateStart = _null;
|
||||||
}
|
}
|
||||||
if(!dateEnd) {
|
if (!dateEnd) {
|
||||||
dateEnd = _null
|
dateEnd = _null;
|
||||||
}
|
}
|
||||||
if (ageMin && (ageMin < 18 || ageMin > 60)) {
|
if (ageMin && (ageMin < 18 || ageMin > 60)) {
|
||||||
throw new HttpError(HttpStatus.NOT_FOUND, "ageMin must be between 18 and 60");
|
throw new HttpError(HttpStatus.NOT_FOUND, "ageMin must be between 18 and 60");
|
||||||
|
|
@ -587,9 +589,9 @@ export class ReportController extends Controller {
|
||||||
}
|
}
|
||||||
|
|
||||||
let retireLawCondition = "1=1";
|
let retireLawCondition = "1=1";
|
||||||
if(isRetireLaw) {
|
if (isRetireLaw) {
|
||||||
retireLawCondition =
|
retireLawCondition =
|
||||||
"DATE(registryEmployee.dateRetireLaw) >= :startDateRetireLaw AND DATE(registryEmployee.dateRetireLaw) <= :endDateRetireLaw";
|
"DATE(registryEmployee.dateRetireLaw) >= :startDateRetireLaw AND DATE(registryEmployee.dateRetireLaw) <= :endDateRetireLaw";
|
||||||
}
|
}
|
||||||
|
|
||||||
const [lists, total] = await AppDataSource.getRepository(viewRegistryEmployee)
|
const [lists, total] = await AppDataSource.getRepository(viewRegistryEmployee)
|
||||||
|
|
@ -606,8 +608,12 @@ export class ReportController extends Controller {
|
||||||
endDateAppoint: dateEnd?.toISOString().split("T")[0],
|
endDateAppoint: dateEnd?.toISOString().split("T")[0],
|
||||||
})
|
})
|
||||||
.andWhere(retireLawCondition, {
|
.andWhere(retireLawCondition, {
|
||||||
startDateRetireLaw: new Date(new Date().getFullYear() - 1, 9, 1, 0, 0, 0, 0)?.toISOString().split("T")[0],
|
startDateRetireLaw: new Date(new Date().getFullYear() - 1, 9, 1, 0, 0, 0, 0)
|
||||||
endDateRetireLaw: new Date(new Date().getFullYear(), 8, 30, 23, 59, 59, 999).toISOString().split("T")[0],
|
?.toISOString()
|
||||||
|
.split("T")[0],
|
||||||
|
endDateRetireLaw: new Date(new Date().getFullYear(), 8, 30, 23, 59, 59, 999)
|
||||||
|
.toISOString()
|
||||||
|
.split("T")[0],
|
||||||
})
|
})
|
||||||
.andWhere("registryEmployee.isProbation = :isProbation", {
|
.andWhere("registryEmployee.isProbation = :isProbation", {
|
||||||
isProbation: isProbation,
|
isProbation: isProbation,
|
||||||
|
|
@ -615,12 +621,10 @@ export class ReportController extends Controller {
|
||||||
.andWhere(IsLeavecondition.join(" AND "), parameters)
|
.andWhere(IsLeavecondition.join(" AND "), parameters)
|
||||||
.andWhere("registryEmployee.employeeClass = 'PERM'")
|
.andWhere("registryEmployee.employeeClass = 'PERM'")
|
||||||
.andWhere(
|
.andWhere(
|
||||||
posType != null && posType != ""
|
posType != null && posType != "" ? "registryEmployee.posTypeName LIKE :posTypeName" : "1=1",
|
||||||
? "registryEmployee.posTypeName LIKE :posTypeName"
|
|
||||||
: "1=1",
|
|
||||||
{
|
{
|
||||||
posTypeName: `%${posType}%`,
|
posTypeName: `%${posType}%`,
|
||||||
}
|
},
|
||||||
)
|
)
|
||||||
.andWhere(
|
.andWhere(
|
||||||
posLevel != null && posLevel != ""
|
posLevel != null && posLevel != ""
|
||||||
|
|
@ -628,39 +632,28 @@ export class ReportController extends Controller {
|
||||||
: "1=1",
|
: "1=1",
|
||||||
{
|
{
|
||||||
posLevelName: `%${posLevel}%`,
|
posLevelName: `%${posLevel}%`,
|
||||||
}
|
},
|
||||||
)
|
)
|
||||||
.andWhere(
|
.andWhere(
|
||||||
position != null && position != ""
|
position != null && position != "" ? "registryEmployee.position LIKE :position" : "1=1",
|
||||||
? "registryEmployee.position LIKE :position"
|
|
||||||
: "1=1",
|
|
||||||
{
|
{
|
||||||
position: `%${position}%`,
|
position: `%${position}%`,
|
||||||
}
|
},
|
||||||
)
|
)
|
||||||
|
.andWhere(gender != null && gender != "" ? "registryEmployee.gender LIKE :gender" : "1=1", {
|
||||||
|
gender: `%${gender}%`,
|
||||||
|
})
|
||||||
.andWhere(
|
.andWhere(
|
||||||
gender != null && gender != ""
|
status != null && status != "" ? "registryEmployee.relationship LIKE :relationship" : "1=1",
|
||||||
? "registryEmployee.gender LIKE :gender"
|
|
||||||
: "1=1",
|
|
||||||
{
|
|
||||||
gender: `%${gender}%`,
|
|
||||||
}
|
|
||||||
)
|
|
||||||
.andWhere(
|
|
||||||
status != null && status != ""
|
|
||||||
? "registryEmployee.relationship LIKE :relationship"
|
|
||||||
: "1=1",
|
|
||||||
{
|
{
|
||||||
relationship: `%${status}%`,
|
relationship: `%${status}%`,
|
||||||
}
|
},
|
||||||
)
|
)
|
||||||
.andWhere(
|
.andWhere(
|
||||||
education != null && education != ""
|
education != null && education != "" ? "registryEmployee.degree LIKE :degree" : "1=1",
|
||||||
? "registryEmployee.degree LIKE :degree"
|
|
||||||
: "1=1",
|
|
||||||
{
|
{
|
||||||
degree: `%${education}%`,
|
degree: `%${education}%`,
|
||||||
}
|
},
|
||||||
)
|
)
|
||||||
.orderBy(`registryEmployee.${sortBy}`, sort)
|
.orderBy(`registryEmployee.${sortBy}`, sort)
|
||||||
.getManyAndCount();
|
.getManyAndCount();
|
||||||
|
|
|
||||||
155
src/entities/view/viewCurrentTenureExcOfficer.ts
Normal file
155
src/entities/view/viewCurrentTenureExcOfficer.ts
Normal file
|
|
@ -0,0 +1,155 @@
|
||||||
|
import { ViewColumn, ViewEntity } from "typeorm";
|
||||||
|
|
||||||
|
@ViewEntity({
|
||||||
|
expression: `
|
||||||
|
SELECT
|
||||||
|
DATE(MIN(commandDateAffect)) AS commandDateAffect,
|
||||||
|
TIMESTAMPDIFF(
|
||||||
|
DAY,
|
||||||
|
LAG(MIN(commandDateAffect)) OVER (PARTITION BY profileId ORDER BY commandDateAffect, \`order\` ASC), MIN(commandDateAffect)) AS days_diff,
|
||||||
|
TIMESTAMPDIFF(
|
||||||
|
DAY,
|
||||||
|
LAG(MIN(commandDateAffect)) OVER (PARTITION BY profileId ORDER BY commandDateAffect, \`order\` ASC), MIN(commandDateAffect)) / 365.2524 AS 'Years',
|
||||||
|
TIMESTAMPDIFF(
|
||||||
|
DAY,
|
||||||
|
LAG(MIN(commandDateAffect)) OVER (PARTITION BY profileId ORDER BY commandDateAffect, \`order\` ASC), MIN(commandDateAffect)) / 30.4375 % 12 AS 'Months',
|
||||||
|
TIMESTAMPDIFF(
|
||||||
|
DAY,
|
||||||
|
LAG(MIN(commandDateAffect)) OVER (PARTITION BY profileId ORDER BY commandDateAffect, \`order\` ASC), MIN(commandDateAffect)) % 30.4375 AS 'Days',
|
||||||
|
positionName,
|
||||||
|
positionCee,
|
||||||
|
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
|
||||||
|
profileSalary
|
||||||
|
WHERE
|
||||||
|
commandCode IN (1, 2, 3, 4, 8, 10, 11, 12, 15, 16) AND
|
||||||
|
positionExecutive <> '' AND
|
||||||
|
positionExecutive is not null
|
||||||
|
GROUP BY
|
||||||
|
profileId, positionExecutive
|
||||||
|
|
||||||
|
UNION ALL
|
||||||
|
|
||||||
|
SELECT
|
||||||
|
CURDATE() AS commandDateAffect,
|
||||||
|
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 positionName,
|
||||||
|
NULL AS positionCee,
|
||||||
|
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,
|
||||||
|
'Comparison with current date' AS remark,
|
||||||
|
profileId,
|
||||||
|
NULL AS orderNumber
|
||||||
|
FROM
|
||||||
|
profileSalary
|
||||||
|
WHERE
|
||||||
|
commandCode IN (1, 2, 3, 4, 8, 10, 11, 12, 15, 16) AND
|
||||||
|
positionExecutive <> '' AND
|
||||||
|
positionExecutive is not null
|
||||||
|
GROUP BY
|
||||||
|
profileId
|
||||||
|
|
||||||
|
ORDER BY
|
||||||
|
profileId,
|
||||||
|
commandDateAffect ASC
|
||||||
|
`,
|
||||||
|
})
|
||||||
|
export class viewCurrentTenureExcOfficer {
|
||||||
|
@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;
|
||||||
|
}
|
||||||
|
|
@ -55,6 +55,26 @@ import { ViewColumn, ViewEntity } from "typeorm";
|
||||||
FROM profileEducation ed
|
FROM profileEducation ed
|
||||||
WHERE ed.isUse IS TRUE
|
WHERE ed.isUse IS TRUE
|
||||||
ORDER BY ed.level ASC
|
ORDER BY ed.level ASC
|
||||||
|
),
|
||||||
|
PositionDate AS (
|
||||||
|
SELECT
|
||||||
|
vcto.Years,
|
||||||
|
vcto.Months,
|
||||||
|
vcto.Days,
|
||||||
|
vcto.profileId,
|
||||||
|
ROW_NUMBER() OVER (PARTITION BY vcto.profileId) AS vcto_number
|
||||||
|
FROM view_current_tenure_officer vcto
|
||||||
|
WHERE vcto.orderNumber Is Null
|
||||||
|
),
|
||||||
|
PositionExcDate AS (
|
||||||
|
SELECT
|
||||||
|
vctoExc.Years,
|
||||||
|
vctoExc.Months,
|
||||||
|
vctoExc.Days,
|
||||||
|
vctoExc.profileId,
|
||||||
|
ROW_NUMBER() OVER (PARTITION BY vctoExc.profileId) AS vctoExc_number
|
||||||
|
FROM view_current_tenure_exc_officer vctoExc
|
||||||
|
WHERE vctoExc.orderNumber Is Null
|
||||||
)
|
)
|
||||||
SELECT
|
SELECT
|
||||||
p.id as profileId,
|
p.id as profileId,
|
||||||
|
|
@ -100,14 +120,17 @@ import { ViewColumn, ViewEntity } from "typeorm";
|
||||||
TIMESTAMPDIFF(YEAR, p.birthdate, CURDATE()) AS age,
|
TIMESTAMPDIFF(YEAR, p.birthdate, CURDATE()) AS age,
|
||||||
vcto.Years,
|
vcto.Years,
|
||||||
vcto.Months,
|
vcto.Months,
|
||||||
vcto.Days
|
vcto.Days,
|
||||||
|
vctoExc.Years AS posExecutiveYears,
|
||||||
|
vctoExc.Months AS posExecutiveMonths,
|
||||||
|
vctoExc.Days AS posExecutiveDays
|
||||||
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
|
||||||
LEFT JOIN PosMaster pm ON p.id = pm.current_holderId AND pm.pm_number = 1
|
LEFT JOIN PosMaster pm ON p.id = pm.current_holderId AND pm.pm_number = 1
|
||||||
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
|
||||||
Inner Join view_current_tenure_officer vcto On p.id = vcto.profileId
|
LEFT JOIN PositionDate vcto ON p.id = vcto.profileId AND vcto.vcto_number = 1
|
||||||
Where vcto.orderNumber Is Null
|
LEFT JOIN PositionExcDate vctoExc ON p.id = vctoExc.profileId AND vctoExc.vctoExc_number = 1
|
||||||
`,
|
`,
|
||||||
})
|
})
|
||||||
export class viewRegistryOfficer {
|
export class viewRegistryOfficer {
|
||||||
|
|
@ -222,13 +245,12 @@ export class viewRegistryOfficer {
|
||||||
@ViewColumn()
|
@ViewColumn()
|
||||||
Days: number;
|
Days: number;
|
||||||
|
|
||||||
// @ViewColumn()
|
@ViewColumn()
|
||||||
// posExecutiveYears: number;
|
posExecutiveYears: number;
|
||||||
|
|
||||||
// @ViewColumn()
|
@ViewColumn()
|
||||||
// posExecutiveMonths: number;
|
posExecutiveMonths: number;
|
||||||
|
|
||||||
// @ViewColumn()
|
|
||||||
// posExecutiveDays: number;
|
|
||||||
|
|
||||||
|
@ViewColumn()
|
||||||
|
posExecutiveDays: number;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
File diff suppressed because one or more lines are too long
Loading…
Add table
Add a link
Reference in a new issue