ptath workflow

This commit is contained in:
kittapath 2024-10-21 10:22:39 +07:00
parent ed134d87f7
commit b2ccdfdf30
5 changed files with 43 additions and 94 deletions

View file

@ -37,7 +37,6 @@ import {
calculateRetireDate,
calculateRetireLaw,
commandTypePath,
commandTypePathLink,
removeProfileInOrganize,
setLogDataDiff,
} from "../interfaces/utils";
@ -1019,7 +1018,7 @@ export class CommandController extends Controller {
.filter((x) => x.profileId != null)
.map((x) => ({
receiverUserId: x.profileId,
notiLink: `${commandTypePathLink(command.commandType.code)}/${x.refId}`,
notiLink: "",
}))
: [];

View file

@ -16,6 +16,7 @@ import { MetaState } from "../entities/MetaState";
import { MetaStateOperator } from "../entities/MetaStateOperator";
import { PosMaster } from "../entities/PosMaster";
import { IsNull, Not } from "typeorm";
import { Assign } from "../entities/Assign";
@Route("api/v1/org/workflow")
@Tags("Workflow")
@ -32,6 +33,7 @@ export class WorkflowController extends Controller {
private metaStateRepo = AppDataSource.getRepository(MetaState);
private metaStateOperatorRepo = AppDataSource.getRepository(MetaStateOperator);
private posMasterRepo = AppDataSource.getRepository(PosMaster);
private assignRepo = AppDataSource.getRepository(Assign);
@Post("add-workflow")
public async checkWorkflow(
@ -505,7 +507,7 @@ export class WorkflowController extends Controller {
where: {
id: body.stateId,
},
relations: ["stateUserComments"],
relations: ["stateUserComments", "workflow"],
});
if (!state) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลขั้นตอนการอนุมัติ");
@ -523,12 +525,23 @@ export class WorkflowController extends Controller {
stateUserComment.lastUpdateFullName = req.user.name;
stateUserComment.lastUpdatedAt = new Date();
await this.stateUserCommentRepo.save(stateUserComment);
state.workflow.sysName;
const assign = await this.assignRepo.findOne({
where: {
id: state.workflow.sysName,
},
});
if (!assign) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลขั้นตอนการอนุมัติ");
await new CallAPI()
.PostData(req, "/placement/noti/profiles", {
subject: `ได้รับรายการ`,
body: `ได้รับรายการ`,
receiverUserIds: [body.profileId],
receiverUserIds: [
{
receiverUserId: body.profileId,
notiLink: `${assign.path}/${state.workflow.refId}`,
},
],
payload: "", //แนบไฟล์
isSendMail: true,
isSendInbox: true,