no message

This commit is contained in:
Kittapath 2024-06-24 10:52:40 +07:00
parent 5a634b4dd3
commit b11be3364f
7 changed files with 201 additions and 125 deletions

View file

@ -1056,7 +1056,7 @@ export class EmployeePositionController extends Controller {
}); });
const authRoleName = await this.authRoleRepo.findOne({ const authRoleName = await this.authRoleRepo.findOne({
where: { id: String(posMaster.authRoleId) } where: { id: String(posMaster.authRoleId) },
}); });
let profile: any; let profile: any;
@ -1149,7 +1149,8 @@ export class EmployeePositionController extends Controller {
profilePoslevel: profilePoslevel:
level == null || type == null ? null : `${type.posTypeShortName} ${level.posLevelName}`, level == null || type == null ? null : `${type.posTypeShortName} ${level.posLevelName}`,
authRoleId: posMaster.authRoleId, 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) => ({ positions: positions.map((position) => ({
id: position.id, id: position.id,
positionName: position.positionName, positionName: position.positionName,
@ -2150,4 +2151,46 @@ export class EmployeePositionController extends Controller {
return new HttpSuccess(); 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();
}
} }

View file

@ -3353,4 +3353,32 @@ export class OrganizationController extends Controller {
return new HttpSuccess(formattedData); 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);
}
} }

View file

