添加推送逻辑

This commit is contained in:
bayi
2018-05-18 17:51:51 +08:00
parent d6db206b83
commit 8c8311e17a
3 changed files with 74 additions and 14 deletions
@@ -17,10 +17,14 @@ import com.fangjia.job.youfang.document.CitySendLog;
import com.fangjia.job.youfang.dto.CityNewPriceDto;
import com.fangjia.job.youfang.dto.CityNewPriceResultDto;
import com.fangjia.job.youfang.po.CityCollect;
import com.fangjia.job.youfang.po.EnterpriseProductUser;
import com.fangjia.job.youfang.remote.FshApiRemoteService;
import com.fangjia.job.youfang.service.CityCollectService;
import com.fangjia.job.youfang.service.CitySendLogService;
import com.fangjia.job.youfang.service.EnterpriseProductUserService;
import com.fangjia.job.youfang.service.PushMessageService;
import com.fangjia.job.youfang.dto.CityStatInfoDto;
import com.fangjia.job.youfang.param.PushMessageParam;
public class CityRankingSendJob implements SimpleJob {
@@ -31,6 +35,12 @@ public class CityRankingSendJob implements SimpleJob {
@Autowired
private CitySendLogService citySendLogService;
@Autowired
private EnterpriseProductUserService enterpriseProductUserService;
@Autowired
private PushMessageService pushMessageService;
@Value("${open.url}")
private String openApiUrl;
@@ -169,16 +179,24 @@ public class CityRankingSendJob implements SimpleJob {
private void baseSend(CityCollect city, Integer rankings, byte sendType) {
String title = null;
if (FangjiaConstant.INCREASE_SEND_TYPE == sendType) {
title = "全国城市涨幅排名第" + rankings + "位";
title = city.getCity()+",全国城市涨幅排名第" + rankings + "位";
} else if (FangjiaConstant.DECLINES_SEND_TYPE == sendType) {
title = "全国城市跌幅排名第" + rankings + "位";
title = city.getCity()+",全国城市跌幅排名第" + rankings + "位";
} else {
title = "全国城市潜力排名第" + rankings + "位";
title = city.getCity()+",全国城市潜力排名第" + rankings + "位";
}
LOG.info("全国城市涨幅(跌幅、潜力)排名推送开始,uid:" + city.getUid() + ",city:" + city.getCity());
// 发送
// TODO
EnterpriseProductUser user = enterpriseProductUserService.getById(city.getUid(), new String[] { "push_client_id" });
LOG.info(title);
PushMessageParam param = new PushMessageParam();
param.setTitle("排行榜提醒");
param.setContent(title);
param.setOperation(1);
param.setOperationPage("");
param.setPushClientId(user.getPushClientId());
pushMessageService.push(param);
// 记录
citySendLogService.save(city.getCity(), city.getUid(), 0L, sendType);
}
@@ -10,28 +10,38 @@ import com.dangdang.ddframe.job.api.ShardingContext;
import com.dangdang.ddframe.job.api.simple.SimpleJob;
import com.fangjia.job.common.base.FangjiaConstant;
import com.fangjia.job.youfang.document.CitySendLog;
import com.fangjia.job.youfang.param.PushMessageParam;
import com.fangjia.job.youfang.po.CityCollect;
import com.fangjia.job.youfang.po.EnterpriseProductUser;
import com.fangjia.job.youfang.po.News;
import com.fangjia.job.youfang.service.CityCollectService;
import com.fangjia.job.youfang.service.CitySendLogService;
import com.fangjia.job.youfang.service.EnterpriseProductUserService;
import com.fangjia.job.youfang.service.NewsService;
import com.fangjia.job.youfang.service.PushMessageService;
public class HousingEstateNewsSendJob implements SimpleJob {
private static final Logger LOG = LoggerFactory.getLogger(TopNewsSendJob.class);
@Autowired
private CityCollectService cityCollectService;
@Autowired
private CitySendLogService citySendLogService;
@Autowired
private NewsService newsService;
@Autowired
private EnterpriseProductUserService enterpriseProductUserService;
@Autowired
private PushMessageService pushMessageService;
@Override
public void execute(ShardingContext context) {
LOG.info("城市小区推送开始,context:"+context);
LOG.info("城市小区推送开始,context:" + context);
// 1.查询
List<CityCollect> cityList = cityCollectService.findAll();
String cityName = "";
@@ -57,7 +67,7 @@ public class HousingEstateNewsSendJob implements SimpleJob {
}
}
}
private void sendNews(CityCollect city, List<News> newsList) {
if (null != newsList && !newsList.isEmpty()) {
for (News n : newsList) {
@@ -67,9 +77,20 @@ public class HousingEstateNewsSendJob implements SimpleJob {
if (null == sendList || sendList.isEmpty()) {
LOG.info("小区推送开始。。。uid:" + city.getUid() + ",newsId:" + n.getId());
// 3.发送
// TODO
EnterpriseProductUser user = enterpriseProductUserService.getById(city.getUid(),
new String[] { "push_client_id" });
String pushMsg = n.getContent();
LOG.info(pushMsg);
PushMessageParam param = new PushMessageParam();
param.setTitle(n.getTitle());
param.setContent(pushMsg);
param.setOperation(1);
param.setOperationPage("");
param.setPushClientId(user.getPushClientId());
pushMessageService.push(param);
// 4.记录
citySendLogService.save(city.getCity(), city.getUid(), n.getId(), FangjiaConstant.HOUSING_ESTATE_SEND_TYPE);
citySendLogService.save(city.getCity(), city.getUid(), n.getId(),
FangjiaConstant.HOUSING_ESTATE_SEND_TYPE);
}
}
}
@@ -4,15 +4,21 @@ import java.util.List;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import com.cxytiandi.jdbc.util.DateUtils;
import com.dangdang.ddframe.job.api.ShardingContext;
import com.dangdang.ddframe.job.api.simple.SimpleJob;
import com.fangjia.job.common.base.FangjiaConstant;
import com.fangjia.job.youfang.document.CitySendLog;
import com.fangjia.job.youfang.param.PushMessageParam;
import com.fangjia.job.youfang.po.CityCollect;
import com.fangjia.job.youfang.po.EnterpriseProductUser;
import com.fangjia.job.youfang.po.News;
import com.fangjia.job.youfang.service.CityCollectService;
import com.fangjia.job.youfang.service.CitySendLogService;
import com.fangjia.job.youfang.service.EnterpriseProductUserService;
import com.fangjia.job.youfang.service.NewsService;
import com.fangjia.job.youfang.service.PushMessageService;
public class TopNewsSendJob implements SimpleJob {
@@ -26,6 +32,12 @@ public class TopNewsSendJob implements SimpleJob {
@Autowired
private NewsService newsService;
@Autowired
private EnterpriseProductUserService enterpriseProductUserService;
@Autowired
private PushMessageService pushMessageService;
@Override
public void execute(ShardingContext context) {
@@ -65,7 +77,16 @@ public class TopNewsSendJob implements SimpleJob {
if (null == sendList || sendList.isEmpty()) {
LOG.info("新闻推送开始。。。uid:" + city.getUid() + ",newsId:" + n.getId());
// 3.发送
// TODO
EnterpriseProductUser user = enterpriseProductUserService.getById(city.getUid(), new String[] { "push_client_id" });
String pushMsg = n.getContent();
LOG.info(pushMsg);
PushMessageParam param = new PushMessageParam();
param.setTitle(n.getTitle());
param.setContent(pushMsg);
param.setOperation(1);
param.setOperationPage("");
param.setPushClientId(user.getPushClientId());
pushMessageService.push(param);
// 4.记录
citySendLogService.save(city.getCity(), city.getUid(), n.getId(), FangjiaConstant.NEWS_SEND_TYPE);
}