Merge branch 'develop' into adiDev
This commit is contained in:
commit
87aa4a2b3d
1 changed files with 88 additions and 14 deletions
|
|
@ -3325,6 +3325,16 @@ export class CommandController extends Controller {
|
||||||
positionTypeNew?: string | null;
|
positionTypeNew?: string | null;
|
||||||
positionLevelNew?: string | null;
|
positionLevelNew?: string | null;
|
||||||
positionNameNew?: string | null;
|
positionNameNew?: string | null;
|
||||||
|
posmasterId?: string| null;
|
||||||
|
posTypeNameNew?: string | null;
|
||||||
|
posLevelNameNew?: string | null;
|
||||||
|
posNoNew?: string | null;
|
||||||
|
posNoAbbNew?: string | null;
|
||||||
|
orgRootNew?: string | null;
|
||||||
|
orgChild1New?: string | null;
|
||||||
|
orgChild2New?: string | null;
|
||||||
|
orgChild3New?: string | null;
|
||||||
|
orgChild4New?: string | null;
|
||||||
}[];
|
}[];
|
||||||
},
|
},
|
||||||
) {
|
) {
|
||||||
|
|
@ -3383,16 +3393,18 @@ export class CommandController extends Controller {
|
||||||
if (!profile) {
|
if (!profile) {
|
||||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลทะเบียนประวัตินี้");
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลทะเบียนประวัตินี้");
|
||||||
}
|
}
|
||||||
|
const returnWork = await checkReturnCommandType(String(item.commandId));
|
||||||
const dest_item = await this.salaryRepo.findOne({
|
const dest_item = await this.salaryRepo.findOne({
|
||||||
where: { profileId: item.profileId },
|
where: { profileId: item.profileId },
|
||||||
order: { order: "DESC" },
|
order: { order: "DESC" },
|
||||||
});
|
});
|
||||||
const before = null;
|
const before = null;
|
||||||
const data = new ProfileSalary();
|
const data = new ProfileSalary();
|
||||||
|
data.posNumCodeSit = _posNumCodeSit;
|
||||||
|
data.posNumCodeSitAbb = _posNumCodeSitAbb;
|
||||||
|
data.dateGovernment = new Date();
|
||||||
|
data.order = dest_item == null ? 1 : dest_item.order + 1;
|
||||||
const meta = {
|
const meta = {
|
||||||
order: dest_item == null ? 1 : dest_item.order + 1,
|
|
||||||
createdUserId: req.user.sub,
|
createdUserId: req.user.sub,
|
||||||
createdFullName: req.user.name,
|
createdFullName: req.user.name,
|
||||||
lastUpdateUserId: req.user.sub,
|
lastUpdateUserId: req.user.sub,
|
||||||
|
|
@ -3400,16 +3412,15 @@ export class CommandController extends Controller {
|
||||||
createdAt: new Date(),
|
createdAt: new Date(),
|
||||||
lastUpdatedAt: new Date(),
|
lastUpdatedAt: new Date(),
|
||||||
};
|
};
|
||||||
data.posNumCodeSit = _posNumCodeSit;
|
if(!returnWork) {
|
||||||
data.posNumCodeSitAbb = _posNumCodeSitAbb;
|
Object.assign(data, { ...item, ...meta });
|
||||||
Object.assign(data, { ...item, ...meta });
|
const history = new ProfileSalaryHistory();
|
||||||
const history = new ProfileSalaryHistory();
|
Object.assign(history, { ...data, id: undefined });
|
||||||
Object.assign(history, { ...data, id: undefined });
|
await this.salaryRepo.save(data, { data: req });
|
||||||
data.dateGovernment = meta.createdAt;
|
setLogDataDiff(req, { before, after: data });
|
||||||
await this.salaryRepo.save(data, { data: req });
|
history.profileSalaryId = data.id;
|
||||||
setLogDataDiff(req, { before, after: data });
|
await this.salaryHistoryRepo.save(history, { data: req });
|
||||||
history.profileSalaryId = data.id;
|
}
|
||||||
await this.salaryHistoryRepo.save(history, { data: req });
|
|
||||||
|
|
||||||
const _null: any = null;
|
const _null: any = null;
|
||||||
profile.isLeave = item.isLeave;
|
profile.isLeave = item.isLeave;
|
||||||
|
|
@ -3442,8 +3453,71 @@ export class CommandController extends Controller {
|
||||||
// profile.posLevelId = _null;
|
// profile.posLevelId = _null;
|
||||||
}
|
}
|
||||||
if (item.isGovernment == true) {
|
if (item.isGovernment == true) {
|
||||||
const returnWork = await checkReturnCommandType(String(item.commandId));
|
|
||||||
if (returnWork) {
|
if (returnWork) {
|
||||||
|
//ปลดตำแหน่งเดิมที่ไม่ถูกปลดออกจากกิ่งครั้งเมื่อออกคำสั่งพักราชการหรือออกราชการไว้
|
||||||
|
await removeProfileInOrganize(profile.id, "OFFICER");
|
||||||
|
//ปั๊มตำแหน่งใหม่
|
||||||
|
const posMaster = await this.posMasterRepository.findOne({
|
||||||
|
where: { id: item.posmasterId?.toString() },
|
||||||
|
});
|
||||||
|
if (posMaster) {
|
||||||
|
const checkPosition = await this.positionRepository.find({
|
||||||
|
where: {
|
||||||
|
posMasterId: posMaster.id,
|
||||||
|
positionIsSelected: true,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
if (checkPosition.length > 0) {
|
||||||
|
const clearPosition = checkPosition.map((positions) => ({
|
||||||
|
...positions,
|
||||||
|
positionIsSelected: false,
|
||||||
|
}));
|
||||||
|
await this.positionRepository.save(clearPosition);
|
||||||
|
}
|
||||||
|
posMaster.current_holderId = profile.id;
|
||||||
|
await this.posMasterRepository.save(posMaster);
|
||||||
|
const positionNew = await this.positionRepository.findOne({
|
||||||
|
where: {
|
||||||
|
posMasterId: posMaster.id,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
if(positionNew) {
|
||||||
|
positionNew.positionIsSelected = true;
|
||||||
|
await this.positionRepository.save(positionNew, { data: req });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
const newMapProfileSalary = {
|
||||||
|
profileId: profile.id,
|
||||||
|
commandId: item.commandId,
|
||||||
|
positionName: item.positionNameNew ?? null,
|
||||||
|
positionType: item.posTypeNameNew ?? null,
|
||||||
|
positionLevel: item.posLevelNameNew ?? null,
|
||||||
|
amount: item.amount ? item.amount : null,
|
||||||
|
positionSalaryAmount: item.positionSalaryAmount ? item.positionSalaryAmount : null,
|
||||||
|
amountSpecial: item.amountSpecial ? item.amountSpecial : null,
|
||||||
|
mouthSalaryAmount: item.mouthSalaryAmount ? item.mouthSalaryAmount : null,
|
||||||
|
posNo: item.posNoNew,
|
||||||
|
posNoAbb: item.posNoAbbNew,
|
||||||
|
orgRoot: item.orgRootNew,
|
||||||
|
orgChild1: item.orgChild1New,
|
||||||
|
orgChild2: item.orgChild2New,
|
||||||
|
orgChild3: item.orgChild3New,
|
||||||
|
orgChild4: item.orgChild4New,
|
||||||
|
isGovernment: item.isGovernment,
|
||||||
|
commandNo: item.commandNo,
|
||||||
|
commandYear: item.commandYear,
|
||||||
|
commandDateAffect: item.commandDateAffect,
|
||||||
|
commandDateSign: item.commandDateSign,
|
||||||
|
commandCode: item.commandCode,
|
||||||
|
commandName: item.commandName,
|
||||||
|
remark: item.remark,
|
||||||
|
};
|
||||||
|
Object.assign(data, {...newMapProfileSalary, ...meta});
|
||||||
|
const history = new ProfileSalaryHistory();
|
||||||
|
Object.assign(history, { ...data, id: undefined });
|
||||||
|
await this.salaryRepo.save(data);
|
||||||
|
history.profileSalaryId = data.id;
|
||||||
|
await this.salaryHistoryRepo.save(history);
|
||||||
profile.leaveReason = _null;
|
profile.leaveReason = _null;
|
||||||
profile.leaveCommandId = _null;
|
profile.leaveCommandId = _null;
|
||||||
profile.leaveCommandNo = _null;
|
profile.leaveCommandNo = _null;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue