package com.api.hrm.service;

import java.lang.reflect.Method;
import java.text.DecimalFormat;
import java.util.*;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import com.alibaba.fastjson.JSONObject;
import com.api.hrm.util.HrmFieldUtil;

import com.api.hrm.util.ServiceUtil;
import com.engine.common.service.HrmCommonService;
import com.engine.common.service.impl.HrmCommonServiceImpl;
import org.apache.commons.lang3.StringUtils;
import weaver.common.DateUtil;
import weaver.conn.RecordSet;
import weaver.filter.XssUtil;
import weaver.formmode.cuspage.cpt.Cpt4modeUtil;
import weaver.general.BaseBean;
import weaver.general.StaticObj;
import weaver.general.Util;
import weaver.hrm.HrmUserVarify;
import weaver.hrm.User;
import weaver.hrm.appdetach.AppDetachComInfo;
import weaver.hrm.company.DepartmentComInfo;
import weaver.hrm.company.SubCompanyComInfo;
import weaver.hrm.definedfield.HrmFieldGroupComInfo;
import weaver.hrm.job.JobActivitiesComInfo;
import weaver.hrm.job.JobCallComInfo;
import weaver.hrm.job.JobTitlesComInfo;
import weaver.hrm.location.LocationComInfo;
import weaver.hrm.moduledetach.ManageDetachComInfo;
import weaver.hrm.resource.*;
import weaver.hrm.tools.HrmResourceFile;
import weaver.hrm.tools.HrmValidate;
import weaver.login.Account;
import weaver.login.VerifyLogin;
import weaver.systeminfo.MouldStatusCominfo;
import weaver.systeminfo.SystemEnv;
import weaver.systeminfo.language.LanguageComInfo;
import weaver.systeminfo.systemright.CheckSubCompanyRight;
import weaver.cowork.CoworkService;
import weaver.gp.util.TaskInfoSearch;
import weaver.meeting.MeetingReportUtil;
import weaver.plugin.util.GetDataUtil;

/***
 * 人员卡片
 * @author lvyi
 *
 */
public class HrmResourceBase4FormalService extends BaseBean {
	private boolean isMobx = false;
	private String id = "";
	/**
	 * 获取人员卡片tab页签信息
	 * @param request
	 * @param response
	 * @return
	 */
	@SuppressWarnings({ "unchecked", "rawtypes" })
	public String getHrmResourceTab(HttpServletRequest request, HttpServletResponse response){
		int isgoveproj = 0;  
		User user = HrmUserVarify.getUser(request, response);
		String id = Util.null2String(request.getParameter("id"));
		this.id = id;
		this.isMobx = Util.null2String(request.getParameter("isMobx")).equals("1");
		if(id.equals("")) id=String.valueOf(user.getUID());
		List<Map<String,Object>> tablist = new ArrayList<Map<String,Object>>();
		try{
			AppDetachComInfo AppDetachComInfo = new AppDetachComInfo();
			ResourceComInfo ResourceComInfo = new ResourceComInfo();
			AllManagers AllManagers = new AllManagers();
			HrmListValidate HrmListValidate = new HrmListValidate();
			CheckSubCompanyRight CheckSubCompanyRight = new CheckSubCompanyRight();
			MouldStatusCominfo MouldStatusCominfo = new MouldStatusCominfo();
			HrmResourceBaseTabComInfo HrmResourceBaseTabComInfo = new HrmResourceBaseTabComInfo();
			RecordSet rs = new RecordSet();
			int detachable=0;
			rs.executeSql("select detachable from SystemSet");
			if(rs.next()){
				detachable=rs.getInt("detachable");
			}
			if(AppDetachComInfo.isUseAppDetach()){
				boolean isApp = true;
				Map resourceDetach = AppDetachComInfo.getAllDetachResourceInfo(user.getUID()+"");
				if(resourceDetach != null && !resourceDetach.isEmpty()){
					if(resourceDetach.get(id) == null) isApp = false;
				}
				if(!isApp){
					String errMsg = SystemEnv.getHtmlLabelName(2012,user.getLanguage()); 
					HashMap<String, String> jsondata = new HashMap<String, String>();
					jsondata.put("errMsg",errMsg);
					jsondata.put("status","-1");
		      return jsondata.toString();
				}
			}
			String departmentid = "";
			String subcompanyid = "";
			rs.executeProc("HrmResource_SelectByID",id);
			if(rs.next()){
				departmentid = Util.toScreen(rs.getString("departmentid"),user.getLanguage()) ;		/*所属部门*/
				subcompanyid = Util.toScreen(rs.getString("subcompanyid1"),user.getLanguage()) ;
			}

			/*显示权限判断*/
			int userid = user.getUID();
			boolean isSelf		=	false;
			boolean isManager	=	false;
			boolean isSys = ResourceComInfo.isSysInfoView2(userid,id);
			boolean isCap = ResourceComInfo.isCapInfoView2(userid,id);
			boolean ishasF =HrmUserVarify.checkUserRight("HrmResourceWelfareEdit:Edit",user)||ResourceComInfo.isFinInfoView2(userid,id);;

			AllManagers.getAll(id);
			if (id.equals(""+user.getUID()) ){
				isSelf = true;
			}
			while(AllManagers.next()){
				String tempmanagerid = AllManagers.getManagerID();
				if (tempmanagerid.equals(""+user.getUID())) {
					isManager = true;
				}
			}
			int idx = 0;
			//tabInfo.put(SystemEnv.getHtmlLabelName(,user.getLanguage()), "/hrm/resource/HrmResourceBase.jsp?isfromtab=true&id="+id);
			tablist.add(setTabInfo("HrmResourceBase",1361,"/hrm/resource/HrmResourceBase.jsp?isfromtab=true&id="+id,"/main/hrm/resource4Formal/HrmResourceBase4Formal/"+id,user));
			idx++;

			boolean cusRight = checkCustomUserRight(isSelf,user.getUID());
			if(cusRight){
				//内部系统开发工作历程
				if(isSelf || isManager){
					tablist.add(setTabInfo("iframe-"+(idx++)+"-OtherInfo",20892,"/hrm/other/OtherInfo.jsp?userid="+id,"/main/hrm/resource/OtherInfo",user));
				}

				//内部系统开发系统日志
				tablist.add(setTabInfo("iframe-"+(idx++)+"-SystemLogInfo",775,"/spa/develop/index_mobx.html?#/main/develop/weaDevelopSysLogNew?userid="+id,"/spa/develop/index_mobx.html?#/main/develop/weaDevelopSysLogNew?_key=c9tuel",user));

				//正式系统工作历程不显示
				//if(HrmListValidate.isValidate(29)){
				//tabInfo.put(SystemEnv.getHtmlLabelName(30804,user.getLanguage()), "/hrm/resource/HrmResourceTotal.jsp?isfromtab=true&id="+id);
				//tablist.add(setTabInfo("iframe-"+(idx++)+"-HrmResourceTotal",30804,"/hrm/resource/HrmResourceTotal.jsp?isfromtab=true&id="+id,"/main/hrm/resource/HrmResourceTotal",user));
				//}
				//tabInfo.put(SystemEnv.getHtmlLabelName(81554,user.getLanguage()), "/hrm/resource/HrmResourceGroupView.jsp?id="+id);
				tablist.add(setTabInfo("HrmResourceGroupView",81554,"/hrm/resource/HrmResourceGroupView.jsp?id="+id,"/main/hrm/resource/HrmResourceGroupView/"+id,user));
				idx++;

				int operatelevel=-1;
				if(detachable==1){
					operatelevel=CheckSubCompanyRight.ChkComRightByUserRightCompanyId(user.getUID(),"HrmResourceEdit:Edit",Integer.parseInt(subcompanyid));
				}else{
					if(HrmUserVarify.checkUserRight("HrmResourceEdit:Edit", user)){
						operatelevel=2;
					}
				}
				int operatelevelnew = -1;
				if(detachable==1){
					operatelevelnew=CheckSubCompanyRight.ChkComRightByUserRightCompanyId(user.getUID(),"ResourcesInformationSystem:All",Integer.parseInt(subcompanyid));
				}else{
					String departmentidtmp = ResourceComInfo.getDepartmentID(id);
					if(HrmUserVarify.checkUserRight("ResourcesInformationSystem:All",user,departmentidtmp)){
						operatelevelnew=2;
					}
				}

				StaticObj staticobj = StaticObj.getInstance();
				String software = (String)staticobj.getObject("software") ;
				if(software == null) software="ALL";
				if(software.equals("ALL") || software.equals("HRM")){
					if((isSelf||operatelevel>=0)&&HrmListValidate.isValidate(11)){
						//tabInfo.put(SystemEnv.getHtmlLabelName(15687,user.getLanguage()), "/hrm/resource/HrmResourcePersonalView.jsp?isfromtab=true&id="+id);
						tablist.add(setTabInfo("HrmResourcePersonalView",15687,"/hrm/resource/HrmResourcePersonalView.jsp?isfromtab=true&id="+id,"/main/hrm/resource4Formal/HrmResourcePersonalView/"+id,user));
						idx++;
					}
					if((isSelf||isManager||operatelevel>=0)&&HrmListValidate.isValidate(12)){
						//tabInfo.put(SystemEnv.getHtmlLabelName(15688,user.getLanguage()), "/hrm/resource/HrmResourceWorkView.jsp?isfromtab=true&id="+id);
						tablist.add(setTabInfo("HrmResourceWorkView",15688,"/hrm/resource/HrmResourceWorkView.jsp?isfromtab=true&id="+id,"/main/hrm/resource4Formal/HrmResourceWorkView/"+id,user));
						idx++;
					}
				}

				if((isSelf||operatelevelnew>=0||isSys)&&HrmListValidate.isValidate(15)){
					//tabInfo.put(SystemEnv.getHtmlLabelName(15804,user.getLanguage()), "/hrm/resource/HrmResourceSystemView.jsp?isfromtab=true&id="+id+"&isView=1");
					tablist.add(setTabInfo("HrmResourceSystemView",15804,"/hrm/resource/HrmResourceSystemView1.jsp?isfromtab=true&id="+id+"&isView=1","/main/hrm/resource4Formal/HrmResourceSystemView4Formal/"+id,user));
					idx++;
				}

				if(software.equals("ALL") || software.equals("HRM")){
					if(isgoveproj==0){
						if((isSelf||ishasF)&&HrmListValidate.isValidate(13)){
							//tabInfo.put(SystemEnv.getHtmlLabelName(16480,user.getLanguage()), "/hrm/resource/HrmResourceFinanceView.jsp?isfromtab=true&id="+id+"&isView=1");
							tablist.add(setTabInfo("HrmResourceFinanceView",16480,"/hrm/resource/HrmResourceFinanceView.jsp?isfromtab=true&id="+id+"&isView=1","/main/hrm/resource4Formal/HrmResourceFinanceView/"+id,user));
							idx++;
						}
					}
					if((isSelf||operatelevel>=0 || isCap)&&HrmListValidate.isValidate(14)&&"1".equals(MouldStatusCominfo.getStatus("cpt"))){
						String cpturl="/cpt/search/SearchOperation.jsp?resourceid="+id+"&isdata=2&from=hrmResourceBase";
						if(Cpt4modeUtil.isUse()){
							cpturl="/formmode/search/CustomSearchBySimpleIframe.jsp?customid="+Cpt4modeUtil.getSearchid("wdzc")+"&resourceid="+id+"&from=hrmResourceBase&mymodetype=wdzc&sqlwhere="+new XssUtil().put("where resourceid="+id);
						}
						//tabInfo.put(SystemEnv.getHtmlLabelName(15806,user.getLanguage()), cpturl);
						tablist.add(setTabInfo("iframe-"+(idx++)+"-cptsearch",15806,"/spa/cpt/index.html#/main/cpt/mycapital?from=hrm&hrmid="+id,"/spa/cpt/index.html#/main/cptcapital/mycapitalResult",user));
					}
				}

				if((isSelf || isManager || HrmUserVarify.checkUserRight("HrmResource:Workflow",user,departmentid))&&HrmListValidate.isValidate(17)){
					//tabInfo.put(SystemEnv.getHtmlLabelName(1207,user.getLanguage()), "/workflow/search/WFSearchTemp.jsp?method=all&viewScope=doing&complete=0&viewcondition=0&resourceid="+id);
					tablist.add(setTabInfo("iframe-"+(idx++)+"-workflowsearch",1207,"/spa/workflow/index_mobx.jsp#/main/workflow/listDoing?needTop=false&needTree=false&resourceid="+id,"/spa/workflow/index.html#/main/workflow/listDoing",user));
					//tablist.add(setTabInfo("iframe-"+(idx++)+"-workflowsearch",1207,"/workflow/search/WFSearchTemp.jsp?method=all&viewScope=doing&complete=0&viewcondition=0&resourceid="+id,"/spa/workflow/index.html#/main/workflow/listDoing",user));
				}
				if((isSelf || isManager || HrmUserVarify.checkUserRight("HrmResource:Plan",user,departmentid))&&HrmListValidate.isValidate(18) ) {
					//tabInfo.put(SystemEnv.getHtmlLabelName(2192,user.getLanguage()), "/workplan/data/WorkPlan.jsp?resourceid="+id);
					tablist.add(setTabInfo("iframe-"+(idx++)+"-workplansearch",2192,"/spa/workplan/static/index.html#/main/wp/myWorkPlan?fromcard=true&selectedUser="+id,"/main/workplan/data/WorkPlan",user));
				}

				if(isgoveproj==0){
					if(software.equals("ALL") || software.equals("HRM")){
						if(isSelf || isManager || HrmUserVarify.checkUserRight("HrmResource:Absense",user,departmentid)) {
							if(HrmListValidate.isValidate(20)){
								//tabInfo.put(SystemEnv.getHtmlLabelName(20080,user.getLanguage()), "/hrm/resource/HrmResourceAbsense.jsp?resourceid="+id);
								tablist.add(setTabInfo("HrmResourceAbsense",20080,"/hrm/resource/HrmResourceAbsense.jsp?resourceid="+id,"/main/hrm/HrmResourceAbsense",user));
								idx++;
							}
						}
						if(isSelf||isManager||HrmUserVarify.checkUserRight("HrmResource:TrainRecord",user)) {
							if(HrmListValidate.isValidate(21)){
								//tabInfo.put(SystemEnv.getHtmlLabelName(816,user.getLanguage()), "/hrm/resource/HrmResourceTrainRecord.jsp?resourceid="+id);
								tablist.add(setTabInfo("HrmResourceTrainRecord",816,"/hrm/resource/HrmResourceTrainRecord.jsp?resourceid="+id,"/main/hrm/resource4Formal/HrmResourceTrainRecord/"+id,user));
								idx++;
							}
						}
						if(isSelf||isManager||HrmUserVarify.checkUserRight("HrmResource:RewardsRecord",user)) {
							if(HrmListValidate.isValidate(22)){
								//tabInfo.put(SystemEnv.getHtmlLabelName(16065,user.getLanguage()), "/hrm/resource/HrmResourceRewardsRecordView.jsp?id="+id);
								tablist.add(setTabInfo("HrmResourceRewardsRecordView",16065,"/hrm/resource/HrmResourceRewardsRecordView.jsp?id="+id,"/main/hrm/resource4Formal/HrmResourceRewardsRecordView/"+id,user));
								idx++;
							}
						}
					}
				}

				//判断该用户对编辑人员机构是否具有的角色维护权限(TD19119)
				boolean rolesmanage = false;
				int varifylevel=-1;
				if(detachable==1){
					varifylevel = CheckSubCompanyRight.ChkComRightByUserRightCompanyId(user.getUID(), "HrmRolesEdit:Edit", Integer.parseInt(subcompanyid));
					if(varifylevel > 0) {
						if(HrmUserVarify.checkUserRight("HrmRolesEdit:Edit", user)){
							varifylevel=2;
						}else{
							varifylevel=-1;
						}
					}
				}else{
					if(HrmUserVarify.checkUserRight("HrmRolesEdit:Edit", user)){
						varifylevel=2;
					}
				}
				if(varifylevel > 0) {
					rolesmanage = true;
				}

				if(HrmUserVarify.checkUserRight("HrmResourceEdit:Edit", user) && rolesmanage){
					//tabInfo.put(SystemEnv.getHtmlLabelName(16527,user.getLanguage()), "/hrm/roles/HrmResourceNewRoles.jsp?resourceid="+id );
					tablist.add(setTabInfo("HrmResourceNewRoles",16527,"/hrm/roles/HrmResourceNewRoles.jsp?resourceid="+id,"/main/hrm/resource4Formal/HrmResourceNewRoles/"+id,user));
					idx++;
				}

				//原工作历程变为其他
				if(HrmListValidate.isValidate(29)){
					tablist.add(setTabInfo("HrmResourceTotal",375,"/wui/index.html#/main/hrm/HrmResourceTotal"+id,"/main/hrm/HrmResourceTotal"+id,user));
					idx++;
				}

				//取自定义标签页
				HrmResourceBaseTabComInfo.setTofirstRow();
				while(HrmResourceBaseTabComInfo.next()){
					if(!HrmResourceBaseTabComInfo.getIsopen().equals("1")){
						continue;
					}
					String tab_urlTemp= HrmResourceBaseTabComInfo.getLinkurl();
					String tab_urlTemp1=tab_urlTemp.replaceAll("\\Q{#id}", ""+id);
					if(tab_urlTemp1.indexOf("?")>=0){
						tab_urlTemp1+="&hrmResourceID="+id;
					}else{
						tab_urlTemp1+="?hrmResourceID="+id;
					}
					String groupname = HrmResourceBaseTabComInfo.getGroupName();
					if( HrmResourceBaseTabComInfo.getTabnum().trim().length()!=0){
						try {
//						  Class c = Class.forName("com.engine.hrm.cmd.hrmcarditem.GetTabNumDemoCmd");
							Class c = Class.forName(HrmResourceBaseTabComInfo.getTabnum().trim());
							Object cObject= c.newInstance();
							Method m = c.getMethod("execute");
							Method  method = c.getMethod("setOwnerid",String.class);
							method.invoke(cObject,""+id);
							method = c.getMethod("setUserid",String.class);
							method.invoke(cObject,""+user.getUID());
							int num = (Integer) m.invoke(cObject);
							groupname+="("+num+")";
						} catch (Exception e) {
							e.printStackTrace();
							groupname+="(error)";
						}
					}
					tablist.add(setTabInfo("iframe-"+(idx++)+"-DefineTab"+id,groupname,tab_urlTemp1,"",user));
				}
			}

			List<Map<String,Object>> tablist1 = new ArrayList<Map<String,Object>>();
			for(Map<String,Object> obj : tablist){
				if(!obj.isEmpty()){
					tablist1.add(obj);
				}
			}
			tablist = tablist1;
		}catch (Exception e) {
			writeLog(e);
		}
		return JSONObject.toJSONString(tablist);
  }

	public Map<String,Object> getValidate(User user) {
		Map<String, Object> retmap = new HashMap<String, Object>();
		try{
			HrmListValidate hrmListValidate = new HrmListValidate();
			Map<String,Object> map = null;
			String[] validateIds = new String[]{"19","31","32","36","37","38"};
			String[] validateTitles = new String[]{""+weaver.systeminfo.SystemEnv.getHtmlLabelName(2051,weaver.general.ThreadVarLanguage.getLang())+"",""+weaver.systeminfo.SystemEnv.getHtmlLabelName(16635,weaver.general.ThreadVarLanguage.getLang())+"",""+weaver.systeminfo.SystemEnv.getHtmlLabelName(18481,weaver.general.ThreadVarLanguage.getLang())+"",""+weaver.systeminfo.SystemEnv.getHtmlLabelName(15707,weaver.general.ThreadVarLanguage.getLang())+"",""+weaver.systeminfo.SystemEnv.getHtmlLabelName(128122,weaver.general.ThreadVarLanguage.getLang())+"",""+weaver.systeminfo.SystemEnv.getHtmlLabelName(83704,weaver.general.ThreadVarLanguage.getLang())+""};
			for(int i=0;i<validateIds.length;i++){
				map = new HashMap<String,Object>();
				map.put("isValidate", hrmListValidate.isValidate(Util.getIntValue(validateIds[i])));
				map.put("validateName", validateTitles[i]);
				retmap.put(validateIds[i],map);
			}
			map = new HashMap<String,Object>();
			map.put("isValidate", hrmListValidate.isValidate(33)&&HrmValidate.hasEmessage(user));
			map.put("validateName", ""+weaver.systeminfo.SystemEnv.getHtmlLabelName(384220,weaver.general.ThreadVarLanguage.getLang())+"");
			retmap.put("33",map);
		}catch (Exception e){
			writeLog(e);
		}
		return retmap;
	}

