Commit 8a7b628a by Lee Munkyeong

性能改善

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