feat(lstv2): added zechetti stuff in so we can print :D
This commit is contained in:
@@ -1,11 +1,6 @@
|
|||||||
import { ControllerManager } from "st-ethernet-ip";
|
import { ControllerManager } from "st-ethernet-ip";
|
||||||
import { getMac } from "./getMachineId.js";
|
import { getMac } from "../../../utils/getMachineId.js";
|
||||||
import { format } from "date-fns-tz";
|
import { labelingProcess } from "../../labeling/labelProcess.js";
|
||||||
import { tryCatch } from "../../../globalUtils/tryCatch.js";
|
|
||||||
|
|
||||||
import { getCurrentLabel } from "../../sqlServer/querys/ocp/getLabel.js";
|
|
||||||
import { query } from "../../sqlServer/prodSqlServer.js";
|
|
||||||
import { createLog } from "../../logger/logger.js";
|
|
||||||
|
|
||||||
export const createPlcMonitor = (config: any) => {
|
export const createPlcMonitor = (config: any) => {
|
||||||
let cm: any;
|
let cm: any;
|
||||||
@@ -77,34 +72,39 @@ export const createPlcMonitor = (config: any) => {
|
|||||||
setTimeout(async () => {
|
setTimeout(async () => {
|
||||||
if (tag.value === 0) return;
|
if (tag.value === 0) return;
|
||||||
const macId = await getMac(tag.value);
|
const macId = await getMac(tag.value);
|
||||||
console.log(macId);
|
// const { data, error } = (await tryCatch(
|
||||||
const { data, error } = (await tryCatch(
|
// query(
|
||||||
query(
|
// getCurrentLabel
|
||||||
getCurrentLabel
|
// .replace(
|
||||||
.replace(
|
// "[macId]",
|
||||||
"[macId]",
|
// macId[0]?.HumanReadableId
|
||||||
macId[0]?.HumanReadableId
|
// )
|
||||||
)
|
// .replace(
|
||||||
.replace(
|
// "[time]",
|
||||||
"[time]",
|
// format(time, "yyyy-MM-dd HH:mm")
|
||||||
format(time, "yyyy-MM-dd HH:mm")
|
// ),
|
||||||
),
|
// "Current label data"
|
||||||
"Current label data"
|
// )
|
||||||
)
|
// )) as any;
|
||||||
)) as any;
|
|
||||||
|
|
||||||
createLog(
|
// createLog(
|
||||||
"info",
|
// "info",
|
||||||
"zechettii",
|
// "zechettii",
|
||||||
"zechettii",
|
// "zechettii",
|
||||||
`${format(time, "yyyy-MM-dd HH:mm")} [${cfg.id}] ${
|
// `${format(time, "yyyy-MM-dd HH:mm")} [${cfg.id}] ${
|
||||||
tag.name
|
// tag.name
|
||||||
}: ${prevVal} -> ${
|
// }: ${prevVal} -> ${
|
||||||
tag.value
|
// tag.value
|
||||||
}, the running number is ${
|
// }, the running number is ${
|
||||||
error ? null : data.data[0]?.LfdNr
|
// error ? null : data.data[0]?.LfdNr
|
||||||
}}`
|
// }}`
|
||||||
);
|
// );
|
||||||
|
const zechette = {
|
||||||
|
line: tag.value.toString(),
|
||||||
|
printer: cfg.printerId, // this is the id of the zechetti 2 to print we should move this to the db
|
||||||
|
printerName: cfg.id,
|
||||||
|
};
|
||||||
|
labelingProcess({ zechette: zechette });
|
||||||
}, 1000);
|
}, 1000);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -1,20 +1,22 @@
|
|||||||
import { createPlcMonitor } from "../../../utils/plcController.js";
|
import { createPlcMonitor } from "./plcController.js";
|
||||||
|
|
||||||
export const zechettiConnect = () => {
|
export const zechettiConnect = () => {
|
||||||
const config: any = {
|
const config: any = {
|
||||||
controllers: [
|
controllers: [
|
||||||
{
|
{
|
||||||
id: "Z1",
|
id: "Zecchetti_1",
|
||||||
ip: "192.168.193.97",
|
ip: "192.168.193.97",
|
||||||
slot: 0,
|
slot: 0,
|
||||||
rpi: 250,
|
rpi: 250,
|
||||||
|
printerId: 22, // grabbed from 2.0
|
||||||
tags: ["N7[0]"],
|
tags: ["N7[0]"],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: "Z2",
|
id: "Zecchetti_2",
|
||||||
ip: "192.168.193.111",
|
ip: "192.168.193.111",
|
||||||
slot: 0,
|
slot: 0,
|
||||||
rpi: 100,
|
rpi: 100,
|
||||||
|
printerId: 23,
|
||||||
tags: ["N8[0]"],
|
tags: ["N8[0]"],
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ import labelRatio from "./routes/labeling/getLabelRatio.js";
|
|||||||
import resetRatio from "./routes/labeling/resetLabelRatio.js";
|
import resetRatio from "./routes/labeling/resetLabelRatio.js";
|
||||||
import materialTransferLot from "./routes/materials/lotTransfer.js";
|
import materialTransferLot from "./routes/materials/lotTransfer.js";
|
||||||
import pendingTransfers from "./routes/materials/currentPending.js";
|
import pendingTransfers from "./routes/materials/currentPending.js";
|
||||||
import { createPlcMonitor } from "./utils/plcController.js";
|
import { createPlcMonitor } from "./controller/specialProcesses/zechettis/plcController.js";
|
||||||
import { zechettiConnect } from "./controller/specialProcesses/zechettis/zechettiConnect.js";
|
import { zechettiConnect } from "./controller/specialProcesses/zechettis/zechettiConnect.js";
|
||||||
|
|
||||||
const app = new OpenAPIHono();
|
const app = new OpenAPIHono();
|
||||||
|
|||||||
@@ -55,13 +55,32 @@ MaterialHumanReadableId
|
|||||||
,case when cp.Pieces >= 0.001 then (lot.TotalProducedLoadingUnits+1) * cp.Pieces else
|
,case when cp.Pieces >= 0.001 then (lot.TotalProducedLoadingUnits+1) * cp.Pieces else
|
||||||
(a.Weight *((case when cp.Percentage is null then 80 else cp.Percentage end) / 100) * ((lot.TotalProducedLoadingUnits+1) * p.LoadingUnitPieces)) / 1000 end totalNeeded
|
(a.Weight *((case when cp.Percentage is null then 80 else cp.Percentage end) / 100) * ((lot.TotalProducedLoadingUnits+1) * p.LoadingUnitPieces)) / 1000 end totalNeeded
|
||||||
|
|
||||||
,case when IsMainMaterial = 1 then
|
,CASE
|
||||||
case when (case when x.ProvidedAmount <> 0
|
WHEN IsMainMaterial = 1 THEN
|
||||||
then x.ProvidedAmount else x.EffectiveConsumption end) >
|
CASE
|
||||||
(case when cp.Pieces >= 0.001 then (lot.TotalProducedQuantity+1) * cp.Pieces else
|
WHEN
|
||||||
(a.Weight *((case when cp.Percentage is null then 80 else cp.Percentage end) / 100) * ((lot.TotalProducedLoadingUnits+1) * p.LoadingUnitPieces)) / 1000 end)
|
(CASE
|
||||||
then 'mmGood'
|
WHEN x.ProvidedAmount > 0
|
||||||
else 'noMM' end else null end as noMMShortage
|
THEN x.ProvidedAmount
|
||||||
|
ELSE x.EffectiveConsumption
|
||||||
|
END)
|
||||||
|
>
|
||||||
|
(CASE
|
||||||
|
WHEN cp.Pieces >= 0.001
|
||||||
|
THEN (lot.TotalProducedQuantity + 1) * cp.Pieces
|
||||||
|
ELSE
|
||||||
|
(a.Weight *
|
||||||
|
(CASE
|
||||||
|
WHEN cp.Percentage IS NULL THEN 80
|
||||||
|
ELSE cp.Percentage
|
||||||
|
END) / 100
|
||||||
|
) * (lot.TotalProducedQuantity + 1) / 1000
|
||||||
|
END)
|
||||||
|
THEN 'mmGood'
|
||||||
|
ELSE 'noMM'
|
||||||
|
END
|
||||||
|
ELSE NULL
|
||||||
|
END AS noMMShortage
|
||||||
|
|
||||||
-- pkg check auto
|
-- pkg check auto
|
||||||
,case when pkg.QuantityPosition is null then null else
|
,case when pkg.QuantityPosition is null then null else
|
||||||
|
|||||||
Reference in New Issue
Block a user