This commit is contained in:
moss 2025-03-29 16:59:26 +07:00
parent ab03d3aa3d
commit 0c6d9ac9c1
2 changed files with 34 additions and 15 deletions

View file

@ -18,7 +18,7 @@ import { AppDataSource } from "../database/data-source";
import HttpSuccess from "../interfaces/http-success";
import HttpStatusCode from "../interfaces/http-status";
import HttpError from "../interfaces/http-error";
import { In, Like, Not } from "typeorm";
import { Brackets, In, Like, Not } from "typeorm";
import {
CreateSalaryFormulaEmployee,
SalaryFormulaEmployee,
@ -245,14 +245,27 @@ export class SalaryFormulaEmployeeController extends Controller {
.leftJoinAndSelect("salaryFormulaEmployee.posLevel", "posLevel")
.leftJoinAndSelect("salaryFormulaEmployee.salaryEmployeeMins", "salaryEmployeeMins")
.andWhere(
keyword == undefined
? "1=1"
: [
{ details: Like(`%${keyword}%`) },
{ position: Like(`%${keyword}%`) },
{ posLevel: { posLevelName: Like(`%${keyword}%`) } },
{ posType: { posTypeName: Like(`%${keyword}%`) } },
],
new Brackets((qb) => {
qb.orWhere(
keyword == undefined ? "1=1" : `salaryFormulaEmployee.details like '%${keyword}%'`,
{
keyword: `%${keyword}%`,
},
);
qb.orWhere(
keyword == undefined ? "1=1" : `salaryFormulaEmployee.position like '%${keyword}%'`,
{
keyword: `%${keyword}%`,
},
).orWhere(
keyword == undefined
? "1=1"
: `CONCAT(posType.posTypeShortName,' ',posLevel.posLevelName) like '%${keyword}%'`,
{
keyword: `%${keyword}%`,
},
);
}),
)
.andWhere(posTypeId == undefined ? "1=1" : { posTypeId: Like(`%${posTypeId}%`) })
.orderBy("salaryFormulaEmployee.lastUpdatedAt", "DESC")

View file

@ -1224,8 +1224,8 @@ export class SalaryPeriodController extends Controller {
})
// .orWhere("profile.citizenId LIKE :keyword", { keyword: `%${body.keyword}%` })
.orWhere("profile.position LIKE :keyword", { keyword: `%${body.keyword}%` })
// .orWhere("profile.posType LIKE :keyword", { keyword: `%${body.keyword}%` })
// .orWhere("profile.posLevel LIKE :keyword", { keyword: `%${body.keyword}%` })
.orWhere("profile.posType LIKE :keyword", { keyword: `%${body.keyword}%` })
.orWhere("profile.posLevel LIKE :keyword", { keyword: `%${body.keyword}%` })
// .orWhere("profile.posExecutive LIKE :keyword", { keyword: `%${body.keyword}%` })
.orWhere("profile.amount LIKE :keyword", { keyword: `%${body.keyword}%` })
.orWhere("profile.amountSpecial LIKE :keyword", { keyword: `%${body.keyword}%` })
@ -1712,13 +1712,14 @@ export class SalaryPeriodController extends Controller {
salaryPeriod.lastUpdatedAt = new Date();
await this.salaryPeriodRepository.save(salaryPeriod, { data: request });
setLogDataDiff(request, { before, after: salaryPeriod });
let _null: any = null;
await Promise.all(
orgs.map(async (root: any) => {
let salaryOrgNew = Object.assign(new SalaryOrg());
salaryOrgNew.salaryPeriodId = salaryPeriod.id;
salaryOrgNew.status = "PENDING";
salaryOrgNew.rootId = root.rootId;
salaryOrgNew.rootDnaId = root.rootDnaId ?? _null;
salaryOrgNew.root = root.root;
salaryOrgNew.revisionId = salaryPeriod.revisionId;
salaryOrgNew.snapshot = snapshot;
@ -1739,6 +1740,7 @@ export class SalaryPeriodController extends Controller {
salaryOrgNew.salaryPeriodId = salaryPeriod.id;
salaryOrgNew.status = "PENDING";
salaryOrgNew.rootId = root.rootId;
salaryOrgNew.rootDnaId = root.rootDnaId ?? _null;
salaryOrgNew.root = root.root;
salaryOrgNew.revisionId = salaryPeriod.revisionId;
salaryOrgNew.snapshot = snapshot;
@ -1835,7 +1837,7 @@ export class SalaryPeriodController extends Controller {
await this.salaryPeriodRepository.save(chk_SalaryPeriod, { data: request });
setLogDataDiff(request, { before: beforeChk_SalaryPeriod, after: chk_SalaryPeriod });
let _null: any = null;
await Promise.all(
orgs.map(async (root: any) => {
let salaryOrgNew = Object.assign(new SalaryOrg());
@ -1844,6 +1846,7 @@ export class SalaryPeriodController extends Controller {
salaryOrgNew.salaryPeriodId = chk_SalaryPeriod.id;
salaryOrgNew.status = "PENDING";
salaryOrgNew.rootId = root.rootId;
salaryOrgNew.rootDnaId = root.rootDnaId ?? _null;
salaryOrgNew.root = root.root;
salaryOrgNew.revisionId = chk_SalaryPeriod.revisionId;
salaryOrgNew.snapshot = snapshot;
@ -1867,6 +1870,7 @@ export class SalaryPeriodController extends Controller {
salaryOrgNew.salaryPeriodId = chk_SalaryPeriod.id;
salaryOrgNew.status = "PENDING";
salaryOrgNew.rootId = root.rootId;
salaryOrgNew.rootDnaId = root.rootDnaId ?? _null;
salaryOrgNew.root = root.root;
salaryOrgNew.revisionId = chk_SalaryPeriod.revisionId;
salaryOrgNew.snapshot = snapshot;
@ -2203,7 +2207,7 @@ export class SalaryPeriodController extends Controller {
salaryOrgNew.salaryPeriodId = salaryPeriod.id;
salaryOrgNew.status = "PENDING";
salaryOrgNew.rootId = root.rootId;
salaryOrgNew.rootDnaId = root.rootDnaId;
salaryOrgNew.rootDnaId = root.rootDnaId ?? _null;
salaryOrgNew.root = root.root;
salaryOrgNew.revisionId = salaryPeriod.revisionId;
salaryOrgNew.snapshot = snapshot;
@ -2721,13 +2725,14 @@ export class SalaryPeriodController extends Controller {
salaryPeriod.lastUpdatedAt = new Date();
await this.salaryPeriodRepository.save(salaryPeriod, { data: request });
setLogDataDiff(request, { before, after: salaryPeriod });
let _null: any = null;
await Promise.all(
orgs.map(async (root: any) => {
let salaryOrgNew = Object.assign(new SalaryOrg());
salaryOrgNew.salaryPeriodId = salaryPeriod.id;
salaryOrgNew.status = "PENDING";
salaryOrgNew.rootId = root.rootId;
salaryOrgNew.rootDnaId = root.rootDnaId ?? _null;
salaryOrgNew.root = root.root;
salaryOrgNew.revisionId = salaryPeriod.revisionId;
salaryOrgNew.snapshot = snapshot;
@ -2756,6 +2761,7 @@ export class SalaryPeriodController extends Controller {
salaryOrgNew.salaryPeriodId = salaryPeriod.id;
salaryOrgNew.status = "PENDING";
salaryOrgNew.rootId = root.rootId;
salaryOrgNew.rootDnaId = root.rootDnaId ?? _null;
salaryOrgNew.root = root.root;
salaryOrgNew.revisionId = salaryPeriod.revisionId;
salaryOrgNew.snapshot = snapshot;