This commit is contained in:
adisak 2025-09-02 10:36:56 +07:00
parent f192c4ed0e
commit 4075f5e55f
4 changed files with 21 additions and 19 deletions

View file

@ -3166,6 +3166,11 @@ export class CommandController extends Controller {
posMaster.lastUpdatedAt = new Date(); posMaster.lastUpdatedAt = new Date();
posMaster.conditionReason = _null; posMaster.conditionReason = _null;
posMaster.isCondition = false; posMaster.isCondition = false;
if (posMasterOld != null) {
await this.posMasterRepository.save(posMasterOld);
await CreatePosMasterHistoryOfficer(posMasterOld.id, req);
}
await this.posMasterRepository.save(posMaster);
const positionNew = await this.positionRepository.findOne({ const positionNew = await this.positionRepository.findOne({
where: { where: {
@ -3183,12 +3188,6 @@ export class CommandController extends Controller {
await this.profileRepository.save(profile); await this.profileRepository.save(profile);
await this.positionRepository.save(positionNew); await this.positionRepository.save(positionNew);
} }
if (posMasterOld != null) {
await this.posMasterRepository.save(posMasterOld);
await CreatePosMasterHistoryOfficer(posMasterOld.id, req);
}
await this.posMasterRepository.save(posMaster);
await CreatePosMasterHistoryOfficer(posMaster.id, req); await CreatePosMasterHistoryOfficer(posMaster.id, req);
}), }),
); );
@ -3359,12 +3358,6 @@ export class CommandController extends Controller {
posMaster.current_holderId = item.profileId; posMaster.current_holderId = item.profileId;
posMaster.lastUpdatedAt = new Date(); posMaster.lastUpdatedAt = new Date();
posMaster.next_holderId = null; posMaster.next_holderId = null;
if (posMasterOld != null) {
await this.employeePosMasterRepository.save(posMasterOld);
await CreatePosMasterHistoryEmployee(posMasterOld.id, req);
}
await this.employeePosMasterRepository.save(posMaster);
await CreatePosMasterHistoryEmployee(posMaster.id, req);
const positionNew = await this.employeePositionRepository.findOne({ const positionNew = await this.employeePositionRepository.findOne({
where: { where: {
@ -3384,6 +3377,13 @@ export class CommandController extends Controller {
await this.profileEmployeeRepository.save(profile); await this.profileEmployeeRepository.save(profile);
await this.employeePositionRepository.save(positionNew); await this.employeePositionRepository.save(positionNew);
} }
if (posMasterOld != null) {
await this.employeePosMasterRepository.save(posMasterOld);
await CreatePosMasterHistoryEmployee(posMasterOld.id, req);
}
await this.employeePosMasterRepository.save(posMaster);
await CreatePosMasterHistoryEmployee(posMaster.id, req);
}), }),
); );
@ -6057,8 +6057,7 @@ export class CommandController extends Controller {
await CreatePosMasterHistoryOfficer(posMasterOld.id, req); await CreatePosMasterHistoryOfficer(posMasterOld.id, req);
} }
await this.posMasterRepository.save(posMaster); await this.posMasterRepository.save(posMaster);
await CreatePosMasterHistoryOfficer(posMaster.id, req);
const positionNew = await this.positionRepository.findOne({ const positionNew = await this.positionRepository.findOne({
where: { where: {
id: item.bodyPosition.positionId, id: item.bodyPosition.positionId,
@ -6075,6 +6074,7 @@ export class CommandController extends Controller {
setLogDataDiff(req, { before, after: profile }); setLogDataDiff(req, { before, after: profile });
await this.positionRepository.save(positionNew, { data: req }); await this.positionRepository.save(positionNew, { data: req });
} }
await CreatePosMasterHistoryOfficer(posMaster.id, req);
} }
// Insignia // Insignia
if (_oldInsigniaIds.length > 0) { if (_oldInsigniaIds.length > 0) {
@ -6442,7 +6442,6 @@ export class CommandController extends Controller {
await CreatePosMasterHistoryEmployee(posMasterOld.id, req); await CreatePosMasterHistoryEmployee(posMasterOld.id, req);
} }
await this.employeePosMasterRepository.save(posMaster); await this.employeePosMasterRepository.save(posMaster);
await CreatePosMasterHistoryEmployee(posMaster.id, req);
const clsTempPosmaster = await this.employeeTempPosMasterRepository.find({ const clsTempPosmaster = await this.employeeTempPosMasterRepository.find({
where: { where: {
@ -6571,6 +6570,8 @@ export class CommandController extends Controller {
}); });
await this.profileEmployeeRepository.save(profile); await this.profileEmployeeRepository.save(profile);
await this.employeePositionRepository.save(positionNew); await this.employeePositionRepository.save(positionNew);
await CreatePosMasterHistoryEmployee(posMaster.id, req);
//ลบออกคนออกจากโครงสร้างลูกจ้างชั่วคราว //ลบออกคนออกจากโครงสร้างลูกจ้างชั่วคราว
const posMasterTemp = await this.employeeTempPosMasterRepository.findOne({ const posMasterTemp = await this.employeeTempPosMasterRepository.findOne({
where: { where: {

View file

@ -2451,7 +2451,6 @@ export class EmployeePositionController extends Controller {
await CreatePosMasterHistoryEmployee(posMasterOld.id, request); await CreatePosMasterHistoryEmployee(posMasterOld.id, request);
} }
await this.employeePosMasterRepository.save(posMaster); await this.employeePosMasterRepository.save(posMaster);
await CreatePosMasterHistoryEmployee(posMaster.id, request);
const positionNew = await this.employeePositionRepository.findOne({ const positionNew = await this.employeePositionRepository.findOne({
where: { where: {
@ -2472,6 +2471,7 @@ export class EmployeePositionController extends Controller {
await this.profileRepository.save(profile); await this.profileRepository.save(profile);
await this.employeePositionRepository.save(positionNew); await this.employeePositionRepository.save(positionNew);
} }
await CreatePosMasterHistoryEmployee(posMaster.id, request);
return new HttpSuccess(); return new HttpSuccess();
} }

View file

@ -2187,7 +2187,6 @@ export class EmployeeTempPositionController extends Controller {
await CreatePosMasterHistoryEmployeeTemp(posMasterOld.id, request); await CreatePosMasterHistoryEmployeeTemp(posMasterOld.id, request);
} }
await this.employeeTempPosMasterRepository.save(posMaster); await this.employeeTempPosMasterRepository.save(posMaster);
await CreatePosMasterHistoryEmployeeTemp(posMaster.id, request);
const positionNew = await this.employeePositionRepository.findOne({ const positionNew = await this.employeePositionRepository.findOne({
where: { where: {
@ -2208,6 +2207,7 @@ export class EmployeeTempPositionController extends Controller {
await this.profileRepository.save(profile); await this.profileRepository.save(profile);
await this.employeePositionRepository.save(positionNew); await this.employeePositionRepository.save(positionNew);
} }
await CreatePosMasterHistoryEmployeeTemp(posMaster.id, request);
return new HttpSuccess(); return new HttpSuccess();
} }

View file

@ -4924,8 +4924,7 @@ export class PositionController extends Controller {
await CreatePosMasterHistoryOfficer(posMasterOld.id, request); await CreatePosMasterHistoryOfficer(posMasterOld.id, request);
} }
await this.posMasterRepository.save(posMaster); await this.posMasterRepository.save(posMaster);
await CreatePosMasterHistoryOfficer(posMaster.id, request);
const positionNew = await this.positionRepository.findOne({ const positionNew = await this.positionRepository.findOne({
where: { where: {
id: body.positionId, id: body.positionId,
@ -4940,6 +4939,8 @@ export class PositionController extends Controller {
await this.profileRepository.save(profile); await this.profileRepository.save(profile);
await this.positionRepository.save(positionNew); await this.positionRepository.save(positionNew);
} }
await CreatePosMasterHistoryOfficer(posMaster.id, request);
return new HttpSuccess(); return new HttpSuccess();
} }