migrate dna
This commit is contained in:
parent
e16390b787
commit
d51357e715
9 changed files with 243 additions and 183 deletions
|
|
@ -370,20 +370,22 @@ export class DevelopmentController extends Controller {
|
|||
await Promise.all(
|
||||
requestBody.positions.map(async (x) => {
|
||||
const _data = Object.assign(new PlannedGoalPosition(), x);
|
||||
let checkPosType:any = null
|
||||
let posTypeShortName:any = null
|
||||
let checkPosType: any = null;
|
||||
let posTypeShortName: any = null;
|
||||
if (x.posTypePlanned) {
|
||||
if(requestBody.groupTarget == "PERSONNEL" &&
|
||||
(requestBody.groupTargetSub == "EMPLOYEE" || requestBody.groupTargetSub == "EMPLOYEETEMP")) {
|
||||
if (
|
||||
requestBody.groupTarget == "PERSONNEL" &&
|
||||
(requestBody.groupTargetSub == "EMPLOYEE" ||
|
||||
requestBody.groupTargetSub == "EMPLOYEETEMP")
|
||||
) {
|
||||
checkPosType = await this.empPosTypeRepository.findOne({
|
||||
where: { posTypeName: x.posTypePlanned },
|
||||
});
|
||||
if (!checkPosType) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลกลุ่มงาน");
|
||||
}
|
||||
posTypeShortName = checkPosType.posTypeShortName
|
||||
}
|
||||
else {
|
||||
posTypeShortName = checkPosType.posTypeShortName;
|
||||
} else {
|
||||
checkPosType = await this.posTypeRepository.findOne({
|
||||
where: { posTypeName: x.posTypePlanned },
|
||||
});
|
||||
|
|
@ -393,24 +395,28 @@ export class DevelopmentController extends Controller {
|
|||
}
|
||||
}
|
||||
if (x.posLevelPlanned) {
|
||||
let checkPosLevel:any
|
||||
if (requestBody.groupTarget == "PERSONNEL" &&
|
||||
(requestBody.groupTargetSub == "EMPLOYEE" || requestBody.groupTargetSub == "EMPLOYEETEMP")) {
|
||||
let checkPosLevel: any;
|
||||
if (
|
||||
requestBody.groupTarget == "PERSONNEL" &&
|
||||
(requestBody.groupTargetSub == "EMPLOYEE" ||
|
||||
requestBody.groupTargetSub == "EMPLOYEETEMP")
|
||||
) {
|
||||
checkPosLevel = await this.empPosLevelRepository.find({
|
||||
where: {
|
||||
posTypeId: checkPosType.id
|
||||
where: {
|
||||
posTypeId: checkPosType.id,
|
||||
},
|
||||
});
|
||||
const mapShortName = checkPosLevel.flatMap((x:any) => `${posTypeShortName} ${x.posLevelName}`);
|
||||
const mapShortName = checkPosLevel.flatMap(
|
||||
(x: any) => `${posTypeShortName} ${x.posLevelName}`,
|
||||
);
|
||||
if (checkPosLevel.length == 0 /*|| !mapShortName.includes(x.posLevelPlanned)*/) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลระดับชั้นงาน");
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
checkPosLevel = await this.posLevelRepository.findOne({
|
||||
where: {
|
||||
where: {
|
||||
posLevelName: x.posLevelPlanned,
|
||||
posTypeId: checkPosType.id
|
||||
posTypeId: checkPosType.id,
|
||||
},
|
||||
});
|
||||
if (!checkPosLevel) {
|
||||
|
|
@ -502,20 +508,21 @@ export class DevelopmentController extends Controller {
|
|||
if (!development) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลโครงการ/หลักสูตรการฝึกอบรมนี้");
|
||||
}
|
||||
let checkPosType:any = null
|
||||
let posTypeShortName:any = null
|
||||
let checkPosType: any = null;
|
||||
let posTypeShortName: any = null;
|
||||
if (requestBody.posTypeActual) {
|
||||
if(requestBody.groupTarget == "PERSONNEL" &&
|
||||
(requestBody.groupTargetSub == "EMPLOYEE" || requestBody.groupTargetSub == "EMPLOYEETEMP")) {
|
||||
if (
|
||||
requestBody.groupTarget == "PERSONNEL" &&
|
||||
(requestBody.groupTargetSub == "EMPLOYEE" || requestBody.groupTargetSub == "EMPLOYEETEMP")
|
||||
) {
|
||||
checkPosType = await this.empPosTypeRepository.findOne({
|
||||
where: { posTypeName: requestBody.posTypeActual },
|
||||
});
|
||||
if (!checkPosType) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลกลุ่มงาน");
|
||||
}
|
||||
posTypeShortName = checkPosType.posTypeShortName
|
||||
}
|
||||
else {
|
||||
posTypeShortName = checkPosType.posTypeShortName;
|
||||
} else {
|
||||
checkPosType = await this.posTypeRepository.findOne({
|
||||
where: { posTypeName: requestBody.posTypeActual },
|
||||
});
|
||||
|
|
@ -525,24 +532,27 @@ export class DevelopmentController extends Controller {
|
|||
}
|
||||
}
|
||||
if (requestBody.posLevelActual) {
|
||||
let checkPosLevel:any
|
||||
if (requestBody.groupTarget == "PERSONNEL" &&
|
||||
(requestBody.groupTargetSub == "EMPLOYEE" || requestBody.groupTargetSub == "EMPLOYEETEMP")) {
|
||||
let checkPosLevel: any;
|
||||
if (
|
||||
requestBody.groupTarget == "PERSONNEL" &&
|
||||
(requestBody.groupTargetSub == "EMPLOYEE" || requestBody.groupTargetSub == "EMPLOYEETEMP")
|
||||
) {
|
||||
checkPosLevel = await this.empPosLevelRepository.find({
|
||||
where: {
|
||||
posTypeId: checkPosType.id
|
||||
where: {
|
||||
posTypeId: checkPosType.id,
|
||||
},
|
||||
});
|
||||
const mapShortName = checkPosLevel.flatMap((x:any) => `${posTypeShortName} ${x.posLevelName}`);
|
||||
const mapShortName = checkPosLevel.flatMap(
|
||||
(x: any) => `${posTypeShortName} ${x.posLevelName}`,
|
||||
);
|
||||
if (checkPosLevel.length == 0 /*|| !mapShortName.includes(x.posLevelPlanned)*/) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลระดับชั้นงาน");
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
checkPosLevel = await this.posLevelRepository.findOne({
|
||||
where: {
|
||||
where: {
|
||||
posLevelName: requestBody.posLevelActual,
|
||||
posTypeId: checkPosType.id
|
||||
posTypeId: checkPosType.id,
|
||||
},
|
||||
});
|
||||
if (!checkPosLevel) {
|
||||
|
|
@ -665,20 +675,22 @@ export class DevelopmentController extends Controller {
|
|||
await Promise.all(
|
||||
requestBody.positions.map(async (x) => {
|
||||
const _data = Object.assign(new PlannedGoalPosition(), x);
|
||||
let checkPosType:any = null
|
||||
let posTypeShortName:any = null
|
||||
let checkPosType: any = null;
|
||||
let posTypeShortName: any = null;
|
||||
if (x.posTypePlanned) {
|
||||
if(requestBody.groupTarget == "PERSONNEL" &&
|
||||
(requestBody.groupTargetSub == "EMPLOYEE" || requestBody.groupTargetSub == "EMPLOYEETEMP")) {
|
||||
if (
|
||||
requestBody.groupTarget == "PERSONNEL" &&
|
||||
(requestBody.groupTargetSub == "EMPLOYEE" ||
|
||||
requestBody.groupTargetSub == "EMPLOYEETEMP")
|
||||
) {
|
||||
checkPosType = await this.empPosTypeRepository.findOne({
|
||||
where: { posTypeName: x.posTypePlanned },
|
||||
});
|
||||
if (!checkPosType) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลกลุ่มงาน");
|
||||
}
|
||||
posTypeShortName = checkPosType.posTypeShortName
|
||||
}
|
||||
else {
|
||||
posTypeShortName = checkPosType.posTypeShortName;
|
||||
} else {
|
||||
checkPosType = await this.posTypeRepository.findOne({
|
||||
where: { posTypeName: x.posTypePlanned },
|
||||
});
|
||||
|
|
@ -688,24 +700,28 @@ export class DevelopmentController extends Controller {
|
|||
}
|
||||
}
|
||||
if (x.posLevelPlanned) {
|
||||
let checkPosLevel:any
|
||||
if (requestBody.groupTarget == "PERSONNEL" &&
|
||||
(requestBody.groupTargetSub == "EMPLOYEE" || requestBody.groupTargetSub == "EMPLOYEETEMP")) {
|
||||
let checkPosLevel: any;
|
||||
if (
|
||||
requestBody.groupTarget == "PERSONNEL" &&
|
||||
(requestBody.groupTargetSub == "EMPLOYEE" ||
|
||||
requestBody.groupTargetSub == "EMPLOYEETEMP")
|
||||
) {
|
||||
checkPosLevel = await this.empPosLevelRepository.find({
|
||||
where: {
|
||||
posTypeId: checkPosType.id
|
||||
where: {
|
||||
posTypeId: checkPosType.id,
|
||||
},
|
||||
});
|
||||
const mapShortName = checkPosLevel.flatMap((x:any) => `${posTypeShortName} ${x.posLevelName}`);
|
||||
const mapShortName = checkPosLevel.flatMap(
|
||||
(x: any) => `${posTypeShortName} ${x.posLevelName}`,
|
||||
);
|
||||
if (checkPosLevel.length == 0 /*|| !mapShortName.includes(x.posLevelPlanned)*/) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลระดับชั้นงาน");
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
checkPosLevel = await this.posLevelRepository.findOne({
|
||||
where: {
|
||||
where: {
|
||||
posLevelName: x.posLevelPlanned,
|
||||
posTypeId: checkPosType.id
|
||||
posTypeId: checkPosType.id,
|
||||
},
|
||||
});
|
||||
if (!checkPosLevel) {
|
||||
|
|
@ -801,20 +817,21 @@ export class DevelopmentController extends Controller {
|
|||
if (!development) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลโครงการ/หลักสูตรการฝึกอบรมนี้");
|
||||
}
|
||||
let checkPosType:any = null
|
||||
let posTypeShortName:any = null
|
||||
let checkPosType: any = null;
|
||||
let posTypeShortName: any = null;
|
||||
if (requestBody.posTypeActual) {
|
||||
if(requestBody.groupTarget == "PERSONNEL" &&
|
||||
(requestBody.groupTargetSub == "EMPLOYEE" || requestBody.groupTargetSub == "EMPLOYEETEMP")) {
|
||||
if (
|
||||
requestBody.groupTarget == "PERSONNEL" &&
|
||||
(requestBody.groupTargetSub == "EMPLOYEE" || requestBody.groupTargetSub == "EMPLOYEETEMP")
|
||||
) {
|
||||
checkPosType = await this.empPosTypeRepository.findOne({
|
||||
where: { posTypeName: requestBody.posTypeActual },
|
||||
});
|
||||
if (!checkPosType) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลกลุ่มงาน");
|
||||
}
|
||||
posTypeShortName = checkPosType.posTypeShortName
|
||||
}
|
||||
else {
|
||||
posTypeShortName = checkPosType.posTypeShortName;
|
||||
} else {
|
||||
checkPosType = await this.posTypeRepository.findOne({
|
||||
where: { posTypeName: requestBody.posTypeActual },
|
||||
});
|
||||
|
|
@ -824,24 +841,27 @@ export class DevelopmentController extends Controller {
|
|||
}
|
||||
}
|
||||
if (requestBody.posLevelActual) {
|
||||
let checkPosLevel:any
|
||||
if (requestBody.groupTarget == "PERSONNEL" &&
|
||||
(requestBody.groupTargetSub == "EMPLOYEE" || requestBody.groupTargetSub == "EMPLOYEETEMP")) {
|
||||
let checkPosLevel: any;
|
||||
if (
|
||||
requestBody.groupTarget == "PERSONNEL" &&
|
||||
(requestBody.groupTargetSub == "EMPLOYEE" || requestBody.groupTargetSub == "EMPLOYEETEMP")
|
||||
) {
|
||||
checkPosLevel = await this.empPosLevelRepository.find({
|
||||
where: {
|
||||
posTypeId: checkPosType.id
|
||||
where: {
|
||||
posTypeId: checkPosType.id,
|
||||
},
|
||||
});
|
||||
const mapShortName = checkPosLevel.flatMap((x:any) => `${posTypeShortName} ${x.posLevelName}`);
|
||||
const mapShortName = checkPosLevel.flatMap(
|
||||
(x: any) => `${posTypeShortName} ${x.posLevelName}`,
|
||||
);
|
||||
if (checkPosLevel.length == 0 /*|| !mapShortName.includes(x.posLevelPlanned)*/) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลระดับชั้นงาน");
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
checkPosLevel = await this.posLevelRepository.findOne({
|
||||
where: {
|
||||
where: {
|
||||
posLevelName: requestBody.posLevelActual,
|
||||
posTypeId: checkPosType.id
|
||||
posTypeId: checkPosType.id,
|
||||
},
|
||||
});
|
||||
if (!checkPosLevel) {
|
||||
|
|
@ -2046,7 +2066,13 @@ export class DevelopmentController extends Controller {
|
|||
@Query("node") node?: number | null,
|
||||
@Query("keyword") keyword?: string,
|
||||
) {
|
||||
// await new permission().PermissionOrgList(request, "SYS_DEV_SCHOLARSHIP");
|
||||
let _data = await new permission().PermissionOrgList(request, "SYS_DEV_PROJECT");
|
||||
await new CallAPI()
|
||||
.PostData(request, "/org/finddna", _data)
|
||||
.then((x) => {
|
||||
_data = x;
|
||||
})
|
||||
.catch((x) => {});
|
||||
const [development, total] = await AppDataSource.getRepository(Development)
|
||||
.createQueryBuilder("development")
|
||||
.andWhere(year > 0 ? "development.year LIKE :year" : "1=1", {
|
||||
|
|
@ -2086,6 +2112,56 @@ export class DevelopmentController extends Controller {
|
|||
keyword: `%${keyword}%`,
|
||||
},
|
||||
)
|
||||
.andWhere(
|
||||
_data.root != undefined && _data.root != null
|
||||
? _data.root[0] != null
|
||||
? `development.rootDnaId IN (:...root)`
|
||||
: `development.rootDnaId is null`
|
||||
: "1=1",
|
||||
{
|
||||
root: _data.root,
|
||||
},
|
||||
)
|
||||
.andWhere(
|
||||
_data.child1 != undefined && _data.child1 != null
|
||||
? _data.child1[0] != null
|
||||
? `development.child1DnaId IN (:...child1)`
|
||||
: `development.child1DnaId is null`
|
||||
: "1=1",
|
||||
{
|
||||
child1: _data.child1,
|
||||
},
|
||||
)
|
||||
.andWhere(
|
||||
_data.child2 != undefined && _data.child2 != null
|
||||
? _data.child2[0] != null
|
||||
? `development.child2DnaId IN (:...child2)`
|
||||
: `development.child2DnaId is null`
|
||||
: "1=1",
|
||||
{
|
||||
child2: _data.child2,
|
||||
},
|
||||
)
|
||||
.andWhere(
|
||||
_data.child3 != undefined && _data.child3 != null
|
||||
? _data.child3[0] != null
|
||||
? `development.child3DnaId IN (:...child3)`
|
||||
: `development.child3DnaId is null`
|
||||
: "1=1",
|
||||
{
|
||||
child3: _data.child3,
|
||||
},
|
||||
)
|
||||
.andWhere(
|
||||
_data.child4 != undefined && _data.child4 != null
|
||||
? _data.child4[0] != null
|
||||
? `development.child4DnaId IN (:...child4)`
|
||||
: `development.child4DnaId is null`
|
||||
: "1=1",
|
||||
{
|
||||
child4: _data.child4,
|
||||
},
|
||||
)
|
||||
.select([
|
||||
"development.id",
|
||||
"development.projectName",
|
||||
|
|
@ -2385,7 +2461,12 @@ export class DevelopmentController extends Controller {
|
|||
dateStart: getDevelopment.dateStart,
|
||||
dateEnd: getDevelopment.dateEnd,
|
||||
totalDate: getDevelopment.totalDate,
|
||||
developmentAddresss: getDevelopment.developmentAddresss == null ? null : getDevelopment.developmentAddresss.sort((a, b) => new Date(a.createdAt).getTime() - new Date(b.createdAt).getTime()),
|
||||
developmentAddresss:
|
||||
getDevelopment.developmentAddresss == null
|
||||
? null
|
||||
: getDevelopment.developmentAddresss.sort(
|
||||
(a, b) => new Date(a.createdAt).getTime() - new Date(b.createdAt).getTime(),
|
||||
),
|
||||
};
|
||||
return new HttpSuccess(_getDevelopment);
|
||||
}
|
||||
|
|
@ -2597,7 +2678,7 @@ export class DevelopmentController extends Controller {
|
|||
startDate: x.dateStart,
|
||||
endDate: x.dateEnd,
|
||||
isDate: true,
|
||||
developmentId: id
|
||||
developmentId: id,
|
||||
})
|
||||
.then((x) => {
|
||||
_data.isDone = true;
|
||||
|
|
@ -2620,7 +2701,7 @@ export class DevelopmentController extends Controller {
|
|||
startDate: x.dateStart,
|
||||
endDate: x.dateEnd,
|
||||
isDate: true,
|
||||
developmentId: id
|
||||
developmentId: id,
|
||||
})
|
||||
.then((x) => {
|
||||
_data.isDone = true;
|
||||
|
|
@ -2658,7 +2739,7 @@ export class DevelopmentController extends Controller {
|
|||
relations: ["development", "development.developmentProjectTechniqueActuals"],
|
||||
});
|
||||
|
||||
let isDevelopment70: boolean = false
|
||||
let isDevelopment70: boolean = false;
|
||||
const dev70Lists = [
|
||||
"on_the_job_training",
|
||||
"job_project_assignment",
|
||||
|
|
@ -2671,18 +2752,18 @@ export class DevelopmentController extends Controller {
|
|||
"benchmarking",
|
||||
"problem_solving",
|
||||
"team_working",
|
||||
"other1"
|
||||
"other1",
|
||||
];
|
||||
let isDevelopment20: boolean = false
|
||||
let isDevelopment20: boolean = false;
|
||||
const dev20Lists = [
|
||||
"coaching",
|
||||
"mentoring",
|
||||
"team_meeting",
|
||||
"consulting",
|
||||
"feedback",
|
||||
"other2"
|
||||
"other2",
|
||||
];
|
||||
let isDevelopment10: boolean = false
|
||||
let isDevelopment10: boolean = false;
|
||||
const dev10Lists = [
|
||||
"self_learning",
|
||||
"classroom_training",
|
||||
|
|
@ -2691,17 +2772,21 @@ export class DevelopmentController extends Controller {
|
|||
"e_training",
|
||||
"meeting",
|
||||
"seminar",
|
||||
"other3"
|
||||
"other3",
|
||||
];
|
||||
await Promise.all(
|
||||
getDevelopment.map(async (x) => {
|
||||
const _data = Object.assign(new DevelopmentHistory(), x);
|
||||
|
||||
const techniqueActuals = x.development?.developmentProjectTechniqueActuals.flatMap(x => x.name) || [];
|
||||
isDevelopment70 = techniqueActuals.length > 0 && dev70Lists.some(item => techniqueActuals.includes(item));
|
||||
isDevelopment20 = techniqueActuals.length > 0 && dev20Lists.some(item => techniqueActuals.includes(item));
|
||||
isDevelopment10 = techniqueActuals.length > 0 && dev10Lists.some(item => techniqueActuals.includes(item));
|
||||
|
||||
const techniqueActuals =
|
||||
x.development?.developmentProjectTechniqueActuals.flatMap((x) => x.name) || [];
|
||||
isDevelopment70 =
|
||||
techniqueActuals.length > 0 && dev70Lists.some((item) => techniqueActuals.includes(item));
|
||||
isDevelopment20 =
|
||||
techniqueActuals.length > 0 && dev20Lists.some((item) => techniqueActuals.includes(item));
|
||||
isDevelopment10 =
|
||||
techniqueActuals.length > 0 && dev10Lists.some((item) => techniqueActuals.includes(item));
|
||||
|
||||
if (x.type == "OFFICER") {
|
||||
await new CallAPI()
|
||||
.PostData(request, "/org/profile/development", {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue