feat: more notification related to task and request
All checks were successful
Spell Check / Spell Check with Typos (push) Successful in 4s
All checks were successful
Spell Check / Spell Check with Typos (push) Successful in 4s
This commit is contained in:
parent
afb89ef949
commit
3455ae604a
1 changed files with 46 additions and 17 deletions
|
|
@ -782,22 +782,33 @@ export class TaskActionController extends Controller {
|
|||
const code = `RI${year}${month}${last.value.toString().padStart(6, "0")}`;
|
||||
|
||||
await Promise.all([
|
||||
tx.taskOrder.update({
|
||||
where: { id: taskOrderId },
|
||||
data: {
|
||||
urgent: false,
|
||||
taskOrderStatus: TaskOrderStatus.Complete,
|
||||
codeProductReceived: code,
|
||||
userTask: {
|
||||
updateMany: {
|
||||
where: { taskOrderId },
|
||||
data: {
|
||||
userTaskStatus: UserTaskStatus.Submit,
|
||||
tx.taskOrder
|
||||
.update({
|
||||
where: { id: taskOrderId },
|
||||
data: {
|
||||
urgent: false,
|
||||
taskOrderStatus: TaskOrderStatus.Complete,
|
||||
codeProductReceived: code,
|
||||
userTask: {
|
||||
updateMany: {
|
||||
where: { taskOrderId },
|
||||
data: {
|
||||
userTaskStatus: UserTaskStatus.Submit,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}),
|
||||
})
|
||||
.then(async (record) => {
|
||||
await tx.notification.create({
|
||||
data: {
|
||||
title: "ใบงานเสร็จสิ้น / Task Complete",
|
||||
detail: "รหัสใบสั่งงาน / Order : " + record.code,
|
||||
receiverId: record.createdByUserId,
|
||||
groupReceiver: { create: { name: "document_checker" } },
|
||||
},
|
||||
});
|
||||
}),
|
||||
tx.requestWorkStepStatus.updateMany({
|
||||
where: {
|
||||
task: {
|
||||
|
|
@ -901,10 +912,28 @@ export class TaskActionController extends Controller {
|
|||
if (completeCheck) completed.push(item.id);
|
||||
});
|
||||
|
||||
await tx.requestData.updateMany({
|
||||
where: { id: { in: completed } },
|
||||
data: { requestDataStatus: RequestDataStatus.Completed },
|
||||
});
|
||||
await tx.requestData
|
||||
.updateManyAndReturn({
|
||||
where: { id: { in: completed } },
|
||||
include: {
|
||||
quotation: {
|
||||
select: {
|
||||
createdByUserId: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
data: { requestDataStatus: RequestDataStatus.Completed },
|
||||
})
|
||||
.then(async (res) => {
|
||||
await tx.notification.createMany({
|
||||
data: res.map((v) => ({
|
||||
title: "รายการคำขอเสร็จสิ้น / Request Complete",
|
||||
detail: "รหัส / code : " + v.code + " Completed",
|
||||
receiverId: v.quotation.createdByUserId,
|
||||
groupReceiver: { create: { name: "document_checker" } },
|
||||
})),
|
||||
});
|
||||
});
|
||||
await tx.quotation
|
||||
.updateManyAndReturn({
|
||||
where: {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue