รายชื่อผู้ได้รับสำเนาคำสั่ง
This commit is contained in:
parent
0ddec18725
commit
ecadf565ac
2 changed files with 84 additions and 5 deletions
|
|
@ -18,7 +18,7 @@ import HttpSuccess from "../interfaces/http-success";
|
||||||
import HttpStatusCode from "../interfaces/http-status";
|
import HttpStatusCode from "../interfaces/http-status";
|
||||||
import HttpError from "../interfaces/http-error";
|
import HttpError from "../interfaces/http-error";
|
||||||
import { Command } from "../entities/Command";
|
import { Command } from "../entities/Command";
|
||||||
import { Brackets, LessThan, MoreThan, Double, In, Between } from "typeorm";
|
import { Brackets, LessThan, MoreThan, Double, In, Between, IsNull, Not } from "typeorm";
|
||||||
import { CommandType } from "../entities/CommandType";
|
import { CommandType } from "../entities/CommandType";
|
||||||
import { CommandSend } from "../entities/CommandSend";
|
import { CommandSend } from "../entities/CommandSend";
|
||||||
import { Profile, CreateProfileAllFields } from "../entities/Profile";
|
import { Profile, CreateProfileAllFields } from "../entities/Profile";
|
||||||
|
|
@ -1429,6 +1429,53 @@ export class CommandController extends Controller {
|
||||||
);
|
);
|
||||||
})
|
})
|
||||||
.catch(() => {});
|
.catch(() => {});
|
||||||
|
|
||||||
|
if (requestBody.persons != undefined && requestBody.persons.length > 0) {
|
||||||
|
const posMaster = await this.posMasterRepository.find({
|
||||||
|
where: {
|
||||||
|
current_holderId: In(requestBody.persons.map((x) => x.profileId)),
|
||||||
|
orgRevision: { orgRevisionIsDraft: false, orgRevisionIsCurrent: true },
|
||||||
|
},
|
||||||
|
select: ["orgRootId"],
|
||||||
|
});
|
||||||
|
|
||||||
|
const _posMaster = await this.posMasterRepository.find({
|
||||||
|
where: {
|
||||||
|
orgRootId: In(posMaster.map((x) => x.orgRootId)),
|
||||||
|
orgRevision: { orgRevisionIsDraft: false, orgRevisionIsCurrent: true },
|
||||||
|
isDirector: true,
|
||||||
|
current_holderId: Not(IsNull()),
|
||||||
|
},
|
||||||
|
relations: ["current_holder", "orgRoot"],
|
||||||
|
});
|
||||||
|
await Promise.all(
|
||||||
|
_posMaster.map(async (item) => {
|
||||||
|
const _commandSend = await this.commandSendRepository.findOne({
|
||||||
|
where: {
|
||||||
|
commandId: command.id,
|
||||||
|
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);
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
}
|
||||||
return new HttpSuccess(command.id);
|
return new HttpSuccess(command.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -2040,7 +2087,7 @@ export class CommandController extends Controller {
|
||||||
createdAt: new Date(),
|
createdAt: new Date(),
|
||||||
lastUpdatedAt: new Date(),
|
lastUpdatedAt: new Date(),
|
||||||
dateGovernment: new Date(),
|
dateGovernment: new Date(),
|
||||||
isGovernment: item.isGovernment
|
isGovernment: item.isGovernment,
|
||||||
};
|
};
|
||||||
|
|
||||||
Object.assign(data, meta);
|
Object.assign(data, meta);
|
||||||
|
|
@ -2253,7 +2300,7 @@ export class CommandController extends Controller {
|
||||||
createdAt: new Date(),
|
createdAt: new Date(),
|
||||||
lastUpdatedAt: new Date(),
|
lastUpdatedAt: new Date(),
|
||||||
dateGovernment: new Date(),
|
dateGovernment: new Date(),
|
||||||
isGovernment: item.isGovernment
|
isGovernment: item.isGovernment,
|
||||||
});
|
});
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
this.profileRepository.save(_profile),
|
this.profileRepository.save(_profile),
|
||||||
|
|
|
||||||
|
|
@ -580,9 +580,41 @@ export class WorkflowController extends Controller {
|
||||||
where: {
|
where: {
|
||||||
id: body.stateUserCommentId,
|
id: body.stateUserCommentId,
|
||||||
},
|
},
|
||||||
|
relations: ["state", "state.workflow", "state.stateOperators"],
|
||||||
});
|
});
|
||||||
if (!stateUserComment)
|
if (!stateUserComment)
|
||||||
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลขั้นตอนการอนุมัติ");
|
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลขั้นตอนการอนุมัติ");
|
||||||
|
stateUserComment.state.stateOperators;
|
||||||
|
|
||||||
|
const workflow = await this.workflowRepo.findOne({
|
||||||
|
where: {
|
||||||
|
refId: stateUserComment.state.workflow.refId,
|
||||||
|
sysName: stateUserComment.state.workflow.sysName,
|
||||||
|
},
|
||||||
|
relations: ["stateOperatorUsers"],
|
||||||
|
});
|
||||||
|
if (!workflow) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่สามารถดำเนินการกระบวนการนี้ได้");
|
||||||
|
let profileNow = workflow.stateOperatorUsers
|
||||||
|
.filter((x) =>
|
||||||
|
stateUserComment.state.stateOperators.map((s) => s.operator).includes(x.operator),
|
||||||
|
)
|
||||||
|
.map((x) => ({
|
||||||
|
receiverUserId: x.profile,
|
||||||
|
notiLink: "",
|
||||||
|
}));
|
||||||
|
await new CallAPI()
|
||||||
|
.PostData(req, "/placement/noti/profiles", {
|
||||||
|
subject: `ผู้บังคับบัญชาดำเนินการ`,
|
||||||
|
body: `ผู้บังคับบัญชาดำเนินการ`,
|
||||||
|
receiverUserIds: profileNow,
|
||||||
|
payload: "", //แนบไฟล์
|
||||||
|
isSendMail: true,
|
||||||
|
isSendInbox: true,
|
||||||
|
isSendNotification: true,
|
||||||
|
})
|
||||||
|
.catch((error) => {
|
||||||
|
console.error("Error calling API:", error);
|
||||||
|
});
|
||||||
let _null: any = null;
|
let _null: any = null;
|
||||||
stateUserComment.isAccept = body.isAccept == null ? _null : body.isAccept;
|
stateUserComment.isAccept = body.isAccept == null ? _null : body.isAccept;
|
||||||
stateUserComment.isApprove = body.isApprove == null ? _null : body.isApprove;
|
stateUserComment.isApprove = body.isApprove == null ? _null : body.isApprove;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue