#1305 ลบ posMasterAct

This commit is contained in:
AdisakKanthawilang 2025-07-25 17:54:26 +07:00
parent c297572c79
commit 018aae2c57
3 changed files with 57 additions and 3 deletions

View file

@ -42,6 +42,7 @@ import {
checkReturnCommandType,
checkExceptCommandType,
checkCommandType,
removePostMasterAct,
} from "../interfaces/utils";
import { Position } from "../entities/Position";
import { PosMaster } from "../entities/PosMaster";
@ -3381,6 +3382,7 @@ export class CommandController extends Controller {
let _posNumCodeSit: string = "";
let _posNumCodeSitAbb: string = "";
const _command = await this.commandRepository.findOne({
relations: ["commandType"],
where: { id: body.data.find((x) => x.commandId)?.commandId ?? "" },
});
if (_command) {
@ -3430,6 +3432,11 @@ export class CommandController extends Controller {
if (!profile) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลทะเบียนประวัตินี้");
}
//ลบตำแหน่งที่รักษาการแทน
const code = _command?.commandType?.code;
if(code && ["C-PM-08","C-PM-17", "C-PM-18"].includes(code)){
removePostMasterAct(profile.id);
}
let _commandYear = item.commandYear;
if (item.commandYear) {
_commandYear = item.commandYear > 2500 ? item.commandYear : item.commandYear + 543;
@ -3492,6 +3499,7 @@ export class CommandController extends Controller {
// profile.posTypeId = _null;
// profile.posLevelId = _null;
}
if (item.isGovernment == true) {
if (returnWork) {
//ปลดตำแหน่งเดิมที่ไม่ถูกปลดออกจากกิ่งครั้งเมื่อออกคำสั่งพักราชการหรือออกราชการไว้
@ -3499,7 +3507,8 @@ export class CommandController extends Controller {
//ปั๊มตำแหน่งใหม่
const posMaster = await this.posMasterRepository.findOne({
where: { id: item.posmasterId?.toString() },
});
});
if (posMaster) {
const checkPosition = await this.positionRepository.find({
where: {
@ -3846,6 +3855,7 @@ export class CommandController extends Controller {
let _posNumCodeSit: string = "";
let _posNumCodeSitAbb: string = "";
const _command = await this.commandRepository.findOne({
relations: ["commandType"],
where: { id: body.data.find((x) => x.commandId)?.commandId ?? "" },
});
if (_command) {
@ -3895,6 +3905,13 @@ export class CommandController extends Controller {
if (!profile) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลทะเบียนประวัตินี้");
}
//ลบตำแหน่งที่รักษาการแทน
const code = _command?.commandType?.code;
if(code && ["C-PM-13"].includes(code)){
removePostMasterAct(profile.id);
}
let _commandYear = item.commandYear;
if (item.commandYear) {
_commandYear = item.commandYear > 2500 ? item.commandYear : item.commandYear + 543;
@ -4159,6 +4176,7 @@ export class CommandController extends Controller {
let _posNumCodeSit: string = "";
let _posNumCodeSitAbb: string = "";
const _command = await this.commandRepository.findOne({
relations: ["commandType"],
where: { id: body.data.find((x) => x.commandId)?.commandId ?? "" },
});
if (_command) {
@ -4231,6 +4249,13 @@ export class CommandController extends Controller {
if (!profile) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลทะเบียนประวัตินี้");
}
//ลบตำแหน่งที่รักษาการแทน
const code = _command?.commandType?.code;
if(code && ["C-PM-19", "C-PM-20"].includes(code)){
removePostMasterAct(profile.id);
}
const orgRevision = await this.orgRevisionRepo.findOne({
where: {
orgRevisionIsCurrent: true,

View file

@ -26,7 +26,7 @@ import { PosMaster } from "../entities/PosMaster";
import { Profile } from "../entities/Profile";
import { RequestWithUser } from "../middlewares/user";
import permission from "../interfaces/permission";
import { setLogDataDiff } from "../interfaces/utils";
import { checkQueueInProgress, setLogDataDiff } from "../interfaces/utils";
import { sendToQueueOrg, sendToQueueOrgDraft } from "../services/rabbitmq";
import { PosType } from "../entities/PosType";
import { PosLevel } from "../entities/PosLevel";
@ -3255,7 +3255,7 @@ export class OrganizationController extends Controller {
user: request.user,
token: request.headers["authorization"],
};
sendToQueueOrg(msg);
await sendToQueueOrg(msg);
return new HttpSuccess();
} catch (error: any) {
if (error?.status && error?.message) {