Quellcode durchsuchen

修改飞亚达订餐
1、PC端设置项目的订餐提醒开关;
2、微信端设置用户的订餐提醒开关;
3、15:30自动推送给项目开启了提醒且用户也开启了提醒的用户;

longmeizhen@avic-s.com vor 2 Jahren
Ursprung
Commit
5b74193984

+ 36 - 22
src/main/java/com/palmnest/application/core/util/DateHelper.java

@@ -109,6 +109,20 @@ public class DateHelper {
 		return formatDate(date.getTime(), format);
 	}
 
+	public static String getNextDay(String day,String format) {
+		Date temp = DateHelper.parseToDate(day,format);
+		Calendar date = Calendar.getInstance();
+		date.setTime(temp);
+		date.add(Calendar.DATE, 1);// 把日期设置为当月第一天
+		return formatDate(date.getTime(), format);
+	}
+
+	public static void main(String[] args) {
+		System.out.println(DateHelper.getNextDay("2022-06-06",DateHelper.CURRENT_DATE));
+	}
+
+
+
 	/**
 	 * 下月第一天
 	 *
@@ -496,29 +510,29 @@ public class DateHelper {
 		return Minutes.minutesBetween(new DateTime(startDate),new DateTime(endDate)).getMinutes();
 	}
 
-	public static void main(String[] args) {
-//		Date startTime = DateHelper.parseToDate("2020-08-2818:20","yyyy-MM-ddHH:mm");
-////		int hours = DateHelper.getMinutesBetween(startTime, new Date());
-////		System.out.println("分钟:"+hours+"--"+hours/60);
+//	public static void main(String[] args) {
+////		Date startTime = DateHelper.parseToDate("2020-08-2818:20","yyyy-MM-ddHH:mm");
+//////		int hours = DateHelper.getMinutesBetween(startTime, new Date());
+//////		System.out.println("分钟:"+hours+"--"+hours/60);
+//////
+//////		System.out.println(new BigDecimal(hours).divide(new BigDecimal(60),1, BigDecimal.ROUND_HALF_UP).doubleValue());
+////System.out.println(DateHelper.getDateByOffsetMinute(startTime,30));
+////		setInfo("22:00","02:00","15","2020-12-04");
+////		List<String> list=getLastDate(7);
+////		System.out.println(JsonUtils.toJson(list));
+//		String times="2040682147338";
 ////
-////		System.out.println(new BigDecimal(hours).divide(new BigDecimal(60),1, BigDecimal.ROUND_HALF_UP).doubleValue());
-//System.out.println(DateHelper.getDateByOffsetMinute(startTime,30));
-//		setInfo("22:00","02:00","15","2020-12-04");
-//		List<String> list=getLastDate(7);
-//		System.out.println(JsonUtils.toJson(list));
-		String times="2040682147338";
-//		
-//		SimpleDateFormat format = new SimpleDateFormat("yyyy年MM月dd日-hh时mm分ss秒");
-//	    Date date =DateHelper.parseToDate(time);
-//	    System.out.println(format.format(date));
-		
-		
-		    long time =Long.parseLong(times);
-		    SimpleDateFormat format = new SimpleDateFormat("yyyy年MM月dd日-hh时mm分ss秒");
-		    Date date = new Date(time);
-		    System.out.println(time);
-		    System.out.println(format.format(date));
-	}
+////		SimpleDateFormat format = new SimpleDateFormat("yyyy年MM月dd日-hh时mm分ss秒");
+////	    Date date =DateHelper.parseToDate(time);
+////	    System.out.println(format.format(date));
+//
+//
+//		    long time =Long.parseLong(times);
+//		    SimpleDateFormat format = new SimpleDateFormat("yyyy年MM月dd日-hh时mm分ss秒");
+//		    Date date = new Date(time);
+//		    System.out.println(time);
+//		    System.out.println(format.format(date));
+//	}
 	
 	
 	public static List<String> getLastDate(int intervals ) {  

+ 40 - 0
src/main/java/com/palmnest/application/dto/DinnerPushSetVo.java

@@ -0,0 +1,40 @@
+package com.palmnest.application.dto;
+
+public class DinnerPushSetVo {
+    private Integer id;
+    private Integer orgId;
+    private Integer userId;
+    private String status;
+
+    public Integer getId() {
+        return id;
+    }
+
+    public void setId(Integer id) {
+        this.id = id;
+    }
+
+    public Integer getOrgId() {
+        return orgId;
+    }
+
+    public void setOrgId(Integer orgId) {
+        this.orgId = orgId;
+    }
+
+    public Integer getUserId() {
+        return userId;
+    }
+
+    public void setUserId(Integer userId) {
+        this.userId = userId;
+    }
+
+    public String getStatus() {
+        return status;
+    }
+
+    public void setStatus(String status) {
+        this.status = status;
+    }
+}

+ 10 - 0
src/main/java/com/palmnest/application/dto/output/VirAccountDto.java

@@ -54,6 +54,16 @@ public class VirAccountDto implements Serializable{
 	private Integer checkRole;
 	private Integer passRecordStatus=0;
 
+	private String pushState;
+
+	public String getPushState() {
+		return pushState;
+	}
+
+	public void setPushState(String pushState) {
+		this.pushState = pushState;
+	}
+
 	public Long getPermId() {
 		return permId;
 	}

+ 17 - 0
src/main/java/com/palmnest/dao/dinner/OrderDinnerSetDao.java

@@ -0,0 +1,17 @@
+package com.palmnest.dao.dinner;
+
+import com.palmnest.dao.GenericDao;
+import com.palmnest.model.dinner.OrderDinnerSet;
+
+import java.util.List;
+import java.util.Map;
+
+public interface OrderDinnerSetDao extends GenericDao<OrderDinnerSet, Integer> {
+    OrderDinnerSet findByOrgId(Integer orgId);
+
+    OrderDinnerSet findByUserId(Integer userId);
+
+    String getOrgListByOrgIds(String orgIds);
+
+    List<Map<String,Object>> findUserByOrgIds(String orgIds,String openId);
+}

+ 63 - 0
src/main/java/com/palmnest/dao/dinner/impl/OrderDinnerSetDaoImpl.java

@@ -0,0 +1,63 @@
+package com.palmnest.dao.dinner.impl;
+
+import cn.jiguang.common.utils.StringUtils;
+import com.palmnest.dao.dinner.OrderDinnerSetDao;
+import com.palmnest.dao.hibernate.GenericDaoHibernate;
+import com.palmnest.model.dinner.OrderDinner;
+import com.palmnest.model.dinner.OrderDinnerSet;
+import com.palmnest.model.dinner.RechargeSet;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.stereotype.Repository;
+import org.springframework.util.CollectionUtils;
+
+import java.util.List;
+import java.util.Map;
+
+@Slf4j
+@Repository("orderDinnerSetDao")
+public class OrderDinnerSetDaoImpl extends GenericDaoHibernate<OrderDinnerSet, Integer> implements OrderDinnerSetDao {
+
+    public OrderDinnerSetDaoImpl() {
+        super(OrderDinnerSet.class);
+    }
+
+    @Override
+    public OrderDinnerSet findByOrgId(Integer orgId) {
+        String sql = "from OrderDinnerSet where orgId=? ";
+        List<OrderDinnerSet> list = getSession().createQuery(sql).setInteger(0, orgId).list();
+        if (CollectionUtils.isEmpty(list)) {
+            return null;
+        }
+        return list.get(0);
+    }
+
+    @Override
+    public OrderDinnerSet findByUserId(Integer userId) {
+        String sql = "from OrderDinnerSet where userId=? ";
+        List<OrderDinnerSet> list = getSession().createQuery(sql).setInteger(0, userId).list();
+        if (CollectionUtils.isEmpty(list)) {
+            return null;
+        }
+        return list.get(0);
+    }
+
+    @Override
+    public String getOrgListByOrgIds(String orgIds) {
+        return null;
+    }
+
+    @Override
+    public List<Map<String, Object>> findUserByOrgIds(String orgIds,String openId) {
+        StringBuilder sql = new StringBuilder("");
+        sql.append(" SELECT t.orgId, t.id userId FROM (   ");
+        sql.append(" SELECT u.organizationId orgId, u.id, ifnull( s.`status`, 1 ) state ");
+        sql.append("  FROM tb_user u LEFT JOIN tb_order_dinner_set s ON u.id = s.userId ");
+        sql.append(" WHERE u.organizationId IN ( "+orgIds+" ) AND u.openId <> '' AND u.isEnabled = '1'  ");
+        if(StringUtils.isNotEmpty(openId)){
+            sql.append(" AND u.openId in ("+openId+")  ");
+        }
+        sql.append("   ) t WHERE t.state = 1 ");
+        sql.append("  ORDER BY t.orgId, t.id ");
+        return getJdbcTemplate().queryForList(sql.toString());
+    }
+}

+ 48 - 0
src/main/java/com/palmnest/model/dinner/OrderDinnerSet.java

@@ -0,0 +1,48 @@
+package com.palmnest.model.dinner;
+
+import javax.persistence.*;
+import java.io.Serializable;
+
+@Entity
+@Table(name = "tb_order_dinner_set")
+public class OrderDinnerSet implements Serializable {
+    @Id
+    @GeneratedValue(strategy = GenerationType.AUTO)
+    @Column(name = "id", unique = true, nullable = false)
+    private Integer id;
+    private Integer orgId;
+    private Integer userId;
+    private String status;
+
+    public Integer getId() {
+        return id;
+    }
+
+    public void setId(Integer id) {
+        this.id = id;
+    }
+
+    public Integer getOrgId() {
+        return orgId;
+    }
+
+    public void setOrgId(Integer orgId) {
+        this.orgId = orgId;
+    }
+
+    public Integer getUserId() {
+        return userId;
+    }
+
+    public void setUserId(Integer userId) {
+        this.userId = userId;
+    }
+
+    public String getStatus() {
+        return status;
+    }
+
+    public void setStatus(String status) {
+        this.status = status;
+    }
+}

+ 17 - 0
src/main/java/com/palmnest/service/dinner/manager/OrderDinnerSetManager.java

@@ -0,0 +1,17 @@
+package com.palmnest.service.dinner.manager;
+
+import com.palmnest.model.dinner.OrderDinnerSet;
+import com.palmnest.service.GenericManager;
+import scala.Int;
+
+import java.util.Map;
+
+public interface OrderDinnerSetManager extends GenericManager<OrderDinnerSet, Integer> {
+    OrderDinnerSet findByOrgId(Integer orgId);
+
+    OrderDinnerSet findByUserId(Integer userId);
+
+    String getOrgListByOrgIds(String orgIds);
+
+    Map<Integer,String> findUserByOrgIds(String orgIds,String openId);
+}

+ 64 - 0
src/main/java/com/palmnest/service/dinner/manager/impl/OrderDinnerSetManagerImpl.java

@@ -0,0 +1,64 @@
+package com.palmnest.service.dinner.manager.impl;
+
+import com.palmnest.dao.dinner.OrderDinnerDao;
+import com.palmnest.dao.dinner.OrderDinnerSetDao;
+import com.palmnest.model.dinner.OrderDinnerSet;
+import com.palmnest.service.dinner.manager.OrderDinnerSetManager;
+import com.palmnest.service.impl.GenericManagerImpl;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.util.CollectionUtils;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+@Slf4j
+@Service("orderDinnerSetManager")
+public class OrderDinnerSetManagerImpl extends GenericManagerImpl<OrderDinnerSet, Integer> implements OrderDinnerSetManager {
+    private OrderDinnerSetDao orderDinnerSetDao;
+
+    @Autowired
+    public void setOrderDinnerSetDao(OrderDinnerSetDao orderDinnerSetDao) {
+        this.orderDinnerSetDao = orderDinnerSetDao;
+        this.dao = orderDinnerSetDao;
+    }
+
+    @Override
+    public OrderDinnerSet findByOrgId(Integer orgId) {
+        return orderDinnerSetDao.findByOrgId(orgId);
+    }
+
+    @Override
+    public OrderDinnerSet findByUserId(Integer userId) {
+        return orderDinnerSetDao.findByUserId(userId);
+    }
+
+    @Override
+    public String getOrgListByOrgIds(String orgIds) {
+        return null;
+    }
+
+    @Override
+    public Map<Integer, String> findUserByOrgIds(String orgIds,String openId) {
+        List<Map<String, Object>> list = orderDinnerSetDao.findUserByOrgIds(orgIds,openId);
+        if(CollectionUtils.isEmpty(list)){
+            return null;
+        }
+        Map<Integer, String> map = new HashMap<>();
+        for(int i = 0 ; i < list.size() ; i++){
+            Map<String, Object> resMap = list.get(i);
+            Integer orgId = Integer.parseInt(resMap.get("orgId").toString());
+            Integer userId = Integer.parseInt(resMap.get("userId").toString());
+            if(map.containsKey(orgId)){
+                String userIds = map.get(orgId);
+                userIds = userIds +"," + userId;
+                map.put(orgId,userIds);
+            }else{
+                map.put(orgId, userId.toString());
+            }
+        }
+        return map;
+    }
+}

+ 12 - 0
src/main/java/com/palmnest/service/dinner/service/PlaceAnOrderService.java

@@ -1,6 +1,7 @@
 package com.palmnest.service.dinner.service;
 
 import com.palmnest.application.bean.AppResultDto;
+import com.palmnest.application.dto.DinnerPushSetVo;
 import com.palmnest.application.dto.RechargeSetDto;
 import com.palmnest.application.dto.WebPageResultDto;
 
@@ -100,6 +101,12 @@ public interface PlaceAnOrderService {
 	 */
 	AppResultDto getRechargeSetRecode(String orgId);
 
+	AppResultDto getPushSet(Integer orgId);
+
+	AppResultDto getPushSetByUserId(Integer userId);
+
+
+
 	/**
 	 * 获取项目下自动充值积分设置
 	 *
@@ -117,6 +124,8 @@ public interface PlaceAnOrderService {
 	 */
 	AppResultDto saveAndRechargeSet(String userId, RechargeSetDto reSetDto);
 
+	AppResultDto saveAndPushSet(DinnerPushSetVo reSetDto);
+
 	/**
 	 * 根据用户id修改这些用户的积分
 	 *
@@ -249,4 +258,7 @@ public interface PlaceAnOrderService {
 	 * @return
 	 */
 	AppResultDto setOrgByMessage(String orgId, Integer isSetMessage,Integer isSetWechatMessage);
+
+
+	void sendTempMsg(String openId, String orgId,String date);
 }

+ 147 - 32
src/main/java/com/palmnest/service/dinner/service/impl/PlaceAnOrderServiceImpl.java

@@ -12,6 +12,10 @@ import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
+import cn.superdesk.libs.common.json.JsonUtils;
+import com.palmnest.application.dto.*;
+import com.palmnest.model.dinner.*;
+import com.palmnest.service.dinner.manager.*;
 import net.sf.json.JsonConfig;
 import net.sf.json.util.JSONUtils;
 
@@ -21,6 +25,7 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
+import org.springframework.util.CollectionUtils;
 import scala.collection.concurrent.TNode;
 import sun.security.krb5.internal.crypto.crc32;
 import cn.jiguang.common.utils.StringUtils;
@@ -45,14 +50,6 @@ import com.palmnest.application.core.util.PageUtils;
 import com.palmnest.application.core.util.PropertiesKit;
 import com.palmnest.application.core.util.StringUtil;
 import com.palmnest.application.core.util.WeekDate;
-import com.palmnest.application.dto.Articles;
-import com.palmnest.application.dto.ConsumerDto;
-import com.palmnest.application.dto.MeetintDto;
-import com.palmnest.application.dto.RechargeRecordDto;
-import com.palmnest.application.dto.RechargeSetDto;
-import com.palmnest.application.dto.RechargeSetRecordDto;
-import com.palmnest.application.dto.StapleFoodDto;
-import com.palmnest.application.dto.WebPageResultDto;
 import com.palmnest.application.dto.output.ElementDto;
 import com.palmnest.application.dto.output.IntegralRecodeDto;
 import com.palmnest.application.dto.output.MealAndUserDto;
@@ -61,11 +58,6 @@ import com.palmnest.application.dto.output.VisitorStatisticsDto;
 import com.palmnest.dao.notice.MobileConfigDao;
 import com.palmnest.model.DateTypeInfo;
 import com.palmnest.model.Element;
-import com.palmnest.model.dinner.IntegralRecodeInfo;
-import com.palmnest.model.dinner.Meal;
-import com.palmnest.model.dinner.MealCar;
-import com.palmnest.model.dinner.RechargeRecord;
-import com.palmnest.model.dinner.RechargeSet;
 import com.palmnest.model.estateserve.AppUser;
 import com.palmnest.model.estateserve.WxUser;
 import com.palmnest.model.notice.MobileConfigModel;
@@ -74,13 +66,6 @@ import com.palmnest.service.AppUserService;
 import com.palmnest.service.ElementGroupManager;
 import com.palmnest.service.OrganizationManager;
 import com.palmnest.service.UserManager;
-import com.palmnest.service.dinner.manager.IntegralRecodeInfoManager;
-import com.palmnest.service.dinner.manager.MealCarManager;
-import com.palmnest.service.dinner.manager.MealManager;
-import com.palmnest.service.dinner.manager.OrderDinnerInfoManager;
-import com.palmnest.service.dinner.manager.OrderDinnerManager;
-import com.palmnest.service.dinner.manager.RechargeRecordManager;
-import com.palmnest.service.dinner.manager.RechargeSetManager;
 import com.palmnest.service.dinner.service.OrderDinnerService;
 import com.palmnest.service.dinner.service.PlaceAnOrderService;
 import com.palmnest.service.estateserve.AppUserManager;
