IO-233 CDK WIP
This commit is contained in:
@@ -26,8 +26,8 @@ exports.default = async function (socket, jobid) {
|
||||
"DEBUG",
|
||||
`Received Job export request for id ${jobid}`
|
||||
);
|
||||
socket["cdk-job-export"] = {};
|
||||
let clVFV, clADPV, clADPC;
|
||||
//The following values will be stored on the socket to allow callbacks.
|
||||
//let clVFV, clADPV, clADPC;
|
||||
const JobData = await QueryJobData(socket, jobid);
|
||||
console.log(JSON.stringify(JobData, null, 2));
|
||||
const DealerId = JobData.bodyshop.cdk_dealerid;
|
||||
@@ -38,8 +38,8 @@ exports.default = async function (socket, jobid) {
|
||||
);
|
||||
|
||||
//{1} Begin Calculate DMS Vehicle Id
|
||||
clVFV = await CalculateDmsVid(socket, JobData);
|
||||
if (clVFV.newId === "Y") {
|
||||
socket.clVFV = await CalculateDmsVid(socket, JobData);
|
||||
if (socket.clVFV.newId === "Y") {
|
||||
//{1.2} This is a new Vehicle ID
|
||||
CdkBase.createLogEvent(
|
||||
socket,
|
||||
@@ -49,7 +49,7 @@ exports.default = async function (socket, jobid) {
|
||||
CdkBase.createLogEvent(
|
||||
socket,
|
||||
"TRACE",
|
||||
`{1.2} clVFV: ${JSON.stringify(clVFV, null, 2)}`
|
||||
`{1.2} clVFV: ${JSON.stringify(socket.clVFV, null, 2)}`
|
||||
);
|
||||
//Check if DMSCustId is Empty - which it should always be?
|
||||
//{6.6} Should check to see if a customer exists so that we can marry it to the new vehicle.
|
||||
@@ -87,7 +87,7 @@ exports.default = async function (socket, jobid) {
|
||||
);
|
||||
socket.emit("cdk-select-customer", strIDS);
|
||||
|
||||
//TOOD: Need to find a way to wait and determine which customer to use.
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
CdkBase.createLogEvent(
|
||||
@@ -108,7 +108,11 @@ exports.default = async function (socket, jobid) {
|
||||
);
|
||||
|
||||
//Use the new customer number to insert the customer record.
|
||||
clADPC = await CreateCustomerInDms(socket, JobData, newCustomerNumber);
|
||||
socket.clADPC = await CreateCustomerInDms(
|
||||
socket,
|
||||
JobData,
|
||||
newCustomerNumber
|
||||
);
|
||||
CdkBase.createLogEvent(
|
||||
socket,
|
||||
"DEBUG",
|
||||
@@ -117,7 +121,7 @@ exports.default = async function (socket, jobid) {
|
||||
CdkBase.createLogEvent(
|
||||
socket,
|
||||
"TRACE",
|
||||
`{11.1} clADPC: ${JSON.stringify(clADPC, null, 2)}`
|
||||
`{11.1} clADPC: ${JSON.stringify(socket.clADPC, null, 2)}`
|
||||
);
|
||||
}
|
||||
} else {
|
||||
@@ -125,14 +129,14 @@ exports.default = async function (socket, jobid) {
|
||||
CdkBase.createLogEvent(
|
||||
socket,
|
||||
"TRACE",
|
||||
`{1.1} clVFV: ${JSON.stringify(clVFV, null, 2)}`
|
||||
`{1.1} clVFV: ${JSON.stringify(socket.clVFV, null, 2)}`
|
||||
);
|
||||
|
||||
//{2} Begin Find Vehicle in DMS
|
||||
clADPV = await FindVehicleInDms(socket, JobData, clVFV); //TODO: Verify that this should always return a result. If an ID was found previously, it should be correct?
|
||||
socket.clADPV = await FindVehicleInDms(socket, JobData, socket.clVFV); //TODO: Verify that this should always return a result. If an ID was found previously, it should be correct?
|
||||
|
||||
//{2.2} Check if the vehicle was found in the DMS.
|
||||
if (clADPV.AppErrorNo === "0") {
|
||||
if (socket.clADPV.AppErrorNo === "0") {
|
||||
//Vehicle was found.
|
||||
CdkBase.createLogEvent(
|
||||
socket,
|
||||
@@ -142,7 +146,7 @@ exports.default = async function (socket, jobid) {
|
||||
CdkBase.createLogEvent(
|
||||
socket,
|
||||
"TRACE",
|
||||
`{1.4} clADPV: ${JSON.stringify(clADPV, null, 2)}`
|
||||
`{1.4} clADPV: ${JSON.stringify(socket.clADPV, null, 2)}`
|
||||
);
|
||||
} else {
|
||||
//Vehicle was not found.
|
||||
@@ -154,7 +158,7 @@ exports.default = async function (socket, jobid) {
|
||||
CdkBase.createLogEvent(
|
||||
socket,
|
||||
"TRACE",
|
||||
`{6.4} clVFV: ${JSON.stringify(clVFV, null, 2)}`
|
||||
`{6.4} clVFV: ${JSON.stringify(socket.clVFV, null, 2)}`
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -167,6 +171,11 @@ exports.default = async function (socket, jobid) {
|
||||
} finally {
|
||||
//Ensure we always insert logEvents
|
||||
//GQL to insert logevents.
|
||||
CdkBase.createLogEvent(
|
||||
socket,
|
||||
"DEBUG",
|
||||
`Capturing log events to database.`
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -45,6 +45,15 @@ io.on("connection", (socket) => {
|
||||
socket.on("cdk-export-job", (jobid) => {
|
||||
CdkJobExport(socket, jobid);
|
||||
});
|
||||
socket.on("cdk-selected-customer", (selectedCustomerId) => {
|
||||
createLogEvent(
|
||||
socket,
|
||||
"DEBUG",
|
||||
`User selected customer ID ${selectedCustomerId}`
|
||||
);
|
||||
socket.selectedCustomerId = selectedCustomerId;
|
||||
//CdkJobExport(socket, jobid);
|
||||
});
|
||||
|
||||
socket.on("disconnect", () => {
|
||||
createLogEvent(socket, "DEBUG", `User disconnected.`);
|
||||
|
||||
Reference in New Issue
Block a user