  /**
	 * 查看人员基本信息
	 * @param request
	 * @param response
	 * @return
	 */
	public String getResourceBaseView(HttpServletRequest request, HttpServletResponse response){
		Map<String,Object> retmap = new HashMap<String,Object>();
		try{
			User user = HrmUserVarify.getUser(request, response);
			HrmListValidate HrmListValidate = new HrmListValidate();
			String id = Util.null2String(request.getParameter("id"));
			if(id.equals("")) id=String.valueOf(user.getUID());
			String status = "";
			String subcompanyid = "";
			RecordSet rs = new RecordSet();
			HttpSession session = request.getSession(true);
			rs.executeSql("select subcompanyid1, status from hrmresource where id = "+id);
			if(rs.next()){
				status = Util.toScreen(rs.getString("status"),user.getLanguage());
				subcompanyid = Util.toScreen(rs.getString("subcompanyid1"),user.getLanguage()) ;
				if(subcompanyid==null||subcompanyid.equals("")||subcompanyid.equalsIgnoreCase("null"))
				 subcompanyid="-1";
				session.setAttribute("hrm_subCompanyId",subcompanyid);
			}
			
			boolean isSelf = false;
			if (id.equals(""+user.getUID()) ){
				isSelf = true;
			}
			int operatelevel=-1;
			//人力资源模块是否开启了管理分权，如不是，则不显示框架，直接转向到列表页面(新的分权管理)
			int hrmdetachable=0;
			ManageDetachComInfo ManageDetachComInfo = new ManageDetachComInfo();
			if(session.getAttribute("hrmdetachable")!=null){
			    hrmdetachable=Util.getIntValue(String.valueOf(session.getAttribute("hrmdetachable")),0);
			}else{
				boolean isUseHrmManageDetach=ManageDetachComInfo.isUseHrmManageDetach();
				if(isUseHrmManageDetach){
				   hrmdetachable=1;
				   session.setAttribute("detachable","1");
				   session.setAttribute("hrmdetachable",String.valueOf(hrmdetachable));
				}else{
				   hrmdetachable=0;
				   session.setAttribute("detachable","0");
				   session.setAttribute("hrmdetachable",String.valueOf(hrmdetachable));
				}
			}
			if(hrmdetachable==1){
				CheckSubCompanyRight CheckSubCompanyRight = new CheckSubCompanyRight();
			  operatelevel=CheckSubCompanyRight.ChkComRightByUserRightCompanyId(user.getUID(),"HrmResourceEdit:Edit",Integer.parseInt(subcompanyid));
			}else{
		    if(HrmUserVarify.checkUserRight("HrmResourceEdit:Edit", user)){
		    	operatelevel=2;
		    }
			}
			Map<String,Object> buttons = new Hashtable<String, Object>();
			if((isSelf||operatelevel>0)&&!status.equals("10")){
				buttons.put("hasEdit", true);
				buttons.put("hasSave", true);
			}
			retmap.put("buttons", buttons);
			
			RecordSet RecordSet = new RecordSet();
			DepartmentComInfo DepartmentComInfo = new DepartmentComInfo();
			ResourceComInfo resourceComInfo = new ResourceComInfo();
			JobTitlesComInfo jobTitlesComInfo = new JobTitlesComInfo();
			JobActivitiesComInfo jobActivitiesComInfo = new JobActivitiesComInfo();
			JobCallComInfo jobCallComInfo = new JobCallComInfo();
			LocationComInfo locationComInfo = new LocationComInfo();
			String sql = "";
			
			List<Map<String,Object>> grouplist = new ArrayList<Map<String,Object>>();
			Map<String,Object> jsondata = null;
			
			Map<String,Object> item1 = new HashMap<String,Object>();//姓名等头部信息lastname,workcode,sex,orginfo
			Map<String,Object> item2 = new HashMap<String,Object>();//账号信息accounttype,accounts,managerid,subordinatescount,status,lastlogindate,createrid,createdate,lastmoddate,lastmodid
			Map<String,Object> item4 = new HashMap<String,Object>();//基本信息 mobile,telephone,mobilecall,fax,email,workroom
			Map<String,Object> item5 = new HashMap<String,Object>();//岗位信息 jobtitle,jobactivity,jobcall,joblevel,jobactivitydesc,managerid,subordinatescount,createdate,tinyintfield1
			grouplist.add(item1);
			grouplist.add(item2);
			grouplist.add(item4);
			grouplist.add(item5);

			List<Object> itemlist1 = new ArrayList<Object>();
			List<Object> itemlist2 = new ArrayList<Object>();
			List<Object> itemlist4 = new ArrayList<Object>();
			List<Object> itemlist5 = new ArrayList<Object>();
			item1.put("title", SystemEnv.getHtmlLabelName(383145, user.getLanguage()));
			item1.put("id", "item1");
			item1.put("defaultshow", true);
			item1.put("items", itemlist1);
			
			item2.put("title", SystemEnv.getHtmlLabelName(383146, user.getLanguage()));
			item2.put("id", "item2");
			item2.put("defaultshow", true);
			item2.put("items", itemlist2);
			
			item4.put("title", SystemEnv.getHtmlLabelName(1361, user.getLanguage()));
			item4.put("id", "item4");
			item4.put("defaultshow", true);
			item4.put("items", itemlist4);
			
			item5.put("title", SystemEnv.getHtmlLabelName(383147, user.getLanguage()));
			item5.put("id", "item5");
			item5.put("defaultshow", true);
			item5.put("items", itemlist5);
			
			//基本信息
			sql = "select * from hrmresource where id="+id;
			rs.executeSql(sql);
			if(rs.next()){
				String lastname = Util.toScreen(rs.getString("lastname"),user.getLanguage());
				String workcode = Util.toScreen(rs.getString("workcode"),user.getLanguage());
				String sex = Util.toScreen(rs.getString("sex"),user.getLanguage());
				subcompanyid = Util.toScreen(rs.getString("subcompanyid1"),user.getLanguage()) ;
				String departmentid = Util.toScreen(rs.getString("departmentid"),user.getLanguage());
				int accounttype = Util.getIntValue(rs.getString("accounttype"),0);
				String managerid = Util.toScreen(rs.getString("managerid"),user.getLanguage());
				status = Util.toScreen(rs.getString("status"),user.getLanguage());
				String lastlogindate = Util.toScreen(rs.getString("lastlogindate"),user.getLanguage());
				String createrid = Util.toScreen(rs.getString("createrid"),user.getLanguage());
				String createdate = Util.toScreen(rs.getString("createdate"),user.getLanguage());
				String lastmoddate = Util.toScreen(rs.getString("lastmoddate"),user.getLanguage());
				String lastmodid = Util.toScreen(rs.getString("lastmodid"),user.getLanguage());
				String jobtitle = Util.toScreen(rs.getString("jobtitle"),user.getLanguage());
				String jobcall = Util.toScreen(rs.getString("jobcall"),user.getLanguage());
				String joblevel = Util.toScreen(rs.getString("joblevel"),user.getLanguage());
				String jobactivitydesc = Util.toScreen(rs.getString("jobactivitydesc"),user.getLanguage());
				String mobile = Util.toScreen(rs.getString("mobile"),user.getLanguage());
				String fax = Util.toScreen(rs.getString("fax"),user.getLanguage());
				String telephone = Util.toScreen(rs.getString("telephone"),user.getLanguage());
				String email= Util.toScreen(rs.getString("email"),user.getLanguage());
				String mobilecall = Util.toScreen(rs.getString("mobilecall"),user.getLanguage());
				String workroom = Util.toScreen(rs.getString("workroom"),user.getLanguage());
				String resourceimageid = Util.getFileidOut(rs.getString("resourceimageid")) ;
				
				lastname = lastname.endsWith("\\")&&!lastname.endsWith("\\\\") == true ? lastname+ "\\" :lastname;
				lastname = weaver.common.StringUtil.replace(lastname, "'", "\\\\'");
				
				jsondata = new HashMap<String, Object>();
				jsondata.put("name","lastname");
				jsondata.put("label",SystemEnv.getHtmlLabelName(413,user.getLanguage()));
				jsondata.put("value",lastname);
				itemlist1.add(jsondata);
				
				jsondata = new HashMap<String, Object>();
				jsondata.put("name","messagerurl");
				jsondata.put("label",SystemEnv.getHtmlLabelName(24513,user.getLanguage()));
				jsondata.put("value",resourceComInfo.getMessagerUrls(id));
				itemlist1.add(jsondata);
				
				
				jsondata = new HashMap<String, Object>();
				jsondata.put("name","workcode");
				jsondata.put("label",SystemEnv.getHtmlLabelName(714,user.getLanguage()));
				jsondata.put("value",workcode);
				itemlist1.add(jsondata);

				jsondata = new HashMap<String, Object>();
				jsondata.put("name","sex");
				jsondata.put("label",SystemEnv.getHtmlLabelName(416,user.getLanguage()));
				jsondata.put("sex",sex);//0：男性，1：女性
				if(sex.equals("0")) {
					jsondata.put("value",SystemEnv.getHtmlLabelName(28473,user.getLanguage()));
				}else if(sex.equals("1")) {
					jsondata.put("value",SystemEnv.getHtmlLabelName(28474,user.getLanguage()));
				}
				itemlist1.add(jsondata);
				
				jsondata = new HashMap<String, Object>();
				jsondata.put("name","orginfo");
				jsondata.put("label",SystemEnv.getHtmlLabelName(376,user.getLanguage()));
				jsondata.put("value",DepartmentComInfo.getAllParentDepartmentNames(departmentid,subcompanyid));
				itemlist1.add(jsondata);
				
				jsondata = new HashMap<String, Object>();
				jsondata.put("name","resourceimageid");
				jsondata.put("label",SystemEnv.getHtmlLabelName(15707,user.getLanguage()));
				String url = "";
				if(!resourceimageid.equals("0") && resourceimageid.length()>0&&HrmListValidate.isValidate(36)){
					url="/weaver/weaver.file.FileDownload?fileid="+resourceimageid;
				}else{
					if(sex.equals("")||sex.equals("0")) {
						url = "/images/messageimages/temp/man_wev8.png";
					}else if(sex.equals("1")){
						url = "/images/messageimages/temp/women_wev8.png";
					}
				}
				jsondata.put("value",url);
				itemlist2.add(jsondata);
				
				jsondata = new HashMap<String, Object>();
				Map<String, Object> options = new HashMap<String, Object>();
				jsondata.put("options",options);
				itemlist2.add(jsondata);
				
				//var data = { "lastname": "吕益", "mobile": "13899998888","telephone":"021-99998888","email":"lvyi@weaver.com","jobtitle":"开发工程师","department":"人力资源组","locationname":"上海"};
				options.put("lastname",lastname);
				options.put("mobile",resourceComInfo.getMobileShow(id,""+user.getUID()));
				options.put("telephone",telephone);
				options.put("email",email);
				options.put("jobtitle",jobTitlesComInfo.getJobTitlesname(joblevel));
				options.put("department",DepartmentComInfo.getDepartmentname(departmentid));
				options.put("locationname",locationComInfo.getLocationname(departmentid));

				List<Object> lsOption = new ArrayList<Object>();
				jsondata = new HashMap<String, Object>();
				jsondata.put("options",lsOption);
				itemlist2.add(jsondata);
				Map<String, Object> option = null;
				option = new HashMap<String,Object>();//发消息
				option.put("id", id);
				option.put("validateId", "33");
				option.put("name", "sendEmessage");
				option.put("funname", "sendEmessage");
				option.put("title", SystemEnv.getHtmlLabelName(127379,user.getLanguage()));
				lsOption.add(option);

				option = new HashMap<String,Object>();//发送短信
				option.put("id", id);
				option.put("validateId", "31");
				option.put("name", "openmessage");
				option.put("funname", "sendSmsMessage");
				option.put("title", SystemEnv.getHtmlLabelName(16635,user.getLanguage()));
				lsOption.add(option);

				option = new HashMap<String,Object>();//发送邮件
				option.put("id", id);
				option.put("validateId", "19");
				option.put("name", "openemail");
				option.put("funname", "sendMail");
				option.put("title", SystemEnv.getHtmlLabelName(2051,user.getLanguage()));
				lsOption.add(option);

				option = new HashMap<String,Object>();//新建日程
				option.put("id", id);
				option.put("validateId", "32");
				option.put("name", "doAddWorkPlan");
				option.put("funname", "doAddWorkPlanByHrm");
				option.put("title", SystemEnv.getHtmlLabelName(18481,user.getLanguage()));
				lsOption.add(option);

				List<Map<String,Object>> ls = new ArrayList<Map<String,Object>>();
				jsondata = new HashMap<String, Object>();
				jsondata.put("accountinfo",ls);
				itemlist2.add(jsondata);
				if(weaver.general.GCONST.getMOREACCOUNTLANDING()){
					jsondata = new HashMap<String, Object>();
					jsondata.put("name","accounttype");
					jsondata.put("label",SystemEnv.getHtmlLabelName(17745,user.getLanguage()));
					jsondata.put("value",accounttype==0?SystemEnv.getHtmlLabelName(17746,user.getLanguage()):SystemEnv.getHtmlLabelName(17747,user.getLanguage()));
					ls.add(jsondata);
					
					List accounts=new VerifyLogin().getAccountsById(Integer.valueOf(id).intValue());
					Iterator iter=null;
					if(accounts!=null)     iter=  accounts.iterator();
					Account current=new Account();
					while(iter!=null&&iter.hasNext()){
					Account a=(Account)iter.next();
					if((""+a.getId()).equals(id))
						current=a;
					}
					if(current.getType()==1){
						jsondata = new HashMap<String, Object>();
						jsondata.put("name","accounts");
						jsondata.put("label",SystemEnv.getHtmlLabelName(17747,user.getLanguage()));
						jsondata.put("value",""+accounts.size());
						ls.add(jsondata);
					}
				}
				
				jsondata = new HashMap<String, Object>();
				jsondata.put("name","weixin");
				jsondata.put("label",SystemEnv.getHtmlLabelName(383148,user.getLanguage()));
				jsondata.put("value","/hrm/resource/qccode.jsp");//前台已写死，该值作废
				ls.add(jsondata);
				
				jsondata = new HashMap<String, Object>();
				jsondata.put("name","status");
				jsondata.put("label",SystemEnv.getHtmlLabelName(602,user.getLanguage()));
				jsondata.put("value",HrmFieldUtil.getResourceStatusName(status, user));
				ls.add(jsondata);
				
				jsondata = new HashMap<String, Object>();
				jsondata.put("name","lastlogindate");
				jsondata.put("label",SystemEnv.getHtmlLabelName(16067,user.getLanguage()));
				jsondata.put("value",lastlogindate);
				ls.add(jsondata);

				jsondata = new HashMap<String, Object>();
				jsondata.put("name","createrid");
				jsondata.put("label",SystemEnv.getHtmlLabelName(882,user.getLanguage()));
				jsondata.put("isOpenHrm",true);
				String value = "";
				String showName = "";
				if(Util.null2String(createrid).length()>0){
					value = createrid;
					showName = resourceComInfo.getLastname(createrid);
				}
				jsondata.put("value",value);
				jsondata.put("showName",showName);
				ls.add(jsondata);
				
				jsondata = new HashMap<String, Object>();
				jsondata.put("name","createdate");
				jsondata.put("label",SystemEnv.getHtmlLabelName(1339,user.getLanguage()));
				jsondata.put("value",createdate);
				ls.add(jsondata);
				
				jsondata = new HashMap<String, Object>();
				jsondata.put("name","lastmodid");
				jsondata.put("label",SystemEnv.getHtmlLabelName(3002,user.getLanguage()));
				jsondata.put("isOpenHrm",true);
				value = "";
				showName = "";
				if(Util.null2String(lastmodid).length()>0){
					value = lastmodid;
					showName = resourceComInfo.getLastname(lastmodid);
				}
				jsondata.put("value",value);
				jsondata.put("showName",showName);
				ls.add(jsondata);
				
				jsondata = new HashMap<String, Object>();
				jsondata.put("name","lastmoddate");
				jsondata.put("label",SystemEnv.getHtmlLabelName(19521,user.getLanguage()));
				jsondata.put("value",lastmoddate);
				ls.add(jsondata);
				
				//基本信息：手机号码、电话号码、其他电话、传真、电子邮件、通讯地址
				jsondata = new HashMap<String, Object>();
				jsondata.put("name","mobile");
				jsondata.put("label",SystemEnv.getHtmlLabelName(620,user.getLanguage()));
				jsondata.put("value",resourceComInfo.getMobileShow(id,""+user.getUID()));
				itemlist4.add(jsondata);
				
				jsondata = new HashMap<String, Object>();
				jsondata.put("name","telephone");
				jsondata.put("label",SystemEnv.getHtmlLabelName(15713,user.getLanguage()));
				jsondata.put("value",telephone);
				itemlist4.add(jsondata);
				
				jsondata = new HashMap<String, Object>();
				jsondata.put("name","mobilecall");
				jsondata.put("label",SystemEnv.getHtmlLabelName(15714,user.getLanguage()));
				jsondata.put("value",mobilecall);
				itemlist4.add(jsondata);
				
				jsondata = new HashMap<String, Object>();
				jsondata.put("name","fax");
				jsondata.put("label",SystemEnv.getHtmlLabelName(494,user.getLanguage()));
				jsondata.put("value",fax);
				itemlist4.add(jsondata);
				
				jsondata = new HashMap<String, Object>();
				jsondata.put("name","email");
				jsondata.put("label",SystemEnv.getHtmlLabelName(477,user.getLanguage()));
				jsondata.put("value",email);
				itemlist4.add(jsondata);
				
				jsondata = new HashMap<String, Object>();
				jsondata.put("name","workroom");
				jsondata.put("label",SystemEnv.getHtmlLabelName(420,user.getLanguage()));
				jsondata.put("value",workroom);
				itemlist4.add(jsondata);
				
				//岗位、职务、职称、职级、职责描述、直接上级、直接下属、入职年限、认证专家
				jsondata = new HashMap<String, Object>();
				jsondata.put("name","jobtitle");
				jsondata.put("label",SystemEnv.getHtmlLabelName(6086,user.getLanguage()));
				jsondata.put("value", "<A href=/spa/hrm/engine.html#/hrmengine/singlePost?id="+jobtitle+" target=_blank>"+Util.toScreen(jobTitlesComInfo.getJobTitlesmark(jobtitle),user.getLanguage())+"</a>");
				itemlist5.add(jsondata);
				
				jsondata = new HashMap<String, Object>();
				jsondata.put("name","jobactivity");
				jsondata.put("label",SystemEnv.getHtmlLabelName(1915,user.getLanguage()));
				jsondata.put("value",Util.toScreen(jobActivitiesComInfo.getJobActivitiesmarks(jobTitlesComInfo.getJobactivityid(jobtitle)),user.getLanguage()));
				itemlist5.add(jsondata);
				
				jsondata = new HashMap<String, Object>();
				jsondata.put("name","jobcall");
				jsondata.put("label",SystemEnv.getHtmlLabelName(806,user.getLanguage()));
				jsondata.put("value",Util.toScreen(jobCallComInfo.getJobCallname(jobcall),user.getLanguage()));
				itemlist5.add(jsondata);
				
				jsondata = new HashMap<String, Object>();
				jsondata.put("name","joblevel");
				jsondata.put("label",SystemEnv.getHtmlLabelName(1909,user.getLanguage()));
				jsondata.put("value",joblevel);
				itemlist5.add(jsondata);
				
				jsondata = new HashMap<String, Object>();
				jsondata.put("name","jobactivitydesc");
				jsondata.put("label",SystemEnv.getHtmlLabelName(15708,user.getLanguage()));
				jsondata.put("value",jobactivitydesc);
				itemlist5.add(jsondata);
				
				jsondata = new HashMap<String, Object>();
				jsondata.put("name","managerid");
				jsondata.put("label",SystemEnv.getHtmlLabelName(15709,user.getLanguage()));
				jsondata.put("isOpenHrm",true);
				value = "";
				showName = "";
				if(Util.null2String(managerid).length()>0){
					value = managerid;
					showName = resourceComInfo.getLastname(managerid);
				}
				jsondata.put("value",value);
				jsondata.put("showName",showName);
				itemlist5.add(jsondata);
				
				jsondata = new HashMap<String, Object>();
				RecordSet.executeProc("HrmResource_SCountBySubordinat",id);
				RecordSet.next();
				String subordinatescount = RecordSet.getString(1) ;
				jsondata.put("name","subordinatescount");
				jsondata.put("label",SystemEnv.getHtmlLabelName(81863,user.getLanguage()));
				
				jsondata.put("value", "<A href=\"/spa/hrm/index_mobx.html#/main/hrm/underling/"+id+"\" target=\"_blank\">"+subordinatescount+"</A>");
				itemlist5.add(jsondata);
				
				jsondata = new HashMap<String, Object>();
				jsondata.put("name","enteryear");
				jsondata.put("label",SystemEnv.getHtmlLabelName(383149,user.getLanguage()));
				String enteryear = "";
				if(createdate.length()>0){
					String lastdate = DateUtil.getCurrentDate();
					if(status.equals("0")||status.equals("1")||status.equals("2")||status.equals("3")){
						
					}else{
						//离职人员按最后登录日期计算
						if(lastlogindate.length()>0){
							lastdate = lastlogindate;
						}
					}
					int day = DateUtil.dayDiff(createdate,lastdate);
					DecimalFormat df = new DecimalFormat("0.0");
					enteryear = df.format(day/365.0);
				}else{
					enteryear = "0.0";
				}
				jsondata.put("value", enteryear);
				itemlist5.add(jsondata);
				
				jsondata = new HashMap<String, Object>();
				jsondata.put("name","expert");
				jsondata.put("label",SystemEnv.getHtmlLabelName(130910,user.getLanguage()));
				String tinyintfield1 = "";
				String isExpert = "";
				rs.executeSql("select tinyintfield1 from hrmresource where id="+id);
				if(rs.next()){
					tinyintfield1 = Util.null2String(rs.getString("tinyintfield1"));
				}
				if(tinyintfield1.equals("1")){
					isExpert = SystemEnv.getHtmlLabelName(163,user.getLanguage());
				}else{
					isExpert = SystemEnv.getHtmlLabelName(161,user.getLanguage());
				}
				jsondata.put("value", isExpert);
				itemlist5.add(jsondata);

				retmap.put("validate", getValidate(user));
				retmap.put("result", grouplist);
			}
		}catch (Exception e) {
			writeLog(e);
		}
		
		return JSONObject.toJSONString(retmap);
	}
	
	/**
	 * 查看人员基本信息
	 * @param request
	 * @param response
	 * @return
	 */
	public String getResourceBaseViewV1(HttpServletRequest request, HttpServletResponse response){
		Map<String,Object> retmap = new HashMap<String,Object>();
		try{
			HrmListValidate HrmListValidate = new HrmListValidate();
			User user = HrmUserVarify.getUser(request, response);
			String id = Util.null2String(request.getParameter("id"));
			if(id.equals("")) id=String.valueOf(user.getUID());
			String status = "";
			String subcompanyid = "";
			RecordSet rs = new RecordSet();
			HttpSession session = request.getSession(true);
			rs.executeSql("select subcompanyid1, status from hrmresource where id = "+id);
			if(rs.next()){
				status = Util.toScreen(rs.getString("status"),user.getLanguage());
				subcompanyid = Util.toScreen(rs.getString("subcompanyid1"),user.getLanguage()) ;
				if(subcompanyid==null||subcompanyid.equals("")||subcompanyid.equalsIgnoreCase("null"))
				 subcompanyid="-1";
				session.setAttribute("hrm_subCompanyId",subcompanyid);
			}
			
			boolean isSelf = false;
			if (id.equals(""+user.getUID()) ){
				isSelf = true;
			}
			int operatelevel=-1;
			//人力资源模块是否开启了管理分权，如不是，则不显示框架，直接转向到列表页面(新的分权管理)
			int hrmdetachable=0;
			ManageDetachComInfo ManageDetachComInfo = new ManageDetachComInfo();
			if(session.getAttribute("hrmdetachable")!=null){
			    hrmdetachable=Util.getIntValue(String.valueOf(session.getAttribute("hrmdetachable")),0);
			}else{
				boolean isUseHrmManageDetach=ManageDetachComInfo.isUseHrmManageDetach();
				if(isUseHrmManageDetach){
				   hrmdetachable=1;
				   session.setAttribute("detachable","1");
				   session.setAttribute("hrmdetachable",String.valueOf(hrmdetachable));
				}else{
				   hrmdetachable=0;
				   session.setAttribute("detachable","0");
				   session.setAttribute("hrmdetachable",String.valueOf(hrmdetachable));
				}
			}
			if(hrmdetachable==1){
				CheckSubCompanyRight CheckSubCompanyRight = new CheckSubCompanyRight();
			  operatelevel=CheckSubCompanyRight.ChkComRightByUserRightCompanyId(user.getUID(),"HrmResourceEdit:Edit",Integer.parseInt(subcompanyid));
			}else{
		    if(HrmUserVarify.checkUserRight("HrmResourceEdit:Edit", user)){
		    	operatelevel=2;
		    }
			}
			Map<String,Object> buttons = new Hashtable<String, Object>();
			if((isSelf||operatelevel>0)&&!status.equals("10")){
				buttons.put("hasEdit", true);
				buttons.put("hasSave", true);
			}
			retmap.put("buttons", buttons);
			
			RecordSet RecordSet = new RecordSet();
			SubCompanyComInfo SubCompanyComInfo = new SubCompanyComInfo();
			DepartmentComInfo DepartmentComInfo = new DepartmentComInfo();
			ResourceComInfo resourceComInfo = new ResourceComInfo();
			JobTitlesComInfo jobTitlesComInfo = new JobTitlesComInfo();
			JobActivitiesComInfo jobActivitiesComInfo = new JobActivitiesComInfo();
			LocationComInfo locationComInfo = new LocationComInfo();
			LanguageComInfo languageComInfo = new LanguageComInfo();
			HrmResourceFile hrmResourceFile = new HrmResourceFile();
			HrmFieldGroupComInfo hrmFieldGroupComInfo = new HrmFieldGroupComInfo();
			ResourceBelongtoComInfo resourceBelongtoComInfo = new ResourceBelongtoComInfo();
			String sql = "";
			
			List<Map<String,Object>> grouplist = new ArrayList<Map<String,Object>>();
			Map<String,Object> jsondata = null;
			
			Map<String,Object> item1 = new HashMap<String,Object>();//姓名等头部信息lastname,workcode,sex,orginfo
			Map<String,Object> item2 = new HashMap<String,Object>();//账号信息accounttype,accounts,managerid,subordinatescount,status,lastlogindate,createrid,createdate,lastmoddate,lastmodid
			Map<String,Object> item4 = new HashMap<String,Object>();//基本信息 mobile,telephone,mobilecall,fax,email,workroom
			Map<String,Object> item5 = new HashMap<String,Object>();//专长介绍
			grouplist.add(item1);
			grouplist.add(item2);
			grouplist.add(item4);
			grouplist.add(item5);
			
			List<Object> itemlist1 = new ArrayList<Object>();
			List<Object> itemlist2 = new ArrayList<Object>();
			List<Object> lsInfo = new ArrayList<Object>();
			List<Object> itemlist4 = new ArrayList<Object>();
			List<Object> itemlist5 = new ArrayList<Object>();
			lsInfo.add(itemlist4);
			lsInfo.add(itemlist5);
			List<Object> itemlist6 = new ArrayList<Object>();
			item1.put("title", SystemEnv.getHtmlLabelName(383145, user.getLanguage()));
			item1.put("id", "item1");
			item1.put("defaultshow", true);
			item1.put("items", itemlist1);
			
			item2.put("title", SystemEnv.getHtmlLabelName(383146, user.getLanguage()));
			item2.put("id", "item2");
			item2.put("defaultshow", true);
			item2.put("items", itemlist2);
			
			item4.put("title", SystemEnv.getHtmlLabelName(1361, user.getLanguage()));
			item4.put("id", "item4");
			item4.put("defaultshow", true);
			item4.put("items", lsInfo);
			
			item5.put("title", SystemEnv.getHtmlLabelName(383144, user.getLanguage()));
			item5.put("id", "item6");
			item5.put("defaultshow", true);
			item5.put("items", itemlist6);
			
			//基本信息
			sql = "select * from hrmresource where id="+id;
			rs.executeSql(sql);
			if(rs.next()){
				String lastname = Util.toScreen(rs.getString("lastname"),user.getLanguage());
				String workcode = Util.toScreen(rs.getString("workcode"),user.getLanguage());
				String sex = Util.toScreen(rs.getString("sex"),user.getLanguage());
				subcompanyid = Util.toScreen(rs.getString("subcompanyid1"),user.getLanguage()) ;
				String departmentid = Util.toScreen(rs.getString("departmentid"),user.getLanguage());
				int accounttype = Util.getIntValue(rs.getString("accounttype"),0);
				String managerid = Util.toScreen(rs.getString("managerid"),user.getLanguage());
				status = Util.toScreen(rs.getString("status"),user.getLanguage());
				String lastlogindate = Util.toScreen(rs.getString("lastlogindate"),user.getLanguage());
				String createrid = Util.toScreen(rs.getString("createrid"),user.getLanguage());
				String createdate = Util.toScreen(rs.getString("createdate"),user.getLanguage());
				String lastmoddate = Util.toScreen(rs.getString("lastmoddate"),user.getLanguage());
				String lastmodid = Util.toScreen(rs.getString("lastmodid"),user.getLanguage());
				String jobtitle = Util.toScreen(rs.getString("jobtitle"),user.getLanguage());
				String jobcall = Util.toScreen(rs.getString("jobcall"),user.getLanguage());
				String joblevel = Util.toScreen(rs.getString("joblevel"),user.getLanguage());
				String jobactivitydesc = Util.toScreen(rs.getString("jobactivitydesc"),user.getLanguage());
				String mobile = Util.toScreen(rs.getString("mobile"),user.getLanguage());
				String fax = Util.toScreen(rs.getString("fax"),user.getLanguage());
				String telephone = Util.toScreen(rs.getString("telephone"),user.getLanguage());
				String email= Util.toScreen(rs.getString("email"),user.getLanguage());
				String mobilecall = Util.toScreen(rs.getString("mobilecall"),user.getLanguage());
				String workroom = Util.toScreen(rs.getString("workroom"),user.getLanguage());
				String locationid = Util.toScreen(rs.getString("locationid"),user.getLanguage());
				String resourceimageid = Util.getFileidOut(rs.getString("resourceimageid")) ;
				String ismobile = Util.null2String(request.getParameter("ismobile"));

				lastname = lastname.endsWith("\\")&&!lastname.endsWith("\\\\") == true ? lastname+ "\\" :lastname;
				lastname = weaver.common.StringUtil.replace(lastname, "'", "\\\\'");

				jsondata = new HashMap<String, Object>();
				jsondata.put("name","lastname");
				jsondata.put("label",SystemEnv.getHtmlLabelName(413,user.getLanguage()));
				jsondata.put("value",lastname);
				itemlist1.add(jsondata);
				
				jsondata = new HashMap<String, Object>();
				jsondata.put("name","messagerurl");
				jsondata.put("label",SystemEnv.getHtmlLabelName(24513,user.getLanguage()));
				jsondata.put("value",resourceComInfo.getMessagerUrls(id));
				itemlist1.add(jsondata);
				
				
				jsondata = new HashMap<String, Object>();
				jsondata.put("name","workcode");
				jsondata.put("label",SystemEnv.getHtmlLabelName(714,user.getLanguage()));
				jsondata.put("value",workcode);
				itemlist1.add(jsondata);

				jsondata = new HashMap<String, Object>();
				jsondata.put("name","sex");
				jsondata.put("label",SystemEnv.getHtmlLabelName(416,user.getLanguage()));
				jsondata.put("sex",sex);//0：男性，1：女性
				if(sex.equals("0")) {
					jsondata.put("value",SystemEnv.getHtmlLabelName(28473,user.getLanguage()));
				}else if(sex.equals("1")) {
					jsondata.put("value",SystemEnv.getHtmlLabelName(28474,user.getLanguage()));
				}
				itemlist1.add(jsondata);
				
				jsondata = new HashMap<String, Object>();
				jsondata.put("name","orginfo");
				jsondata.put("label",SystemEnv.getHtmlLabelName(376,user.getLanguage()));
				jsondata.put("value",DepartmentComInfo.getAllParentDepartmentNames(departmentid,subcompanyid));
				itemlist1.add(jsondata);
				
				jsondata = new HashMap<String, Object>();
				jsondata.put("name","resourceimageid");
				jsondata.put("label",SystemEnv.getHtmlLabelName(15707,user.getLanguage()));
				String url = "";
				if(!resourceimageid.equals("0") && resourceimageid.length()>0&&HrmListValidate.isValidate(36)){
					url="/weaver/weaver.file.FileDownload?fileid="+resourceimageid;
				}else{
					if(sex.equals("")||sex.equals("0")) {
						url = "/images/messageimages/temp/man_wev8.png";
					}else if(sex.equals("1")){
						url = "/images/messageimages/temp/women_wev8.png";
					}
				}
				jsondata.put("value",url);
				itemlist2.add(jsondata);
				
				jsondata = new HashMap<String, Object>();
				Map<String, Object> options = new HashMap<String, Object>();
				jsondata.put("options",options);
				itemlist2.add(jsondata);
				
				//var data = { "lastname": "吕益", "mobile": "13899998888","telephone":"021-99998888","email":"lvyi@weaver.com","jobtitle":"开发工程师","department":"人力资源组","locationname":"上海"};
				options.put("lastname",lastname);
				options.put("mobile",resourceComInfo.getMobileShow(id,""+user.getUID()));
				options.put("telephone",telephone);
				options.put("email",email);
				options.put("jobtitle",jobTitlesComInfo.getJobTitlesname(joblevel));
				options.put("department",DepartmentComInfo.getDepartmentname(departmentid));
				options.put("locationname",locationComInfo.getLocationname(departmentid));

				List<Object> lsOption = new ArrayList<Object>();
				jsondata = new HashMap<String, Object>();
				jsondata.put("options",lsOption);
				itemlist2.add(jsondata);
				Map<String, Object> option = null;
				option = new HashMap<String,Object>();//发消息
				option.put("id", id);
				option.put("validateId", "33");
				option.put("name", "sendEmessage");
				option.put("funname", "sendEmessage");
				option.put("title", SystemEnv.getHtmlLabelName(127379,user.getLanguage()));
				lsOption.add(option);

				option = new HashMap<String,Object>();//发送短信
				option.put("id", id);
				option.put("validateId", "31");
				option.put("name", "openmessage");
				option.put("funname", "sendSmsMessage");
				option.put("title", SystemEnv.getHtmlLabelName(16635,user.getLanguage()));
				lsOption.add(option);

				option = new HashMap<String,Object>();//发送邮件
				option.put("id", id);
				option.put("validateId", "19");
				option.put("name", "openemail");
				option.put("funname", "sendMail");
				option.put("title", SystemEnv.getHtmlLabelName(2051,user.getLanguage()));
				lsOption.add(option);

				option = new HashMap<String,Object>();//新建日程
				option.put("id", id);
				option.put("validateId", "32");
				option.put("name", "doAddWorkPlan");
				option.put("funname", "doAddWorkPlanByHrm");
				option.put("title", SystemEnv.getHtmlLabelName(18481,user.getLanguage()));
				lsOption.add(option);

				List<Map<String,Object>> ls = new ArrayList<Map<String,Object>>();
				jsondata = new HashMap<String, Object>();
				jsondata.put("accountinfo",ls);
				itemlist2.add(jsondata);
				String value = "";
				String showName = "";
				List accounts=new VerifyLogin().getAccountsById(Integer.valueOf(id).intValue());
				Iterator iter=null;
				if(accounts!=null)     iter=  accounts.iterator();
				Account current=new Account();
				while(iter!=null&&iter.hasNext()){
					Account a=(Account)iter.next();
					if((""+a.getId()).equals(id))
						current=a;
				}
				if(weaver.general.GCONST.getMOREACCOUNTLANDING()){
					jsondata = new HashMap<String, Object>();
					jsondata.put("name","accounttype");
					jsondata.put("label",SystemEnv.getHtmlLabelName(17745,user.getLanguage()));
					jsondata.put("value",accounttype==0?SystemEnv.getHtmlLabelName(17746,user.getLanguage()):SystemEnv.getHtmlLabelName(17747,user.getLanguage()));
					ls.add(jsondata);

					List lsUser = resourceBelongtoComInfo.getBelongtousers(""+id);
					if(lsUser!=null && lsUser.size()>0 && current.getType()==0) {
						jsondata = new HashMap<String, Object>();
						jsondata.put("name", "accounts");
						jsondata.put("label", SystemEnv.getHtmlLabelName(17747, user.getLanguage()));
						jsondata.put("value", "" + lsUser.size());
						ls.add(jsondata);
					}

					if(current.getType()==1){
						jsondata = new HashMap<String, Object>();
						jsondata.put("name","belongto");
						jsondata.put("label",SystemEnv.getHtmlLabelName(17746,weaver.general.Util.getIntValue(user.getLanguage())));
						jsondata.put("value",resourceComInfo.getBelongTo(id));
						jsondata.put("showName",resourceComInfo.getLastname(resourceComInfo.getBelongTo(id)));
						jsondata.put("isOpenHrm",true);
						ls.add(jsondata);
					}

					//					if(current.getType()==1){
					//						jsondata = new HashMap<String, Object>();
					//						jsondata.put("name","accounts");
					//						jsondata.put("label",SystemEnv.getHtmlLabelNames("17747,141,124",user.getLanguage()));
					//						iter=accounts.iterator();
					//						while(accounts.size()>1&&iter.hasNext()){
					//							Account a=(Account)iter.next();
					//							if(a.getType()==0){
					//								String subcompanyname=SubCompanyComInfo.getSubCompanyname(""+a.getSubcompanyid());
					//								String departmentname=DepartmentComInfo.getDepartmentname(""+a.getDepartmentid());
					//								String jobtitlename=jobTitlesComInfo.getJobTitlesname(""+a.getJobtitleid());
					//         				//<a href="/hrm/resource/HrmResource.jsp?id=<%=a.getId()%>" target="_blank"><%=subcompanyname+"/"+departmentname+"/"+jobtitlename%></a>
					//         			}
					//						}
					//						jsondata.put("value",""+accounts.size());
					//						ls.add(jsondata);
					//					}
				}
				
				jsondata = new HashMap<String, Object>();
				jsondata.put("name","weixin");
				jsondata.put("label",SystemEnv.getHtmlLabelName(383148,user.getLanguage()));
				jsondata.put("value","/hrm/resource/qccode.jsp");//前台已写死，该值作废
				ls.add(jsondata);
				
				jsondata = new HashMap<String, Object>();
				jsondata.put("name","status");
				jsondata.put("label",SystemEnv.getHtmlLabelName(602,user.getLanguage()));
				jsondata.put("value",HrmFieldUtil.getResourceStatusName(status, user));
				ls.add(jsondata);
				
				jsondata = new HashMap<String, Object>();
				jsondata.put("name","lastlogindate");
				jsondata.put("label",SystemEnv.getHtmlLabelName(16067,user.getLanguage()));
				jsondata.put("value",lastlogindate);
				ls.add(jsondata);

				jsondata = new HashMap<String, Object>();
				jsondata.put("name","createrid");
				jsondata.put("label",SystemEnv.getHtmlLabelName(882,user.getLanguage()));
				jsondata.put("isOpenHrm",true);
				value = "";
				showName = "";
				if(Util.null2String(createrid).length()>0){
					value = createrid;
					showName = resourceComInfo.getLastname(createrid);
				}
				jsondata.put("value",value);
				jsondata.put("showName",showName);
				ls.add(jsondata);
				
				jsondata = new HashMap<String, Object>();
				jsondata.put("name","createdate");
				jsondata.put("label",SystemEnv.getHtmlLabelName(1339,user.getLanguage()));
				jsondata.put("value",createdate);
				ls.add(jsondata);
				
				jsondata = new HashMap<String, Object>();
				jsondata.put("name","lastmodid");
				jsondata.put("label",SystemEnv.getHtmlLabelName(3002,user.getLanguage()));
				jsondata.put("isOpenHrm",true);
				value = "";
				showName = "";
				if(Util.null2String(lastmodid).length()>0){
					value = lastmodid;
					showName = resourceComInfo.getLastname(lastmodid);
				}
				jsondata.put("value",value);
				jsondata.put("showName",showName);
				ls.add(jsondata);
				
				jsondata = new HashMap<String, Object>();
				jsondata.put("name","lastmoddate");
				jsondata.put("label",SystemEnv.getHtmlLabelName(19521,user.getLanguage()));
				jsondata.put("value",lastmoddate);
				ls.add(jsondata);
				
				//基本信息：移动电话、办公电话、其他电话、传真号码、电子邮件、办公室、办公地点
				if(ismobile.equals("1")) {
					jsondata = new HashMap<String, Object>();
					jsondata.put("name","status");
					jsondata.put("label",SystemEnv.getHtmlLabelName(602,user.getLanguage()));
					jsondata.put("value",HrmFieldUtil.getResourceStatusName(status, user));
					itemlist4.add(jsondata);
				}

				jsondata = new HashMap<String, Object>();
				jsondata.put("name","mobile");
				jsondata.put("label",SystemEnv.getHtmlLabelName(620,user.getLanguage()));
				jsondata.put("value",resourceComInfo.getMobileShow(id,""+user.getUID()));
				itemlist4.add(jsondata);
				
				jsondata = new HashMap<String, Object>();
				jsondata.put("name","telephone");
				jsondata.put("label",SystemEnv.getHtmlLabelName(15713,user.getLanguage()));
				jsondata.put("value",telephone);
				itemlist4.add(jsondata);
				
				jsondata = new HashMap<String, Object>();
				jsondata.put("name","mobilecall");
				jsondata.put("label",SystemEnv.getHtmlLabelName(15714,user.getLanguage()));
				jsondata.put("value",mobilecall);
				itemlist4.add(jsondata);
				
				jsondata = new HashMap<String, Object>();
				jsondata.put("name","fax");
				jsondata.put("label",SystemEnv.getHtmlLabelName(383143,user.getLanguage()));
				jsondata.put("value",fax);
				itemlist4.add(jsondata);
				
				jsondata = new HashMap<String, Object>();
				jsondata.put("name","email");
				jsondata.put("label",SystemEnv.getHtmlLabelName(477,user.getLanguage()));
				jsondata.put("value",email);
				itemlist4.add(jsondata);
				
				jsondata = new HashMap<String, Object>();
				jsondata.put("name","workroom");
				jsondata.put("label",SystemEnv.getHtmlLabelName(420,user.getLanguage()));
				jsondata.put("value",workroom);
				itemlist4.add(jsondata);
				
				jsondata = new HashMap<String, Object>();
				jsondata.put("name","workaddress");
				jsondata.put("label",SystemEnv.getHtmlLabelName(378,user.getLanguage()));
				jsondata.put("value",locationComInfo.getLocationname(locationid));
				itemlist4.add(jsondata);
				
				//岗位信息、职务信息、职责描述、直接上级、直接下属、入职年限、认证专家
				jsondata = new HashMap<String, Object>();
				jsondata.put("name","jobtitle");
				jsondata.put("label",SystemEnv.getHtmlLabelName(383147,user.getLanguage()));
				jsondata.put("value", "<A href=/spa/hrm/engine.html#/hrmengine/singlePost?id="+jobtitle+" target=_blank>"+Util.toScreen(jobTitlesComInfo.getJobTitlesname(jobtitle),user.getLanguage())+"</a>");
				itemlist5.add(jsondata);
				
				jsondata = new HashMap<String, Object>();
				jsondata.put("name","jobactivity");
				jsondata.put("label",SystemEnv.getHtmlLabelName(383211,user.getLanguage()));
				jsondata.put("value",Util.toScreen(jobActivitiesComInfo.getJobActivitiesname(jobTitlesComInfo.getJobactivityid(jobtitle)),user.getLanguage()));
				itemlist5.add(jsondata);
				
				jsondata = new HashMap<String, Object>();
				jsondata.put("name","jobactivitydesc");
				jsondata.put("label",SystemEnv.getHtmlLabelName(15708,user.getLanguage()));
				jsondata.put("value",jobactivitydesc);
				itemlist5.add(jsondata);
				
				jsondata = new HashMap<String, Object>();
				jsondata.put("name","managerid");
				jsondata.put("label",SystemEnv.getHtmlLabelName(15709,user.getLanguage()));
				jsondata.put("isOpenHrm",true);
				value = "";
				showName = "";
				if(Util.null2String(managerid).length()>0){
					value = managerid;
					showName = resourceComInfo.getLastname(managerid);
				}
				jsondata.put("value",value);
				jsondata.put("showName",showName);
				itemlist5.add(jsondata);
				
				jsondata = new HashMap<String, Object>();
				RecordSet.executeProc("HrmResource_SCountBySubordinat",id);
				RecordSet.next();
				String subordinatescount = RecordSet.getString(1) ;
				jsondata.put("name","subordinatescount");
				jsondata.put("label",SystemEnv.getHtmlLabelName(81863,user.getLanguage()));
				
				jsondata.put("value", "<A href=\"/spa/hrm/index_mobx.html#/main/hrm/underling/"+id+"\" target=\"_blank\">"+subordinatescount+"</A>");
				itemlist5.add(jsondata);
				
				jsondata = new HashMap<String, Object>();
				jsondata.put("name","enteryear");
				jsondata.put("label",SystemEnv.getHtmlLabelName(383149,user.getLanguage()));
				String enteryear = "";
				if(createdate.length()>0){
					String lastdate = DateUtil.getCurrentDate();
					if(status.equals("0")||status.equals("1")||status.equals("2")||status.equals("3")){
						
					}else{
						//离职人员按最后登录日期计算
						if(lastlogindate.length()>0){
							lastdate = lastlogindate;
						}
					}
					int day = DateUtil.dayDiff(createdate,lastdate);
					DecimalFormat df = new DecimalFormat("0.0");
					enteryear = df.format(day/365.0);
				}else{
					enteryear = "0.0";
				}
				jsondata.put("value", enteryear);
				itemlist5.add(jsondata);
				
				jsondata = new HashMap<String, Object>();
				jsondata.put("name","expert");
				jsondata.put("label",SystemEnv.getHtmlLabelName(130910,user.getLanguage()));
				String tinyintfield1 = "";
				String isExpert = "";
				rs.executeSql("select tinyintfield1 from hrmresource where id="+id);
				if(rs.next()){
					tinyintfield1 = Util.null2String(rs.getString("tinyintfield1"));
				}
				if(tinyintfield1.equals("1")){
					isExpert = SystemEnv.getHtmlLabelName(163,user.getLanguage());
				}else{
					isExpert = SystemEnv.getHtmlLabelName(161,user.getLanguage());
				}
				jsondata.put("value", isExpert);
				itemlist5.add(jsondata);
				
				
				String remark = "";
				String tag = "";
				rs.executeSql("select remark,tag from HRM_AbilityIntro where userid="+id);
				if(rs.next()){
					remark = Util.convertDB2Input(Util.null2String(rs.getString("remark")));
					tag = Util.null2String(rs.getString("tag"));
					
					remark = remark.replace("<div>", "");
					remark = remark.replace("</div>", "\n");
					if(remark.endsWith("\n"))remark=remark.substring(0, remark.length()-1);
				}
				List taglist = Util.TokenizerString(tag,",");
				jsondata = new HashMap<String, Object>();
				jsondata.put("name","remark");
				jsondata.put("label","");
				jsondata.put("value",remark);
				itemlist6.add(jsondata);
				
				jsondata = new HashMap<String, Object>();
				jsondata.put("name","tag");
				jsondata.put("label","");
				jsondata.put("value",taglist);
				itemlist6.add(jsondata);
				
				isSelf = false;
				if(user.getUID()==Util.getIntValue(id)){
					isSelf=true;
				}
				retmap.put("isSelf",isSelf);
				retmap.put("result", grouplist);
				retmap.put("validate", getValidate(user));
			}
		}catch (Exception e) {
			writeLog(e);
		}
		
		return JSONObject.toJSONString(retmap);
	}
	
  /**
	 * 查看人员基本信息工作业绩、工作过程
	 * @param request
	 * @param response
	 * @return
	 */
	public String getResourceBaseData(HttpServletRequest request, HttpServletResponse response){
		Map<String,Object> retmap = new HashMap<String,Object>();
		try{
			User user = HrmUserVarify.getUser(request, response);
			String resourceid = Util.null2String(request.getParameter("id"));
			if(resourceid.length()==0)resourceid=""+user.getUID();
			boolean noLoadData = Util.null2String(request.getParameter("noLoadData")).equals("1");//不加载数据
			List<Map<String,Object>> grouplist = new ArrayList<Map<String,Object>>();
			Map<String,Object> jsondata = null;
			Map<String,Object> item6 = new HashMap<String,Object>();//工作业绩
			Map<String,Object> item7 = new HashMap<String,Object>();//工作过程
			grouplist.add(item6);
			grouplist.add(item7);
			List<Object> itemlist6 = new ArrayList<Object>();
			List<Object> itemlist7 = new ArrayList<Object>();
			
			item6.put("title", SystemEnv.getHtmlLabelName(383150,user.getLanguage()));
			item6.put("id", "item6");
			item6.put("defaultshow", true);
			item6.put("items", itemlist6);
			
			item7.put("title", SystemEnv.getHtmlLabelName(383151,user.getLanguage()));
			item7.put("id", "item7");
			item7.put("defaultshow", true);
			item7.put("items", itemlist7);
			
			String item01="0";
			String item02="0";
			String item03="0";
			String item04="0";
			String item05="0";
			String item06="0";
			String item10="0";
			org.json.JSONObject tmpdata = new org.json.JSONObject();
			try{
				if(!noLoadData){
					Map<String,String> param = new HashMap<String,String>();
					param.put("hrmid",resourceid);
					tmpdata = GetDataUtil.getJsonData("jgzxxx",user.getUID(),param);
					org.json.JSONObject datas= (org.json.JSONObject)tmpdata.get("datas");
					
					item01=(String)datas.get("item01");
					item02=(String)datas.get("item02");
					item03=(String)datas.get("item03");
					item04=(String)datas.get("item04");
					item05=(String)datas.get("item05");
					item06=(String)datas.get("item06");
					item10=(String)datas.get("item10");
				}
			}catch (Exception e) {

			}
			
			//工作业绩：合同额、收款额、验收额、客户、人脉、商机
			jsondata = new HashMap<String, Object>();
			jsondata.put("name","contract_amount");
			jsondata.put("label",SystemEnv.getHtmlLabelName(383153,user.getLanguage())+":");
			jsondata.put("value", item01);
			jsondata.put("link", "<a href=\"/cm/data/SearchFrame.jsp?tablename=zxht\" target=\"_blank\">"+SystemEnv.getHtmlLabelName(17463,user.getLanguage())+"</a>");
			itemlist6.add(jsondata);
			
			jsondata = new HashMap<String, Object>();
			jsondata.put("name","amount_received");
			jsondata.put("label",SystemEnv.getHtmlLabelName(383154,user.getLanguage())+":");
			jsondata.put("value", item02);
			jsondata.put("link", "<a href=\"/cm/data/SearchFrame.jsp?tablename=sk\" target=\"_blank\">"+SystemEnv.getHtmlLabelName(17463,user.getLanguage())+"</a>");
			itemlist6.add(jsondata);
			
			jsondata = new HashMap<String, Object>();
			jsondata.put("name","acceptance_amount");
			jsondata.put("label",SystemEnv.getHtmlLabelName(383155,user.getLanguage())+":");
			jsondata.put("value", item03);
			jsondata.put("link", "<a href=\"/cm/data/SearchFrame.jsp?tablename=xmys\" target=\"_blank\">"+SystemEnv.getHtmlLabelName(17463,user.getLanguage())+"</a>");
			itemlist6.add(jsondata);
			
			jsondata = new HashMap<String, Object>();
			jsondata.put("name","customer");
			jsondata.put("label",SystemEnv.getHtmlLabelName(136,user.getLanguage())+":");
			jsondata.put("value", item04);
			jsondata.put("link", "<a href=\"/CRM/manage/customer/Main.jsp?maintype=1\" target=\"_blank\">"+SystemEnv.getHtmlLabelName(17463,user.getLanguage())+"</a>");
			itemlist6.add(jsondata);
			
			jsondata = new HashMap<String, Object>();
			jsondata.put("name","contacts");
			jsondata.put("label",SystemEnv.getHtmlLabelName(383156,user.getLanguage())+":");
			jsondata.put("value", item05);
			jsondata.put("link", "<a href=\"/CRM/manage/customer/Main.jsp?maintype=3\" target=\"_blank\">"+SystemEnv.getHtmlLabelName(17463,user.getLanguage())+"</a>");
			itemlist6.add(jsondata);
			
			jsondata = new HashMap<String, Object>();
			jsondata.put("name","business_opportunity");
			jsondata.put("label",SystemEnv.getHtmlLabelName(383157,user.getLanguage())+":");
			jsondata.put("value", item06);
			jsondata.put("link", "<a href=\"/CRM/manage/sellchance/Main.jsp\" target=\"_blank\">"+SystemEnv.getHtmlLabelName(17463,user.getLanguage())+"</a>");
			itemlist6.add(jsondata);
			
			//项目数据
			String projectnum = item10;
			
			//工作过程：创建流程、审批流程、创建知识、微博、协作、会议、项目、任务、收支
			String firstDayOfYear = DateUtil.getFirstDayOfYear();
			String lastDayOfYear = DateUtil.getLastDayOfYear();
			String sql="";
			RecordSet rs = new RecordSet();
			int workflowcreated = 0;//创建流程
			int workflowapprove = 0;//审批流程
			int blognum = 0;//微博
			String coworknum = "0";//协作
			int docnum = 0;//创建知识
			String meetingnum = "0";//会议
			String tasknum = "0";//任务
			DecimalFormat df = new DecimalFormat("0.00");
			double sum_shourusum =62000* Util.getIntValue(DateUtil.getMonth());//收入数据
			double sum_feesum =0.0;//支出数据
			
			if(!noLoadData){
				workflowcreated = getRequestCountByType("1",resourceid);//创建流程
				
				workflowapprove = getRequestCountByType("2",resourceid);//审批流程
				
				//创建知识
			  sql = "select count(id) num from DocDetail where doccreaterid=" + resourceid + " and docstatus in(1,2,5,7)";
			  sql += " and (ishistory is null or ishistory = 0) and (isreply is null or isreply='' or isreply=0) "; 
			  rs.executeSql(sql);
			  if(rs.next()){
					docnum = rs.getInt("num");
			  }
			  
			  //微博
				sql = " select count(id) AS blognum from blog_discuss WHERE workdate >= '"+firstDayOfYear+"' and workdate <= '"+lastDayOfYear+"' and userid="+resourceid;
				rs.executeSql(sql);
				if(rs.next()){
					blognum=rs.getInt("blognum");
					if(blognum<0)blognum=0;
				}
				
				//协作
				coworknum = getMyAllCoworkCount(resourceid);
				
				//会议
				MeetingReportUtil	MeetingReportUtil = new MeetingReportUtil();
				meetingnum = MeetingReportUtil.getMeetingCount(resourceid);
				
				//任务
				TaskInfoSearch TaskInfoSearch = new TaskInfoSearch();
				User tmpuser = new User(Util.getIntValue(resourceid));
				tasknum = TaskInfoSearch.getCurrentYearTaskCount(tmpuser);
			
				//收支
				sql="select sum(isnull(b.feesum, 0.00)) sum_feesum from bill_hrmfinance a "
					+ " join Bill_ExpenseDetail b on a.id = b.expenseid "
					//+ " join workflow_requestbase c on a.requestid = c.requestid "
					+ " join fnabudgetfeetype d on b.feetypeid = d.id "
					//+ " where c.currentnodetype = 3 "
					+ " where b.relatedate >= '"+firstDayOfYear+"' and b.relatedate <= '"+lastDayOfYear+"' "
					+ " and a.resourceid = "+resourceid;
				rs.executeSql(sql);
				if(rs.next()){
					sum_feesum = rs.getDouble("sum_feesum");
				}
				if(sum_feesum<0)sum_feesum=.0;
			}
			jsondata = new HashMap<String, Object>();
			jsondata.put("name","create_flow");
			jsondata.put("label",SystemEnv.getHtmlLabelName(23087,user.getLanguage())+":");
			jsondata.put("value", ""+workflowcreated);
			jsondata.put("link", "<a href=\"/hrm/resource/HrmRequestShow.jsp?type=1\" target=\"_blank\">"+weaver.systeminfo.SystemEnv.getHtmlLabelName(126218,weaver.general.ThreadVarLanguage.getLang())+"</a>");
			itemlist7.add(jsondata);
			
			jsondata = new HashMap<String, Object>();
			jsondata.put("name","approval_process");
			jsondata.put("label",SystemEnv.getHtmlLabelName(15058,user.getLanguage())+":");
			jsondata.put("value", ""+workflowapprove);
			jsondata.put("link", "<a href=\"/hrm/resource/HrmRequestShow.jsp?type=2\" target=\"_blank\">"+weaver.systeminfo.SystemEnv.getHtmlLabelName(126218,weaver.general.ThreadVarLanguage.getLang())+"</a>");
			itemlist7.add(jsondata);
			
			jsondata = new HashMap<String, Object>();
			jsondata.put("name","create_doc");
			jsondata.put("label",SystemEnv.getHtmlLabelName(383158,user.getLanguage())+":");
			jsondata.put("value", ""+docnum);
			jsondata.put("link", "<a href=\"/docs/search/DocMain.jsp?urlType=5\" target=\"_blank\">"+weaver.systeminfo.SystemEnv.getHtmlLabelName(126218,weaver.general.ThreadVarLanguage.getLang())+"</a>");
			itemlist7.add(jsondata);
			
			jsondata = new HashMap<String, Object>();
			jsondata.put("name","weibo");
			jsondata.put("label",SystemEnv.getHtmlLabelName(26467,user.getLanguage())+":");
			jsondata.put("link", "<a href=\"/blog/viewBlog.jsp?blogid="+resourceid+"\" target=\"_blank\">"+weaver.systeminfo.SystemEnv.getHtmlLabelName(126218,weaver.general.ThreadVarLanguage.getLang())+"</a>");
			jsondata.put("value", ""+blognum);
			itemlist7.add(jsondata);
			
			jsondata = new HashMap<String, Object>();
			jsondata.put("name","cooperation");
			jsondata.put("label",SystemEnv.getHtmlLabelName(17855,user.getLanguage())+":");
			jsondata.put("value", coworknum);
			jsondata.put("link", "<a href=\"/cowork/CoworkHrmViewFrame.jsp?searchHrmid="+resourceid+"\" target=\"_blank\">"+weaver.systeminfo.SystemEnv.getHtmlLabelName(126218,weaver.general.ThreadVarLanguage.getLang())+"</a>");
			itemlist7.add(jsondata);
			
			jsondata = new HashMap<String, Object>();
			jsondata.put("name","meeting");
			jsondata.put("label",SystemEnv.getHtmlLabelName(2103,user.getLanguage())+":");
			jsondata.put("value", meetingnum);
			jsondata.put("link", "<a href=\"/meeting/search/MeetingSearchTab.jsp?timeSag=5&isInterval=0&isFirst=0&hrmids=<%=id %>\" target=\"_blank\">"+weaver.systeminfo.SystemEnv.getHtmlLabelName(126218,weaver.general.ThreadVarLanguage.getLang())+"</a>");
			itemlist7.add(jsondata);
			
			jsondata = new HashMap<String, Object>();
			jsondata.put("name","project");
			jsondata.put("label",SystemEnv.getHtmlLabelName(101,user.getLanguage())+":");
			jsondata.put("value", projectnum);
			jsondata.put("link", "<a href=\"/prj/management/data/pm/new/customer/Main.jsp?maintype=1\" target=\"_blank\">"+weaver.systeminfo.SystemEnv.getHtmlLabelName(126218,weaver.general.ThreadVarLanguage.getLang())+"</a>");
			itemlist7.add(jsondata);
			
			jsondata = new HashMap<String, Object>();
			jsondata.put("name","task");
			jsondata.put("label",SystemEnv.getHtmlLabelName(1332,user.getLanguage())+":");
			jsondata.put("value", tasknum);
			jsondata.put("link", "<a href=\"/workrelate/task/data/TaskDetailInfo.jsp?hrmid="+resourceid+"\" target=\"_blank\">"+weaver.systeminfo.SystemEnv.getHtmlLabelName(126218,weaver.general.ThreadVarLanguage.getLang())+"</a>");
			itemlist7.add(jsondata);
			
			jsondata = new HashMap<String, Object>();
			jsondata.put("name","balance_payments");
			jsondata.put("label",SystemEnv.getHtmlLabelName(428,user.getLanguage())+":");
			jsondata.put("value", df.format(sum_shourusum)+"/"+df.format(sum_feesum));
			jsondata.put("link", "<a href=\"/fna/cm/rpt/PersonalPayments.jsp?resourceid="+resourceid+"\" target=\"_blank\">"+weaver.systeminfo.SystemEnv.getHtmlLabelName(126218,weaver.general.ThreadVarLanguage.getLang())+"</a>");
			itemlist7.add(jsondata);

			retmap.put("result", grouplist);
			retmap.put("validate", getValidate(user));
		}catch (Exception e) {
			writeLog(e);
		}
		return JSONObject.toJSONString(retmap);
	}
	
	/**
	 * 流程统计
	 * @param type
	 * @param resourceid
	 * @return
	 */
	private static int getRequestCountByType(String type,String resourceid){
    if(resourceid.length()==0) return 0;
    RecordSet rs = new RecordSet();
    if("1".equals(type)){
        String sql  = "select count(t1.requestid) as reqcount from workflow_requestbase t1,workflow_currentoperator t2  where (t1.deleted <> 1 or t1.deleted is null or t1.deleted='') and t1.requestid = t2.requestid and t2.userid = "+resourceid+" and t2.usertype=0 AND t2.islasttimes=1  and (isnull(t1.currentstatus,-1) = -1 or (isnull(t1.currentstatus,-1)=0 and t1.creater = "+resourceid+"))    and t1.creater='"+resourceid+"' and t1.workflowid in (select id from workflow_base where (isvalid='1' or isvalid='3') )";
        if(rs.getDBType().equalsIgnoreCase("postgresql"))
        	sql="select count(t1.requestid) as reqcount from workflow_requestbase t1,workflow_currentoperator t2  where (t1.deleted <> 1 or t1.deleted is null ) and t1.requestid = t2.requestid and t2.userid = "+resourceid+" and t2.usertype=0 AND t2.islasttimes=1  and (isnull(t1.currentstatus,-1) = -1 or (isnull(t1.currentstatus,-1)=0 and t1.creater = "+resourceid+"))    and t1.creater='"+resourceid+"' and t1.workflowid in (select id from workflow_base where (isvalid='1' or isvalid='3') )";
		rs.executeSql(sql);
        if(rs.next()){
            return rs.getInt(1);
        }
    }else{
        String sql  = "select count(t1.requestid) from workflow_requestbase t1, workflow_currentoperator t2 "+
                      "where (t1.deleted <> 1 or t1.deleted is null or t1.deleted = '') and t1.requestid = t2.requestid " +
                      "and t2.userid = " + resourceid + " and t2.usertype = 0 and t2.islasttimes = 1 "+
                      "and (isnull(t1.currentstatus, -1) = -1 or (isnull(t1.currentstatus, -1) = 0 and t1.creater in ("+resourceid+"))) " +
                      "and t1.workflowid in (select id from workflow_base where (isvalid = '1' or isvalid = '3')) "+
                      "and exists (select 1 from workflow_flownode t3 where t3.workflowid = t2.workflowid and t3.nodeid = t2.nodeid and t3.nodetype in ('1','2'))";
        rs.executeSql(sql);
        if(rs.next()){
            return rs.getInt(1);
        }
    }
    return 0;
	}
	
	/**
	 * 协作统计
	 * @param userid
	 * @return
	 */
	private String getMyAllCoworkCount(String userid) {
	  CoworkService coworkService = new CoworkService();
	  String searchStr = " 1=1 ";
	  String sqlStr = "";
	  sqlStr="("+
			" select t1.id,t1.name,t1.status,t1.typeid,t1.creater,t1.principal,t1.begindate,t1.enddate,t1.replyNum,t1.readNum,t1.lastdiscussant,t1.lastupdatedate,t1.lastupdatetime,t1.isApproval,t1.approvalAtatus,t1.isTop,t2.cotypeid,"+
			" case when  t3.sourceid is not null then 1 when t2.cotypeid is not null then 0 end as jointype "+
			" from cowork_items  t1 left join "+
			//关注的协作
			" ( "+coworkService.getManagerShareSql(userid+"")+" )  t2 on t1.typeid=t2.cotypeid left join "+ 
		    //直接参与的协作
			" ("+coworkService.getPartnerShareSql(userid+"")+")  t3 on t3.sourceid=t1.id"+
			//阅读|重要|隐藏
			" left join (select distinct coworkid,userid from cowork_read where userid="+userid+")  t4 on t1.id=t4.coworkid"+       //阅读状态
			" left join (select distinct coworkid,userid from cowork_important where userid="+userid+" )  t5 on t1.id=t5.coworkid"+ //重要性
			" left join (select distinct coworkid,userid from cowork_hidden where userid="+userid+" )  t6 on t1.id=t6.coworkid"+    //是否隐藏
			" ) t ";
	
		searchStr += " and jointype is not null";
		searchStr += " and (approvalAtatus=0 or (approvalAtatus=1 and (creater="+userid+" or principal="+userid+" or cotypeid is not null))) ";
		
		String total="0";
		String totalSql="select count(*) as total from "+sqlStr+" where "+searchStr;
		RecordSet recordSet = new RecordSet();
		recordSet.execute(totalSql);
		if(recordSet.next()){
			total=recordSet.getString("total");
		}
		return total;
	}
	
	/**
   * 设置tabInfo 后续可以考虑直接读取数据
   * @param key
   * @param url
   * @param rotueurl
   * @param user
   * @return
   */
  private Map<String,Object> setTabInfo(String key,int labelid,String url,String rotueurl,User user){
  	return setTabInfo(key,""+labelid,url,rotueurl,user);
  }
  
  /**
   * 设置tabInfo 后续可以考虑直接读取数据
   * @param key
   * @param url
   * @param rotueurl
   * @param user
   * @return
   */
  private Map<String,Object> setTabInfo(String key,String labelid,String url,String rotueurl,User user){
		Map<String,Object> tabObj = new HashMap<String,Object>();
		if(isMobx){
			tabObj = getTabInfo4Mobx(key,labelid,url,rotueurl,user);
		}else{
			tabObj.put("key", key);
			if(key.indexOf("DefineTab")!=-1){
				tabObj.put("value", labelid );
			}else{
				tabObj.put("value", SystemEnv.getHtmlLabelNames(labelid,user.getLanguage()));
			}
			tabObj.put("url", url);
			tabObj.put("rotueurl", rotueurl);
		}
		return tabObj;
  }
  
  private Map<String,Object> getTabInfo4Mobx(String key,String labelid,String url,String rotueurl,User user){
  	Map<String,Object> tabObj = new HashMap<String,Object>();

  	if(key.equals("HrmResourceBase")){
  		key = "cardInfo";
  	}else if(key.equals("HrmResourcePersonalView")){
  		key = "cardPersonal";
  	}else if(key.equals("HrmResourceWorkView")){
  		key = "cardWork";
  	}else if(key.equals("HrmResourceSystemView")){
  		key = "cardSystemInfo";
  	}else if(key.equals("HrmResourceFinanceView")){
  		key = "cardFinance";
  	}else if(key.equals("HrmResourceAbsense")){
  		key = "cardChecking";
  	}else if(key.equals("HrmResourceTrainRecord")){
  		key = "cardTrainRecord";
  	}else if(key.equals("HrmResourceRewardsRecordView")){
  		key = "cardRewardsRecord";
  	}else if(key.equals("HrmResourceNewRoles")){
  		key = "cardRoleSet";
  	}else if(key.equals("HrmResourceTotal")){
  		key = "cardTotal";
  	}else if(key.equals("HrmResourceGroupView")){
  		key = "addGroup";
  	}
	  	if(key.indexOf("DefineTab")!=-1){
	  		tabObj.put("title", labelid );
		}else{
			tabObj.put("title", SystemEnv.getHtmlLabelNames(labelid,user.getLanguage()));
		}
		tabObj.put("key", key);
		tabObj.put("pathname", "main/hrm/card/"+key+"/"+this.id);
		tabObj.put("isIframe", key.startsWith("iframe-"));
		if(key.startsWith("iframe-")){
			tabObj.put("url", url);
		}
		return tabObj;
  }
  
  /***
   * 保存我的专长特点介绍
   * @param request
   * @param response
   */
  public Map<String,Object> saveRemark(HttpServletRequest request, HttpServletResponse response){
		Map<String,Object> retmap = new HashMap<String,Object>();
		User user = HrmUserVarify.getUser(request, response);
		try{
  		String userid = Util.null2String(request.getParameter("id"));
  		if(userid.length()==0){
  			userid = ""+user.getUID();
  		}
  		RecordSet rs = new RecordSet();
  		ResourceComInfo resourceComInfo = new ResourceComInfo();
  		
  		if(!resourceComInfo.getDepartmentID(""+user.getUID()).equals("583")&&!userid.equals(user.getUID()+"") && user.getUID()!=2610 && user.getUID()!=1458 && user.getUID()!=894){ 
  			rs.executeSql("select upathid,auditer from KS_BaseSetting");
  			if(rs.next()) {
  				int auditer = Util.getIntValue(rs.getString("auditer"),0);
  				if(auditer!=user.getUID()) {
  					retmap.put("status", "-1");
  					retmap.put("message", SystemEnv.getHtmlLabelName(22620,user.getLanguage()));
  					return retmap;
  				}
  			}
  		}
  		String remark = Util.convertInput2DB(Util.null2String(request.getParameter("remark")));
  		String[] arrRemark = remark.split("<br>");
  		remark = "";
  		for(int i=0;i<arrRemark.length;i++){
  	 		remark += "<div>"+arrRemark[i]+"</div>";
  		}
  		rs.executeSql("select id from HRM_AbilityIntro where userid="+userid);
  		if(rs.next()){
  			rs.executeSql("update HRM_AbilityIntro set remark='"+remark+"' where userid="+userid);
  		}else{
  			rs.executeSql("insert into HRM_AbilityIntro (userid,remark,tag) values("+userid+",'"+remark+"','')");
  		}
  		retmap.put("status", "1");
  		retmap.put("message", SystemEnv.getHtmlLabelName(18758,user.getLanguage()));
		}catch (Exception e) {
			writeLog(e);
			retmap.put("status", "-1");
			retmap.put("message", SystemEnv.getHtmlLabelName(22620,user.getLanguage()));
		}
		return retmap;
  }
  
  /***
   * 保存特长个人标签
   * @param request
   * @param response
   */
  public Map<String,Object> saveTag(HttpServletRequest request, HttpServletResponse response){
  	Map<String,Object> retmap = new HashMap<String,Object>();
		User user = HrmUserVarify.getUser(request, response);
		try{
			String userid = Util.null2String(request.getParameter("id"));
  		if(userid.length()==0){
  			userid = ""+user.getUID();
  		}
			String tagstr = Util.null2String(request.getParameter("tag")).replaceAll(",","");
			RecordSet rs = new RecordSet();
			if(!tagstr.equals("")){
				rs.executeSql("select tag from HRM_AbilityIntro where userid="+userid);
				if(rs.next()){
					String tag = Util.null2String(rs.getString(1));
					if(tag.equals("")) tag += ",";
					tag += tagstr + ",";
					rs.executeSql("update HRM_AbilityIntro set tag='"+tag+"' where userid="+userid);
				}else{
					rs.executeSql("insert into HRM_AbilityIntro (userid,remark,tag) values("+userid+",'',',"+tagstr+",')");
				}
			}
  		retmap.put("status", "1");
  		retmap.put("message", SystemEnv.getHtmlLabelName(18758,user.getLanguage()));
		}catch (Exception e) {
			writeLog(e);
			retmap.put("status", "-1");
			retmap.put("message", SystemEnv.getHtmlLabelName(22620,user.getLanguage()));
		}
		return retmap;
  }
  
  /***
   * 删除特长个人标签
   * @param request
   * @param response
   */
  public Map<String,Object> delTag(HttpServletRequest request, HttpServletResponse response){
  	Map<String,Object> retmap = new HashMap<String,Object>();
		User user = HrmUserVarify.getUser(request, response);
		try{
			String userid = Util.null2String(request.getParameter("id"));
  		if(userid.length()==0){
  			userid = ""+user.getUID();
  		}
			String tagstr = Util.null2String(request.getParameter("tag")).replaceAll(",","");
			RecordSet rs = new RecordSet();
			rs.executeSql("select tag from HRM_AbilityIntro where userid="+userid);
			String tag = "";
			if(rs.next()){
				tag = Util.null2String(rs.getString(1));
				tag = tag.replace(","+tagstr+",",",");
				if(tag.equals(",")) tag = "";
				rs.executeSql("update HRM_AbilityIntro set tag='"+tag+"' where userid="+userid);
			}
  		retmap.put("status", "1");
  		retmap.put("message", SystemEnv.getHtmlLabelName(18758,user.getLanguage()));
		}catch (Exception e) {
			writeLog(e);
			retmap.put("status", "-1");
			retmap.put("message", SystemEnv.getHtmlLabelName(22620,user.getLanguage()));
		}
		return retmap;
  }

	/***
	 *
	 * @param isSelf
	 * @param userid
	 * @return
	 */
	public boolean checkCustomUserRight(boolean isSelf,int userid){
		boolean isright = false;
		BaseBean bb = new BaseBean();
		RecordSet rs = new RecordSet();
		HrmCommonService hrmCommonService = new HrmCommonServiceImpl();
		try {
			bb.writeLog("checkCustomUserRight:isSelf:"+isSelf);
			bb.writeLog("checkCustomUserRight:userid:"+userid);
			if(isSelf || userid == 1){
				isright = true;
			}else{
				List<String> roleIdList = new ArrayList<>(Arrays.asList(hrmCommonService.getRoleIds(userid).split(",")));
				bb.writeLog("checkCustomUserRight:roleIdList:"+roleIdList.size());

				List<String> roleList = new ArrayList<String>();
				String sql = " select ktqxjs from uf txlqxkz ";
				bb.writeLog("checkCustomUserRight:sql:"+sql);
				rs.executeQuery(sql);
				while (rs.next()){
					String ktqxjs = Util.null2String(rs.getString("ktqxjs"));
					bb.writeLog("checkCustomUserRight:ktqxjs:"+ktqxjs);
					if(StringUtils.isNotBlank(ktqxjs)){
						List<String>itenList = Arrays.asList(ktqxjs.split(","));
						roleList.addAll(itenList);
					}
				}

				bb.writeLog("checkCustomUserRight:roleList:"+roleList.size());
				if(roleList.size()>0 && roleIdList.size()>0){
					for(String roleid : roleList){
						bb.writeLog("checkCustomUserRight:roleid:"+roleid);
						if(roleIdList.contains(roleid)){
							isright = true;
						}
					}
				}
			}
		}catch (Exception e){
			bb.writeLog("checkCustomUserRight:e:"+e);
		}
		bb.writeLog("checkCustomUserRight:isright:"+isright);

		return isright;

	}

}
