Ver código fonte

WIP: Numero colli minimo

Fabio Dalle Ave 2 meses atrás
pai
commit
ecd9f9f806

+ 1 - 1
src/main/java/powerage/dao/LogDAO.java

@@ -26,7 +26,7 @@ public class LogDAO extends GenericDAO<Log, Long> implements IDAO<Log, Long> {
 		}
 		}
 
 
 		Query<Long> countQuery = currentSession()
 		Query<Long> countQuery = currentSession()
-			.createQuery("select count(l) " + hql.toString(), Long.class);
+			.createQuery("select count(l.idLog) " + hql.toString(), Long.class);
 		if (filter != null && !filter.isEmpty()) {
 		if (filter != null && !filter.isEmpty()) {
 			countQuery.setParameter("filter", "%" + filter + "%");
 			countQuery.setParameter("filter", "%" + filter + "%");
 			countQuery.setParameter("filterExact", filter);
 			countQuery.setParameter("filterExact", filter);

+ 12 - 21
src/main/java/powerage/dao/OrdineDAO.java

@@ -1,13 +1,11 @@
 package powerage.dao;
 package powerage.dao;
 
 
+import java.util.ArrayList;
 import java.util.List;
 import java.util.List;
 
 
 import commons.utility.MutableHolder;
 import commons.utility.MutableHolder;
 
 
-import jakarta.persistence.EntityManager;
-import jakarta.persistence.TypedQuery;
-import jakarta.transaction.Transactional;
-import lombok.RequiredArgsConstructor;
+import org.hibernate.SessionFactory;
 import org.hibernate.query.Query;
 import org.hibernate.query.Query;
 
 
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -18,7 +16,7 @@ import powerage.entities.Ordine;
 import commons.utility.dao.IDAO;
 import commons.utility.dao.IDAO;
 
 
 @Repository
 @Repository
-public class OrdineDAO
+public class OrdineDAO 
 		extends PowerAgeDAO<Ordine, Long> 
 		extends PowerAgeDAO<Ordine, Long> 
 		implements IDAO<Ordine, Long>  {
 		implements IDAO<Ordine, Long>  {
 
 
@@ -32,7 +30,7 @@ public class OrdineDAO
 			hql.append(" and (c.ragioneSociale like :filter or c.codCliente = :filterExact or a.ragioneSociale = :filterRS or a.codAgente = :filterCA)");
 			hql.append(" and (c.ragioneSociale like :filter or c.codCliente = :filterExact or a.ragioneSociale = :filterRS or a.codAgente = :filterCA)");
 		}
 		}
 
 
-		TypedQuery<Long> countQuery = currentSession()
+		Query<Long> countQuery = currentSession()
 			.createQuery("select count(o.idOrdine) " + hql.toString(), Long.class);
 			.createQuery("select count(o.idOrdine) " + hql.toString(), Long.class);
 		if (idAgente != 0)
 		if (idAgente != 0)
 			countQuery.setParameter("idAgente", idAgente);
 			countQuery.setParameter("idAgente", idAgente);
@@ -42,8 +40,7 @@ public class OrdineDAO
 			countQuery.setParameter("filterRS", filter);
 			countQuery.setParameter("filterRS", filter);
 			countQuery.setParameter("filterCA", filter);
 			countQuery.setParameter("filterCA", filter);
 		}
 		}
-
-		rowCount.value = (countQuery.getSingleResult()).intValue();
+		rowCount.value = countQuery.uniqueResult().intValue();
 
 
 		Query<Ordine> query = currentSession()
 		Query<Ordine> query = currentSession()
 			.createQuery(hql.toString() + " order by o.dataOrdine desc", Ordine.class);
 			.createQuery(hql.toString() + " order by o.dataOrdine desc", Ordine.class);
@@ -62,7 +59,6 @@ public class OrdineDAO
 		return res;
 		return res;
 	}
 	}
 
 
-
 	public List<Ordine> getOrdiniNuovi(int idAgente, String filter, int iDisplayStart, int iDisplayLength, int iSortCol_0, String sSortDir_0, MutableHolder<Integer> rowCount) {
 	public List<Ordine> getOrdiniNuovi(int idAgente, String filter, int iDisplayStart, int iDisplayLength, int iSortCol_0, String sSortDir_0, MutableHolder<Integer> rowCount) {
 		boolean tx = startTransaction();
 		boolean tx = startTransaction();
 
 
@@ -106,19 +102,15 @@ public class OrdineDAO
 
 
 	public List<Ordine> getNewOrders() {
 	public List<Ordine> getNewOrders() {
 		boolean tx = startTransaction();
 		boolean tx = startTransaction();
-
-		Query<Ordine> q = currentSession()
-			.createQuery("select o from Ordine o where o.stato = :stato", Ordine.class)
+		List<Ordine> res = currentSession()
+			.createQuery("from Ordine o where o.stato = :stato", Ordine.class)
 			.setParameter("stato", "N")
 			.setParameter("stato", "N")
-			;
-
-		List<Ordine> res = q.list();
+			.list();
 		if (tx)
 		if (tx)
 			commit();
 			commit();
 		return res;
 		return res;
 	}
 	}
 
 
-
 	public Ordine getByIdOrdineAgente(long idAgente, long idOrdineAgente) {
 	public Ordine getByIdOrdineAgente(long idAgente, long idOrdineAgente) {
 		List<Ordine> res = currentSession()
 		List<Ordine> res = currentSession()
 			.createQuery("from Ordine o join fetch o.agente a where a.idAgente = :idAgente and o.idOrdineAgente = :idOrdAgente", Ordine.class)
 			.createQuery("from Ordine o join fetch o.agente a where a.idAgente = :idAgente and o.idOrdineAgente = :idOrdAgente", Ordine.class)
@@ -136,7 +128,7 @@ public class OrdineDAO
 
 
 		boolean tx = startTransaction();
 		boolean tx = startTransaction();
 
 
-		StringBuilder hql = new StringBuilder("from Ordine o join o.cliente c join o.agente a where 1=1 ");
+		StringBuilder hql = new StringBuilder("from Ordine o join  o.cliente c join  o.agente a where 1=1 ");
 		if (beanFiltriOrdine != null) {
 		if (beanFiltriOrdine != null) {
 			if (beanFiltriOrdine.getCbSoloNuovi())
 			if (beanFiltriOrdine.getCbSoloNuovi())
 				hql.append(" and o.stato = :stato");
 				hql.append(" and o.stato = :stato");
@@ -153,9 +145,8 @@ public class OrdineDAO
 				hql.append(" and o.dataOrdine <= :aData");
 				hql.append(" and o.dataOrdine <= :aData");
 		}
 		}
 
 
-
-		jakarta.persistence.Query countQuery =  currentSession().createQuery("select count(distinct o)" + hql.toString());
-
+		Query<Long> countQuery = currentSession()
+			.createQuery("select count(distinct o) " + hql.toString(), Long.class);
 		if (beanFiltriOrdine != null) {
 		if (beanFiltriOrdine != null) {
 			if (beanFiltriOrdine.getCbSoloNuovi())
 			if (beanFiltriOrdine.getCbSoloNuovi())
 				countQuery.setParameter("stato", K_NUOVO);
 				countQuery.setParameter("stato", K_NUOVO);
@@ -172,7 +163,7 @@ public class OrdineDAO
 			if (beanFiltriOrdine.getaData() != null)
 			if (beanFiltriOrdine.getaData() != null)
 				countQuery.setParameter("aData", beanFiltriOrdine.getaData());
 				countQuery.setParameter("aData", beanFiltriOrdine.getaData());
 		}
 		}
-		Object cnt = ((Number)(countQuery.getSingleResult())).longValue();
+		Object cnt = countQuery.uniqueResult();
 		if (cnt instanceof Long)
 		if (cnt instanceof Long)
 			rowCount.value = ((Long) cnt).intValue();
 			rowCount.value = ((Long) cnt).intValue();
 		else
 		else

+ 9 - 4
src/main/java/powerage/importers/impl/ArticoliImporter.java

@@ -38,7 +38,7 @@ public class ArticoliImporter extends BaseImporter implements IBaseImporter {
 		Articolo articolo;
 		Articolo articolo;
 		Tabella classifica1 = null, classifica2 = null, classifica3 = null, classifica4 = null;
 		Tabella classifica1 = null, classifica2 = null, classifica3 = null, classifica4 = null;
 		String codArticolo, descrizione, unitaMisura, categoria, codGruppo, codInventario, codIVA, codStatistico;
 		String codArticolo, descrizione, unitaMisura, categoria, codGruppo, codInventario, codIVA, codStatistico;
-		float prezzoBase, pezziConfezione, pesoUnitario;
+		float prezzoBase, pezziConfezione, pesoUnitario, numColliMinimo;
 		boolean changed;
 		boolean changed;
 		
 		
 		codArticolo = getNextField(15);
 		codArticolo = getNextField(15);
@@ -68,11 +68,14 @@ public class ArticoliImporter extends BaseImporter implements IBaseImporter {
 		pezziConfezione = Float.parseFloat(getNextField(13)) / 10000;  // 4 decimali
 		pezziConfezione = Float.parseFloat(getNextField(13)) / 10000;  // 4 decimali
 		setCurrentIndex(292);
 		setCurrentIndex(292);
 		prezzoBase = Float.parseFloat(getNextField(17)) / 1000000;  // 6 decimali
 		prezzoBase = Float.parseFloat(getNextField(17)) / 1000000;  // 6 decimali
-		
+
+		// fixme
+		numColliMinimo = 0;
+
 		// Cerca l'articolo
 		// Cerca l'articolo
 		articolo = articoloDAO.getByCode(codArticolo);
 		articolo = articoloDAO.getByCode(codArticolo);
 		Tabella tblIva = tabellaDAO.getByCode(TipoTabella.IVA, codIVA);
 		Tabella tblIva = tabellaDAO.getByCode(TipoTabella.IVA, codIVA);
-		
+
 		// cerca l'iva
 		// cerca l'iva
 		
 		
 		if (articolo==null) {
 		if (articolo==null) {
@@ -89,7 +92,8 @@ public class ArticoliImporter extends BaseImporter implements IBaseImporter {
 					((tblIva!=null) && (articolo.getIva()==null)) ||
 					((tblIva!=null) && (articolo.getIva()==null)) ||
 					(tblIva!=null&&(tblIva.getIdTabella().compareTo(articolo.getIva().getIdTabella())!=0))||
 					(tblIva!=null&&(tblIva.getIdTabella().compareTo(articolo.getIva().getIdTabella())!=0))||
 					(articolo.getCategoria().compareTo(categoria)!=0) ||
 					(articolo.getCategoria().compareTo(categoria)!=0) ||
-					(articolo.getGruppo().compareTo(codGruppo)!=0) 
+					(articolo.getGruppo().compareTo(codGruppo)!=0)  ||
+					(numColliMinimo != articolo.getNumColliMinimo())
 					;
 					;
 		}
 		}
 
 
@@ -102,6 +106,7 @@ public class ArticoliImporter extends BaseImporter implements IBaseImporter {
 			articolo.setPeso(pesoUnitario);
 			articolo.setPeso(pesoUnitario);
 			articolo.setGruppo(codGruppo);
 			articolo.setGruppo(codGruppo);
 			articolo.setCategoria(categoria);
 			articolo.setCategoria(categoria);
+			articolo.setNumColliMinimo(numColliMinimo);
 			if (tblIva!=null)
 			if (tblIva!=null)
 				articolo.setIva(tblIva);
 				articolo.setIva(tblIva);
 			else
 			else