fix transfer command & registry report
This commit is contained in:
parent
fbdce54a12
commit
70003ef609
2 changed files with 94 additions and 38 deletions
|
|
@ -312,16 +312,44 @@ 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,
|
||||
birthdate: x.birthdate,
|
||||
degree: x.degree,
|
||||
age: x.age,
|
||||
currentPosition: null,
|
||||
lengthPosition: null,
|
||||
}));
|
||||
return new HttpSuccess({
|
||||
// template: "registry-officer",
|
||||
// reportName: "xlsx-report",
|
||||
// data: {
|
||||
// date: Extension.ToThaiNumber(Extension.ToThaiShortDate(new Date())),
|
||||
// data: lists,
|
||||
// total: total
|
||||
// },
|
||||
data: lists,
|
||||
data: mapData,
|
||||
total: total
|
||||
});
|
||||
}
|
||||
|
|
@ -477,49 +505,49 @@ export class ReportController extends Controller {
|
|||
|
||||
let nodeCondition = "1=1";
|
||||
if (node === 0 && nodeId) {
|
||||
nodeCondition = "registryOfficer.orgRootId = :nodeId";
|
||||
nodeCondition = "registryEmployee.orgRootId = :nodeId";
|
||||
}
|
||||
else if (node === 1 && nodeId) {
|
||||
nodeCondition = "registryOfficer.orgChild1Id = :nodeId";
|
||||
nodeCondition = "registryEmployee.orgChild1Id = :nodeId";
|
||||
}
|
||||
else if (node === 2 && nodeId) {
|
||||
nodeCondition = "registryOfficer.orgChild2Id = :nodeId";
|
||||
nodeCondition = "registryEmployee.orgChild2Id = :nodeId";
|
||||
}
|
||||
else if (node === 3 && nodeId) {
|
||||
nodeCondition = "registryOfficer.orgChild3Id = :nodeId";
|
||||
nodeCondition = "registryEmployee.orgChild3Id = :nodeId";
|
||||
}
|
||||
else if (node === 4 && nodeId) {
|
||||
nodeCondition = "registryOfficer.orgChild4Id = :nodeId";
|
||||
nodeCondition = "registryEmployee.orgChild4Id = :nodeId";
|
||||
}
|
||||
let dateAppointCondition = "1=1";
|
||||
if (startDateAppoint && endDateAppoint) {
|
||||
dateAppointCondition = "DATE(registryOfficer.dateAppoint) >= :startDateAppoint AND DATE(registryOfficer.dateAppoint) <= :endDateAppoint";
|
||||
dateAppointCondition = "DATE(registryEmployee.dateAppoint) >= :startDateAppoint AND DATE(registryEmployee.dateAppoint) <= :endDateAppoint";
|
||||
} else if (startDateAppoint) {
|
||||
dateAppointCondition = "DATE(registryOfficer.dateAppoint) >= :startDateAppoint";
|
||||
dateAppointCondition = "DATE(registryEmployee.dateAppoint) >= :startDateAppoint";
|
||||
} else if (endDateAppoint) {
|
||||
dateAppointCondition = "DATE(registryOfficer.dateAppoint) <= :endDateAppoint";
|
||||
dateAppointCondition = "DATE(registryEmployee.dateAppoint) <= :endDateAppoint";
|
||||
}
|
||||
|
||||
const IsLeavecondition = ["registryOfficer.isLeave = :isLeave"];
|
||||
const IsLeavecondition = ["registryEmployee.isLeave = :isLeave"];
|
||||
const parameters: any = { isLeave: isRetire };
|
||||
|
||||
if (retireType && retireType.trim() !== "") {
|
||||
IsLeavecondition.push("registryOfficer.leaveType = :retireType");
|
||||
IsLeavecondition.push("registryEmployee.leaveType = :retireType");
|
||||
parameters.retireType = retireType;
|
||||
}
|
||||
const [lists, total] = await AppDataSource.getRepository(viewRegistryEmployee)
|
||||
.createQueryBuilder("registryOfficer")
|
||||
.createQueryBuilder("registryEmployee")
|
||||
.where(nodeCondition, {
|
||||
nodeId: nodeId
|
||||
})
|
||||
.andWhere("registryOfficer.age BETWEEN :ageMin AND :ageMax", {
|
||||
.andWhere("registryEmployee.age BETWEEN :ageMin AND :ageMax", {
|
||||
ageMin, ageMax
|
||||
})
|
||||
.andWhere(dateAppointCondition, {
|
||||
startDateAppoint: startDateAppoint?.toISOString().split("T")[0],
|
||||
endDateAppoint: endDateAppoint?.toISOString().split("T")[0]
|
||||
})
|
||||
.andWhere("registryOfficer.isProbation = :isProbation", {
|
||||
.andWhere("registryEmployee.isProbation = :isProbation", {
|
||||
isProbation: isProbation,
|
||||
})
|
||||
.andWhere(IsLeavecondition.join(" AND "), parameters)
|
||||
|
|
@ -527,7 +555,7 @@ export class ReportController extends Controller {
|
|||
new Brackets((qb) => {
|
||||
qb.orWhere(
|
||||
posTypeName != null && posTypeName != ""
|
||||
? "registryOfficer.posTypeName LIKE :posTypeName"
|
||||
? "registryEmployee.posTypeName LIKE :posTypeName"
|
||||
: "1=1",
|
||||
{
|
||||
posTypeName: `%${posTypeName}%`,
|
||||
|
|
@ -535,7 +563,7 @@ export class ReportController extends Controller {
|
|||
)
|
||||
qb.orWhere(
|
||||
posLevelName != null && posLevelName != ""
|
||||
? "registryOfficer.posLevelName LIKE :posLevelName"
|
||||
? "registryEmployee.posLevelName LIKE :posLevelName"
|
||||
: "1=1",
|
||||
{
|
||||
posLevelName: `%${posLevelName}%`,
|
||||
|
|
@ -543,7 +571,7 @@ export class ReportController extends Controller {
|
|||
)
|
||||
qb.orWhere(
|
||||
position != null && position != ""
|
||||
? "registryOfficer.position LIKE :position"
|
||||
? "registryEmployee.position LIKE :position"
|
||||
: "1=1",
|
||||
{
|
||||
position: `%${position}%`,
|
||||
|
|
@ -551,7 +579,7 @@ export class ReportController extends Controller {
|
|||
)
|
||||
qb.orWhere(
|
||||
gender != null && gender != ""
|
||||
? "registryOfficer.gender LIKE :gender"
|
||||
? "registryEmployee.gender LIKE :gender"
|
||||
: "1=1",
|
||||
{
|
||||
gender: `%${gender}%`,
|
||||
|
|
@ -559,7 +587,7 @@ export class ReportController extends Controller {
|
|||
)
|
||||
qb.orWhere(
|
||||
relationship != null && relationship != ""
|
||||
? "registryOfficer.relationship LIKE :relationship"
|
||||
? "registryEmployee.relationship LIKE :relationship"
|
||||
: "1=1",
|
||||
{
|
||||
relationship: `%${relationship}%`,
|
||||
|
|
@ -567,7 +595,7 @@ export class ReportController extends Controller {
|
|||
)
|
||||
qb.orWhere(
|
||||
degree != null && degree != ""
|
||||
? "registryOfficer.degree LIKE :degree"
|
||||
? "registryEmployee.degree LIKE :degree"
|
||||
: "1=1",
|
||||
{
|
||||
degree: `%${degree}%`,
|
||||
|
|
@ -575,18 +603,45 @@ export class ReportController extends Controller {
|
|||
)
|
||||
}),
|
||||
)
|
||||
.orderBy(`registryOfficer.${sortBy}`, sort)
|
||||
.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,
|
||||
birthdate: x.birthdate,
|
||||
degree: x.degree,
|
||||
age: x.age,
|
||||
currentPosition: null,
|
||||
lengthPosition: null,
|
||||
}));
|
||||
return new HttpSuccess({
|
||||
// template: "registry-officer",
|
||||
// reportName: "xlsx-report",
|
||||
// data: {
|
||||
// date: Extension.ToThaiNumber(Extension.ToThaiShortDate(new Date())),
|
||||
// data: lists,
|
||||
// total: total
|
||||
// },
|
||||
data: lists,
|
||||
data: mapData,
|
||||
total: total
|
||||
});
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue