สลับสำเนา
This commit is contained in:
parent
637916e5d8
commit
dc9ac66896
1 changed files with 195 additions and 192 deletions
|
|
@ -1152,7 +1152,7 @@ export class CommandController extends Controller {
|
||||||
const msgNoti = {
|
const msgNoti = {
|
||||||
data: {
|
data: {
|
||||||
command: command,
|
command: command,
|
||||||
profiles: profiles
|
profiles: profiles,
|
||||||
},
|
},
|
||||||
user: request.user,
|
user: request.user,
|
||||||
token: request.headers["authorization"],
|
token: request.headers["authorization"],
|
||||||
|
|
@ -1989,6 +1989,199 @@ export class CommandController extends Controller {
|
||||||
);
|
);
|
||||||
})
|
})
|
||||||
.catch(() => {});
|
.catch(() => {});
|
||||||
|
|
||||||
|
if (
|
||||||
|
[
|
||||||
|
"C-PM-01",
|
||||||
|
"C-PM-02",
|
||||||
|
"C-PM-03",
|
||||||
|
"C-PM-04",
|
||||||
|
"C-PM-05",
|
||||||
|
"C-PM-07",
|
||||||
|
"C-PM-08",
|
||||||
|
"C-PM-09",
|
||||||
|
"C-PM-13",
|
||||||
|
"C-PM-14",
|
||||||
|
"C-PM-15",
|
||||||
|
"C-PM-16",
|
||||||
|
"C-PM-21",
|
||||||
|
"C-PM-22",
|
||||||
|
"C-PM-24",
|
||||||
|
"C-PM-39",
|
||||||
|
].includes(commandCode)
|
||||||
|
) {
|
||||||
|
const _posMasterCommission = await this.posMasterRepository.findOne({
|
||||||
|
where: {
|
||||||
|
orgRoot: {
|
||||||
|
isCommission: true,
|
||||||
|
},
|
||||||
|
isDirector: true,
|
||||||
|
orgChild1: IsNull(),
|
||||||
|
orgRevision: { orgRevisionIsDraft: false, orgRevisionIsCurrent: true },
|
||||||
|
current_holderId: Not(IsNull()),
|
||||||
|
},
|
||||||
|
relations: ["current_holder", "orgRoot", "positions"],
|
||||||
|
order: { posMasterOrder: "ASC" },
|
||||||
|
});
|
||||||
|
let _commandSend = await this.commandSendRepository.findOne({
|
||||||
|
where: {
|
||||||
|
commandId: command.id,
|
||||||
|
profileId: _posMasterCommission?.current_holder.id ?? _null,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
if (!_commandSend && _posMasterCommission != null) {
|
||||||
|
let commandSend = new CommandSend();
|
||||||
|
commandSend.citizenId = _posMasterCommission?.current_holder.citizenId ?? _null;
|
||||||
|
commandSend.prefix = _posMasterCommission?.current_holder.prefix ?? _null;
|
||||||
|
commandSend.firstName = _posMasterCommission?.current_holder.firstName ?? _null;
|
||||||
|
commandSend.lastName = _posMasterCommission?.current_holder.lastName ?? _null;
|
||||||
|
commandSend.position = _posMasterCommission?.current_holder.position ?? _null;
|
||||||
|
commandSend.org =
|
||||||
|
_posMasterCommission && _posMasterCommission.orgRoot
|
||||||
|
? _posMasterCommission.orgRoot.orgRootName
|
||||||
|
: _null;
|
||||||
|
commandSend.profileId = _posMasterCommission?.current_holderId ?? _null;
|
||||||
|
commandSend.commandId = command.id;
|
||||||
|
commandSend.createdUserId = request.user.sub;
|
||||||
|
commandSend.createdFullName = request.user.name;
|
||||||
|
commandSend.createdAt = new Date();
|
||||||
|
commandSend.lastUpdateUserId = request.user.sub;
|
||||||
|
commandSend.lastUpdateFullName = request.user.name;
|
||||||
|
commandSend.lastUpdatedAt = new Date();
|
||||||
|
await this.commandSendRepository.save(commandSend);
|
||||||
|
if (commandSend && commandSend.id) {
|
||||||
|
let _ccName = new Array("EMAIL", "INBOX");
|
||||||
|
let _dataSendCC = new Array();
|
||||||
|
for (let i = 0; i < _ccName.length; i++) {
|
||||||
|
_dataSendCC.push({
|
||||||
|
commandSendId: commandSend.id,
|
||||||
|
name: _ccName[i],
|
||||||
|
createdUserId: request.user.sub,
|
||||||
|
createdFullName: request.user.name,
|
||||||
|
createdAt: new Date(),
|
||||||
|
lastUpdateUserId: request.user.sub,
|
||||||
|
lastUpdateFullName: request.user.name,
|
||||||
|
lastUpdatedAt: new Date(),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
await this.commandSendCCRepository.save(_dataSendCC);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
const _posMasterInformation = await this.posMasterRepository.findOne({
|
||||||
|
where: {
|
||||||
|
orgChild1: {
|
||||||
|
isInformation: true,
|
||||||
|
},
|
||||||
|
isDirector: true,
|
||||||
|
orgChild2: IsNull(),
|
||||||
|
orgRevision: { orgRevisionIsDraft: false, orgRevisionIsCurrent: true },
|
||||||
|
current_holderId: Not(IsNull()),
|
||||||
|
},
|
||||||
|
relations: ["current_holder", "orgRoot", "positions"],
|
||||||
|
order: { posMasterOrder: "ASC" },
|
||||||
|
});
|
||||||
|
_commandSend = await this.commandSendRepository.findOne({
|
||||||
|
where: {
|
||||||
|
commandId: command.id,
|
||||||
|
profileId: _posMasterInformation?.current_holder.id ?? _null,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
if (!_commandSend && _posMasterInformation != null) {
|
||||||
|
let commandSend = new CommandSend();
|
||||||
|
commandSend.citizenId = _posMasterInformation?.current_holder.citizenId ?? _null;
|
||||||
|
commandSend.prefix = _posMasterInformation?.current_holder.prefix ?? _null;
|
||||||
|
commandSend.firstName = _posMasterInformation?.current_holder.firstName ?? _null;
|
||||||
|
commandSend.lastName = _posMasterInformation?.current_holder.lastName ?? _null;
|
||||||
|
commandSend.position = _posMasterInformation?.current_holder.position ?? _null;
|
||||||
|
commandSend.org =
|
||||||
|
_posMasterInformation && _posMasterInformation.orgRoot
|
||||||
|
? _posMasterInformation.orgRoot.orgRootName
|
||||||
|
: _null;
|
||||||
|
commandSend.profileId = _posMasterInformation?.current_holderId ?? _null;
|
||||||
|
commandSend.commandId = command.id;
|
||||||
|
commandSend.createdUserId = request.user.sub;
|
||||||
|
commandSend.createdFullName = request.user.name;
|
||||||
|
commandSend.createdAt = new Date();
|
||||||
|
commandSend.lastUpdateUserId = request.user.sub;
|
||||||
|
commandSend.lastUpdateFullName = request.user.name;
|
||||||
|
commandSend.lastUpdatedAt = new Date();
|
||||||
|
await this.commandSendRepository.save(commandSend);
|
||||||
|
if (commandSend && commandSend.id) {
|
||||||
|
let _ccName = new Array("EMAIL", "INBOX");
|
||||||
|
let _dataSendCC = new Array();
|
||||||
|
for (let i = 0; i < _ccName.length; i++) {
|
||||||
|
_dataSendCC.push({
|
||||||
|
commandSendId: commandSend.id,
|
||||||
|
name: _ccName[i],
|
||||||
|
createdUserId: request.user.sub,
|
||||||
|
createdFullName: request.user.name,
|
||||||
|
createdAt: new Date(),
|
||||||
|
lastUpdateUserId: request.user.sub,
|
||||||
|
lastUpdateFullName: request.user.name,
|
||||||
|
lastUpdatedAt: new Date(),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
await this.commandSendCCRepository.save(_dataSendCC);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
const _posMasterOfficer = await this.posMasterRepository.findOne({
|
||||||
|
where: {
|
||||||
|
orgChild1: {
|
||||||
|
isOfficer: true,
|
||||||
|
},
|
||||||
|
isDirector: true,
|
||||||
|
orgChild2: IsNull(),
|
||||||
|
orgRevision: { orgRevisionIsDraft: false, orgRevisionIsCurrent: true },
|
||||||
|
current_holderId: Not(IsNull()),
|
||||||
|
},
|
||||||
|
relations: ["current_holder", "orgRoot", "positions"],
|
||||||
|
order: { posMasterOrder: "ASC" },
|
||||||
|
});
|
||||||
|
_commandSend = await this.commandSendRepository.findOne({
|
||||||
|
where: {
|
||||||
|
commandId: command.id,
|
||||||
|
profileId: _posMasterOfficer?.current_holder.id ?? _null,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
if (!_commandSend && _posMasterOfficer != null) {
|
||||||
|
let commandSend = new CommandSend();
|
||||||
|
commandSend.citizenId = _posMasterOfficer?.current_holder.citizenId ?? _null;
|
||||||
|
commandSend.prefix = _posMasterOfficer?.current_holder.prefix ?? _null;
|
||||||
|
commandSend.firstName = _posMasterOfficer?.current_holder.firstName ?? _null;
|
||||||
|
commandSend.lastName = _posMasterOfficer?.current_holder.lastName ?? _null;
|
||||||
|
commandSend.position = _posMasterOfficer?.current_holder.position ?? _null;
|
||||||
|
commandSend.org =
|
||||||
|
_posMasterOfficer && _posMasterOfficer.orgRoot
|
||||||
|
? _posMasterOfficer.orgRoot.orgRootName
|
||||||
|
: _null;
|
||||||
|
commandSend.profileId = _posMasterOfficer?.current_holderId ?? _null;
|
||||||
|
commandSend.commandId = command.id;
|
||||||
|
commandSend.createdUserId = request.user.sub;
|
||||||
|
commandSend.createdFullName = request.user.name;
|
||||||
|
commandSend.createdAt = new Date();
|
||||||
|
commandSend.lastUpdateUserId = request.user.sub;
|
||||||
|
commandSend.lastUpdateFullName = request.user.name;
|
||||||
|
commandSend.lastUpdatedAt = new Date();
|
||||||
|
await this.commandSendRepository.save(commandSend);
|
||||||
|
if (commandSend && commandSend.id) {
|
||||||
|
let _ccName = new Array("EMAIL", "INBOX");
|
||||||
|
let _dataSendCC = new Array();
|
||||||
|
for (let i = 0; i < _ccName.length; i++) {
|
||||||
|
_dataSendCC.push({
|
||||||
|
commandSendId: commandSend.id,
|
||||||
|
name: _ccName[i],
|
||||||
|
createdUserId: request.user.sub,
|
||||||
|
createdFullName: request.user.name,
|
||||||
|
createdAt: new Date(),
|
||||||
|
lastUpdateUserId: request.user.sub,
|
||||||
|
lastUpdateFullName: request.user.name,
|
||||||
|
lastUpdatedAt: new Date(),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
await this.commandSendCCRepository.save(_dataSendCC);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
if (!["C-PM-10"].includes(commandCode)) {
|
if (!["C-PM-10"].includes(commandCode)) {
|
||||||
if (requestBody.persons != undefined && requestBody.persons.length > 0) {
|
if (requestBody.persons != undefined && requestBody.persons.length > 0) {
|
||||||
let _orgRoot: any = [];
|
let _orgRoot: any = [];
|
||||||
|
|
@ -2292,196 +2485,6 @@ export class CommandController extends Controller {
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (
|
|
||||||
[
|
|
||||||
"C-PM-01",
|
|
||||||
"C-PM-02",
|
|
||||||
"C-PM-03",
|
|
||||||
"C-PM-04",
|
|
||||||
"C-PM-05",
|
|
||||||
"C-PM-07",
|
|
||||||
"C-PM-08",
|
|
||||||
"C-PM-09",
|
|
||||||
"C-PM-13",
|
|
||||||
"C-PM-14",
|
|
||||||
"C-PM-15",
|
|
||||||
"C-PM-16",
|
|
||||||
"C-PM-21",
|
|
||||||
"C-PM-22",
|
|
||||||
"C-PM-24",
|
|
||||||
"C-PM-39",
|
|
||||||
].includes(commandCode)
|
|
||||||
) {
|
|
||||||
const _posMasterCommission = await this.posMasterRepository.findOne({
|
|
||||||
where: {
|
|
||||||
orgRoot: {
|
|
||||||
isCommission: true,
|
|
||||||
},
|
|
||||||
isDirector: true,
|
|
||||||
orgChild1: IsNull(),
|
|
||||||
orgRevision: { orgRevisionIsDraft: false, orgRevisionIsCurrent: true },
|
|
||||||
current_holderId: Not(IsNull()),
|
|
||||||
},
|
|
||||||
relations: ["current_holder", "orgRoot", "positions"],
|
|
||||||
});
|
|
||||||
let _commandSend = await this.commandSendRepository.findOne({
|
|
||||||
where: {
|
|
||||||
commandId: command.id,
|
|
||||||
profileId: _posMasterCommission?.current_holder.id ?? _null,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
if (!_commandSend && _posMasterCommission != null) {
|
|
||||||
let commandSend = new CommandSend();
|
|
||||||
commandSend.citizenId = _posMasterCommission?.current_holder.citizenId ?? _null;
|
|
||||||
commandSend.prefix = _posMasterCommission?.current_holder.prefix ?? _null;
|
|
||||||
commandSend.firstName = _posMasterCommission?.current_holder.firstName ?? _null;
|
|
||||||
commandSend.lastName = _posMasterCommission?.current_holder.lastName ?? _null;
|
|
||||||
commandSend.position = _posMasterCommission?.current_holder.position ?? _null;
|
|
||||||
commandSend.org =
|
|
||||||
_posMasterCommission && _posMasterCommission.orgRoot
|
|
||||||
? _posMasterCommission.orgRoot.orgRootName
|
|
||||||
: _null;
|
|
||||||
commandSend.profileId = _posMasterCommission?.current_holderId ?? _null;
|
|
||||||
commandSend.commandId = command.id;
|
|
||||||
commandSend.createdUserId = request.user.sub;
|
|
||||||
commandSend.createdFullName = request.user.name;
|
|
||||||
commandSend.createdAt = new Date();
|
|
||||||
commandSend.lastUpdateUserId = request.user.sub;
|
|
||||||
commandSend.lastUpdateFullName = request.user.name;
|
|
||||||
commandSend.lastUpdatedAt = new Date();
|
|
||||||
await this.commandSendRepository.save(commandSend);
|
|
||||||
if (commandSend && commandSend.id) {
|
|
||||||
let _ccName = new Array("EMAIL", "INBOX");
|
|
||||||
let _dataSendCC = new Array();
|
|
||||||
for (let i = 0; i < _ccName.length; i++) {
|
|
||||||
_dataSendCC.push({
|
|
||||||
commandSendId: commandSend.id,
|
|
||||||
name: _ccName[i],
|
|
||||||
createdUserId: request.user.sub,
|
|
||||||
createdFullName: request.user.name,
|
|
||||||
createdAt: new Date(),
|
|
||||||
lastUpdateUserId: request.user.sub,
|
|
||||||
lastUpdateFullName: request.user.name,
|
|
||||||
lastUpdatedAt: new Date(),
|
|
||||||
});
|
|
||||||
}
|
|
||||||
await this.commandSendCCRepository.save(_dataSendCC);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
const _posMasterInformation = await this.posMasterRepository.findOne({
|
|
||||||
where: {
|
|
||||||
orgChild1: {
|
|
||||||
isInformation: true,
|
|
||||||
},
|
|
||||||
isDirector: true,
|
|
||||||
orgChild2: IsNull(),
|
|
||||||
orgRevision: { orgRevisionIsDraft: false, orgRevisionIsCurrent: true },
|
|
||||||
current_holderId: Not(IsNull()),
|
|
||||||
},
|
|
||||||
relations: ["current_holder", "orgRoot", "positions"],
|
|
||||||
});
|
|
||||||
_commandSend = await this.commandSendRepository.findOne({
|
|
||||||
where: {
|
|
||||||
commandId: command.id,
|
|
||||||
profileId: _posMasterInformation?.current_holder.id ?? _null,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
if (!_commandSend && _posMasterInformation != null) {
|
|
||||||
let commandSend = new CommandSend();
|
|
||||||
commandSend.citizenId = _posMasterInformation?.current_holder.citizenId ?? _null;
|
|
||||||
commandSend.prefix = _posMasterInformation?.current_holder.prefix ?? _null;
|
|
||||||
commandSend.firstName = _posMasterInformation?.current_holder.firstName ?? _null;
|
|
||||||
commandSend.lastName = _posMasterInformation?.current_holder.lastName ?? _null;
|
|
||||||
commandSend.position = _posMasterInformation?.current_holder.position ?? _null;
|
|
||||||
commandSend.org =
|
|
||||||
_posMasterInformation && _posMasterInformation.orgRoot
|
|
||||||
? _posMasterInformation.orgRoot.orgRootName
|
|
||||||
: _null;
|
|
||||||
commandSend.profileId = _posMasterInformation?.current_holderId ?? _null;
|
|
||||||
commandSend.commandId = command.id;
|
|
||||||
commandSend.createdUserId = request.user.sub;
|
|
||||||
commandSend.createdFullName = request.user.name;
|
|
||||||
commandSend.createdAt = new Date();
|
|
||||||
commandSend.lastUpdateUserId = request.user.sub;
|
|
||||||
commandSend.lastUpdateFullName = request.user.name;
|
|
||||||
commandSend.lastUpdatedAt = new Date();
|
|
||||||
await this.commandSendRepository.save(commandSend);
|
|
||||||
if (commandSend && commandSend.id) {
|
|
||||||
let _ccName = new Array("EMAIL", "INBOX");
|
|
||||||
let _dataSendCC = new Array();
|
|
||||||
for (let i = 0; i < _ccName.length; i++) {
|
|
||||||
_dataSendCC.push({
|
|
||||||
commandSendId: commandSend.id,
|
|
||||||
name: _ccName[i],
|
|
||||||
createdUserId: request.user.sub,
|
|
||||||
createdFullName: request.user.name,
|
|
||||||
createdAt: new Date(),
|
|
||||||
lastUpdateUserId: request.user.sub,
|
|
||||||
lastUpdateFullName: request.user.name,
|
|
||||||
lastUpdatedAt: new Date(),
|
|
||||||
});
|
|
||||||
}
|
|
||||||
await this.commandSendCCRepository.save(_dataSendCC);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
const _posMasterOfficer = await this.posMasterRepository.findOne({
|
|
||||||
where: {
|
|
||||||
orgChild1: {
|
|
||||||
isOfficer: true,
|
|
||||||
},
|
|
||||||
isDirector: true,
|
|
||||||
orgChild2: IsNull(),
|
|
||||||
orgRevision: { orgRevisionIsDraft: false, orgRevisionIsCurrent: true },
|
|
||||||
current_holderId: Not(IsNull()),
|
|
||||||
},
|
|
||||||
relations: ["current_holder", "orgRoot", "positions"],
|
|
||||||
});
|
|
||||||
_commandSend = await this.commandSendRepository.findOne({
|
|
||||||
where: {
|
|
||||||
commandId: command.id,
|
|
||||||
profileId: _posMasterOfficer?.current_holder.id ?? _null,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
if (!_commandSend && _posMasterOfficer != null) {
|
|
||||||
let commandSend = new CommandSend();
|
|
||||||
commandSend.citizenId = _posMasterOfficer?.current_holder.citizenId ?? _null;
|
|
||||||
commandSend.prefix = _posMasterOfficer?.current_holder.prefix ?? _null;
|
|
||||||
commandSend.firstName = _posMasterOfficer?.current_holder.firstName ?? _null;
|
|
||||||
commandSend.lastName = _posMasterOfficer?.current_holder.lastName ?? _null;
|
|
||||||
commandSend.position = _posMasterOfficer?.current_holder.position ?? _null;
|
|
||||||
commandSend.org =
|
|
||||||
_posMasterOfficer && _posMasterOfficer.orgRoot
|
|
||||||
? _posMasterOfficer.orgRoot.orgRootName
|
|
||||||
: _null;
|
|
||||||
commandSend.profileId = _posMasterOfficer?.current_holderId ?? _null;
|
|
||||||
commandSend.commandId = command.id;
|
|
||||||
commandSend.createdUserId = request.user.sub;
|
|
||||||
commandSend.createdFullName = request.user.name;
|
|
||||||
commandSend.createdAt = new Date();
|
|
||||||
commandSend.lastUpdateUserId = request.user.sub;
|
|
||||||
commandSend.lastUpdateFullName = request.user.name;
|
|
||||||
commandSend.lastUpdatedAt = new Date();
|
|
||||||
await this.commandSendRepository.save(commandSend);
|
|
||||||
if (commandSend && commandSend.id) {
|
|
||||||
let _ccName = new Array("EMAIL", "INBOX");
|
|
||||||
let _dataSendCC = new Array();
|
|
||||||
for (let i = 0; i < _ccName.length; i++) {
|
|
||||||
_dataSendCC.push({
|
|
||||||
commandSendId: commandSend.id,
|
|
||||||
name: _ccName[i],
|
|
||||||
createdUserId: request.user.sub,
|
|
||||||
createdFullName: request.user.name,
|
|
||||||
createdAt: new Date(),
|
|
||||||
lastUpdateUserId: request.user.sub,
|
|
||||||
lastUpdateFullName: request.user.name,
|
|
||||||
lastUpdatedAt: new Date(),
|
|
||||||
});
|
|
||||||
}
|
|
||||||
await this.commandSendCCRepository.save(_dataSendCC);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return new HttpSuccess(command.id);
|
return new HttpSuccess(command.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue