Compare commits
7 Commits
7b60ddcadf
...
136bf9820d
| Author | SHA1 | Date | |
|---|---|---|---|
| 136bf9820d | |||
| ab23dcdfb8 | |||
| e1332e754a | |||
| 879172d9cd | |||
| bcede5be86 | |||
| 853f0848a1 | |||
| b1856d9155 |
@@ -35,7 +35,7 @@
|
||||
}
|
||||
},
|
||||
"admConfig": {
|
||||
"build": 385,
|
||||
"build": 389,
|
||||
"oldBuild": "backend-0.1.3.zip"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
||||
@@ -22,6 +22,8 @@ export const pNgForecast = async (data: any, user: any) => {
|
||||
};
|
||||
}
|
||||
|
||||
const pNg = s.filter((n: any) => n.name === "pNgAddress");
|
||||
|
||||
const { data: a, error: ae } = await tryCatch(
|
||||
query(activeArticle, "p&g active av")
|
||||
);
|
||||
@@ -86,7 +88,7 @@ export const pNgForecast = async (data: any, user: any) => {
|
||||
Date.now()
|
||||
).toLocaleString("en-US")}`,
|
||||
sender: user.username || "lst-system",
|
||||
customerId: 139,
|
||||
customerId: pNg[0].value,
|
||||
positions: [],
|
||||
};
|
||||
|
||||
|
||||
@@ -0,0 +1,98 @@
|
||||
import { eq, sql } from "drizzle-orm";
|
||||
import { db } from "../../../../../database/dbclient.js";
|
||||
import { notifications } from "../../../../../database/schema/notifications.js";
|
||||
import { tryCatch } from "../../../../globalUtils/tryCatch.js";
|
||||
import { createLog } from "../../../logger/logger.js";
|
||||
import { query } from "../../../sqlServer/prodSqlServer.js";
|
||||
import { sendEmail } from "../sendMail.js";
|
||||
import { bow2incoming } from "../../../sqlServer/querys/notifications/bow2henkel.js";
|
||||
|
||||
const notification = async (notifyData: any) => {
|
||||
/**
|
||||
* Pass the entire notification over
|
||||
*/
|
||||
createLog("debug", "reprinting", "notify", `monitoring ${notifyData.name}`);
|
||||
|
||||
// validate if there are any emails.
|
||||
if (notifyData.emails === "") {
|
||||
createLog(
|
||||
"error",
|
||||
"reprinting",
|
||||
"notify",
|
||||
`There are no emails set for ${notifyData.name}`
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
//let labels: Labels[];
|
||||
|
||||
const { data: l, error: labelError } = await tryCatch(
|
||||
query(
|
||||
bow2incoming.replace(
|
||||
"[time]",
|
||||
notifyData.notifiySettings.processTime
|
||||
),
|
||||
"Label Reprints"
|
||||
)
|
||||
);
|
||||
const labels: any = l?.data as any;
|
||||
if (labelError) {
|
||||
createLog(
|
||||
"error",
|
||||
"reprinting",
|
||||
"notify",
|
||||
`Failed to get the labels: ${labelError}`
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
if (labels.length > 0) {
|
||||
//send the email :D
|
||||
const emailSetup = {
|
||||
email: notifyData.emails,
|
||||
subject: "Alert! New incoming goods has been received",
|
||||
template: "bow2IncomingGoods",
|
||||
context: {
|
||||
items: labels,
|
||||
time: notifyData.notifiySettings.processTime,
|
||||
},
|
||||
};
|
||||
|
||||
const sentEmail = await sendEmail(emailSetup);
|
||||
|
||||
if (!sentEmail.success) {
|
||||
createLog(
|
||||
"error",
|
||||
"reprinting",
|
||||
"notify",
|
||||
"Failed to send email, will try again on next interval"
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
// // update the last time we ran and the prod id
|
||||
// const notifUpdate = {
|
||||
// prodID: labels[0].IdEtikettenHistorie,
|
||||
// lastRan: nowDate(),
|
||||
// };
|
||||
|
||||
// update the last time ran
|
||||
|
||||
const { data, error } = await tryCatch(
|
||||
db
|
||||
.update(notifications)
|
||||
.set({
|
||||
lastRan: sql`NOW()`,
|
||||
notifiySettings: {
|
||||
...notifyData.notifiySettings,
|
||||
prodID: labels[0].IdEtikettenHistorie,
|
||||
},
|
||||
})
|
||||
.where(eq(notifications.name, notifyData.name))
|
||||
);
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
};
|
||||
|
||||
export default notification;
|
||||
@@ -107,6 +107,16 @@ export const note: any = [
|
||||
releases: [1, 2, 3],
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "bow2henkelincoming",
|
||||
description:
|
||||
"Checks for new incoming goods orders to be completed and sends an email for what truck and carrier it was",
|
||||
checkInterval: 15,
|
||||
timeType: "min",
|
||||
emails: "blake.matthes@alpla.com",
|
||||
active: false,
|
||||
notifiySettings: { processTime: 15 },
|
||||
},
|
||||
];
|
||||
|
||||
export const notificationCreate = async () => {
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
{{!-- <link rel="stylesheet" href="styles/styles.css" /> --}}
|
||||
{{> styles}}
|
||||
</head>
|
||||
<body>
|
||||
<p>All,</p>
|
||||
<p>New incomings goods have been received in the last {{time}}min.</p>
|
||||
<table >
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Truck Number</th>
|
||||
<th>Carrier</th>
|
||||
<th>Add Date</th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tbody>
|
||||
{{#each items}}
|
||||
<tr>
|
||||
<td>{{truckNumber}}</td>
|
||||
<td>{{carrier}}</td>
|
||||
<td>{{Add_Date}}</td>
|
||||
</tr>
|
||||
{{/each}}
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<div>
|
||||
<p>Thank you,</p>
|
||||
<p>LST Team</p>
|
||||
</div>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -15,6 +15,17 @@ const newProdRoles: any = [
|
||||
roles: ["Manufacturing\\IssueMaterial\\MaterialHandler"],
|
||||
rolesLegacy: [3],
|
||||
},
|
||||
{
|
||||
name: "prodsupervisor",
|
||||
description:
|
||||
"Production supervisor, planning, labeling, and production contorlling.",
|
||||
roles: [
|
||||
"Manufacturing\\IssueMaterial\\MaterialHandler",
|
||||
"Manufacturing\\IssueMaterial\\ProcessAdmin",
|
||||
"Manufacturing\\ProductionLabelling\\ProcessAdmin",
|
||||
],
|
||||
rolesLegacy: [3, 11, 41, 48, 49],
|
||||
},
|
||||
];
|
||||
export const prodRoles = async () => {
|
||||
// get the roles
|
||||
|
||||
@@ -214,6 +214,14 @@ const newSettings = [
|
||||
serviceBelowsTo: "ocp",
|
||||
roleToChange: "admin",
|
||||
},
|
||||
{
|
||||
name: "pNgAddress",
|
||||
value: `139`,
|
||||
description:
|
||||
"What is the address for p&g so we can make sure we have the correct fake edi forcast going in.",
|
||||
serviceBelowsTo: "dm",
|
||||
roleToChange: "admin",
|
||||
},
|
||||
// temp settings can be deleted at a later date once that code is removed
|
||||
{
|
||||
name: "siloAdjMigrations",
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
export const bow2incoming = `
|
||||
select LKWNummer as truckNumber
|
||||
,LKWBezeichnung as carrier
|
||||
,Add_Date
|
||||
|
||||
from [AlplaPROD_test1].[dbo].[V_WareneingangAuftraege]
|
||||
|
||||
where Add_Date > DATEADD(MINUTE, -[time], getdate())
|
||||
`;
|
||||
Reference in New Issue
Block a user