消息推送
This commit is contained in:
+24
-7
@@ -16,14 +16,16 @@ import com.dangdang.ddframe.job.api.ShardingContext;
|
||||
import com.dangdang.ddframe.job.api.simple.SimpleJob;
|
||||
import com.fangjia.job.common.core.FangjiaThreadPoolExecutor;
|
||||
import com.fangjia.job.common.util.DateUtilCustom;
|
||||
import com.fangjia.job.youfang.param.PushMessageParam;
|
||||
import com.fangjia.job.youfang.po.EnterpriseProductUser;
|
||||
import com.fangjia.job.youfang.po.HouseInfo;
|
||||
import com.fangjia.job.youfang.service.EnterpriseProductUserService;
|
||||
import com.fangjia.job.youfang.service.HouseInfoService;
|
||||
import com.fangjia.job.youfang.service.PushMessageService;
|
||||
|
||||
/**
|
||||
* 房产租金提醒任务<br>
|
||||
* 每天触发一次,逻辑在服务端
|
||||
* 每天触发一次
|
||||
* @author yinjihuan
|
||||
*/
|
||||
public class HouseRentNoticeJob implements SimpleJob {
|
||||
@@ -39,6 +41,9 @@ public class HouseRentNoticeJob implements SimpleJob {
|
||||
@Autowired
|
||||
private EnterpriseProductUserService enterpriseProductUserService;
|
||||
|
||||
@Autowired
|
||||
private PushMessageService pushMessageService;
|
||||
|
||||
@Override
|
||||
public void execute(ShardingContext shardingContext) {
|
||||
logger.info("开始执行HouseRentNoticeJob");
|
||||
@@ -103,9 +108,6 @@ public class HouseRentNoticeJob implements SimpleJob {
|
||||
|
||||
// 收租提醒,提前7天通知
|
||||
private void rentPush(HouseInfo houseInfo) {
|
||||
if(houseInfo.getId().equals(107419093023326208L)){
|
||||
System.out.println("a");
|
||||
}
|
||||
int unitMonth = houseInfo.getRentCycle() * 1;
|
||||
if("季".equals(houseInfo.getRentCycleUnit())){
|
||||
unitMonth = houseInfo.getRentCycle() * 3;
|
||||
@@ -162,8 +164,16 @@ public class HouseRentNoticeJob implements SimpleJob {
|
||||
if (nextDay != null) {
|
||||
int days = DateUtilCustom.between(new Date(), nextDay);
|
||||
if (days == 7) {
|
||||
EnterpriseProductUser user = enterpriseProductUserService.getById(Long.parseLong(houseInfo.getUid()), new String[] { "push_client_id" });
|
||||
String pushMsg = DateUtils.date2Str(nextDay, "yyyy年MM月dd日") + "是您的到期收租日,又要有现金到账咯,请注意查收。详情请点击查看。";
|
||||
System.err.println(pushMsg);
|
||||
logger.info(pushMsg);
|
||||
PushMessageParam param = new PushMessageParam();
|
||||
param.setTitle("收租提醒");
|
||||
param.setContent(pushMsg);
|
||||
param.setOperation(1);
|
||||
param.setOperationPage("");
|
||||
param.setPushClientId(user.getPushClientId());
|
||||
pushMessageService.push(param);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -179,9 +189,16 @@ public class HouseRentNoticeJob implements SimpleJob {
|
||||
// 判断当前时间距离到期日期的天数,在30天和15天的时候进行推送
|
||||
int days = DateUtilCustom.between(new Date(), leaseEndDate);
|
||||
if(days == 15 || days == 30) {
|
||||
String pushMsg = DateUtils.date2Str(leaseEndDate, "yyyy年MM月dd日") + "您的房子租期就到了,快来看看现在的市场租金价格吧。详情请点击查看。";
|
||||
System.err.println(pushMsg);
|
||||
EnterpriseProductUser user = enterpriseProductUserService.getById(Long.parseLong(house.getUid()), new String[] { "push_client_id" });
|
||||
String pushMsg = DateUtils.date2Str(leaseEndDate, "yyyy年MM月dd日") + "您的房子租期就到了,快来看看现在的市场租金价格吧。详情请点击查看。";
|
||||
logger.info(pushMsg);
|
||||
PushMessageParam param = new PushMessageParam();
|
||||
param.setTitle("收租提醒");
|
||||
param.setContent(pushMsg);
|
||||
param.setOperation(1);
|
||||
param.setOperationPage("");
|
||||
param.setPushClientId(user.getPushClientId());
|
||||
pushMessageService.push(param);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+71
@@ -0,0 +1,71 @@
|
||||
package com.fangjia.job.youfang.param;
|
||||
|
||||
public class PushMessageParam {
|
||||
|
||||
// 标题
|
||||
private String title;
|
||||
|
||||
// 内容
|
||||
private String content;
|
||||
|
||||
// 通知操作(0:打开应用,1:打开指定页面,2:打开url)
|
||||
private int operation;
|
||||
|
||||
// 当通知操作为打开具体页面时这个值就是页面的值,当为打开url时这个值就是url的值
|
||||
private String operationPage;
|
||||
|
||||
// 推送ID
|
||||
private String pushClientId;
|
||||
|
||||
// 推送给哪个用户
|
||||
private Long userId;
|
||||
|
||||
public String getTitle() {
|
||||
return title;
|
||||
}
|
||||
|
||||
public void setTitle(String title) {
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
public String getContent() {
|
||||
return content;
|
||||
}
|
||||
|
||||
public void setContent(String content) {
|
||||
this.content = content;
|
||||
}
|
||||
|
||||
public int getOperation() {
|
||||
return operation;
|
||||
}
|
||||
|
||||
public void setOperation(int operation) {
|
||||
this.operation = operation;
|
||||
}
|
||||
|
||||
public String getOperationPage() {
|
||||
return operationPage;
|
||||
}
|
||||
|
||||
public void setOperationPage(String operationPage) {
|
||||
this.operationPage = operationPage;
|
||||
}
|
||||
|
||||
public String getPushClientId() {
|
||||
return pushClientId;
|
||||
}
|
||||
|
||||
public void setPushClientId(String pushClientId) {
|
||||
this.pushClientId = pushClientId;
|
||||
}
|
||||
|
||||
public Long getUserId() {
|
||||
return userId;
|
||||
}
|
||||
|
||||
public void setUserId(Long userId) {
|
||||
this.userId = userId;
|
||||
}
|
||||
|
||||
}
|
||||
+8
@@ -76,4 +76,12 @@ public interface FshApiRemoteService {
|
||||
*/
|
||||
@RequestLine("GET /fsh/districtDetail")
|
||||
public DistrictDetailDto districtDetail(@QueryMap Map<String, Object> queryMap);
|
||||
|
||||
/**
|
||||
* 消息推送接口
|
||||
* @param queryMap
|
||||
* @return
|
||||
*/
|
||||
@RequestLine("POST /rest/message/push")
|
||||
public Response pushMessage(@QueryMap Map<String, Object> queryMap);
|
||||
}
|
||||
|
||||
+8
@@ -1,5 +1,13 @@
|
||||
package com.fangjia.job.youfang.service;
|
||||
|
||||
import com.fangjia.job.youfang.param.PushMessageParam;
|
||||
|
||||
public interface PushMessageService {
|
||||
|
||||
/**
|
||||
* 推送消息
|
||||
* @param param
|
||||
*/
|
||||
void push(PushMessageParam param);
|
||||
|
||||
}
|
||||
|
||||
+33
-1
@@ -1,11 +1,43 @@
|
||||
package com.fangjia.job.youfang.service;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.cxytiandi.jdbc.EntityService;
|
||||
import com.fangjia.job.common.util.DingDingMessageUtil;
|
||||
import com.fangjia.job.common.util.RestApiCallUtils;
|
||||
import com.fangjia.job.youfang.param.PushMessageParam;
|
||||
import com.fangjia.job.youfang.po.PushMessage;
|
||||
import com.fangjia.job.youfang.remote.FshApiRemoteService;
|
||||
|
||||
@Service
|
||||
public class PushMessageServiceImpl extends EntityService<PushMessage> implements PushMessageService {
|
||||
|
||||
private Logger logger = LoggerFactory.getLogger(PushMessageServiceImpl.class);
|
||||
|
||||
@Value("${fsh.url}")
|
||||
private String fshApiUrl;
|
||||
|
||||
@Override
|
||||
public void push(PushMessageParam param) {
|
||||
FshApiRemoteService fshApiRemoteService = RestApiCallUtils.getRestClient(FshApiRemoteService.class, fshApiUrl);
|
||||
try {
|
||||
Map<String, Object> params = new HashMap<String, Object>();
|
||||
params.put("token", "goojia123456");
|
||||
params.put("title", param.getTitle());
|
||||
params.put("content", param.getContent());
|
||||
params.put("operation", param.getOperation());
|
||||
params.put("operationPage", param.getOperationPage());
|
||||
params.put("pushClientId", param.getPushClientId());
|
||||
params.put("userId", param.getUserId());
|
||||
fshApiRemoteService.pushMessage(params);
|
||||
} catch (Exception e) {
|
||||
logger.error("消息推送异常:", e);
|
||||
DingDingMessageUtil.sendTextMessage("消息推送异常:" + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user