no message

This commit is contained in:
kittapath 2025-01-30 13:48:23 +07:00
parent a796deb763
commit ca9e79d1a4

View file

@ -1853,7 +1853,7 @@ export class CommandController extends Controller {
) { ) {
let command = new Command(); let command = new Command();
let commandCode: string = ""; let commandCode: string = "";
let null_: any = null; let _null: any = null;
if ( if (
requestBody.commandId != undefined && requestBody.commandId != undefined &&
requestBody.commandId != null && requestBody.commandId != null &&
@ -1895,10 +1895,10 @@ export class CommandController extends Controller {
command.issue = commandType.name; command.issue = commandType.name;
(command.commandAffectDate = requestBody.commandAffectDate (command.commandAffectDate = requestBody.commandAffectDate
? new Date(requestBody.commandAffectDate) ? new Date(requestBody.commandAffectDate)
: null_), : _null),
(command.commandExcecuteDate = requestBody.commandExcecuteDate (command.commandExcecuteDate = requestBody.commandExcecuteDate
? new Date(requestBody.commandExcecuteDate) ? new Date(requestBody.commandExcecuteDate)
: null_), : _null),
(command.createdUserId = request.user.sub); (command.createdUserId = request.user.sub);
command.createdFullName = request.user.name; command.createdFullName = request.user.name;
command.createdAt = new Date(); command.createdAt = new Date();
@ -1932,7 +1932,7 @@ export class CommandController extends Controller {
let commandRecive = new CommandRecive(); let commandRecive = new CommandRecive();
commandRecive = Object.assign(new CommandRecive(), item); commandRecive = Object.assign(new CommandRecive(), item);
commandRecive.order = order; commandRecive.order = order;
let salaryData = null_; let salaryData = _null;
// const excludedCommands = ["C-PM-33", "C-PM-34", "C-PM-35", "C-PM-36", "C-PM-37"]; // const excludedCommands = ["C-PM-33", "C-PM-34", "C-PM-35", "C-PM-36", "C-PM-37"];
// if (!excludedCommands.includes(commandCode)) { // if (!excludedCommands.includes(commandCode)) {
@ -1942,7 +1942,7 @@ export class CommandController extends Controller {
id: item.profileId, id: item.profileId,
}, },
}); });
let null_: any = 0; let _setZero: any = 0;
if (!salaryData) { if (!salaryData) {
salaryData = await this.profileEmployeeRepository.findOne({ salaryData = await this.profileEmployeeRepository.findOne({
where: { where: {
@ -1950,30 +1950,25 @@ export class CommandController extends Controller {
}, },
}); });
} }
commandRecive.amount = item.amount ?? (salaryData ? salaryData.amount : null_); commandRecive.amount = item.amount ?? (salaryData ? salaryData.amount : _setZero);
commandRecive.amountSpecial = commandRecive.amountSpecial =
item.amountSpecial ?? (salaryData ? salaryData.amountSpecial : null_); item.amountSpecial ?? (salaryData ? salaryData.amountSpecial : _setZero);
commandRecive.positionSalaryAmount = commandRecive.positionSalaryAmount =
item.positionSalaryAmount ?? (salaryData ? salaryData.positionSalaryAmount : null_); item.positionSalaryAmount ??
(salaryData ? salaryData.positionSalaryAmount : _setZero);
commandRecive.mouthSalaryAmount = commandRecive.mouthSalaryAmount =
item.mouthSalaryAmount ?? (salaryData ? salaryData.mouthSalaryAmount : null_); item.mouthSalaryAmount ?? (salaryData ? salaryData.mouthSalaryAmount : _setZero);
} else { } else {
commandRecive.amount = null_; commandRecive.amount = _null;
commandRecive.amountSpecial = null_; commandRecive.amountSpecial = _null;
commandRecive.positionSalaryAmount = null_; commandRecive.positionSalaryAmount = _null;
commandRecive.mouthSalaryAmount = null_; commandRecive.mouthSalaryAmount = _null;
} }
// } else {
// commandRecive.amount = item.amount ?? null_;
// commandRecive.amountSpecial = item.amountSpecial ?? null_;
// commandRecive.positionSalaryAmount = item.positionSalaryAmount ?? null_;
// commandRecive.mouthSalaryAmount = item.mouthSalaryAmount ?? null_;
// }
commandRecive.remarkVertical = commandRecive.remarkVertical =
item.remarkVertical == null ? null_ : item.remarkVertical; item.remarkVertical == null ? _null : item.remarkVertical;
commandRecive.remarkHorizontal = commandRecive.remarkHorizontal =
item.remarkHorizontal == null ? null_ : item.remarkHorizontal; item.remarkHorizontal == null ? _null : item.remarkHorizontal;
commandRecive.order = order; commandRecive.order = order;
commandRecive.commandId = command.id; commandRecive.commandId = command.id;
commandRecive.createdUserId = request.user.sub; commandRecive.createdUserId = request.user.sub;
@ -1987,129 +1982,70 @@ export class CommandController extends Controller {
); );
}) })
.catch(() => {}); .catch(() => {});
if (!["C-PM-10"].includes(commandCode)) {
if (requestBody.persons != undefined && requestBody.persons.length > 0) { if (requestBody.persons != undefined && requestBody.persons.length > 0) {
let posMaster: any; let posMaster: any;
if (["C-PM-36", "C-PM-37"].includes(commandCode)) { if (["C-PM-36", "C-PM-37"].includes(commandCode)) {
posMaster = await this.employeePosMasterRepository.find({ posMaster = await this.employeePosMasterRepository.find({
where: {
current_holderId: In(requestBody.persons.map((x) => x.profileId)),
orgRevision: { orgRevisionIsDraft: false, orgRevisionIsCurrent: true },
},
select: ["orgRootId"],
});
} else {
var posMasterOfficer = await this.posMasterRepository.find({
where: {
current_holderId: In(requestBody.persons.map((x) => x.profileId)),
orgRevision: { orgRevisionIsDraft: false, orgRevisionIsCurrent: true },
},
select: ["orgRootId"],
});
var posMasterEmployee = await this.employeePosMasterRepository.find({
where: {
current_holderId: In(requestBody.persons.map((x) => x.profileId)),
orgRevision: { orgRevisionIsDraft: false, orgRevisionIsCurrent: true },
},
select: ["orgRootId"],
});
posMaster = [...posMasterOfficer, ...posMasterEmployee];
}
let _posMaster: any;
if (["C-PM-38", "C-PM-40"].includes(commandCode)) {
_posMaster = await this.posMasterRepository.find({
where: {
orgRootId: In(posMaster.map((x: any) => x.orgRootId)),
orgChild1: IsNull(),
orgChild2: IsNull(),
orgChild3: IsNull(),
orgChild4: IsNull(),
orgRevision: { orgRevisionIsDraft: false, orgRevisionIsCurrent: true },
isDirector: true,
current_holderId: Not(IsNull()),
},
relations: ["current_holder", "orgRoot"],
});
} else {
_posMaster = await this.posMasterRepository.find({
where: {
orgRootId: In(posMaster.map((x: any) => x.orgRootId)),
orgRevision: { orgRevisionIsDraft: false, orgRevisionIsCurrent: true },
isDirector: true,
current_holderId: Not(IsNull()),
},
relations: ["current_holder", "orgRoot"],
});
}
await Promise.all(
_posMaster.map(async (item: any) => {
const _commandSend = await this.commandSendRepository.findOne({
where: { where: {
commandId: command.id, current_holderId: In(requestBody.persons.map((x) => x.profileId)),
profileId: item.current_holder.id, orgRevision: { orgRevisionIsDraft: false, orgRevisionIsCurrent: true },
}, },
select: ["orgRootId"],
}); });
if (_commandSend) return; } else {
let commandSend = new CommandSend(); var posMasterOfficer = await this.posMasterRepository.find({
commandSend.citizenId = item.current_holder.citizenId;
commandSend.prefix = item.current_holder.prefix;
commandSend.firstName = item.current_holder.firstName;
commandSend.lastName = item.current_holder.lastName;
commandSend.position = item.current_holder.position;
commandSend.org = item.orgRoot.orgRootName;
commandSend.profileId = item.current_holder.id;
commandSend.commandId = command.id;
commandSend.createdUserId = request.user.sub;
commandSend.createdFullName = request.user.name;
commandSend.createdAt = new Date();
commandSend.lastUpdateUserId = request.user.sub;
commandSend.lastUpdateFullName = request.user.name;
commandSend.lastUpdatedAt = new Date();
await this.commandSendRepository.save(commandSend);
if (commandSend && commandSend.id) {
let _ccName = new Array("EMAIL", "INBOX");
let _dataSendCC = new Array();
for (let i = 0; i < _ccName.length; i++) {
_dataSendCC.push({
commandSendId: commandSend.id,
name: _ccName[i],
createdUserId: request.user.sub,
createdFullName: request.user.name,
createdAt: new Date(),
lastUpdateUserId: request.user.sub,
lastUpdateFullName: request.user.name,
lastUpdatedAt: new Date(),
});
}
await this.commandSendCCRepository.save(_dataSendCC);
}
}),
);
const _posMasterNext = await this.posMasterRepository.find({
where: {
orgRootId: In(
requestBody.persons
.filter((x) => x.rootId != undefined && x.rootId != null && x.rootId != "")
.map((x) => x.rootId),
),
orgRevision: { orgRevisionIsDraft: false, orgRevisionIsCurrent: true },
isDirector: true,
current_holderId: Not(IsNull()),
},
relations: ["current_holder", "orgRoot"],
});
await Promise.all(
_posMasterNext.map(async (item) => {
const _commandSend = await this.commandSendRepository.findOne({
where: { where: {
commandId: command.id, current_holderId: In(requestBody.persons.map((x) => x.profileId)),
profileId: item.current_holder.id, orgRevision: { orgRevisionIsDraft: false, orgRevisionIsCurrent: true },
}, },
select: ["orgRootId"],
}); });
// if (_commandSend) return; var posMasterEmployee = await this.employeePosMasterRepository.find({
if (!_commandSend) { where: {
current_holderId: In(requestBody.persons.map((x) => x.profileId)),
orgRevision: { orgRevisionIsDraft: false, orgRevisionIsCurrent: true },
},
select: ["orgRootId"],
});
posMaster = [...posMasterOfficer, ...posMasterEmployee];
}
let _posMaster: any;
if (["C-PM-38", "C-PM-40"].includes(commandCode)) {
_posMaster = await this.posMasterRepository.find({
where: {
orgRootId: In(posMaster.map((x: any) => x.orgRootId)),
orgChild1: IsNull(),
orgChild2: IsNull(),
orgChild3: IsNull(),
orgChild4: IsNull(),
orgRevision: { orgRevisionIsDraft: false, orgRevisionIsCurrent: true },
isDirector: true,
current_holderId: Not(IsNull()),
},
relations: ["current_holder", "orgRoot"],
});
} else {
_posMaster = await this.posMasterRepository.find({
where: {
orgRootId: In(posMaster.map((x: any) => x.orgRootId)),
orgRevision: { orgRevisionIsDraft: false, orgRevisionIsCurrent: true },
isDirector: true,
current_holderId: Not(IsNull()),
},
relations: ["current_holder", "orgRoot"],
});
}
await Promise.all(
_posMaster.map(async (item: any) => {
const _commandSend = await this.commandSendRepository.findOne({
where: {
commandId: command.id,
profileId: item.current_holder.id,
},
});
if (_commandSend) return;
let commandSend = new CommandSend(); let commandSend = new CommandSend();
commandSend.citizenId = item.current_holder.citizenId; commandSend.citizenId = item.current_holder.citizenId;
commandSend.prefix = item.current_holder.prefix; commandSend.prefix = item.current_holder.prefix;
@ -2143,9 +2079,69 @@ export class CommandController extends Controller {
} }
await this.commandSendCCRepository.save(_dataSendCC); await this.commandSendCCRepository.save(_dataSendCC);
} }
} }),
}), );
);
const _posMasterNext = await this.posMasterRepository.find({
where: {
orgRootId: In(
requestBody.persons
.filter((x) => x.rootId != undefined && x.rootId != null && x.rootId != "")
.map((x) => x.rootId),
),
orgRevision: { orgRevisionIsDraft: false, orgRevisionIsCurrent: true },
isDirector: true,
current_holderId: Not(IsNull()),
},
relations: ["current_holder", "orgRoot"],
});
await Promise.all(
_posMasterNext.map(async (item) => {
const _commandSend = await this.commandSendRepository.findOne({
where: {
commandId: command.id,
profileId: item.current_holder.id,
},
});
// if (_commandSend) return;
if (!_commandSend) {
let commandSend = new CommandSend();
commandSend.citizenId = item.current_holder.citizenId;
commandSend.prefix = item.current_holder.prefix;
commandSend.firstName = item.current_holder.firstName;
commandSend.lastName = item.current_holder.lastName;
commandSend.position = item.current_holder.position;
commandSend.org = item.orgRoot.orgRootName;
commandSend.profileId = item.current_holder.id;
commandSend.commandId = command.id;
commandSend.createdUserId = request.user.sub;
commandSend.createdFullName = request.user.name;
commandSend.createdAt = new Date();
commandSend.lastUpdateUserId = request.user.sub;
commandSend.lastUpdateFullName = request.user.name;
commandSend.lastUpdatedAt = new Date();
await this.commandSendRepository.save(commandSend);
if (commandSend && commandSend.id) {
let _ccName = new Array("EMAIL", "INBOX");
let _dataSendCC = new Array();
for (let i = 0; i < _ccName.length; i++) {
_dataSendCC.push({
commandSendId: commandSend.id,
name: _ccName[i],
createdUserId: request.user.sub,
createdFullName: request.user.name,
createdAt: new Date(),
lastUpdateUserId: request.user.sub,
lastUpdateFullName: request.user.name,
lastUpdatedAt: new Date(),
});
}
await this.commandSendCCRepository.save(_dataSendCC);
}
}
}),
);
}
if (["C-PM-10"].includes(commandCode)) { if (["C-PM-10"].includes(commandCode)) {
await Promise.all( await Promise.all(
@ -2161,7 +2157,7 @@ export class CommandController extends Controller {
const _commandSend = await this.commandSendRepository.findOne({ const _commandSend = await this.commandSendRepository.findOne({
where: { where: {
commandId: command.id, commandId: command.id,
profileId: item.profileId ?? null_, profileId: item.profileId ?? _null,
}, },
}); });
if (!_commandSend) { if (!_commandSend) {
@ -2170,14 +2166,11 @@ export class CommandController extends Controller {
commandSend.prefix = item.prefix; commandSend.prefix = item.prefix;
commandSend.firstName = item.firstName; commandSend.firstName = item.firstName;
commandSend.lastName = item.lastName; commandSend.lastName = item.lastName;
commandSend.position = commandSend.position = _posMasterDirector?.current_holder.position ?? _null;
_posMasterDirector && _posMasterDirector.positions.length > 0
? _posMasterDirector.positions[0].positionName
: null_;
commandSend.org = commandSend.org =
_posMasterDirector && _posMasterDirector.orgRoot _posMasterDirector && _posMasterDirector.orgRoot
? _posMasterDirector.orgRoot.orgRootName ? _posMasterDirector.orgRoot.orgRootName
: null_; : _null;
commandSend.profileId = item.profileId; commandSend.profileId = item.profileId;
commandSend.commandId = command.id; commandSend.commandId = command.id;
commandSend.createdUserId = request.user.sub; commandSend.createdUserId = request.user.sub;
@ -2208,6 +2201,196 @@ export class CommandController extends Controller {
}), }),
); );
} }
if (
[
"C-PM-01",
"C-PM-02",
"C-PM-03",
"C-PM-04",
"C-PM-05",
"C-PM-07",
"C-PM-08",
"C-PM-09",
"C-PM-13",
"C-PM-14",
"C-PM-15",
"C-PM-16",
"C-PM-21",
"C-PM-22",
"C-PM-24",
"C-PM-39",
].includes(commandCode)
) {
const _posMasterCommission = await this.posMasterRepository.findOne({
where: {
orgRoot: {
isCommission: true,
},
isDirector: true,
orgChild1: IsNull(),
orgRevision: { orgRevisionIsDraft: false, orgRevisionIsCurrent: true },
current_holderId: Not(IsNull()),
},
relations: ["current_holder", "orgRoot", "positions"],
});
let _commandSend = await this.commandSendRepository.findOne({
where: {
commandId: command.id,
profileId: _posMasterCommission?.current_holder.id ?? _null,
},
});
if (!_commandSend && _posMasterCommission != null) {
let commandSend = new CommandSend();
commandSend.citizenId = _posMasterCommission?.current_holder.citizenId ?? _null;
commandSend.prefix = _posMasterCommission?.current_holder.prefix ?? _null;
commandSend.firstName = _posMasterCommission?.current_holder.firstName ?? _null;
commandSend.lastName = _posMasterCommission?.current_holder.lastName ?? _null;
commandSend.position = _posMasterCommission?.current_holder.position ?? _null;
commandSend.org =
_posMasterCommission && _posMasterCommission.orgRoot
? _posMasterCommission.orgRoot.orgRootName
: _null;
commandSend.profileId = _posMasterCommission?.current_holderId ?? _null;
commandSend.commandId = command.id;
commandSend.createdUserId = request.user.sub;
commandSend.createdFullName = request.user.name;
commandSend.createdAt = new Date();
commandSend.lastUpdateUserId = request.user.sub;
commandSend.lastUpdateFullName = request.user.name;
commandSend.lastUpdatedAt = new Date();
await this.commandSendRepository.save(commandSend);
if (commandSend && commandSend.id) {
let _ccName = new Array("EMAIL", "INBOX");
let _dataSendCC = new Array();
for (let i = 0; i < _ccName.length; i++) {
_dataSendCC.push({
commandSendId: commandSend.id,
name: _ccName[i],
createdUserId: request.user.sub,
createdFullName: request.user.name,
createdAt: new Date(),
lastUpdateUserId: request.user.sub,
lastUpdateFullName: request.user.name,
lastUpdatedAt: new Date(),
});
}
await this.commandSendCCRepository.save(_dataSendCC);
}
}
const _posMasterInformation = await this.posMasterRepository.findOne({
where: {
orgChild1: {
isInformation: true,
},
isDirector: true,
orgChild2: IsNull(),
orgRevision: { orgRevisionIsDraft: false, orgRevisionIsCurrent: true },
current_holderId: Not(IsNull()),
},
relations: ["current_holder", "orgRoot", "positions"],
});
_commandSend = await this.commandSendRepository.findOne({
where: {
commandId: command.id,
profileId: _posMasterInformation?.current_holder.id ?? _null,
},
});
if (!_commandSend && _posMasterInformation != null) {
let commandSend = new CommandSend();
commandSend.citizenId = _posMasterInformation?.current_holder.citizenId ?? _null;
commandSend.prefix = _posMasterInformation?.current_holder.prefix ?? _null;
commandSend.firstName = _posMasterInformation?.current_holder.firstName ?? _null;
commandSend.lastName = _posMasterInformation?.current_holder.lastName ?? _null;
commandSend.position = _posMasterInformation?.current_holder.position ?? _null;
commandSend.org =
_posMasterInformation && _posMasterInformation.orgRoot
? _posMasterInformation.orgRoot.orgRootName
: _null;
commandSend.profileId = _posMasterInformation?.current_holderId ?? _null;
commandSend.commandId = command.id;
commandSend.createdUserId = request.user.sub;
commandSend.createdFullName = request.user.name;
commandSend.createdAt = new Date();
commandSend.lastUpdateUserId = request.user.sub;
commandSend.lastUpdateFullName = request.user.name;
commandSend.lastUpdatedAt = new Date();
await this.commandSendRepository.save(commandSend);
if (commandSend && commandSend.id) {
let _ccName = new Array("EMAIL", "INBOX");
let _dataSendCC = new Array();
for (let i = 0; i < _ccName.length; i++) {
_dataSendCC.push({
commandSendId: commandSend.id,
name: _ccName[i],
createdUserId: request.user.sub,
createdFullName: request.user.name,
createdAt: new Date(),
lastUpdateUserId: request.user.sub,
lastUpdateFullName: request.user.name,
lastUpdatedAt: new Date(),
});
}
await this.commandSendCCRepository.save(_dataSendCC);
}
}
const _posMasterOfficer = await this.posMasterRepository.findOne({
where: {
orgChild1: {
isOfficer: true,
},
isDirector: true,
orgChild2: IsNull(),
orgRevision: { orgRevisionIsDraft: false, orgRevisionIsCurrent: true },
current_holderId: Not(IsNull()),
},
relations: ["current_holder", "orgRoot", "positions"],
});
_commandSend = await this.commandSendRepository.findOne({
where: {
commandId: command.id,
profileId: _posMasterOfficer?.current_holder.id ?? _null,
},
});
if (!_commandSend && _posMasterOfficer != null) {
let commandSend = new CommandSend();
commandSend.citizenId = _posMasterOfficer?.current_holder.citizenId ?? _null;
commandSend.prefix = _posMasterOfficer?.current_holder.prefix ?? _null;
commandSend.firstName = _posMasterOfficer?.current_holder.firstName ?? _null;
commandSend.lastName = _posMasterOfficer?.current_holder.lastName ?? _null;
commandSend.position = _posMasterOfficer?.current_holder.position ?? _null;
commandSend.org =
_posMasterOfficer && _posMasterOfficer.orgRoot
? _posMasterOfficer.orgRoot.orgRootName
: _null;
commandSend.profileId = _posMasterOfficer?.current_holderId ?? _null;
commandSend.commandId = command.id;
commandSend.createdUserId = request.user.sub;
commandSend.createdFullName = request.user.name;
commandSend.createdAt = new Date();
commandSend.lastUpdateUserId = request.user.sub;
commandSend.lastUpdateFullName = request.user.name;
commandSend.lastUpdatedAt = new Date();
await this.commandSendRepository.save(commandSend);
if (commandSend && commandSend.id) {
let _ccName = new Array("EMAIL", "INBOX");
let _dataSendCC = new Array();
for (let i = 0; i < _ccName.length; i++) {
_dataSendCC.push({
commandSendId: commandSend.id,
name: _ccName[i],
createdUserId: request.user.sub,
createdFullName: request.user.name,
createdAt: new Date(),
lastUpdateUserId: request.user.sub,
lastUpdateFullName: request.user.name,
lastUpdatedAt: new Date(),
});
}
await this.commandSendCCRepository.save(_dataSendCC);
}
}
}
} }
return new HttpSuccess(command.id); return new HttpSuccess(command.id);
} }
@ -2596,7 +2779,7 @@ export class CommandController extends Controller {
if (item.isGovernment == true) { if (item.isGovernment == true) {
const returnWork = await checkReturnCommandType(String(item.commandId)); const returnWork = await checkReturnCommandType(String(item.commandId));
if (returnWork) { if (returnWork) {
profile.leaveReason = _null; profile.leaveReason = _null;
profile.leaveCommandId = _null; profile.leaveCommandId = _null;
profile.leaveCommandNo = _null; profile.leaveCommandNo = _null;
profile.leaveRemark = _null; profile.leaveRemark = _null;
@ -3133,7 +3316,7 @@ export class CommandController extends Controller {
if (item.isLeave == true) { if (item.isLeave == true) {
await removeProfileInOrganize(_profile.id, "OFFICER"); await removeProfileInOrganize(_profile.id, "OFFICER");
const exceptClear = await checkExceptCommandType(String(item.commandId)); const exceptClear = await checkExceptCommandType(String(item.commandId));
if(exceptClear.status){ if (exceptClear.status) {
_profile.leaveReason = item.leaveReason ?? _null; _profile.leaveReason = item.leaveReason ?? _null;
_profile.leaveCommandId = item.commandId ?? _null; _profile.leaveCommandId = item.commandId ?? _null;
_profile.leaveCommandNo = item.refCommandNo ?? _null; _profile.leaveCommandNo = item.refCommandNo ?? _null;
@ -3324,7 +3507,7 @@ export class CommandController extends Controller {
if (item.isLeave == true) { if (item.isLeave == true) {
await removeProfileInOrganize(_profile.id, "EMPLOYEE"); await removeProfileInOrganize(_profile.id, "EMPLOYEE");
const exceptClear = await checkExceptCommandType(String(item.commandId)); const exceptClear = await checkExceptCommandType(String(item.commandId));
if(exceptClear.status) { if (exceptClear.status) {
_profile.leaveReason = item.leaveReason ?? _null; _profile.leaveReason = item.leaveReason ?? _null;
_profile.leaveCommandId = item.commandId ?? _null; _profile.leaveCommandId = item.commandId ?? _null;
_profile.leaveCommandNo = item.refCommandNo ?? _null; _profile.leaveCommandNo = item.refCommandNo ?? _null;
@ -3551,7 +3734,7 @@ export class CommandController extends Controller {
if (item.isLeave == true) { if (item.isLeave == true) {
await removeProfileInOrganize(_profile.id, "EMPLOYEE"); await removeProfileInOrganize(_profile.id, "EMPLOYEE");
const exceptClear = await checkExceptCommandType(String(item.commandId)); const exceptClear = await checkExceptCommandType(String(item.commandId));
if(exceptClear.status) { if (exceptClear.status) {
_profile.leaveReason = item.leaveReason ?? _null; _profile.leaveReason = item.leaveReason ?? _null;
_profile.leaveCommandId = item.commandId ?? _null; _profile.leaveCommandId = item.commandId ?? _null;
_profile.leaveCommandNo = item.refCommandNo ?? _null; _profile.leaveCommandNo = item.refCommandNo ?? _null;
@ -3945,7 +4128,7 @@ export class CommandController extends Controller {
const roleKeycloak = await this.roleKeycloakRepo.findOne({ const roleKeycloak = await this.roleKeycloakRepo.findOne({
where: { name: Like("USER") }, where: { name: Like("USER") },
}); });
const null_: any = null; const _null: any = null;
await Promise.all( await Promise.all(
body.data.map(async (item) => { body.data.map(async (item) => {
const before = null; const before = null;
@ -4027,32 +4210,32 @@ export class CommandController extends Controller {
}); });
profile.registrationProvinceId = registrationProvinceId profile.registrationProvinceId = registrationProvinceId
? registrationProvinceId.id ? registrationProvinceId.id
: null_; : _null;
let registrationDistrictId = await this.districtRepo.findOneBy({ let registrationDistrictId = await this.districtRepo.findOneBy({
id: profile.registrationDistrictId, id: profile.registrationDistrictId,
}); });
profile.registrationDistrictId = registrationDistrictId profile.registrationDistrictId = registrationDistrictId
? registrationDistrictId.id ? registrationDistrictId.id
: null_; : _null;
let registrationSubDistrictId = await this.subDistrictRepo.findOneBy({ let registrationSubDistrictId = await this.subDistrictRepo.findOneBy({
id: profile.registrationSubDistrictId, id: profile.registrationSubDistrictId,
}); });
profile.registrationSubDistrictId = registrationSubDistrictId profile.registrationSubDistrictId = registrationSubDistrictId
? registrationSubDistrictId.id ? registrationSubDistrictId.id
: null_; : _null;
let currentProvinceId = await this.provinceRepo.findOneBy({ let currentProvinceId = await this.provinceRepo.findOneBy({
id: profile.currentProvinceId, id: profile.currentProvinceId,
}); });
profile.currentProvinceId = currentProvinceId ? currentProvinceId.id : null_; profile.currentProvinceId = currentProvinceId ? currentProvinceId.id : _null;
let currentDistrictId = await this.districtRepo.findOneBy({ let currentDistrictId = await this.districtRepo.findOneBy({
id: profile.currentDistrictId, id: profile.currentDistrictId,
}); });
profile.currentDistrictId = currentDistrictId ? currentDistrictId.id : null_; profile.currentDistrictId = currentDistrictId ? currentDistrictId.id : _null;
let currentSubDistrictId = await this.subDistrictRepo.findOneBy({ let currentSubDistrictId = await this.subDistrictRepo.findOneBy({
id: profile.currentSubDistrictId, id: profile.currentSubDistrictId,
}); });
profile.currentSubDistrictId = currentSubDistrictId ? currentSubDistrictId.id : null_; profile.currentSubDistrictId = currentSubDistrictId ? currentSubDistrictId.id : _null;
profile.email = item.bodyProfile.email; profile.email = item.bodyProfile.email;
profile.dateStart = item.bodyProfile.dateStart; profile.dateStart = item.bodyProfile.dateStart;
profile.amount = item.bodyProfile.amount ?? null; profile.amount = item.bodyProfile.amount ?? null;