Merge branch 'develop' into adiDev
This commit is contained in:
commit
ca45bb780c
3 changed files with 102 additions and 45 deletions
|
|
@ -1,6 +1,6 @@
|
||||||
import { Controller, Post, Route, Security, Tags, Request, UploadedFile } from "tsoa";
|
import { Controller, Post, Route, Security, Tags, Request, UploadedFile } from "tsoa";
|
||||||
import { AppDataSource } from "../database/data-source";
|
import { AppDataSource } from "../database/data-source";
|
||||||
import { In, IsNull, Not } from "typeorm";
|
import { In, IsNull, LessThanOrEqual, Not } from "typeorm";
|
||||||
import HttpSuccess from "../interfaces/http-success";
|
import HttpSuccess from "../interfaces/http-success";
|
||||||
import { UseInterceptors } from "@nestjs/common";
|
import { UseInterceptors } from "@nestjs/common";
|
||||||
import { Profile } from "../entities/Profile";
|
import { Profile } from "../entities/Profile";
|
||||||
|
|
@ -2276,11 +2276,11 @@ export class ImportDataController extends Controller {
|
||||||
@Post("mapposition-Officer")
|
@Post("mapposition-Officer")
|
||||||
async MapPositionOfficer(@Request() request: { user: Record<string, any> }) {
|
async MapPositionOfficer(@Request() request: { user: Record<string, any> }) {
|
||||||
const officer = await AppDataSource.getRepository(Profile)
|
const officer = await AppDataSource.getRepository(Profile)
|
||||||
.createQueryBuilder("profile")
|
.createQueryBuilder("profile")
|
||||||
.leftJoinAndSelect("profile.current_holders", "posMaster")
|
.leftJoinAndSelect("profile.current_holders", "posMaster")
|
||||||
// .where({citizenId: "1720700018869"})
|
// .where({citizenId: "1720700018869"})
|
||||||
.where("posMaster.id IS NULL")
|
.where("posMaster.id IS NULL")
|
||||||
.getMany();
|
.getMany();
|
||||||
let rowCount = 0;
|
let rowCount = 0;
|
||||||
let _null: any = null;
|
let _null: any = null;
|
||||||
let type_: any = null;
|
let type_: any = null;
|
||||||
|
|
@ -2294,22 +2294,22 @@ export class ImportDataController extends Controller {
|
||||||
console.log(rowCount);
|
console.log(rowCount);
|
||||||
const item = await AppDataSource.getRepository(OFFICER)
|
const item = await AppDataSource.getRepository(OFFICER)
|
||||||
.createQueryBuilder("OFFICER")
|
.createQueryBuilder("OFFICER")
|
||||||
.where({ CIT: _item.citizenId })
|
.where({ CIT: _item.citizenId })
|
||||||
.getOne();
|
.getOne();
|
||||||
|
|
||||||
if (item == null) {
|
if (item == null) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
let posMaster = new PosMaster();
|
let posMaster = new PosMaster();
|
||||||
let orgRoot = (await this.orgRootRepo.findOne({
|
let orgRoot = (await this.orgRootRepo.findOne({
|
||||||
where: {
|
where: {
|
||||||
DEPARTMENT_CODE: item.DEPARTMENT_CODE,
|
DEPARTMENT_CODE: item.DEPARTMENT_CODE,
|
||||||
DIVISION_CODE: item.DIVISION_CODE,
|
DIVISION_CODE: item.DIVISION_CODE,
|
||||||
SECTION_CODE: item.SECTION_CODE,
|
SECTION_CODE: item.SECTION_CODE,
|
||||||
JOB_CODE: item.JOB_CODE,
|
JOB_CODE: item.JOB_CODE,
|
||||||
orgRevisionId: orgRevision.id,
|
orgRevisionId: orgRevision.id,
|
||||||
},
|
},
|
||||||
})) as OrgRoot;
|
})) as OrgRoot;
|
||||||
if (orgRoot != null) {
|
if (orgRoot != null) {
|
||||||
posMaster.orgRootId = orgRoot.id ?? _null;
|
posMaster.orgRootId = orgRoot.id ?? _null;
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -2325,7 +2325,7 @@ export class ImportDataController extends Controller {
|
||||||
if (orgChild1 != null) {
|
if (orgChild1 != null) {
|
||||||
posMaster.orgRootId = orgChild1.orgRootId ?? _null;
|
posMaster.orgRootId = orgChild1.orgRootId ?? _null;
|
||||||
posMaster.orgChild1Id = orgChild1.id ?? _null;
|
posMaster.orgChild1Id = orgChild1.id ?? _null;
|
||||||
} else {
|
} else {
|
||||||
let orgChild2 = await this.orgChild2Repo.findOne({
|
let orgChild2 = await this.orgChild2Repo.findOne({
|
||||||
where: {
|
where: {
|
||||||
DEPARTMENT_CODE: item.DEPARTMENT_CODE,
|
DEPARTMENT_CODE: item.DEPARTMENT_CODE,
|
||||||
|
|
@ -2381,7 +2381,7 @@ export class ImportDataController extends Controller {
|
||||||
posMaster.isDirector = false;
|
posMaster.isDirector = false;
|
||||||
posMaster.isSit = false;
|
posMaster.isSit = false;
|
||||||
posMaster.current_holderId = _item.id;
|
posMaster.current_holderId = _item.id;
|
||||||
posMaster.posMasterNo = item.SALARY == "" ? _null : Number(item.POS_NUM_CODE);
|
posMaster.posMasterNo = item.POS_NUM_CODE == "" || item.POS_NUM_CODE == null ? _null : Number(item.POS_NUM_CODE);
|
||||||
posMaster.orgRevisionId = orgRevision.id;
|
posMaster.orgRevisionId = orgRevision.id;
|
||||||
posMaster.posMasterCreatedAt = new Date();
|
posMaster.posMasterCreatedAt = new Date();
|
||||||
posMaster.createdUserId = request.user.sub;
|
posMaster.createdUserId = request.user.sub;
|
||||||
|
|
@ -2583,4 +2583,24 @@ export class ImportDataController extends Controller {
|
||||||
}
|
}
|
||||||
return new HttpSuccess();
|
return new HttpSuccess();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @summary เงินเดือน ข้าราชการ
|
||||||
|
*/
|
||||||
|
@Post("update-amount")
|
||||||
|
async UpdateAmount(@Request() request: { user: Record<string, any> }) {
|
||||||
|
let rowCount = 0;
|
||||||
|
const profile:any = await this.profileRepo.find({where: { amount: LessThanOrEqual(0) }});
|
||||||
|
|
||||||
|
for await (const _item of profile) {
|
||||||
|
const OFFICER = await this.OFFICERRepo.findOne({ select: ["CIT", "SALARY"], where: { CIT: _item.citizenId } });
|
||||||
|
if (OFFICER) {
|
||||||
|
rowCount++;
|
||||||
|
_item.amount = Number(OFFICER.SALARY);
|
||||||
|
await this.profileRepo.save(_item);
|
||||||
|
console.log(rowCount);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return new HttpSuccess();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -903,7 +903,17 @@ export class KeycloakController extends Controller {
|
||||||
});
|
});
|
||||||
|
|
||||||
for await (const _item of profiles) {
|
for await (const _item of profiles) {
|
||||||
const result = await changeUserPassword(_item.keycloak, "P@ssw0rd");
|
let password = _item.citizenId;
|
||||||
|
if (_item.birthDate != null) {
|
||||||
|
const gregorianYear = _item.birthDate.getFullYear() + 543;
|
||||||
|
|
||||||
|
const formattedDate =
|
||||||
|
_item.birthDate.toISOString().slice(8, 10) +
|
||||||
|
_item.birthDate.toISOString().slice(5, 7) +
|
||||||
|
gregorianYear;
|
||||||
|
password = formattedDate;
|
||||||
|
}
|
||||||
|
const result = await changeUserPassword(_item.keycloak, password);
|
||||||
if (!result) {
|
if (!result) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
import { Body, Controller, Get, Path, Post, Put, Request, Route, Security, Tags, } from "tsoa";
|
import { Body, Controller, Get, Path, Post, Put, Request, Route, Security, Tags } from "tsoa";
|
||||||
import { AppDataSource } from "../database/data-source";
|
import { AppDataSource } from "../database/data-source";
|
||||||
import { RequestWithUser } from "../middlewares/user";
|
import { RequestWithUser } from "../middlewares/user";
|
||||||
import HttpError from "../interfaces/http-error";
|
import HttpError from "../interfaces/http-error";
|
||||||
|
|
@ -658,7 +658,7 @@ export class WorkflowController extends Controller {
|
||||||
receiverUserIds: [
|
receiverUserIds: [
|
||||||
{
|
{
|
||||||
receiverUserId: body.profileId,
|
receiverUserId: body.profileId,
|
||||||
notiLink: `${process.env.VITE_URL_SSO}/${assign.path}/${state.workflow.refId}`,
|
notiLink: `${process.env.VITE_URL_MGT}/${assign.path}/${state.workflow.refId}`,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
payload: "", //แนบไฟล์
|
payload: "", //แนบไฟล์
|
||||||
|
|
@ -802,6 +802,18 @@ export class WorkflowController extends Controller {
|
||||||
pageSize: number;
|
pageSize: number;
|
||||||
},
|
},
|
||||||
) {
|
) {
|
||||||
|
let userId = "";
|
||||||
|
if (xxx) {
|
||||||
|
} else {
|
||||||
|
const posMasterUser = await this.posMasterRepo.findOne({
|
||||||
|
where: {
|
||||||
|
orgRevision: { orgRevisionIsCurrent: true, orgRevisionIsDraft: false },
|
||||||
|
current_holder: { keycloak: request.user.sub },
|
||||||
|
},
|
||||||
|
relations: ["current_holder", "current_holder.posType", "current_holder.posLevel"],
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
const posMasterUser = await this.posMasterRepo.findOne({
|
const posMasterUser = await this.posMasterRepo.findOne({
|
||||||
where: {
|
where: {
|
||||||
orgRevision: { orgRevisionIsCurrent: true, orgRevisionIsDraft: false },
|
orgRevision: { orgRevisionIsCurrent: true, orgRevisionIsDraft: false },
|
||||||
|
|
@ -825,6 +837,19 @@ export class WorkflowController extends Controller {
|
||||||
};
|
};
|
||||||
|
|
||||||
if (type.trim().toUpperCase() == "OPERATE") {
|
if (type.trim().toUpperCase() == "OPERATE") {
|
||||||
|
condition = {
|
||||||
|
isDirector: true,
|
||||||
|
orgRootId: posMasterUser.orgRootId,
|
||||||
|
orgRevisionId: posMasterUser.orgRevisionId,
|
||||||
|
// orgChild1Id: IsNull(),
|
||||||
|
// orgChild2Id: IsNull(),
|
||||||
|
// orgChild3Id: IsNull(),
|
||||||
|
// orgChild4Id: IsNull(),
|
||||||
|
};
|
||||||
|
condition.orgChild1Id = IsNull();
|
||||||
|
condition.orgChild2Id = IsNull();
|
||||||
|
condition.orgChild3Id = IsNull();
|
||||||
|
condition.orgChild4Id = IsNull();
|
||||||
} else {
|
} else {
|
||||||
if (
|
if (
|
||||||
(posMasterUser.current_holder.posType.posTypeName == "ทั่วไป" &&
|
(posMasterUser.current_holder.posType.posTypeName == "ทั่วไป" &&
|
||||||
|
|
@ -1144,46 +1169,48 @@ export class WorkflowController extends Controller {
|
||||||
return new HttpSuccess();
|
return new HttpSuccess();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* API เช็ค สกจ
|
* API เช็ค สกจ
|
||||||
*
|
*
|
||||||
* @summary เช็ค สกจ
|
* @summary เช็ค สกจ
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Post("find/director")
|
@Post("find/director")
|
||||||
async getProfileDirectorByProfileId(@Request() req: RequestWithUser,
|
async getProfileDirectorByProfileId(
|
||||||
@Body()
|
@Request() req: RequestWithUser,
|
||||||
body: {
|
@Body()
|
||||||
refId: string[];
|
body: {
|
||||||
},) {
|
refId: string[];
|
||||||
|
},
|
||||||
|
) {
|
||||||
const _posMaster = await this.posMasterRepo.find({
|
const _posMaster = await this.posMasterRepo.find({
|
||||||
where: {
|
where: {
|
||||||
orgRevision: { orgRevisionIsDraft: false, orgRevisionIsCurrent: true },
|
orgRevision: { orgRevisionIsDraft: false, orgRevisionIsCurrent: true },
|
||||||
current_holderId: In(body.refId),
|
current_holderId: In(body.refId),
|
||||||
},
|
},
|
||||||
select:["orgRootId","orgChild1Id","orgChild2Id","orgChild3Id","orgChild4Id"]
|
select: ["orgRootId", "orgChild1Id", "orgChild2Id", "orgChild3Id", "orgChild4Id"],
|
||||||
});
|
});
|
||||||
const _data:any = _posMaster.map((x) => ({
|
const _data: any = _posMaster.map((x) => ({
|
||||||
orgRootId: x.orgRootId,
|
orgRootId: x.orgRootId,
|
||||||
orgChild1Id: x.orgChild1Id,
|
orgChild1Id: x.orgChild1Id,
|
||||||
orgChild2Id: x.orgChild2Id,
|
orgChild2Id: x.orgChild2Id,
|
||||||
orgChild3Id: x.orgChild3Id,
|
orgChild3Id: x.orgChild3Id,
|
||||||
orgChild4Id: x.orgChild4Id,
|
orgChild4Id: x.orgChild4Id,
|
||||||
isDirector: true,
|
isDirector: true,
|
||||||
current_holder: Not(IsNull()),
|
current_holder: Not(IsNull()),
|
||||||
}));
|
}));
|
||||||
const posMaster = await this.posMasterRepo.find({
|
const posMaster = await this.posMasterRepo.find({
|
||||||
where: _data,
|
where: _data,
|
||||||
relations:["current_holder"]
|
relations: ["current_holder"],
|
||||||
});
|
});
|
||||||
|
|
||||||
const data = posMaster.map((x) => ({
|
const data = posMaster.map((x) => ({
|
||||||
id: x.current_holder.id,
|
id: x.current_holder.id,
|
||||||
citizenId: x.current_holder.citizenId,
|
citizenId: x.current_holder.citizenId,
|
||||||
prefix: x.current_holder.prefix,
|
prefix: x.current_holder.prefix,
|
||||||
firstName: x.current_holder.firstName,
|
firstName: x.current_holder.firstName,
|
||||||
lastName: x.current_holder.lastName,
|
lastName: x.current_holder.lastName,
|
||||||
}));
|
}));
|
||||||
return new HttpSuccess(data);
|
return new HttpSuccess(data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue