Commit 07969554 authored by helinlin's avatar helinlin

修改消防巡查消息推送

parent f190a9a3
package com.yeejoin.amos.patrol.business.dto;
import com.yeejoin.amos.component.rule.Label;
import com.yeejoin.amos.component.rule.RuleFact;
import lombok.Data;
import java.io.Serializable;
import java.util.List;
import java.util.Map;
/**
* 发送到规则平台的消息对象
*/
@Data
@RuleFact(value = "消防巡查", project = "消息规则")
public class MsgRo implements Serializable {
private static final long serialVersionUID = -4210693601552557441L;
@Label("名称")
private String name;
@Label("内容")
private String content;
@Label(value = "推送时间")
private String sendTime;
@Label(value = "接收人")
private List<String> recivers;
@Label(value = "发送到web标识")
private Boolean isSendWeb;
@Label(value = "发送到app标识")
private Boolean isSendApp;
@Label("关联id")
private String relationId;
@Label("消息类型")
private String msgType;
@Label(value = "终端标识")
private String terminal;
@Label(value = "扩展参数")
private Map<String, String> extras;
}
...@@ -247,7 +247,7 @@ public class MessageServiceImpl implements IMessageService { ...@@ -247,7 +247,7 @@ public class MessageServiceImpl implements IMessageService {
pushMsgParam.setRelationId(checkMsgBo.getCheckId()+""); pushMsgParam.setRelationId(checkMsgBo.getCheckId()+"");
pmps.add(pushMsgParam); pmps.add(pushMsgParam);
List<Msg> msgList =createMsg(jpushUser,checkMsgBo); List<Msg> msgList =createMsg(jpushUser,checkMsgBo);
pushFeignServer.sendMessage( toke, product, appKey,pmps); pushFeignServer.sendMessage(pmps);
} }
} }
...@@ -328,7 +328,7 @@ public class MessageServiceImpl implements IMessageService { ...@@ -328,7 +328,7 @@ public class MessageServiceImpl implements IMessageService {
pmps.add(pushMsg); pmps.add(pushMsg);
msg.setSendTime(new Date()); msg.setSendTime(new Date());
msg.setStatus(1); msg.setStatus(1);
pushFeignServer.sendMessage( toke, product, appKey,pmps); pushFeignServer.sendMessage(pmps);
iMsgDao.save(msg); iMsgDao.save(msg);
return msg; return msg;
} }
...@@ -436,7 +436,6 @@ public class MessageServiceImpl implements IMessageService { ...@@ -436,7 +436,6 @@ public class MessageServiceImpl implements IMessageService {
@Override @Override
public void pushMsg(String toke, String product, String appKey, PushMsgParam pmsg) { public void pushMsg(String toke, String product, String appKey, PushMsgParam pmsg) {
// TODO Auto-generated method stub pushFeignServer.sendMessage(pmsg);
pushFeignServer.sendMessage( toke, product, appKey,pmsg);
} }
} }
package com.yeejoin.amos.patrol.business.service.impl;
import com.yeejoin.amos.component.rule.RuleTrigger;
import com.yeejoin.amos.patrol.business.dto.MsgRo;
import com.yeejoin.amos.patrol.business.param.PushMsgParam;
import com.yeejoin.amos.patrol.business.util.DateUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Date;
/**
* @Author: hll
* @Description: 消防巡查触发规则
* @Date: 2021/11/10 9:50
*/
@Service
public class RulePlanService {
private final String packageId = "消息/addCheckRule";
private final String msgType = "patrol";
private final String APP = "APP";
private final String WEB = "WEB";
private final String APP_WEB = "APP/WEB";
@Autowired
private RuleTrigger ruleTrigger;
public Boolean sendRule(PushMsgParam pushMsgParam) {
MsgRo msgRo = new MsgRo();
msgRo.setName(pushMsgParam.getSubject());
msgRo.setContent(pushMsgParam.getContent());
msgRo.setRecivers(pushMsgParam.getRecivers());
msgRo.setMsgType(msgType);
msgRo.setTerminal(APP_WEB);
msgRo.setSendTime(DateUtil.date2LongStr(new Date()));
msgRo.setRelationId(pushMsgParam.getRelationId());
msgRo.setExtras(pushMsgParam.getExtras());
msgRo.setIsSendApp(true);
msgRo.setIsSendWeb(true);
//触发规则
try {
ruleTrigger.publish(msgRo, packageId, new String[0]);
return true;
} catch (Exception e) {
e.printStackTrace();
return false;
}
}
}
package com.yeejoin.amos.patrol.feign; package com.yeejoin.amos.patrol.feign;
import java.util.List; import com.yeejoin.amos.patrol.business.param.PushMsgParam;
import com.yeejoin.amos.patrol.business.service.impl.RulePlanService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import com.yeejoin.amos.feign.systemctl.Systemctl; import java.util.List;
import com.yeejoin.amos.feign.systemctl.model.MessageModel;
import com.yeejoin.amos.patrol.business.param.PushMsgParam;
@Service("pushFeignServer") @Service("pushFeignServer")
public class PushFeignServer { public class PushFeignServer {
public void sendMessage( String toke,String product,String appKey, List<PushMsgParam> pushMsgParam){ @Autowired
try { RulePlanService rulePlanService;
pushMsgParam.forEach(action->{
sendJP(action); /**
}); * 批量发送
} catch (Exception e) { *
e.printStackTrace(); * @param pushMsgParam 消息参数
} */
} public void sendMessage(List<PushMsgParam> pushMsgParam) {
pushMsgParam.forEach(rulePlanService::sendRule);
}
public void sendMessage( String toke,String product,String appKey, PushMsgParam pushMsgParam){
try { /**
sendJP(pushMsgParam); * 单个发送
} catch (Exception e) { *
e.printStackTrace(); * @param pushMsgParam 消息参数
} */
} public void sendMessage(PushMsgParam pushMsgParam) {
rulePlanService.sendRule(pushMsgParam);
private void sendJP(PushMsgParam pushMsgParam){ }
MessageModel model = new MessageModel();
model.setRelationId(pushMsgParam.getRelationId());
model.setTitle(pushMsgParam.getSubject());
model.setBody(pushMsgParam.getContent());
model.setMsgType("patrolSystem");
model.setIsSendApp(true);
model.setRecivers(pushMsgParam.getRecivers());
model.setExtras(pushMsgParam.getExtras());
Systemctl.messageClient.create(model);
}
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment