Example #1
0
 /**
  * Replica los clientes faltantes de enviar a las sucursales
  *
  * <p>Util para tareas especiales
  */
 public void replicarFaltantes() {
   final JdbcTemplate template = Services.getInstance().getJdbcTemplate();
   String sql =
       "select distinct clave from sx_clientes_log where tx_replicado is null order by modificado desc";
   List<Map<String, Object>> rows = template.queryForList(sql);
   if (rows.size() > 0) {
     logger.info("Clientes pendiente de replicado: " + rows.size());
   }
   for (Map<String, Object> row : rows) {
     String clave = (String) row.get("CLAVE");
     Cliente c = Services.getInstance().getClientesManager().buscarPorClave(clave);
     if (c != null) {
       logger.info("Replicando :" + c.getClave());
       for (Long sucursalId : getSucursales()) {
         HibernateTemplate target = ReplicaServices.getInstance().getHibernateTemplate(sucursalId);
         try {
           target.replicate(c, ReplicationMode.OVERWRITE);
           logger.info("Cliente replicado: " + c.getClave());
         } catch (Exception e) {
           logger.error(
               "Error replicando cliente: "
                   + c.getClave()
                   + " A sucursal: "
                   + sucursalId
                   + "  "
                   + ExceptionUtils.getRootCauseMessage(e));
         }
       }
     }
   }
 }
Example #2
0
  public void replicarPendientes() {
    for (Long sucursalId : getSucursales()) {
      importarPendientes(sucursalId);
    }
    final JdbcTemplate template = Services.getInstance().getJdbcTemplate();
    String sql =
        "select * from sx_clientes_log where tx_replicado is null and date(modificado)>=? order by modificado desc";
    Object[] values = new Object[] {new SqlParameterValue(Types.DATE, new Date())};
    List<Map<String, Object>> rows = template.queryForList(sql, values);
    if (rows.size() > 0) {
      logger.info("Client es pendiente de replicado: " + rows.size());
    }
    for (Map<String, Object> row : rows) {
      String clave = (String) row.get("CLAVE");
      Number id = (Number) row.get("ID");
      Cliente c = Services.getInstance().getClientesManager().buscarPorClave(clave);
      boolean aplicado = true;
      if (c != null) {
        logger.info("Replicando :" + c.getClave() + " Log ID:" + id);
        for (Long sucursalId : getSucursales()) {

          HibernateTemplate target = ReplicaServices.getInstance().getHibernateTemplate(sucursalId);
          try {

            target.replicate(c, ReplicationMode.OVERWRITE);

          } catch (Exception e) {
            aplicado = false;
            logger.error(
                "Error replicando cliente: "
                    + c.getClave()
                    + " A sucursal: "
                    + sucursalId
                    + "  "
                    + ExceptionUtils.getRootCauseMessage(e));
          }
        }
        if (aplicado) {
          try {
            Object[] params = {
              new SqlParameterValue(Types.TIMESTAMP, new Date()),
              new SqlParameterValue(Types.NUMERIC, id.longValue())
            };
            template.update("update sx_clientes_log set tx_replicado=? where id=?", params);
            // logger.info("Log replicado: "+id+ "Cliente : "+c.getClave());
          } catch (Exception e) {
            logger.error(e);
          }
          logger.info(
              "Actualizacion de cliente exitosa Log ID: " + id + " Cliente(Clave):" + c.getClave());
        }
      }
    }
  }
Example #3
0
  public void asignarCliente(Cliente c, Venta v, Map<String, Object> context) {

    if (c.getCredito() != null) {

    } else {
      context.put(TIPO_DE_VENTA_KEY, new String[] {"CONTADO"});
    }
  }
Example #4
0
 @Override
 protected List<Venta> getData() {
   String hql = "from Venta v where v.fecha between ? and ?";
   Object[] params = new Object[] {periodo.getFechaInicial(), periodo.getFechaFinal()};
   if (cliente != null) {
     hql = "from Venta v where v.fecha between ? and ? and v.cliente.clave=?";
     params =
         new Object[] {periodo.getFechaInicial(), periodo.getFechaFinal(), cliente.getClave()};
   }
   return Services.getInstance().getHibernateTemplate().find(hql, params);
 }
Example #5
0
  /**
   * Regresa las cuentas por cobrar del cliente indicado
   *
   * @param cliente
   * @return
   */
  public static List<Cargo> seleccionar(final Cliente cliente, OrigenDeOperacion origen) {

    String nombre = cliente != null ? cliente.getLabel() : "";
    String title = "Facturas/Cargos  pendies para: " + nombre;
    DialogoSelectorDeCxC dialog = new DialogoSelectorDeCxC("");
    dialog.setTitle(title);
    dialog.selector.setCliente(cliente);
    dialog.selector.setOrigen(origen);
    dialog.open();
    if (!dialog.hasBeenCanceled()) {
      List data = new ArrayList();
      data.addAll(dialog.selector.selectionModel.getSelected());
      dialog = null;
      return data;
    }
    return null;
  }