master
lujian 6 years ago
parent 4a563a148f
commit 06d4c3a512

@ -321,39 +321,42 @@ public class RiskBusinessServiceImpl implements RiskBusinessService, ManagerTodo
logger.debug("sendRiskAppMessage-" + client.getString("client_moniker") + "-" + "risk_id:"+event.getString("risk_id"));
List<JSONObject> tokens = clientDeviceTokenMapper.listTokensByClient_id(client.getIntValue("client_id"));
for (JSONObject devToken : tokens) {
String token = devToken.getString("token");
if (token == null) {
continue;
}
JSONObject log = saveAppMessageLog(devToken.getString("dev_id"), devToken.getIntValue("client_id"), "risk", token,
event.getString("risk_id"));
try {
JSONObject type = new JSONObject();
type.put("send_type", "risk");
type.put("id", event.getString("risk_id"));
Runnable task = () -> {
String token = devToken.getString("token");
if (token == null || devToken.getString("client_type") == null) {
return;
}
JSONObject log = saveAppMessageLog(devToken.getString("dev_id"), devToken.getIntValue("client_id"), "risk" + devToken.getString("client_type"), token,
event.getString("risk_id"));
try {
JSONObject type = new JSONObject();
type.put("send_type", "risk");
type.put("id", event.getString("risk_id"));
// apnsMessageHelper.sendAppleMessageDetail(
// LocaleSupport.localeMessage("app.message.title.risk"), LocaleSupport.localeMessage("app.message.body.risk"),
// token, event, type);
AppMsgSender sender = senderMap.get(devToken.getString("client_type"));
if (token == null || sender == null) {
continue;
AppMsgSender sender = senderMap.get(devToken.getString("client_type"));
if (StringUtils.isBlank(token) || sender == null) {
return;
}
JSONObject managerMsg = new JSONObject();
managerMsg.put("title", LocaleSupport.localeMessage("app.message.title.risk"));
managerMsg.put("body",
LocaleSupport.localeMessage("app.message.body.risk"));
managerMsg.put("type", type);
managerMsg.put("data", new JSONObject());
managerMsg.put("msgType", "risk");
AppMessage appMessage = new AppManagerMessageBuilder(managerMsg).buildMessage();
sender.sendMessage(appMessage, devToken);
log.put("status", 2);
appMessageLogMapper.update(log);
} catch (Exception e) {
logger.error("出错了:" + e.getMessage());
appMessageLogMapper.updateStatus(log.getString("send_id"), 1, e.getMessage());
throw new ServerErrorException("Send App " + devToken.getString("client_type") + " Failed" + ",token" + token, e);
}
JSONObject managerMsg = new JSONObject();
managerMsg.put("title", LocaleSupport.localeMessage("app.message.title.risk"));
managerMsg.put("body",
LocaleSupport.localeMessage("app.message.body.risk"));
managerMsg.put("type", type);
managerMsg.put("data", event);
managerMsg.put("msgType", "risk");
AppMessage appMessage = new AppManagerMessageBuilder(managerMsg).buildMessage();
sender.sendMessage(appMessage, devToken);
log.put("status", 2);
appMessageLogMapper.update(log);
} catch (Exception e) {
logger.error("出错了:" + e.getMessage());
appMessageLogMapper.updateStatus(log.getString("send_id"), 1, e.getMessage());
throw new ServerErrorException("Send App " + devToken.getString("client_type") + " Failed" + ",token" + token, e);
}
};
sendingAppleMsgPool.execute(task);
}
}

Loading…
Cancel
Save