@ -117,8 +117,8 @@ export class OrganizationDotnetController extends Controller {
}), }),
); );
} }
const profileEmp = await queryBuilder.getMany(); const profileEmp = await queryBuilder.getMany();
return new HttpSuccess(profileEmp); return new HttpSuccess(profileEmp);
} }
/** /**
@ -154,7 +154,7 @@ export class OrganizationDotnetController extends Controller {
if (!orgRoot) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); if (!orgRoot) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
return new HttpSuccess(orgRoot); return new HttpSuccess(orgRoot);
} }
/** /**
* 3. API Get Profile keycloak id * 3. API Get Profile keycloak id
* *
@ -168,14 +168,14 @@ export class OrganizationDotnetController extends Controller {
relations: { relations: {
posLevel: true, posLevel: true,
posType: true, posType: true,
profileSalary: true profileSalary: true,
}, },
where: { keycloak: keycloakId }, where: { keycloak: keycloakId },
order:{ order: {
profileSalary:{ profileSalary: {
date: "DESC" date: "DESC",
} },
} },
}); });
if (!profile) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); if (!profile) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
@ -184,26 +184,26 @@ export class OrganizationDotnetController extends Controller {
avatar: profile.avatar, avatar: profile.avatar,
avatarName: profile.avatarName, avatarName: profile.avatarName,
rank: profile.rank, rank: profile.rank,
prefix: profile.prefix, prefix: profile.prefix,
firstName: profile.firstName, firstName: profile.firstName,
lastName: profile.lastName, lastName: profile.lastName,
citizenId: profile.citizenId, citizenId: profile.citizenId,
position: profile.position, position: profile.position,
posLevelId: profile.posLevelId, posLevelId: profile.posLevelId,
email: profile.email, email: profile.email,
phone: profile.phone, phone: profile.phone,
keycloak: profile.keycloak, keycloak: profile.keycloak,
isProbation: profile.isProbation, isProbation: profile.isProbation,
isLeave: profile.isLeave, isLeave: profile.isLeave,
leaveReason: profile.leaveReason, leaveReason: profile.leaveReason,
dateRetire: profile.dateRetire, dateRetire: profile.dateRetire,
dateAppoint: profile.dateAppoint, dateAppoint: profile.dateAppoint,
dateRetireLaw: profile.dateRetireLaw, dateRetireLaw: profile.dateRetireLaw,
dateStart: profile.dateStart, dateStart: profile.dateStart,
govAgeAbsent: profile.govAgeAbsent, govAgeAbsent: profile.govAgeAbsent,
govAgePlus: profile.govAgePlus, govAgePlus: profile.govAgePlus,
birthDate: profile.birthDate, birthDate: profile.birthDate,
reasonSameDate: profile.reasonSameDate, reasonSameDate: profile.reasonSameDate,
telephoneNumber: profile.telephoneNumber, telephoneNumber: profile.telephoneNumber,
nationality: profile.nationality, nationality: profile.nationality,
gender: profile.gender, gender: profile.gender,
@ -215,18 +215,16 @@ export class OrganizationDotnetController extends Controller {
registrationDistrictId: profile.registrationDistrictId, registrationDistrictId: profile.registrationDistrictId,
registrationSubDistrictId: profile.registrationSubDistrictId, registrationSubDistrictId: profile.registrationSubDistrictId,
registrationZipCode: profile.registrationZipCode, registrationZipCode: profile.registrationZipCode,
currentAddress: profile.currentAddress, currentAddress: profile.currentAddress,
currentProvinceId: profile.currentProvinceId, currentProvinceId: profile.currentProvinceId,
currentSubDistrictId: profile.currentSubDistrictId, currentSubDistrictId: profile.currentSubDistrictId,
currentZipCode: profile.currentZipCode, currentZipCode: profile.currentZipCode,
dutyTimeId: profile.dutyTimeId, dutyTimeId: profile.dutyTimeId,
dutyTimeEffectiveDate: profile.dutyTimeEffectiveDate, dutyTimeEffectiveDate: profile.dutyTimeEffectiveDate,
posLevel: profile.posLevel? profile.posLevel : null, posLevel: profile.posLevel ? profile.posLevel : null,
posType: profile.posType? profile.posType : null, posType: profile.posType ? profile.posType : null,
profileSalary: profile.profileSalary.length > 0 profileSalary: profile.profileSalary.length > 0 ? profile.profileSalary[0] : null,
? profile.profileSalary[0] };
: null
}
return new HttpSuccess(mapProfile); return new HttpSuccess(mapProfile);
} }
@ -242,10 +240,10 @@ export class OrganizationDotnetController extends Controller {
async GetUserFullName(@Path() keycloakId: string) { async GetUserFullName(@Path() keycloakId: string) {
const profile = await this.profileRepo.findOne({ const profile = await this.profileRepo.findOne({
where: { keycloak: keycloakId }, where: { keycloak: keycloakId },
select: ["prefix", "firstName", "lastName"] select: ["prefix", "firstName", "lastName"],
}); });
if (!profile) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); 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); return new HttpSuccess(fullName);
} }
@ -296,7 +294,7 @@ export class OrganizationDotnetController extends Controller {
root: root == null ? null : root.orgRootName, root: root == null ? null : root.orgRootName,
rootShortName: root == null ? null : root.orgRootShortName, rootShortName: root == null ? null : root.orgRootShortName,
}; };
return new HttpSuccess(profile); return new HttpSuccess(_profile);
} }
/** /**
@ -380,7 +378,7 @@ export class OrganizationDotnetController extends Controller {
where: { where: {
posMasterId: posMaster?.id, posMasterId: posMaster?.id,
}, },
}); });
const _profile: any = { const _profile: any = {
profileId: profile.id, profileId: profile.id,
@ -462,7 +460,7 @@ export class OrganizationDotnetController extends Controller {
where: { id: ocId }, where: { id: ocId },
}); });
if (!orgRoot) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); if (!orgRoot) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
const root = orgRoot? orgRoot.id : ""; const root = orgRoot ? orgRoot.id : "";
return new HttpSuccess(root); return new HttpSuccess(root);
} }
@ -475,25 +473,26 @@ export class OrganizationDotnetController extends Controller {
@Get("keycloak") @Get("keycloak")
async GetProfileWithKeycloak() { async GetProfileWithKeycloak() {
const profile = await this.profileRepo.find({ const profile = await this.profileRepo.find({
where: { keycloak: Not(IsNull()) || Not(""), }, where: { keycloak: Not(IsNull()) || Not("") },
}); });
return new HttpSuccess(profile); 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") @Put("update-dutytime")
async UpdateDutyTimeAsync( async UpdateDutyTimeAsync(
@Request() req: RequestWithUser, @Request() req: RequestWithUser,
@Body() body: { @Body()
body: {
profileId: string; profileId: string;
roundId: string; roundId: string;
effectiveDate: Date; effectiveDate: Date;
} },
) { ) {
const profile = await this.profileRepo.findOne({ const profile = await this.profileRepo.findOne({
where: { id: body.profileId }, where: { id: body.profileId },
@ -507,5 +506,4 @@ export class OrganizationDotnetController extends Controller {
await this.profileRepo.save(profile); await this.profileRepo.save(profile);
return new HttpSuccess(); return new HttpSuccess();
} }
} }

View file

@ -3267,4 +3267,44 @@ export class PositionController extends Controller {
); );
return new HttpSuccess(data); 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();
}
} }

View file

@ -4266,17 +4266,25 @@ export class ProfileController extends Controller {
async updateLeaveUser( async updateLeaveUser(
@Path() id: string, @Path() id: string,
@Body() @Body()
requestBody: { isLeave: boolean; leaveReason: string; dateLeave: Date }, requestBody: { isLeave: boolean; leaveReason?: any; dateLeave?: any },
@Request() request: { user: Record<string, any> }, @Request() request: { user: Record<string, any> },
) { ) {
const profile = await this.profileRepo.findOne({ const profile = await this.profileRepo.findOne({
where: { id: id }, where: { id: id },
}); });
if (!profile) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); if (!profile) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
const _null: any = null;
profile.isLeave = requestBody.isLeave; profile.isLeave = requestBody.isLeave;
profile.leaveReason = requestBody.leaveReason; if (profile.leaveReason != undefined && profile.leaveReason != null) {
profile.dateLeave = requestBody.dateLeave; 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); await this.profileRepo.save(profile);
const profileSalary = await this.salaryRepository.findOne({ const profileSalary = await this.salaryRepository.findOne({
@ -4488,7 +4496,7 @@ export class ProfileController extends Controller {
return new HttpSuccess(profile); return new HttpSuccess(profile);
} }
/** /**
* API * API
* *
* @summary ORG_065 - (ADMIN) #XXX * @summary ORG_065 - (ADMIN) #XXX
@ -4499,11 +4507,16 @@ export class ProfileController extends Controller {
@Request() request: RequestWithUser, @Request() request: RequestWithUser,
@Body() body: CreateProfileAllFields, @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); const profile: Profile = Object.assign(new Profile(), body);
if (body && body.posLevelId) { if (body && body.posLevelId) {
const findPosLevel = await this.posLevelRepo.findOne({ const findPosLevel = await this.posLevelRepo.findOne({
where: { posLevelName: body.posLevelId }, where: { posLevelName: body.posLevelId },
select:['id','posLevelName'] select: ["id", "posLevelName"],
}); });
if (findPosLevel) { if (findPosLevel) {
profile.posLevelId = findPosLevel.id; profile.posLevelId = findPosLevel.id;
@ -4512,7 +4525,7 @@ export class ProfileController extends Controller {
if (body && body.posTypeId) { if (body && body.posTypeId) {
const findPosType = await this.posTypeRepo.findOne({ const findPosType = await this.posTypeRepo.findOne({
where: { posTypeName: body.posTypeId }, where: { posTypeName: body.posTypeId },
select:['id','posTypeName'] select: ["id", "posTypeName"],
}); });
if (findPosType) { if (findPosType) {
profile.posTypeId = findPosType.id; profile.posTypeId = findPosType.id;
@ -4521,7 +4534,7 @@ export class ProfileController extends Controller {
if (body && body.prefix) { if (body && body.prefix) {
const findPrefix = await this.prefixRepo.findOne({ const findPrefix = await this.prefixRepo.findOne({
where: { name: body.prefix }, where: { name: body.prefix },
select:['id','name'] select: ["id", "name"],
}); });
if (findPrefix) { if (findPrefix) {
profile.prefix = findPrefix.id; profile.prefix = findPrefix.id;
@ -4531,25 +4544,25 @@ export class ProfileController extends Controller {
if (body && body.currentProvinceId) { if (body && body.currentProvinceId) {
const findProvince = await this.provinceRepo.findOne({ const findProvince = await this.provinceRepo.findOne({
where: { name: body.currentProvinceId }, where: { name: body.currentProvinceId },
select:['id','name'] select: ["id", "name"],
}); });
if (findProvince) { if (findProvince) {
profile.currentProvinceId = findProvince.id; profile.currentProvinceId = findProvince.id;
} }
} }
if (body && body.currentDistrictId) { if (body && body.currentDistrictId) {
const findDistrict = await this.districtRepo.findOne({ const findDistrict = await this.districtRepo.findOne({
where: { name: body.currentDistrictId }, where: { name: body.currentDistrictId },
select:['id','name'] select: ["id", "name"],
}); });
if (findDistrict) { if (findDistrict) {
profile.currentDistrictId = findDistrict.id; profile.currentDistrictId = findDistrict.id;
} }
} }
if (body && body.currentSubDistrictId) { if (body && body.currentSubDistrictId) {
const findSubDistrict = await this.subDistrictRepo.findOne({ const findSubDistrict = await this.subDistrictRepo.findOne({
where: { name: body.currentSubDistrictId }, where: { name: body.currentSubDistrictId },
select:['id','name'] select: ["id", "name"],
}); });
if (findSubDistrict) { if (findSubDistrict) {
profile.currentSubDistrictId = findSubDistrict.id; profile.currentSubDistrictId = findSubDistrict.id;
@ -4559,7 +4572,7 @@ export class ProfileController extends Controller {
if (body && body.registrationProvinceId) { if (body && body.registrationProvinceId) {
const findProvince_regis = await this.provinceRepo.findOne({ const findProvince_regis = await this.provinceRepo.findOne({
where: { name: body.registrationProvinceId }, where: { name: body.registrationProvinceId },
select:['id','name'] select: ["id", "name"],
}); });
if (findProvince_regis) { if (findProvince_regis) {
profile.registrationProvinceId = findProvince_regis.id; profile.registrationProvinceId = findProvince_regis.id;
@ -4568,7 +4581,7 @@ export class ProfileController extends Controller {
if (body && body.registrationDistrictId) { if (body && body.registrationDistrictId) {
const findDistrict_regis = await this.districtRepo.findOne({ const findDistrict_regis = await this.districtRepo.findOne({
where: { name: body.registrationDistrictId }, where: { name: body.registrationDistrictId },
select:['id','name'] select: ["id", "name"],
}); });
if (findDistrict_regis) { if (findDistrict_regis) {
profile.registrationDistrictId = findDistrict_regis.id; profile.registrationDistrictId = findDistrict_regis.id;
@ -4577,13 +4590,13 @@ export class ProfileController extends Controller {
if (body && body.registrationSubDistrictId) { if (body && body.registrationSubDistrictId) {
const findSubDistrict_regis = await this.subDistrictRepo.findOne({ const findSubDistrict_regis = await this.subDistrictRepo.findOne({
where: { name: body.registrationSubDistrictId }, where: { name: body.registrationSubDistrictId },
select:['id','name'] select: ["id", "name"],
}); });
if (findSubDistrict_regis) { if (findSubDistrict_regis) {
profile.registrationSubDistrictId = findSubDistrict_regis.id; profile.registrationSubDistrictId = findSubDistrict_regis.id;
} }
} }
profile.createdUserId = request.user.sub; profile.createdUserId = request.user.sub;
profile.createdFullName = request.user.name; profile.createdFullName = request.user.name;
profile.lastUpdateUserId = request.user.sub; profile.lastUpdateUserId = request.user.sub;

View file

@ -2705,7 +2705,6 @@ export class ProfileEmployeeController extends Controller {
refCommandNo: null, refCommandNo: null,
templateDoc: requestBody.leaveReason, templateDoc: requestBody.leaveReason,
}); });
return new HttpSuccess(); return new HttpSuccess();
} }
@ -3032,6 +3031,13 @@ export class ProfileEmployeeController extends Controller {
profile.employeeClass = "PERM"; profile.employeeClass = "PERM";
await this.profileRepo.save(profile); 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