|
|
|
@ -0,0 +1,845 @@
|
|
|
|
|
package com.cloudstore.dev.api.service;
|
|
|
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
|
|
import com.api.system.language.util.ParseLangDataUtil;
|
|
|
|
|
import com.cloudstore.dev.api.bean.CodeTimeBean;
|
|
|
|
|
import com.cloudstore.dev.api.util.EMManager;
|
|
|
|
|
import com.cloudstore.dev.api.util.Util_DataMap;
|
|
|
|
|
import com.cloudstore.dev.api.util.Util_public;
|
|
|
|
|
import com.cloudstore.eccom.common.WeaIndexManager;
|
|
|
|
|
import com.cloudstore.eccom.constant.WeaMessageCode;
|
|
|
|
|
import com.cloudstore.eccom.core.WeaDataChange;
|
|
|
|
|
import com.cloudstore.eccom.result.WeaResultMsg;
|
|
|
|
|
import com.cloudstore.mobile.constant.AuthTypeConstant;
|
|
|
|
|
import com.cloudstore.mobile.entity.Emobile7Response;
|
|
|
|
|
import com.cloudstore.mobile.sso.util.Emobile7SsoUtil;
|
|
|
|
|
import com.cloudstore.mobile.sso.util.TokenStore;
|
|
|
|
|
import com.engine.common.util.ParamUtil;
|
|
|
|
|
import com.engine.common.util.ServiceUtil;
|
|
|
|
|
import com.engine.ditoSsologin.service.MobileSsoLoginService;
|
|
|
|
|
import com.engine.ditoSsologin.service.impl.MobileSsoLoginServiceImpl;
|
|
|
|
|
import com.engine.msgcenter.bean.WeaVavleType;
|
|
|
|
|
import com.engine.msgcenter.util.ValveConfigManager;
|
|
|
|
|
import com.engine.organization.service.DepartmentService;
|
|
|
|
|
import com.engine.organization.service.impl.DepartmentServiceImpl;
|
|
|
|
|
import com.engine.systeminfo.util.AppSyncUtil;
|
|
|
|
|
import com.engine.systeminfo.util.IpTablesUtil;
|
|
|
|
|
import com.google.common.collect.Maps;
|
|
|
|
|
|
|
|
|
|
import java.io.*;
|
|
|
|
|
import java.net.URL;
|
|
|
|
|
import java.net.URLConnection;
|
|
|
|
|
import java.net.URLDecoder;
|
|
|
|
|
import java.security.Principal;
|
|
|
|
|
import java.util.*;
|
|
|
|
|
import javax.servlet.RequestDispatcher;
|
|
|
|
|
import javax.servlet.ServletContext;
|
|
|
|
|
import javax.servlet.ServletInputStream;
|
|
|
|
|
import javax.servlet.http.Cookie;
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
|
|
import javax.servlet.http.HttpSession;
|
|
|
|
|
import javax.ws.rs.GET;
|
|
|
|
|
import javax.ws.rs.POST;
|
|
|
|
|
import javax.ws.rs.Path;
|
|
|
|
|
import javax.ws.rs.Produces;
|
|
|
|
|
import javax.ws.rs.core.Context;
|
|
|
|
|
|
|
|
|
|
import org.apache.commons.lang.StringUtils;
|
|
|
|
|
import org.apache.commons.lang3.ObjectUtils;
|
|
|
|
|
import org.apache.commons.logging.Log;
|
|
|
|
|
import org.apache.commons.logging.LogFactory;
|
|
|
|
|
import weaver.common.util.string.StringUtil;
|
|
|
|
|
import weaver.conn.RecordSet;
|
|
|
|
|
import weaver.general.PasswordUtil;
|
|
|
|
|
import weaver.general.ThreadVarLanguage;
|
|
|
|
|
import weaver.general.Util;
|
|
|
|
|
import weaver.hrm.HrmUserVarify;
|
|
|
|
|
import weaver.hrm.OnLineMonitor;
|
|
|
|
|
import weaver.hrm.User;
|
|
|
|
|
import weaver.hrm.resource.ResourceComInfo;
|
|
|
|
|
import weaver.mobile.plugin.ecology.service.HrmResourceService;
|
|
|
|
|
import weaver.rsa.security.RSA;
|
|
|
|
|
import weaver.systeminfo.SystemEnv;
|
|
|
|
|
|
|
|
|
|
@Path("/ec/dev/app")
|
|
|
|
|
public class ServiceEC {
|
|
|
|
|
private static volatile boolean inited;
|
|
|
|
|
|
|
|
|
|
private static final Log logger = LogFactory.getLog(ServiceEC.class);
|
|
|
|
|
|
|
|
|
|
public MobileSsoLoginService getMobileSsoLoginService() {
|
|
|
|
|
return ServiceUtil.getService(MobileSsoLoginServiceImpl.class);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@POST
|
|
|
|
|
@Path("/join")
|
|
|
|
|
@Produces({"text/plain"})
|
|
|
|
|
public String systemJoin(@Context HttpServletRequest paramHttpServletRequest, @Context HttpServletResponse paramHttpServletResponse) {
|
|
|
|
|
WeaResultMsg weaResultMsg = new WeaResultMsg(false);
|
|
|
|
|
try {
|
|
|
|
|
Map<String, String> map = WeaDataChange.getRequestToMapStr(paramHttpServletRequest);
|
|
|
|
|
if (map != null) {
|
|
|
|
|
map.put("ec_version", EMManager.getEcologyVersion());
|
|
|
|
|
map.put("ec_iscluster", EMManager.getEcologyCluster() ? "1" : "0");
|
|
|
|
|
}
|
|
|
|
|
Util_DataMap.clearVal("access_token");
|
|
|
|
|
RSA rSA = new RSA();
|
|
|
|
|
if (logger.isDebugEnabled()) {
|
|
|
|
|
logger.debug("systemJoin" + map);
|
|
|
|
|
}
|
|
|
|
|
String str = RSA.getRSA_PUB();
|
|
|
|
|
map.put("rsa_pub", str);
|
|
|
|
|
EMManager eMManager = new EMManager();
|
|
|
|
|
if (eMManager.findEnableCount() > 1) {
|
|
|
|
|
return weaResultMsg.fail("" + SystemEnv.getHtmlLabelName(10004763, ThreadVarLanguage.getLang()) + "").toString();
|
|
|
|
|
}
|
|
|
|
|
JSONObject jSONObject = eMManager.systemJoin(map, map.get("em_url"));
|
|
|
|
|
if ("0".equals(jSONObject.getString("errcode"))) {
|
|
|
|
|
String str1 = jSONObject.getString("ec_id");
|
|
|
|
|
String str2 = jSONObject.getString("accesstoken");
|
|
|
|
|
Map map1 = new HashMap<>();
|
|
|
|
|
if (StringUtils.isNotBlank(str1)) {
|
|
|
|
|
map1 = EMManager.getEmobileInfo(str1);
|
|
|
|
|
}
|
|
|
|
|
map.put("ec_id", str1);
|
|
|
|
|
map.put("accesstoken", str2);
|
|
|
|
|
map.put("ec_version", EMManager.getEcologyVersion());
|
|
|
|
|
map.put("ec_iscluster", EMManager.getEcologyCluster() ? "1" : "0");
|
|
|
|
|
boolean bool = eMManager.saveOrupdateEMData(map);
|
|
|
|
|
weaResultMsg.put("savedata", Boolean.valueOf(bool));
|
|
|
|
|
eMManager.refreshDataFormDB();
|
|
|
|
|
Util_DataMap.setVal("ec_id", str1);
|
|
|
|
|
Util_DataMap.setVal("accesstoken", str2);
|
|
|
|
|
weaResultMsg.setDatas(jSONObject);
|
|
|
|
|
User user = HrmUserVarify.getUser(paramHttpServletRequest, paramHttpServletResponse);
|
|
|
|
|
try {
|
|
|
|
|
String str3 = Util.getIpAddr(paramHttpServletRequest);
|
|
|
|
|
EMManager.afterEmobileJoin(EMManager.buildBizLogContext(str3, user, map1, ParamUtil.request2Map(paramHttpServletRequest)));
|
|
|
|
|
} catch (Exception exception) {
|
|
|
|
|
exception.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
return weaResultMsg.success(SystemEnv.getHtmlLabelName(16746, user.getLanguage())).toString();
|
|
|
|
|
}
|
|
|
|
|
return weaResultMsg.fail(jSONObject.getString("errmsg"), 0).toString();
|
|
|
|
|
} catch (Exception exception) {
|
|
|
|
|
exception.printStackTrace();
|
|
|
|
|
logger.error(exception.getMessage());
|
|
|
|
|
weaResultMsg.fail("error");
|
|
|
|
|
return weaResultMsg.toString();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@GET
|
|
|
|
|
@Path("/heartbeat")
|
|
|
|
|
@Produces({"text/plain"})
|
|
|
|
|
public String systemHeartbeat(@Context HttpServletRequest paramHttpServletRequest, @Context HttpServletResponse paramHttpServletResponse) {
|
|
|
|
|
WeaResultMsg weaResultMsg = new WeaResultMsg(true);
|
|
|
|
|
weaResultMsg.success("ok");
|
|
|
|
|
return weaResultMsg.toString();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@GET
|
|
|
|
|
@Path("/rejoin")
|
|
|
|
|
@Produces({"text/plain"})
|
|
|
|
|
public String systemReJoin(@Context HttpServletRequest paramHttpServletRequest, @Context HttpServletResponse paramHttpServletResponse) {
|
|
|
|
|
WeaResultMsg weaResultMsg = new WeaResultMsg(false);
|
|
|
|
|
try {
|
|
|
|
|
Map<String, String> map = WeaDataChange.getRequestToMapStr(paramHttpServletRequest);
|
|
|
|
|
Util_DataMap.clearVal("access_token");
|
|
|
|
|
RSA rSA = new RSA();
|
|
|
|
|
String str1 = Util_DataMap.getVal("ec_id");
|
|
|
|
|
String str2 = Util_DataMap.getVal("accesstoken");
|
|
|
|
|
Map map1 = new HashMap<>();
|
|
|
|
|
if (StringUtils.isNotBlank(str1))
|
|
|
|
|
map1 = EMManager.getEmobileInfo(str1);
|
|
|
|
|
if (StringUtil.isNotNullAndEmpty(str1)) {
|
|
|
|
|
map.put("ec_id", str1);
|
|
|
|
|
map.put("accesstoken", str2);
|
|
|
|
|
}
|
|
|
|
|
String str3 = RSA.getRSA_PUB();
|
|
|
|
|
map.put("rsa_pub", str3);
|
|
|
|
|
Util_DataMap.setVal("rsa_pub", str3);
|
|
|
|
|
EMManager eMManager = new EMManager();
|
|
|
|
|
JSONObject jSONObject = eMManager.systemJoin(map);
|
|
|
|
|
if ("0".equals(jSONObject.getString("errcode"))) {
|
|
|
|
|
str1 = jSONObject.getString("ec_id");
|
|
|
|
|
str2 = jSONObject.getString("accesstoken");
|
|
|
|
|
map.put("ec_id", str1);
|
|
|
|
|
map.put("accesstoken", str2);
|
|
|
|
|
eMManager.saveOrupdateEMData(map);
|
|
|
|
|
eMManager.refreshDataFormDB();
|
|
|
|
|
Util_DataMap.setVal("ec_id", str1);
|
|
|
|
|
Util_DataMap.setVal("accesstoken", str2);
|
|
|
|
|
weaResultMsg.setDatas(jSONObject);
|
|
|
|
|
User user = HrmUserVarify.getUser(paramHttpServletRequest, paramHttpServletResponse);
|
|
|
|
|
try {
|
|
|
|
|
String str = Util.getIpAddr(paramHttpServletRequest);
|
|
|
|
|
EMManager.afterEmobileJoin(EMManager.buildBizLogContext(str, user, map1, ParamUtil.request2Map(paramHttpServletRequest)));
|
|
|
|
|
} catch (Exception exception) {
|
|
|
|
|
exception.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
return weaResultMsg.success(SystemEnv.getHtmlLabelName(16746, user.getLanguage())).toString();
|
|
|
|
|
}
|
|
|
|
|
return weaResultMsg.fail(jSONObject.getString("errmsg"), 1).toString();
|
|
|
|
|
} catch (Exception exception) {
|
|
|
|
|
exception.printStackTrace();
|
|
|
|
|
logger.error(exception.getMessage());
|
|
|
|
|
weaResultMsg.fail("error");
|
|
|
|
|
return weaResultMsg.toString();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@GET
|
|
|
|
|
@Path("/test")
|
|
|
|
|
@Produces({"text/plain"})
|
|
|
|
|
public String test(@Context HttpServletRequest paramHttpServletRequest, @Context HttpServletResponse paramHttpServletResponse) {
|
|
|
|
|
WeaResultMsg weaResultMsg = new WeaResultMsg(false);
|
|
|
|
|
try {
|
|
|
|
|
int i = Util.getIntValue(paramHttpServletRequest.getParameter("timeZoneOffset"), -100);
|
|
|
|
|
if (i != -100) {
|
|
|
|
|
int k = i / 60;
|
|
|
|
|
String str1 = "GMT" + ((k > 0) ? ("-" + k) : ("+" + (-1 * k)));
|
|
|
|
|
paramHttpServletRequest.getSession().setAttribute("timeZone", str1);
|
|
|
|
|
}
|
|
|
|
|
int j = Util.getIntValue(EMManager.checkEMFilterInWebXml(paramHttpServletRequest), 0);
|
|
|
|
|
if (j == 0 && StringUtils.isNotBlank(paramHttpServletRequest.getParameter("em_auth_code"))) {
|
|
|
|
|
|
|
|
|
|
return weaResultMsg.fail("" + SystemEnv.getHtmlLabelName(10004764, ThreadVarLanguage.getLang()) + "," + SystemEnv.getHtmlLabelName(504523, ThreadVarLanguage.getLang()) + "").toString();
|
|
|
|
|
}
|
|
|
|
|
User user = null;
|
|
|
|
|
String authCode = paramHttpServletRequest.getParameter("authCode");
|
|
|
|
|
if (StringUtils.isNotEmpty(authCode)) {
|
|
|
|
|
user = ssoLoginByAuthCode(paramHttpServletRequest);
|
|
|
|
|
} else {
|
|
|
|
|
user = HrmUserVarify.getUser(paramHttpServletRequest, paramHttpServletResponse);
|
|
|
|
|
}
|
|
|
|
|
Map map = EMManager.getEMData();
|
|
|
|
|
String str = (String) map.get("em_url");
|
|
|
|
|
if (user != null) {
|
|
|
|
|
weaResultMsg.put("em_corpid", map.get("em_corpid"));
|
|
|
|
|
weaResultMsg.put("languageType", user.getLanguage());
|
|
|
|
|
weaResultMsg.put("jemUrl", paramHttpServletRequest.getSession().getAttribute("jemUrl"));
|
|
|
|
|
weaResultMsg.put("m_access_token", paramHttpServletRequest.getAttribute("m_access_token"));
|
|
|
|
|
weaResultMsg.put("m_refresh_token", paramHttpServletRequest.getAttribute("m_refresh_token"));
|
|
|
|
|
weaResultMsg.put("mobileTokenName", AuthTypeConstant.MOBILE_TOKEN_NAME);
|
|
|
|
|
}
|
|
|
|
|
weaResultMsg.put("ec_id", map.get("ec_id"));
|
|
|
|
|
weaResultMsg.put("download", "emdownload");
|
|
|
|
|
weaResultMsg.put("filtering", Integer.valueOf(j));
|
|
|
|
|
weaResultMsg.put("costcode", Integer.valueOf(Util.getIntValue(Util.null2String(paramHttpServletRequest.getAttribute("@is_cost_code")), 0)));
|
|
|
|
|
weaResultMsg.put("em_url_open", map.get("em_url_open"));
|
|
|
|
|
if (IpTablesUtil.exist(paramHttpServletRequest.getRequestURL().toString())) {
|
|
|
|
|
weaResultMsg.put("em_url_open", str);
|
|
|
|
|
}
|
|
|
|
|
weaResultMsg.put("ec_url", IpTablesUtil.getRequestAddress(paramHttpServletRequest));
|
|
|
|
|
weaResultMsg.success("ok");
|
|
|
|
|
} catch (Exception exception) {
|
|
|
|
|
logger.info("test_error");
|
|
|
|
|
exception.printStackTrace();
|
|
|
|
|
logger.error("test:" + exception.getMessage());
|
|
|
|
|
weaResultMsg.fail("error");
|
|
|
|
|
}
|
|
|
|
|
logger.info(weaResultMsg.toString());
|
|
|
|
|
return weaResultMsg.toString();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 通过authCode获取人员信息登录
|
|
|
|
|
*/
|
|
|
|
|
private User ssoLoginByAuthCode(HttpServletRequest request) {
|
|
|
|
|
String authCode = request.getParameter("authCode");
|
|
|
|
|
HashMap<String, Object> paramMap = new HashMap<>();
|
|
|
|
|
paramMap.put("auth_code", authCode);
|
|
|
|
|
logger.info("ssoLogin_auth_code:" + authCode);
|
|
|
|
|
MobileSsoLoginService mobileSsoLoginService = getMobileSsoLoginService();
|
|
|
|
|
Map<String, Object> userInfo = mobileSsoLoginService.getUserInfo(paramMap, null);
|
|
|
|
|
Map<String, Object> userInfoData = (HashMap<String, Object>) userInfo.get("data");
|
|
|
|
|
String userCode = (String) userInfoData.get("userCode");
|
|
|
|
|
logger.info("userCode:" + userCode);
|
|
|
|
|
if (StringUtils.isNotEmpty(userCode)) {
|
|
|
|
|
RecordSet rs = new RecordSet();
|
|
|
|
|
String sql = " select * from hrmresource where workcode=?";
|
|
|
|
|
rs.executeQuery(sql, userCode);
|
|
|
|
|
if (rs.next()) {
|
|
|
|
|
User user = new User();
|
|
|
|
|
String languageidweaver = "8";
|
|
|
|
|
user.setUid(rs.getInt("id"));
|
|
|
|
|
user.setLoginid(rs.getString("loginid"));
|
|
|
|
|
user.setFirstname(rs.getString("firstname"));
|
|
|
|
|
user.setLastname(rs.getString("lastname"));
|
|
|
|
|
user.setAliasname(rs.getString("aliasname"));
|
|
|
|
|
user.setTitle(rs.getString("title"));
|
|
|
|
|
user.setTitlelocation(rs.getString("titlelocation"));
|
|
|
|
|
user.setSex(rs.getString("sex"));
|
|
|
|
|
user.setPwd(rs.getString("password"));
|
|
|
|
|
languageidweaver = rs.getString("systemlanguage");
|
|
|
|
|
user.setLanguage(Util.getIntValue(languageidweaver, 0));
|
|
|
|
|
user.setTelephone(rs.getString("telephone"));
|
|
|
|
|
user.setMobile(rs.getString("mobile"));
|
|
|
|
|
user.setMobilecall(rs.getString("mobilecall"));
|
|
|
|
|
user.setEmail(rs.getString("email"));
|
|
|
|
|
user.setCountryid(rs.getString("countryid"));
|
|
|
|
|
user.setLocationid(rs.getString("locationid"));
|
|
|
|
|
user.setResourcetype(rs.getString("resourcetype"));
|
|
|
|
|
user.setStartdate(rs.getString("startdate"));
|
|
|
|
|
user.setEnddate(rs.getString("enddate"));
|
|
|
|
|
user.setContractdate(rs.getString("contractdate"));
|
|
|
|
|
user.setJobtitle(rs.getString("jobtitle"));
|
|
|
|
|
user.setJobgroup(rs.getString("jobgroup"));
|
|
|
|
|
user.setJobactivity(rs.getString("jobactivity"));
|
|
|
|
|
user.setJoblevel(rs.getString("joblevel"));
|
|
|
|
|
user.setSeclevel(rs.getString("seclevel"));
|
|
|
|
|
user.setUserDepartment(Util.getIntValue(rs.getString("departmentid"), 0));
|
|
|
|
|
user.setUserSubCompany1(Util.getIntValue(rs.getString("subcompanyid1"), 0));
|
|
|
|
|
user.setUserSubCompany2(Util.getIntValue(rs.getString("subcompanyid2"), 0));
|
|
|
|
|
user.setUserSubCompany3(Util.getIntValue(rs.getString("subcompanyid3"), 0));
|
|
|
|
|
user.setUserSubCompany4(Util.getIntValue(rs.getString("subcompanyid4"), 0));
|
|
|
|
|
user.setManagerid(rs.getString("managerid"));
|
|
|
|
|
user.setAssistantid(rs.getString("assistantid"));
|
|
|
|
|
user.setPurchaselimit(rs.getString("purchaselimit"));
|
|
|
|
|
user.setCurrencyid(rs.getString("currencyid"));
|
|
|
|
|
user.setLastlogindate(rs.getString("currentdate"));
|
|
|
|
|
user.setLogintype("1");
|
|
|
|
|
user.setAccount(rs.getString("account"));
|
|
|
|
|
user.setLoginip(request.getRemoteAddr());
|
|
|
|
|
|
|
|
|
|
request.getSession(true).setMaxInactiveInterval(60 * 60 * 24);
|
|
|
|
|
request.getSession(true).setAttribute("weaver_user@bean", user);
|
|
|
|
|
request.getSession(true).setAttribute("moniter", new OnLineMonitor("" + user.getUID(), user.getLoginip()));
|
|
|
|
|
return user;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@POST
|
|
|
|
|
@Path("/refreshToken")
|
|
|
|
|
@Produces({"text/plain"})
|
|
|
|
|
public String refreshToken(@Context HttpServletRequest paramHttpServletRequest, @Context HttpServletResponse paramHttpServletResponse) {
|
|
|
|
|
WeaResultMsg weaResultMsg = new WeaResultMsg(false);
|
|
|
|
|
String str = paramHttpServletRequest.getParameter("m_refresh_token");
|
|
|
|
|
TokenStore tokenStore = new TokenStore();
|
|
|
|
|
try {
|
|
|
|
|
Object object = tokenStore.get(str, 2);
|
|
|
|
|
if (Objects.nonNull(object)) {
|
|
|
|
|
weaResultMsg.put("m_access_token", tokenStore.generateAccessToken(object));
|
|
|
|
|
return weaResultMsg.success().toString();
|
|
|
|
|
}
|
|
|
|
|
logger.error("无效或者过期的refresh_token>>>>" + str);
|
|
|
|
|
weaResultMsg.put("m_refresh_token", str);
|
|
|
|
|
if (Boolean.TRUE.toString().equals(Emobile7SsoUtil.getParameter(paramHttpServletRequest, "_ec_ismobile"))) {
|
|
|
|
|
weaResultMsg.fail("" + SystemEnv.getHtmlLabelName(10004765, ThreadVarLanguage.getLang()) + "refresh_token");
|
|
|
|
|
weaResultMsg.setCode(WeaMessageCode.BS_NOT_FOUND.getCode());
|
|
|
|
|
return weaResultMsg.toString();
|
|
|
|
|
}
|
|
|
|
|
return weaResultMsg.fail("" + SystemEnv.getHtmlLabelName(10004765, ThreadVarLanguage.getLang()) + "refresh_token").toString();
|
|
|
|
|
} catch (Exception exception) {
|
|
|
|
|
exception.printStackTrace();
|
|
|
|
|
logger.error(exception.getMessage());
|
|
|
|
|
weaResultMsg.fail("error");
|
|
|
|
|
return weaResultMsg.toString();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public String verify(@Context HttpServletRequest paramHttpServletRequest, @Context HttpServletResponse paramHttpServletResponse) {
|
|
|
|
|
WeaResultMsg weaResultMsg = new WeaResultMsg(false);
|
|
|
|
|
String str1 = paramHttpServletRequest.getParameter("username");
|
|
|
|
|
String str2 = paramHttpServletRequest.getParameter("pwd");
|
|
|
|
|
int i = Util.getIntValue(paramHttpServletRequest.getParameter("time"));
|
|
|
|
|
try {
|
|
|
|
|
if (PasswordUtil.checkPasswordByLoginid(str1, str2, false)) {
|
|
|
|
|
TokenStore tokenStore = new TokenStore();
|
|
|
|
|
Emobile7Response emobile7Response = new Emobile7Response();
|
|
|
|
|
HrmResourceService hrmResourceService = new HrmResourceService();
|
|
|
|
|
emobile7Response.setUserId(String.valueOf(hrmResourceService.getUserId(str1)));
|
|
|
|
|
emobile7Response.setOpenType(1);
|
|
|
|
|
if (i > 0) {
|
|
|
|
|
weaResultMsg.put("m_access_token", tokenStore.generateAccessToken(emobile7Response, i));
|
|
|
|
|
} else {
|
|
|
|
|
weaResultMsg.put("m_access_token", tokenStore.generateAccessToken(emobile7Response));
|
|
|
|
|
}
|
|
|
|
|
weaResultMsg.put("m_refresh_token", tokenStore.generateRefreshToken(emobile7Response));
|
|
|
|
|
weaResultMsg.put("mobileTokenName", AuthTypeConstant.MOBILE_TOKEN_NAME);
|
|
|
|
|
return weaResultMsg.success().toString();
|
|
|
|
|
}
|
|
|
|
|
return weaResultMsg.fail("" + SystemEnv.getHtmlLabelName(10004766, ThreadVarLanguage.getLang()) + "").toString();
|
|
|
|
|
} catch (Exception exception) {
|
|
|
|
|
exception.printStackTrace();
|
|
|
|
|
logger.error(exception.getMessage());
|
|
|
|
|
weaResultMsg.fail("error");
|
|
|
|
|
return weaResultMsg.toString();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@GET
|
|
|
|
|
@Path("/checkJoin")
|
|
|
|
|
@Produces({"text/plain"})
|
|
|
|
|
public String checkJoin(@Context HttpServletRequest paramHttpServletRequest, @Context HttpServletResponse paramHttpServletResponse) {
|
|
|
|
|
WeaResultMsg weaResultMsg = new WeaResultMsg(true);
|
|
|
|
|
weaResultMsg.putAll(ValveConfigManager.getTypeValves(WeaVavleType.JOIN.getValue()));
|
|
|
|
|
weaResultMsg.putAll(ValveConfigManager.getTypeValves(WeaVavleType.SHARE.getValue()));
|
|
|
|
|
weaResultMsg.put("joinStatus", Boolean.valueOf(EMManager.getJoinStatus(true)));
|
|
|
|
|
return weaResultMsg.toString();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@POST
|
|
|
|
|
@Path("/setValue")
|
|
|
|
|
@Produces({"text/plain"})
|
|
|
|
|
public String setValve(@Context HttpServletRequest paramHttpServletRequest, @Context HttpServletResponse paramHttpServletResponse) {
|
|
|
|
|
WeaResultMsg weaResultMsg = new WeaResultMsg(false);
|
|
|
|
|
try {
|
|
|
|
|
String str1 = paramHttpServletRequest.getParameter("key");
|
|
|
|
|
if (StringUtils.isBlank(str1)) {
|
|
|
|
|
str1 = "emSwitch";
|
|
|
|
|
}
|
|
|
|
|
String str2 = paramHttpServletRequest.getParameter("value");
|
|
|
|
|
if (StringUtils.isBlank(str1)) {
|
|
|
|
|
str2 = "0";
|
|
|
|
|
}
|
|
|
|
|
ValveConfigManager.setValve(str1, str2);
|
|
|
|
|
weaResultMsg.success();
|
|
|
|
|
} catch (Exception exception) {
|
|
|
|
|
exception.printStackTrace();
|
|
|
|
|
logger.error(exception.getMessage());
|
|
|
|
|
weaResultMsg.fail("error");
|
|
|
|
|
}
|
|
|
|
|
return weaResultMsg.toString();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@POST
|
|
|
|
|
@Path("/saveSystemInfo")
|
|
|
|
|
@Produces({"text/plain"})
|
|
|
|
|
public String saveSystemInfo(@Context HttpServletRequest paramHttpServletRequest, @Context HttpServletResponse paramHttpServletResponse) {
|
|
|
|
|
WeaResultMsg weaResultMsg = new WeaResultMsg(false);
|
|
|
|
|
try {
|
|
|
|
|
Map map = WeaDataChange.getRequestToMapStr(paramHttpServletRequest);
|
|
|
|
|
EMManager eMManager = new EMManager();
|
|
|
|
|
eMManager.saveOrupdateEMData(map);
|
|
|
|
|
weaResultMsg.success("ok");
|
|
|
|
|
} catch (Exception exception) {
|
|
|
|
|
exception.printStackTrace();
|
|
|
|
|
logger.error(exception.getMessage());
|
|
|
|
|
weaResultMsg.fail("error");
|
|
|
|
|
}
|
|
|
|
|
return weaResultMsg.toString();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@POST
|
|
|
|
|
@Path("/updateSystemInfo")
|
|
|
|
|
@Produces({"text/plain"})
|
|
|
|
|
public String updateSystemInfo(@Context HttpServletRequest paramHttpServletRequest, @Context HttpServletResponse paramHttpServletResponse) {
|
|
|
|
|
WeaResultMsg weaResultMsg = new WeaResultMsg(false);
|
|
|
|
|
try {
|
|
|
|
|
Map map = WeaDataChange.getRequestToMapStr(paramHttpServletRequest);
|
|
|
|
|
EMManager eMManager = new EMManager();
|
|
|
|
|
eMManager.saveOrupdateEMData(map);
|
|
|
|
|
weaResultMsg.success("ok");
|
|
|
|
|
} catch (Exception exception) {
|
|
|
|
|
exception.printStackTrace();
|
|
|
|
|
weaResultMsg.fail("error");
|
|
|
|
|
}
|
|
|
|
|
return weaResultMsg.toString();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@GET
|
|
|
|
|
@Path("/refreshSystemInfo")
|
|
|
|
|
@Produces({"text/plain"})
|
|
|
|
|
public String refreshSystemInfo(@Context HttpServletRequest paramHttpServletRequest, @Context HttpServletResponse paramHttpServletResponse) {
|
|
|
|
|
WeaResultMsg weaResultMsg = new WeaResultMsg(false);
|
|
|
|
|
try {
|
|
|
|
|
EMManager eMManager = new EMManager();
|
|
|
|
|
Map map = eMManager.refreshDataFormDB();
|
|
|
|
|
weaResultMsg.setDatas(map);
|
|
|
|
|
weaResultMsg.success();
|
|
|
|
|
} catch (Exception exception) {
|
|
|
|
|
exception.printStackTrace();
|
|
|
|
|
logger.error(exception.getMessage());
|
|
|
|
|
weaResultMsg.fail("error");
|
|
|
|
|
}
|
|
|
|
|
return weaResultMsg.toString();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@GET
|
|
|
|
|
@Path("/getSystemInfo")
|
|
|
|
|
@Produces({"text/plain"})
|
|
|
|
|
public String getSystemInfo(@Context HttpServletRequest paramHttpServletRequest, @Context HttpServletResponse paramHttpServletResponse) {
|
|
|
|
|
WeaResultMsg weaResultMsg = new WeaResultMsg(false);
|
|
|
|
|
try {
|
|
|
|
|
EMManager eMManager = new EMManager();
|
|
|
|
|
Map map = EMManager.getEMData();
|
|
|
|
|
weaResultMsg.setDatas(map);
|
|
|
|
|
weaResultMsg.success();
|
|
|
|
|
} catch (Exception exception) {
|
|
|
|
|
exception.printStackTrace();
|
|
|
|
|
logger.error(exception.getMessage());
|
|
|
|
|
weaResultMsg.fail("error");
|
|
|
|
|
}
|
|
|
|
|
return weaResultMsg.toString();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@GET
|
|
|
|
|
@Path("/getToken")
|
|
|
|
|
@Produces({"text/plain"})
|
|
|
|
|
public String getToken(@Context HttpServletRequest paramHttpServletRequest, @Context HttpServletResponse paramHttpServletResponse) {
|
|
|
|
|
JSONObject jSONObject = new JSONObject();
|
|
|
|
|
jSONObject.put("status", Boolean.valueOf(true));
|
|
|
|
|
try {
|
|
|
|
|
User user = HrmUserVarify.getUser(paramHttpServletRequest, paramHttpServletResponse);
|
|
|
|
|
if (user == null) {
|
|
|
|
|
jSONObject.put("msg", "" + SystemEnv.getHtmlLabelName(10004767, ThreadVarLanguage.getLang()) + "");
|
|
|
|
|
jSONObject.put("datas", new ArrayList());
|
|
|
|
|
}
|
|
|
|
|
} catch (Exception exception) {
|
|
|
|
|
exception.printStackTrace();
|
|
|
|
|
logger.error(exception.getMessage());
|
|
|
|
|
jSONObject.put("status", Boolean.valueOf(false));
|
|
|
|
|
}
|
|
|
|
|
return JSON.toJSONString(jSONObject);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@POST
|
|
|
|
|
@Path("/checkSSOCode")
|
|
|
|
|
@Produces({"application/json"})
|
|
|
|
|
public String checkSSOCode(@Context HttpServletRequest paramHttpServletRequest, @Context HttpServletResponse paramHttpServletResponse) {
|
|
|
|
|
WeaResultMsg weaResultMsg = new WeaResultMsg(false);
|
|
|
|
|
try {
|
|
|
|
|
String str1 = new String(Util_public.readInputStream((InputStream) paramHttpServletRequest.getInputStream()), "UTF-8");
|
|
|
|
|
Map map = (Map) JSON.parseObject(str1, Map.class);
|
|
|
|
|
String str2 = (String) map.get("auth_code");
|
|
|
|
|
CodeTimeBean codeTimeBean = null;
|
|
|
|
|
Object object = Util_DataMap.getObjVal(str2);
|
|
|
|
|
if (object == null) {
|
|
|
|
|
codeTimeBean = loadCodeFromDB(str2);
|
|
|
|
|
} else {
|
|
|
|
|
codeTimeBean = (CodeTimeBean) object;
|
|
|
|
|
}
|
|
|
|
|
if (codeTimeBean == null) {
|
|
|
|
|
weaResultMsg.fail("not found code");
|
|
|
|
|
weaResultMsg.put("errcode", Integer.valueOf(2));
|
|
|
|
|
weaResultMsg.put("errmsg", "EM" + SystemEnv.getHtmlLabelName(10004768, ThreadVarLanguage.getLang()) + "");
|
|
|
|
|
weaResultMsg.put("auth_code", str2);
|
|
|
|
|
logger.error("not found code:" + str2);
|
|
|
|
|
return weaResultMsg.toString();
|
|
|
|
|
}
|
|
|
|
|
long l = System.currentTimeMillis();
|
|
|
|
|
if (l - codeTimeBean.getTime() < 300000L) {
|
|
|
|
|
weaResultMsg.put("UserId", Integer.valueOf(codeTimeBean.getUserId()));
|
|
|
|
|
weaResultMsg.success("ok");
|
|
|
|
|
weaResultMsg.put("errcode", Integer.valueOf(0));
|
|
|
|
|
weaResultMsg.put("errmsg", "ok");
|
|
|
|
|
} else {
|
|
|
|
|
weaResultMsg.fail("time out");
|
|
|
|
|
weaResultMsg.put("errcode", Integer.valueOf(1));
|
|
|
|
|
logger.error("time out code is:" + str2);
|
|
|
|
|
weaResultMsg.put("errmsg", "time out");
|
|
|
|
|
}
|
|
|
|
|
} catch (Exception exception) {
|
|
|
|
|
exception.printStackTrace();
|
|
|
|
|
logger.error(exception.getMessage());
|
|
|
|
|
weaResultMsg.fail("error");
|
|
|
|
|
weaResultMsg.put("errcode", Integer.valueOf(3));
|
|
|
|
|
weaResultMsg.put("errmsg", "error");
|
|
|
|
|
}
|
|
|
|
|
return weaResultMsg.toString();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public CodeTimeBean loadCodeFromDB(String paramString) {
|
|
|
|
|
RecordSet recordSet = new RecordSet();
|
|
|
|
|
recordSet.executeQuery("select obj from ECOLOGY_BIZ_CACHECODE where id=?", new Object[]{paramString});
|
|
|
|
|
CodeTimeBean codeTimeBean = null;
|
|
|
|
|
if (recordSet.next()) {
|
|
|
|
|
String str = recordSet.getString("obj");
|
|
|
|
|
try {
|
|
|
|
|
if (StringUtil.isNotNullAndEmpty(str))
|
|
|
|
|
codeTimeBean = (CodeTimeBean) JSON.parseObject(str, CodeTimeBean.class);
|
|
|
|
|
} catch (Exception exception) {
|
|
|
|
|
logger.error("数据实列化失败");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return codeTimeBean;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public boolean saveCodeToDB(String paramString, CodeTimeBean paramCodeTimeBean) {
|
|
|
|
|
if (!inited) {
|
|
|
|
|
inited = true;
|
|
|
|
|
try {
|
|
|
|
|
Timer timer = new Timer();
|
|
|
|
|
timer.schedule((TimerTask) new Object(), 5000L, 43200000L);
|
|
|
|
|
} catch (Exception exception) {
|
|
|
|
|
exception.printStackTrace();
|
|
|
|
|
logger.error("clear em code task begin fail...e:" + exception.getMessage());
|
|
|
|
|
inited = false;
|
|
|
|
|
clear();
|
|
|
|
|
}
|
|
|
|
|
logger.info("clear em code task is start success...");
|
|
|
|
|
}
|
|
|
|
|
RecordSet recordSet = new RecordSet();
|
|
|
|
|
Date date = new Date();
|
|
|
|
|
return recordSet.executeUpdate("insert into ECOLOGY_BIZ_CACHECODE(id,obj,outtime) values(?,?,?)", new Object[]{paramString, JSON.toJSONString(paramCodeTimeBean), Long.valueOf(date.getTime() + 3600000L)});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static boolean clear() {
|
|
|
|
|
RecordSet recordSet = new RecordSet();
|
|
|
|
|
recordSet.executeUpdate("delete from ECOLOGY_BIZ_CACHECODE where outtime<? ", new Object[]{Long.valueOf((new Date()).getTime())});
|
|
|
|
|
return recordSet.next();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@GET
|
|
|
|
|
@Path("/getSSOCode")
|
|
|
|
|
@Produces({"text/plain"})
|
|
|
|
|
public String getSSOCode(@Context HttpServletRequest paramHttpServletRequest, @Context HttpServletResponse paramHttpServletResponse) {
|
|
|
|
|
WeaResultMsg weaResultMsg = new WeaResultMsg(false);
|
|
|
|
|
try {
|
|
|
|
|
User user = HrmUserVarify.getUser(paramHttpServletRequest, paramHttpServletResponse);
|
|
|
|
|
if (user == null) {
|
|
|
|
|
weaResultMsg.fail("" + SystemEnv.getHtmlLabelName(10004767, ThreadVarLanguage.getLang()) + "");
|
|
|
|
|
return weaResultMsg.toString();
|
|
|
|
|
}
|
|
|
|
|
String str1 = WeaIndexManager.getGuid();
|
|
|
|
|
CodeTimeBean codeTimeBean = new CodeTimeBean();
|
|
|
|
|
codeTimeBean.setUserId(user.getUID());
|
|
|
|
|
codeTimeBean.setTime(System.currentTimeMillis());
|
|
|
|
|
Util_DataMap.setObjValAuto(str1, codeTimeBean, 300);
|
|
|
|
|
saveCodeToDB(str1, codeTimeBean);
|
|
|
|
|
String str2 = Util.null2String(Util.getCookie(paramHttpServletRequest, "cacheAccount"));
|
|
|
|
|
String str3 = Util.getCookie(paramHttpServletRequest, "cachePassword");
|
|
|
|
|
if (str2.length() > 0) {
|
|
|
|
|
|
|
|
|
|
str2 = URLDecoder.decode(str2, "UTF-8");
|
|
|
|
|
}
|
|
|
|
|
weaResultMsg.put("isRememberAccount", Util.getCookie(paramHttpServletRequest, "isRememberAccount"));
|
|
|
|
|
weaResultMsg.put("isRememberPassword", Util.getCookie(paramHttpServletRequest, "isRememberPassword"));
|
|
|
|
|
weaResultMsg.put("cacheAccount", str2);
|
|
|
|
|
weaResultMsg.put("cachePassword", str3);
|
|
|
|
|
weaResultMsg.put("langid", ParseLangDataUtil.converteEmLangtype(user.getLanguage()));
|
|
|
|
|
weaResultMsg.put("keycode", str1);
|
|
|
|
|
weaResultMsg.success();
|
|
|
|
|
} catch (Exception exception) {
|
|
|
|
|
exception.printStackTrace();
|
|
|
|
|
logger.error(exception.getMessage());
|
|
|
|
|
weaResultMsg.fail("error");
|
|
|
|
|
}
|
|
|
|
|
return weaResultMsg.toString();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@GET
|
|
|
|
|
@Path("/getUserInfo")
|
|
|
|
|
@Produces({"text/plain"})
|
|
|
|
|
public String getUserInfo(@Context HttpServletRequest paramHttpServletRequest, @Context HttpServletResponse paramHttpServletResponse) {
|
|
|
|
|
JSONObject jSONObject = new JSONObject();
|
|
|
|
|
jSONObject.put("status", Boolean.valueOf(true));
|
|
|
|
|
try {
|
|
|
|
|
User user = HrmUserVarify.getUser(paramHttpServletRequest, paramHttpServletResponse);
|
|
|
|
|
if (user == null) {
|
|
|
|
|
jSONObject.put("msg", "" + SystemEnv.getHtmlLabelName(10004767, ThreadVarLanguage.getLang()) + "");
|
|
|
|
|
} else {
|
|
|
|
|
jSONObject.put("userid", Integer.valueOf(user.getUID()));
|
|
|
|
|
jSONObject.put("loginid", user.getLoginid());
|
|
|
|
|
ResourceComInfo resourceComInfo = new ResourceComInfo();
|
|
|
|
|
if ("1".equals(resourceComInfo.getAccountType(String.valueOf(user.getUID())).trim())) {
|
|
|
|
|
jSONObject.put("isSubAccount", Boolean.valueOf(true));
|
|
|
|
|
}
|
|
|
|
|
jSONObject.put("isAdmin", Boolean.valueOf(user.isAdmin()));
|
|
|
|
|
}
|
|
|
|
|
} catch (Exception exception) {
|
|
|
|
|
exception.printStackTrace();
|
|
|
|
|
logger.error(exception.getMessage());
|
|
|
|
|
jSONObject.put("status", Boolean.valueOf(false));
|
|
|
|
|
}
|
|
|
|
|
return JSON.toJSONString(jSONObject);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@POST
|
|
|
|
|
@Path("/getCheckSystemInfo")
|
|
|
|
|
@Produces({"application/json"})
|
|
|
|
|
public String getEMCheckSystemInfo(@Context HttpServletRequest paramHttpServletRequest, @Context HttpServletResponse paramHttpServletResponse) {
|
|
|
|
|
WeaResultMsg weaResultMsg = new WeaResultMsg(false);
|
|
|
|
|
try {
|
|
|
|
|
String str1 = new String(Util_public.readInputStream((InputStream) paramHttpServletRequest.getInputStream()), "UTF-8");
|
|
|
|
|
Map map1 = (Map) JSON.parseObject(str1, Map.class);
|
|
|
|
|
String str2 = (String) map1.get("rsa_encrypt");
|
|
|
|
|
if (logger.isDebugEnabled()) {
|
|
|
|
|
logger.debug("rsa_encrypt:" + str2);
|
|
|
|
|
}
|
|
|
|
|
if (!map1.containsKey("rsa_encrypt")) {
|
|
|
|
|
weaResultMsg.put("errcode", Integer.valueOf(1));
|
|
|
|
|
weaResultMsg.put("errmsg", "Not found rsa_encrypt");
|
|
|
|
|
logger.error("Not found rsa_encrypt");
|
|
|
|
|
return weaResultMsg.toString();
|
|
|
|
|
}
|
|
|
|
|
EMManager eMManager = new EMManager();
|
|
|
|
|
Map map2 = EMManager.getEMData();
|
|
|
|
|
String str3 = (String) map2.get("accesstoken");
|
|
|
|
|
String str4 = (String) map2.get("em_url");
|
|
|
|
|
String str5 = (String) map2.get("em_url_open");
|
|
|
|
|
String str6 = (String) map2.get("em_corpid");
|
|
|
|
|
RSA rSA = new RSA();
|
|
|
|
|
String str7 = rSA.decrypt(null, str2, true);
|
|
|
|
|
weaResultMsg.put("errcode", Integer.valueOf(0));
|
|
|
|
|
weaResultMsg.put("errmsg", "ok");
|
|
|
|
|
weaResultMsg.put("ec_version", EMManager.getEcologyVersion());
|
|
|
|
|
int i = Util.getIntValue(EMManager.getEcologyCluster() ? "1" : "0", 0);
|
|
|
|
|
weaResultMsg.put("ec_iscluster", Integer.valueOf(i));
|
|
|
|
|
weaResultMsg.put("ec_keys", Integer.valueOf((i == 1) ? (EMManager.isSoftlinkKeys() ? 1 : 0) : 1));
|
|
|
|
|
weaResultMsg.put("ec_emfilter", Integer.valueOf(Util.getIntValue(EMManager.checkEMFilterInWebXml(paramHttpServletRequest), 0)));
|
|
|
|
|
weaResultMsg.put("ec_servertime", Long.valueOf((new Date()).getTime()));
|
|
|
|
|
String str8 = null;
|
|
|
|
|
try {
|
|
|
|
|
String str9 = paramHttpServletRequest.getRealPath("/") + "mobile/jem.js";
|
|
|
|
|
String str10 = str4 + "/open/js/jem.js";
|
|
|
|
|
try {
|
|
|
|
|
downloadJS(str9, str10);
|
|
|
|
|
} catch (Exception exception) {
|
|
|
|
|
logger.info("jem.js文件下载失败");
|
|
|
|
|
}
|
|
|
|
|
JSONObject jSONObject = EMManager.getToken(str6, str3);
|
|
|
|
|
logger.error("getToken");
|
|
|
|
|
if ("0".equals(jSONObject.getString("errcode"))) {
|
|
|
|
|
str8 = jSONObject.getString("access_token");
|
|
|
|
|
logger.error("setJoinStatus");
|
|
|
|
|
EMManager.setJoinStatus(true);
|
|
|
|
|
} else {
|
|
|
|
|
logger.error(jSONObject.toJSONString());
|
|
|
|
|
}
|
|
|
|
|
} catch (Exception exception) {
|
|
|
|
|
exception.printStackTrace();
|
|
|
|
|
logger.error("accesstoken:" + exception.getMessage());
|
|
|
|
|
str8 = null;
|
|
|
|
|
}
|
|
|
|
|
weaResultMsg.put("ec_gettoken", Integer.valueOf(StringUtils.isNotBlank(str8) ? 1 : 0));
|
|
|
|
|
weaResultMsg.put("em_url", str4);
|
|
|
|
|
weaResultMsg.put("em_url_open", str5);
|
|
|
|
|
weaResultMsg.put("em_corpid", str6);
|
|
|
|
|
weaResultMsg.put("rsa_decrypt", str7);
|
|
|
|
|
weaResultMsg.success();
|
|
|
|
|
} catch (Exception exception) {
|
|
|
|
|
exception.printStackTrace();
|
|
|
|
|
logger.error(exception.getMessage());
|
|
|
|
|
weaResultMsg.fail("error");
|
|
|
|
|
}
|
|
|
|
|
logger.error("data:" + weaResultMsg.toString());
|
|
|
|
|
return weaResultMsg.toString();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@POST
|
|
|
|
|
@Path("/emjoin")
|
|
|
|
|
@Produces({"application/json"})
|
|
|
|
|
public String systemEMJoin(@Context HttpServletRequest paramHttpServletRequest, @Context HttpServletResponse paramHttpServletResponse) {
|
|
|
|
|
WeaResultMsg weaResultMsg = new WeaResultMsg(false);
|
|
|
|
|
try {
|
|
|
|
|
Map map = new HashMap<>();
|
|
|
|
|
Map<String, String> map1 = WeaDataChange.getRequestBodyToMapStr(paramHttpServletRequest);
|
|
|
|
|
String str1 = paramHttpServletRequest.getRealPath("/") + "mobile/jem.js";
|
|
|
|
|
String str2 = (String) map1.get("em_url") + "/open/js/jem.js";
|
|
|
|
|
try {
|
|
|
|
|
downloadJS(str1, str2);
|
|
|
|
|
} catch (Exception exception) {
|
|
|
|
|
logger.info("jem.js文件下载失败");
|
|
|
|
|
}
|
|
|
|
|
String str3 = (String) map1.get("ec_loginid");
|
|
|
|
|
String str4 = (String) map1.get("ec_password");
|
|
|
|
|
String str5 = (String) map1.get("ec_id");
|
|
|
|
|
String str6 = (String) map1.get("workbench_agentid");
|
|
|
|
|
if (StringUtils.isNotBlank(str5)) {
|
|
|
|
|
map = EMManager.getEmobileInfo(str5);
|
|
|
|
|
}
|
|
|
|
|
String str7 = RSA.getRSA_PUB();
|
|
|
|
|
EMManager eMManager = new EMManager();
|
|
|
|
|
if (PasswordUtil.checkPasswordByLoginid(str3, str4, true)) {
|
|
|
|
|
Map<String, String> map2 = EMManager.getEMData();
|
|
|
|
|
weaResultMsg.put("rsa_pub", str7);
|
|
|
|
|
map1.put("rsa_pub", str7);
|
|
|
|
|
map1.put("ec_version", EMManager.getEcologyVersion());
|
|
|
|
|
map1.put("ec_iscluster", EMManager.getEcologyCluster() ? "1" : "0");
|
|
|
|
|
map1.put("workbench_agentid", str6);
|
|
|
|
|
map1.put("em_name", "emobile7");
|
|
|
|
|
map2.putAll(map1);
|
|
|
|
|
eMManager.saveOrupdateEMData(map2);
|
|
|
|
|
eMManager.refreshDataFormDB();
|
|
|
|
|
EMManager.setJoinStatus(false);
|
|
|
|
|
try {
|
|
|
|
|
String str = Util.getIpAddr(paramHttpServletRequest);
|
|
|
|
|
HrmResourceService hrmResourceService = new HrmResourceService();
|
|
|
|
|
User user = hrmResourceService.getUserById(hrmResourceService.getUserId(str3));
|
|
|
|
|
HashMap hashMap = Maps.newHashMap();
|
|
|
|
|
map1.forEach((paramString1, paramString2) -> hashMap.put(paramString1, paramString2));
|
|
|
|
|
EMManager.afterEmobileJoin(EMManager.buildBizLogContext(str, user, map, hashMap));
|
|
|
|
|
} catch (Exception exception) {
|
|
|
|
|
exception.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
if (!StringUtils.isBlank(str6)) {
|
|
|
|
|
weaResultMsg.put("workbench_url", AppSyncUtil.getWorkbenchUrl("1"));
|
|
|
|
|
weaResultMsg.put("workbench_url_pc", AppSyncUtil.getWorkbenchUrl("2"));
|
|
|
|
|
}
|
|
|
|
|
weaResultMsg.put("errcode", "0");
|
|
|
|
|
weaResultMsg.put("errmsg", "ok");
|
|
|
|
|
return weaResultMsg.success("ok").toString();
|
|
|
|
|
}
|
|
|
|
|
weaResultMsg.put("errcode", "1");
|
|
|
|
|
weaResultMsg.put("errmsg", "account or password error");
|
|
|
|
|
return weaResultMsg.fail("ok").toString();
|
|
|
|
|
} catch (Exception exception) {
|
|
|
|
|
exception.printStackTrace();
|
|
|
|
|
logger.error(exception.getMessage());
|
|
|
|
|
weaResultMsg.fail("error");
|
|
|
|
|
return weaResultMsg.toString();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@GET
|
|
|
|
|
@Path("/getModuleList")
|
|
|
|
|
@Produces({"text/plain"})
|
|
|
|
|
public String getModuleList(@Context HttpServletRequest paramHttpServletRequest, @Context HttpServletResponse paramHttpServletResponse) {
|
|
|
|
|
WeaResultMsg weaResultMsg = new WeaResultMsg(false);
|
|
|
|
|
try {
|
|
|
|
|
String str = " select eba.*, ebat.module as moduleid, ebat.apptype as typename, ebam.name as modulename from ecology_biz_app eba left join ecology_biz_app_type ebat on eba.apptype=ebat.id left join ecology_biz_app_module ebam on ebat.module=ebam.id where eba.status='y' ";
|
|
|
|
|
RecordSet recordSet = new RecordSet();
|
|
|
|
|
recordSet.execute(str);
|
|
|
|
|
List list = WeaDataChange.getRecordToMapListUpperCase(recordSet);
|
|
|
|
|
weaResultMsg.put("data", list);
|
|
|
|
|
weaResultMsg.success();
|
|
|
|
|
} catch (Exception exception) {
|
|
|
|
|
exception.printStackTrace();
|
|
|
|
|
logger.error(exception.getMessage());
|
|
|
|
|
weaResultMsg.fail("error");
|
|
|
|
|
}
|
|
|
|
|
return weaResultMsg.toString();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void downloadJS(String paramString1, String paramString2) throws IOException {
|
|
|
|
|
if (!paramString2.startsWith("http")) {
|
|
|
|
|
|
|
|
|
|
throw new RuntimeException("请求地址不正确");
|
|
|
|
|
}
|
|
|
|
|
logger.info("filePath : " + paramString1 + "urlPath : " + paramString2);
|
|
|
|
|
int i = 0;
|
|
|
|
|
int j = 0;
|
|
|
|
|
URL uRL = new URL(paramString2);
|
|
|
|
|
InputStream inputStream = null;
|
|
|
|
|
FileOutputStream fileOutputStream = null;
|
|
|
|
|
try {
|
|
|
|
|
URLConnection uRLConnection = uRL.openConnection();
|
|
|
|
|
inputStream = uRLConnection.getInputStream();
|
|
|
|
|
fileOutputStream = new FileOutputStream(paramString1);
|
|
|
|
|
byte[] arrayOfByte = new byte[1204];
|
|
|
|
|
while ((i = inputStream.read(arrayOfByte)) != -1) {
|
|
|
|
|
j += i;
|
|
|
|
|
fileOutputStream.write(arrayOfByte, 0, i);
|
|
|
|
|
}
|
|
|
|
|
} catch (FileNotFoundException fileNotFoundException) {
|
|
|
|
|
logger.info("文件路径未找到...");
|
|
|
|
|
} catch (IOException iOException) {
|
|
|
|
|
logger.info("文件下载出错...");
|
|
|
|
|
} finally {
|
|
|
|
|
if (inputStream != null) {
|
|
|
|
|
inputStream.close();
|
|
|
|
|
}
|
|
|
|
|
if (fileOutputStream != null) {
|
|
|
|
|
fileOutputStream.close();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|