1.已经存好了一个List ,需要把另一个list的值更新到一个已经存好数据的list,这里可以通过会员编号,两个list 都有这个值,然后进行筛选,匹配,更新数据。
nr = pushService.pushGzMsg(pushGzMsgParams);
System.out.println("nr>1:推送后的结果" + nr);
resp.put("NotifyResponse", nr);
if (nr == null || nr.getData() == null) {
resp.put("status", false);
return resp;
}
List<Map> dataList = (List<Map>) nr.getData();
// if (dataList == null || dataList.size() < 1) {
// resp.put("status", false);
// return resp;
// }
// if "info=true" key=uid else key=openid
System.out.println("nr.getData():" + nr.getData());
// nr.getData():[{openid=oWM7djr08tyULLyJyFvAg5Ta26t8, status=ok}, {openid=oWM7djiCudmvYrgnSZxc8LidHxoY, status=ok}]
// List<GzStstus> resultList = new ArrayList<GzStstus>();
String memberKeyString = null;
for (Map m : dataList) {
java.util.Optional<String> memberKeyOptional = lstPplString.stream()
.filter(e -> e.containsKey("openId") && m.containsKey("uid") && e.get("openId") != null && e.get("openId").equalsIgnoreCase(m.get("uid").toString())).map(e -> String.format("%s", e.get("memberKey")))
.findAny();
memberKeyString = memberKeyOptional.isPresent() ? memberKeyOptional.get() : null;
if (memberKeyString != null) {
final String memberKey = memberKeyString;
java.util.Optional<NotifySettingRecord> recordOptional = paramsGzRecordList.stream().filter(e -> e.getMemberKey() != null && Long.toString(e.getMemberKey()).equalsIgnoreCase(memberKey)).findAny();
if (recordOptional.isPresent()) {
String realStatuString = "";
String realReasonString = "";
String statusString = m.get("status").toString();
if (statusString.equalsIgnoreCase("ok")) {
realStatuString = "推送成功";
realTotal = realTotal + 1;
System.out.println("realTotal:" + realTotal);
}
else {
realStatuString = "推送失败";
if (statusString.contains("invalid appid")) {
realReasonString = "无效appid";
}
else if (statusString.contains("invalid openid")) {
realReasonString = "无效openid";
}
else if (statusString.contains("user refuse")) {
realReasonString = "用户拒绝接收";
}
else if (statusString.contains("require subscribe rid")) {
realReasonString = "未订阅";
}
else if (statusString.contains("access_token expired")) {
realReasonString = "token过期";
}
else if (statusString.contains("invalid weapp pagepath ")) {
realReasonString = "无效的跳转路径";
}
}
recordOptional.get().setStatus(m.containsKey("status") ? realStatuString : "unknow");
recordOptional.get().setReason(m.containsKey("status") ? realReasonString : "");
}
}
// status.setOpenid(m.containsKey("openid") ? m.get("openid").toString() : "");
// status.setStatus(m.containsKey("status") ? m.get("status").toString() : "");
// resultList.add(status);
}
}
addRecords(paramsGzRecordList);
log.getLogger("notify_s").info("notify.updateRecords.>1:({},{}):{}", adminInfo.getCurrent_empId(), pushGzMsgParams);
}