Advertisement
claukiller

Untitled

Dec 11th, 2016
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.34 KB | None | 0 0
  1. public void generarPedido() throws SQLException {
  2. Long aux = codigoPedido();
  3. for (Map<String,Object> rep : getRepuestosEscasos()){
  4. List<Map<String, Object>> proveedores = findProveedorMasBarato((Long)rep.get("codigo"));
  5. //aqui selecciono uno pero no se como)
  6. if (!proveedorUsado((Long)proveedor.get("id"))){
  7. PreparedStatement pst = null;
  8. try {
  9. pst = c.prepareStatement(Conf.get("SQLinsertPedido"));
  10. pst.setLong(1, aux);
  11. pst.setDate(2, java.sql.Date.valueOf(java.time.LocalDate.now()));
  12. pst.setDate(3, null);
  13. pst.setString(4, "PEDIDO");
  14. pst.setLong(5,(Long) proveedor.get("id"));
  15. pst.executeUpdate();
  16. } catch (SQLException e) {
  17. throw e;
  18. } finally {
  19. Jdbc.close(pst);
  20. }
  21. }else {
  22. aux = getIdPedidoDeProveedor((Long) proveedor.get("id"));
  23. }
  24. PreparedStatement pst = null;
  25. try {
  26. pst = c.prepareStatement(Conf.get("SQLinsertRepuestoPedido"));
  27. pst.setLong(1,(int)rep.get("min_existencias") - (int)rep.get("existencias"));
  28. pst.setDouble(2, getPrecio((Long) rep.get("id"), (Long) proveedor.get("id")) );
  29. pst.setLong(3, (Long) rep.get("id"));
  30. pst.setLong(4, getIdPedido(aux));
  31. pst.executeUpdate();
  32. } catch (SQLException e) {
  33. throw e;
  34. } finally {
  35. Jdbc.close(pst);
  36. }
  37. }
  38. }
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement