master
lujian 8 years ago
parent 4a563a148f
commit 06d4c3a512

@ -321,11 +321,12 @@ public class RiskBusinessServiceImpl implements RiskBusinessService, ManagerTodo
logger.debug("sendRiskAppMessage-" + client.getString("client_moniker") + "-" + "risk_id:"+event.getString("risk_id")); logger.debug("sendRiskAppMessage-" + client.getString("client_moniker") + "-" + "risk_id:"+event.getString("risk_id"));
List<JSONObject> tokens = clientDeviceTokenMapper.listTokensByClient_id(client.getIntValue("client_id")); List<JSONObject> tokens = clientDeviceTokenMapper.listTokensByClient_id(client.getIntValue("client_id"));
for (JSONObject devToken : tokens) { for (JSONObject devToken : tokens) {
Runnable task = () -> {
String token = devToken.getString("token"); String token = devToken.getString("token");
if (token == null) { if (token == null || devToken.getString("client_type") == null) {
continue; return;
} }
JSONObject log = saveAppMessageLog(devToken.getString("dev_id"), devToken.getIntValue("client_id"), "risk", token, JSONObject log = saveAppMessageLog(devToken.getString("dev_id"), devToken.getIntValue("client_id"), "risk" + devToken.getString("client_type"), token,
event.getString("risk_id")); event.getString("risk_id"));
try { try {
JSONObject type = new JSONObject(); JSONObject type = new JSONObject();
@ -335,15 +336,15 @@ public class RiskBusinessServiceImpl implements RiskBusinessService, ManagerTodo
// LocaleSupport.localeMessage("app.message.title.risk"), LocaleSupport.localeMessage("app.message.body.risk"), // LocaleSupport.localeMessage("app.message.title.risk"), LocaleSupport.localeMessage("app.message.body.risk"),
// token, event, type); // token, event, type);
AppMsgSender sender = senderMap.get(devToken.getString("client_type")); AppMsgSender sender = senderMap.get(devToken.getString("client_type"));
if (token == null || sender == null) { if (StringUtils.isBlank(token) || sender == null) {
continue; return;
} }
JSONObject managerMsg = new JSONObject(); JSONObject managerMsg = new JSONObject();
managerMsg.put("title", LocaleSupport.localeMessage("app.message.title.risk")); managerMsg.put("title", LocaleSupport.localeMessage("app.message.title.risk"));
managerMsg.put("body", managerMsg.put("body",
LocaleSupport.localeMessage("app.message.body.risk")); LocaleSupport.localeMessage("app.message.body.risk"));
managerMsg.put("type", type); managerMsg.put("type", type);
managerMsg.put("data", event); managerMsg.put("data", new JSONObject());
managerMsg.put("msgType", "risk"); managerMsg.put("msgType", "risk");
AppMessage appMessage = new AppManagerMessageBuilder(managerMsg).buildMessage(); AppMessage appMessage = new AppManagerMessageBuilder(managerMsg).buildMessage();
sender.sendMessage(appMessage, devToken); sender.sendMessage(appMessage, devToken);
@ -354,6 +355,8 @@ public class RiskBusinessServiceImpl implements RiskBusinessService, ManagerTodo
appMessageLogMapper.updateStatus(log.getString("send_id"), 1, e.getMessage()); appMessageLogMapper.updateStatus(log.getString("send_id"), 1, e.getMessage());
throw new ServerErrorException("Send App " + devToken.getString("client_type") + " Failed" + ",token" + token, e); throw new ServerErrorException("Send App " + devToken.getString("client_type") + " Failed" + ",token" + token, e);
} }
};
sendingAppleMsgPool.execute(task);
} }
} }

Loading…
Cancel
Save