fix bug #2183
All checks were successful
Build & Deploy on Dev / build (push) Successful in 1m22s
All checks were successful
Build & Deploy on Dev / build (push) Successful in 1m22s
This commit is contained in:
parent
6a07841763
commit
5ef5f7d4ed
2 changed files with 16 additions and 12 deletions
|
|
@ -4040,10 +4040,12 @@ export class CommandController extends Controller {
|
||||||
where: { refId: item.resignId },
|
where: { refId: item.resignId },
|
||||||
relations: { command: true },
|
relations: { command: true },
|
||||||
});
|
});
|
||||||
const executeDate = commandResign ? new Date(commandResign.command.commandExcecuteDate).setHours(0,0,0,0) : today;
|
const executeDate = commandResign
|
||||||
if (_command.status != "REPORTED"
|
? new Date(commandResign.command.commandExcecuteDate).setHours(0,0,0,0)
|
||||||
&& (_command.status != "WAITING" || today < executeDate)) {
|
: today;
|
||||||
await reOrderCommandRecivesAndDelete(commandResign!.refId);
|
if (commandResign && _command.status !== "REPORTED" &&
|
||||||
|
(_command.status !== "WAITING" || today < executeDate)) {
|
||||||
|
await reOrderCommandRecivesAndDelete(commandResign!.id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
let _commandYear = item.commandYear;
|
let _commandYear = item.commandYear;
|
||||||
|
|
@ -4377,6 +4379,7 @@ export class CommandController extends Controller {
|
||||||
let _posNumCodeSitAbb: string = "";
|
let _posNumCodeSitAbb: string = "";
|
||||||
const _command = await this.commandRepository.findOne({
|
const _command = await this.commandRepository.findOne({
|
||||||
where: { id: body.data.find((x) => x.commandId)?.commandId ?? "" },
|
where: { id: body.data.find((x) => x.commandId)?.commandId ?? "" },
|
||||||
|
relations: { commandType: true },
|
||||||
});
|
});
|
||||||
if (_command) {
|
if (_command) {
|
||||||
if (_command?.isBangkok?.toLocaleUpperCase() == "OFFICE") {
|
if (_command?.isBangkok?.toLocaleUpperCase() == "OFFICE") {
|
||||||
|
|
@ -4438,9 +4441,11 @@ export class CommandController extends Controller {
|
||||||
where: { refId: item.resignId },
|
where: { refId: item.resignId },
|
||||||
relations: { command: true },
|
relations: { command: true },
|
||||||
});
|
});
|
||||||
const executeDate = commandResign ? new Date(commandResign.command.commandExcecuteDate).setHours(0,0,0,0) : today;
|
const executeDate = commandResign
|
||||||
if (_command.status != "REPORTED"
|
? new Date(commandResign.command.commandExcecuteDate).setHours(0,0,0,0)
|
||||||
&& (_command.status !== "WAITING" || today < executeDate)) {
|
: today;
|
||||||
|
if (commandResign && _command.status !== "REPORTED" &&
|
||||||
|
(_command.status !== "WAITING" || today < executeDate)) {
|
||||||
await reOrderCommandRecivesAndDelete(commandResign!.id);
|
await reOrderCommandRecivesAndDelete(commandResign!.id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -4,20 +4,19 @@ import { Command } from "../entities/Command";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* เรียงลำดับผู้ได้รับคำสั่งใหม่หลังจากลบรายการ และอัพเดทสถานะคำสั่งถ้าไม่มีผู้ได้รับคำสั่งเหลือ
|
* เรียงลำดับผู้ได้รับคำสั่งใหม่หลังจากลบรายการ และอัพเดทสถานะคำสั่งถ้าไม่มีผู้ได้รับคำสั่งเหลือ
|
||||||
* @param refId refId ของผู้ได้รับคำสั่ง
|
* @param reciveId commandRecive.Id ของผู้ได้รับคำสั่ง
|
||||||
* @param code ประเภทคำสั่ง
|
* @param code ประเภทคำสั่ง
|
||||||
* @returns Promise<void>
|
* @returns Promise<void>
|
||||||
*/
|
*/
|
||||||
export async function reOrderCommandRecivesAndDelete(
|
export async function reOrderCommandRecivesAndDelete(
|
||||||
refId: string
|
reciveId: string
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
const commandReciveRepo = AppDataSource.getRepository(CommandRecive);
|
const commandReciveRepo = AppDataSource.getRepository(CommandRecive);
|
||||||
const commandRepo = AppDataSource.getRepository(Command);
|
const commandRepo = AppDataSource.getRepository(Command);
|
||||||
|
|
||||||
// ค้นหาข้อมูลผู้ได้รับคำสั่งตาม refId
|
// ค้นหาข้อมูลผู้ได้รับคำสั่งตาม reciveId
|
||||||
const commandRecive = await commandReciveRepo.findOne({
|
const commandRecive = await commandReciveRepo.findOne({
|
||||||
where: { refId: refId },
|
where: { id: reciveId }
|
||||||
relations: { command: true},
|
|
||||||
});
|
});
|
||||||
|
|
||||||
if (commandRecive == null)
|
if (commandRecive == null)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue