expiryMode = ctrl.getKeyValue("EXPIRY DATE MODE");
inter.getInterfaceProperties("Production Declaration", "Output");
String device = inter.getDevice();
JDBPalletHistory palhist = new JDBPalletHistory(getHostID(), getSessionID());
ResultSet rs = palhist.getInterfacingData(transactionRef, "PROD DEC", "CONFIRM", Long.valueOf(1), "SSCC", "asc");
try
{
if (rs.next())
{
palhist.getPropertiesfromResultSet(rs);
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", "Production Declaration");
message.appendChild(messageType);
Element messageInformation = addElement(document, "messageInformation", "SSCC=" + palhist.getPallet().getSSCC());
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 productionDeclaration = (Element) document.createElement("productionDeclaration");
Element sscc = addElement(document, "SSCC", palhist.getPallet().getSSCC());
productionDeclaration.appendChild(sscc);
Element processOrder = addElement(document, "processOrder", palhist.getPallet().getProcessOrder());
productionDeclaration.appendChild(processOrder);
Element recipe = addElement(document, "recipe", palhist.getPallet().getProcessOrderObj(false).getRecipe());
productionDeclaration.appendChild(recipe);
Element required_resource = addElement(document, "requiredResource", palhist.getPallet().getProcessOrderObj(false).getRequiredResource());
productionDeclaration.appendChild(required_resource);
Element material = addElement(document, "material", palhist.getPallet().getMaterial());
productionDeclaration.appendChild(material);
if (mat.getMaterialProperties(palhist.getPallet().getMaterial()) == true)
{
Element description = addElement(document, "description", mat.getDescription());
productionDeclaration.appendChild(description);
Element old_code = addElement(document,"old_code",mat.getOldMaterial());
productionDeclaration.appendChild(old_code);
}
else
{
Element description = addElement(document, "description", "");
productionDeclaration.appendChild(description);
Element old_code = addElement(document,"old_code","");
productionDeclaration.appendChild(old_code);
}
Element ean = addElement(document, "ean", palhist.getPallet().getEAN());
productionDeclaration.appendChild(ean);
Element variant = addElement(document, "variant", palhist.getPallet().getVariant());
productionDeclaration.appendChild(variant);
Element status = addElement(document, "status", palhist.getPallet().getStatus());
productionDeclaration.appendChild(status);
Element batch = addElement(document, "batch", palhist.getPallet().getBatchNumber());
productionDeclaration.appendChild(batch);
Element batchStatus = addElement(document, "batchStatus", palhist.getPallet().getMaterialBatchStatus());
productionDeclaration.appendChild(batchStatus);
Element expiryDateMode = addElement(document, "expiry_Mode", expiryMode);
productionDeclaration.appendChild(expiryDateMode);
if (expiryMode.equals("BATCH") == true)
{
Element expiryDate = addElement(document, "expiryDate", JUtility.getISOTimeStampStringFormat(palhist.getPallet().getMaterialBatchExpiryDate()));
productionDeclaration.appendChild(expiryDate);
}
else
{
Element expiryDate = addElement(document, "expiryDate", JUtility.getISOTimeStampStringFormat(palhist.getPallet().getBatchExpiry()));
productionDeclaration.appendChild(expiryDate);
}
Element location = addElement(document, "location", palhist.getPallet().getLocationID());
productionDeclaration.appendChild(location);
Element name = addElement(document, "name", palhist.getPallet().getLocationObj().getDescription());
productionDeclaration.appendChild(name);
Element gln = addElement(document, "gln", palhist.getPallet().getLocationObj().getGLN());
productionDeclaration.appendChild(gln);
Element plant = addElement(document, "plant", palhist.getPallet().getLocationObj().getPlant());
productionDeclaration.appendChild(plant);
Element warehouse = addElement(document, "warehouse", palhist.getPallet().getLocationObj().getWarehouse());
productionDeclaration.appendChild(warehouse);
Element storageLocation = addElement(document, "storageLocation", palhist.getPallet().getLocationObj().getStorageLocation());
productionDeclaration.appendChild(storageLocation);
Element storageSection = addElement(document, "storageSection", palhist.getPallet().getLocationObj().getStorageSection());
productionDeclaration.appendChild(storageSection);
Element storageBin = addElement(document, "storageBin", palhist.getPallet().getLocationObj().getStorageBin());
productionDeclaration.appendChild(storageBin);
Element storageType = addElement(document, "storageType", palhist.getPallet().getLocationObj().getStorageType());
productionDeclaration.appendChild(storageType);
Element productionQuantity = addElement(document, "productionQuantity", String.valueOf(palhist.getPallet().getQuantity()));
productionDeclaration.appendChild(productionQuantity);
String paluom = palhist.getPallet().getUom();
paluom = uom.convertUom(inter.getUOMConversion(), paluom);
Element productionUOM = addElement(document, "productionUOM", paluom);
productionDeclaration.appendChild(productionUOM);
Element productionConfirmed = addElement(document, "confirmed", palhist.getPallet().getConfirmed());
productionDeclaration.appendChild(productionConfirmed);
Element productionDate = addElement(document, "productionDate", JUtility.getISOTimeStampStringFormat(palhist.getPallet().getDateOfManufacture()));
productionDeclaration.appendChild(productionDate);
Element messageData = (Element) document.createElement("messageData");
messageData.appendChild(productionDeclaration);
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,"_"+ palhist.getPallet().getLocationID().replace(" ", "_")+"_ProductionDeclaration.xml") == true)
{
result = true;
il.write(gmh, GenericMessageHeader.msgStatusSuccess, "Processed OK", "File Write", fio.getFilename());
setErrorMessage("");