/**
* 朋友圈图片上传
* @author wechatno:tangjinjinwx
* @param ctx
* @param vo
*/
public void handleMsg(ChannelHandlerContext ctx, TransportMessage vo) {
try {
CircleDetailNoticeMessage req = vo.getContent().unpack(CircleDetailNoticeMessage.class);
log.info(JsonFormat.printer().print(req));
// 把消息转发给pc端
// a、根据wechatId找到accountid
// b、通过accountid找到account
// c、通过account账号找到通道
WeChatAccountInfo account = weChatAccountService.findWeChatAccountInfoByWeChatId(req.getWeChatId());
if (null != account && null != account.getAccountid() && 1 != account.getIslogined()) {
AccountInfo accInfo = accountService.findAccountInfoByid(account.getAccountid());
if (null != accInfo) {
// 转发给pc端
ChannelHandlerContext chx = NettyConnectionUtil.getClientChannelHandlerContextByUserId(accInfo.getAccount());
if (null != chx) {
MessageUtil.sendJsonMsg(chx, EnumMsgType.CircleDetailNotice, NettyConnectionUtil.getNettyId(chx),null, req);
}
}
}
//转发给商务app端
BusinessWechatFriends buiness = businessWechatFriendsService.getBusinessWechatFriendsByFriendWechatid(req.getWeChatId());
if(null != buiness){
String nettyName = buiness.getCid()+"_"+buiness.getB_number();
ChannelHandlerContext cx_netty = NettyConnectionUtil.getClientChannelHandlerContextByUserId(nettyName);
if(null != cx_netty){
MessageUtil.sendJsonMsg(cx_netty, EnumMsgType.CircleDetailNotice, NettyConnectionUtil.getNettyId(ctx), null, req);
}
}
// 告诉客户端消息已收到
MessageUtil.sendMsg(ctx, EnumMsgType.MsgReceivedAck, vo.getAccessToken(), vo.getId(), null);
} catch (Exception e) {
e.printStackTrace();
MessageUtil.sendErrMsg(ctx, EnumErrorCode.InvalidParam, Constant.ERROR_MSG_DECODFAIL);
}
}
}