Merge branch 'develop'
This commit is contained in:
commit
c408f3533d
22 changed files with 1949 additions and 2080 deletions
3
.github/workflows/release.yaml
vendored
3
.github/workflows/release.yaml
vendored
|
|
@ -7,7 +7,8 @@ on:
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
env:
|
env:
|
||||||
REGISTRY: docker.frappet.com
|
REGISTRY: docker.frappet.com
|
||||||
IMAGE_NAME: ehr/bma-ehr-node-service
|
# IMAGE_NAME: ehr/bma-ehr-node-service
|
||||||
|
IMAGE_NAME: ehr/bma-ehr-probation
|
||||||
DEPLOY_HOST: frappet.com
|
DEPLOY_HOST: frappet.com
|
||||||
# COMPOSE_PATH: /home/frappet/docker/bma-ehr
|
# COMPOSE_PATH: /home/frappet/docker/bma-ehr
|
||||||
COMPOSE_PATH: /home/frappet/docker/bma/bma-ehr-probation
|
COMPOSE_PATH: /home/frappet/docker/bma/bma-ehr-probation
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ WORKDIR /app
|
||||||
# Install app dependencies
|
# Install app dependencies
|
||||||
COPY package*.json ./
|
COPY package*.json ./
|
||||||
|
|
||||||
RUN npm ci
|
RUN npm i
|
||||||
|
|
||||||
COPY . .
|
COPY . .
|
||||||
|
|
||||||
|
|
@ -24,7 +24,7 @@ WORKDIR /app
|
||||||
COPY package*.json ./
|
COPY package*.json ./
|
||||||
# COPY .env ./
|
# COPY .env ./
|
||||||
|
|
||||||
RUN npm ci --production
|
RUN npm i --production
|
||||||
|
|
||||||
COPY --from=builder /app/dist ./dist
|
COPY --from=builder /app/dist ./dist
|
||||||
|
|
||||||
|
|
|
||||||
25
README.md
25
README.md
|
|
@ -6,16 +6,29 @@ Envelopment
|
||||||
- Express
|
- Express
|
||||||
- Mysql
|
- Mysql
|
||||||
|
|
||||||
Run Project
|
Install packages
|
||||||
|
|
||||||
```
|
```
|
||||||
> npm install
|
npm install
|
||||||
> npm run dev
|
```
|
||||||
|
|
||||||
|
Run project
|
||||||
|
|
||||||
|
```
|
||||||
|
npm run dev
|
||||||
```
|
```
|
||||||
|
|
||||||
Migration
|
Migration
|
||||||
|
|
||||||
1. สร้าง entities
|
1. สร้าง/แก้ไข entities
|
||||||
2. สร้างไฟล์ migration จาก entities และรัน update เข้า database
|
2. สร้างไฟล์ migration จาก entities และรัน update เข้า database
|
||||||
> npm run migration:generate src/migration/xxx (xxx คือชื่อไฟล์ migrate)
|
|
||||||
> npm run migration:run
|
```
|
||||||
|
npm run migration:generate src/migration/xxx (xxx คือชื่อไฟล์ migrate)
|
||||||
|
```
|
||||||
|
|
||||||
|
3. Run migration
|
||||||
|
|
||||||
|
```
|
||||||
|
npm run migration:run
|
||||||
|
```
|
||||||
|
|
|
||||||
13
src/app.ts
13
src/app.ts
|
|
@ -4,11 +4,10 @@ import cors from "cors";
|
||||||
import express from "express";
|
import express from "express";
|
||||||
import swaggerUi from "swagger-ui-express";
|
import swaggerUi from "swagger-ui-express";
|
||||||
import swaggerDocument from "./swagger.json";
|
import swaggerDocument from "./swagger.json";
|
||||||
import * as cron from "node-cron";
|
|
||||||
import error from "./middlewares/error";
|
import error from "./middlewares/error";
|
||||||
import { AppDataSource } from "./database/data-source";
|
import { AppDataSource } from "./database/data-source";
|
||||||
import { RegisterRoutes } from "./routes";
|
import { RegisterRoutes } from "./routes";
|
||||||
// import logMiddleware from "./middlewares/logs";
|
import logMiddleware from "./middlewares/logs";
|
||||||
|
|
||||||
async function main() {
|
async function main() {
|
||||||
await AppDataSource.initialize();
|
await AppDataSource.initialize();
|
||||||
|
|
@ -18,11 +17,11 @@ async function main() {
|
||||||
app.use(
|
app.use(
|
||||||
cors({
|
cors({
|
||||||
origin: "*",
|
origin: "*",
|
||||||
})
|
}),
|
||||||
);
|
);
|
||||||
app.use(express.json());
|
app.use(express.json());
|
||||||
app.use(express.urlencoded({ extended: true }));
|
app.use(express.urlencoded({ extended: true }));
|
||||||
// app.use(logMiddleware);
|
app.use(logMiddleware);
|
||||||
app.use("/", express.static("static"));
|
app.use("/", express.static("static"));
|
||||||
app.use("/api-docs", swaggerUi.serve, swaggerUi.setup(swaggerDocument));
|
app.use("/api-docs", swaggerUi.serve, swaggerUi.setup(swaggerDocument));
|
||||||
|
|
||||||
|
|
@ -36,11 +35,9 @@ async function main() {
|
||||||
APP_PORT,
|
APP_PORT,
|
||||||
APP_HOST,
|
APP_HOST,
|
||||||
() => (
|
() => (
|
||||||
console.log(
|
console.log(`[APP] Application is running on: http://localhost:${APP_PORT}`),
|
||||||
`[APP] Application is running on: http://localhost:${APP_PORT}`
|
|
||||||
),
|
|
||||||
console.log(`[APP] Swagger on: http://localhost:${APP_PORT}/api-docs`)
|
console.log(`[APP] Swagger on: http://localhost:${APP_PORT}/api-docs`)
|
||||||
)
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -21,21 +21,12 @@ import { findEndDate, setLogDataDiff } from "../interfaces/utils";
|
||||||
import { Personal } from "../entities/Personal";
|
import { Personal } from "../entities/Personal";
|
||||||
import permission from "../interfaces/permission";
|
import permission from "../interfaces/permission";
|
||||||
import { Assign, CreateAssign } from "../entities/Assign";
|
import { Assign, CreateAssign } from "../entities/Assign";
|
||||||
import {
|
import { AssignDirector, CreateAssignDirector } from "../entities/AssignDirector";
|
||||||
AssignDirector,
|
|
||||||
CreateAssignDirector,
|
|
||||||
} from "../entities/AssignDirector";
|
|
||||||
import { AssignJob, CreateAssignJob } from "../entities/AssignJob";
|
import { AssignJob, CreateAssignJob } from "../entities/AssignJob";
|
||||||
import {
|
import { AssignKnowledge, CreateAssignKnowledge } from "../entities/AssignKnowledge";
|
||||||
AssignKnowledge,
|
|
||||||
CreateAssignKnowledge,
|
|
||||||
} from "../entities/AssignKnowledge";
|
|
||||||
import { AssignLaw, CreateAssignLaw } from "../entities/AssignLaw";
|
import { AssignLaw, CreateAssignLaw } from "../entities/AssignLaw";
|
||||||
import { AssignSkill, CreateAssignSkill } from "../entities/AssignSkill";
|
import { AssignSkill, CreateAssignSkill } from "../entities/AssignSkill";
|
||||||
import {
|
import { AssignCompetency, CreateAssignCompetency } from "../entities/AssignCompetency";
|
||||||
AssignCompetency,
|
|
||||||
CreateAssignCompetency,
|
|
||||||
} from "../entities/AssignCompetency";
|
|
||||||
import {
|
import {
|
||||||
AssignCompetencyGroup,
|
AssignCompetencyGroup,
|
||||||
CreateAssignCompetencyGroup,
|
CreateAssignCompetencyGroup,
|
||||||
|
|
@ -44,29 +35,24 @@ import { AssignOutput, CreateAssignOutput } from "../entities/AssignOutput";
|
||||||
import { Law } from "../entities/Law";
|
import { Law } from "../entities/Law";
|
||||||
import CallAPI from "../interfaces/call-api";
|
import CallAPI from "../interfaces/call-api";
|
||||||
|
|
||||||
@Route("api/v1/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, "สำเร็จ")
|
@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 =
|
private assignDirectorRepository = AppDataSource.getRepository(AssignDirector);
|
||||||
AppDataSource.getRepository(AssignDirector);
|
|
||||||
private assignJobRepository = AppDataSource.getRepository(AssignJob);
|
private assignJobRepository = AppDataSource.getRepository(AssignJob);
|
||||||
private assignKnowledgeRepository =
|
private assignKnowledgeRepository = AppDataSource.getRepository(AssignKnowledge);
|
||||||
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 =
|
private assignCompetencyRepository = AppDataSource.getRepository(AssignCompetency);
|
||||||
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);
|
||||||
|
|
||||||
|
|
@ -77,32 +63,29 @@ export class AssignController extends Controller {
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Post("")
|
@Post("")
|
||||||
async AddAssign(
|
async AddAssign(@Request() request: RequestWithUser, @Body() requestBody: CreateAssign) {
|
||||||
@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.personal_id,
|
personal_id: requestBody.personalId,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!person) {
|
if (!person) {
|
||||||
return new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลบุคคล");
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลบุคคล");
|
||||||
}
|
}
|
||||||
|
|
||||||
const roundNo = await this.assignRepository.count({
|
const roundNo = await this.assignRepository.count({
|
||||||
where: {
|
where: {
|
||||||
active: 1,
|
active: 1,
|
||||||
personal_id: requestBody.personal_id,
|
personal_id: requestBody.personalId,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
const data: any = {
|
const data: any = {
|
||||||
...requestBody,
|
...requestBody,
|
||||||
round_no: roundNo + 1,
|
round_no: roundNo + 1,
|
||||||
personal_id: requestBody.personal_id,
|
personal_id: requestBody.personalId,
|
||||||
createdUserId: request.user.sub,
|
createdUserId: request.user.sub,
|
||||||
createdFullName: request.user.name,
|
createdFullName: request.user.name,
|
||||||
updateUserId: request.user.sub,
|
updateUserId: request.user.sub,
|
||||||
|
|
@ -112,8 +95,7 @@ export class AssignController extends Controller {
|
||||||
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(
|
const jobs = await requestBody.assign_jobs.map((x: CreateAssignJob, index: number) => ({
|
||||||
(x: CreateAssignJob, index: number) => ({
|
|
||||||
...x,
|
...x,
|
||||||
id: index + 1,
|
id: index + 1,
|
||||||
assign_id: assign.id,
|
assign_id: assign.id,
|
||||||
|
|
@ -121,8 +103,7 @@ 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 });
|
||||||
|
|
||||||
|
|
@ -135,13 +116,12 @@ 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(
|
const laws = await requestBody.assign_law.map((x: CreateAssignLaw, index: number) => ({
|
||||||
(x: CreateAssignLaw, index: number) => ({
|
|
||||||
ordering: index + 1,
|
ordering: index + 1,
|
||||||
law_id: x.id,
|
law_id: x.id,
|
||||||
assign_id: assign.id,
|
assign_id: assign.id,
|
||||||
|
|
@ -149,13 +129,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.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(
|
const skills = await requestBody.assign_skill.map((x: CreateAssignSkill, index: number) => ({
|
||||||
(x: CreateAssignSkill, index: number) => ({
|
|
||||||
skill_id: index + 1,
|
skill_id: index + 1,
|
||||||
skill_level: x.level,
|
skill_level: x.level,
|
||||||
assign_id: assign.id,
|
assign_id: assign.id,
|
||||||
|
|
@ -163,8 +141,7 @@ 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 });
|
||||||
|
|
||||||
|
|
@ -179,7 +156,7 @@ 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 });
|
||||||
|
|
@ -195,7 +172,7 @@ 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,
|
||||||
|
|
@ -211,7 +188,7 @@ 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 });
|
||||||
|
|
@ -226,7 +203,7 @@ 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 });
|
||||||
|
|
@ -244,7 +221,7 @@ export class AssignController extends Controller {
|
||||||
async EditAssign(
|
async EditAssign(
|
||||||
@Query() assign_id: string,
|
@Query() assign_id: string,
|
||||||
@Request() request: RequestWithUser,
|
@Request() request: RequestWithUser,
|
||||||
@Body() requestBody: CreateAssign
|
@Body() requestBody: CreateAssign,
|
||||||
) {
|
) {
|
||||||
await new permission().PermissionUpdate(request, "SYS_PROBATION");
|
await new permission().PermissionUpdate(request, "SYS_PROBATION");
|
||||||
|
|
||||||
|
|
@ -254,20 +231,17 @@ export class AssignController extends Controller {
|
||||||
let before = assign;
|
let before = assign;
|
||||||
|
|
||||||
if (!assign) {
|
if (!assign) {
|
||||||
return new HttpError(
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลแบบมอบหมายงาน");
|
||||||
HttpStatusCode.NOT_FOUND,
|
|
||||||
"ไม่พบข้อมูลแบบมอบหมายงาน"
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const person = await this.personalRepository.findOne({
|
const person = await this.personalRepository.findOne({
|
||||||
where: {
|
where: {
|
||||||
personal_id: requestBody.personal_id,
|
personal_id: requestBody.personalId,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!person) {
|
if (!person) {
|
||||||
return new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลบุคคล");
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลบุคคล");
|
||||||
}
|
}
|
||||||
|
|
||||||
const data: any = {
|
const data: any = {
|
||||||
|
|
@ -278,8 +252,7 @@ export class AssignController extends Controller {
|
||||||
};
|
};
|
||||||
|
|
||||||
await this.assignJobRepository.delete({ assign_id });
|
await this.assignJobRepository.delete({ assign_id });
|
||||||
const jobs = await requestBody.assign_jobs.map(
|
const jobs = await requestBody.assign_jobs.map((x: CreateAssignJob, index: number) => ({
|
||||||
(x: CreateAssignJob, index: number) => ({
|
|
||||||
...x,
|
...x,
|
||||||
id: index + 1,
|
id: index + 1,
|
||||||
assign_id: assign.id,
|
assign_id: assign.id,
|
||||||
|
|
@ -287,8 +260,7 @@ 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 });
|
||||||
|
|
@ -301,13 +273,12 @@ 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(
|
const laws = await requestBody.assign_law.map((x: CreateAssignLaw, index: number) => ({
|
||||||
(x: CreateAssignLaw, index: number) => ({
|
|
||||||
ordering: index + 1,
|
ordering: index + 1,
|
||||||
law_id: x.id,
|
law_id: x.id,
|
||||||
assign_id: assign.id,
|
assign_id: assign.id,
|
||||||
|
|
@ -315,13 +286,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.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(
|
const skills = await requestBody.assign_skill.map((x: CreateAssignSkill, index: number) => ({
|
||||||
(x: CreateAssignSkill, index: number) => ({
|
|
||||||
skill_id: index + 1,
|
skill_id: index + 1,
|
||||||
skill_level: x.level,
|
skill_level: x.level,
|
||||||
assign_id: assign.id,
|
assign_id: assign.id,
|
||||||
|
|
@ -329,8 +298,7 @@ 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 });
|
||||||
|
|
@ -345,7 +313,7 @@ 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);
|
||||||
|
|
||||||
|
|
@ -361,7 +329,7 @@ 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);
|
||||||
|
|
||||||
|
|
@ -375,7 +343,7 @@ 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);
|
||||||
|
|
||||||
|
|
@ -390,7 +358,7 @@ 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);
|
||||||
|
|
||||||
|
|
@ -469,10 +437,7 @@ export class AssignController extends Controller {
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Get("assign-list")
|
@Get("assign-list")
|
||||||
async ListPersonal(
|
async ListPersonal(@Request() request: RequestWithUser, @Query() personal_id: string) {
|
||||||
@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"],
|
||||||
|
|
@ -486,6 +451,7 @@ export class AssignController extends Controller {
|
||||||
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" },
|
||||||
});
|
});
|
||||||
|
|
||||||
let mentors = "";
|
let mentors = "";
|
||||||
|
|
@ -500,14 +466,10 @@ export class AssignController extends Controller {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const commanderData = await (director.find(
|
const commanderData = await (director.find((x) => x.role == "commander") ?? null);
|
||||||
(x) => x.role == "commander"
|
|
||||||
) ?? null);
|
|
||||||
const commander = commanderData ? commanderData.fullname : null;
|
const commander = commanderData ? commanderData.fullname : null;
|
||||||
|
|
||||||
const chairmanData = await (director.find(
|
const chairmanData = await (director.find((x) => x.role == "chairman") ?? null);
|
||||||
(x) => x.role == "chairman"
|
|
||||||
) ?? null);
|
|
||||||
const chairman = chairmanData ? chairmanData.fullname : null;
|
const chairman = chairmanData ? chairmanData.fullname : null;
|
||||||
|
|
||||||
await result.push({
|
await result.push({
|
||||||
|
|
@ -516,7 +478,7 @@ export class AssignController extends Controller {
|
||||||
commander: commander,
|
commander: commander,
|
||||||
chairman: chairman,
|
chairman: chairman,
|
||||||
});
|
});
|
||||||
})
|
}),
|
||||||
);
|
);
|
||||||
|
|
||||||
return new HttpSuccess(result);
|
return new HttpSuccess(result);
|
||||||
|
|
@ -529,11 +491,8 @@ export class AssignController extends Controller {
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Get("")
|
@Get("")
|
||||||
async GetAssign(
|
async GetAssign(@Query() assign_id: string, @Request() request: RequestWithUser) {
|
||||||
@Query() assign_id: string,
|
await new permission().PermissionGet(request, "SYS_PROBATION");
|
||||||
@Request() request: RequestWithUser
|
|
||||||
) {
|
|
||||||
await new permission().PermissionUpdate(request, "SYS_PROBATION");
|
|
||||||
|
|
||||||
const assign = await this.assignRepository.findOne({
|
const assign = await this.assignRepository.findOne({
|
||||||
select: [
|
select: [
|
||||||
|
|
@ -542,6 +501,7 @@ export class AssignController extends Controller {
|
||||||
"round_no",
|
"round_no",
|
||||||
"date_start",
|
"date_start",
|
||||||
"date_finish",
|
"date_finish",
|
||||||
|
"other_desc",
|
||||||
"other4_desc",
|
"other4_desc",
|
||||||
"other5_no1_desc",
|
"other5_no1_desc",
|
||||||
"experimenter_dated",
|
"experimenter_dated",
|
||||||
|
|
@ -553,10 +513,7 @@ export class AssignController extends Controller {
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!assign) {
|
if (!assign) {
|
||||||
return new HttpError(
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลแบบมอบหมายงาน");
|
||||||
HttpStatusCode.NOT_FOUND,
|
|
||||||
"ไม่พบข้อมูลแบบมอบหมายงาน"
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const profileData = await this.personalRepository.findOne({
|
const profileData = await this.personalRepository.findOne({
|
||||||
|
|
@ -577,7 +534,7 @@ export class AssignController extends Controller {
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!profileData) {
|
if (!profileData) {
|
||||||
return new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลบุคคล");
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลบุคคล");
|
||||||
}
|
}
|
||||||
|
|
||||||
const profile = {
|
const profile = {
|
||||||
|
|
@ -620,12 +577,21 @@ export class AssignController extends Controller {
|
||||||
where: { active: 1 },
|
where: { active: 1 },
|
||||||
});
|
});
|
||||||
|
|
||||||
const laws = await lawData.map((x) => ({
|
const laws = await Promise.all(
|
||||||
|
lawData.map(async (x) => {
|
||||||
|
const assignLaw = await this.assignLawRepository.countBy({
|
||||||
|
assign_id: assign_id,
|
||||||
|
law_id: x.id,
|
||||||
|
});
|
||||||
|
|
||||||
|
return {
|
||||||
id: x.id,
|
id: x.id,
|
||||||
selected: x.assignLaw ? 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"],
|
||||||
|
|
@ -651,12 +617,7 @@ export class AssignController extends Controller {
|
||||||
}));
|
}));
|
||||||
|
|
||||||
const competencyData = await this.assignCompetencyRepository.find({
|
const competencyData = await this.assignCompetencyRepository.find({
|
||||||
select: [
|
select: ["competency_id", "competency_level", "competency_name", "competency_description"],
|
||||||
"competency_id",
|
|
||||||
"competency_level",
|
|
||||||
"competency_name",
|
|
||||||
"competency_description",
|
|
||||||
],
|
|
||||||
where: { assign_id },
|
where: { assign_id },
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -667,8 +628,7 @@ export class AssignController extends Controller {
|
||||||
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_id",
|
||||||
"competency_group_level",
|
"competency_group_level",
|
||||||
|
|
@ -676,8 +636,7 @@ export class AssignController extends Controller {
|
||||||
"competency_group_description",
|
"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,
|
||||||
|
|
@ -692,6 +651,7 @@ export class AssignController extends Controller {
|
||||||
|
|
||||||
const director = await this.assignDirectorRepository.find({
|
const director = await this.assignDirectorRepository.find({
|
||||||
where: { assign_id },
|
where: { assign_id },
|
||||||
|
order: { ordering: "ASC" },
|
||||||
});
|
});
|
||||||
|
|
||||||
let mentors = [];
|
let mentors = [];
|
||||||
|
|
@ -703,16 +663,13 @@ export class AssignController extends Controller {
|
||||||
...e,
|
...e,
|
||||||
name: e.fullname,
|
name: e.fullname,
|
||||||
label:
|
label:
|
||||||
e.fullname +
|
e.fullname + " " + (e.position ? `(${e.position}, ${e.posType}: ${e.posLevel})` : ""),
|
||||||
" " +
|
|
||||||
(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") ??
|
const commanderData = await (director.find((x) => x.role == "commander") ?? null);
|
||||||
null);
|
|
||||||
const commander = await (commanderData
|
const commander = await (commanderData
|
||||||
? {
|
? {
|
||||||
...commanderData,
|
...commanderData,
|
||||||
|
|
@ -727,8 +684,7 @@ export class AssignController extends Controller {
|
||||||
}
|
}
|
||||||
: null);
|
: null);
|
||||||
|
|
||||||
const chairmanData = await (director.find((x) => x.role == "chairman") ??
|
const chairmanData = await (director.find((x) => x.role == "chairman") ?? null);
|
||||||
null);
|
|
||||||
const chairman = await (chairmanData
|
const chairman = await (chairmanData
|
||||||
? {
|
? {
|
||||||
...chairmanData,
|
...chairmanData,
|
||||||
|
|
|
||||||
|
|
@ -15,12 +15,12 @@ import HttpStatusCode from "../interfaces/http-status";
|
||||||
import { RequestWithUser } from "../middlewares/user";
|
import { RequestWithUser } from "../middlewares/user";
|
||||||
import { findEndDate } from "../interfaces/utils";
|
import { findEndDate } from "../interfaces/utils";
|
||||||
|
|
||||||
@Route("api/v1/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, "สำเร็จ")
|
@SuccessResponse(HttpStatusCode.OK, "สำเร็จ")
|
||||||
export class CalculateController extends Controller {
|
export class CalculateController extends Controller {
|
||||||
|
|
@ -37,7 +37,7 @@ export class CalculateController extends Controller {
|
||||||
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);
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,6 @@ import {
|
||||||
Route,
|
Route,
|
||||||
Security,
|
Security,
|
||||||
Tags,
|
Tags,
|
||||||
Path,
|
|
||||||
Request,
|
Request,
|
||||||
SuccessResponse,
|
SuccessResponse,
|
||||||
Response,
|
Response,
|
||||||
|
|
@ -21,20 +20,20 @@ import { MapKnowledgeSkill } from "../entities/MapKnowledgeSkill";
|
||||||
import { Personal } from "../entities/Personal";
|
import { Personal } from "../entities/Personal";
|
||||||
import { Law } from "../entities/Law";
|
import { Law } from "../entities/Law";
|
||||||
import { Assign } from "../entities/Assign";
|
import { Assign } from "../entities/Assign";
|
||||||
|
import permission from "../interfaces/permission";
|
||||||
|
|
||||||
@Route("api/v1/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, "สำเร็จ")
|
@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 =
|
private mapKnowledgeSkillRepository = AppDataSource.getRepository(MapKnowledgeSkill);
|
||||||
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);
|
||||||
|
|
@ -46,21 +45,16 @@ export class DataOptionController extends Controller {
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Get("knowledge")
|
@Get("knowledge")
|
||||||
async GetKnowledge(
|
async GetKnowledge(@Query() personal_id: string) {
|
||||||
@Query() personal_id: string,
|
|
||||||
@Request() request: RequestWithUser
|
|
||||||
) {
|
|
||||||
const person = await this.personalRepository.findOne({
|
const person = await this.personalRepository.findOne({
|
||||||
where: { personal_id },
|
where: { personal_id },
|
||||||
});
|
});
|
||||||
|
|
||||||
console.log(person);
|
|
||||||
|
|
||||||
if (!person) {
|
if (!person) {
|
||||||
return new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลบุคคล");
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลบุคคล");
|
||||||
}
|
}
|
||||||
|
|
||||||
const result = await this.mapKnowledgeSkillRepository.findOne({
|
let result = await this.mapKnowledgeSkillRepository.findOne({
|
||||||
where: {
|
where: {
|
||||||
positionName: person.positionName,
|
positionName: person.positionName,
|
||||||
positionLevelName: person.positionLevelName,
|
positionLevelName: person.positionLevelName,
|
||||||
|
|
@ -69,7 +63,17 @@ export class DataOptionController extends Controller {
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!result) {
|
if (!result) {
|
||||||
return new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล");
|
// ถ้าตำแหน่งไม่ตรงหาจากระดับตำแหน่งแทนเพื่อให้ฟอร์มสามารถกรอกต่อได้
|
||||||
|
result = await this.mapKnowledgeSkillRepository.findOne({
|
||||||
|
where: {
|
||||||
|
positionLevelName: person.positionLevelName,
|
||||||
|
active: 1,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!result) {
|
||||||
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลความรู้ที่ตรงกับตำแหน่ง");
|
||||||
}
|
}
|
||||||
|
|
||||||
const knowledges = await this.knowledgeRepository.find({
|
const knowledges = await this.knowledgeRepository.find({
|
||||||
|
|
@ -102,19 +106,16 @@ export class DataOptionController extends Controller {
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Get("skill")
|
@Get("skill")
|
||||||
async GetSkill(
|
async GetSkill(@Query() personal_id: string) {
|
||||||
@Query() personal_id: string,
|
|
||||||
@Request() request: RequestWithUser
|
|
||||||
) {
|
|
||||||
const person = await this.personalRepository.findOne({
|
const person = await this.personalRepository.findOne({
|
||||||
where: { personal_id },
|
where: { personal_id },
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!person) {
|
if (!person) {
|
||||||
return new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล");
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล");
|
||||||
}
|
}
|
||||||
|
|
||||||
const result = await this.mapKnowledgeSkillRepository.findOne({
|
let result = await this.mapKnowledgeSkillRepository.findOne({
|
||||||
select: [
|
select: [
|
||||||
"skill_computer_level",
|
"skill_computer_level",
|
||||||
"skill_english_level",
|
"skill_english_level",
|
||||||
|
|
@ -129,90 +130,124 @@ export class DataOptionController extends Controller {
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!result) {
|
if (!result) {
|
||||||
return new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล");
|
// ถ้าตำแหน่งไม่ตรงหาจากระดับตำแหน่งแทนเพื่อให้ฟอร์มสามารถกรอกต่อได้
|
||||||
|
result = await this.mapKnowledgeSkillRepository.findOne({
|
||||||
|
select: [
|
||||||
|
"skill_computer_level",
|
||||||
|
"skill_english_level",
|
||||||
|
"skill_information_level",
|
||||||
|
"skill_resourse_level",
|
||||||
|
],
|
||||||
|
where: {
|
||||||
|
positionLevelName: person.positionLevelName,
|
||||||
|
active: 1,
|
||||||
|
},
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
const skills = await this.skillRepository.find({
|
if (!result) {
|
||||||
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลทักษะที่ตรงกับตำแหน่ง");
|
||||||
|
}
|
||||||
|
|
||||||
|
const computerData = await this.skillRepository.findOne({
|
||||||
where: { type: TypeSkill.COMPUTER, active: 1 },
|
where: { type: TypeSkill.COMPUTER, active: 1 },
|
||||||
});
|
});
|
||||||
const skill = await skills.map((v) => ({
|
|
||||||
id: v.id,
|
|
||||||
title: v.title,
|
|
||||||
level_description:
|
|
||||||
result.skill_english_level == 1
|
|
||||||
? v.level1
|
|
||||||
: result.skill_english_level == 2
|
|
||||||
? v.level2
|
|
||||||
: result.skill_english_level == 3
|
|
||||||
? v.level3
|
|
||||||
: result.skill_english_level == 4
|
|
||||||
? v.level4
|
|
||||||
: v.level5,
|
|
||||||
level: result.skill_english_level,
|
|
||||||
}));
|
|
||||||
|
|
||||||
const englishs = await this.skillRepository.find({
|
if (!computerData) {
|
||||||
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลทักษะคอมพิวเตอร์");
|
||||||
|
}
|
||||||
|
const computer = await {
|
||||||
|
id: computerData.id,
|
||||||
|
title: computerData.title,
|
||||||
|
level_description:
|
||||||
|
result.skill_computer_level == 1
|
||||||
|
? computerData.level1
|
||||||
|
: result.skill_computer_level == 2
|
||||||
|
? computerData.level2
|
||||||
|
: result.skill_computer_level == 3
|
||||||
|
? computerData.level3
|
||||||
|
: result.skill_computer_level == 4
|
||||||
|
? computerData.level4
|
||||||
|
: computerData.level5,
|
||||||
|
level: result.skill_computer_level,
|
||||||
|
};
|
||||||
|
|
||||||
|
const englishData = await this.skillRepository.findOne({
|
||||||
where: { type: TypeSkill.ENG, active: 1 },
|
where: { type: TypeSkill.ENG, active: 1 },
|
||||||
});
|
});
|
||||||
const english = await englishs.map((v) => ({
|
|
||||||
id: v.id,
|
if (!englishData) {
|
||||||
title: v.title,
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลทักษะภาษาอังกฤษ");
|
||||||
|
}
|
||||||
|
|
||||||
|
const english = await {
|
||||||
|
id: englishData.id,
|
||||||
|
title: englishData.title,
|
||||||
level_description:
|
level_description:
|
||||||
result.skill_english_level == 1
|
result.skill_english_level == 1
|
||||||
? v.level1
|
? englishData.level1
|
||||||
: result.skill_english_level == 2
|
: result.skill_english_level == 2
|
||||||
? v.level2
|
? englishData.level2
|
||||||
: result.skill_english_level == 3
|
: result.skill_english_level == 3
|
||||||
? v.level3
|
? englishData.level3
|
||||||
: result.skill_english_level == 4
|
: result.skill_english_level == 4
|
||||||
? v.level4
|
? englishData.level4
|
||||||
: v.level5,
|
: englishData.level5,
|
||||||
level: result.skill_english_level,
|
level: result.skill_english_level,
|
||||||
}));
|
};
|
||||||
|
|
||||||
const informations = await this.skillRepository.find({
|
const informationData = await this.skillRepository.findOne({
|
||||||
where: { type: TypeSkill.INFORMATION, active: 1 },
|
where: { type: TypeSkill.INFORMATION, active: 1 },
|
||||||
});
|
});
|
||||||
const information = await informations.map((v) => ({
|
|
||||||
id: v.id,
|
if (!informationData) {
|
||||||
title: v.title,
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล");
|
||||||
|
}
|
||||||
|
|
||||||
|
const information = await {
|
||||||
|
id: informationData.id,
|
||||||
|
title: informationData.title,
|
||||||
level_description:
|
level_description:
|
||||||
result.skill_information_level == 1
|
result.skill_information_level == 1
|
||||||
? v.level1
|
? informationData.level1
|
||||||
: result.skill_information_level == 2
|
: result.skill_information_level == 2
|
||||||
? v.level2
|
? informationData.level2
|
||||||
: result.skill_information_level == 3
|
: result.skill_information_level == 3
|
||||||
? v.level3
|
? informationData.level3
|
||||||
: result.skill_information_level == 4
|
: result.skill_information_level == 4
|
||||||
? v.level4
|
? informationData.level4
|
||||||
: v.level5,
|
: informationData.level5,
|
||||||
level: result.skill_information_level,
|
level: result.skill_information_level,
|
||||||
}));
|
};
|
||||||
|
|
||||||
const resourses = await this.skillRepository.find({
|
const resourseData = await this.skillRepository.findOne({
|
||||||
where: { type: TypeSkill.RESOURSE, active: 1 },
|
where: { type: TypeSkill.RESOURSE, active: 1 },
|
||||||
});
|
});
|
||||||
const resourse = await resourses.map((v) => ({
|
if (!resourseData) {
|
||||||
id: v.id,
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล");
|
||||||
title: v.title,
|
}
|
||||||
|
|
||||||
|
const resourse = await {
|
||||||
|
id: resourseData.id,
|
||||||
|
title: resourseData.title,
|
||||||
level_description:
|
level_description:
|
||||||
result.skill_resourse_level == 1
|
result.skill_resourse_level == 1
|
||||||
? v.level1
|
? resourseData.level1
|
||||||
: result.skill_resourse_level == 2
|
: result.skill_resourse_level == 2
|
||||||
? v.level2
|
? resourseData.level2
|
||||||
: result.skill_resourse_level == 3
|
: result.skill_resourse_level == 3
|
||||||
? v.level3
|
? resourseData.level3
|
||||||
: result.skill_resourse_level == 4
|
: result.skill_resourse_level == 4
|
||||||
? v.level4
|
? resourseData.level4
|
||||||
: v.level5,
|
: resourseData.level5,
|
||||||
level: result.skill_resourse_level,
|
level: result.skill_resourse_level,
|
||||||
}));
|
};
|
||||||
|
|
||||||
return new HttpSuccess({
|
return new HttpSuccess({
|
||||||
computer: skill,
|
computer,
|
||||||
english: english,
|
english,
|
||||||
information: information,
|
information,
|
||||||
resourse: resourse,
|
resourse,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -223,10 +258,7 @@ export class DataOptionController extends Controller {
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Get("law")
|
@Get("law")
|
||||||
async GetLaw(
|
async GetLaw(@Query() personal_id: string) {
|
||||||
@Query() personal_id: string,
|
|
||||||
@Request() request: RequestWithUser
|
|
||||||
) {
|
|
||||||
const results = await this.lawRepository.find({
|
const results = await this.lawRepository.find({
|
||||||
select: ["id", "parent_id", "description", "status_select"],
|
select: ["id", "parent_id", "description", "status_select"],
|
||||||
where: {
|
where: {
|
||||||
|
|
@ -235,7 +267,7 @@ export class DataOptionController extends Controller {
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!results) {
|
if (!results) {
|
||||||
return new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล");
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล");
|
||||||
}
|
}
|
||||||
|
|
||||||
const result = await results.map((v) => ({
|
const result = await results.map((v) => ({
|
||||||
|
|
@ -253,10 +285,9 @@ export class DataOptionController extends Controller {
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Get("new-assign")
|
@Get("new-assign")
|
||||||
async NewAssign(
|
async NewAssign(@Query() personal_id: string, @Request() request: RequestWithUser) {
|
||||||
@Query() personal_id: string,
|
await new permission().PermissionGet(request, "SYS_PROBATION");
|
||||||
@Request() request: RequestWithUser
|
|
||||||
) {
|
|
||||||
const person = await this.personalRepository.findOne({
|
const person = await this.personalRepository.findOne({
|
||||||
select: [
|
select: [
|
||||||
"personal_id",
|
"personal_id",
|
||||||
|
|
@ -277,7 +308,7 @@ export class DataOptionController extends Controller {
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!person) {
|
if (!person) {
|
||||||
return new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล");
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล");
|
||||||
}
|
}
|
||||||
|
|
||||||
const assign = await this.assignRepository.count({
|
const assign = await this.assignRepository.count({
|
||||||
|
|
@ -291,12 +322,10 @@ export class DataOptionController extends Controller {
|
||||||
...person,
|
...person,
|
||||||
};
|
};
|
||||||
|
|
||||||
const data = await {
|
return new HttpSuccess({
|
||||||
person: responsePerson,
|
person: responsePerson,
|
||||||
assign_no: assign + 1,
|
assign_no: assign + 1,
|
||||||
assign_month: 6,
|
assign_month: 6,
|
||||||
};
|
});
|
||||||
|
|
||||||
return new HttpSuccess({ data: data });
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -22,25 +22,20 @@ import HttpError from "../interfaces/http-error";
|
||||||
import { Assign } from "../entities/Assign";
|
import { Assign } from "../entities/Assign";
|
||||||
import { Personal } from "../entities/Personal";
|
import { Personal } from "../entities/Personal";
|
||||||
import CallAPI from "../interfaces/call-api";
|
import CallAPI from "../interfaces/call-api";
|
||||||
import {
|
import { CreateEvaluateChairman, EvaluateChairman } from "../entities/EvaluateChairman";
|
||||||
CreateEvaluateChairman,
|
import permission from "../interfaces/permission";
|
||||||
EvaluateChairman,
|
@Route("api/v1/probation/evaluate-chairman")
|
||||||
} from "../entities/EvaluateChairman";
|
|
||||||
|
|
||||||
@Route("api/v1/evaluate-chairman")
|
|
||||||
@Tags("แบบประเมินผล (คณะกรรมการ)")
|
@Tags("แบบประเมินผล (คณะกรรมการ)")
|
||||||
@Security("bearerAuth")
|
@Security("bearerAuth")
|
||||||
@Response(
|
@Response(
|
||||||
HttpStatusCode.INTERNAL_SERVER_ERROR,
|
HttpStatusCode.INTERNAL_SERVER_ERROR,
|
||||||
"เกิดข้อผิดพลาด ไม่สามารถแสดงรายการได้ กรุณาลองใหม่ในภายหลัง"
|
"เกิดข้อผิดพลาด ไม่สามารถแสดงรายการได้ กรุณาลองใหม่ในภายหลัง",
|
||||||
)
|
)
|
||||||
@SuccessResponse(HttpStatusCode.OK, "สำเร็จ")
|
@SuccessResponse(HttpStatusCode.OK, "สำเร็จ")
|
||||||
export class EvaluateChairmanController extends Controller {
|
export class EvaluateChairmanController extends Controller {
|
||||||
private assignDirectorRepository =
|
private assignDirectorRepository = AppDataSource.getRepository(AssignDirector);
|
||||||
AppDataSource.getRepository(AssignDirector);
|
|
||||||
private assignRepository = AppDataSource.getRepository(Assign);
|
private assignRepository = AppDataSource.getRepository(Assign);
|
||||||
private evaluateChairmanRepository =
|
private evaluateChairmanRepository = AppDataSource.getRepository(EvaluateChairman);
|
||||||
AppDataSource.getRepository(EvaluateChairman);
|
|
||||||
private personalRepository = AppDataSource.getRepository(Personal);
|
private personalRepository = AppDataSource.getRepository(Personal);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -50,10 +45,9 @@ export class EvaluateChairmanController extends Controller {
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Get("create")
|
@Get("create")
|
||||||
async CreateEvaluate(
|
async CreateEvaluate(@Query() assign_id: string, @Request() request: RequestWithUser) {
|
||||||
@Query() assign_id: string,
|
await new permission().PermissionGet(request, "SYS_PROBATION");
|
||||||
@Request() request: RequestWithUser
|
|
||||||
) {
|
|
||||||
const director = await this.assignDirectorRepository.findOne({
|
const director = await this.assignDirectorRepository.findOne({
|
||||||
select: ["personal_id"],
|
select: ["personal_id"],
|
||||||
where: {
|
where: {
|
||||||
|
|
@ -62,7 +56,7 @@ export class EvaluateChairmanController extends Controller {
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
if (!director) {
|
if (!director) {
|
||||||
return new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลผู้ดูแล");
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลผู้ดูแล");
|
||||||
}
|
}
|
||||||
const director_id = director.personal_id;
|
const director_id = director.personal_id;
|
||||||
|
|
||||||
|
|
@ -71,10 +65,7 @@ export class EvaluateChairmanController extends Controller {
|
||||||
where: { id: assign_id },
|
where: { id: assign_id },
|
||||||
});
|
});
|
||||||
if (!assign) {
|
if (!assign) {
|
||||||
return new HttpError(
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลแบบมอบหมายงาน");
|
||||||
HttpStatusCode.NOT_FOUND,
|
|
||||||
"ไม่พบข้อมูลแบบมอบหมายงาน"
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const profile = await (assign.profile
|
const profile = await (assign.profile
|
||||||
|
|
@ -82,10 +73,7 @@ export class EvaluateChairmanController extends Controller {
|
||||||
...assign.profile,
|
...assign.profile,
|
||||||
id: assign.profile.personal_id,
|
id: assign.profile.personal_id,
|
||||||
name:
|
name:
|
||||||
assign.profile.prefixName +
|
assign.profile.prefixName + assign.profile.firstName + " " + assign.profile.lastName,
|
||||||
assign.profile.firstName +
|
|
||||||
" " +
|
|
||||||
assign.profile.lastName,
|
|
||||||
Oc: assign.profile.organization,
|
Oc: assign.profile.organization,
|
||||||
}
|
}
|
||||||
: null);
|
: null);
|
||||||
|
|
@ -104,36 +92,70 @@ export class EvaluateChairmanController extends Controller {
|
||||||
|
|
||||||
const directorData = await this.assignDirectorRepository.find({
|
const directorData = await this.assignDirectorRepository.find({
|
||||||
where: { assign_id },
|
where: { assign_id },
|
||||||
|
order: { ordering: "ASC" },
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!directorData) {
|
if (!directorData) {
|
||||||
return new HttpError(
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลผู้ดูแล ผู้บังคับบัญชาและประธาน");
|
||||||
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 += e.fullname;
|
|
||||||
if (index < mentorList.length - 1) {
|
mentors.push({
|
||||||
mentors += ", ";
|
personal_id: e.personal_id,
|
||||||
}
|
dated: e.dated,
|
||||||
|
name: e.fullname,
|
||||||
|
label:
|
||||||
|
e.fullname + " " + (e.position ? `(${e.position}, ${e.posType}: ${e.posLevel})` : ""),
|
||||||
|
position: e.position,
|
||||||
|
posType: e.posType,
|
||||||
|
posLevel: e.posLevel,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const commanderData = await (directorData.find(
|
const commanderData = await (directorData.find((x) => x.role == "commander") ?? null);
|
||||||
(x) => x.role == "commander"
|
|
||||||
) ?? null);
|
|
||||||
const commander = commanderData ? commanderData.fullname : null;
|
|
||||||
|
|
||||||
const chairmanData = await (directorData.find(
|
const commander =
|
||||||
(x) => x.role == "chairman"
|
commanderData != null
|
||||||
) ?? null);
|
? {
|
||||||
const chairman = chairmanData ? chairmanData.fullname : null;
|
personal_id: commanderData.personal_id,
|
||||||
|
dated: commanderData.dated,
|
||||||
|
name: commanderData.fullname,
|
||||||
|
label:
|
||||||
|
commanderData.fullname +
|
||||||
|
" " +
|
||||||
|
(commanderData.position
|
||||||
|
? `(${commanderData.position}, ${commanderData.posType}: ${commanderData.posLevel})`
|
||||||
|
: ""),
|
||||||
|
position: commanderData.position,
|
||||||
|
posType: commanderData.posType,
|
||||||
|
posLevel: commanderData.posLevel,
|
||||||
|
}
|
||||||
|
: null;
|
||||||
|
|
||||||
|
const chairmanData = await (directorData.find((x) => x.role == "chairman") ?? null);
|
||||||
|
const chairman =
|
||||||
|
chairmanData != null
|
||||||
|
? {
|
||||||
|
personal_id: chairmanData.personal_id,
|
||||||
|
dated: chairmanData.dated,
|
||||||
|
name: chairmanData.fullname,
|
||||||
|
label:
|
||||||
|
chairmanData.fullname +
|
||||||
|
" " +
|
||||||
|
(chairmanData.position
|
||||||
|
? `(${chairmanData.position}, ${chairmanData.posType}: ${chairmanData.posLevel})`
|
||||||
|
: ""),
|
||||||
|
position: chairmanData.position,
|
||||||
|
posType: chairmanData.posType,
|
||||||
|
posLevel: chairmanData.posLevel,
|
||||||
|
}
|
||||||
|
: null;
|
||||||
|
|
||||||
return new HttpSuccess({
|
return new HttpSuccess({
|
||||||
person: profile ? profile : null,
|
person: profile ? profile : null,
|
||||||
|
|
@ -154,7 +176,12 @@ export class EvaluateChairmanController extends Controller {
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Get("")
|
@Get("")
|
||||||
async GetEvaluate(@Query() assign_id: string, @Query() evaluate_no?: string) {
|
async GetEvaluate(
|
||||||
|
@Request() request: RequestWithUser,
|
||||||
|
@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"],
|
||||||
|
|
@ -164,7 +191,7 @@ export class EvaluateChairmanController extends Controller {
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
if (!director) {
|
if (!director) {
|
||||||
return 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;
|
||||||
|
|
@ -177,26 +204,29 @@ export class EvaluateChairmanController extends Controller {
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
evaluate = await this.evaluateChairmanRepository.findOne({
|
evaluate = await this.evaluateChairmanRepository.find({
|
||||||
where: {
|
where: {
|
||||||
director_id,
|
director_id,
|
||||||
assign_id,
|
assign_id,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (evaluate)
|
||||||
|
evaluate = await evaluate.map((element: EvaluateChairman) => ({
|
||||||
|
...element,
|
||||||
|
no: Number(element.no),
|
||||||
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!evaluate) {
|
if (!evaluate) {
|
||||||
return 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) {
|
||||||
return new HttpError(
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลแบบมอบหมายงาน");
|
||||||
HttpStatusCode.NOT_FOUND,
|
|
||||||
"ไม่พบข้อมูลแบบมอบหมายงาน"
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const experimenteeData = await this.personalRepository.find({
|
const experimenteeData = await this.personalRepository.find({
|
||||||
|
|
@ -220,36 +250,70 @@ export class EvaluateChairmanController extends Controller {
|
||||||
|
|
||||||
const directorData = await this.assignDirectorRepository.find({
|
const directorData = await this.assignDirectorRepository.find({
|
||||||
where: { assign_id },
|
where: { assign_id },
|
||||||
|
order: { ordering: "ASC" },
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!directorData) {
|
if (!directorData) {
|
||||||
return new HttpError(
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลผู้ดูแล ผู้บังคับบัญชาและประธาน");
|
||||||
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 += e.fullname;
|
|
||||||
if (index < mentorList.length - 1) {
|
mentors.push({
|
||||||
mentors += ", ";
|
personal_id: e.personal_id,
|
||||||
}
|
dated: e.dated,
|
||||||
|
name: e.fullname,
|
||||||
|
label:
|
||||||
|
e.fullname + " " + (e.position ? `(${e.position}, ${e.posType}: ${e.posLevel})` : ""),
|
||||||
|
position: e.position,
|
||||||
|
posType: e.posType,
|
||||||
|
posLevel: e.posLevel,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const commanderData = await (directorData.find(
|
const commanderData = await (directorData.find((x) => x.role == "commander") ?? null);
|
||||||
(x) => x.role == "commander"
|
|
||||||
) ?? null);
|
|
||||||
const commander = commanderData ? commanderData.fullname : null;
|
|
||||||
|
|
||||||
const chairmanData = await (directorData.find(
|
const commander =
|
||||||
(x) => x.role == "chairman"
|
commanderData != null
|
||||||
) ?? null);
|
? {
|
||||||
const chairman = chairmanData ? chairmanData.fullname : null;
|
personal_id: commanderData.personal_id,
|
||||||
|
dated: commanderData.dated,
|
||||||
|
name: commanderData.fullname,
|
||||||
|
label:
|
||||||
|
commanderData.fullname +
|
||||||
|
" " +
|
||||||
|
(commanderData.position
|
||||||
|
? `(${commanderData.position}, ${commanderData.posType}: ${commanderData.posLevel})`
|
||||||
|
: ""),
|
||||||
|
position: commanderData.position,
|
||||||
|
posType: commanderData.posType,
|
||||||
|
posLevel: commanderData.posLevel,
|
||||||
|
}
|
||||||
|
: null;
|
||||||
|
|
||||||
|
const chairmanData = await (directorData.find((x) => x.role == "chairman") ?? null);
|
||||||
|
const chairman =
|
||||||
|
chairmanData != null
|
||||||
|
? {
|
||||||
|
personal_id: chairmanData.personal_id,
|
||||||
|
dated: chairmanData.dated,
|
||||||
|
name: chairmanData.fullname,
|
||||||
|
label:
|
||||||
|
chairmanData.fullname +
|
||||||
|
" " +
|
||||||
|
(chairmanData.position
|
||||||
|
? `(${chairmanData.position}, ${chairmanData.posType}: ${chairmanData.posLevel})`
|
||||||
|
: ""),
|
||||||
|
position: chairmanData.position,
|
||||||
|
posType: chairmanData.posType,
|
||||||
|
posLevel: chairmanData.posLevel,
|
||||||
|
}
|
||||||
|
: null;
|
||||||
|
|
||||||
return new HttpSuccess({
|
return new HttpSuccess({
|
||||||
experimentee: experimentee,
|
experimentee: experimentee,
|
||||||
|
|
@ -271,8 +335,10 @@ export class EvaluateChairmanController extends Controller {
|
||||||
async PostData(
|
async PostData(
|
||||||
@Query() assign_id: string,
|
@Query() assign_id: string,
|
||||||
@Body() requestBody: CreateEvaluateChairman,
|
@Body() requestBody: CreateEvaluateChairman,
|
||||||
@Request() request: RequestWithUser
|
@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"],
|
||||||
where: {
|
where: {
|
||||||
|
|
@ -281,7 +347,7 @@ export class EvaluateChairmanController extends Controller {
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
if (!director) {
|
if (!director) {
|
||||||
return new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลผู้ดูแล");
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลผู้ดูแล");
|
||||||
}
|
}
|
||||||
|
|
||||||
const director_id = director.personal_id;
|
const director_id = director.personal_id;
|
||||||
|
|
@ -291,10 +357,7 @@ export class EvaluateChairmanController extends Controller {
|
||||||
where: { id: assign_id },
|
where: { id: assign_id },
|
||||||
});
|
});
|
||||||
if (!assign) {
|
if (!assign) {
|
||||||
return new HttpError(
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลแบบมอบหมายงาน");
|
||||||
HttpStatusCode.NOT_FOUND,
|
|
||||||
"ไม่พบข้อมูลแบบมอบหมายงาน"
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const postData: any = await {
|
const postData: any = await {
|
||||||
|
|
@ -313,9 +376,7 @@ export class EvaluateChairmanController extends Controller {
|
||||||
: 0,
|
: 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 != ""
|
requestBody.behavior_orther.text != "" ? Number(requestBody.behavior_orther.level) : 0,
|
||||||
? Number(requestBody.behavior_orther.level)
|
|
||||||
: 0,
|
|
||||||
|
|
||||||
createdUserId: request.user.sub,
|
createdUserId: request.user.sub,
|
||||||
createdFullName: request.user.name,
|
createdFullName: request.user.name,
|
||||||
|
|
@ -359,11 +420,13 @@ export class EvaluateChairmanController extends Controller {
|
||||||
*/
|
*/
|
||||||
@Put("")
|
@Put("")
|
||||||
async UpdateData(
|
async UpdateData(
|
||||||
@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");
|
||||||
|
|
||||||
let evaluate = await this.evaluateChairmanRepository.findOne({
|
let evaluate = await this.evaluateChairmanRepository.findOne({
|
||||||
where: { id: evaluate_id },
|
where: { id: evaluate_id },
|
||||||
});
|
});
|
||||||
|
|
@ -371,7 +434,7 @@ export class EvaluateChairmanController extends Controller {
|
||||||
const before = evaluate;
|
const before = evaluate;
|
||||||
|
|
||||||
if (!evaluate) {
|
if (!evaluate) {
|
||||||
return new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลการประเมิน");
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลการประเมิน");
|
||||||
}
|
}
|
||||||
|
|
||||||
evaluate.chairman_dated = requestBody.chairman_dated;
|
evaluate.chairman_dated = requestBody.chairman_dated;
|
||||||
|
|
@ -384,9 +447,7 @@ export class EvaluateChairmanController extends Controller {
|
||||||
? requestBody.achievement_other.text
|
? requestBody.achievement_other.text
|
||||||
: "";
|
: "";
|
||||||
evaluate.achievement_other_level =
|
evaluate.achievement_other_level =
|
||||||
requestBody.achievement_other.text != ""
|
requestBody.achievement_other.text != "" ? Number(requestBody.achievement_other.level) : 0;
|
||||||
? 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;
|
||||||
|
|
@ -402,24 +463,15 @@ export class EvaluateChairmanController extends Controller {
|
||||||
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 != ""
|
requestBody.behavior_orther.text != "" ? Number(requestBody.behavior_orther.level) : 0;
|
||||||
? 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 =
|
evaluate.develop_self_learning_score = requestBody.develop_self_learning_score;
|
||||||
requestBody.develop_self_learning_score;
|
evaluate.develop_training_seminar_score = requestBody.develop_training_seminar_score;
|
||||||
evaluate.develop_training_seminar_score =
|
evaluate.develop_other_training_score = requestBody.develop_other_training_score;
|
||||||
requestBody.develop_training_seminar_score;
|
evaluate.develop_orientation_percent = requestBody.develop_orientation_percent;
|
||||||
evaluate.develop_other_training_score =
|
evaluate.develop_self_learning_percent = requestBody.develop_self_learning_percent;
|
||||||
requestBody.develop_other_training_score;
|
evaluate.develop_training_seminar_percent = requestBody.develop_training_seminar_percent;
|
||||||
evaluate.develop_orientation_percent =
|
evaluate.develop_other_training_percent = requestBody.develop_other_training_percent;
|
||||||
requestBody.develop_orientation_percent;
|
|
||||||
evaluate.develop_self_learning_percent =
|
|
||||||
requestBody.develop_self_learning_percent;
|
|
||||||
evaluate.develop_training_seminar_percent =
|
|
||||||
requestBody.develop_training_seminar_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;
|
||||||
|
|
|
||||||
|
|
@ -20,27 +20,22 @@ import { AppDataSource } from "../database/data-source";
|
||||||
import { AssignDirector } from "../entities/AssignDirector";
|
import { AssignDirector } from "../entities/AssignDirector";
|
||||||
import HttpError from "../interfaces/http-error";
|
import HttpError from "../interfaces/http-error";
|
||||||
import { Assign } from "../entities/Assign";
|
import { Assign } from "../entities/Assign";
|
||||||
import {
|
import { CreateEvaluateCommander, EvaluateCommander } from "../entities/EvaluateCommander";
|
||||||
CreateEvaluateCommander,
|
|
||||||
EvaluateCommander,
|
|
||||||
} from "../entities/EvaluateCommander";
|
|
||||||
import { Personal } from "../entities/Personal";
|
import { Personal } from "../entities/Personal";
|
||||||
import CallAPI from "../interfaces/call-api";
|
import CallAPI from "../interfaces/call-api";
|
||||||
|
import permission from "../interfaces/permission";
|
||||||
@Route("api/v1/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, "สำเร็จ")
|
@SuccessResponse(HttpStatusCode.OK, "สำเร็จ")
|
||||||
export class EvaluateController extends Controller {
|
export class EvaluateController extends Controller {
|
||||||
private assignDirectorRepository =
|
private assignDirectorRepository = AppDataSource.getRepository(AssignDirector);
|
||||||
AppDataSource.getRepository(AssignDirector);
|
|
||||||
private assignRepository = AppDataSource.getRepository(Assign);
|
private assignRepository = AppDataSource.getRepository(Assign);
|
||||||
private evaluateCommanderRepository =
|
private evaluateCommanderRepository = AppDataSource.getRepository(EvaluateCommander);
|
||||||
AppDataSource.getRepository(EvaluateCommander);
|
|
||||||
private personalRepository = AppDataSource.getRepository(Personal);
|
private personalRepository = AppDataSource.getRepository(Personal);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -50,10 +45,9 @@ export class EvaluateController extends Controller {
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Get("create")
|
@Get("create")
|
||||||
async CreateEvaluate(
|
async CreateEvaluate(@Query() assign_id: string, @Request() request: RequestWithUser) {
|
||||||
@Query() assign_id: string,
|
await new permission().PermissionGet(request, "SYS_PROBATION");
|
||||||
@Request() request: RequestWithUser
|
|
||||||
) {
|
|
||||||
const director = await this.assignDirectorRepository.findOne({
|
const director = await this.assignDirectorRepository.findOne({
|
||||||
select: ["personal_id"],
|
select: ["personal_id"],
|
||||||
where: {
|
where: {
|
||||||
|
|
@ -62,7 +56,7 @@ export class EvaluateController extends Controller {
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
if (!director) {
|
if (!director) {
|
||||||
return new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลผู้ดูแล");
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลผู้ดูแล");
|
||||||
}
|
}
|
||||||
const director_id = director.personal_id;
|
const director_id = director.personal_id;
|
||||||
|
|
||||||
|
|
@ -71,10 +65,7 @@ export class EvaluateController extends Controller {
|
||||||
where: { id: assign_id },
|
where: { id: assign_id },
|
||||||
});
|
});
|
||||||
if (!assign) {
|
if (!assign) {
|
||||||
return new HttpError(
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลแบบมอบหมายงาน");
|
||||||
HttpStatusCode.NOT_FOUND,
|
|
||||||
"ไม่พบข้อมูลแบบมอบหมายงาน"
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const profile = await (assign.profile
|
const profile = await (assign.profile
|
||||||
|
|
@ -82,10 +73,7 @@ export class EvaluateController extends Controller {
|
||||||
...assign.profile,
|
...assign.profile,
|
||||||
id: assign.profile.personal_id,
|
id: assign.profile.personal_id,
|
||||||
name:
|
name:
|
||||||
assign.profile.prefixName +
|
assign.profile.prefixName + assign.profile.firstName + " " + assign.profile.lastName,
|
||||||
assign.profile.firstName +
|
|
||||||
" " +
|
|
||||||
assign.profile.lastName,
|
|
||||||
Oc: assign.profile.organization,
|
Oc: assign.profile.organization,
|
||||||
}
|
}
|
||||||
: null);
|
: null);
|
||||||
|
|
@ -102,23 +90,18 @@ export class EvaluateController extends Controller {
|
||||||
? assign.date_start
|
? assign.date_start
|
||||||
: findEndDate(evaluate_amount * 3, assign.date_start);
|
: findEndDate(evaluate_amount * 3, assign.date_start);
|
||||||
|
|
||||||
const commanderData = await this.assignDirectorRepository.find({
|
const commanderData = await this.assignDirectorRepository.findOne({
|
||||||
select: [
|
select: ["personal_id", "dated", "fullname", "position", "posType", "posLevel"],
|
||||||
"personal_id",
|
|
||||||
"dated",
|
|
||||||
"fullname",
|
|
||||||
"position",
|
|
||||||
"posType",
|
|
||||||
"posLevel",
|
|
||||||
],
|
|
||||||
where: { personal_id: director_id },
|
where: { personal_id: director_id },
|
||||||
});
|
});
|
||||||
|
if (!commanderData) {
|
||||||
const commander = await commanderData.map((element) => ({
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลผู้บังคับบัญชา");
|
||||||
...element,
|
}
|
||||||
name: element.fullname,
|
const commander = await {
|
||||||
label: `${element.fullname} (${element.position}, ${element.posType}: ${element.posLevel})`,
|
...commanderData,
|
||||||
}));
|
name: commanderData.fullname,
|
||||||
|
label: `${commanderData.fullname} (${commanderData.position}, ${commanderData.posType}: ${commanderData.posLevel})`,
|
||||||
|
};
|
||||||
|
|
||||||
return new HttpSuccess({
|
return new HttpSuccess({
|
||||||
person: profile,
|
person: profile,
|
||||||
|
|
@ -137,7 +120,13 @@ export class EvaluateController extends Controller {
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Get("")
|
@Get("")
|
||||||
async GetEvaluate(@Query() assign_id: string, @Query() evaluate_no?: string) {
|
async GetEvaluate(
|
||||||
|
@Request() request: RequestWithUser,
|
||||||
|
@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"],
|
||||||
|
|
@ -147,7 +136,7 @@ export class EvaluateController extends Controller {
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
if (!director) {
|
if (!director) {
|
||||||
return 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;
|
||||||
|
|
@ -160,26 +149,29 @@ export class EvaluateController extends Controller {
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
evaluate = await this.evaluateCommanderRepository.findOne({
|
evaluate = await this.evaluateCommanderRepository.find({
|
||||||
where: {
|
where: {
|
||||||
director_id,
|
director_id,
|
||||||
assign_id,
|
assign_id,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (evaluate)
|
||||||
|
evaluate = await evaluate.map((element: EvaluateCommander) => ({
|
||||||
|
...element,
|
||||||
|
no: Number(element.no),
|
||||||
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!evaluate) {
|
if (!evaluate) {
|
||||||
return 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) {
|
||||||
return new HttpError(
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลแบบมอบหมายงาน");
|
||||||
HttpStatusCode.NOT_FOUND,
|
|
||||||
"ไม่พบข้อมูลแบบมอบหมายงาน"
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// const profile = await (assign.profile
|
// const profile = await (assign.profile
|
||||||
|
|
@ -208,14 +200,7 @@ export class EvaluateController extends Controller {
|
||||||
// : findEndDate(evaluate_amount * 3, assign.date_start);
|
// : findEndDate(evaluate_amount * 3, assign.date_start);
|
||||||
|
|
||||||
const directorData = await this.assignDirectorRepository.find({
|
const directorData = await this.assignDirectorRepository.find({
|
||||||
select: [
|
select: ["personal_id", "dated", "fullname", "position", "posType", "posLevel"],
|
||||||
"personal_id",
|
|
||||||
"dated",
|
|
||||||
"fullname",
|
|
||||||
"position",
|
|
||||||
"posType",
|
|
||||||
"posLevel",
|
|
||||||
],
|
|
||||||
where: { personal_id: director_id },
|
where: { personal_id: director_id },
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -262,8 +247,10 @@ export class EvaluateController extends Controller {
|
||||||
async PostData(
|
async PostData(
|
||||||
@Query() assign_id: string,
|
@Query() assign_id: string,
|
||||||
@Body() requestBody: CreateEvaluateCommander,
|
@Body() requestBody: CreateEvaluateCommander,
|
||||||
@Request() request: RequestWithUser
|
@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"],
|
||||||
where: {
|
where: {
|
||||||
|
|
@ -272,7 +259,7 @@ export class EvaluateController extends Controller {
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
if (!director) {
|
if (!director) {
|
||||||
return new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลผู้ดูแล");
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลผู้ดูแล");
|
||||||
}
|
}
|
||||||
|
|
||||||
const director_id = director.personal_id;
|
const director_id = director.personal_id;
|
||||||
|
|
@ -282,10 +269,7 @@ export class EvaluateController extends Controller {
|
||||||
where: { id: assign_id },
|
where: { id: assign_id },
|
||||||
});
|
});
|
||||||
if (!assign) {
|
if (!assign) {
|
||||||
return new HttpError(
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลแบบมอบหมายงาน");
|
||||||
HttpStatusCode.NOT_FOUND,
|
|
||||||
"ไม่พบข้อมูลแบบมอบหมายงาน"
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const postData: any = await {
|
const postData: any = await {
|
||||||
|
|
@ -304,9 +288,7 @@ export class EvaluateController extends Controller {
|
||||||
: 0,
|
: 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 != ""
|
requestBody.behavior_orther.text != "" ? Number(requestBody.behavior_orther.level) : 0,
|
||||||
? Number(requestBody.behavior_orther.level)
|
|
||||||
: 0,
|
|
||||||
|
|
||||||
createdUserId: request.user.sub,
|
createdUserId: request.user.sub,
|
||||||
createdFullName: request.user.name,
|
createdFullName: request.user.name,
|
||||||
|
|
@ -350,11 +332,13 @@ export class EvaluateController extends Controller {
|
||||||
*/
|
*/
|
||||||
@Put("")
|
@Put("")
|
||||||
async UpdateData(
|
async UpdateData(
|
||||||
@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");
|
||||||
|
|
||||||
let evaluate = await this.evaluateCommanderRepository.findOne({
|
let evaluate = await this.evaluateCommanderRepository.findOne({
|
||||||
where: { id: evaluate_id },
|
where: { id: evaluate_id },
|
||||||
});
|
});
|
||||||
|
|
@ -362,7 +346,7 @@ export class EvaluateController extends Controller {
|
||||||
const before = evaluate;
|
const before = evaluate;
|
||||||
|
|
||||||
if (!evaluate) {
|
if (!evaluate) {
|
||||||
return new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลการประเมิน");
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลการประเมิน");
|
||||||
}
|
}
|
||||||
|
|
||||||
evaluate.commander_dated = requestBody.commander_dated;
|
evaluate.commander_dated = requestBody.commander_dated;
|
||||||
|
|
@ -376,9 +360,7 @@ export class EvaluateController extends Controller {
|
||||||
? requestBody.achievement_other.text
|
? requestBody.achievement_other.text
|
||||||
: "";
|
: "";
|
||||||
evaluate.achievement_other_level =
|
evaluate.achievement_other_level =
|
||||||
requestBody.achievement_other.text != ""
|
requestBody.achievement_other.text != "" ? Number(requestBody.achievement_other.level) : 0;
|
||||||
? 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;
|
||||||
|
|
@ -394,9 +376,7 @@ export class EvaluateController extends Controller {
|
||||||
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 != ""
|
requestBody.behavior_orther.text != "" ? Number(requestBody.behavior_orther.level) : 0;
|
||||||
? 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;
|
||||||
|
|
|
||||||
|
|
@ -22,34 +22,25 @@ import HttpError from "../interfaces/http-error";
|
||||||
import { Assign } from "../entities/Assign";
|
import { Assign } from "../entities/Assign";
|
||||||
import { Personal } from "../entities/Personal";
|
import { Personal } from "../entities/Personal";
|
||||||
import { AssignOutput } from "../entities/AssignOutput";
|
import { AssignOutput } from "../entities/AssignOutput";
|
||||||
import {
|
import { CreateEvaluateAssessor, EvaluateAssessor } from "../entities/EvaluateAssessor";
|
||||||
CreateEvaluateAssessor,
|
import { CreateEvaluateAchievement, EvaluateAchievement } from "../entities/EvaluateAchievement";
|
||||||
EvaluateAssessor,
|
|
||||||
} from "../entities/EvaluateAssessor";
|
|
||||||
import {
|
|
||||||
CreateEvaluateAchievement,
|
|
||||||
EvaluateAchievement,
|
|
||||||
} from "../entities/EvaluateAchievement";
|
|
||||||
import CallAPI from "../interfaces/call-api";
|
import CallAPI from "../interfaces/call-api";
|
||||||
|
import permission from "../interfaces/permission";
|
||||||
@Route("api/v1/evaluate-record")
|
@Route("api/v1/probation/evaluate-record")
|
||||||
@Tags("แบบบันทึกผล")
|
@Tags("แบบบันทึกผล")
|
||||||
@Security("bearerAuth")
|
@Security("bearerAuth")
|
||||||
@Response(
|
@Response(
|
||||||
HttpStatusCode.INTERNAL_SERVER_ERROR,
|
HttpStatusCode.INTERNAL_SERVER_ERROR,
|
||||||
"เกิดข้อผิดพลาด ไม่สามารถแสดงรายการได้ กรุณาลองใหม่ในภายหลัง"
|
"เกิดข้อผิดพลาด ไม่สามารถแสดงรายการได้ กรุณาลองใหม่ในภายหลัง",
|
||||||
)
|
)
|
||||||
@SuccessResponse(HttpStatusCode.OK, "สำเร็จ")
|
@SuccessResponse(HttpStatusCode.OK, "สำเร็จ")
|
||||||
export class EvaluateRecordController extends Controller {
|
export class EvaluateRecordController extends Controller {
|
||||||
private assignDirectorRepository =
|
private assignDirectorRepository = AppDataSource.getRepository(AssignDirector);
|
||||||
AppDataSource.getRepository(AssignDirector);
|
|
||||||
private assignRepository = AppDataSource.getRepository(Assign);
|
private assignRepository = AppDataSource.getRepository(Assign);
|
||||||
private personalRepository = AppDataSource.getRepository(Personal);
|
private personalRepository = AppDataSource.getRepository(Personal);
|
||||||
private assignOutputRepository = AppDataSource.getRepository(AssignOutput);
|
private assignOutputRepository = AppDataSource.getRepository(AssignOutput);
|
||||||
private evaluateAssessorRepository =
|
private evaluateAssessorRepository = AppDataSource.getRepository(EvaluateAssessor);
|
||||||
AppDataSource.getRepository(EvaluateAssessor);
|
private evaluateAchievementRepository = AppDataSource.getRepository(EvaluateAchievement);
|
||||||
private evaluateAchievementRepository =
|
|
||||||
AppDataSource.getRepository(EvaluateAchievement);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* API ดึงข้อมูลตอนกดสร้างแบบบันทึกผล
|
* API ดึงข้อมูลตอนกดสร้างแบบบันทึกผล
|
||||||
|
|
@ -58,19 +49,11 @@ export class EvaluateRecordController extends Controller {
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Get("create")
|
@Get("create")
|
||||||
async GetCreate(
|
async GetCreate(@Query() assign_id: string, @Request() request: RequestWithUser) {
|
||||||
@Query() assign_id: string,
|
await new permission().PermissionGet(request, "SYS_PROBATION");
|
||||||
@Request() request: RequestWithUser
|
|
||||||
) {
|
|
||||||
const directorData = await this.assignDirectorRepository.findOne({
|
const directorData = await this.assignDirectorRepository.findOne({
|
||||||
select: [
|
select: ["personal_id", "dated", "fullname", "position", "posType", "posLevel"],
|
||||||
"personal_id",
|
|
||||||
"dated",
|
|
||||||
"fullname",
|
|
||||||
"position",
|
|
||||||
"posType",
|
|
||||||
"posLevel",
|
|
||||||
],
|
|
||||||
where: {
|
where: {
|
||||||
assign_id,
|
assign_id,
|
||||||
role: "mentor",
|
role: "mentor",
|
||||||
|
|
@ -78,7 +61,7 @@ export class EvaluateRecordController extends Controller {
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!directorData) {
|
if (!directorData) {
|
||||||
return new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล");
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล");
|
||||||
}
|
}
|
||||||
|
|
||||||
const director = await {
|
const director = await {
|
||||||
|
|
@ -96,10 +79,7 @@ export class EvaluateRecordController extends Controller {
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!assign) {
|
if (!assign) {
|
||||||
return new HttpError(
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลแบบมอบหมายงาน");
|
||||||
HttpStatusCode.NOT_FOUND,
|
|
||||||
"ไม่พบข้อมูลแบบมอบหมายงาน"
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const profileData = await this.personalRepository.findOne({
|
const profileData = await this.personalRepository.findOne({
|
||||||
|
|
@ -117,16 +97,12 @@ export class EvaluateRecordController extends Controller {
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
if (!profileData) {
|
if (!profileData) {
|
||||||
return new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลบุคคล");
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลบุคคล");
|
||||||
}
|
}
|
||||||
|
|
||||||
const profile = await {
|
const profile = await {
|
||||||
id: profileData.personal_id,
|
id: profileData.personal_id,
|
||||||
name:
|
name: profileData.prefixName + profileData.firstName + " " + profileData.lastName,
|
||||||
profileData.prefixName +
|
|
||||||
profileData.firstName +
|
|
||||||
" " +
|
|
||||||
profileData.lastName,
|
|
||||||
positionName: profileData.positionName,
|
positionName: profileData.positionName,
|
||||||
positionLevelName: profileData.positionLevelName,
|
positionLevelName: profileData.positionLevelName,
|
||||||
Oc: profileData.organization,
|
Oc: profileData.organization,
|
||||||
|
|
@ -153,22 +129,12 @@ export class EvaluateRecordController extends Controller {
|
||||||
: findEndDate(evaluate_amount * 2, assign.date_start));
|
: findEndDate(evaluate_amount * 2, assign.date_start));
|
||||||
|
|
||||||
var commanderData = await this.assignDirectorRepository.findOne({
|
var commanderData = await this.assignDirectorRepository.findOne({
|
||||||
select: [
|
select: ["personal_id", "dated", "fullname", "position", "posType", "posLevel"],
|
||||||
"personal_id",
|
|
||||||
"dated",
|
|
||||||
"fullname",
|
|
||||||
"position",
|
|
||||||
"posType",
|
|
||||||
"posLevel",
|
|
||||||
],
|
|
||||||
where: { personal_id: director_id },
|
where: { personal_id: director_id },
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!commanderData) {
|
if (!commanderData) {
|
||||||
return new HttpError(
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลผู้บังคับบัญชา");
|
||||||
HttpStatusCode.NOT_FOUND,
|
|
||||||
"ไม่พบข้อมูลผู้บังคับบัญชา"
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const commander = await {
|
const commander = await {
|
||||||
|
|
@ -195,7 +161,13 @@ export class EvaluateRecordController extends Controller {
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Get("")
|
@Get("")
|
||||||
async GetData(@Query() assign_id: string, @Query() evaluate_no?: string) {
|
async GetData(
|
||||||
|
@Request() request: RequestWithUser,
|
||||||
|
@Query() assign_id: string,
|
||||||
|
@Query() evaluate_no?: string,
|
||||||
|
) {
|
||||||
|
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"],
|
||||||
where: {
|
where: {
|
||||||
|
|
@ -204,7 +176,7 @@ export class EvaluateRecordController extends Controller {
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
if (!director) {
|
if (!director) {
|
||||||
return new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลผู้ดูแล");
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลผู้ดูแล");
|
||||||
}
|
}
|
||||||
|
|
||||||
const director_id = director.personal_id;
|
const director_id = director.personal_id;
|
||||||
|
|
@ -221,23 +193,18 @@ export class EvaluateRecordController extends Controller {
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!evaluate) {
|
if (!evaluate) {
|
||||||
return new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลแบบประเมิน");
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลแบบประเมิน");
|
||||||
}
|
}
|
||||||
|
|
||||||
const achievementData = await this.evaluateAchievementRepository.find({
|
const achievementData = await this.evaluateAchievementRepository.find({
|
||||||
select: [
|
select: ["output_desc", "evaluate_expect_level", "output_desc", "evaluate_output_level"],
|
||||||
"output_desc",
|
|
||||||
"evaluate_expect_level",
|
|
||||||
"output_desc",
|
|
||||||
"evaluate_output_level",
|
|
||||||
],
|
|
||||||
where: {
|
where: {
|
||||||
evaluate_id: evaluate.id,
|
evaluate_id: evaluate.id,
|
||||||
},
|
},
|
||||||
order: { output_id: "ASC" },
|
order: { output_id: "ASC" },
|
||||||
});
|
});
|
||||||
if (!achievementData) {
|
if (!achievementData) {
|
||||||
return new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล");
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล");
|
||||||
}
|
}
|
||||||
|
|
||||||
const achievements = await achievementData.map((achievement) => {
|
const achievements = await achievementData.map((achievement) => {
|
||||||
|
|
@ -252,7 +219,7 @@ export class EvaluateRecordController extends Controller {
|
||||||
id: evaluate.id,
|
id: evaluate.id,
|
||||||
director_id: evaluate.director_id,
|
director_id: evaluate.director_id,
|
||||||
assign_id,
|
assign_id,
|
||||||
no: evaluate.no,
|
no: Number(evaluate.no),
|
||||||
date_start: evaluate.date_start,
|
date_start: evaluate.date_start,
|
||||||
date_finish: evaluate.date_finish,
|
date_finish: evaluate.date_finish,
|
||||||
assessor_dated: evaluate.assessor_dated,
|
assessor_dated: evaluate.assessor_dated,
|
||||||
|
|
@ -299,13 +266,12 @@ export class EvaluateRecordController extends Controller {
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!evaluate) {
|
if (!evaluate) {
|
||||||
return new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล");
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล");
|
||||||
}
|
}
|
||||||
|
|
||||||
await Promise.all(
|
await Promise.all(
|
||||||
evaluate.map(async (element: any, index: number) => {
|
evaluate.map(async (element: any, index: number) => {
|
||||||
const achievementData = await this.evaluateAchievementRepository.find(
|
const achievementData = await this.evaluateAchievementRepository.find({
|
||||||
{
|
|
||||||
select: [
|
select: [
|
||||||
"output_desc",
|
"output_desc",
|
||||||
"evaluate_expect_level",
|
"evaluate_expect_level",
|
||||||
|
|
@ -316,8 +282,7 @@ export class EvaluateRecordController extends Controller {
|
||||||
evaluate_id: element.id,
|
evaluate_id: element.id,
|
||||||
},
|
},
|
||||||
order: { output_id: "ASC" },
|
order: { output_id: "ASC" },
|
||||||
}
|
});
|
||||||
);
|
|
||||||
|
|
||||||
const achievements = await achievementData.map((achievement) => {
|
const achievements = await achievementData.map((achievement) => {
|
||||||
return {
|
return {
|
||||||
|
|
@ -331,7 +296,7 @@ export class EvaluateRecordController extends Controller {
|
||||||
id: element.id,
|
id: element.id,
|
||||||
director_id: element.director_id,
|
director_id: element.director_id,
|
||||||
assign_id,
|
assign_id,
|
||||||
no: element.no,
|
no: Number(element.no),
|
||||||
date_start: element.date_start,
|
date_start: element.date_start,
|
||||||
date_finish: element.date_finish,
|
date_finish: element.date_finish,
|
||||||
assessor_dated: element.assessor_dated,
|
assessor_dated: element.assessor_dated,
|
||||||
|
|
@ -368,7 +333,7 @@ export class EvaluateRecordController extends Controller {
|
||||||
updatedAt: element.updatedAt,
|
updatedAt: element.updatedAt,
|
||||||
achievements: achievements,
|
achievements: achievements,
|
||||||
};
|
};
|
||||||
})
|
}),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -379,10 +344,7 @@ export class EvaluateRecordController extends Controller {
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!assign) {
|
if (!assign) {
|
||||||
return new HttpError(
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลแบบมอบหมายงาน");
|
||||||
HttpStatusCode.NOT_FOUND,
|
|
||||||
"ไม่พบข้อมูลแบบมอบหมายงาน"
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const experimenteeData = await this.personalRepository.find({
|
const experimenteeData = await this.personalRepository.find({
|
||||||
|
|
@ -405,14 +367,7 @@ export class EvaluateRecordController extends Controller {
|
||||||
}));
|
}));
|
||||||
|
|
||||||
const directorData = await this.assignDirectorRepository.find({
|
const directorData = await this.assignDirectorRepository.find({
|
||||||
select: [
|
select: ["personal_id", "dated", "fullname", "position", "posType", "posLevel"],
|
||||||
"personal_id",
|
|
||||||
"dated",
|
|
||||||
"fullname",
|
|
||||||
"position",
|
|
||||||
"posType",
|
|
||||||
"posLevel",
|
|
||||||
],
|
|
||||||
where: { personal_id: director_id },
|
where: { personal_id: director_id },
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -440,8 +395,10 @@ export class EvaluateRecordController extends Controller {
|
||||||
async PostData(
|
async PostData(
|
||||||
@Query() assign_id: string,
|
@Query() assign_id: string,
|
||||||
@Body() requestBody: CreateEvaluateAssessor,
|
@Body() requestBody: CreateEvaluateAssessor,
|
||||||
@Request() request: RequestWithUser
|
@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"],
|
||||||
where: {
|
where: {
|
||||||
|
|
@ -450,7 +407,7 @@ export class EvaluateRecordController extends Controller {
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
if (!director) {
|
if (!director) {
|
||||||
return new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลผู้ดูแล");
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลผู้ดูแล");
|
||||||
}
|
}
|
||||||
|
|
||||||
const director_id = director.personal_id;
|
const director_id = director.personal_id;
|
||||||
|
|
@ -460,10 +417,7 @@ export class EvaluateRecordController extends Controller {
|
||||||
where: { id: assign_id },
|
where: { id: assign_id },
|
||||||
});
|
});
|
||||||
if (!assign) {
|
if (!assign) {
|
||||||
return new HttpError(
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลแบบมอบหมายงาน");
|
||||||
HttpStatusCode.NOT_FOUND,
|
|
||||||
"ไม่พบข้อมูลแบบมอบหมายงาน"
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const postData: any = await {
|
const postData: any = await {
|
||||||
|
|
@ -482,9 +436,7 @@ export class EvaluateRecordController extends Controller {
|
||||||
: 0,
|
: 0,
|
||||||
behavior_other_desc: requestBody.behavio_orther.text,
|
behavior_other_desc: requestBody.behavio_orther.text,
|
||||||
behavior_other_level:
|
behavior_other_level:
|
||||||
requestBody.behavio_orther.text != ""
|
requestBody.behavio_orther.text != "" ? Number(requestBody.behavio_orther.level) : 0,
|
||||||
? Number(requestBody.behavio_orther.level)
|
|
||||||
: 0,
|
|
||||||
behavior_strength_desc: requestBody.behavior_strength_desc,
|
behavior_strength_desc: requestBody.behavior_strength_desc,
|
||||||
behavior_improve_desc: requestBody.behavior_improve_desc,
|
behavior_improve_desc: requestBody.behavior_improve_desc,
|
||||||
orientation: requestBody.orientation,
|
orientation: requestBody.orientation,
|
||||||
|
|
@ -497,10 +449,9 @@ export class EvaluateRecordController extends Controller {
|
||||||
updateFullName: request.user.name,
|
updateFullName: request.user.name,
|
||||||
};
|
};
|
||||||
|
|
||||||
const evaluateAssessor = await this.evaluateAssessorRepository.save(
|
const evaluateAssessor = await this.evaluateAssessorRepository.save(postData, {
|
||||||
postData,
|
data: request,
|
||||||
{ data: request }
|
});
|
||||||
);
|
|
||||||
|
|
||||||
if (evaluateAssessor) {
|
if (evaluateAssessor) {
|
||||||
await Promise.all(
|
await Promise.all(
|
||||||
|
|
@ -513,9 +464,7 @@ export class EvaluateRecordController extends Controller {
|
||||||
assessor_id: director_id,
|
assessor_id: director_id,
|
||||||
evaluate_expect_level: Number(expenct.level),
|
evaluate_expect_level: Number(expenct.level),
|
||||||
output_desc: requestBody.evaluate_ouptut[index].text,
|
output_desc: requestBody.evaluate_ouptut[index].text,
|
||||||
evaluate_output_level: Number(
|
evaluate_output_level: Number(requestBody.evaluate_ouptut[index].level),
|
||||||
requestBody.evaluate_ouptut[index].level
|
|
||||||
),
|
|
||||||
createdUserId: request.user.sub,
|
createdUserId: request.user.sub,
|
||||||
createdFullName: request.user.name,
|
createdFullName: request.user.name,
|
||||||
updateUserId: request.user.sub,
|
updateUserId: request.user.sub,
|
||||||
|
|
@ -524,7 +473,7 @@ export class EvaluateRecordController extends Controller {
|
||||||
await this.evaluateAchievementRepository.save(evaluateAchievement, {
|
await this.evaluateAchievementRepository.save(evaluateAchievement, {
|
||||||
data: request,
|
data: request,
|
||||||
});
|
});
|
||||||
})
|
}),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -564,8 +513,10 @@ export class EvaluateRecordController extends Controller {
|
||||||
@Query() assign_id: string,
|
@Query() assign_id: string,
|
||||||
@Query() evaluate_id: string,
|
@Query() evaluate_id: string,
|
||||||
@Body() requestBody: CreateEvaluateAssessor,
|
@Body() requestBody: CreateEvaluateAssessor,
|
||||||
@Request() request: RequestWithUser
|
@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"],
|
||||||
where: {
|
where: {
|
||||||
|
|
@ -574,7 +525,7 @@ export class EvaluateRecordController extends Controller {
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
if (!director) {
|
if (!director) {
|
||||||
return new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลผู้ดูแล");
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลผู้ดูแล");
|
||||||
}
|
}
|
||||||
|
|
||||||
const director_id = director.personal_id;
|
const director_id = director.personal_id;
|
||||||
|
|
@ -586,7 +537,7 @@ export class EvaluateRecordController extends Controller {
|
||||||
const before = evaluate;
|
const before = evaluate;
|
||||||
|
|
||||||
if (!evaluate) {
|
if (!evaluate) {
|
||||||
return new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลการประเมิน");
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลการประเมิน");
|
||||||
}
|
}
|
||||||
|
|
||||||
evaluate.assessor_dated = requestBody.assessor_dated;
|
evaluate.assessor_dated = requestBody.assessor_dated;
|
||||||
|
|
@ -599,9 +550,7 @@ export class EvaluateRecordController extends Controller {
|
||||||
? requestBody.achievement_other.text
|
? requestBody.achievement_other.text
|
||||||
: "";
|
: "";
|
||||||
evaluate.achievement_other_level =
|
evaluate.achievement_other_level =
|
||||||
requestBody.achievement_other.text != ""
|
requestBody.achievement_other.text != "" ? Number(requestBody.achievement_other.level) : 0;
|
||||||
? Number(requestBody.achievement_other.level)
|
|
||||||
: 0;
|
|
||||||
|
|
||||||
evaluate.achievement_strength_desc = requestBody.achievement_strength_desc;
|
evaluate.achievement_strength_desc = requestBody.achievement_strength_desc;
|
||||||
evaluate.achievement_improve_desc = requestBody.achievement_improve_desc;
|
evaluate.achievement_improve_desc = requestBody.achievement_improve_desc;
|
||||||
|
|
@ -619,9 +568,7 @@ export class EvaluateRecordController extends Controller {
|
||||||
evaluate.discipline5_level = requestBody.discipline5_level;
|
evaluate.discipline5_level = requestBody.discipline5_level;
|
||||||
evaluate.behavior_other_desc = requestBody.behavio_orther.text;
|
evaluate.behavior_other_desc = requestBody.behavio_orther.text;
|
||||||
evaluate.behavior_other_level =
|
evaluate.behavior_other_level =
|
||||||
requestBody.behavio_orther.text != ""
|
requestBody.behavio_orther.text != "" ? Number(requestBody.behavio_orther.level) : 0;
|
||||||
? Number(requestBody.behavio_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;
|
||||||
|
|
@ -631,10 +578,9 @@ export class EvaluateRecordController extends Controller {
|
||||||
evaluate.updateUserId = request.user.sub;
|
evaluate.updateUserId = request.user.sub;
|
||||||
evaluate.updateFullName = request.user.name;
|
evaluate.updateFullName = request.user.name;
|
||||||
|
|
||||||
const evaluateAssessor = await this.evaluateAssessorRepository.save(
|
const evaluateAssessor = await this.evaluateAssessorRepository.save(evaluate, {
|
||||||
evaluate,
|
data: request,
|
||||||
{ data: request }
|
});
|
||||||
);
|
|
||||||
|
|
||||||
if (evaluateAssessor) {
|
if (evaluateAssessor) {
|
||||||
await this.evaluateAchievementRepository.delete({
|
await this.evaluateAchievementRepository.delete({
|
||||||
|
|
@ -649,9 +595,7 @@ export class EvaluateRecordController extends Controller {
|
||||||
assessor_id: director_id,
|
assessor_id: director_id,
|
||||||
evaluate_expect_level: Number(expenct.level),
|
evaluate_expect_level: Number(expenct.level),
|
||||||
output_desc: requestBody.evaluate_ouptut[index].text,
|
output_desc: requestBody.evaluate_ouptut[index].text,
|
||||||
evaluate_output_level: Number(
|
evaluate_output_level: Number(requestBody.evaluate_ouptut[index].level),
|
||||||
requestBody.evaluate_ouptut[index].level
|
|
||||||
),
|
|
||||||
createdUserId: request.user.sub,
|
createdUserId: request.user.sub,
|
||||||
createdFullName: request.user.name,
|
createdFullName: request.user.name,
|
||||||
updateUserId: request.user.sub,
|
updateUserId: request.user.sub,
|
||||||
|
|
@ -660,7 +604,7 @@ export class EvaluateRecordController extends Controller {
|
||||||
await this.evaluateAchievementRepository.save(evaluateAchievement, {
|
await this.evaluateAchievementRepository.save(evaluateAchievement, {
|
||||||
data: request,
|
data: request,
|
||||||
});
|
});
|
||||||
})
|
}),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -676,19 +620,11 @@ export class EvaluateRecordController extends Controller {
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Get("create/commander")
|
@Get("create/commander")
|
||||||
async GetCreateCommander(
|
async GetCreateCommander(@Query() assign_id: string, @Request() request: RequestWithUser) {
|
||||||
@Query() assign_id: string,
|
await new permission().PermissionGet(request, "SYS_PROBATION");
|
||||||
@Request() request: RequestWithUser
|
|
||||||
) {
|
|
||||||
const directorData = await this.assignDirectorRepository.findOne({
|
const directorData = await this.assignDirectorRepository.findOne({
|
||||||
select: [
|
select: ["personal_id", "dated", "fullname", "position", "posType", "posLevel"],
|
||||||
"personal_id",
|
|
||||||
"dated",
|
|
||||||
"fullname",
|
|
||||||
"position",
|
|
||||||
"posType",
|
|
||||||
"posLevel",
|
|
||||||
],
|
|
||||||
where: {
|
where: {
|
||||||
assign_id,
|
assign_id,
|
||||||
role: "commander",
|
role: "commander",
|
||||||
|
|
@ -696,7 +632,7 @@ export class EvaluateRecordController extends Controller {
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!directorData) {
|
if (!directorData) {
|
||||||
return new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล");
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล");
|
||||||
}
|
}
|
||||||
|
|
||||||
const director = await {
|
const director = await {
|
||||||
|
|
@ -714,10 +650,7 @@ export class EvaluateRecordController extends Controller {
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!assign) {
|
if (!assign) {
|
||||||
return new HttpError(
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลแบบมอบหมายงาน");
|
||||||
HttpStatusCode.NOT_FOUND,
|
|
||||||
"ไม่พบข้อมูลแบบมอบหมายงาน"
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const profileData = await this.personalRepository.findOne({
|
const profileData = await this.personalRepository.findOne({
|
||||||
|
|
@ -735,16 +668,12 @@ export class EvaluateRecordController extends Controller {
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
if (!profileData) {
|
if (!profileData) {
|
||||||
return new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลบุคคล");
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลบุคคล");
|
||||||
}
|
}
|
||||||
|
|
||||||
const profile = await {
|
const profile = await {
|
||||||
id: profileData.personal_id,
|
id: profileData.personal_id,
|
||||||
name:
|
name: profileData.prefixName + profileData.firstName + " " + profileData.lastName,
|
||||||
profileData.prefixName +
|
|
||||||
profileData.firstName +
|
|
||||||
" " +
|
|
||||||
profileData.lastName,
|
|
||||||
positionName: profileData.positionName,
|
positionName: profileData.positionName,
|
||||||
positionLevelName: profileData.positionLevelName,
|
positionLevelName: profileData.positionLevelName,
|
||||||
Oc: profileData.organization,
|
Oc: profileData.organization,
|
||||||
|
|
@ -789,9 +718,12 @@ export class EvaluateRecordController extends Controller {
|
||||||
*/
|
*/
|
||||||
@Get("commander")
|
@Get("commander")
|
||||||
async GetDataCommander(
|
async GetDataCommander(
|
||||||
|
@Request() request: RequestWithUser,
|
||||||
@Query() assign_id: string,
|
@Query() assign_id: string,
|
||||||
@Query() evaluate_no?: string
|
@Query() evaluate_no?: string,
|
||||||
) {
|
) {
|
||||||
|
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"],
|
||||||
where: {
|
where: {
|
||||||
|
|
@ -800,7 +732,7 @@ export class EvaluateRecordController extends Controller {
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
if (!director) {
|
if (!director) {
|
||||||
return new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลผู้ดูแล");
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลผู้ดูแล");
|
||||||
}
|
}
|
||||||
|
|
||||||
const director_id = director.personal_id;
|
const director_id = director.personal_id;
|
||||||
|
|
@ -817,23 +749,18 @@ export class EvaluateRecordController extends Controller {
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!evaluate) {
|
if (!evaluate) {
|
||||||
return new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลแบบประเมิน");
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลแบบประเมิน");
|
||||||
}
|
}
|
||||||
|
|
||||||
const achievementData = await this.evaluateAchievementRepository.find({
|
const achievementData = await this.evaluateAchievementRepository.find({
|
||||||
select: [
|
select: ["output_desc", "evaluate_expect_level", "output_desc", "evaluate_output_level"],
|
||||||
"output_desc",
|
|
||||||
"evaluate_expect_level",
|
|
||||||
"output_desc",
|
|
||||||
"evaluate_output_level",
|
|
||||||
],
|
|
||||||
where: {
|
where: {
|
||||||
evaluate_id: evaluate.id,
|
evaluate_id: evaluate.id,
|
||||||
},
|
},
|
||||||
order: { output_id: "ASC" },
|
order: { output_id: "ASC" },
|
||||||
});
|
});
|
||||||
if (!achievementData) {
|
if (!achievementData) {
|
||||||
return new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล");
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล");
|
||||||
}
|
}
|
||||||
|
|
||||||
const achievements = await achievementData.map((achievement) => {
|
const achievements = await achievementData.map((achievement) => {
|
||||||
|
|
@ -848,7 +775,7 @@ export class EvaluateRecordController extends Controller {
|
||||||
id: evaluate.id,
|
id: evaluate.id,
|
||||||
director_id: evaluate.director_id,
|
director_id: evaluate.director_id,
|
||||||
assign_id,
|
assign_id,
|
||||||
no: evaluate.no,
|
no: Number(evaluate.no),
|
||||||
date_start: evaluate.date_start,
|
date_start: evaluate.date_start,
|
||||||
date_finish: evaluate.date_finish,
|
date_finish: evaluate.date_finish,
|
||||||
assessor_dated: evaluate.assessor_dated,
|
assessor_dated: evaluate.assessor_dated,
|
||||||
|
|
@ -895,13 +822,12 @@ export class EvaluateRecordController extends Controller {
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!evaluate) {
|
if (!evaluate) {
|
||||||
return new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล");
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล");
|
||||||
}
|
}
|
||||||
|
|
||||||
await Promise.all(
|
await Promise.all(
|
||||||
evaluate.map(async (element: any, index: number) => {
|
evaluate.map(async (element: any, index: number) => {
|
||||||
const achievementData = await this.evaluateAchievementRepository.find(
|
const achievementData = await this.evaluateAchievementRepository.find({
|
||||||
{
|
|
||||||
select: [
|
select: [
|
||||||
"output_desc",
|
"output_desc",
|
||||||
"evaluate_expect_level",
|
"evaluate_expect_level",
|
||||||
|
|
@ -912,8 +838,7 @@ export class EvaluateRecordController extends Controller {
|
||||||
evaluate_id: element.id,
|
evaluate_id: element.id,
|
||||||
},
|
},
|
||||||
order: { output_id: "ASC" },
|
order: { output_id: "ASC" },
|
||||||
}
|
});
|
||||||
);
|
|
||||||
|
|
||||||
const achievements = await achievementData.map((achievement) => {
|
const achievements = await achievementData.map((achievement) => {
|
||||||
return {
|
return {
|
||||||
|
|
@ -927,7 +852,7 @@ export class EvaluateRecordController extends Controller {
|
||||||
id: element.id,
|
id: element.id,
|
||||||
director_id: element.director_id,
|
director_id: element.director_id,
|
||||||
assign_id,
|
assign_id,
|
||||||
no: element.no,
|
no: Number(element.no),
|
||||||
date_start: element.date_start,
|
date_start: element.date_start,
|
||||||
date_finish: element.date_finish,
|
date_finish: element.date_finish,
|
||||||
assessor_dated: element.assessor_dated,
|
assessor_dated: element.assessor_dated,
|
||||||
|
|
@ -964,7 +889,7 @@ export class EvaluateRecordController extends Controller {
|
||||||
updatedAt: element.updatedAt,
|
updatedAt: element.updatedAt,
|
||||||
achievements: achievements,
|
achievements: achievements,
|
||||||
};
|
};
|
||||||
})
|
}),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -975,10 +900,7 @@ export class EvaluateRecordController extends Controller {
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!assign) {
|
if (!assign) {
|
||||||
return new HttpError(
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลแบบมอบหมายงาน");
|
||||||
HttpStatusCode.NOT_FOUND,
|
|
||||||
"ไม่พบข้อมูลแบบมอบหมายงาน"
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const experimenteeData = await this.personalRepository.find({
|
const experimenteeData = await this.personalRepository.find({
|
||||||
|
|
@ -1001,14 +923,7 @@ export class EvaluateRecordController extends Controller {
|
||||||
}));
|
}));
|
||||||
|
|
||||||
const directorData = await this.assignDirectorRepository.find({
|
const directorData = await this.assignDirectorRepository.find({
|
||||||
select: [
|
select: ["personal_id", "dated", "fullname", "position", "posType", "posLevel"],
|
||||||
"personal_id",
|
|
||||||
"dated",
|
|
||||||
"fullname",
|
|
||||||
"position",
|
|
||||||
"posType",
|
|
||||||
"posLevel",
|
|
||||||
],
|
|
||||||
where: { personal_id: director_id },
|
where: { personal_id: director_id },
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -1036,8 +951,10 @@ export class EvaluateRecordController extends Controller {
|
||||||
async PostDataCommander(
|
async PostDataCommander(
|
||||||
@Query() assign_id: string,
|
@Query() assign_id: string,
|
||||||
@Body() requestBody: CreateEvaluateAssessor,
|
@Body() requestBody: CreateEvaluateAssessor,
|
||||||
@Request() request: RequestWithUser
|
@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"],
|
||||||
where: {
|
where: {
|
||||||
|
|
@ -1046,7 +963,7 @@ export class EvaluateRecordController extends Controller {
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
if (!director) {
|
if (!director) {
|
||||||
return new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลผู้ดูแล");
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลผู้ดูแล");
|
||||||
}
|
}
|
||||||
|
|
||||||
const director_id = director.personal_id;
|
const director_id = director.personal_id;
|
||||||
|
|
@ -1056,10 +973,7 @@ export class EvaluateRecordController extends Controller {
|
||||||
where: { id: assign_id },
|
where: { id: assign_id },
|
||||||
});
|
});
|
||||||
if (!assign) {
|
if (!assign) {
|
||||||
return new HttpError(
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลแบบมอบหมายงาน");
|
||||||
HttpStatusCode.NOT_FOUND,
|
|
||||||
"ไม่พบข้อมูลแบบมอบหมายงาน"
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const postData: any = await {
|
const postData: any = await {
|
||||||
|
|
@ -1078,9 +992,7 @@ export class EvaluateRecordController extends Controller {
|
||||||
: 0,
|
: 0,
|
||||||
behavior_other_desc: requestBody.behavio_orther.text,
|
behavior_other_desc: requestBody.behavio_orther.text,
|
||||||
behavior_other_level:
|
behavior_other_level:
|
||||||
requestBody.behavio_orther.text != ""
|
requestBody.behavio_orther.text != "" ? Number(requestBody.behavio_orther.level) : 0,
|
||||||
? Number(requestBody.behavio_orther.level)
|
|
||||||
: 0,
|
|
||||||
behavior_strength_desc: requestBody.behavior_strength_desc,
|
behavior_strength_desc: requestBody.behavior_strength_desc,
|
||||||
behavior_improve_desc: requestBody.behavior_improve_desc,
|
behavior_improve_desc: requestBody.behavior_improve_desc,
|
||||||
orientation: requestBody.orientation,
|
orientation: requestBody.orientation,
|
||||||
|
|
@ -1093,10 +1005,9 @@ export class EvaluateRecordController extends Controller {
|
||||||
updateFullName: request.user.name,
|
updateFullName: request.user.name,
|
||||||
};
|
};
|
||||||
|
|
||||||
const evaluateAssessor = await this.evaluateAssessorRepository.save(
|
const evaluateAssessor = await this.evaluateAssessorRepository.save(postData, {
|
||||||
postData,
|
data: request,
|
||||||
{ data: request }
|
});
|
||||||
);
|
|
||||||
if (evaluateAssessor) {
|
if (evaluateAssessor) {
|
||||||
await Promise.all(
|
await Promise.all(
|
||||||
requestBody.evaluate_expenct_level.map(async (expenct, index) => {
|
requestBody.evaluate_expenct_level.map(async (expenct, index) => {
|
||||||
|
|
@ -1107,9 +1018,7 @@ export class EvaluateRecordController extends Controller {
|
||||||
assessor_id: director_id,
|
assessor_id: director_id,
|
||||||
evaluate_expect_level: Number(expenct.level),
|
evaluate_expect_level: Number(expenct.level),
|
||||||
output_desc: requestBody.evaluate_ouptut[index].text,
|
output_desc: requestBody.evaluate_ouptut[index].text,
|
||||||
evaluate_output_level: Number(
|
evaluate_output_level: Number(requestBody.evaluate_ouptut[index].level),
|
||||||
requestBody.evaluate_ouptut[index].level
|
|
||||||
),
|
|
||||||
createdUserId: request.user.sub,
|
createdUserId: request.user.sub,
|
||||||
createdFullName: request.user.name,
|
createdFullName: request.user.name,
|
||||||
updateUserId: request.user.sub,
|
updateUserId: request.user.sub,
|
||||||
|
|
@ -1118,7 +1027,7 @@ export class EvaluateRecordController extends Controller {
|
||||||
await this.evaluateAchievementRepository.save(evaluateAchievement, {
|
await this.evaluateAchievementRepository.save(evaluateAchievement, {
|
||||||
data: request,
|
data: request,
|
||||||
});
|
});
|
||||||
})
|
}),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1157,8 +1066,10 @@ export class EvaluateRecordController extends Controller {
|
||||||
@Query() assign_id: string,
|
@Query() assign_id: string,
|
||||||
@Query() evaluate_id: string,
|
@Query() evaluate_id: string,
|
||||||
@Body() requestBody: CreateEvaluateAssessor,
|
@Body() requestBody: CreateEvaluateAssessor,
|
||||||
@Request() request: RequestWithUser
|
@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"],
|
||||||
where: {
|
where: {
|
||||||
|
|
@ -1167,7 +1078,7 @@ export class EvaluateRecordController extends Controller {
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
if (!director) {
|
if (!director) {
|
||||||
return new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลผู้ดูแล");
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลผู้ดูแล");
|
||||||
}
|
}
|
||||||
|
|
||||||
const director_id = director.personal_id;
|
const director_id = director.personal_id;
|
||||||
|
|
@ -1177,7 +1088,7 @@ export class EvaluateRecordController extends Controller {
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!evaluate) {
|
if (!evaluate) {
|
||||||
return new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลการประเมิน");
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลการประเมิน");
|
||||||
}
|
}
|
||||||
const before = evaluate;
|
const before = evaluate;
|
||||||
|
|
||||||
|
|
@ -1191,9 +1102,7 @@ export class EvaluateRecordController extends Controller {
|
||||||
? requestBody.achievement_other.text
|
? requestBody.achievement_other.text
|
||||||
: "";
|
: "";
|
||||||
evaluate.achievement_other_level =
|
evaluate.achievement_other_level =
|
||||||
requestBody.achievement_other.text != ""
|
requestBody.achievement_other.text != "" ? Number(requestBody.achievement_other.level) : 0;
|
||||||
? Number(requestBody.achievement_other.level)
|
|
||||||
: 0;
|
|
||||||
|
|
||||||
evaluate.achievement_strength_desc = requestBody.achievement_strength_desc;
|
evaluate.achievement_strength_desc = requestBody.achievement_strength_desc;
|
||||||
evaluate.achievement_improve_desc = requestBody.achievement_improve_desc;
|
evaluate.achievement_improve_desc = requestBody.achievement_improve_desc;
|
||||||
|
|
@ -1211,9 +1120,7 @@ export class EvaluateRecordController extends Controller {
|
||||||
evaluate.discipline5_level = requestBody.discipline5_level;
|
evaluate.discipline5_level = requestBody.discipline5_level;
|
||||||
evaluate.behavior_other_desc = requestBody.behavio_orther.text;
|
evaluate.behavior_other_desc = requestBody.behavio_orther.text;
|
||||||
evaluate.behavior_other_level =
|
evaluate.behavior_other_level =
|
||||||
requestBody.behavio_orther.text != ""
|
requestBody.behavio_orther.text != "" ? Number(requestBody.behavio_orther.level) : 0;
|
||||||
? Number(requestBody.behavio_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;
|
||||||
|
|
@ -1223,10 +1130,9 @@ export class EvaluateRecordController extends Controller {
|
||||||
evaluate.updateUserId = request.user.sub;
|
evaluate.updateUserId = request.user.sub;
|
||||||
evaluate.updateFullName = request.user.name;
|
evaluate.updateFullName = request.user.name;
|
||||||
|
|
||||||
const evaluateAssessor = await this.evaluateAssessorRepository.save(
|
const evaluateAssessor = await this.evaluateAssessorRepository.save(evaluate, {
|
||||||
evaluate,
|
data: request,
|
||||||
{ data: request }
|
});
|
||||||
);
|
|
||||||
|
|
||||||
if (evaluateAssessor) {
|
if (evaluateAssessor) {
|
||||||
await this.evaluateAchievementRepository.delete({
|
await this.evaluateAchievementRepository.delete({
|
||||||
|
|
@ -1241,9 +1147,7 @@ export class EvaluateRecordController extends Controller {
|
||||||
assessor_id: director_id,
|
assessor_id: director_id,
|
||||||
evaluate_expect_level: Number(expenct.level),
|
evaluate_expect_level: Number(expenct.level),
|
||||||
output_desc: requestBody.evaluate_ouptut[index].text,
|
output_desc: requestBody.evaluate_ouptut[index].text,
|
||||||
evaluate_output_level: Number(
|
evaluate_output_level: Number(requestBody.evaluate_ouptut[index].level),
|
||||||
requestBody.evaluate_ouptut[index].level
|
|
||||||
),
|
|
||||||
createdUserId: request.user.sub,
|
createdUserId: request.user.sub,
|
||||||
createdFullName: request.user.name,
|
createdFullName: request.user.name,
|
||||||
updateUserId: request.user.sub,
|
updateUserId: request.user.sub,
|
||||||
|
|
@ -1252,7 +1156,7 @@ export class EvaluateRecordController extends Controller {
|
||||||
await this.evaluateAchievementRepository.save(evaluateAchievement, {
|
await this.evaluateAchievementRepository.save(evaluateAchievement, {
|
||||||
data: request,
|
data: request,
|
||||||
});
|
});
|
||||||
})
|
}),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -20,35 +20,26 @@ import { AppDataSource } from "../database/data-source";
|
||||||
import { AssignDirector } from "../entities/AssignDirector";
|
import { AssignDirector } from "../entities/AssignDirector";
|
||||||
import HttpError from "../interfaces/http-error";
|
import HttpError from "../interfaces/http-error";
|
||||||
import { Assign } from "../entities/Assign";
|
import { Assign } from "../entities/Assign";
|
||||||
import {
|
|
||||||
CreateEvaluateCommander,
|
|
||||||
EvaluateCommander,
|
|
||||||
} from "../entities/EvaluateCommander";
|
|
||||||
import { Personal } from "../entities/Personal";
|
import { Personal } from "../entities/Personal";
|
||||||
import CallAPI from "../interfaces/call-api";
|
import CallAPI from "../interfaces/call-api";
|
||||||
import { EvaluateChairman } from "../entities/EvaluateChairman";
|
import { EvaluateChairman } from "../entities/EvaluateChairman";
|
||||||
import {
|
import { CreateEvaluateResult, EvaluateResult } from "../entities/EvaluateResult";
|
||||||
CreateEvaluateResult,
|
import permission from "../interfaces/permission";
|
||||||
EvaluateResult,
|
|
||||||
} from "../entities/EvaluateResult";
|
|
||||||
|
|
||||||
@Route("api/v1/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, "สำเร็จ")
|
@SuccessResponse(HttpStatusCode.OK, "สำเร็จ")
|
||||||
export class EvaluateResultController extends Controller {
|
export class EvaluateResultController extends Controller {
|
||||||
private assignDirectorRepository =
|
private assignDirectorRepository = AppDataSource.getRepository(AssignDirector);
|
||||||
AppDataSource.getRepository(AssignDirector);
|
|
||||||
private assignRepository = AppDataSource.getRepository(Assign);
|
private assignRepository = AppDataSource.getRepository(Assign);
|
||||||
private evaluateChairmanRepository =
|
private evaluateChairmanRepository = AppDataSource.getRepository(EvaluateChairman);
|
||||||
AppDataSource.getRepository(EvaluateChairman);
|
|
||||||
private personalRepository = AppDataSource.getRepository(Personal);
|
private personalRepository = AppDataSource.getRepository(Personal);
|
||||||
private evaluateResultRepository =
|
private evaluateResultRepository = AppDataSource.getRepository(EvaluateResult);
|
||||||
AppDataSource.getRepository(EvaluateResult);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* API ข้อมูลตอนกดสร้างแบบรายงานการประเมินฯ
|
* API ข้อมูลตอนกดสร้างแบบรายงานการประเมินฯ
|
||||||
|
|
@ -57,19 +48,15 @@ export class EvaluateResultController extends Controller {
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Get("create")
|
@Get("create")
|
||||||
async CreateEvaluate(
|
async CreateEvaluate(@Query() assign_id: string, @Request() request: RequestWithUser) {
|
||||||
@Query() assign_id: string,
|
await new permission().PermissionGet(request, "SYS_PROBATION");
|
||||||
@Request() request: RequestWithUser
|
|
||||||
) {
|
|
||||||
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) {
|
||||||
return new HttpError(
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลแบบมอบหมายงาน");
|
||||||
HttpStatusCode.NOT_FOUND,
|
|
||||||
"ไม่พบข้อมูลแบบมอบหมายงาน"
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const profile = await (assign.profile
|
const profile = await (assign.profile
|
||||||
|
|
@ -77,46 +64,77 @@ export class EvaluateResultController extends Controller {
|
||||||
...assign.profile,
|
...assign.profile,
|
||||||
id: assign.profile.personal_id,
|
id: assign.profile.personal_id,
|
||||||
name:
|
name:
|
||||||
assign.profile.prefixName +
|
assign.profile.prefixName + assign.profile.firstName + " " + assign.profile.lastName,
|
||||||
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" },
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!directorData) {
|
if (!directorData) {
|
||||||
return new HttpError(
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลผู้ดูแล ผู้บังคับบัญชาและประธาน");
|
||||||
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 += e.fullname;
|
|
||||||
if (index < mentorList.length - 1) {
|
mentors.push({
|
||||||
mentors += ", ";
|
personal_id: e.personal_id,
|
||||||
}
|
dated: e.dated,
|
||||||
|
name: e.fullname,
|
||||||
|
label:
|
||||||
|
e.fullname + " " + (e.position ? `(${e.position}, ${e.posType}: ${e.posLevel})` : ""),
|
||||||
|
position: e.position,
|
||||||
|
posType: e.posType,
|
||||||
|
posLevel: e.posLevel,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const commanderData = await (directorData.find(
|
const commanderData = await (directorData.find((x) => x.role == "commander") ?? null);
|
||||||
(x) => x.role == "commander"
|
|
||||||
) ?? null);
|
|
||||||
const commander = commanderData ? commanderData.fullname : null;
|
|
||||||
|
|
||||||
const chairmanData = await (directorData.find(
|
const commander =
|
||||||
(x) => x.role == "chairman"
|
commanderData != null
|
||||||
) ?? null);
|
? {
|
||||||
const chairman = chairmanData ? chairmanData.fullname : null;
|
personal_id: commanderData.personal_id,
|
||||||
|
dated: commanderData.dated,
|
||||||
|
name: commanderData.fullname,
|
||||||
|
label:
|
||||||
|
commanderData.fullname +
|
||||||
|
" " +
|
||||||
|
(commanderData.position
|
||||||
|
? `(${commanderData.position}, ${commanderData.posType}: ${commanderData.posLevel})`
|
||||||
|
: ""),
|
||||||
|
position: commanderData.position,
|
||||||
|
posType: commanderData.posType,
|
||||||
|
posLevel: commanderData.posLevel,
|
||||||
|
}
|
||||||
|
: null;
|
||||||
|
|
||||||
|
const chairmanData = await (directorData.find((x) => x.role == "chairman") ?? null);
|
||||||
|
const chairman =
|
||||||
|
chairmanData != null
|
||||||
|
? {
|
||||||
|
personal_id: chairmanData.personal_id,
|
||||||
|
dated: chairmanData.dated,
|
||||||
|
name: chairmanData.fullname,
|
||||||
|
label:
|
||||||
|
chairmanData.fullname +
|
||||||
|
" " +
|
||||||
|
(chairmanData.position
|
||||||
|
? `(${chairmanData.position}, ${chairmanData.posType}: ${chairmanData.posLevel})`
|
||||||
|
: ""),
|
||||||
|
position: chairmanData.position,
|
||||||
|
posType: chairmanData.posType,
|
||||||
|
posLevel: chairmanData.posLevel,
|
||||||
|
}
|
||||||
|
: null;
|
||||||
|
|
||||||
const resultData = await this.evaluateChairmanRepository.findOne({
|
const resultData = await this.evaluateChairmanRepository.findOne({
|
||||||
select: [
|
select: [
|
||||||
|
|
@ -131,7 +149,7 @@ export class EvaluateResultController extends Controller {
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!resultData) {
|
if (!resultData) {
|
||||||
return 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 &&
|
||||||
|
|
@ -164,7 +182,13 @@ export class EvaluateResultController extends Controller {
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Get("")
|
@Get("")
|
||||||
async GetEvaluate(@Query() assign_id: string, @Query() evaluate_no?: string) {
|
async GetEvaluate(
|
||||||
|
@Request() request: RequestWithUser,
|
||||||
|
@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"],
|
||||||
|
|
@ -174,11 +198,11 @@ export class EvaluateResultController extends Controller {
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
if (!director) {
|
if (!director) {
|
||||||
return 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.evaluateChairmanRepository.findOne({
|
const evaluate = await this.evaluateResultRepository.findOne({
|
||||||
where: {
|
where: {
|
||||||
director_id,
|
director_id,
|
||||||
assign_id,
|
assign_id,
|
||||||
|
|
@ -186,20 +210,17 @@ export class EvaluateResultController extends Controller {
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!evaluate) {
|
if (!evaluate) {
|
||||||
return new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลแบบประเมิน");
|
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) {
|
||||||
return new HttpError(
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลแบบมอบหมายงาน");
|
||||||
HttpStatusCode.NOT_FOUND,
|
|
||||||
"ไม่พบข้อมูลแบบมอบหมายงาน"
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const experimenteeData = await this.personalRepository.find({
|
const experimenteeData = await this.personalRepository.findOne({
|
||||||
select: [
|
select: [
|
||||||
"personal_id",
|
"personal_id",
|
||||||
"prefixName",
|
"prefixName",
|
||||||
|
|
@ -212,44 +233,82 @@ export class EvaluateResultController extends Controller {
|
||||||
where: { personal_id: assign.personal_id },
|
where: { personal_id: assign.personal_id },
|
||||||
});
|
});
|
||||||
|
|
||||||
const experimentee = await experimenteeData.map((element) => ({
|
if (!experimenteeData) {
|
||||||
...element,
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลบุคคล");
|
||||||
name: element.prefixName + element.firstName + " " + element.lastName,
|
}
|
||||||
Oc: element.organization,
|
const experimentee = await {
|
||||||
}));
|
...experimenteeData,
|
||||||
|
name:
|
||||||
|
experimenteeData.prefixName + experimenteeData.firstName + " " + experimenteeData.lastName,
|
||||||
|
Oc: experimenteeData.organization,
|
||||||
|
};
|
||||||
|
|
||||||
const directorData = await this.assignDirectorRepository.find({
|
const directorData = await this.assignDirectorRepository.find({
|
||||||
where: { assign_id },
|
where: { assign_id },
|
||||||
|
order: { ordering: "ASC" },
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!directorData) {
|
if (!directorData) {
|
||||||
return new HttpError(
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลผู้ดูแล ผู้บังคับบัญชาและประธาน");
|
||||||
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 += e.fullname;
|
|
||||||
if (index < mentorList.length - 1) {
|
mentors.push({
|
||||||
mentors += ", ";
|
personal_id: e.personal_id,
|
||||||
}
|
dated: e.dated,
|
||||||
|
name: e.fullname,
|
||||||
|
label:
|
||||||
|
e.fullname + " " + (e.position ? `(${e.position}, ${e.posType}: ${e.posLevel})` : ""),
|
||||||
|
position: e.position,
|
||||||
|
posType: e.posType,
|
||||||
|
posLevel: e.posLevel,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const commanderData = await (directorData.find(
|
const commanderData = await (directorData.find((x) => x.role == "commander") ?? null);
|
||||||
(x) => x.role == "commander"
|
|
||||||
) ?? null);
|
|
||||||
const commander = commanderData ? commanderData.fullname : null;
|
|
||||||
|
|
||||||
const chairmanData = await (directorData.find(
|
const commander =
|
||||||
(x) => x.role == "chairman"
|
commanderData != null
|
||||||
) ?? null);
|
? {
|
||||||
const chairman = chairmanData ? chairmanData.fullname : null;
|
personal_id: commanderData.personal_id,
|
||||||
|
dated: commanderData.dated,
|
||||||
|
name: commanderData.fullname,
|
||||||
|
label:
|
||||||
|
commanderData.fullname +
|
||||||
|
" " +
|
||||||
|
(commanderData.position
|
||||||
|
? `(${commanderData.position}, ${commanderData.posType}: ${commanderData.posLevel})`
|
||||||
|
: ""),
|
||||||
|
position: commanderData.position,
|
||||||
|
posType: commanderData.posType,
|
||||||
|
posLevel: commanderData.posLevel,
|
||||||
|
}
|
||||||
|
: null;
|
||||||
|
|
||||||
|
const chairmanData = await (directorData.find((x) => x.role == "chairman") ?? null);
|
||||||
|
const chairman =
|
||||||
|
chairmanData != null
|
||||||
|
? {
|
||||||
|
personal_id: chairmanData.personal_id,
|
||||||
|
dated: chairmanData.dated,
|
||||||
|
name: chairmanData.fullname,
|
||||||
|
label:
|
||||||
|
chairmanData.fullname +
|
||||||
|
" " +
|
||||||
|
(chairmanData.position
|
||||||
|
? `(${chairmanData.position}, ${chairmanData.posType}: ${chairmanData.posLevel})`
|
||||||
|
: ""),
|
||||||
|
position: chairmanData.position,
|
||||||
|
posType: chairmanData.posType,
|
||||||
|
posLevel: chairmanData.posLevel,
|
||||||
|
}
|
||||||
|
: null;
|
||||||
|
|
||||||
return new HttpSuccess({
|
return new HttpSuccess({
|
||||||
commander,
|
commander,
|
||||||
|
|
@ -271,8 +330,10 @@ export class EvaluateResultController extends Controller {
|
||||||
async PostData(
|
async PostData(
|
||||||
@Query() assign_id: string,
|
@Query() assign_id: string,
|
||||||
@Body() requestBody: CreateEvaluateResult,
|
@Body() requestBody: CreateEvaluateResult,
|
||||||
@Request() request: RequestWithUser
|
@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"],
|
||||||
where: {
|
where: {
|
||||||
|
|
@ -281,7 +342,7 @@ export class EvaluateResultController extends Controller {
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
if (!director) {
|
if (!director) {
|
||||||
return new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลผู้ดูแล");
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลผู้ดูแล");
|
||||||
}
|
}
|
||||||
|
|
||||||
const director_id = director.personal_id;
|
const director_id = director.personal_id;
|
||||||
|
|
@ -291,10 +352,7 @@ export class EvaluateResultController extends Controller {
|
||||||
where: { id: assign_id },
|
where: { id: assign_id },
|
||||||
});
|
});
|
||||||
if (!assign) {
|
if (!assign) {
|
||||||
return new HttpError(
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลแบบมอบหมายงาน");
|
||||||
HttpStatusCode.NOT_FOUND,
|
|
||||||
"ไม่พบข้อมูลแบบมอบหมายงาน"
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const postData: any = await {
|
const postData: any = await {
|
||||||
|
|
@ -304,8 +362,7 @@ export class EvaluateResultController extends Controller {
|
||||||
no: 1,
|
no: 1,
|
||||||
personal_id: assign.personal_id,
|
personal_id: assign.personal_id,
|
||||||
date_start: requestBody.start_date,
|
date_start: requestBody.start_date,
|
||||||
expand_month:
|
expand_month: requestBody.pass_result == 3 ? Number(requestBody.expand_month) : 0,
|
||||||
requestBody.pass_result == 3 ? Number(requestBody.expand_month) : 0,
|
|
||||||
|
|
||||||
createdUserId: request.user.sub,
|
createdUserId: request.user.sub,
|
||||||
createdFullName: request.user.name,
|
createdFullName: request.user.name,
|
||||||
|
|
@ -323,7 +380,7 @@ export class EvaluateResultController extends Controller {
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!personal) {
|
if (!personal) {
|
||||||
return new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลบุคคล");
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลบุคคล");
|
||||||
}
|
}
|
||||||
personal.probation_status =
|
personal.probation_status =
|
||||||
requestBody.pass_result == 1
|
requestBody.pass_result == 1
|
||||||
|
|
@ -366,8 +423,10 @@ export class EvaluateResultController extends Controller {
|
||||||
@Query() assign_id: string,
|
@Query() assign_id: string,
|
||||||
@Query() evaluate_id: string,
|
@Query() evaluate_id: string,
|
||||||
@Body() requestBody: CreateEvaluateResult,
|
@Body() requestBody: CreateEvaluateResult,
|
||||||
@Request() request: RequestWithUser
|
@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 },
|
||||||
});
|
});
|
||||||
|
|
@ -375,7 +434,7 @@ export class EvaluateResultController extends Controller {
|
||||||
const before = evaluate;
|
const before = evaluate;
|
||||||
|
|
||||||
if (!evaluate) {
|
if (!evaluate) {
|
||||||
return new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลการประเมิน");
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลการประเมิน");
|
||||||
}
|
}
|
||||||
|
|
||||||
evaluate.date_start = requestBody.start_date;
|
evaluate.date_start = requestBody.start_date;
|
||||||
|
|
@ -383,7 +442,9 @@ export class EvaluateResultController extends Controller {
|
||||||
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 == 3 ? requestBody.expand_month : 0;
|
requestBody.pass_result && requestBody.pass_result == 3
|
||||||
|
? Number(requestBody.expand_month)
|
||||||
|
: 0;
|
||||||
evaluate.reson = requestBody.reson;
|
evaluate.reson = requestBody.reson;
|
||||||
evaluate.chairman_dated = requestBody.chairman_dated;
|
evaluate.chairman_dated = requestBody.chairman_dated;
|
||||||
|
|
||||||
|
|
@ -400,17 +461,14 @@ export class EvaluateResultController extends Controller {
|
||||||
where: { id: assign_id },
|
where: { id: assign_id },
|
||||||
});
|
});
|
||||||
if (!assign) {
|
if (!assign) {
|
||||||
return new HttpError(
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลแบบมอบหมายงาน");
|
||||||
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) {
|
||||||
return new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลบุคคล");
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลบุคคล");
|
||||||
}
|
}
|
||||||
personal.probation_status =
|
personal.probation_status =
|
||||||
requestBody.pass_result == 1
|
requestBody.pass_result == 1
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,11 @@
|
||||||
import { Controller, Get, Route, Security, Tags } from "tsoa";
|
import { Controller, Get, Route, Tags } from "tsoa";
|
||||||
|
|
||||||
@Route("/hello")
|
@Route("/probation/hello")
|
||||||
@Tags("Test")
|
@Tags("Test")
|
||||||
@Security("bearerAuth")
|
// @Security("bearerAuth")
|
||||||
export class AppController extends Controller {
|
export class AppController extends Controller {
|
||||||
@Get()
|
@Get()
|
||||||
public async GET() {
|
public async GET() {
|
||||||
return { message: "Hello Development" };
|
return { message: "Hello Probation System" };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -21,12 +21,12 @@ import { Personal, PostPersonal } from "../entities/Personal";
|
||||||
import permission from "../interfaces/permission";
|
import permission from "../interfaces/permission";
|
||||||
import { Assign } from "../entities/Assign";
|
import { Assign } from "../entities/Assign";
|
||||||
|
|
||||||
@Route("api/v1/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, "สำเร็จ")
|
@SuccessResponse(HttpStatusCode.OK, "สำเร็จ")
|
||||||
export class PersonalController extends Controller {
|
export class PersonalController extends Controller {
|
||||||
|
|
@ -40,43 +40,25 @@ export class PersonalController extends Controller {
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Post("add")
|
@Post("add")
|
||||||
async AddPersonal(
|
async AddPersonal(@Body() requestBody: PostPersonal, @Request() request: RequestWithUser) {
|
||||||
@Body() requestBody: PostPersonal,
|
|
||||||
@Request() request: RequestWithUser
|
|
||||||
) {
|
|
||||||
await new permission().PermissionCreate(request, "SYS_PROBATION");
|
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) {
|
||||||
return 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.probation_status = 1;
|
||||||
personalData.createdUserId = request.user.sub;
|
personalData.createdUserId = request.user.sub;
|
||||||
personalData.createdFullName = request.user.name;
|
personalData.createdFullName = request.user.name;
|
||||||
|
|
@ -87,12 +69,8 @@ export class PersonalController extends Controller {
|
||||||
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.positionName = requestBody.position
|
|
||||||
? requestBody.position
|
|
||||||
: "";
|
|
||||||
personalData.positionLineName = requestBody.posLineName;
|
personalData.positionLineName = requestBody.posLineName;
|
||||||
personalData.positionTypeName = requestBody.posTypeName;
|
personalData.positionTypeName = requestBody.posTypeName;
|
||||||
personalData.posNo = requestBody.posNo ? requestBody.posNo : "";
|
personalData.posNo = requestBody.posNo ? requestBody.posNo : "";
|
||||||
|
|
@ -135,10 +113,7 @@ export class PersonalController extends Controller {
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!lists) {
|
if (!lists) {
|
||||||
return new HttpError(
|
throw new HttpError(HttpStatusCode.INTERNAL_SERVER_ERROR, "ไม่สามารถแสดงข้อมูลได้");
|
||||||
HttpStatusCode.INTERNAL_SERVER_ERROR,
|
|
||||||
"ไม่สามารถแสดงข้อมูลได้"
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let result: any = [];
|
let result: any = [];
|
||||||
|
|
@ -163,7 +138,7 @@ export class PersonalController extends Controller {
|
||||||
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 });
|
||||||
|
|
@ -176,17 +151,14 @@ 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().PermissionList(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) {
|
||||||
return 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({
|
||||||
|
|
|
||||||
|
|
@ -1,54 +1,35 @@
|
||||||
import {
|
import { Controller, Route, Security, Tags, Body, Request, SuccessResponse, Response, Get, Query, Put, Post } 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"
|
||||||
Body,
|
import { RequestWithUser } from "../middlewares/user"
|
||||||
Request,
|
import { DataPass, setLogDataDiff } from "../interfaces/utils"
|
||||||
SuccessResponse,
|
import { Personal } from "../entities/Personal"
|
||||||
Response,
|
import { Assign } from "../entities/Assign"
|
||||||
Get,
|
import { EvaluateChairman } from "../entities/EvaluateChairman"
|
||||||
Query,
|
import { EvaluateResult } from "../entities/EvaluateResult"
|
||||||
Put,
|
import { EvaluateAssessor } from "../entities/EvaluateAssessor"
|
||||||
} from "tsoa";
|
import { AssignDirector } from "../entities/AssignDirector"
|
||||||
import { AppDataSource } from "../database/data-source";
|
import { EvaluateAchievement } from "../entities/EvaluateAchievement"
|
||||||
import HttpSuccess from "../interfaces/http-success";
|
import { EvaluateCommander } from "../entities/EvaluateCommander"
|
||||||
import HttpStatusCode from "../interfaces/http-status";
|
import CallAPI from "../interfaces/call-api"
|
||||||
import HttpError from "../interfaces/http-error";
|
import { Double, In } from "typeorm"
|
||||||
import { RequestWithUser } from "../middlewares/user";
|
import Extension from "../interfaces/extension"
|
||||||
import { DataPass, setLogDataDiff } from "../interfaces/utils";
|
|
||||||
import { Personal } from "../entities/Personal";
|
|
||||||
import { Assign } from "../entities/Assign";
|
|
||||||
import { EvaluateChairman } from "../entities/EvaluateChairman";
|
|
||||||
import { EvaluateResult } from "../entities/EvaluateResult";
|
|
||||||
import { EvaluateAssessor } from "../entities/EvaluateAssessor";
|
|
||||||
import { AssignDirector } from "../entities/AssignDirector";
|
|
||||||
import { EvaluateAchievement } from "../entities/EvaluateAchievement";
|
|
||||||
import { EvaluateCommander } from "../entities/EvaluateCommander";
|
|
||||||
import CallAPI from "../interfaces/call-api";
|
|
||||||
|
|
||||||
@Route("api/v1/report")
|
@Route("api/v1/probation/report")
|
||||||
@Tags("Report")
|
@Tags("Report")
|
||||||
@Security("bearerAuth")
|
@Security("bearerAuth")
|
||||||
@Response(
|
@Response(HttpStatusCode.INTERNAL_SERVER_ERROR, "เกิดข้อผิดพลาด ไม่สามารถแสดงรายการได้ กรุณาลองใหม่ในภายหลัง")
|
||||||
HttpStatusCode.INTERNAL_SERVER_ERROR,
|
|
||||||
"เกิดข้อผิดพลาด ไม่สามารถแสดงรายการได้ กรุณาลองใหม่ในภายหลัง"
|
|
||||||
)
|
|
||||||
@SuccessResponse(HttpStatusCode.OK, "สำเร็จ")
|
@SuccessResponse(HttpStatusCode.OK, "สำเร็จ")
|
||||||
export class ReportController extends Controller {
|
export class ReportController extends Controller {
|
||||||
private evaluateChairmanRepository =
|
private evaluateChairmanRepository = AppDataSource.getRepository(EvaluateChairman)
|
||||||
AppDataSource.getRepository(EvaluateChairman);
|
private evaluateResultRepository = AppDataSource.getRepository(EvaluateResult)
|
||||||
private evaluateResultRepository =
|
private personalRepository = AppDataSource.getRepository(Personal)
|
||||||
AppDataSource.getRepository(EvaluateResult);
|
private evaluateAssessorRepository = AppDataSource.getRepository(EvaluateAssessor)
|
||||||
private personalRepository = AppDataSource.getRepository(Personal);
|
private assignDirectorRepository = AppDataSource.getRepository(AssignDirector)
|
||||||
private evaluateAssessorRepository =
|
private evaluateAchievementRepository = AppDataSource.getRepository(EvaluateAchievement)
|
||||||
AppDataSource.getRepository(EvaluateAssessor);
|
private evaluateCommanderRepository = AppDataSource.getRepository(EvaluateCommander)
|
||||||
private assignDirectorRepository =
|
|
||||||
AppDataSource.getRepository(AssignDirector);
|
|
||||||
private evaluateAchievementRepository =
|
|
||||||
AppDataSource.getRepository(EvaluateAchievement);
|
|
||||||
private evaluateCommanderRepository =
|
|
||||||
AppDataSource.getRepository(EvaluateCommander);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* API สำหรับออกรายงาน
|
* API สำหรับออกรายงาน
|
||||||
|
|
@ -57,37 +38,27 @@ export class ReportController extends Controller {
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Get("")
|
@Get("")
|
||||||
async GetReport(
|
async GetReport(@Query() assign_id: string) {
|
||||||
@Query() assign_id: string,
|
|
||||||
@Request() request: RequestWithUser
|
|
||||||
) {
|
|
||||||
const evaluate = await this.evaluateChairmanRepository.findOne({
|
const evaluate = await this.evaluateChairmanRepository.findOne({
|
||||||
where: { assign_id },
|
where: { assign_id },
|
||||||
});
|
})
|
||||||
|
|
||||||
const result = await this.evaluateResultRepository.findOne({
|
const result = await this.evaluateResultRepository.findOne({
|
||||||
where: { assign_id },
|
where: { assign_id },
|
||||||
});
|
})
|
||||||
|
|
||||||
if (!evaluate || !result) {
|
if (!evaluate || !result) {
|
||||||
return new HttpError(
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลผลการทดลองปฏิบัติราชการ")
|
||||||
HttpStatusCode.NOT_FOUND,
|
|
||||||
"ไม่พบข้อมูลผลการทดลองปฏิบัติราชการ"
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const develop_total_score = await (Number(
|
const develop_total_score = await (Number(evaluate.develop_orientation_score) +
|
||||||
evaluate.develop_orientation_score
|
|
||||||
) +
|
|
||||||
Number(evaluate.develop_self_learning_score) +
|
Number(evaluate.develop_self_learning_score) +
|
||||||
Number(evaluate.develop_training_seminar_score) +
|
Number(evaluate.develop_training_seminar_score) +
|
||||||
Number(evaluate.develop_other_training_score));
|
Number(evaluate.develop_other_training_score))
|
||||||
const develop_total_percent = await (Number(
|
const develop_total_percent = await (Number(evaluate.develop_orientation_percent) +
|
||||||
evaluate.develop_orientation_percent
|
|
||||||
) +
|
|
||||||
Number(evaluate.develop_orientation_percent) +
|
Number(evaluate.develop_orientation_percent) +
|
||||||
Number(evaluate.develop_self_learning_percent) +
|
Number(evaluate.develop_self_learning_percent) +
|
||||||
Number(evaluate.develop_training_seminar_percent));
|
Number(evaluate.develop_training_seminar_percent))
|
||||||
|
|
||||||
const data = await {
|
const data = await {
|
||||||
develop_orientation_score: evaluate.develop_orientation_score,
|
develop_orientation_score: evaluate.develop_orientation_score,
|
||||||
|
|
@ -97,8 +68,7 @@ export class ReportController extends Controller {
|
||||||
develop_total_score,
|
develop_total_score,
|
||||||
develop_orientation_percent: evaluate.develop_orientation_percent,
|
develop_orientation_percent: evaluate.develop_orientation_percent,
|
||||||
develop_self_learning_percent: evaluate.develop_self_learning_percent,
|
develop_self_learning_percent: evaluate.develop_self_learning_percent,
|
||||||
develop_training_seminar_percent:
|
develop_training_seminar_percent: evaluate.develop_training_seminar_percent,
|
||||||
evaluate.develop_training_seminar_percent,
|
|
||||||
develop_other_training_percent: evaluate.develop_other_training_percent,
|
develop_other_training_percent: evaluate.develop_other_training_percent,
|
||||||
develop_total_percent,
|
develop_total_percent,
|
||||||
develop_result: evaluate.develop_result,
|
develop_result: evaluate.develop_result,
|
||||||
|
|
@ -115,9 +85,9 @@ export class ReportController extends Controller {
|
||||||
reason: result.reson,
|
reason: result.reson,
|
||||||
pass_result: result.pass_result,
|
pass_result: result.pass_result,
|
||||||
evaluate_date: result.chairman_dated,
|
evaluate_date: result.chairman_dated,
|
||||||
};
|
}
|
||||||
|
|
||||||
return new HttpSuccess(data);
|
return new HttpSuccess(data)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -127,18 +97,18 @@ export class ReportController extends Controller {
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Get("pass")
|
@Get("pass")
|
||||||
async GetPass(@Request() request: RequestWithUser) {
|
async GetPass() {
|
||||||
const lists = await this.personalRepository.find({
|
const lists = await this.personalRepository.find({
|
||||||
where: { probation_status: 2 },
|
where: { probation_status: 2 },
|
||||||
});
|
})
|
||||||
|
|
||||||
let data: DataPass[] = [];
|
let data: DataPass[] = []
|
||||||
await Promise.all(
|
await Promise.all(
|
||||||
lists.map(async (list) => {
|
lists.map(async list => {
|
||||||
const assign = await AppDataSource.getRepository(Assign).findOne({
|
const assign = await AppDataSource.getRepository(Assign).findOne({
|
||||||
select: ["date_start", "date_finish"],
|
select: ["date_start", "date_finish"],
|
||||||
where: { personal_id: list.personal_id },
|
where: { personal_id: list.personal_id },
|
||||||
});
|
})
|
||||||
|
|
||||||
if (assign)
|
if (assign)
|
||||||
data.push({
|
data.push({
|
||||||
|
|
@ -147,11 +117,11 @@ export class ReportController extends Controller {
|
||||||
name: `${list.prefixName}${list.firstName} ${list.lastName}`,
|
name: `${list.prefixName}${list.firstName} ${list.lastName}`,
|
||||||
},
|
},
|
||||||
assign,
|
assign,
|
||||||
});
|
|
||||||
})
|
})
|
||||||
);
|
})
|
||||||
|
)
|
||||||
|
|
||||||
return new HttpSuccess(data);
|
return new HttpSuccess(data)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -161,18 +131,18 @@ export class ReportController extends Controller {
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Get("not-pass")
|
@Get("not-pass")
|
||||||
async GetDataNotPass(@Request() request: RequestWithUser) {
|
async GetDataNotPass() {
|
||||||
const lists = await this.personalRepository.find({
|
const lists = await this.personalRepository.find({
|
||||||
where: { probation_status: 3 },
|
where: { probation_status: 3 },
|
||||||
});
|
})
|
||||||
|
|
||||||
let data: DataPass[] = [];
|
let data: DataPass[] = []
|
||||||
await Promise.all(
|
await Promise.all(
|
||||||
lists.map(async (list) => {
|
lists.map(async list => {
|
||||||
const assign = await AppDataSource.getRepository(Assign).findOne({
|
const assign = await AppDataSource.getRepository(Assign).findOne({
|
||||||
select: ["date_start", "date_finish"],
|
select: ["date_start", "date_finish"],
|
||||||
where: { personal_id: list.personal_id },
|
where: { personal_id: list.personal_id },
|
||||||
});
|
})
|
||||||
|
|
||||||
if (assign)
|
if (assign)
|
||||||
data.push({
|
data.push({
|
||||||
|
|
@ -181,11 +151,11 @@ export class ReportController extends Controller {
|
||||||
name: `${list.prefixName}${list.firstName} ${list.lastName}`,
|
name: `${list.prefixName}${list.firstName} ${list.lastName}`,
|
||||||
},
|
},
|
||||||
assign,
|
assign,
|
||||||
});
|
|
||||||
})
|
})
|
||||||
);
|
})
|
||||||
|
)
|
||||||
|
|
||||||
return new HttpSuccess(data);
|
return new HttpSuccess(data)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -195,13 +165,13 @@ export class ReportController extends Controller {
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Get("expand")
|
@Get("expand")
|
||||||
async GetDataExpand(@Request() request: RequestWithUser) {
|
async GetDataExpand() {
|
||||||
const lists = await this.personalRepository.find({
|
const data = await this.personalRepository.find({
|
||||||
select: ["personal_id"],
|
select: ["personal_id"],
|
||||||
where: { probation_status: 7 },
|
where: { probation_status: 7 },
|
||||||
});
|
})
|
||||||
|
|
||||||
return new HttpSuccess(lists);
|
return new HttpSuccess(data)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -211,30 +181,25 @@ export class ReportController extends Controller {
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Put("status")
|
@Put("status")
|
||||||
async UpdateStatus(
|
async UpdateStatus(@Query() personal_id: string, @Body() requestBody: { command_no: string }, @Request() request: RequestWithUser) {
|
||||||
@Query() personal_id: string,
|
|
||||||
@Body() requestBody: { command_no: string },
|
|
||||||
@Request() request: RequestWithUser
|
|
||||||
) {
|
|
||||||
const personal = await this.personalRepository.findOne({
|
const personal = await this.personalRepository.findOne({
|
||||||
where: { personal_id },
|
where: { personal_id },
|
||||||
});
|
})
|
||||||
const before = personal;
|
const before = personal
|
||||||
|
|
||||||
if (!personal) {
|
if (!personal) {
|
||||||
return new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลบุคคล");
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลบุคคล")
|
||||||
}
|
}
|
||||||
|
|
||||||
personal.order_number = requestBody.command_no;
|
personal.order_number = requestBody.command_no
|
||||||
personal.probation_status = 8;
|
personal.probation_status = 8
|
||||||
|
personal.updateFullName = request.user.name
|
||||||
|
personal.updateUserId = request.user.sub
|
||||||
|
|
||||||
this.personalRepository.save(personal, { data: request });
|
this.personalRepository.save(personal, { data: request })
|
||||||
setLogDataDiff(request, { before, after: personal });
|
setLogDataDiff(request, { before, after: personal })
|
||||||
|
|
||||||
const resultText =
|
const resultText = (await personal.probation_status) === 2 ? "ไม่ต่ำกว่ามาตรฐานที่กำหนด เห็นควรให้รับราชการต่อ" : "ต่ำกว่ามาตรฐานที่กำหนด เห็นควรให้ออกจากราชการ"
|
||||||
(await personal.probation_status) === 2
|
|
||||||
? "ไม่ต่ำกว่ามาตรฐานที่กำหนด เห็นควรให้รับราชการต่อ"
|
|
||||||
: "ต่ำกว่ามาตรฐานที่กำหนด เห็นควรให้ออกจากราชการ";
|
|
||||||
|
|
||||||
await new CallAPI()
|
await new CallAPI()
|
||||||
.PostData(request, "/placement/noti", {
|
.PostData(request, "/placement/noti", {
|
||||||
|
|
@ -246,11 +211,11 @@ export class ReportController 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)
|
||||||
});
|
})
|
||||||
|
|
||||||
return new HttpSuccess();
|
return new HttpSuccess()
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -260,25 +225,24 @@ export class ReportController extends Controller {
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Put("change-status")
|
@Put("change-status")
|
||||||
async ChangeStatus(
|
async ChangeStatus(@Query() personal_id: string, @Body() reqBody: { status: number }, @Request() request: RequestWithUser) {
|
||||||
@Query() personal_id: string,
|
const personal = await this.personalRepository.findOne({
|
||||||
@Body() reqBody: { status: number },
|
|
||||||
@Request() request: RequestWithUser
|
|
||||||
) {
|
|
||||||
const person = await this.personalRepository.findOne({
|
|
||||||
where: { personal_id },
|
where: { personal_id },
|
||||||
});
|
})
|
||||||
const before = person;
|
const before = personal
|
||||||
|
|
||||||
if (!person) {
|
if (!personal) {
|
||||||
return new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลบุคคล");
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลบุคคล")
|
||||||
}
|
}
|
||||||
|
|
||||||
person.probation_status = await reqBody.status;
|
personal.probation_status = await reqBody.status
|
||||||
await this.personalRepository.save(person, { data: request });
|
personal.updateFullName = request.user.name
|
||||||
setLogDataDiff(request, { before, after: person });
|
personal.updateUserId = request.user.sub
|
||||||
|
|
||||||
return new HttpSuccess();
|
await this.personalRepository.save(personal, { data: request })
|
||||||
|
setLogDataDiff(request, { before, after: personal })
|
||||||
|
|
||||||
|
return new HttpSuccess()
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -288,60 +252,49 @@ export class ReportController extends Controller {
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Get("form-record")
|
@Get("form-record")
|
||||||
async GetDataFormRecord(
|
async GetDataFormRecord(@Query() id: string) {
|
||||||
@Query() id: string,
|
|
||||||
@Request() request: RequestWithUser
|
|
||||||
) {
|
|
||||||
const evaluate = await this.evaluateAssessorRepository.findOne({
|
const evaluate = await this.evaluateAssessorRepository.findOne({
|
||||||
where: { id },
|
where: { id },
|
||||||
});
|
})
|
||||||
|
|
||||||
if (!evaluate) {
|
if (!evaluate) {
|
||||||
return new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล");
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล")
|
||||||
}
|
}
|
||||||
|
|
||||||
const directorData = await this.assignDirectorRepository.findOne({
|
const directorData = await this.assignDirectorRepository.findOne({
|
||||||
select: [
|
select: ["personal_id", "fullname", "position", "posType", "posLevel", "role", "dated"],
|
||||||
"personal_id",
|
|
||||||
"fullname",
|
|
||||||
"position",
|
|
||||||
"posType",
|
|
||||||
"posLevel",
|
|
||||||
"role",
|
|
||||||
"dated",
|
|
||||||
],
|
|
||||||
where: { personal_id: evaluate.director_id },
|
where: { personal_id: evaluate.director_id },
|
||||||
});
|
})
|
||||||
|
|
||||||
if (!directorData) {
|
if (!directorData) {
|
||||||
return new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล");
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล")
|
||||||
}
|
}
|
||||||
|
|
||||||
const director = await {
|
const director = await {
|
||||||
...directorData,
|
...directorData,
|
||||||
name: directorData.fullname,
|
name: directorData.fullname,
|
||||||
position: directorData.position,
|
position: directorData.position,
|
||||||
};
|
}
|
||||||
|
|
||||||
const achievements = await this.evaluateAchievementRepository.find({
|
const achievements = await this.evaluateAchievementRepository.find({
|
||||||
select: ["evaluate_expect_level", "evaluate_output_level"],
|
select: ["evaluate_expect_level", "evaluate_output_level"],
|
||||||
where: { evaluate_id: evaluate.id },
|
where: { evaluate_id: evaluate.id },
|
||||||
});
|
})
|
||||||
|
|
||||||
if (!achievements) {
|
if (!achievements) {
|
||||||
return new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล");
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล")
|
||||||
}
|
}
|
||||||
|
|
||||||
let achievement: any = [];
|
let achievement: any = []
|
||||||
await Promise.all(
|
await Promise.all(
|
||||||
achievements.map(async (element) => {
|
achievements.map(async element => {
|
||||||
const evaluate_expect_level = await {
|
const evaluate_expect_level = await {
|
||||||
col1: element.evaluate_expect_level == 1 ? "/" : "",
|
col1: element.evaluate_expect_level == 1 ? "/" : "",
|
||||||
col2: element.evaluate_expect_level == 2 ? "/" : "",
|
col2: element.evaluate_expect_level == 2 ? "/" : "",
|
||||||
col3: element.evaluate_expect_level == 3 ? "/" : "",
|
col3: element.evaluate_expect_level == 3 ? "/" : "",
|
||||||
col4: element.evaluate_expect_level == 4 ? "/" : "",
|
col4: element.evaluate_expect_level == 4 ? "/" : "",
|
||||||
col5: element.evaluate_expect_level == 5 ? "/" : "",
|
col5: element.evaluate_expect_level == 5 ? "/" : "",
|
||||||
};
|
}
|
||||||
|
|
||||||
const evaluate_output_level = await {
|
const evaluate_output_level = await {
|
||||||
col1: element.evaluate_output_level == 1 ? "/" : "",
|
col1: element.evaluate_output_level == 1 ? "/" : "",
|
||||||
|
|
@ -349,15 +302,15 @@ export class ReportController extends Controller {
|
||||||
col3: element.evaluate_output_level == 3 ? "/" : "",
|
col3: element.evaluate_output_level == 3 ? "/" : "",
|
||||||
col4: element.evaluate_output_level == 4 ? "/" : "",
|
col4: element.evaluate_output_level == 4 ? "/" : "",
|
||||||
col5: element.evaluate_output_level == 5 ? "/" : "",
|
col5: element.evaluate_output_level == 5 ? "/" : "",
|
||||||
};
|
}
|
||||||
|
|
||||||
achievement.push({
|
achievement.push({
|
||||||
...element,
|
...element,
|
||||||
evaluate_expect_level,
|
evaluate_expect_level,
|
||||||
evaluate_output_level,
|
evaluate_output_level,
|
||||||
});
|
|
||||||
})
|
})
|
||||||
);
|
})
|
||||||
|
)
|
||||||
|
|
||||||
const evaluateData = await {
|
const evaluateData = await {
|
||||||
id: evaluate.id,
|
id: evaluate.id,
|
||||||
|
|
@ -531,25 +484,25 @@ export class ReportController extends Controller {
|
||||||
updatedAt: evaluate.updatedAt,
|
updatedAt: evaluate.updatedAt,
|
||||||
achievements: achievement,
|
achievements: achievement,
|
||||||
role: director.role,
|
role: director.role,
|
||||||
};
|
}
|
||||||
|
|
||||||
const assign = await AppDataSource.getRepository(Assign).findOne({
|
const assign = await AppDataSource.getRepository(Assign).findOne({
|
||||||
select: ["id", "personal_id", "round_no", "date_start", "date_finish"],
|
select: ["id", "personal_id", "round_no", "date_start", "date_finish"],
|
||||||
where: { id: evaluate.assign_id },
|
where: { id: evaluate.assign_id },
|
||||||
});
|
})
|
||||||
|
|
||||||
if (!assign) {
|
if (!assign) {
|
||||||
return new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล");
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล")
|
||||||
}
|
}
|
||||||
|
|
||||||
const experimenteeData = await this.personalRepository.findOne({
|
const experimenteeData = await this.personalRepository.findOne({
|
||||||
where: {
|
where: {
|
||||||
personal_id: assign.personal_id,
|
personal_id: assign.personal_id,
|
||||||
},
|
},
|
||||||
});
|
})
|
||||||
|
|
||||||
if (!experimenteeData) {
|
if (!experimenteeData) {
|
||||||
return new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล");
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล")
|
||||||
}
|
}
|
||||||
|
|
||||||
const experimentee = await {
|
const experimentee = await {
|
||||||
|
|
@ -561,15 +514,15 @@ export class ReportController extends Controller {
|
||||||
Department: "-",
|
Department: "-",
|
||||||
OrganizationOrganization: experimenteeData.orgRootName,
|
OrganizationOrganization: experimenteeData.orgRootName,
|
||||||
Oc: experimenteeData.organization,
|
Oc: experimenteeData.organization,
|
||||||
};
|
}
|
||||||
|
|
||||||
const data = await {
|
const data = await {
|
||||||
experimentee: experimentee ? experimentee : null,
|
experimentee: experimentee ? experimentee : null,
|
||||||
director: director ? director : null,
|
director: director ? director : null,
|
||||||
assign,
|
assign,
|
||||||
evaluate: evaluateData,
|
evaluate: evaluateData,
|
||||||
};
|
}
|
||||||
return new HttpSuccess(data);
|
return new HttpSuccess(data)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -579,16 +532,13 @@ export class ReportController extends Controller {
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Get("evaluate-commander")
|
@Get("evaluate-commander")
|
||||||
async GetDataEvaluateCommander(
|
async GetDataEvaluateCommander(@Query() id: string, @Request() request: RequestWithUser) {
|
||||||
@Query() id: string,
|
|
||||||
@Request() request: RequestWithUser
|
|
||||||
) {
|
|
||||||
const evaluate = await this.evaluateCommanderRepository.findOne({
|
const evaluate = await this.evaluateCommanderRepository.findOne({
|
||||||
where: { id },
|
where: { id },
|
||||||
});
|
})
|
||||||
|
|
||||||
if (!evaluate) {
|
if (!evaluate) {
|
||||||
return new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล");
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล")
|
||||||
}
|
}
|
||||||
|
|
||||||
const evaluateData = await {
|
const evaluateData = await {
|
||||||
|
|
@ -765,25 +715,25 @@ export class ReportController extends Controller {
|
||||||
other_training: evaluate.other_training,
|
other_training: evaluate.other_training,
|
||||||
createdAt: evaluate.createdAt,
|
createdAt: evaluate.createdAt,
|
||||||
updatedAt: evaluate.updatedAt,
|
updatedAt: evaluate.updatedAt,
|
||||||
};
|
}
|
||||||
|
|
||||||
const assign = await AppDataSource.getRepository(Assign).findOne({
|
const assign = await AppDataSource.getRepository(Assign).findOne({
|
||||||
select: ["id", "personal_id", "round_no", "date_start", "date_finish"],
|
select: ["id", "personal_id", "round_no", "date_start", "date_finish"],
|
||||||
where: { id: evaluate.assign_id },
|
where: { id: evaluate.assign_id },
|
||||||
});
|
})
|
||||||
|
|
||||||
if (!assign) {
|
if (!assign) {
|
||||||
return new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล");
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล")
|
||||||
}
|
}
|
||||||
|
|
||||||
const experimenteeData = await this.personalRepository.findOne({
|
const experimenteeData = await this.personalRepository.findOne({
|
||||||
where: {
|
where: {
|
||||||
personal_id: assign.personal_id,
|
personal_id: assign.personal_id,
|
||||||
},
|
},
|
||||||
});
|
})
|
||||||
|
|
||||||
if (!experimenteeData) {
|
if (!experimenteeData) {
|
||||||
return new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล");
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล")
|
||||||
}
|
}
|
||||||
|
|
||||||
const experimentee = await {
|
const experimentee = await {
|
||||||
|
|
@ -795,38 +745,29 @@ export class ReportController extends Controller {
|
||||||
Department: "-",
|
Department: "-",
|
||||||
OrganizationOrganization: experimenteeData.orgRootName,
|
OrganizationOrganization: experimenteeData.orgRootName,
|
||||||
Oc: experimenteeData.organization,
|
Oc: experimenteeData.organization,
|
||||||
};
|
}
|
||||||
|
|
||||||
const commanderData = await this.assignDirectorRepository.findOne({
|
const commanderData = await this.assignDirectorRepository.findOne({
|
||||||
select: [
|
select: ["personal_id", "fullname", "position", "position", "posType", "posLevel", "role", "dated"],
|
||||||
"personal_id",
|
|
||||||
"fullname",
|
|
||||||
"position",
|
|
||||||
"position",
|
|
||||||
"posType",
|
|
||||||
"posLevel",
|
|
||||||
"role",
|
|
||||||
"dated",
|
|
||||||
],
|
|
||||||
where: { personal_id: evaluate.director_id },
|
where: { personal_id: evaluate.director_id },
|
||||||
});
|
})
|
||||||
|
|
||||||
if (!commanderData) {
|
if (!commanderData) {
|
||||||
return 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,
|
||||||
Position: commanderData.position,
|
Position: commanderData.position,
|
||||||
};
|
}
|
||||||
|
|
||||||
return new HttpSuccess({
|
return new HttpSuccess({
|
||||||
experimentee: experimentee ? experimentee : null,
|
experimentee: experimentee ? experimentee : null,
|
||||||
commander: commander ? commander : null,
|
commander: commander ? commander : null,
|
||||||
assign,
|
assign,
|
||||||
evaluate: evaluateData,
|
evaluate: evaluateData,
|
||||||
});
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -836,30 +777,23 @@ export class ReportController extends Controller {
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Get("evaluate-chairman")
|
@Get("evaluate-chairman")
|
||||||
async GetDataEvaluateChairman(
|
async GetDataEvaluateChairman(@Query() id: string, @Request() request: RequestWithUser) {
|
||||||
@Query() id: string,
|
|
||||||
@Request() request: RequestWithUser
|
|
||||||
) {
|
|
||||||
const evaluate = await this.evaluateChairmanRepository.findOne({
|
const evaluate = await this.evaluateChairmanRepository.findOne({
|
||||||
where: { id },
|
where: { id },
|
||||||
});
|
})
|
||||||
|
|
||||||
if (!evaluate) {
|
if (!evaluate) {
|
||||||
return new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล");
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล")
|
||||||
}
|
}
|
||||||
|
|
||||||
const develop_total_score = await (Number(
|
const develop_total_score = await (Number(evaluate.develop_orientation_score) +
|
||||||
evaluate.develop_orientation_score
|
|
||||||
) +
|
|
||||||
Number(evaluate.develop_self_learning_score) +
|
Number(evaluate.develop_self_learning_score) +
|
||||||
Number(evaluate.develop_training_seminar_score) +
|
Number(evaluate.develop_training_seminar_score) +
|
||||||
Number(evaluate.develop_other_training_score));
|
Number(evaluate.develop_other_training_score))
|
||||||
const develop_total_percent = await (Number(
|
const develop_total_percent = await (Number(evaluate.develop_orientation_percent) +
|
||||||
evaluate.develop_orientation_percent
|
|
||||||
) +
|
|
||||||
Number(evaluate.develop_orientation_percent) +
|
Number(evaluate.develop_orientation_percent) +
|
||||||
Number(evaluate.develop_self_learning_percent) +
|
Number(evaluate.develop_self_learning_percent) +
|
||||||
Number(evaluate.develop_training_seminar_percent));
|
Number(evaluate.develop_training_seminar_percent))
|
||||||
|
|
||||||
const evaluateData = await {
|
const evaluateData = await {
|
||||||
id: evaluate.id,
|
id: evaluate.id,
|
||||||
|
|
@ -1029,33 +963,32 @@ export class ReportController extends Controller {
|
||||||
develop_total_score: develop_total_score,
|
develop_total_score: develop_total_score,
|
||||||
develop_orientation_percent: evaluate.develop_orientation_percent,
|
develop_orientation_percent: evaluate.develop_orientation_percent,
|
||||||
develop_self_learning_percent: evaluate.develop_self_learning_percent,
|
develop_self_learning_percent: evaluate.develop_self_learning_percent,
|
||||||
develop_training_seminar_percent:
|
develop_training_seminar_percent: evaluate.develop_training_seminar_percent,
|
||||||
evaluate.develop_training_seminar_percent,
|
|
||||||
develop_other_training_percent: evaluate.develop_other_training_percent,
|
develop_other_training_percent: evaluate.develop_other_training_percent,
|
||||||
develop_total_percent: develop_total_percent,
|
develop_total_percent: develop_total_percent,
|
||||||
develop_result: evaluate.develop_result,
|
develop_result: evaluate.develop_result,
|
||||||
evaluate_result: evaluate.evaluate_result,
|
evaluate_result: evaluate.evaluate_result,
|
||||||
createdAt: evaluate.createdAt,
|
createdAt: evaluate.createdAt,
|
||||||
updatedAt: evaluate.updatedAt,
|
updatedAt: evaluate.updatedAt,
|
||||||
};
|
}
|
||||||
|
|
||||||
const assign = await AppDataSource.getRepository(Assign).findOne({
|
const assign = await AppDataSource.getRepository(Assign).findOne({
|
||||||
select: ["id", "personal_id", "round_no", "date_start", "date_finish"],
|
select: ["id", "personal_id", "round_no", "date_start", "date_finish"],
|
||||||
where: { id: evaluate.assign_id },
|
where: { id: evaluate.assign_id },
|
||||||
});
|
})
|
||||||
|
|
||||||
if (!assign) {
|
if (!assign) {
|
||||||
return new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล");
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล")
|
||||||
}
|
}
|
||||||
|
|
||||||
const experimenteeData = await this.personalRepository.findOne({
|
const experimenteeData = await this.personalRepository.findOne({
|
||||||
where: {
|
where: {
|
||||||
personal_id: assign.personal_id,
|
personal_id: assign.personal_id,
|
||||||
},
|
},
|
||||||
});
|
})
|
||||||
|
|
||||||
if (!experimenteeData) {
|
if (!experimenteeData) {
|
||||||
return new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล");
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล")
|
||||||
}
|
}
|
||||||
|
|
||||||
const experimentee = await {
|
const experimentee = await {
|
||||||
|
|
@ -1067,45 +1000,35 @@ export class ReportController extends Controller {
|
||||||
Department: "-",
|
Department: "-",
|
||||||
OrganizationOrganization: experimenteeData.orgRootName,
|
OrganizationOrganization: experimenteeData.orgRootName,
|
||||||
Oc: experimenteeData.organization,
|
Oc: experimenteeData.organization,
|
||||||
};
|
}
|
||||||
|
|
||||||
const directorData = await this.assignDirectorRepository.find({
|
const directorData = await this.assignDirectorRepository.find({
|
||||||
select: [
|
select: ["personal_id", "fullname", "position", "posType", "posLevel", "role", "dated"],
|
||||||
"personal_id",
|
|
||||||
"fullname",
|
|
||||||
"position",
|
|
||||||
"posType",
|
|
||||||
"posLevel",
|
|
||||||
"role",
|
|
||||||
"dated",
|
|
||||||
],
|
|
||||||
where: { assign_id: assign.id },
|
where: { assign_id: assign.id },
|
||||||
});
|
})
|
||||||
|
|
||||||
if (!directorData) {
|
if (!directorData) {
|
||||||
return new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล");
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล")
|
||||||
}
|
}
|
||||||
|
|
||||||
const director = await Promise.all(
|
const director = await Promise.all(
|
||||||
directorData.map(async (element) => {
|
directorData.map(async element => {
|
||||||
return {
|
return {
|
||||||
...element,
|
...element,
|
||||||
name: element.fullname,
|
name: element.fullname,
|
||||||
Position: element.position,
|
Position: element.position,
|
||||||
};
|
}
|
||||||
})
|
})
|
||||||
);
|
)
|
||||||
|
|
||||||
const mentorData = await (director.find((x) => x.role == "mentor") ?? null);
|
const mentorData = await (director.find(x => x.role == "mentor") ?? null)
|
||||||
const mentor = mentorData != null ? mentorData : null;
|
const mentor = mentorData != null ? mentorData : null
|
||||||
|
|
||||||
const commanderData = await (director.find((x) => x.role == "commander") ??
|
const commanderData = await (director.find(x => x.role == "commander") ?? null)
|
||||||
null);
|
const commander = commanderData != null ? commanderData : null
|
||||||
const commander = commanderData != null ? commanderData : null;
|
|
||||||
|
|
||||||
const chairmanData = await (director.find((x) => x.role == "chairman") ??
|
const chairmanData = await (director.find(x => x.role == "chairman") ?? null)
|
||||||
null);
|
const chairman = chairmanData != null ? chairmanData : null
|
||||||
const chairman = chairmanData != null ? chairmanData : null;
|
|
||||||
|
|
||||||
return new HttpSuccess({
|
return new HttpSuccess({
|
||||||
experimentee: experimentee ? experimentee : null,
|
experimentee: experimentee ? experimentee : null,
|
||||||
|
|
@ -1114,6 +1037,96 @@ export class ReportController extends Controller {
|
||||||
director2: mentor ? mentor : null,
|
director2: mentor ? mentor : null,
|
||||||
assign,
|
assign,
|
||||||
evaluate: evaluateData,
|
evaluate: evaluateData,
|
||||||
});
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
@Post("command11/officer/report/excecute")
|
||||||
|
public async command11Excecute(
|
||||||
|
@Request() request: RequestWithUser,
|
||||||
|
@Body()
|
||||||
|
body: {
|
||||||
|
refIds: {
|
||||||
|
refId: string
|
||||||
|
commandAffectDate: Date | null
|
||||||
|
commandNo: string | null
|
||||||
|
commandYear: number
|
||||||
|
templateDoc: string | null
|
||||||
|
amount: Double | null
|
||||||
|
positionSalaryAmount: Double | null
|
||||||
|
mouthSalaryAmount: Double | null
|
||||||
|
}[]
|
||||||
|
}
|
||||||
|
) {
|
||||||
|
await new CallAPI()
|
||||||
|
.PostData(request, "/org/command/excexute/salary-probation", {
|
||||||
|
data: body.refIds.map(v => ({
|
||||||
|
profileId: v.refId,
|
||||||
|
date: v.commandAffectDate,
|
||||||
|
refCommandNo: `${v.commandNo}/${Extension.ToThaiYear(v.commandYear)}`,
|
||||||
|
salaryRef: v.templateDoc,
|
||||||
|
})),
|
||||||
|
})
|
||||||
|
.then(async res => {})
|
||||||
|
.catch(() => {})
|
||||||
|
return new HttpSuccess()
|
||||||
|
}
|
||||||
|
@Post("command11/officer/report")
|
||||||
|
public async command11(
|
||||||
|
@Request() req: RequestWithUser,
|
||||||
|
@Body()
|
||||||
|
body: {
|
||||||
|
refIds: string[]
|
||||||
|
}
|
||||||
|
) {
|
||||||
|
const lists = await this.personalRepository.find({
|
||||||
|
where: { probation_status: 2, personal_id: In(body.refIds) },
|
||||||
|
})
|
||||||
|
|
||||||
|
return new HttpSuccess()
|
||||||
|
}
|
||||||
|
|
||||||
|
@Post("command12/officer/report/excecute")
|
||||||
|
public async command12Excecute(
|
||||||
|
@Request() request: RequestWithUser,
|
||||||
|
@Body()
|
||||||
|
body: {
|
||||||
|
refIds: {
|
||||||
|
refId: string
|
||||||
|
commandAffectDate: Date | null
|
||||||
|
commandNo: string | null
|
||||||
|
commandYear: number
|
||||||
|
templateDoc: string | null
|
||||||
|
amount: Double | null
|
||||||
|
positionSalaryAmount: Double | null
|
||||||
|
mouthSalaryAmount: Double | null
|
||||||
|
}[]
|
||||||
|
}
|
||||||
|
) {
|
||||||
|
await new CallAPI()
|
||||||
|
.PostData(request, "/org/command/excexute/salary-probation-leave", {
|
||||||
|
data: body.refIds.map(v => ({
|
||||||
|
profileId: v.refId,
|
||||||
|
date: v.commandAffectDate,
|
||||||
|
refCommandNo: `${v.commandNo}/${Extension.ToThaiYear(v.commandYear)}`,
|
||||||
|
salaryRef: v.templateDoc,
|
||||||
|
})),
|
||||||
|
})
|
||||||
|
.then(async res => {})
|
||||||
|
.catch(() => {})
|
||||||
|
return new HttpSuccess()
|
||||||
|
}
|
||||||
|
@Post("command12/officer/report")
|
||||||
|
public async command12(
|
||||||
|
@Request() req: RequestWithUser,
|
||||||
|
@Body()
|
||||||
|
body: {
|
||||||
|
refIds: string[]
|
||||||
|
}
|
||||||
|
) {
|
||||||
|
const lists = await this.personalRepository.find({
|
||||||
|
where: { probation_status: 3, personal_id: In(body.refIds) },
|
||||||
|
})
|
||||||
|
|
||||||
|
return new HttpSuccess()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -18,12 +18,12 @@ import { setLogDataDiff } from "../interfaces/utils";
|
||||||
import { Survey } from "../entities/Survey";
|
import { Survey } from "../entities/Survey";
|
||||||
import { AppDataSource } from "../database/data-source";
|
import { AppDataSource } from "../database/data-source";
|
||||||
|
|
||||||
@Route("api/v1/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, "สำเร็จ")
|
@SuccessResponse(HttpStatusCode.OK, "สำเร็จ")
|
||||||
export class SurveyController extends Controller {
|
export class SurveyController extends Controller {
|
||||||
|
|
@ -36,16 +36,13 @@ export class SurveyController extends Controller {
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Get("")
|
@Get("")
|
||||||
async GetSurvey(
|
async GetSurvey(@Query() assign_id: string) {
|
||||||
@Query() assign_id: string,
|
const data = await this.surveyRepository.findOne({
|
||||||
@Request() request: RequestWithUser
|
|
||||||
) {
|
|
||||||
const result = await this.surveyRepository.findOne({
|
|
||||||
where: {
|
where: {
|
||||||
assign_id,
|
assign_id,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
return new HttpSuccess(result);
|
return new HttpSuccess(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -58,13 +55,13 @@ export class SurveyController extends Controller {
|
||||||
async PostSurvey(
|
async PostSurvey(
|
||||||
@Query() assign_id: string,
|
@Query() assign_id: string,
|
||||||
@Body() requestBody: any,
|
@Body() requestBody: any,
|
||||||
@Request() request: RequestWithUser
|
@Request() request: RequestWithUser,
|
||||||
) {
|
) {
|
||||||
const before = null;
|
const before = null;
|
||||||
const data = await { ...requestBody, personal_id: request.user.sub };
|
const data = await { ...requestBody, personal_id: request.user.sub, assign_id };
|
||||||
await this.surveyRepository.save(data, { data: request });
|
await this.surveyRepository.save(data, { data: request });
|
||||||
setLogDataDiff(request, { before, after: data });
|
setLogDataDiff(request, { before, after: data });
|
||||||
|
|
||||||
return new HttpSuccess(data);
|
return new HttpSuccess();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,20 +1,7 @@
|
||||||
import {
|
import { CreateEvaluateCommander, EvaluateCommander } from "./EvaluateCommander";
|
||||||
CreateEvaluateCommander,
|
import { Entity, Column, OneToMany, JoinColumn, PrimaryGeneratedColumn, ManyToOne } from "typeorm";
|
||||||
EvaluateCommander,
|
|
||||||
} from "./EvaluateCommander";
|
|
||||||
import {
|
|
||||||
Entity,
|
|
||||||
Column,
|
|
||||||
OneToMany,
|
|
||||||
JoinColumn,
|
|
||||||
PrimaryGeneratedColumn,
|
|
||||||
ManyToOne,
|
|
||||||
} from "typeorm";
|
|
||||||
import { EntityBase } from "./base/Base";
|
import { EntityBase } from "./base/Base";
|
||||||
import {
|
import { AssignCompetencyGroup, CreateAssignCompetencyGroup } from "./AssignCompetencyGroup";
|
||||||
AssignCompetencyGroup,
|
|
||||||
CreateAssignCompetencyGroup,
|
|
||||||
} from "./AssignCompetencyGroup";
|
|
||||||
import { CreateSurvel, Survey } from "./Survey";
|
import { CreateSurvel, Survey } from "./Survey";
|
||||||
import { AssignCompetency, CreateAssignCompetency } from "./AssignCompetency";
|
import { AssignCompetency, CreateAssignCompetency } from "./AssignCompetency";
|
||||||
import { AssignDirector, CreateAssignDirector } from "./AssignDirector";
|
import { AssignDirector, CreateAssignDirector } from "./AssignDirector";
|
||||||
|
|
@ -23,10 +10,7 @@ import { AssignKnowledge, CreateAssignKnowledge } from "./AssignKnowledge";
|
||||||
import { AssignLaw, CreateAssignLaw } from "./AssignLaw";
|
import { AssignLaw, CreateAssignLaw } from "./AssignLaw";
|
||||||
import { AssignOutput, CreateAssignOutput } from "./AssignOutput";
|
import { AssignOutput, CreateAssignOutput } from "./AssignOutput";
|
||||||
import { AssignSkill, CreateAssignSkill } from "./AssignSkill";
|
import { AssignSkill, CreateAssignSkill } from "./AssignSkill";
|
||||||
import {
|
import { CreateEvaluateAchievement, EvaluateAchievement } from "./EvaluateAchievement";
|
||||||
CreateEvaluateAchievement,
|
|
||||||
EvaluateAchievement,
|
|
||||||
} from "./EvaluateAchievement";
|
|
||||||
import { CreateEvaluateAssessor, EvaluateAssessor } from "./EvaluateAssessor";
|
import { CreateEvaluateAssessor, EvaluateAssessor } from "./EvaluateAssessor";
|
||||||
import { CreateEvaluateChairman, EvaluateChairman } from "./EvaluateChairman";
|
import { CreateEvaluateChairman, EvaluateChairman } from "./EvaluateChairman";
|
||||||
import { CreateEvaluateResult, EvaluateResult } from "./EvaluateResult";
|
import { CreateEvaluateResult, EvaluateResult } from "./EvaluateResult";
|
||||||
|
|
@ -96,28 +80,28 @@ export class Assign extends EntityBase {
|
||||||
})
|
})
|
||||||
active: number;
|
active: number;
|
||||||
|
|
||||||
|
@Column({
|
||||||
|
nullable: true,
|
||||||
|
comment: "กฎหมายอื่นๆ",
|
||||||
|
})
|
||||||
|
other_desc!: string;
|
||||||
|
|
||||||
@ManyToOne(() => Personal, (person: Personal) => person.personal_id)
|
@ManyToOne(() => Personal, (person: Personal) => person.personal_id)
|
||||||
@JoinColumn({ name: "personal_id" })
|
@JoinColumn({ name: "personal_id" })
|
||||||
profile: Personal;
|
profile: Personal;
|
||||||
|
|
||||||
@OneToMany(
|
@OneToMany(
|
||||||
() => AssignCompetencyGroup,
|
() => AssignCompetencyGroup,
|
||||||
(competencyGroup: AssignCompetencyGroup) => competencyGroup.assign
|
(competencyGroup: AssignCompetencyGroup) => competencyGroup.assign,
|
||||||
)
|
)
|
||||||
@JoinColumn({ name: "id" })
|
@JoinColumn({ name: "id" })
|
||||||
competencyGroups: AssignCompetencyGroup[];
|
competencyGroups: AssignCompetencyGroup[];
|
||||||
|
|
||||||
@OneToMany(
|
@OneToMany(() => AssignCompetency, (competency: AssignCompetency) => competency.assign)
|
||||||
() => AssignCompetency,
|
|
||||||
(competency: AssignCompetency) => competency.assign
|
|
||||||
)
|
|
||||||
@JoinColumn({ name: "id" })
|
@JoinColumn({ name: "id" })
|
||||||
competencys: AssignCompetency[];
|
competencys: AssignCompetency[];
|
||||||
|
|
||||||
@OneToMany(
|
@OneToMany(() => AssignDirector, (director: AssignDirector) => director.assign)
|
||||||
() => AssignDirector,
|
|
||||||
(director: AssignDirector) => director.assign
|
|
||||||
)
|
|
||||||
@JoinColumn({ name: "id" })
|
@JoinColumn({ name: "id" })
|
||||||
directors: AssignDirector[];
|
directors: AssignDirector[];
|
||||||
|
|
||||||
|
|
@ -125,10 +109,7 @@ export class Assign extends EntityBase {
|
||||||
@JoinColumn({ name: "id" })
|
@JoinColumn({ name: "id" })
|
||||||
jobs: AssignJob[];
|
jobs: AssignJob[];
|
||||||
|
|
||||||
@OneToMany(
|
@OneToMany(() => AssignKnowledge, (knowledge: AssignKnowledge) => knowledge.assign)
|
||||||
() => AssignKnowledge,
|
|
||||||
(knowledge: AssignKnowledge) => knowledge.assign
|
|
||||||
)
|
|
||||||
@JoinColumn({ name: "id" })
|
@JoinColumn({ name: "id" })
|
||||||
knowledges: AssignKnowledge[];
|
knowledges: AssignKnowledge[];
|
||||||
|
|
||||||
|
|
@ -150,28 +131,28 @@ export class Assign extends EntityBase {
|
||||||
|
|
||||||
@OneToMany(
|
@OneToMany(
|
||||||
() => EvaluateAchievement,
|
() => EvaluateAchievement,
|
||||||
(evaluateAchievement: EvaluateAchievement) => evaluateAchievement.assign
|
(evaluateAchievement: EvaluateAchievement) => evaluateAchievement.assign,
|
||||||
)
|
)
|
||||||
@JoinColumn({ name: "id" })
|
@JoinColumn({ name: "id" })
|
||||||
evaluateAchievements: EvaluateAchievement;
|
evaluateAchievements: EvaluateAchievement;
|
||||||
|
|
||||||
@OneToMany(
|
@OneToMany(
|
||||||
() => EvaluateAssessor,
|
() => EvaluateAssessor,
|
||||||
(evaluateAssessor: EvaluateAssessor) => evaluateAssessor.assign
|
(evaluateAssessor: EvaluateAssessor) => evaluateAssessor.assign,
|
||||||
)
|
)
|
||||||
@JoinColumn({ name: "id" })
|
@JoinColumn({ name: "id" })
|
||||||
evaluateAssessors: EvaluateAssessor;
|
evaluateAssessors: EvaluateAssessor;
|
||||||
|
|
||||||
@OneToMany(
|
@OneToMany(
|
||||||
() => EvaluateChairman,
|
() => EvaluateChairman,
|
||||||
(evaluateChairman: EvaluateChairman) => evaluateChairman.assign
|
(evaluateChairman: EvaluateChairman) => evaluateChairman.assign,
|
||||||
)
|
)
|
||||||
@JoinColumn({ name: "id" })
|
@JoinColumn({ name: "id" })
|
||||||
evaluateChairmans: EvaluateChairman;
|
evaluateChairmans: EvaluateChairman;
|
||||||
|
|
||||||
@OneToMany(
|
@OneToMany(
|
||||||
() => EvaluateCommander,
|
() => EvaluateCommander,
|
||||||
(evaluateCommander: EvaluateCommander) => evaluateCommander.assign
|
(evaluateCommander: EvaluateCommander) => evaluateCommander.assign,
|
||||||
)
|
)
|
||||||
@JoinColumn({ name: "id" })
|
@JoinColumn({ name: "id" })
|
||||||
evaluateCommanders: EvaluateCommander;
|
evaluateCommanders: EvaluateCommander;
|
||||||
|
|
@ -193,7 +174,7 @@ export class CreateAssign {
|
||||||
@Column()
|
@Column()
|
||||||
experimenter_dated?: Date;
|
experimenter_dated?: Date;
|
||||||
@Column()
|
@Column()
|
||||||
personal_id?: string;
|
personalId?: string;
|
||||||
fullname?: string;
|
fullname?: string;
|
||||||
position?: string;
|
position?: string;
|
||||||
monthSelect?: number;
|
monthSelect?: number;
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
import { Entity, Column, ManyToOne, JoinColumn, OneToMany } from "typeorm";
|
import { Entity, Column, ManyToOne, JoinColumn, OneToMany, OneToOne } from "typeorm";
|
||||||
import { EntityBase } from "./base/Base";
|
import { EntityBase } from "./base/Base";
|
||||||
import { Assign } from "./Assign";
|
import { Assign } from "./Assign";
|
||||||
import { Law } from "./Law";
|
import { Law } from "./Law";
|
||||||
|
|
@ -27,13 +27,13 @@ export class AssignLaw extends EntityBase {
|
||||||
})
|
})
|
||||||
ordering: number;
|
ordering: number;
|
||||||
|
|
||||||
@ManyToOne(() => Assign, (assign: Assign) => assign.laws)
|
@ManyToOne(() => Assign, (assign: Assign) => assign.id)
|
||||||
@JoinColumn({ name: "assign_id" })
|
@JoinColumn({ name: "assign_id" })
|
||||||
assign: Assign;
|
assign: Assign;
|
||||||
|
|
||||||
@OneToMany(() => Law, (law: Law) => law.assignLaw)
|
// @ManyToOne(() => Law, (law: Law) => law.assignLaw)
|
||||||
@JoinColumn({ name: "law_id" })
|
// @JoinColumn({ name: "law_id" })
|
||||||
law: Law;
|
// law: Law;
|
||||||
}
|
}
|
||||||
|
|
||||||
export class CreateAssignLaw {
|
export class CreateAssignLaw {
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,4 @@
|
||||||
import {
|
import { Entity, Column, ManyToOne, JoinColumn, PrimaryGeneratedColumn } from "typeorm";
|
||||||
Entity,
|
|
||||||
Column,
|
|
||||||
ManyToOne,
|
|
||||||
JoinColumn,
|
|
||||||
PrimaryGeneratedColumn,
|
|
||||||
} from "typeorm";
|
|
||||||
import { EntityBase } from "./base/Base";
|
import { EntityBase } from "./base/Base";
|
||||||
import { Assign } from "./Assign";
|
import { Assign } from "./Assign";
|
||||||
|
|
||||||
|
|
@ -103,7 +97,7 @@ export class CreateEvaluateResult {
|
||||||
date_finish: Date;
|
date_finish: Date;
|
||||||
develop_complete: number;
|
develop_complete: number;
|
||||||
pass_result: number;
|
pass_result: number;
|
||||||
expand_month: number;
|
expand_month?: number;
|
||||||
reson: string;
|
reson: string;
|
||||||
chairman_dated: Date | null;
|
chairman_dated: Date | null;
|
||||||
director1_dated: Date | null;
|
director1_dated: Date | null;
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,4 @@
|
||||||
import {
|
import { Entity, Column, PrimaryGeneratedColumn, OneToMany, JoinColumn, OneToOne } from "typeorm";
|
||||||
Entity,
|
|
||||||
Column,
|
|
||||||
PrimaryGeneratedColumn,
|
|
||||||
OneToMany,
|
|
||||||
JoinColumn,
|
|
||||||
} from "typeorm";
|
|
||||||
import { EntityBase } from "./base/Base";
|
import { EntityBase } from "./base/Base";
|
||||||
import { AssignLaw } from "./AssignLaw";
|
import { AssignLaw } from "./AssignLaw";
|
||||||
|
|
||||||
|
|
@ -41,7 +35,7 @@ export class Law extends EntityBase {
|
||||||
})
|
})
|
||||||
active: number;
|
active: number;
|
||||||
|
|
||||||
@OneToMany(() => AssignLaw, (assignLaw: AssignLaw) => assignLaw.law_id)
|
// @OneToMany(() => AssignLaw, (l: AssignLaw) => l.law_id)
|
||||||
@JoinColumn({ name: "id" })
|
// @JoinColumn({ name: "id" })
|
||||||
assignLaw: AssignLaw[];
|
// assignLaw: AssignLaw[];
|
||||||
}
|
}
|
||||||
|
|
|
||||||
15
src/migration/1725594553970-update-assigntb.ts
Normal file
15
src/migration/1725594553970-update-assigntb.ts
Normal file
|
|
@ -0,0 +1,15 @@
|
||||||
|
import { MigrationInterface, QueryRunner } from "typeorm";
|
||||||
|
|
||||||
|
export class UpdateAssigntb1725594553970 implements MigrationInterface {
|
||||||
|
name = "UpdateAssigntb1725594553970";
|
||||||
|
|
||||||
|
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||||
|
await queryRunner.query(
|
||||||
|
`ALTER TABLE \`assign\` ADD \`other_desc\` varchar(255) NULL COMMENT 'กฎหมายอื่นๆ'`,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||||
|
await queryRunner.query(`ALTER TABLE \`assign\` DROP COLUMN \`other_desc\``);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -9,7 +9,7 @@
|
||||||
"info": {
|
"info": {
|
||||||
"title": "bma-ehr-probation - API",
|
"title": "bma-ehr-probation - API",
|
||||||
"version": "0.0.1",
|
"version": "0.0.1",
|
||||||
"description": "ระบบการพัฒนาบุคลากร/การศึกษาต่อ (Development: DV)",
|
"description": "ระบบทดลองปฏิบัติหน้าที่ราชการ (Probation)",
|
||||||
"license": {
|
"license": {
|
||||||
"name": "by Frappet",
|
"name": "by Frappet",
|
||||||
"url": "https://frappet.com"
|
"url": "https://frappet.com"
|
||||||
|
|
|
||||||
|
|
@ -1,87 +0,0 @@
|
||||||
name: release-test
|
|
||||||
run-name: release-test ${{ github.actor }}
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
tags:
|
|
||||||
- "version-[0-9]+.[0-9]+.[0-9]+"
|
|
||||||
workflow_dispatch:
|
|
||||||
env:
|
|
||||||
REGISTRY: docker.frappet.com
|
|
||||||
IMAGE_NAME: ehr/bma-ehr-development-service
|
|
||||||
DEPLOY_HOST: frappet.com
|
|
||||||
# COMPOSE_PATH: /home/frappet/docker/bma-ehr
|
|
||||||
COMPOSE_PATH: /home/frappet/docker/bma/bma-ehr-development
|
|
||||||
jobs:
|
|
||||||
# act workflow_dispatch -W .github/workflows/release.yaml --input IMAGE_VER=test-v1 -s DOCKER_USER=sorawit -s DOCKER_PASS=P@ssword -s SSH_PASSWORD=P@ssw0rd
|
|
||||||
release-test:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v3
|
|
||||||
# skip Set up QEMU because it fail on act and container
|
|
||||||
# Gen Version try to get version from tag or inut
|
|
||||||
- name: Set output tags
|
|
||||||
id: vars
|
|
||||||
run: echo "tag=${GITHUB_REF#refs/*/}" >> $GITHUB_OUTPUT
|
|
||||||
- name: Gen Version
|
|
||||||
id: gen_ver
|
|
||||||
run: |
|
|
||||||
if [[ $GITHUB_REF == 'refs/tags/'* ]]; then
|
|
||||||
IMAGE_VER=${{ steps.vars.outputs.tag }}
|
|
||||||
else
|
|
||||||
IMAGE_VER=${{ github.event.inputs.IMAGE_VER }}
|
|
||||||
fi
|
|
||||||
if [[ $IMAGE_VER == '' ]]; then
|
|
||||||
IMAGE_VER='test-vBeta'
|
|
||||||
fi
|
|
||||||
echo '::set-output name=image_ver::'$IMAGE_VER
|
|
||||||
- name: Check Version
|
|
||||||
run: |
|
|
||||||
echo $GITHUB_REF
|
|
||||||
echo ${{ steps.gen_ver.outputs.image_ver }}
|
|
||||||
|
|
||||||
- name: Set up Docker Buildx
|
|
||||||
uses: docker/setup-buildx-action@v2
|
|
||||||
- name: Login in to registry
|
|
||||||
uses: docker/login-action@v2
|
|
||||||
with:
|
|
||||||
registry: ${{env.REGISTRY}}
|
|
||||||
username: ${{secrets.DOCKER_USER}}
|
|
||||||
password: ${{secrets.DOCKER_PASS}}
|
|
||||||
- name: Build and push docker image
|
|
||||||
uses: docker/build-push-action@v3
|
|
||||||
with:
|
|
||||||
context: .
|
|
||||||
platforms: linux/amd64
|
|
||||||
push: true
|
|
||||||
tags: ${{env.REGISTRY}}/${{env.IMAGE_NAME}}:${{ steps.gen_ver.outputs.image_ver }},${{env.REGISTRY}}/${{env.IMAGE_NAME}}:latest
|
|
||||||
- name: Remote Deployment
|
|
||||||
uses: appleboy/ssh-action@v0.1.8
|
|
||||||
with:
|
|
||||||
host: ${{env.DEPLOY_HOST}}
|
|
||||||
username: frappet
|
|
||||||
password: ${{ secrets.SSH_PASSWORD }}
|
|
||||||
port: 10102
|
|
||||||
script: |
|
|
||||||
cd "${{env.COMPOSE_PATH}}"
|
|
||||||
docker compose pull
|
|
||||||
docker compose up -d
|
|
||||||
echo "${{ steps.gen_ver.outputs.image_ver }}"> success
|
|
||||||
- uses: snow-actions/line-notify@v1.1.0
|
|
||||||
if: success()
|
|
||||||
with:
|
|
||||||
access_token: ${{ secrets.TOKEN_LINE }}
|
|
||||||
message: |
|
|
||||||
-Success✅✅✅
|
|
||||||
Image: ${{env.IMAGE_NAME}}
|
|
||||||
Version: ${{ steps.gen_ver.outputs.IMAGE_VER }}
|
|
||||||
By: ${{github.actor}}
|
|
||||||
- uses: snow-actions/line-notify@v1.1.0
|
|
||||||
if: failure()
|
|
||||||
with:
|
|
||||||
access_token: ${{ secrets.TOKEN_LINE }}
|
|
||||||
message: |
|
|
||||||
-Failure❌❌❌
|
|
||||||
Image: ${{env.IMAGE_NAME}}
|
|
||||||
Version: ${{ steps.gen_ver.outputs.IMAGE_VER }}
|
|
||||||
By: ${{github.actor}}
|
|
||||||
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue