Browse Source

修改飞亚达订餐
1、微信端允许订下周及以后的餐
2、导出数据改为提前一天的16:40开始导第二天的数据(遇到周五的情况,可导出下周一的)

longmeizhen@avic-s.com 2 years ago
parent
commit
5127ca1ccb

+ 2 - 2
sql/huanjingpeizhi/formal environment/tomcat_super_service/WEB-INF/classes/quartz_job2.xml

@@ -343,8 +343,8 @@
     <bean id="orderDinnerGetOrderInfoTrigger" class="org.springframework.scheduling.quartz.CronTriggerBean">
         <property name="jobDetail" ref="orderDinnerGetOrderInfoTimer"/>
         <property name="cronExpression">
-            <value>0 40,41,42,43,44,45,46,47,48,49,50 16 * * ?</value>
-            <!-- 从16点40开始执行,每1分钟执行一次,只执行到16点50 -->
+            <value>0 40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59 16 * * ?</value>
+            <!-- 从16点40开始执行,每1分钟执行一次,只执行到16点59 -->
         </property>
     </bean>
 

+ 5 - 7
src/main/java/com/palmnest/dao/dinner/OrderDinnerDao.java

@@ -118,7 +118,6 @@ public interface OrderDinnerDao extends GenericDao<OrderDinner, Long> {
 	 * @param year
 	 * @param time
 	 * @param type
-	 * @param dept
 	 * @return
 	 */
 	int getTempFoodCountByDept(String orgId, int dateType, String year, String time, int type, String deptOrComp, int isDept);
@@ -175,7 +174,6 @@ public interface OrderDinnerDao extends GenericDao<OrderDinner, Long> {
 	/**
 	 * 这些项目下所有有效的订单
 	 *
-	 * @param orgId
 	 * @return
 	 */
 	int updateOrderDinnerByTime(String orgIds, String time);
@@ -218,7 +216,7 @@ public interface OrderDinnerDao extends GenericDao<OrderDinner, Long> {
 	 */
 	int getCountByUserAndMeal(String userId, String itemId, String itemOrgId);
 
-	int getCountByUserAndMealFood(String userId, String foodId, String foodOrgId);
+	int getCountByUserAndMealFood(String userId, String foodId, String foodOrgId,String date);
 
 	/**
 	 * 根据地址获取相应地址下的部门
@@ -237,9 +235,9 @@ public interface OrderDinnerDao extends GenericDao<OrderDinner, Long> {
 	 * @param itemOrgId 现餐品名
 	 * @return
 	 */
-	int getCountByDeptAndMeal(String deptId, String itemId, String itemOrgId);
+	int getCountByDeptAndMeal(String deptId, String itemId, String itemOrgId,String date);
 
-	int getCountByDeptAndMealFood(String addressId, String addressOrgId, String deptId, String foodId, String foodOrgId);
+	int getCountByDeptAndMealFood(String addressId, String addressOrgId, String deptId, String foodId, String foodOrgId,String date);
 
 	/**
 	 * 获取该部门或者用户的订餐情况
@@ -249,9 +247,9 @@ public interface OrderDinnerDao extends GenericDao<OrderDinner, Long> {
 	 * @param deptId
 	 * @return
 	 */
-	List<Map<String, Object>> getCountByUserOrDept(String orgId, String userId, String addressId, String addressOrgId, String deptId);
+	List<Map<String, Object>> getCountByUserOrDept(String orgId, String userId, String addressId, String addressOrgId, String deptId,String date);
 
-	List<Map<String, Object>> getCountByAddress(String orgId, String addressId, String addressOrgId);
+	List<Map<String, Object>> getCountByAddress(String orgId, String addressId, String addressOrgId,String date);
 
 	/**
 	 * 获取订餐统计总数、会议餐、普通餐、临时工作餐

+ 13 - 10
src/main/java/com/palmnest/dao/dinner/impl/OrderDinnerDaoImpl.java

@@ -4,6 +4,7 @@ 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;
@@ -18,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);
@@ -725,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;
@@ -762,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());
@@ -789,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  ");
@@ -800,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());
@@ -816,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  ");
@@ -827,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 + "  ");
@@ -842,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  ");
@@ -850,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());

+ 9 - 9
src/main/java/com/palmnest/service/dinner/manager/impl/OrderDinnerManagerImpl.java

@@ -590,10 +590,10 @@ public class OrderDinnerManagerImpl extends GenericManagerImpl<OrderDinner, Long
 						info.put("address", address);
 						info.put("deptname", deptname);
 						if (1 == type) {//是否为用户
-							info = setInfo(orgId, addressId, addressOrgId, id, "", info);
+							info = setInfo(orgId, addressId, addressOrgId, id, "", info,date);
 							infoList.add(info);
 						} else if (2 == type) {//是否为部门
-							info = setInfo(orgId, addressId, addressOrgId, "", id, info);
+							info = setInfo(orgId, addressId, addressOrgId, "", id, info,date);
 							int count = info.get("heji") == null ? 0 : Integer.parseInt(info.get("heji").toString());
 							if (count > 0) {
 								infoList.add(info);
@@ -610,7 +610,7 @@ public class OrderDinnerManagerImpl extends GenericManagerImpl<OrderDinner, Long
 			Map<String, Object> heji = new HashMap<String, Object>();
 			heji.put("address", "");
 			heji.put("deptname", "合计");
-			List<Map<String, Object>> addList = orderDinnerDao.getCountByAddress(orgId, addressId, addressOrgId);
+			List<Map<String, Object>> addList = orderDinnerDao.getCountByAddress(orgId, addressId, addressOrgId,date);
 			if (addList != null && addList.size() > 0) {
 				int sumAddHeji = 0;
 				for (int i = 0; i < addList.size(); i++) {
@@ -640,8 +640,8 @@ public class OrderDinnerManagerImpl extends GenericManagerImpl<OrderDinner, Long
 	 * @param info
 	 * @return
 	 */
-	private Map<String, Object> setInfo(String orgId, String addressId, String addressOrgId, String userId, String deptId, Map<String, Object> info) {
-		List<Map<String, Object>> mapList = orderDinnerDao.getCountByUserOrDept(orgId, userId, addressId, addressOrgId, deptId);
+	private Map<String, Object> setInfo(String orgId, String addressId, String addressOrgId, String userId, String deptId, Map<String, Object> info,String date) {
+		List<Map<String, Object>> mapList = orderDinnerDao.getCountByUserOrDept(orgId, userId, addressId, addressOrgId, deptId,date);
 		int                       sumHe   = 0;
 		if (mapList != null && mapList.size() > 0) {
 			for (int i = 0; i < mapList.size(); i++) {
@@ -669,11 +669,11 @@ public class OrderDinnerManagerImpl extends GenericManagerImpl<OrderDinner, Long
 		Map<String, Object> bunsMap   = getFoodItem(orgId, "stapleFood", "馒头");
 		Map<String, Object> rollMap   = getFoodItem(orgId, "stapleFood", "花卷");
 		if (StringUtil.isNotEmpty(userId)) {//是否为用户
-			rollCount = orderDinnerDao.getCountByUserAndMealFood(userId, rollMap.get("itemId").toString(), rollMap.get("itemOrgId").toString());
-			bunsCount = orderDinnerDao.getCountByUserAndMealFood(userId, bunsMap.get("itemId").toString(), bunsMap.get("itemOrgId").toString());
+			rollCount = orderDinnerDao.getCountByUserAndMealFood(userId, rollMap.get("itemId").toString(), rollMap.get("itemOrgId").toString(),date);
+			bunsCount = orderDinnerDao.getCountByUserAndMealFood(userId, bunsMap.get("itemId").toString(), bunsMap.get("itemOrgId").toString(),date);
 		} else if (StringUtil.isNotEmpty(deptId)) {//是否为部门
-			rollCount = orderDinnerDao.getCountByDeptAndMealFood(addressId, addressOrgId, deptId, rollMap.get("itemId").toString(), rollMap.get("itemOrgId").toString());
-			bunsCount = orderDinnerDao.getCountByDeptAndMealFood(addressId, addressOrgId, deptId, bunsMap.get("itemId").toString(), bunsMap.get("itemOrgId").toString());
+			rollCount = orderDinnerDao.getCountByDeptAndMealFood(addressId, addressOrgId, deptId, rollMap.get("itemId").toString(), rollMap.get("itemOrgId").toString(),date);
+			bunsCount = orderDinnerDao.getCountByDeptAndMealFood(addressId, addressOrgId, deptId, bunsMap.get("itemId").toString(), bunsMap.get("itemOrgId").toString(),date);
 		}
 		info.put(CodeConstants.BUNS, bunsCount);
 		info.put(CodeConstants.ROLLS, rollCount);