| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645 |
- package com.uas.ps.message.service.impl;
- import com.alibaba.fastjson.JSONObject;
- import com.uas.account.entity.User;
- import com.uas.account.entity.UserView;
- import com.uas.account.util.AccountUtils;
- import com.uas.account.util.FlexJsonUtil;
- import com.uas.ps.core.page.PageInfo;
- import com.uas.ps.core.page.PageParams;
- import com.uas.ps.core.page.criteria.LogicalExpression;
- import com.uas.ps.core.page.criteria.PredicateUtils;
- import com.uas.ps.core.page.criteria.SimpleExpression;
- import com.uas.ps.core.util.ArrayUtils;
- import com.uas.ps.message.dao.AppDao;
- import com.uas.ps.message.dao.MessageDao;
- import com.uas.ps.message.domain.App;
- import com.uas.ps.message.domain.Message;
- import com.uas.ps.message.domain.SmsMessage;
- import com.uas.ps.message.exception.IllegalOperatorException;
- import com.uas.ps.message.exception.ParameterMissingException;
- import com.uas.ps.message.service.MessageService;
- import com.uas.ps.message.util.Constant;
- import com.uas.ps.message.util.ConsumeType;
- import com.uas.ps.message.util.FastjsonUtils;
- import com.uas.ps.message.util.SMSType;
- import com.uas.ps.message.util.SplitChar;
- import com.uas.ps.message.util.account.HttpUtil;
- import com.uas.ps.message.util.account.HttpUtil.ResponseWrap;
- import java.util.ArrayList;
- import java.util.Date;
- import java.util.HashMap;
- import java.util.HashSet;
- import java.util.List;
- import java.util.Map;
- import java.util.Set;
- import javax.persistence.criteria.CriteriaBuilder;
- import javax.persistence.criteria.CriteriaQuery;
- import javax.persistence.criteria.Predicate;
- import javax.persistence.criteria.Root;
- import org.apache.log4j.Logger;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.data.domain.Page;
- import org.springframework.data.jpa.domain.Specification;
- import org.springframework.http.HttpHeaders;
- import org.springframework.http.MediaType;
- import org.springframework.stereotype.Service;
- import org.springframework.ui.ModelMap;
- import org.springframework.util.CollectionUtils;
- import org.springframework.util.StringUtils;
- /**
- * Created by wangyc on 2018/1/13.
- *
- * @version 2018/1/13 15:44 wangyc
- */
- @Service
- public class MessageServiceImpl implements MessageService {
- private final MessageDao messageDao;
- private final AppDao appDao;
- private static final Logger logger = Logger.getLogger(Logger.class);
- // private RestTemplate restTemplate;
- // private static final String EMAIL_REGEX = "\\w[-\\w.+]*@([A-Za-z0-9][-A-Za-z0-9]+\\.)+[A-Za-z]{2,14}";
- // private static final String TEL_REGEXP = "^((\\(\\d{3}\\))|(\\d{3}\\-))?(13|15|18|17)\\d{9}$";
- private static final String PROD_URL = "https://mobile.ubtob.com/tigase/baiduPush";
- private static final String PUBLIC_INQUIRY_IM_URL= "https://mobile.ubtob.com:8443/openapp/?pagekind=B&id=%s&uu=%s&telephone=%s";
- /**
- * 邮件服务主机地址
- */
- private static final String MAIL_CONSOLE_HOST = "http://10.10.100.136:8080";
- /**
- * 发送邮件给单个人url
- */
- private static final String MAIL_SEND_URL = "mail/send";
- /**
- * 发送邮件给多个人 url
- */
- private static final String MAIL_SEND_MANY_URL = "mail/send/o2m";
- /**
- * 短信接口
- */
- private final String messageUrl = "http://10.10.100.136:8080/sms/send";
- @Autowired
- public MessageServiceImpl(MessageDao messageDao, AppDao appDao) {
- this.messageDao = messageDao;
- this.appDao = appDao;
- }
- @Override
- public Page<Message> getMessages(String receiverUu, String receiverEnuu, String consumerApp, String isRead,
- String keyword, PageParams pageParams) {
- if (StringUtils.isEmpty(receiverUu) || StringUtils.isEmpty(receiverEnuu)) {
- throw new ParameterMissingException("接收人信息为空");
- }
- if (StringUtils.isEmpty(consumerApp)) {
- throw new ParameterMissingException("接收应用信息为空");
- }
- App consumerAppExists = appDao.findByName(consumerApp);
- if (consumerApp == null) {
- throw new IllegalOperatorException("接收应用不存在");
- }
- final Long consumerAppId = consumerAppExists.getId();
- // 消息接收人过滤
- SimpleExpression receiverUuExp = PredicateUtils.eq("receiverUu", Long.valueOf(receiverUu), true);
- // 消息接收企业过滤
- SimpleExpression receiverEnuuExp = PredicateUtils.eq("receiverEnuu", Long.valueOf(receiverEnuu), true);
- SimpleExpression[] simpleExpressions = new SimpleExpression[] {receiverUuExp, receiverEnuuExp};
- // 读取状态
- if (!StringUtils.isEmpty(isRead)) {
- SimpleExpression isReadExp = PredicateUtils.eq("isRead", Short.valueOf(isRead), true);
- simpleExpressions = ArrayUtils.concat(simpleExpressions, new SimpleExpression[] {isReadExp});
- }
- // 关键词搜索
- if (!StringUtils.isEmpty(keyword)) {
- SimpleExpression contentExp = PredicateUtils.like("content", keyword, true);
- simpleExpressions = ArrayUtils.concat(simpleExpressions, new SimpleExpression[] {contentExp});
- }
- final LogicalExpression logicalExpression = PredicateUtils.and(simpleExpressions);
- final PageInfo pageInfo = new PageInfo(pageParams);
- return messageDao.findAll(new Specification<Message>() {
- @Override
- public Predicate toPredicate(Root<Message> root, CriteriaQuery<?> criteriaQuery,
- CriteriaBuilder criteriaBuilder) {
- Predicate messagePredicate = criteriaBuilder.and(logicalExpression.toPredicate(root, criteriaQuery,
- criteriaBuilder));
- // 消费应用过滤
- Predicate consumerAppPredicate = criteriaBuilder.equal(root.join("consumerApp").get("id"),
- consumerAppId);
- Predicate all = criteriaBuilder.and(messagePredicate, consumerAppPredicate);
- criteriaQuery.where(all);
- return null;
- }
- }, pageInfo);
- }
- @Override
- public Map<String, Object> getUnReadMessageCount(String receiverUu, String receiverEnuu, String consumerApp) {
- if (StringUtils.isEmpty(receiverUu) || StringUtils.isEmpty(receiverEnuu)) {
- throw new ParameterMissingException("接收人信息为空");
- }
- if (StringUtils.isEmpty(consumerApp)) {
- throw new ParameterMissingException("接收应用信息为空");
- }
- App consumerAppExists = appDao.findByName(consumerApp);
- if (consumerApp == null) {
- throw new IllegalOperatorException("接收应用不存在");
- }
- Integer messagesCount = messageDao.findCountByReceiverUuAndReceiverEnuuAndIsReadAndConsumerAppId(Long.valueOf(receiverUu),
- Long.valueOf(receiverEnuu), Constant.NO, consumerAppExists.getId());
- Map<String, Object> resultMap = new HashMap<>();
- resultMap.put("success", "success");
- resultMap.put("count", messagesCount);
- return resultMap;
- }
- @Override
- public Map<String, Object> getMessageCount(String receiverUu, String receiverEnuu, String consumerApp,
- String isRead) {
- if (StringUtils.isEmpty(receiverUu) || StringUtils.isEmpty(receiverEnuu)) {
- throw new ParameterMissingException("接收人信息为空");
- }
- if (StringUtils.isEmpty(consumerApp)) {
- throw new ParameterMissingException("接收应用信息为空");
- }
- App consumerAppExists = appDao.findByName(consumerApp);
- if (consumerApp == null) {
- throw new IllegalOperatorException("接收应用不存在");
- }
- Integer messagesCount = 0;
- if (StringUtils.isEmpty(isRead) || (!isRead.equals(Constant.NO.toString()) && !isRead.equals(Constant.YES.toString()))) {
- messagesCount = messageDao.findCountByReceiverUuAndReceiverEnuuAndConsumerAppId(Long.valueOf(receiverUu),
- Long.valueOf(receiverEnuu), consumerAppExists.getId());
- } else {
- messagesCount = messageDao.findCountByReceiverUuAndReceiverEnuuAndIsReadAndConsumerAppId(Long.valueOf(receiverUu),
- Long.valueOf(receiverEnuu), Short.valueOf(isRead), consumerAppExists.getId());
- }
- Map<String, Object> resultMap = new HashMap<>();
- resultMap.put("success", "success");
- resultMap.put("count", messagesCount);
- return resultMap;
- }
- @Override
- public List<Message> saveMessages(String messages) {
- List<JSONObject> jsonObjects = FastjsonUtils.fromJsonArray(messages, JSONObject.class);
- List<Message> messageList = convertFromJsonObj(jsonObjects);
- return messageDao.save(messageList);
- }
- @Override
- public Map<String, Object> sendMessage(String consumerApp) {
- JSONObject consumer = FastjsonUtils.parseObject(consumerApp);
- Object consumerAppObj = consumer.get("consumerApp");
- if (consumerAppObj != null && !StringUtils.isEmpty(String.valueOf(consumerAppObj))) {
- App consumerAppExists = appDao.findByName(String.valueOf(consumerAppObj));
- if (consumerAppExists == null) {
- throw new IllegalOperatorException("接收应用不存在");
- }
- // 获取改应用应接收的未读、未发送的需要推送的消息(取前500条)
- List<Message> messages = messageDao.findByConsumerAppIdAndIsReadAndIsSentNeedToSend(
- consumerAppExists.getId(), Constant.NO, Constant.NO);
- logger.info("信息数量:" + messages.size());
- Map<String, Object> resultMap = sendMessageByAPI(messages, consumerApp);
- resultMap.put("success", "success");
- return resultMap;
- } else {
- throw new ParameterMissingException("接收应用信息为空");
- }
- }
- @Override
- public ModelMap readMessage(String consumer) {
- ModelMap map = new ModelMap();
- map.put("success", "false");
- if (StringUtils.isEmpty(consumer)) {
- throw new ParameterMissingException("接收人信息为空,无法阅读消息");
- }
- JSONObject jsonObject = FastjsonUtils.parseObject(consumer);
- // 消息id
- Object messageId = jsonObject.get("messageId");
- Object receiverUu = jsonObject.get("receiverUu");
- Object receiverEnuu = jsonObject.get("receiverEnuu");
- Object consumerApp = jsonObject.get("consumerApp");
- if (StringUtils.isEmpty(messageId)) {
- map.put("data", "消息id为空,请重新确认消息信息");
- return map;
- } else {
- String[] messageIds = String.valueOf(messageId).split(SplitChar.COMMA);
- List<Message> messages = new ArrayList<>();
- for (String id : messageIds) {
- Message message = messageDao.findOne(Long.valueOf(String.valueOf(id)));
- if (message == null) {
- map.put("data", "消息不存在,请重新确认消息信息");
- return map;
- }
- if (receiverUu == null || StringUtils.isEmpty(String.valueOf(receiverEnuu)) || receiverEnuu == null
- || StringUtils.isEmpty(String.valueOf(receiverUu))
- || StringUtils.isEmpty(String.valueOf(consumerApp))) {
- map.put("data", "用户信息为空,无法读取消息");
- return map;
- }
- if (!Long.valueOf(String.valueOf(receiverEnuu)).equals(message.getReceiverEnuu())
- || !Long.valueOf(String.valueOf(receiverUu)).equals(message.getReceiverUu())) {
- map.put("data", "此消息不属于当前用户,请重新确认后读取");
- return map;
- }
- if (Constant.YES.equals(message.getIsRead())) {
- map.put("data", "消息已阅读");
- return map;
- }
- App app = appDao.findByName(String.valueOf(consumerApp));
- if (app == null) {
- map.put("data", "消费应用不存在,请重新确认用户信息");
- return map;
- }
- if (!message.getConsumerApp().contains(app)) {
- map.put("data", "消息不属于当前应用");
- return map;
- }
- message.setIsRead(Constant.YES);
- messages.add(message);
- }
- messages = messageDao.save(messages);
- map.put("success", "success");
- map.put("data", FastjsonUtils.toJson(messages));
- return map;
- }
- }
- /**
- * jsonObject转换为Message
- * @param jsonObjects jsonObjects
- * @return messages
- */
- private List<Message> convertFromJsonObj(List<JSONObject> jsonObjects) {
- List<Message> messages = new ArrayList<>();
- for (JSONObject jsonObject : jsonObjects) {
- Message message = new Message();
- // 消息内容
- Object content = jsonObject.get("content");
- if (StringUtils.isEmpty(content)) {
- throw new ParameterMissingException("消息内容为空");
- } else {
- message.setContent(String.valueOf(content));
- }
- // 发送人
- Object senderUu = jsonObject.get("senderUu");
- Object senderEnuu = jsonObject.get("senderEnuu");
- if (StringUtils.isEmpty(senderUu) || StringUtils.isEmpty(senderEnuu)) {
- throw new ParameterMissingException("发送人信息为空");
- } else {
- message.setSenderUu(Long.valueOf(String.valueOf(senderUu)));
- message.setSenderEnuu(Long.valueOf(String.valueOf(senderEnuu)));
- }
- // 接收人
- Object receiverUu = jsonObject.get("receiverUu");
- Object receiverEnuu = jsonObject.get("receiverEnuu");
- if (StringUtils.isEmpty(receiverUu) || StringUtils.isEmpty(receiverEnuu)) {
- throw new ParameterMissingException("接收人信息为空");
- } else {
- message.setReceiverUu(Long.valueOf(String.valueOf(receiverUu)));
- message.setReceiverEnuu(Long.valueOf(String.valueOf(receiverEnuu)));
- }
- // 发送应用
- Object producerApp = jsonObject.get("producerApp");
- if (StringUtils.isEmpty(producerApp)) {
- throw new ParameterMissingException("发送应用为空");
- } else {
- App app = appDao.findByName(String.valueOf(producerApp));
- if (app == null) {
- throw new IllegalOperatorException("发送应用不存在");
- }
- message.setProducerApp(app.getId());
- }
- // 接收应用
- Object consumerType = jsonObject.get("consumerType");
- if (StringUtils.isEmpty(consumerType)) {
- throw new ParameterMissingException("接收应用类型为空");
- } else {
- String type = String.valueOf(consumerType);
- // 消息接收类型为公共,即所有子应用共享
- if (ConsumeType.PUBLIC.equals(type)) {
- List<App> apps = appDao.findAll();
- message.setConsumerApp(new HashSet<>(apps));
- message.setConsumeType(type);
- } else {
- Object consumerApp = jsonObject.get("consumerApp");
- if (consumerApp == null) {
- throw new ParameterMissingException("接收应用为空");
- } else {
- // 取出通过逗号拼接的接收应用
- String[] consumers = String.valueOf(consumerApp).split(SplitChar.COMMA);
- if (consumers.length < 1) {
- throw new ParameterMissingException("接收应用为空");
- }
- Set<App> consumerApps = new HashSet<>();
- for (String consumer : consumers) {
- App app = appDao.findByName(consumer);
- if (app == null) {
- throw new IllegalOperatorException("接收应用不存在");
- }
- consumerApps.add(app);
- }
- message.setConsumerApp(consumerApps);
- message.setConsumeType(consumers.length > 1 ? ConsumeType.MULTI : ConsumeType.SINGLE);
- }
- }
- }
- // 消息类型(暂时未定)
- Object type = jsonObject.get("type");
- if (!StringUtils.isEmpty(type)) {
- message.setType(String.valueOf(type));
- }
- // 推送类型
- Object smsType = jsonObject.get("smsType");
- if (StringUtils.isEmpty(smsType)) {
- message.setSmsType(SMSType.DONT_SEND);
- } else {
- message.setSmsType(String.valueOf(smsType));
- }
- // 备注
- Object remark = jsonObject.get("remark");
- if (!StringUtils.isEmpty(remark)) {
- message.setRemark(String.valueOf(remark));
- }
- // 来源id
- Object sourceId = jsonObject.get("sourceId");
- if (!StringUtils.isEmpty(sourceId)) {
- message.setSourceId(Long.valueOf(String.valueOf(sourceId)));
- }
- // 邮件模板
- Object mailTemplate = jsonObject.get("mailTemplate");
- if (!StringUtils.isEmpty(mailTemplate)) {
- message.setMailTemplate(String.valueOf(mailTemplate));
- }
- // 短信模板
- Object smTemplate = jsonObject.get("smTemplate");
- if (!StringUtils.isEmpty(smTemplate)) {
- message.setSmTemplate(String.valueOf(smTemplate));
- }
- message.setIsRead(Constant.NO);
- message.setCreateTime(new Date());
- message.setIsSent(Constant.NO);
- messages.add(message);
- }
- return messages;
- }
- /**
- * 推送消息(调用邮件、短信、IM接口)
- * @param messages 消息
- * @param consumerApp 消费app
- * @return resultMap
- */
- private Map<String, Object> sendMessageByAPI(List<Message> messages, String consumerApp) {
- Map<String, Object> resultMap = new HashMap<>();
- if (!CollectionUtils.isEmpty(messages)) {
- for (Message message : messages) {
- try {
- UserView receiver = AccountUtils.getImUserByUserUU(message.getReceiverUu(),
- message.getReceiverEnuu());
- if (receiver.getName() != null) {
- logger.info("接收人:" + receiver.getName());
- UserView sender = AccountUtils.getImUserByUserUU(message.getSenderUu(),
- message.getSenderEnuu());
- if (sender != null && sender.getName() != null && sender.getSpaceName() != null) {
- logger.info("发送人:" + sender.getName());
- boolean sendSuccess = false;
- // 发送邮件
- // if (message.getSmsType().contains(SMSType.MAIL)) {
- // sendMail(message, receiver);
- // }
- // 发送短息
- if (message.getSmsType().contains(SMSType.SM)) {
- logger.info("开始推送短信");
- sendSuccess = sendSM(message, receiver, sender);
- }
- // 发送IM
- if (message.getSmsType().contains(SMSType.IM)) {
- logger.info("开始推送IM");
- sendSuccess = sendIM(message, receiver, consumerApp);
- }
- // 推送成功
- if (sendSuccess) {
- pushSuccess(message, receiver, sender);
- }
- } else {
- logger.info("发送人信息为空,uu:" + message.getSenderUu() + ",enuu:" + message.getSenderEnuu());
- }
- } else {
- logger.info("接收人姓名为空,uu:" + message.getReceiverUu() + ",enuu:" + message.getReceiverEnuu());
- }
- } catch (Exception e) {
- message.setIsSent(Constant.ERROR);
- logger.info(e.getMessage());
- }
- }
- messageDao.save(messages);
- }
- return resultMap;
- }
- /**
- * 发送邮件
- * @param message 消息
- * @param receiver 接收人
- */
- private void sendMail(Message message, User receiver) {
- if (message.getMailTemplate() != null && receiver.getSecondUID() != null) {
- HttpHeaders headers = new HttpHeaders();
- MediaType type = MediaType.parseMediaType("application/json; charset=UTF-8");
- headers.setContentType(type);
- headers.add("Accept", MediaType.APPLICATION_JSON.toString());
- JSONObject object = new JSONObject();
- object.put("templateId", message.getMailTemplate());
- object.put("receiver", receiver.getSecondUID());
- object.put("params", message.getContent());
- // HttpEntity<String> formEntity = new HttpEntity<String>(, headers);
- try {
- ResponseWrap responseWrap = HttpUtil.doPost(MAIL_CONSOLE_HOST + MAIL_SEND_URL,
- FlexJsonUtil.toJson(object));
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- }
- /**
- * 发送短信
- * @param message 消息
- * @param receiver 接收人
- * @param sender 发送人
- * @return 推送成功状态
- */
- private boolean sendSM(Message message, UserView receiver, UserView sender) {
- if (!StringUtils.isEmpty(message.getSmTemplate()) && !StringUtils.isEmpty(receiver.getUid())) {
- try {
- SmsMessage sms = new SmsMessage();
- List<Object> obj = new ArrayList<Object>();
- switch (message.getSmTemplate()) {
- // 公共询价单,普通短信
- case "e14d502a-25b8-40a0-8acf-5c61ae38d763" :
- obj.add(receiver.getName());
- obj.add(sender.getSpaceName());
- obj.add(message.getRemark());
- pushSm(sms, message, obj, receiver, sender);
- break;
- // 公共询价单,UU互联
- case "6e094dcf-f2c7-462a-9686-b2d32d684a78" :
- obj.add(message.getSourceId());
- obj.add(message.getReceiverEnuu());
- obj.add(receiver.getUid());
- pushSm(sms, message, obj, receiver, sender);
- break;
- // 公共询价统计
- case "e6320a3c-89ac-4c77-a75f-62a727bce654" :
- obj.add(message.getRemark());
- pushSm(sms, message, obj, receiver, sender);
- default:
- break;
- }
- return true;
- } catch (Exception e) {
- logger.info("短信推送异常:" + e.getMessage());
- e.printStackTrace();
- return false;
- }
- }
- return false;
- }
- /**
- * 调用短信接口
- * @param sms 短信model
- * @param message 消息
- * @param param 短信参数
- * @param receiver 接收人
- * @param sender 发送人
- */
- private void pushSm(SmsMessage sms, Message message, List<Object> param, UserView receiver, UserView sender) {
- sms.setParams(param);
- sms.setReceiver(receiver.getUid());
- sms.setTemplateId(message.getSmTemplate());
- String response = com.uas.ps.message.util.HttpUtil
- .sendPost(messageUrl, FastjsonUtils.toJson(sms));
- logger.info("短信推送成功:" + response);
- }
- public static void main(String[] args) {
- SmsMessage smsMessage = new SmsMessage();
- List<Object> param = new ArrayList<>();
- param.add("测试公司");
- param.add("测试型号");
- smsMessage.setParams(param);
- smsMessage.setReceiver("13632823241");
- smsMessage.setTemplateId("7879bfda-f871-4a95-9430-54d1ea00b198");
- String response = com.uas.ps.message.util.HttpUtil
- .sendPost("http://10.10.100.136:8080/sms/send", FastjsonUtils.toJson(smsMessage));
- System.out.println(response);
- }
- /**
- * 设置推送送成功
- * @param message 消息
- * @param receiver 接收人
- * @param sender 发送人
- */
- private void pushSuccess(Message message, UserView receiver, UserView sender) {
- message.setIsSent(Constant.YES);
- message.setReceiver(FastjsonUtils.toJson(receiver));
- message.setSender(FastjsonUtils.toJson(sender));
- }
- /**
- * 发送IM
- * @param message 消息
- * @param receiver 接收人
- * @param consumerApp 消费app
- * @return 推送成功状态
- */
- private boolean sendIM(Message message, UserView receiver, String consumerApp) {
- Map<String, Object> params = new HashMap<>();
- if (!StringUtils.isEmpty(receiver.getDialectUID())) {
- params.put("master", receiver.getSpaceName()); // 账套 公司名称
- params.put("userid", receiver.getDialectUID()); // 推送目标用户
- params.put("title", message.getType() == null ? "" : message.getType()); // 推送标题
- params.put("content", message.getContent()); // 正文
- params.put("enUU", message.getReceiverEnuu()); // UU号
- params.put("masterId", null);
- params.put("url", String.format(PUBLIC_INQUIRY_IM_URL, message.getSourceId(),
- message.getReceiverEnuu(), receiver.getUid())); // 跳转链接地址
- params.put("pageTitle", message.getType() == null ? "" : message.getType());
- params.put("platform", "B2B"); // 系统名称,ERP或B2B
- try {
- ResponseWrap res = HttpUtil.doPost(PROD_URL, params);
- if (res.isSuccess()) {
- logger.info("IM推送成功");
- return true;
- } else {
- logger.info("IM推送失败:" + res.getContent());
- }
- } catch (Exception e) {
- e.printStackTrace();
- return false;
- }
- }
- return false;
- }
- }
|