Commit 40c8c327 by Lee Munkyeong

メッセージ取得修正。

parent f1076f09
...@@ -146,6 +146,7 @@ public interface ABookCommConstants { ...@@ -146,6 +146,7 @@ public interface ABookCommConstants {
interface SIZE { interface SIZE {
Integer MAX_FAVORITE_COUNT = 100; Integer MAX_FAVORITE_COUNT = 100;
Integer MESSAGE_PAGING_SIZE = 20;
} }
String FILE_SAVE_PATH = "/data/user/0/jp.co.agentec.abookplus.check/files/"; String FILE_SAVE_PATH = "/data/user/0/jp.co.agentec.abookplus.check/files/";
......
...@@ -3,6 +3,7 @@ package jp.agentec.abook.abv.bl.data.dao; ...@@ -3,6 +3,7 @@ package jp.agentec.abook.abv.bl.data.dao;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import jp.agentec.abook.abv.bl.common.constant.ABookCommConstants;
import jp.agentec.abook.abv.bl.common.db.Cursor; import jp.agentec.abook.abv.bl.common.db.Cursor;
import jp.agentec.abook.abv.bl.common.log.Logger; import jp.agentec.abook.abv.bl.common.log.Logger;
import jp.agentec.abook.abv.bl.dto.ChatMessageDto; import jp.agentec.abook.abv.bl.dto.ChatMessageDto;
...@@ -107,10 +108,41 @@ public class ChatMessageDao extends AbstractCommunicationDao { ...@@ -107,10 +108,41 @@ public class ChatMessageDao extends AbstractCommunicationDao {
sql.append(" ON cm.shop_member_id = sm.shop_member_id "); sql.append(" ON cm.shop_member_id = sm.shop_member_id ");
sql.append(" WHERE cm.chat_room_id = ? "); sql.append(" WHERE cm.chat_room_id = ? ");
sql.append(" ORDER BY cm.insert_date DESC "); sql.append(" ORDER BY cm.insert_date DESC ");
sql.append(" LIMIT " + ABookCommConstants.SIZE.MESSAGE_PAGING_SIZE);
List<ChatMessageDto> list = rawQueryGetDtoList(sql.toString(), new String[]{""+ chatRoomId}, ChatMessageDto.class); List<ChatMessageDto> list = rawQueryGetDtoList(sql.toString(), new String[]{""+ chatRoomId}, ChatMessageDto.class);
return list; return list;
} }
public List<ChatMessageDto> getChatMessageFromMessageId(int chatRoomId, String MessageId) {
StringBuffer sql = new StringBuffer();
sql.append(" SELECT ");
sql.append(" cm.chat_message_id ");
sql.append(" ,cm.chat_room_id ");
sql.append(" ,cm.shop_member_id ");
sql.append(" ,cm.login_id ");
sql.append(" ,cm.message ");
sql.append(" ,cm.message_type ");
sql.append(" ,cm.image_name ");
sql.append(" ,cm.download_file_name ");
sql.append(" ,cm.save_path ");
sql.append(" ,cm.insert_date ");
sql.append(" ,sm.shop_member_name ");
sql.append(" ,sm.profile_url ");
sql.append(" ,sm.self_flg ");
sql.append(" ,cm.unread_count ");
sql.append(" FROM ");
sql.append(" t_chat_message AS cm ");
sql.append(" INNER JOIN ");
sql.append(" m_shop_member AS sm ");
sql.append(" ON cm.shop_member_id = sm.shop_member_id ");
sql.append(" WHERE cm.chat_room_id = ? ");
sql.append(" AND cm.chat_message_id < ? ");
sql.append(" ORDER BY cm.insert_date DESC ");
sql.append(" LIMIT " + ABookCommConstants.SIZE.MESSAGE_PAGING_SIZE);
List<ChatMessageDto> list = rawQueryGetDtoList(sql.toString(), new String[]{"" + chatRoomId, "" + MessageId}, ChatMessageDto.class);
return list;
}
public List<ChatMessageDto> searchChatMessage(int chatRoomId, String[] keywords, String userList) { public List<ChatMessageDto> searchChatMessage(int chatRoomId, String[] keywords, String userList) {
StringBuffer sql = new StringBuffer(); StringBuffer sql = new StringBuffer();
sql.append(" SELECT "); sql.append(" SELECT ");
......
...@@ -127,6 +127,35 @@ public class CommunicationLogic extends AbstractLogic { ...@@ -127,6 +127,35 @@ public class CommunicationLogic extends AbstractLogic {
Map<String, Object> chatMessageMap = new HashMap<String, Object>(); Map<String, Object> chatMessageMap = new HashMap<String, Object>();
chatMessageMap.put(ABookCommConstants.KEY.CHAT_ROOM_ID, chatMessageDto.chatRoomId); chatMessageMap.put(ABookCommConstants.KEY.CHAT_ROOM_ID, chatMessageDto.chatRoomId);
chatMessageMap.put(ABookCommConstants.KEY.LOGIN_ID, chatMessageDto.shopMemberName); chatMessageMap.put(ABookCommConstants.KEY.LOGIN_ID, chatMessageDto.shopMemberName);
chatMessageMap.put(ABookCommConstants.KEY.MESSAGE_ID, chatMessageDto.chatMessageId);
chatMessageMap.put(ABookCommConstants.KEY.SHOP_MEMBER_ID, chatMessageDto.shopMemberId);
if (ABookCommConstants.FLAG.MESSAGE_TYPE.PHOTO.equals(chatMessageDto.messageType) || ABookCommConstants.FLAG.MESSAGE_TYPE.VIDEO.equals(chatMessageDto.messageType)) {
chatMessageMap.put(ABookCommConstants.KEY.MESSAGE, getFileUrlPath(chatMessageDto.message));
} else {
chatMessageMap.put(ABookCommConstants.KEY.MESSAGE, chatMessageDto.message);
}
chatMessageMap.put(ABookCommConstants.KEY.MESSAGE_TYPE, chatMessageDto.messageType);
chatMessageMap.put(ABookCommConstants.KEY.INSERT_DATE, chatMessageDto.insertDate);
chatMessageMap.put(ABookCommConstants.KEY.PROFILE_URL, getProfileUrlPath(chatMessageDto.profileUrl));
chatMessageMap.put(ABookCommConstants.KEY.SELF_FLG, chatMessageDto.selfFlg);
chatMessageMap.put(ABookCommConstants.KEY.UNREAD_COUNT, chatMessageDto.unreadCount);
JSONObject jsonObject = new JSONObject(chatMessageMap);
resultJsonArray.put(jsonObject);
}
String messageListStr = resultJsonArray.toString();
return messageListStr;
}
public String getMessagesFromMessageId(Integer roomId, String messageId) {
List<ChatMessageDto> chatMessageDtoList = chatMessageDao.getChatMessageFromMessageId(roomId, messageId);
JSONArray resultJsonArray = new JSONArray();
for (ChatMessageDto chatMessageDto : chatMessageDtoList) {
Map<String, Object> chatMessageMap = new HashMap<String, Object>();
chatMessageMap.put(ABookCommConstants.KEY.CHAT_ROOM_ID, chatMessageDto.chatRoomId);
chatMessageMap.put(ABookCommConstants.KEY.LOGIN_ID, chatMessageDto.shopMemberName);
chatMessageMap.put(ABookCommConstants.KEY.MESSAGE_ID, chatMessageDto.chatMessageId);
chatMessageMap.put(ABookCommConstants.KEY.SHOP_MEMBER_ID, chatMessageDto.shopMemberId); chatMessageMap.put(ABookCommConstants.KEY.SHOP_MEMBER_ID, chatMessageDto.shopMemberId);
if (ABookCommConstants.FLAG.MESSAGE_TYPE.PHOTO.equals(chatMessageDto.messageType) || ABookCommConstants.FLAG.MESSAGE_TYPE.VIDEO.equals(chatMessageDto.messageType)) { if (ABookCommConstants.FLAG.MESSAGE_TYPE.PHOTO.equals(chatMessageDto.messageType) || ABookCommConstants.FLAG.MESSAGE_TYPE.VIDEO.equals(chatMessageDto.messageType)) {
chatMessageMap.put(ABookCommConstants.KEY.MESSAGE, getFileUrlPath(chatMessageDto.message)); chatMessageMap.put(ABookCommConstants.KEY.MESSAGE, getFileUrlPath(chatMessageDto.message));
......
...@@ -1672,6 +1672,23 @@ public class ChatWebViewActivity extends CommunicationWebViewActivity { ...@@ -1672,6 +1672,23 @@ public class ChatWebViewActivity extends CommunicationWebViewActivity {
public void finishPip() { public void finishPip() {
finishPIPmode(); finishPIPmode();
} }
@JavascriptInterface
public void updatePreMessage(String messageId) throws NetworkDisconnectedException, AcmsException {
if (messageId.equals("0")) {
return;
}
updateMessageFromMessageId(messageId);
}
@JavascriptInterface
public String getMessageListFromMessageId(String messageId) {
if (messageId.equals("0")) {
return "";
}
String messageListStr = communicationLogic.getMessagesFromMessageId(roomId.intValue(), messageId);
return messageListStr;
}
} }
/** /**
...@@ -1995,4 +2012,14 @@ public class ChatWebViewActivity extends CommunicationWebViewActivity { ...@@ -1995,4 +2012,14 @@ public class ChatWebViewActivity extends CommunicationWebViewActivity {
UnreadCountJSON resultJson = AcmsClient.getInstance(ABVEnvironment.getInstance().networkAdapter).getMessagesUnreadCount(sid, Integer.toString(roomId.intValue())); UnreadCountJSON resultJson = AcmsClient.getInstance(ABVEnvironment.getInstance().networkAdapter).getMessagesUnreadCount(sid, Integer.toString(roomId.intValue()));
communicationLogic.updateUnreadCount(resultJson.chatMessageDtoArrayList); communicationLogic.updateUnreadCount(resultJson.chatMessageDtoArrayList);
} }
public void updateMessageFromMessageId(String messageId) throws NetworkDisconnectedException, AcmsException {
MessageInfoListJSON resultJson = AcmsClient.getInstance(ABVEnvironment.getInstance().networkAdapter).getMessages(sid, Integer.toString(roomId.intValue()), messageId, null);
for (ChatMessageDto chatMessageDto : resultJson.chatMessageDtoArrayList) {
chatMessageDto.chatRoomId = roomId.intValue();
}
communicationLogic.insertMessageList(resultJson.chatMessageDtoArrayList);
communicationLogic.insertShopMember(resultJson.shopMemberDtoArrayList);
updateUnreadCount();
}
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment