Resolve PPG data pump issue.

This commit is contained in:
Patrick Fic
2022-09-20 15:30:32 -07:00
parent 78a04067c5
commit cccd025a24

View File

@@ -24,9 +24,8 @@ exports.mixdataUpload = async (req, res) => {
});
try {
req.files.forEach(async (element) => {
for (const element of req.files) {
const b = Buffer.from(element.buffer);
console.log(b.toString());
const inboundRequest = await xml2js.parseStringPromise(b.toString(), {
explicitArray: false,
@@ -59,23 +58,24 @@ exports.mixdataUpload = async (req, res) => {
ScaleType,
jobHash
);
const foundJobs = MixDataArray.filter((m) => m.jobid);
const MixDataQuery = `
mutation UPSERT_MIXDATA{
${MixDataArray.map((md, idx) =>
GenerateGqlForMixData(md, idx)
).join(" ")}
${foundJobs
.map((md, idx) => GenerateGqlForMixData(md, idx))
.join(" ")}
}
`;
const resp = await client.request(MixDataQuery);
if (foundJobs.length > 1) {
const resp = await client.request(MixDataQuery);
}
//Process the list of ROs and return an object to generate the queries.
}
});
}
res.sendStatus(200);
} catch (error) {
res.status(500).JSON(error);
res.status(500).json(error);
logger.log("job-mixdata-upload-error", "ERROR", null, null, {
error: error.message,
...error,
@@ -98,7 +98,7 @@ function DetermineScaleType(inboundRequest) {
function GetListOfRos(inboundRequest, ScaleType) {
if (ScaleType.company === "PPG" && ScaleType.version === "1.3.0") {
return inboundRequest.PPG.DataExportInterface.ROData.RepairOrders.RO.map(
return inboundRequest.PPG.MixDataInterface.ROData.RepairOrders.RO.map(
(r) => r.RONumber
);
}
@@ -106,11 +106,11 @@ function GetListOfRos(inboundRequest, ScaleType) {
function GenerateMixDataArray(inboundRequest, ScaleType, jobHash) {
if (ScaleType.company === "PPG" && ScaleType.version === "1.3.0") {
return inboundRequest.PPG.DataExportInterface.ROData.RepairOrders.RO.map(
return inboundRequest.PPG.MixDataInterface.ROData.RepairOrders.RO.map(
(r) => {
return {
jobid: jobHash[r.RONumber].jobid,
id: jobHash[r.RONumber].mixdataid,
jobid: jobHash[r.RONumber]?.jobid,
id: jobHash[r.RONumber]?.mixdataid,
mixdata: r,
totalliquidcost: r.TotalLiquidCost,
totalsundrycost: r.TotalSundryCost,