error taos
This commit is contained in:
parent
318839c1e9
commit
181f351860
12 changed files with 2553 additions and 3182 deletions
928
package-lock.json
generated
928
package-lock.json
generated
File diff suppressed because it is too large
Load diff
|
|
@ -1,40 +1,22 @@
|
||||||
import {
|
import { Controller, Route, Security, Tags, Body, Request, SuccessResponse, Response, Get, Put, Post, Path, Delete } from "tsoa"
|
||||||
Controller,
|
import { setLogDataDiff } from "../interfaces/utils"
|
||||||
Route,
|
|
||||||
Security,
|
|
||||||
Tags,
|
|
||||||
Body,
|
|
||||||
Request,
|
|
||||||
SuccessResponse,
|
|
||||||
Response,
|
|
||||||
Get,
|
|
||||||
Put,
|
|
||||||
Post,
|
|
||||||
Path,
|
|
||||||
Delete,
|
|
||||||
} from "tsoa";
|
|
||||||
import { setLogDataDiff } from "../interfaces/utils";
|
|
||||||
|
|
||||||
import { AppDataSource } from "../database/data-source";
|
import { AppDataSource } from "../database/data-source"
|
||||||
import HttpSuccess from "../interfaces/http-success";
|
import HttpSuccess from "../interfaces/http-success"
|
||||||
import HttpStatusCode from "../interfaces/http-status";
|
import HttpStatusCode from "../interfaces/http-status"
|
||||||
import HttpError from "../interfaces/http-error";
|
import HttpError from "../interfaces/http-error"
|
||||||
import permission from "../interfaces/permission";
|
import permission from "../interfaces/permission"
|
||||||
import { RequestWithUser } from "../middlewares/user";
|
import { RequestWithUser } from "../middlewares/user"
|
||||||
import { Appoint, CreateAppoint, Person, UpdateAppoint } from "../entities/Appoint";
|
import { Appoint, CreateAppoint, Person, UpdateAppoint } from "../entities/Appoint"
|
||||||
import { AppointDirector } from "../entities/AppointDirector";
|
import { AppointDirector } from "../entities/AppointDirector"
|
||||||
|
|
||||||
@Route("api/v1/probation/appoint")
|
@Route("api/v1/probation/appoint")
|
||||||
@Tags("Appoint Director")
|
@Tags("Appoint Director")
|
||||||
@Security("bearerAuth")
|
@Security("bearerAuth")
|
||||||
@Response(
|
@Response(HttpStatusCode.INTERNAL_SERVER_ERROR, "เกิดข้อผิดพลาด ไม่สามารถแสดงรายการได้ กรุณาลองใหม่ในภายหลัง")
|
||||||
HttpStatusCode.INTERNAL_SERVER_ERROR,
|
|
||||||
"เกิดข้อผิดพลาด ไม่สามารถแสดงรายการได้ กรุณาลองใหม่ในภายหลัง",
|
|
||||||
)
|
|
||||||
@SuccessResponse(HttpStatusCode.OK, "สำเร็จ")
|
|
||||||
export class AppointController extends Controller {
|
export class AppointController extends Controller {
|
||||||
private appointRepository = AppDataSource.getRepository(Appoint);
|
private appointRepository = AppDataSource.getRepository(Appoint)
|
||||||
private appointDirectorRepository = AppDataSource.getRepository(AppointDirector);
|
private appointDirectorRepository = AppDataSource.getRepository(AppointDirector)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* API รายการแต่งตั้งคณะกรรมการฯ ทดลองงาน
|
* API รายการแต่งตั้งคณะกรรมการฯ ทดลองงาน
|
||||||
|
|
@ -44,11 +26,11 @@ export class AppointController extends Controller {
|
||||||
*/
|
*/
|
||||||
@Get("")
|
@Get("")
|
||||||
async GetList(@Request() request: RequestWithUser) {
|
async GetList(@Request() request: RequestWithUser) {
|
||||||
await new permission().PermissionList(request, "SYS_PROBATION");
|
await new permission().PermissionList(request, "SYS_PROBATION")
|
||||||
|
|
||||||
const appoint = await this.appointRepository.find({});
|
const appoint = await this.appointRepository.find({})
|
||||||
|
|
||||||
return new HttpSuccess(appoint);
|
return new HttpSuccess(appoint)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -62,9 +44,9 @@ export class AppointController extends Controller {
|
||||||
const appoint = await this.appointRepository.find({
|
const appoint = await this.appointRepository.find({
|
||||||
relations: ["directors"],
|
relations: ["directors"],
|
||||||
where: { profileId: id, status: "DONE" },
|
where: { profileId: id, status: "DONE" },
|
||||||
});
|
})
|
||||||
|
|
||||||
return new HttpSuccess(appoint);
|
return new HttpSuccess(appoint)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -75,19 +57,19 @@ export class AppointController extends Controller {
|
||||||
*/
|
*/
|
||||||
@Post("")
|
@Post("")
|
||||||
async Create(@Request() request: RequestWithUser, @Body() requestBody: CreateAppoint) {
|
async Create(@Request() request: RequestWithUser, @Body() requestBody: CreateAppoint) {
|
||||||
await new permission().PermissionCreate(request, "SYS_PROBATION");
|
await new permission().PermissionCreate(request, "SYS_PROBATION")
|
||||||
|
|
||||||
const data: any = {
|
const data: any = {
|
||||||
topic: requestBody.topic,
|
topic: requestBody.topic,
|
||||||
profileId: requestBody.profileId,
|
profileId: requestBody.profileId,
|
||||||
createdUserId: request.user.sub,
|
createdUserId: request.user.sub,
|
||||||
createdFullName: request.user.name,
|
createdFullName: request.user.name,
|
||||||
};
|
}
|
||||||
const before = null;
|
const before = null
|
||||||
const appoint = await this.appointRepository.save(data, { data: request });
|
const appoint = await this.appointRepository.save(data, { data: request })
|
||||||
setLogDataDiff(request, { before, after: appoint });
|
setLogDataDiff(request, { before, after: appoint })
|
||||||
|
|
||||||
return new HttpSuccess(appoint.id);
|
return new HttpSuccess(appoint.id)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -98,15 +80,15 @@ export class AppointController extends Controller {
|
||||||
*/
|
*/
|
||||||
@Get("{id}")
|
@Get("{id}")
|
||||||
async GetById(@Request() request: RequestWithUser, @Path() id: string) {
|
async GetById(@Request() request: RequestWithUser, @Path() id: string) {
|
||||||
await new permission().PermissionGet(request, "SYS_PROBATION");
|
await new permission().PermissionGet(request, "SYS_PROBATION")
|
||||||
|
|
||||||
const appoint = await this.appointRepository.findOne({
|
const appoint = await this.appointRepository.findOne({
|
||||||
select: ["id", "topic", "status", "profileId"],
|
select: ["id", "topic", "status", "profileId"],
|
||||||
where: { id },
|
where: { id },
|
||||||
relations: ["directors"],
|
relations: ["directors"],
|
||||||
});
|
})
|
||||||
|
|
||||||
return new HttpSuccess(appoint);
|
return new HttpSuccess(appoint)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -116,26 +98,22 @@ export class AppointController extends Controller {
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Put("{id}")
|
@Put("{id}")
|
||||||
async Update(
|
async Update(@Request() request: RequestWithUser, @Body() requestBody: UpdateAppoint, @Path() id: string) {
|
||||||
@Request() request: RequestWithUser,
|
await new permission().PermissionUpdate(request, "SYS_PROBATION")
|
||||||
@Body() requestBody: UpdateAppoint,
|
|
||||||
@Path() id: string,
|
|
||||||
) {
|
|
||||||
await new permission().PermissionUpdate(request, "SYS_PROBATION");
|
|
||||||
|
|
||||||
const appoint: any = await this.appointRepository.findOne({ where: { id } });
|
const appoint: any = await this.appointRepository.findOne({ where: { id } })
|
||||||
|
|
||||||
if (!appoint) {
|
if (!appoint) {
|
||||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลการแต่งตั้งคณะกรรมการฯ");
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลการแต่งตั้งคณะกรรมการฯ")
|
||||||
}
|
}
|
||||||
|
|
||||||
const before = appoint;
|
const before = appoint
|
||||||
|
|
||||||
appoint.topic = requestBody.topic;
|
appoint.topic = requestBody.topic
|
||||||
appoint.updateUserId = request.user.sub;
|
appoint.updateUserId = request.user.sub
|
||||||
appoint.updateFullName = request.user.name;
|
appoint.updateFullName = request.user.name
|
||||||
|
|
||||||
await this.appointDirectorRepository.delete({ appointId: id });
|
await this.appointDirectorRepository.delete({ appointId: id })
|
||||||
const directors = await requestBody.persons.map((x: Person) => ({
|
const directors = await requestBody.persons.map((x: Person) => ({
|
||||||
...x,
|
...x,
|
||||||
appointId: id,
|
appointId: id,
|
||||||
|
|
@ -143,13 +121,13 @@ export class AppointController extends Controller {
|
||||||
createdFullName: request.user.name,
|
createdFullName: request.user.name,
|
||||||
updateUserId: request.user.sub,
|
updateUserId: request.user.sub,
|
||||||
updateFullName: request.user.name,
|
updateFullName: request.user.name,
|
||||||
}));
|
}))
|
||||||
await this.appointDirectorRepository.save(directors);
|
await this.appointDirectorRepository.save(directors)
|
||||||
|
|
||||||
await this.appointRepository.save(appoint, { data: request });
|
await this.appointRepository.save(appoint, { data: request })
|
||||||
setLogDataDiff(request, { before, after: appoint });
|
setLogDataDiff(request, { before, after: appoint })
|
||||||
|
|
||||||
return new HttpSuccess();
|
return new HttpSuccess()
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -160,13 +138,13 @@ export class AppointController extends Controller {
|
||||||
*/
|
*/
|
||||||
@Delete("{id}")
|
@Delete("{id}")
|
||||||
public async deleteRole(@Path() id: string, @Request() request: RequestWithUser) {
|
public async deleteRole(@Path() id: string, @Request() request: RequestWithUser) {
|
||||||
await new permission().PermissionDelete(request, "SYS_PROBATION");
|
await new permission().PermissionDelete(request, "SYS_PROBATION")
|
||||||
|
|
||||||
await this.appointDirectorRepository.delete({ appointId: id });
|
await this.appointDirectorRepository.delete({ appointId: id })
|
||||||
|
|
||||||
const result = await this.appointRepository.delete({ id });
|
const result = await this.appointRepository.delete({ id })
|
||||||
if (!result) throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล");
|
if (!result) throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล")
|
||||||
|
|
||||||
return new HttpSuccess();
|
return new HttpSuccess()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,60 +1,40 @@
|
||||||
import {
|
import { Controller, Post, Put, Route, Security, Tags, Body, Request, SuccessResponse, Response, Get, Query } from "tsoa"
|
||||||
Controller,
|
import { AppDataSource } from "../database/data-source"
|
||||||
Post,
|
import HttpSuccess from "../interfaces/http-success"
|
||||||
Put,
|
import HttpStatusCode from "../interfaces/http-status"
|
||||||
Route,
|
import HttpError from "../interfaces/http-error"
|
||||||
Security,
|
import { RequestWithUser } from "../middlewares/user"
|
||||||
Tags,
|
import { findEndDate, setLogDataDiff } from "../interfaces/utils"
|
||||||
Body,
|
import { Personal } from "../entities/Personal"
|
||||||
Request,
|
import permission from "../interfaces/permission"
|
||||||
SuccessResponse,
|
import { Assign, CreateAssign } from "../entities/Assign"
|
||||||
Response,
|
import { AssignDirector, CreateAssignDirector } from "../entities/AssignDirector"
|
||||||
Get,
|
import { AssignJob, CreateAssignJob } from "../entities/AssignJob"
|
||||||
Query,
|
import { AssignKnowledge, CreateAssignKnowledge } from "../entities/AssignKnowledge"
|
||||||
} from "tsoa";
|
import { AssignLaw, CreateAssignLaw } from "../entities/AssignLaw"
|
||||||
import { AppDataSource } from "../database/data-source";
|
import { AssignSkill, CreateAssignSkill } from "../entities/AssignSkill"
|
||||||
import HttpSuccess from "../interfaces/http-success";
|
import { AssignCompetency, CreateAssignCompetency } from "../entities/AssignCompetency"
|
||||||
import HttpStatusCode from "../interfaces/http-status";
|
import { AssignCompetencyGroup, CreateAssignCompetencyGroup } from "../entities/AssignCompetencyGroup"
|
||||||
import HttpError from "../interfaces/http-error";
|
import { AssignOutput, CreateAssignOutput } from "../entities/AssignOutput"
|
||||||
import { RequestWithUser } from "../middlewares/user";
|
import { Law } from "../entities/Law"
|
||||||
import { findEndDate, setLogDataDiff } from "../interfaces/utils";
|
import CallAPI from "../interfaces/call-api"
|
||||||
import { Personal } from "../entities/Personal";
|
|
||||||
import permission from "../interfaces/permission";
|
|
||||||
import { Assign, CreateAssign } from "../entities/Assign";
|
|
||||||
import { AssignDirector, CreateAssignDirector } from "../entities/AssignDirector";
|
|
||||||
import { AssignJob, CreateAssignJob } from "../entities/AssignJob";
|
|
||||||
import { AssignKnowledge, CreateAssignKnowledge } from "../entities/AssignKnowledge";
|
|
||||||
import { AssignLaw, CreateAssignLaw } from "../entities/AssignLaw";
|
|
||||||
import { AssignSkill, CreateAssignSkill } from "../entities/AssignSkill";
|
|
||||||
import { AssignCompetency, CreateAssignCompetency } from "../entities/AssignCompetency";
|
|
||||||
import {
|
|
||||||
AssignCompetencyGroup,
|
|
||||||
CreateAssignCompetencyGroup,
|
|
||||||
} from "../entities/AssignCompetencyGroup";
|
|
||||||
import { AssignOutput, CreateAssignOutput } from "../entities/AssignOutput";
|
|
||||||
import { Law } from "../entities/Law";
|
|
||||||
import CallAPI from "../interfaces/call-api";
|
|
||||||
|
|
||||||
@Route("api/v1/probation/assign")
|
@Route("api/v1/probation/assign")
|
||||||
@Tags("ฟอร์มมอบหมายงาน")
|
@Tags("ฟอร์มมอบหมายงาน")
|
||||||
@Security("bearerAuth")
|
@Security("bearerAuth")
|
||||||
@Response(
|
@Response(HttpStatusCode.INTERNAL_SERVER_ERROR, "เกิดข้อผิดพลาด ไม่สามารถแสดงรายการได้ กรุณาลองใหม่ในภายหลัง")
|
||||||
HttpStatusCode.INTERNAL_SERVER_ERROR,
|
|
||||||
"เกิดข้อผิดพลาด ไม่สามารถแสดงรายการได้ กรุณาลองใหม่ในภายหลัง",
|
|
||||||
)
|
|
||||||
@SuccessResponse(HttpStatusCode.OK, "สำเร็จ")
|
|
||||||
export class AssignController extends Controller {
|
export class AssignController extends Controller {
|
||||||
private assignRepository = AppDataSource.getRepository(Assign);
|
private assignRepository = AppDataSource.getRepository(Assign)
|
||||||
private personalRepository = AppDataSource.getRepository(Personal);
|
private personalRepository = AppDataSource.getRepository(Personal)
|
||||||
private assignDirectorRepository = AppDataSource.getRepository(AssignDirector);
|
private assignDirectorRepository = AppDataSource.getRepository(AssignDirector)
|
||||||
private assignJobRepository = AppDataSource.getRepository(AssignJob);
|
private assignJobRepository = AppDataSource.getRepository(AssignJob)
|
||||||
private assignKnowledgeRepository = AppDataSource.getRepository(AssignKnowledge);
|
private assignKnowledgeRepository = AppDataSource.getRepository(AssignKnowledge)
|
||||||
private assignLawRepository = AppDataSource.getRepository(AssignLaw);
|
private assignLawRepository = AppDataSource.getRepository(AssignLaw)
|
||||||
private assignSkillRepository = AppDataSource.getRepository(AssignSkill);
|
private assignSkillRepository = AppDataSource.getRepository(AssignSkill)
|
||||||
private assignCompetencyRepository = AppDataSource.getRepository(AssignCompetency);
|
private assignCompetencyRepository = AppDataSource.getRepository(AssignCompetency)
|
||||||
private assignCompetencyGroupRepository = AppDataSource.getRepository(AssignCompetencyGroup);
|
private assignCompetencyGroupRepository = AppDataSource.getRepository(AssignCompetencyGroup)
|
||||||
private assignOutputRepository = AppDataSource.getRepository(AssignOutput);
|
private assignOutputRepository = AppDataSource.getRepository(AssignOutput)
|
||||||
private lawsRepository = AppDataSource.getRepository(Law);
|
private lawsRepository = AppDataSource.getRepository(Law)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* API เพิ่มข้อมูลการมอบหมายงาน
|
* API เพิ่มข้อมูลการมอบหมายงาน
|
||||||
|
|
@ -64,15 +44,15 @@ export class AssignController extends Controller {
|
||||||
*/
|
*/
|
||||||
@Post("")
|
@Post("")
|
||||||
async AddAssign(@Request() request: RequestWithUser, @Body() requestBody: CreateAssign) {
|
async AddAssign(@Request() request: RequestWithUser, @Body() requestBody: CreateAssign) {
|
||||||
await new permission().PermissionUpdate(request, "SYS_PROBATION");
|
await new permission().PermissionUpdate(request, "SYS_PROBATION")
|
||||||
const person = await this.personalRepository.findOne({
|
const person = await this.personalRepository.findOne({
|
||||||
where: {
|
where: {
|
||||||
personal_id: requestBody.personalId,
|
personal_id: requestBody.personalId,
|
||||||
},
|
},
|
||||||
});
|
})
|
||||||
|
|
||||||
if (!person) {
|
if (!person) {
|
||||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลบุคคล");
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลบุคคล")
|
||||||
}
|
}
|
||||||
|
|
||||||
const roundNo = await this.assignRepository.count({
|
const roundNo = await this.assignRepository.count({
|
||||||
|
|
@ -80,7 +60,7 @@ export class AssignController extends Controller {
|
||||||
active: 1,
|
active: 1,
|
||||||
personal_id: requestBody.personalId,
|
personal_id: requestBody.personalId,
|
||||||
},
|
},
|
||||||
});
|
})
|
||||||
|
|
||||||
const data: any = {
|
const data: any = {
|
||||||
...requestBody,
|
...requestBody,
|
||||||
|
|
@ -90,10 +70,10 @@ export class AssignController extends Controller {
|
||||||
createdFullName: request.user.name,
|
createdFullName: request.user.name,
|
||||||
updateUserId: request.user.sub,
|
updateUserId: request.user.sub,
|
||||||
updateFullName: request.user.name,
|
updateFullName: request.user.name,
|
||||||
};
|
}
|
||||||
const before = null;
|
const before = null
|
||||||
const assign = await this.assignRepository.save(data, { data: request });
|
const assign = await this.assignRepository.save(data, { data: request })
|
||||||
setLogDataDiff(request, { before, after: data });
|
setLogDataDiff(request, { before, after: data })
|
||||||
|
|
||||||
const jobs = await requestBody.assign_jobs.map((x: CreateAssignJob, index: number) => ({
|
const jobs = await requestBody.assign_jobs.map((x: CreateAssignJob, index: number) => ({
|
||||||
...x,
|
...x,
|
||||||
|
|
@ -103,12 +83,11 @@ export class AssignController extends Controller {
|
||||||
createdFullName: request.user.name,
|
createdFullName: request.user.name,
|
||||||
updateUserId: request.user.sub,
|
updateUserId: request.user.sub,
|
||||||
updateFullName: request.user.name,
|
updateFullName: request.user.name,
|
||||||
}));
|
}))
|
||||||
await this.assignJobRepository.save(jobs, { data: request });
|
await this.assignJobRepository.save(jobs, { data: request })
|
||||||
setLogDataDiff(request, { before, after: jobs });
|
setLogDataDiff(request, { before, after: jobs })
|
||||||
|
|
||||||
const knowledges = await requestBody.assign_knowledges.map(
|
const knowledges = await requestBody.assign_knowledges.map((x: CreateAssignKnowledge, index: number) => ({
|
||||||
(x: CreateAssignKnowledge, index: number) => ({
|
|
||||||
knowledge_level: x.level,
|
knowledge_level: x.level,
|
||||||
knowledge_id: x.id,
|
knowledge_id: x.id,
|
||||||
assign_id: assign.id,
|
assign_id: assign.id,
|
||||||
|
|
@ -116,10 +95,9 @@ export class AssignController extends Controller {
|
||||||
createdFullName: request.user.name,
|
createdFullName: request.user.name,
|
||||||
updateUserId: request.user.sub,
|
updateUserId: request.user.sub,
|
||||||
updateFullName: request.user.name,
|
updateFullName: request.user.name,
|
||||||
}),
|
}))
|
||||||
);
|
await this.assignKnowledgeRepository.save(knowledges, { data: request })
|
||||||
await this.assignKnowledgeRepository.save(knowledges, { data: request });
|
setLogDataDiff(request, { before, after: knowledges })
|
||||||
setLogDataDiff(request, { before, after: knowledges });
|
|
||||||
|
|
||||||
const laws = await requestBody.assign_law.map((x: CreateAssignLaw, index: number) => ({
|
const laws = await requestBody.assign_law.map((x: CreateAssignLaw, index: number) => ({
|
||||||
ordering: index + 1,
|
ordering: index + 1,
|
||||||
|
|
@ -129,9 +107,9 @@ export class AssignController extends Controller {
|
||||||
createdFullName: request.user.name,
|
createdFullName: request.user.name,
|
||||||
updateUserId: request.user.sub,
|
updateUserId: request.user.sub,
|
||||||
updateFullName: request.user.name,
|
updateFullName: request.user.name,
|
||||||
}));
|
}))
|
||||||
await this.assignLawRepository.save(laws, { data: request });
|
await this.assignLawRepository.save(laws, { data: request })
|
||||||
setLogDataDiff(request, { before, after: laws });
|
setLogDataDiff(request, { before, after: laws })
|
||||||
|
|
||||||
const skills = await requestBody.assign_skill.map((x: CreateAssignSkill, index: number) => ({
|
const skills = await requestBody.assign_skill.map((x: CreateAssignSkill, index: number) => ({
|
||||||
skill_id: index + 1,
|
skill_id: index + 1,
|
||||||
|
|
@ -141,12 +119,11 @@ export class AssignController extends Controller {
|
||||||
createdFullName: request.user.name,
|
createdFullName: request.user.name,
|
||||||
updateUserId: request.user.sub,
|
updateUserId: request.user.sub,
|
||||||
updateFullName: request.user.name,
|
updateFullName: request.user.name,
|
||||||
}));
|
}))
|
||||||
await this.assignSkillRepository.save(skills, { data: request });
|
await this.assignSkillRepository.save(skills, { data: request })
|
||||||
setLogDataDiff(request, { before, after: skills });
|
setLogDataDiff(request, { before, after: skills })
|
||||||
|
|
||||||
const competencise = await requestBody.assign_competency.map(
|
const competencise = await requestBody.assign_competency.map((x: CreateAssignCompetency, index: number) => ({
|
||||||
(x: CreateAssignCompetency, index: number) => ({
|
|
||||||
competency_id: x.id,
|
competency_id: x.id,
|
||||||
competency_level: x.level,
|
competency_level: x.level,
|
||||||
competency_name: x.name,
|
competency_name: x.name,
|
||||||
|
|
@ -156,13 +133,11 @@ export class AssignController extends Controller {
|
||||||
createdFullName: request.user.name,
|
createdFullName: request.user.name,
|
||||||
updateUserId: request.user.sub,
|
updateUserId: request.user.sub,
|
||||||
updateFullName: request.user.name,
|
updateFullName: request.user.name,
|
||||||
}),
|
}))
|
||||||
);
|
await this.assignCompetencyRepository.save(competencise, { data: request })
|
||||||
await this.assignCompetencyRepository.save(competencise, { data: request });
|
setLogDataDiff(request, { before, after: competencise })
|
||||||
setLogDataDiff(request, { before, after: competencise });
|
|
||||||
|
|
||||||
const competencyGroups = await requestBody.assign_competency_group.map(
|
const competencyGroups = await requestBody.assign_competency_group.map((x: CreateAssignCompetencyGroup, index: number) => ({
|
||||||
(x: CreateAssignCompetencyGroup, index: number) => ({
|
|
||||||
competency_group_id: x.id,
|
competency_group_id: x.id,
|
||||||
competency_group_level: x.level,
|
competency_group_level: x.level,
|
||||||
competency_group_name: x.name,
|
competency_group_name: x.name,
|
||||||
|
|
@ -172,15 +147,13 @@ export class AssignController extends Controller {
|
||||||
createdFullName: request.user.name,
|
createdFullName: request.user.name,
|
||||||
updateUserId: request.user.sub,
|
updateUserId: request.user.sub,
|
||||||
updateFullName: request.user.name,
|
updateFullName: request.user.name,
|
||||||
}),
|
}))
|
||||||
);
|
|
||||||
await this.assignCompetencyGroupRepository.save(competencyGroups, {
|
await this.assignCompetencyGroupRepository.save(competencyGroups, {
|
||||||
data: request,
|
data: request,
|
||||||
});
|
})
|
||||||
setLogDataDiff(request, { before, after: competencyGroups });
|
setLogDataDiff(request, { before, after: competencyGroups })
|
||||||
|
|
||||||
const outputs = await requestBody.assign_outputs.map(
|
const outputs = await requestBody.assign_outputs.map((x: CreateAssignOutput, index: number) => ({
|
||||||
(x: CreateAssignOutput, index: number) => ({
|
|
||||||
...x,
|
...x,
|
||||||
id: index + 1,
|
id: index + 1,
|
||||||
assign_id: assign.id,
|
assign_id: assign.id,
|
||||||
|
|
@ -188,13 +161,11 @@ export class AssignController extends Controller {
|
||||||
createdFullName: request.user.name,
|
createdFullName: request.user.name,
|
||||||
updateUserId: request.user.sub,
|
updateUserId: request.user.sub,
|
||||||
updateFullName: request.user.name,
|
updateFullName: request.user.name,
|
||||||
}),
|
}))
|
||||||
);
|
await this.assignOutputRepository.save(outputs, { data: request })
|
||||||
await this.assignOutputRepository.save(outputs, { data: request });
|
setLogDataDiff(request, { before, after: outputs })
|
||||||
setLogDataDiff(request, { before, after: outputs });
|
|
||||||
|
|
||||||
const directors = await requestBody.assign_director.map(
|
const directors = await requestBody.assign_director.map((x: CreateAssignDirector, index: number) => ({
|
||||||
(x: CreateAssignDirector, index: number) => ({
|
|
||||||
...x,
|
...x,
|
||||||
assign_id: assign.id,
|
assign_id: assign.id,
|
||||||
fullname: x.name,
|
fullname: x.name,
|
||||||
|
|
@ -203,12 +174,11 @@ export class AssignController extends Controller {
|
||||||
createdFullName: request.user.name,
|
createdFullName: request.user.name,
|
||||||
updateUserId: request.user.sub,
|
updateUserId: request.user.sub,
|
||||||
updateFullName: request.user.name,
|
updateFullName: request.user.name,
|
||||||
}),
|
}))
|
||||||
);
|
await this.assignDirectorRepository.save(directors, { data: request })
|
||||||
await this.assignDirectorRepository.save(directors, { data: request });
|
setLogDataDiff(request, { before, after: directors })
|
||||||
setLogDataDiff(request, { before, after: directors });
|
|
||||||
|
|
||||||
return new HttpSuccess();
|
return new HttpSuccess()
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -218,30 +188,26 @@ export class AssignController extends Controller {
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Put("")
|
@Put("")
|
||||||
async EditAssign(
|
async EditAssign(@Query() assign_id: string, @Request() request: RequestWithUser, @Body() requestBody: CreateAssign) {
|
||||||
@Query() assign_id: string,
|
await new permission().PermissionUpdate(request, "SYS_PROBATION")
|
||||||
@Request() request: RequestWithUser,
|
|
||||||
@Body() requestBody: CreateAssign,
|
|
||||||
) {
|
|
||||||
await new permission().PermissionUpdate(request, "SYS_PROBATION");
|
|
||||||
|
|
||||||
const assign = await this.assignRepository.findOne({
|
const assign = await this.assignRepository.findOne({
|
||||||
where: { id: assign_id },
|
where: { id: assign_id },
|
||||||
});
|
})
|
||||||
let before = assign;
|
let before = assign
|
||||||
|
|
||||||
if (!assign) {
|
if (!assign) {
|
||||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลแบบมอบหมายงาน");
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลแบบมอบหมายงาน")
|
||||||
}
|
}
|
||||||
|
|
||||||
const person = await this.personalRepository.findOne({
|
const person = await this.personalRepository.findOne({
|
||||||
where: {
|
where: {
|
||||||
personal_id: requestBody.personalId,
|
personal_id: requestBody.personalId,
|
||||||
},
|
},
|
||||||
});
|
})
|
||||||
|
|
||||||
if (!person) {
|
if (!person) {
|
||||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลบุคคล");
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลบุคคล")
|
||||||
}
|
}
|
||||||
|
|
||||||
const data: any = {
|
const data: any = {
|
||||||
|
|
@ -249,9 +215,9 @@ export class AssignController extends Controller {
|
||||||
id: assign_id,
|
id: assign_id,
|
||||||
updateUserId: request.user.sub,
|
updateUserId: request.user.sub,
|
||||||
updateFullName: request.user.name,
|
updateFullName: request.user.name,
|
||||||
};
|
}
|
||||||
|
|
||||||
await this.assignJobRepository.delete({ assign_id });
|
await this.assignJobRepository.delete({ assign_id })
|
||||||
const jobs = await requestBody.assign_jobs.map((x: CreateAssignJob, index: number) => ({
|
const jobs = await requestBody.assign_jobs.map((x: CreateAssignJob, index: number) => ({
|
||||||
...x,
|
...x,
|
||||||
id: index + 1,
|
id: index + 1,
|
||||||
|
|
@ -260,12 +226,11 @@ export class AssignController extends Controller {
|
||||||
createdFullName: request.user.name,
|
createdFullName: request.user.name,
|
||||||
updateUserId: request.user.sub,
|
updateUserId: request.user.sub,
|
||||||
updateFullName: request.user.name,
|
updateFullName: request.user.name,
|
||||||
}));
|
}))
|
||||||
await this.assignJobRepository.save(jobs);
|
await this.assignJobRepository.save(jobs)
|
||||||
|
|
||||||
await this.assignKnowledgeRepository.delete({ assign_id });
|
await this.assignKnowledgeRepository.delete({ assign_id })
|
||||||
const knowledges = await requestBody.assign_knowledges.map(
|
const knowledges = await requestBody.assign_knowledges.map((x: CreateAssignKnowledge, index: number) => ({
|
||||||
(x: CreateAssignKnowledge, index: number) => ({
|
|
||||||
knowledge_level: x.level,
|
knowledge_level: x.level,
|
||||||
knowledge_id: x.id,
|
knowledge_id: x.id,
|
||||||
assign_id: assign.id,
|
assign_id: assign.id,
|
||||||
|
|
@ -273,11 +238,10 @@ export class AssignController extends Controller {
|
||||||
createdFullName: request.user.name,
|
createdFullName: request.user.name,
|
||||||
updateUserId: request.user.sub,
|
updateUserId: request.user.sub,
|
||||||
updateFullName: request.user.name,
|
updateFullName: request.user.name,
|
||||||
}),
|
}))
|
||||||
);
|
await this.assignKnowledgeRepository.save(knowledges)
|
||||||
await this.assignKnowledgeRepository.save(knowledges);
|
|
||||||
|
|
||||||
await this.assignLawRepository.delete({ assign_id });
|
await this.assignLawRepository.delete({ assign_id })
|
||||||
const laws = await requestBody.assign_law.map((x: CreateAssignLaw, index: number) => ({
|
const laws = await requestBody.assign_law.map((x: CreateAssignLaw, index: number) => ({
|
||||||
ordering: index + 1,
|
ordering: index + 1,
|
||||||
law_id: x.id,
|
law_id: x.id,
|
||||||
|
|
@ -286,10 +250,10 @@ export class AssignController extends Controller {
|
||||||
createdFullName: request.user.name,
|
createdFullName: request.user.name,
|
||||||
updateUserId: request.user.sub,
|
updateUserId: request.user.sub,
|
||||||
updateFullName: request.user.name,
|
updateFullName: request.user.name,
|
||||||
}));
|
}))
|
||||||
await this.assignLawRepository.save(laws);
|
await this.assignLawRepository.save(laws)
|
||||||
|
|
||||||
await this.assignSkillRepository.delete({ assign_id });
|
await this.assignSkillRepository.delete({ assign_id })
|
||||||
const skills = await requestBody.assign_skill.map((x: CreateAssignSkill, index: number) => ({
|
const skills = await requestBody.assign_skill.map((x: CreateAssignSkill, index: number) => ({
|
||||||
skill_id: index + 1,
|
skill_id: index + 1,
|
||||||
skill_level: x.level,
|
skill_level: x.level,
|
||||||
|
|
@ -298,12 +262,11 @@ export class AssignController extends Controller {
|
||||||
createdFullName: request.user.name,
|
createdFullName: request.user.name,
|
||||||
updateUserId: request.user.sub,
|
updateUserId: request.user.sub,
|
||||||
updateFullName: request.user.name,
|
updateFullName: request.user.name,
|
||||||
}));
|
}))
|
||||||
await this.assignSkillRepository.save(skills);
|
await this.assignSkillRepository.save(skills)
|
||||||
|
|
||||||
await this.assignCompetencyRepository.delete({ assign_id });
|
await this.assignCompetencyRepository.delete({ assign_id })
|
||||||
const competencise = await requestBody.assign_competency.map(
|
const competencise = await requestBody.assign_competency.map((x: CreateAssignCompetency, index: number) => ({
|
||||||
(x: CreateAssignCompetency, index: number) => ({
|
|
||||||
competency_id: x.id,
|
competency_id: x.id,
|
||||||
competency_level: x.level,
|
competency_level: x.level,
|
||||||
competency_name: x.name,
|
competency_name: x.name,
|
||||||
|
|
@ -313,13 +276,11 @@ export class AssignController extends Controller {
|
||||||
createdFullName: request.user.name,
|
createdFullName: request.user.name,
|
||||||
updateUserId: request.user.sub,
|
updateUserId: request.user.sub,
|
||||||
updateFullName: request.user.name,
|
updateFullName: request.user.name,
|
||||||
}),
|
}))
|
||||||
);
|
await this.assignCompetencyRepository.save(competencise)
|
||||||
await this.assignCompetencyRepository.save(competencise);
|
|
||||||
|
|
||||||
await this.assignCompetencyGroupRepository.delete({ assign_id });
|
await this.assignCompetencyGroupRepository.delete({ assign_id })
|
||||||
const competencyGroups = await requestBody.assign_competency_group.map(
|
const competencyGroups = await requestBody.assign_competency_group.map((x: CreateAssignCompetencyGroup, index: number) => ({
|
||||||
(x: CreateAssignCompetencyGroup, index: number) => ({
|
|
||||||
competency_group_id: x.id,
|
competency_group_id: x.id,
|
||||||
competency_group_level: x.level,
|
competency_group_level: x.level,
|
||||||
competency_group_name: x.name,
|
competency_group_name: x.name,
|
||||||
|
|
@ -329,13 +290,11 @@ export class AssignController extends Controller {
|
||||||
createdFullName: request.user.name,
|
createdFullName: request.user.name,
|
||||||
updateUserId: request.user.sub,
|
updateUserId: request.user.sub,
|
||||||
updateFullName: request.user.name,
|
updateFullName: request.user.name,
|
||||||
}),
|
}))
|
||||||
);
|
await this.assignCompetencyGroupRepository.save(competencyGroups)
|
||||||
await this.assignCompetencyGroupRepository.save(competencyGroups);
|
|
||||||
|
|
||||||
await this.assignOutputRepository.delete({ assign_id });
|
await this.assignOutputRepository.delete({ assign_id })
|
||||||
const outputs = await requestBody.assign_outputs.map(
|
const outputs = await requestBody.assign_outputs.map((x: CreateAssignOutput, index: number) => ({
|
||||||
(x: CreateAssignOutput, index: number) => ({
|
|
||||||
...x,
|
...x,
|
||||||
id: index + 1,
|
id: index + 1,
|
||||||
assign_id: assign.id,
|
assign_id: assign.id,
|
||||||
|
|
@ -343,13 +302,11 @@ export class AssignController extends Controller {
|
||||||
createdFullName: request.user.name,
|
createdFullName: request.user.name,
|
||||||
updateUserId: request.user.sub,
|
updateUserId: request.user.sub,
|
||||||
updateFullName: request.user.name,
|
updateFullName: request.user.name,
|
||||||
}),
|
}))
|
||||||
);
|
await this.assignOutputRepository.save(outputs)
|
||||||
await this.assignOutputRepository.save(outputs);
|
|
||||||
|
|
||||||
await this.assignDirectorRepository.delete({ assign_id });
|
await this.assignDirectorRepository.delete({ assign_id })
|
||||||
const directors = await requestBody.assign_director.map(
|
const directors = await requestBody.assign_director.map((x: CreateAssignDirector, index: number) => ({
|
||||||
(x: CreateAssignDirector, index: number) => ({
|
|
||||||
...x,
|
...x,
|
||||||
assign_id: assign.id,
|
assign_id: assign.id,
|
||||||
fullname: x.name,
|
fullname: x.name,
|
||||||
|
|
@ -358,19 +315,18 @@ export class AssignController extends Controller {
|
||||||
createdFullName: request.user.name,
|
createdFullName: request.user.name,
|
||||||
updateUserId: request.user.sub,
|
updateUserId: request.user.sub,
|
||||||
updateFullName: request.user.name,
|
updateFullName: request.user.name,
|
||||||
}),
|
}))
|
||||||
);
|
await this.assignDirectorRepository.save(directors)
|
||||||
await this.assignDirectorRepository.save(directors);
|
|
||||||
|
|
||||||
await this.assignRepository.save(data, { data: request });
|
await this.assignRepository.save(data, { data: request })
|
||||||
setLogDataDiff(request, { before, after: data });
|
setLogDataDiff(request, { before, after: data })
|
||||||
|
|
||||||
// #noted cronjob
|
// #noted cronjob
|
||||||
// แจ้งผู้ดูแลและผู้บังคับบัญชาเข้ามาบันทึกผลทุก 2 เดือน
|
// แจ้งผู้ดูแลและผู้บังคับบัญชาเข้ามาบันทึกผลทุก 2 เดือน
|
||||||
const dateSaveForm = await findEndDate(2, requestBody.date_start);
|
const dateSaveForm = await findEndDate(2, requestBody.date_start)
|
||||||
requestBody.assign_director
|
requestBody.assign_director
|
||||||
.filter((x) => x.role == "mentor" || x.role == "commander")
|
.filter(x => x.role == "mentor" || x.role == "commander")
|
||||||
.map(async (director) => {
|
.map(async director => {
|
||||||
await new CallAPI()
|
await new CallAPI()
|
||||||
.PostData(request, "/placement/noti", {
|
.PostData(request, "/placement/noti", {
|
||||||
subject: `ถึงกำหนดบันทึกผลการทดลองปฏิบัติหน้าที่ราชการครั้งที่ 1 ${requestBody.fullname}`,
|
subject: `ถึงกำหนดบันทึกผลการทดลองปฏิบัติหน้าที่ราชการครั้งที่ 1 ${requestBody.fullname}`,
|
||||||
|
|
@ -381,16 +337,16 @@ export class AssignController extends Controller {
|
||||||
isSendInbox: true,
|
isSendInbox: true,
|
||||||
receiveDate: dateSaveForm,
|
receiveDate: dateSaveForm,
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch(error => {
|
||||||
console.error("Error calling API:", error);
|
console.error("Error calling API:", error)
|
||||||
});
|
})
|
||||||
});
|
})
|
||||||
|
|
||||||
// แจ้งผู้บังคับบัญชา และคณะกรรมการเข้ามาประเมินทุก 3 เดือน
|
// แจ้งผู้บังคับบัญชา และคณะกรรมการเข้ามาประเมินทุก 3 เดือน
|
||||||
const dateEvaluate = await findEndDate(3, requestBody.date_start);
|
const dateEvaluate = await findEndDate(3, requestBody.date_start)
|
||||||
requestBody.assign_director
|
requestBody.assign_director
|
||||||
.filter((x) => x.role == "commander" || x.role == "chairman")
|
.filter(x => x.role == "commander" || x.role == "chairman")
|
||||||
.map(async (director) => {
|
.map(async director => {
|
||||||
await new CallAPI()
|
await new CallAPI()
|
||||||
.PostData(request, "/placement/noti", {
|
.PostData(request, "/placement/noti", {
|
||||||
subject: `ถึงกำหนดประเมินผลการทดลองปฏิบัติหน้าที่ราชการครั้งที่ 1 ${requestBody.fullname}`,
|
subject: `ถึงกำหนดประเมินผลการทดลองปฏิบัติหน้าที่ราชการครั้งที่ 1 ${requestBody.fullname}`,
|
||||||
|
|
@ -401,16 +357,16 @@ export class AssignController extends Controller {
|
||||||
isSendInbox: true,
|
isSendInbox: true,
|
||||||
receiveDate: dateEvaluate,
|
receiveDate: dateEvaluate,
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch(error => {
|
||||||
console.error("Error calling API:", error);
|
console.error("Error calling API:", error)
|
||||||
});
|
})
|
||||||
});
|
})
|
||||||
|
|
||||||
// แจ้งประธาน 6 เดือน
|
// แจ้งประธาน 6 เดือน
|
||||||
const dateResult = await findEndDate(6, requestBody.date_start);
|
const dateResult = await findEndDate(6, requestBody.date_start)
|
||||||
requestBody.assign_director
|
requestBody.assign_director
|
||||||
.filter((x) => x.role == "chairman")
|
.filter(x => x.role == "chairman")
|
||||||
.map(async (director) => {
|
.map(async director => {
|
||||||
await new CallAPI()
|
await new CallAPI()
|
||||||
.PostData(request, "/placement/noti", {
|
.PostData(request, "/placement/noti", {
|
||||||
subject: `ถึงกำหนดรายงานการประเมินผลการทดลองปฏิบัติหน้าที่ราชการ ${requestBody.fullname}`,
|
subject: `ถึงกำหนดรายงานการประเมินผลการทดลองปฏิบัติหน้าที่ราชการ ${requestBody.fullname}`,
|
||||||
|
|
@ -422,12 +378,12 @@ export class AssignController extends Controller {
|
||||||
// isSendNotification: true
|
// isSendNotification: true
|
||||||
receiveDate: dateResult,
|
receiveDate: dateResult,
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch(error => {
|
||||||
console.error("Error calling API:", error);
|
console.error("Error calling API:", error)
|
||||||
});
|
})
|
||||||
});
|
})
|
||||||
|
|
||||||
return new HttpSuccess();
|
return new HttpSuccess()
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -438,50 +394,50 @@ export class AssignController extends Controller {
|
||||||
*/
|
*/
|
||||||
@Get("assign-list")
|
@Get("assign-list")
|
||||||
async ListPersonal(@Request() request: RequestWithUser, @Query() personal_id: string) {
|
async ListPersonal(@Request() request: RequestWithUser, @Query() personal_id: string) {
|
||||||
await new permission().PermissionGet(request, "SYS_PROBATION");
|
await new permission().PermissionGet(request, "SYS_PROBATION")
|
||||||
const lists = await this.assignRepository.find({
|
const lists = await this.assignRepository.find({
|
||||||
select: ["id", "round_no", "date_start", "date_finish"],
|
select: ["id", "round_no", "date_start", "date_finish"],
|
||||||
where: { personal_id },
|
where: { personal_id },
|
||||||
order: { round_no: "ASC" },
|
order: { round_no: "ASC" },
|
||||||
});
|
})
|
||||||
|
|
||||||
let result: any = [];
|
let result: any = []
|
||||||
|
|
||||||
await Promise.all(
|
await Promise.all(
|
||||||
lists.map(async (item) => {
|
lists.map(async item => {
|
||||||
const director = await this.assignDirectorRepository.find({
|
const director = await this.assignDirectorRepository.find({
|
||||||
where: { assign_id: item.id },
|
where: { assign_id: item.id },
|
||||||
order: { ordering: "ASC" },
|
order: { ordering: "ASC" },
|
||||||
});
|
})
|
||||||
|
|
||||||
let mentors = "";
|
let mentors = ""
|
||||||
const mentorList = await director.filter((x) => x.role == "mentor");
|
const mentorList = await director.filter(x => x.role == "mentor")
|
||||||
if (mentorList.length > 0) {
|
if (mentorList.length > 0) {
|
||||||
for (let index = 0; index < mentorList.length; index++) {
|
for (let index = 0; index < mentorList.length; index++) {
|
||||||
const e = await mentorList[index];
|
const e = await mentorList[index]
|
||||||
mentors += e.fullname;
|
mentors += e.fullname
|
||||||
if (index < mentorList.length - 1) {
|
if (index < mentorList.length - 1) {
|
||||||
mentors += ", ";
|
mentors += ", "
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const commanderData = await (director.find((x) => x.role == "commander") ?? null);
|
const commanderData = await (director.find(x => x.role == "commander") ?? null)
|
||||||
const commander = commanderData ? commanderData.fullname : null;
|
const commander = commanderData ? commanderData.fullname : null
|
||||||
|
|
||||||
const chairmanData = await (director.find((x) => x.role == "chairman") ?? null);
|
const chairmanData = await (director.find(x => x.role == "chairman") ?? null)
|
||||||
const chairman = chairmanData ? chairmanData.fullname : null;
|
const chairman = chairmanData ? chairmanData.fullname : null
|
||||||
|
|
||||||
await result.push({
|
await result.push({
|
||||||
...item,
|
...item,
|
||||||
mentors: mentors,
|
mentors: mentors,
|
||||||
commander: commander,
|
commander: commander,
|
||||||
chairman: chairman,
|
chairman: chairman,
|
||||||
});
|
})
|
||||||
}),
|
})
|
||||||
);
|
)
|
||||||
|
|
||||||
return new HttpSuccess(result);
|
return new HttpSuccess(result)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -492,49 +448,26 @@ export class AssignController extends Controller {
|
||||||
*/
|
*/
|
||||||
@Get("")
|
@Get("")
|
||||||
async GetAssign(@Query() assign_id: string, @Request() request: RequestWithUser) {
|
async GetAssign(@Query() assign_id: string, @Request() request: RequestWithUser) {
|
||||||
await new permission().PermissionGet(request, "SYS_PROBATION");
|
await new permission().PermissionGet(request, "SYS_PROBATION")
|
||||||
|
|
||||||
const assign = await this.assignRepository.findOne({
|
const assign = await this.assignRepository.findOne({
|
||||||
select: [
|
select: ["id", "personal_id", "round_no", "date_start", "date_finish", "other_desc", "other4_desc", "other5_no1_desc", "experimenter_dated", "active", "createdAt", "updatedAt"],
|
||||||
"id",
|
|
||||||
"personal_id",
|
|
||||||
"round_no",
|
|
||||||
"date_start",
|
|
||||||
"date_finish",
|
|
||||||
"other_desc",
|
|
||||||
"other4_desc",
|
|
||||||
"other5_no1_desc",
|
|
||||||
"experimenter_dated",
|
|
||||||
"active",
|
|
||||||
"createdAt",
|
|
||||||
"updatedAt",
|
|
||||||
],
|
|
||||||
where: { id: assign_id },
|
where: { id: assign_id },
|
||||||
});
|
})
|
||||||
|
|
||||||
if (!assign) {
|
if (!assign) {
|
||||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลแบบมอบหมายงาน");
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลแบบมอบหมายงาน")
|
||||||
}
|
}
|
||||||
|
|
||||||
const profileData = await this.personalRepository.findOne({
|
const profileData = await this.personalRepository.findOne({
|
||||||
select: [
|
select: ["personal_id", "prefixName", "firstName", "lastName", "positionName", "positionLevelName", "positionLineName", "orgRootName", "organization"],
|
||||||
"personal_id",
|
|
||||||
"prefixName",
|
|
||||||
"firstName",
|
|
||||||
"lastName",
|
|
||||||
"positionName",
|
|
||||||
"positionLevelName",
|
|
||||||
"positionLineName",
|
|
||||||
"orgRootName",
|
|
||||||
"organization",
|
|
||||||
],
|
|
||||||
where: {
|
where: {
|
||||||
personal_id: assign.personal_id,
|
personal_id: assign.personal_id,
|
||||||
},
|
},
|
||||||
});
|
})
|
||||||
|
|
||||||
if (!profileData) {
|
if (!profileData) {
|
||||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลบุคคล");
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลบุคคล")
|
||||||
}
|
}
|
||||||
|
|
||||||
const profile = {
|
const profile = {
|
||||||
|
|
@ -544,18 +477,18 @@ export class AssignController extends Controller {
|
||||||
Department: "-",
|
Department: "-",
|
||||||
OrganizationOrganization: profileData.orgRootName,
|
OrganizationOrganization: profileData.orgRootName,
|
||||||
Oc: profileData.organization,
|
Oc: profileData.organization,
|
||||||
};
|
}
|
||||||
|
|
||||||
const jobs = await this.assignJobRepository.find({
|
const jobs = await this.assignJobRepository.find({
|
||||||
select: ["id", "activity_desc", "goal_desc"],
|
select: ["id", "activity_desc", "goal_desc"],
|
||||||
where: { assign_id },
|
where: { assign_id },
|
||||||
});
|
})
|
||||||
|
|
||||||
const knowledgeData = await this.assignKnowledgeRepository.find({
|
const knowledgeData = await this.assignKnowledgeRepository.find({
|
||||||
relations: ["knowledge"],
|
relations: ["knowledge"],
|
||||||
where: { assign_id },
|
where: { assign_id },
|
||||||
});
|
})
|
||||||
const knowledges = await knowledgeData.map((x) => ({
|
const knowledges = await knowledgeData.map(x => ({
|
||||||
id: x.knowledge_id,
|
id: x.knowledge_id,
|
||||||
level: x.knowledge_level,
|
level: x.knowledge_level,
|
||||||
title: x.knowledge.title,
|
title: x.knowledge.title,
|
||||||
|
|
@ -571,34 +504,34 @@ export class AssignController extends Controller {
|
||||||
: x.knowledge_level == 5
|
: x.knowledge_level == 5
|
||||||
? x.knowledge.level5
|
? x.knowledge.level5
|
||||||
: "",
|
: "",
|
||||||
}));
|
}))
|
||||||
|
|
||||||
const lawData = await this.lawsRepository.find({
|
const lawData = await this.lawsRepository.find({
|
||||||
where: { active: 1 },
|
where: { active: 1 },
|
||||||
});
|
})
|
||||||
|
|
||||||
const laws = await Promise.all(
|
const laws = await Promise.all(
|
||||||
lawData.map(async (x) => {
|
lawData.map(async x => {
|
||||||
const assignLaw = await this.assignLawRepository.countBy({
|
const assignLaw = await this.assignLawRepository.countBy({
|
||||||
assign_id: assign_id,
|
assign_id: assign_id,
|
||||||
law_id: x.id,
|
law_id: x.id,
|
||||||
});
|
})
|
||||||
|
|
||||||
return {
|
return {
|
||||||
id: x.id,
|
id: x.id,
|
||||||
selected: assignLaw > 0 ? 1 : 0,
|
selected: assignLaw > 0 ? 1 : 0,
|
||||||
description: x.description,
|
description: x.description,
|
||||||
status_select: x.status_select,
|
status_select: x.status_select,
|
||||||
};
|
}
|
||||||
}),
|
})
|
||||||
);
|
)
|
||||||
|
|
||||||
const skillsData = await this.assignSkillRepository.find({
|
const skillsData = await this.assignSkillRepository.find({
|
||||||
relations: ["skill"],
|
relations: ["skill"],
|
||||||
where: { assign_id },
|
where: { assign_id },
|
||||||
});
|
})
|
||||||
|
|
||||||
const skills = await skillsData.map((x) => ({
|
const skills = await skillsData.map(x => ({
|
||||||
id: x.skill_id,
|
id: x.skill_id,
|
||||||
level: x.skill_level,
|
level: x.skill_level,
|
||||||
title: x.skill.title,
|
title: x.skill.title,
|
||||||
|
|
@ -614,90 +547,74 @@ export class AssignController extends Controller {
|
||||||
: x.skill_level == 5
|
: x.skill_level == 5
|
||||||
? x.skill.level5
|
? x.skill.level5
|
||||||
: "",
|
: "",
|
||||||
}));
|
}))
|
||||||
|
|
||||||
const competencyData = await this.assignCompetencyRepository.find({
|
const competencyData = await this.assignCompetencyRepository.find({
|
||||||
select: ["competency_id", "competency_level", "competency_name", "competency_description"],
|
select: ["competency_id", "competency_level", "competency_name", "competency_description"],
|
||||||
where: { assign_id },
|
where: { assign_id },
|
||||||
});
|
})
|
||||||
|
|
||||||
const competencys = await competencyData.map((x) => ({
|
const competencys = await competencyData.map(x => ({
|
||||||
id: x.competency_id,
|
id: x.competency_id,
|
||||||
level: x.competency_level,
|
level: x.competency_level,
|
||||||
name: x.competency_name,
|
name: x.competency_name,
|
||||||
description: x.competency_description,
|
description: x.competency_description,
|
||||||
}));
|
}))
|
||||||
|
|
||||||
const competencyGroupData = await this.assignCompetencyGroupRepository.find({
|
const competencyGroupData = await this.assignCompetencyGroupRepository.find({
|
||||||
select: [
|
select: ["competency_group_id", "competency_group_level", "competency_group_name", "competency_group_description"],
|
||||||
"competency_group_id",
|
|
||||||
"competency_group_level",
|
|
||||||
"competency_group_name",
|
|
||||||
"competency_group_description",
|
|
||||||
],
|
|
||||||
where: { assign_id },
|
where: { assign_id },
|
||||||
});
|
})
|
||||||
const competency_groups = await competencyGroupData.map((x) => ({
|
const competency_groups = await competencyGroupData.map(x => ({
|
||||||
id: x.competency_group_id,
|
id: x.competency_group_id,
|
||||||
level: x.competency_group_level,
|
level: x.competency_group_level,
|
||||||
name: x.competency_group_name,
|
name: x.competency_group_name,
|
||||||
description: x.competency_group_description,
|
description: x.competency_group_description,
|
||||||
}));
|
}))
|
||||||
|
|
||||||
const outputs = await this.assignOutputRepository.find({
|
const outputs = await this.assignOutputRepository.find({
|
||||||
select: ["id", "output_desc", "indicator_desc"],
|
select: ["id", "output_desc", "indicator_desc"],
|
||||||
where: { assign_id },
|
where: { assign_id },
|
||||||
});
|
})
|
||||||
|
|
||||||
const director = await this.assignDirectorRepository.find({
|
const director = await this.assignDirectorRepository.find({
|
||||||
where: { assign_id },
|
where: { assign_id },
|
||||||
order: { ordering: "ASC" },
|
order: { ordering: "ASC" },
|
||||||
});
|
})
|
||||||
|
|
||||||
let mentors = [];
|
let mentors = []
|
||||||
const mentorList = await director.filter((x) => x.role == "mentor");
|
const mentorList = await director.filter(x => x.role == "mentor")
|
||||||
if (mentorList.length > 0) {
|
if (mentorList.length > 0) {
|
||||||
for (let index = 0; index < mentorList.length; index++) {
|
for (let index = 0; index < mentorList.length; index++) {
|
||||||
const e = await mentorList[index];
|
const e = await mentorList[index]
|
||||||
mentors.push({
|
mentors.push({
|
||||||
...e,
|
...e,
|
||||||
name: e.fullname,
|
name: e.fullname,
|
||||||
label:
|
label: e.fullname + " " + (e.position ? `(${e.position}, ${e.posType}: ${e.posLevel})` : ""),
|
||||||
e.fullname + " " + (e.position ? `(${e.position}, ${e.posType}: ${e.posLevel})` : ""),
|
|
||||||
Position: e.position, // report
|
Position: e.position, // report
|
||||||
});
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const commanderData = await (director.find((x) => x.role == "commander") ?? null);
|
const commanderData = await (director.find(x => x.role == "commander") ?? null)
|
||||||
const commander = await (commanderData
|
const commander = await (commanderData
|
||||||
? {
|
? {
|
||||||
...commanderData,
|
...commanderData,
|
||||||
name: commanderData.fullname,
|
name: commanderData.fullname,
|
||||||
label:
|
label: commanderData.fullname + " " + (commanderData.position ? `(${commanderData.position}, ${commanderData.posType}: ${commanderData.posLevel})` : ""),
|
||||||
commanderData.fullname +
|
|
||||||
" " +
|
|
||||||
(commanderData.position
|
|
||||||
? `(${commanderData.position}, ${commanderData.posType}: ${commanderData.posLevel})`
|
|
||||||
: ""),
|
|
||||||
Position: commanderData.position, // report
|
Position: commanderData.position, // report
|
||||||
}
|
}
|
||||||
: null);
|
: null)
|
||||||
|
|
||||||
const chairmanData = await (director.find((x) => x.role == "chairman") ?? null);
|
const chairmanData = await (director.find(x => x.role == "chairman") ?? null)
|
||||||
const chairman = await (chairmanData
|
const chairman = await (chairmanData
|
||||||
? {
|
? {
|
||||||
...chairmanData,
|
...chairmanData,
|
||||||
name: chairmanData.fullname,
|
name: chairmanData.fullname,
|
||||||
label:
|
label: chairmanData.fullname + " " + (chairmanData.position ? `(${chairmanData.position}, ${chairmanData.posType}: ${chairmanData.posLevel})` : ""),
|
||||||
chairmanData.fullname +
|
|
||||||
" " +
|
|
||||||
(chairmanData.position
|
|
||||||
? `(${chairmanData.position}, ${chairmanData.posType}: ${chairmanData.posLevel})`
|
|
||||||
: ""),
|
|
||||||
Position: chairmanData.position, // report
|
Position: chairmanData.position, // report
|
||||||
}
|
}
|
||||||
: null);
|
: null)
|
||||||
|
|
||||||
return new HttpSuccess({
|
return new HttpSuccess({
|
||||||
assign,
|
assign,
|
||||||
|
|
@ -712,6 +629,6 @@ export class AssignController extends Controller {
|
||||||
mentors,
|
mentors,
|
||||||
commander,
|
commander,
|
||||||
chairman,
|
chairman,
|
||||||
});
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,28 +1,13 @@
|
||||||
import {
|
import { Controller, Route, Security, Tags, Request, SuccessResponse, Response, Get, Post, Body } from "tsoa"
|
||||||
Controller,
|
import HttpSuccess from "../interfaces/http-success"
|
||||||
Route,
|
import HttpStatusCode from "../interfaces/http-status"
|
||||||
Security,
|
import { RequestWithUser } from "../middlewares/user"
|
||||||
Tags,
|
import { findEndDate } from "../interfaces/utils"
|
||||||
Request,
|
|
||||||
SuccessResponse,
|
|
||||||
Response,
|
|
||||||
Get,
|
|
||||||
Post,
|
|
||||||
Body,
|
|
||||||
} from "tsoa";
|
|
||||||
import HttpSuccess from "../interfaces/http-success";
|
|
||||||
import HttpStatusCode from "../interfaces/http-status";
|
|
||||||
import { RequestWithUser } from "../middlewares/user";
|
|
||||||
import { findEndDate } from "../interfaces/utils";
|
|
||||||
|
|
||||||
@Route("api/v1/probation/calculate")
|
@Route("api/v1/probation/calculate")
|
||||||
@Tags("ฟอร์มมอบหมายงาน")
|
@Tags("ฟอร์มมอบหมายงาน")
|
||||||
@Security("bearerAuth")
|
@Security("bearerAuth")
|
||||||
@Response(
|
@Response(HttpStatusCode.INTERNAL_SERVER_ERROR, "เกิดข้อผิดพลาด ไม่สามารถแสดงรายการได้ กรุณาลองใหม่ในภายหลัง")
|
||||||
HttpStatusCode.INTERNAL_SERVER_ERROR,
|
|
||||||
"เกิดข้อผิดพลาด ไม่สามารถแสดงรายการได้ กรุณาลองใหม่ในภายหลัง",
|
|
||||||
)
|
|
||||||
@SuccessResponse(HttpStatusCode.OK, "สำเร็จ")
|
|
||||||
export class CalculateController extends Controller {
|
export class CalculateController extends Controller {
|
||||||
/**
|
/**
|
||||||
* API คำนวนวันสิ้นสุดตามวันที่เริ่มและระยะเวลาเดือนตามที่ส่งค่ามา
|
* API คำนวนวันสิ้นสุดตามวันที่เริ่มและระยะเวลาเดือนตามที่ส่งค่ามา
|
||||||
|
|
@ -34,14 +19,14 @@ export class CalculateController extends Controller {
|
||||||
async AssignFinish(
|
async AssignFinish(
|
||||||
@Body()
|
@Body()
|
||||||
requestBody: {
|
requestBody: {
|
||||||
month: number;
|
month: number
|
||||||
start_date: Date;
|
start_date: Date
|
||||||
},
|
},
|
||||||
@Request() request: RequestWithUser,
|
@Request() request: RequestWithUser
|
||||||
) {
|
) {
|
||||||
const { month, start_date } = requestBody;
|
const { month, start_date } = requestBody
|
||||||
const finish_date = findEndDate(month, start_date);
|
const finish_date = findEndDate(month, start_date)
|
||||||
|
|
||||||
return new HttpSuccess({ finish_date });
|
return new HttpSuccess({ finish_date })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,42 +1,28 @@
|
||||||
import {
|
import { Controller, Route, Security, Tags, Request, SuccessResponse, Response, Get, Query } from "tsoa"
|
||||||
Controller,
|
import { AppDataSource } from "../database/data-source"
|
||||||
Route,
|
import HttpSuccess from "../interfaces/http-success"
|
||||||
Security,
|
import HttpStatusCode from "../interfaces/http-status"
|
||||||
Tags,
|
import HttpError from "../interfaces/http-error"
|
||||||
Request,
|
import { RequestWithUser } from "../middlewares/user"
|
||||||
SuccessResponse,
|
import { Knowledge, TypeKnowledge } from "../entities/Knowledge"
|
||||||
Response,
|
import { Skill, TypeSkill } from "../entities/Skill"
|
||||||
Get,
|
import { MapKnowledgeSkill } from "../entities/MapKnowledgeSkill"
|
||||||
Query,
|
import { Personal } from "../entities/Personal"
|
||||||
} from "tsoa";
|
import { Law } from "../entities/Law"
|
||||||
import { AppDataSource } from "../database/data-source";
|
import { Assign } from "../entities/Assign"
|
||||||
import HttpSuccess from "../interfaces/http-success";
|
import permission from "../interfaces/permission"
|
||||||
import HttpStatusCode from "../interfaces/http-status";
|
|
||||||
import HttpError from "../interfaces/http-error";
|
|
||||||
import { RequestWithUser } from "../middlewares/user";
|
|
||||||
import { Knowledge, TypeKnowledge } from "../entities/Knowledge";
|
|
||||||
import { Skill, TypeSkill } from "../entities/Skill";
|
|
||||||
import { MapKnowledgeSkill } from "../entities/MapKnowledgeSkill";
|
|
||||||
import { Personal } from "../entities/Personal";
|
|
||||||
import { Law } from "../entities/Law";
|
|
||||||
import { Assign } from "../entities/Assign";
|
|
||||||
import permission from "../interfaces/permission";
|
|
||||||
|
|
||||||
@Route("api/v1/probation/data-options")
|
@Route("api/v1/probation/data-options")
|
||||||
@Tags("Data Options")
|
@Tags("Data Options")
|
||||||
@Security("bearerAuth")
|
@Security("bearerAuth")
|
||||||
@Response(
|
@Response(HttpStatusCode.INTERNAL_SERVER_ERROR, "เกิดข้อผิดพลาด ไม่สามารถแสดงรายการได้ กรุณาลองใหม่ในภายหลัง")
|
||||||
HttpStatusCode.INTERNAL_SERVER_ERROR,
|
|
||||||
"เกิดข้อผิดพลาด ไม่สามารถแสดงรายการได้ กรุณาลองใหม่ในภายหลัง",
|
|
||||||
)
|
|
||||||
@SuccessResponse(HttpStatusCode.OK, "สำเร็จ")
|
|
||||||
export class DataOptionController extends Controller {
|
export class DataOptionController extends Controller {
|
||||||
private personalRepository = AppDataSource.getRepository(Personal);
|
private personalRepository = AppDataSource.getRepository(Personal)
|
||||||
private knowledgeRepository = AppDataSource.getRepository(Knowledge);
|
private knowledgeRepository = AppDataSource.getRepository(Knowledge)
|
||||||
private mapKnowledgeSkillRepository = AppDataSource.getRepository(MapKnowledgeSkill);
|
private mapKnowledgeSkillRepository = AppDataSource.getRepository(MapKnowledgeSkill)
|
||||||
private skillRepository = AppDataSource.getRepository(Skill);
|
private skillRepository = AppDataSource.getRepository(Skill)
|
||||||
private lawRepository = AppDataSource.getRepository(Law);
|
private lawRepository = AppDataSource.getRepository(Law)
|
||||||
private assignRepository = AppDataSource.getRepository(Assign);
|
private assignRepository = AppDataSource.getRepository(Assign)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* API list รายการความรู้
|
* API list รายการความรู้
|
||||||
|
|
@ -48,10 +34,10 @@ export class DataOptionController extends Controller {
|
||||||
async GetKnowledge(@Query() personal_id: string) {
|
async GetKnowledge(@Query() personal_id: string) {
|
||||||
const person = await this.personalRepository.findOne({
|
const person = await this.personalRepository.findOne({
|
||||||
where: { personal_id },
|
where: { personal_id },
|
||||||
});
|
})
|
||||||
|
|
||||||
if (!person) {
|
if (!person) {
|
||||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลบุคคล");
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลบุคคล")
|
||||||
}
|
}
|
||||||
|
|
||||||
let result = await this.mapKnowledgeSkillRepository.findOne({
|
let result = await this.mapKnowledgeSkillRepository.findOne({
|
||||||
|
|
@ -60,7 +46,7 @@ export class DataOptionController extends Controller {
|
||||||
positionLevelName: person.positionLevelName,
|
positionLevelName: person.positionLevelName,
|
||||||
active: 1,
|
active: 1,
|
||||||
},
|
},
|
||||||
});
|
})
|
||||||
|
|
||||||
if (!result) {
|
if (!result) {
|
||||||
// ถ้าตำแหน่งไม่ตรงหาจากระดับตำแหน่งแทนเพื่อให้ฟอร์มสามารถกรอกต่อได้
|
// ถ้าตำแหน่งไม่ตรงหาจากระดับตำแหน่งแทนเพื่อให้ฟอร์มสามารถกรอกต่อได้
|
||||||
|
|
@ -69,18 +55,18 @@ export class DataOptionController extends Controller {
|
||||||
positionLevelName: person.positionLevelName,
|
positionLevelName: person.positionLevelName,
|
||||||
active: 1,
|
active: 1,
|
||||||
},
|
},
|
||||||
});
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!result) {
|
if (!result) {
|
||||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลความรู้ที่ตรงกับตำแหน่ง");
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลความรู้ที่ตรงกับตำแหน่ง")
|
||||||
}
|
}
|
||||||
|
|
||||||
const knowledges = await this.knowledgeRepository.find({
|
const knowledges = await this.knowledgeRepository.find({
|
||||||
where: { type: TypeKnowledge.PERFORMANCE, active: 1 },
|
where: { type: TypeKnowledge.PERFORMANCE, active: 1 },
|
||||||
});
|
})
|
||||||
|
|
||||||
const knowledge = knowledges.map((knowledge) => ({
|
const knowledge = knowledges.map(knowledge => ({
|
||||||
id: knowledge.id,
|
id: knowledge.id,
|
||||||
title: knowledge.title,
|
title: knowledge.title,
|
||||||
description:
|
description:
|
||||||
|
|
@ -94,9 +80,9 @@ export class DataOptionController extends Controller {
|
||||||
? knowledge.level4
|
? knowledge.level4
|
||||||
: knowledge.level5,
|
: knowledge.level5,
|
||||||
level: result.knowlage_performance_level,
|
level: result.knowlage_performance_level,
|
||||||
}));
|
}))
|
||||||
|
|
||||||
return new HttpSuccess(knowledge);
|
return new HttpSuccess(knowledge)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -109,52 +95,42 @@ export class DataOptionController extends Controller {
|
||||||
async GetSkill(@Query() personal_id: string) {
|
async GetSkill(@Query() personal_id: string) {
|
||||||
const person = await this.personalRepository.findOne({
|
const person = await this.personalRepository.findOne({
|
||||||
where: { personal_id },
|
where: { personal_id },
|
||||||
});
|
})
|
||||||
|
|
||||||
if (!person) {
|
if (!person) {
|
||||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล");
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล")
|
||||||
}
|
}
|
||||||
|
|
||||||
let result = await this.mapKnowledgeSkillRepository.findOne({
|
let result = await this.mapKnowledgeSkillRepository.findOne({
|
||||||
select: [
|
select: ["skill_computer_level", "skill_english_level", "skill_information_level", "skill_resourse_level"],
|
||||||
"skill_computer_level",
|
|
||||||
"skill_english_level",
|
|
||||||
"skill_information_level",
|
|
||||||
"skill_resourse_level",
|
|
||||||
],
|
|
||||||
where: {
|
where: {
|
||||||
positionName: person.positionName,
|
positionName: person.positionName,
|
||||||
positionLevelName: person.positionLevelName,
|
positionLevelName: person.positionLevelName,
|
||||||
active: 1,
|
active: 1,
|
||||||
},
|
},
|
||||||
});
|
})
|
||||||
|
|
||||||
if (!result) {
|
if (!result) {
|
||||||
// ถ้าตำแหน่งไม่ตรงหาจากระดับตำแหน่งแทนเพื่อให้ฟอร์มสามารถกรอกต่อได้
|
// ถ้าตำแหน่งไม่ตรงหาจากระดับตำแหน่งแทนเพื่อให้ฟอร์มสามารถกรอกต่อได้
|
||||||
result = await this.mapKnowledgeSkillRepository.findOne({
|
result = await this.mapKnowledgeSkillRepository.findOne({
|
||||||
select: [
|
select: ["skill_computer_level", "skill_english_level", "skill_information_level", "skill_resourse_level"],
|
||||||
"skill_computer_level",
|
|
||||||
"skill_english_level",
|
|
||||||
"skill_information_level",
|
|
||||||
"skill_resourse_level",
|
|
||||||
],
|
|
||||||
where: {
|
where: {
|
||||||
positionLevelName: person.positionLevelName,
|
positionLevelName: person.positionLevelName,
|
||||||
active: 1,
|
active: 1,
|
||||||
},
|
},
|
||||||
});
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!result) {
|
if (!result) {
|
||||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลทักษะที่ตรงกับตำแหน่ง");
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลทักษะที่ตรงกับตำแหน่ง")
|
||||||
}
|
}
|
||||||
|
|
||||||
const computerData = await this.skillRepository.findOne({
|
const computerData = await this.skillRepository.findOne({
|
||||||
where: { type: TypeSkill.COMPUTER, active: 1 },
|
where: { type: TypeSkill.COMPUTER, active: 1 },
|
||||||
});
|
})
|
||||||
|
|
||||||
if (!computerData) {
|
if (!computerData) {
|
||||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลทักษะคอมพิวเตอร์");
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลทักษะคอมพิวเตอร์")
|
||||||
}
|
}
|
||||||
const computer = await {
|
const computer = await {
|
||||||
id: computerData.id,
|
id: computerData.id,
|
||||||
|
|
@ -170,14 +146,14 @@ export class DataOptionController extends Controller {
|
||||||
? computerData.level4
|
? computerData.level4
|
||||||
: computerData.level5,
|
: computerData.level5,
|
||||||
level: result.skill_computer_level,
|
level: result.skill_computer_level,
|
||||||
};
|
}
|
||||||
|
|
||||||
const englishData = await this.skillRepository.findOne({
|
const englishData = await this.skillRepository.findOne({
|
||||||
where: { type: TypeSkill.ENG, active: 1 },
|
where: { type: TypeSkill.ENG, active: 1 },
|
||||||
});
|
})
|
||||||
|
|
||||||
if (!englishData) {
|
if (!englishData) {
|
||||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลทักษะภาษาอังกฤษ");
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลทักษะภาษาอังกฤษ")
|
||||||
}
|
}
|
||||||
|
|
||||||
const english = await {
|
const english = await {
|
||||||
|
|
@ -194,14 +170,14 @@ export class DataOptionController extends Controller {
|
||||||
? englishData.level4
|
? englishData.level4
|
||||||
: englishData.level5,
|
: englishData.level5,
|
||||||
level: result.skill_english_level,
|
level: result.skill_english_level,
|
||||||
};
|
}
|
||||||
|
|
||||||
const informationData = await this.skillRepository.findOne({
|
const informationData = await this.skillRepository.findOne({
|
||||||
where: { type: TypeSkill.INFORMATION, active: 1 },
|
where: { type: TypeSkill.INFORMATION, active: 1 },
|
||||||
});
|
})
|
||||||
|
|
||||||
if (!informationData) {
|
if (!informationData) {
|
||||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล");
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล")
|
||||||
}
|
}
|
||||||
|
|
||||||
const information = await {
|
const information = await {
|
||||||
|
|
@ -218,13 +194,13 @@ export class DataOptionController extends Controller {
|
||||||
? informationData.level4
|
? informationData.level4
|
||||||
: informationData.level5,
|
: informationData.level5,
|
||||||
level: result.skill_information_level,
|
level: result.skill_information_level,
|
||||||
};
|
}
|
||||||
|
|
||||||
const resourseData = await this.skillRepository.findOne({
|
const resourseData = await this.skillRepository.findOne({
|
||||||
where: { type: TypeSkill.RESOURSE, active: 1 },
|
where: { type: TypeSkill.RESOURSE, active: 1 },
|
||||||
});
|
})
|
||||||
if (!resourseData) {
|
if (!resourseData) {
|
||||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล");
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล")
|
||||||
}
|
}
|
||||||
|
|
||||||
const resourse = await {
|
const resourse = await {
|
||||||
|
|
@ -241,14 +217,14 @@ export class DataOptionController extends Controller {
|
||||||
? resourseData.level4
|
? resourseData.level4
|
||||||
: resourseData.level5,
|
: resourseData.level5,
|
||||||
level: result.skill_resourse_level,
|
level: result.skill_resourse_level,
|
||||||
};
|
}
|
||||||
|
|
||||||
return new HttpSuccess({
|
return new HttpSuccess({
|
||||||
computer,
|
computer,
|
||||||
english,
|
english,
|
||||||
information,
|
information,
|
||||||
resourse,
|
resourse,
|
||||||
});
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -264,18 +240,18 @@ export class DataOptionController extends Controller {
|
||||||
where: {
|
where: {
|
||||||
active: 1,
|
active: 1,
|
||||||
},
|
},
|
||||||
});
|
})
|
||||||
|
|
||||||
if (!results) {
|
if (!results) {
|
||||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล");
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล")
|
||||||
}
|
}
|
||||||
|
|
||||||
const result = await results.map((v) => ({
|
const result = await results.map(v => ({
|
||||||
...v,
|
...v,
|
||||||
checked: 0,
|
checked: 0,
|
||||||
}));
|
}))
|
||||||
|
|
||||||
return new HttpSuccess(result);
|
return new HttpSuccess(result)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -286,7 +262,7 @@ export class DataOptionController extends Controller {
|
||||||
*/
|
*/
|
||||||
@Get("new-assign")
|
@Get("new-assign")
|
||||||
async NewAssign(@Query() personal_id: string, @Request() request: RequestWithUser) {
|
async NewAssign(@Query() personal_id: string, @Request() request: RequestWithUser) {
|
||||||
await new permission().PermissionGet(request, "SYS_PROBATION");
|
await new permission().PermissionGet(request, "SYS_PROBATION")
|
||||||
|
|
||||||
const person = await this.personalRepository.findOne({
|
const person = await this.personalRepository.findOne({
|
||||||
select: [
|
select: [
|
||||||
|
|
@ -305,27 +281,27 @@ export class DataOptionController extends Controller {
|
||||||
"updatedAt",
|
"updatedAt",
|
||||||
],
|
],
|
||||||
where: { personal_id },
|
where: { personal_id },
|
||||||
});
|
})
|
||||||
|
|
||||||
if (!person) {
|
if (!person) {
|
||||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล");
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล")
|
||||||
}
|
}
|
||||||
|
|
||||||
const assign = await this.assignRepository.count({
|
const assign = await this.assignRepository.count({
|
||||||
where: {
|
where: {
|
||||||
personal_id,
|
personal_id,
|
||||||
},
|
},
|
||||||
});
|
})
|
||||||
|
|
||||||
const responsePerson = {
|
const responsePerson = {
|
||||||
id: person.personal_id,
|
id: person.personal_id,
|
||||||
...person,
|
...person,
|
||||||
};
|
}
|
||||||
|
|
||||||
return new HttpSuccess({
|
return new HttpSuccess({
|
||||||
person: responsePerson,
|
person: responsePerson,
|
||||||
assign_no: assign + 1,
|
assign_no: assign + 1,
|
||||||
assign_month: 6,
|
assign_month: 6,
|
||||||
});
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,42 +1,25 @@
|
||||||
import {
|
import { Controller, Route, Security, Tags, Request, SuccessResponse, Response, Get, Post, Body, Query, Put } from "tsoa"
|
||||||
Controller,
|
import HttpSuccess from "../interfaces/http-success"
|
||||||
Route,
|
import HttpStatusCode from "../interfaces/http-status"
|
||||||
Security,
|
import { RequestWithUser } from "../middlewares/user"
|
||||||
Tags,
|
import { findEndDate, setLogDataDiff } from "../interfaces/utils"
|
||||||
Request,
|
import { AppDataSource } from "../database/data-source"
|
||||||
SuccessResponse,
|
import { AssignDirector } from "../entities/AssignDirector"
|
||||||
Response,
|
import HttpError from "../interfaces/http-error"
|
||||||
Get,
|
import { Assign } from "../entities/Assign"
|
||||||
Post,
|
import { Personal } from "../entities/Personal"
|
||||||
Body,
|
import CallAPI from "../interfaces/call-api"
|
||||||
Query,
|
import { CreateEvaluateChairman, EvaluateChairman } from "../entities/EvaluateChairman"
|
||||||
Put,
|
import permission from "../interfaces/permission"
|
||||||
} from "tsoa";
|
|
||||||
import HttpSuccess from "../interfaces/http-success";
|
|
||||||
import HttpStatusCode from "../interfaces/http-status";
|
|
||||||
import { RequestWithUser } from "../middlewares/user";
|
|
||||||
import { findEndDate, setLogDataDiff } from "../interfaces/utils";
|
|
||||||
import { AppDataSource } from "../database/data-source";
|
|
||||||
import { AssignDirector } from "../entities/AssignDirector";
|
|
||||||
import HttpError from "../interfaces/http-error";
|
|
||||||
import { Assign } from "../entities/Assign";
|
|
||||||
import { Personal } from "../entities/Personal";
|
|
||||||
import CallAPI from "../interfaces/call-api";
|
|
||||||
import { CreateEvaluateChairman, EvaluateChairman } from "../entities/EvaluateChairman";
|
|
||||||
import permission from "../interfaces/permission";
|
|
||||||
@Route("api/v1/probation/evaluate-chairman")
|
@Route("api/v1/probation/evaluate-chairman")
|
||||||
@Tags("แบบประเมินผล (คณะกรรมการ)")
|
@Tags("แบบประเมินผล (คณะกรรมการ)")
|
||||||
@Security("bearerAuth")
|
@Security("bearerAuth")
|
||||||
@Response(
|
@Response(HttpStatusCode.INTERNAL_SERVER_ERROR, "เกิดข้อผิดพลาด ไม่สามารถแสดงรายการได้ กรุณาลองใหม่ในภายหลัง")
|
||||||
HttpStatusCode.INTERNAL_SERVER_ERROR,
|
|
||||||
"เกิดข้อผิดพลาด ไม่สามารถแสดงรายการได้ กรุณาลองใหม่ในภายหลัง",
|
|
||||||
)
|
|
||||||
@SuccessResponse(HttpStatusCode.OK, "สำเร็จ")
|
|
||||||
export class EvaluateChairmanController extends Controller {
|
export class EvaluateChairmanController extends Controller {
|
||||||
private assignDirectorRepository = AppDataSource.getRepository(AssignDirector);
|
private assignDirectorRepository = AppDataSource.getRepository(AssignDirector)
|
||||||
private assignRepository = AppDataSource.getRepository(Assign);
|
private assignRepository = AppDataSource.getRepository(Assign)
|
||||||
private evaluateChairmanRepository = AppDataSource.getRepository(EvaluateChairman);
|
private evaluateChairmanRepository = AppDataSource.getRepository(EvaluateChairman)
|
||||||
private personalRepository = AppDataSource.getRepository(Personal);
|
private personalRepository = AppDataSource.getRepository(Personal)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* API ข้อมูลตอนกดสร้างแบบประเมินผล (คณะกรรมการ)
|
* API ข้อมูลตอนกดสร้างแบบประเมินผล (คณะกรรมการ)
|
||||||
|
|
@ -46,7 +29,7 @@ export class EvaluateChairmanController extends Controller {
|
||||||
*/
|
*/
|
||||||
@Get("create")
|
@Get("create")
|
||||||
async CreateEvaluate(@Query() assign_id: string, @Request() request: RequestWithUser) {
|
async CreateEvaluate(@Query() assign_id: string, @Request() request: RequestWithUser) {
|
||||||
await new permission().PermissionGet(request, "SYS_PROBATION");
|
await new permission().PermissionGet(request, "SYS_PROBATION")
|
||||||
|
|
||||||
const director = await this.assignDirectorRepository.findOne({
|
const director = await this.assignDirectorRepository.findOne({
|
||||||
select: ["personal_id"],
|
select: ["personal_id"],
|
||||||
|
|
@ -54,71 +37,66 @@ export class EvaluateChairmanController extends Controller {
|
||||||
assign_id,
|
assign_id,
|
||||||
role: "chairman",
|
role: "chairman",
|
||||||
},
|
},
|
||||||
});
|
})
|
||||||
if (!director) {
|
if (!director) {
|
||||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลผู้ดูแล");
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลผู้ดูแล")
|
||||||
}
|
}
|
||||||
const director_id = director.personal_id;
|
const director_id = director.personal_id
|
||||||
|
|
||||||
const assign = await this.assignRepository.findOne({
|
const assign = await this.assignRepository.findOne({
|
||||||
relations: ["profile"],
|
relations: ["profile"],
|
||||||
where: { id: assign_id },
|
where: { id: assign_id },
|
||||||
});
|
})
|
||||||
if (!assign) {
|
if (!assign) {
|
||||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลแบบมอบหมายงาน");
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลแบบมอบหมายงาน")
|
||||||
}
|
}
|
||||||
|
|
||||||
const profile = await (assign.profile
|
const profile = await (assign.profile
|
||||||
? {
|
? {
|
||||||
...assign.profile,
|
...assign.profile,
|
||||||
id: assign.profile.personal_id,
|
id: assign.profile.personal_id,
|
||||||
name:
|
name: assign.profile.prefixName + assign.profile.firstName + " " + assign.profile.lastName,
|
||||||
assign.profile.prefixName + assign.profile.firstName + " " + assign.profile.lastName,
|
|
||||||
Oc: assign.profile.organization,
|
Oc: assign.profile.organization,
|
||||||
}
|
}
|
||||||
: null);
|
: null)
|
||||||
|
|
||||||
const evaluate_amount = await this.evaluateChairmanRepository.count({
|
const evaluate_amount = await this.evaluateChairmanRepository.count({
|
||||||
where: {
|
where: {
|
||||||
assign_id,
|
assign_id,
|
||||||
director_id,
|
director_id,
|
||||||
},
|
},
|
||||||
});
|
})
|
||||||
const evaluate_no = await (evaluate_amount + 1);
|
const evaluate_no = await (evaluate_amount + 1)
|
||||||
const start_date =
|
const start_date = evaluate_amount == 0 ? assign.date_start : findEndDate(evaluate_amount * 3, assign.date_start)
|
||||||
evaluate_amount == 0
|
|
||||||
? assign.date_start
|
|
||||||
: findEndDate(evaluate_amount * 3, assign.date_start);
|
|
||||||
|
|
||||||
const directorData = await this.assignDirectorRepository.find({
|
const directorData = await this.assignDirectorRepository.find({
|
||||||
where: { assign_id },
|
where: { assign_id },
|
||||||
order: { ordering: "ASC" },
|
order: { ordering: "ASC" },
|
||||||
});
|
})
|
||||||
|
|
||||||
if (!directorData) {
|
if (!directorData) {
|
||||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลผู้ดูแล ผู้บังคับบัญชาและประธาน");
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลผู้ดูแล ผู้บังคับบัญชาและประธาน")
|
||||||
}
|
}
|
||||||
|
|
||||||
let mentors = [];
|
let mentors = []
|
||||||
const mentorList = await directorData.filter((x) => x.role == "mentor");
|
const mentorList = await directorData.filter(x => x.role == "mentor")
|
||||||
if (mentorList.length > 0) {
|
if (mentorList.length > 0) {
|
||||||
for (let index = 0; index < mentorList.length; index++) {
|
for (let index = 0; index < mentorList.length; index++) {
|
||||||
const e = await mentorList[index];
|
const e = await mentorList[index]
|
||||||
|
|
||||||
mentors.push({
|
mentors.push({
|
||||||
personal_id: e.personal_id,
|
personal_id: e.personal_id,
|
||||||
dated: e.dated,
|
dated: e.dated,
|
||||||
name: e.fullname,
|
name: e.fullname,
|
||||||
label:
|
label: e.fullname + " " + (e.position ? `(${e.position}, ${e.posType}: ${e.posLevel})` : ""),
|
||||||
e.fullname + " " + (e.position ? `(${e.position}, ${e.posType}: ${e.posLevel})` : ""),
|
|
||||||
position: e.position,
|
position: e.position,
|
||||||
posType: e.posType,
|
posType: e.posType,
|
||||||
posLevel: e.posLevel,
|
posLevel: e.posLevel,
|
||||||
});
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const commanderData = await (directorData.find((x) => x.role == "commander") ?? null);
|
const commanderData = await (directorData.find(x => x.role == "commander") ?? null)
|
||||||
|
|
||||||
const commander =
|
const commander =
|
||||||
commanderData != null
|
commanderData != null
|
||||||
|
|
@ -126,36 +104,26 @@ export class EvaluateChairmanController extends Controller {
|
||||||
personal_id: commanderData.personal_id,
|
personal_id: commanderData.personal_id,
|
||||||
dated: commanderData.dated,
|
dated: commanderData.dated,
|
||||||
name: commanderData.fullname,
|
name: commanderData.fullname,
|
||||||
label:
|
label: commanderData.fullname + " " + (commanderData.position ? `(${commanderData.position}, ${commanderData.posType}: ${commanderData.posLevel})` : ""),
|
||||||
commanderData.fullname +
|
|
||||||
" " +
|
|
||||||
(commanderData.position
|
|
||||||
? `(${commanderData.position}, ${commanderData.posType}: ${commanderData.posLevel})`
|
|
||||||
: ""),
|
|
||||||
position: commanderData.position,
|
position: commanderData.position,
|
||||||
posType: commanderData.posType,
|
posType: commanderData.posType,
|
||||||
posLevel: commanderData.posLevel,
|
posLevel: commanderData.posLevel,
|
||||||
}
|
}
|
||||||
: null;
|
: null
|
||||||
|
|
||||||
const chairmanData = await (directorData.find((x) => x.role == "chairman") ?? null);
|
const chairmanData = await (directorData.find(x => x.role == "chairman") ?? null)
|
||||||
const chairman =
|
const chairman =
|
||||||
chairmanData != null
|
chairmanData != null
|
||||||
? {
|
? {
|
||||||
personal_id: chairmanData.personal_id,
|
personal_id: chairmanData.personal_id,
|
||||||
dated: chairmanData.dated,
|
dated: chairmanData.dated,
|
||||||
name: chairmanData.fullname,
|
name: chairmanData.fullname,
|
||||||
label:
|
label: chairmanData.fullname + " " + (chairmanData.position ? `(${chairmanData.position}, ${chairmanData.posType}: ${chairmanData.posLevel})` : ""),
|
||||||
chairmanData.fullname +
|
|
||||||
" " +
|
|
||||||
(chairmanData.position
|
|
||||||
? `(${chairmanData.position}, ${chairmanData.posType}: ${chairmanData.posLevel})`
|
|
||||||
: ""),
|
|
||||||
position: chairmanData.position,
|
position: chairmanData.position,
|
||||||
posType: chairmanData.posType,
|
posType: chairmanData.posType,
|
||||||
posLevel: chairmanData.posLevel,
|
posLevel: chairmanData.posLevel,
|
||||||
}
|
}
|
||||||
: null;
|
: null
|
||||||
|
|
||||||
return new HttpSuccess({
|
return new HttpSuccess({
|
||||||
person: profile ? profile : null,
|
person: profile ? profile : null,
|
||||||
|
|
@ -166,7 +134,7 @@ export class EvaluateChairmanController extends Controller {
|
||||||
commander,
|
commander,
|
||||||
mentors,
|
mentors,
|
||||||
chairman,
|
chairman,
|
||||||
});
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -176,12 +144,8 @@ export class EvaluateChairmanController extends Controller {
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Get("")
|
@Get("")
|
||||||
async GetEvaluate(
|
async GetEvaluate(@Request() request: RequestWithUser, @Query() assign_id: string, @Query() evaluate_no?: string) {
|
||||||
@Request() request: RequestWithUser,
|
await new permission().PermissionGet(request, "SYS_PROBATION")
|
||||||
@Query() assign_id: string,
|
|
||||||
@Query() evaluate_no?: string,
|
|
||||||
) {
|
|
||||||
await new permission().PermissionGet(request, "SYS_PROBATION");
|
|
||||||
// ต้องปรับเป็น id ของคนที่ access เข้ามา
|
// ต้องปรับเป็น id ของคนที่ access เข้ามา
|
||||||
const director = await this.assignDirectorRepository.findOne({
|
const director = await this.assignDirectorRepository.findOne({
|
||||||
select: ["personal_id"],
|
select: ["personal_id"],
|
||||||
|
|
@ -189,12 +153,12 @@ export class EvaluateChairmanController extends Controller {
|
||||||
assign_id,
|
assign_id,
|
||||||
role: "chairman",
|
role: "chairman",
|
||||||
},
|
},
|
||||||
});
|
})
|
||||||
if (!director) {
|
if (!director) {
|
||||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลผู้ดูแล");
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลผู้ดูแล")
|
||||||
}
|
}
|
||||||
const director_id = director.personal_id;
|
const director_id = director.personal_id
|
||||||
let evaluate: any = null;
|
let evaluate: any = null
|
||||||
if (evaluate_no) {
|
if (evaluate_no) {
|
||||||
evaluate = await this.evaluateChairmanRepository.findOne({
|
evaluate = await this.evaluateChairmanRepository.findOne({
|
||||||
where: {
|
where: {
|
||||||
|
|
@ -202,81 +166,72 @@ export class EvaluateChairmanController extends Controller {
|
||||||
assign_id,
|
assign_id,
|
||||||
no: evaluate_no,
|
no: evaluate_no,
|
||||||
},
|
},
|
||||||
});
|
})
|
||||||
} else {
|
} else {
|
||||||
evaluate = await this.evaluateChairmanRepository.find({
|
evaluate = await this.evaluateChairmanRepository.find({
|
||||||
where: {
|
where: {
|
||||||
director_id,
|
director_id,
|
||||||
assign_id,
|
assign_id,
|
||||||
},
|
},
|
||||||
});
|
})
|
||||||
|
|
||||||
if (evaluate)
|
if (evaluate)
|
||||||
evaluate = await evaluate.map((element: EvaluateChairman) => ({
|
evaluate = await evaluate.map((element: EvaluateChairman) => ({
|
||||||
...element,
|
...element,
|
||||||
no: Number(element.no),
|
no: Number(element.no),
|
||||||
}));
|
}))
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!evaluate) {
|
if (!evaluate) {
|
||||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลแบบประเมิน");
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลแบบประเมิน")
|
||||||
}
|
}
|
||||||
|
|
||||||
const assign = await this.assignRepository.findOne({
|
const assign = await this.assignRepository.findOne({
|
||||||
where: { id: assign_id },
|
where: { id: assign_id },
|
||||||
});
|
})
|
||||||
if (!assign) {
|
if (!assign) {
|
||||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลแบบมอบหมายงาน");
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลแบบมอบหมายงาน")
|
||||||
}
|
}
|
||||||
|
|
||||||
const experimenteeData = await this.personalRepository.find({
|
const experimenteeData = await this.personalRepository.find({
|
||||||
select: [
|
select: ["personal_id", "prefixName", "firstName", "lastName", "positionName", "positionLevelName", "organization"],
|
||||||
"personal_id",
|
|
||||||
"prefixName",
|
|
||||||
"firstName",
|
|
||||||
"lastName",
|
|
||||||
"positionName",
|
|
||||||
"positionLevelName",
|
|
||||||
"organization",
|
|
||||||
],
|
|
||||||
where: { personal_id: assign.personal_id },
|
where: { personal_id: assign.personal_id },
|
||||||
});
|
})
|
||||||
|
|
||||||
const experimentee = await experimenteeData.map((element) => ({
|
const experimentee = await experimenteeData.map(element => ({
|
||||||
...element,
|
...element,
|
||||||
name: element.prefixName + element.firstName + " " + element.lastName,
|
name: element.prefixName + element.firstName + " " + element.lastName,
|
||||||
Oc: element.organization,
|
Oc: element.organization,
|
||||||
}));
|
}))
|
||||||
|
|
||||||
const directorData = await this.assignDirectorRepository.find({
|
const directorData = await this.assignDirectorRepository.find({
|
||||||
where: { assign_id },
|
where: { assign_id },
|
||||||
order: { ordering: "ASC" },
|
order: { ordering: "ASC" },
|
||||||
});
|
})
|
||||||
|
|
||||||
if (!directorData) {
|
if (!directorData) {
|
||||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลผู้ดูแล ผู้บังคับบัญชาและประธาน");
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลผู้ดูแล ผู้บังคับบัญชาและประธาน")
|
||||||
}
|
}
|
||||||
|
|
||||||
let mentors = [];
|
let mentors = []
|
||||||
const mentorList = await directorData.filter((x) => x.role == "mentor");
|
const mentorList = await directorData.filter(x => x.role == "mentor")
|
||||||
if (mentorList.length > 0) {
|
if (mentorList.length > 0) {
|
||||||
for (let index = 0; index < mentorList.length; index++) {
|
for (let index = 0; index < mentorList.length; index++) {
|
||||||
const e = await mentorList[index];
|
const e = await mentorList[index]
|
||||||
|
|
||||||
mentors.push({
|
mentors.push({
|
||||||
personal_id: e.personal_id,
|
personal_id: e.personal_id,
|
||||||
dated: e.dated,
|
dated: e.dated,
|
||||||
name: e.fullname,
|
name: e.fullname,
|
||||||
label:
|
label: e.fullname + " " + (e.position ? `(${e.position}, ${e.posType}: ${e.posLevel})` : ""),
|
||||||
e.fullname + " " + (e.position ? `(${e.position}, ${e.posType}: ${e.posLevel})` : ""),
|
|
||||||
position: e.position,
|
position: e.position,
|
||||||
posType: e.posType,
|
posType: e.posType,
|
||||||
posLevel: e.posLevel,
|
posLevel: e.posLevel,
|
||||||
});
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const commanderData = await (directorData.find((x) => x.role == "commander") ?? null);
|
const commanderData = await (directorData.find(x => x.role == "commander") ?? null)
|
||||||
|
|
||||||
const commander =
|
const commander =
|
||||||
commanderData != null
|
commanderData != null
|
||||||
|
|
@ -284,36 +239,26 @@ export class EvaluateChairmanController extends Controller {
|
||||||
personal_id: commanderData.personal_id,
|
personal_id: commanderData.personal_id,
|
||||||
dated: commanderData.dated,
|
dated: commanderData.dated,
|
||||||
name: commanderData.fullname,
|
name: commanderData.fullname,
|
||||||
label:
|
label: commanderData.fullname + " " + (commanderData.position ? `(${commanderData.position}, ${commanderData.posType}: ${commanderData.posLevel})` : ""),
|
||||||
commanderData.fullname +
|
|
||||||
" " +
|
|
||||||
(commanderData.position
|
|
||||||
? `(${commanderData.position}, ${commanderData.posType}: ${commanderData.posLevel})`
|
|
||||||
: ""),
|
|
||||||
position: commanderData.position,
|
position: commanderData.position,
|
||||||
posType: commanderData.posType,
|
posType: commanderData.posType,
|
||||||
posLevel: commanderData.posLevel,
|
posLevel: commanderData.posLevel,
|
||||||
}
|
}
|
||||||
: null;
|
: null
|
||||||
|
|
||||||
const chairmanData = await (directorData.find((x) => x.role == "chairman") ?? null);
|
const chairmanData = await (directorData.find(x => x.role == "chairman") ?? null)
|
||||||
const chairman =
|
const chairman =
|
||||||
chairmanData != null
|
chairmanData != null
|
||||||
? {
|
? {
|
||||||
personal_id: chairmanData.personal_id,
|
personal_id: chairmanData.personal_id,
|
||||||
dated: chairmanData.dated,
|
dated: chairmanData.dated,
|
||||||
name: chairmanData.fullname,
|
name: chairmanData.fullname,
|
||||||
label:
|
label: chairmanData.fullname + " " + (chairmanData.position ? `(${chairmanData.position}, ${chairmanData.posType}: ${chairmanData.posLevel})` : ""),
|
||||||
chairmanData.fullname +
|
|
||||||
" " +
|
|
||||||
(chairmanData.position
|
|
||||||
? `(${chairmanData.position}, ${chairmanData.posType}: ${chairmanData.posLevel})`
|
|
||||||
: ""),
|
|
||||||
position: chairmanData.position,
|
position: chairmanData.position,
|
||||||
posType: chairmanData.posType,
|
posType: chairmanData.posType,
|
||||||
posLevel: chairmanData.posLevel,
|
posLevel: chairmanData.posLevel,
|
||||||
}
|
}
|
||||||
: null;
|
: null
|
||||||
|
|
||||||
return new HttpSuccess({
|
return new HttpSuccess({
|
||||||
experimentee: experimentee,
|
experimentee: experimentee,
|
||||||
|
|
@ -322,7 +267,7 @@ export class EvaluateChairmanController extends Controller {
|
||||||
chairman: chairman,
|
chairman: chairman,
|
||||||
assign,
|
assign,
|
||||||
evaluate,
|
evaluate,
|
||||||
});
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -332,12 +277,8 @@ export class EvaluateChairmanController extends Controller {
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Post("")
|
@Post("")
|
||||||
async PostData(
|
async PostData(@Query() assign_id: string, @Body() requestBody: CreateEvaluateChairman, @Request() request: RequestWithUser) {
|
||||||
@Query() assign_id: string,
|
await new permission().PermissionUpdate(request, "SYS_PROBATION")
|
||||||
@Body() requestBody: CreateEvaluateChairman,
|
|
||||||
@Request() request: RequestWithUser,
|
|
||||||
) {
|
|
||||||
await new permission().PermissionUpdate(request, "SYS_PROBATION");
|
|
||||||
|
|
||||||
const director = await this.assignDirectorRepository.findOne({
|
const director = await this.assignDirectorRepository.findOne({
|
||||||
select: ["personal_id"],
|
select: ["personal_id"],
|
||||||
|
|
@ -345,19 +286,19 @@ export class EvaluateChairmanController extends Controller {
|
||||||
assign_id,
|
assign_id,
|
||||||
role: "chairman",
|
role: "chairman",
|
||||||
},
|
},
|
||||||
});
|
})
|
||||||
if (!director) {
|
if (!director) {
|
||||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลผู้ดูแล");
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลผู้ดูแล")
|
||||||
}
|
}
|
||||||
|
|
||||||
const director_id = director.personal_id;
|
const director_id = director.personal_id
|
||||||
|
|
||||||
const assign = await this.assignRepository.findOne({
|
const assign = await this.assignRepository.findOne({
|
||||||
relations: ["profile"],
|
relations: ["profile"],
|
||||||
where: { id: assign_id },
|
where: { id: assign_id },
|
||||||
});
|
})
|
||||||
if (!assign) {
|
if (!assign) {
|
||||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลแบบมอบหมายงาน");
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลแบบมอบหมายงาน")
|
||||||
}
|
}
|
||||||
|
|
||||||
const postData: any = await {
|
const postData: any = await {
|
||||||
|
|
@ -368,32 +309,27 @@ export class EvaluateChairmanController extends Controller {
|
||||||
date_start: requestBody.start_date,
|
date_start: requestBody.start_date,
|
||||||
personal_id: assign.personal_id,
|
personal_id: assign.personal_id,
|
||||||
|
|
||||||
achievement_other_desc: requestBody.achievement_other
|
achievement_other_desc: requestBody.achievement_other ? requestBody.achievement_other.text : "",
|
||||||
? requestBody.achievement_other.text
|
achievement_other_level: requestBody.achievement_other ? Number(requestBody.achievement_other.level) : 0,
|
||||||
: "",
|
|
||||||
achievement_other_level: requestBody.achievement_other
|
|
||||||
? Number(requestBody.achievement_other.level)
|
|
||||||
: 0,
|
|
||||||
behavior_other_desc: requestBody.behavior_orther.text,
|
behavior_other_desc: requestBody.behavior_orther.text,
|
||||||
behavior_other_level:
|
behavior_other_level: requestBody.behavior_orther.text != "" ? Number(requestBody.behavior_orther.level) : 0,
|
||||||
requestBody.behavior_orther.text != "" ? Number(requestBody.behavior_orther.level) : 0,
|
|
||||||
|
|
||||||
createdUserId: request.user.sub,
|
createdUserId: request.user.sub,
|
||||||
createdFullName: request.user.name,
|
createdFullName: request.user.name,
|
||||||
updateUserId: request.user.sub,
|
updateUserId: request.user.sub,
|
||||||
updateFullName: request.user.name,
|
updateFullName: request.user.name,
|
||||||
};
|
}
|
||||||
|
|
||||||
await this.evaluateChairmanRepository.save(postData, {
|
await this.evaluateChairmanRepository.save(postData, {
|
||||||
data: request,
|
data: request,
|
||||||
});
|
})
|
||||||
setLogDataDiff(request, { before: null, after: postData });
|
setLogDataDiff(request, { before: null, after: postData })
|
||||||
|
|
||||||
if (Number(requestBody.evaluate_no) < 2) {
|
if (Number(requestBody.evaluate_no) < 2) {
|
||||||
// #noted cronjob
|
// #noted cronjob
|
||||||
// แจ้งประธานเข้ามาบันทึกผลทุก 3 เดือน 2 ครั้ง
|
// แจ้งประธานเข้ามาบันทึกผลทุก 3 เดือน 2 ครั้ง
|
||||||
var dateSend = await findEndDate(3, requestBody.start_date);
|
var dateSend = await findEndDate(3, requestBody.start_date)
|
||||||
const nextNo = await (Number(requestBody.evaluate_no) + 1);
|
const nextNo = await (Number(requestBody.evaluate_no) + 1)
|
||||||
await new CallAPI()
|
await new CallAPI()
|
||||||
.PostData(request, "/placement/noti", {
|
.PostData(request, "/placement/noti", {
|
||||||
subject: `ถึงกำหนดประเมินผลการทดลองปฏิบัติหน้าที่ราชการครั้งที่ ${nextNo} ${assign.profile.prefixName}${assign.profile.firstName} ${assign.profile.lastName}`,
|
subject: `ถึงกำหนดประเมินผลการทดลองปฏิบัติหน้าที่ราชการครั้งที่ ${nextNo} ${assign.profile.prefixName}${assign.profile.firstName} ${assign.profile.lastName}`,
|
||||||
|
|
@ -404,12 +340,12 @@ export class EvaluateChairmanController extends Controller {
|
||||||
isSendInbox: true,
|
isSendInbox: true,
|
||||||
receiveDate: dateSend,
|
receiveDate: dateSend,
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch(error => {
|
||||||
console.error("Error calling API:", error);
|
console.error("Error calling API:", error)
|
||||||
});
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
return new HttpSuccess();
|
return new HttpSuccess()
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -423,74 +359,70 @@ export class EvaluateChairmanController extends Controller {
|
||||||
// @Query() assign_id: string,
|
// @Query() assign_id: string,
|
||||||
@Query() evaluate_id: string,
|
@Query() evaluate_id: string,
|
||||||
@Body() requestBody: CreateEvaluateChairman,
|
@Body() requestBody: CreateEvaluateChairman,
|
||||||
@Request() request: RequestWithUser,
|
@Request() request: RequestWithUser
|
||||||
) {
|
) {
|
||||||
await new permission().PermissionUpdate(request, "SYS_PROBATION");
|
await new permission().PermissionUpdate(request, "SYS_PROBATION")
|
||||||
|
|
||||||
let evaluate = await this.evaluateChairmanRepository.findOne({
|
let evaluate = await this.evaluateChairmanRepository.findOne({
|
||||||
where: { id: evaluate_id },
|
where: { id: evaluate_id },
|
||||||
});
|
})
|
||||||
|
|
||||||
const before = evaluate;
|
const before = evaluate
|
||||||
|
|
||||||
if (!evaluate) {
|
if (!evaluate) {
|
||||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลการประเมิน");
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลการประเมิน")
|
||||||
}
|
}
|
||||||
|
|
||||||
evaluate.chairman_dated = requestBody.chairman_dated;
|
evaluate.chairman_dated = requestBody.chairman_dated
|
||||||
evaluate.director1_dated = requestBody.director1_dated;
|
evaluate.director1_dated = requestBody.director1_dated
|
||||||
evaluate.director2_dated = requestBody.director2_dated;
|
evaluate.director2_dated = requestBody.director2_dated
|
||||||
evaluate.knowledge_level = requestBody.knowledge_level;
|
evaluate.knowledge_level = requestBody.knowledge_level
|
||||||
evaluate.apply_level = requestBody.apply_level;
|
evaluate.apply_level = requestBody.apply_level
|
||||||
evaluate.success_level = requestBody.success_level;
|
evaluate.success_level = requestBody.success_level
|
||||||
evaluate.achievement_other_desc = requestBody.achievement_other
|
evaluate.achievement_other_desc = requestBody.achievement_other ? requestBody.achievement_other.text : ""
|
||||||
? requestBody.achievement_other.text
|
evaluate.achievement_other_level = requestBody.achievement_other.text != "" ? Number(requestBody.achievement_other.level) : 0
|
||||||
: "";
|
|
||||||
evaluate.achievement_other_level =
|
|
||||||
requestBody.achievement_other.text != "" ? Number(requestBody.achievement_other.level) : 0;
|
|
||||||
|
|
||||||
evaluate.conduct1_level = requestBody.conduct1_level;
|
evaluate.conduct1_level = requestBody.conduct1_level
|
||||||
evaluate.conduct2_level = requestBody.conduct2_level;
|
evaluate.conduct2_level = requestBody.conduct2_level
|
||||||
evaluate.conduct3_level = requestBody.conduct3_level;
|
evaluate.conduct3_level = requestBody.conduct3_level
|
||||||
evaluate.conduct4_level = requestBody.conduct4_level;
|
evaluate.conduct4_level = requestBody.conduct4_level
|
||||||
evaluate.moral1_level = requestBody.moral1_level;
|
evaluate.moral1_level = requestBody.moral1_level
|
||||||
evaluate.moral2_level = requestBody.moral2_level;
|
evaluate.moral2_level = requestBody.moral2_level
|
||||||
evaluate.moral3_level = requestBody.moral3_level;
|
evaluate.moral3_level = requestBody.moral3_level
|
||||||
evaluate.discipline1_level = requestBody.discipline1_level;
|
evaluate.discipline1_level = requestBody.discipline1_level
|
||||||
evaluate.discipline2_level = requestBody.discipline2_level;
|
evaluate.discipline2_level = requestBody.discipline2_level
|
||||||
evaluate.discipline3_level = requestBody.discipline3_level;
|
evaluate.discipline3_level = requestBody.discipline3_level
|
||||||
evaluate.discipline4_level = requestBody.discipline4_level;
|
evaluate.discipline4_level = requestBody.discipline4_level
|
||||||
evaluate.discipline5_level = requestBody.discipline5_level;
|
evaluate.discipline5_level = requestBody.discipline5_level
|
||||||
evaluate.behavior_other_desc = requestBody.behavior_orther.text;
|
evaluate.behavior_other_desc = requestBody.behavior_orther.text
|
||||||
evaluate.behavior_other_level =
|
evaluate.behavior_other_level = requestBody.behavior_orther.text != "" ? Number(requestBody.behavior_orther.level) : 0
|
||||||
requestBody.behavior_orther.text != "" ? Number(requestBody.behavior_orther.level) : 0;
|
evaluate.develop_orientation_score = requestBody.develop_orientation_score
|
||||||
evaluate.develop_orientation_score = requestBody.develop_orientation_score;
|
evaluate.develop_self_learning_score = requestBody.develop_self_learning_score
|
||||||
evaluate.develop_self_learning_score = requestBody.develop_self_learning_score;
|
evaluate.develop_training_seminar_score = requestBody.develop_training_seminar_score
|
||||||
evaluate.develop_training_seminar_score = requestBody.develop_training_seminar_score;
|
evaluate.develop_other_training_score = requestBody.develop_other_training_score
|
||||||
evaluate.develop_other_training_score = requestBody.develop_other_training_score;
|
evaluate.develop_orientation_percent = requestBody.develop_orientation_percent
|
||||||
evaluate.develop_orientation_percent = requestBody.develop_orientation_percent;
|
evaluate.develop_self_learning_percent = requestBody.develop_self_learning_percent
|
||||||
evaluate.develop_self_learning_percent = requestBody.develop_self_learning_percent;
|
evaluate.develop_training_seminar_percent = requestBody.develop_training_seminar_percent
|
||||||
evaluate.develop_training_seminar_percent = requestBody.develop_training_seminar_percent;
|
evaluate.develop_other_training_percent = requestBody.develop_other_training_percent
|
||||||
evaluate.develop_other_training_percent = requestBody.develop_other_training_percent;
|
evaluate.develop_result = requestBody.develop_result
|
||||||
evaluate.develop_result = requestBody.develop_result;
|
evaluate.achievement_score = requestBody.achievement_score
|
||||||
evaluate.achievement_score = requestBody.achievement_score;
|
evaluate.achievement_score_total = requestBody.achievement_score_total
|
||||||
evaluate.achievement_score_total = requestBody.achievement_score_total;
|
evaluate.achievement_percent = requestBody.achievement_percent
|
||||||
evaluate.achievement_percent = requestBody.achievement_percent;
|
evaluate.achievement_result = requestBody.achievement_result
|
||||||
evaluate.achievement_result = requestBody.achievement_result;
|
evaluate.behavior_score = requestBody.behavior_score
|
||||||
evaluate.behavior_score = requestBody.behavior_score;
|
evaluate.behavior_score_total = requestBody.behavior_score_total
|
||||||
evaluate.behavior_score_total = requestBody.behavior_score_total;
|
evaluate.behavior_percent = requestBody.behavior_percent
|
||||||
evaluate.behavior_percent = requestBody.behavior_percent;
|
evaluate.behavior_result = requestBody.behavior_result
|
||||||
evaluate.behavior_result = requestBody.behavior_result;
|
evaluate.sum_score = requestBody.sum_score
|
||||||
evaluate.sum_score = requestBody.sum_score;
|
evaluate.sum_percent = requestBody.sum_percent
|
||||||
evaluate.sum_percent = requestBody.sum_percent;
|
evaluate.evaluate_result = requestBody.evaluate_result
|
||||||
evaluate.evaluate_result = requestBody.evaluate_result;
|
|
||||||
|
|
||||||
evaluate.updateUserId = request.user.sub;
|
evaluate.updateUserId = request.user.sub
|
||||||
evaluate.updateFullName = request.user.name;
|
evaluate.updateFullName = request.user.name
|
||||||
|
|
||||||
await this.evaluateChairmanRepository.save(evaluate, { data: request });
|
await this.evaluateChairmanRepository.save(evaluate, { data: request })
|
||||||
setLogDataDiff(request, { before, after: evaluate });
|
setLogDataDiff(request, { before, after: evaluate })
|
||||||
|
|
||||||
return new HttpSuccess();
|
return new HttpSuccess()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,42 +1,25 @@
|
||||||
import {
|
import { Controller, Route, Security, Tags, Request, SuccessResponse, Response, Get, Post, Body, Query, Put } from "tsoa"
|
||||||
Controller,
|
import HttpSuccess from "../interfaces/http-success"
|
||||||
Route,
|
import HttpStatusCode from "../interfaces/http-status"
|
||||||
Security,
|
import { RequestWithUser } from "../middlewares/user"
|
||||||
Tags,
|
import { findEndDate, setLogDataDiff } from "../interfaces/utils"
|
||||||
Request,
|
import { AppDataSource } from "../database/data-source"
|
||||||
SuccessResponse,
|
import { AssignDirector } from "../entities/AssignDirector"
|
||||||
Response,
|
import HttpError from "../interfaces/http-error"
|
||||||
Get,
|
import { Assign } from "../entities/Assign"
|
||||||
Post,
|
import { CreateEvaluateCommander, EvaluateCommander } from "../entities/EvaluateCommander"
|
||||||
Body,
|
import { Personal } from "../entities/Personal"
|
||||||
Query,
|
import CallAPI from "../interfaces/call-api"
|
||||||
Put,
|
import permission from "../interfaces/permission"
|
||||||
} from "tsoa";
|
|
||||||
import HttpSuccess from "../interfaces/http-success";
|
|
||||||
import HttpStatusCode from "../interfaces/http-status";
|
|
||||||
import { RequestWithUser } from "../middlewares/user";
|
|
||||||
import { findEndDate, setLogDataDiff } from "../interfaces/utils";
|
|
||||||
import { AppDataSource } from "../database/data-source";
|
|
||||||
import { AssignDirector } from "../entities/AssignDirector";
|
|
||||||
import HttpError from "../interfaces/http-error";
|
|
||||||
import { Assign } from "../entities/Assign";
|
|
||||||
import { CreateEvaluateCommander, EvaluateCommander } from "../entities/EvaluateCommander";
|
|
||||||
import { Personal } from "../entities/Personal";
|
|
||||||
import CallAPI from "../interfaces/call-api";
|
|
||||||
import permission from "../interfaces/permission";
|
|
||||||
@Route("api/v1/probation/evaluate")
|
@Route("api/v1/probation/evaluate")
|
||||||
@Tags("แบบประเมินผล (ผู้บังคับบัญชา)")
|
@Tags("แบบประเมินผล (ผู้บังคับบัญชา)")
|
||||||
@Security("bearerAuth")
|
@Security("bearerAuth")
|
||||||
@Response(
|
@Response(HttpStatusCode.INTERNAL_SERVER_ERROR, "เกิดข้อผิดพลาด ไม่สามารถแสดงรายการได้ กรุณาลองใหม่ในภายหลัง")
|
||||||
HttpStatusCode.INTERNAL_SERVER_ERROR,
|
|
||||||
"เกิดข้อผิดพลาด ไม่สามารถแสดงรายการได้ กรุณาลองใหม่ในภายหลัง",
|
|
||||||
)
|
|
||||||
@SuccessResponse(HttpStatusCode.OK, "สำเร็จ")
|
|
||||||
export class EvaluateController extends Controller {
|
export class EvaluateController extends Controller {
|
||||||
private assignDirectorRepository = AppDataSource.getRepository(AssignDirector);
|
private assignDirectorRepository = AppDataSource.getRepository(AssignDirector)
|
||||||
private assignRepository = AppDataSource.getRepository(Assign);
|
private assignRepository = AppDataSource.getRepository(Assign)
|
||||||
private evaluateCommanderRepository = AppDataSource.getRepository(EvaluateCommander);
|
private evaluateCommanderRepository = AppDataSource.getRepository(EvaluateCommander)
|
||||||
private personalRepository = AppDataSource.getRepository(Personal);
|
private personalRepository = AppDataSource.getRepository(Personal)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* API ข้อมูลตอนกดสร้างแบบประเมินผล (ผู้บังคับบัญชา)
|
* API ข้อมูลตอนกดสร้างแบบประเมินผล (ผู้บังคับบัญชา)
|
||||||
|
|
@ -46,7 +29,7 @@ export class EvaluateController extends Controller {
|
||||||
*/
|
*/
|
||||||
@Get("create")
|
@Get("create")
|
||||||
async CreateEvaluate(@Query() assign_id: string, @Request() request: RequestWithUser) {
|
async CreateEvaluate(@Query() assign_id: string, @Request() request: RequestWithUser) {
|
||||||
await new permission().PermissionGet(request, "SYS_PROBATION");
|
await new permission().PermissionGet(request, "SYS_PROBATION")
|
||||||
|
|
||||||
const director = await this.assignDirectorRepository.findOne({
|
const director = await this.assignDirectorRepository.findOne({
|
||||||
select: ["personal_id"],
|
select: ["personal_id"],
|
||||||
|
|
@ -54,54 +37,50 @@ export class EvaluateController extends Controller {
|
||||||
assign_id,
|
assign_id,
|
||||||
role: "commander",
|
role: "commander",
|
||||||
},
|
},
|
||||||
});
|
})
|
||||||
if (!director) {
|
if (!director) {
|
||||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลผู้ดูแล");
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลผู้ดูแล")
|
||||||
}
|
}
|
||||||
const director_id = director.personal_id;
|
const director_id = director.personal_id
|
||||||
|
|
||||||
const assign = await this.assignRepository.findOne({
|
const assign = await this.assignRepository.findOne({
|
||||||
relations: ["profile"],
|
relations: ["profile"],
|
||||||
where: { id: assign_id },
|
where: { id: assign_id },
|
||||||
});
|
})
|
||||||
if (!assign) {
|
if (!assign) {
|
||||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลแบบมอบหมายงาน");
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลแบบมอบหมายงาน")
|
||||||
}
|
}
|
||||||
|
|
||||||
const profile = await (assign.profile
|
const profile = await (assign.profile
|
||||||
? {
|
? {
|
||||||
...assign.profile,
|
...assign.profile,
|
||||||
id: assign.profile.personal_id,
|
id: assign.profile.personal_id,
|
||||||
name:
|
name: assign.profile.prefixName + assign.profile.firstName + " " + assign.profile.lastName,
|
||||||
assign.profile.prefixName + assign.profile.firstName + " " + assign.profile.lastName,
|
|
||||||
Oc: assign.profile.organization,
|
Oc: assign.profile.organization,
|
||||||
}
|
}
|
||||||
: null);
|
: null)
|
||||||
|
|
||||||
const evaluate_amount = await this.evaluateCommanderRepository.count({
|
const evaluate_amount = await this.evaluateCommanderRepository.count({
|
||||||
where: {
|
where: {
|
||||||
assign_id,
|
assign_id,
|
||||||
director_id,
|
director_id,
|
||||||
},
|
},
|
||||||
});
|
})
|
||||||
const evaluate_no = await (evaluate_amount + 1);
|
const evaluate_no = await (evaluate_amount + 1)
|
||||||
const start_date =
|
const start_date = evaluate_amount == 0 ? assign.date_start : findEndDate(evaluate_amount * 3, assign.date_start)
|
||||||
evaluate_amount == 0
|
|
||||||
? assign.date_start
|
|
||||||
: findEndDate(evaluate_amount * 3, assign.date_start);
|
|
||||||
|
|
||||||
const commanderData = await this.assignDirectorRepository.findOne({
|
const commanderData = await this.assignDirectorRepository.findOne({
|
||||||
select: ["personal_id", "dated", "fullname", "position", "posType", "posLevel"],
|
select: ["personal_id", "dated", "fullname", "position", "posType", "posLevel"],
|
||||||
where: { personal_id: director_id },
|
where: { personal_id: director_id },
|
||||||
});
|
})
|
||||||
if (!commanderData) {
|
if (!commanderData) {
|
||||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลผู้บังคับบัญชา");
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลผู้บังคับบัญชา")
|
||||||
}
|
}
|
||||||
const commander = await {
|
const commander = await {
|
||||||
...commanderData,
|
...commanderData,
|
||||||
name: commanderData.fullname,
|
name: commanderData.fullname,
|
||||||
label: `${commanderData.fullname} (${commanderData.position}, ${commanderData.posType}: ${commanderData.posLevel})`,
|
label: `${commanderData.fullname} (${commanderData.position}, ${commanderData.posType}: ${commanderData.posLevel})`,
|
||||||
};
|
}
|
||||||
|
|
||||||
return new HttpSuccess({
|
return new HttpSuccess({
|
||||||
person: profile,
|
person: profile,
|
||||||
|
|
@ -110,7 +89,7 @@ export class EvaluateController extends Controller {
|
||||||
start_date: start_date,
|
start_date: start_date,
|
||||||
end_date: findEndDate(3, start_date),
|
end_date: findEndDate(3, start_date),
|
||||||
director: commander,
|
director: commander,
|
||||||
});
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -120,12 +99,8 @@ export class EvaluateController extends Controller {
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Get("")
|
@Get("")
|
||||||
async GetEvaluate(
|
async GetEvaluate(@Request() request: RequestWithUser, @Query() assign_id: string, @Query() evaluate_no?: string) {
|
||||||
@Request() request: RequestWithUser,
|
await new permission().PermissionGet(request, "SYS_PROBATION")
|
||||||
@Query() assign_id: string,
|
|
||||||
@Query() evaluate_no?: string,
|
|
||||||
) {
|
|
||||||
await new permission().PermissionGet(request, "SYS_PROBATION");
|
|
||||||
|
|
||||||
// ต้องปรับเป็น id ของคนที่ access เข้ามา
|
// ต้องปรับเป็น id ของคนที่ access เข้ามา
|
||||||
const director = await this.assignDirectorRepository.findOne({
|
const director = await this.assignDirectorRepository.findOne({
|
||||||
|
|
@ -134,12 +109,12 @@ export class EvaluateController extends Controller {
|
||||||
assign_id,
|
assign_id,
|
||||||
role: "commander",
|
role: "commander",
|
||||||
},
|
},
|
||||||
});
|
})
|
||||||
if (!director) {
|
if (!director) {
|
||||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลผู้ดูแล");
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลผู้ดูแล")
|
||||||
}
|
}
|
||||||
const director_id = director.personal_id;
|
const director_id = director.personal_id
|
||||||
let evaluate: any = null;
|
let evaluate: any = null
|
||||||
if (evaluate_no) {
|
if (evaluate_no) {
|
||||||
evaluate = await this.evaluateCommanderRepository.findOne({
|
evaluate = await this.evaluateCommanderRepository.findOne({
|
||||||
where: {
|
where: {
|
||||||
|
|
@ -147,31 +122,31 @@ export class EvaluateController extends Controller {
|
||||||
assign_id,
|
assign_id,
|
||||||
no: evaluate_no,
|
no: evaluate_no,
|
||||||
},
|
},
|
||||||
});
|
})
|
||||||
} else {
|
} else {
|
||||||
evaluate = await this.evaluateCommanderRepository.find({
|
evaluate = await this.evaluateCommanderRepository.find({
|
||||||
where: {
|
where: {
|
||||||
director_id,
|
director_id,
|
||||||
assign_id,
|
assign_id,
|
||||||
},
|
},
|
||||||
});
|
})
|
||||||
|
|
||||||
if (evaluate)
|
if (evaluate)
|
||||||
evaluate = await evaluate.map((element: EvaluateCommander) => ({
|
evaluate = await evaluate.map((element: EvaluateCommander) => ({
|
||||||
...element,
|
...element,
|
||||||
no: Number(element.no),
|
no: Number(element.no),
|
||||||
}));
|
}))
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!evaluate) {
|
if (!evaluate) {
|
||||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลแบบประเมิน");
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลแบบประเมิน")
|
||||||
}
|
}
|
||||||
|
|
||||||
const assign = await this.assignRepository.findOne({
|
const assign = await this.assignRepository.findOne({
|
||||||
where: { id: assign_id },
|
where: { id: assign_id },
|
||||||
});
|
})
|
||||||
if (!assign) {
|
if (!assign) {
|
||||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลแบบมอบหมายงาน");
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลแบบมอบหมายงาน")
|
||||||
}
|
}
|
||||||
|
|
||||||
// const profile = await (assign.profile
|
// const profile = await (assign.profile
|
||||||
|
|
@ -202,39 +177,31 @@ export class EvaluateController extends Controller {
|
||||||
const directorData = await this.assignDirectorRepository.find({
|
const directorData = await this.assignDirectorRepository.find({
|
||||||
select: ["personal_id", "dated", "fullname", "position", "posType", "posLevel"],
|
select: ["personal_id", "dated", "fullname", "position", "posType", "posLevel"],
|
||||||
where: { personal_id: director_id },
|
where: { personal_id: director_id },
|
||||||
});
|
})
|
||||||
|
|
||||||
const directors = await directorData.map((element) => ({
|
const directors = await directorData.map(element => ({
|
||||||
...element,
|
...element,
|
||||||
name: element.fullname,
|
name: element.fullname,
|
||||||
label: `${element.fullname} (${element.position}, ${element.posType}: ${element.posLevel})`,
|
label: `${element.fullname} (${element.position}, ${element.posType}: ${element.posLevel})`,
|
||||||
}));
|
}))
|
||||||
|
|
||||||
const experimenteeData = await this.personalRepository.find({
|
const experimenteeData = await this.personalRepository.find({
|
||||||
select: [
|
select: ["personal_id", "prefixName", "firstName", "lastName", "positionName", "positionLevelName", "organization"],
|
||||||
"personal_id",
|
|
||||||
"prefixName",
|
|
||||||
"firstName",
|
|
||||||
"lastName",
|
|
||||||
"positionName",
|
|
||||||
"positionLevelName",
|
|
||||||
"organization",
|
|
||||||
],
|
|
||||||
where: { personal_id: assign.personal_id },
|
where: { personal_id: assign.personal_id },
|
||||||
});
|
})
|
||||||
|
|
||||||
const experimentee = await experimenteeData.map((element) => ({
|
const experimentee = await experimenteeData.map(element => ({
|
||||||
...element,
|
...element,
|
||||||
name: element.prefixName + element.firstName + " " + element.lastName,
|
name: element.prefixName + element.firstName + " " + element.lastName,
|
||||||
Oc: element.organization,
|
Oc: element.organization,
|
||||||
}));
|
}))
|
||||||
|
|
||||||
return new HttpSuccess({
|
return new HttpSuccess({
|
||||||
experimentee: experimentee,
|
experimentee: experimentee,
|
||||||
director: directors ? directors : null,
|
director: directors ? directors : null,
|
||||||
assign,
|
assign,
|
||||||
evaluate,
|
evaluate,
|
||||||
});
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -244,12 +211,8 @@ export class EvaluateController extends Controller {
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Post("")
|
@Post("")
|
||||||
async PostData(
|
async PostData(@Query() assign_id: string, @Body() requestBody: CreateEvaluateCommander, @Request() request: RequestWithUser) {
|
||||||
@Query() assign_id: string,
|
await new permission().PermissionUpdate(request, "SYS_PROBATION")
|
||||||
@Body() requestBody: CreateEvaluateCommander,
|
|
||||||
@Request() request: RequestWithUser,
|
|
||||||
) {
|
|
||||||
await new permission().PermissionUpdate(request, "SYS_PROBATION");
|
|
||||||
|
|
||||||
const director = await this.assignDirectorRepository.findOne({
|
const director = await this.assignDirectorRepository.findOne({
|
||||||
select: ["personal_id"],
|
select: ["personal_id"],
|
||||||
|
|
@ -257,19 +220,19 @@ export class EvaluateController extends Controller {
|
||||||
assign_id,
|
assign_id,
|
||||||
role: "commander",
|
role: "commander",
|
||||||
},
|
},
|
||||||
});
|
})
|
||||||
if (!director) {
|
if (!director) {
|
||||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลผู้ดูแล");
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลผู้ดูแล")
|
||||||
}
|
}
|
||||||
|
|
||||||
const director_id = director.personal_id;
|
const director_id = director.personal_id
|
||||||
|
|
||||||
const assign = await this.assignRepository.findOne({
|
const assign = await this.assignRepository.findOne({
|
||||||
relations: ["profile"],
|
relations: ["profile"],
|
||||||
where: { id: assign_id },
|
where: { id: assign_id },
|
||||||
});
|
})
|
||||||
if (!assign) {
|
if (!assign) {
|
||||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลแบบมอบหมายงาน");
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลแบบมอบหมายงาน")
|
||||||
}
|
}
|
||||||
|
|
||||||
const postData: any = await {
|
const postData: any = await {
|
||||||
|
|
@ -280,32 +243,27 @@ export class EvaluateController extends Controller {
|
||||||
date_start: requestBody.start_date,
|
date_start: requestBody.start_date,
|
||||||
personal_id: assign.personal_id,
|
personal_id: assign.personal_id,
|
||||||
|
|
||||||
achievement_other_desc: requestBody.achievement_other
|
achievement_other_desc: requestBody.achievement_other ? requestBody.achievement_other.text : "",
|
||||||
? requestBody.achievement_other.text
|
achievement_other_level: requestBody.achievement_other ? Number(requestBody.achievement_other.level) : 0,
|
||||||
: "",
|
|
||||||
achievement_other_level: requestBody.achievement_other
|
|
||||||
? Number(requestBody.achievement_other.level)
|
|
||||||
: 0,
|
|
||||||
behavior_other_desc: requestBody.behavior_orther.text,
|
behavior_other_desc: requestBody.behavior_orther.text,
|
||||||
behavior_other_level:
|
behavior_other_level: requestBody.behavior_orther.text != "" ? Number(requestBody.behavior_orther.level) : 0,
|
||||||
requestBody.behavior_orther.text != "" ? Number(requestBody.behavior_orther.level) : 0,
|
|
||||||
|
|
||||||
createdUserId: request.user.sub,
|
createdUserId: request.user.sub,
|
||||||
createdFullName: request.user.name,
|
createdFullName: request.user.name,
|
||||||
updateUserId: request.user.sub,
|
updateUserId: request.user.sub,
|
||||||
updateFullName: request.user.name,
|
updateFullName: request.user.name,
|
||||||
};
|
}
|
||||||
|
|
||||||
await this.evaluateCommanderRepository.save(postData, {
|
await this.evaluateCommanderRepository.save(postData, {
|
||||||
data: request,
|
data: request,
|
||||||
});
|
})
|
||||||
setLogDataDiff(request, { before: null, after: postData });
|
setLogDataDiff(request, { before: null, after: postData })
|
||||||
|
|
||||||
if (Number(requestBody.evaluate_no) < 2) {
|
if (Number(requestBody.evaluate_no) < 2) {
|
||||||
// #noted cronjob
|
// #noted cronjob
|
||||||
// แจ้งผู้บังคับบัญชาเข้ามาบันทึกผลทุก 3 เดือน 2 ครั้ง
|
// แจ้งผู้บังคับบัญชาเข้ามาบันทึกผลทุก 3 เดือน 2 ครั้ง
|
||||||
var dateSend = await findEndDate(3, requestBody.start_date);
|
var dateSend = await findEndDate(3, requestBody.start_date)
|
||||||
const nextNo = await (Number(requestBody.evaluate_no) + 1);
|
const nextNo = await (Number(requestBody.evaluate_no) + 1)
|
||||||
await new CallAPI()
|
await new CallAPI()
|
||||||
.PostData(request, "/placement/noti", {
|
.PostData(request, "/placement/noti", {
|
||||||
subject: `ถึงกำหนดประเมินผลการทดลองปฏิบัติหน้าที่ราชการครั้งที่ ${nextNo} ${assign.profile.prefixName}${assign.profile.firstName} ${assign.profile.lastName}`,
|
subject: `ถึงกำหนดประเมินผลการทดลองปฏิบัติหน้าที่ราชการครั้งที่ ${nextNo} ${assign.profile.prefixName}${assign.profile.firstName} ${assign.profile.lastName}`,
|
||||||
|
|
@ -316,12 +274,12 @@ export class EvaluateController extends Controller {
|
||||||
isSendInbox: true,
|
isSendInbox: true,
|
||||||
receiveDate: dateSend,
|
receiveDate: dateSend,
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch(error => {
|
||||||
console.error("Error calling API:", error);
|
console.error("Error calling API:", error)
|
||||||
});
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
return new HttpSuccess();
|
return new HttpSuccess()
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -335,60 +293,56 @@ export class EvaluateController extends Controller {
|
||||||
// @Query() assign_id: string,
|
// @Query() assign_id: string,
|
||||||
@Query() evaluate_id: string,
|
@Query() evaluate_id: string,
|
||||||
@Body() requestBody: CreateEvaluateCommander,
|
@Body() requestBody: CreateEvaluateCommander,
|
||||||
@Request() request: RequestWithUser,
|
@Request() request: RequestWithUser
|
||||||
) {
|
) {
|
||||||
await new permission().PermissionUpdate(request, "SYS_PROBATION");
|
await new permission().PermissionUpdate(request, "SYS_PROBATION")
|
||||||
|
|
||||||
let evaluate = await this.evaluateCommanderRepository.findOne({
|
let evaluate = await this.evaluateCommanderRepository.findOne({
|
||||||
where: { id: evaluate_id },
|
where: { id: evaluate_id },
|
||||||
});
|
})
|
||||||
|
|
||||||
const before = evaluate;
|
const before = evaluate
|
||||||
|
|
||||||
if (!evaluate) {
|
if (!evaluate) {
|
||||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลการประเมิน");
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลการประเมิน")
|
||||||
}
|
}
|
||||||
|
|
||||||
evaluate.commander_dated = requestBody.commander_dated;
|
evaluate.commander_dated = requestBody.commander_dated
|
||||||
evaluate.knowledge_level = requestBody.knowledge_level;
|
evaluate.knowledge_level = requestBody.knowledge_level
|
||||||
evaluate.skill_level = requestBody.skill_level;
|
evaluate.skill_level = requestBody.skill_level
|
||||||
evaluate.competency_level = requestBody.competency_level;
|
evaluate.competency_level = requestBody.competency_level
|
||||||
evaluate.learn_level = requestBody.learn_level;
|
evaluate.learn_level = requestBody.learn_level
|
||||||
evaluate.apply_level = requestBody.apply_level;
|
evaluate.apply_level = requestBody.apply_level
|
||||||
evaluate.success_level = requestBody.success_level;
|
evaluate.success_level = requestBody.success_level
|
||||||
evaluate.achievement_other_desc = requestBody.achievement_other
|
evaluate.achievement_other_desc = requestBody.achievement_other ? requestBody.achievement_other.text : ""
|
||||||
? requestBody.achievement_other.text
|
evaluate.achievement_other_level = requestBody.achievement_other.text != "" ? Number(requestBody.achievement_other.level) : 0
|
||||||
: "";
|
|
||||||
evaluate.achievement_other_level =
|
|
||||||
requestBody.achievement_other.text != "" ? Number(requestBody.achievement_other.level) : 0;
|
|
||||||
|
|
||||||
evaluate.conduct1_level = requestBody.conduct1_level;
|
evaluate.conduct1_level = requestBody.conduct1_level
|
||||||
evaluate.conduct2_level = requestBody.conduct2_level;
|
evaluate.conduct2_level = requestBody.conduct2_level
|
||||||
evaluate.conduct3_level = requestBody.conduct3_level;
|
evaluate.conduct3_level = requestBody.conduct3_level
|
||||||
evaluate.conduct4_level = requestBody.conduct4_level;
|
evaluate.conduct4_level = requestBody.conduct4_level
|
||||||
evaluate.moral1_level = requestBody.moral1_level;
|
evaluate.moral1_level = requestBody.moral1_level
|
||||||
evaluate.moral2_level = requestBody.moral2_level;
|
evaluate.moral2_level = requestBody.moral2_level
|
||||||
evaluate.moral3_level = requestBody.moral3_level;
|
evaluate.moral3_level = requestBody.moral3_level
|
||||||
evaluate.discipline1_level = requestBody.discipline1_level;
|
evaluate.discipline1_level = requestBody.discipline1_level
|
||||||
evaluate.discipline2_level = requestBody.discipline2_level;
|
evaluate.discipline2_level = requestBody.discipline2_level
|
||||||
evaluate.discipline3_level = requestBody.discipline3_level;
|
evaluate.discipline3_level = requestBody.discipline3_level
|
||||||
evaluate.discipline4_level = requestBody.discipline4_level;
|
evaluate.discipline4_level = requestBody.discipline4_level
|
||||||
evaluate.discipline5_level = requestBody.discipline5_level;
|
evaluate.discipline5_level = requestBody.discipline5_level
|
||||||
evaluate.behavior_other_desc = requestBody.behavior_orther.text;
|
evaluate.behavior_other_desc = requestBody.behavior_orther.text
|
||||||
evaluate.behavior_other_level =
|
evaluate.behavior_other_level = requestBody.behavior_orther.text != "" ? Number(requestBody.behavior_orther.level) : 0
|
||||||
requestBody.behavior_orther.text != "" ? Number(requestBody.behavior_orther.level) : 0;
|
evaluate.behavior_strength_desc = requestBody.behavior_strength_desc
|
||||||
evaluate.behavior_strength_desc = requestBody.behavior_strength_desc;
|
evaluate.behavior_improve_desc = requestBody.behavior_improve_desc
|
||||||
evaluate.behavior_improve_desc = requestBody.behavior_improve_desc;
|
evaluate.orientation = requestBody.orientation
|
||||||
evaluate.orientation = requestBody.orientation;
|
evaluate.self_learning = requestBody.self_learning
|
||||||
evaluate.self_learning = requestBody.self_learning;
|
evaluate.training_seminar = requestBody.training_seminar
|
||||||
evaluate.training_seminar = requestBody.training_seminar;
|
evaluate.other_training = requestBody.other_training
|
||||||
evaluate.other_training = requestBody.other_training;
|
evaluate.updateUserId = request.user.sub
|
||||||
evaluate.updateUserId = request.user.sub;
|
evaluate.updateFullName = request.user.name
|
||||||
evaluate.updateFullName = request.user.name;
|
|
||||||
|
|
||||||
await this.evaluateCommanderRepository.save(evaluate, { data: request });
|
await this.evaluateCommanderRepository.save(evaluate, { data: request })
|
||||||
setLogDataDiff(request, { before, after: evaluate });
|
setLogDataDiff(request, { before, after: evaluate })
|
||||||
|
|
||||||
return new HttpSuccess();
|
return new HttpSuccess()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -33,7 +33,6 @@ import permission from "../interfaces/permission";
|
||||||
HttpStatusCode.INTERNAL_SERVER_ERROR,
|
HttpStatusCode.INTERNAL_SERVER_ERROR,
|
||||||
"เกิดข้อผิดพลาด ไม่สามารถแสดงรายการได้ กรุณาลองใหม่ในภายหลัง",
|
"เกิดข้อผิดพลาด ไม่สามารถแสดงรายการได้ กรุณาลองใหม่ในภายหลัง",
|
||||||
)
|
)
|
||||||
@SuccessResponse(HttpStatusCode.OK, "สำเร็จ")
|
|
||||||
export class EvaluateRecordController extends Controller {
|
export class EvaluateRecordController extends Controller {
|
||||||
private assignDirectorRepository = AppDataSource.getRepository(AssignDirector);
|
private assignDirectorRepository = AppDataSource.getRepository(AssignDirector);
|
||||||
private assignRepository = AppDataSource.getRepository(Assign);
|
private assignRepository = AppDataSource.getRepository(Assign);
|
||||||
|
|
|
||||||
|
|
@ -1,45 +1,28 @@
|
||||||
import {
|
import { Controller, Route, Security, Tags, Request, SuccessResponse, Response, Get, Post, Body, Query, Put } from "tsoa"
|
||||||
Controller,
|
import HttpSuccess from "../interfaces/http-success"
|
||||||
Route,
|
import HttpStatusCode from "../interfaces/http-status"
|
||||||
Security,
|
import { RequestWithUser } from "../middlewares/user"
|
||||||
Tags,
|
import { setLogDataDiff } from "../interfaces/utils"
|
||||||
Request,
|
import { AppDataSource } from "../database/data-source"
|
||||||
SuccessResponse,
|
import { AssignDirector } from "../entities/AssignDirector"
|
||||||
Response,
|
import HttpError from "../interfaces/http-error"
|
||||||
Get,
|
import { Assign } from "../entities/Assign"
|
||||||
Post,
|
import { Personal } from "../entities/Personal"
|
||||||
Body,
|
import CallAPI from "../interfaces/call-api"
|
||||||
Query,
|
import { EvaluateChairman } from "../entities/EvaluateChairman"
|
||||||
Put,
|
import { CreateEvaluateResult, EvaluateResult } from "../entities/EvaluateResult"
|
||||||
} from "tsoa";
|
import permission from "../interfaces/permission"
|
||||||
import HttpSuccess from "../interfaces/http-success";
|
|
||||||
import HttpStatusCode from "../interfaces/http-status";
|
|
||||||
import { RequestWithUser } from "../middlewares/user";
|
|
||||||
import { setLogDataDiff } from "../interfaces/utils";
|
|
||||||
import { AppDataSource } from "../database/data-source";
|
|
||||||
import { AssignDirector } from "../entities/AssignDirector";
|
|
||||||
import HttpError from "../interfaces/http-error";
|
|
||||||
import { Assign } from "../entities/Assign";
|
|
||||||
import { Personal } from "../entities/Personal";
|
|
||||||
import CallAPI from "../interfaces/call-api";
|
|
||||||
import { EvaluateChairman } from "../entities/EvaluateChairman";
|
|
||||||
import { CreateEvaluateResult, EvaluateResult } from "../entities/EvaluateResult";
|
|
||||||
import permission from "../interfaces/permission";
|
|
||||||
|
|
||||||
@Route("api/v1/probation/evaluate-result")
|
@Route("api/v1/probation/evaluate-result")
|
||||||
@Tags("แบบรายงานการประเมินฯ")
|
@Tags("แบบรายงานการประเมินฯ")
|
||||||
@Security("bearerAuth")
|
@Security("bearerAuth")
|
||||||
@Response(
|
@Response(HttpStatusCode.INTERNAL_SERVER_ERROR, "เกิดข้อผิดพลาด ไม่สามารถแสดงรายการได้ กรุณาลองใหม่ในภายหลัง")
|
||||||
HttpStatusCode.INTERNAL_SERVER_ERROR,
|
|
||||||
"เกิดข้อผิดพลาด ไม่สามารถแสดงรายการได้ กรุณาลองใหม่ในภายหลัง",
|
|
||||||
)
|
|
||||||
@SuccessResponse(HttpStatusCode.OK, "สำเร็จ")
|
|
||||||
export class EvaluateResultController extends Controller {
|
export class EvaluateResultController extends Controller {
|
||||||
private assignDirectorRepository = AppDataSource.getRepository(AssignDirector);
|
private assignDirectorRepository = AppDataSource.getRepository(AssignDirector)
|
||||||
private assignRepository = AppDataSource.getRepository(Assign);
|
private assignRepository = AppDataSource.getRepository(Assign)
|
||||||
private evaluateChairmanRepository = AppDataSource.getRepository(EvaluateChairman);
|
private evaluateChairmanRepository = AppDataSource.getRepository(EvaluateChairman)
|
||||||
private personalRepository = AppDataSource.getRepository(Personal);
|
private personalRepository = AppDataSource.getRepository(Personal)
|
||||||
private evaluateResultRepository = AppDataSource.getRepository(EvaluateResult);
|
private evaluateResultRepository = AppDataSource.getRepository(EvaluateResult)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* API ข้อมูลตอนกดสร้างแบบรายงานการประเมินฯ
|
* API ข้อมูลตอนกดสร้างแบบรายงานการประเมินฯ
|
||||||
|
|
@ -49,55 +32,53 @@ export class EvaluateResultController extends Controller {
|
||||||
*/
|
*/
|
||||||
@Get("create")
|
@Get("create")
|
||||||
async CreateEvaluate(@Query() assign_id: string, @Request() request: RequestWithUser) {
|
async CreateEvaluate(@Query() assign_id: string, @Request() request: RequestWithUser) {
|
||||||
await new permission().PermissionGet(request, "SYS_PROBATION");
|
await new permission().PermissionGet(request, "SYS_PROBATION")
|
||||||
|
|
||||||
const assign = await this.assignRepository.findOne({
|
const assign = await this.assignRepository.findOne({
|
||||||
relations: ["profile"],
|
relations: ["profile"],
|
||||||
where: { id: assign_id },
|
where: { id: assign_id },
|
||||||
});
|
})
|
||||||
if (!assign) {
|
if (!assign) {
|
||||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลแบบมอบหมายงาน");
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลแบบมอบหมายงาน")
|
||||||
}
|
}
|
||||||
|
|
||||||
const profile = await (assign.profile
|
const profile = await (assign.profile
|
||||||
? {
|
? {
|
||||||
...assign.profile,
|
...assign.profile,
|
||||||
id: assign.profile.personal_id,
|
id: assign.profile.personal_id,
|
||||||
name:
|
name: assign.profile.prefixName + assign.profile.firstName + " " + assign.profile.lastName,
|
||||||
assign.profile.prefixName + assign.profile.firstName + " " + assign.profile.lastName,
|
|
||||||
Oc: assign.profile.organization,
|
Oc: assign.profile.organization,
|
||||||
}
|
}
|
||||||
: null);
|
: null)
|
||||||
|
|
||||||
const directorData = await this.assignDirectorRepository.find({
|
const directorData = await this.assignDirectorRepository.find({
|
||||||
where: { assign_id },
|
where: { assign_id },
|
||||||
order: { ordering: "ASC" },
|
order: { ordering: "ASC" },
|
||||||
});
|
})
|
||||||
|
|
||||||
if (!directorData) {
|
if (!directorData) {
|
||||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลผู้ดูแล ผู้บังคับบัญชาและประธาน");
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลผู้ดูแล ผู้บังคับบัญชาและประธาน")
|
||||||
}
|
}
|
||||||
|
|
||||||
let mentors = [];
|
let mentors = []
|
||||||
const mentorList = await directorData.filter((x) => x.role == "mentor");
|
const mentorList = await directorData.filter(x => x.role == "mentor")
|
||||||
if (mentorList.length > 0) {
|
if (mentorList.length > 0) {
|
||||||
for (let index = 0; index < mentorList.length; index++) {
|
for (let index = 0; index < mentorList.length; index++) {
|
||||||
const e = await mentorList[index];
|
const e = await mentorList[index]
|
||||||
|
|
||||||
mentors.push({
|
mentors.push({
|
||||||
personal_id: e.personal_id,
|
personal_id: e.personal_id,
|
||||||
dated: e.dated,
|
dated: e.dated,
|
||||||
name: e.fullname,
|
name: e.fullname,
|
||||||
label:
|
label: e.fullname + " " + (e.position ? `(${e.position}, ${e.posType}: ${e.posLevel})` : ""),
|
||||||
e.fullname + " " + (e.position ? `(${e.position}, ${e.posType}: ${e.posLevel})` : ""),
|
|
||||||
position: e.position,
|
position: e.position,
|
||||||
posType: e.posType,
|
posType: e.posType,
|
||||||
posLevel: e.posLevel,
|
posLevel: e.posLevel,
|
||||||
});
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const commanderData = await (directorData.find((x) => x.role == "commander") ?? null);
|
const commanderData = await (directorData.find(x => x.role == "commander") ?? null)
|
||||||
|
|
||||||
const commander =
|
const commander =
|
||||||
commanderData != null
|
commanderData != null
|
||||||
|
|
@ -105,65 +86,46 @@ export class EvaluateResultController extends Controller {
|
||||||
personal_id: commanderData.personal_id,
|
personal_id: commanderData.personal_id,
|
||||||
dated: commanderData.dated,
|
dated: commanderData.dated,
|
||||||
name: commanderData.fullname,
|
name: commanderData.fullname,
|
||||||
label:
|
label: commanderData.fullname + " " + (commanderData.position ? `(${commanderData.position}, ${commanderData.posType}: ${commanderData.posLevel})` : ""),
|
||||||
commanderData.fullname +
|
|
||||||
" " +
|
|
||||||
(commanderData.position
|
|
||||||
? `(${commanderData.position}, ${commanderData.posType}: ${commanderData.posLevel})`
|
|
||||||
: ""),
|
|
||||||
position: commanderData.position,
|
position: commanderData.position,
|
||||||
posType: commanderData.posType,
|
posType: commanderData.posType,
|
||||||
posLevel: commanderData.posLevel,
|
posLevel: commanderData.posLevel,
|
||||||
}
|
}
|
||||||
: null;
|
: null
|
||||||
|
|
||||||
const chairmanData = await (directorData.find((x) => x.role == "chairman") ?? null);
|
const chairmanData = await (directorData.find(x => x.role == "chairman") ?? null)
|
||||||
const chairman =
|
const chairman =
|
||||||
chairmanData != null
|
chairmanData != null
|
||||||
? {
|
? {
|
||||||
personal_id: chairmanData.personal_id,
|
personal_id: chairmanData.personal_id,
|
||||||
dated: chairmanData.dated,
|
dated: chairmanData.dated,
|
||||||
name: chairmanData.fullname,
|
name: chairmanData.fullname,
|
||||||
label:
|
label: chairmanData.fullname + " " + (chairmanData.position ? `(${chairmanData.position}, ${chairmanData.posType}: ${chairmanData.posLevel})` : ""),
|
||||||
chairmanData.fullname +
|
|
||||||
" " +
|
|
||||||
(chairmanData.position
|
|
||||||
? `(${chairmanData.position}, ${chairmanData.posType}: ${chairmanData.posLevel})`
|
|
||||||
: ""),
|
|
||||||
position: chairmanData.position,
|
position: chairmanData.position,
|
||||||
posType: chairmanData.posType,
|
posType: chairmanData.posType,
|
||||||
posLevel: chairmanData.posLevel,
|
posLevel: chairmanData.posLevel,
|
||||||
}
|
}
|
||||||
: null;
|
: null
|
||||||
|
|
||||||
const resultData = await this.evaluateChairmanRepository.findOne({
|
const resultData = await this.evaluateChairmanRepository.findOne({
|
||||||
select: [
|
select: ["develop_orientation_score", "develop_self_learning_score", "develop_training_seminar_score", "evaluate_result"],
|
||||||
"develop_orientation_score",
|
|
||||||
"develop_self_learning_score",
|
|
||||||
"develop_training_seminar_score",
|
|
||||||
"evaluate_result",
|
|
||||||
],
|
|
||||||
where: {
|
where: {
|
||||||
assign_id,
|
assign_id,
|
||||||
},
|
},
|
||||||
});
|
})
|
||||||
|
|
||||||
if (!resultData) {
|
if (!resultData) {
|
||||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลการประเมินผล");
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลการประเมินผล")
|
||||||
}
|
}
|
||||||
|
|
||||||
const develop_complete = await (resultData.develop_orientation_score > 0 &&
|
const develop_complete = await (resultData.develop_orientation_score > 0 && resultData.develop_self_learning_score > 0 && resultData.develop_training_seminar_score > 0 ? 1 : 2)
|
||||||
resultData.develop_self_learning_score > 0 &&
|
|
||||||
resultData.develop_training_seminar_score > 0
|
|
||||||
? 1
|
|
||||||
: 2);
|
|
||||||
|
|
||||||
const evaluate_result = await (resultData.evaluate_result == 1 ? 1 : 2);
|
const evaluate_result = await (resultData.evaluate_result == 1 ? 1 : 2)
|
||||||
|
|
||||||
const result = await {
|
const result = await {
|
||||||
develop_complete: develop_complete,
|
develop_complete: develop_complete,
|
||||||
evaluate_result: evaluate_result,
|
evaluate_result: evaluate_result,
|
||||||
};
|
}
|
||||||
|
|
||||||
return new HttpSuccess({
|
return new HttpSuccess({
|
||||||
person: profile,
|
person: profile,
|
||||||
|
|
@ -172,7 +134,7 @@ export class EvaluateResultController extends Controller {
|
||||||
mentors,
|
mentors,
|
||||||
commander,
|
commander,
|
||||||
chairman,
|
chairman,
|
||||||
});
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -182,12 +144,8 @@ export class EvaluateResultController extends Controller {
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Get("")
|
@Get("")
|
||||||
async GetEvaluate(
|
async GetEvaluate(@Request() request: RequestWithUser, @Query() assign_id: string, @Query() evaluate_no?: string) {
|
||||||
@Request() request: RequestWithUser,
|
await new permission().PermissionGet(request, "SYS_PROBATION")
|
||||||
@Query() assign_id: string,
|
|
||||||
@Query() evaluate_no?: string,
|
|
||||||
) {
|
|
||||||
await new permission().PermissionGet(request, "SYS_PROBATION");
|
|
||||||
|
|
||||||
// ต้องปรับเป็น id ของคนที่ access เข้ามา
|
// ต้องปรับเป็น id ของคนที่ access เข้ามา
|
||||||
const director = await this.assignDirectorRepository.findOne({
|
const director = await this.assignDirectorRepository.findOne({
|
||||||
|
|
@ -196,82 +154,72 @@ export class EvaluateResultController extends Controller {
|
||||||
assign_id,
|
assign_id,
|
||||||
role: "chairman",
|
role: "chairman",
|
||||||
},
|
},
|
||||||
});
|
})
|
||||||
if (!director) {
|
if (!director) {
|
||||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลผู้ดูแล");
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลผู้ดูแล")
|
||||||
}
|
}
|
||||||
const director_id = director.personal_id;
|
const director_id = director.personal_id
|
||||||
|
|
||||||
const evaluate = await this.evaluateResultRepository.findOne({
|
const evaluate = await this.evaluateResultRepository.findOne({
|
||||||
where: {
|
where: {
|
||||||
director_id,
|
director_id,
|
||||||
assign_id,
|
assign_id,
|
||||||
},
|
},
|
||||||
});
|
})
|
||||||
|
|
||||||
if (!evaluate) {
|
if (!evaluate) {
|
||||||
return new HttpSuccess(null);
|
return new HttpSuccess(null)
|
||||||
}
|
}
|
||||||
|
|
||||||
const assign = await this.assignRepository.findOne({
|
const assign = await this.assignRepository.findOne({
|
||||||
where: { id: assign_id },
|
where: { id: assign_id },
|
||||||
});
|
})
|
||||||
if (!assign) {
|
if (!assign) {
|
||||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลแบบมอบหมายงาน");
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลแบบมอบหมายงาน")
|
||||||
}
|
}
|
||||||
|
|
||||||
const experimenteeData = await this.personalRepository.findOne({
|
const experimenteeData = await this.personalRepository.findOne({
|
||||||
select: [
|
select: ["personal_id", "prefixName", "firstName", "lastName", "positionName", "positionLevelName", "organization"],
|
||||||
"personal_id",
|
|
||||||
"prefixName",
|
|
||||||
"firstName",
|
|
||||||
"lastName",
|
|
||||||
"positionName",
|
|
||||||
"positionLevelName",
|
|
||||||
"organization",
|
|
||||||
],
|
|
||||||
where: { personal_id: assign.personal_id },
|
where: { personal_id: assign.personal_id },
|
||||||
});
|
})
|
||||||
|
|
||||||
if (!experimenteeData) {
|
if (!experimenteeData) {
|
||||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลบุคคล");
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลบุคคล")
|
||||||
}
|
}
|
||||||
const experimentee = await {
|
const experimentee = await {
|
||||||
...experimenteeData,
|
...experimenteeData,
|
||||||
name:
|
name: experimenteeData.prefixName + experimenteeData.firstName + " " + experimenteeData.lastName,
|
||||||
experimenteeData.prefixName + experimenteeData.firstName + " " + experimenteeData.lastName,
|
|
||||||
Oc: experimenteeData.organization,
|
Oc: experimenteeData.organization,
|
||||||
};
|
}
|
||||||
|
|
||||||
const directorData = await this.assignDirectorRepository.find({
|
const directorData = await this.assignDirectorRepository.find({
|
||||||
where: { assign_id },
|
where: { assign_id },
|
||||||
order: { ordering: "ASC" },
|
order: { ordering: "ASC" },
|
||||||
});
|
})
|
||||||
|
|
||||||
if (!directorData) {
|
if (!directorData) {
|
||||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลผู้ดูแล ผู้บังคับบัญชาและประธาน");
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลผู้ดูแล ผู้บังคับบัญชาและประธาน")
|
||||||
}
|
}
|
||||||
|
|
||||||
let mentors = [];
|
let mentors = []
|
||||||
const mentorList = await directorData.filter((x) => x.role == "mentor");
|
const mentorList = await directorData.filter(x => x.role == "mentor")
|
||||||
if (mentorList.length > 0) {
|
if (mentorList.length > 0) {
|
||||||
for (let index = 0; index < mentorList.length; index++) {
|
for (let index = 0; index < mentorList.length; index++) {
|
||||||
const e = await mentorList[index];
|
const e = await mentorList[index]
|
||||||
|
|
||||||
mentors.push({
|
mentors.push({
|
||||||
personal_id: e.personal_id,
|
personal_id: e.personal_id,
|
||||||
dated: e.dated,
|
dated: e.dated,
|
||||||
name: e.fullname,
|
name: e.fullname,
|
||||||
label:
|
label: e.fullname + " " + (e.position ? `(${e.position}, ${e.posType}: ${e.posLevel})` : ""),
|
||||||
e.fullname + " " + (e.position ? `(${e.position}, ${e.posType}: ${e.posLevel})` : ""),
|
|
||||||
position: e.position,
|
position: e.position,
|
||||||
posType: e.posType,
|
posType: e.posType,
|
||||||
posLevel: e.posLevel,
|
posLevel: e.posLevel,
|
||||||
});
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const commanderData = await (directorData.find((x) => x.role == "commander") ?? null);
|
const commanderData = await (directorData.find(x => x.role == "commander") ?? null)
|
||||||
|
|
||||||
const commander =
|
const commander =
|
||||||
commanderData != null
|
commanderData != null
|
||||||
|
|
@ -279,36 +227,26 @@ export class EvaluateResultController extends Controller {
|
||||||
personal_id: commanderData.personal_id,
|
personal_id: commanderData.personal_id,
|
||||||
dated: commanderData.dated,
|
dated: commanderData.dated,
|
||||||
name: commanderData.fullname,
|
name: commanderData.fullname,
|
||||||
label:
|
label: commanderData.fullname + " " + (commanderData.position ? `(${commanderData.position}, ${commanderData.posType}: ${commanderData.posLevel})` : ""),
|
||||||
commanderData.fullname +
|
|
||||||
" " +
|
|
||||||
(commanderData.position
|
|
||||||
? `(${commanderData.position}, ${commanderData.posType}: ${commanderData.posLevel})`
|
|
||||||
: ""),
|
|
||||||
position: commanderData.position,
|
position: commanderData.position,
|
||||||
posType: commanderData.posType,
|
posType: commanderData.posType,
|
||||||
posLevel: commanderData.posLevel,
|
posLevel: commanderData.posLevel,
|
||||||
}
|
}
|
||||||
: null;
|
: null
|
||||||
|
|
||||||
const chairmanData = await (directorData.find((x) => x.role == "chairman") ?? null);
|
const chairmanData = await (directorData.find(x => x.role == "chairman") ?? null)
|
||||||
const chairman =
|
const chairman =
|
||||||
chairmanData != null
|
chairmanData != null
|
||||||
? {
|
? {
|
||||||
personal_id: chairmanData.personal_id,
|
personal_id: chairmanData.personal_id,
|
||||||
dated: chairmanData.dated,
|
dated: chairmanData.dated,
|
||||||
name: chairmanData.fullname,
|
name: chairmanData.fullname,
|
||||||
label:
|
label: chairmanData.fullname + " " + (chairmanData.position ? `(${chairmanData.position}, ${chairmanData.posType}: ${chairmanData.posLevel})` : ""),
|
||||||
chairmanData.fullname +
|
|
||||||
" " +
|
|
||||||
(chairmanData.position
|
|
||||||
? `(${chairmanData.position}, ${chairmanData.posType}: ${chairmanData.posLevel})`
|
|
||||||
: ""),
|
|
||||||
position: chairmanData.position,
|
position: chairmanData.position,
|
||||||
posType: chairmanData.posType,
|
posType: chairmanData.posType,
|
||||||
posLevel: chairmanData.posLevel,
|
posLevel: chairmanData.posLevel,
|
||||||
}
|
}
|
||||||
: null;
|
: null
|
||||||
|
|
||||||
return new HttpSuccess({
|
return new HttpSuccess({
|
||||||
commander,
|
commander,
|
||||||
|
|
@ -317,7 +255,7 @@ export class EvaluateResultController extends Controller {
|
||||||
experimentee,
|
experimentee,
|
||||||
assign,
|
assign,
|
||||||
evaluate: evaluate,
|
evaluate: evaluate,
|
||||||
});
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -327,12 +265,8 @@ export class EvaluateResultController extends Controller {
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Post("")
|
@Post("")
|
||||||
async PostData(
|
async PostData(@Query() assign_id: string, @Body() requestBody: CreateEvaluateResult, @Request() request: RequestWithUser) {
|
||||||
@Query() assign_id: string,
|
await new permission().PermissionUpdate(request, "SYS_PROBATION")
|
||||||
@Body() requestBody: CreateEvaluateResult,
|
|
||||||
@Request() request: RequestWithUser,
|
|
||||||
) {
|
|
||||||
await new permission().PermissionUpdate(request, "SYS_PROBATION");
|
|
||||||
|
|
||||||
const director = await this.assignDirectorRepository.findOne({
|
const director = await this.assignDirectorRepository.findOne({
|
||||||
select: ["personal_id"],
|
select: ["personal_id"],
|
||||||
|
|
@ -340,19 +274,19 @@ export class EvaluateResultController extends Controller {
|
||||||
assign_id,
|
assign_id,
|
||||||
role: "chairman",
|
role: "chairman",
|
||||||
},
|
},
|
||||||
});
|
})
|
||||||
if (!director) {
|
if (!director) {
|
||||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลผู้ดูแล");
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลผู้ดูแล")
|
||||||
}
|
}
|
||||||
|
|
||||||
const director_id = director.personal_id;
|
const director_id = director.personal_id
|
||||||
|
|
||||||
const assign = await this.assignRepository.findOne({
|
const assign = await this.assignRepository.findOne({
|
||||||
relations: ["profile"],
|
relations: ["profile"],
|
||||||
where: { id: assign_id },
|
where: { id: assign_id },
|
||||||
});
|
})
|
||||||
if (!assign) {
|
if (!assign) {
|
||||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลแบบมอบหมายงาน");
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลแบบมอบหมายงาน")
|
||||||
}
|
}
|
||||||
|
|
||||||
const postData: any = await {
|
const postData: any = await {
|
||||||
|
|
@ -368,29 +302,24 @@ export class EvaluateResultController extends Controller {
|
||||||
createdFullName: request.user.name,
|
createdFullName: request.user.name,
|
||||||
updateUserId: request.user.sub,
|
updateUserId: request.user.sub,
|
||||||
updateFullName: request.user.name,
|
updateFullName: request.user.name,
|
||||||
};
|
}
|
||||||
|
|
||||||
await this.evaluateResultRepository.save(postData, {
|
await this.evaluateResultRepository.save(postData, {
|
||||||
data: request,
|
data: request,
|
||||||
});
|
})
|
||||||
setLogDataDiff(request, { before: null, after: postData });
|
setLogDataDiff(request, { before: null, after: postData })
|
||||||
|
|
||||||
const personal = await this.personalRepository.findOne({
|
const personal = await this.personalRepository.findOne({
|
||||||
where: { personal_id: assign.personal_id },
|
where: { personal_id: assign.personal_id },
|
||||||
});
|
})
|
||||||
|
|
||||||
if (!personal) {
|
if (!personal) {
|
||||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลบุคคล");
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลบุคคล")
|
||||||
}
|
}
|
||||||
personal.probation_status =
|
personal.probation_status = requestBody.pass_result == 1 ? 2 : requestBody.pass_result == 2 ? 3 : personal.probation_status
|
||||||
requestBody.pass_result == 1
|
|
||||||
? 2
|
|
||||||
: requestBody.pass_result == 2
|
|
||||||
? 3
|
|
||||||
: personal.probation_status;
|
|
||||||
|
|
||||||
if (requestBody.pass_result == 3) {
|
if (requestBody.pass_result == 3) {
|
||||||
personal.probation_status = 7;
|
personal.probation_status = 7
|
||||||
// #noti ผลการประเมินการทดลองปฏิบัติหน้าที่ราชการ กรณีขยายระยะเวลา
|
// #noti ผลการประเมินการทดลองปฏิบัติหน้าที่ราชการ กรณีขยายระยะเวลา
|
||||||
await new CallAPI()
|
await new CallAPI()
|
||||||
.PostData(request, "/placement/noti", {
|
.PostData(request, "/placement/noti", {
|
||||||
|
|
@ -402,14 +331,14 @@ export class EvaluateResultController extends Controller {
|
||||||
isSendInbox: true,
|
isSendInbox: true,
|
||||||
isSendNotification: true,
|
isSendNotification: true,
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch(error => {
|
||||||
console.error("Error calling API:", error);
|
console.error("Error calling API:", error)
|
||||||
});
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
await this.personalRepository.save(personal, { data: request });
|
await this.personalRepository.save(personal, { data: request })
|
||||||
|
|
||||||
return new HttpSuccess();
|
return new HttpSuccess()
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -419,66 +348,53 @@ export class EvaluateResultController extends Controller {
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Put("")
|
@Put("")
|
||||||
async UpdateData(
|
async UpdateData(@Query() assign_id: string, @Query() evaluate_id: string, @Body() requestBody: CreateEvaluateResult, @Request() request: RequestWithUser) {
|
||||||
@Query() assign_id: string,
|
await new permission().PermissionUpdate(request, "SYS_PROBATION")
|
||||||
@Query() evaluate_id: string,
|
|
||||||
@Body() requestBody: CreateEvaluateResult,
|
|
||||||
@Request() request: RequestWithUser,
|
|
||||||
) {
|
|
||||||
await new permission().PermissionUpdate(request, "SYS_PROBATION");
|
|
||||||
|
|
||||||
let evaluate = await this.evaluateResultRepository.findOne({
|
let evaluate = await this.evaluateResultRepository.findOne({
|
||||||
where: { id: evaluate_id },
|
where: { id: evaluate_id },
|
||||||
});
|
})
|
||||||
|
|
||||||
const before = evaluate;
|
const before = evaluate
|
||||||
|
|
||||||
if (!evaluate) {
|
if (!evaluate) {
|
||||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลการประเมิน");
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลการประเมิน")
|
||||||
}
|
}
|
||||||
|
|
||||||
evaluate.date_start = requestBody.start_date;
|
evaluate.date_start = requestBody.start_date
|
||||||
evaluate.date_finish = requestBody.date_finish;
|
evaluate.date_finish = requestBody.date_finish
|
||||||
evaluate.develop_complete = requestBody.develop_complete;
|
evaluate.develop_complete = requestBody.develop_complete
|
||||||
evaluate.pass_result = requestBody.pass_result;
|
evaluate.pass_result = requestBody.pass_result
|
||||||
evaluate.expand_month =
|
evaluate.expand_month = requestBody.pass_result && requestBody.pass_result == 3 ? Number(requestBody.expand_month) : 0
|
||||||
requestBody.pass_result && requestBody.pass_result == 3
|
evaluate.reson = requestBody.reson
|
||||||
? Number(requestBody.expand_month)
|
evaluate.chairman_dated = requestBody.chairman_dated
|
||||||
: 0;
|
|
||||||
evaluate.reson = requestBody.reson;
|
|
||||||
evaluate.chairman_dated = requestBody.chairman_dated;
|
|
||||||
|
|
||||||
evaluate.director1_dated = requestBody.director1_dated;
|
evaluate.director1_dated = requestBody.director1_dated
|
||||||
evaluate.director2_dated = requestBody.director2_dated;
|
evaluate.director2_dated = requestBody.director2_dated
|
||||||
evaluate.updateUserId = request.user.sub;
|
evaluate.updateUserId = request.user.sub
|
||||||
evaluate.updateFullName = request.user.name;
|
evaluate.updateFullName = request.user.name
|
||||||
|
|
||||||
await this.evaluateResultRepository.save(evaluate, { data: request });
|
await this.evaluateResultRepository.save(evaluate, { data: request })
|
||||||
setLogDataDiff(request, { before, after: evaluate });
|
setLogDataDiff(request, { before, after: evaluate })
|
||||||
|
|
||||||
const assign = await this.assignRepository.findOne({
|
const assign = await this.assignRepository.findOne({
|
||||||
relations: ["profile"],
|
relations: ["profile"],
|
||||||
where: { id: assign_id },
|
where: { id: assign_id },
|
||||||
});
|
})
|
||||||
if (!assign) {
|
if (!assign) {
|
||||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลแบบมอบหมายงาน");
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลแบบมอบหมายงาน")
|
||||||
}
|
}
|
||||||
const personal = await this.personalRepository.findOne({
|
const personal = await this.personalRepository.findOne({
|
||||||
where: { personal_id: assign.personal_id },
|
where: { personal_id: assign.personal_id },
|
||||||
});
|
})
|
||||||
|
|
||||||
if (!personal) {
|
if (!personal) {
|
||||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลบุคคล");
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลบุคคล")
|
||||||
}
|
}
|
||||||
personal.probation_status =
|
personal.probation_status = requestBody.pass_result == 1 ? 2 : requestBody.pass_result == 2 ? 3 : personal.probation_status
|
||||||
requestBody.pass_result == 1
|
|
||||||
? 2
|
|
||||||
: requestBody.pass_result == 2
|
|
||||||
? 3
|
|
||||||
: personal.probation_status;
|
|
||||||
|
|
||||||
if (requestBody.pass_result == 3) {
|
if (requestBody.pass_result == 3) {
|
||||||
personal.probation_status = 7;
|
personal.probation_status = 7
|
||||||
// #noti ผลการประเมินการทดลองปฏิบัติหน้าที่ราชการ กรณีขยายระยะเวลา
|
// #noti ผลการประเมินการทดลองปฏิบัติหน้าที่ราชการ กรณีขยายระยะเวลา
|
||||||
await new CallAPI()
|
await new CallAPI()
|
||||||
.PostData(request, "/placement/noti", {
|
.PostData(request, "/placement/noti", {
|
||||||
|
|
@ -490,13 +406,13 @@ export class EvaluateResultController extends Controller {
|
||||||
isSendInbox: true,
|
isSendInbox: true,
|
||||||
isSendNotification: true,
|
isSendNotification: true,
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch(error => {
|
||||||
console.error("Error calling API:", error);
|
console.error("Error calling API:", error)
|
||||||
});
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
await this.personalRepository.save(personal, { data: request });
|
await this.personalRepository.save(personal, { data: request })
|
||||||
|
|
||||||
return new HttpSuccess();
|
return new HttpSuccess()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,37 +1,21 @@
|
||||||
import {
|
import { Controller, Post, Route, Security, Tags, Body, Request, SuccessResponse, Response, Get, Query } from "tsoa"
|
||||||
Controller,
|
import { AppDataSource } from "../database/data-source"
|
||||||
Post,
|
import HttpSuccess from "../interfaces/http-success"
|
||||||
Route,
|
import HttpStatusCode from "../interfaces/http-status"
|
||||||
Security,
|
import HttpError from "../interfaces/http-error"
|
||||||
Tags,
|
import { RequestWithUser } from "../middlewares/user"
|
||||||
Body,
|
import { setLogDataDiff } from "../interfaces/utils"
|
||||||
Request,
|
import { Personal, PostPersonal } from "../entities/Personal"
|
||||||
SuccessResponse,
|
import permission from "../interfaces/permission"
|
||||||
Response,
|
import { Assign } from "../entities/Assign"
|
||||||
Get,
|
|
||||||
Query,
|
|
||||||
} from "tsoa";
|
|
||||||
import { AppDataSource } from "../database/data-source";
|
|
||||||
import HttpSuccess from "../interfaces/http-success";
|
|
||||||
import HttpStatusCode from "../interfaces/http-status";
|
|
||||||
import HttpError from "../interfaces/http-error";
|
|
||||||
import { RequestWithUser } from "../middlewares/user";
|
|
||||||
import { setLogDataDiff } from "../interfaces/utils";
|
|
||||||
import { Personal, PostPersonal } from "../entities/Personal";
|
|
||||||
import permission from "../interfaces/permission";
|
|
||||||
import { Assign } from "../entities/Assign";
|
|
||||||
|
|
||||||
@Route("api/v1/probation/personal")
|
@Route("api/v1/probation/personal")
|
||||||
@Tags("Personal")
|
@Tags("Personal")
|
||||||
@Security("bearerAuth")
|
@Security("bearerAuth")
|
||||||
@Response(
|
@Response(HttpStatusCode.INTERNAL_SERVER_ERROR, "เกิดข้อผิดพลาด ไม่สามารถแสดงรายการได้ กรุณาลองใหม่ในภายหลัง")
|
||||||
HttpStatusCode.INTERNAL_SERVER_ERROR,
|
|
||||||
"เกิดข้อผิดพลาด ไม่สามารถแสดงรายการได้ กรุณาลองใหม่ในภายหลัง"
|
|
||||||
)
|
|
||||||
@SuccessResponse(HttpStatusCode.OK, "สำเร็จ")
|
|
||||||
export class PersonalController extends Controller {
|
export class PersonalController extends Controller {
|
||||||
private personalRepository = AppDataSource.getRepository(Personal);
|
private personalRepository = AppDataSource.getRepository(Personal)
|
||||||
private assignRepository = AppDataSource.getRepository(Assign);
|
private assignRepository = AppDataSource.getRepository(Assign)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* API ข้อมูลบุคคลในระบบทดลองงาน
|
* API ข้อมูลบุคคลในระบบทดลองงาน
|
||||||
|
|
@ -40,73 +24,51 @@ export class PersonalController extends Controller {
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Post("add")
|
@Post("add")
|
||||||
async AddPersonal(
|
async AddPersonal(@Body() requestBody: PostPersonal, @Request() request: RequestWithUser) {
|
||||||
@Body() requestBody: PostPersonal,
|
await new permission().PermissionCreate(request, "SYS_PROBATION")
|
||||||
@Request() request: RequestWithUser
|
|
||||||
) {
|
|
||||||
await new permission().PermissionCreate(request, "SYS_PROBATION");
|
|
||||||
|
|
||||||
const checkPersonal: number = await this.personalRepository.count({
|
const checkPersonal: number = await this.personalRepository.count({
|
||||||
where: { personal_id: requestBody.id },
|
where: { personal_id: requestBody.id },
|
||||||
});
|
})
|
||||||
if (checkPersonal > 0) {
|
if (checkPersonal > 0) {
|
||||||
throw new HttpError(
|
throw new HttpError(HttpStatusCode.BAD_REQUEST, "ผู้ทดลองปฏิบัติหน้าที่ราชการนี้มีอยู่แล้ว")
|
||||||
HttpStatusCode.BAD_REQUEST,
|
|
||||||
"ผู้ทดลองปฏิบัติหน้าที่ราชการนี้มีอยู่แล้ว"
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let organization = await (requestBody.orgChild4Name
|
let organization = await (requestBody.orgChild4Name ? requestBody.orgChild4Name + "/" : "")
|
||||||
? requestBody.orgChild4Name + "/"
|
organization += await (requestBody.orgChild3Name ? requestBody.orgChild3Name + "/" : "")
|
||||||
: "");
|
organization += await (requestBody.orgChild2Name ? requestBody.orgChild2Name + "/" : "")
|
||||||
organization += await (requestBody.orgChild3Name
|
organization += await (requestBody.orgChild1Name ? requestBody.orgChild1Name + "/" : "")
|
||||||
? requestBody.orgChild3Name + "/"
|
organization += await (requestBody.orgRootName ? requestBody.orgRootName : "")
|
||||||
: "");
|
|
||||||
organization += await (requestBody.orgChild2Name
|
|
||||||
? requestBody.orgChild2Name + "/"
|
|
||||||
: "");
|
|
||||||
organization += await (requestBody.orgChild1Name
|
|
||||||
? requestBody.orgChild1Name + "/"
|
|
||||||
: "");
|
|
||||||
organization += await (requestBody.orgRootName
|
|
||||||
? requestBody.orgRootName
|
|
||||||
: "");
|
|
||||||
|
|
||||||
const personalData = Object.assign(new Personal());
|
const personalData = Object.assign(new Personal())
|
||||||
personalData.personal_id = requestBody.id;
|
personalData.personal_id = requestBody.id
|
||||||
personalData.order_number = requestBody.order_number
|
personalData.order_number = requestBody.order_number ? requestBody.order_number : ""
|
||||||
? requestBody.order_number
|
personalData.probation_status = 1
|
||||||
: "";
|
personalData.createdUserId = request.user.sub
|
||||||
personalData.probation_status = 1;
|
personalData.createdFullName = request.user.name
|
||||||
personalData.createdUserId = request.user.sub;
|
personalData.updateUserId = request.user.sub
|
||||||
personalData.createdFullName = request.user.name;
|
personalData.updateFullName = request.user.name
|
||||||
personalData.updateUserId = request.user.sub;
|
|
||||||
personalData.updateFullName = request.user.name;
|
|
||||||
|
|
||||||
personalData.idcard = requestBody.idcard;
|
personalData.idcard = requestBody.idcard
|
||||||
personalData.prefixName = requestBody.prefix;
|
personalData.prefixName = requestBody.prefix
|
||||||
personalData.firstName = requestBody.firstName;
|
personalData.firstName = requestBody.firstName
|
||||||
personalData.lastName = requestBody.lastName;
|
personalData.lastName = requestBody.lastName
|
||||||
personalData.isProbation = requestBody.isProbation ? 1 : 0;
|
personalData.isProbation = requestBody.isProbation ? 1 : 0
|
||||||
personalData.positionLevelName = requestBody.posLevelName
|
personalData.positionLevelName = requestBody.posLevelName ? requestBody.posLevelName : ""
|
||||||
? requestBody.posLevelName
|
personalData.positionName = requestBody.position ? requestBody.position : ""
|
||||||
: "";
|
personalData.positionLineName = requestBody.posLineName
|
||||||
personalData.positionName = requestBody.position
|
personalData.positionTypeName = requestBody.posTypeName
|
||||||
? requestBody.position
|
personalData.posNo = requestBody.posNo ? requestBody.posNo : ""
|
||||||
: "";
|
personalData.orgRootName = requestBody.orgRootName
|
||||||
personalData.positionLineName = requestBody.posLineName;
|
personalData.organization = organization
|
||||||
personalData.positionTypeName = requestBody.posTypeName;
|
|
||||||
personalData.posNo = requestBody.posNo ? requestBody.posNo : "";
|
|
||||||
personalData.orgRootName = requestBody.orgRootName;
|
|
||||||
personalData.organization = organization;
|
|
||||||
|
|
||||||
const before = null;
|
const before = null
|
||||||
const personal = await this.personalRepository.save(personalData, {
|
const personal = await this.personalRepository.save(personalData, {
|
||||||
data: request,
|
data: request,
|
||||||
});
|
})
|
||||||
setLogDataDiff(request, { before, after: personal });
|
setLogDataDiff(request, { before, after: personal })
|
||||||
|
|
||||||
return new HttpSuccess();
|
return new HttpSuccess()
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -116,16 +78,11 @@ export class PersonalController extends Controller {
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Get("list")
|
@Get("list")
|
||||||
async ListPersonal(
|
async ListPersonal(@Query() status: string = "", @Query("page") page: number = 1, @Query("pageSize") pageSize: number = 10, @Request() request: RequestWithUser) {
|
||||||
@Query() status: string = "",
|
await new permission().PermissionList(request, "SYS_PROBATION")
|
||||||
@Query("page") page: number = 1,
|
const conditions: any = {}
|
||||||
@Query("pageSize") pageSize: number = 10,
|
|
||||||
@Request() request: RequestWithUser
|
|
||||||
) {
|
|
||||||
await new permission().PermissionList(request, "SYS_PROBATION");
|
|
||||||
const conditions: any = {};
|
|
||||||
if (status) {
|
if (status) {
|
||||||
conditions.probation_status = status;
|
conditions.probation_status = status
|
||||||
}
|
}
|
||||||
|
|
||||||
const [lists, total] = await this.personalRepository.findAndCount({
|
const [lists, total] = await this.personalRepository.findAndCount({
|
||||||
|
|
@ -133,16 +90,13 @@ export class PersonalController extends Controller {
|
||||||
where: conditions,
|
where: conditions,
|
||||||
skip: (page - 1) * pageSize,
|
skip: (page - 1) * pageSize,
|
||||||
take: pageSize,
|
take: pageSize,
|
||||||
});
|
})
|
||||||
|
|
||||||
if (!lists) {
|
if (!lists) {
|
||||||
throw new HttpError(
|
throw new HttpError(HttpStatusCode.INTERNAL_SERVER_ERROR, "ไม่สามารถแสดงข้อมูลได้")
|
||||||
HttpStatusCode.INTERNAL_SERVER_ERROR,
|
|
||||||
"ไม่สามารถแสดงข้อมูลได้"
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let result: any = [];
|
let result: any = []
|
||||||
|
|
||||||
await Promise.all(
|
await Promise.all(
|
||||||
lists.map(async (item, index) => {
|
lists.map(async (item, index) => {
|
||||||
|
|
@ -150,7 +104,7 @@ export class PersonalController extends Controller {
|
||||||
where: {
|
where: {
|
||||||
personal_id: item.personal_id,
|
personal_id: item.personal_id,
|
||||||
},
|
},
|
||||||
});
|
})
|
||||||
|
|
||||||
await result.push({
|
await result.push({
|
||||||
personal_id: item.personal_id,
|
personal_id: item.personal_id,
|
||||||
|
|
@ -167,11 +121,11 @@ export class PersonalController extends Controller {
|
||||||
probation_no: probation_no,
|
probation_no: probation_no,
|
||||||
order_number: item.order_number,
|
order_number: item.order_number,
|
||||||
probation_status: item.probation_status,
|
probation_status: item.probation_status,
|
||||||
});
|
|
||||||
})
|
})
|
||||||
);
|
})
|
||||||
|
)
|
||||||
|
|
||||||
return new HttpSuccess({ data: result, total: total });
|
return new HttpSuccess({ data: result, total: total })
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -181,22 +135,19 @@ export class PersonalController extends Controller {
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Get("")
|
@Get("")
|
||||||
async GetPersonal(
|
async GetPersonal(@Request() request: RequestWithUser, @Query() personal_id: string) {
|
||||||
@Request() request: RequestWithUser,
|
await new permission().PermissionGet(request, "SYS_PROBATION")
|
||||||
@Query() personal_id: string
|
|
||||||
) {
|
|
||||||
await new permission().PermissionGet(request, "SYS_PROBATION");
|
|
||||||
const person = await this.personalRepository.findOne({
|
const person = await this.personalRepository.findOne({
|
||||||
where: { personal_id: personal_id },
|
where: { personal_id: personal_id },
|
||||||
});
|
})
|
||||||
|
|
||||||
if (!person) {
|
if (!person) {
|
||||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลบุคคล");
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลบุคคล")
|
||||||
}
|
}
|
||||||
|
|
||||||
const probation_no = await this.assignRepository.count({
|
const probation_no = await this.assignRepository.count({
|
||||||
where: { personal_id: person.personal_id },
|
where: { personal_id: person.personal_id },
|
||||||
});
|
})
|
||||||
|
|
||||||
const result = await {
|
const result = await {
|
||||||
personal_id: person.personal_id,
|
personal_id: person.personal_id,
|
||||||
|
|
@ -208,8 +159,8 @@ export class PersonalController extends Controller {
|
||||||
probation_no: probation_no,
|
probation_no: probation_no,
|
||||||
order_number: person.order_number,
|
order_number: person.order_number,
|
||||||
probation_status: person.probation_status,
|
probation_status: person.probation_status,
|
||||||
};
|
}
|
||||||
|
|
||||||
return new HttpSuccess(result);
|
return new HttpSuccess(result)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,6 @@ import { Appoint } from "../entities/Appoint"
|
||||||
@Tags("Report")
|
@Tags("Report")
|
||||||
@Security("bearerAuth")
|
@Security("bearerAuth")
|
||||||
@Response(HttpStatusCode.INTERNAL_SERVER_ERROR, "เกิดข้อผิดพลาด ไม่สามารถแสดงรายการได้ กรุณาลองใหม่ในภายหลัง")
|
@Response(HttpStatusCode.INTERNAL_SERVER_ERROR, "เกิดข้อผิดพลาด ไม่สามารถแสดงรายการได้ กรุณาลองใหม่ในภายหลัง")
|
||||||
@SuccessResponse(HttpStatusCode.OK, "สำเร็จ")
|
|
||||||
export class ReportController extends Controller {
|
export class ReportController extends Controller {
|
||||||
private evaluateChairmanRepository = AppDataSource.getRepository(EvaluateChairman)
|
private evaluateChairmanRepository = AppDataSource.getRepository(EvaluateChairman)
|
||||||
private evaluateResultRepository = AppDataSource.getRepository(EvaluateResult)
|
private evaluateResultRepository = AppDataSource.getRepository(EvaluateResult)
|
||||||
|
|
|
||||||
|
|
@ -1,33 +1,17 @@
|
||||||
import {
|
import { Controller, Route, Security, Tags, Request, SuccessResponse, Response, Get, Post, Body, Query } from "tsoa"
|
||||||
Controller,
|
import HttpSuccess from "../interfaces/http-success"
|
||||||
Route,
|
import HttpStatusCode from "../interfaces/http-status"
|
||||||
Security,
|
import { RequestWithUser } from "../middlewares/user"
|
||||||
Tags,
|
import { setLogDataDiff } from "../interfaces/utils"
|
||||||
Request,
|
import { Survey } from "../entities/Survey"
|
||||||
SuccessResponse,
|
import { AppDataSource } from "../database/data-source"
|
||||||
Response,
|
|
||||||
Get,
|
|
||||||
Post,
|
|
||||||
Body,
|
|
||||||
Query,
|
|
||||||
} from "tsoa";
|
|
||||||
import HttpSuccess from "../interfaces/http-success";
|
|
||||||
import HttpStatusCode from "../interfaces/http-status";
|
|
||||||
import { RequestWithUser } from "../middlewares/user";
|
|
||||||
import { setLogDataDiff } from "../interfaces/utils";
|
|
||||||
import { Survey } from "../entities/Survey";
|
|
||||||
import { AppDataSource } from "../database/data-source";
|
|
||||||
|
|
||||||
@Route("api/v1/probation/survey")
|
@Route("api/v1/probation/survey")
|
||||||
@Tags("Survey")
|
@Tags("Survey")
|
||||||
@Security("bearerAuth")
|
@Security("bearerAuth")
|
||||||
@Response(
|
@Response(HttpStatusCode.INTERNAL_SERVER_ERROR, "เกิดข้อผิดพลาด ไม่สามารถแสดงรายการได้ กรุณาลองใหม่ในภายหลัง")
|
||||||
HttpStatusCode.INTERNAL_SERVER_ERROR,
|
|
||||||
"เกิดข้อผิดพลาด ไม่สามารถแสดงรายการได้ กรุณาลองใหม่ในภายหลัง",
|
|
||||||
)
|
|
||||||
@SuccessResponse(HttpStatusCode.OK, "สำเร็จ")
|
|
||||||
export class SurveyController extends Controller {
|
export class SurveyController extends Controller {
|
||||||
private surveyRepository = AppDataSource.getRepository(Survey);
|
private surveyRepository = AppDataSource.getRepository(Survey)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* API แบบสำรวจความคิดเห็น
|
* API แบบสำรวจความคิดเห็น
|
||||||
|
|
@ -41,8 +25,8 @@ export class SurveyController extends Controller {
|
||||||
where: {
|
where: {
|
||||||
assign_id,
|
assign_id,
|
||||||
},
|
},
|
||||||
});
|
})
|
||||||
return new HttpSuccess(data);
|
return new HttpSuccess(data)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -52,16 +36,12 @@ export class SurveyController extends Controller {
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Post("")
|
@Post("")
|
||||||
async PostSurvey(
|
async PostSurvey(@Query() assign_id: string, @Body() requestBody: any, @Request() request: RequestWithUser) {
|
||||||
@Query() assign_id: string,
|
const before = null
|
||||||
@Body() requestBody: any,
|
const data = await { ...requestBody, personal_id: request.user.sub, assign_id }
|
||||||
@Request() request: RequestWithUser,
|
await this.surveyRepository.save(data, { data: request })
|
||||||
) {
|
setLogDataDiff(request, { before, after: data })
|
||||||
const before = null;
|
|
||||||
const data = await { ...requestBody, personal_id: request.user.sub, assign_id };
|
|
||||||
await this.surveyRepository.save(data, { data: request });
|
|
||||||
setLogDataDiff(request, { before, after: data });
|
|
||||||
|
|
||||||
return new HttpSuccess();
|
return new HttpSuccess()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue