Merge branch 'develop' into dev

* develop:
  add role parent
  migrate #2043
  เฉพาะคำสั่ง C-PM-10 ให้ตัด profilesNotiRequest ที่ส่ง noti ครั้งแรกออก เพราะ UI ปิด Tab นี้
  เฉพาะคำสั่ง C-PM-10 ให้ตัด receiverUserId ที่ส่ง noti ครั้งแรกออก #1995
  fix รายชื่อราชการที่เลื่อนเงินเดือน (isPunish) salary/gen เส้นเก่า
  #2036
  อัพเดตฟิลด์ prefixMain #2033
  อัพเดท view_pos_master
  fix duplicate salary list
  fix
This commit is contained in:
Warunee Tamkoo 2025-12-01 11:42:23 +07:00
commit e0c6d62265
16 changed files with 312 additions and 291 deletions

View file

@ -215,7 +215,7 @@ export class CommandController extends Controller {
_data.child1 != undefined && _data.child1 != null _data.child1 != undefined && _data.child1 != null
? _data.child1[0] != null ? _data.child1[0] != null
? `current_holders.orgChild1Id IN (:...child1)` ? `current_holders.orgChild1Id IN (:...child1)`
: `current_holders.orgChild1Id is null` : `current_holders.orgChild1Id is ${_data.privilege == "PARENT" ? "not null" : "null"}`
: "1=1", : "1=1",
{ {
child1: _data.child1, child1: _data.child1,
@ -1477,7 +1477,7 @@ export class CommandController extends Controller {
} }
// @Get("XXX") // @Get("XXX")
async cronjobUpdateRetirementStatus(/*@Request() request: RequestWithUser*/) { async cronjobUpdateRetirementStatus(/*@Request() request: RequestWithUser*/) {
const adminToken = await getToken() ?? ""; const adminToken = (await getToken()) ?? "";
const today = new Date(); const today = new Date();
today.setUTCHours(0, 0, 0, 0); today.setUTCHours(0, 0, 0, 0);
let type: string = "OFFICER"; let type: string = "OFFICER";
@ -1672,7 +1672,7 @@ export class CommandController extends Controller {
positionIsSelected: false, positionIsSelected: false,
lastUpdateFullName: "System Administrator", lastUpdateFullName: "System Administrator",
lastUpdatedAt: _Date, lastUpdatedAt: _Date,
} },
); );
_posMaster.isSit = false; _posMaster.isSit = false;
_posMaster.current_holderId = null; _posMaster.current_holderId = null;
@ -1702,7 +1702,7 @@ export class CommandController extends Controller {
positionIsSelected: false, positionIsSelected: false,
lastUpdateFullName: "System Administrator", lastUpdateFullName: "System Administrator",
lastUpdatedAt: _Date, lastUpdatedAt: _Date,
} },
); );
_posMaster.isSit = false; _posMaster.isSit = false;
_posMaster.next_holderId = null; _posMaster.next_holderId = null;
@ -1730,7 +1730,7 @@ export class CommandController extends Controller {
positionIsSelected: false, positionIsSelected: false,
lastUpdateFullName: "System Administrator", lastUpdateFullName: "System Administrator",
lastUpdatedAt: _Date, lastUpdatedAt: _Date,
} },
); );
_posMaster.isSit = false; _posMaster.isSit = false;
_posMaster.current_holderId = null; _posMaster.current_holderId = null;
@ -1977,35 +1977,38 @@ export class CommandController extends Controller {
if (commandCode == "C-PM-21") { if (commandCode == "C-PM-21") {
profileTemp.position = profile?.positionTemp ?? "-"; profileTemp.position = profile?.positionTemp ?? "-";
profileTemp.posLevel = profile?.posLevelNameTemp ?? "-"; profileTemp.posLevel = profile?.posLevelNameTemp ?? "-";
profileTemp.org = (profile?.child4Temp == null ? "" : profile?.child4Temp + "\n") + profileTemp.org =
(profile?.child4Temp == null ? "" : profile?.child4Temp + "\n") +
(profile?.child3Temp == null ? "" : profile?.child3Temp + "\n") + (profile?.child3Temp == null ? "" : profile?.child3Temp + "\n") +
(profile?.child2Temp == null ? "" : profile?.child2Temp + "\n") + (profile?.child2Temp == null ? "" : profile?.child2Temp + "\n") +
(profile?.child1Temp == null ? "" : profile?.child1Temp + "\n") + (profile?.child1Temp == null ? "" : profile?.child1Temp + "\n") +
(profile?.rootTemp == null ? "" : profile?.rootTemp) (profile?.rootTemp == null ? "" : profile?.rootTemp);
if (profile?.nodeTemp) { if (profile?.nodeTemp) {
switch (profile?.nodeTemp) { switch (profile?.nodeTemp) {
case "4": case "4":
profileTemp.posNo = `${profile.child4ShortNameTemp} ${profile?.posMasterNoTemp}`; profileTemp.posNo = `${profile.child4ShortNameTemp} ${profile?.posMasterNoTemp}`;
break break;
case "3": case "3":
profileTemp.posNo = `${profile.child3ShortNameTemp} ${profile?.posMasterNoTemp}`; profileTemp.posNo = `${profile.child3ShortNameTemp} ${profile?.posMasterNoTemp}`;
break break;
case "2": case "2":
profileTemp.posNo = `${profile.child2ShortNameTemp} ${profile?.posMasterNoTemp}`; profileTemp.posNo = `${profile.child2ShortNameTemp} ${profile?.posMasterNoTemp}`;
break break;
case "1": case "1":
profileTemp.posNo = `${profile.child1ShortNameTemp} ${profile?.posMasterNoTemp}`; profileTemp.posNo = `${profile.child1ShortNameTemp} ${profile?.posMasterNoTemp}`;
break break;
case "0": case "0":
profileTemp.posNo = `${profile.rootShortNameTemp} ${profile?.posMasterNoTemp}`; profileTemp.posNo = `${profile.rootShortNameTemp} ${profile?.posMasterNoTemp}`;
break break;
default: break; default:
break;
} }
} }
} }
return { return {
no: Extension.ToThaiNumber((idx + 1).toString()), no: Extension.ToThaiNumber((idx + 1).toString()),
org: commandCode != "C-PM-21" org:
commandCode != "C-PM-21"
? profile?.isLeave == false ? profile?.isLeave == false
? (_child4 == null ? "" : _child4 + "\n") + ? (_child4 == null ? "" : _child4 + "\n") +
(_child3 == null ? "" : _child3 + "\n") + (_child3 == null ? "" : _child3 + "\n") +
@ -2016,19 +2019,22 @@ export class CommandController extends Controller {
: profileTemp.org, : profileTemp.org,
fullName: `${x.prefix}${x.firstName} ${x.lastName}`, fullName: `${x.prefix}${x.firstName} ${x.lastName}`,
citizenId: Extension.ToThaiNumber(x.citizenId), citizenId: Extension.ToThaiNumber(x.citizenId),
position: commandCode != "C-PM-21" position:
commandCode != "C-PM-21"
? profile?.position ? profile?.position
? profile?.position ? profile?.position
: "-" : "-"
: profileTemp.position, : profileTemp.position,
posLevel: commandCode != "C-PM-21" posLevel:
commandCode != "C-PM-21"
? profile?.posType && profile?.posLevel ? profile?.posType && profile?.posLevel
? Extension.ToThaiNumber( ? Extension.ToThaiNumber(
`${profile?.posType.posTypeShortName} ${profile?.posLevel.posLevelName}`, `${profile?.posType.posTypeShortName} ${profile?.posLevel.posLevelName}`,
) )
: "-" : "-"
: Extension.ToThaiNumber(profileTemp.posLevel), : Extension.ToThaiNumber(profileTemp.posLevel),
posNo: commandCode != "C-PM-21" posNo:
commandCode != "C-PM-21"
? shortName ? shortName
? Extension.ToThaiNumber(shortName) ? Extension.ToThaiNumber(shortName)
: "-" : "-"
@ -4277,12 +4283,11 @@ export class CommandController extends Controller {
orgRevision: { orgRevision: {
orgRevisionIsCurrent: true, orgRevisionIsCurrent: true,
orgRevisionIsDraft: false, orgRevisionIsDraft: false,
}
}, },
relations:['orgRevision'] },
relations: ["orgRevision"],
}); });
const orgRevisionRef = posMaster ? posMaster.id : null; const orgRevisionRef = posMaster ? posMaster.id : null;
//ลบตำแหน่งที่รักษาการแทน //ลบตำแหน่งที่รักษาการแทน
@ -6041,6 +6046,7 @@ export class CommandController extends Controller {
profile.isProbation = item.bodyProfile.isProbation; profile.isProbation = item.bodyProfile.isProbation;
//เพิ่มใหม่จากรับโอน //เพิ่มใหม่จากรับโอน
profile.prefix = item.bodyProfile.prefix ?? null; profile.prefix = item.bodyProfile.prefix ?? null;
profile.prefixMain = item.bodyProfile.prefix ?? null;
profile.firstName = item.bodyProfile.firstName ?? null; profile.firstName = item.bodyProfile.firstName ?? null;
profile.lastName = item.bodyProfile.lastName ?? null; profile.lastName = item.bodyProfile.lastName ?? null;
profile.birthDate = item.bodyProfile.birthDate ?? null; profile.birthDate = item.bodyProfile.birthDate ?? null;
@ -6093,6 +6099,7 @@ export class CommandController extends Controller {
profile.amountSpecial = item.bodyProfile.amountSpecial ?? null; profile.amountSpecial = item.bodyProfile.amountSpecial ?? null;
profile.isProbation = item.bodyProfile.isProbation; profile.isProbation = item.bodyProfile.isProbation;
profile.prefix = item.bodyProfile.prefix ?? null; profile.prefix = item.bodyProfile.prefix ?? null;
profile.prefixMain = item.bodyProfile.prefix ?? null;
profile.firstName = item.bodyProfile.firstName ?? null; profile.firstName = item.bodyProfile.firstName ?? null;
profile.lastName = item.bodyProfile.lastName ?? null; profile.lastName = item.bodyProfile.lastName ?? null;
profile.birthDate = item.bodyProfile.birthDate ?? null; profile.birthDate = item.bodyProfile.birthDate ?? null;
@ -6152,6 +6159,7 @@ export class CommandController extends Controller {
item.bodyProfile.prefix && item.bodyProfile.prefix != "" item.bodyProfile.prefix && item.bodyProfile.prefix != ""
? item.bodyProfile.prefix ? item.bodyProfile.prefix
: profile.prefix; : profile.prefix;
profile.prefixMain = item.bodyProfile.prefix ?? null;
profile.firstName = profile.firstName =
item.bodyProfile.firstName && item.bodyProfile.firstName != "" item.bodyProfile.firstName && item.bodyProfile.firstName != ""
? item.bodyProfile.firstName ? item.bodyProfile.firstName

View file

@ -104,13 +104,10 @@ export class DevelopmentRequestController extends Controller {
); );
}), }),
) )
.orderBy("developmentRequest.createdAt", "DESC") .orderBy("developmentRequest.createdAt", "DESC");
if (sortBy) { if (sortBy) {
query = query.orderBy( query = query.orderBy(`developmentRequest.${sortBy}`, descending ? "DESC" : "ASC");
`developmentRequest.${sortBy}`,
descending ? "DESC" : "ASC"
);
} }
const [lists, total] = await query const [lists, total] = await query
@ -166,7 +163,7 @@ export class DevelopmentRequestController extends Controller {
data.child1 != undefined && data.child1 != null data.child1 != undefined && data.child1 != null
? data.child1[0] != null ? data.child1[0] != null
? `current_holders.orgChild1Id IN (:...child1)` ? `current_holders.orgChild1Id IN (:...child1)`
: `current_holders.orgChild1Id is null` : `current_holders.orgChild1Id is ${data.privilege == "PARENT" ? "not null" : "null"}`
: "1=1", : "1=1",
{ {
child1: data.child1, child1: data.child1,
@ -250,14 +247,10 @@ export class DevelopmentRequestController extends Controller {
); );
}), }),
) )
.orderBy("developmentRequest.createdAt", "DESC") .orderBy("developmentRequest.createdAt", "DESC");
if (sortBy) { if (sortBy) {
query = query.orderBy( query = query.orderBy(`developmentRequest.${sortBy}`, descending ? "DESC" : "ASC");
`developmentRequest.${sortBy}`,
descending ? "DESC" : "ASC"
);
} }
const [lists, total] = await query const [lists, total] = await query

View file

@ -132,6 +132,8 @@ export class EducationLevelController extends Controller {
"id", "id",
"name", "name",
"rank", "rank",
"educationLevel",
"isHigh",
"createdAt", "createdAt",
"lastUpdatedAt", "lastUpdatedAt",
"createdFullName", "createdFullName",
@ -157,6 +159,8 @@ export class EducationLevelController extends Controller {
"id", "id",
"name", "name",
"rank", "rank",
"educationLevel",
"isHigh",
"createdAt", "createdAt",
"lastUpdatedAt", "lastUpdatedAt",
"createdFullName", "createdFullName",

View file

@ -1211,6 +1211,7 @@ export class OrganizationDotnetController extends Controller {
let pos = await this.posMasterRepository.findOne({ let pos = await this.posMasterRepository.findOne({
relations: ["current_holder"], relations: ["current_holder"],
where: { where: {
current_holder: Not(IsNull()),
orgRevision: { orgRevision: {
orgRevisionIsCurrent: true, orgRevisionIsCurrent: true,
orgRevisionIsDraft: false, orgRevisionIsDraft: false,
@ -1234,6 +1235,7 @@ export class OrganizationDotnetController extends Controller {
let pos = await this.posMasterRepository.findOne({ let pos = await this.posMasterRepository.findOne({
relations: ["current_holder"], relations: ["current_holder"],
where: { where: {
current_holder: Not(IsNull()),
orgRevision: { orgRevision: {
orgRevisionIsCurrent: true, orgRevisionIsCurrent: true,
orgRevisionIsDraft: false, orgRevisionIsDraft: false,
@ -1256,6 +1258,7 @@ export class OrganizationDotnetController extends Controller {
let pos = await this.posMasterRepository.findOne({ let pos = await this.posMasterRepository.findOne({
relations: ["current_holder"], relations: ["current_holder"],
where: { where: {
current_holder: Not(IsNull()),
orgRevision: { orgRevision: {
orgRevisionIsCurrent: true, orgRevisionIsCurrent: true,
orgRevisionIsDraft: false, orgRevisionIsDraft: false,
@ -1278,6 +1281,7 @@ export class OrganizationDotnetController extends Controller {
let pos = await this.posMasterRepository.findOne({ let pos = await this.posMasterRepository.findOne({
relations: ["current_holder"], relations: ["current_holder"],
where: { where: {
current_holder: Not(IsNull()),
orgRevision: { orgRevision: {
orgRevisionIsCurrent: true, orgRevisionIsCurrent: true,
orgRevisionIsDraft: false, orgRevisionIsDraft: false,
@ -1300,6 +1304,7 @@ export class OrganizationDotnetController extends Controller {
let pos = await this.posMasterRepository.findOne({ let pos = await this.posMasterRepository.findOne({
relations: ["current_holder"], relations: ["current_holder"],
where: { where: {
current_holder: Not(IsNull()),
orgRevision: { orgRevision: {
orgRevisionIsCurrent: true, orgRevisionIsCurrent: true,
orgRevisionIsDraft: false, orgRevisionIsDraft: false,
@ -1511,6 +1516,7 @@ export class OrganizationDotnetController extends Controller {
let pos = await this.posMasterRepository.findOne({ let pos = await this.posMasterRepository.findOne({
relations: ["current_holder"], relations: ["current_holder"],
where: { where: {
current_holder: Not(IsNull()),
orgRevision: { orgRevision: {
orgRevisionIsCurrent: true, orgRevisionIsCurrent: true,
orgRevisionIsDraft: false, orgRevisionIsDraft: false,
@ -1534,6 +1540,7 @@ export class OrganizationDotnetController extends Controller {
let pos = await this.posMasterRepository.findOne({ let pos = await this.posMasterRepository.findOne({
relations: ["current_holder"], relations: ["current_holder"],
where: { where: {
current_holder: Not(IsNull()),
orgRevision: { orgRevision: {
orgRevisionIsCurrent: true, orgRevisionIsCurrent: true,
orgRevisionIsDraft: false, orgRevisionIsDraft: false,
@ -1556,6 +1563,7 @@ export class OrganizationDotnetController extends Controller {
let pos = await this.posMasterRepository.findOne({ let pos = await this.posMasterRepository.findOne({
relations: ["current_holder"], relations: ["current_holder"],
where: { where: {
current_holder: Not(IsNull()),
orgRevision: { orgRevision: {
orgRevisionIsCurrent: true, orgRevisionIsCurrent: true,
orgRevisionIsDraft: false, orgRevisionIsDraft: false,
@ -1578,6 +1586,7 @@ export class OrganizationDotnetController extends Controller {
let pos = await this.posMasterRepository.findOne({ let pos = await this.posMasterRepository.findOne({
relations: ["current_holder"], relations: ["current_holder"],
where: { where: {
current_holder: Not(IsNull()),
orgRevision: { orgRevision: {
orgRevisionIsCurrent: true, orgRevisionIsCurrent: true,
orgRevisionIsDraft: false, orgRevisionIsDraft: false,
@ -1600,6 +1609,7 @@ export class OrganizationDotnetController extends Controller {
let pos = await this.posMasterRepository.findOne({ let pos = await this.posMasterRepository.findOne({
relations: ["current_holder"], relations: ["current_holder"],
where: { where: {
current_holder: Not(IsNull()),
orgRevision: { orgRevision: {
orgRevisionIsCurrent: true, orgRevisionIsCurrent: true,
orgRevisionIsDraft: false, orgRevisionIsDraft: false,

View file

@ -280,8 +280,8 @@ export class OrganizationUnauthorizeController extends Controller {
`${new Date(x.date).getFullYear()}-${String(new Date(x.date).getMonth() + 1).padStart(2, "0")}-${String(new Date(x.date).getDate() + 1).padStart(2, "0")}T00:00:00.000Z`, `${new Date(x.date).getFullYear()}-${String(new Date(x.date).getMonth() + 1).padStart(2, "0")}-${String(new Date(x.date).getDate() + 1).padStart(2, "0")}T00:00:00.000Z`,
) <= datePeriodEnd, ) <= datePeriodEnd,
).length > 0 ).length > 0
? true ? false
: false, : true,
isSuspension: item.current_holder.dateRetire == null ? false : true, isSuspension: item.current_holder.dateRetire == null ? false : true,
isAbsent: item.current_holder.profileDisciplines.length > 0 ? true : false, isAbsent: item.current_holder.profileDisciplines.length > 0 ? true : false,
isLeave: item.current_holder.profileLeaves.length > 0 ? true : false, isLeave: item.current_holder.profileLeaves.length > 0 ? true : false,
@ -340,6 +340,7 @@ export class OrganizationUnauthorizeController extends Controller {
const [findPosMaster, total] = await AppDataSource.getRepository(viewPosMaster) const [findPosMaster, total] = await AppDataSource.getRepository(viewPosMaster)
.createQueryBuilder("viewPosMaster") .createQueryBuilder("viewPosMaster")
.where({orgRevisionId: findRevision?.id}) .where({orgRevisionId: findRevision?.id})
.andWhere({positionIsSelected: true})
// .andWhere("viewPosMaster.rootId IN (:...rootIds)", { rootIds }) // .andWhere("viewPosMaster.rootId IN (:...rootIds)", { rootIds })
.andWhere( .andWhere(
new Brackets((qb) => { new Brackets((qb) => {
@ -517,8 +518,8 @@ export class OrganizationUnauthorizeController extends Controller {
new Date( new Date(
`${new Date(item.disCriplineDate).getFullYear()}-${String(new Date(item.disCriplineDate).getMonth() + 1).padStart(2, "0")}-${String(new Date(item.disCriplineDate).getDate() + 1).padStart(2, "0")}T00:00:00.000Z`, `${new Date(item.disCriplineDate).getFullYear()}-${String(new Date(item.disCriplineDate).getMonth() + 1).padStart(2, "0")}-${String(new Date(item.disCriplineDate).getDate() + 1).padStart(2, "0")}T00:00:00.000Z`,
) <= datePeriodEnd ) <= datePeriodEnd
? true ? false
: false, : true,
isSuspension: item.dateRetire == null ? false : true, isSuspension: item.dateRetire == null ? false : true,
isAbsent: item.profileDisciplineId ? true : false, isAbsent: item.profileDisciplineId ? true : false,
isLeave: item.profileLeaveId ? true : false, isLeave: item.profileLeaveId ? true : false,
@ -739,8 +740,8 @@ export class OrganizationUnauthorizeController extends Controller {
`${new Date(x.date).getFullYear()}-${String(new Date(x.date).getMonth() + 1).padStart(2, "0")}-${String(new Date(x.date).getDate() + 1).padStart(2, "0")}T00:00:00.000Z`, `${new Date(x.date).getFullYear()}-${String(new Date(x.date).getMonth() + 1).padStart(2, "0")}-${String(new Date(x.date).getDate() + 1).padStart(2, "0")}T00:00:00.000Z`,
) <= datePeriodEnd, ) <= datePeriodEnd,
).length > 0 ).length > 0
? true ? false
: false, : true,
isSuspension: item.current_holder.dateRetire == null ? false : true, isSuspension: item.current_holder.dateRetire == null ? false : true,
isAbsent: item.current_holder.profileDisciplines.length > 0 ? true : false, isAbsent: item.current_holder.profileDisciplines.length > 0 ? true : false,
isLeave: item.current_holder.profileLeaves.length > 0 ? true : false, isLeave: item.current_holder.profileLeaves.length > 0 ? true : false,
@ -971,8 +972,8 @@ export class OrganizationUnauthorizeController extends Controller {
new Date( new Date(
`${new Date(item.disCriplineDate).getFullYear()}-${String(new Date(item.disCriplineDate).getMonth() + 1).padStart(2, "0")}-${String(new Date(item.disCriplineDate).getDate() + 1).padStart(2, "0")}T00:00:00.000Z`, `${new Date(item.disCriplineDate).getFullYear()}-${String(new Date(item.disCriplineDate).getMonth() + 1).padStart(2, "0")}-${String(new Date(item.disCriplineDate).getDate() + 1).padStart(2, "0")}T00:00:00.000Z`,
) <= datePeriodEnd ) <= datePeriodEnd
? true ? false
: false, : true,
isSuspension: item.dateRetire == null ? false : true, isSuspension: item.dateRetire == null ? false : true,
isAbsent: item.profileDisciplineId ? true : false, isAbsent: item.profileDisciplineId ? true : false,
isLeave: item.profileLeaveId ? true : false, isLeave: item.profileLeaveId ? true : false,

View file

@ -2219,7 +2219,7 @@ export class ProfileController extends Controller {
_data.child1 != undefined && _data.child1 != null _data.child1 != undefined && _data.child1 != null
? _data.child1[0] != null ? _data.child1[0] != null
? `current_holders.orgChild1Id IN (:...child1)` ? `current_holders.orgChild1Id IN (:...child1)`
: `current_holders.orgChild1Id is null` : `current_holders.orgChild1Id is ${_data.privilege == "PARENT" ? "not null" : "null"}`
: "1=1", : "1=1",
{ {
child1: _data.child1, child1: _data.child1,
@ -3302,10 +3302,7 @@ export class ProfileController extends Controller {
citizenIdDigits[10] * 3 + citizenIdDigits[10] * 3 +
citizenIdDigits[11] * 2; citizenIdDigits[11] * 2;
const calStp2 = cal % 11; const calStp2 = cal % 11;
let chkDigit = 11 - calStp2; const chkDigit = (11 - calStp2) % 10;
if (chkDigit >= 10) {
chkDigit = 0;
}
if (citizenIdDigits[12] !== chkDigit) { if (citizenIdDigits[12] !== chkDigit) {
throw new HttpError(HttpStatus.NOT_FOUND, "ข้อมูลรหัสบัตรประจำตัวประชาชนไม่ถูกต้อง"); throw new HttpError(HttpStatus.NOT_FOUND, "ข้อมูลรหัสบัตรประจำตัวประชาชนไม่ถูกต้อง");
@ -3338,10 +3335,7 @@ export class ProfileController extends Controller {
citizenIdDigits[10] * 3 + citizenIdDigits[10] * 3 +
citizenIdDigits[11] * 2; citizenIdDigits[11] * 2;
const calStp2 = cal % 11; const calStp2 = cal % 11;
let chkDigit = 11 - calStp2; const chkDigit = (11 - calStp2) % 10;
if (chkDigit >= 10) {
chkDigit = 0;
}
// else if(chkDigit === 11){ // else if(chkDigit === 11){
// chkDigit = cal % 10; // chkDigit = cal % 10;
// } // }
@ -3416,10 +3410,7 @@ export class ProfileController extends Controller {
citizenIdDigits[10] * 3 + citizenIdDigits[10] * 3 +
citizenIdDigits[11] * 2; citizenIdDigits[11] * 2;
const calStp2 = cal % 11; const calStp2 = cal % 11;
let chkDigit = 11 - calStp2; const chkDigit = (11 - calStp2) % 10;
if (chkDigit >= 10) {
chkDigit = 0;
}
if (citizenIdDigits[12] !== chkDigit) { if (citizenIdDigits[12] !== chkDigit) {
throw new HttpError(HttpStatus.NOT_FOUND, "ข้อมูลรหัสบัตรประจำตัวประชาชนไม่ถูกต้อง"); throw new HttpError(HttpStatus.NOT_FOUND, "ข้อมูลรหัสบัตรประจำตัวประชาชนไม่ถูกต้อง");
@ -3484,10 +3475,7 @@ export class ProfileController extends Controller {
citizenIdDigits[10] * 3 + citizenIdDigits[10] * 3 +
citizenIdDigits[11] * 2; citizenIdDigits[11] * 2;
const calStp2 = cal % 11; const calStp2 = cal % 11;
let chkDigit = 11 - calStp2; const chkDigit = (11 - calStp2) % 10;
if (chkDigit >= 10) {
chkDigit = 0;
}
if (citizenIdDigits[12] !== chkDigit) { if (citizenIdDigits[12] !== chkDigit) {
throw new HttpError(HttpStatus.NOT_FOUND, "ข้อมูลรหัสบัตรประจำตัวประชาชนไม่ถูกต้อง"); throw new HttpError(HttpStatus.NOT_FOUND, "ข้อมูลรหัสบัตรประจำตัวประชาชนไม่ถูกต้อง");
@ -5249,10 +5237,7 @@ export class ProfileController extends Controller {
citizenIdDigits[10] * 3 + citizenIdDigits[10] * 3 +
citizenIdDigits[11] * 2; citizenIdDigits[11] * 2;
const calStp2 = cal % 11; const calStp2 = cal % 11;
let chkDigit = 11 - calStp2; const chkDigit = (11 - calStp2) % 10;
if (chkDigit >= 10) {
chkDigit = 0;
}
if (citizenIdDigits[12] !== chkDigit) { if (citizenIdDigits[12] !== chkDigit) {
throw new HttpError(HttpStatus.NOT_FOUND, "ข้อมูลรหัสบัตรประจำตัวประชาชนไม่ถูกต้อง"); throw new HttpError(HttpStatus.NOT_FOUND, "ข้อมูลรหัสบัตรประจำตัวประชาชนไม่ถูกต้อง");
@ -6152,7 +6137,7 @@ export class ProfileController extends Controller {
_data.child1 != undefined && _data.child1 != null _data.child1 != undefined && _data.child1 != null
? _data.child1[0] != null ? _data.child1[0] != null
? `current_holders.orgChild1Id IN (:...child1)` ? `current_holders.orgChild1Id IN (:...child1)`
: `current_holders.orgChild1Id is null` : `current_holders.orgChild1Id is ${_data.privilege == "PARENT" ? "not null" : "null"}`
: "1=1", : "1=1",
{ child1: _data.child1 }, { child1: _data.child1 },
) )
@ -6539,7 +6524,7 @@ export class ProfileController extends Controller {
_data.child1 != undefined && _data.child1 != null _data.child1 != undefined && _data.child1 != null
? _data.child1[0] != null ? _data.child1[0] != null
? `current_holders.orgChild1Id IN (:...child1)` ? `current_holders.orgChild1Id IN (:...child1)`
: `current_holders.orgChild1Id is null` : `current_holders.orgChild1Id is ${_data.privilege == "PARENT" ? "not null" : "null"}`
: "1=1", : "1=1",
{ child1: _data.child1 }, { child1: _data.child1 },
) )
@ -6647,6 +6632,7 @@ export class ProfileController extends Controller {
position: _data.position, position: _data.position,
posNo: shortName ?? null, posNo: shortName ?? null,
rootId: holder?.orgRoot?.id ?? null, rootId: holder?.orgRoot?.id ?? null,
child1Id: holder?.orgChild1Id ?? null,
root: holder?.orgRoot?.orgRootName ?? null, root: holder?.orgRoot?.orgRootName ?? null,
rootDnaId: holder?.orgRoot == null ? null : holder?.orgRoot?.ancestorDNA, rootDnaId: holder?.orgRoot == null ? null : holder?.orgRoot?.ancestorDNA,
orgRootShortName: holder?.orgRoot?.orgRootShortName ?? null, orgRootShortName: holder?.orgRoot?.orgRootShortName ?? null,
@ -7367,7 +7353,7 @@ export class ProfileController extends Controller {
nodeDnaId: null, nodeDnaId: null,
type: profile.employeeClass, type: profile.employeeClass,
salary: profile.amount, salary: profile.amount,
posNo: null posNo: null,
// root?.orgRootShortName && posMaster?.posMasterNo // root?.orgRootShortName && posMaster?.posMasterNo
// ? `${root?.orgRootShortName} ${posMaster?.posMasterNo}` // ? `${root?.orgRootShortName} ${posMaster?.posMasterNo}`
// : "", // : "",
@ -7536,7 +7522,7 @@ export class ProfileController extends Controller {
nodeDnaId: null, nodeDnaId: null,
salary: profile ? profile.amount : null, salary: profile ? profile.amount : null,
amountSpecial: profile ? profile.amountSpecial : null, amountSpecial: profile ? profile.amountSpecial : null,
posNo: null posNo: null,
// root?.orgRootShortName && posMaster?.posMasterNo // root?.orgRootShortName && posMaster?.posMasterNo
// ? `${root?.orgRootShortName} ${posMaster?.posMasterNo}` // ? `${root?.orgRootShortName} ${posMaster?.posMasterNo}`
// : "", // : "",
@ -8882,7 +8868,7 @@ export class ProfileController extends Controller {
_data.child1 != undefined && _data.child1 != null _data.child1 != undefined && _data.child1 != null
? _data.child1[0] != null ? _data.child1[0] != null
? `current_holders.orgChild1Id IN (:...child1)` ? `current_holders.orgChild1Id IN (:...child1)`
: `current_holders.orgChild1Id is null` : `current_holders.orgChild1Id is ${_data.privilege == "PARENT" ? "not null" : "null"}`
: "1=1", : "1=1",
{ child1: _data.child1 }, { child1: _data.child1 },
) )
@ -9405,7 +9391,7 @@ export class ProfileController extends Controller {
_data.child1 != undefined && _data.child1 != null _data.child1 != undefined && _data.child1 != null
? _data.child1[0] != null ? _data.child1[0] != null
? `current_holders.orgChild1Id IN (:...child1)` ? `current_holders.orgChild1Id IN (:...child1)`
: `current_holders.orgChild1Id is null` : `current_holders.orgChild1Id is ${_data.privilege == "PARENT" ? "not null" : "null"}`
: "1=1", : "1=1",
{ {
child1: _data.child1, child1: _data.child1,
@ -9796,15 +9782,20 @@ export class ProfileController extends Controller {
.leftJoinAndSelect("current_holders.positions", "positions") .leftJoinAndSelect("current_holders.positions", "positions")
.leftJoinAndSelect("positions.posExecutive", "posExecutive") .leftJoinAndSelect("positions.posExecutive", "posExecutive")
.andWhere( .andWhere(
new Brackets(qb => { new Brackets((qb) => {
qb.where("profile.position LIKE :keyword", { keyword: `%${body.keyword}%` }) qb.where("profile.position LIKE :keyword", { keyword: `%${body.keyword}%` })
.orWhere("posLevel.posLevelName LIKE :keyword", { keyword: `%${body.keyword}%` }) .orWhere("posLevel.posLevelName LIKE :keyword", { keyword: `%${body.keyword}%` })
.orWhere("posType.posTypeName LIKE :keyword", { keyword: `%${body.keyword}%` }) .orWhere("posType.posTypeName LIKE :keyword", { keyword: `%${body.keyword}%` })
.orWhere("CONCAT(profile.prefix, profile.firstName, ' ', profile.lastName) LIKE :keyword", { keyword: `%${body.keyword}%` }); .orWhere(
}) "CONCAT(profile.prefix, profile.firstName, ' ', profile.lastName) LIKE :keyword",
{ keyword: `%${body.keyword}%` },
);
}),
) )
.andWhere("profile.isLeave = false") .andWhere("profile.isLeave = false")
.andWhere("current_holders.orgRevisionId = :orgRevisionId", { orgRevisionId: orgRevisionActive.id }); .andWhere("current_holders.orgRevisionId = :orgRevisionId", {
orgRevisionId: orgRevisionActive.id,
});
const [findProfile, total] = await query const [findProfile, total] = await query
.orderBy("profile.citizenId", "ASC") .orderBy("profile.citizenId", "ASC")
@ -9822,9 +9813,10 @@ export class ProfileController extends Controller {
: item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive.id); : item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive.id);
const position = const position =
posMaster == null || posMaster == null ||
item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive.id)?.positions == null || item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive.id)?.positions ==
item.current_holders?.find((x) => x.orgRevisionId == orgRevisionActive.id)?.positions.length == null ||
0 || item.current_holders?.find((x) => x.orgRevisionId == orgRevisionActive.id)?.positions
.length == 0 ||
item.current_holders item.current_holders
.find((x) => x.orgRevisionId == orgRevisionActive.id) .find((x) => x.orgRevisionId == orgRevisionActive.id)
?.positions?.find((position) => position.positionIsSelected == true) == null ?.positions?.find((position) => position.positionIsSelected == true) == null
@ -9852,18 +9844,20 @@ export class ProfileController extends Controller {
item.current_holders.length == 0 item.current_holders.length == 0
? null ? null
: item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive.id) != null && : item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive.id) != null &&
item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive.id)?.orgChild4 != item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive.id)
null ?.orgChild4 != null
? `${item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive.id)?.orgChild4.orgChild4ShortName} ${item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive.id)?.posMasterNo}` ? `${item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive.id)?.orgChild4.orgChild4ShortName} ${item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive.id)?.posMasterNo}`
: item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive.id) != null && : item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive.id) != null &&
item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive.id)?.orgChild3 != item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive.id)
null ?.orgChild3 != null
? `${item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive.id)?.orgChild3.orgChild3ShortName} ${item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive.id)?.posMasterNo}` ? `${item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive.id)?.orgChild3.orgChild3ShortName} ${item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive.id)?.posMasterNo}`
: item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive.id) != null && : item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive.id) !=
null &&
item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive.id) item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive.id)
?.orgChild2 != null ?.orgChild2 != null
? `${item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive.id)?.orgChild2.orgChild2ShortName} ${item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive.id)?.posMasterNo}` ? `${item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive.id)?.orgChild2.orgChild2ShortName} ${item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive.id)?.posMasterNo}`
: item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive.id) != null && : item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive.id) !=
null &&
item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive.id) item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive.id)
?.orgChild1 != null ?.orgChild1 != null
? `${item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive.id)?.orgChild1.orgChild1ShortName} ${item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive.id)?.posMasterNo}` ? `${item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive.id)?.orgChild1.orgChild1ShortName} ${item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive.id)?.posMasterNo}`

View file

@ -75,13 +75,10 @@ export class ProfileEditController extends Controller {
); );
}), }),
) )
.orderBy("ProfileEdit.createdAt", "DESC") .orderBy("ProfileEdit.createdAt", "DESC");
if (sortBy) { if (sortBy) {
query = query.orderBy( query = query.orderBy(`ProfileEdit.${sortBy}`, descending ? "DESC" : "ASC");
`ProfileEdit.${sortBy}`,
descending ? "DESC" : "ASC"
);
} }
const [getProfileEdit, total] = await query const [getProfileEdit, total] = await query
@ -153,7 +150,7 @@ export class ProfileEditController extends Controller {
data.child1 != undefined && data.child1 != null data.child1 != undefined && data.child1 != null
? data.child1[0] != null ? data.child1[0] != null
? `current_holders.orgChild1Id IN (:...child1)` ? `current_holders.orgChild1Id IN (:...child1)`
: `current_holders.orgChild1Id is null` : `current_holders.orgChild1Id is ${data.privilege == "PARENT" ? "not null" : "null"}`
: "1=1", : "1=1",
{ {
child1: data.child1, child1: data.child1,
@ -216,19 +213,13 @@ export class ProfileEditController extends Controller {
); );
}), }),
) )
.orderBy("ProfileEdit.createdAt", "DESC") .orderBy("ProfileEdit.createdAt", "DESC");
if (sortBy) { if (sortBy) {
if (sortBy == "fullname") { if (sortBy == "fullname") {
query = query.orderBy( query = query.orderBy(`profile.firstName`, descending ? "DESC" : "ASC");
`profile.firstName`,
descending ? "DESC" : "ASC"
);
} else { } else {
query = query.orderBy( query = query.orderBy(`ProfileEdit.${sortBy}`, descending ? "DESC" : "ASC");
`ProfileEdit.${sortBy}`,
descending ? "DESC" : "ASC"
);
} }
} }

View file

@ -148,7 +148,7 @@ export class ProfileEditEmployeeController extends Controller {
data.child1 != undefined && data.child1 != null data.child1 != undefined && data.child1 != null
? data.child1[0] != null ? data.child1[0] != null
? `current_holders.orgChild1Id IN (:...child1)` ? `current_holders.orgChild1Id IN (:...child1)`
: `current_holders.orgChild1Id is null` : `current_holders.orgChild1Id is ${data.privilege == "PARENT" ? "not null" : "null"}`
: "1=1", : "1=1",
{ {
child1: data.child1, child1: data.child1,
@ -211,19 +211,13 @@ export class ProfileEditEmployeeController extends Controller {
); );
}), }),
) )
.orderBy("ProfileEdit.createdAt", "DESC") .orderBy("ProfileEdit.createdAt", "DESC");
if (sortBy) { if (sortBy) {
if (sortBy == "fullname") { if (sortBy == "fullname") {
query = query.orderBy( query = query.orderBy(`profileEmployee.firstName`, descending ? "DESC" : "ASC");
`profileEmployee.firstName`,
descending ? "DESC" : "ASC"
);
} else { } else {
query = query.orderBy( query = query.orderBy(`ProfileEdit.${sortBy}`, descending ? "DESC" : "ASC");
`ProfileEdit.${sortBy}`,
descending ? "DESC" : "ASC"
);
} }
} }

View file

@ -1891,10 +1891,7 @@ export class ProfileEmployeeController extends Controller {
citizenIdDigits[10] * 3 + citizenIdDigits[10] * 3 +
citizenIdDigits[11] * 2; citizenIdDigits[11] * 2;
const calStp2 = cal % 11; const calStp2 = cal % 11;
let chkDigit = 11 - calStp2; const chkDigit = (11 - calStp2) % 10;
if (chkDigit >= 10) {
chkDigit = 0;
}
if (citizenIdDigits[12] !== chkDigit) { if (citizenIdDigits[12] !== chkDigit) {
throw new HttpError(HttpStatus.NOT_FOUND, "ข้อมูลรหัสบัตรประจำตัวประชาชนไม่ถูกต้อง"); throw new HttpError(HttpStatus.NOT_FOUND, "ข้อมูลรหัสบัตรประจำตัวประชาชนไม่ถูกต้อง");
@ -1983,10 +1980,7 @@ export class ProfileEmployeeController extends Controller {
citizenIdDigits[10] * 3 + citizenIdDigits[10] * 3 +
citizenIdDigits[11] * 2; citizenIdDigits[11] * 2;
const calStp2 = cal % 11; const calStp2 = cal % 11;
let chkDigit = 11 - calStp2; const chkDigit = (11 - calStp2) % 10;
if (chkDigit >= 10) {
chkDigit = 0;
}
if (citizenIdDigits[12] !== chkDigit) { if (citizenIdDigits[12] !== chkDigit) {
throw new HttpError(HttpStatus.NOT_FOUND, "ข้อมูลรหัสบัตรประจำตัวประชาชนไม่ถูกต้อง"); throw new HttpError(HttpStatus.NOT_FOUND, "ข้อมูลรหัสบัตรประจำตัวประชาชนไม่ถูกต้อง");
@ -2045,7 +2039,10 @@ export class ProfileEmployeeController extends Controller {
await this.informationHistoryRepository.delete({ profileEmployeeId: id }); await this.informationHistoryRepository.delete({ profileEmployeeId: id });
await this.profileRepo.remove(result); await this.profileRepo.remove(result);
} catch { } catch {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่สามารถลบข้อมูลได้ เนื่องจากข้อมูลนี้ถูกใช้งานในระบบอื่น"); throw new HttpError(
HttpStatusCode.NOT_FOUND,
"ไม่สามารถลบข้อมูลได้ เนื่องจากข้อมูลนี้ถูกใช้งานในระบบอื่น",
);
} }
return new HttpSuccess(); return new HttpSuccess();
} }
@ -2843,7 +2840,7 @@ export class ProfileEmployeeController extends Controller {
_data.child1 != undefined && _data.child1 != null _data.child1 != undefined && _data.child1 != null
? _data.child1[0] != null ? _data.child1[0] != null
? `current_holders.orgChild1Id IN (:...child1)` ? `current_holders.orgChild1Id IN (:...child1)`
: `current_holders.orgChild1Id is null` : `current_holders.orgChild1Id is ${_data.privilege == "PARENT" ? "not null" : "null"}`
: "1=1", : "1=1",
{ {
child1: _data.child1, child1: _data.child1,
@ -3588,7 +3585,7 @@ export class ProfileEmployeeController extends Controller {
nodeDnaId: null, nodeDnaId: null,
salary: profile ? profile.amount : null, salary: profile ? profile.amount : null,
amountSpecial: profile ? profile.amountSpecial : null, amountSpecial: profile ? profile.amountSpecial : null,
posNo: null posNo: null,
// root?.orgRootShortName && posMaster?.posMasterNo // root?.orgRootShortName && posMaster?.posMasterNo
// ? `${root?.orgRootShortName} ${posMaster?.posMasterNo}` // ? `${root?.orgRootShortName} ${posMaster?.posMasterNo}`
// : "", // : "",
@ -3722,7 +3719,7 @@ export class ProfileEmployeeController extends Controller {
_data.child1 != undefined && _data.child1 != null _data.child1 != undefined && _data.child1 != null
? _data.child1[0] != null ? _data.child1[0] != null
? `current_holders.orgChild1Id IN (:...child1)` ? `current_holders.orgChild1Id IN (:...child1)`
: `current_holders.orgChild1Id is null` : `current_holders.orgChild1Id is ${_data.privilege == "PARENT" ? "not null" : "null"}`
: "1=1", : "1=1",
{ child1: _data.child1 }, { child1: _data.child1 },
) )
@ -4280,7 +4277,7 @@ export class ProfileEmployeeController extends Controller {
_data.child1 != undefined && _data.child1 != null _data.child1 != undefined && _data.child1 != null
? _data.child1[0] != null ? _data.child1[0] != null
? `current_holders.orgChild1Id IN (:...child1)` ? `current_holders.orgChild1Id IN (:...child1)`
: `current_holders.orgChild1Id is null` : `current_holders.orgChild1Id is ${_data.privilege == "PARENT" ? "not null" : "null"}`
: "1=1", : "1=1",
{ {
child1: _data.child1, child1: _data.child1,
@ -4441,22 +4438,26 @@ export class ProfileEmployeeController extends Controller {
.leftJoinAndSelect("current_holders.orgChild4", "orgChild4") .leftJoinAndSelect("current_holders.orgChild4", "orgChild4")
.leftJoinAndSelect("current_holders.positions", "positions") .leftJoinAndSelect("current_holders.positions", "positions")
.andWhere( .andWhere(
new Brackets(qb => { new Brackets((qb) => {
qb.where("profileEmployee.position LIKE :keyword", { keyword: `%${body.keyword}%` }) qb.where("profileEmployee.position LIKE :keyword", { keyword: `%${body.keyword}%` })
.orWhere("posLevel.posLevelName LIKE :keyword", { keyword: `%${body.keyword}%` }) .orWhere("posLevel.posLevelName LIKE :keyword", { keyword: `%${body.keyword}%` })
.orWhere("posType.posTypeName LIKE :keyword", { keyword: `%${body.keyword}%` }) .orWhere("posType.posTypeName LIKE :keyword", { keyword: `%${body.keyword}%` })
.orWhere("CONCAT(profileEmployee.prefix, profileEmployee.firstName, ' ', profileEmployee.lastName) LIKE :keyword", { keyword: `%${body.keyword}%` }); .orWhere(
}) "CONCAT(profileEmployee.prefix, profileEmployee.firstName, ' ', profileEmployee.lastName) LIKE :keyword",
{ keyword: `%${body.keyword}%` },
);
}),
) )
.andWhere("profileEmployee.isLeave = false") .andWhere("profileEmployee.isLeave = false")
.andWhere("current_holders.orgRevisionId = :orgRevisionId", { orgRevisionId: orgRevisionActive.id }); .andWhere("current_holders.orgRevisionId = :orgRevisionId", {
orgRevisionId: orgRevisionActive.id,
});
if (body.type) { if (body.type) {
const typeUpper = body.type.trim().toUpperCase(); const typeUpper = body.type.trim().toUpperCase();
if (typeUpper === "EMPLOYEE") { if (typeUpper === "EMPLOYEE") {
query = query.andWhere("profileEmployee.employeeClass = 'PERM'"); query = query.andWhere("profileEmployee.employeeClass = 'PERM'");
} } else if (typeUpper === "TEMP") {
else if (typeUpper === "TEMP"){
query = query.andWhere("profileEmployee.employeeClass = 'TEMP'"); query = query.andWhere("profileEmployee.employeeClass = 'TEMP'");
} }
} }
@ -4477,9 +4478,10 @@ export class ProfileEmployeeController extends Controller {
: item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive.id); : item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive.id);
const position = const position =
posMaster == null || posMaster == null ||
item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive.id)?.positions == null || item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive.id)?.positions ==
item.current_holders?.find((x) => x.orgRevisionId == orgRevisionActive.id)?.positions.length == null ||
0 || item.current_holders?.find((x) => x.orgRevisionId == orgRevisionActive.id)?.positions
.length == 0 ||
item.current_holders item.current_holders
.find((x) => x.orgRevisionId == orgRevisionActive.id) .find((x) => x.orgRevisionId == orgRevisionActive.id)
?.positions?.find((position) => position.positionIsSelected == true) == null ?.positions?.find((position) => position.positionIsSelected == true) == null
@ -4492,18 +4494,20 @@ export class ProfileEmployeeController extends Controller {
item.current_holders.length == 0 item.current_holders.length == 0
? null ? null
: item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive.id) != null && : item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive.id) != null &&
item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive.id)?.orgChild4 != item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive.id)
null ?.orgChild4 != null
? `${item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive.id)?.orgChild4.orgChild4ShortName} ${item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive.id)?.posMasterNo}` ? `${item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive.id)?.orgChild4.orgChild4ShortName} ${item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive.id)?.posMasterNo}`
: item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive.id) != null && : item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive.id) != null &&
item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive.id)?.orgChild3 != item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive.id)
null ?.orgChild3 != null
? `${item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive.id)?.orgChild3.orgChild3ShortName} ${item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive.id)?.posMasterNo}` ? `${item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive.id)?.orgChild3.orgChild3ShortName} ${item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive.id)?.posMasterNo}`
: item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive.id) != null && : item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive.id) !=
null &&
item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive.id) item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive.id)
?.orgChild2 != null ?.orgChild2 != null
? `${item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive.id)?.orgChild2.orgChild2ShortName} ${item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive.id)?.posMasterNo}` ? `${item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive.id)?.orgChild2.orgChild2ShortName} ${item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive.id)?.posMasterNo}`
: item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive.id) != null && : item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive.id) !=
null &&
item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive.id) item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive.id)
?.orgChild1 != null ?.orgChild1 != null
? `${item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive.id)?.orgChild1.orgChild1ShortName} ${item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive.id)?.posMasterNo}` ? `${item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive.id)?.orgChild1.orgChild1ShortName} ${item.current_holders.find((x) => x.orgRevisionId == orgRevisionActive.id)?.posMasterNo}`

View file

@ -120,7 +120,7 @@ export class ProfileSalaryTempController extends Controller {
_data.child1 != undefined && _data.child1 != null _data.child1 != undefined && _data.child1 != null
? _data.child1[0] != null ? _data.child1[0] != null
? `current_holders.orgChild1Id IN (:...child1)` ? `current_holders.orgChild1Id IN (:...child1)`
: `current_holders.orgChild1Id is null` : `current_holders.orgChild1Id is ${_data.privilege == "PARENT" ? "not null" : "null"}`
: "1=1", : "1=1",
{ {
child1: _data.child1, child1: _data.child1,
@ -322,46 +322,36 @@ export class ProfileSalaryTempController extends Controller {
.andWhere("current_holders.orgRootId = :rootId", { .andWhere("current_holders.orgRootId = :rootId", {
rootId: rootId, rootId: rootId,
}) })
.addSelect("CASE WHEN current_holders.posMasterNo IS NULL THEN 1 ELSE 0 END", "sort_order") .addSelect("CASE WHEN current_holders.posMasterNo IS NULL THEN 1 ELSE 0 END", "sort_order");
// .orderBy(`${sortBy}`, sort) // .orderBy(`${sortBy}`, sort)
if (sortBy) { if (sortBy) {
if (sortBy == "posLevel") { if (sortBy == "posLevel") {
query = query.orderBy( query = query.orderBy(`posLevel.posLevelName`, descending ? "DESC" : "ASC");
`posLevel.posLevelName`,
descending ? "DESC" : "ASC"
);
} else if (sortBy == "posType") { } else if (sortBy == "posType") {
query = query.orderBy( query = query.orderBy(`posType.posTypeName`, descending ? "DESC" : "ASC");
`posType.posTypeName`,
descending ? "DESC" : "ASC"
);
} else if (sortBy == "posExecutive") { } else if (sortBy == "posExecutive") {
query = query.orderBy( query = query.orderBy(`posExecutive.posExecutiveName`, descending ? "DESC" : "ASC");
`posExecutive.posExecutiveName`,
descending ? "DESC" : "ASC"
);
} else if (sortBy == "posNo") { } else if (sortBy == "posNo") {
query = query.orderBy("orgChild4.orgChild4ShortName",descending ? "DESC" : "ASC") query = query
.orderBy("orgChild4.orgChild4ShortName", descending ? "DESC" : "ASC")
.addOrderBy("orgChild3.orgChild3ShortName", descending ? "DESC" : "ASC") .addOrderBy("orgChild3.orgChild3ShortName", descending ? "DESC" : "ASC")
.addOrderBy("orgChild2.orgChild2ShortName", descending ? "DESC" : "ASC") .addOrderBy("orgChild2.orgChild2ShortName", descending ? "DESC" : "ASC")
.addOrderBy("orgChild1.orgChild1ShortName", descending ? "DESC" : "ASC") .addOrderBy("orgChild1.orgChild1ShortName", descending ? "DESC" : "ASC")
.addOrderBy("orgRoot.orgRootShortName", descending ? "DESC" : "ASC") .addOrderBy("orgRoot.orgRootShortName", descending ? "DESC" : "ASC")
.addOrderBy("current_holders.posMasterNo",descending ? "DESC" : "ASC") .addOrderBy("current_holders.posMasterNo", descending ? "DESC" : "ASC");
} else { } else {
query = query.orderBy( query = query.orderBy(`profile.${sortBy}`, descending ? "DESC" : "ASC");
`profile.${sortBy}`,
descending ? "DESC" : "ASC"
);
} }
} else { } else {
query = query.orderBy("sort_order", "ASC") query = query
.orderBy("sort_order", "ASC")
.addOrderBy("orgRoot.orgRootOrder", "ASC") .addOrderBy("orgRoot.orgRootOrder", "ASC")
.addOrderBy("orgChild1.orgChild1Order", "ASC") .addOrderBy("orgChild1.orgChild1Order", "ASC")
.addOrderBy("orgChild2.orgChild2Order", "ASC") .addOrderBy("orgChild2.orgChild2Order", "ASC")
.addOrderBy("orgChild3.orgChild3Order", "ASC") .addOrderBy("orgChild3.orgChild3Order", "ASC")
.addOrderBy("orgChild4.orgChild4Order", "ASC") .addOrderBy("orgChild4.orgChild4Order", "ASC")
.addOrderBy("current_holders.posMasterNo", "ASC") .addOrderBy("current_holders.posMasterNo", "ASC");
} }
const [record, total] = await query const [record, total] = await query
@ -541,7 +531,7 @@ export class ProfileSalaryTempController extends Controller {
_data.child1 != undefined && _data.child1 != null _data.child1 != undefined && _data.child1 != null
? _data.child1[0] != null ? _data.child1[0] != null
? `current_holders.orgChild1Id IN (:...child1)` ? `current_holders.orgChild1Id IN (:...child1)`
: `current_holders.orgChild1Id is null` : `current_holders.orgChild1Id is ${_data.privilege == "PARENT" ? "not null" : "null"}`
: "1=1", : "1=1",
{ {
child1: _data.child1, child1: _data.child1,
@ -755,30 +745,18 @@ export class ProfileSalaryTempController extends Controller {
.andWhere("current_holders.orgRootId = :rootId", { .andWhere("current_holders.orgRootId = :rootId", {
rootId: rootId, rootId: rootId,
}) })
.orderBy("current_holders.posMasterNo", "ASC") .orderBy("current_holders.posMasterNo", "ASC");
// .orderBy(`${sortBy}`, sort) // .orderBy(`${sortBy}`, sort)
if (sortBy) { if (sortBy) {
if (sortBy == "posLevel") { if (sortBy == "posLevel") {
query = query.orderBy( query = query.orderBy(`posLevel.posLevelName`, descending ? "DESC" : "ASC");
`posLevel.posLevelName`,
descending ? "DESC" : "ASC"
);
} else if (sortBy == "posType") { } else if (sortBy == "posType") {
query = query.orderBy( query = query.orderBy(`posType.posTypeName`, descending ? "DESC" : "ASC");
`posType.posTypeName`,
descending ? "DESC" : "ASC"
);
} else if (sortBy == "posNo") { } else if (sortBy == "posNo") {
query = query.orderBy( query = query.orderBy(`orgRoot.orgRootShortName`, descending ? "DESC" : "ASC");
`orgRoot.orgRootShortName`,
descending ? "DESC" : "ASC"
);
} else { } else {
query = query.orderBy( query = query.orderBy(`profileEmployee.${sortBy}`, descending ? "DESC" : "ASC");
`profileEmployee.${sortBy}`,
descending ? "DESC" : "ASC"
);
} }
} }
const [record, total] = await query const [record, total] = await query

View file

@ -17,6 +17,21 @@ export class EducationLevel extends EntityBase {
default: null, default: null,
}) })
rank: number; rank: number;
@Column({
nullable: true,
comment: "ขีดจำกัดวุฒิการศึกษา",
length: 50,
default: null,
})
educationLevel?: string;
@Column({
nullable: true,
comment: "วุฒิการศึกษาสูงสุด",
default: null,
})
isHigh?: boolean;
} }
export class CreateEducationLevel { export class CreateEducationLevel {
@ -25,6 +40,12 @@ export class CreateEducationLevel {
@Column() @Column()
rank: number; rank: number;
@Column()
educationLevel?: string;
@Column()
isHigh?: boolean;
} }
export type UpdateEducationLevel = Partial<CreateEducationLevel>; export type UpdateEducationLevel = Partial<CreateEducationLevel>;

View file

@ -79,12 +79,16 @@ import { ViewColumn, ViewEntity } from "typeorm";
posExecutive ON position.posExecutiveId = posExecutive.id posExecutive ON position.posExecutiveId = posExecutive.id
LEFT JOIN ( LEFT JOIN (
SELECT * SELECT *
FROM profileDiscipline pd1 FROM (
WHERE pd1.date = ( SELECT
SELECT MAX(pd2.date) pd.*,
FROM profileDiscipline pd2 ROW_NUMBER() OVER (
WHERE pd2.profileId = pd1.profileId PARTITION BY profileId
) ORDER BY date DESC, id DESC
) AS rn
FROM profileDiscipline pd
) t
WHERE rn = 1
) AS profileDiscipline ON profileDiscipline.profileId = profile.id ) AS profileDiscipline ON profileDiscipline.profileId = profile.id
LEFT JOIN ( LEFT JOIN (
SELECT pl1.* SELECT pl1.*

View file

@ -275,10 +275,7 @@ class Extension {
citizenIdDigits[10] * 3 + citizenIdDigits[10] * 3 +
citizenIdDigits[11] * 2; citizenIdDigits[11] * 2;
const calStp2 = cal % 11; const calStp2 = cal % 11;
let chkDigit = 11 - calStp2; const chkDigit = (11 - calStp2) % 10;
if (chkDigit >= 10) {
chkDigit = 0;
}
// if (citizenIdDigits[12] !== chkDigit) { // if (citizenIdDigits[12] !== chkDigit) {
// throw new HttpError(HttpStatus.NOT_FOUND, "ข้อมูลรหัสบัตรประจำตัวประชาชนไม่ถูกต้อง"); // throw new HttpError(HttpStatus.NOT_FOUND, "ข้อมูลรหัสบัตรประจำตัวประชาชนไม่ถูกต้อง");

View file

@ -97,7 +97,7 @@ class CheckAuth {
} else if (privilege == "PARENT") { } else if (privilege == "PARENT") {
data = { data = {
root: [x.orgRootId], root: [x.orgRootId],
child1: null, child1: [null],
child2: null, child2: null,
child3: null, child3: null,
child4: null, child4: null,

View file

@ -0,0 +1,16 @@
import { MigrationInterface, QueryRunner } from "typeorm";
export class UpdateTableEducationLeaveAddFields1764244579743 implements MigrationInterface {
name = 'UpdateTableEducationLeaveAddFields1764244579743'
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE \`educationLevel\` ADD \`educationLevel\` varchar(50) NULL COMMENT 'ขีดจำกัดวุฒิการศึกษา'`);
await queryRunner.query(`ALTER TABLE \`educationLevel\` ADD \`isHigh\` tinyint NULL COMMENT 'วุฒิการศึกษาสูงสุด'`);
}
public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE \`educationLevel\` DROP COLUMN \`isHigh\``);
await queryRunner.query(`ALTER TABLE \`educationLevel\` DROP COLUMN \`educationLevel\``);
}
}

View file

@ -445,7 +445,6 @@ async function handler_command_noti(msg: amqp.ConsumeMessage): Promise<boolean>
isSendNotification: true, isSendNotification: true,
})) }))
: []; : [];
const payloadStr = await PayloadSendNoti(command.id); const payloadStr = await PayloadSendNoti(command.id);
const profilesSendRequest = new CallAPI() const profilesSendRequest = new CallAPI()
.PostData( .PostData(
@ -475,7 +474,14 @@ async function handler_command_noti(msg: amqp.ConsumeMessage): Promise<boolean>
console.error("Full error object:", error); console.error("Full error object:", error);
}); });
/*เฉพาะคำสั่ง C-PM-10 ให้ตัด profilesNotiRequest ที่ส่ง noti ครั้งแรกออก*/
if (command && command.commandType && ["C-PM-10"].includes(command.commandType.code)) {
await Promise.all([profilesSendRequest]);
}
else {
await Promise.all([profilesNotiRequest, profilesSendRequest]); await Promise.all([profilesNotiRequest, profilesSendRequest]);
}
console.log("[AMQ] Send Notification Success"); console.log("[AMQ] Send Notification Success");
return true; return true;