refactor(material checks): added proper logging to capture it all for auditing later
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -195,3 +195,4 @@ controller/Dockerfile-ignore
|
|||||||
controller/docker-compose.yml
|
controller/docker-compose.yml
|
||||||
controller/index.html
|
controller/index.html
|
||||||
controller/index.html
|
controller/index.html
|
||||||
|
LogisticsSupportTool_API_DOCS/environments/lst.bru
|
||||||
|
|||||||
@@ -36,6 +36,12 @@ export const isMainMatStaged = async (lot: any) => {
|
|||||||
|
|
||||||
// strangly the lot is not always sending over in slc so adding this in for now to see what line is cauing this issue
|
// strangly the lot is not always sending over in slc so adding this in for now to see what line is cauing this issue
|
||||||
if (!lot) {
|
if (!lot) {
|
||||||
|
createLog(
|
||||||
|
"info",
|
||||||
|
"mainMaterial",
|
||||||
|
"ocp",
|
||||||
|
"No lot was passed correctly."
|
||||||
|
);
|
||||||
return isStaged;
|
return isStaged;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -81,6 +87,17 @@ export const isMainMatStaged = async (lot: any) => {
|
|||||||
|
|
||||||
if (subset.some(failCondition)) {
|
if (subset.some(failCondition)) {
|
||||||
const failing = subset.filter(failCondition);
|
const failing = subset.filter(failCondition);
|
||||||
|
createLog(
|
||||||
|
"info",
|
||||||
|
"mainMaterial",
|
||||||
|
"ocp",
|
||||||
|
`lot: ${lot.lot}, is missing: ${failing
|
||||||
|
.map(
|
||||||
|
(o: any) =>
|
||||||
|
`${o.MaterialHumanReadableId} - ${o.MaterialDescription}`
|
||||||
|
)
|
||||||
|
.join(",\n ")} ${failMessage}`
|
||||||
|
);
|
||||||
return {
|
return {
|
||||||
message: `lot: ${lot.lot}, is missing: ${failing
|
message: `lot: ${lot.lot}, is missing: ${failing
|
||||||
.map(
|
.map(
|
||||||
@@ -91,6 +108,12 @@ export const isMainMatStaged = async (lot: any) => {
|
|||||||
success: false,
|
success: false,
|
||||||
};
|
};
|
||||||
} else {
|
} else {
|
||||||
|
createLog(
|
||||||
|
"info",
|
||||||
|
"mainMaterial",
|
||||||
|
"ocp",
|
||||||
|
`lot: ${lot.lot}, ${JSON.stringify(results)}`
|
||||||
|
);
|
||||||
return { message: successMessage, success: true };
|
return { message: successMessage, success: true };
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -99,6 +122,12 @@ export const isMainMatStaged = async (lot: any) => {
|
|||||||
|
|
||||||
const mainMaterial = res.find((n: any) => n.IsMainMaterial);
|
const mainMaterial = res.find((n: any) => n.IsMainMaterial);
|
||||||
if (mainMaterial?.noMMShortage === "noMM") {
|
if (mainMaterial?.noMMShortage === "noMM") {
|
||||||
|
createLog(
|
||||||
|
"info",
|
||||||
|
"mainMaterial",
|
||||||
|
"ocp",
|
||||||
|
`Main material: ${mainMaterial.MaterialHumanReadableId} - ${mainMaterial.MaterialDescription}: is not staged for ${lot.lot}`
|
||||||
|
);
|
||||||
return {
|
return {
|
||||||
message: `Main material: ${mainMaterial.MaterialHumanReadableId} - ${mainMaterial.MaterialDescription}: is not staged for ${lot.lot}`,
|
message: `Main material: ${mainMaterial.MaterialHumanReadableId} - ${mainMaterial.MaterialDescription}: is not staged for ${lot.lot}`,
|
||||||
success: false,
|
success: false,
|
||||||
@@ -125,7 +154,12 @@ export const isMainMatStaged = async (lot: any) => {
|
|||||||
successMessage: "auto color is good",
|
successMessage: "auto color is good",
|
||||||
});
|
});
|
||||||
if (!autoColor.success) return autoColor;
|
if (!autoColor.success) return autoColor;
|
||||||
console.log(autoColor);
|
createLog(
|
||||||
|
"info",
|
||||||
|
"mainMaterial",
|
||||||
|
"ocp",
|
||||||
|
`Auto Color: ${JSON.stringify(autoColor)}`
|
||||||
|
);
|
||||||
|
|
||||||
// 3. Manual color
|
// 3. Manual color
|
||||||
const manualColor = checkCondition({
|
const manualColor = checkCondition({
|
||||||
@@ -141,7 +175,12 @@ export const isMainMatStaged = async (lot: any) => {
|
|||||||
successMessage: "manual color is good",
|
successMessage: "manual color is good",
|
||||||
});
|
});
|
||||||
if (!manualColor.success) return manualColor;
|
if (!manualColor.success) return manualColor;
|
||||||
console.log(manualColor);
|
createLog(
|
||||||
|
"info",
|
||||||
|
"mainMaterial",
|
||||||
|
"ocp",
|
||||||
|
`Manual Color: ${JSON.stringify(manualColor)}`
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
createLog(
|
createLog(
|
||||||
"info",
|
"info",
|
||||||
@@ -166,8 +205,12 @@ export const isMainMatStaged = async (lot: any) => {
|
|||||||
successMessage: "auto PKG is good",
|
successMessage: "auto PKG is good",
|
||||||
});
|
});
|
||||||
if (!pkgAuto.success) return pkgAuto;
|
if (!pkgAuto.success) return pkgAuto;
|
||||||
console.log(pkgAuto);
|
createLog(
|
||||||
|
"info",
|
||||||
|
"mainMaterial",
|
||||||
|
"ocp",
|
||||||
|
`PKG Auto: ${JSON.stringify(pkgAuto)}`
|
||||||
|
);
|
||||||
// 5. Packaging manual
|
// 5. Packaging manual
|
||||||
const pkgManual = checkCondition({
|
const pkgManual = checkCondition({
|
||||||
results: res,
|
results: res,
|
||||||
@@ -182,7 +225,12 @@ export const isMainMatStaged = async (lot: any) => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
if (!pkgManual.success) return pkgManual;
|
if (!pkgManual.success) return pkgManual;
|
||||||
console.log(pkgManual);
|
createLog(
|
||||||
|
"info",
|
||||||
|
"mainMaterial",
|
||||||
|
"ocp",
|
||||||
|
`PKG Manual: ${JSON.stringify(pkgManual)}`
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
createLog(
|
createLog(
|
||||||
"info",
|
"info",
|
||||||
@@ -205,6 +253,17 @@ export const isMainMatStaged = async (lot: any) => {
|
|||||||
(n: any) => n.noPKGManualShortage === "noManPkg"
|
(n: any) => n.noPKGManualShortage === "noManPkg"
|
||||||
)
|
)
|
||||||
) {
|
) {
|
||||||
|
createLog(
|
||||||
|
"info",
|
||||||
|
"mainMaterial",
|
||||||
|
"ocp",
|
||||||
|
`lot: ${lot.lot}, is missing: ${packagingCheck
|
||||||
|
.map(
|
||||||
|
(o: any) =>
|
||||||
|
`${o.MaterialHumanReadableId} - ${o.MaterialDescription}`
|
||||||
|
)
|
||||||
|
.join(",\n ")} for pkg`
|
||||||
|
);
|
||||||
return (isStaged = {
|
return (isStaged = {
|
||||||
message: `lot: ${lot.lot}, is missing: ${packagingCheck
|
message: `lot: ${lot.lot}, is missing: ${packagingCheck
|
||||||
.map(
|
.map(
|
||||||
|
|||||||
Reference in New Issue
Block a user