Merge branch 'develop'
This commit is contained in:
commit
c0fdb3bf1a
9 changed files with 1128 additions and 51 deletions
|
|
@ -3423,6 +3423,7 @@ export class CommandController extends Controller {
|
||||||
profileId: profile.id,
|
profileId: profile.id,
|
||||||
commandId: item.commandId,
|
commandId: item.commandId,
|
||||||
position: profile.position,
|
position: profile.position,
|
||||||
|
positionName: profile.position,
|
||||||
positionType: profile?.posType?.posTypeName ?? null,
|
positionType: profile?.posType?.posTypeName ?? null,
|
||||||
positionLevel: profile?.posLevel?.posLevelName ?? null,
|
positionLevel: profile?.posLevel?.posLevelName ?? null,
|
||||||
positionExecutive: position?.posExecutive?.posExecutiveName ?? null,
|
positionExecutive: position?.posExecutive?.posExecutiveName ?? null,
|
||||||
|
|
@ -3451,8 +3452,8 @@ export class CommandController extends Controller {
|
||||||
isGovernment: item.isGovernment,
|
isGovernment: item.isGovernment,
|
||||||
commandNo: item.commandNo,
|
commandNo: item.commandNo,
|
||||||
commandYear: item.commandYear,
|
commandYear: item.commandYear,
|
||||||
posNo: shortName,
|
posNo: posNo,
|
||||||
posNoAbb: posNo,
|
posNoAbb: shortName,
|
||||||
commandDateAffect: item.commandDateAffect,
|
commandDateAffect: item.commandDateAffect,
|
||||||
commandDateSign: item.commandDateSign,
|
commandDateSign: item.commandDateSign,
|
||||||
commandCode: item.commandCode,
|
commandCode: item.commandCode,
|
||||||
|
|
@ -3612,6 +3613,7 @@ export class CommandController extends Controller {
|
||||||
profileEmployeeId: profile.id,
|
profileEmployeeId: profile.id,
|
||||||
commandId: item.commandId,
|
commandId: item.commandId,
|
||||||
position: profile.position,
|
position: profile.position,
|
||||||
|
positionName: profile.position,
|
||||||
positionType: profile?.posType?.posTypeName ?? null,
|
positionType: profile?.posType?.posTypeName ?? null,
|
||||||
positionLevel: profile?.posLevel?.posLevelName ?? null,
|
positionLevel: profile?.posLevel?.posLevelName ?? null,
|
||||||
amount: item.amount ? item.amount : null,
|
amount: item.amount ? item.amount : null,
|
||||||
|
|
@ -3638,8 +3640,8 @@ export class CommandController extends Controller {
|
||||||
isGovernment: item.isGovernment,
|
isGovernment: item.isGovernment,
|
||||||
commandNo: item.commandNo,
|
commandNo: item.commandNo,
|
||||||
commandYear: item.commandYear,
|
commandYear: item.commandYear,
|
||||||
posNo: shortName,
|
posNo: posNo,
|
||||||
posNoAbb: posNo,
|
posNoAbb: shortName,
|
||||||
commandDateAffect: item.commandDateAffect,
|
commandDateAffect: item.commandDateAffect,
|
||||||
commandDateSign: item.commandDateSign,
|
commandDateSign: item.commandDateSign,
|
||||||
commandCode: item.commandCode,
|
commandCode: item.commandCode,
|
||||||
|
|
@ -3867,8 +3869,8 @@ export class CommandController extends Controller {
|
||||||
isGovernment: item.isGovernment,
|
isGovernment: item.isGovernment,
|
||||||
commandNo: item.commandNo,
|
commandNo: item.commandNo,
|
||||||
commandYear: item.commandYear,
|
commandYear: item.commandYear,
|
||||||
posNo: shortName,
|
posNo: posNo,
|
||||||
posNoAbb: posNo,
|
posNoAbb: shortName,
|
||||||
commandDateAffect: item.commandDateAffect,
|
commandDateAffect: item.commandDateAffect,
|
||||||
commandDateSign: item.commandDateSign,
|
commandDateSign: item.commandDateSign,
|
||||||
commandCode: item.commandCode,
|
commandCode: item.commandCode,
|
||||||
|
|
@ -4091,8 +4093,8 @@ export class CommandController extends Controller {
|
||||||
lastUpdatedAt: new Date(),
|
lastUpdatedAt: new Date(),
|
||||||
commandNo: item.commandNo,
|
commandNo: item.commandNo,
|
||||||
commandYear: item.commandYear,
|
commandYear: item.commandYear,
|
||||||
posNo: shortName,
|
posNo: posNo,
|
||||||
posNoAbb: posNo,
|
posNoAbb: shortName,
|
||||||
commandDateAffect: item.commandDateAffect,
|
commandDateAffect: item.commandDateAffect,
|
||||||
commandDateSign: item.commandDateSign,
|
commandDateSign: item.commandDateSign,
|
||||||
commandCode: item.commandCode,
|
commandCode: item.commandCode,
|
||||||
|
|
@ -4266,8 +4268,8 @@ export class CommandController extends Controller {
|
||||||
isGovernment: item.isGovernment,
|
isGovernment: item.isGovernment,
|
||||||
commandNo: item.commandNo,
|
commandNo: item.commandNo,
|
||||||
commandYear: item.commandYear,
|
commandYear: item.commandYear,
|
||||||
posNo: shortName,
|
posNo: posNo,
|
||||||
posNoAbb: posNo,
|
posNoAbb: shortName,
|
||||||
commandDateAffect: item.commandDateAffect,
|
commandDateAffect: item.commandDateAffect,
|
||||||
commandDateSign: item.commandDateSign,
|
commandDateSign: item.commandDateSign,
|
||||||
commandCode: item.commandCode,
|
commandCode: item.commandCode,
|
||||||
|
|
@ -4794,8 +4796,8 @@ export class CommandController extends Controller {
|
||||||
lastUpdatedAt: new Date(),
|
lastUpdatedAt: new Date(),
|
||||||
commandNo: item.commandNo,
|
commandNo: item.commandNo,
|
||||||
commandYear: item.commandYear,
|
commandYear: item.commandYear,
|
||||||
posNo: orgShortName,
|
posNo: profile.posMasterNoTemp ?? "",
|
||||||
posNoAbb: profile.posMasterNoTemp ?? "",
|
posNoAbb: orgShortName,
|
||||||
commandDateAffect: item.commandDateAffect,
|
commandDateAffect: item.commandDateAffect,
|
||||||
commandDateSign: item.commandDateSign,
|
commandDateSign: item.commandDateSign,
|
||||||
commandCode: item.commandCode,
|
commandCode: item.commandCode,
|
||||||
|
|
@ -5048,8 +5050,8 @@ export class CommandController extends Controller {
|
||||||
lastUpdatedAt: new Date(),
|
lastUpdatedAt: new Date(),
|
||||||
commandNo: body.refIds[0].commandNo,
|
commandNo: body.refIds[0].commandNo,
|
||||||
commandYear: body.refIds[0].commandYear,
|
commandYear: body.refIds[0].commandYear,
|
||||||
posNo: shortName,
|
posNo: item.posMaster.posMasterNo,
|
||||||
posNoAbb: item.posMaster.posMasterNo,
|
posNoAbb: shortName,
|
||||||
commandDateAffect: body.refIds[0].commandDateAffect,
|
commandDateAffect: body.refIds[0].commandDateAffect,
|
||||||
commandDateSign: body.refIds[0].commandDateSign,
|
commandDateSign: body.refIds[0].commandDateSign,
|
||||||
commandCode: body.refIds[0].commandCode,
|
commandCode: body.refIds[0].commandCode,
|
||||||
|
|
@ -5293,8 +5295,8 @@ export class CommandController extends Controller {
|
||||||
lastUpdatedAt: new Date(),
|
lastUpdatedAt: new Date(),
|
||||||
commandNo: item.commandNo,
|
commandNo: item.commandNo,
|
||||||
commandYear: item.commandYear,
|
commandYear: item.commandYear,
|
||||||
posNo: shortName,
|
posNo: posMaster.posMasterNo,
|
||||||
posNoAbb: posMaster.posMasterNo,
|
posNoAbb: shortName,
|
||||||
commandDateAffect: item.commandDateAffect,
|
commandDateAffect: item.commandDateAffect,
|
||||||
commandDateSign: item.commandDateSign,
|
commandDateSign: item.commandDateSign,
|
||||||
commandCode: item.commandCode,
|
commandCode: item.commandCode,
|
||||||
|
|
|
||||||
|
|
@ -48,6 +48,7 @@ import { Position } from "../entities/Position";
|
||||||
import { PosMaster } from "../entities/PosMaster";
|
import { PosMaster } from "../entities/PosMaster";
|
||||||
import { positionOfficer } from "../entities/positionOfficer";
|
import { positionOfficer } from "../entities/positionOfficer";
|
||||||
// import { uuidv7 } from "uuidv7";
|
// import { uuidv7 } from "uuidv7";
|
||||||
|
// import { ProfileSalaries } from "../entities/ProfileSalaries";
|
||||||
@Route("api/v1/org/upload")
|
@Route("api/v1/org/upload")
|
||||||
@Tags("UPLOAD")
|
@Tags("UPLOAD")
|
||||||
@Security("bearerAuth")
|
@Security("bearerAuth")
|
||||||
|
|
@ -62,6 +63,7 @@ export class ImportDataController extends Controller {
|
||||||
private posLevelRepo = AppDataSource.getRepository(PosLevel);
|
private posLevelRepo = AppDataSource.getRepository(PosLevel);
|
||||||
private posTypeRepo = AppDataSource.getRepository(PosType);
|
private posTypeRepo = AppDataSource.getRepository(PosType);
|
||||||
private positionOfficerRepo = AppDataSource.getRepository(positionOfficer);
|
private positionOfficerRepo = AppDataSource.getRepository(positionOfficer);
|
||||||
|
// private ProfileSalariesRepo = AppDataSource.getRepository(ProfileSalaries);
|
||||||
private HR_PERSONAL_OFFICER_FAMILYRepo = AppDataSource.getRepository(HR_PERSONAL_OFFICER_FAMILY);
|
private HR_PERSONAL_OFFICER_FAMILYRepo = AppDataSource.getRepository(HR_PERSONAL_OFFICER_FAMILY);
|
||||||
private HR_EDUCATIONRepo = AppDataSource.getRepository(HR_EDUCATION);
|
private HR_EDUCATIONRepo = AppDataSource.getRepository(HR_EDUCATION);
|
||||||
private HR_PERSONAL_OFFICER_ADDRESSRepo = AppDataSource.getRepository(
|
private HR_PERSONAL_OFFICER_ADDRESSRepo = AppDataSource.getRepository(
|
||||||
|
|
@ -330,13 +332,29 @@ export class ImportDataController extends Controller {
|
||||||
.select(["profile.citizenId", "profile.id"])
|
.select(["profile.citizenId", "profile.id"])
|
||||||
.orderBy("profile.citizenId", "ASC")
|
.orderBy("profile.citizenId", "ASC")
|
||||||
// .where("profile.citizenId = '3101702379675'")
|
// .where("profile.citizenId = '3101702379675'")
|
||||||
.skip(0)
|
.where({
|
||||||
.take(10000)
|
citizenId: In([
|
||||||
|
// "1100600109451",
|
||||||
|
// "1209900075508",
|
||||||
|
// "1739900231556",
|
||||||
|
// "1809900305214",
|
||||||
|
// "1920600228762",
|
||||||
|
// "3101600963742",
|
||||||
|
// "3102401171243",
|
||||||
|
// "3120100454406",
|
||||||
|
// "3180100306172",
|
||||||
|
// "3700100094722",
|
||||||
|
// "3809900116957",
|
||||||
|
"3940900213929",
|
||||||
|
]),
|
||||||
|
})
|
||||||
|
// .skip(10000)
|
||||||
|
// .take(20000)
|
||||||
.getManyAndCount();
|
.getManyAndCount();
|
||||||
var _profiles: ProfileSalary[] = [];
|
var _profiles: ProfileSalary[] = [];
|
||||||
const filePath = path.join(__dirname, "salaryProfile.csv");
|
const filePath = path.join(__dirname, "salaryProfile1.csv");
|
||||||
// CSV Header
|
// CSV Header
|
||||||
let csvData = `"id","createdAt","createdUserId","lastUpdatedAt","lastUpdateUserId","createdFullName","lastUpdateFullName","profileId","profileEmployeeId","order","commandNo","commandYear","commandDateSign","commandDateAffect","commandCode","commandName","posNoAbb","posNo","positionName","positionType","positionLevel","positionCee","orgRoot","orgChild1","orgChild2","orgChild3","orgChild4","positionExecutive","amount","amountSpecial","positionSalaryAmount","mouthSalaryAmount","remark","dateGovernment","isGovernment","commandId"\n`;
|
let csvData = `"id","createdAt","createdUserId","lastUpdatedAt","lastUpdateUserId","createdFullName","lastUpdateFullName","profileId","profileEmployeeId","order","commandNo","commandYear","commandDateSign","commandDateAffect","commandCode","commandName","posNoAbb","posNo","positionName","positionType","positionLevel","positionCee","orgRoot","orgChild1","orgChild2","orgChild3","orgChild4","positionExecutive","amount","amountSpecial","positionSalaryAmount","mouthSalaryAmount","remark","dateGovernment","isGovernment","commandId","refId"\n`;
|
||||||
|
|
||||||
fs.appendFile(filePath, csvData, (err) => {
|
fs.appendFile(filePath, csvData, (err) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
|
|
@ -364,8 +382,20 @@ export class ImportDataController extends Controller {
|
||||||
order = order + 1;
|
order = order + 1;
|
||||||
profileSalary.commandNo = item.mp_command_num;
|
profileSalary.commandNo = item.mp_command_num;
|
||||||
profileSalary.commandYear = item.cur_year > 2500 ? item.cur_year - 543 : item.cur_year;
|
profileSalary.commandYear = item.cur_year > 2500 ? item.cur_year - 543 : item.cur_year;
|
||||||
profileSalary.commandDateSign = item.mp_command_date;
|
profileSalary.commandDateSign =
|
||||||
profileSalary.commandDateAffect = item.mp_pos_date;
|
item.mp_command_date == null
|
||||||
|
? null_
|
||||||
|
: new Date(item.mp_command_date.setDate(item.mp_command_date.getDate() + 1))
|
||||||
|
.toISOString()
|
||||||
|
.replace("T", " ")
|
||||||
|
.substring(0, 19);
|
||||||
|
profileSalary.commandDateAffect =
|
||||||
|
item.mp_pos_date == null
|
||||||
|
? null_
|
||||||
|
: new Date(item.mp_pos_date.setDate(item.mp_pos_date.getDate() + 1))
|
||||||
|
.toISOString()
|
||||||
|
.replace("T", " ")
|
||||||
|
.substring(0, 19);
|
||||||
if (
|
if (
|
||||||
[
|
[
|
||||||
"0",
|
"0",
|
||||||
|
|
@ -445,52 +475,203 @@ export class ImportDataController extends Controller {
|
||||||
profileSalary.commandName = "รักษาราชการ, ช่วยราชการ";
|
profileSalary.commandName = "รักษาราชการ, ช่วยราชการ";
|
||||||
}
|
}
|
||||||
if (
|
if (
|
||||||
item.flag_to_name == "" &&
|
item.flag_to_name_code == null &&
|
||||||
(item.flag_to_name_code == "เลื่อน 1 ขั้นและเลื่อนระดับ" ||
|
(item.flag_to_name == "เลื่อน 1 ขั้นและเลื่อนระดับ" ||
|
||||||
item.flag_to_name_code == "เลื่อน 0.5 ขั้นและเลื่อนระดับ" ||
|
item.flag_to_name == "เลื่อน 0.5 ขั้นและเลื่อนระดับ" ||
|
||||||
item.flag_to_name_code == "ลาศึกษาต่อ")
|
item.flag_to_name == "ลาศึกษาต่อ")
|
||||||
) {
|
) {
|
||||||
profileSalary.commandCode = "0";
|
profileSalary.commandCode = "0";
|
||||||
profileSalary.commandName = "อื่น ๆ";
|
profileSalary.commandName = "อื่น ๆ";
|
||||||
} else if (item.flag_to_name == "" && item.flag_to_name_code == "เลื่อนเงินเดือน") {
|
} else if (item.flag_to_name_code == null && item.flag_to_name == "เลื่อนเงินเดือน") {
|
||||||
profileSalary.commandCode = "5";
|
profileSalary.commandCode = "5";
|
||||||
profileSalary.commandName = "เลื่อนเงินเดือนตามปกติ";
|
profileSalary.commandName = "เลื่อนเงินเดือนตามปกติ";
|
||||||
} else if (
|
} else if (
|
||||||
item.flag_to_name == "" &&
|
item.flag_to_name_code == null &&
|
||||||
(item.flag_to_name_code == "ปรับตามบัญชีเงินเดือนใหม่" ||
|
(item.flag_to_name == "ปรับตามบัญชีเงินเดือนใหม่" ||
|
||||||
item.flag_to_name_code == "เลื่อนเงินเดือน" ||
|
item.flag_to_name == "เลื่อนเงินเดือน" ||
|
||||||
item.flag_to_name_code == "ปรับเงินเดือนตาม กพ.")
|
item.flag_to_name == "ปรับเงินเดือนตาม กพ.")
|
||||||
) {
|
) {
|
||||||
profileSalary.commandCode = "6";
|
profileSalary.commandCode = "6";
|
||||||
profileSalary.commandName = "เลื่อนเงินเดือนกรณีอื่น ๆ";
|
profileSalary.commandName = "เลื่อนเงินเดือนกรณีอื่น ๆ";
|
||||||
} else if (
|
} else if (
|
||||||
item.flag_to_name == "" &&
|
item.flag_to_name_code == null &&
|
||||||
item.flag_to_name_code == "แต่งตั้งตามการปรับปรุงโครงฯ"
|
item.flag_to_name == "แต่งตั้งตามการปรับปรุงโครงฯ"
|
||||||
) {
|
) {
|
||||||
profileSalary.commandCode = "8";
|
profileSalary.commandCode = "8";
|
||||||
profileSalary.commandName = "ปรับโครงสร้าง";
|
profileSalary.commandName = "ปรับโครงสร้าง";
|
||||||
} else if (
|
} else if (
|
||||||
item.flag_to_name == "" &&
|
item.flag_to_name_code == null &&
|
||||||
item.flag_to_name_code == "พ้นทดลองปฏิบัติราชการ"
|
item.flag_to_name == "พ้นทดลองปฏิบัติราชการ"
|
||||||
) {
|
) {
|
||||||
profileSalary.commandCode = "9";
|
profileSalary.commandCode = "9";
|
||||||
profileSalary.commandName = "พ้นทดลองปฏิบัติราชการ";
|
profileSalary.commandName = "พ้นทดลองปฏิบัติราชการ";
|
||||||
} else if (item.flag_to_name == "" && item.flag_to_name_code == "ให้โอนมา") {
|
} else if (item.flag_to_name_code == null && item.flag_to_name == "ให้โอนมา") {
|
||||||
profileSalary.commandCode = "11";
|
profileSalary.commandCode = "11";
|
||||||
profileSalary.commandName = "รับโอน";
|
profileSalary.commandName = "รับโอน";
|
||||||
} else if (
|
} else if (
|
||||||
item.flag_to_name == "" &&
|
item.flag_to_name_code == null &&
|
||||||
item.flag_to_name_code == "โอนไปปฏิบัติราชการที่อื่น"
|
item.flag_to_name == "โอนไปปฏิบัติราชการที่อื่น"
|
||||||
) {
|
) {
|
||||||
profileSalary.commandCode = "12";
|
profileSalary.commandCode = "12";
|
||||||
profileSalary.commandName = "ให้โอน";
|
profileSalary.commandName = "ให้โอน";
|
||||||
} else if (item.flag_to_name == "" && item.flag_to_name_code == "ยกเลิกคำสั่ง") {
|
} else if (item.flag_to_name_code == null && item.flag_to_name == "ยกเลิกคำสั่ง") {
|
||||||
profileSalary.commandCode = "14";
|
profileSalary.commandCode = "14";
|
||||||
profileSalary.commandName = "ยกเลิกคำสั่ง";
|
profileSalary.commandName = "ยกเลิกคำสั่ง";
|
||||||
} else if (item.flag_to_name == "" && item.flag_to_name_code == "รักษาการในตำแหน่ง") {
|
} else if (item.flag_to_name_code == null && item.flag_to_name == "รักษาการในตำแหน่ง") {
|
||||||
profileSalary.commandCode = "17";
|
profileSalary.commandCode = "17";
|
||||||
profileSalary.commandName = "รักษาราชการ, ช่วยราชการ";
|
profileSalary.commandName = "รักษาราชการ, ช่วยราชการ";
|
||||||
}
|
}
|
||||||
|
if (
|
||||||
|
(profileSalary.commandCode == null || profileSalary.commandCode == undefined) &&
|
||||||
|
(profileSalary.commandName == null || profileSalary.commandName == undefined)
|
||||||
|
) {
|
||||||
|
if (
|
||||||
|
[
|
||||||
|
"อื่นๆ",
|
||||||
|
"กลับไปปฏิบัติงานทางต้นสังกัด",
|
||||||
|
"เปลี่ยนประเภทข้าราชการ",
|
||||||
|
"โอนสับเปลี่ยน",
|
||||||
|
"เข้ารับฝึกอบรม",
|
||||||
|
"ดูงาน",
|
||||||
|
"ศึกษาต่อ",
|
||||||
|
"ขยายเวลาเข้ารับการฝึกอบรม",
|
||||||
|
"ขยายเวลาศึกษาต่อ",
|
||||||
|
"รายงานตัวกลับเข้าปฏิบัติราชการ",
|
||||||
|
"ไม่ได้เลื่อนขั้น",
|
||||||
|
"เลือนเงินเดือนและระดับ",
|
||||||
|
"เลื่อนเงินเดือนและระดับ",
|
||||||
|
"ตัดเงินเดือน",
|
||||||
|
"ลดขั้นเงินเดือน",
|
||||||
|
"ให้ข้าราชการกลับเข้ารับราชการ",
|
||||||
|
"ไม่ระบุ",
|
||||||
|
].includes(item.flag_to_name)
|
||||||
|
) {
|
||||||
|
profileSalary.commandCode = "0";
|
||||||
|
profileSalary.commandName = "อื่น ๆ";
|
||||||
|
} else if (
|
||||||
|
[
|
||||||
|
"บรรจุและแต่งตั้งผู้สอบแข่งขันได้",
|
||||||
|
"ทดลองปฎิบัติราชการ",
|
||||||
|
"ทดลองปฏิบัติราชการและปรับวุฒิ",
|
||||||
|
"บรรจุใหม่",
|
||||||
|
].includes(item.flag_to_name)
|
||||||
|
) {
|
||||||
|
profileSalary.commandCode = "1";
|
||||||
|
profileSalary.commandName = "บรรจุและแต่งตั้งผู้สอบแข่งขันได้";
|
||||||
|
} else if (["บรรจุและแต่งตั้งผู้ได้รับการคัดเลือก"].includes(item.flag_to_name)) {
|
||||||
|
profileSalary.commandCode = "2";
|
||||||
|
profileSalary.commandName = "บรรจุและแต่งตั้งผู้ได้รับคัดเลือก";
|
||||||
|
} else if (
|
||||||
|
[
|
||||||
|
"แต่งตั้ง (ย้ายสับเปลี่ยน)",
|
||||||
|
"แต่งตั้ง (ย้าย)",
|
||||||
|
"แต่งตั้ง",
|
||||||
|
"เปลี่ยนสายงาน",
|
||||||
|
"เปลี่ยนตำแหน่ง",
|
||||||
|
"ตัดโอนตำแหน่ง",
|
||||||
|
].includes(item.flag_to_name)
|
||||||
|
) {
|
||||||
|
profileSalary.commandCode = "3";
|
||||||
|
profileSalary.commandName = "แต่งตั้ง ย้าย";
|
||||||
|
} else if (["เลื่อนและแต่งตั้ง", "เลื่อนระดับ"].includes(item.flag_to_name)) {
|
||||||
|
profileSalary.commandCode = "4";
|
||||||
|
profileSalary.commandName = "เลื่อน";
|
||||||
|
} else if (["เลื่อนขั้นเงินเดือน", "เลื่อนเงินเดือน"].includes(item.flag_to_name)) {
|
||||||
|
profileSalary.commandCode = "5";
|
||||||
|
profileSalary.commandName = "เลื่อนเงินเดือนตามปกติ";
|
||||||
|
} else if (
|
||||||
|
[
|
||||||
|
"ปรับเงินเดือนตามคุณวุฒิ",
|
||||||
|
"ได้รับเงินตอบแทนพิเศษ",
|
||||||
|
"เงินเพิ่มการครองชีพชั่วคราว",
|
||||||
|
"เลื่อนขั้นเงินเดือนกรณีพิเศษ",
|
||||||
|
"ปรับอัตราเงินเดือนตามบัญชีอัตราเงินเดือนใหม่ ท้าย พ.ร.บ. เงินเดือนและเงินประจำตำ",
|
||||||
|
"ปรับอัตราเงินเดือนตามพระราชกฤษฎีกา การปรับอัตราเงินเดือนของข้าราชการ",
|
||||||
|
"เลื่อนขั้นเงินเดือน (เพิ่มเติม)",
|
||||||
|
"ปรับอัตราเงินเดือน",
|
||||||
|
"ให้ข้าราชการได้รับเงินเดือนตามคุณวุฒิ",
|
||||||
|
].includes(item.flag_to_name)
|
||||||
|
) {
|
||||||
|
profileSalary.commandCode = "6";
|
||||||
|
profileSalary.commandName = "เลื่อนเงินเดือนกรณีอื่น ๆ";
|
||||||
|
} else if (["--"].includes(item.flag_to_name)) {
|
||||||
|
profileSalary.commandCode = "7";
|
||||||
|
profileSalary.commandName = "เงินพิเศษอื่น ๆ";
|
||||||
|
} else if (
|
||||||
|
["ปรับโครงสร้าง", "แต่งตั้ง (จัดคนลงกรอบ)", "แต่งตั้งตามแผนอัตรากำลังฯ"].includes(
|
||||||
|
item.flag_to_name,
|
||||||
|
)
|
||||||
|
) {
|
||||||
|
profileSalary.commandCode = "8";
|
||||||
|
profileSalary.commandName = "ปรับโครงสร้าง";
|
||||||
|
} else if (["พ้นทดลองปฏิบัติราชการ"].includes(item.flag_to_name)) {
|
||||||
|
profileSalary.commandCode = "9";
|
||||||
|
profileSalary.commandName = "พ้นทดลองปฏิบัติราชการ";
|
||||||
|
} else if (
|
||||||
|
[
|
||||||
|
"บรรจุกลับ",
|
||||||
|
"บรรจุกลับข้าราชการ",
|
||||||
|
"บรรจุและแต่งตั้งผู้ไปรับราชการทหารกลับเข้ารับราชการ",
|
||||||
|
].includes(item.flag_to_name)
|
||||||
|
) {
|
||||||
|
profileSalary.commandCode = "10";
|
||||||
|
profileSalary.commandName = "บรรจุกลับ";
|
||||||
|
} else if (
|
||||||
|
[
|
||||||
|
"รับโอนข้าราชการตามกฎหมายอื่น",
|
||||||
|
"รับโอนข้าราชการตามกฎหมายอื่น ผู้สอบแข่งขันได้",
|
||||||
|
"รับโอนข้าราชการตามกฏหมายอื่น โดยการคัดเลือก",
|
||||||
|
].includes(item.flag_to_name)
|
||||||
|
) {
|
||||||
|
profileSalary.commandCode = "11";
|
||||||
|
profileSalary.commandName = "รับโอน";
|
||||||
|
} else if (["ให้โอน"].includes(item.flag_to_name)) {
|
||||||
|
profileSalary.commandCode = "12";
|
||||||
|
profileSalary.commandName = "ให้โอน";
|
||||||
|
} else if (["แก้ไขคำสั่ง"].includes(item.flag_to_name)) {
|
||||||
|
profileSalary.commandCode = "13";
|
||||||
|
profileSalary.commandName = "แก้ไขคำสั่ง";
|
||||||
|
} else if (["ยกเลิกคำสั่ง"].includes(item.flag_to_name)) {
|
||||||
|
profileSalary.commandCode = "14";
|
||||||
|
profileSalary.commandName = "ยกเลิกคำสั่ง";
|
||||||
|
} else if (
|
||||||
|
[
|
||||||
|
"ลาออกจากราชการ",
|
||||||
|
"พ้นจากราชการ/ลาออกจากราชการตามมาตรการพัฒนาและบริหารกำลังคน",
|
||||||
|
].includes(item.flag_to_name)
|
||||||
|
) {
|
||||||
|
profileSalary.commandCode = "15";
|
||||||
|
profileSalary.commandName = "ลาออกจากราชการ";
|
||||||
|
} else if (
|
||||||
|
[
|
||||||
|
"พ้นจากราชการ/เพื่อไปปฏิบัติราชการทหาร",
|
||||||
|
"เกษียณ",
|
||||||
|
"ไม่พ้นทดลองปฏิบัติราชการ",
|
||||||
|
"พ้นจากราชการ/ให้ออก",
|
||||||
|
"พ้นจากราชการ/ไล่ออก",
|
||||||
|
"พ้นจากราชการ/เสียชีวิต",
|
||||||
|
"พ้นจากราชการ/ปลดออก",
|
||||||
|
].includes(item.flag_to_name)
|
||||||
|
) {
|
||||||
|
profileSalary.commandCode = "16";
|
||||||
|
profileSalary.commandName = "พ้นจากราชการ";
|
||||||
|
} else if (
|
||||||
|
[
|
||||||
|
"แต่งตั้งข้าราชการรักษาราชการแทน",
|
||||||
|
"ช่วยราชการ",
|
||||||
|
"รักษาการ",
|
||||||
|
"รักษาราชการแทน",
|
||||||
|
"มอบหมายให้ปฏิบัติหน้าที่",
|
||||||
|
"มอบหมายข้าราชการปฏิบัติหน้าที่แทน",
|
||||||
|
].includes(item.flag_to_name)
|
||||||
|
) {
|
||||||
|
profileSalary.commandCode = "17";
|
||||||
|
profileSalary.commandName = "รักษาราชการ, ช่วยราชการ";
|
||||||
|
} else {
|
||||||
|
profileSalary.commandCode = "0";
|
||||||
|
profileSalary.commandName = item.flag_to_name;
|
||||||
|
}
|
||||||
|
}
|
||||||
profileSalary.posNoAbb = item.pos_num_name;
|
profileSalary.posNoAbb = item.pos_num_name;
|
||||||
profileSalary.posNo = item.pos_num_code;
|
profileSalary.posNo = item.pos_num_code;
|
||||||
profileSalary.positionName = item.work_line_name;
|
profileSalary.positionName = item.work_line_name;
|
||||||
|
|
@ -558,6 +739,8 @@ export class ImportDataController extends Controller {
|
||||||
profileSalary.positionExecutive = item.admin_name;
|
profileSalary.positionExecutive = item.admin_name;
|
||||||
profileSalary.amount = item.salary;
|
profileSalary.amount = item.salary;
|
||||||
profileSalary.remark = item.remark;
|
profileSalary.remark = item.remark;
|
||||||
|
profileSalary.refId = item.id;
|
||||||
|
profileSalary.isEntry = false;
|
||||||
|
|
||||||
const sal_pos_amount_1: any =
|
const sal_pos_amount_1: any =
|
||||||
item.sal_pos_amount_1 == null || item.sal_pos_amount_1 == ""
|
item.sal_pos_amount_1 == null || item.sal_pos_amount_1 == ""
|
||||||
|
|
@ -576,8 +759,8 @@ export class ImportDataController extends Controller {
|
||||||
profileSalary.createdFullName = request.user.name;
|
profileSalary.createdFullName = request.user.name;
|
||||||
profileSalary.lastUpdateUserId = request.user.sub;
|
profileSalary.lastUpdateUserId = request.user.sub;
|
||||||
profileSalary.lastUpdateFullName = request.user.name;
|
profileSalary.lastUpdateFullName = request.user.name;
|
||||||
profileSalary.createdAt = new Date();
|
profileSalary.createdAt = new Date().toISOString().split("T")[0];
|
||||||
profileSalary.lastUpdatedAt = new Date();
|
profileSalary.lastUpdatedAt = new Date().toISOString().split("T")[0];
|
||||||
// const result = uuidv7();
|
// const result = uuidv7();
|
||||||
// profileSalary.id = result;
|
// profileSalary.id = result;
|
||||||
// console.log(">>>>>>>>>>>>>>>>>>>" + rowCount);
|
// console.log(">>>>>>>>>>>>>>>>>>>" + rowCount);
|
||||||
|
|
@ -599,7 +782,8 @@ export class ImportDataController extends Controller {
|
||||||
|
|
||||||
// Loop through each salary profile and format data as CSV
|
// Loop through each salary profile and format data as CSV
|
||||||
// _profiles.forEach((profile) => {
|
// _profiles.forEach((profile) => {
|
||||||
csvData = `"${profileSalary.id || "NULL"}","${profileSalary.createdAt?.toISOString()?.split("T")[0] || "NULL"}","${profileSalary.createdUserId || "NULL"}","${profileSalary.lastUpdatedAt?.toISOString()?.split("T")[0] || "NULL"}","${profileSalary.lastUpdateUserId || "NULL"}","${profileSalary.createdFullName || "NULL"}","${profileSalary.lastUpdateFullName || "NULL"}","${profileSalary.profileId || "NULL"}","${profileSalary.profileEmployeeId || "NULL"}","${profileSalary.order || "NULL"}","${profileSalary.commandNo || "NULL"}","${profileSalary.commandYear || "NULL"}","${profileSalary.commandDateSign?.toISOString()?.split("T")[0] || "NULL"}","${profileSalary.commandDateAffect?.toISOString()?.split("T")[0] || "NULL"}","${profileSalary.commandCode || "NULL"}","${profileSalary.commandName || "NULL"}","${profileSalary.posNoAbb || "NULL"}","${profileSalary.posNo || "NULL"}","${profileSalary.positionName || "NULL"}","${profileSalary.positionType || "NULL"}","${profileSalary.positionLevel || "NULL"}","${profileSalary.positionCee || "NULL"}","${profileSalary.orgRoot || "NULL"}","${profileSalary.orgChild1 || "NULL"}","${profileSalary.orgChild2 || "NULL"}","${profileSalary.orgChild3 || "NULL"}","${profileSalary.orgChild4 || "NULL"}","${profileSalary.positionExecutive || "NULL"}","${profileSalary.amount || 0}","${profileSalary.amountSpecial || 0}","${profileSalary.positionSalaryAmount || 0}","${profileSalary.mouthSalaryAmount || 0}","${profileSalary.remark || "NULL"}","${profileSalary.dateGovernment?.toISOString()?.split("T")[0] || "NULL"}","${profileSalary.isGovernment || "NULL"}","${profileSalary.commandId || "NULL"}"\n`;
|
console.log(profileSalary.commandDateSign);
|
||||||
|
csvData = `"${profileSalary.id || "NULL"}","${profileSalary.createdAt || "NULL"}","${profileSalary.createdUserId || "NULL"}","${profileSalary.lastUpdatedAt || "NULL"}","${profileSalary.lastUpdateUserId || "NULL"}","${profileSalary.createdFullName || "NULL"}","${profileSalary.lastUpdateFullName || "NULL"}","${profileSalary.profileId || "NULL"}","${profileSalary.profileEmployeeId || "NULL"}","${profileSalary.order || "NULL"}","${profileSalary.commandNo || "NULL"}","${profileSalary.commandYear || "NULL"}","${profileSalary.commandDateSign || "NULL"}","${profileSalary.commandDateAffect || "NULL"}","${profileSalary.commandCode || "NULL"}","${profileSalary.commandName || "NULL"}","${profileSalary.posNoAbb || "NULL"}","${profileSalary.posNo || "NULL"}","${profileSalary.positionName || "NULL"}","${profileSalary.positionType || "NULL"}","${profileSalary.positionLevel || "NULL"}","${profileSalary.positionCee || "NULL"}","${profileSalary.orgRoot || "NULL"}","${profileSalary.orgChild1 || "NULL"}","${profileSalary.orgChild2 || "NULL"}","${profileSalary.orgChild3 || "NULL"}","${profileSalary.orgChild4 || "NULL"}","${profileSalary.positionExecutive || "NULL"}","${profileSalary.amount || 0}","${profileSalary.amountSpecial || 0}","${profileSalary.positionSalaryAmount || 0}","${profileSalary.mouthSalaryAmount || 0}","${profileSalary.remark || "NULL"}","${profileSalary.dateGovernment || "NULL"}","${profileSalary.isGovernment || "NULL"}","${profileSalary.commandId || "NULL"}","${profileSalary.refId || "NULL"}"\n`;
|
||||||
// });
|
// });
|
||||||
|
|
||||||
// Write the CSV data to the file
|
// Write the CSV data to the file
|
||||||
|
|
@ -1693,6 +1877,7 @@ export class ImportDataController extends Controller {
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
//order xxxxxxxxxxxxxxxx
|
||||||
await Promise.all(
|
await Promise.all(
|
||||||
IMPORT_CHILD.map(async (item) => {
|
IMPORT_CHILD.map(async (item) => {
|
||||||
const orgRoot = new OrgRoot();
|
const orgRoot = new OrgRoot();
|
||||||
|
|
@ -2092,4 +2277,110 @@ export class ImportDataController extends Controller {
|
||||||
}
|
}
|
||||||
return new HttpSuccess();
|
return new HttpSuccess();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// /**
|
||||||
|
// * @summary เงินเดือน ข้าราชการ
|
||||||
|
// */
|
||||||
|
// @Post("uploadProfileSalary-OfficerEntry")
|
||||||
|
// async UploadFileSQLSalaryEntry(@Request() request: { user: Record<string, any> }) {
|
||||||
|
// let rowCount = 0;
|
||||||
|
// let null_: any = null;
|
||||||
|
// let sqlStatements: string[] = [];
|
||||||
|
|
||||||
|
// const [profiles, total] = await AppDataSource.getRepository(Profile)
|
||||||
|
// .createQueryBuilder("profile")
|
||||||
|
// .select(["profile.citizenId", "profile.id"])
|
||||||
|
// .orderBy("profile.citizenId", "ASC")
|
||||||
|
// // .where("profile.citizenId = '3101702379675'")
|
||||||
|
// .skip(10000)
|
||||||
|
// .take(20000)
|
||||||
|
// .getManyAndCount();
|
||||||
|
// var _profiles: ProfileSalary[] = [];
|
||||||
|
// const filePath = path.join(__dirname, "salaryProfile1.csv");
|
||||||
|
// // CSV Header
|
||||||
|
// let csvData = `"id","createdAt","createdUserId","lastUpdatedAt","lastUpdateUserId","createdFullName","lastUpdateFullName","profileId","profileEmployeeId","order","commandNo","commandYear","commandDateSign","commandDateAffect","commandCode","commandName","posNoAbb","posNo","positionName","positionType","positionLevel","positionCee","orgRoot","orgChild1","orgChild2","orgChild3","orgChild4","positionExecutive","amount","amountSpecial","positionSalaryAmount","mouthSalaryAmount","remark","dateGovernment","isGovernment","commandId","refId"\n`;
|
||||||
|
|
||||||
|
// fs.appendFile(filePath, csvData, (err) => {
|
||||||
|
// if (err) {
|
||||||
|
// console.error("Error writing CSV file:", err);
|
||||||
|
// } else {
|
||||||
|
// console.log("Salary profiles successfully written to salaryProfile.csv");
|
||||||
|
// }
|
||||||
|
// });
|
||||||
|
// await Promise.all(
|
||||||
|
// profiles.map(async (_item) => {
|
||||||
|
// const existingProfile = await this.ProfileSalariesRepo.find({
|
||||||
|
// where: { ProfileId: _item.citizenId },
|
||||||
|
// order: {
|
||||||
|
// Order: "ASC",
|
||||||
|
// },
|
||||||
|
// });
|
||||||
|
// let order = 1;
|
||||||
|
// await Promise.all(
|
||||||
|
// existingProfile.map(async (item) => {
|
||||||
|
// rowCount++;
|
||||||
|
// const profileSalary: any = new ProfileSalary();
|
||||||
|
// profileSalary.profileId = _item.id;
|
||||||
|
// profileSalary.order = item.Order;
|
||||||
|
|
||||||
|
// profileSalary.commandDateAffect =
|
||||||
|
// item.Date == null
|
||||||
|
// ? null_
|
||||||
|
// : new Date(item.Date.setDate(item.Date.getDate() + 1))
|
||||||
|
// .toISOString()
|
||||||
|
// .replace("T", " ")
|
||||||
|
// .substring(0, 19);
|
||||||
|
// profileSalary.remark = item.SalaryRef + item.PositionName;
|
||||||
|
// profileSalary.amount = item.Amount;
|
||||||
|
// profileSalary.positionSalaryAmount = item.PositionSalaryAmount;
|
||||||
|
// const str = item.PosNoName;
|
||||||
|
// const parts = str.split(" ");
|
||||||
|
// if (parts.length > 1) {
|
||||||
|
// const posNo = parts.at(-1);
|
||||||
|
// const posNoAbb = parts.slice(0, -1).join(" ");
|
||||||
|
// profileSalary.posNoAbb = posNoAbb;
|
||||||
|
// profileSalary.posNo = posNo;
|
||||||
|
// }
|
||||||
|
// profileSalary.posLevel = this.canConvertToInt(item.PositionLevelName)
|
||||||
|
// ? null_
|
||||||
|
// : item.PositionLevelName;
|
||||||
|
// profileSalary.posCee = this.canConvertToInt(item.PositionLevelName)
|
||||||
|
// ? item.PositionLevelName
|
||||||
|
// : null_;
|
||||||
|
// //xxxxxxxxxxxxxxxxx
|
||||||
|
// profileSalary.posType = item.PositionTypeName;
|
||||||
|
// profileSalary.isEntry = true;
|
||||||
|
|
||||||
|
// profileSalary.createdUserId = request.user.sub;
|
||||||
|
// profileSalary.createdFullName = request.user.name;
|
||||||
|
// profileSalary.lastUpdateUserId = request.user.sub;
|
||||||
|
// profileSalary.lastUpdateFullName = request.user.name;
|
||||||
|
// profileSalary.createdAt = new Date().toISOString().split("T")[0];
|
||||||
|
// profileSalary.lastUpdatedAt = new Date().toISOString().split("T")[0];
|
||||||
|
// // const result = uuidv7();
|
||||||
|
// // profileSalary.id = result;
|
||||||
|
|
||||||
|
// console.log(profileSalary.commandDateSign);
|
||||||
|
// csvData = `"${profileSalary.id || "NULL"}","${profileSalary.createdAt || "NULL"}","${profileSalary.createdUserId || "NULL"}","${profileSalary.lastUpdatedAt || "NULL"}","${profileSalary.lastUpdateUserId || "NULL"}","${profileSalary.createdFullName || "NULL"}","${profileSalary.lastUpdateFullName || "NULL"}","${profileSalary.profileId || "NULL"}","${profileSalary.profileEmployeeId || "NULL"}","${profileSalary.order || "NULL"}","${profileSalary.commandNo || "NULL"}","${profileSalary.commandYear || "NULL"}","${profileSalary.commandDateSign || "NULL"}","${profileSalary.commandDateAffect || "NULL"}","${profileSalary.commandCode || "NULL"}","${profileSalary.commandName || "NULL"}","${profileSalary.posNoAbb || "NULL"}","${profileSalary.posNo || "NULL"}","${profileSalary.positionName || "NULL"}","${profileSalary.positionType || "NULL"}","${profileSalary.positionLevel || "NULL"}","${profileSalary.positionCee || "NULL"}","${profileSalary.orgRoot || "NULL"}","${profileSalary.orgChild1 || "NULL"}","${profileSalary.orgChild2 || "NULL"}","${profileSalary.orgChild3 || "NULL"}","${profileSalary.orgChild4 || "NULL"}","${profileSalary.positionExecutive || "NULL"}","${profileSalary.amount || 0}","${profileSalary.amountSpecial || 0}","${profileSalary.positionSalaryAmount || 0}","${profileSalary.mouthSalaryAmount || 0}","${profileSalary.remark || "NULL"}","${profileSalary.dateGovernment || "NULL"}","${profileSalary.isGovernment || "NULL"}","${profileSalary.commandId || "NULL"}","${profileSalary.refId || "NULL"}"\n`;
|
||||||
|
|
||||||
|
// fs.appendFile(filePath, csvData.replace('"NULL"', "NULL"), (err) => {
|
||||||
|
// if (err) {
|
||||||
|
// console.error("Error writing CSV file:", err);
|
||||||
|
// } else {
|
||||||
|
// console.log(
|
||||||
|
// "Salary profiles successfully written to salaryProfile.csv: " + rowCount,
|
||||||
|
// );
|
||||||
|
// }
|
||||||
|
// });
|
||||||
|
// }),
|
||||||
|
// );
|
||||||
|
// order = 1;
|
||||||
|
// }),
|
||||||
|
// );
|
||||||
|
// return new HttpSuccess();
|
||||||
|
// }
|
||||||
|
// canConvertToInt(str: string) {
|
||||||
|
// const num = Number(str);
|
||||||
|
// return Number.isInteger(num);
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -34,6 +34,7 @@ import { PosMasterAssign } from "../entities/PosMasterAssign";
|
||||||
import { PosMasterAct } from "../entities/PosMasterAct";
|
import { PosMasterAct } from "../entities/PosMasterAct";
|
||||||
import { EmployeePosition } from "../entities/EmployeePosition";
|
import { EmployeePosition } from "../entities/EmployeePosition";
|
||||||
import { EmployeePosMaster } from "../entities/EmployeePosMaster";
|
import { EmployeePosMaster } from "../entities/EmployeePosMaster";
|
||||||
|
import { EmployeeTempPosMaster } from "../entities/EmployeeTempPosMaster";
|
||||||
|
|
||||||
@Route("api/v1/org")
|
@Route("api/v1/org")
|
||||||
@Tags("Organization")
|
@Tags("Organization")
|
||||||
|
|
@ -57,6 +58,7 @@ export class OrganizationController extends Controller {
|
||||||
private profileRepo = AppDataSource.getRepository(Profile);
|
private profileRepo = AppDataSource.getRepository(Profile);
|
||||||
private employeePosMasterRepository = AppDataSource.getRepository(EmployeePosMaster);
|
private employeePosMasterRepository = AppDataSource.getRepository(EmployeePosMaster);
|
||||||
private employeePositionRepository = AppDataSource.getRepository(EmployeePosition);
|
private employeePositionRepository = AppDataSource.getRepository(EmployeePosition);
|
||||||
|
private employeeTempPosMasterRepository = AppDataSource.getRepository(EmployeeTempPosMaster);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* API ล้างข้อมูล
|
* API ล้างข้อมูล
|
||||||
|
|
@ -243,6 +245,53 @@ export class OrganizationController extends Controller {
|
||||||
}));
|
}));
|
||||||
await this.posMasterRepository.save(_orgPosMaster);
|
await this.posMasterRepository.save(_orgPosMaster);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//หา dna posmaster ถ้าไม่มีให้เอาตัวเองเป็น dna
|
||||||
|
const orgemployeePosMaster = await this.employeePosMasterRepository.find({
|
||||||
|
where: { orgRevisionId: requestBody.orgRevisionId },
|
||||||
|
relations: ["positions"],
|
||||||
|
});
|
||||||
|
|
||||||
|
let _orgemployeePosMaster: EmployeePosMaster[];
|
||||||
|
if (
|
||||||
|
requestBody.typeDraft.toUpperCase() == "ORG_POSITION" ||
|
||||||
|
requestBody.typeDraft.toUpperCase() == "ORG_POSITION_PERSON" ||
|
||||||
|
requestBody.typeDraft.toUpperCase() == "ORG_POSITION_ROLE" ||
|
||||||
|
requestBody.typeDraft.toUpperCase() == "ORG_POSITION_PERSON_ROLE"
|
||||||
|
) {
|
||||||
|
_orgemployeePosMaster = orgemployeePosMaster.map((x) => ({
|
||||||
|
...x,
|
||||||
|
ancestorDNA:
|
||||||
|
x.ancestorDNA == null || x.ancestorDNA == "00000000-0000-0000-0000-000000000000"
|
||||||
|
? x.id
|
||||||
|
: x.ancestorDNA,
|
||||||
|
}));
|
||||||
|
await this.employeePosMasterRepository.save(_orgemployeePosMaster);
|
||||||
|
}
|
||||||
|
|
||||||
|
//หา dna posmaster ถ้าไม่มีให้เอาตัวเองเป็น dna
|
||||||
|
const orgemployeeTempPosMaster = await this.employeeTempPosMasterRepository.find({
|
||||||
|
where: { orgRevisionId: requestBody.orgRevisionId },
|
||||||
|
relations: ["positions"],
|
||||||
|
});
|
||||||
|
|
||||||
|
let _orgemployeeTempPosMaster: EmployeeTempPosMaster[];
|
||||||
|
if (
|
||||||
|
requestBody.typeDraft.toUpperCase() == "ORG_POSITION" ||
|
||||||
|
requestBody.typeDraft.toUpperCase() == "ORG_POSITION_PERSON" ||
|
||||||
|
requestBody.typeDraft.toUpperCase() == "ORG_POSITION_ROLE" ||
|
||||||
|
requestBody.typeDraft.toUpperCase() == "ORG_POSITION_PERSON_ROLE"
|
||||||
|
) {
|
||||||
|
_orgemployeeTempPosMaster = orgemployeeTempPosMaster.map((x) => ({
|
||||||
|
...x,
|
||||||
|
ancestorDNA:
|
||||||
|
x.ancestorDNA == null || x.ancestorDNA == "00000000-0000-0000-0000-000000000000"
|
||||||
|
? x.id
|
||||||
|
: x.ancestorDNA,
|
||||||
|
}));
|
||||||
|
await this.employeeTempPosMasterRepository.save(_orgemployeeTempPosMaster);
|
||||||
|
}
|
||||||
|
|
||||||
//create org
|
//create org
|
||||||
_orgRoot.forEach(async (x: any) => {
|
_orgRoot.forEach(async (x: any) => {
|
||||||
var dataId = x.id;
|
var dataId = x.id;
|
||||||
|
|
@ -319,6 +368,126 @@ export class OrganizationController extends Controller {
|
||||||
});
|
});
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
//create employeePosmaster
|
||||||
|
await Promise.all(
|
||||||
|
_orgemployeePosMaster
|
||||||
|
.filter((x: EmployeePosMaster) => x.orgRootId == dataId && x.orgChild1Id == null)
|
||||||
|
.map(async (item: any) => {
|
||||||
|
delete item.id;
|
||||||
|
const employeePosMaster = Object.assign(new EmployeePosMaster(), item);
|
||||||
|
employeePosMaster.positions = [];
|
||||||
|
if (
|
||||||
|
requestBody.typeDraft.toUpperCase() == "ORG_POSITION_PERSON" ||
|
||||||
|
requestBody.typeDraft.toUpperCase() == "ORG_POSITION_PERSON_ROLE"
|
||||||
|
) {
|
||||||
|
employeePosMaster.current_holderId = item.current_holderId;
|
||||||
|
} else {
|
||||||
|
// employeePosMaster.next_holderId = null;
|
||||||
|
employeePosMaster.isSit = false;
|
||||||
|
}
|
||||||
|
if (
|
||||||
|
requestBody.typeDraft.toUpperCase() == "ORG_POSITION_ROLE" ||
|
||||||
|
requestBody.typeDraft.toUpperCase() == "ORG_POSITION_PERSON_ROLE"
|
||||||
|
) {
|
||||||
|
employeePosMaster.authRoleId = item.authRoleId;
|
||||||
|
} else {
|
||||||
|
employeePosMaster.authRoleId = null;
|
||||||
|
}
|
||||||
|
// employeePosMaster.current_holderId = null;
|
||||||
|
employeePosMaster.orgRevisionId = revision.id;
|
||||||
|
employeePosMaster.orgRootId = data.id;
|
||||||
|
employeePosMaster.createdUserId = request.user.sub;
|
||||||
|
employeePosMaster.createdFullName = request.user.name;
|
||||||
|
employeePosMaster.createdAt = new Date();
|
||||||
|
employeePosMaster.lastUpdateUserId = request.user.sub;
|
||||||
|
employeePosMaster.lastUpdateFullName = request.user.name;
|
||||||
|
employeePosMaster.lastUpdatedAt = new Date();
|
||||||
|
await this.employeePosMasterRepository.save(employeePosMaster);
|
||||||
|
|
||||||
|
//create employeePosition
|
||||||
|
item.positions.map(async (pos: any) => {
|
||||||
|
delete pos.id;
|
||||||
|
const employeePosition: EmployeePosition = Object.assign(
|
||||||
|
new EmployeePosition(),
|
||||||
|
pos,
|
||||||
|
);
|
||||||
|
employeePosition.posMasterId = employeePosMaster.id;
|
||||||
|
if (
|
||||||
|
requestBody.typeDraft.toUpperCase() == "ORG_POSITION" ||
|
||||||
|
requestBody.typeDraft.toUpperCase() == "ORG_POSITION_ROLE"
|
||||||
|
) {
|
||||||
|
employeePosition.positionIsSelected = false;
|
||||||
|
}
|
||||||
|
employeePosition.createdUserId = request.user.sub;
|
||||||
|
employeePosition.createdFullName = request.user.name;
|
||||||
|
employeePosition.createdAt = new Date();
|
||||||
|
employeePosition.lastUpdateUserId = request.user.sub;
|
||||||
|
employeePosition.lastUpdateFullName = request.user.name;
|
||||||
|
employeePosition.lastUpdatedAt = new Date();
|
||||||
|
await this.employeePositionRepository.save(employeePosition);
|
||||||
|
});
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
//create employeeTempPosmaster
|
||||||
|
await Promise.all(
|
||||||
|
_orgemployeeTempPosMaster
|
||||||
|
.filter((x: EmployeeTempPosMaster) => x.orgRootId == dataId && x.orgChild1Id == null)
|
||||||
|
.map(async (item: any) => {
|
||||||
|
delete item.id;
|
||||||
|
const employeeTempPosMaster = Object.assign(new EmployeeTempPosMaster(), item);
|
||||||
|
employeeTempPosMaster.positions = [];
|
||||||
|
if (
|
||||||
|
requestBody.typeDraft.toUpperCase() == "ORG_POSITION_PERSON" ||
|
||||||
|
requestBody.typeDraft.toUpperCase() == "ORG_POSITION_PERSON_ROLE"
|
||||||
|
) {
|
||||||
|
employeeTempPosMaster.current_holderId = item.current_holderId;
|
||||||
|
} else {
|
||||||
|
// employeeTempPosMaster.next_holderId = null;
|
||||||
|
employeeTempPosMaster.isSit = false;
|
||||||
|
}
|
||||||
|
if (
|
||||||
|
requestBody.typeDraft.toUpperCase() == "ORG_POSITION_ROLE" ||
|
||||||
|
requestBody.typeDraft.toUpperCase() == "ORG_POSITION_PERSON_ROLE"
|
||||||
|
) {
|
||||||
|
employeeTempPosMaster.authRoleId = item.authRoleId;
|
||||||
|
} else {
|
||||||
|
employeeTempPosMaster.authRoleId = null;
|
||||||
|
}
|
||||||
|
// employeeTempPosMaster.current_holderId = null;
|
||||||
|
employeeTempPosMaster.orgRevisionId = revision.id;
|
||||||
|
employeeTempPosMaster.orgRootId = data.id;
|
||||||
|
employeeTempPosMaster.createdUserId = request.user.sub;
|
||||||
|
employeeTempPosMaster.createdFullName = request.user.name;
|
||||||
|
employeeTempPosMaster.createdAt = new Date();
|
||||||
|
employeeTempPosMaster.lastUpdateUserId = request.user.sub;
|
||||||
|
employeeTempPosMaster.lastUpdateFullName = request.user.name;
|
||||||
|
employeeTempPosMaster.lastUpdatedAt = new Date();
|
||||||
|
await this.employeeTempPosMasterRepository.save(employeeTempPosMaster);
|
||||||
|
|
||||||
|
//create employeePosition
|
||||||
|
item.positions.map(async (pos: any) => {
|
||||||
|
delete pos.id;
|
||||||
|
const employeePosition: EmployeePosition = Object.assign(
|
||||||
|
new EmployeePosition(),
|
||||||
|
pos,
|
||||||
|
);
|
||||||
|
employeePosition.posMasterTempId = employeeTempPosMaster.id;
|
||||||
|
if (
|
||||||
|
requestBody.typeDraft.toUpperCase() == "ORG_POSITION" ||
|
||||||
|
requestBody.typeDraft.toUpperCase() == "ORG_POSITION_ROLE"
|
||||||
|
) {
|
||||||
|
employeePosition.positionIsSelected = false;
|
||||||
|
}
|
||||||
|
employeePosition.createdUserId = request.user.sub;
|
||||||
|
employeePosition.createdFullName = request.user.name;
|
||||||
|
employeePosition.createdAt = new Date();
|
||||||
|
employeePosition.lastUpdateUserId = request.user.sub;
|
||||||
|
employeePosition.lastUpdateFullName = request.user.name;
|
||||||
|
employeePosition.lastUpdatedAt = new Date();
|
||||||
|
await this.employeePositionRepository.save(employeePosition);
|
||||||
|
});
|
||||||
|
}),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
//create org
|
//create org
|
||||||
|
|
@ -401,6 +570,130 @@ export class OrganizationController extends Controller {
|
||||||
});
|
});
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
//create employeePosmaster
|
||||||
|
await Promise.all(
|
||||||
|
_orgemployeePosMaster
|
||||||
|
.filter(
|
||||||
|
(x: EmployeePosMaster) => x.orgChild1Id == data1Id && x.orgChild2Id == null,
|
||||||
|
)
|
||||||
|
.map(async (item: any) => {
|
||||||
|
delete item.id;
|
||||||
|
const employeePosMaster = Object.assign(new EmployeePosMaster(), item);
|
||||||
|
employeePosMaster.positions = [];
|
||||||
|
if (
|
||||||
|
requestBody.typeDraft.toUpperCase() == "ORG_POSITION_PERSON" ||
|
||||||
|
requestBody.typeDraft.toUpperCase() == "ORG_POSITION_PERSON_ROLE"
|
||||||
|
) {
|
||||||
|
employeePosMaster.current_holderId = item.current_holderId;
|
||||||
|
} else {
|
||||||
|
// employeePosMaster.next_holderId = null;
|
||||||
|
employeePosMaster.isSit = false;
|
||||||
|
}
|
||||||
|
if (
|
||||||
|
requestBody.typeDraft.toUpperCase() == "ORG_POSITION_ROLE" ||
|
||||||
|
requestBody.typeDraft.toUpperCase() == "ORG_POSITION_PERSON_ROLE"
|
||||||
|
) {
|
||||||
|
employeePosMaster.authRoleId = item.authRoleId;
|
||||||
|
} else {
|
||||||
|
employeePosMaster.authRoleId = null;
|
||||||
|
}
|
||||||
|
// employeePosMaster.current_holderId = null;
|
||||||
|
employeePosMaster.orgRevisionId = revision.id;
|
||||||
|
employeePosMaster.orgRootId = data.id;
|
||||||
|
employeePosMaster.createdUserId = request.user.sub;
|
||||||
|
employeePosMaster.createdFullName = request.user.name;
|
||||||
|
employeePosMaster.createdAt = new Date();
|
||||||
|
employeePosMaster.lastUpdateUserId = request.user.sub;
|
||||||
|
employeePosMaster.lastUpdateFullName = request.user.name;
|
||||||
|
employeePosMaster.lastUpdatedAt = new Date();
|
||||||
|
await this.employeePosMasterRepository.save(employeePosMaster);
|
||||||
|
|
||||||
|
//create employeePosition
|
||||||
|
item.positions.map(async (pos: any) => {
|
||||||
|
delete pos.id;
|
||||||
|
const employeePosition: EmployeePosition = Object.assign(
|
||||||
|
new EmployeePosition(),
|
||||||
|
pos,
|
||||||
|
);
|
||||||
|
employeePosition.posMasterId = employeePosMaster.id;
|
||||||
|
if (
|
||||||
|
requestBody.typeDraft.toUpperCase() == "ORG_POSITION" ||
|
||||||
|
requestBody.typeDraft.toUpperCase() == "ORG_POSITION_ROLE"
|
||||||
|
) {
|
||||||
|
employeePosition.positionIsSelected = false;
|
||||||
|
}
|
||||||
|
employeePosition.createdUserId = request.user.sub;
|
||||||
|
employeePosition.createdFullName = request.user.name;
|
||||||
|
employeePosition.createdAt = new Date();
|
||||||
|
employeePosition.lastUpdateUserId = request.user.sub;
|
||||||
|
employeePosition.lastUpdateFullName = request.user.name;
|
||||||
|
employeePosition.lastUpdatedAt = new Date();
|
||||||
|
await this.employeePositionRepository.save(employeePosition);
|
||||||
|
});
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
//create employeeTempPosmaster
|
||||||
|
await Promise.all(
|
||||||
|
_orgemployeeTempPosMaster
|
||||||
|
.filter(
|
||||||
|
(x: EmployeeTempPosMaster) => x.orgChild1Id == data1Id && x.orgChild2Id == null,
|
||||||
|
)
|
||||||
|
.map(async (item: any) => {
|
||||||
|
delete item.id;
|
||||||
|
const employeeTempPosMaster = Object.assign(new EmployeeTempPosMaster(), item);
|
||||||
|
employeeTempPosMaster.positions = [];
|
||||||
|
if (
|
||||||
|
requestBody.typeDraft.toUpperCase() == "ORG_POSITION_PERSON" ||
|
||||||
|
requestBody.typeDraft.toUpperCase() == "ORG_POSITION_PERSON_ROLE"
|
||||||
|
) {
|
||||||
|
employeeTempPosMaster.current_holderId = item.current_holderId;
|
||||||
|
} else {
|
||||||
|
// employeeTempPosMaster.next_holderId = null;
|
||||||
|
employeeTempPosMaster.isSit = false;
|
||||||
|
}
|
||||||
|
if (
|
||||||
|
requestBody.typeDraft.toUpperCase() == "ORG_POSITION_ROLE" ||
|
||||||
|
requestBody.typeDraft.toUpperCase() == "ORG_POSITION_PERSON_ROLE"
|
||||||
|
) {
|
||||||
|
employeeTempPosMaster.authRoleId = item.authRoleId;
|
||||||
|
} else {
|
||||||
|
employeeTempPosMaster.authRoleId = null;
|
||||||
|
}
|
||||||
|
// employeeTempPosMaster.current_holderId = null;
|
||||||
|
employeeTempPosMaster.orgRevisionId = revision.id;
|
||||||
|
employeeTempPosMaster.orgRootId = data.id;
|
||||||
|
employeeTempPosMaster.createdUserId = request.user.sub;
|
||||||
|
employeeTempPosMaster.createdFullName = request.user.name;
|
||||||
|
employeeTempPosMaster.createdAt = new Date();
|
||||||
|
employeeTempPosMaster.lastUpdateUserId = request.user.sub;
|
||||||
|
employeeTempPosMaster.lastUpdateFullName = request.user.name;
|
||||||
|
employeeTempPosMaster.lastUpdatedAt = new Date();
|
||||||
|
await this.employeeTempPosMasterRepository.save(employeeTempPosMaster);
|
||||||
|
|
||||||
|
//create employeePosition
|
||||||
|
item.positions.map(async (pos: any) => {
|
||||||
|
delete pos.id;
|
||||||
|
const employeePosition: EmployeePosition = Object.assign(
|
||||||
|
new EmployeePosition(),
|
||||||
|
pos,
|
||||||
|
);
|
||||||
|
employeePosition.posMasterTempId = employeeTempPosMaster.id;
|
||||||
|
if (
|
||||||
|
requestBody.typeDraft.toUpperCase() == "ORG_POSITION" ||
|
||||||
|
requestBody.typeDraft.toUpperCase() == "ORG_POSITION_ROLE"
|
||||||
|
) {
|
||||||
|
employeePosition.positionIsSelected = false;
|
||||||
|
}
|
||||||
|
employeePosition.createdUserId = request.user.sub;
|
||||||
|
employeePosition.createdFullName = request.user.name;
|
||||||
|
employeePosition.createdAt = new Date();
|
||||||
|
employeePosition.lastUpdateUserId = request.user.sub;
|
||||||
|
employeePosition.lastUpdateFullName = request.user.name;
|
||||||
|
employeePosition.lastUpdatedAt = new Date();
|
||||||
|
await this.employeePositionRepository.save(employeePosition);
|
||||||
|
});
|
||||||
|
}),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
//create org
|
//create org
|
||||||
|
|
@ -485,6 +778,134 @@ export class OrganizationController extends Controller {
|
||||||
});
|
});
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
//create employeePosmaster
|
||||||
|
await Promise.all(
|
||||||
|
_orgemployeePosMaster
|
||||||
|
.filter(
|
||||||
|
(x: EmployeePosMaster) => x.orgChild2Id == data2Id && x.orgChild3Id == null,
|
||||||
|
)
|
||||||
|
.map(async (item: any) => {
|
||||||
|
delete item.id;
|
||||||
|
const employeePosMaster = Object.assign(new EmployeePosMaster(), item);
|
||||||
|
employeePosMaster.positions = [];
|
||||||
|
if (
|
||||||
|
requestBody.typeDraft.toUpperCase() == "ORG_POSITION_PERSON" ||
|
||||||
|
requestBody.typeDraft.toUpperCase() == "ORG_POSITION_PERSON_ROLE"
|
||||||
|
) {
|
||||||
|
employeePosMaster.current_holderId = item.current_holderId;
|
||||||
|
} else {
|
||||||
|
// employeePosMaster.next_holderId = null;
|
||||||
|
employeePosMaster.isSit = false;
|
||||||
|
}
|
||||||
|
if (
|
||||||
|
requestBody.typeDraft.toUpperCase() == "ORG_POSITION_ROLE" ||
|
||||||
|
requestBody.typeDraft.toUpperCase() == "ORG_POSITION_PERSON_ROLE"
|
||||||
|
) {
|
||||||
|
employeePosMaster.authRoleId = item.authRoleId;
|
||||||
|
} else {
|
||||||
|
employeePosMaster.authRoleId = null;
|
||||||
|
}
|
||||||
|
// employeePosMaster.current_holderId = null;
|
||||||
|
employeePosMaster.orgRevisionId = revision.id;
|
||||||
|
employeePosMaster.orgRootId = data.id;
|
||||||
|
employeePosMaster.createdUserId = request.user.sub;
|
||||||
|
employeePosMaster.createdFullName = request.user.name;
|
||||||
|
employeePosMaster.createdAt = new Date();
|
||||||
|
employeePosMaster.lastUpdateUserId = request.user.sub;
|
||||||
|
employeePosMaster.lastUpdateFullName = request.user.name;
|
||||||
|
employeePosMaster.lastUpdatedAt = new Date();
|
||||||
|
await this.employeePosMasterRepository.save(employeePosMaster);
|
||||||
|
|
||||||
|
//create employeePosition
|
||||||
|
item.positions.map(async (pos: any) => {
|
||||||
|
delete pos.id;
|
||||||
|
const employeePosition: EmployeePosition = Object.assign(
|
||||||
|
new EmployeePosition(),
|
||||||
|
pos,
|
||||||
|
);
|
||||||
|
employeePosition.posMasterId = employeePosMaster.id;
|
||||||
|
if (
|
||||||
|
requestBody.typeDraft.toUpperCase() == "ORG_POSITION" ||
|
||||||
|
requestBody.typeDraft.toUpperCase() == "ORG_POSITION_ROLE"
|
||||||
|
) {
|
||||||
|
employeePosition.positionIsSelected = false;
|
||||||
|
}
|
||||||
|
employeePosition.createdUserId = request.user.sub;
|
||||||
|
employeePosition.createdFullName = request.user.name;
|
||||||
|
employeePosition.createdAt = new Date();
|
||||||
|
employeePosition.lastUpdateUserId = request.user.sub;
|
||||||
|
employeePosition.lastUpdateFullName = request.user.name;
|
||||||
|
employeePosition.lastUpdatedAt = new Date();
|
||||||
|
await this.employeePositionRepository.save(employeePosition);
|
||||||
|
});
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
//create employeeTempPosmaster
|
||||||
|
await Promise.all(
|
||||||
|
_orgemployeeTempPosMaster
|
||||||
|
.filter(
|
||||||
|
(x: EmployeeTempPosMaster) =>
|
||||||
|
x.orgChild2Id == data2Id && x.orgChild3Id == null,
|
||||||
|
)
|
||||||
|
.map(async (item: any) => {
|
||||||
|
delete item.id;
|
||||||
|
const employeeTempPosMaster = Object.assign(
|
||||||
|
new EmployeeTempPosMaster(),
|
||||||
|
item,
|
||||||
|
);
|
||||||
|
employeeTempPosMaster.positions = [];
|
||||||
|
if (
|
||||||
|
requestBody.typeDraft.toUpperCase() == "ORG_POSITION_PERSON" ||
|
||||||
|
requestBody.typeDraft.toUpperCase() == "ORG_POSITION_PERSON_ROLE"
|
||||||
|
) {
|
||||||
|
employeeTempPosMaster.current_holderId = item.current_holderId;
|
||||||
|
} else {
|
||||||
|
// employeeTempPosMaster.next_holderId = null;
|
||||||
|
employeeTempPosMaster.isSit = false;
|
||||||
|
}
|
||||||
|
if (
|
||||||
|
requestBody.typeDraft.toUpperCase() == "ORG_POSITION_ROLE" ||
|
||||||
|
requestBody.typeDraft.toUpperCase() == "ORG_POSITION_PERSON_ROLE"
|
||||||
|
) {
|
||||||
|
employeeTempPosMaster.authRoleId = item.authRoleId;
|
||||||
|
} else {
|
||||||
|
employeeTempPosMaster.authRoleId = null;
|
||||||
|
}
|
||||||
|
// employeeTempPosMaster.current_holderId = null;
|
||||||
|
employeeTempPosMaster.orgRevisionId = revision.id;
|
||||||
|
employeeTempPosMaster.orgRootId = data.id;
|
||||||
|
employeeTempPosMaster.createdUserId = request.user.sub;
|
||||||
|
employeeTempPosMaster.createdFullName = request.user.name;
|
||||||
|
employeeTempPosMaster.createdAt = new Date();
|
||||||
|
employeeTempPosMaster.lastUpdateUserId = request.user.sub;
|
||||||
|
employeeTempPosMaster.lastUpdateFullName = request.user.name;
|
||||||
|
employeeTempPosMaster.lastUpdatedAt = new Date();
|
||||||
|
await this.employeeTempPosMasterRepository.save(employeeTempPosMaster);
|
||||||
|
|
||||||
|
//create employeePosition
|
||||||
|
item.positions.map(async (pos: any) => {
|
||||||
|
delete pos.id;
|
||||||
|
const employeePosition: EmployeePosition = Object.assign(
|
||||||
|
new EmployeePosition(),
|
||||||
|
pos,
|
||||||
|
);
|
||||||
|
employeePosition.posMasterTempId = employeeTempPosMaster.id;
|
||||||
|
if (
|
||||||
|
requestBody.typeDraft.toUpperCase() == "ORG_POSITION" ||
|
||||||
|
requestBody.typeDraft.toUpperCase() == "ORG_POSITION_ROLE"
|
||||||
|
) {
|
||||||
|
employeePosition.positionIsSelected = false;
|
||||||
|
}
|
||||||
|
employeePosition.createdUserId = request.user.sub;
|
||||||
|
employeePosition.createdFullName = request.user.name;
|
||||||
|
employeePosition.createdAt = new Date();
|
||||||
|
employeePosition.lastUpdateUserId = request.user.sub;
|
||||||
|
employeePosition.lastUpdateFullName = request.user.name;
|
||||||
|
employeePosition.lastUpdatedAt = new Date();
|
||||||
|
await this.employeePositionRepository.save(employeePosition);
|
||||||
|
});
|
||||||
|
}),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
//create org
|
//create org
|
||||||
|
|
@ -573,6 +994,135 @@ export class OrganizationController extends Controller {
|
||||||
});
|
});
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
//create employeePosmaster
|
||||||
|
await Promise.all(
|
||||||
|
_orgemployeePosMaster
|
||||||
|
.filter(
|
||||||
|
(x: EmployeePosMaster) =>
|
||||||
|
x.orgChild3Id == data3Id && x.orgChild4Id == null,
|
||||||
|
)
|
||||||
|
.map(async (item: any) => {
|
||||||
|
delete item.id;
|
||||||
|
const employeePosMaster = Object.assign(new EmployeePosMaster(), item);
|
||||||
|
employeePosMaster.positions = [];
|
||||||
|
if (
|
||||||
|
requestBody.typeDraft.toUpperCase() == "ORG_POSITION_PERSON" ||
|
||||||
|
requestBody.typeDraft.toUpperCase() == "ORG_POSITION_PERSON_ROLE"
|
||||||
|
) {
|
||||||
|
employeePosMaster.current_holderId = item.current_holderId;
|
||||||
|
} else {
|
||||||
|
// employeePosMaster.next_holderId = null;
|
||||||
|
employeePosMaster.isSit = false;
|
||||||
|
}
|
||||||
|
if (
|
||||||
|
requestBody.typeDraft.toUpperCase() == "ORG_POSITION_ROLE" ||
|
||||||
|
requestBody.typeDraft.toUpperCase() == "ORG_POSITION_PERSON_ROLE"
|
||||||
|
) {
|
||||||
|
employeePosMaster.authRoleId = item.authRoleId;
|
||||||
|
} else {
|
||||||
|
employeePosMaster.authRoleId = null;
|
||||||
|
}
|
||||||
|
// employeePosMaster.current_holderId = null;
|
||||||
|
employeePosMaster.orgRevisionId = revision.id;
|
||||||
|
employeePosMaster.orgRootId = data.id;
|
||||||
|
employeePosMaster.createdUserId = request.user.sub;
|
||||||
|
employeePosMaster.createdFullName = request.user.name;
|
||||||
|
employeePosMaster.createdAt = new Date();
|
||||||
|
employeePosMaster.lastUpdateUserId = request.user.sub;
|
||||||
|
employeePosMaster.lastUpdateFullName = request.user.name;
|
||||||
|
employeePosMaster.lastUpdatedAt = new Date();
|
||||||
|
await this.employeePosMasterRepository.save(employeePosMaster);
|
||||||
|
|
||||||
|
//create employeePosition
|
||||||
|
item.positions.map(async (pos: any) => {
|
||||||
|
delete pos.id;
|
||||||
|
const employeePosition: EmployeePosition = Object.assign(
|
||||||
|
new EmployeePosition(),
|
||||||
|
pos,
|
||||||
|
);
|
||||||
|
employeePosition.posMasterId = employeePosMaster.id;
|
||||||
|
if (
|
||||||
|
requestBody.typeDraft.toUpperCase() == "ORG_POSITION" ||
|
||||||
|
requestBody.typeDraft.toUpperCase() == "ORG_POSITION_ROLE"
|
||||||
|
) {
|
||||||
|
employeePosition.positionIsSelected = false;
|
||||||
|
}
|
||||||
|
employeePosition.createdUserId = request.user.sub;
|
||||||
|
employeePosition.createdFullName = request.user.name;
|
||||||
|
employeePosition.createdAt = new Date();
|
||||||
|
employeePosition.lastUpdateUserId = request.user.sub;
|
||||||
|
employeePosition.lastUpdateFullName = request.user.name;
|
||||||
|
employeePosition.lastUpdatedAt = new Date();
|
||||||
|
await this.employeePositionRepository.save(employeePosition);
|
||||||
|
});
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
//create employeeTempPosmaster
|
||||||
|
await Promise.all(
|
||||||
|
_orgemployeeTempPosMaster
|
||||||
|
.filter(
|
||||||
|
(x: EmployeeTempPosMaster) =>
|
||||||
|
x.orgChild3Id == data3Id && x.orgChild4Id == null,
|
||||||
|
)
|
||||||
|
.map(async (item: any) => {
|
||||||
|
delete item.id;
|
||||||
|
const employeeTempPosMaster = Object.assign(
|
||||||
|
new EmployeeTempPosMaster(),
|
||||||
|
item,
|
||||||
|
);
|
||||||
|
employeeTempPosMaster.positions = [];
|
||||||
|
if (
|
||||||
|
requestBody.typeDraft.toUpperCase() == "ORG_POSITION_PERSON" ||
|
||||||
|
requestBody.typeDraft.toUpperCase() == "ORG_POSITION_PERSON_ROLE"
|
||||||
|
) {
|
||||||
|
employeeTempPosMaster.current_holderId = item.current_holderId;
|
||||||
|
} else {
|
||||||
|
// employeeTempPosMaster.next_holderId = null;
|
||||||
|
employeeTempPosMaster.isSit = false;
|
||||||
|
}
|
||||||
|
if (
|
||||||
|
requestBody.typeDraft.toUpperCase() == "ORG_POSITION_ROLE" ||
|
||||||
|
requestBody.typeDraft.toUpperCase() == "ORG_POSITION_PERSON_ROLE"
|
||||||
|
) {
|
||||||
|
employeeTempPosMaster.authRoleId = item.authRoleId;
|
||||||
|
} else {
|
||||||
|
employeeTempPosMaster.authRoleId = null;
|
||||||
|
}
|
||||||
|
// employeeTempPosMaster.current_holderId = null;
|
||||||
|
employeeTempPosMaster.orgRevisionId = revision.id;
|
||||||
|
employeeTempPosMaster.orgRootId = data.id;
|
||||||
|
employeeTempPosMaster.createdUserId = request.user.sub;
|
||||||
|
employeeTempPosMaster.createdFullName = request.user.name;
|
||||||
|
employeeTempPosMaster.createdAt = new Date();
|
||||||
|
employeeTempPosMaster.lastUpdateUserId = request.user.sub;
|
||||||
|
employeeTempPosMaster.lastUpdateFullName = request.user.name;
|
||||||
|
employeeTempPosMaster.lastUpdatedAt = new Date();
|
||||||
|
await this.employeeTempPosMasterRepository.save(employeeTempPosMaster);
|
||||||
|
|
||||||
|
//create employeePosition
|
||||||
|
item.positions.map(async (pos: any) => {
|
||||||
|
delete pos.id;
|
||||||
|
const employeePosition: EmployeePosition = Object.assign(
|
||||||
|
new EmployeePosition(),
|
||||||
|
pos,
|
||||||
|
);
|
||||||
|
employeePosition.posMasterTempId = employeeTempPosMaster.id;
|
||||||
|
if (
|
||||||
|
requestBody.typeDraft.toUpperCase() == "ORG_POSITION" ||
|
||||||
|
requestBody.typeDraft.toUpperCase() == "ORG_POSITION_ROLE"
|
||||||
|
) {
|
||||||
|
employeePosition.positionIsSelected = false;
|
||||||
|
}
|
||||||
|
employeePosition.createdUserId = request.user.sub;
|
||||||
|
employeePosition.createdFullName = request.user.name;
|
||||||
|
employeePosition.createdAt = new Date();
|
||||||
|
employeePosition.lastUpdateUserId = request.user.sub;
|
||||||
|
employeePosition.lastUpdateFullName = request.user.name;
|
||||||
|
employeePosition.lastUpdatedAt = new Date();
|
||||||
|
await this.employeePositionRepository.save(employeePosition);
|
||||||
|
});
|
||||||
|
}),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
//create org
|
//create org
|
||||||
|
|
@ -661,6 +1211,134 @@ export class OrganizationController extends Controller {
|
||||||
});
|
});
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
//create employeePosmaster
|
||||||
|
await Promise.all(
|
||||||
|
_orgemployeePosMaster
|
||||||
|
.filter((x: EmployeePosMaster) => x.orgChild4Id == data4Id)
|
||||||
|
.map(async (item: any) => {
|
||||||
|
delete item.id;
|
||||||
|
const employeePosMaster = Object.assign(
|
||||||
|
new EmployeePosMaster(),
|
||||||
|
item,
|
||||||
|
);
|
||||||
|
employeePosMaster.positions = [];
|
||||||
|
if (
|
||||||
|
requestBody.typeDraft.toUpperCase() == "ORG_POSITION_PERSON" ||
|
||||||
|
requestBody.typeDraft.toUpperCase() == "ORG_POSITION_PERSON_ROLE"
|
||||||
|
) {
|
||||||
|
employeePosMaster.current_holderId = item.current_holderId;
|
||||||
|
} else {
|
||||||
|
// employeePosMaster.next_holderId = null;
|
||||||
|
employeePosMaster.isSit = false;
|
||||||
|
}
|
||||||
|
if (
|
||||||
|
requestBody.typeDraft.toUpperCase() == "ORG_POSITION_ROLE" ||
|
||||||
|
requestBody.typeDraft.toUpperCase() == "ORG_POSITION_PERSON_ROLE"
|
||||||
|
) {
|
||||||
|
employeePosMaster.authRoleId = item.authRoleId;
|
||||||
|
} else {
|
||||||
|
employeePosMaster.authRoleId = null;
|
||||||
|
}
|
||||||
|
// employeePosMaster.current_holderId = null;
|
||||||
|
employeePosMaster.orgRevisionId = revision.id;
|
||||||
|
employeePosMaster.orgRootId = data.id;
|
||||||
|
employeePosMaster.createdUserId = request.user.sub;
|
||||||
|
employeePosMaster.createdFullName = request.user.name;
|
||||||
|
employeePosMaster.createdAt = new Date();
|
||||||
|
employeePosMaster.lastUpdateUserId = request.user.sub;
|
||||||
|
employeePosMaster.lastUpdateFullName = request.user.name;
|
||||||
|
employeePosMaster.lastUpdatedAt = new Date();
|
||||||
|
await this.employeePosMasterRepository.save(employeePosMaster);
|
||||||
|
|
||||||
|
//create employeePosition
|
||||||
|
item.positions.map(async (pos: any) => {
|
||||||
|
delete pos.id;
|
||||||
|
const employeePosition: EmployeePosition = Object.assign(
|
||||||
|
new EmployeePosition(),
|
||||||
|
pos,
|
||||||
|
);
|
||||||
|
employeePosition.posMasterId = employeePosMaster.id;
|
||||||
|
if (
|
||||||
|
requestBody.typeDraft.toUpperCase() == "ORG_POSITION" ||
|
||||||
|
requestBody.typeDraft.toUpperCase() == "ORG_POSITION_ROLE"
|
||||||
|
) {
|
||||||
|
employeePosition.positionIsSelected = false;
|
||||||
|
}
|
||||||
|
employeePosition.createdUserId = request.user.sub;
|
||||||
|
employeePosition.createdFullName = request.user.name;
|
||||||
|
employeePosition.createdAt = new Date();
|
||||||
|
employeePosition.lastUpdateUserId = request.user.sub;
|
||||||
|
employeePosition.lastUpdateFullName = request.user.name;
|
||||||
|
employeePosition.lastUpdatedAt = new Date();
|
||||||
|
await this.employeePositionRepository.save(employeePosition);
|
||||||
|
});
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
//create employeeTempPosmaster
|
||||||
|
await Promise.all(
|
||||||
|
_orgemployeeTempPosMaster
|
||||||
|
.filter((x: EmployeeTempPosMaster) => x.orgChild4Id == data4Id)
|
||||||
|
.map(async (item: any) => {
|
||||||
|
delete item.id;
|
||||||
|
const employeeTempPosMaster = Object.assign(
|
||||||
|
new EmployeeTempPosMaster(),
|
||||||
|
item,
|
||||||
|
);
|
||||||
|
employeeTempPosMaster.positions = [];
|
||||||
|
if (
|
||||||
|
requestBody.typeDraft.toUpperCase() == "ORG_POSITION_PERSON" ||
|
||||||
|
requestBody.typeDraft.toUpperCase() == "ORG_POSITION_PERSON_ROLE"
|
||||||
|
) {
|
||||||
|
employeeTempPosMaster.current_holderId = item.current_holderId;
|
||||||
|
} else {
|
||||||
|
// employeeTempPosMaster.next_holderId = null;
|
||||||
|
employeeTempPosMaster.isSit = false;
|
||||||
|
}
|
||||||
|
if (
|
||||||
|
requestBody.typeDraft.toUpperCase() == "ORG_POSITION_ROLE" ||
|
||||||
|
requestBody.typeDraft.toUpperCase() == "ORG_POSITION_PERSON_ROLE"
|
||||||
|
) {
|
||||||
|
employeeTempPosMaster.authRoleId = item.authRoleId;
|
||||||
|
} else {
|
||||||
|
employeeTempPosMaster.authRoleId = null;
|
||||||
|
}
|
||||||
|
// employeeTempPosMaster.current_holderId = null;
|
||||||
|
employeeTempPosMaster.orgRevisionId = revision.id;
|
||||||
|
employeeTempPosMaster.orgRootId = data.id;
|
||||||
|
employeeTempPosMaster.createdUserId = request.user.sub;
|
||||||
|
employeeTempPosMaster.createdFullName = request.user.name;
|
||||||
|
employeeTempPosMaster.createdAt = new Date();
|
||||||
|
employeeTempPosMaster.lastUpdateUserId = request.user.sub;
|
||||||
|
employeeTempPosMaster.lastUpdateFullName = request.user.name;
|
||||||
|
employeeTempPosMaster.lastUpdatedAt = new Date();
|
||||||
|
await this.employeeTempPosMasterRepository.save(
|
||||||
|
employeeTempPosMaster,
|
||||||
|
);
|
||||||
|
|
||||||
|
//create employeePosition
|
||||||
|
item.positions.map(async (pos: any) => {
|
||||||
|
delete pos.id;
|
||||||
|
const employeePosition: EmployeePosition = Object.assign(
|
||||||
|
new EmployeePosition(),
|
||||||
|
pos,
|
||||||
|
);
|
||||||
|
employeePosition.posMasterTempId = employeeTempPosMaster.id;
|
||||||
|
if (
|
||||||
|
requestBody.typeDraft.toUpperCase() == "ORG_POSITION" ||
|
||||||
|
requestBody.typeDraft.toUpperCase() == "ORG_POSITION_ROLE"
|
||||||
|
) {
|
||||||
|
employeePosition.positionIsSelected = false;
|
||||||
|
}
|
||||||
|
employeePosition.createdUserId = request.user.sub;
|
||||||
|
employeePosition.createdFullName = request.user.name;
|
||||||
|
employeePosition.createdAt = new Date();
|
||||||
|
employeePosition.lastUpdateUserId = request.user.sub;
|
||||||
|
employeePosition.lastUpdateFullName = request.user.name;
|
||||||
|
employeePosition.lastUpdatedAt = new Date();
|
||||||
|
await this.employeePositionRepository.save(employeePosition);
|
||||||
|
});
|
||||||
|
}),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -1739,10 +1739,14 @@ export class ProfileController extends Controller {
|
||||||
orgRevision: { orgRevisionIsDraft: false, orgRevisionIsCurrent: true },
|
orgRevision: { orgRevisionIsDraft: false, orgRevisionIsCurrent: true },
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
return new HttpSuccess({ data: [], total: 0 });
|
if (!posMaster) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลการครองตำแหน่ง");
|
||||||
|
posMaster.current_holderId = "";
|
||||||
|
// return new HttpSuccess({ data: [], total: 0 });
|
||||||
} else if ((posMaster?.current_holder?.posLevel?.posLevelAuthority ?? null) == "GOVERNOR") {
|
} else if ((posMaster?.current_holder?.posLevel?.posLevelAuthority ?? null) == "GOVERNOR") {
|
||||||
return new HttpSuccess({ data: [], total: 0 });
|
return new HttpSuccess({ data: [], total: 0 });
|
||||||
}
|
}
|
||||||
|
console.log(posMaster);
|
||||||
|
console.log(posMaster.id);
|
||||||
let condition: any = {
|
let condition: any = {
|
||||||
orgRootId: posMaster.orgRootId,
|
orgRootId: posMaster.orgRootId,
|
||||||
id: Not(posMaster.current_holderId || ""),
|
id: Not(posMaster.current_holderId || ""),
|
||||||
|
|
@ -1772,6 +1776,9 @@ export class ProfileController extends Controller {
|
||||||
condition.isDirector = true;
|
condition.isDirector = true;
|
||||||
conditionNow.isDirector = true;
|
conditionNow.isDirector = true;
|
||||||
}
|
}
|
||||||
|
console.log(condition);
|
||||||
|
console.log("------------------");
|
||||||
|
console.log(conditionNow);
|
||||||
if (body.isAct == true) {
|
if (body.isAct == true) {
|
||||||
const [lists, total] = await AppDataSource.getRepository(viewDirectorActing)
|
const [lists, total] = await AppDataSource.getRepository(viewDirectorActing)
|
||||||
.createQueryBuilder("viewDirectorActing")
|
.createQueryBuilder("viewDirectorActing")
|
||||||
|
|
|
||||||
|
|
@ -2443,7 +2443,9 @@ export class ProfileEmployeeController extends Controller {
|
||||||
dateRetireLaw: profile.dateRetireLaw,
|
dateRetireLaw: profile.dateRetireLaw,
|
||||||
posMaster: posMaster == null ? null : posMaster.posMasterNo,
|
posMaster: posMaster == null ? null : posMaster.posMasterNo,
|
||||||
posMasterNo: posMaster == null ? null : posMaster.posMasterNo,
|
posMasterNo: posMaster == null ? null : posMaster.posMasterNo,
|
||||||
posLevelName: profile.posLevel == null ? null : profile.posLevel.posLevelName,
|
posLevelName: profile.posLevel == null && profile.posType == null
|
||||||
|
? null
|
||||||
|
: `${profile.posType.posTypeShortName} ${profile.posLevel.posLevelName}`,
|
||||||
posLevelRank: profile.posLevel == null ? null : profile.posLevel.posLevelRank,
|
posLevelRank: profile.posLevel == null ? null : profile.posLevel.posLevelRank,
|
||||||
posLevelId: profile.posLevel == null ? null : profile.posLevel.id,
|
posLevelId: profile.posLevel == null ? null : profile.posLevel.id,
|
||||||
posTypeName: profile.posType == null ? null : profile.posType.posTypeName,
|
posTypeName: profile.posType == null ? null : profile.posType.posTypeName,
|
||||||
|
|
@ -2834,7 +2836,9 @@ export class ProfileEmployeeController extends Controller {
|
||||||
posTypeId: item.posTypeId,
|
posTypeId: item.posTypeId,
|
||||||
posTypeName: item.posType?.posTypeName,
|
posTypeName: item.posType?.posTypeName,
|
||||||
posLevelId: item.posLevelId,
|
posLevelId: item.posLevelId,
|
||||||
posLevelName: item.posLevel?.posLevelName,
|
posLevelName: item.posLevel == null && item.posType == null
|
||||||
|
? null
|
||||||
|
: `${item.posType?.posTypeShortName} ${item.posLevel?.posLevelName}`,
|
||||||
educationDegree:
|
educationDegree:
|
||||||
latestProfileEducation != null && latestProfileEducation.educationLevel != null
|
latestProfileEducation != null && latestProfileEducation.educationLevel != null
|
||||||
? latestProfileEducation.educationLevel
|
? latestProfileEducation.educationLevel
|
||||||
|
|
@ -4633,7 +4637,9 @@ export class ProfileEmployeeController extends Controller {
|
||||||
posTypeId: item.posTypeId,
|
posTypeId: item.posTypeId,
|
||||||
posTypeName: item.posType?.posTypeName,
|
posTypeName: item.posType?.posTypeName,
|
||||||
posLevelId: item.posLevelId,
|
posLevelId: item.posLevelId,
|
||||||
posLevelName: item.posLevel?.posLevelName,
|
posLevelName: item.posLevel == null && item.posType == null
|
||||||
|
? null
|
||||||
|
: `${item.posType?.posTypeShortName} ${item.posLevel?.posLevelName}`,
|
||||||
educationDegree:
|
educationDegree:
|
||||||
latestProfileEducation != null && latestProfileEducation.educationLevel != null
|
latestProfileEducation != null && latestProfileEducation.educationLevel != null
|
||||||
? latestProfileEducation.educationLevel
|
? latestProfileEducation.educationLevel
|
||||||
|
|
|
||||||
|
|
@ -111,7 +111,7 @@ export class ProfileGovernmentEmployeeController extends Controller {
|
||||||
posLevel:
|
posLevel:
|
||||||
record.posType == null && record.posLevel == null
|
record.posType == null && record.posLevel == null
|
||||||
? null
|
? null
|
||||||
: `${record.posType.posTypeShortName}${record.posLevel.posLevelName}`, //ระดับ
|
: `${record.posType.posTypeShortName} ${record.posLevel.posLevelName}`, //ระดับ
|
||||||
posMasterNo: posMaster == null ? null : `${orgShortName} ${posMaster.posMasterNo}`, //เลขที่ตำแหน่ง
|
posMasterNo: posMaster == null ? null : `${orgShortName} ${posMaster.posMasterNo}`, //เลขที่ตำแหน่ง
|
||||||
posType: record.posType == null ? null : record.posType.posTypeName, //ประเภท
|
posType: record.posType == null ? null : record.posType.posTypeName, //ประเภท
|
||||||
dateLeave: record.birthDate == null ? null : calculateRetireDate(record.birthDate),
|
dateLeave: record.birthDate == null ? null : calculateRetireDate(record.birthDate),
|
||||||
|
|
@ -299,7 +299,9 @@ export class ProfileGovernmentEmployeeController extends Controller {
|
||||||
const data = {
|
const data = {
|
||||||
org: org, //สังกัด
|
org: org, //สังกัด
|
||||||
position: record.position, //ตำแหน่ง
|
position: record.position, //ตำแหน่ง
|
||||||
posLevel: record.posLevel == null ? null : record.posLevel.posLevelName, //ระดับ
|
posLevel: record.posLevel == null && record.posType == null
|
||||||
|
? null
|
||||||
|
: `${record.posType.posTypeShortName} ${record.posLevel.posLevelName}`, //ระดับ
|
||||||
posMasterNo: posMaster == null ? null : `${orgShortName} ${posMaster.posMasterNo}`, //เลขที่ตำแหน่ง
|
posMasterNo: posMaster == null ? null : `${orgShortName} ${posMaster.posMasterNo}`, //เลขที่ตำแหน่ง
|
||||||
posType: record.posType == null ? null : record.posType.posTypeName, //ประเภท
|
posType: record.posType == null ? null : record.posType.posTypeName, //ประเภท
|
||||||
dateLeave: record.birthDate == null ? null : calculateRetireDate(record.birthDate), //วันเกษียณ
|
dateLeave: record.birthDate == null ? null : calculateRetireDate(record.birthDate), //วันเกษียณ
|
||||||
|
|
|
||||||
|
|
@ -203,6 +203,13 @@ export class ProfileSalary extends EntityBase {
|
||||||
})
|
})
|
||||||
remark: string;
|
remark: string;
|
||||||
|
|
||||||
|
@Column({
|
||||||
|
nullable: true,
|
||||||
|
comment: "refId",
|
||||||
|
default: null,
|
||||||
|
})
|
||||||
|
refId: number;
|
||||||
|
|
||||||
@Column({
|
@Column({
|
||||||
comment: "วันที่",
|
comment: "วันที่",
|
||||||
type: "datetime",
|
type: "datetime",
|
||||||
|
|
@ -217,6 +224,13 @@ export class ProfileSalary extends EntityBase {
|
||||||
})
|
})
|
||||||
isGovernment: boolean;
|
isGovernment: boolean;
|
||||||
|
|
||||||
|
@Column({
|
||||||
|
nullable: true,
|
||||||
|
comment: "ข้อมูลจาก Entry",
|
||||||
|
default: null,
|
||||||
|
})
|
||||||
|
isEntry: boolean;
|
||||||
|
|
||||||
@Column({
|
@Column({
|
||||||
nullable: true,
|
nullable: true,
|
||||||
length: 40,
|
length: 40,
|
||||||
|
|
|
||||||
18
src/migration/1740561148833-updateprofilesalaryaddrefid.ts
Normal file
18
src/migration/1740561148833-updateprofilesalaryaddrefid.ts
Normal file
|
|
@ -0,0 +1,18 @@
|
||||||
|
import { MigrationInterface, QueryRunner } from "typeorm";
|
||||||
|
|
||||||
|
export class Updateprofilesalaryaddrefid1740561148833 implements MigrationInterface {
|
||||||
|
name = 'Updateprofilesalaryaddrefid1740561148833'
|
||||||
|
|
||||||
|
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||||
|
await queryRunner.query(`CREATE TABLE \`ProfileSalaries\` (\`id\` varchar(36) NOT NULL, \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT CURRENT_TIMESTAMP(6), \`createdUserId\` varchar(40) NOT NULL COMMENT 'User Id ที่สร้างข้อมูล' DEFAULT '00000000-0000-0000-0000-000000000000', \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6), \`lastUpdateUserId\` varchar(40) NOT NULL COMMENT 'User Id ที่แก้ไขข้อมูล' DEFAULT '00000000-0000-0000-0000-000000000000', \`createdFullName\` varchar(200) NOT NULL COMMENT 'ชื่อ User ที่สร้างข้อมูล' DEFAULT 'string', \`lastUpdateFullName\` varchar(200) NOT NULL COMMENT 'ชื่อ User ที่แก้ไขข้อมูลล่าสุด' DEFAULT 'string', \`Order\` int NULL, \`Date\` datetime NULL, \`SalaryRef\` varchar(255) NULL, \`Amount\` double NULL, \`PositionSalaryAmount\` double NULL, \`PosNoName\` varchar(255) NULL, \`PositionTypeName\` varchar(255) NULL, \`PositionLevelName\` varchar(255) NULL, \`PositionName\` varchar(255) NULL, \`ProfileId\` varchar(255) NULL, PRIMARY KEY (\`id\`)) ENGINE=InnoDB`);
|
||||||
|
await queryRunner.query(`ALTER TABLE \`profileSalary\` ADD \`refId\` int NULL COMMENT 'refId'`);
|
||||||
|
await queryRunner.query(`ALTER TABLE \`profileSalary\` ADD \`isEntry\` tinyint NULL COMMENT 'ข้อมูลจาก Entry'`);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||||
|
await queryRunner.query(`ALTER TABLE \`profileSalary\` DROP COLUMN \`isEntry\``);
|
||||||
|
await queryRunner.query(`ALTER TABLE \`profileSalary\` DROP COLUMN \`refId\``);
|
||||||
|
await queryRunner.query(`DROP TABLE \`ProfileSalaries\``);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -8,6 +8,9 @@ import HttpStatusCode from "../interfaces/http-status";
|
||||||
import { RequestWithUser } from "../middlewares/user";
|
import { RequestWithUser } from "../middlewares/user";
|
||||||
import { PosMaster } from "../entities/PosMaster";
|
import { PosMaster } from "../entities/PosMaster";
|
||||||
import { Profile } from "../entities/Profile";
|
import { Profile } from "../entities/Profile";
|
||||||
|
import { EmployeePosMaster } from "../entities/EmployeePosMaster";
|
||||||
|
import { EmployeeTempPosMaster } from "../entities/EmployeeTempPosMaster";
|
||||||
|
import { ProfileEmployee } from "../entities/ProfileEmployee";
|
||||||
|
|
||||||
export let sendToQueue: (payload: any) => void;
|
export let sendToQueue: (payload: any) => void;
|
||||||
export let sendToQueueOrg: (payload: any) => void;
|
export let sendToQueueOrg: (payload: any) => void;
|
||||||
|
|
@ -42,7 +45,7 @@ export async function init() {
|
||||||
|
|
||||||
console.log("[AMQ] Listening for message...");
|
console.log("[AMQ] Listening for message...");
|
||||||
createConsumer(queue, channel, handler), //----> (3) Process Consumer
|
createConsumer(queue, channel, handler), //----> (3) Process Consumer
|
||||||
createConsumer(queue_org, channel, handler_org);
|
createConsumer(queue_org, channel, handler_org);
|
||||||
// createConsumer(queue2, channel, handler2);
|
// createConsumer(queue2, channel, handler2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -125,7 +128,10 @@ async function handler(msg: amqp.ConsumeMessage): Promise<boolean> {
|
||||||
async function handler_org(msg: amqp.ConsumeMessage): Promise<boolean> {
|
async function handler_org(msg: amqp.ConsumeMessage): Promise<boolean> {
|
||||||
//----> condition before process consume
|
//----> condition before process consume
|
||||||
const repoPosmaster = AppDataSource.getRepository(PosMaster);
|
const repoPosmaster = AppDataSource.getRepository(PosMaster);
|
||||||
|
const repoEmployeePosmaster = AppDataSource.getRepository(EmployeePosMaster);
|
||||||
|
const repoEmployeeTempPosmaster = AppDataSource.getRepository(EmployeeTempPosMaster);
|
||||||
const repoProfile = AppDataSource.getRepository(Profile);
|
const repoProfile = AppDataSource.getRepository(Profile);
|
||||||
|
const repoProfileEmployee = AppDataSource.getRepository(ProfileEmployee);
|
||||||
const { data, token, user } = JSON.parse(msg.content.toString());
|
const { data, token, user } = JSON.parse(msg.content.toString());
|
||||||
const { id, status, lastUpdateUserId, lastUpdateFullName, lastUpdatedAt } = data;
|
const { id, status, lastUpdateUserId, lastUpdateFullName, lastUpdatedAt } = data;
|
||||||
try {
|
try {
|
||||||
|
|
@ -166,6 +172,60 @@ async function handler_org(msg: amqp.ConsumeMessage): Promise<boolean> {
|
||||||
await repoPosmaster.save(item).catch((e) => console.log(e));
|
await repoPosmaster.save(item).catch((e) => console.log(e));
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
const employeePosMaster = await repoEmployeePosmaster.find({
|
||||||
|
where: { orgRevisionId: id },
|
||||||
|
relations: ["positions", "positions.posLevel", "positions.posType"],
|
||||||
|
});
|
||||||
|
await Promise.all(
|
||||||
|
employeePosMaster.map(async (item) => {
|
||||||
|
if (item.next_holderId != null && status == "NOW") {
|
||||||
|
const profile = await repoProfileEmployee.findOne({
|
||||||
|
where: { id: item.next_holderId == null ? "" : item.next_holderId },
|
||||||
|
});
|
||||||
|
const position = await item.positions.find((x) => x.positionIsSelected == true);
|
||||||
|
const _null: any = null;
|
||||||
|
if (profile != null) {
|
||||||
|
profile.posLevelId = position?.posLevelId ?? _null;
|
||||||
|
profile.posTypeId = position?.posTypeId ?? _null;
|
||||||
|
profile.position = position?.positionName ?? _null;
|
||||||
|
await repoProfileEmployee.save(profile);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// item.current_holderId = item.next_holderId;
|
||||||
|
// item.next_holderId = null;
|
||||||
|
item.lastUpdateUserId = lastUpdateUserId;
|
||||||
|
item.lastUpdateFullName = lastUpdateFullName;
|
||||||
|
item.lastUpdatedAt = lastUpdatedAt;
|
||||||
|
await repoEmployeePosmaster.save(item).catch((e) => console.log(e));
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
const employeeTempPosMaster = await repoEmployeeTempPosmaster.find({
|
||||||
|
where: { orgRevisionId: id },
|
||||||
|
relations: ["positions", "positions.posLevel", "positions.posType"],
|
||||||
|
});
|
||||||
|
await Promise.all(
|
||||||
|
employeeTempPosMaster.map(async (item) => {
|
||||||
|
if (item.next_holderId != null && status == "NOW") {
|
||||||
|
const profile = await repoProfileEmployee.findOne({
|
||||||
|
where: { id: item.next_holderId == null ? "" : item.next_holderId },
|
||||||
|
});
|
||||||
|
const position = await item.positions.find((x) => x.positionIsSelected == true);
|
||||||
|
const _null: any = null;
|
||||||
|
if (profile != null) {
|
||||||
|
profile.posLevelId = position?.posLevelId ?? _null;
|
||||||
|
profile.posTypeId = position?.posTypeId ?? _null;
|
||||||
|
profile.position = position?.positionName ?? _null;
|
||||||
|
await repoProfileEmployee.save(profile);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// item.current_holderId = item.next_holderId;
|
||||||
|
// item.next_holderId = null;
|
||||||
|
item.lastUpdateUserId = lastUpdateUserId;
|
||||||
|
item.lastUpdateFullName = lastUpdateFullName;
|
||||||
|
item.lastUpdatedAt = lastUpdatedAt;
|
||||||
|
await repoEmployeeTempPosmaster.save(item).catch((e) => console.log(e));
|
||||||
|
}),
|
||||||
|
);
|
||||||
console.log("[AMQ] Excecute Organization Success");
|
console.log("[AMQ] Excecute Organization Success");
|
||||||
return true;
|
return true;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|
@ -173,4 +233,3 @@ async function handler_org(msg: amqp.ConsumeMessage): Promise<boolean> {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue