Merge branch 'develop' of github.com:Frappet/hrms-api-org into develop
This commit is contained in:
commit
7b2773f557
5 changed files with 239 additions and 93 deletions
|
|
@ -19,7 +19,7 @@ import HttpError from "../interfaces/http-error";
|
|||
import { ProfileSalaryHistory } from "../entities/ProfileSalaryHistory";
|
||||
import { RequestWithUser } from "../middlewares/user";
|
||||
import { Profile } from "../entities/Profile";
|
||||
import { LessThan, MoreThan } from "typeorm";
|
||||
import { In, LessThan, MoreThan } from "typeorm";
|
||||
import permission from "../interfaces/permission";
|
||||
import { setLogDataDiff } from "../interfaces/utils";
|
||||
@Route("api/v1/org/profile/salary")
|
||||
|
|
@ -62,7 +62,7 @@ export class ProfileSalaryController extends Controller {
|
|||
if (_workflow == false)
|
||||
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", profileId);
|
||||
const record = await this.salaryRepo.find({
|
||||
where: { profileId: profileId },
|
||||
where: { profileId: profileId, commandCode: In(["5", "6", "7"]) },
|
||||
order: { order: "ASC" },
|
||||
});
|
||||
return new HttpSuccess(record);
|
||||
|
|
@ -74,7 +74,25 @@ export class ProfileSalaryController extends Controller {
|
|||
if (_workflow == false)
|
||||
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", profileId);
|
||||
const record = await this.salaryRepo.find({
|
||||
where: { profileId: profileId },
|
||||
where: {
|
||||
profileId: profileId,
|
||||
commandCode: In([
|
||||
"0",
|
||||
"9",
|
||||
"1",
|
||||
"2",
|
||||
"3",
|
||||
"4",
|
||||
"8",
|
||||
"10",
|
||||
"11",
|
||||
"12",
|
||||
"13",
|
||||
"14",
|
||||
"15",
|
||||
"16",
|
||||
]),
|
||||
},
|
||||
order: { order: "ASC" },
|
||||
});
|
||||
return new HttpSuccess(record);
|
||||
|
|
|
|||
|
|
@ -31,6 +31,9 @@ import { Profile } from "../entities/Profile";
|
|||
import { viewRegistryOfficer } from "../entities/view/viewRegistryOfficer";
|
||||
import { viewRegistryEmployee } from "../entities/view/viewRegistryEmployee";
|
||||
import { EmployeeTempPosMaster } from "../entities/EmployeeTempPosMaster";
|
||||
// import { WebSocket } from "ws";
|
||||
// import { wss } from "../app";
|
||||
|
||||
@Route("api/v1/org/report")
|
||||
@Tags("Report")
|
||||
@Security("bearerAuth")
|
||||
|
|
@ -334,58 +337,82 @@ export class ReportController extends Controller {
|
|||
.orderBy(`registryOfficer.${sortBy}`, sort)
|
||||
.getManyAndCount();
|
||||
|
||||
const mapData = lists.map((x) => ({
|
||||
profileId: x.profileId,
|
||||
citizenId: x.citizenId,
|
||||
prefix: x.prefix,
|
||||
firstName: x.firstName,
|
||||
lastName: x.lastName,
|
||||
isProbation: x.isProbation,
|
||||
isLeave: x.isLeave,
|
||||
isRetirement: x.isRetirement,
|
||||
leaveType: x.leaveType,
|
||||
posMasterNo: x.posMasterNo,
|
||||
orgRootId: x.orgRootId,
|
||||
orgChild1Id: x.orgChild1Id,
|
||||
orgChild2Id: x.orgChild2Id,
|
||||
orgChild3Id: x.orgChild3Id,
|
||||
orgChild4Id: x.orgChild4Id,
|
||||
orgRootName: x.orgRootName,
|
||||
orgChild1Name: x.orgChild1Name,
|
||||
orgChild2Name: x.orgChild2Name,
|
||||
orgChild3Name: x.orgChild3Name,
|
||||
orgChild4Name: x.orgChild4Name,
|
||||
org: x.org,
|
||||
searchShortName: x.searchShortName,
|
||||
posExecutiveName: x.posExecutiveName,
|
||||
position: x.position,
|
||||
posTypeName: x.posTypeName,
|
||||
posLevelName: x.posLevelName,
|
||||
gender: x.gender,
|
||||
relationship: x.relationship,
|
||||
dateAppoint: x.dateAppoint,
|
||||
dateRetire: x.dateRetire,
|
||||
dateRetireLaw: x.dateRetireLaw,
|
||||
birthdate: x.birthdate,
|
||||
degree: x.degree,
|
||||
age: x.age,
|
||||
currentPosition: null,
|
||||
lengthPosition: null,
|
||||
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,
|
||||
},
|
||||
const mapData = await Promise.all(lists.map(async(x) => {
|
||||
const position = await AppDataSource.query("CALL GetProfileSalaryPosition(?)", [x.profileId])
|
||||
const _position = position.length > 0 ? position[0] : [];
|
||||
const lastPosition = _position.length > 0 ? _position[_position.length - 1] : null; // last row
|
||||
const mapPosition = lastPosition
|
||||
? [{
|
||||
Years: lastPosition.Years ? Math.floor(Number(lastPosition.Years)) : 0,
|
||||
Months: lastPosition.Months ? Math.floor(Number(lastPosition.Months)) : 0,
|
||||
Daysday: lastPosition.Days ? Math.floor(Number(lastPosition.Days)) : 0,
|
||||
}]
|
||||
: [];
|
||||
const posLevel = await AppDataSource.query("CALL GetProfileSalaryLevel(?)", [x.profileId])
|
||||
const _posLevel = posLevel.length > 0 ? posLevel[0] : [];
|
||||
const lastPosLevel= _posLevel.length > 0 ? _posLevel[_posLevel.length - 1] : null;
|
||||
const mapPosLevel = lastPosLevel
|
||||
? [{
|
||||
Years: lastPosLevel.Years ? Math.floor(Number(lastPosLevel.Years)) : 0,
|
||||
Months: lastPosLevel.Months ? Math.floor(Number(lastPosLevel.Months)) : 0,
|
||||
Daysday: lastPosLevel.Days ? Math.floor(Number(lastPosLevel.Days)) : 0,
|
||||
}]
|
||||
: [];
|
||||
return {
|
||||
profileId: x.profileId,
|
||||
citizenId: x.citizenId,
|
||||
prefix: x.prefix,
|
||||
firstName: x.firstName,
|
||||
lastName: x.lastName,
|
||||
isProbation: x.isProbation,
|
||||
isLeave: x.isLeave,
|
||||
isRetirement: x.isRetirement,
|
||||
leaveType: x.leaveType,
|
||||
posMasterNo: x.posMasterNo,
|
||||
orgRootId: x.orgRootId,
|
||||
orgChild1Id: x.orgChild1Id,
|
||||
orgChild2Id: x.orgChild2Id,
|
||||
orgChild3Id: x.orgChild3Id,
|
||||
orgChild4Id: x.orgChild4Id,
|
||||
orgRootName: x.orgRootName,
|
||||
orgChild1Name: x.orgChild1Name,
|
||||
orgChild2Name: x.orgChild2Name,
|
||||
orgChild3Name: x.orgChild3Name,
|
||||
orgChild4Name: x.orgChild4Name,
|
||||
org: x.org,
|
||||
searchShortName: x.searchShortName,
|
||||
posExecutiveName: x.posExecutiveName,
|
||||
position: x.position,
|
||||
posTypeName: x.posTypeName,
|
||||
posLevelName: x.posLevelName,
|
||||
gender: x.gender,
|
||||
relationship: x.relationship,
|
||||
dateAppoint: x.dateAppoint,
|
||||
dateRetire: x.dateRetire,
|
||||
dateRetireLaw: x.dateRetireLaw,
|
||||
birthdate: x.birthdate,
|
||||
degree: x.degree,
|
||||
age: x.age,
|
||||
currentPosition: null,
|
||||
lengthPosition: null,
|
||||
// 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,
|
||||
// },
|
||||
positionDate: mapPosition,
|
||||
posLevelDate: mapPosLevel
|
||||
}
|
||||
}));
|
||||
return new HttpSuccess({
|
||||
data: mapData,
|
||||
|
|
@ -654,43 +681,68 @@ export class ReportController extends Controller {
|
|||
)
|
||||
.orderBy(`registryEmployee.${sortBy}`, sort)
|
||||
.getManyAndCount();
|
||||
const mapData = lists.map((x) => ({
|
||||
profileId: x.profileEmployeeId,
|
||||
citizenId: x.citizenId,
|
||||
prefix: x.prefix,
|
||||
firstName: x.firstName,
|
||||
lastName: x.lastName,
|
||||
isProbation: x.isProbation,
|
||||
isLeave: x.isLeave,
|
||||
isRetirement: x.isRetirement,
|
||||
leaveType: x.leaveType,
|
||||
posMasterNo: x.posMasterNo,
|
||||
orgRootId: x.orgRootId,
|
||||
orgChild1Id: x.orgChild1Id,
|
||||
orgChild2Id: x.orgChild2Id,
|
||||
orgChild3Id: x.orgChild3Id,
|
||||
orgChild4Id: x.orgChild4Id,
|
||||
orgRootName: x.orgRootName,
|
||||
orgChild1Name: x.orgChild1Name,
|
||||
orgChild2Name: x.orgChild2Name,
|
||||
orgChild3Name: x.orgChild3Name,
|
||||
orgChild4Name: x.orgChild4Name,
|
||||
org: x.org,
|
||||
searchShortName: x.searchShortName,
|
||||
position: x.position,
|
||||
posTypeName: x.posTypeName,
|
||||
posLevelName: x.posLevelName,
|
||||
gender: x.gender,
|
||||
relationship: x.relationship,
|
||||
dateAppoint: x.dateAppoint,
|
||||
dateRetire: x.dateRetire,
|
||||
dateRetireLaw: x.dateRetireLaw,
|
||||
birthdate: x.birthdate,
|
||||
degree: x.degree,
|
||||
age: x.age,
|
||||
currentPosition: null,
|
||||
lengthPosition: null,
|
||||
}));
|
||||
|
||||
const mapData = await Promise.all(lists.map(async(x) => {
|
||||
const position = await AppDataSource.query("CALL GetProfileEmployeeSalaryPosition(?)", [x.profileEmployeeId])
|
||||
const _position = position.length > 0 ? position[0] : [];
|
||||
const lastPosition = _position.length > 0 ? _position[_position.length - 1] : null;
|
||||
const mapPosition = lastPosition
|
||||
? [{
|
||||
Years: lastPosition.Years ? Math.floor(Number(lastPosition.Years)) : 0,
|
||||
Months: lastPosition.Months ? Math.floor(Number(lastPosition.Months)) : 0,
|
||||
Daysday: lastPosition.Days ? Math.floor(Number(lastPosition.Days)) : 0,
|
||||
}]
|
||||
: [];
|
||||
const posLevel = await AppDataSource.query("CALL GetProfileEmployeeSalaryLevel(?)", [x.profileEmployeeId])
|
||||
const _posLevel = posLevel.length > 0 ? posLevel[0] : [];
|
||||
const lastPosLevel= _posLevel.length > 0 ? _posLevel[_posLevel.length - 1] : null;
|
||||
const mapPosLevel = lastPosLevel
|
||||
? [{
|
||||
Years: lastPosLevel.Years ? Math.floor(Number(lastPosLevel.Years)) : 0,
|
||||
Months: lastPosLevel.Months ? Math.floor(Number(lastPosLevel.Months)) : 0,
|
||||
Daysday: lastPosLevel.Days ? Math.floor(Number(lastPosLevel.Days)) : 0,
|
||||
}]
|
||||
: [];
|
||||
return {
|
||||
profileId: x.profileEmployeeId,
|
||||
citizenId: x.citizenId,
|
||||
prefix: x.prefix,
|
||||
firstName: x.firstName,
|
||||
lastName: x.lastName,
|
||||
isProbation: x.isProbation,
|
||||
isLeave: x.isLeave,
|
||||
isRetirement: x.isRetirement,
|
||||
leaveType: x.leaveType,
|
||||
posMasterNo: x.posMasterNo,
|
||||
orgRootId: x.orgRootId,
|
||||
orgChild1Id: x.orgChild1Id,
|
||||
orgChild2Id: x.orgChild2Id,
|
||||
orgChild3Id: x.orgChild3Id,
|
||||
orgChild4Id: x.orgChild4Id,
|
||||
orgRootName: x.orgRootName,
|
||||
orgChild1Name: x.orgChild1Name,
|
||||
orgChild2Name: x.orgChild2Name,
|
||||
orgChild3Name: x.orgChild3Name,
|
||||
orgChild4Name: x.orgChild4Name,
|
||||
org: x.org,
|
||||
searchShortName: x.searchShortName,
|
||||
position: x.position,
|
||||
posTypeName: x.posTypeName,
|
||||
posLevelName: x.posLevelName,
|
||||
gender: x.gender,
|
||||
relationship: x.relationship,
|
||||
dateAppoint: x.dateAppoint,
|
||||
dateRetire: x.dateRetire,
|
||||
dateRetireLaw: x.dateRetireLaw,
|
||||
birthdate: x.birthdate,
|
||||
degree: x.degree,
|
||||
age: x.age,
|
||||
currentPosition: null,
|
||||
lengthPosition: null,
|
||||
positionDate: mapPosition,
|
||||
posLevelDate: mapPosLevel
|
||||
}
|
||||
}));
|
||||
return new HttpSuccess({
|
||||
data: mapData,
|
||||
total: total,
|
||||
|
|
@ -3511,7 +3563,21 @@ export class ReportController extends Controller {
|
|||
}
|
||||
}
|
||||
}
|
||||
return new HttpSuccess({ template: "report2", reportName: "report2", data: { data } });
|
||||
// console.log(">>",data);
|
||||
|
||||
// wss.clients.forEach((client: any) => {
|
||||
// if (client.readyState === WebSocket.OPEN) {
|
||||
// const message = JSON.stringify({ template: "report2", reportName: "report2", data: { data } });
|
||||
// console.log("📤 Sending data to client:", message);
|
||||
// client.send(message, (err:any) => {
|
||||
// if (err) {
|
||||
// console.error("❌ Error sending message:", err);
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
// });
|
||||
|
||||
return new HttpSuccess({ template: "report2", reportName: "report2", data: { data } });
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue