no message
This commit is contained in:
parent
5a634b4dd3
commit
b11be3364f
7 changed files with 201 additions and 125 deletions
|
|
@ -1056,7 +1056,7 @@ export class EmployeePositionController extends Controller {
|
|||
});
|
||||
|
||||
const authRoleName = await this.authRoleRepo.findOne({
|
||||
where: { id: String(posMaster.authRoleId) }
|
||||
where: { id: String(posMaster.authRoleId) },
|
||||
});
|
||||
|
||||
let profile: any;
|
||||
|
|
@ -1149,7 +1149,8 @@ export class EmployeePositionController extends Controller {
|
|||
profilePoslevel:
|
||||
level == null || type == null ? null : `${type.posTypeShortName} ${level.posLevelName}`,
|
||||
authRoleId: posMaster.authRoleId,
|
||||
authRoleName: authRoleName == null || authRoleName.roleName == null ? null : authRoleName.roleName,
|
||||
authRoleName:
|
||||
authRoleName == null || authRoleName.roleName == null ? null : authRoleName.roleName,
|
||||
positions: positions.map((position) => ({
|
||||
id: position.id,
|
||||
positionName: position.positionName,
|
||||
|
|
@ -2150,4 +2151,46 @@ export class EmployeePositionController extends Controller {
|
|||
|
||||
return new HttpSuccess();
|
||||
}
|
||||
|
||||
/**
|
||||
* API บันทึกตำแหน่งใหม่
|
||||
*
|
||||
* @summary บันทึกตำแหน่งใหม่
|
||||
*
|
||||
*/
|
||||
@Post("report/current")
|
||||
async reportApproveCurrent(
|
||||
@Body()
|
||||
body: {
|
||||
posmasterId: string;
|
||||
positionId: string;
|
||||
profileId: string;
|
||||
},
|
||||
) {
|
||||
const posMaster = await this.employeePosMasterRepository.findOne({
|
||||
where: { id: body.posmasterId },
|
||||
});
|
||||
if (posMaster == null) throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลตำแหน่งนี้");
|
||||
|
||||
const posMasterOld = await this.employeePosMasterRepository.findOne({
|
||||
where: {
|
||||
current_holderId: body.profileId,
|
||||
orgRevisionId: posMaster.orgRevisionId,
|
||||
},
|
||||
});
|
||||
if (posMasterOld != null) posMasterOld.current_holderId = null;
|
||||
if (posMasterOld != null) posMasterOld.next_holderId = null;
|
||||
|
||||
const profile = await this.profileRepository.findOne({
|
||||
where: { id: body.profileId },
|
||||
});
|
||||
if (profile == null)
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลทะเบียนประวัตินี้");
|
||||
|
||||
posMaster.current_holderId = body.profileId;
|
||||
posMaster.next_holderId = body.profileId;
|
||||
if (posMasterOld != null) await this.employeePosMasterRepository.save(posMasterOld);
|
||||
await this.employeePosMasterRepository.save(posMaster);
|
||||
return new HttpSuccess();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3353,4 +3353,32 @@ export class OrganizationController extends Controller {
|
|||
|
||||
return new HttpSuccess(formattedData);
|
||||
}
|
||||
|
||||
/**
|
||||
* API
|
||||
*
|
||||
* @summary (ADMIN)
|
||||
*
|
||||
* @param {string} id
|
||||
*/
|
||||
@Get("approver/{id}")
|
||||
async getUserRootOrg(@Path() id: string, @Request() request: { user: Record<string, any> }) {
|
||||
const root = await this.orgRootRepository.findOne({
|
||||
where: { id: id },
|
||||
});
|
||||
if (!root) throw new HttpError(HttpStatusCode.NOT_FOUND, "not found. Root");
|
||||
const posMaster = await this.posMasterRepository.find({
|
||||
where: { orgRootId: root.id, orgChild1Id: IsNull() },
|
||||
relations: ["current_holder"],
|
||||
});
|
||||
if (!posMaster) throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลตำแหน่ง");
|
||||
|
||||
const maps = posMaster.map((posMaster) => ({
|
||||
Id: posMaster.current_holder.id,
|
||||
Name: `${posMaster.current_holder.prefix}${posMaster.current_holder.firstName} ${posMaster.current_holder.lastName}`,
|
||||
PositionName: posMaster.current_holder.position,
|
||||
}));
|
||||
|
||||
return new HttpSuccess(maps);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -117,8 +117,8 @@ export class OrganizationDotnetController extends Controller {
|
|||
}),
|
||||
);
|
||||
}
|
||||
const profileEmp = await queryBuilder.getMany();
|
||||
return new HttpSuccess(profileEmp);
|
||||
const profileEmp = await queryBuilder.getMany();
|
||||
return new HttpSuccess(profileEmp);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -154,7 +154,7 @@ export class OrganizationDotnetController extends Controller {
|
|||
if (!orgRoot) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
||||
return new HttpSuccess(orgRoot);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 3. API Get Profile จาก keycloak id
|
||||
*
|
||||
|
|
@ -168,14 +168,14 @@ export class OrganizationDotnetController extends Controller {
|
|||
relations: {
|
||||
posLevel: true,
|
||||
posType: true,
|
||||
profileSalary: true
|
||||
profileSalary: true,
|
||||
},
|
||||
where: { keycloak: keycloakId },
|
||||
order:{
|
||||
profileSalary:{
|
||||
date: "DESC"
|
||||
}
|
||||
}
|
||||
order: {
|
||||
profileSalary: {
|
||||
date: "DESC",
|
||||
},
|
||||
},
|
||||
});
|
||||
if (!profile) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
||||
|
||||
|
|
@ -184,26 +184,26 @@ export class OrganizationDotnetController extends Controller {
|
|||
avatar: profile.avatar,
|
||||
avatarName: profile.avatarName,
|
||||
rank: profile.rank,
|
||||
prefix: profile.prefix,
|
||||
firstName: profile.firstName,
|
||||
lastName: profile.lastName,
|
||||
citizenId: profile.citizenId,
|
||||
position: profile.position,
|
||||
posLevelId: profile.posLevelId,
|
||||
email: profile.email,
|
||||
phone: profile.phone,
|
||||
prefix: profile.prefix,
|
||||
firstName: profile.firstName,
|
||||
lastName: profile.lastName,
|
||||
citizenId: profile.citizenId,
|
||||
position: profile.position,
|
||||
posLevelId: profile.posLevelId,
|
||||
email: profile.email,
|
||||
phone: profile.phone,
|
||||
keycloak: profile.keycloak,
|
||||
isProbation: profile.isProbation,
|
||||
isLeave: profile.isLeave,
|
||||
leaveReason: profile.leaveReason,
|
||||
dateRetire: profile.dateRetire,
|
||||
leaveReason: profile.leaveReason,
|
||||
dateRetire: profile.dateRetire,
|
||||
dateAppoint: profile.dateAppoint,
|
||||
dateRetireLaw: profile.dateRetireLaw,
|
||||
dateStart: profile.dateStart,
|
||||
govAgeAbsent: profile.govAgeAbsent,
|
||||
govAgePlus: profile.govAgePlus,
|
||||
birthDate: profile.birthDate,
|
||||
reasonSameDate: profile.reasonSameDate,
|
||||
dateStart: profile.dateStart,
|
||||
govAgeAbsent: profile.govAgeAbsent,
|
||||
govAgePlus: profile.govAgePlus,
|
||||
birthDate: profile.birthDate,
|
||||
reasonSameDate: profile.reasonSameDate,
|
||||
telephoneNumber: profile.telephoneNumber,
|
||||
nationality: profile.nationality,
|
||||
gender: profile.gender,
|
||||
|
|
@ -215,18 +215,16 @@ export class OrganizationDotnetController extends Controller {
|
|||
registrationDistrictId: profile.registrationDistrictId,
|
||||
registrationSubDistrictId: profile.registrationSubDistrictId,
|
||||
registrationZipCode: profile.registrationZipCode,
|
||||
currentAddress: profile.currentAddress,
|
||||
currentProvinceId: profile.currentProvinceId,
|
||||
currentSubDistrictId: profile.currentSubDistrictId,
|
||||
currentZipCode: profile.currentZipCode,
|
||||
dutyTimeId: profile.dutyTimeId,
|
||||
currentAddress: profile.currentAddress,
|
||||
currentProvinceId: profile.currentProvinceId,
|
||||
currentSubDistrictId: profile.currentSubDistrictId,
|
||||
currentZipCode: profile.currentZipCode,
|
||||
dutyTimeId: profile.dutyTimeId,
|
||||
dutyTimeEffectiveDate: profile.dutyTimeEffectiveDate,
|
||||
posLevel: profile.posLevel? profile.posLevel : null,
|
||||
posType: profile.posType? profile.posType : null,
|
||||
profileSalary: profile.profileSalary.length > 0
|
||||
? profile.profileSalary[0]
|
||||
: null
|
||||
}
|
||||
posLevel: profile.posLevel ? profile.posLevel : null,
|
||||
posType: profile.posType ? profile.posType : null,
|
||||
profileSalary: profile.profileSalary.length > 0 ? profile.profileSalary[0] : null,
|
||||
};
|
||||
|
||||
return new HttpSuccess(mapProfile);
|
||||
}
|
||||
|
|
@ -242,10 +240,10 @@ export class OrganizationDotnetController extends Controller {
|
|||
async GetUserFullName(@Path() keycloakId: string) {
|
||||
const profile = await this.profileRepo.findOne({
|
||||
where: { keycloak: keycloakId },
|
||||
select: ["prefix", "firstName", "lastName"]
|
||||
select: ["prefix", "firstName", "lastName"],
|
||||
});
|
||||
if (!profile) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
||||
const fullName = profile? `${profile.prefix}${profile.firstName} ${profile.lastName}` : "-";
|
||||
const fullName = profile ? `${profile.prefix}${profile.firstName} ${profile.lastName}` : "-";
|
||||
return new HttpSuccess(fullName);
|
||||
}
|
||||
|
||||
|
|
@ -296,7 +294,7 @@ export class OrganizationDotnetController extends Controller {
|
|||
root: root == null ? null : root.orgRootName,
|
||||
rootShortName: root == null ? null : root.orgRootShortName,
|
||||
};
|
||||
return new HttpSuccess(profile);
|
||||
return new HttpSuccess(_profile);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -380,7 +378,7 @@ export class OrganizationDotnetController extends Controller {
|
|||
where: {
|
||||
posMasterId: posMaster?.id,
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
const _profile: any = {
|
||||
profileId: profile.id,
|
||||
|
|
@ -462,7 +460,7 @@ export class OrganizationDotnetController extends Controller {
|
|||
where: { id: ocId },
|
||||
});
|
||||
if (!orgRoot) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
||||
const root = orgRoot? orgRoot.id : "";
|
||||
const root = orgRoot ? orgRoot.id : "";
|
||||
return new HttpSuccess(root);
|
||||
}
|
||||
|
||||
|
|
@ -475,25 +473,26 @@ export class OrganizationDotnetController extends Controller {
|
|||
@Get("keycloak")
|
||||
async GetProfileWithKeycloak() {
|
||||
const profile = await this.profileRepo.find({
|
||||
where: { keycloak: Not(IsNull()) || Not(""), },
|
||||
where: { keycloak: Not(IsNull()) || Not("") },
|
||||
});
|
||||
return new HttpSuccess(profile);
|
||||
}
|
||||
|
||||
/**
|
||||
* 4. API Update รอบการลงเวลา ในตาราง profile
|
||||
* 4. API Update รอบการลงเวลา ในตาราง profile
|
||||
*
|
||||
* @summary 4. API Update รอบการลงเวลา ในตาราง profile
|
||||
* @summary 4. API Update รอบการลงเวลา ในตาราง profile
|
||||
*
|
||||
*/
|
||||
@Put("update-dutytime")
|
||||
async UpdateDutyTimeAsync(
|
||||
@Request() req: RequestWithUser,
|
||||
@Body() body: {
|
||||
@Body()
|
||||
body: {
|
||||
profileId: string;
|
||||
roundId: string;
|
||||
effectiveDate: Date;
|
||||
}
|
||||
},
|
||||
) {
|
||||
const profile = await this.profileRepo.findOne({
|
||||
where: { id: body.profileId },
|
||||
|
|
@ -507,5 +506,4 @@ export class OrganizationDotnetController extends Controller {
|
|||
await this.profileRepo.save(profile);
|
||||
return new HttpSuccess();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3267,4 +3267,44 @@ export class PositionController extends Controller {
|
|||
);
|
||||
return new HttpSuccess(data);
|
||||
}
|
||||
|
||||
/**
|
||||
* API บันทึกตำแหน่งใหม่
|
||||
*
|
||||
* @summary บันทึกตำแหน่งใหม่
|
||||
*
|
||||
*/
|
||||
@Post("report/current")
|
||||
async reportApproveCurrent(
|
||||
@Body()
|
||||
body: {
|
||||
posmasterId: string;
|
||||
positionId: string;
|
||||
profileId: string;
|
||||
},
|
||||
) {
|
||||
const posMaster = await this.posMasterRepository.findOne({
|
||||
where: { id: body.posmasterId },
|
||||
});
|
||||
if (posMaster == null) throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลตำแหน่งนี้");
|
||||
|
||||
const posMasterOld = await this.posMasterRepository.findOne({
|
||||
where: {
|
||||
current_holderId: body.profileId,
|
||||
orgRevisionId: posMaster.orgRevisionId,
|
||||
},
|
||||
});
|
||||
if (posMasterOld != null) posMasterOld.current_holderId = null;
|
||||
|
||||
const profile = await this.profileRepository.findOne({
|
||||
where: { id: body.profileId },
|
||||
});
|
||||
if (profile == null)
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลทะเบียนประวัตินี้");
|
||||
|
||||
posMaster.current_holderId = body.profileId;
|
||||
if (posMasterOld != null) await this.posMasterRepository.save(posMasterOld);
|
||||
await this.posMasterRepository.save(posMaster);
|
||||
return new HttpSuccess();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4266,17 +4266,25 @@ export class ProfileController extends Controller {
|
|||
async updateLeaveUser(
|
||||
@Path() id: string,
|
||||
@Body()
|
||||
requestBody: { isLeave: boolean; leaveReason: string; dateLeave: Date },
|
||||
requestBody: { isLeave: boolean; leaveReason?: any; dateLeave?: any },
|
||||
@Request() request: { user: Record<string, any> },
|
||||
) {
|
||||
const profile = await this.profileRepo.findOne({
|
||||
where: { id: id },
|
||||
});
|
||||
if (!profile) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
||||
|
||||
const _null: any = null;
|
||||
profile.isLeave = requestBody.isLeave;
|
||||
profile.leaveReason = requestBody.leaveReason;
|
||||
profile.dateLeave = requestBody.dateLeave;
|
||||
if (profile.leaveReason != undefined && profile.leaveReason != null) {
|
||||
profile.leaveReason = requestBody.leaveReason;
|
||||
} else {
|
||||
profile.leaveReason = _null;
|
||||
}
|
||||
if (profile.dateLeave != undefined && profile.dateLeave != null) {
|
||||
profile.dateLeave = requestBody.dateLeave;
|
||||
} else {
|
||||
profile.dateLeave = _null;
|
||||
}
|
||||
await this.profileRepo.save(profile);
|
||||
|
||||
const profileSalary = await this.salaryRepository.findOne({
|
||||
|
|
@ -4488,7 +4496,7 @@ export class ProfileController extends Controller {
|
|||
return new HttpSuccess(profile);
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* API สร้างทะเบียนประวัติใหม่
|
||||
*
|
||||
* @summary ORG_065 - สร้างทะเบียนประวัติใหม่ (ADMIN) #XXX
|
||||
|
|
@ -4499,11 +4507,16 @@ export class ProfileController extends Controller {
|
|||
@Request() request: RequestWithUser,
|
||||
@Body() body: CreateProfileAllFields,
|
||||
) {
|
||||
const citizen = await this.profileRepo.findOne({
|
||||
where: { citizenId: body.citizenId },
|
||||
select: ["id"],
|
||||
});
|
||||
if (citizen) return new HttpSuccess(citizen.id);
|
||||
const profile: Profile = Object.assign(new Profile(), body);
|
||||
if (body && body.posLevelId) {
|
||||
const findPosLevel = await this.posLevelRepo.findOne({
|
||||
where: { posLevelName: body.posLevelId },
|
||||
select:['id','posLevelName']
|
||||
select: ["id", "posLevelName"],
|
||||
});
|
||||
if (findPosLevel) {
|
||||
profile.posLevelId = findPosLevel.id;
|
||||
|
|
@ -4512,7 +4525,7 @@ export class ProfileController extends Controller {
|
|||
if (body && body.posTypeId) {
|
||||
const findPosType = await this.posTypeRepo.findOne({
|
||||
where: { posTypeName: body.posTypeId },
|
||||
select:['id','posTypeName']
|
||||
select: ["id", "posTypeName"],
|
||||
});
|
||||
if (findPosType) {
|
||||
profile.posTypeId = findPosType.id;
|
||||
|
|
@ -4521,7 +4534,7 @@ export class ProfileController extends Controller {
|
|||
if (body && body.prefix) {
|
||||
const findPrefix = await this.prefixRepo.findOne({
|
||||
where: { name: body.prefix },
|
||||
select:['id','name']
|
||||
select: ["id", "name"],
|
||||
});
|
||||
if (findPrefix) {
|
||||
profile.prefix = findPrefix.id;
|
||||
|
|
@ -4531,25 +4544,25 @@ export class ProfileController extends Controller {
|
|||
if (body && body.currentProvinceId) {
|
||||
const findProvince = await this.provinceRepo.findOne({
|
||||
where: { name: body.currentProvinceId },
|
||||
select:['id','name']
|
||||
select: ["id", "name"],
|
||||
});
|
||||
if (findProvince) {
|
||||
profile.currentProvinceId = findProvince.id;
|
||||
}
|
||||
if (findProvince) {
|
||||
profile.currentProvinceId = findProvince.id;
|
||||
}
|
||||
}
|
||||
if (body && body.currentDistrictId) {
|
||||
const findDistrict = await this.districtRepo.findOne({
|
||||
where: { name: body.currentDistrictId },
|
||||
select:['id','name']
|
||||
select: ["id", "name"],
|
||||
});
|
||||
if (findDistrict) {
|
||||
profile.currentDistrictId = findDistrict.id;
|
||||
}
|
||||
if (findDistrict) {
|
||||
profile.currentDistrictId = findDistrict.id;
|
||||
}
|
||||
}
|
||||
if (body && body.currentSubDistrictId) {
|
||||
const findSubDistrict = await this.subDistrictRepo.findOne({
|
||||
where: { name: body.currentSubDistrictId },
|
||||
select:['id','name']
|
||||
select: ["id", "name"],
|
||||
});
|
||||
if (findSubDistrict) {
|
||||
profile.currentSubDistrictId = findSubDistrict.id;
|
||||
|
|
@ -4559,7 +4572,7 @@ export class ProfileController extends Controller {
|
|||
if (body && body.registrationProvinceId) {
|
||||
const findProvince_regis = await this.provinceRepo.findOne({
|
||||
where: { name: body.registrationProvinceId },
|
||||
select:['id','name']
|
||||
select: ["id", "name"],
|
||||
});
|
||||
if (findProvince_regis) {
|
||||
profile.registrationProvinceId = findProvince_regis.id;
|
||||
|
|
@ -4568,7 +4581,7 @@ export class ProfileController extends Controller {
|
|||
if (body && body.registrationDistrictId) {
|
||||
const findDistrict_regis = await this.districtRepo.findOne({
|
||||
where: { name: body.registrationDistrictId },
|
||||
select:['id','name']
|
||||
select: ["id", "name"],
|
||||
});
|
||||
if (findDistrict_regis) {
|
||||
profile.registrationDistrictId = findDistrict_regis.id;
|
||||
|
|
@ -4577,13 +4590,13 @@ export class ProfileController extends Controller {
|
|||
if (body && body.registrationSubDistrictId) {
|
||||
const findSubDistrict_regis = await this.subDistrictRepo.findOne({
|
||||
where: { name: body.registrationSubDistrictId },
|
||||
select:['id','name']
|
||||
select: ["id", "name"],
|
||||
});
|
||||
if (findSubDistrict_regis) {
|
||||
profile.registrationSubDistrictId = findSubDistrict_regis.id;
|
||||
}
|
||||
if (findSubDistrict_regis) {
|
||||
profile.registrationSubDistrictId = findSubDistrict_regis.id;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
profile.createdUserId = request.user.sub;
|
||||
profile.createdFullName = request.user.name;
|
||||
profile.lastUpdateUserId = request.user.sub;
|
||||
|
|
|
|||
|
|
@ -2705,7 +2705,6 @@ export class ProfileEmployeeController extends Controller {
|
|||
refCommandNo: null,
|
||||
templateDoc: requestBody.leaveReason,
|
||||
});
|
||||
|
||||
|
||||
return new HttpSuccess();
|
||||
}
|
||||
|
|
@ -3032,6 +3031,13 @@ export class ProfileEmployeeController extends Controller {
|
|||
profile.employeeClass = "PERM";
|
||||
await this.profileRepo.save(profile);
|
||||
});
|
||||
await new CallAPI()
|
||||
.PostData(request, "org/employee/pos/report/current", {
|
||||
posmasterId: profile.posmasterIdTemp,
|
||||
positionId: profile.positionIdTemp,
|
||||
profileId: profile.id,
|
||||
})
|
||||
.then(async (x) => {});
|
||||
}
|
||||
}),
|
||||
);
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
Loading…
Add table
Add a link
Reference in a new issue