หาผู้บังคับบัญชา
This commit is contained in:
parent
b933666c8d
commit
7cada3195d
1 changed files with 45 additions and 5 deletions
|
|
@ -1,4 +1,4 @@
|
|||
import { Body, Controller, Post, Request, Route, Security, Tags } from "tsoa";
|
||||
import { Body, Controller, Get, Path, Post, Request, Route, Security, Tags } from "tsoa";
|
||||
import { AppDataSource } from "../database/data-source";
|
||||
import { RequestWithUser } from "../middlewares/user";
|
||||
import HttpError from "../interfaces/http-error";
|
||||
|
|
@ -16,7 +16,7 @@ import { MetaState } from "../entities/MetaState";
|
|||
import { MetaStateOperator } from "../entities/MetaStateOperator";
|
||||
import { PosMasterAssign } from "../entities/PosMasterAssign";
|
||||
import { PosMaster } from "../entities/PosMaster";
|
||||
import { Not } from "typeorm";
|
||||
import { IsNull, Not } from "typeorm";
|
||||
|
||||
@Route("api/v1/org/workflow")
|
||||
@Tags("Workflow")
|
||||
|
|
@ -131,7 +131,7 @@ export class WorkflowController extends Controller {
|
|||
if (item.orgChild1 == null || item.orgChild1.isOfficer == false) {
|
||||
const stateOperatorUser = new StateOperatorUser();
|
||||
Object.assign(stateOperatorUser, {
|
||||
profileId: profile.id,
|
||||
profileId: item.current_holderId,
|
||||
operator: "Officer",
|
||||
order: i + 2,
|
||||
workflowId: workflow.id,
|
||||
|
|
@ -141,7 +141,7 @@ export class WorkflowController extends Controller {
|
|||
} else {
|
||||
const stateOperatorUser = new StateOperatorUser();
|
||||
Object.assign(stateOperatorUser, {
|
||||
profileId: profile.id,
|
||||
profileId: item.current_holderId,
|
||||
operator: "PersonnelOfficer",
|
||||
order: i + 2,
|
||||
workflowId: workflow.id,
|
||||
|
|
@ -266,7 +266,8 @@ export class WorkflowController extends Controller {
|
|||
});
|
||||
if (!stateOperatorUser)
|
||||
throw new HttpError(HttpStatus.NOT_FOUND, "ผู้ใช้งานนี้ไม่มีหน้าที่ในกระบวนการนี้");
|
||||
|
||||
console.log(stateOperatorUser.operator);
|
||||
console.log(stateOperatorUser.workflow.stateId);
|
||||
const operator = await this.stateOperatorRepo.findOne({
|
||||
where: {
|
||||
operator: stateOperatorUser.operator,
|
||||
|
|
@ -586,4 +587,43 @@ export class WorkflowController extends Controller {
|
|||
profileId: stateUserComment?.profileId || null,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
*/
|
||||
@Get("commander")
|
||||
async getProfilePlacement(@Request() req: RequestWithUser) {
|
||||
const posMasterUser = await this.posMasterRepo.findOne({
|
||||
where: {
|
||||
orgRevision: { orgRevisionIsCurrent: false, orgRevisionIsDraft: true },
|
||||
current_holder: { keycloak: req.user.sub },
|
||||
},
|
||||
});
|
||||
if (!posMasterUser || !posMasterUser.orgRootId)
|
||||
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบตำแหน่งผู้ใช้งาน");
|
||||
|
||||
const posMasters = await this.posMasterRepo.find({
|
||||
where: {
|
||||
orgRevision: { orgRevisionIsCurrent: false, orgRevisionIsDraft: true },
|
||||
isDirector: true,
|
||||
current_holderId: Not(IsNull()),
|
||||
orgRootId: posMasterUser.orgRootId,
|
||||
},
|
||||
relations: ["current_holder", "orgRoot"],
|
||||
});
|
||||
|
||||
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,
|
||||
orgRoot: data.orgRoot.orgRootName,
|
||||
}));
|
||||
|
||||
return new HttpSuccess(_posMasters);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue