/**
 * Copyright &copy; 2015-2020 <a href="http://www.jeeplus.org/">JeePlus</a> All rights reserved.
 */
package com.jeeplus.common.websocket.onchat;

import com.jeeplus.common.json.IMAjaxJson;
import com.jeeplus.common.utils.JsonUtil;
import com.jeeplus.common.utils.SpringContextHolder;
import com.jeeplus.common.utils.StringUtils;
import com.jeeplus.common.websocket.utils.Constant;
import com.jeeplus.modules.iim.entity.ChatHistory;
import com.jeeplus.modules.iim.entity.LayGroupUser;
import com.jeeplus.modules.iim.entity.MailBox;
import com.jeeplus.modules.iim.service.ChatHistoryService;
import com.jeeplus.modules.iim.service.LayGroupService;
import com.jeeplus.modules.iim.service.MailBoxService;
import com.jeeplus.modules.oa.entity.OaNotify;
import com.jeeplus.modules.oa.service.OaNotifyService;
import com.jeeplus.modules.sys.entity.Office;
import com.jeeplus.modules.sys.entity.Role;
import com.jeeplus.modules.sys.entity.User;
import com.jeeplus.modules.sys.security.SystemAuthorizingRealm;
import com.jeeplus.modules.sys.service.OfficeService;
import com.jeeplus.modules.sys.service.RoleService;
import com.jeeplus.modules.sys.service.UserService;
import com.jeeplus.modules.sys.utils.UserUtils;
import com.jeeplus.modules.workprojectnotify.entity.WorkProjectNotify;
import com.jeeplus.modules.workprojectnotify.service.WorkProjectNotifyService;
import net.sf.json.JSONObject;
import org.java_websocket.WebSocket;
import org.java_websocket.WebSocketImpl;
import org.java_websocket.framing.Framedata;
import org.java_websocket.handshake.ClientHandshake;
import org.java_websocket.server.WebSocketServer;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.servlet.http.HttpServletRequest;
import java.io.IOException;
import java.net.InetSocketAddress;
import java.net.UnknownHostException;
import java.nio.ByteBuffer;
import java.nio.CharBuffer;
import java.nio.charset.Charset;
import java.nio.charset.CharsetDecoder;
import java.util.*;

@SuppressWarnings("all")
@Service
@Transactional(readOnly = true)
public class ChatServer extends WebSocketServer{

	public static WorkProjectNotifyService workProjectNotifyService = SpringContextHolder.getBean(WorkProjectNotifyService.class);
	public static MailBoxService mailBoxService = SpringContextHolder.getBean(MailBoxService.class);
	public static OaNotifyService oaNotifyService = SpringContextHolder.getBean(OaNotifyService.class);
	public static RoleService roleService = SpringContextHolder.getBean(RoleService.class);
	public static UserService userService = SpringContextHolder.getBean(UserService.class);
	public static OfficeService officeService = SpringContextHolder.getBean(OfficeService.class);

	public ChatServer(int port) throws UnknownHostException {
		super(new InetSocketAddress(port));
	}

	public ChatServer() throws UnknownHostException {
		super();
	};

	public ChatServer(InetSocketAddress address) {
		super(address);
	}

	/**
	 * 触发连接事件
	 */
	@Override
	public void onOpen( WebSocket conn, ClientHandshake handshake ) {
		/*Collection<String> onlineUsers = ChatServerPool.getOnlineUser();
		IMAjaxJson j = new IMAjaxJson();
		j.put("data", onlineUsers);
		ChatServerPool.sendMessageToUser(conn, "_online_all_status_"+j.getJsonStr());//首次登陆系统时，获取用户的在线状态
		System.out.println("有新连接加入！当前在线人数为"+j.toString());*/
	}

	/**
	 * 触发关闭事件
	 */
	@Override
	public void onClose( WebSocket conn, int code, String reason, boolean remote ) {
		userLeave(conn);
		Collection<String> onlineUsers = ChatServerPool.getOnlineUser();
		IMAjaxJson j = new IMAjaxJson();
		j.put("data", onlineUsers);
		ChatServerPool.sendMessage(j.getJsonStr());//通知所有用户更新在线信息
	}

	/**
	 * 客户端发送消息到服务器时触发事件
	 */
	@Override
	public void onMessage(WebSocket conn, String message){
		try {
			message = message.toString();
			System.err.println("===========WebSocket接收到客户端发来的消息=========");
			System.err.println(message);
			System.err.println("===========WebSocket返回到客户端发来的消息=========");
			Map<String,String> map = jsonStrToMap(message);
			String JSESSIONID = map.get("JSESSIONID");
			String messageType = map.get("useType");
			if(null != message && messageType.equals(Constant._notify_)){
				//System.err.println("===========WebSocket接收到客户端发来的消息=========");
				String noReadCount = "";
				String mailPage = "";
				String count = "";
				String page = "";
				String notifyCount="";
				String notifyPage = "";
				String notifyShowCount = "";
				String notifyShowPage = "";

				String userId="",companyId="",officeId="",roleId="",type="";
				try {
					List<Role> roles = new ArrayList<>();
					if(StringUtils.isNotBlank(message)){
						userId = map.get("userId");
						companyId = map.get("companyId");
						officeId = map.get("officeId");
						String roleListStr = map.get("roleId");
						type = map.get("type");

						if(StringUtils.isNotBlank(roleListStr)){
							roleListStr=roleListStr.replace("[","")
									.replace("]","")
									.replaceAll(" ","");

							String[] roleIdArray = roleListStr.split(",");
							if(roleIdArray.length>=1){
								for (int i = 0; i < roleIdArray.length; i++) {
									roleId = roleIdArray[i];
									Role role1 = roleService.get(roleId);
									if(role1!=null && StringUtils.isNotBlank(role1.getId())){
										roles.add(role1);
									}
								}
							}
							/*try {
								System.out.println("im连接数据---------------------------------------------------------");
								System.out.println("userId:"+userId+",companyId:"+companyId+",officeId:"+officeId+",roleId:"+roleId+"");
								if(StringUtils.isNotBlank(companyId) && UserUtils.getCache("selectCompany")==null){
									System.out.print("--userId:"+userId);
									UserUtils.putCache("selectCompany",companyId);
								}
								if(StringUtils.isNotBlank(officeId) && UserUtils.getCache("selectOffice")==null){
									System.out.print("--companyId:"+companyId);
									UserUtils.putCache("selectOffice",officeId);
								}
								if(roles!=null && roles.size()!=0 && UserUtils.getCache("selectRole")==null){
									System.out.print("--roleId:"+roles.get(0).getName());
									UserUtils.putCache("selectRole",roles);
								}
								System.out.println("selectCompany:"+UserUtils.getCache("selectCompany")+",selectOffice:"+UserUtils.getCache("selectOffice"));
								System.out.println("---------------------------------------------------------");

							}catch (Exception e){
								System.out.println("缓存连接失败---------------------------------------------------------");
							}*/
						}
					}

					Office company = officeService.get(companyId);
					Office office = officeService.get(officeId);

					User user = userService.get(userId);

					//邮件
					MailBox mailBox = new MailBox();
					mailBox.setReceiver(user);
					mailBox.setReadstatus("0");//筛选未读
					List<MailBox> mailBoxList = mailBoxService.findList(mailBox);
					noReadCount = mailBoxService.getCount(mailBox)+"";
					if(mailBoxList!=null&&mailBoxList.size()>0){
						mailPage = JsonUtil.list_to_json(mailBoxList).replaceAll("\"","\'");
					}
					//公告
					OaNotify oaNotify = new OaNotify();
					oaNotify.setSelf(true);
					oaNotify.setReadFlag("0");
					oaNotify.setCurrentUser(user);
					oaNotify.setCompany(company);
					List<OaNotify> oaNotifyList = oaNotifyService.findList(oaNotify);
					if(oaNotifyList!=null && oaNotifyList.size()>0){
						for (int i = 0; i < oaNotifyList.size(); i++) {
							OaNotify on = oaNotifyList.get(i);
							on.setContents("");
							on.setContent("");
							//公告的内容是富文本，含有特殊字符,json无法解析
						}
					}
					count = oaNotifyList.size()+"";
					if(oaNotifyList!=null&&oaNotifyList.size()>0){
						page = JsonUtil.list_to_json(oaNotifyList).replaceAll("\"","\'");
					}
					//WorkProjectNotify -- 待审批
					WorkProjectNotify workProjectNotify = new WorkProjectNotify();
					workProjectNotify.setCurrentUser(user);
					workProjectNotify.setUser(user);
					workProjectNotify.setCompanyId(companyId);
					workProjectNotify.setStatus("0");
					//workProjectNotify.setNotifyRole(role.getEnname());
					workProjectNotify.setRemarks("待审批");
					List<WorkProjectNotify> workProjectNotifyList = workProjectNotifyService.findListByHome(workProjectNotify);
					List<WorkProjectNotify> notifyList = new ArrayList<WorkProjectNotify>();
					for (WorkProjectNotify WorkProjectNotify :workProjectNotifyList){
						User createBy = userService.get(WorkProjectNotify.getCreateBy().getId());
						notifyList.add(WorkProjectNotify);

					}
					notifyCount = notifyList.size()+"";
					if(notifyList!=null&&notifyList.size()>0){
						notifyPage = JsonUtil.list_to_json(notifyList).replaceAll("\"","\'");
					}
					//WorkProjectNotify -- 待通知
					workProjectNotify.setRemarks("待通知");
					List<WorkProjectNotify> notifyList2 = workProjectNotifyService.findList(workProjectNotify);
					List<WorkProjectNotify> showlist = new ArrayList<WorkProjectNotify>();
					for (WorkProjectNotify WorkProjectNotify : notifyList2){
						User createBy = userService.get(WorkProjectNotify.getCreateBy().getId());
						showlist.add(WorkProjectNotify);
					}
					notifyShowCount = showlist.size()+"";
					if(showlist!=null&&showlist.size()>0){
						notifyShowPage = JsonUtil.list_to_json(showlist).replaceAll("\"","\'");
					}

					String resultData = "{\"resultState\":\"success\""
							+",\"noReadCount\":\""+noReadCount+"\""
							+",\"mailPage\":\""+mailPage+"\""
							+",\"count\":\""+count+"\""
							+",\"page\":\""+page+"\""
							+",\"notifyCount\":\""+notifyCount+"\""
							+",\"notifyPage\":\""+notifyPage+"\""
							+",\"notifyShowCount\":\""+notifyShowCount+"\""
							+",\"notifyShowPage\":\""+notifyShowPage+"\"}";
					if(null!=conn){
						conn.send(resultData);
					}

				} catch (Exception e) {
					e.printStackTrace();
				}
			}
			ChatHistoryService chatHistoryService = SpringContextHolder.getBean("chatHistoryService");
			LayGroupService layGroupService = SpringContextHolder.getBean("layGroupService");
			if(null != message && messageType.equals(Constant._online_user_)){//用户上线
				System.out.println("用户上线");
				String userId = map.get("userId");
				this.userjoin(userId,conn);

				//通知所有用户更新在线信息
				Collection<String> onlineUsers = ChatServerPool.getOnlineUser();
				IMAjaxJson j = new IMAjaxJson();
				j.put("data", onlineUsers);
				ChatServerPool.sendMessage(j.getJsonStr());//通知所有用户更新在线信息

				//读取离线信息
				ChatHistory chat = new ChatHistory();
				chat.setUserid2(userId);
				chat.setStatus("0");
				List<ChatHistory> list =chatHistoryService.findList(chat);
				for(ChatHistory c : list){
					String userid1 = c.getUserid1();
					String sender = c.getUserid1();
					if("group".equals(c.getType())){
						sender=c.getUserid1().split(Constant._msg_)[0];
						userid1=c.getUserid1().split(Constant._msg_)[1];
					}
					User user = UserUtils.get(userid1);
					User user2 = UserUtils.get(c.getUserid2());
					String messages = "{\"from\":\""+sender+"\"," +
							"\"msg\":\""+c.getMsg()+"\"," +
							"\"msgId\":\""+(sender+System.currentTimeMillis())+"\"," +
							"\"timeStamp\":\""+c.getCreateDate().getTime()+"\"," +
							"\"sendTime\":\""+new Date().getTime()+"\"," +
							"\"to\":\""+c.getUserid2()+"\"," +
							"\"groupId\":\"\"," +
							"\"groupName\":\"\"," +
							"\"fromPortrait\":\""+user.getPhoto()+"\"," +
							"\"toPortrait\":\""+user2.getPhoto()+"\"," +
							"\"nickName\":\""+user.getName()+"\"," +
							"\"chatType\":\""+c.getType()+"\"," +
							"\"type\":\"txt\"," +
							"\"useType\":\"_msg_\"}";
					//String messages = sender+Constant._msg_+c.getUserid2()+Constant._msg_+c.getMsg()+Constant._msg_+UserUtils.get(userid1).getPhoto()+Constant._msg_+c.getType()+Constant._msg_+UserUtils.get(userid1).getName()+Constant._msg_+c.getCreateDate().getTime();//向所某用户发送消息

					ChatServerPool.sendMessageToUser(conn, messages);
					c.setStatus("1");//标记为已读
					chatHistoryService.save(c);
				}


			}if(null != message && messageType.equals(Constant._leave_user_)){//用户离线
				System.out.println("用户离线");
				String userId = map.get("userId");
				this.userLeave(conn);
				Collection<String> onlineUsers = ChatServerPool.getOnlineUser();
				IMAjaxJson j = new IMAjaxJson();
				j.put("data", onlineUsers);
				String str = j.getJsonStr();
				ChatServerPool.sendMessage(str);//通知所有用户更新在线信息
			}if(null != message && messageType.equals(Constant._online_app_)){//
				System.out.println("app连接");

				//ChatServerPool.sendMessage("_online_all_status_"+str);//通知所有用户更新在线信息
			}if(null != message && messageType.equals(Constant._msg_)){//发送消息
				System.out.println("用户消息");
				//message = message.replace(Constant._msg_,"");
				//保存聊天记录
				String from = map.get("from");
				String msg = map.get("msg");
				String msgId = map.get("msgId");
				String timeStamp = map.get("timeStamp");
				String sendTime = map.get("sendTime");
				String to = map.get("to");//如果是私聊就是用户id，如果是群聊就是群组id
				String groupId= map.get("groupId");
				String groupName= map.get("groupName");
				String fromPortrait= map.get("fromPortrait");
				String toPortrait= map.get("toPortrait");
				String fromUserName= map.get("fromUserName");
				String chatType= map.get("chatType");
				if (StringUtils.isBlank(msgId) && chatType.equals("group")){
					msgId = groupId+System.currentTimeMillis();
				}else if (StringUtils.isBlank(msgId) && chatType.equals("friend")){
					msgId = from+System.currentTimeMillis();
				}
				String type= map.get("type");
				String useType= map.get("useType");

				ChatHistory chat = new ChatHistory();

				if("group".equals(chatType)){//如果是群聊

					List<LayGroupUser> layGroupUserlist = new ArrayList();
					/*//群主
					LayGroupUser owner = new LayGroupUser();
					owner.setUser( layGroupService.get(toUser).getCreateBy());
					layGroupUserlist.add(owner);*/
					//群成员
					List<LayGroupUser> zlist = layGroupService.get(groupId).getLayGroupUserList();
					layGroupUserlist.addAll(zlist);
					boolean status = false;
					for(LayGroupUser lgUser:layGroupUserlist){
						if(from.equals(lgUser.getUser().getId())){
							continue;//群聊消息不发给自己。
						}
						//群聊时信息先发送给群聊id（即toUser)，在后台转发给所有非发送者的人的话，toUser就变成发送者。
						//保存聊天记录
						chat.setUserid1(groupId + Constant._msg_ + from);//群聊时保存群聊id和发送者id
						chat.setUserid2(lgUser.getUser().getId());//群中所有信息获得者人员
						chat.setMsg(msg);
						chat.setCreateDate(new Date());
						chat.setType("group");
                        List<WebSocket> toUserConns = ChatServerPool.getWebSocketByUser(lgUser.getUser().getId());
						if (toUserConns!=null && toUserConns.size()!=0) {
							for (WebSocket toUserConn : toUserConns) {
								User user = UserUtils.get(from);
								/*String messages = "{\"from\":\""+from+"\"," +
										"\"msg\":\""+msg+"\"," +
										"\"msgId\":\""+msgId+"\"," +
										"\"timeStamp\":\""+new Date().getTime()+"\"," +
										"\"sendTime\":\""+new Date().getTime()+"\"," +
										"\"to\":\""+lgUser.getUser().getId()+"\"," +
										"\"groupId\":\""+groupId+"\"," +
										"\"groupName\":\""+groupName+"\"," +
										"\"fromPortrait\":\""+user.getPhoto()+"\"," +
										"\"toPortrait\":\""+lgUser.getUser().getPhoto()+"\"," +
										"\"fromUserName\":\""+user.getName()+"\"," +
										"\"toUserName\":\""+lgUser.getUser().getName()+"\"," +
										"\"chatType\":\""+chatType+"\"," +
										"\"type\":\"txt\"," +
										"\"useType\":\"_msg_\"}";*/
								ChatServerPool.sendMessageToUser(toUserConn,message);//向所某用户发送消息
								chat.setStatus("1");//设置为已读
								//message = groupId + Constant._msg_ + lgUser.getUser().getId() + Constant.` + msg + Constant._msg_ + avatar + Constant._msg_ + type + Constant._msg_ + fromUsername + Constant._msg_ + datatime;
							}
						}else {
							//ChatServerPool.sendMessageToUser(conn, toUser+"_sys_对方现在离线，他将在上线后收到你的消息!");//同时向本人发送消息
							chat.setStatus("0");//设置为未读
						}
						chatHistoryService.insert(chat);
					}
					String m = "{\"timeStamp\":\""+new Date().getTime()+"\"," +
							"\"msgId\":\""+msgId+"\"," +
							"\"status\":\""+true+"\"," +
							"\"useType\":\"_msgMe_\"}";
					ChatServerPool.sendMessageToUser(conn, m);//同时向本人发送消息

				}else{//如果是私聊
					chat.setUserid1(from);
					chat.setUserid2(to);
					chat.setMsg(msg);
					chat.setType("friend");
					chat.setCreateDate(new Date());
					List<WebSocket> toUserConns = ChatServerPool.getWebSocketByUser(to);
					if (toUserConns!=null && toUserConns.size()!=0){
						for (WebSocket toUserConn:toUserConns){
							User user1 = UserUtils.get(from);
							User user2 = UserUtils.get(to);
							/*String messages = "{\"from\":\""+from+"\"," +
									"\"msg\":\""+msg+"\"," +
									"\"msgId\":\""+msgId+"\"," +
									"\"timeStamp\":\""+new Date().getTime()+"\"," +
									"\"sendTime\":\""+new Date().getTime()+"\"," +
									"\"to\":\""+to+"\"," +
									"\"groupId\":\"\"," +
									"\"groupName\":\"\"," +
									"\"fromPortrait\":\""+user1.getPhoto()+"\"," +
									"\"toPortrait\":\""+user2.getPhoto()+"\"," +
									"\"fromUserName\":\""+user1.getName()+"\"," +
									"\"toUserName\":\""+user2.getName()+"\"," +
									"\"chatType\":\""+chatType+"\"," +
									"\"type\":\"txt\"," +
									"\"useType\":\"_msg_\"}";*/
							//message = fromUser+Constant._msg_+toUser+Constant._msg_+msg+Constant._msg_+avatar+Constant._msg_+type+Constant._msg_+fromUsername+Constant._msg_+datatime;
							ChatServerPool.sendMessageToUser(toUserConn,message);//向所某用户发送消息
							chat.setStatus("1");//设置为已读
						}
						String m = "{\"timeStamp\":\""+new Date().getTime()+"\"," +
								"\"msgId\":\""+msgId+"\"," +
								"\"status\":\""+true+"\"," +
								"\"useType\":\"_msgMe_\"}";
						ChatServerPool.sendMessageToUser(conn, m);//同时向本人发送消息
					}else {
						String m = "{\"timeStamp\":\""+new Date().getTime()+"\"," +
								"\"msgId\":\""+msgId+"\"," +
								"\"status\":\""+false+"\"," +
								"\"useType\":\"_msgMe_\"}";
						ChatServerPool.sendMessageToUser(conn, m);//同时向本人发送消息
						message = "{\"to\":\""+to+"\"," +
								"\"msg\":\"对方现在离线，他将在上线后收到你的消息!\"," +
								"\"JSESSIONID\":\""+JSESSIONID+"\"," +
								"\"useType\":\"sys\"}";
						System.out.println(message);
						ChatServerPool.sendMessageToUser(conn, message);//同时向本人发送消息
						chat.setStatus("0");//设置为未读
					}
					chatHistoryService.save(chat);
				}
			}
		}catch (Exception e){

			System.out.println("--------------Exception e"+e);
			System.out.println("--------------客户端发送消息到服务器时触发事件异常------------------");
		}

	}

	/**
	 * 触发异常事件
	 */
	@Override
	public void onError( WebSocket conn, Exception ex ) {
		System.err.println("===========WebSocket出现了异常=========");
		ex.printStackTrace();
		if( conn != null ) {
			//some errors like port binding failed may not be assignable to a specific websocket
		}
	}

	public static void main( String[] args ) throws InterruptedException , IOException {
		WebSocketImpl.DEBUG = false;
		int port = 8668; //端口
		ChatServer s = new ChatServer(port);
		s.start();
		System.err.println( "WebSocket服务器的端口" + s.getPort() );
	}

	@Override
	public void onMessage(WebSocket conn, ByteBuffer buffer){
		System.out.println("执行了发送消息的动作2");
		Charset charset = null;
		CharsetDecoder decoder = null;
		CharBuffer charBuffer = null;
		try {
			charset = Charset.forName("UTF-8");
			decoder = charset.newDecoder();
			// charBuffer = decoder.decode(buffer);//用这个的话，只能输出来一次结果，第二次显示为空
			charBuffer = decoder.decode(buffer.asReadOnlyBuffer());
			//return charBuffer.toString();
			System.out.println( charBuffer.toString());
		} catch (Exception ex) {
			ex.printStackTrace();
		}
	}

	public void onFragment( WebSocket conn, Framedata fragment ) {
	}


	/**
	 * 用户加入处理
	 * @param user
	 */
	public void userjoin(String user, WebSocket conn){
//		IMAjaxJson j = new IMAjaxJson();
//		j.put("type", "user_join");
//		j.put("user", "<a onclick=\"toUserMsg('"+user+"');\">"+user+"</a>");
//		MsgServerPool.sendMessage(j.getJsonStr());				//把当前用户加入到所有在线用户列表中
//		String joinMsg = "{\"from\":\"[系统]\",\"content\":\""+user+"上线了\",\"timestamp\":"+new Date().getTime()+",\"type\":\"message\"}";
//		MsgServerPool.sendMessage(joinMsg);						//向所有在线用户推送当前用户上线的消息
//		j = new IMAjaxJson();
//		j.put("type", "get_online_user");
		ChatServerPool.addUser(user,conn);							//向连接池添加当前的连接对象
//		j.put("list", MsgServerPool.getOnlineUser());
//		MsgServerPool.sendMessageToUser(conn, j.getJsonStr());	//向当前连接发送当前在线用户的列表
	}

	/**
	 * 用户下线处理
	 * @param user
	 */
	public void userLeave(WebSocket conn){
		String user = ChatServerPool.getUserByKey(conn);
		boolean b = ChatServerPool.removeUser(conn);				//在连接池中移除连接
//		if(b){
//			IMAjaxJson j = new IMAjaxJson();
//			j.put("type", "user_leave");
//			j.put("user", "<a onclick=\"toUserMsg('"+user+"');\">"+user+"</a>");
//			MsgServerPool.sendMessage(j.getJsonStr());			//把当前用户从所有在线用户列表中删除
//			String joinMsg = "{\"from\":\"[系统]\",\"content\":\""+user+"下线了\",\"timestamp\":"+new Date().getTime()+",\"type\":\"message\"}";
//			MsgServerPool.sendMessage(joinMsg);					//向在线用户发送当前用户退出的消息
//		}
	}

	public static HashMap<String, String> jsonStrToMap(String jsonString) {
		HashMap<String, String> requestMap = new HashMap<String, String>();
		JSONObject jsonObject = JSONObject.fromObject(jsonString);

		Iterator<String> keys = jsonObject.keys();// 定义迭代器

		String key = null;
		String value = null;

		while (keys.hasNext()) {
			key = keys.next().toString();
			value = jsonObject.get(key).toString();

			requestMap.put(key.trim(), value.trim());
		}
		return requestMap;
	}

}
class ParamObj{
	String userId;
	String companyId;
	String officeId;
	String roleId;
	String type;

	public void setUserId(String userId){this.userId=userId;}
	public String getUserId(){return userId;}
	public void setCompanyId(String companyId){this.companyId=companyId;}
	public String getCompanyId(){return companyId;}
	public void setOfficeId(String officeId){this.officeId=officeId;}
	public String getOfficeId(){return officeId;}
	public void setRoleId(String roleId){this.roleId=roleId;}
	public String getRoleId(){return roleId;}

	public String getType() {
		return type;
	}

	public void setType(String type) {
		this.type = type;
	}
}

