|
|
@@ -148,26 +148,8 @@ public class ConversationContentServiceImpl implements ConversationContentServic
|
|
|
InputChatMsg chatMsg = new InputChatMsg(jsonObject);
|
|
|
ChatMsg chatMsg1 = chatMsgMapper.selectByMsgId(chatMsg.getMsgid());
|
|
|
if (chatMsg1 == null){
|
|
|
- if(!msgtype.equals("text")){
|
|
|
- if (msgtype.equals("mixed")){
|
|
|
- System.out.println(jsonObject);
|
|
|
- com.alibaba.fastjson.JSONArray mixed = jsonObject.getJSONArray("mixed");
|
|
|
- for (int j = 0; j < mixed.size(); j++) {
|
|
|
- com.alibaba.fastjson.JSONObject e = mixed.getJSONObject(j);
|
|
|
- if (e.getString("msgtype").equals("text")){
|
|
|
- String content = pushFileUrl(sdk,e.getString("msgtype"),e);
|
|
|
- chatMsg.setContent(content);
|
|
|
- }else {
|
|
|
- String url = pushFileUrl(sdk,e.getString("msgtype"),e);
|
|
|
- chatMsg.setMsgurl(url);
|
|
|
- }
|
|
|
- }
|
|
|
- }else {
|
|
|
- String url=pushFileUrl(sdk,msgtype,jsonObject);
|
|
|
- chatMsg.setMsgurl(url);
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
+ //处理数据
|
|
|
+ pushSmgType(msgtype, jsonObject, sdk, chatMsg);
|
|
|
list.add(chatMsg);
|
|
|
}
|
|
|
} catch (Exception e) {
|
|
|
@@ -184,6 +166,46 @@ public class ConversationContentServiceImpl implements ConversationContentServic
|
|
|
return map;
|
|
|
}
|
|
|
|
|
|
+ private void pushSmgType(String msgtype, com.alibaba.fastjson.JSONObject jsonObject, long sdk, InputChatMsg chatMsg) {
|
|
|
+ if (msgtype.equals("text")) {
|
|
|
+ com.alibaba.fastjson.JSONObject text = jsonObject.getJSONObject("text");
|
|
|
+ if (text!=null){
|
|
|
+ String content1 = text.getString("content");
|
|
|
+ try {
|
|
|
+ String osname = System.getProperties().getProperty("os.name");
|
|
|
+ if (osname.contains("Windows")) {
|
|
|
+ String result = new String(content1.getBytes("GBK"),"UTF-8");
|
|
|
+ chatMsg.setContent(result);
|
|
|
+ }else{
|
|
|
+ chatMsg.setContent(content1);
|
|
|
+ }
|
|
|
+ } catch (UnsupportedEncodingException e) {
|
|
|
+ throw new RuntimeException(e);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }else if (msgtype.equals("mixed")){
|
|
|
+ System.out.println(jsonObject);
|
|
|
+ com.alibaba.fastjson.JSONArray mixed = jsonObject.getJSONArray("mixed");
|
|
|
+ for (int j = 0; j < mixed.size(); j++) {
|
|
|
+ com.alibaba.fastjson.JSONObject e = mixed.getJSONObject(j);
|
|
|
+ if (e.getString("msgtype").equals("text")){
|
|
|
+ String content = pushFileUrl(sdk,e.getString("msgtype"),e);
|
|
|
+ chatMsg.setContent(content);
|
|
|
+ }else {
|
|
|
+ String url = pushFileUrl(sdk,e.getString("msgtype"),e);
|
|
|
+ chatMsg.setMsgurl(url);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else if (msgtype.equals("sphfeed")) {
|
|
|
+ chatMsg.setContent(jsonObject.getString("sphfeed"));
|
|
|
+ } else if (msgtype.equals("file")||msgtype.equals("image")||msgtype.equals("video")){
|
|
|
+ String url=pushFileUrl(sdk, msgtype, jsonObject);
|
|
|
+ chatMsg.setMsgurl(url);
|
|
|
+ } else {
|
|
|
+ chatMsg.setContent(jsonObject.toJSONString());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
private String pushFileUrl(long sdk, String msgtype, com.alibaba.fastjson.JSONObject jsonObject) {
|
|
|
String url = uploadPath;
|
|
|
String sdkfileid=null;
|
|
|
@@ -368,9 +390,10 @@ public class ConversationContentServiceImpl implements ConversationContentServic
|
|
|
}else {
|
|
|
String msgIdSub = userId.substring(0, 2);
|
|
|
String url=null;
|
|
|
- Integer type=0;
|
|
|
+ Integer type;
|
|
|
if (msgIdSub.equals("wb")){
|
|
|
- url=String.format("https://qyapi.weixin.qq.com/cgi-bin/msgaudit/get_robot_info??access_token=%s&robot_id=%s",getAppAccessToken(),userId);
|
|
|
+ type=0;
|
|
|
+// url=String.format("https://qyapi.weixin.qq.com/cgi-bin/msgaudit/get_robot_info??access_token=%s&robot_id=%s",getAppAccessToken(),userId);
|
|
|
}else if (msgIdSub.equals("wo")||msgIdSub.equals("wm")){
|
|
|
// https://qyapi.weixin.qq.com/cgi-bin/externalcontact/get
|
|
|
url=String.format("https://qyapi.weixin.qq.com/cgi-bin/externalcontact/get?access_token=%s&external_userid=%s",getAppAccessToken(),userId);
|
|
|
@@ -435,7 +458,7 @@ public class ConversationContentServiceImpl implements ConversationContentServic
|
|
|
}
|
|
|
if (jsonObject.getInteger("errcode")==0){
|
|
|
}else {
|
|
|
- System.out.println("获取外部群名称失败");
|
|
|
+ System.out.println("获取外部群名称失败"+jsonObject.getString("errcode"));
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
@@ -453,7 +476,7 @@ public class ConversationContentServiceImpl implements ConversationContentServic
|
|
|
}
|
|
|
if (jsonObject.getInteger("errcode")==0){
|
|
|
}else {
|
|
|
- System.out.println("获取内部群名称失败");
|
|
|
+ System.out.println("获取内部群名称失败"+jsonObject.getString("errcode"));
|
|
|
}
|
|
|
|
|
|
}
|