Merge branch 'develop' into adiDev
This commit is contained in:
commit
ea2566395e
13 changed files with 341 additions and 55 deletions
|
|
@ -27,11 +27,25 @@ export class AuthSysController extends Controller {
|
|||
|
||||
@Get("list")
|
||||
public async listAuthSys() {
|
||||
const getList = await this.authSysRepo.find();
|
||||
// if (!getList || getList.length === 0) {
|
||||
// throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
||||
// }
|
||||
return new HttpSuccess(getList);
|
||||
const getList = await this.authSysRepo.find({
|
||||
select: ["id", "parentId", "sysName", "sysDescription", "order"],
|
||||
});
|
||||
|
||||
if (!getList || getList.length === 0) {
|
||||
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
||||
}
|
||||
|
||||
const lists = getList
|
||||
.filter((x) => x.parentId == null)
|
||||
.map((item) => {
|
||||
return {
|
||||
...item,
|
||||
children: getList.filter((x) => x.parentId == item.id).sort((a, b) => a.order - b.order),
|
||||
};
|
||||
})
|
||||
.sort((a, b) => a.order - b.order);
|
||||
|
||||
return new HttpSuccess(lists);
|
||||
}
|
||||
|
||||
@Get("{systemId}")
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@ import HttpError from "../interfaces/http-error";
|
|||
import { Equal, ILike, In, IsNull, Like, Not, Brackets, MoreThan } from "typeorm";
|
||||
import { RequestWithUser } from "../middlewares/user";
|
||||
import { ChangePosition, CreateChangePosition, UpdateChangePosition } from "../entities/ChangePosition";
|
||||
import { ProfileChangePosition, CreateProfileChangePosition } from "../entities/ProfileChangePosition";
|
||||
|
||||
@Route("api/v1/org/placement/change-position")
|
||||
@Tags("Placement")
|
||||
|
|
@ -33,7 +34,8 @@ import { ChangePosition, CreateChangePosition, UpdateChangePosition } from "../e
|
|||
)
|
||||
@SuccessResponse(HttpStatusCode.OK, "สำเร็จ")
|
||||
export class ChangePositionController extends Controller {
|
||||
private ChangePositionRepository = AppDataSource.getRepository(ChangePosition);
|
||||
private ChangePositionRepository = AppDataSource.getRepository(ChangePosition);
|
||||
private ProfileChangePositionRepository = AppDataSource.getRepository(ProfileChangePosition);
|
||||
|
||||
/**
|
||||
* API เพิ่มรอบย้ายสับเปลี่ยนตำแหน่ง
|
||||
|
|
@ -68,6 +70,41 @@ export class ChangePositionController extends Controller {
|
|||
return new HttpSuccess();
|
||||
}
|
||||
|
||||
/**
|
||||
* API เพิ่มเพิ่มรายชื่อผู้ที่ย้ายสับเปลี่ยนตำแหน่ง
|
||||
*
|
||||
* @summary เพิ่มเพิ่มรายชื่อผู้ที่ย้ายสับเปลี่ยนตำแหน่ง (ADMIN)
|
||||
*
|
||||
* @param {string} id Id รอบย้ายสับเปลี่ยนตำแหน่ง
|
||||
*/
|
||||
@Post("profile/{id}")
|
||||
async CreateProfileChangePosition(
|
||||
@Path() id: string,
|
||||
@Body() body: CreateProfileChangePosition,
|
||||
@Request() request: RequestWithUser,
|
||||
) {
|
||||
const changePosition = await this.ChangePositionRepository.findOneBy({ id });
|
||||
if (!changePosition) throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลรอบย้ายสับเปลี่ยนตำแหน่ง");
|
||||
|
||||
const profileChangePositions: ProfileChangePosition[] = [];
|
||||
const profiles = new ProfileChangePosition();
|
||||
for (const data of body.profiles) {
|
||||
Object.assign(profiles, data);
|
||||
let positionOld = data.positionOld ? `${data.positionOld}` : "";
|
||||
let rootOld = data.rootOld ? data.positionOld ? `/${data.rootOld}` : `${data.rootOld}` : "";
|
||||
profiles.changePositionId = id;
|
||||
profiles.organizationPositionOld = `${positionOld}${rootOld}`,
|
||||
profiles.status = "WAITTING",
|
||||
profiles.createdUserId = request.user.sub;
|
||||
profiles.createdFullName = request.user.name;
|
||||
profiles.lastUpdateUserId = request.user.sub;
|
||||
profiles.lastUpdateFullName = request.user.name;
|
||||
profileChangePositions.push(profiles);
|
||||
}
|
||||
await this.ProfileChangePositionRepository.save(profileChangePositions);
|
||||
return new HttpSuccess();
|
||||
}
|
||||
|
||||
/**
|
||||
* API ลบรอบย้ายสับเปลี่ยนตำแหน่ง
|
||||
*
|
||||
|
|
@ -107,7 +144,7 @@ export class ChangePositionController extends Controller {
|
|||
) {
|
||||
|
||||
const changePosition = await this.ChangePositionRepository.findOneBy({ id });
|
||||
if (!changePosition) throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล");
|
||||
if (!changePosition) throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลรอบย้ายสับเปลี่ยนตำแหน่ง");
|
||||
|
||||
const checkDuplicate = await this.ChangePositionRepository.find({
|
||||
where: {
|
||||
|
|
@ -134,7 +171,7 @@ export class ChangePositionController extends Controller {
|
|||
* @summary API รายการรอบย้ายสับเปลี่ยนตำแหน่ง (ADMIN)
|
||||
*
|
||||
*/
|
||||
@Get("")
|
||||
@Get()
|
||||
async GetChangePositionLists() {
|
||||
const data = await this.ChangePositionRepository.find();
|
||||
return new HttpSuccess(data);
|
||||
|
|
|
|||
|
|
@ -255,6 +255,8 @@ export class EmployeePositionController extends Controller {
|
|||
? null
|
||||
: `${position.posType.posTypeShortName} ${position.posLevel.posLevelName}`,
|
||||
positionIsSelected: position.positionIsSelected,
|
||||
isOfficer: posMaster.isOfficer,
|
||||
isDirecter: posMaster.isDirector,
|
||||
})),
|
||||
};
|
||||
return new HttpSuccess(formattedData);
|
||||
|
|
@ -611,6 +613,8 @@ export class EmployeePositionController extends Controller {
|
|||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลอัตรากำลัง");
|
||||
}
|
||||
posMaster.posMasterNo = requestBody.posMasterNo;
|
||||
posMaster.isDirector = requestBody.isDirector;
|
||||
posMaster.isOfficer = requestBody.isOfficer;
|
||||
posMaster.posMasterNoPrefix = requestBody.posMasterNoPrefix;
|
||||
posMaster.posMasterNoSuffix = requestBody.posMasterNoSuffix;
|
||||
posMaster.reason = requestBody.reason == null ? "" : requestBody.reason;
|
||||
|
|
|
|||
|
|
@ -28,6 +28,8 @@ import { ProfileFamilyCouple } from "../entities/ProfileFamilyCouple";
|
|||
import { ProfileFamilyMother } from "../entities/ProfileFamilyMother";
|
||||
import { ProfileFamilyFather } from "../entities/ProfileFamilyFather";
|
||||
import { ProfileEmployee } from "../entities/ProfileEmployee";
|
||||
import { PosLevel } from "../entities/PosLevel";
|
||||
import { PosType } from "../entities/PosType";
|
||||
|
||||
@Route("api/v1/org/upload")
|
||||
@Tags("UPLOAD")
|
||||
|
|
@ -40,6 +42,8 @@ export class ImportDataController extends Controller {
|
|||
private salaryRepository = AppDataSource.getRepository(ProfileSalary);
|
||||
private profileRepo = AppDataSource.getRepository(Profile);
|
||||
private profileEmpRepo = AppDataSource.getRepository(ProfileEmployee);
|
||||
private posLevelRepo = AppDataSource.getRepository(PosLevel);
|
||||
private posTypeRepo = AppDataSource.getRepository(PosType);
|
||||
/**
|
||||
* API upload EDU
|
||||
*
|
||||
|
|
@ -594,4 +598,58 @@ export class ImportDataController extends Controller {
|
|||
await this.salaryRepository.save(profiles);
|
||||
return new HttpSuccess(allData);
|
||||
}
|
||||
|
||||
@Post("uploadposSQL")
|
||||
@UseInterceptors(FileInterceptor("file"))
|
||||
async UploadPOSFileSQL(@UploadedFile() file: Express.Multer.File) {
|
||||
const workbook = xlsx.read(file.buffer, { type: "buffer" });
|
||||
const sheetName = workbook.SheetNames[0];
|
||||
const sheet = workbook.Sheets[sheetName];
|
||||
const getProFile = xlsx.utils.sheet_to_json(sheet);
|
||||
let profiles: any = [];
|
||||
await Promise.all(
|
||||
getProFile.map(async (item: any) => {
|
||||
// Find profile by ID
|
||||
let profile = await this.profileRepo.findOne({
|
||||
where: { citizenId: item["ID"] },
|
||||
});
|
||||
if (!profile) {
|
||||
return; // Skip processing this item
|
||||
}
|
||||
|
||||
if (item["MP_CEE_TYPE"] === "NULL") {
|
||||
profile.posTypeId = null;
|
||||
} else {
|
||||
// Find posType by posTypeName
|
||||
const posType = await this.posTypeRepo.findOne({
|
||||
where: { posTypeName: item["MP_CEE_TYPE"] },
|
||||
});
|
||||
if (!posType) {
|
||||
return; // Skip processing this item
|
||||
}
|
||||
profile.posTypeId = posType.id;
|
||||
}
|
||||
// Check if posLevelName is "NULL"
|
||||
if (item["MP_CEE_POSITION"] === "NULL") {
|
||||
profile.posLevelId = null;
|
||||
} else {
|
||||
// Find posLevel by posLevelName
|
||||
const posLevel = await this.posLevelRepo.findOne({
|
||||
where: { posLevelName: item["MP_CEE_POSITION"] },
|
||||
});
|
||||
if (!posLevel) {
|
||||
console.error(
|
||||
`posLevel with name ${item["MP_CEE_POSITION"]} not found for profile ID ${profile.id}`,
|
||||
);
|
||||
return; // Skip processing this item
|
||||
}
|
||||
profile.posLevelId = posLevel.id;
|
||||
}
|
||||
|
||||
profiles.push(profile);
|
||||
}),
|
||||
);
|
||||
await this.profileRepo.save(profiles);
|
||||
return new HttpSuccess(getProFile);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -797,6 +797,8 @@ export class PositionController extends Controller {
|
|||
if (!posMaster) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลอัตรากำลัง");
|
||||
}
|
||||
posMaster.isDirector = requestBody.isDirector;
|
||||
posMaster.isOfficer = requestBody.isOfficer;
|
||||
posMaster.posMasterNo = requestBody.posMasterNo;
|
||||
posMaster.posMasterNoPrefix = requestBody.posMasterNoPrefix;
|
||||
posMaster.posMasterNoSuffix = requestBody.posMasterNoSuffix;
|
||||
|
|
@ -949,6 +951,8 @@ export class PositionController extends Controller {
|
|||
position.positionExecutiveField = x.posDictExecutiveField;
|
||||
position.positionArea = x.posDictArea;
|
||||
position.isSpecial = x.isSpecial;
|
||||
position.isOfficer = x.isOfficer;
|
||||
position.isDirector = x.isDirector;
|
||||
position.positionIsSelected = x.positionIsSelected;
|
||||
position.posMasterId = posMaster.id;
|
||||
position.createdUserId = request.user.sub;
|
||||
|
|
@ -1001,6 +1005,8 @@ export class PositionController extends Controller {
|
|||
positionArea: position.positionArea,
|
||||
positionIsSelected: position.positionIsSelected,
|
||||
isSpecial: position.isSpecial,
|
||||
isOfficer: posMaster.isOfficer,
|
||||
isDirecter: posMaster.isDirector,
|
||||
})),
|
||||
};
|
||||
return new HttpSuccess(formattedData);
|
||||
|
|
|
|||
|
|
@ -563,17 +563,27 @@ export class ProfileController extends Controller {
|
|||
where: { keycloak: request.user.sub },
|
||||
});
|
||||
|
||||
if (!profile) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
||||
|
||||
const _caregiver = await this.profileRepo.find({
|
||||
relations: { posLevel: true, posType: true },
|
||||
});
|
||||
const _commander = await this.profileRepo.find({
|
||||
relations: { posLevel: true, posType: true },
|
||||
});
|
||||
const _chairman = await this.profileRepo.find({
|
||||
relations: { posLevel: true, posType: true },
|
||||
});
|
||||
const _caregiver = await this.profileRepo
|
||||
.createQueryBuilder("profile")
|
||||
.leftJoinAndSelect("profile.posLevel", "posLevel")
|
||||
.leftJoinAndSelect("profile.posType", "posType")
|
||||
.skip((1 - 1) * 20)
|
||||
.take(20)
|
||||
.getMany();
|
||||
const _commander = await this.profileRepo
|
||||
.createQueryBuilder("profile")
|
||||
.leftJoinAndSelect("profile.posLevel", "posLevel")
|
||||
.leftJoinAndSelect("profile.posType", "posType")
|
||||
.skip((1 - 1) * 20)
|
||||
.take(20)
|
||||
.getMany();
|
||||
const _chairman = await this.profileRepo
|
||||
.createQueryBuilder("profile")
|
||||
.leftJoinAndSelect("profile.posLevel", "posLevel")
|
||||
.leftJoinAndSelect("profile.posType", "posType")
|
||||
.skip((1 - 1) * 20)
|
||||
.take(20)
|
||||
.getMany();
|
||||
|
||||
const caregiver = _caregiver.map((_data) => ({
|
||||
id: _data.id,
|
||||
|
|
@ -2097,6 +2107,7 @@ export class ProfileController extends Controller {
|
|||
child3ShortName: child3Holder?.orgChild3ShortName ?? null,
|
||||
child4: child4Holder?.orgChild4Name ?? null,
|
||||
child4Id: child4Holder?.id ?? null,
|
||||
child4ShortName: child4Holder?.orgChild4ShortName ?? null,
|
||||
posMasterNo: posMasterNo ?? null,
|
||||
posTypeId: item.posTypeId,
|
||||
posTypeName: item.posType?.posTypeName,
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ import { AppDataSource } from "../database/data-source";
|
|||
import HttpSuccess from "../interfaces/http-success";
|
||||
import HttpStatus from "../interfaces/http-status";
|
||||
import HttpError from "../interfaces/http-error";
|
||||
import { Brackets, IsNull, Like, Not } from "typeorm";
|
||||
import { Brackets, In, IsNull, Like, Not } from "typeorm";
|
||||
import { OrgRevision } from "../entities/OrgRevision";
|
||||
import { calculateRetireDate, calculateRetireLaw } from "../interfaces/utils";
|
||||
import { EmployeePosMaster } from "../entities/EmployeePosMaster";
|
||||
|
|
@ -557,10 +557,10 @@ export class ProfileEmployeeController extends Controller {
|
|||
const exists =
|
||||
!!body.citizenId &&
|
||||
(await this.profileRepo.findOne({
|
||||
where: {
|
||||
id: Not(id),
|
||||
citizenId: body.citizenId,
|
||||
employeeClass: String(body.employeeClass)
|
||||
where: {
|
||||
id: Not(id),
|
||||
citizenId: body.citizenId,
|
||||
employeeClass: String(body.employeeClass),
|
||||
},
|
||||
}));
|
||||
|
||||
|
|
@ -690,12 +690,12 @@ export class ProfileEmployeeController extends Controller {
|
|||
: _data.current_holders[0].orgRoot != null
|
||||
? `${_data.current_holders[0].orgRoot.orgRootShortName}${_data.current_holders[0].posMasterNo}`
|
||||
: null;
|
||||
const dateEmployment =
|
||||
const dateEmployment =
|
||||
_data.profileEmployeeEmployment.length == 0
|
||||
? null
|
||||
: _data.profileEmployeeEmployment.reduce((latest, current) => {
|
||||
return (latest.date > current.date) ? latest : current;
|
||||
}).date;
|
||||
return latest.date > current.date ? latest : current;
|
||||
}).date;
|
||||
return {
|
||||
id: _data.id,
|
||||
prefix: _data.prefix,
|
||||
|
|
@ -933,12 +933,12 @@ export class ProfileEmployeeController extends Controller {
|
|||
: _data.current_holders[0].orgRoot != null
|
||||
? `${_data.current_holders[0].orgRoot.orgRootShortName}${_data.current_holders[0].posMasterNo}`
|
||||
: null;
|
||||
const dateEmployment =
|
||||
const dateEmployment =
|
||||
_data.profileEmployeeEmployment.length == 0
|
||||
? null
|
||||
: _data.profileEmployeeEmployment.reduce((latest, current) => {
|
||||
return (latest.date > current.date) ? latest : current;
|
||||
}).date;
|
||||
return latest.date > current.date ? latest : current;
|
||||
}).date;
|
||||
return {
|
||||
id: _data.id,
|
||||
prefix: _data.prefix,
|
||||
|
|
@ -2569,33 +2569,33 @@ export class ProfileEmployeeController extends Controller {
|
|||
/**
|
||||
* API ข้อมูลลูกจ้างชั่วคราว
|
||||
*
|
||||
* @summary ข้อมูลลูกจ้างชั่วคราว (ADMIN)
|
||||
* @summary ข้อมูลลูกจ้างชั่วคราว (ADMIN)
|
||||
*
|
||||
* @param {string} profileEmployeeId profileEmployeeId ทะเบียนประวัติลูกจ้างชั่วคราว
|
||||
*/
|
||||
@Get("information/{profileEmployeeId}")
|
||||
async getInformationById(@Path() profileEmployeeId: string) {
|
||||
const profileInformation = await this.profileRepo.findOne({
|
||||
where: { id: profileEmployeeId }
|
||||
where: { id: profileEmployeeId },
|
||||
});
|
||||
if (!profileInformation) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
||||
|
||||
const mapData = {
|
||||
id: profileInformation.id,
|
||||
positionEmployeeGroupId: profileInformation.positionEmployeeGroupId,
|
||||
positionEmployeeLineId: profileInformation.positionEmployeeLineId,
|
||||
positionEmployeePositionId: profileInformation.positionEmployeePositionId,
|
||||
employeeOc: profileInformation.employeeOc,
|
||||
employeeTypeIndividual: profileInformation.employeeTypeIndividual,
|
||||
employeeWage: profileInformation.employeeWage,
|
||||
employeeMoneyIncrease: profileInformation.employeeMoneyIncrease,
|
||||
employeeMoneyAllowance: profileInformation.employeeMoneyAllowance,
|
||||
employeeMoneyEmployee: profileInformation.employeeMoneyEmployee,
|
||||
employeeMoneyEmployer: profileInformation.employeeMoneyEmployer,
|
||||
id: profileInformation.id,
|
||||
positionEmployeeGroupId: profileInformation.positionEmployeeGroupId,
|
||||
positionEmployeeLineId: profileInformation.positionEmployeeLineId,
|
||||
positionEmployeePositionId: profileInformation.positionEmployeePositionId,
|
||||
employeeOc: profileInformation.employeeOc,
|
||||
employeeTypeIndividual: profileInformation.employeeTypeIndividual,
|
||||
employeeWage: profileInformation.employeeWage,
|
||||
employeeMoneyIncrease: profileInformation.employeeMoneyIncrease,
|
||||
employeeMoneyAllowance: profileInformation.employeeMoneyAllowance,
|
||||
employeeMoneyEmployee: profileInformation.employeeMoneyEmployee,
|
||||
employeeMoneyEmployer: profileInformation.employeeMoneyEmployer,
|
||||
};
|
||||
return new HttpSuccess(mapData);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* API ประวัติการแก้ไขข้อมูลลูกจ้างชั่วคราว
|
||||
*
|
||||
|
|
@ -2781,4 +2781,42 @@ export class ProfileEmployeeController extends Controller {
|
|||
|
||||
return new HttpSuccess();
|
||||
}
|
||||
|
||||
/**
|
||||
* API ออกคำสั่งลูกจ้าง
|
||||
*
|
||||
* @summary ORG_038 - ออกคำสั่งลูกจ้าง (ADMIN) #
|
||||
*
|
||||
*/
|
||||
@Post("report")
|
||||
async sendReport(@Request() request: RequestWithUser, @Body() requestBody: { id: string[] }) {
|
||||
const profiles = await this.profileRepo.find({ where: { id: In(requestBody.id) } });
|
||||
|
||||
const _profiles = await Promise.all(
|
||||
profiles.map(async (item: any) => {
|
||||
return {
|
||||
...item,
|
||||
statusTemp: "REPORT",
|
||||
lastUpdateUserId: request.user.sub,
|
||||
lastUpdateFullName: request.user.name,
|
||||
};
|
||||
}),
|
||||
);
|
||||
await this.profileRepo.save(_profiles);
|
||||
return new HttpSuccess();
|
||||
}
|
||||
|
||||
/**
|
||||
* API ออกคำสั่งลูกจ้าง
|
||||
*
|
||||
* @summary ORG_038 - ออกคำสั่งลูกจ้าง (ADMIN) #
|
||||
*
|
||||
*/
|
||||
@Get("report")
|
||||
async getReport(@Request() request: RequestWithUser) {
|
||||
const profiles = await this.profileRepo.find({
|
||||
where: { statusTemp: "REPORT", employeeClass: "TEMP" },
|
||||
});
|
||||
return new HttpSuccess(profiles);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue