feat(ocp): added dual printing back in
This commit is contained in:
@@ -11,6 +11,7 @@ import { prolinkCheck } from "../lots/prolinkCheck.js";
|
|||||||
import { createLabel } from "./createLabel.js";
|
import { createLabel } from "./createLabel.js";
|
||||||
import { bookInLabel } from "./bookIn.js";
|
import { bookInLabel } from "./bookIn.js";
|
||||||
import { delieryInhouse } from "../specialProcesses/inhouse/inhouseDelivery.js";
|
import { delieryInhouse } from "../specialProcesses/inhouse/inhouseDelivery.js";
|
||||||
|
import { dualPrintingProcess } from "../specialProcesses/dualPrinting/dualPrinting.js";
|
||||||
|
|
||||||
interface Printer {
|
interface Printer {
|
||||||
name: string;
|
name: string;
|
||||||
@@ -120,7 +121,7 @@ export const labelingProcess = async ({
|
|||||||
`${printer?.name}, being sent over for dual printing processing.`
|
`${printer?.name}, being sent over for dual printing processing.`
|
||||||
);
|
);
|
||||||
// process what line to print the label for and return the lot info and change filteredLot to returned one.
|
// process what line to print the label for and return the lot info and change filteredLot to returned one.
|
||||||
//filteredLot = await dualPrintingProcess(filteredLot);
|
filteredLot = await dualPrintingProcess(filteredLot);
|
||||||
}
|
}
|
||||||
|
|
||||||
// if there are more than 2 lots it might be an auto labeler, autolabeler will be defined by its id for now only dayton
|
// if there are more than 2 lots it might be an auto labeler, autolabeler will be defined by its id for now only dayton
|
||||||
|
|||||||
@@ -0,0 +1,147 @@
|
|||||||
|
import { createLog } from "../../../../logger/logger.js";
|
||||||
|
import { query } from "../../../../sqlServer/prodSqlServer.js";
|
||||||
|
|
||||||
|
export const dualPrintingProcess = async (lotInfo: any) => {
|
||||||
|
// currently we will only allow for 2 printers to be linked only crazy people want more than 2
|
||||||
|
createLog(
|
||||||
|
"info",
|
||||||
|
"ocp",
|
||||||
|
"ocp",
|
||||||
|
"Dual printing running logic here to see what to print"
|
||||||
|
);
|
||||||
|
// each check
|
||||||
|
let lastPrinted;
|
||||||
|
let firstLine;
|
||||||
|
let secondLine;
|
||||||
|
|
||||||
|
// this query checks the last line to print a label
|
||||||
|
const printedQuery = `SELECT TOP(1) IdProdPlanung,
|
||||||
|
IdArtikelvarianten,
|
||||||
|
IdMaschine,
|
||||||
|
LfdNr,
|
||||||
|
ArtikelVariantenBez,
|
||||||
|
Add_User,
|
||||||
|
Add_Date,
|
||||||
|
Upd_User,
|
||||||
|
Upd_Date,
|
||||||
|
IdProdBereich
|
||||||
|
FROM AlplaPROD_test1.dbo.T_EtikettenGedruckt (nolock)
|
||||||
|
where IdMaschine in (${lotInfo[0].machineID},${lotInfo[1].machineID}) order by Add_Date desc`;
|
||||||
|
|
||||||
|
const fisrtLineDT = `SELECT top(1) IdMaschine,
|
||||||
|
case when Endzeit ='1900-01-01 00:00:00.000' and DATEDIFF(MINUTE, Startzeit, GETDATE()) >= 3 Then 1 else 0 end as 'LineCheck'
|
||||||
|
FROM AlplaPROD_test1.dbo.T_HistoryStillstandsereignis (nolock) where IdMaschine = ${lotInfo[0].machineID} order by Add_Date desc`;
|
||||||
|
|
||||||
|
const secondLineDT = `SELECT top(1) IdMaschine,
|
||||||
|
case when Endzeit ='1900-01-01 00:00:00.000' and DATEDIFF(MINUTE, Startzeit, GETDATE()) >= 3 Then 1 else 0 end as 'LineCheck'
|
||||||
|
FROM AlplaPROD_test1.dbo.T_HistoryStillstandsereignis (nolock) where IdMaschine = ${lotInfo[1].machineID} order by Add_Date desc`;
|
||||||
|
|
||||||
|
try {
|
||||||
|
// get what was last printed
|
||||||
|
const result = await query(printedQuery, "Last Printed Query");
|
||||||
|
lastPrinted = result[0].IdMaschine;
|
||||||
|
} catch (err) {
|
||||||
|
createLog(
|
||||||
|
"error",
|
||||||
|
"ocp",
|
||||||
|
"ocp",
|
||||||
|
`Error: getting last printed querty: ${err}`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
// get if if running or down
|
||||||
|
const first = await query(fisrtLineDT, "First line DT Check");
|
||||||
|
firstLine = first[0].LineCheck;
|
||||||
|
} catch (err) {
|
||||||
|
createLog(
|
||||||
|
"error",
|
||||||
|
"ocp",
|
||||||
|
"ocp",
|
||||||
|
`Error: with getting ${lotInfo[0].machineID} data query: ${err}`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
const second = await query(secondLineDT, "Second line DT Check");
|
||||||
|
secondLine = second[0].LineCheck;
|
||||||
|
} catch (err) {
|
||||||
|
createLog(
|
||||||
|
"error",
|
||||||
|
"ocp",
|
||||||
|
"ocp",
|
||||||
|
`Error: with getting ${lotInfo[1].machineID} data query: ${err}`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// first check if both are up and running
|
||||||
|
if (firstLine === 0 && secondLine === 0) {
|
||||||
|
createLog("info", "ocp", "ocp", "Both lines are up");
|
||||||
|
// what line last printed
|
||||||
|
if (lastPrinted === lotInfo[0].machineID) {
|
||||||
|
// IE 7 then print 8, usslc was the main example for all of this
|
||||||
|
let whatToPrint = lotInfo.filter(
|
||||||
|
(m: any) => m.machineID === lotInfo[1].machineID
|
||||||
|
);
|
||||||
|
// send to label
|
||||||
|
createLog(
|
||||||
|
"info",
|
||||||
|
"ocp",
|
||||||
|
"ocp",
|
||||||
|
`Printing label for ${whatToPrint.MachineDescription}`
|
||||||
|
);
|
||||||
|
return whatToPrint;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (lastPrinted === lotInfo[1].machineID) {
|
||||||
|
// IE 8 then print 7, usslc was the main example for all of this
|
||||||
|
let whatToPrint = lotInfo.filter(
|
||||||
|
(m: any) => m.machineID === lotInfo[0].machineID
|
||||||
|
);
|
||||||
|
// send to label
|
||||||
|
createLog(
|
||||||
|
"info",
|
||||||
|
"ocp",
|
||||||
|
"ocp",
|
||||||
|
`Printing label for ${whatToPrint.MachineDescription}`
|
||||||
|
);
|
||||||
|
return whatToPrint;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// as we are only allowing 2 lines if one is down the other must be up... still going to conditional it to be sure
|
||||||
|
createLog(
|
||||||
|
"info",
|
||||||
|
"ocp",
|
||||||
|
"ocp",
|
||||||
|
"Looking at what line is down and printing the other one!"
|
||||||
|
);
|
||||||
|
if (firstLine === 1 && secondLine === 0) {
|
||||||
|
// print the other line
|
||||||
|
let whatToPrint = lotInfo.filter(
|
||||||
|
(m: any) => m.machineID === lotInfo[1].machineID
|
||||||
|
);
|
||||||
|
|
||||||
|
// send to label
|
||||||
|
createLog(
|
||||||
|
"info",
|
||||||
|
"ocp",
|
||||||
|
"ocp",
|
||||||
|
`Printing label for ${whatToPrint.MachineDescription}`
|
||||||
|
);
|
||||||
|
return whatToPrint;
|
||||||
|
} else if (firstLine === 0 && secondLine === 1) {
|
||||||
|
// print the other line
|
||||||
|
let whatToPrint = lotInfo.filter(
|
||||||
|
(m: any) => m.machineID === lotInfo[0].machineID
|
||||||
|
);
|
||||||
|
// send to label
|
||||||
|
createLog(
|
||||||
|
"info",
|
||||||
|
"ocp",
|
||||||
|
"ocp",
|
||||||
|
`Printing label for ${whatToPrint.MachineDescription}`
|
||||||
|
);
|
||||||
|
return whatToPrint;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user