Commit 31f79590 by Lee Munkyeong

CONTECT 画面修正

parent dacf27c7
......@@ -10,6 +10,7 @@ import jp.agentec.abook.abv.bl.common.exception.JSONValidationException;
import jp.agentec.abook.abv.bl.dto.ChatMessageDto;
import jp.agentec.abook.abv.bl.dto.ChatRoomDto;
import jp.agentec.abook.abv.bl.dto.GroupDto;
import jp.agentec.abook.abv.bl.dto.ShopMemberDto;
import jp.agentec.adf.util.DateTimeUtil;
public class GroupListJSON extends AcmsCommonJSON {
......@@ -20,9 +21,14 @@ public class GroupListJSON extends AcmsCommonJSON {
private static final String GROUP_NAME = "groupName";
private static final String PARENT_GROUP_ID = "parentGroupId";
private static final String DEL_FLG = "delFlg";
private static final String GROUP_MEMBER_LIST = "groupMemberList";
private static final String SHOP_MEMBER_ID = "shopMemberId";
private static final String MEMBER_NAME = "memberName";
private static final String PROFILE_IMAGE_PATH = "profileImagePath";
public ArrayList<GroupDto> groupList;
public GroupListJSON(String jsonString) throws AcmsException {
super(jsonString);
}
......@@ -50,6 +56,24 @@ public class GroupListJSON extends AcmsCommonJSON {
groupDto.groupName = groupListJsonArray.getJSONObject(listCount).getString(GROUP_NAME);
groupDto.delFlg = groupListJsonArray.getJSONObject(listCount).getInt(DEL_FLG);
if (groupListJsonArray.getJSONObject(listCount).has(GROUP_MEMBER_LIST)) {
JSONArray groupMemberJsonArray = groupListJsonArray.getJSONObject(listCount).getJSONArray(GROUP_MEMBER_LIST);
ArrayList<ShopMemberDto> groupMembers = new ArrayList<ShopMemberDto>();
for (int groupMemberCount = 0; groupMemberCount < groupMemberJsonArray.length(); groupMemberCount++) {
ShopMemberDto shopMemberDto = new ShopMemberDto();
shopMemberDto.shopMemberId = groupMemberJsonArray.getJSONObject(groupMemberCount).getInt(SHOP_MEMBER_ID);
shopMemberDto.shopMemberName = groupMemberJsonArray.getJSONObject(groupMemberCount).getString(MEMBER_NAME);
if (groupMemberJsonArray.getJSONObject(groupMemberCount).has(PROFILE_IMAGE_PATH)) {
shopMemberDto.profileUrl = groupMemberJsonArray.getJSONObject(groupMemberCount).getString(PROFILE_IMAGE_PATH);
}
ArrayList groupIds = new ArrayList();
groupIds.add(groupDto.groupId);
shopMemberDto.groupIdList = groupIds;
groupMembers.add(shopMemberDto);
}
groupDto.groupMembers = groupMembers;
}
groupList.add(groupDto);
}
}
......
......@@ -481,7 +481,11 @@ public class GroupDao extends AbstractDao {
public GroupDto getGroup(int groupId) {
return rawQueryGetDto("select * from m_group where group_id = " + groupId, null, GroupDto.class);
}
public List<GroupDto> getFavoriteGroup() {
return rawQueryGetDtoList("select * from m_group where favorite_register_date IS NOT NULL ORDER BY favorite_register_date ", null, GroupDto.class);
}
public List<GroupDto> getGroupSpareList(int baseId, int parentId) {
List<GroupDto> list;
list = rawQueryGetDtoList("select * from m_group mg where (mg.group_id = ?) UNION select * from m_group mg where (mg.parent_group_id = ?)", new String[]{""+ baseId, ""+ parentId}, GroupDto.class);
......
......@@ -82,7 +82,7 @@ public class ShopMemberDao extends AbstractDao {
insert("insert or replace into m_shop_member (shop_member_id, shop_member_name, profile_url, favorite_register_date, self_flg) values (?,?,?,?,?)", dto.getInsertValues());
if (dto.groupIdList == null) { continue; }
for (Integer groupId : dto.groupIdList) {
insert("insert into r_shop_member_group (shop_member_id, group_id) values ("+dto.shopMemberId+",?)", dto.getGroupIds());
insert("insert or replace into r_shop_member_group (shop_member_id, group_id) values ("+dto.shopMemberId+",?)", dto.getGroupIds());
}
}
commit();
......@@ -118,6 +118,22 @@ public class ShopMemberDao extends AbstractDao {
return list;
}
public List<ShopMemberDto> getMyGroupUsers() {
StringBuffer sql = new StringBuffer();
sql.append(" SELECT ");
sql.append(" sm.shop_member_id ");
sql.append(" ,sm.shop_member_name ");
sql.append(" ,sm.profile_url");
sql.append(" FROM ");
sql.append(" m_shop_member AS sm ");
sql.append(" INNER JOIN r_shop_member_group AS rsmg ");
sql.append(" ON sm.shop_member_id = rsmg.shop_member_id ");
sql.append(" WHERE rsmg.group_id IN (SELECT group_id FROM m_shop_member INNER JOIN r_shop_member_group WHERE self_flg = 1 GROUP BY group_id)");
sql.append(" ORDER BY sm.shop_member_name DESC ");
List<ShopMemberDto> list = rawQueryGetDtoList(sql.toString(), null, ShopMemberDto.class);
return list;
}
public boolean updateShopMember(MemberInfoDto dto) {
long count = update("update m_shop_member set shop_member_name=?, profile_url=?, favorite_register_date=? where shop_member_id=?", dto.getUpdateValues());
return count > 0;
......
package jp.agentec.abook.abv.bl.dto;
import java.util.List;
/**
* グループ情報を格納します。m_groupのPKであるgroup_relation_idはこのdtoの扱いません。内部的なキーはgetKyeValuesメソッドで定義してあります。
* @author Taejin Hong
......@@ -18,6 +20,7 @@ public class GroupDto extends AbstractDto {
public String favoriteRegisterDate = "";
public boolean userGroupFlg;
public int delFlg;
public List<ShopMemberDto> groupMembers;
public GroupDto() {
}
......
......@@ -125,6 +125,33 @@ public class CommunicationLogic extends AbstractLogic {
return myInfoStr;
}
public String getMyGroupUsers() {
List<ShopMemberDto> myGroupUsers = shopMemberDao.getMyGroupUsers();
JSONArray myGroupUsersJson = new JSONArray();
for (ShopMemberDto myGroupUser : myGroupUsers) {
Map<String, Object> myGroupUserMap = new HashMap<String, Object>();
myGroupUserMap.put("shopMemberId",myGroupUser.shopMemberId);
myGroupUserMap.put("shopMemberName",myGroupUser.shopMemberName);
myGroupUserMap.put("profileUrl",myGroupUser.profileUrl);
JSONObject jsonObject = new JSONObject(myGroupUserMap);
myGroupUsersJson.put(jsonObject);
}
String myInfoStr = myGroupUsersJson.toString();
return myInfoStr;
}
public String getMyGroupIds() {
List<GroupDto> myGroupList = groupDao.getUserGroups();
String groupIds = "";
for (GroupDto myGroup : myGroupList) {
if (!groupIds.equals("")) {
groupIds = groupIds + ",";
}
groupIds = groupIds + myGroup.groupId;
}
return groupIds;
}
public String getFavoriteUsers() {
List<ShopMemberDto> favoriteUsers = shopMemberDao.getfavoriteUserList();
......@@ -143,23 +170,22 @@ public class CommunicationLogic extends AbstractLogic {
return favoriteUsersStr;
}
// public String getFavoriteGroups() {
//
// List<ShopMemberDto> favoriteUsers = groupDao.();
//
// JSONArray resultJsonArray = new JSONArray();
// for (ShopMemberDto favoriteUser : favoriteUsers) {
// Map<String, Object> favoriteUserMap = new HashMap<String, Object>();
// favoriteUserMap.put("shopMemberId",favoriteUser.shopMemberId);
// favoriteUserMap.put("shopMemberName",favoriteUser.shopMemberName);
// favoriteUserMap.put("profileUrl",favoriteUser.profileUrl);
// JSONObject jsonObject = new JSONObject(favoriteUserMap);
// resultJsonArray.put(jsonObject);
// }
//
// String favoriteUsersStr = resultJsonArray.toString();
// return favoriteUsersStr;
// }
public String getFavoriteGroups() {
List<GroupDto> favoriteGroups = groupDao.getFavoriteGroup();
JSONArray resultJsonArray = new JSONArray();
for (GroupDto favoriteGroup : favoriteGroups) {
Map<String, Object> favoriteGroupMap = new HashMap<String, Object>();
favoriteGroupMap.put("groupName",favoriteGroup.groupName);
favoriteGroupMap.put("groupId",favoriteGroup.groupId);
JSONObject jsonObject = new JSONObject(favoriteGroupMap);
resultJsonArray.put(jsonObject);
}
String favoriteGroupsStr = resultJsonArray.toString();
return favoriteGroupsStr;
}
public void insertChatRoomList(List<ChatRoomDto> roomList) {
......@@ -182,6 +208,12 @@ public class CommunicationLogic extends AbstractLogic {
}
public void insertShopMember(ShopMemberDto shopMemberDto) {
ShopMemberDto myInfo = shopMemberDao.getMyInfo();
if (myInfo.shopMemberId.equals(shopMemberDto.shopMemberId)) {
shopMemberDto.selfFlg = 1;
} else {
shopMemberDto.selfFlg = 0;
}
shopMemberDao.insertShopMember(shopMemberDto);
}
public void insertShopMember(List<ShopMemberDto> shopMemberDtoList) {
......@@ -212,6 +244,11 @@ public class CommunicationLogic extends AbstractLogic {
} else {
updateGroupList.add(groupDto);
}
if (groupDto.groupMembers == null) {
continue;
}
insertShopMember(groupDto.groupMembers);
}
groupDao.insertGroupList(insertGroupList);
groupDao.updateGroupList(updateGroupList);
......
......@@ -46,6 +46,7 @@ import jp.agentec.abook.abv.bl.common.exception.NetworkDisconnectedException;
import jp.agentec.abook.abv.bl.common.log.Logger;
import jp.agentec.abook.abv.bl.data.ABVDataCache;
import jp.agentec.abook.abv.bl.dto.ChatMessageDto;
import jp.agentec.abook.abv.bl.dto.GroupDto;
import jp.agentec.abook.abv.bl.dto.PushMessageDto;
import jp.agentec.abook.abv.bl.dto.ShopMemberDto;
import jp.agentec.abook.abv.bl.logic.AbstractLogic;
......@@ -78,6 +79,7 @@ public class ChatWebviewActivity extends ParentWebViewActivity {
//private final String NETWORK_ERROR_PLACE_HOLDER = "file:///android_asset/chat/public/networkError.html";
private final String CHAT_PAGE_URL = "file:///android_asset/chat/public/index.html";
private final String DEFAULT_CHECKSUM = "0000000000";
//AISDevelop
private JsInf jsInf = new JsInf();
......@@ -705,8 +707,13 @@ public class ChatWebviewActivity extends ParentWebViewActivity {
@JavascriptInterface
public void updateGroupInfo() throws NetworkDisconnectedException, AcmsException {
GroupListJSON resultJson = AcmsClient.getInstance(ABVEnvironment.getInstance().networkAdapter).getGroupInfo(sid,"0","1900010115");
communicationLogic.updateGroup(resultJson.groupList);
updateGroupInfoFromServer("0");
}
@JavascriptInterface
public void updateGroupUser() throws NetworkDisconnectedException, AcmsException {
updateGroupInfoFromServer(communicationLogic.getMyGroupIds());
}
@JavascriptInterface
......@@ -747,11 +754,22 @@ public class ChatWebviewActivity extends ParentWebViewActivity {
return favoriteUsersStr;
}
// @JavascriptInterface
// public String getFavoriteGroups() {
// String favoriteGroupsStr = communicationLogic.getFavoriteGroups();
// return favoriteGroupsStr;
// }
@JavascriptInterface
public String getMyInfo() {
String myInfoStr = communicationLogic.getMyInfo();
return myInfoStr;
}
@JavascriptInterface
public String getMyGroupUsers() {
String myGroupUsersStr = communicationLogic.getMyGroupUsers();
return myGroupUsersStr;
}
@JavascriptInterface
public String getFavoriteGroups() {
String favoriteGroupsStr = communicationLogic.getFavoriteGroups();
return favoriteGroupsStr;
}
}
......@@ -772,6 +790,11 @@ public class ChatWebviewActivity extends ParentWebViewActivity {
MyInfoJSON resultJson = AcmsClient.getInstance(ABVEnvironment.getInstance().networkAdapter).getMyInfo(sid);
communicationLogic.insertShopMember(resultJson.shopMemberDto);
}
private void updateGroupInfoFromServer(String groupIds) throws NetworkDisconnectedException, AcmsException {
GroupListJSON resultJson = AcmsClient.getInstance(ABVEnvironment.getInstance().networkAdapter).getGroupInfo(sid,groupIds,DEFAULT_CHECKSUM);
communicationLogic.updateGroup(resultJson.groupList);
}
/** 
* ボタンイベント設定
*/
......
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