fix issue #103
This commit is contained in:
parent
91ba933a65
commit
8e120660a1
1 changed files with 103 additions and 33 deletions
|
|
@ -623,6 +623,11 @@ export class CommandController extends Controller {
|
|||
await new permission().PermissionGet(request, "COMMAND");
|
||||
const command = await this.commandRepository.findOne({
|
||||
where: { id },
|
||||
order: {
|
||||
commandSends : {
|
||||
createdAt: "ASC"
|
||||
}
|
||||
},
|
||||
relations: ["commandSends", "commandSends.commandSendCCs"],
|
||||
});
|
||||
if (!command) {
|
||||
|
|
@ -637,7 +642,9 @@ export class CommandController extends Controller {
|
|||
lastName: item.lastName,
|
||||
position: item.position,
|
||||
org: item.org,
|
||||
sendCC: item.commandSendCCs.map((x) => x.name),
|
||||
sendCC: item.commandSendCCs
|
||||
.sort((a, b) => a.name.localeCompare(b.name))
|
||||
.map((x) => x.name),
|
||||
profileId: item.profileId,
|
||||
}));
|
||||
return new HttpSuccess(_command);
|
||||
|
|
@ -1883,42 +1890,105 @@ export class CommandController extends Controller {
|
|||
profileId: item.current_holder.id,
|
||||
},
|
||||
});
|
||||
if (_commandSend) return;
|
||||
let commandSend = new CommandSend();
|
||||
commandSend.citizenId = item.current_holder.citizenId;
|
||||
commandSend.prefix = item.current_holder.prefix;
|
||||
commandSend.firstName = item.current_holder.firstName;
|
||||
commandSend.lastName = item.current_holder.lastName;
|
||||
commandSend.position = item.current_holder.position;
|
||||
commandSend.org = item.orgRoot.orgRootName;
|
||||
commandSend.profileId = item.current_holder.id;
|
||||
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(),
|
||||
});
|
||||
// if (_commandSend) return;
|
||||
if (!_commandSend) {
|
||||
let commandSend = new CommandSend();
|
||||
commandSend.citizenId = item.current_holder.citizenId;
|
||||
commandSend.prefix = item.current_holder.prefix;
|
||||
commandSend.firstName = item.current_holder.firstName;
|
||||
commandSend.lastName = item.current_holder.lastName;
|
||||
commandSend.position = item.current_holder.position;
|
||||
commandSend.org = item.orgRoot.orgRootName;
|
||||
commandSend.profileId = item.current_holder.id;
|
||||
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);
|
||||
}
|
||||
await this.commandSendCCRepository.save(_dataSendCC);
|
||||
}
|
||||
}),
|
||||
);
|
||||
|
||||
if (["C-PM-10"].includes(commandCode)) {
|
||||
await Promise.all(
|
||||
requestBody.persons.map(async (item:any) => {
|
||||
const _posMasterDirector = await this.posMasterRepository.findOne({
|
||||
where: {
|
||||
orgRootId: item.rootId,
|
||||
orgRevision: { orgRevisionIsDraft: false, orgRevisionIsCurrent: true },
|
||||
current_holderId: item.profileId,
|
||||
},
|
||||
relations: ["current_holder", "orgRoot", "positions"],
|
||||
});
|
||||
const _commandSend = await this.commandSendRepository.findOne({
|
||||
where: {
|
||||
commandId: command.id,
|
||||
profileId: item.profileId ?? null_
|
||||
},
|
||||
});
|
||||
if (!_commandSend) {
|
||||
let commandSend = new CommandSend();
|
||||
commandSend.citizenId = item.citizenId;
|
||||
commandSend.prefix = item.prefix;
|
||||
commandSend.firstName = item.firstName;
|
||||
commandSend.lastName = item.lastName;
|
||||
commandSend.position = _posMasterDirector && _posMasterDirector.positions.length > 0
|
||||
? _posMasterDirector.positions[0].positionName
|
||||
: null_;
|
||||
commandSend.org = _posMasterDirector && _posMasterDirector.orgRoot
|
||||
? _posMasterDirector.orgRoot.orgRootName
|
||||
: null_;
|
||||
commandSend.profileId = item.profileId;
|
||||
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);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue