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")}`;
|
const code = `RI${year}${month}${last.value.toString().padStart(6, "0")}`;
|
||||||
|
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
tx.taskOrder.update({
|
tx.taskOrder
|
||||||
where: { id: taskOrderId },
|
.update({
|
||||||
data: {
|
where: { id: taskOrderId },
|
||||||
urgent: false,
|
data: {
|
||||||
taskOrderStatus: TaskOrderStatus.Complete,
|
urgent: false,
|
||||||
codeProductReceived: code,
|
taskOrderStatus: TaskOrderStatus.Complete,
|
||||||
userTask: {
|
codeProductReceived: code,
|
||||||
updateMany: {
|
userTask: {
|
||||||
where: { taskOrderId },
|
updateMany: {
|
||||||
data: {
|
where: { taskOrderId },
|
||||||
userTaskStatus: UserTaskStatus.Submit,
|
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({
|
tx.requestWorkStepStatus.updateMany({
|
||||||
where: {
|
where: {
|
||||||
task: {
|
task: {
|
||||||
|
|
@ -901,10 +912,28 @@ export class TaskActionController extends Controller {
|
||||||
if (completeCheck) completed.push(item.id);
|
if (completeCheck) completed.push(item.id);
|
||||||
});
|
});
|
||||||
|
|
||||||
await tx.requestData.updateMany({
|
await tx.requestData
|
||||||
where: { id: { in: completed } },
|
.updateManyAndReturn({
|
||||||
data: { requestDataStatus: RequestDataStatus.Completed },
|
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
|
await tx.quotation
|
||||||
.updateManyAndReturn({
|
.updateManyAndReturn({
|
||||||
where: {
|
where: {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue