add posexcutive date

This commit is contained in:
kittapath 2025-02-28 11:45:04 +07:00
parent 180cdd225e
commit f781af3151
7 changed files with 984 additions and 155 deletions

View file

@ -1269,7 +1269,9 @@ export class ImportDataController extends Controller {
education.level = educationLevel == null ? 1 : educationLevel.level + 1;
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.level = item.EDUCATION_SEQ ? null_ : Number(item.EDUCATION_SEQ);
education.startDate = startDate;

View file

@ -82,53 +82,48 @@ export class ProfileSalaryController extends Controller {
@Get("tenure/{profileId}")
public async getPositionTenure(@Path() profileId: string, @Request() req: RequestWithUser) {
const position = await AppDataSource.query(
"CALL GetProfileSalaryPosition(?)",
[profileId]
);
const _position = position.length > 0 ? position[0] : []
const mapPosition = _position.length > 1
? _position
.slice(1)
.map((curr: any, index: number) => ({
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 position = await AppDataSource.query("CALL GetProfileSalaryPosition(?)", [profileId]);
const _position = position.length > 0 ? position[0] : [];
const mapPosition =
_position.length > 1
? _position.slice(1).map((curr: any, index: number) => ({
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 = [{
year: 1,
month: 0,
day: 0,
name: "ต้น",
}];
const posExecutive = await AppDataSource.query(
"CALL GetProfileSalaryExecutive(?)",
[profileId]
);
const _posExecutive = posExecutive.length > 0 ? posExecutive[0] : []
const mapPosExecutive = _posExecutive.length > 1
? _posExecutive
.slice(1)
.map((curr: any, index: number) => ({
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: _posExecutive[index]?.positionName
}))
: [];
const posLevel: any = [
// {
// year: 1,
// month: 0,
// day: 0,
// name: "ต้น",
// }
];
const posExecutive = await AppDataSource.query("CALL GetProfileSalaryExecutive(?)", [
profileId,
]);
const _posExecutive = posExecutive.length > 0 ? posExecutive[0] : [];
const mapPosExecutive =
_posExecutive.length > 1
? _posExecutive.slice(1).map((curr: any, index: number) => ({
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: _posExecutive[index]?.positionName,
}))
: [];
return new HttpSuccess({
position: mapPosition,
posLevel: posLevel,
posExecutive: mapPosExecutive
posLevel: posLevel,
posExecutive: mapPosExecutive,
});
}
@Get("admin/{profileId}")
public async getSalaryAdmin(@Path() profileId: string, @Request() req: RequestWithUser) {
let _workflow = await new permission().Workflow(req, profileId, "SYS_SALARY_OFFICER");

View file

@ -89,32 +89,31 @@ export class ProfileSalaryEmployeeController extends Controller {
@Get("tenure/{profileId}")
public async getPositionTenure(@Path() profileId: string, @Request() req: RequestWithUser) {
const position = await AppDataSource.query(
"CALL GetProfileEmployeeSalaryPosition(?)",
[profileId]
);
const _position = position.length > 0 ? position[0] : []
const mapPosition = _position.length > 1
? _position
.slice(1)
.map((curr: any, index: number) => ({
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 position = await AppDataSource.query("CALL GetProfileEmployeeSalaryPosition(?)", [
profileId,
]);
const _position = position.length > 0 ? position[0] : [];
const mapPosition =
_position.length > 1
? _position.slice(1).map((curr: any, index: number) => ({
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 = [{
year: 3,
month: 0,
day: 0,
name: "ส 1",
}];
const posLevel: any = [
// {
// year: 3,
// month: 0,
// day: 0,
// name: "ส 1",
// }
];
return new HttpSuccess({
position: mapPosition,
posLevel: posLevel
posLevel: posLevel,
});
}

View file

@ -196,11 +196,11 @@ export class ReportController extends Controller {
@Query() sort: "ASC" | "DESC" = "ASC",
) {
const _null: any = null;
if(!dateStart) {
dateStart = _null
if (!dateStart) {
dateStart = _null;
}
if(!dateEnd) {
dateEnd = _null
if (!dateEnd) {
dateEnd = _null;
}
if (ageMin && (ageMin < 18 || ageMin > 60)) {
throw new HttpError(HttpStatus.NOT_FOUND, "ageMin must be between 18 and 60");
@ -247,18 +247,17 @@ export class ReportController extends Controller {
}
let retireLawCondition = "1=1";
if(isRetireLaw) {
if (isRetireLaw) {
retireLawCondition =
"DATE(registryOfficer.dateRetireLaw) >= :startDateRetireLaw AND DATE(registryOfficer.dateRetireLaw) <= :endDateRetireLaw";
"DATE(registryOfficer.dateRetireLaw) >= :startDateRetireLaw AND DATE(registryOfficer.dateRetireLaw) <= :endDateRetireLaw";
}
let tenureTypeCondition = "1=1";
if(tenureType != "" && tenureType == "position") {
if (tenureType != "" && tenureType == "position") {
tenureTypeCondition = "registryOfficer.Years BETWEEN :tenureMin AND :tenureMax";
} else if (tenureType != "" && tenureType == "level") {
tenureTypeCondition = "registryOfficer.Years BETWEEN :tenureMin AND :tenureMax"; //xxxxxxxxxxxx
}
else if (tenureType != "" && tenureType == "level") {
tenureTypeCondition = "registryOfficer.posxecutiveYears BETWEEN :tenureMin AND :tenureMax";
}
const [lists, total] = await AppDataSource.getRepository(viewRegistryOfficer)
.createQueryBuilder("registryOfficer")
@ -278,36 +277,36 @@ export class ReportController extends Controller {
endDateAppoint: dateEnd?.toISOString().split("T")[0],
})
.andWhere(retireLawCondition, {
startDateRetireLaw: new Date(new Date().getFullYear() - 1, 9, 1, 0, 0, 0, 0)?.toISOString().split("T")[0],
endDateRetireLaw: new Date(new Date().getFullYear(), 8, 30, 23, 59, 59, 999).toISOString().split("T")[0],
startDateRetireLaw: new Date(new Date().getFullYear() - 1, 9, 1, 0, 0, 0, 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", {
isProbation: isProbation,
})
.andWhere(IsLeavecondition.join(" AND "), parameters)
.andWhere(
posType != null && posType != ""
? "registryOfficer.posTypeName LIKE :posTypeName"
: "1=1",
posType != null && posType != "" ? "registryOfficer.posTypeName LIKE :posTypeName" : "1=1",
{
posTypeName: `%${posType}%`,
}
},
)
.andWhere(
posLevel != null && posLevel != ""
? "registryOfficer.posLevelName LIKE :posLevelName"
posLevel != null && posLevel != ""
? "registryOfficer.posLevelName LIKE :posLevelName"
: "1=1",
{
posLevelName: `%${posLevel}%`,
}
},
)
.andWhere(
position != null && position != ""
? "registryOfficer.position LIKE :position"
: "1=1",
position != null && position != "" ? "registryOfficer.position LIKE :position" : "1=1",
{
position: `%${position}%`,
}
},
)
.andWhere(
positionExecutive != null && positionExecutive != ""
@ -315,31 +314,22 @@ export class ReportController extends Controller {
: "1=1",
{
posExecutiveName: `%${positionExecutive}%`,
}
},
)
.andWhere(gender != null && gender != "" ? "registryOfficer.gender LIKE :gender" : "1=1", {
gender: `%${gender}%`,
})
.andWhere(
gender != null && gender != ""
? "registryOfficer.gender LIKE :gender"
: "1=1",
{
gender: `%${gender}%`,
}
)
.andWhere(
status != null && status != ""
? "registryOfficer.relationship LIKE :relationship"
: "1=1",
status != null && status != "" ? "registryOfficer.relationship LIKE :relationship" : "1=1",
{
relationship: `%${status}%`,
}
},
)
.andWhere(
education != null && education != ""
? "registryOfficer.degree LIKE :degree"
: "1=1",
education != null && education != "" ? "registryOfficer.degree LIKE :degree" : "1=1",
{
degree: `%${education}%`,
}
},
)
.orderBy(`registryOfficer.${sortBy}`, sort)
.getManyAndCount();
@ -381,12 +371,24 @@ export class ReportController extends Controller {
age: x.age,
currentPosition: null,
lengthPosition: null,
Years: x.Years,
Months: x.Months,
Days: x.Days,
// posExecutiveYears: x.posExecutiveYears,
// posExecutiveMonths: x.posExecutiveMonths,
// posExecutiveDays: x.posExecutiveDays
positionDate: {
Years: x.Years,
Months: x.Months,
Days: x.Days,
},
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({
data: mapData,
@ -536,11 +538,11 @@ export class ReportController extends Controller {
@Query() sort: "ASC" | "DESC" = "ASC",
) {
const _null: any = null;
if(!dateStart) {
dateStart = _null
if (!dateStart) {
dateStart = _null;
}
if(!dateEnd) {
dateEnd = _null
if (!dateEnd) {
dateEnd = _null;
}
if (ageMin && (ageMin < 18 || ageMin > 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";
if(isRetireLaw) {
if (isRetireLaw) {
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)
@ -606,8 +608,12 @@ export class ReportController extends Controller {
endDateAppoint: dateEnd?.toISOString().split("T")[0],
})
.andWhere(retireLawCondition, {
startDateRetireLaw: new Date(new Date().getFullYear() - 1, 9, 1, 0, 0, 0, 0)?.toISOString().split("T")[0],
endDateRetireLaw: new Date(new Date().getFullYear(), 8, 30, 23, 59, 59, 999).toISOString().split("T")[0],
startDateRetireLaw: new Date(new Date().getFullYear() - 1, 9, 1, 0, 0, 0, 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", {
isProbation: isProbation,
@ -615,52 +621,39 @@ export class ReportController extends Controller {
.andWhere(IsLeavecondition.join(" AND "), parameters)
.andWhere("registryEmployee.employeeClass = 'PERM'")
.andWhere(
posType != null && posType != ""
? "registryEmployee.posTypeName LIKE :posTypeName"
: "1=1",
posType != null && posType != "" ? "registryEmployee.posTypeName LIKE :posTypeName" : "1=1",
{
posTypeName: `%${posType}%`,
}
},
)
.andWhere(
posLevel != null && posLevel != ""
? "registryEmployee.posLevelName LIKE :posLevelName"
posLevel != null && posLevel != ""
? "registryEmployee.posLevelName LIKE :posLevelName"
: "1=1",
{
posLevelName: `%${posLevel}%`,
}
},
)
.andWhere(
position != null && position != ""
? "registryEmployee.position LIKE :position"
: "1=1",
position != null && position != "" ? "registryEmployee.position LIKE :position" : "1=1",
{
position: `%${position}%`,
}
},
)
.andWhere(gender != null && gender != "" ? "registryEmployee.gender LIKE :gender" : "1=1", {
gender: `%${gender}%`,
})
.andWhere(
gender != null && gender != ""
? "registryEmployee.gender LIKE :gender"
: "1=1",
{
gender: `%${gender}%`,
}
)
.andWhere(
status != null && status != ""
? "registryEmployee.relationship LIKE :relationship"
: "1=1",
status != null && status != "" ? "registryEmployee.relationship LIKE :relationship" : "1=1",
{
relationship: `%${status}%`,
}
},
)
.andWhere(
education != null && education != ""
? "registryEmployee.degree LIKE :degree"
: "1=1",
education != null && education != "" ? "registryEmployee.degree LIKE :degree" : "1=1",
{
degree: `%${education}%`,
}
},
)
.orderBy(`registryEmployee.${sortBy}`, sort)
.getManyAndCount();