Merge branch 'develop' into develop-Bright

# Conflicts:
#	src/controllers/ReportController.ts
This commit is contained in:
Bright 2024-11-19 18:09:28 +07:00
commit 3803e593a5
10 changed files with 2358 additions and 9 deletions

View file

@ -1121,7 +1121,15 @@ export class PositionController extends Controller {
const positions = await this.positionRepository.find({
where: { posMasterId: posMaster.id },
relations: ["posType", "posLevel", "posExecutive"],
order: { lastUpdatedAt: "ASC" },
// order: { lastUpdatedAt: "ASC" },
order: {
posType: {
posTypeRank: "ASC"
},
posLevel: {
posLevelRank: "ASC"
}
},
});
const formattedData = {
id: posMaster.id,

View file

@ -4310,6 +4310,8 @@ export class ProfileController extends Controller {
)
.skip((requestBody.page - 1) * requestBody.pageSize)
.take(requestBody.pageSize)
.orderBy("posType.posTypeRank", "ASC")
.addOrderBy("posLevel.posLevelRank", "ASC")
.getManyAndCount();
const data = profiles.map((_data) => ({

File diff suppressed because it is too large Load diff

View file

@ -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: {

View file

@ -34,6 +34,7 @@ import { ProfileEdit } from "./ProfileEdit";
import { ProfileDevelopment } from "./ProfileDevelopment";
import { DevelopmentRequest } from "./DevelopmentRequest";
import { RoleKeycloak } from "./RoleKeycloak";
import { StateOperatorUser } from "./StateOperatorUser";
@Entity("profileEmployee")
export class ProfileEmployee extends EntityBase {
@ -695,6 +696,9 @@ export class ProfileEmployee extends EntityBase {
@OneToMany(() => ProfileFamilyCouple, (v) => v.profile)
profileFamilyCouple: ProfileFamilyCouple[];
@OneToMany(() => StateOperatorUser, (v) => v.profile)
stateOperatorUsers: StateOperatorUser[];
//ที่อยู่
@Column({
nullable: true,

View file

@ -13,6 +13,14 @@ export class RoleKeycloak extends EntityBase {
})
name: string;
@Column({
nullable: true,
comment: "คำอธิบาย",
length: 255,
default: null,
})
description: string;
@ManyToMany(() => Profile, (profile) => profile.roleKeycloaks)
profiles: Profile[];

View file

@ -2,6 +2,7 @@ import { Entity, Column, ManyToOne, JoinColumn } from "typeorm";
import { EntityBase } from "./base/Base";
import { Workflow } from "./Workflow";
import { Profile } from "./Profile";
import { ProfileEmployee } from "./ProfileEmployee";
@Entity("stateOperatorUser")
export class StateOperatorUser extends EntityBase {
@ -13,6 +14,14 @@ export class StateOperatorUser extends EntityBase {
})
operator: string;
@Column({
nullable: true,
comment: "ผู้ใช้งาน",
length: 255,
default: null,
})
profileType: string;
@Column({
nullable: true,
comment: "ลำดับ",
@ -44,4 +53,17 @@ export class StateOperatorUser extends EntityBase {
@ManyToOne(() => Profile, (profile) => profile.stateOperatorUsers)
@JoinColumn({ name: "profileId" })
profile: Profile;
@Column({
nullable: true,
length: 40,
comment: "คีย์นอก(FK)ของตาราง profileEmployee",
type: "uuid",
default: null,
})
profileEmployeeId: string;
@ManyToOne(() => ProfileEmployee, (profileEmployee) => profileEmployee.stateOperatorUsers)
@JoinColumn({ name: "profileEmployeeId" })
profileEmployee: ProfileEmployee;
}

View file

@ -13,6 +13,14 @@ export class Workflow extends EntityBase {
})
refId: string;
@Column({
nullable: true,
comment: "ผู้ใช้งาน",
length: 255,
default: null,
})
profileType: string;
@Column({
nullable: true,
comment: "ชื่อ flow",

View file

@ -0,0 +1,20 @@
import { MigrationInterface, QueryRunner } from "typeorm";
export class UpdataWorkflowAddRmployee1731941837869 implements MigrationInterface {
name = 'UpdataWorkflowAddRmployee1731941837869'
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE \`workflow\` ADD \`profileType\` varchar(255) NULL COMMENT 'ผู้ใช้งาน'`);
await queryRunner.query(`ALTER TABLE \`stateOperatorUser\` ADD \`profileType\` varchar(255) NULL COMMENT 'ผู้ใช้งาน'`);
await queryRunner.query(`ALTER TABLE \`stateOperatorUser\` ADD \`profileEmployeeId\` varchar(40) NULL COMMENT 'คีย์นอก(FK)ของตาราง profileEmployee'`);
await queryRunner.query(`ALTER TABLE \`stateOperatorUser\` ADD CONSTRAINT \`FK_7039ce6f8c316e5bbdc879e801b\` FOREIGN KEY (\`profileEmployeeId\`) REFERENCES \`profileEmployee\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
}
public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE \`stateOperatorUser\` DROP FOREIGN KEY \`FK_7039ce6f8c316e5bbdc879e801b\``);
await queryRunner.query(`ALTER TABLE \`stateOperatorUser\` DROP COLUMN \`profileEmployeeId\``);
await queryRunner.query(`ALTER TABLE \`stateOperatorUser\` DROP COLUMN \`profileType\``);
await queryRunner.query(`ALTER TABLE \`workflow\` DROP COLUMN \`profileType\``);
}
}

View file

@ -0,0 +1,14 @@
import { MigrationInterface, QueryRunner } from "typeorm";
export class UpdataWorkflowAddRmployee11731987222018 implements MigrationInterface {
name = 'UpdataWorkflowAddRmployee11731987222018'
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE \`roleKeycloak\` ADD \`description\` varchar(255) NULL COMMENT 'คำอธิบาย'`);
}
public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE \`roleKeycloak\` DROP COLUMN \`description\``);
}
}