Merge branch 'develop' into adiDev
This commit is contained in:
commit
8eae807a64
8 changed files with 2296 additions and 46 deletions
File diff suppressed because it is too large
Load diff
|
|
@ -21,6 +21,7 @@ import { PosMasterAct } from "../entities/PosMasterAct";
|
|||
import { getAllJSDocTagsOfKind } from "typescript";
|
||||
import { viewDirectorActing } from "../entities/view/viewDirectorActing";
|
||||
import { viewDirector } from "../entities/view/viewDirector";
|
||||
import { ProfileEmployee } from "../entities/ProfileEmployee";
|
||||
|
||||
@Route("api/v1/org/workflow")
|
||||
@Tags("Workflow")
|
||||
|
|
@ -32,6 +33,7 @@ export class WorkflowController extends Controller {
|
|||
private stateOperatorUserRepo = AppDataSource.getRepository(StateOperatorUser);
|
||||
private stateUserCommentRepo = AppDataSource.getRepository(StateUserComment);
|
||||
private profileRepo = AppDataSource.getRepository(Profile);
|
||||
private profileEmployeeRepo = AppDataSource.getRepository(ProfileEmployee);
|
||||
|
||||
private metaWorkflowRepo = AppDataSource.getRepository(MetaWorkflow);
|
||||
private metaStateRepo = AppDataSource.getRepository(MetaState);
|
||||
|
|
@ -51,12 +53,21 @@ export class WorkflowController extends Controller {
|
|||
posTypeName: string;
|
||||
},
|
||||
) {
|
||||
const profile = await this.profileRepo.findOne({
|
||||
let profileType = "OFFICER";
|
||||
let profile: any = await this.profileRepo.findOne({
|
||||
where: {
|
||||
keycloak: req.user.sub,
|
||||
},
|
||||
});
|
||||
if (!profile) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลผู้ใช้งาน");
|
||||
if (!profile) {
|
||||
profileType = "EMPLOYEE";
|
||||
profile = await this.profileEmployeeRepo.findOne({
|
||||
where: {
|
||||
keycloak: req.user.sub,
|
||||
},
|
||||
});
|
||||
if (!profile) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลผู้ใช้งาน");
|
||||
}
|
||||
|
||||
const metaWorkflow = await this.metaWorkflowRepo.findOne({
|
||||
where: {
|
||||
|
|
@ -81,6 +92,7 @@ export class WorkflowController extends Controller {
|
|||
id: undefined,
|
||||
...meta,
|
||||
...body,
|
||||
profileType: profileType,
|
||||
system: body.sysName,
|
||||
});
|
||||
await this.workflowRepo.save(workflow);
|
||||
|
|
@ -117,7 +129,9 @@ export class WorkflowController extends Controller {
|
|||
|
||||
const stateOperatorUser = new StateOperatorUser();
|
||||
Object.assign(stateOperatorUser, {
|
||||
profileId: profile.id,
|
||||
profileId: profileType == "OFFICER" ? profile.id : null,
|
||||
profileEmployeeId: profileType != "OFFICER" ? profile.id : null,
|
||||
profileType: profileType,
|
||||
operator: "Owner",
|
||||
order: 1,
|
||||
workflowId: workflow.id,
|
||||
|
|
@ -205,14 +219,22 @@ export class WorkflowController extends Controller {
|
|||
action: string;
|
||||
},
|
||||
) {
|
||||
const stateOperatorUser = await this.stateOperatorUserRepo.findOne({
|
||||
let stateOperatorUser = await this.stateOperatorUserRepo.findOne({
|
||||
where: {
|
||||
profileId: body.profileId,
|
||||
workflowId: body.workflowId,
|
||||
},
|
||||
});
|
||||
if (!stateOperatorUser)
|
||||
throw new HttpError(HttpStatus.NOT_FOUND, "ผู้ใช้งานนี้ไม่มีหน้าที่ในกระบวนการนี้");
|
||||
if (!stateOperatorUser) {
|
||||
stateOperatorUser = await this.stateOperatorUserRepo.findOne({
|
||||
where: {
|
||||
profileEmployeeId: body.profileId,
|
||||
workflowId: body.workflowId,
|
||||
},
|
||||
});
|
||||
if (!stateOperatorUser)
|
||||
throw new HttpError(HttpStatus.NOT_FOUND, "ผู้ใช้งานนี้ไม่มีหน้าที่ในกระบวนการนี้");
|
||||
}
|
||||
|
||||
const operator = await this.stateOperatorRepo.findOne({
|
||||
where: {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue