Commit 17b556c6 by 史文博

Merge branch 'feature/form_statistics_05' into 'develop'

修复销售汇总报表Sql

See merge request kunlun/xyst_dinas/xyst_dinas_backend!47
parents ae0de2d7 d3aec35c
......@@ -2,6 +2,8 @@ package com.xyst.dinas.statistics.internal.dao;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import javax.persistence.Tuple;
import org.hibernate.HibernateException;
......@@ -157,7 +159,7 @@ public class SalesSummaryDaoImpl implements SalesSummaryDao {
+ " GROUP BY salesSummary1.station_id\r\n"
+ " ) AS decAmount ON decAmount.dealYear1 = salesSummary.deal_Year ");
if (stationList != null && !(stationList.isEmpty()))
hql.append(" WHERE 1=1 AND station.id IN ( :stationList ) ");
hql.append(" WHERE 1=1 AND salesSummary.station_id IN ( :stationList ) ");
hql.append(" GROUP BY salesSummary.deal_Year\r\n" + " UNION ALL\r\n" + " SELECT\r\n"
+ " station.station_Name as station,\r\n" + " '小计' as dinas_Type,\r\n"
+ " SUM(salesSummary.sale_Deal_Amount) as saleDealAmount,\r\n"
......@@ -276,7 +278,7 @@ public class SalesSummaryDaoImpl implements SalesSummaryDao {
+ " ) AS decAmount ON decAmount.station1 = salesSummary.station_id\r\n"
+ " AND decAmount.dealYear1 = salesSummary.deal_Year ");
if (stationList != null && !(stationList.isEmpty()))
hql.append(" WHERE 1=1 AND station.id IN ( :stationList ) ");
hql.append(" WHERE 1=1 AND salesSummary.station_id IN ( :stationList ) ");
hql.append(" GROUP BY salesSummary.station_id\r\n" + " UNION ALL\r\n" + " SELECT\r\n"
+ " station.station_Name as station,\r\n"
+ " dinasType.dinas_Type_Name as dinasType,\r\n"
......@@ -409,7 +411,7 @@ public class SalesSummaryDaoImpl implements SalesSummaryDao {
+ " ) AS decAmount ON decAmount.station1 = salesSummary.station_id AND decAmount.dinasType1 = salesSummary.dinas_Type_id\r\n"
+ " AND decAmount.dealYear1 = salesSummary.deal_Year");
if (stationList != null && !(stationList.isEmpty()))
hql.append(" WHERE 1=1 AND station.id IN ( :stationList ) ");
hql.append(" WHERE 1=1 AND salesSummary.station_id IN ( :stationList ) ");
hql.append(" GROUP BY salesSummary.dinas_Type_id " + " ) AS result ");
hql.append(" WHERE 1=1 ");
if (dealYear != null && !(dealYear.isEmpty()))
......@@ -421,8 +423,14 @@ public class SalesSummaryDaoImpl implements SalesSummaryDao {
Query<Tuple> query = session.createNativeQuery(hql.toString(), Tuple.class);
if (dealYear != null && !(dealYear.isEmpty()))
query.setParameter("dealYear", dealYear);
if (stationList != null && !(stationList.isEmpty()))
query.setParameter("stationList", stationList);
if (stationList != null && !(stationList.isEmpty())) {
String[] strList = stationList.split(",");
List<UUID> uuidList = new ArrayList<UUID>();
for(String str : strList) {
uuidList.add(UUID.fromString(str));
}
query.setParameter("stationList", uuidList);
}
List<Tuple> resultList = query.getResultList();
if (resultList.isEmpty())
return null;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment