fix report filter

This commit is contained in:
AdisakKanthawilang 2024-12-18 17:23:20 +07:00
parent ce86d800a7
commit 97cd947b7c

View file

@ -45,8 +45,8 @@ export class ReportController extends Controller {
*/ */
@Get("registry-officer") @Get("registry-officer")
async registryOfficer( async registryOfficer(
@Query() rootId: string, @Query() rootId?: string,
@Query() year: number, @Query() year?: number,
@Query() ageMin?: number, @Query() ageMin?: number,
@Query() ageMax?: number, @Query() ageMax?: number,
) { ) {
@ -80,7 +80,7 @@ export class ReportController extends Controller {
.leftJoinAndSelect('current_holder.posLevel', 'posLevel') .leftJoinAndSelect('current_holder.posLevel', 'posLevel')
.leftJoinAndSelect('current_holder.profileEducations', 'profileEducations') .leftJoinAndSelect('current_holder.profileEducations', 'profileEducations')
.where('posMaster.orgRevisionId = :currentRevisionId', { currentRevisionId: currentRevision?.id }) .where('posMaster.orgRevisionId = :currentRevisionId', { currentRevisionId: currentRevision?.id })
.andWhere('posMaster.orgRootId = :rootId', { rootId }) .andWhere(rootId?'posMaster.orgRootId = :rootId': "1=1", { rootId: rootId })
.andWhere('posMaster.current_holderId Is Not Null') .andWhere('posMaster.current_holderId Is Not Null')
.andWhere('positions.positionIsSelected = :positionIsSelected', { positionIsSelected: true }) .andWhere('positions.positionIsSelected = :positionIsSelected', { positionIsSelected: true })
.andWhere( yearInAD && yearInAD != null? 'YEAR(current_holder.dateAppoint) = :year': "1=1", { year: yearInAD }) .andWhere( yearInAD && yearInAD != null? 'YEAR(current_holder.dateAppoint) = :year': "1=1", { year: yearInAD })
@ -142,7 +142,7 @@ export class ReportController extends Controller {
template: "registry-officer", template: "registry-officer",
reportName: "xlsx-report", reportName: "xlsx-report",
data: { data: {
year: Extension.ToThaiNumber(year.toString()), year: year?Extension.ToThaiNumber(year.toString()):Extension.ToThaiNumber(new Date().getFullYear().toString()),
date: Extension.ToThaiNumber(Extension.ToThaiShortDate(new Date())), date: Extension.ToThaiNumber(Extension.ToThaiShortDate(new Date())),
list: result list: result
}, },
@ -156,8 +156,8 @@ export class ReportController extends Controller {
*/ */
@Get("registry-emp") @Get("registry-emp")
async registryEmp( async registryEmp(
@Query() rootId: string, @Query() rootId?: string,
@Query() year: number, @Query() year?: number,
@Query() ageMin?: number, @Query() ageMin?: number,
@Query() ageMax?: number, @Query() ageMax?: number,
) { ) {
@ -190,7 +190,7 @@ export class ReportController extends Controller {
.leftJoinAndSelect('current_holder.posLevel', 'posLevel') .leftJoinAndSelect('current_holder.posLevel', 'posLevel')
.leftJoinAndSelect('current_holder.profileEducations', 'profileEducations') .leftJoinAndSelect('current_holder.profileEducations', 'profileEducations')
.where('posMaster.orgRevisionId = :currentRevisionId', { currentRevisionId: currentRevision?.id }) .where('posMaster.orgRevisionId = :currentRevisionId', { currentRevisionId: currentRevision?.id })
.andWhere('posMaster.orgRootId = :rootId', { rootId }) .andWhere(rootId?'posMaster.orgRootId = :rootId': "1=1", { rootId: rootId })
.andWhere('posMaster.current_holderId Is Not Null') .andWhere('posMaster.current_holderId Is Not Null')
.andWhere('positions.positionIsSelected = :positionIsSelected', { positionIsSelected: true }) .andWhere('positions.positionIsSelected = :positionIsSelected', { positionIsSelected: true })
.andWhere( yearInAD && yearInAD != null? 'YEAR(current_holder.dateAppoint) = :year': "1=1", { year: yearInAD }) .andWhere( yearInAD && yearInAD != null? 'YEAR(current_holder.dateAppoint) = :year': "1=1", { year: yearInAD })
@ -248,7 +248,7 @@ export class ReportController extends Controller {
template: "registry-emp", template: "registry-emp",
reportName: "xlsx-report", reportName: "xlsx-report",
data: { data: {
year: Extension.ToThaiNumber(year.toString()), year: year?Extension.ToThaiNumber(year.toString()):Extension.ToThaiNumber(new Date().getFullYear().toString()),
date: Extension.ToThaiNumber(Extension.ToThaiShortDate(new Date())), date: Extension.ToThaiNumber(Extension.ToThaiShortDate(new Date())),
list: result list: result
}, },