IO-227 Begin PPG 2 way communication.
This commit is contained in:
206
server/mixdata/PPGSampleData.json
Normal file
206
server/mixdata/PPGSampleData.json
Normal file
@@ -0,0 +1,206 @@
|
||||
{
|
||||
"PPG": {
|
||||
"Header": {
|
||||
"Protocol": {
|
||||
"Message": "MixDataInterface",
|
||||
"Name": "PPG",
|
||||
"Version": "1.3.0"
|
||||
},
|
||||
"Transaction": {
|
||||
"TransactionID": "3F2504E0-4F89-11D3-9A0C-0305E82C3301",
|
||||
"TransactionDate": "2006-06-06T15:00:00"
|
||||
},
|
||||
"ShopInfo": {
|
||||
"ShopID": "SomeShopID",
|
||||
"ShopName": "Some Body Shop"
|
||||
}
|
||||
},
|
||||
"DataExportInterface": {
|
||||
"ROData": {
|
||||
"ROCount": "2",
|
||||
"RepairOrders": {
|
||||
"RO": [
|
||||
{
|
||||
"ROCounter": "1",
|
||||
"RONumber": "27187",
|
||||
"Notes": "This is a painter note",
|
||||
"Undercoat": "False",
|
||||
"Clearcoat": "False",
|
||||
"Basecoat": "True",
|
||||
"TotalLiquidCost": "133.26",
|
||||
"TotalSundryCost": "47.12",
|
||||
"MixCount": "2",
|
||||
"Mixes": {
|
||||
"Mix": [
|
||||
{
|
||||
"MixCounter": "1",
|
||||
"MixRONumber": "27187",
|
||||
"MixedDate": "2008-09-17T00:00:00",
|
||||
"MixedBy": "Tony Blair",
|
||||
"MixedByEmployeeID": "5>",
|
||||
"PPGBrandCode": "ABC",
|
||||
"MixCost": "83.49",
|
||||
"FormulaType": "Standard",
|
||||
"ComponentCount": "5",
|
||||
"Components": {
|
||||
"Component": [
|
||||
{
|
||||
"ComponentCounter": "1",
|
||||
"ComponentRONumber": "27187",
|
||||
"ComponentCode": "P425-900",
|
||||
"ComponentDescription": "F3550 CLEAR",
|
||||
"ComponentCost": "44.84",
|
||||
"ComponentWeightApplied": "521.5347",
|
||||
"ComponentWeightTarget": "525.4023",
|
||||
"ComponentDensity": "1.311"
|
||||
},
|
||||
{
|
||||
"ComponentCounter": "2",
|
||||
"ComponentRONumber": "27187",
|
||||
"ComponentCode": "P425-948",
|
||||
"ComponentDescription": "H/S BLACK",
|
||||
"ComponentCost": "13.77",
|
||||
"ComponentWeightApplied": "118.5779",
|
||||
"ComponentWeightTarget": "118.5832",
|
||||
"ComponentDensity": "0.971"
|
||||
},
|
||||
{
|
||||
"ComponentCounter": "3",
|
||||
"ComponentRONumber": "27187",
|
||||
"ComponentCode": "P425-921",
|
||||
"ComponentDescription": "H/S CLARET",
|
||||
"ComponentCost": "0.24",
|
||||
"ComponentWeightApplied": "2.082",
|
||||
"ComponentWeightTarget": "2.1022",
|
||||
"ComponentDensity": "0.976"
|
||||
},
|
||||
{
|
||||
"ComponentCounter": "4",
|
||||
"ComponentRONumber": "27187",
|
||||
"ComponentCode": "P425-937",
|
||||
"ComponentDescription": "PALE YELLOW",
|
||||
"ComponentCost": "2.85",
|
||||
"ComponentWeightApplied": "20.4412",
|
||||
"ComponentWeightTarget": "20.4888",
|
||||
"ComponentDensity": "1.136"
|
||||
},
|
||||
{
|
||||
"ComponentCounter": "5",
|
||||
"ComponentRONumber": "27187",
|
||||
"ComponentCode": "P425-948",
|
||||
"ComponentDescription": "Matting Agent",
|
||||
"ComponentCost": "21.79",
|
||||
"ComponentWeightApplied": "414.8808",
|
||||
"ComponentWeightTarget": "414.8798",
|
||||
"ComponentDensity": "0.987"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"MixCounter": "2",
|
||||
"MixRONumber": "27187",
|
||||
"MixedDate": "2008-09-17T00:00:00",
|
||||
"MixedBy": "Bill Clinton",
|
||||
"MixedByEmployeeID": "42>",
|
||||
"PPGBrandCode": "DEF",
|
||||
"MixCost": "49.76",
|
||||
"FormulaType": "RFU",
|
||||
"ComponentCount": "2",
|
||||
"Components": {
|
||||
"Component": [
|
||||
{
|
||||
"ComponentCounter": "1",
|
||||
"ComponentRONumber": "27187",
|
||||
"ComponentCode": "P850-1401",
|
||||
"ComponentDescription": "Fade-Out Thinner",
|
||||
"ComponentCost": "17.34",
|
||||
"ComponentWeightApplied": "837.1649",
|
||||
"ComponentWeightTarget": "838.2232",
|
||||
"ComponentDensity": "0.8716"
|
||||
},
|
||||
{
|
||||
"ComponentCounter": "2",
|
||||
"ComponentRONumber": "27187",
|
||||
"ComponentCode": "P190-478",
|
||||
"ComponentDescription": "Ultraclear",
|
||||
"ComponentCost": "32.42",
|
||||
"ComponentWeightApplied": "862.5329",
|
||||
"ComponentWeightTarget": "870.3238",
|
||||
"ComponentDensity": "0.898"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"SundryCount": "1",
|
||||
"Sundries": {
|
||||
"Sundry": {
|
||||
"SundryCounter": "1",
|
||||
"SundryRONumber": "27187",
|
||||
"SundryAddedDate": "2008-09-17T00:00:00",
|
||||
"SundryAddedBy": "Tony Blair",
|
||||
"SundryCode": "Sundry1",
|
||||
"SundryDescription": "Bumper Prep Kit",
|
||||
"SundryCost": "23.56",
|
||||
"SundryQuantity": "2",
|
||||
"SundryQuantityUOM": "Each"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"ROCounter": "2",
|
||||
"RONumber": "27320",
|
||||
"Notes": "This is a painter note too",
|
||||
"Undercoat": "True",
|
||||
"Clearcoat": "False",
|
||||
"Basecoat": "False",
|
||||
"TotalLiquidCost": "9.59",
|
||||
"TotalSundryCost": "0.0",
|
||||
"MixCount": "1",
|
||||
"Mixes": {
|
||||
"Mix": {
|
||||
"MixCounter": "1",
|
||||
"MixRONumber": "27320",
|
||||
"MixedDate": "2008-12-03T00:00:00",
|
||||
"MixedBy": "Jerry Primer",
|
||||
"MixedByEmployeeID": "87>",
|
||||
"PPGBrandCode": "GHI",
|
||||
"MixCost": "9.59",
|
||||
"FormulaType": "Standard",
|
||||
"ComponentCount": "2",
|
||||
"Components": {
|
||||
"Component": [
|
||||
{
|
||||
"ComponentCounter": "1",
|
||||
"ComponentRONumber": "27320",
|
||||
"ComponentCode": "P565-957",
|
||||
"ComponentDescription": "Long Life Etch",
|
||||
"ComponentCost": "5.31",
|
||||
"ComponentWeightApplied": "117.8754",
|
||||
"ComponentWeightTarget": "116.0129",
|
||||
"ComponentDensity": "0.9808"
|
||||
},
|
||||
{
|
||||
"ComponentCounter": "2",
|
||||
"ComponentRONumber": "27320",
|
||||
"ComponentCode": "P275-61",
|
||||
"ComponentDescription": "Acitvator For Long Life",
|
||||
"ComponentCost": "4.28",
|
||||
"ComponentWeightApplied": "103.4325",
|
||||
"ComponentWeightTarget": "101.3950",
|
||||
"ComponentDensity": "0.8571"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
"SundryCount": "0"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
65
server/mixdata/mixdata.js
Normal file
65
server/mixdata/mixdata.js
Normal file
@@ -0,0 +1,65 @@
|
||||
const path = require("path");
|
||||
const _ = require("lodash");
|
||||
const logger = require("../utils/logger");
|
||||
const xml2js = require("xml2js");
|
||||
|
||||
require("dotenv").config({
|
||||
path: path.resolve(
|
||||
process.cwd(),
|
||||
`.env.${process.env.NODE_ENV || "development"}`
|
||||
),
|
||||
});
|
||||
|
||||
exports.mixdataUpload = async (req, res) => {
|
||||
const { bodyshopid } = req.body;
|
||||
logger.log("media-bulk-download", "DEBUG", req.user.email, ids, null);
|
||||
const BearerToken = req.headers.authorization;
|
||||
logger.log("job-mixdata-upload", "DEBUG", req.user.email, null, null);
|
||||
const client = new GraphQLClient(process.env.GRAPHQL_ENDPOINT, {
|
||||
headers: {
|
||||
Authorization: BearerToken,
|
||||
},
|
||||
});
|
||||
|
||||
try {
|
||||
req.files.forEach(async (element) => {
|
||||
const b = Buffer.from(element.buffer);
|
||||
console.log(b.toString());
|
||||
|
||||
const inboundRequest = await xml2js.parseStringPromise(b.toString(), {
|
||||
explicitArray: false,
|
||||
});
|
||||
|
||||
const ScaleType = DetermineScaleType(inboundRequest);
|
||||
const ROList = GetListOfRos(inboundRequest, ScaleType);
|
||||
|
||||
//Query the list of ROs based on the RO number.
|
||||
|
||||
console.log(ROList);
|
||||
});
|
||||
res.sendStatus(200);
|
||||
} catch (error) {
|
||||
res.status(500).JSON(error);
|
||||
}
|
||||
};
|
||||
|
||||
function DetermineScaleType(inboundRequest) {
|
||||
const ret = { type: "", verson: 0 };
|
||||
|
||||
//PPG Mix Data
|
||||
if (inboundRequest.PPG && inboundRequest.PPG.Header.Protocol.Name === "PPG") {
|
||||
return {
|
||||
type: inboundRequest.PPG.Header.Protocol.Name,
|
||||
company: "PPG",
|
||||
version: inboundRequest.PPG.Header.Protocol.Version,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
function GetListOfRos(inboundRequest, ScaleType) {
|
||||
if (ScaleType.company === "PPG" && ScaleType.version === "1.3.0") {
|
||||
return inboundRequest.PPG.DataExportInterface.ROData.RepairOrders.RO.map(
|
||||
(r) => r.RONumber
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user