IO-233 WIP CDK
This commit is contained in:
@@ -23,7 +23,7 @@ exports.default = async function (socket, jobid) {
|
||||
`Received Job export request for id ${jobid}`
|
||||
);
|
||||
//The following values will be stored on the socket to allow callbacks.
|
||||
//let clVFV, clADPV, clADPC;
|
||||
//let DMSVid, DMSVeh, clADPC;
|
||||
const JobData = await QueryJobData(socket, jobid);
|
||||
const DealerId = JobData.bodyshop.cdk_dealerid;
|
||||
CdkBase.createLogEvent(
|
||||
@@ -33,18 +33,18 @@ exports.default = async function (socket, jobid) {
|
||||
);
|
||||
|
||||
//{1} Begin Calculate DMS Vehicle Id
|
||||
socket.clVFV = await CalculateDmsVid(socket, JobData);
|
||||
if (socket.clVFV.newId === "Y") {
|
||||
socket.DMSVid = await CalculateDmsVid(socket, JobData);
|
||||
if (socket.DMSVid.newId === "Y") {
|
||||
//{1.2} This is a new Vehicle ID
|
||||
CdkBase.createLogEvent(
|
||||
socket,
|
||||
"DEBUG",
|
||||
`{1.2} clVFV DMSVid does *not* exist.`
|
||||
`{1.2} DMSVid DMSVid does *not* exist.`
|
||||
);
|
||||
CdkBase.createLogEvent(
|
||||
socket,
|
||||
"TRACE",
|
||||
`{1.2} clVFV: ${JSON.stringify(socket.clVFV, null, 2)}`
|
||||
`{1.2} DMSVid: ${JSON.stringify(socket.DMSVid, 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.
|
||||
@@ -55,7 +55,7 @@ exports.default = async function (socket, jobid) {
|
||||
);
|
||||
|
||||
//Array
|
||||
const strIDS = await FindCustomerIdFromDms(socket, JobData);
|
||||
const strIDS = await QueryDmsCustomerByName(socket, JobData);
|
||||
if (strIDS && strIDS.length > 0) {
|
||||
CdkBase.createLogEvent(
|
||||
socket,
|
||||
@@ -120,18 +120,22 @@ exports.default = async function (socket, jobid) {
|
||||
);
|
||||
}
|
||||
} else {
|
||||
CdkBase.createLogEvent(socket, "DEBUG", `{1.1} clVFV DMSVid does exist.`);
|
||||
CdkBase.createLogEvent(
|
||||
socket,
|
||||
"DEBUG",
|
||||
`{1.1} DMSVid DMSVid does exist.`
|
||||
);
|
||||
CdkBase.createLogEvent(
|
||||
socket,
|
||||
"TRACE",
|
||||
`{1.1} clVFV: ${JSON.stringify(socket.clVFV, null, 2)}`
|
||||
`{1.1} DMSVid: ${JSON.stringify(socket.DMSVid, null, 2)}`
|
||||
);
|
||||
|
||||
//{2} Begin Find Vehicle in DMS
|
||||
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?
|
||||
socket.DMSVeh = await QueryDmsVehicleById(socket, JobData, socket.DMSVid); //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 (socket.clADPV.AppErrorNo === "0") {
|
||||
if (socket.DMSVeh.AppErrorNo === "0") {
|
||||
//Vehicle was found.
|
||||
CdkBase.createLogEvent(
|
||||
socket,
|
||||
@@ -141,7 +145,7 @@ exports.default = async function (socket, jobid) {
|
||||
CdkBase.createLogEvent(
|
||||
socket,
|
||||
"TRACE",
|
||||
`{1.4} clADPV: ${JSON.stringify(socket.clADPV, null, 2)}`
|
||||
`{1.4} DMSVeh: ${JSON.stringify(socket.DMSVeh, null, 2)}`
|
||||
);
|
||||
} else {
|
||||
//Vehicle was not found.
|
||||
@@ -153,7 +157,7 @@ exports.default = async function (socket, jobid) {
|
||||
CdkBase.createLogEvent(
|
||||
socket,
|
||||
"TRACE",
|
||||
`{6.4} clVFV: ${JSON.stringify(socket.clVFV, null, 2)}`
|
||||
`{6.4} DMSVid: ${JSON.stringify(socket.DMSVid, null, 2)}`
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -308,7 +312,7 @@ async function GenerateCustomerNumberFromDms(socket, JobData) {
|
||||
}
|
||||
}
|
||||
|
||||
async function FindCustomerIdFromDms(socket, JobData) {
|
||||
async function QueryDmsCustomerByName(socket, JobData) {
|
||||
const ownerName = `${JobData.ownr_ln},${JobData.ownr_fn}`;
|
||||
CdkBase.createLogEvent(
|
||||
socket,
|
||||
@@ -352,23 +356,24 @@ async function FindCustomerIdFromDms(socket, JobData) {
|
||||
CdkBase.createLogEvent(
|
||||
socket,
|
||||
"ERROR",
|
||||
`Error in FindCustomerIdFromDms - ${JSON.stringify(error, null, 2)}`
|
||||
`Error in QueryDmsCustomerByName - ${JSON.stringify(error, null, 2)}`
|
||||
);
|
||||
throw new Error(error);
|
||||
}
|
||||
}
|
||||
|
||||
async function FindVehicleInDms(socket, JobData, clVFV) {
|
||||
async function QueryDmsVehicleById(socket, JobData, DMSVid) {
|
||||
CdkBase.createLogEvent(
|
||||
socket,
|
||||
"DEBUG",
|
||||
`{2}/{6} Begin Find Vehicle In DMS using clVFV: ${clVFV}`
|
||||
`{2}/{6} Begin Find Vehicle In DMS using DMSVid: ${DMSVid}`
|
||||
);
|
||||
|
||||
try {
|
||||
const soapClientVehicleInsertUpdate = await soap.createClientAsync(
|
||||
CdkWsdl.VehicleInsertUpdate
|
||||
);
|
||||
|
||||
const soapResponseVehicleInsertUpdate =
|
||||
await soapClientVehicleInsertUpdate.readBulkAsync(
|
||||
{
|
||||
@@ -376,7 +381,7 @@ async function FindVehicleInDms(socket, JobData, clVFV) {
|
||||
arg1: { id: JobData.bodyshop.cdk_dealerid },
|
||||
arg2: {
|
||||
fileType: "VEHICLES",
|
||||
vehiclesVehicleId: clVFV.vehiclesVehId,
|
||||
vehiclesVehicleId: DMSVid.vehiclesVehId,
|
||||
},
|
||||
},
|
||||
|
||||
@@ -401,7 +406,7 @@ async function FindVehicleInDms(socket, JobData, clVFV) {
|
||||
CdkBase.createLogEvent(
|
||||
socket,
|
||||
"ERROR",
|
||||
`Error in FindVehicleInDms - ${JSON.stringify(error, null, 2)}`
|
||||
`Error in QueryDmsVehicleById - ${JSON.stringify(error, null, 2)}`
|
||||
);
|
||||
throw new Error(error);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user