no message
This commit is contained in:
parent
32b0aa325d
commit
4ffb2c008b
2 changed files with 123 additions and 16 deletions
|
|
@ -210,7 +210,7 @@ export class ProfileEditController extends Controller {
|
||||||
await new CallAPI()
|
await new CallAPI()
|
||||||
.PostData(req, "/org/workflow/add-workflow", {
|
.PostData(req, "/org/workflow/add-workflow", {
|
||||||
refId: data.id,
|
refId: data.id,
|
||||||
sysName: "SYS_REGISTRY_OFFICER",
|
sysName: "REGISTRY_PROFILE",
|
||||||
posLevelName: profile.posLevel.posLevelName,
|
posLevelName: profile.posLevel.posLevelName,
|
||||||
posTypeName: profile.posType.posTypeName,
|
posTypeName: profile.posType.posTypeName,
|
||||||
})
|
})
|
||||||
|
|
|
||||||
|
|
@ -15,8 +15,10 @@ import { MetaWorkflow } from "../entities/MetaWorkflow";
|
||||||
import { MetaState } from "../entities/MetaState";
|
import { MetaState } from "../entities/MetaState";
|
||||||
import { MetaStateOperator } from "../entities/MetaStateOperator";
|
import { MetaStateOperator } from "../entities/MetaStateOperator";
|
||||||
import { PosMaster } from "../entities/PosMaster";
|
import { PosMaster } from "../entities/PosMaster";
|
||||||
import { IsNull, Not } from "typeorm";
|
import { In, IsNull, Not } from "typeorm";
|
||||||
import { Assign } from "../entities/Assign";
|
import { Assign } from "../entities/Assign";
|
||||||
|
import { PosMasterAct } from "../entities/PosMasterAct";
|
||||||
|
import { getAllJSDocTagsOfKind } from "typescript";
|
||||||
|
|
||||||
@Route("api/v1/org/workflow")
|
@Route("api/v1/org/workflow")
|
||||||
@Tags("Workflow")
|
@Tags("Workflow")
|
||||||
|
|
@ -33,6 +35,7 @@ export class WorkflowController extends Controller {
|
||||||
private metaStateRepo = AppDataSource.getRepository(MetaState);
|
private metaStateRepo = AppDataSource.getRepository(MetaState);
|
||||||
private metaStateOperatorRepo = AppDataSource.getRepository(MetaStateOperator);
|
private metaStateOperatorRepo = AppDataSource.getRepository(MetaStateOperator);
|
||||||
private posMasterRepo = AppDataSource.getRepository(PosMaster);
|
private posMasterRepo = AppDataSource.getRepository(PosMaster);
|
||||||
|
private posMasterActRepo = AppDataSource.getRepository(PosMasterAct);
|
||||||
private assignRepo = AppDataSource.getRepository(Assign);
|
private assignRepo = AppDataSource.getRepository(Assign);
|
||||||
|
|
||||||
@Post("add-workflow")
|
@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) {
|
async getProfilePlacement(@Request() req: RequestWithUser, @Path() type: string) {
|
||||||
const posMasterUser = await this.posMasterRepo.findOne({
|
const posMasterUser = await this.posMasterRepo.findOne({
|
||||||
where: {
|
where: {
|
||||||
orgRevision: { orgRevisionIsCurrent: true, orgRevisionIsDraft: false },
|
orgRevision: { orgRevisionIsCurrent: true, orgRevisionIsDraft: false },
|
||||||
current_holder: { keycloak: req.user.sub },
|
current_holder: { keycloak: req.user.sub },
|
||||||
},
|
},
|
||||||
|
relations: ["current_holder", "current_holder.posType", "current_holder.posLevel"],
|
||||||
});
|
});
|
||||||
if (!posMasterUser || !posMasterUser.orgRootId)
|
if (!posMasterUser || !posMasterUser.orgRootId)
|
||||||
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบตำแหน่งผู้ใช้งาน");
|
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบตำแหน่งผู้ใช้งาน");
|
||||||
|
let _posMasters = [];
|
||||||
const posMasters = await this.posMasterRepo.find({
|
let sortPosmaster: any = {
|
||||||
where: {
|
where: {
|
||||||
orgRevision: { orgRevisionIsCurrent: true, orgRevisionIsDraft: false },
|
orgRevision: { orgRevisionIsCurrent: true, orgRevisionIsDraft: false },
|
||||||
isDirector: true,
|
isDirector: true,
|
||||||
current_holderId: Not(IsNull()),
|
current_holderId: Not(IsNull()),
|
||||||
orgRootId: posMasterUser.orgRootId,
|
orgRootId: posMasterUser.orgRootId,
|
||||||
},
|
},
|
||||||
relations: ["current_holder"],
|
relations: [
|
||||||
});
|
"current_holder",
|
||||||
|
"current_holder.posLevel",
|
||||||
|
"current_holder.posType",
|
||||||
|
"positions",
|
||||||
|
"positions.posExecutive",
|
||||||
|
],
|
||||||
|
};
|
||||||
|
|
||||||
let _posMasters = posMasters.map((data) => ({
|
if (type.trim().toLowerCase() == "OPERATE") {
|
||||||
id: data.current_holderId,
|
} else {
|
||||||
prefix: data.current_holder.prefix,
|
if (
|
||||||
firstName: data.current_holder.firstName,
|
(posMasterUser.current_holder.posType.posTypeName == "ทั่วไป" &&
|
||||||
lastName: data.current_holder.lastName,
|
posMasterUser.current_holder.posLevel.posLevelName == "ชำนาญงาน") ||
|
||||||
position: data.current_holder.position,
|
(posMasterUser.current_holder.posType.posTypeName == "ทั่วไป" &&
|
||||||
posLevel: data.current_holder.posLevel,
|
posMasterUser.current_holder.posLevel.posLevelName == "ปฏิบัติงาน") ||
|
||||||
posType: data.current_holder.posType,
|
(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);
|
return new HttpSuccess(_posMasters);
|
||||||
}
|
}
|
||||||
|
|
@ -727,7 +834,7 @@ export class WorkflowController extends Controller {
|
||||||
where: {
|
where: {
|
||||||
states: { stateUserComments: { profile: { keycloak: req.user.sub } } },
|
states: { stateUserComments: { profile: { keycloak: req.user.sub } } },
|
||||||
refId: body.refId,
|
refId: body.refId,
|
||||||
sysName: body.sysName,
|
// sysName: body.sysName,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
if (!profileOfficer) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลสิทธิ์");
|
if (!profileOfficer) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลสิทธิ์");
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue