result = true;
il.write(gmh, GenericMessageHeader.msgStatusSuccess, "Processed OK", "File Write", fio.getFilename());
setErrorMessage("");
if (device.equals("Email"))
{
ogm = new JeMailOutGoingMessage(inter,transactionRef,fio);
ogm.sendEmail();
}
}
else
{
result = false;
il.write(gmh, GenericMessageHeader.msgStatusError, fio.getErrorMessage(), "File Write", fio.getFilename());
setErrorMessage(fio.getErrorMessage());
}
}
}
catch (SQLException e)
{
}
}
if (inter.getFormat().equals("XML"))
{
try
{
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
DocumentBuilder builder = factory.newDocumentBuilder();
Document document = builder.newDocument();
Element message = (Element) document.createElement("message");
Element hostUniqueID = addElement(document, "hostRef", Common.hostList.getHost(getHostID()).getUniqueID());
message.appendChild(hostUniqueID);
Element messageRef = addElement(document, "messageRef", String.valueOf(transactionRef));
message.appendChild(messageRef);
Element messageType = addElement(document, "interfaceType", "Despatch Confirmation");
message.appendChild(messageType);
Element messageInformation = addElement(document, "messageInformation", "Despatch=" + desp.getDespatchNo());
message.appendChild(messageInformation);
Element messageDirection = addElement(document, "interfaceDirection", "Output");
message.appendChild(messageDirection);
Element messageDate = addElement(document, "messageDate", JUtility.getISOTimeStampStringFormat(JUtility.getSQLDateTime()));
message.appendChild(messageDate);
Element despatchConfirmation = (Element) document.createElement("despatchConfirmation");
Element noofpallets = addElement(document, "numberOfPallets", String.valueOf(desp.getTotalPallets()));
despatchConfirmation.appendChild(noofpallets);
Element haulier = addElement(document, "haulier", String.valueOf(JUtility.replaceNullStringwithBlank(desp.getHaulier())));
despatchConfirmation.appendChild(haulier);
Element trailer = addElement(document, "trailer", String.valueOf(JUtility.replaceNullStringwithBlank(desp.getTrailer())));
despatchConfirmation.appendChild(trailer);
Element despatch = addElement(document, "despatchNo", desp.getDespatchNo());
despatchConfirmation.appendChild(despatch);
Element despatchDate = addElement(document, "despatchDate", JUtility.getISOTimeStampStringFormat(desp.getDespatchDate()));
despatchConfirmation.appendChild(despatchDate);
Element locationFrom = addElement(document, "fromLocation", desp.getLocationIDFrom());
despatchConfirmation.appendChild(locationFrom);
Element locationFromPlant = addElement(document, "fromPlant", desp.getLocationDBFrom().getPlant());
despatchConfirmation.appendChild(locationFromPlant);
Element locationFromWarehouse = addElement(document, "fromWarehouse", desp.getLocationDBFrom().getWarehouse());
despatchConfirmation.appendChild(locationFromWarehouse);
Element locationFromStorageSection = addElement(document, "fromStorageSection", desp.getLocationDBFrom().getStorageSection());
despatchConfirmation.appendChild(locationFromStorageSection);
Element locationFromStorageType = addElement(document, "fromStorageType", desp.getLocationDBFrom().getStorageType());
despatchConfirmation.appendChild(locationFromStorageType);
Element locationFromStorageBin = addElement(document, "fromStorageBin", desp.getLocationDBFrom().getStorageBin());
despatchConfirmation.appendChild(locationFromStorageBin);
Element locationFromGLN = addElement(document, "fromGLN", desp.getLocationDBFrom().getGLN());
despatchConfirmation.appendChild(locationFromGLN);
Element locationFromStorageLocation = addElement(document, "fromStorageLocation", desp.getLocationDBFrom().getStorageLocation());
despatchConfirmation.appendChild(locationFromStorageLocation);
Element locationTo = addElement(document, "toLocation", desp.getLocationIDTo());
despatchConfirmation.appendChild(locationTo);
Element locationToPlant = addElement(document, "toPlant", desp.getLocationDBTo().getPlant());
despatchConfirmation.appendChild(locationToPlant);
Element locationToWarehouse = addElement(document, "toWarehouse", desp.getLocationDBTo().getWarehouse());
despatchConfirmation.appendChild(locationToWarehouse);
Element locationToStorageSection = addElement(document, "toStorageSection", desp.getLocationDBTo().getStorageSection());
despatchConfirmation.appendChild(locationToStorageSection);
Element locationToStorageType = addElement(document, "toStorageType", desp.getLocationDBTo().getStorageType());
despatchConfirmation.appendChild(locationToStorageType);
Element locationToStorageBin = addElement(document, "toStorageBin", desp.getLocationDBTo().getStorageBin());
despatchConfirmation.appendChild(locationToStorageBin);
Element locationToGLN = addElement(document, "toGLN", desp.getLocationDBTo().getGLN());
despatchConfirmation.appendChild(locationToGLN);
Element locationToStorageLocation = addElement(document, "toStorageLocation", desp.getLocationDBTo().getStorageLocation());
despatchConfirmation.appendChild(locationToStorageLocation);
Element contents = (Element) document.createElement("contents");
despatchConfirmation.appendChild(contents);
JDBPalletHistory palhist = new JDBPalletHistory(getHostID(), getSessionID());
ResultSet rs = palhist.getInterfacingData(transactionRef, "DESPATCH", "TO", Long.valueOf(0), "SSCC", "asc");
int x = 1;
try
{
rs.beforeFirst();
while (rs.next())
{
palhist.getPropertiesfromResultSet(rs);
Element pallet = (Element) document.createElement("pallet");
Element item = addElement(document, "item", String.valueOf(x));
pallet.appendChild(item);
x++;
Element sscc = addElement(document, "SSCC", palhist.getPallet().getSSCC());
pallet.appendChild(sscc);
Element processOrder = addElement(document, "processOrder", palhist.getPallet().getProcessOrder());
pallet.appendChild(processOrder);
Element material = addElement(document, "material", palhist.getPallet().getMaterial());
pallet.appendChild(material);
Element ean = addElement(document, "ean", palhist.getPallet().getEAN());
pallet.appendChild(ean);
Element variant = addElement(document, "variant", palhist.getPallet().getVariant());
pallet.appendChild(variant);
Element qty = addElement(document, "quantity", palhist.getPallet().getQuantity().toString());
pallet.appendChild(qty);
String paluom = palhist.getPallet().getUom();
paluom = uoml.convertUom(inter.getUOMConversion(), paluom);
Element uom = addElement(document, "UOM", paluom);
pallet.appendChild(uom);
Element status = addElement(document, "status", palhist.getPallet().getStatus());
pallet.appendChild(status);
Element bbe = addElement(document, "bestBefore", JUtility.getISOTimeStampStringFormat(palhist.getPallet().getMaterialBatchExpiryDate()));
pallet.appendChild(bbe);
Element dom = addElement(document, "productionDate", JUtility.getISOTimeStampStringFormat(palhist.getPallet().getDateOfManufacture()));
pallet.appendChild(dom);
Element batch = addElement(document, "batch", palhist.getPallet().getBatchNumber());
pallet.appendChild(batch);
Element batchStatus = addElement(document, "batchStatus", palhist.getPallet().getMaterialBatchStatus());
pallet.appendChild(batchStatus);
contents.appendChild(pallet);
}
rs.close();
}
catch (SQLException e)
{
}
Element messageData = (Element) document.createElement("messageData");
messageData.appendChild(despatchConfirmation);
message.appendChild(messageData);
document.appendChild(message);
JXMLDocument xmld = new JXMLDocument();
xmld.setDocument(document);
gmh.decodeHeader(xmld);
if (device.equals("Disk") | device.equals("Email"))
{
path = inter.getRealPath();
if (fio.writeToDisk(path, document, transactionRef, "_"+desp.getLocationIDTo().replace(" ", "_")+"_DespatchConfirmation.xml") == true)
{
result = true;
il.write(gmh, GenericMessageHeader.msgStatusSuccess, "Processed OK", "File Write", fio.getFilename());
setErrorMessage("");
if (device.equals("Email"))
{
ogm = new JeMailOutGoingMessage(inter,transactionRef,fio);
ogm.sendEmail();
}
}
else
{