|
@@ -1551,61 +1551,67 @@ public class ImGroupServiceImpl extends BaseServiceImpl<String, ImGroup> impleme
|
|
|
public void imToTencent(List<HistoryMessage> list) {
|
|
|
|
|
|
for (HistoryMessage historyMessage : list) {
|
|
|
- HistoryMessageTencent tencent = new HistoryMessageTencent();
|
|
|
- tencent.setId(historyMessage.getMsgUID());
|
|
|
- // 时间
|
|
|
- String dateTime = historyMessage.getDateTime();
|
|
|
- LocalDateTime ldt = LocalDateTime.parse(dateTime, DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.SSS"));
|
|
|
- // yyyyMMddHH
|
|
|
- String date = ldt.format(DateTimeFormatter.ofPattern("yyyyMMddHH"));
|
|
|
- tencent.setMsgTime(Long.parseLong(date));
|
|
|
-
|
|
|
- List<TencentRequest.MessageBody> bodyList = new ArrayList<>();
|
|
|
- JSONObject jsonObject = JSONObject.parseObject(historyMessage.getContent());
|
|
|
- // 类型
|
|
|
- if (historyMessage.getTargetType() == 1) {
|
|
|
- tencent.setChatType("C2C");
|
|
|
- tencent.setToAccount(historyMessage.getTargetId());
|
|
|
- bodyList = getPrivateMessge(historyMessage,jsonObject);
|
|
|
- } else if (historyMessage.getTargetType() == 3) {
|
|
|
- tencent.setChatType("GROUP");
|
|
|
- tencent.setGroupId(historyMessage.getGroupId());
|
|
|
- bodyList = getGroupMessage(historyMessage,jsonObject);
|
|
|
- } else {
|
|
|
+ try {
|
|
|
+ HistoryMessageTencent tencent = new HistoryMessageTencent();
|
|
|
+ tencent.setId(historyMessage.getMsgUID());
|
|
|
+ // 时间
|
|
|
+ String dateTime = historyMessage.getDateTime();
|
|
|
+ LocalDateTime ldt = LocalDateTime.parse(dateTime, DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.SSS"));
|
|
|
+ // yyyyMMddHH
|
|
|
+ String date = ldt.format(DateTimeFormatter.ofPattern("yyyyMMddHH"));
|
|
|
+ tencent.setMsgTime(Long.parseLong(date));
|
|
|
+
|
|
|
+ List<TencentRequest.MessageBody> bodyList = new ArrayList<>();
|
|
|
+ JSONObject jsonObject = JSONObject.parseObject(historyMessage.getContent());
|
|
|
+ // 类型
|
|
|
+ if (historyMessage.getTargetType() == 1) {
|
|
|
+ tencent.setChatType("C2C");
|
|
|
+ tencent.setToAccount(historyMessage.getTargetId());
|
|
|
+ bodyList = getPrivateMessge(historyMessage,jsonObject);
|
|
|
+ } else if (historyMessage.getTargetType() == 3) {
|
|
|
+ tencent.setChatType("GROUP");
|
|
|
+ tencent.setGroupId(historyMessage.getGroupId());
|
|
|
+ bodyList = getGroupMessage(historyMessage,jsonObject);
|
|
|
+ } else {
|
|
|
+
|
|
|
+ historyMessage.setSyncFlag(1);
|
|
|
+ historyMessageService.updateSyncFlag(historyMessage.getMsgUID(),1);
|
|
|
+ continue;
|
|
|
+ }
|
|
|
|
|
|
- historyMessage.setSyncFlag(1);
|
|
|
- historyMessageService.updateSyncFlag(historyMessage.getMsgUID(),1);
|
|
|
- continue;
|
|
|
- }
|
|
|
+ if (CollectionUtils.isEmpty(bodyList)) {
|
|
|
+
|
|
|
+ historyMessage.setSyncFlag(1);
|
|
|
+ historyMessageService.updateSyncFlag(historyMessage.getMsgUID(),1);
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ bodyList = bodyList.stream().filter(Objects::nonNull).collect(Collectors.toList());
|
|
|
+ if (CollectionUtils.isEmpty(bodyList)) {
|
|
|
+ historyMessage.setSyncFlag(1);
|
|
|
+ historyMessageService.updateSyncFlag(historyMessage.getMsgUID(),1);
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ // 发送人
|
|
|
+ tencent.setFromAccount(historyMessage.getFromUserId());
|
|
|
+ //类型
|
|
|
+ tencent.setAppService("MEC");
|
|
|
+ tencent.setMsgFromPlatform(historyMessage.getSource());
|
|
|
+ tencent.setMsgTimestamp(ldt.toInstant(ZoneId.systemDefault().getRules().getOffset(ldt)).toEpochMilli()/1000);
|
|
|
|
|
|
- if (CollectionUtils.isEmpty(bodyList)) {
|
|
|
+ // 消息转换
|
|
|
+ tencent.setCloudCustomData(jsonObject.getString("extra"));
|
|
|
+ tencent.setMsgBody(JSON.toJSONString(bodyList));
|
|
|
+ tencent.setMsgBodyJson(JSON.parseObject(tencent.getMsgBody(), JSONArray.class));
|
|
|
+
|
|
|
+ historyMessageTencentService.insert(tencent);
|
|
|
|
|
|
historyMessage.setSyncFlag(1);
|
|
|
historyMessageService.updateSyncFlag(historyMessage.getMsgUID(),1);
|
|
|
- continue;
|
|
|
- }
|
|
|
- bodyList = bodyList.stream().filter(Objects::nonNull).collect(Collectors.toList());
|
|
|
- if (CollectionUtils.isEmpty(bodyList)) {
|
|
|
- historyMessage.setSyncFlag(1);
|
|
|
+ } catch (Exception e) {
|
|
|
+ historyMessage.setSyncFlag(2);
|
|
|
historyMessageService.updateSyncFlag(historyMessage.getMsgUID(),1);
|
|
|
- continue;
|
|
|
}
|
|
|
- // 发送人
|
|
|
- tencent.setFromAccount(historyMessage.getFromUserId());
|
|
|
- //类型
|
|
|
- tencent.setAppService("MEC");
|
|
|
- tencent.setMsgFromPlatform(historyMessage.getSource());
|
|
|
- tencent.setMsgTimestamp(ldt.toInstant(ZoneId.systemDefault().getRules().getOffset(ldt)).toEpochMilli()/1000);
|
|
|
-
|
|
|
- // 消息转换
|
|
|
- tencent.setCloudCustomData(jsonObject.getString("extra"));
|
|
|
- tencent.setMsgBody(JSON.toJSONString(bodyList));
|
|
|
- tencent.setMsgBodyJson(JSON.parseObject(tencent.getMsgBody(), JSONArray.class));
|
|
|
-
|
|
|
- historyMessageTencentService.insert(tencent);
|
|
|
-
|
|
|
- historyMessage.setSyncFlag(1);
|
|
|
- historyMessageService.updateSyncFlag(historyMessage.getMsgUID(),1);
|
|
|
+
|
|
|
}
|
|
|
|
|
|
}
|