Merge branch 'develop' into develop-Bright
This commit is contained in:
commit
07564d29ee
2 changed files with 340 additions and 0 deletions
|
|
@ -95,6 +95,7 @@ import { ProfileLeaves } from "../entities/ProfileLeaves";
|
||||||
import { ProfileSalaryTemp } from "../entities/ProfileSalaryTemp";
|
import { ProfileSalaryTemp } from "../entities/ProfileSalaryTemp";
|
||||||
import { ProfileTraining } from "../entities/ProfileTraining";
|
import { ProfileTraining } from "../entities/ProfileTraining";
|
||||||
import { ProfileTrainings } from "../entities/ProfileTrainings";
|
import { ProfileTrainings } from "../entities/ProfileTrainings";
|
||||||
|
import { EMPLOYEETEMP } from "../entities/EMPLOYEETEMP";
|
||||||
@Route("api/v1/org/upload")
|
@Route("api/v1/org/upload")
|
||||||
@Tags("UPLOAD")
|
@Tags("UPLOAD")
|
||||||
@Security("bearerAuth")
|
@Security("bearerAuth")
|
||||||
|
|
@ -155,6 +156,7 @@ export class ImportDataController extends Controller {
|
||||||
private IMPORT_ORGRepo = AppDataSource.getRepository(IMPORT_ORG);
|
private IMPORT_ORGRepo = AppDataSource.getRepository(IMPORT_ORG);
|
||||||
private OFFICERRepo = AppDataSource.getRepository(OFFICER);
|
private OFFICERRepo = AppDataSource.getRepository(OFFICER);
|
||||||
private EMPLOYEERepo = AppDataSource.getRepository(EMPLOYEE);
|
private EMPLOYEERepo = AppDataSource.getRepository(EMPLOYEE);
|
||||||
|
private EMPLOYEETEMPRepo = AppDataSource.getRepository(EMPLOYEETEMP);
|
||||||
|
|
||||||
private positionEmpRepo = AppDataSource.getRepository(EmployeePosition);
|
private positionEmpRepo = AppDataSource.getRepository(EmployeePosition);
|
||||||
private positionRepo = AppDataSource.getRepository(Position);
|
private positionRepo = AppDataSource.getRepository(Position);
|
||||||
|
|
@ -472,6 +474,141 @@ export class ImportDataController extends Controller {
|
||||||
return new HttpSuccess();
|
return new HttpSuccess();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @summary ทะเบียนประวัติ ลูกจ้างชั่วคราว
|
||||||
|
*/
|
||||||
|
@Post("uploadProfile-EmployeeTemp")
|
||||||
|
async UploadFileSQLTemp(@Request() request: { user: Record<string, any> }) {
|
||||||
|
// const existingProfile = await this.profileEmpRepo.find({
|
||||||
|
// where: { employeeClass: "TEMP" },
|
||||||
|
// select: ["citizenId"],
|
||||||
|
// });
|
||||||
|
|
||||||
|
const EMPLOYEE = await this.EMPLOYEETEMPRepo.find({
|
||||||
|
// where: { CIT: Not(In(existingProfile.map((x) => x.citizenId))) },
|
||||||
|
});
|
||||||
|
let rowCount = 0;
|
||||||
|
let _null: any = null;
|
||||||
|
let profile: any;
|
||||||
|
for await (const item of EMPLOYEE) {
|
||||||
|
rowCount++;
|
||||||
|
let type_: any = null;
|
||||||
|
let level_: any = null;
|
||||||
|
profile = null;
|
||||||
|
profile = new ProfileEmployee();
|
||||||
|
|
||||||
|
if (item.CIT.toString() == "1101801164891") {
|
||||||
|
// profile.id = existingProfile.id;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
const existingProfile = await this.profileEmpRepo.findOne({
|
||||||
|
where: { employeeClass: "TEMP", citizenId: item.CIT.toString() },
|
||||||
|
});
|
||||||
|
if (existingProfile) {
|
||||||
|
profile.id = existingProfile.id;
|
||||||
|
// continue;
|
||||||
|
} else {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
var positionType = "";
|
||||||
|
var positionLevel = 0;
|
||||||
|
const value2 = item.POSITION_LEVEL;
|
||||||
|
// const part1 = workLevel.split("/")[0]; // "ส 2"
|
||||||
|
// const value2 = part1.split(" ")[1]; // "2"
|
||||||
|
if (value2) {
|
||||||
|
positionLevel = parseInt(value2);
|
||||||
|
}
|
||||||
|
if (item.CATEGORY_SAL_CODE == "11") {
|
||||||
|
positionType = "บริการพื้นฐาน";
|
||||||
|
// positionLevel = "ปฏิบัติงาน";
|
||||||
|
} else if (item.CATEGORY_SAL_CODE == "12") {
|
||||||
|
positionType = "สนับสนุน";
|
||||||
|
// positionLevel = "ชำนาญงาน";
|
||||||
|
} else if (item.CATEGORY_SAL_CODE == "13") {
|
||||||
|
positionType = "ช่าง";
|
||||||
|
// positionLevel = "อาวุโส";
|
||||||
|
}
|
||||||
|
if (positionType) {
|
||||||
|
type_ = await this.posTypeEmpRepo.findOne({
|
||||||
|
where: { posTypeName: positionType },
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if (positionLevel) {
|
||||||
|
if (type_ == null) {
|
||||||
|
level_ = await this.posLevelEmpRepo.findOne({
|
||||||
|
where: {
|
||||||
|
posLevelName: positionLevel,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
level_ = await this.posLevelEmpRepo.findOne({
|
||||||
|
where: {
|
||||||
|
posLevelName: positionLevel,
|
||||||
|
posTypeId: type_.id,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
let BORN = item.BORN;
|
||||||
|
if (item.BORN) {
|
||||||
|
// const [datePart] = item.BORN.split(" ");
|
||||||
|
// const [day, month, year] = datePart.split("/");
|
||||||
|
// BORN = `${year}-${month.padStart(2, "0")}-${day.padStart(2, "0")}`;
|
||||||
|
}
|
||||||
|
let BEGIN_ENTRY_DATE = item.BEGIN_ENTRY_DATE;
|
||||||
|
if (item.BEGIN_ENTRY_DATE) {
|
||||||
|
// const [datePart] = item.BEGIN_ENTRY_DATE.split(" ");
|
||||||
|
// const [day, month, year] = datePart.split("/");
|
||||||
|
// BEGIN_ENTRY_DATE = `${year}-${month.padStart(2, "0")}-${day.padStart(2, "0")}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
profile.citizenId = item.CIT;
|
||||||
|
profile.rank =
|
||||||
|
item.RANK_NAME == "" ||
|
||||||
|
item.RANK_NAME == "นาย" ||
|
||||||
|
item.RANK_NAME == "นาง" ||
|
||||||
|
item.RANK_NAME == "นางสาว"
|
||||||
|
? null
|
||||||
|
: item.RANK_NAME;
|
||||||
|
profile.prefix = item.RANK_NAME == "" ? null : item.RANK_NAME;
|
||||||
|
profile.prefixMain =
|
||||||
|
item.RANK_NAME == "" ||
|
||||||
|
(item.RANK_NAME != "นาย" && item.RANK_NAME != "นาง" && item.RANK_NAME != "นางสาว")
|
||||||
|
? null
|
||||||
|
: item.RANK_NAME;
|
||||||
|
profile.firstName = item.FNAME == "" ? null : item.FNAME;
|
||||||
|
profile.lastName = item.LNAME == "" ? null : item.LNAME;
|
||||||
|
profile.employeeClass = "TEMP";
|
||||||
|
profile.gender = item.SEX == "1" ? "ชาย" : item.SEX == "2" ? "หญิง" : _null;
|
||||||
|
profile.birthDate = BORN == "" ? _null : new Date(BORN);
|
||||||
|
profile.dateAppoint = BEGIN_ENTRY_DATE == "" ? _null : new Date(BEGIN_ENTRY_DATE);
|
||||||
|
profile.dateStart = BEGIN_ENTRY_DATE == "" ? _null : new Date(BEGIN_ENTRY_DATE);
|
||||||
|
profile.dateRetire = BORN == "" ? _null : calculateRetireDate(new Date(BORN));
|
||||||
|
profile.dateRetireLaw = BORN == "" ? _null : calculateRetireLaw(new Date(BORN));
|
||||||
|
profile.position = item.WORK_LINE_NAME == "" ? null : item.WORK_LINE_NAME.split(" ")[0];
|
||||||
|
profile.posTypeId =
|
||||||
|
type_ != null && type_.posTypeName == positionType && type_ ? type_.id : null;
|
||||||
|
profile.posLevelId =
|
||||||
|
level_ != null && level_.posLevelName == positionLevel && level_ ? level_.id : null;
|
||||||
|
|
||||||
|
profile.amount = item.SALARY == "" ? 0 : Number(item.SALARY);
|
||||||
|
profile.salaryLevel = item.SALARY == "" ? null : Number(item.SALARY_LEVEL_CODE);
|
||||||
|
profile.createdUserId = request.user.sub;
|
||||||
|
profile.createdFullName = request.user.name;
|
||||||
|
profile.lastUpdateUserId = request.user.sub;
|
||||||
|
profile.lastUpdateFullName = request.user.name;
|
||||||
|
profile.createdAt = new Date();
|
||||||
|
profile.lastUpdatedAt = new Date();
|
||||||
|
|
||||||
|
console.log(">>>>>>>>>>>>>>>>>>>" + rowCount);
|
||||||
|
|
||||||
|
await this.profileEmpRepo.save(profile);
|
||||||
|
}
|
||||||
|
return new HttpSuccess();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @summary เงินเดือน ข้าราชการ
|
* @summary เงินเดือน ข้าราชการ
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
203
src/entities/EMPLOYEETEMP.ts
Normal file
203
src/entities/EMPLOYEETEMP.ts
Normal file
|
|
@ -0,0 +1,203 @@
|
||||||
|
import { Entity, Column, PrimaryGeneratedColumn } from "typeorm";
|
||||||
|
|
||||||
|
@Entity("EMPLOYEETEMP")
|
||||||
|
export class EMPLOYEETEMP {
|
||||||
|
@PrimaryGeneratedColumn()
|
||||||
|
id!: number;
|
||||||
|
|
||||||
|
// @Column({
|
||||||
|
// nullable: true,
|
||||||
|
// type: "text",
|
||||||
|
// default: null,
|
||||||
|
// })
|
||||||
|
// RET_YEAR: string;
|
||||||
|
|
||||||
|
@Column({
|
||||||
|
nullable: true,
|
||||||
|
type: "text",
|
||||||
|
default: null,
|
||||||
|
})
|
||||||
|
ID: string;
|
||||||
|
|
||||||
|
@Column({
|
||||||
|
nullable: true,
|
||||||
|
type: "text",
|
||||||
|
default: null,
|
||||||
|
})
|
||||||
|
CIT: string;
|
||||||
|
|
||||||
|
// @Column({
|
||||||
|
// nullable: true,
|
||||||
|
// type: "text",
|
||||||
|
// default: null,
|
||||||
|
// })
|
||||||
|
// MP_CATEGORY: string;
|
||||||
|
|
||||||
|
// @Column({
|
||||||
|
// nullable: true,
|
||||||
|
// type: "text",
|
||||||
|
// default: null,
|
||||||
|
// })
|
||||||
|
// MP_LEVEL: string;
|
||||||
|
|
||||||
|
@Column({
|
||||||
|
nullable: true,
|
||||||
|
type: "text",
|
||||||
|
default: null,
|
||||||
|
})
|
||||||
|
BORN: string;
|
||||||
|
|
||||||
|
@Column({
|
||||||
|
nullable: true,
|
||||||
|
type: "text",
|
||||||
|
default: null,
|
||||||
|
})
|
||||||
|
RANK_NAME: string;
|
||||||
|
|
||||||
|
@Column({
|
||||||
|
nullable: true,
|
||||||
|
type: "text",
|
||||||
|
default: null,
|
||||||
|
})
|
||||||
|
FNAME: string;
|
||||||
|
|
||||||
|
@Column({
|
||||||
|
nullable: true,
|
||||||
|
type: "text",
|
||||||
|
default: null,
|
||||||
|
})
|
||||||
|
LNAME: string;
|
||||||
|
|
||||||
|
@Column({
|
||||||
|
nullable: true,
|
||||||
|
type: "text",
|
||||||
|
default: null,
|
||||||
|
})
|
||||||
|
BEGIN_ENTRY_DATE: string;
|
||||||
|
|
||||||
|
@Column({
|
||||||
|
nullable: true,
|
||||||
|
type: "text",
|
||||||
|
default: null,
|
||||||
|
})
|
||||||
|
SEX: string;
|
||||||
|
|
||||||
|
@Column({
|
||||||
|
nullable: true,
|
||||||
|
type: "text",
|
||||||
|
default: null,
|
||||||
|
})
|
||||||
|
WORK_LINE_NAME: string;
|
||||||
|
|
||||||
|
@Column({
|
||||||
|
nullable: true,
|
||||||
|
type: "text",
|
||||||
|
default: null,
|
||||||
|
})
|
||||||
|
SALARY: string;
|
||||||
|
|
||||||
|
@Column({
|
||||||
|
nullable: true,
|
||||||
|
type: "text",
|
||||||
|
default: null,
|
||||||
|
})
|
||||||
|
DEPARTMENT_NAME: string;
|
||||||
|
|
||||||
|
@Column({
|
||||||
|
nullable: true,
|
||||||
|
type: "text",
|
||||||
|
default: null,
|
||||||
|
})
|
||||||
|
DEPARTMENT_CODE: string;
|
||||||
|
|
||||||
|
@Column({
|
||||||
|
nullable: true,
|
||||||
|
type: "text",
|
||||||
|
default: null,
|
||||||
|
})
|
||||||
|
DIVISION_NAME: string;
|
||||||
|
|
||||||
|
@Column({
|
||||||
|
nullable: true,
|
||||||
|
type: "text",
|
||||||
|
default: null,
|
||||||
|
})
|
||||||
|
DIVISION_CODE: string;
|
||||||
|
|
||||||
|
@Column({
|
||||||
|
nullable: true,
|
||||||
|
type: "text",
|
||||||
|
default: null,
|
||||||
|
})
|
||||||
|
SECTION_NAME: string;
|
||||||
|
|
||||||
|
@Column({
|
||||||
|
nullable: true,
|
||||||
|
type: "text",
|
||||||
|
default: null,
|
||||||
|
})
|
||||||
|
SECTION_CODE: string;
|
||||||
|
|
||||||
|
@Column({
|
||||||
|
nullable: true,
|
||||||
|
type: "text",
|
||||||
|
default: null,
|
||||||
|
})
|
||||||
|
JOB_NAME: string;
|
||||||
|
|
||||||
|
@Column({
|
||||||
|
nullable: true,
|
||||||
|
type: "text",
|
||||||
|
default: null,
|
||||||
|
})
|
||||||
|
JOB_CODE: string;
|
||||||
|
|
||||||
|
@Column({
|
||||||
|
nullable: true,
|
||||||
|
type: "text",
|
||||||
|
default: null,
|
||||||
|
})
|
||||||
|
POS_NUM_CODE: string;
|
||||||
|
|
||||||
|
@Column({
|
||||||
|
nullable: true,
|
||||||
|
type: "text",
|
||||||
|
default: null,
|
||||||
|
})
|
||||||
|
POS_NUM_NAME: string;
|
||||||
|
|
||||||
|
@Column({
|
||||||
|
nullable: true,
|
||||||
|
type: "text",
|
||||||
|
default: null,
|
||||||
|
})
|
||||||
|
CATEGORY_SAL_CODE: string;
|
||||||
|
|
||||||
|
@Column({
|
||||||
|
nullable: true,
|
||||||
|
type: "text",
|
||||||
|
default: null,
|
||||||
|
})
|
||||||
|
SALARY_LEVEL_CODE: string;
|
||||||
|
|
||||||
|
@Column({
|
||||||
|
nullable: true,
|
||||||
|
type: "text",
|
||||||
|
default: null,
|
||||||
|
})
|
||||||
|
LEVEL_NAME: string;
|
||||||
|
|
||||||
|
@Column({
|
||||||
|
nullable: true,
|
||||||
|
type: "text",
|
||||||
|
default: null,
|
||||||
|
})
|
||||||
|
WORK_LEVEL: string;
|
||||||
|
|
||||||
|
@Column({
|
||||||
|
nullable: true,
|
||||||
|
type: "text",
|
||||||
|
default: null,
|
||||||
|
})
|
||||||
|
POSITION_LEVEL: string;
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue