|
@@ -3,6 +3,8 @@ package com.palmnest.dao.dinner.impl;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
|
|
|
+import com.palmnest.application.Constants;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
import org.openxmlformats.schemas.drawingml.x2006.chart.STScatterStyle;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
@@ -17,6 +19,7 @@ import com.palmnest.dao.dinner.OrderDinnerDao;
|
|
|
import com.palmnest.dao.hibernate.GenericDaoHibernate;
|
|
|
import com.palmnest.model.dinner.OrderDinner;
|
|
|
|
|
|
+@Slf4j
|
|
|
@Repository("orderDinnerDao")
|
|
|
public class OrderDinnerDaoImpl extends GenericDaoHibernate<OrderDinner, Long> implements OrderDinnerDao {
|
|
|
private static Logger LOG = LoggerFactory.getLogger(OrderDinnerDaoImpl.class);
|
|
@@ -196,7 +199,7 @@ public class OrderDinnerDaoImpl extends GenericDaoHibernate<OrderDinner, Long> i
|
|
|
if (StringUtils.isEmpty(orgId)) {
|
|
|
return null;
|
|
|
}
|
|
|
- sql.append(" select vir.name companyName,sum(od.foodCount) sumCount,c.id,c.userName,dl.name dept,c.userMobile mobile ");
|
|
|
+ sql.append(" select vir.name companyName,sum(od.foodCount) sumCount,c.id,c.user_Name userName,dl.name dept,c.user_Mobile mobile ");
|
|
|
if (dateType == 1) {//年度
|
|
|
sql.append(" ,(select ifnull(sum(odi.foodCount),0) from tb_order_dinner tod ");
|
|
|
sql.append(" left join tb_order_dinner_info odi on tod.id=odi.orderId ");
|
|
@@ -232,11 +235,11 @@ public class OrderDinnerDaoImpl extends GenericDaoHibernate<OrderDinner, Long> i
|
|
|
sql.append(" and year(od.createTime)=" + year + " and month(od.createTime)=" + time + " and tod.isTempOrder=1) tempWorkFood ");
|
|
|
}
|
|
|
sql.append(" from tb_order_dinner_info od ");
|
|
|
- sql.append(" inner join tb_user c on od.consId=c.id ");
|
|
|
- sql.append(" left join tb_department dl on dl.id=c.departmentId ");
|
|
|
+ sql.append(" inner join " + Constants.DATABASE + "tb_user c on od.consId=c.id ");
|
|
|
+ sql.append(" left join " + Constants.DATABASE + "tb_department dl on dl.id=c.department_Id ");
|
|
|
sql.append(" left join tb_order_dinner o on o.id=od.orderId ");
|
|
|
- sql.append(" left join tb_virtualarchitecture vir on vir.id=c.virtualArchId ");
|
|
|
- sql.append(" where c.organizationId in (" + orgId + ") and o.isEnabled='1' and od.isEnabled='1' and (o.status='2' or o.status='3') ");
|
|
|
+ sql.append(" left join tb_virtualarchitecture vir on vir.id=c.virt_id ");
|
|
|
+ sql.append(" where c.org_id in (" + orgId + ") and o.isEnabled='1' and od.isEnabled='1' and (o.status='2' or o.status='3') ");
|
|
|
if (dateType == 1) {//年度
|
|
|
sql.append(" and year(od.createTime)=" + year + " ");
|
|
|
} else if (dateType == 2) {//季度
|
|
@@ -463,9 +466,9 @@ public class OrderDinnerDaoImpl extends GenericDaoHibernate<OrderDinner, Long> i
|
|
|
sql.append(" select vir.name companyName,dl.name dept,sum(od.foodCount) sumCount,od.stapleFood,od.stapleFoodStr ");
|
|
|
sql.append(" from tb_order_dinner_info od ");
|
|
|
sql.append(" LEFT join tb_order_dinner o on o.id=od.orderId ");
|
|
|
- sql.append(" left join tb_user c on c.id=od.consId ");
|
|
|
- sql.append(" left join tb_department dl on dl.id=c.departmentId ");
|
|
|
- sql.append(" left join tb_virtualarchitecture vir on vir.id=c.virtualArchId ");
|
|
|
+ sql.append(" left join " + Constants.DATABASE + "tb_user c on c.id=od.consId ");
|
|
|
+ sql.append(" left join " + Constants.DATABASE + "tb_department dl on dl.id=c.department_Id ");
|
|
|
+ sql.append(" left join tb_virtualarchitecture vir on vir.id=c.virt_id ");
|
|
|
// sql.append(" left join tb_consumer c on c.id=od.creator ");
|
|
|
sql.append(" where 1=1 ");
|
|
|
if (StringUtils.isNotEmpty(orgId)) {
|
|
@@ -479,7 +482,7 @@ public class OrderDinnerDaoImpl extends GenericDaoHibernate<OrderDinner, Long> i
|
|
|
} else if (dateType == 3) {//月
|
|
|
sql.append(" and year(od.createTime)=" + year + " and month(od.createTime)=" + time + " ");
|
|
|
}
|
|
|
- sql.append(" group by c.virtualArchId,dl.id,od.stapleFood ");
|
|
|
+ sql.append(" group by c.virt_id,dl.id,od.stapleFood ");
|
|
|
return getJdbcTemplate().queryForList(sql.toString());
|
|
|
}
|
|
|
|
|
@@ -724,13 +727,13 @@ public class OrderDinnerDaoImpl extends GenericDaoHibernate<OrderDinner, Long> i
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public int getCountByUserAndMealFood(String userId, String foodId, String foodOrgId) {
|
|
|
+ public int getCountByUserAndMealFood(String userId, String foodId, String foodOrgId,String date) {
|
|
|
StringBuilder sql = new StringBuilder(" select SUM(od.foodCount) sumCount from tb_order_dinner d ");
|
|
|
sql.append(" left join tb_order_dinner_info od on d.id=od.orderId ");
|
|
|
sql.append(" left join tb_meal m on m.id=od.mealId ");
|
|
|
sql.append(" where d.status=1 and d.consId=" + userId + " ");
|
|
|
sql.append(" and (od.stapleFood='" + foodId + "' or (od.stapleFood='" + foodOrgId + "' and m.spec>1 ) ) ");
|
|
|
- sql.append(" and date_format(d.dinnerTime,'%Y-%m-%d')=date_format(SYSDATE(),'%Y-%m-%d') ");
|
|
|
+ sql.append(" and date_format(d.dinnerTime,'%Y-%m-%d')=date_format('"+date+"','%Y-%m-%d') ");
|
|
|
sql.append(" GROUP BY d.consId ");
|
|
|
List<Map<String, Object>> list = getJdbcTemplate().queryForList(sql.toString());
|
|
|
int count = 0;
|
|
@@ -745,27 +748,13 @@ public class OrderDinnerDaoImpl extends GenericDaoHibernate<OrderDinner, Long> i
|
|
|
|
|
|
@Override
|
|
|
public List<Map<String, Object>> getDeptByOrgAddress(String orgId,
|
|
|
- String addressId, String addressOrgId) {
|
|
|
-// StringBuilder sql = new StringBuilder(" select distinct ifnull(ador.itemname,adr.itemname) address,d.id,IF(IFNULL(d.shortName,'')='',d.name,d.shortName) deptname ");
|
|
|
-// sql.append(" from tb_department d ");
|
|
|
-// sql.append(" left join tb_user u on d.id=u.departmentId ");
|
|
|
-// sql.append(" left join tb_dictionary_item adr on adr.id=u.address ");
|
|
|
-// sql.append(" left join tb_dictionary_org_item ador on ador.id=u.address ");
|
|
|
-// sql.append(" where d.isEnabled=1 and u.organizationId=" + orgId + " and (adr.id= '" + addressId + "' or ador.id= '" + addressOrgId + "' ) ");
|
|
|
-// sql.append(" and d.id in (select us.departmentId from tb_order_dinner o ");
|
|
|
-// sql.append(" left join tb_order_dinner_info od on o.id=od.orderId ");
|
|
|
-// sql.append(" left join tb_user us on us.id=od.consId ");
|
|
|
-// sql.append(" where o.`status`='1' and od.orgId=u.organizationId and od.isEnabled='1' and (us.address=adr.id or us.address=ador.id ) ");
|
|
|
-// sql.append(" and date_format(od.dinnerTime,'%Y-%m-%d')=date_format(SYSDATE(),'%Y-%m-%d') ");
|
|
|
-// sql.append(" GROUP BY us.departmentId) ");
|
|
|
-// sql.append(" ORDER BY d.orderNum ");
|
|
|
+ String addressId, String addressOrgId,String date) {
|
|
|
StringBuilder sql = new StringBuilder(" SELECT DISTINCT ifnull(doi.itemname, di.itemname) AS address,d.id, ");
|
|
|
- //sql.append(" IF (IFNULL(d.shortName, '') = '',d. NAME,d.shortName) AS deptname,2 type ");
|
|
|
sql.append(" d. NAME AS deptname,2 type ");
|
|
|
sql.append(" FROM tb_department d, ");
|
|
|
sql.append(" ( SELECT DISTINCT us.departmentId FROM tb_order_dinner o ");
|
|
|
sql.append(" LEFT JOIN tb_order_dinner_info od ON o.id = od.orderId AND od.isEnabled = '1' ");
|
|
|
- sql.append(" AND date_format(od.dinnerTime, '%Y-%m-%d') = date_format(SYSDATE(), '%Y-%m-%d') ");
|
|
|
+ sql.append(" AND date_format(od.dinnerTime, '%Y-%m-%d') = date_format('"+date+"', '%Y-%m-%d') ");
|
|
|
sql.append(" LEFT JOIN tb_user us ON us.id = od.consId ");
|
|
|
sql.append(" WHERE o.`status` = '1' AND od.orgId = "+orgId+" ");
|
|
|
sql.append(" AND ( us.address = '"+addressId+"' OR us.address = '"+addressOrgId+"' ) ");
|
|
@@ -775,19 +764,20 @@ public class OrderDinnerDaoImpl extends GenericDaoHibernate<OrderDinner, Long> i
|
|
|
sql.append(" WHERE b.departmentId = d.id AND u.departmentId = d.id and u.organizationId="+orgId+" ");
|
|
|
sql.append(" AND ( u.address = '"+addressId+"' OR u.address = '"+addressOrgId+"') ");
|
|
|
sql.append(" ORDER BY d.orderNum ");
|
|
|
+ log.info("getDeptByOrgAddress-sql:{}",sql);
|
|
|
List<Map<String, Object>> list = getJdbcTemplate().queryForList(sql.toString());
|
|
|
return list;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public int getCountByDeptAndMeal(String deptId, String itemId, String itemOrgId) {
|
|
|
+ public int getCountByDeptAndMeal(String deptId, String itemId, String itemOrgId,String date) {
|
|
|
StringBuilder sql = new StringBuilder(" select SUM(od.foodCount) sumCount from tb_order_dinner d ");
|
|
|
sql.append(" left join tb_order_dinner_info od on d.id=od.orderId ");
|
|
|
sql.append(" left join tb_user u on u.id=d.consId ");
|
|
|
sql.append(" left join tb_department dept on dept.id=u.departmentId ");
|
|
|
sql.append(" left join tb_meal m on m.id=od.mealId ");
|
|
|
sql.append(" where d.status=1 and u.departmentId=" + deptId + " and (m.mealCodeId='" + itemId + "' or m.mealCodeId='" + itemOrgId + "' ) ");
|
|
|
- sql.append(" and date_format(d.dinnerTime,'%Y-%m-%d')=date_format(SYSDATE(),'%Y-%m-%d') ");
|
|
|
+ sql.append(" and date_format(d.dinnerTime,'%Y-%m-%d')=date_format('"+date+"','%Y-%m-%d') ");
|
|
|
sql.append(" and u.id not in (select us.id from tb_user us where us.organizationId=u.organizationId and us.isLeader=1) ");
|
|
|
sql.append(" GROUP BY u.departmentId,m.mealCodeId ");
|
|
|
List<Map<String, Object>> list = getJdbcTemplate().queryForList(sql.toString());
|
|
@@ -802,7 +792,7 @@ public class OrderDinnerDaoImpl extends GenericDaoHibernate<OrderDinner, Long> i
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public int getCountByDeptAndMealFood(String addressId, String addressOrgId, String deptId, String foodId, String foodOrgId) {
|
|
|
+ public int getCountByDeptAndMealFood(String addressId, String addressOrgId, String deptId, String foodId, String foodOrgId,String date) {
|
|
|
StringBuilder sql = new StringBuilder(" select SUM(od.foodCount) sumCount from tb_order_dinner d ");
|
|
|
sql.append(" left join tb_order_dinner_info od on d.id=od.orderId ");
|
|
|
sql.append(" left join tb_user u on u.id=d.consId ");
|
|
@@ -813,7 +803,7 @@ public class OrderDinnerDaoImpl extends GenericDaoHibernate<OrderDinner, Long> i
|
|
|
sql.append(" where d.status=1 and u.departmentId=" + deptId + " ");
|
|
|
sql.append(" and (dl.id='" + addressId + "' or dol.id='" + addressOrgId + "') ");
|
|
|
sql.append(" and (od.stapleFood='" + foodId + "' or (od.stapleFood='" + foodOrgId + "' and m.spec>1 ) ) ");
|
|
|
- sql.append(" and date_format(d.dinnerTime,'%Y-%m-%d')=date_format(SYSDATE(),'%Y-%m-%d') ");
|
|
|
+ sql.append(" and date_format(d.dinnerTime,'%Y-%m-%d')=date_format('"+date+"','%Y-%m-%d') ");
|
|
|
sql.append(" and u.id not in (select us.id from tb_user us where us.organizationId=u.organizationId and us.isLeader=1) ");
|
|
|
sql.append(" GROUP BY u.departmentId ");
|
|
|
List<Map<String, Object>> list = getJdbcTemplate().queryForList(sql.toString());
|
|
@@ -829,7 +819,7 @@ public class OrderDinnerDaoImpl extends GenericDaoHibernate<OrderDinner, Long> i
|
|
|
|
|
|
@Override
|
|
|
public List<Map<String, Object>> getCountByUserOrDept(String orgId,
|
|
|
- String userId, String addressId, String addressOrgId, String deptId) {
|
|
|
+ String userId, String addressId, String addressOrgId, String deptId,String date) {
|
|
|
StringBuilder sql = new StringBuilder();
|
|
|
sql.append(" select m.mealCodeId,ifnull(di.itemname,doi.itemname) mealName,sum(od.foodCount) sumCount from tb_order_dinner_info od ");
|
|
|
sql.append(" left join tb_order_dinner o on o.id=od.orderId ");
|
|
@@ -840,7 +830,7 @@ public class OrderDinnerDaoImpl extends GenericDaoHibernate<OrderDinner, Long> i
|
|
|
sql.append(" left join tb_dictionary_item dl on dl.id=u.address ");
|
|
|
sql.append(" left join tb_dictionary_org_item dol on dol.id=u.address ");
|
|
|
sql.append(" left join tb_department d on d.id=u.departmentId ");
|
|
|
- sql.append(" where o.isEnabled=1 and date_format(o.dinnerTime,'%Y-%m-%d')=date_format(SYSDATE(),'%Y-%m-%d') ");
|
|
|
+ sql.append(" where o.isEnabled=1 and date_format(o.dinnerTime,'%Y-%m-%d')=date_format('"+date+"','%Y-%m-%d') ");
|
|
|
sql.append(" and o.status=1 and u.organizationId=" + orgId + " ");
|
|
|
if (StringUtil.isNotEmpty(userId)) {
|
|
|
sql.append(" and u.id=" + userId + " ");
|
|
@@ -855,7 +845,7 @@ public class OrderDinnerDaoImpl extends GenericDaoHibernate<OrderDinner, Long> i
|
|
|
|
|
|
@Override
|
|
|
public List<Map<String, Object>> getCountByAddress(String orgId,
|
|
|
- String addressId, String addressOrgId) {
|
|
|
+ String addressId, String addressOrgId,String date) {
|
|
|
StringBuilder sql = new StringBuilder();
|
|
|
sql.append(" select ifnull(doi.itemname,di.itemname) mealName,sum(od.foodCount) sumCount from tb_order_dinner_info od ");
|
|
|
sql.append(" left join tb_order_dinner o on o.id=od.orderId ");
|
|
@@ -863,7 +853,7 @@ public class OrderDinnerDaoImpl extends GenericDaoHibernate<OrderDinner, Long> i
|
|
|
sql.append(" left join tb_dictionary_item di on di.id=m.mealCodeId ");
|
|
|
sql.append(" left join tb_dictionary_org_item doi on doi.id=m.mealCodeId ");
|
|
|
sql.append(" left join tb_user u on u.id=od.consId ");
|
|
|
- sql.append(" where o.isEnabled=1 and date_format(o.dinnerTime,'%Y-%m-%d')=date_format(SYSDATE(),'%Y-%m-%d') ");
|
|
|
+ sql.append(" where o.isEnabled=1 and date_format(o.dinnerTime,'%Y-%m-%d')=date_format('"+date+"','%Y-%m-%d') ");
|
|
|
sql.append(" and o.status=1 and o.orgId=" + orgId + " and (u.address='" + addressId + "' or u.address='" + addressOrgId + "' ) ");
|
|
|
sql.append(" group by ifnull(doi.itemname,di.itemname) ");
|
|
|
return getJdbcTemplate().queryForList(sql.toString());
|