System.out.println("Descripciones ..." + ansDescriptions);
PreparedStatement stmtItem = c.prepareStatement("insert into articulo ( codigo , descripcion , fecha_registro , "
+ "codigo_de_barras , modelo , unidad_venta, "
+ "existencia_actual, bloqueado, imagen, descuento ) values (?,?,now(),?,?,?,0,0,?,?)");
PreparedStatement stmtBarcode = c.prepareStatement("insert IGNORE into codigo_de_barras(codigo_de_articulo,codigo_de_barras) values(?,?)");
XMLElement xmlI = null;
for (Object x : xml.getChildren()) {
xmlI = (XMLElement)x;
if ( !itemsNeededJustOnce.contains(xmlI.getAttribute("MATNR","")) ){
stmtItem.setString(1, xmlI.getAttribute("MATNR",""));
stmtItem.setString(2, xmlI.getAttribute("MAKTG",""));
stmtItem.setString(3, xmlI.getAttribute("EAN11",""));
stmtItem.setString(4, xmlI.getAttribute("MATKL",""));
stmtItem.setString(5, xmlI.getAttribute("MSEH3",""));
stmtItem.setString(6, Shared.getConfig("photoDir") + xmlI.getAttribute("MATNR","") + ".JPG");
stmtItem.setString(7, "0");
stmtItem.executeUpdate();
stmtBarcode.setString(1, xmlI.getAttribute("MATNR",""));
stmtBarcode.setString(2, xmlI.getAttribute("EAN11",""));
stmtBarcode.executeUpdate();
itemsNeededJustOnce.add(xmlI.getAttribute("MATNR",""));
}
xmlI = null;
}
itemsNeededJustOnce = null;
xml = null;
parser = null;
reader = null;
ansDescriptions = null;
Iterator<XMLElement> itr = Shared.itemsNeeded.iterator();
stmtItem = c.prepareStatement("update articulo set existencia_actual = existencia_actual + ? where codigo = ? ");
while ( itr.hasNext() ){
xmlI = itr.next();
int reason = 1;
if ( checkReason ){
reason = Shared.calculateReason(xmlI.getAttribute("BWART",""), xmlI.getAttribute("SHKZG",""));
}
if ( reason == 0 ){
// we are in problems... =(
}else{
stmtItem.setString(2, xmlI.getAttribute("MATNR",""));
stmtItem.setInt(1, reason * Integer.parseInt(xmlI.getAttribute("MENGE","").split("\\.")[0]));
int ans = stmtItem.executeUpdate();
if ( ans == 0 ){
// We are in problemas again... ='(
}
}