ออกคำสั่ง
This commit is contained in:
parent
63ed0534d0
commit
3f3ec27abd
8 changed files with 268 additions and 19 deletions
|
|
@ -1329,10 +1329,10 @@ export class CommandController extends Controller {
|
|||
persons: {
|
||||
refId: string;
|
||||
profileId?: string | null;
|
||||
citizenId: string;
|
||||
prefix: string;
|
||||
firstName: string;
|
||||
lastName: string;
|
||||
citizenId: string | null;
|
||||
prefix: string | null;
|
||||
firstName: string | null;
|
||||
lastName: string | null;
|
||||
}[];
|
||||
},
|
||||
@Request() request: RequestWithUser,
|
||||
|
|
@ -2704,6 +2704,14 @@ export class CommandController extends Controller {
|
|||
}[];
|
||||
},
|
||||
) {
|
||||
const posMasters = await this.posMasterActRepository.find({
|
||||
where: { id: In(body.refIds.map((x) => x.refId)) },
|
||||
});
|
||||
const data = posMasters.map((_data) => ({
|
||||
..._data,
|
||||
statusReport: "PENDING",
|
||||
}));
|
||||
await this.posMasterActRepository.save(data);
|
||||
return new HttpSuccess();
|
||||
}
|
||||
@Post("command40/officer/report")
|
||||
|
|
@ -2714,12 +2722,12 @@ export class CommandController extends Controller {
|
|||
refIds: string[];
|
||||
},
|
||||
) {
|
||||
// const profile = await this.profileEmployeeRepository.find({ where: { id: In(body.refIds) } });
|
||||
// const data = profile.map((_data) => ({
|
||||
// ..._data,
|
||||
// statusTemp: "DONE",
|
||||
// }));
|
||||
// await this.profileEmployeeRepository.save(data);
|
||||
const posMasters = await this.posMasterActRepository.find({ where: { id: In(body.refIds) } });
|
||||
const data = posMasters.map((_data) => ({
|
||||
..._data,
|
||||
statusReport: "REPORT",
|
||||
}));
|
||||
await this.posMasterActRepository.save(data);
|
||||
return new HttpSuccess();
|
||||
}
|
||||
@Post("command40/officer/delete")
|
||||
|
|
@ -2730,12 +2738,12 @@ export class CommandController extends Controller {
|
|||
refIds: string[];
|
||||
},
|
||||
) {
|
||||
// const profile = await this.profileEmployeeRepository.find({ where: { id: In(body.refIds) } });
|
||||
// const data = profile.map((_data) => ({
|
||||
// ..._data,
|
||||
// statusTemp: "WAITTING",
|
||||
// }));
|
||||
// await this.profileEmployeeRepository.save(data);
|
||||
const posMasters = await this.posMasterActRepository.find({ where: { id: In(body.refIds) } });
|
||||
const data = posMasters.map((_data) => ({
|
||||
..._data,
|
||||
statusReport: "PENDING",
|
||||
}));
|
||||
await this.posMasterActRepository.save(data);
|
||||
return new HttpSuccess();
|
||||
}
|
||||
@Post("command40/officer/report/attachment")
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ import HttpStatusCode from "../interfaces/http-status";
|
|||
import HttpError from "../interfaces/http-error";
|
||||
import { PosMasterAct } from "../entities/PosMasterAct";
|
||||
import { PosMaster } from "../entities/PosMaster";
|
||||
import { LessThan, MoreThan } from "typeorm";
|
||||
import { Brackets, LessThan, MoreThan } from "typeorm";
|
||||
import { OrgRevision } from "../entities/OrgRevision";
|
||||
import Extension from "../interfaces/extension";
|
||||
|
||||
|
|
@ -390,4 +390,116 @@ export class PosMasterActController extends Controller {
|
|||
);
|
||||
return new HttpSuccess(data);
|
||||
}
|
||||
|
||||
/**
|
||||
* API รายชื่อตามกลุ่มในรักษาการแทน
|
||||
*
|
||||
* @summary รายชื่อตามกลุ่มในรักษาการแทน
|
||||
*
|
||||
*/
|
||||
@Post("report/draft")
|
||||
async reportDraft(
|
||||
@Body()
|
||||
body: {
|
||||
type: string;
|
||||
rootId: string;
|
||||
},
|
||||
) {
|
||||
let conditionGroup = "";
|
||||
if (body.type.trim().toUpperCase() == "GROUP1.1") {
|
||||
conditionGroup =
|
||||
"(posType.posTypeName = 'ทั่วไป' AND posLevel.posLevelName = 'ชำนาญงาน') OR (posType.posTypeName = 'ทั่วไป' AND posLevel.posLevelName = 'ปฏิบัติงาน') OR (posType.posTypeName = 'วิชาการ' AND posLevel.posLevelName = 'ปฏิบัติการ') OR (posType.posTypeName = 'วิชาการ' AND posLevel.posLevelName = 'ชำนาญการ')";
|
||||
} else if (body.type.trim().toUpperCase() == "GROUP1.2") {
|
||||
conditionGroup =
|
||||
"(posType.posTypeName = 'ทั่วไป' AND posLevel.posLevelName = 'อาวุโส') OR (posType.posTypeName = 'วิชาการ' AND posLevel.posLevelName = 'ชำนาญการพิเศษ') OR (posType.posTypeName = 'อำนวยการ' AND posLevel.posLevelName = 'ต้น')";
|
||||
} else if (body.type.trim().toUpperCase() == "GROUP2") {
|
||||
conditionGroup =
|
||||
"(posType.posTypeName = 'ทั่วไป' AND posLevel.posLevelName = 'ทักษะพิเศษ') OR (posType.posTypeName = 'วิชาการ' AND posLevel.posLevelName = 'เชี่ยวชาญ') OR (posType.posTypeName = 'วิชาการ' AND posLevel.posLevelName = 'ทรงคุณวุฒิ') OR (posType.posTypeName = 'อำนวยการ' AND posLevel.posLevelName = 'สูง') OR (posType.posTypeName = 'บริหาร' AND posLevel.posLevelName = 'ต้น') OR (posType.posTypeName = 'บริหาร' AND posLevel.posLevelName = 'สูง')";
|
||||
} else {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "กลุ่มเป้าหมายไม่ถูกต้อง");
|
||||
}
|
||||
|
||||
let posMaster = await AppDataSource.getRepository(PosMasterAct)
|
||||
.createQueryBuilder("posMasterAct")
|
||||
.leftJoinAndSelect("posMasterAct.posMasterChild", "posMasterChild")
|
||||
.leftJoinAndSelect("posMasterChild.orgRoot", "orgRoot")
|
||||
.leftJoinAndSelect("posMasterChild.orgChild1", "orgChild1")
|
||||
.leftJoinAndSelect("posMasterChild.orgChild2", "orgChild2")
|
||||
.leftJoinAndSelect("posMasterChild.orgChild3", "orgChild3")
|
||||
.leftJoinAndSelect("posMasterChild.orgChild4", "orgChild4")
|
||||
.leftJoinAndSelect("posMasterChild.current_holder", "current_holder")
|
||||
.leftJoinAndSelect("posMasterChild.positions", "positions")
|
||||
.leftJoinAndSelect("positions.posType", "posType")
|
||||
.leftJoinAndSelect("positions.posLevel", "posLevel")
|
||||
.leftJoinAndSelect("posMasterChild.orgRevision", "orgRevision")
|
||||
.andWhere("posMasterChild.orgRootId LIKE :orgRootId", {
|
||||
orgRootId: body.type.trim().toUpperCase() == "GROUP1.1" ? body.rootId : `%%`,
|
||||
})
|
||||
.andWhere("posMasterAct.statusReport = :statusReport", { statusReport: "PENDING" })
|
||||
.andWhere("posMasterChild.current_holderId IS NOT NULL")
|
||||
.andWhere("orgRevision.orgRevisionIsCurrent = :orgRevisionIsCurrent", {
|
||||
orgRevisionIsCurrent: true,
|
||||
})
|
||||
.andWhere("orgRevision.orgRevisionIsDraft = :orgRevisionIsDraft", {
|
||||
orgRevisionIsDraft: false,
|
||||
})
|
||||
.andWhere("positions.positionIsSelected = :isSelected", { isSelected: true })
|
||||
.andWhere(
|
||||
new Brackets((qb) => {
|
||||
qb.andWhere(conditionGroup);
|
||||
}),
|
||||
)
|
||||
.orderBy("posMasterChild.posMasterOrder", "ASC")
|
||||
.select([
|
||||
"posMasterAct.id",
|
||||
"posMasterChild.posMasterNo",
|
||||
"positions.positionName",
|
||||
"positions.positionIsSelected",
|
||||
"posType.posTypeName",
|
||||
"posLevel.posLevelName",
|
||||
"orgRoot.orgRootShortName",
|
||||
"orgChild1.orgChild1ShortName",
|
||||
"orgChild2.orgChild2ShortName",
|
||||
"orgChild3.orgChild3ShortName",
|
||||
"orgChild4.orgChild4ShortName",
|
||||
"current_holder.prefix",
|
||||
"current_holder.firstName",
|
||||
"current_holder.lastName",
|
||||
"current_holder.id",
|
||||
"current_holder.citizenId",
|
||||
])
|
||||
.getMany();
|
||||
const _posMaster = posMaster.map((x) => {
|
||||
const posMasterNo =
|
||||
x.posMasterChild.orgChild4 != null
|
||||
? `${x.posMasterChild.orgChild4.orgChild4ShortName}${x.posMasterChild.posMasterNo}`
|
||||
: x.posMasterChild != null && x?.posMasterChild?.orgChild3 != null
|
||||
? `${x.posMasterChild.orgChild3.orgChild3ShortName}${x.posMasterChild.posMasterNo}`
|
||||
: x.posMasterChild != null && x?.posMasterChild?.orgChild2 != null
|
||||
? `${x.posMasterChild.orgChild2.orgChild2ShortName}${x.posMasterChild.posMasterNo}`
|
||||
: x.posMasterChild != null && x?.posMasterChild?.orgChild1 != null
|
||||
? `${x.posMasterChild.orgChild1.orgChild1ShortName}${x.posMasterChild.posMasterNo}`
|
||||
: x.posMasterChild != null && x?.posMasterChild?.orgRoot != null
|
||||
? `${x.posMasterChild.orgRoot.orgRootShortName}${x.posMasterChild.posMasterNo}`
|
||||
: null;
|
||||
const position =
|
||||
x.posMasterChild.positions.filter((x) => x.positionIsSelected == true).length > 0
|
||||
? x.posMasterChild.positions.filter((x) => x.positionIsSelected == true)[0]
|
||||
: null;
|
||||
return {
|
||||
id: x.id,
|
||||
posMasterNo: posMasterNo,
|
||||
positionName: position?.positionName || null,
|
||||
posType: position?.posType?.posTypeName || null,
|
||||
posLevel: position?.posLevel?.posLevelName || null,
|
||||
profileId: x.posMasterChild?.current_holder?.id || null,
|
||||
prefix: x.posMasterChild?.current_holder?.prefix || null,
|
||||
firstName: x.posMasterChild?.current_holder?.firstName || null,
|
||||
lastName: x.posMasterChild?.current_holder?.lastName || null,
|
||||
citizenId: x.posMasterChild?.current_holder?.citizenId || null,
|
||||
};
|
||||
});
|
||||
|
||||
return new HttpSuccess(_posMaster);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4091,7 +4091,7 @@ export class PositionController extends Controller {
|
|||
.leftJoinAndSelect("positions.posLevel", "posLevel")
|
||||
.leftJoinAndSelect("posMaster.orgRevision", "orgRevision")
|
||||
.andWhere("posMaster.orgRootId LIKE :orgRootId", {
|
||||
orgRootId: body.type.trim().toUpperCase() == "GROUP1" ? body.rootId : `%%`,
|
||||
orgRootId: body.type.trim().toUpperCase() == "GROUP1.1" ? body.rootId : `%%`,
|
||||
})
|
||||
.andWhere("posMaster.statusReport = :statusReport", { statusReport: "PENDING" })
|
||||
.andWhere("posMaster.next_holderId IS NOT NULL")
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ import {
|
|||
ProfileHistory,
|
||||
CreateProfileAllFields,
|
||||
} from "../entities/Profile";
|
||||
import { Any, Brackets, IsNull, Like, Not } from "typeorm";
|
||||
import { Any, Brackets, In, IsNull, Like, Not } from "typeorm";
|
||||
import { OrgRevision } from "../entities/OrgRevision";
|
||||
import { PosMaster } from "../entities/PosMaster";
|
||||
import { PosLevel } from "../entities/PosLevel";
|
||||
|
|
@ -1224,6 +1224,112 @@ export class ProfileController extends Controller {
|
|||
|
||||
return new HttpSuccess({ caregiver, commander, chairman });
|
||||
}
|
||||
/**
|
||||
*
|
||||
*
|
||||
*/
|
||||
@Post("commander-director")
|
||||
async getProfileCommanderDirector(
|
||||
@Request() request: RequestWithUser,
|
||||
@Body() body: { isDirector: boolean },
|
||||
) {
|
||||
const posMaster = await this.posMasterRepo.findOne({
|
||||
where: {
|
||||
current_holder: { keycloak: request.user.sub },
|
||||
orgRevision: { orgRevisionIsDraft: false, orgRevisionIsCurrent: true },
|
||||
},
|
||||
});
|
||||
if (!posMaster) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลการครองตำแหน่ง");
|
||||
if (body.isDirector == true) {
|
||||
const _posMaster = await this.posMasterRepo.find({
|
||||
where: {
|
||||
orgRootId: posMaster.orgRootId || "",
|
||||
orgRevision: { orgRevisionIsDraft: false, orgRevisionIsCurrent: true },
|
||||
isDirector: true,
|
||||
current_holderId: Not(IsNull()),
|
||||
},
|
||||
relations: ["current_holder", "current_holder.posLevel", "current_holder.posType"],
|
||||
});
|
||||
const posMasterActs = await this.posMasterActRepository.find({
|
||||
where: {
|
||||
posMasterId: In(_posMaster.map((x) => x.id)),
|
||||
posMasterChild: {
|
||||
current_holderId: Not(In(_posMaster.map((x) => x.current_holderId))),
|
||||
},
|
||||
},
|
||||
relations: [
|
||||
"posMaster",
|
||||
"posMaster.current_holder",
|
||||
"posMasterChild",
|
||||
"posMasterChild.current_holder",
|
||||
"posMasterChild.current_holder.posLevel",
|
||||
"posMasterChild.current_holder.posType",
|
||||
],
|
||||
});
|
||||
let data = _posMaster.map((_data) => ({
|
||||
id: _data.current_holderId || null,
|
||||
prefix: _data.current_holder?.prefix || "",
|
||||
firstName: _data.current_holder?.firstName || "",
|
||||
lastName: _data.current_holder?.lastName || "",
|
||||
citizenId: _data.current_holder?.citizenId || "",
|
||||
position: _data.current_holder?.position || "",
|
||||
posLevel:
|
||||
_data.current_holder?.posLevel == null
|
||||
? null
|
||||
: _data.current_holder?.posLevel?.posLevelName || "",
|
||||
posType:
|
||||
_data.current_holder?.posType == null
|
||||
? null
|
||||
: _data.current_holder?.posType?.posTypeName || "",
|
||||
isDirector: _data.isDirector || false,
|
||||
actFullName: null,
|
||||
}));
|
||||
posMasterActs.map((x) => {
|
||||
let item: any = {
|
||||
id: x.posMasterChild?.current_holderId || null,
|
||||
prefix: x.posMasterChild?.current_holder?.prefix || "",
|
||||
firstName: x.posMasterChild?.current_holder?.firstName || "",
|
||||
lastName: x.posMasterChild?.current_holder?.lastName || "",
|
||||
citizenId: x.posMasterChild?.current_holder?.citizenId || "",
|
||||
position: x.posMasterChild?.current_holder?.position || "",
|
||||
posLevel: x.posMasterChild?.current_holder?.posLevel?.posLevelName || "",
|
||||
posType: x.posMasterChild?.current_holder?.posType?.posTypeName || "",
|
||||
isDirector: x.posMasterChild?.isDirector || true,
|
||||
actFullName: `${x.posMaster?.current_holder?.prefix || ""}${x.posMaster?.current_holder?.firstName || ""} ${x.posMaster?.current_holder?.lastName || ""}`,
|
||||
};
|
||||
data.push(item);
|
||||
});
|
||||
return new HttpSuccess(data);
|
||||
} else {
|
||||
const _posMaster = await this.posMasterRepo.find({
|
||||
where: {
|
||||
orgRootId: posMaster.orgRootId || "",
|
||||
orgRevision: { orgRevisionIsDraft: false, orgRevisionIsCurrent: true },
|
||||
current_holderId: Not(IsNull()),
|
||||
},
|
||||
relations: ["current_holder", "current_holder.posLevel", "current_holder.posType"],
|
||||
});
|
||||
let data = _posMaster.map((_data) => ({
|
||||
id: _data.current_holderId || null,
|
||||
prefix: _data.current_holder?.prefix || "",
|
||||
firstName: _data.current_holder?.firstName || "",
|
||||
lastName: _data.current_holder?.lastName || "",
|
||||
citizenId: _data.current_holder?.citizenId || "",
|
||||
position: _data.current_holder?.position || "",
|
||||
posLevel:
|
||||
_data.current_holder?.posLevel == null
|
||||
? null
|
||||
: _data.current_holder?.posLevel?.posLevelName || "",
|
||||
posType:
|
||||
_data.current_holder?.posType == null
|
||||
? null
|
||||
: _data.current_holder?.posType?.posTypeName || "",
|
||||
isDirector: _data.isDirector || false,
|
||||
actFullName: null,
|
||||
}));
|
||||
return new HttpSuccess(data);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* API เลือกผู้ประเมินสำหรับ User (ADMIN)
|
||||
|
|
|
|||
|
|
@ -167,6 +167,7 @@ export class ProfileEditController extends Controller {
|
|||
id: getProfileEdit.id,
|
||||
topic: getProfileEdit.topic,
|
||||
detail: getProfileEdit.detail,
|
||||
citizenId: getProfileEdit?.profile?.citizenId ?? "",
|
||||
status: getProfileEdit.status,
|
||||
remark: getProfileEdit.remark,
|
||||
createdAt: getProfileEdit.createdAt,
|
||||
|
|
|
|||
|
|
@ -173,6 +173,7 @@ export class ProfileEditEmployeeController extends Controller {
|
|||
id: getProfileEdit.id,
|
||||
topic: getProfileEdit.topic,
|
||||
detail: getProfileEdit.detail,
|
||||
citizenId: getProfileEdit?.profile?.citizenId ?? "",
|
||||
status: getProfileEdit.status,
|
||||
remark: getProfileEdit.remark,
|
||||
createdAt: getProfileEdit.createdAt,
|
||||
|
|
|
|||
|
|
@ -34,6 +34,13 @@ export class PosMasterAct extends EntityBase {
|
|||
@ManyToOne(() => PosMaster, (posMaster) => posMaster.posMasterActChilds)
|
||||
@JoinColumn({ name: "posMasterChildId" })
|
||||
posMasterChild: PosMaster;
|
||||
|
||||
@Column({
|
||||
comment: "สถานะออกคำสั่ง",
|
||||
default: "PENDING",
|
||||
length: 20,
|
||||
})
|
||||
statusReport: string;
|
||||
}
|
||||
|
||||
export class CreatePosMaster {
|
||||
|
|
|
|||
14
src/migration/1729617727307-update_root_add_isdeputy1.ts
Normal file
14
src/migration/1729617727307-update_root_add_isdeputy1.ts
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
import { MigrationInterface, QueryRunner } from "typeorm";
|
||||
|
||||
export class UpdateRootAddIsdeputy11729617727307 implements MigrationInterface {
|
||||
name = 'UpdateRootAddIsdeputy11729617727307'
|
||||
|
||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(`ALTER TABLE \`posMasterAct\` ADD \`statusReport\` varchar(20) NOT NULL COMMENT 'สถานะออกคำสั่ง' DEFAULT 'PENDING'`);
|
||||
}
|
||||
|
||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(`ALTER TABLE \`posMasterAct\` DROP COLUMN \`statusReport\``);
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue