space posno
This commit is contained in:
parent
b1b9700e40
commit
d9fb4110e3
18 changed files with 1283 additions and 875 deletions
|
|
@ -30,7 +30,10 @@ import { ProfileEmployee } from "../entities/ProfileEmployee";
|
|||
import permission from "../interfaces/permission";
|
||||
import { OrgRevision } from "../entities/OrgRevision";
|
||||
import Extension from "../interfaces/extension";
|
||||
import { CreatePositionSalaryEditHistory, PositionSalaryEditHistory } from "../entities/PositionSalaryEditHistory";
|
||||
import {
|
||||
CreatePositionSalaryEditHistory,
|
||||
PositionSalaryEditHistory,
|
||||
} from "../entities/PositionSalaryEditHistory";
|
||||
|
||||
@Route("api/v1/org/profile/salaryTemp")
|
||||
@Tags("ProfileSalaryTemp")
|
||||
|
|
@ -157,67 +160,67 @@ export class ProfileSalaryTempController extends Controller {
|
|||
? `profile.citizenId like '%${searchKeyword}%'`
|
||||
: "1=1",
|
||||
)
|
||||
.orWhere(
|
||||
searchKeyword != null && searchKeyword != ""
|
||||
? `profile.position like '%${searchKeyword}%'`
|
||||
: "1=1",
|
||||
)
|
||||
.orWhere(
|
||||
searchKeyword != null && searchKeyword != ""
|
||||
? `CONCAT(profile.prefix, profile.firstName," ",profile.lastName) like '%${searchKeyword}%'`
|
||||
: "1=1",
|
||||
)
|
||||
.orWhere(
|
||||
searchKeyword != null && searchKeyword != ""
|
||||
? `posType.posTypeName like '%${searchKeyword}%'`
|
||||
: "1=1",
|
||||
)
|
||||
.orWhere(
|
||||
searchKeyword != null && searchKeyword != ""
|
||||
? `posLevel.posLevelName like '%${searchKeyword}%'`
|
||||
: "1=1",
|
||||
)
|
||||
.orWhere(
|
||||
searchKeyword != null && searchKeyword != ""
|
||||
? `CONCAT(
|
||||
.orWhere(
|
||||
searchKeyword != null && searchKeyword != ""
|
||||
? `profile.position like '%${searchKeyword}%'`
|
||||
: "1=1",
|
||||
)
|
||||
.orWhere(
|
||||
searchKeyword != null && searchKeyword != ""
|
||||
? `CONCAT(profile.prefix, profile.firstName," ",profile.lastName) like '%${searchKeyword}%'`
|
||||
: "1=1",
|
||||
)
|
||||
.orWhere(
|
||||
searchKeyword != null && searchKeyword != ""
|
||||
? `posType.posTypeName like '%${searchKeyword}%'`
|
||||
: "1=1",
|
||||
)
|
||||
.orWhere(
|
||||
searchKeyword != null && searchKeyword != ""
|
||||
? `posLevel.posLevelName like '%${searchKeyword}%'`
|
||||
: "1=1",
|
||||
)
|
||||
.orWhere(
|
||||
searchKeyword != null && searchKeyword != ""
|
||||
? `CONCAT(
|
||||
orgRoot.orgRootShortName,
|
||||
current_holders.posMasterNo
|
||||
) like '%${searchKeyword}%'`
|
||||
: "1=1",
|
||||
)
|
||||
.orWhere(
|
||||
searchKeyword != null && searchKeyword != ""
|
||||
? `CONCAT(
|
||||
: "1=1",
|
||||
)
|
||||
.orWhere(
|
||||
searchKeyword != null && searchKeyword != ""
|
||||
? `CONCAT(
|
||||
orgRoot.orgRootShortName,
|
||||
orgChild1.orgChild1ShortName,
|
||||
current_holders.posMasterNo
|
||||
) like '%${searchKeyword}%'`
|
||||
: "1=1",
|
||||
)
|
||||
.orWhere(
|
||||
searchKeyword != null && searchKeyword != ""
|
||||
? `CONCAT(
|
||||
: "1=1",
|
||||
)
|
||||
.orWhere(
|
||||
searchKeyword != null && searchKeyword != ""
|
||||
? `CONCAT(
|
||||
orgRoot.orgRootShortName,
|
||||
orgChild1.orgChild1ShortName,
|
||||
orgChild2.orgChild2ShortName,
|
||||
current_holders.posMasterNo
|
||||
) like '%${searchKeyword}%'`
|
||||
: "1=1",
|
||||
)
|
||||
.orWhere(
|
||||
searchKeyword != null && searchKeyword != ""
|
||||
? `CONCAT(
|
||||
: "1=1",
|
||||
)
|
||||
.orWhere(
|
||||
searchKeyword != null && searchKeyword != ""
|
||||
? `CONCAT(
|
||||
orgRoot.orgRootShortName,
|
||||
orgChild1.orgChild1ShortName,
|
||||
orgChild2.orgChild2ShortName,
|
||||
orgChild3.orgChild3ShortName,
|
||||
current_holders.posMasterNo
|
||||
) like '%${searchKeyword}%'`
|
||||
: "1=1",
|
||||
)
|
||||
.orWhere(
|
||||
searchKeyword != null && searchKeyword != ""
|
||||
? `CONCAT(
|
||||
: "1=1",
|
||||
)
|
||||
.orWhere(
|
||||
searchKeyword != null && searchKeyword != ""
|
||||
? `CONCAT(
|
||||
orgRoot.orgRootShortName,
|
||||
orgChild1.orgChild1ShortName,
|
||||
orgChild2.orgChild2ShortName,
|
||||
|
|
@ -225,8 +228,8 @@ export class ProfileSalaryTempController extends Controller {
|
|||
orgChild4.orgChild4ShortName,
|
||||
current_holders.posMasterNo
|
||||
) like '%${searchKeyword}%'`
|
||||
: "1=1",
|
||||
);
|
||||
: "1=1",
|
||||
);
|
||||
}),
|
||||
)
|
||||
// .andWhere(
|
||||
|
|
@ -251,7 +254,7 @@ export class ProfileSalaryTempController extends Controller {
|
|||
.skip((page - 1) * pageSize)
|
||||
.take(pageSize)
|
||||
.getManyAndCount();
|
||||
|
||||
|
||||
const data = await Promise.all(
|
||||
record.map((_data) => {
|
||||
const posExecutive =
|
||||
|
|
@ -277,25 +280,25 @@ export class ProfileSalaryTempController extends Controller {
|
|||
: _data.current_holders.find((x) => x.orgRevisionId == findRevision.id) != null &&
|
||||
_data.current_holders.find((x) => x.orgRevisionId == findRevision.id)
|
||||
?.orgChild4 != null
|
||||
? `${_data.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild4.orgChild4ShortName}${_data.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}`
|
||||
? `${_data.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild4.orgChild4ShortName} ${_data.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}`
|
||||
: _data.current_holders.find((x) => x.orgRevisionId == findRevision.id) != null &&
|
||||
_data.current_holders.find((x) => x.orgRevisionId == findRevision.id)
|
||||
?.orgChild3 != null
|
||||
? `${_data.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild3.orgChild3ShortName}${_data.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}`
|
||||
? `${_data.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild3.orgChild3ShortName} ${_data.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}`
|
||||
: _data.current_holders.find((x) => x.orgRevisionId == findRevision.id) != null &&
|
||||
_data.current_holders.find((x) => x.orgRevisionId == findRevision.id)
|
||||
?.orgChild2 != null
|
||||
? `${_data.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild2.orgChild2ShortName}${_data.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}`
|
||||
? `${_data.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild2.orgChild2ShortName} ${_data.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}`
|
||||
: _data.current_holders.find((x) => x.orgRevisionId == findRevision.id) !=
|
||||
null &&
|
||||
_data.current_holders.find((x) => x.orgRevisionId == findRevision.id)
|
||||
?.orgChild1 != null
|
||||
? `${_data.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild1.orgChild1ShortName}${_data.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}`
|
||||
? `${_data.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild1.orgChild1ShortName} ${_data.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}`
|
||||
: _data.current_holders.find((x) => x.orgRevisionId == findRevision.id) !=
|
||||
null &&
|
||||
_data.current_holders.find((x) => x.orgRevisionId == findRevision.id)
|
||||
?.orgRoot != null
|
||||
? `${_data.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgRoot.orgRootShortName}${_data.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}`
|
||||
? `${_data.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgRoot.orgRootShortName} ${_data.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}`
|
||||
: null;
|
||||
const root =
|
||||
_data.current_holders.length == 0 ||
|
||||
|
|
@ -333,10 +336,10 @@ export class ProfileSalaryTempController extends Controller {
|
|||
? null
|
||||
: _data.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild4;
|
||||
|
||||
let _child1 =child1?.orgChild1Name;
|
||||
let _child2 =child2?.orgChild2Name;
|
||||
let _child3 =child3?.orgChild3Name;
|
||||
let _child4 =child4?.orgChild4Name;
|
||||
let _child1 = child1?.orgChild1Name;
|
||||
let _child2 = child2?.orgChild2Name;
|
||||
let _child3 = child3?.orgChild3Name;
|
||||
let _child4 = child4?.orgChild4Name;
|
||||
|
||||
return {
|
||||
id: _data.id,
|
||||
|
|
@ -358,11 +361,12 @@ export class ProfileSalaryTempController extends Controller {
|
|||
root: root == null ? null : root.orgRootName,
|
||||
orgRootShortName: root == null ? null : root.orgRootShortName,
|
||||
orgRevisionId: root == null ? null : root.orgRevisionId,
|
||||
org: (_child4 == null ? "" : _child4 + "\n") +
|
||||
(_child3 == null ? "" : _child3 + "\n") +
|
||||
(_child2 == null ? "" : _child2 + "\n") +
|
||||
(_child1 == null ? "" : _child1 + "\n") +
|
||||
(root?.orgRootName == null ? "" : root?.orgRootName),
|
||||
org:
|
||||
(_child4 == null ? "" : _child4 + "\n") +
|
||||
(_child3 == null ? "" : _child3 + "\n") +
|
||||
(_child2 == null ? "" : _child2 + "\n") +
|
||||
(_child1 == null ? "" : _child1 + "\n") +
|
||||
(root?.orgRootName == null ? "" : root?.orgRootName),
|
||||
statusCheckEdit: _data.statusCheckEdit,
|
||||
type: "OFFICER",
|
||||
};
|
||||
|
|
@ -486,25 +490,25 @@ export class ProfileSalaryTempController extends Controller {
|
|||
: _data.current_holders.find((x) => x.orgRevisionId == findRevision.id) != null &&
|
||||
_data.current_holders.find((x) => x.orgRevisionId == findRevision.id)
|
||||
?.orgChild4 != null
|
||||
? `${_data.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild4.orgChild4ShortName}${_data.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}`
|
||||
? `${_data.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild4.orgChild4ShortName} ${_data.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}`
|
||||
: _data.current_holders.find((x) => x.orgRevisionId == findRevision.id) != null &&
|
||||
_data.current_holders.find((x) => x.orgRevisionId == findRevision.id)
|
||||
?.orgChild3 != null
|
||||
? `${_data.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild3.orgChild3ShortName}${_data.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}`
|
||||
? `${_data.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild3.orgChild3ShortName} ${_data.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}`
|
||||
: _data.current_holders.find((x) => x.orgRevisionId == findRevision.id) != null &&
|
||||
_data.current_holders.find((x) => x.orgRevisionId == findRevision.id)
|
||||
?.orgChild2 != null
|
||||
? `${_data.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild2.orgChild2ShortName}${_data.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}`
|
||||
? `${_data.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild2.orgChild2ShortName} ${_data.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}`
|
||||
: _data.current_holders.find((x) => x.orgRevisionId == findRevision.id) !=
|
||||
null &&
|
||||
_data.current_holders.find((x) => x.orgRevisionId == findRevision.id)
|
||||
?.orgChild1 != null
|
||||
? `${_data.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild1.orgChild1ShortName}${_data.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}`
|
||||
? `${_data.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild1.orgChild1ShortName} ${_data.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}`
|
||||
: _data.current_holders.find((x) => x.orgRevisionId == findRevision.id) !=
|
||||
null &&
|
||||
_data.current_holders.find((x) => x.orgRevisionId == findRevision.id)
|
||||
?.orgRoot != null
|
||||
? `${_data.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgRoot.orgRootShortName}${_data.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}`
|
||||
? `${_data.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgRoot.orgRootShortName} ${_data.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}`
|
||||
: null;
|
||||
const dateEmployment =
|
||||
_data.profileEmployeeEmployment.length == 0
|
||||
|
|
@ -548,10 +552,10 @@ export class ProfileSalaryTempController extends Controller {
|
|||
? null
|
||||
: _data.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild4;
|
||||
|
||||
let _child1 =child1?.orgChild1Name;
|
||||
let _child2 =child2?.orgChild2Name;
|
||||
let _child3 =child3?.orgChild3Name;
|
||||
let _child4 =child4?.orgChild4Name;
|
||||
let _child1 = child1?.orgChild1Name;
|
||||
let _child2 = child2?.orgChild2Name;
|
||||
let _child3 = child3?.orgChild3Name;
|
||||
let _child4 = child4?.orgChild4Name;
|
||||
return {
|
||||
id: _data.id,
|
||||
prefix: _data.prefix,
|
||||
|
|
@ -631,11 +635,12 @@ export class ProfileSalaryTempController extends Controller {
|
|||
child4: _data.child4Temp ? _data.child4Temp : null,
|
||||
child4Id: _data.child4IdTemp ? _data.child4IdTemp : null,
|
||||
child4ShortName: _data.child4ShortNameTemp ? _data.child4ShortNameTemp : null,
|
||||
org: (_child4 == null ? "" : _child4 + "\n") +
|
||||
(_child3 == null ? "" : _child3 + "\n") +
|
||||
(_child2 == null ? "" : _child2 + "\n") +
|
||||
(_child1 == null ? "" : _child1 + "\n") +
|
||||
(root?.orgRootName == null ? "" : root?.orgRootName),
|
||||
org:
|
||||
(_child4 == null ? "" : _child4 + "\n") +
|
||||
(_child3 == null ? "" : _child3 + "\n") +
|
||||
(_child2 == null ? "" : _child2 + "\n") +
|
||||
(_child1 == null ? "" : _child1 + "\n") +
|
||||
(root?.orgRootName == null ? "" : root?.orgRootName),
|
||||
statusCheckEdit: _data.statusCheckEdit,
|
||||
type: "EMPLOYEE",
|
||||
};
|
||||
|
|
@ -1149,33 +1154,36 @@ export class ProfileSalaryTempController extends Controller {
|
|||
let profile = null;
|
||||
let profileEmployee = null;
|
||||
profile = await this.profileRepo.findOneBy({ id: profileId });
|
||||
|
||||
|
||||
if (!profile) {
|
||||
profileEmployee = await this.profileEmployeeRepo.findOneBy({ id: profileId });
|
||||
if (!profileEmployee) {
|
||||
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
||||
}
|
||||
profileEmployee = await this.profileEmployeeRepo.findOneBy({ id: profileId });
|
||||
if (!profileEmployee) {
|
||||
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
try {
|
||||
if (profile) {
|
||||
profile.statusCheckEdit = "PENDING";
|
||||
await this.profileRepo.save(profile);
|
||||
} else if (profileEmployee) {
|
||||
profileEmployee.statusCheckEdit = "PENDING";
|
||||
await this.profileEmployeeRepo.save(profileEmployee);
|
||||
}
|
||||
|
||||
const history : PositionSalaryEditHistory = Object.assign(new PositionSalaryEditHistory(), body);
|
||||
if (profile) {
|
||||
history.profileId = profileId;
|
||||
} else if (profileEmployee) {
|
||||
history.profileEmployeeId = profileId;
|
||||
}
|
||||
history.returnedDate = new Date();
|
||||
history.examinerName = req.user.name;
|
||||
history.createdFullName = req.user.name;
|
||||
history.lastUpdateFullName = req.user.name;
|
||||
if (profile) {
|
||||
profile.statusCheckEdit = "PENDING";
|
||||
await this.profileRepo.save(profile);
|
||||
} else if (profileEmployee) {
|
||||
profileEmployee.statusCheckEdit = "PENDING";
|
||||
await this.profileEmployeeRepo.save(profileEmployee);
|
||||
}
|
||||
|
||||
const history: PositionSalaryEditHistory = Object.assign(
|
||||
new PositionSalaryEditHistory(),
|
||||
body,
|
||||
);
|
||||
if (profile) {
|
||||
history.profileId = profileId;
|
||||
} else if (profileEmployee) {
|
||||
history.profileEmployeeId = profileId;
|
||||
}
|
||||
history.returnedDate = new Date();
|
||||
history.examinerName = req.user.name;
|
||||
history.createdFullName = req.user.name;
|
||||
history.lastUpdateFullName = req.user.name;
|
||||
await this.positionSalaryEditHistoryRepo.save(history);
|
||||
|
||||
return new HttpSuccess();
|
||||
|
|
@ -1191,24 +1199,21 @@ export class ProfileSalaryTempController extends Controller {
|
|||
*
|
||||
*/
|
||||
@Get("return-edit/history/{profileId}")
|
||||
public async returnEditHistory(
|
||||
@Path() profileId: string,
|
||||
) {
|
||||
try{
|
||||
|
||||
public async returnEditHistory(@Path() profileId: string) {
|
||||
try {
|
||||
let history = await this.positionSalaryEditHistoryRepo.find({
|
||||
where:{ profileId: profileId },
|
||||
order: { returnedDate: "DESC" }
|
||||
where: { profileId: profileId },
|
||||
order: { returnedDate: "DESC" },
|
||||
});
|
||||
|
||||
//EMP
|
||||
if(!history){
|
||||
if (!history) {
|
||||
history = await this.positionSalaryEditHistoryRepo.find({
|
||||
where:{ profileEmployeeId: profileId },
|
||||
order: { returnedDate: "DESC" }
|
||||
where: { profileEmployeeId: profileId },
|
||||
order: { returnedDate: "DESC" },
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
return new HttpSuccess(history);
|
||||
} catch {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่สามารถดําเนินการได้");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue