Commit 8a7b628a by Lee Munkyeong

性能改善

parent f4db91dd
...@@ -597,14 +597,13 @@ public class AcmsClient implements AcmsClientResponseListener { ...@@ -597,14 +597,13 @@ public class AcmsClient implements AcmsClientResponseListener {
* 全てのグループ更新。 * 全てのグループ更新。
* *
* @param sid * @param sid
* @param groupId
* @param updatedDate * @param updatedDate
* @return * @return
* @throws NetworkDisconnectedException * @throws NetworkDisconnectedException
* @throws AcmsException * @throws AcmsException
*/ */
public GroupListJSON getGroupInfo(String sid, String groupId, String updatedDate) throws NetworkDisconnectedException, AcmsException { public GroupListJSON getGroupInfo(String sid, String updatedDate) throws NetworkDisconnectedException, AcmsException {
HttpResponse response = send(AcmsApis.ApigetUser, new GetGroupInfoParameters(sid, AcmsApis.UserCmds.getGroupInfo, groupId, updatedDate)); HttpResponse response = send(AcmsApis.ApigetUser, new GetGroupInfoParameters(sid, AcmsApis.UserCmds.getGroupInfo, updatedDate));
GroupListJSON json = new GroupListJSON(response.httpResponseBody); GroupListJSON json = new GroupListJSON(response.httpResponseBody);
return json; return json;
} }
......
...@@ -15,7 +15,7 @@ public class GroupListJSON extends AcmsCommonJSON { ...@@ -15,7 +15,7 @@ public class GroupListJSON extends AcmsCommonJSON {
public ArrayList<ChatGroupDto> groupList; public ArrayList<ChatGroupDto> groupList;
public String allGroupLastUpdateDate; public String lastRequestDate;
public GroupListJSON(String jsonString) throws AcmsException { public GroupListJSON(String jsonString) throws AcmsException {
super(jsonString); super(jsonString);
...@@ -46,9 +46,6 @@ public class GroupListJSON extends AcmsCommonJSON { ...@@ -46,9 +46,6 @@ public class GroupListJSON extends AcmsCommonJSON {
} }
groupDto.groupName = groupJSON.getString(ABookCommConstants.KEY.GROUP_NAME); groupDto.groupName = groupJSON.getString(ABookCommConstants.KEY.GROUP_NAME);
groupDto.delFlg = groupJSON.getInt(ABookCommConstants.KEY.DEL_FLG); groupDto.delFlg = groupJSON.getInt(ABookCommConstants.KEY.DEL_FLG);
if (groupJSON.has(ABookCommConstants.KEY.GROUP_INFO_LAST_UPDATE_DATE)) {
groupDto.updateDate = groupJSON.getString(ABookCommConstants.KEY.GROUP_INFO_LAST_UPDATE_DATE);
}
if (groupJSON.has(ABookCommConstants.KEY.GROUP_MEMBER_LIST)) { if (groupJSON.has(ABookCommConstants.KEY.GROUP_MEMBER_LIST)) {
JSONArray groupMemberJsonArray = groupJSON.getJSONArray(ABookCommConstants.KEY.GROUP_MEMBER_LIST); JSONArray groupMemberJsonArray = groupJSON.getJSONArray(ABookCommConstants.KEY.GROUP_MEMBER_LIST);
ArrayList<ShopMemberDto> groupMembers = new ArrayList<ShopMemberDto>(); ArrayList<ShopMemberDto> groupMembers = new ArrayList<ShopMemberDto>();
...@@ -62,17 +59,14 @@ public class GroupListJSON extends AcmsCommonJSON { ...@@ -62,17 +59,14 @@ public class GroupListJSON extends AcmsCommonJSON {
if (groupMember.has(ABookCommConstants.KEY.PROFILE_IMAGE_PATH)) { if (groupMember.has(ABookCommConstants.KEY.PROFILE_IMAGE_PATH)) {
shopMemberDto.profileUrl = groupMember.getString(ABookCommConstants.KEY.PROFILE_IMAGE_PATH); shopMemberDto.profileUrl = groupMember.getString(ABookCommConstants.KEY.PROFILE_IMAGE_PATH);
} }
// ArrayList groupIds = new ArrayList();
// groupIds.add(groupDto.groupId);
// shopMemberDto.groupIdList = groupIds;
groupMembers.add(shopMemberDto); groupMembers.add(shopMemberDto);
} }
groupDto.groupMembers = groupMembers; groupDto.groupMembers = groupMembers;
} }
groupList.add(groupDto); groupList.add(groupDto);
} }
if (json.getJSONObject(ABookCommConstants.KEY.BODY).has(ABookCommConstants.KEY.GROUP_INFO_LAST_UPDATE_DATE)) { if (json.getJSONObject(ABookCommConstants.KEY.BODY).has(ABookCommConstants.KEY.LAST_REQUEST_DATE)) {
allGroupLastUpdateDate = json.getJSONObject(ABookCommConstants.KEY.BODY).getString(ABookCommConstants.KEY.GROUP_INFO_LAST_UPDATE_DATE); lastRequestDate = json.getJSONObject(ABookCommConstants.KEY.BODY).getString(ABookCommConstants.KEY.LAST_REQUEST_DATE);
} }
} }
......
...@@ -38,10 +38,9 @@ public class GetGroupInfoParameters extends HttpParameterObject { ...@@ -38,10 +38,9 @@ public class GetGroupInfoParameters extends HttpParameterObject {
this.cmd = cmd; this.cmd = cmd;
} }
public GetGroupInfoParameters(String sid, String cmd, String groupId, String updatedDate) { public GetGroupInfoParameters(String sid, String cmd, String updatedDate) {
this.sid = sid; this.sid = sid;
this.cmd = cmd; this.cmd = cmd;
this.groupIds = groupId;
this.updatedDate = updatedDate; this.updatedDate = updatedDate;
} }
......
...@@ -55,7 +55,7 @@ public interface ABookCommConstants { ...@@ -55,7 +55,7 @@ public interface ABookCommConstants {
String LAST_MESSAGE_INFO = "lastMessageInfo"; String LAST_MESSAGE_INFO = "lastMessageInfo";
String FAVORITE_USER_IDS = "favoriteUserIds"; String FAVORITE_USER_IDS = "favoriteUserIds";
String FAVORITE_GROUP_IDS = "favoriteGroupIds"; String FAVORITE_GROUP_IDS = "favoriteGroupIds";
String GROUP_INFO_LAST_UPDATE_DATE = "groupInfoLastUpdateDate"; String LAST_REQUEST_DATE = "lastRequestDate";
String ARCHIVE_INFO_LIST = "archiveInfoList"; String ARCHIVE_INFO_LIST = "archiveInfoList";
String ARCHIVE_INFO = "archiveInfo"; String ARCHIVE_INFO = "archiveInfo";
...@@ -80,6 +80,8 @@ public interface ABookCommConstants { ...@@ -80,6 +80,8 @@ public interface ABookCommConstants {
String MY_SHOPE_MEMBER_ID = "myShopMemberId"; String MY_SHOPE_MEMBER_ID = "myShopMemberId";
String ROOT_GROUP_ID = "rootGroupId"; String ROOT_GROUP_ID = "rootGroupId";
String GROUP_MEMBER_UPDATED_DATE = "groupMemberUpdatedDate";
String HTTP_STATUS = "httpStatus"; String HTTP_STATUS = "httpStatus";
interface API_KIND { interface API_KIND {
String USER = "user"; String USER = "user";
......
...@@ -283,6 +283,7 @@ public class ChatGroupDao extends AbstractCommunicationDao { ...@@ -283,6 +283,7 @@ public class ChatGroupDao extends AbstractCommunicationDao {
beginTransaction(); beginTransaction();
for (ChatGroupDto groupDto : groupList) { for (ChatGroupDto groupDto : groupList) {
update(sql.toString(), new Object[] { groupDto.groupId }); update(sql.toString(), new Object[] { groupDto.groupId });
update("delete from r_shop_member_group where group_id = ? ", new Object[] { groupDto.groupId });
} }
commit(); commit();
} catch (Exception e) { } catch (Exception e) {
......
...@@ -107,6 +107,7 @@ public class ShopMemberDao extends AbstractCommunicationDao { ...@@ -107,6 +107,7 @@ public class ShopMemberDao extends AbstractCommunicationDao {
public void insertShopMemberGroupRelation(Integer groupId, List<ShopMemberDto> dtoList) { public void insertShopMemberGroupRelation(Integer groupId, List<ShopMemberDto> dtoList) {
try { try {
update("delete from r_shop_member_group where group_id = ? ", new Object[] { groupId });
for (ShopMemberDto dto : dtoList) { for (ShopMemberDto dto : dtoList) {
insert("insert or replace into r_shop_member_group (shop_member_id, group_id) values ("+dto.shopMemberId+",?)", new Integer[]{groupId}); insert("insert or replace into r_shop_member_group (shop_member_id, group_id) values ("+dto.shopMemberId+",?)", new Integer[]{groupId});
} }
......
...@@ -827,8 +827,8 @@ public class CommunicationLogic extends AbstractLogic { ...@@ -827,8 +827,8 @@ public class CommunicationLogic extends AbstractLogic {
} }
public void updateGroup(List<ChatGroupDto> GroupList) { public void updateGroup(List<ChatGroupDto> GroupList) {
List<ChatGroupDto> existGroupList = chatGroupDao.getAllGroups(); List<ChatGroupDto> existGroupList = chatGroupDao.getAllGroups();
Map<Integer, ChatGroupDto> existGroupMap = convertGroupListToMap(existGroupList);
ArrayList<ChatGroupDto> insertGroupList = new ArrayList<ChatGroupDto>(); ArrayList<ChatGroupDto> insertGroupList = new ArrayList<ChatGroupDto>();
ArrayList<ChatGroupDto> deleteGroupList = new ArrayList<ChatGroupDto>(); ArrayList<ChatGroupDto> deleteGroupList = new ArrayList<ChatGroupDto>();
ArrayList<ChatGroupDto> updateGroupList = new ArrayList<ChatGroupDto>(); ArrayList<ChatGroupDto> updateGroupList = new ArrayList<ChatGroupDto>();
...@@ -838,7 +838,7 @@ public class CommunicationLogic extends AbstractLogic { ...@@ -838,7 +838,7 @@ public class CommunicationLogic extends AbstractLogic {
deleteGroupList.add(chatGroupDto); deleteGroupList.add(chatGroupDto);
continue; continue;
} }
if (chatGroupDao.getGroup(chatGroupDto.groupId) == null) { if (existGroupMap.get(chatGroupDto.groupId) == null) {
insertGroupList.add(chatGroupDto); insertGroupList.add(chatGroupDto);
} else { } else {
updateGroupList.add(chatGroupDto); updateGroupList.add(chatGroupDto);
...@@ -847,13 +847,11 @@ public class CommunicationLogic extends AbstractLogic { ...@@ -847,13 +847,11 @@ public class CommunicationLogic extends AbstractLogic {
continue; continue;
} }
groupMembersMap.put(chatGroupDto.groupId, chatGroupDto.groupMembers); groupMembersMap.put(chatGroupDto.groupId, chatGroupDto.groupMembers);
//insertShopMember(chatGroupDto.groupMembers);
} }
insertShopMemberByMap(groupMembersMap);
chatGroupDao.insertGroupList(insertGroupList); chatGroupDao.insertGroupList(insertGroupList);
chatGroupDao.updateGroupList(updateGroupList); chatGroupDao.updateGroupList(updateGroupList);
chatGroupDao.deleteGroupList(deleteGroupList); chatGroupDao.deleteGroupList(deleteGroupList);
insertShopMemberByMap(groupMembersMap);
} }
public ShopMemberDto getMyShopMemberDto() { public ShopMemberDto getMyShopMemberDto() {
...@@ -1083,4 +1081,12 @@ public class CommunicationLogic extends AbstractLogic { ...@@ -1083,4 +1081,12 @@ public class CommunicationLogic extends AbstractLogic {
} }
return resultJsonArray.toString(); return resultJsonArray.toString();
} }
public Map<Integer, ChatGroupDto> convertGroupListToMap(List<ChatGroupDto> groupList) {
Map<Integer, ChatGroupDto> map = new HashMap<Integer, ChatGroupDto>();
for (ChatGroupDto group : groupList) {
map.put(group.groupId, group);
}
return map;
}
} }
...@@ -229,7 +229,6 @@ public class ChatWebViewActivity extends CommunicationWebViewActivity { ...@@ -229,7 +229,6 @@ public class ChatWebViewActivity extends CommunicationWebViewActivity {
CommonExecutor.execute(new Runnable() { CommonExecutor.execute(new Runnable() {
@Override @Override
public void run() { public void run() {
communicationLogic.initChatData();
try { try {
updateMyInfoFromServer(); updateMyInfoFromServer();
updateAllGroupInfo(); updateAllGroupInfo();
...@@ -1023,14 +1022,8 @@ public class ChatWebViewActivity extends CommunicationWebViewActivity { ...@@ -1023,14 +1022,8 @@ public class ChatWebViewActivity extends CommunicationWebViewActivity {
} }
@JavascriptInterface @JavascriptInterface
public void updateGroupInfo(String groupId) throws NetworkDisconnectedException, AcmsException {
updateGroupInfoFromServer(groupId);
}
@JavascriptInterface
public void updateGroupUser() throws NetworkDisconnectedException, AcmsException { public void updateGroupUser() throws NetworkDisconnectedException, AcmsException {
updateGroupInfoFromServer(communicationLogic.getMyGroupIds()); updateGroupInfoFromServer();
} }
@JavascriptInterface @JavascriptInterface
...@@ -1768,30 +1761,16 @@ public class ChatWebViewActivity extends CommunicationWebViewActivity { ...@@ -1768,30 +1761,16 @@ public class ChatWebViewActivity extends CommunicationWebViewActivity {
return true; return true;
} }
private void updateGroupInfoFromServer(String groupIds) throws NetworkDisconnectedException, AcmsException { private void updateGroupInfoFromServer() throws NetworkDisconnectedException, AcmsException {
ArrayList<String> checkSumList = new ArrayList<String>(); ArrayList<String> checkSumList = new ArrayList<String>();
SharedPreferences pref = getSharedPreferences(ABookCommConstants.TAG, MODE_PRIVATE); SharedPreferences pref = getSharedPreferences(ABookCommConstants.TAG, MODE_PRIVATE);
String lastUpdatedDate = pref.getString(ABookCommConstants.KEY.GROUP_MEMBER_UPDATED_DATE, DEFAULT_CHECKSUM);
for (String groupId : groupIds.split(",")) {
//checkSumList.add(pref.getString(groupId,DEFAULT_CHECKSUM));
checkSumList.add(DEFAULT_CHECKSUM);
}
String checkSumListStr = StringUtil.join(",",checkSumList);
if (groupIds.equals(ABookCommConstants.FLAG.GROUP_REQUEST_ALL.toString())) {
checkSumListStr = DEFAULT_CHECKSUM;
}
try { try {
GroupListJSON resultJson = AcmsClient.getInstance(ABVEnvironment.getInstance().networkAdapter).getGroupInfo(sid,groupIds,checkSumListStr); GroupListJSON resultJson = AcmsClient.getInstance(ABVEnvironment.getInstance().networkAdapter).getGroupInfo(sid, lastUpdatedDate);
if (CollectionUtil.isNotEmpty(resultJson.groupList)) { if (CollectionUtil.isNotEmpty(resultJson.groupList)) {
SharedPreferences.Editor editor = pref.edit();
communicationLogic.updateGroup(resultJson.groupList); communicationLogic.updateGroup(resultJson.groupList);
if (groupIds.equals(ABookCommConstants.FLAG.GROUP_REQUEST_ALL.toString())) { SharedPreferences.Editor editor = pref.edit();
editor.putString(ABookCommConstants.FLAG.GROUP_REQUEST_ALL.toString(),resultJson.allGroupLastUpdateDate); editor.putString(ABookCommConstants.KEY.GROUP_MEMBER_UPDATED_DATE, resultJson.lastRequestDate);
} else {
for (ChatGroupDto groupDto : resultJson.groupList) {
editor.putString(Integer.toString(groupDto.groupId),groupDto.updateDate);
}
}
editor.commit(); editor.commit();
} }
} catch (AcmsException e) { } catch (AcmsException e) {
...@@ -1811,13 +1790,7 @@ public class ChatWebViewActivity extends CommunicationWebViewActivity { ...@@ -1811,13 +1790,7 @@ public class ChatWebViewActivity extends CommunicationWebViewActivity {
} }
private void updateAllGroupInfo() throws NetworkDisconnectedException, AcmsException { private void updateAllGroupInfo() throws NetworkDisconnectedException, AcmsException {
updateGroupInfoFromServer(ABookCommConstants.FLAG.GROUP_REQUEST_ALL.toString()); updateGroupInfoFromServer();
List<ChatGroupDto> groupList = communicationLogic.getAllGroup();
for (ChatGroupDto group : groupList) {
updateGroupInfoFromServer(Integer.toString(group.groupId));
}
int test = 1;
} }
private void updateFavoriteInfo() throws NetworkDisconnectedException, AcmsException { private void updateFavoriteInfo() throws NetworkDisconnectedException, AcmsException {
......
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