Merge branch 'develop' into adiDev
This commit is contained in:
commit
bda7c1328f
2 changed files with 216 additions and 3 deletions
|
|
@ -40,6 +40,9 @@ import {
|
|||
import { RequestWithUser } from "../middlewares/user";
|
||||
import { Position } from "../entities/Position";
|
||||
import { ProfileEmployee } from "../entities/ProfileEmployee";
|
||||
import { Province } from "../entities/Province";
|
||||
import { District } from "../entities/District";
|
||||
import { SubDistrict } from "../entities/SubDistrict";
|
||||
|
||||
@Route("api/v1/org/profile")
|
||||
@Tags("Profile")
|
||||
|
|
@ -57,8 +60,110 @@ export class ProfileController extends Controller {
|
|||
private profileHistoryRepo = AppDataSource.getRepository(ProfileHistory);
|
||||
private posLevelRepo = AppDataSource.getRepository(PosLevel);
|
||||
private posTypeRepo = AppDataSource.getRepository(PosType);
|
||||
private orgRevisionRepository = AppDataSource.getRepository(OrgRevision);
|
||||
private positionRepository = AppDataSource.getRepository(Position);
|
||||
private provinceRepository = AppDataSource.getRepository(Province);
|
||||
private districtRepository = AppDataSource.getRepository(District);
|
||||
private subDistrict = AppDataSource.getRepository(SubDistrict);
|
||||
|
||||
/**
|
||||
* report ประวัติแบบย่อ ข้าราชการ
|
||||
*
|
||||
* @summary report ประวัติแบบย่อ ข้าราชการ
|
||||
*
|
||||
* @param {string} id Id โปรไฟล์
|
||||
*/
|
||||
@Get("kp7-short/{id}")
|
||||
async kp7ShortById(@Path() id: string) {
|
||||
const orgRevision = await this.orgRevisionRepo.findOne({
|
||||
where: { orgRevisionIsCurrent: true },
|
||||
});
|
||||
|
||||
const profile = await this.profileRepo.findOne({
|
||||
relations: [
|
||||
"profileSalary",
|
||||
"profileEducations",
|
||||
"current_holders",
|
||||
"current_holders.orgRoot",
|
||||
"current_holders.orgChild1",
|
||||
"current_holders.orgChild2",
|
||||
"current_holders.orgChild3",
|
||||
"current_holders.orgChild4"
|
||||
],
|
||||
where: { id: id, },
|
||||
});
|
||||
if (!profile) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
||||
|
||||
const province = await this.provinceRepository.findOneBy({ id: profile.registrationProvinceId })
|
||||
const district = await this.districtRepository.findOneBy({ id: profile.registrationDistrictId })
|
||||
const subDistrict = await this.subDistrict.findOneBy({ id: profile.registrationSubDistrictId })
|
||||
|
||||
const root =
|
||||
profile.current_holders == null ||
|
||||
profile.current_holders.length == 0 ||
|
||||
profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) == null
|
||||
? null
|
||||
: profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgRoot;
|
||||
|
||||
const child1 =
|
||||
profile.current_holders == null ||
|
||||
profile.current_holders.length == 0 ||
|
||||
profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) == null
|
||||
? null
|
||||
: profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgChild1;
|
||||
|
||||
const child2 =
|
||||
profile.current_holders == null ||
|
||||
profile.current_holders.length == 0 ||
|
||||
profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) == null
|
||||
? null
|
||||
: profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgChild2;
|
||||
|
||||
const child3 =
|
||||
profile.current_holders == null ||
|
||||
profile.current_holders.length == 0 ||
|
||||
profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) == null
|
||||
? null
|
||||
: profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgChild3;
|
||||
|
||||
const child4 =
|
||||
profile.current_holders == null ||
|
||||
profile.current_holders.length == 0 ||
|
||||
profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) == null
|
||||
? null
|
||||
: profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgChild4;
|
||||
|
||||
let _root = root == null || root == undefined ? "" : `${root.orgRootName}`;
|
||||
let _child1 = child1 == null || child1 == undefined ? "" : `${child1.orgChild1Name}/`;
|
||||
let _child2 = child2 == null || child2 == undefined ? "" : `${child2.orgChild2Name}/`;
|
||||
let _child3 = child3 == null || child3 == undefined ? "" : `${child3.orgChild3Name}/`;
|
||||
let _child4 = child4 == null || child4 == undefined ? "" : `${child4.orgChild4Name}/`;
|
||||
|
||||
const mapData = {
|
||||
Id: profile.id,
|
||||
CitizenId: profile.citizenId,
|
||||
Prefix: profile.prefix,
|
||||
FirstName: profile.firstName,
|
||||
LastName: profile.lastName,
|
||||
DateOfBirth: profile.birthDate,
|
||||
DateRetire: profile.dateRetire,
|
||||
RegistrationAddress: `${profile.registrationAddress}\r\nตำบล/แขวง ${province?.name}\r\nเขต/อำเภอ ${district?.name}\r\nจังหวัด ${subDistrict?.name} รหัสไปรษณีย์ ${profile.registrationZipCode}`,
|
||||
SalaryAmount: profile.profileSalary.length > 0
|
||||
? profile.profileSalary[0].amount
|
||||
: null,
|
||||
Education: profile.profileEducations.length > 0
|
||||
? profile.profileEducations[profile.profileEducations.length-1].institute
|
||||
: null,
|
||||
AppointText: profile.dateAppoint,
|
||||
SalaryDate: profile.profileSalary.length > 0
|
||||
? profile.profileSalary[0].date
|
||||
: null,
|
||||
PositionName: profile.position,
|
||||
OcFullPath: `${_child4}${_child3}${_child2}${_child1}${_root}`,
|
||||
}
|
||||
|
||||
return new HttpSuccess(mapData);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
|
|
@ -572,7 +677,7 @@ export class ProfileController extends Controller {
|
|||
.skip((page - 1) * pageSize)
|
||||
.take(pageSize)
|
||||
.getManyAndCount();
|
||||
const findRevision = await this.orgRevisionRepository.findOne({
|
||||
const findRevision = await this.orgRevisionRepo.findOne({
|
||||
where: { orgRevisionIsCurrent: true },
|
||||
});
|
||||
if (!findRevision) {
|
||||
|
|
@ -1139,6 +1244,7 @@ export class ProfileController extends Controller {
|
|||
*
|
||||
* @summary ORG_065 - ข้อมูลทะเบียนประวัติตาม citizenId (ADMIN) #70
|
||||
*
|
||||
* @param id หมายเลขประจำตัวประชาชน (citizenId)
|
||||
*/
|
||||
@Get("citizenid/position/{id}")
|
||||
async getProfileByCitizenId(
|
||||
|
|
@ -1685,7 +1791,7 @@ export class ProfileController extends Controller {
|
|||
const orgRevisionActive = await this.orgRevisionRepo.findOne({
|
||||
where: { orgRevisionIsCurrent: true, orgRevisionIsDraft: false },
|
||||
});
|
||||
const findRevision = await this.orgRevisionRepository.findOne({
|
||||
const findRevision = await this.orgRevisionRepo.findOne({
|
||||
where: { orgRevisionIsCurrent: true },
|
||||
});
|
||||
if (!findRevision) {
|
||||
|
|
|
|||
|
|
@ -31,6 +31,10 @@ import {
|
|||
import { EmployeePosLevel } from "../entities/EmployeePosLevel";
|
||||
import { EmployeePosType } from "../entities/EmployeePosType";
|
||||
import { RequestWithUser } from "../middlewares/user";
|
||||
import { Position } from "../entities/Position";
|
||||
import { Province } from "../entities/Province";
|
||||
import { District } from "../entities/District";
|
||||
import { SubDistrict } from "../entities/SubDistrict";
|
||||
|
||||
@Route("api/v1/org/profile-employee")
|
||||
@Tags("ProfileEmployee")
|
||||
|
|
@ -47,6 +51,109 @@ export class ProfileEmployeeController extends Controller {
|
|||
private profileHistoryRepo = AppDataSource.getRepository(ProfileEmployeeHistory);
|
||||
private posLevelRepo = AppDataSource.getRepository(EmployeePosLevel);
|
||||
private posTypeRepo = AppDataSource.getRepository(EmployeePosType);
|
||||
private provinceRepository = AppDataSource.getRepository(Province);
|
||||
private districtRepository = AppDataSource.getRepository(District);
|
||||
private subDistrict = AppDataSource.getRepository(SubDistrict);
|
||||
|
||||
/**
|
||||
* report ประวัติแบบย่อ ลูกจ้าง
|
||||
*
|
||||
* @summary report ประวัติแบบย่อ ลูกจ้าง
|
||||
*
|
||||
* @param {string} id Id โปรไฟล์
|
||||
*/
|
||||
@Get("kp7-short/{id}")
|
||||
async kp7ShortById(@Path() id: string) {
|
||||
const orgRevision = await this.orgRevisionRepo.findOne({
|
||||
where: { orgRevisionIsCurrent: true },
|
||||
});
|
||||
|
||||
const profile = await this.profileRepo.findOne({
|
||||
relations: [
|
||||
"profileSalarys",
|
||||
"profileEducations",
|
||||
"current_holders",
|
||||
"current_holders.orgRoot",
|
||||
"current_holders.orgChild1",
|
||||
"current_holders.orgChild2",
|
||||
"current_holders.orgChild3",
|
||||
"current_holders.orgChild4"
|
||||
],
|
||||
where: { id: id, },
|
||||
});
|
||||
if (!profile) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
||||
|
||||
const province = await this.provinceRepository.findOneBy({ id: profile.registrationProvinceId })
|
||||
const district = await this.districtRepository.findOneBy({ id: profile.registrationDistrictId })
|
||||
const subDistrict = await this.subDistrict.findOneBy({ id: profile.registrationSubDistrictId })
|
||||
|
||||
const root =
|
||||
profile.current_holders == null ||
|
||||
profile.current_holders.length == 0 ||
|
||||
profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) == null
|
||||
? null
|
||||
: profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgRoot;
|
||||
|
||||
const child1 =
|
||||
profile.current_holders == null ||
|
||||
profile.current_holders.length == 0 ||
|
||||
profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) == null
|
||||
? null
|
||||
: profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgChild1;
|
||||
|
||||
const child2 =
|
||||
profile.current_holders == null ||
|
||||
profile.current_holders.length == 0 ||
|
||||
profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) == null
|
||||
? null
|
||||
: profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgChild2;
|
||||
|
||||
const child3 =
|
||||
profile.current_holders == null ||
|
||||
profile.current_holders.length == 0 ||
|
||||
profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) == null
|
||||
? null
|
||||
: profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgChild3;
|
||||
|
||||
const child4 =
|
||||
profile.current_holders == null ||
|
||||
profile.current_holders.length == 0 ||
|
||||
profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id) == null
|
||||
? null
|
||||
: profile.current_holders.find((x) => x.orgRevisionId == orgRevision?.id)?.orgChild4;
|
||||
|
||||
let _root = root == null || root == undefined ? "" : `${root.orgRootName}`;
|
||||
let _child1 = child1 == null || child1 == undefined ? "" : `${child1.orgChild1Name}/`;
|
||||
let _child2 = child2 == null || child2 == undefined ? "" : `${child2.orgChild2Name}/`;
|
||||
let _child3 = child3 == null || child3 == undefined ? "" : `${child3.orgChild3Name}/`;
|
||||
let _child4 = child4 == null || child4 == undefined ? "" : `${child4.orgChild4Name}/`;
|
||||
|
||||
const mapData = {
|
||||
Id: profile.id,
|
||||
CitizenId: profile.citizenId,
|
||||
Prefix: profile.prefix,
|
||||
FirstName: profile.firstName,
|
||||
LastName: profile.lastName,
|
||||
DateOfBirth: profile.birthDate,
|
||||
DateRetire: profile.dateRetire,
|
||||
RegistrationAddress: `${profile.registrationAddress}\r\nตำบล/แขวง ${province?.name}\r\nเขต/อำเภอ ${district?.name}\r\nจังหวัด ${subDistrict?.name} รหัสไปรษณีย์ ${profile.registrationZipCode}`,
|
||||
SalaryAmount: profile.profileSalarys.length > 0
|
||||
? profile.profileSalarys[0].amount
|
||||
: null,
|
||||
Education: profile.profileEducations.length > 0
|
||||
? profile.profileEducations[profile.profileEducations.length-1].institute
|
||||
: null,
|
||||
AppointText: profile.dateAppoint,
|
||||
SalaryDate: profile.profileSalarys.length > 0
|
||||
? profile.profileSalarys[0].date
|
||||
: null,
|
||||
PositionName: profile.position,
|
||||
OcFullPath: `${_child4}${_child3}${_child2}${_child1}${_root}`,
|
||||
}
|
||||
|
||||
return new HttpSuccess(mapData);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* API สร้างทะเบียนประวัติ
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue