no message

This commit is contained in:
kittapath 2024-10-22 11:59:12 +07:00
parent 32b0aa325d
commit 4ffb2c008b
2 changed files with 123 additions and 16 deletions

View file

@ -210,7 +210,7 @@ export class ProfileEditController extends Controller {
await new CallAPI()
.PostData(req, "/org/workflow/add-workflow", {
refId: data.id,
sysName: "SYS_REGISTRY_OFFICER",
sysName: "REGISTRY_PROFILE",
posLevelName: profile.posLevel.posLevelName,
posTypeName: profile.posType.posTypeName,
})

View file

@ -15,8 +15,10 @@ import { MetaWorkflow } from "../entities/MetaWorkflow";
import { MetaState } from "../entities/MetaState";
import { MetaStateOperator } from "../entities/MetaStateOperator";
import { PosMaster } from "../entities/PosMaster";
import { IsNull, Not } from "typeorm";
import { In, IsNull, Not } from "typeorm";
import { Assign } from "../entities/Assign";
import { PosMasterAct } from "../entities/PosMasterAct";
import { getAllJSDocTagsOfKind } from "typescript";
@Route("api/v1/org/workflow")
@Tags("Workflow")
@ -33,6 +35,7 @@ export class WorkflowController extends Controller {
private metaStateRepo = AppDataSource.getRepository(MetaState);
private metaStateOperatorRepo = AppDataSource.getRepository(MetaStateOperator);
private posMasterRepo = AppDataSource.getRepository(PosMaster);
private posMasterActRepo = AppDataSource.getRepository(PosMasterAct);
private assignRepo = AppDataSource.getRepository(Assign);
@Post("add-workflow")
@ -639,36 +642,140 @@ export class WorkflowController extends Controller {
*
*
*/
@Get("commander/{type}") //xxxxxxxxxxxxxxxxxx
@Get("commander/{type}")
async getProfilePlacement(@Request() req: RequestWithUser, @Path() type: string) {
const posMasterUser = await this.posMasterRepo.findOne({
where: {
orgRevision: { orgRevisionIsCurrent: true, orgRevisionIsDraft: false },
current_holder: { keycloak: req.user.sub },
},
relations: ["current_holder", "current_holder.posType", "current_holder.posLevel"],
});
if (!posMasterUser || !posMasterUser.orgRootId)
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบตำแหน่งผู้ใช้งาน");
const posMasters = await this.posMasterRepo.find({
let _posMasters = [];
let sortPosmaster: any = {
where: {
orgRevision: { orgRevisionIsCurrent: true, orgRevisionIsDraft: false },
isDirector: true,
current_holderId: Not(IsNull()),
orgRootId: posMasterUser.orgRootId,
},
relations: ["current_holder"],
});
relations: [
"current_holder",
"current_holder.posLevel",
"current_holder.posType",
"positions",
"positions.posExecutive",
],
};
let _posMasters = posMasters.map((data) => ({
id: data.current_holderId,
prefix: data.current_holder.prefix,
firstName: data.current_holder.firstName,
lastName: data.current_holder.lastName,
position: data.current_holder.position,
posLevel: data.current_holder.posLevel,
posType: data.current_holder.posType,
if (type.trim().toLowerCase() == "OPERATE") {
} else {
if (
(posMasterUser.current_holder.posType.posTypeName == "ทั่วไป" &&
posMasterUser.current_holder.posLevel.posLevelName == "ชำนาญงาน") ||
(posMasterUser.current_holder.posType.posTypeName == "ทั่วไป" &&
posMasterUser.current_holder.posLevel.posLevelName == "ปฏิบัติงาน") ||
(posMasterUser.current_holder.posType.posTypeName == "วิชาการ" &&
posMasterUser.current_holder.posLevel.posLevelName == "ปฏิบัติการ") ||
(posMasterUser.current_holder.posType.posTypeName == "วิชาการ" &&
posMasterUser.current_holder.posLevel.posLevelName == "ชำนาญการ")
) {
sortPosmaster = {
where: {
orgRevision: { orgRevisionIsCurrent: true, orgRevisionIsDraft: false },
isDirector: true,
current_holderId: Not(IsNull()),
orgRootId: posMasterUser.orgRootId,
orgChild1Id: IsNull(),
orgChild2Id: IsNull(),
orgChild3Id: IsNull(),
orgChild4Id: IsNull(),
},
relations: [
"current_holder",
"current_holder.posLevel",
"current_holder.posType",
"positions",
"positions.posExecutive",
],
};
} else if (
(posMasterUser.current_holder.posType.posTypeName == "ทั่วไป" &&
posMasterUser.current_holder.posLevel.posLevelName == "อาวุโส") ||
(posMasterUser.current_holder.posType.posTypeName == "วิชาการ" &&
posMasterUser.current_holder.posLevel.posLevelName == "ชำนาญการพิเศษ") ||
(posMasterUser.current_holder.posType.posTypeName == "อำนวยการ" &&
posMasterUser.current_holder.posLevel.posLevelName == "ต้น")
) {
sortPosmaster = {
where: {
orgRevision: { orgRevisionIsCurrent: true, orgRevisionIsDraft: false },
isDirector: true,
current_holderId: Not(IsNull()),
orgRoot: {
isDeputy: true,
},
orgChild1Id: IsNull(),
orgChild2Id: IsNull(),
orgChild3Id: IsNull(),
orgChild4Id: IsNull(),
},
relations: [
"current_holder",
"current_holder.posLevel",
"current_holder.posType",
"positions",
"positions.posExecutive",
],
};
} else {
}
}
const posMasters = await this.posMasterRepo.find(sortPosmaster);
_posMasters = posMasters.map((data) => ({
id: data.current_holderId || null,
prefix: data.current_holder?.prefix || null,
firstName: data.current_holder?.firstName || null,
lastName: data.current_holder?.lastName || null,
position: data.current_holder?.position || null,
posLevel: data.current_holder?.posLevel?.posLevelName || null,
posType: data.current_holder?.posType?.posTypeName || null,
posExecutiveName:
data.positions?.filter((x) => x.positionIsSelected == true)[0]?.posExecutive
?.posExecutiveName || null,
actFullName: null,
}));
const posMasterActs = await this.posMasterActRepo.find({
where: { posMasterId: In(posMasters.map((x) => x.id)) },
relations: [
"posMaster",
"posMaster.current_holder",
"posMasterChild",
"posMasterChild.positions",
"posMasterChild.positions.posExecutive",
"posMasterChild.current_holder",
"posMasterChild.current_holder.posLevel",
"posMasterChild.current_holder.posType",
],
});
posMasterActs.map((x) => {
let item: any = {
id: x.posMaster?.current_holderId || null,
prefix: x.posMasterChild?.current_holder?.prefix || "",
firstName: x.posMasterChild?.current_holder?.firstName || "",
lastName: x.posMasterChild?.current_holder?.lastName || "",
position: x.posMasterChild?.current_holder?.position || "",
posLevel: x.posMasterChild?.current_holder?.posLevel?.posLevelName || "",
posType: x.posMasterChild?.current_holder?.posType?.posTypeName || "",
posExecutiveName:
x.posMasterChild?.positions?.filter((x) => x.positionIsSelected == true)[0]?.posExecutive
?.posExecutiveName || "",
actFullName: `${x.posMaster?.current_holder?.prefix || ""}${x.posMaster?.current_holder?.firstName || ""} ${x.posMaster?.current_holder?.lastName || ""}`,
};
_posMasters.push(item);
});
return new HttpSuccess(_posMasters);
}
@ -727,7 +834,7 @@ export class WorkflowController extends Controller {
where: {
states: { stateUserComments: { profile: { keycloak: req.user.sub } } },
refId: body.refId,
sysName: body.sysName,
// sysName: body.sysName,
},
});
if (!profileOfficer) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลสิทธิ์");