浩鲸单点及菜单推送

feature-LeeD-20221025
李栋 2 years ago
parent cf62f82a90
commit 17ff0f44e6

@ -0,0 +1,124 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Palette2">
<group name="Swing">
<item class="com.intellij.uiDesigner.HSpacer" tooltip-text="Horizontal Spacer" icon="/com/intellij/uiDesigner/icons/hspacer.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="1" hsize-policy="6" anchor="0" fill="1" />
</item>
<item class="com.intellij.uiDesigner.VSpacer" tooltip-text="Vertical Spacer" icon="/com/intellij/uiDesigner/icons/vspacer.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="1" anchor="0" fill="2" />
</item>
<item class="javax.swing.JPanel" icon="/com/intellij/uiDesigner/icons/panel.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3" />
</item>
<item class="javax.swing.JScrollPane" icon="/com/intellij/uiDesigner/icons/scrollPane.png" removable="false" auto-create-binding="false" can-attach-label="true">
<default-constraints vsize-policy="7" hsize-policy="7" anchor="0" fill="3" />
</item>
<item class="javax.swing.JButton" icon="/com/intellij/uiDesigner/icons/button.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="3" anchor="0" fill="1" />
<initial-values>
<property name="text" value="Button" />
</initial-values>
</item>
<item class="javax.swing.JRadioButton" icon="/com/intellij/uiDesigner/icons/radioButton.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
<initial-values>
<property name="text" value="RadioButton" />
</initial-values>
</item>
<item class="javax.swing.JCheckBox" icon="/com/intellij/uiDesigner/icons/checkBox.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
<initial-values>
<property name="text" value="CheckBox" />
</initial-values>
</item>
<item class="javax.swing.JLabel" icon="/com/intellij/uiDesigner/icons/label.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="0" anchor="8" fill="0" />
<initial-values>
<property name="text" value="Label" />
</initial-values>
</item>
<item class="javax.swing.JTextField" icon="/com/intellij/uiDesigner/icons/textField.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
<preferred-size width="150" height="-1" />
</default-constraints>
</item>
<item class="javax.swing.JPasswordField" icon="/com/intellij/uiDesigner/icons/passwordField.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
<preferred-size width="150" height="-1" />
</default-constraints>
</item>
<item class="javax.swing.JFormattedTextField" icon="/com/intellij/uiDesigner/icons/formattedTextField.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
<preferred-size width="150" height="-1" />
</default-constraints>
</item>
<item class="javax.swing.JTextArea" icon="/com/intellij/uiDesigner/icons/textArea.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JTextPane" icon="/com/intellij/uiDesigner/icons/textPane.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JEditorPane" icon="/com/intellij/uiDesigner/icons/editorPane.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JComboBox" icon="/com/intellij/uiDesigner/icons/comboBox.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="2" anchor="8" fill="1" />
</item>
<item class="javax.swing.JTable" icon="/com/intellij/uiDesigner/icons/table.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JList" icon="/com/intellij/uiDesigner/icons/list.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="2" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JTree" icon="/com/intellij/uiDesigner/icons/tree.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JTabbedPane" icon="/com/intellij/uiDesigner/icons/tabbedPane.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
<preferred-size width="200" height="200" />
</default-constraints>
</item>
<item class="javax.swing.JSplitPane" icon="/com/intellij/uiDesigner/icons/splitPane.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
<preferred-size width="200" height="200" />
</default-constraints>
</item>
<item class="javax.swing.JSpinner" icon="/com/intellij/uiDesigner/icons/spinner.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
</item>
<item class="javax.swing.JSlider" icon="/com/intellij/uiDesigner/icons/slider.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
</item>
<item class="javax.swing.JSeparator" icon="/com/intellij/uiDesigner/icons/separator.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3" />
</item>
<item class="javax.swing.JProgressBar" icon="/com/intellij/uiDesigner/icons/progressbar.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1" />
</item>
<item class="javax.swing.JToolBar" icon="/com/intellij/uiDesigner/icons/toolbar.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1">
<preferred-size width="-1" height="20" />
</default-constraints>
</item>
<item class="javax.swing.JToolBar$Separator" icon="/com/intellij/uiDesigner/icons/toolbarSeparator.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="0" anchor="0" fill="1" />
</item>
<item class="javax.swing.JScrollBar" icon="/com/intellij/uiDesigner/icons/scrollbar.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="0" anchor="0" fill="2" />
</item>
</group>
</component>
</project>

@ -17,8 +17,8 @@
<service>
<name>ServiceMessageCustom</name>
<namespace>http://localhost/services/ServiceMessageCustom</namespace>
<serviceClass>com.cloudstore.dev.api.service.ServiceMessageCustom</serviceClass>
<implementationClass>com.cloudstore.dev.api.service.ServiceMessageCustomImpl</implementationClass>
<serviceClass>com.com.cloudstore.dev.api.service.ServiceMessageCustom</serviceClass>
<implementationClass>com.com.cloudstore.dev.api.service.ServiceMessageCustomImpl</implementationClass>
</service>
<service>
<name>WorkflowService</name>

@ -1,12 +0,0 @@
package com.api.dito.web;
import javax.ws.rs.Path;
/**
* @author Lee
*/
@Path("/dito/ssologin/action")
public class SsoLoginAction extends com.engine.ditoSsologin.web.SsoLoginAction {
}

@ -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();
}
}
}
}

@ -32,6 +32,7 @@ public class MobileSsoLoginServiceImpl extends Service implements MobileSsoLogin
//从缓存中获取用户accessToken
String userAccessTokenCache = (String) Util_DataCache.getObjVal(SSO_LOGIN_USER_ACCESS_TOKEN + user.getLoginid());
if (returnTokenWithCache(dataMap, userAccessTokenCache)) {
baseBean.writeLog("returnTokenWithCache" + dataMap.toString());
return dataMap;
}
//请求链接地址
@ -43,15 +44,17 @@ public class MobileSsoLoginServiceImpl extends Service implements MobileSsoLogin
String accessToken = getAccessToken();
HashMap<String, Object> requestMap = new HashMap<>();
requestMap.put("auth_code", authCode);
requestMap.put("access_token", accessToken);
requestMap.put("app_access_token", accessToken);
//请求获取用户accessToken
baseBean.writeLog("getUserAccessToken:" + requestMap.toString());
String data = HttpUtils.doPost(userAccessTokenUrl, requestMap, null);
baseBean.writeLog("getUserAccessTokenResult:" + data);
JSONObject dataJson = JSONObject.parseObject(data);
String resultCode = dataJson.getString("resultCode");
JSONObject resultJson = dataJson.getJSONObject("result");
if (resultJson != null && SUCCESS_RESULT_CODE.equals(resultCode)) {
baseBean.writeLog("获取userAccessToken", resultJson.toString());
String userAccessToken = resultJson.getString("access_token");
String userAccessToken = resultJson.getString("user_access_token");
String expiresIn = resultJson.getString("expires_in");
String refreshToken = resultJson.getString("refresh_token");
//access_token加缓存
@ -75,20 +78,24 @@ public class MobileSsoLoginServiceImpl extends Service implements MobileSsoLogin
public Map<String, Object> getUserInfo(Map<String, Object> paramMap, User user) {
Map<String, Object> dataMap = new HashMap<>();
BaseBean baseBean = new BaseBean();
baseBean.writeLog("getUserInfoStart");
try {
String authCode = (String) paramMap.get("auth_code");
String accessToken = (String) Util_DataCache.getObjVal(SSO_LOGIN_ACCESS_TOKEN);
if (StringUtils.isEmpty(accessToken)) {
accessToken = getAccessToken();
}
baseBean.writeLog("accessToken:" + accessToken);
// String userAccessToken = (String) Util_DataCache.getObjVal(SSO_LOGIN_USER_ACCESS_TOKEN + user.getLoginid());
//请求链接地址
String userInfoUrl = baseBean.getPropValue("weaverssologin", "userInfoUrl");
dataMap.put("api_status", false);
HashMap<String, Object> requestMap = new HashMap<>();
requestMap.put("auth_code", authCode);
requestMap.put("access_token", accessToken);
requestMap.put("app_access_token", accessToken);
baseBean.writeLog("getUserInfo:" + requestMap.toString());
String data = HttpUtils.doPost(userInfoUrl, requestMap, null);
baseBean.writeLog("getUserInfoResult:" + data);
JSONObject dataJson = JSONObject.parseObject(data);
String resultCode = dataJson.getString("resultCode");
JSONObject resultJson = dataJson.getJSONObject("result");
@ -126,13 +133,15 @@ public class MobileSsoLoginServiceImpl extends Service implements MobileSsoLogin
HashMap<String, Object> requestMap = new HashMap<>();
requestMap.put("appKey", appKey);
requestMap.put("appSecret", appSecret);
baseBean.writeLog("getAccessToken:" + requestMap.toString());
String data = HttpUtils.doPost(accessTokenUrl, requestMap, null);
baseBean.writeLog("getAccessTokenResult:" + data);
JSONObject dataJson = JSONObject.parseObject(data);
String resultCode = dataJson.getString("resultCode");
JSONObject resultJson = dataJson.getJSONObject("result");
if (resultJson != null && SUCCESS_RESULT_CODE.equals(resultCode)) {
baseBean.writeLog("获取accessToken", resultJson.toString());
String accessToken = resultJson.getString("access_token");
String accessToken = resultJson.getString("app_access_token");
String expiresIn = resultJson.getString("expires_in");
Util_DataCache.setObjValWithRedis(SSO_LOGIN_ACCESS_TOKEN, accessToken, Integer.parseInt(expiresIn));
dataMap.put("api_status", true);
@ -165,7 +174,7 @@ public class MobileSsoLoginServiceImpl extends Service implements MobileSsoLogin
if (StringUtils.isEmpty(accessToken)) {
Map<String, Object> accessTokenMap = getAccessToken(null, null);
Map data = (Map) accessTokenMap.get("data");
accessToken = (String) data.get("access_token");
accessToken = (String) data.get("app_access_token");
}
return accessToken;
}

@ -1,78 +0,0 @@
package com.engine.ditoSsologin.web;
import com.alibaba.fastjson.JSONObject;
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 weaver.hrm.HrmUserVarify;
import weaver.hrm.User;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
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 java.util.HashMap;
import java.util.Map;
/**
* @author Lee
*/
public class SsoLoginAction {
private MobileSsoLoginService getService() {
return ServiceUtil.getService(MobileSsoLoginServiceImpl.class);
}
@GET
@Path("/getAccessToken")
@Produces({"application/json"})
public String getAccessToken(@Context HttpServletRequest request, @Context HttpServletResponse response) {
Map<String, Object> apidatas = new HashMap<>();
try {
User user = HrmUserVarify.getUser(request, response);
apidatas = getService().getAccessToken(ParamUtil.request2Map(request), user);
} catch (Exception e) {
e.printStackTrace();
apidatas.put("api_status", false);
apidatas.put("api_errormsg", "catch exception : " + e.getMessage());
}
return JSONObject.toJSONString(apidatas);
}
@POST
@Path("/getUserAccessToken")
@Produces({"application/json"})
public String getUserAccessToken(@Context HttpServletRequest request, @Context HttpServletResponse response) {
Map<String, Object> apidatas = new HashMap<>();
try {
User user = HrmUserVarify.getUser(request, response);
apidatas = getService().getUserAccessToken(ParamUtil.request2Map(request), user);
} catch (Exception e) {
e.printStackTrace();
apidatas.put("api_status", false);
apidatas.put("api_errormsg", "catch exception : " + e.getMessage());
}
return JSONObject.toJSONString(apidatas);
}
@POST
@Path("/getUserInfo")
@Produces({"application/json"})
public String getUserInfo(@Context HttpServletRequest request, @Context HttpServletResponse response) {
Map<String, Object> apidatas = new HashMap<>();
try {
User user = HrmUserVarify.getUser(request, response);
apidatas = getService().getUserInfo(ParamUtil.request2Map(request), user);
} catch (Exception e) {
e.printStackTrace();
apidatas.put("api_status", false);
apidatas.put("api_errormsg", "catch exception : " + e.getMessage());
}
return JSONObject.toJSONString(apidatas);
}
}

@ -0,0 +1,192 @@
package weaver.interfaces.job;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang.StringUtils;
import weaver.conn.RecordSet;
import weaver.general.BaseBean;
import weaver.general.Time;
import weaver.general.TimeUtil;
import weaver.interfaces.schedule.BaseCronJob;
import weaver.share.ShareManager;
import java.util.*;
/**
* @version 1.0
* @Title ecology-9
* @Company
* @CreateDate 2022/11/14
* @Description ${description}
* @Author Lee
*/
public class WorkflowAuthModelingCronJob extends BaseCronJob {
@Override
public void execute() {
BaseBean bb = new BaseBean();
bb.writeLog("start WorkflowAuthModelingCronJob");
RecordSet rs = new RecordSet();
//查询模块id
String formModeIdSql = "SELECT DISTINCT formmodeid FROM uf_workflow_auth";
rs.execute(formModeIdSql);
String formModeId = "";
if (rs.next()) {
formModeId = rs.getString("formmodeid");
}
/*
E9idSet
*/
//根据流程id查询出所有创建人id,封装成Map<String,Set>
ShareManager shareManager = new ShareManager();
Set<String> baseWorkflowIdSet = new HashSet<>();
Map<String, Set<String>> baseWorkflowMap = new HashMap<>();
Map<String, String> baseWorkflowName = new HashMap<>();
String baseWorkflowSql = "SELECT id,workflowname FROM workflow_base WHERE ISVALID = 1";
rs.execute(baseWorkflowSql);
while (rs.next()) {
String workflowId = rs.getString("id");
String workflowname = rs.getString("workflowname");
baseWorkflowIdSet.add(workflowId);
String userIds = shareManager.getWorkflowCreater(Integer.parseInt(workflowId));
Set<String> userIdList = new HashSet<>(Arrays.asList(userIds.split(",")));
baseWorkflowMap.put(workflowId, userIdList);
baseWorkflowName.put(workflowId, workflowname);
}
bb.writeLog("baseWorkflowMap", baseWorkflowMap.toString());
/*
id,Set
idMap<String,Set>
*/
RecordSet rs2 = new RecordSet();
String modelWorkflowSql = "SELECT DISTINCT workflowselect as id FROM uf_workflow_auth";
rs.execute(modelWorkflowSql);
Set<String> modelWorkflowIdSet = new HashSet<>();
Map<String, Set<String>> modeWorkflowMap = new HashMap<>();
while (rs.next()) {
String workflowId = rs.getString("id");
modelWorkflowIdSet.add(workflowId);
String modelUserSql = "SELECT userselect as userId FROM uf_workflow_auth WHERE workflowselect=?";
rs2.executeQuery(modelUserSql, workflowId);
Set<String> userIdList = new HashSet<>();
while (rs2.next()) {
userIdList.add(rs2.getString("userId"));
}
modeWorkflowMap.put(workflowId, userIdList);
}
bb.writeLog("modeWorkflowMap", modeWorkflowMap.toString());
/*
SetE9Set
*/
//取交集,表示需要更新的流程。再用建模表与交集取差集表示建模表要删除的流程。E9集合与此交集的差集表示要新增的流程
Set<String> updateSet = new HashSet<>(baseWorkflowIdSet);
updateSet.retainAll(modelWorkflowIdSet);
bb.writeLog("updateSet", updateSet.size());
Set<String> deleteSet = new HashSet<>(modelWorkflowIdSet);
deleteSet.removeAll(updateSet);
bb.writeLog("deleteSet", deleteSet.size());
Set<String> addSet = new HashSet<>(baseWorkflowIdSet);
addSet.removeAll(updateSet);
bb.writeLog("addSet", addSet.size());
deleteWorkflow(bb, deleteSet);
updateWorkflow(bb, updateSet, baseWorkflowMap, modeWorkflowMap, baseWorkflowName,formModeId);
addWorkflow(bb, addSet, baseWorkflowMap, baseWorkflowName,formModeId);
}
/**
*
* @param bb
* @param addSet
* @param baseWorkflowMap
* @param baseWorkflowName
* @param formModeId
*/
private void addWorkflow(BaseBean bb, Set<String> addSet, Map<String, Set<String>> baseWorkflowMap, Map<String, String> baseWorkflowName, String formModeId) {
bb.writeLog("addWorkflow-----start");
RecordSet rs = new RecordSet();
RecordSet rs2= new RecordSet();
String currentDate = TimeUtil.getCurrentDateString();
String onlyCurrentTime = TimeUtil.getOnlyCurrentTimeString();
String addSql = "INSERT INTO uf_workflow_auth (userselect,effective,formmodeid,modedatacreatedate,modedatacreatetime,workflowselect,workflowname,workcode) values (?,?,?,?,?,?,?,?)";
for (String workflowId : addSet) {
Set<String> userIds = baseWorkflowMap.get(workflowId);
for (String addUserId : userIds) {
String workflowName = baseWorkflowName.get(workflowId);
String workCodeQuery = "SELECT workcode FROM hrmresource WHERE id=?";
rs2.executeQuery(workCodeQuery, addUserId);
if (rs2.next()) {
String workCode = rs2.getString("workcode");
rs.executeUpdate(addSql, addUserId, 0, formModeId, currentDate, onlyCurrentTime, workflowId, workflowName, workCode);
}
}
}
}
/**
*
* @param bb
* @param updateSet
* @param baseWorkflowMap
* @param modeWorkflowMap
* @param baseWorkflowName
* @param formModeId
*/
private void updateWorkflow(BaseBean bb, Set<String> updateSet, Map<String, Set<String>> baseWorkflowMap, Map<String, Set<String>> modeWorkflowMap, Map<String, String> baseWorkflowName, String formModeId) {
bb.writeLog("updateWorkflow-----start");
RecordSet rs = new RecordSet();
RecordSet rs2 = new RecordSet();
String currentTime = TimeUtil.getCurrentTimeString();
String currentDate = TimeUtil.getCurrentDateString();
String onlyCurrentTime = TimeUtil.getOnlyCurrentTimeString();
//对比人员Set
for (String workflowId : updateSet) {
String workflowName = baseWorkflowName.get(workflowId);
Set<String> baseUsers = baseWorkflowMap.get(workflowId);
Set<String> modeUsers = modeWorkflowMap.get(workflowId);
//交集,更新为可用
HashSet<String> diffUsers = new HashSet<>(baseUsers);
String updateSql = "UPDATE uf_workflow_auth SET modedatamodifydatetime=?,effective=0 WHERE userselect=? AND workflowselect=?";
diffUsers.retainAll(modeUsers);
for (String diffUserId : diffUsers) {
rs.executeUpdate(updateSql, currentTime, diffUserId, workflowId);
}
//建模users与交集取差集删除
HashSet<String> deleteUsers = new HashSet<>(modeUsers);
deleteUsers.removeAll(diffUsers);
String deleteSql = "UPDATE uf_workflow_auth SET modedatamodifydatetime=?,effective=1 WHERE userselect=? AND workflowselect=?";
for (String deleteUserId : deleteUsers) {
rs.executeUpdate(deleteSql, currentTime, deleteUserId, workflowId);
}
//e9users与交集取差集新增
HashSet<String> addUsers = new HashSet<>(baseUsers);
addUsers.removeAll(diffUsers);
String addSql = "INSERT INTO uf_workflow_auth (userselect,effective,formmodeid,modedatacreatedate,modedatacreatetime,workflowselect,workflowname,workcode) values (?,?,?,?,?,?,?,?)";
for (String addUserId : addUsers) {
String workCodeQuery = "SELECT workcode FROM hrmresource WHERE id=?";
rs2.executeQuery(workCodeQuery, addUserId);
if (rs2.next()) {
String workcode = rs2.getString("workcode");
rs.executeUpdate(addSql, addUserId, 0, formModeId, currentDate, onlyCurrentTime, workflowId, workflowName, workcode);
}
}
}
}
/**
*
*
* @param baseBean
* @param deleteSet
*/
private void deleteWorkflow(BaseBean baseBean, Set<String> deleteSet) {
RecordSet rs = new RecordSet();
String currentTime = TimeUtil.getCurrentTimeString();
String sql = "UPDATE uf_workflow_auth SET modedatamodifydatetime=?,effective=1 WHERE workflowselect=?";
for (String id : deleteSet) {
boolean flag = rs.executeUpdate(sql, currentTime, id);
baseBean.writeLog("deleteWorkflow-----" + id + "------" + flag);
}
}
}

@ -6,6 +6,7 @@ import weaver.conn.RecordSet;
import weaver.conn.util.IdGenerator;
import weaver.general.BaseBean;
import weaver.general.TimeUtil;
import weaver.general.Util;
import weaver.interfaces.schedule.BaseCronJob;
import weaver.interfaces.util.HttpUtils;
@ -30,14 +31,13 @@ public class WorkflowSyncCronJob extends BaseCronJob {
@Override
public void execute() {
BaseBean bb = new BaseBean();
bb.writeLog("开始推送流程");
bb.writeLog("WorkflowSyncCronJob start");
try {
//推送流程url
String synchronizeFlowUrl = bb.getPropValue("PORTAL_INFO", "synchronizeFlowUrl");
//同步人员权限url
String synchronizeUserUrl = bb.getPropValue("PORTAL_INFO", "synchronizeUserUrl");
//新建流程推送到目录code
String catalogueCode = bb.getPropValue("PORTAL_INFO", "catalogueCode");
String center = bb.getPropValue("PORTAL_INFO", "center");
String workflowAuthTable = bb.getPropValue("PORTAL_INFO", "workflowAuthTable");
String timeNodeTable = bb.getPropValue("PORTAL_INFO", "timeNodeTable");
@ -46,14 +46,16 @@ public class WorkflowSyncCronJob extends BaseCronJob {
String timeNodeFormModeId = bb.getPropValue("PORTAL_INFO", "timeNodeFormModeId");
//全量同步使用全量同步方法
if (SYNC_ALL.equals(syncType)) {
bb.writeLog("WorkflowSyncCronJob ALL start");
String currentTime = TimeUtil.getCurrentTimeString();
allSynchronizeWorkflow(bb, synchronizeFlowUrl, synchronizeUserUrl, center, catalogueCode, workflowAuthTable, accountName, password);
allSynchronizeWorkflow(bb, synchronizeFlowUrl, synchronizeUserUrl, center, workflowAuthTable, accountName, password);
writeTimeNode(timeNodeTable, currentTime, SYNC_ALL, TIME_NODE_USE_WORKFLOW_SYNC, timeNodeFormModeId);
}
//增量同步使用增量同步方法
if (SYNC_INCREMENT.equals(syncType)) {
bb.writeLog("WorkflowSyncCronJob INCREMENT start");
String currentTime = TimeUtil.getCurrentTimeString();
IncrementSynchronizeWorkflow(bb, synchronizeFlowUrl, synchronizeUserUrl, center, catalogueCode, workflowAuthTable, timeNodeTable, accountName, password);
IncrementSynchronizeWorkflow(bb, synchronizeFlowUrl, synchronizeUserUrl, center, workflowAuthTable, timeNodeTable, accountName, password);
writeTimeNode(timeNodeTable, currentTime, SYNC_INCREMENT, TIME_NODE_USE_WORKFLOW_SYNC, timeNodeFormModeId);
}
} catch (Exception e) {
@ -63,7 +65,7 @@ public class WorkflowSyncCronJob extends BaseCronJob {
// 增量同步
private void IncrementSynchronizeWorkflow(BaseBean bb, String synchronizeFlowUrl, String synchronizeUserUrl, String center, String cataCode, String workflowAuthTable, String timeNodeTable, String accountName, String password) {
private void IncrementSynchronizeWorkflow(BaseBean bb, String synchronizeFlowUrl, String synchronizeUserUrl, String center, String workflowAuthTable, String timeNodeTable, String accountName, String password) {
RecordSet recordSet = new RecordSet();
//查询时间节点表,上次流程推送增量同步的时间
String timeSql = "select timenode from " + timeNodeTable + " where type=? and useto=? order by timenode desc";
@ -72,20 +74,21 @@ public class WorkflowSyncCronJob extends BaseCronJob {
if (recordSet.next()) {
preTime = recordSet.getString("timenode");
}
syncWorkflowByCondition(bb, synchronizeFlowUrl, synchronizeUserUrl, center, cataCode, workflowAuthTable, accountName, password, preTime);
syncWorkflowByCondition(bb, synchronizeFlowUrl, synchronizeUserUrl, center, workflowAuthTable, accountName, password, preTime);
}
// 全量同步
private void allSynchronizeWorkflow(BaseBean bb, String synchronizeFlowUrl, String synchronizeUserUrl, String center, String cataCode, String workflowAuthTable, String accountName, String password) {
syncWorkflowByCondition(bb, synchronizeFlowUrl, synchronizeUserUrl, center, cataCode, workflowAuthTable, accountName, password, null);
private void allSynchronizeWorkflow(BaseBean bb, String synchronizeFlowUrl, String synchronizeUserUrl, String center, String workflowAuthTable, String accountName, String password) {
syncWorkflowByCondition(bb, synchronizeFlowUrl, synchronizeUserUrl, center, workflowAuthTable, accountName, password, null);
}
/**
*
*/
private void syncWorkflowByCondition(BaseBean bb, String synchronizeFlowUrl, String synchronizeUserUrl, String center, String cataCode, String workflowAuthTable, String accountName, String password, String timeCondition) {
private void syncWorkflowByCondition(BaseBean bb, String synchronizeFlowUrl, String synchronizeUserUrl, String center, String workflowAuthTable, String accountName, String password, String timeCondition) {
RecordSet recordSet = new RecordSet();
RecordSet recordSet2 = new RecordSet();
RecordSet recordSet3 = new RecordSet();
ArrayList<Map<String, Object>> addWorkflowList = new ArrayList<>();
ArrayList<Map<String, Object>> delWorkflowList = new ArrayList<>();
ArrayList<Map<String, Object>> addUserList = new ArrayList<>();
@ -94,8 +97,9 @@ public class WorkflowSyncCronJob extends BaseCronJob {
String workflowSql = "SELECT DISTINCT workflowselect as flowCode,workflowname as flowName,effective FROM " + workflowAuthTable +
" WHERE effective IN (SELECT DISTINCT effective FROM " + workflowAuthTable + ")";
if (StringUtils.isNotEmpty(timeCondition)) {
String[] time = timeCondition.split(" ");
timeCondition = "'" + timeCondition + "'";
workflowSql += " AND (modedatamodifydatetime >= " + timeCondition + " OR modedatacreatedate+ ' '+ modedatacreatetime>= " + timeCondition + ")";
workflowSql += " AND (modedatamodifydatetime >= " + timeCondition + " OR modedatacreatedate >= '" + time[0] + "' AND modedatacreatetime>= '" + time[1] + "')";
}
recordSet.execute(workflowSql);
//区分有效和无效的流程
@ -103,7 +107,15 @@ public class WorkflowSyncCronJob extends BaseCronJob {
String effective = recordSet.getString("effective");
String flowCode = recordSet.getString("flowCode");
String flowName = recordSet.getString("flowName");
bb.writeLog("WorkflowSyncCronJob flowCode :" + flowCode);
String cataCode = "";
//查询要推送到哪个目录下
String cataCodeSql = "select cataCodeName from uf_syncCataCode where flowCode=?";
recordSet3.executeQuery(cataCodeSql, flowCode);
if (recordSet3.next()) {
cataCode = Util.null2String(recordSet3.getString("cataCodeName"));
bb.writeLog("WorkflowSyncCronJob cataCode :" + cataCode);
}
if (EFFECTIVE_YES.equals(effective)) {
//拼接有效流程请求参数
concatWorkflowCondition(center, cataCode, flowCode, flowName, ACTION_TYPE_ADD, addWorkflowList);
@ -162,7 +174,7 @@ public class WorkflowSyncCronJob extends BaseCronJob {
* @return
*/
private boolean workflowHasEffective(String workflowAuthTable, RecordSet recordSet2, String flowCode) {
String querySql = "SELECT top 1 id FROM " + workflowAuthTable + " WHERE workflowselect=? AND effective=?";
String querySql = "SELECT count(*) FROM " + workflowAuthTable + " WHERE workflowselect=? AND effective=?";
recordSet2.executeQuery(querySql, flowCode, EFFECTIVE_YES);
return recordSet2.next();
}

Loading…
Cancel
Save