ส่งสำเนาห้ามซ้ำ

This commit is contained in:
mamoss 2025-07-29 22:31:22 +07:00
parent 5b56e311fe
commit e28f554275

View file

@ -2327,7 +2327,7 @@ export class CommandController extends Controller {
let _commandSend = await this.commandSendRepository.findOne({ let _commandSend = await this.commandSendRepository.findOne({
where: { where: {
commandId: command.id, commandId: command.id,
profileId: _posMasterCommission?.current_holder.id ?? _null, profileId: _posMasterCommission?.current_holderId ?? _null,
}, },
}); });
if (!_commandSend && _posMasterCommission != null) { if (!_commandSend && _posMasterCommission != null) {
@ -2384,7 +2384,7 @@ export class CommandController extends Controller {
_commandSend = await this.commandSendRepository.findOne({ _commandSend = await this.commandSendRepository.findOne({
where: { where: {
commandId: command.id, commandId: command.id,
profileId: _posMasterInformation?.current_holder.id ?? _null, profileId: _posMasterInformation?.current_holderId ?? _null,
}, },
}); });
if (!_commandSend && _posMasterInformation != null) { if (!_commandSend && _posMasterInformation != null) {
@ -2441,7 +2441,7 @@ export class CommandController extends Controller {
_commandSend = await this.commandSendRepository.findOne({ _commandSend = await this.commandSendRepository.findOne({
where: { where: {
commandId: command.id, commandId: command.id,
profileId: _posMasterOfficer?.current_holder.id ?? _null, profileId: _posMasterOfficer?.current_holderId ?? _null,
}, },
}); });
if (!_commandSend && _posMasterOfficer != null) { if (!_commandSend && _posMasterOfficer != null) {
@ -2626,10 +2626,10 @@ export class CommandController extends Controller {
const _commandSend = await this.commandSendRepository.findOne({ const _commandSend = await this.commandSendRepository.findOne({
where: { where: {
commandId: command.id, commandId: command.id,
profileId: item.current_holder.id, profileId: item.current_holderId,
}, },
}); });
if (_commandSend) return; if (!_commandSend) {
let commandSend = new CommandSend(); let commandSend = new CommandSend();
commandSend.citizenId = item.current_holder.citizenId; commandSend.citizenId = item.current_holder.citizenId;
commandSend.prefix = item.current_holder.prefix; commandSend.prefix = item.current_holder.prefix;
@ -2637,7 +2637,7 @@ export class CommandController extends Controller {
commandSend.lastName = item.current_holder.lastName; commandSend.lastName = item.current_holder.lastName;
commandSend.position = item.current_holder.position; commandSend.position = item.current_holder.position;
commandSend.org = item.orgRoot.orgRootName; commandSend.org = item.orgRoot.orgRootName;
commandSend.profileId = item.current_holder.id; commandSend.profileId = item.current_holderId;
commandSend.commandId = command.id; commandSend.commandId = command.id;
commandSend.createdUserId = request.user.sub; commandSend.createdUserId = request.user.sub;
commandSend.createdFullName = request.user.name; commandSend.createdFullName = request.user.name;
@ -2663,6 +2663,7 @@ export class CommandController extends Controller {
} }
await this.commandSendCCRepository.save(_dataSendCC); await this.commandSendCCRepository.save(_dataSendCC);
} }
}
}), }),
); );
@ -2681,11 +2682,11 @@ export class CommandController extends Controller {
relations: ["current_holder", "orgRoot"], relations: ["current_holder", "orgRoot"],
}); });
await Promise.all( await Promise.all(
_posMasterNext.map(async (item) => { _posMasterNext.map(async (item: any) => {
const _commandSend = await this.commandSendRepository.findOne({ const _commandSend = await this.commandSendRepository.findOne({
where: { where: {
commandId: command.id, commandId: command.id,
profileId: item.current_holder.id, profileId: item.current_holderId,
}, },
}); });
// if (_commandSend) return; // if (_commandSend) return;
@ -2697,7 +2698,7 @@ export class CommandController extends Controller {
commandSend.lastName = item.current_holder.lastName; commandSend.lastName = item.current_holder.lastName;
commandSend.position = item.current_holder.position; commandSend.position = item.current_holder.position;
commandSend.org = item.orgRoot.orgRootName; commandSend.org = item.orgRoot.orgRootName;
commandSend.profileId = item.current_holder.id; commandSend.profileId = item.current_holderId;
commandSend.commandId = command.id; commandSend.commandId = command.id;
commandSend.createdUserId = request.user.sub; commandSend.createdUserId = request.user.sub;
commandSend.createdFullName = request.user.name; commandSend.createdFullName = request.user.name;