[PHP]
import java.util.Iterator;
import org.jivesoftware.smack.ConnectionConfiguration;
import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.XMPPException;
import org.jivesoftware.smack.packet.DefaultPacketExtension;
import org.jivesoftware.smack.packet.Message;
import com.justep.system.data.KSQL;
import com.justep.system.data.Row;
import com.justep.system.data.Table;
public class SendNotice {
public static void SendNoticeToMeet(String rowid) throws XMPPException {
//获取msg服务器信息
String sql = "select m.fMsgSendPsnID,m.fMsgSendPsnCode,
m.fMsgSendPsnName,o.sPassword,m.fMsgServerIP,m.fMsgDomain from OA_MT_MsgSendCfg m join SA_OPPerson o on m.fMsgSendPsnID = o";
Table stab = KSQL.select(sql, null, "/OA/meeting/data", null);
Row srow = stab.iterator().next();
String serverID = srow.getString("fMsgServerIP"); //msg服务器电脑ip
String domain = srow.getString("fMsgDomain"); // 域名
domain = String.format("@%s/xmsg", domain);
//获取发送者信息
String ssql = "select u.fApplyPsnID,o.sName,o.sCode,o.sPassword "
+ "from OA_MT_UseApply u join SA_OPPerson o"
+ " on u.fApplyPsnID = o where u = '" + rowid + "'";
Table stab1 = KSQL.select(ssql, null, "/OA/meeting/data", null);
Row srow1 = stab1.iterator().next();
String sCode = srow1.getString("sCode");// 发送者sCode
String senderID = srow1.getString("fApplyPsnID");// 发送者sID
String pwd = srow1.getString("sPassword");// 发送者登录系统密码
//登录msg服务器,发送通知
ConnectionConfiguration config = new ConnectionConfiguration(serverID,
5222); // 根据msg服务器ip和端口,获取配置信息
XMPPConnection conn = null;
conn = new XMPPConnection(config);
conn.connect();
try {
conn.login(sCode, pwd); // 登录msg服务器
} catch (XMPPException e) {
conn.disconnect();
throw e;
}
String ksql = "select mu.fPersonID from OA_MT_UseApplyPsns mu where mu.fMasterID = '" + rowid + "'";
Table tab = KSQL.select(ksql, null, "/OA/meeting/data", null);
Iterator rows = tab.iterator();
while (rows.hasNext()) {
Row row = rows.next();
String recvId = row.getString("fPersonID");// 接收者sid
String sendUserJID = senderID + "@" + domain + "/xmsg";
String recvUserJID = recvId + domain;
long threadID = System.currentTimeMillis();
String thread = String.valueOf(threadID);
double flag = Math.random() * 1000;
String packetID = "xmsg_" + String.valueOf(flag);
Message msgX = new Message();
msgX.setFrom(sendUserJID);
msgX.setTo(recvUserJID);
msgX.setSubject("消息标题");
msgX.setType(Message.Type.normal);
msgX.setThread(thread);
msgX.setPacketID(packetID);
/boardroomUseApplyDetail/mainActivity.w?applyID="+ rowid +"\">会议详细内容
";DefaultPacketExtension ext = new DefaultPacketExtension("html", "http://jabber.org/protocol/xhtml-im");
ext.setValue("body", S);
msgX.setBody(S); // 发送内容
msgX.addExtension(ext);
conn.sendPacket(msgX);
}
conn.disconnect();
}
}[/PHP]
本文由WeX5君整理,WeX5一款开源免费的html5开发工具,H5 App开发就用WeX5!