@@ -144,18 +129,18 @@ public class PlaceAnOrderServiceImpl implements PlaceAnOrderService{
 	private OrderDinnerService orderDinnerService;
 	@Autowired
 	private DateTypeInfoManager dateTypeInfoManager;
+
+	@Autowired
+	private OrderDinnerSetManager orderDinnerSetManager;
 	
     private SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd");
     
 	public static String host = PropertiesKit.readPropertiesValue("hostUrl", "wechat.properties");
 	public static String wxDinnerUrl = PropertiesKit.readPropertiesValue("wxDinnerUrl", "wechat.properties");
 	public static String clientNo = PropertiesKit.readPropertiesValue("clientNo", "wechat.properties");
+	public static final String wxMessageUrl  = PropertiesKit.readPropertiesValue("wxMessageUrl", "wechat.properties");
 	/**
 	 * 获取能够订餐的用户
-	 * @param orgId 项目
-	 * @param time 订餐日期
-	 * @param openId操作人
-	 * @param developIds
 	 * @return
 	 */
 	@Override
@@ -543,10 +528,6 @@ public class PlaceAnOrderServiceImpl implements PlaceAnOrderService{
 	 /**
      * 根据参数获取该餐品下购物车中的详情(仅限组合)
      * @param parements
-     * @param orgId
-	 * @param openId
-	 * @param mealId
-	 * @param time
      * @return
      */
 	@Override
@@ -629,7 +610,6 @@ public class PlaceAnOrderServiceImpl implements PlaceAnOrderService{
 	}
 	/**
 	 * 获取会议餐的总份数
-	 * @param list
 	 * @return
 	 */
 	@Override
@@ -971,7 +951,7 @@ public class PlaceAnOrderServiceImpl implements PlaceAnOrderService{
 		}
 	}
 	@Transactional
-	private void saveAppUserByRecharge(String orgId,int sumCount){
+	public void saveAppUserByRecharge(String orgId,int sumCount){
 		//获取该项目下所有有效的人员
 		List<AppUser> list=appUserManager.getAppUserByOrgId(Integer.parseInt(orgId));
 		if(list!=null&&list.size()>0){
@@ -1010,7 +990,31 @@ public class PlaceAnOrderServiceImpl implements PlaceAnOrderService{
 		}
 		return AppResultUtil.createSuccesDto();
 	}
-	
+
+	@Override
+	public AppResultDto getPushSet(Integer orgId) {
+		OrderDinnerSet set = orderDinnerSetManager.findByOrgId(orgId);
+		if(null == set){
+			set = new OrderDinnerSet();
+			set.setStatus("1");
+			set.setOrgId(orgId);
+			return AppResultUtil.createSuccesDto(set);
+		}
+		return AppResultUtil.createSuccesDto(set);
+	}
+
+	@Override
+	public AppResultDto getPushSetByUserId(Integer userId) {
+		OrderDinnerSet set = orderDinnerSetManager.findByUserId(userId);
+		if(null == set){
+			set = new OrderDinnerSet();
+			set.setStatus("1");
+			set.setUserId(userId);
+			return AppResultUtil.createSuccesDto(set);
+		}
+		return AppResultUtil.createSuccesDto(set);
+	}
+
 	@Override
 	public RechargeSetDto getRechargeSetDto(String orgId) {
 		//获取该项目下所配置的积分设置
@@ -1049,6 +1053,44 @@ public class PlaceAnOrderServiceImpl implements PlaceAnOrderService{
 		    return AppResultUtil.createErrorDto("100", "保存失败");
 		}
 	}
+
+	@Override
+	public AppResultDto saveAndPushSet(DinnerPushSetVo reSetDto) {
+		if(StringUtils.isEmpty(reSetDto.getStatus())){
+			reSetDto.setStatus("1");
+		}
+		try {
+			if(null != reSetDto.getOrgId()){
+				OrderDinnerSet set = orderDinnerSetManager.findByOrgId(reSetDto.getOrgId());
+				if(null == set){
+					set = new OrderDinnerSet();
+					set.setOrgId(reSetDto.getOrgId());
+					set.setStatus(reSetDto.getStatus());
+					orderDinnerSetManager.save(set);
+				}else{
+					set.setStatus(reSetDto.getStatus());
+					orderDinnerSetManager.updateModel(set);
+				}
+			}else if(null != reSetDto.getUserId()){
+				OrderDinnerSet set = orderDinnerSetManager.findByUserId(reSetDto.getUserId());
+				if(null == set){
+					set = new OrderDinnerSet();
+					set.setUserId(reSetDto.getUserId());
+					set.setStatus(reSetDto.getStatus());
+					orderDinnerSetManager.save(set);
+				}else{
+					set.setStatus(reSetDto.getStatus());
+					orderDinnerSetManager.updateModel(set);
+				}
+			}
+			return AppResultUtil.createSuccesDto();
+		} catch (Exception e) {
+			LOG.error(e.getMessage());
+			e.printStackTrace();
+			return AppResultUtil.createErrorDto("100", "保存失败");
+		}
+	}
+
 	@Override
 	public void updateOrderDinner() {
 		//获取使用订餐的项目
@@ -1198,7 +1240,6 @@ public class PlaceAnOrderServiceImpl implements PlaceAnOrderService{
 	}
 	/**
 	 * 封装查询到的订餐总数、普通订餐数、临时工作餐数、会议餐数
-	 * @param orgId
 	 * @param dateType
 	 * @param date
 	 * @param endDate
@@ -1581,6 +1622,80 @@ public class PlaceAnOrderServiceImpl implements PlaceAnOrderService{
 		}
 		
 	}
+
+	@Override
+	public void sendTempMsg(String openId, String orgId,String date) {
+		String nextDate = "";
+		if(StringUtils.isEmpty(date)){
+			date =  DateHelper.formatDate(new Date(),DateHelper.CURRENT_DATE);
+		}
+
+		String tomorrow = DateHelper.getNextDay(date,DateHelper.CURRENT_DATE);
+		LOG.info("sendTempMsg/tomorrow:"+tomorrow);
+
+		String orgIds="";
+
+		if(StringUtils.isNotEmpty(orgId)){
+			orgIds = orgId;
+		}else{
+			String newOrgs=serviceProjectAllocationManager.getServiceProjectByServiceCode("DCFW");
+			LOG.info("sendTempMsg/orgIds:"+newOrgs);
+			String[] orgArr=newOrgs.split(",");
+			//获取设置了微信提醒的项目
+
+			if(null == orgArr || orgArr.length == 0){
+				return;
+			}
+			for(int i=0;i<orgArr.length;i++){
+				Integer org = Integer.parseInt(orgArr[i]);
+				OrderDinnerSet orderDinnerSet = orderDinnerSetManager.findByOrgId(org);
+				if(null != orderDinnerSet && "0".equals(orderDinnerSet.getStatus())){
+					continue;
+				}
+				//获取下一个上了餐的日期:需要判断日期是否为明天,如果是明天,今天才做推送,如果不是明天,不做推送
+				LOG.info("begin sendTempMsg-:" + org+";date:"+date);
+				nextDate = mealManager.getNextMealDate(org,date,1);
+				LOG.info("begin sendTempMsg-:" + org+";date:"+date+";nextDate:"+nextDate);
+				if(StringUtils.isEmpty(nextDate)){
+					nextDate = date;
+					LOG.info("begin sendTempMsg-:" + org+";date:"+date+";nextDate2:"+nextDate);
+				}
+				if(!tomorrow.equals(nextDate)){
+					continue;
+				}
+
+				if(null == orderDinnerSet || StringUtils.isEmpty(orderDinnerSet.getStatus())){
+					orgIds = orgIds+org+",";
+				}else if("1".equals(orderDinnerSet.getStatus())){
+					orgIds = orgIds+org+",";
+				}
+			}
+			LOG.info("sendTempMsg-newOrgs:"+orgIds);
+			if(StringUtils.isNotEmpty(orgIds)&&",".equals(orgIds.substring(orgIds.length()-1,orgIds.length()))){
+				orgIds=orgIds.substring(0,orgIds.length()-1);
+			}
+		}
+		LOG.info("sendTempMsg-newOrgs:上线了订餐服务且开启了订餐提醒的项目:"+orgIds);
+
+		//根据项目列表获取所有开启了订餐提醒的用户
+		String content = "您好,请及时预定明天的餐品,马上要截止订餐了!";
+		String url="";
+		//获取项目下允许订餐推送的用户
+		Map<Integer,String> resMap = orderDinnerSetManager.findUserByOrgIds(orgIds,openId);
+		for (Integer org : resMap.keySet()){
+			Map<String,Object> map=new HashMap<>();
+			map.put("orgId",org);
+			map.put("userIds",resMap.get(org).split(","));
+			map.put("content",content);
+			map.put("url",url);
+			String params=com.alibaba.fastjson.JSONObject.toJSONString(map);
+			LOG.info("sendTempMsg params===>"+  params);
+			LOG.info("sendTempMsg wxMessageUrl===>"+  wxMessageUrl);
+			String result=HttpKit.HttpClientPost(params,wxMessageUrl);
+			LOG.info("sendTempMsg result===>"+  JsonUtils.toJson(result));
+		}
+	}
+
 	@Override
 	public void sendMessageByOrgSet(String orgId,String mobile) {
 		Calendar calendar = Calendar.getInstance();    

+ 3 - 1
src/main/java/com/palmnest/service/estateserve/AppUserManager.java

@@ -444,6 +444,8 @@ public interface AppUserManager extends GenericManager<AppUser, Integer> {
 	List<Map<String, Object>> getAllUserByOrgIds(String orgIds,String userIds,String openIds);
 	
 	AppUser findLoginUserByOpenId(Integer orgId,String openId);
-	
+
+
+	List<Integer> getPushUserList(String orgIds);
 
 }

+ 15 - 0
src/main/java/com/palmnest/service/virtProject/impl/VirtualArchServiceImpl.java

@@ -16,6 +16,7 @@ import com.palmnest.model.OrgElement;
 import com.palmnest.model.RoomInfo;
 import com.palmnest.model.VirtUserInfo;
 import com.palmnest.model.dinner.Department;
+import com.palmnest.model.dinner.OrderDinnerSet;
 import com.palmnest.model.enterprise.VirPermConfig;
 import com.palmnest.model.estateserve.*;
 import com.palmnest.model.property.TbBuild;
@@ -27,6 +28,7 @@ import com.palmnest.service.ElementGroupManager;
 import com.palmnest.service.OrganizationManager;
 import com.palmnest.service.UserManager;
 import com.palmnest.service.dinner.manager.DeptManager;
+import com.palmnest.service.dinner.manager.OrderDinnerSetManager;
 import com.palmnest.service.dinner.service.PlaceAnOrderService;
 import com.palmnest.service.estateserve.*;
 import com.palmnest.service.estateserve.release.GoodsReleaseManager;
@@ -94,6 +96,9 @@ public class VirtualArchServiceImpl implements VirtualArchService {
 	@Autowired
 	private GoodsReleaseManager goodsReleaseManager;
 
+	@Autowired
+	private OrderDinnerSetManager orderDinnerSetManager;
+
 	public static String image_server = PropertiesKit.readPropertiesValue("image_server", "wechat.properties");
 
 	public Map<String, Object> importVirtualInfo(InputStream ins, String buildId) throws Exception {
@@ -846,6 +851,16 @@ public class VirtualArchServiceImpl implements VirtualArchService {
 					dto.setFoodCardNo(meal_card);
 					String foodCardH5 = PropertiesKit.readPropertiesValue("food_card_H5", "wechat.properties"); ////饭卡企业号
 					dto.setFoodCardH5(foodCardH5);
+
+					if(StringUtils.isNotEmpty(dto.getUserId())){
+						OrderDinnerSet set = orderDinnerSetManager.findByUserId(Integer.parseInt(dto.getUserId()));
+						if(null == set){
+							dto.setPushState("1");
+						}else{
+							dto.setPushState(set.getStatus());
+						}
+					}
+
 					return AppResultUtil.createSuccesDto(dto);
 				} else {
 					return AppResultUtil.createErrorDto("100", "楼宇不允许为空");

+ 37 - 0
src/main/java/com/palmnest/webapp/controller/dinner/PlaceAnOrderController.java

@@ -3,6 +3,7 @@ package com.palmnest.webapp.controller.dinner;
 import com.palmnest.application.bean.AppResultDto;
 import com.palmnest.application.core.util.AppResultUtil;
 import com.palmnest.application.core.util.StringUtil;
+import com.palmnest.application.dto.DinnerPushSetVo;
 import com.palmnest.application.dto.OrgDto;
 import com.palmnest.application.dto.RechargeSetDto;
 import com.palmnest.application.dto.WebPageResultDto;
@@ -86,6 +87,42 @@ public class PlaceAnOrderController extends BaseFormController {
 		return placeAnOrderService.saveAndRechargeSet(userId, reSetDto);
 	}
 
+
+	/**
+	 * 获取该项目下的推送设置
+	 *
+	 * @param orgId
+	 * @return
+	 */
+	@RequestMapping(value = "getPushSetByOrgId")
+	@ResponseBody
+	public AppResultDto getPushSetByOrgId(Integer orgId) {
+		if (null == orgId) {
+			return AppResultUtil.createErrorDto("100", "项目不允许为空");
+		}
+		return placeAnOrderService.getPushSet(orgId);
+	}
+
+	/**
+	 * 保存推送设置
+	 *
+	 * @param request
+	 * @param dinnerPushSetVo
+	 * @return
+	 */
+	@RequestMapping(value = "saveAndPushSet")
+	@ResponseBody
+	public AppResultDto saveAndPushSet(HttpServletRequest request, DinnerPushSetVo dinnerPushSetVo) {
+		User   user   = (User) request.getSession().getAttribute("UserCache");
+		String userId = "";
+		if (user != null) {
+			userId = user.getId().toString();
+		} else {
+			return AppResultUtil.createErrorDto("100", "用户没有登录");
+		}
+		return placeAnOrderService.saveAndPushSet(dinnerPushSetVo);
+	}
+
 	/**
 	 * 修改选中用户积分
 	 *

+ 41 - 0
src/main/java/com/palmnest/webapp/controller/dinner/wechat/WechatPlaceAnOrderController.java

@@ -5,6 +5,8 @@ import com.palmnest.application.bean.AppResultDto;
 import com.palmnest.application.core.util.AppResultUtil;
 import com.palmnest.application.core.util.DateUtils;
 import com.palmnest.application.core.util.StringUtil;
+import com.palmnest.application.dto.DinnerPushSetVo;
+import com.palmnest.model.User;
 import com.palmnest.service.AppUserService;
 import com.palmnest.service.dinner.service.OrderDinnerService;
 import com.palmnest.service.dinner.service.PlaceAnOrderService;
@@ -17,6 +19,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RequestParam;
 import org.springframework.web.bind.annotation.ResponseBody;
 
+import javax.servlet.http.HttpServletRequest;
 import java.text.SimpleDateFormat;
 import java.util.Date;
 import java.util.HashMap;
@@ -417,4 +420,42 @@ public class WechatPlaceAnOrderController extends BaseFormController {
 		orderDinnerService.getOrderInfoTask(orgId);
 		return AppResultUtil.createSuccesDto();
 	}
+
+	/**
+	 * 保存推送设置
+	 *
+	 * @param request
+	 * @param dinnerPushSetVo
+	 * @return
+	 */
+	@RequestMapping(value = "saveAndPushSet")
+	@ResponseBody
+	public AppResultDto saveAndPushSet(HttpServletRequest request, DinnerPushSetVo dinnerPushSetVo) {
+		return placeAnOrderService.saveAndPushSet(dinnerPushSetVo);
+	}
+
+	@RequestMapping(value = "getPushSetByOrgId")
+	@ResponseBody
+	public AppResultDto getPushSetByOrgId(Integer orgId) {
+		if (null == orgId) {
+			return AppResultUtil.createErrorDto("100", "项目不允许为空");
+		}
+		return placeAnOrderService.getPushSet(orgId);
+	}
+
+	@RequestMapping(value = "getPushSetByUserId")
+	@ResponseBody
+	public AppResultDto getPushSetByUserId(Integer userId) {
+		if (null == userId) {
+			return AppResultUtil.createErrorDto("100", "用户不允许为空");
+		}
+		return placeAnOrderService.getPushSetByUserId(userId);
+	}
+
+	@RequestMapping(value = "getOrderInfoTask")
+	@ResponseBody
+	public AppResultDto getOrderInfoTask(@RequestParam(value = "openId",required = false) String openId,@RequestParam(value = "orgId",required = false) String orgId,@RequestParam(value = "date",required = false) String date) {
+		placeAnOrderService.sendTempMsg(openId,orgId,date);
+		return AppResultUtil.createSuccesDto();
+	}
 }

+ 21 - 0
src/main/java/com/palmnest/webapp/quartz/OrderDinnerPushTempMsgTimerTask.java

@@ -0,0 +1,21 @@
+package com.palmnest.webapp.quartz;
+
+import com.palmnest.service.dinner.service.PlaceAnOrderService;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+import java.util.Date;
+
+@Slf4j
+@Component("orderDinnerPushTempMsgTimerTask")
+public class OrderDinnerPushTempMsgTimerTask {
+    @Autowired
+    private PlaceAnOrderService placeAnOrderService;
+
+    private void run() {
+        log.info("quartz into orderDinnerPushTempMsgTimerTask start ..." + new Date());
+        placeAnOrderService.sendTempMsg("","","");
+        log.info("quartz into orderDinnerPushTempMsgTimerTask end ...");
+    }
+}

+ 1 - 0
src/main/resources/hibernate.cfg.xml

@@ -192,6 +192,7 @@
         <mapping class="com.palmnest.model.dinner.RechargeSet"/>
         <mapping class="com.palmnest.model.dinner.RechargeRecord"/>
         <mapping class="com.palmnest.model.dinner.Department"/>
+        <mapping class="com.palmnest.model.dinner.OrderDinnerSet"/>
 
         <!-- 令令开门 -->
         <mapping class="com.palmnest.model.lingling.LingLingDevice"/>

+ 16 - 0
src/main/resources/quartz_job2.xml

@@ -332,6 +332,21 @@
         </property>
     </bean>
 
+    <!-- 定时推送模板消息给开启订餐的用户,通知他们提前订明天的餐 -->
+    <bean id="orderDinnerPushTempMsgTimer"
+          class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">
+        <property name="targetObject" ref="orderDinnerPushTempMsgTimerTask"/>
+        <property name="targetMethod" value="run"/>
+    </bean>
+
+    <bean id="orderDinnerPushTempMsgTrigger" class="org.springframework.scheduling.quartz.CronTriggerBean">
+        <property name="jobDetail" ref="orderDinnerPushTempMsgTimer"/>
+        <property name="cronExpression">
+            <value>0 30 15 * * ?</value>
+            <!-- 每天15:30推一次消息 -->
+        </property>
+    </bean>
+
 
     <!--定时每分钟执行获取飞亚达订餐的订餐数据-->
     <bean id="orderDinnerGetOrderInfoTimer"
@@ -371,6 +386,7 @@
                 <ref local="airConditionerOrderTrigger"/>
                 <ref local="orderDinnerDatePushTrigger"/>
                 <ref local="orderDinnerPushMessageTrigger"/>
+                <ref local="orderDinnerPushTempMsgTrigger"/>
                 <ref local="orderDinnerPushTrigger"/>
                 <ref local="dinnerConfirmServiceTrigger"/>
                 <ref local="dinnerTransferAccountsTrigger"/>