|
|
@@ -1,8 +1,10 @@
|
|
|
package com.kede.wechat.service.impl;
|
|
|
|
|
|
import com.kede.common.dao.ChatMsgMapper;
|
|
|
+import com.kede.common.dao.ChatMsgOptimizeMapper;
|
|
|
import com.kede.common.enums.WechatSmgTypeEnum;
|
|
|
import com.kede.common.model.ChatMsg;
|
|
|
+import com.kede.common.model.ChatMsgOptimize;
|
|
|
import com.kede.common.model.ChatMsgUser;
|
|
|
import com.kede.common.utils.DateUtils;
|
|
|
import com.kede.common.utils.HttpUtils;
|
|
|
@@ -36,29 +38,6 @@ import static sun.plugin2.os.windows.OSVERSIONINFOA.size;
|
|
|
@Service("ConversationContentService")
|
|
|
public class ConversationContentServiceImpl extends BaseMybatisDao<ChatMsgUserMapper> implements ConversationContentService {
|
|
|
|
|
|
- Logger logger = LoggerFactory.getLogger(ConversationContentServiceImpl.class);
|
|
|
- @Resource
|
|
|
- private RedisTemplate redisTemplate;
|
|
|
- @Resource
|
|
|
- private ChatMsgUserMapper chatMsgUserMapper;
|
|
|
- @Resource
|
|
|
- private ChatMsgMapper chatMsgMapper;
|
|
|
-
|
|
|
-
|
|
|
- @Value(value = "${conversationContent.corpid}")
|
|
|
- private String corpid;
|
|
|
- @Value(value = "${conversationContent.secret}")
|
|
|
- private String secret;
|
|
|
-
|
|
|
- @Value(value = "${conversationContent.app.secret}")
|
|
|
- private String appSecret;
|
|
|
- @Value(value = "${conversationContent.addressBook.secret}")
|
|
|
- private String addressBookSecret;
|
|
|
- @Value(value = "${upload.path}")
|
|
|
- private String uploadPath;
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
static String priKey ="-----BEGIN PRIVATE KEY-----\n" +
|
|
|
"MIIEvAIBADANBgkqhkiG9w0BAQEFAASCBKYwggSiAgEAAoIBAQCnh5N/kiyeNx/y\n" +
|
|
|
"dDKe3FO8HWj8tuQQUCkCc8ol1Sqmcs9ey7S2189UDbZOPeY2xiiMD6AdFVUK5Y0P\n" +
|
|
|
@@ -96,6 +75,33 @@ public class ConversationContentServiceImpl extends BaseMybatisDao<ChatMsgUserMa
|
|
|
"/DxihQOhdMEmozS3Ooj4OZoIjkuY9NjdvpxDfJu7yHS+x3dMq4oH+ZBHZcfTwuzm\n" +
|
|
|
"KQIDAQAB\n" +
|
|
|
"-----END PUBLIC KEY-----";
|
|
|
+
|
|
|
+ Logger logger = LoggerFactory.getLogger(ConversationContentServiceImpl.class);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ @Value(value = "${conversationContent.corpid}")
|
|
|
+ private String corpid;
|
|
|
+ @Value(value = "${conversationContent.secret}")
|
|
|
+ private String secret;
|
|
|
+
|
|
|
+ @Value(value = "${conversationContent.app.secret}")
|
|
|
+ private String appSecret;
|
|
|
+ @Value(value = "${conversationContent.addressBook.secret}")
|
|
|
+ private String addressBookSecret;
|
|
|
+ @Value(value = "${upload.path}")
|
|
|
+ private String uploadPath;
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private RedisTemplate redisTemplate;
|
|
|
+ @Resource
|
|
|
+ private ChatMsgUserMapper chatMsgUserMapper;
|
|
|
+ @Resource
|
|
|
+ private ChatMsgMapper chatMsgMapper;
|
|
|
+ @Resource
|
|
|
+ private ChatMsgOptimizeMapper chatMsgOptimizeMapper;
|
|
|
+
|
|
|
+
|
|
|
@Override
|
|
|
public Map<String,Object> getChatData(Integer pageSeq, Integer pageLimit) {
|
|
|
String message = null;
|
|
|
@@ -122,6 +128,8 @@ public class ConversationContentServiceImpl extends BaseMybatisDao<ChatMsgUserMa
|
|
|
JSONArray chatdata = jo.getJSONArray("chatdata");
|
|
|
total=chatdata.length();
|
|
|
System.out.println("消息数:" + total);
|
|
|
+ Date earlyToday = DateUtils.getEarlyToday();
|
|
|
+ Date date = DateUtils.getDateBefore(earlyToday, -1);
|
|
|
for (int i = 0; i < chatdata.length(); i++) {
|
|
|
String item = chatdata.get(i).toString();
|
|
|
// item:{
|
|
|
@@ -151,13 +159,17 @@ public class ConversationContentServiceImpl extends BaseMybatisDao<ChatMsgUserMa
|
|
|
String str = String.valueOf(Finance.GetContentFromSlice(msg));
|
|
|
com.alibaba.fastjson.JSONObject jsonObject = com.alibaba.fastjson.JSONObject.parseObject(str);
|
|
|
String msgtype = jsonObject.getString("msgtype");
|
|
|
- Date earlyToday = DateUtils.getEarlyToday();
|
|
|
- Date date = DateUtils.getDateBefore(earlyToday, -1);
|
|
|
InputChatMsg chatMsg = new InputChatMsg(jsonObject);
|
|
|
if (chatMsg.getMsgtime().getTime()>date.getTime()){
|
|
|
//处理数据
|
|
|
- pushSmgType(msgtype, jsonObject, sdk, chatMsg);
|
|
|
- list.add(chatMsg);
|
|
|
+ ChatMsgOptimize chatMsgOptimize = chatMsgOptimizeMapper.selectById(chatMsg.getMsgid());
|
|
|
+ if (chatMsgOptimize==null){
|
|
|
+ chatMsgOptimize = new ChatMsgOptimize();
|
|
|
+ chatMsgOptimize.setMsgid(chatMsg.getMsgid());
|
|
|
+ chatMsgOptimize.setMsgtime(chatMsg.getMsgtime());
|
|
|
+ pushSmgType(msgtype, jsonObject, sdk, chatMsg);
|
|
|
+ list.add(chatMsg);
|
|
|
+ }
|
|
|
}
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
@@ -168,6 +180,7 @@ public class ConversationContentServiceImpl extends BaseMybatisDao<ChatMsgUserMa
|
|
|
|
|
|
}
|
|
|
Finance.FreeSlice(slice);
|
|
|
+ chatMsgOptimizeMapper.deleteFromTime(date);
|
|
|
map.put("list",list);
|
|
|
map.put("total",total);
|
|
|
return map;
|