|
|
@@ -6,6 +6,7 @@ import java.util.*;
|
|
|
|
|
|
import com.wxxcx.index.wxSendMessage;
|
|
|
import com.wxxcx.user.WxRelatiion;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
import org.eclipse.paho.client.mqttv3.IMqttDeliveryToken;
|
|
|
import org.eclipse.paho.client.mqttv3.MqttCallback;
|
|
|
import org.eclipse.paho.client.mqttv3.MqttClient;
|
|
|
@@ -25,6 +26,7 @@ import com.wxxcx.targets.EventListVO;
|
|
|
import com.wxxcx.user.MiniUserVO;
|
|
|
import com.wxxcx.ws.PushMsgWebSocket;
|
|
|
|
|
|
+@Slf4j
|
|
|
public class MqttUtil {
|
|
|
// private static String HOST = "tcp://119.45.12.173:1883";
|
|
|
// 测试websocket
|
|
|
@@ -220,6 +222,7 @@ public class MqttUtil {
|
|
|
|
|
|
// 发送短信
|
|
|
if (topic.equals("/das/event") && event.equals("fall_confirmed")) {
|
|
|
+ System.out.println("mqttutil--有跌倒事件");
|
|
|
List<String> openids = new ArrayList<String>();
|
|
|
StringBuffer dev_name = new StringBuffer("");
|
|
|
// 设备拥有者openid
|
|
|
@@ -228,20 +231,6 @@ public class MqttUtil {
|
|
|
openids.add(dev.getUser_openid());
|
|
|
dev_name.append(dev.getDev_name());
|
|
|
|
|
|
- // dev_id dev_info == 拥有者 openId openId ==> userInfo ==> phone oppenId == > wx_relation 微信公众号id
|
|
|
- // 这里添加 微信服务号消息推送 String devName, String phoneNo, String fwhOpenId
|
|
|
- List<MiniUserVO> users = baseDAO.queryAllByCondition(MiniUserVO.class, "and openid = " + dev.getUser_openid(), null);
|
|
|
- String phoneNo = "";
|
|
|
- if (users != null && !users.isEmpty()) {
|
|
|
- phoneNo = users.get(0).getPhone();
|
|
|
- }
|
|
|
- List<WxRelatiion> wxRelatiions = baseDAO.queryAllByCondition(WxRelatiion.class, "and openid = " + dev.getUser_openid(), null);
|
|
|
- String fwhOpenId = "";
|
|
|
- if (wxRelatiions != null && !wxRelatiions.isEmpty()) {
|
|
|
- fwhOpenId = wxRelatiions.get(0).getFwhopenid();
|
|
|
- }
|
|
|
- System.out.println("发送微信公众号信息:devName=" + dev.getDev_name() + ", phoneNo=" + phoneNo + "fwhOpenId=" + fwhOpenId);
|
|
|
- wxSendMessage.queryAccessToken(dev.getDev_name(), phoneNo, fwhOpenId);
|
|
|
}
|
|
|
// 被分享者openid
|
|
|
// List<ShareVO> shares = baseDAO.queryAllByCondition(ShareVO.class, " and dev_id ='"+dev_id+"' ", null);
|
|
|
@@ -264,7 +253,21 @@ public class MqttUtil {
|
|
|
for (int i = 0; i < users.size(); i++) {
|
|
|
MiniUserVO user = users.get(i);
|
|
|
// 发送跌倒短信
|
|
|
+ System.out.println("mqttutil--开始发送跌倒消息");
|
|
|
MsgUtil.sendNotifyMsg(user.getPhone(), dev_name.toString());
|
|
|
+ log.info("mqttutil--sendmsg:phone{}, dev_name:{}", user.getPhone(), dev_name.toString());
|
|
|
+
|
|
|
+ System.out.println("mqttUtil--消息发完了");
|
|
|
+ List<WxRelatiion> wxRelatiions = baseDAO.queryAllByConditionNocare(WxRelatiion.class, "and openid = '" + user.getOpenid() + "'", null);
|
|
|
+ String fwhOpenId = "";
|
|
|
+ if (wxRelatiions != null && !wxRelatiions.isEmpty()) {
|
|
|
+ fwhOpenId = wxRelatiions.get(0).getFwhopenid();
|
|
|
+ }
|
|
|
+ System.out.println("mqttutil--当前useropenid=" + user.getOpenid() +", fwhopenId=" + fwhOpenId);
|
|
|
+ System.out.println("发送微信公众号信息:devName=" + dev_name.toString() + ", phoneNo=" + user.getPhone() + "fwhOpenId=" + fwhOpenId);
|
|
|
+// log.info("mqttutil--发送微信公众号信息:devName=" + dev.getDev_name() + ", phoneNo=" + phoneNo + "fwhOpenId=" + fwhOpenId);
|
|
|
+ wxSendMessage.queryAccessToken(dev_name.toString(), user.getPhone(), fwhOpenId);
|
|
|
+ System.out.println("发送微信公众号消息发完了");
|
|
|
}
|
|
|
|
|
|
}
|