diff --git a/com.awspaas.user.apps.yili.integration/lib/com.awspaas.user.apps.yili.integration.jar b/com.awspaas.user.apps.yili.integration/lib/com.awspaas.user.apps.yili.integration.jar index 2c7d09c5..b214859b 100644 Binary files a/com.awspaas.user.apps.yili.integration/lib/com.awspaas.user.apps.yili.integration.jar and b/com.awspaas.user.apps.yili.integration/lib/com.awspaas.user.apps.yili.integration.jar differ diff --git a/com.awspaas.user.apps.yili.integration/src/com/awspaas/user/apps/integration/controller/GetSomeIndexController.java b/com.awspaas.user.apps.yili.integration/src/com/awspaas/user/apps/integration/controller/GetSomeIndexController.java index 4cc4b802..fefb2702 100644 --- a/com.awspaas.user.apps.yili.integration/src/com/awspaas/user/apps/integration/controller/GetSomeIndexController.java +++ b/com.awspaas.user.apps.yili.integration/src/com/awspaas/user/apps/integration/controller/GetSomeIndexController.java @@ -72,7 +72,7 @@ public class GetSomeIndexController { } bo.set("WSID", "7d3ca852-a0bd-42e6-80b1-3dcea6f55083"); bo.set("RELEASE_INSTRUCTIONS", - "


关于发布《XXXXXXXXXXXX》的通知

 

各事业部、分(子)公司、总部各部(室):

xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx,现下发《xxxxxxxxxxxxxxx》,请各单位遵照执行。

特此通知。

(xxxxxxxxx)单位名称

2022年7月27日

");// 流程实例状态 + "



 

各事业部、分(子)公司、总部各部(室):

xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx,现下发《xxxxxxxxxxxxxxx》,请各单位遵照执行。

特此通知。

(xxxxxxxxx)单位名称

2022年7月27日

");// 流程实例状态 SDK.getBOAPI().create("BO_ACT_COE_PUBLISH", bo, processInstance, userContext); } diff --git a/com.awspaas.user.apps.yili.integration/src/com/awspaas/user/apps/integration/oauth/OauthLoginView.java b/com.awspaas.user.apps.yili.integration/src/com/awspaas/user/apps/integration/oauth/OauthLoginView.java new file mode 100644 index 00000000..21ca3085 --- /dev/null +++ b/com.awspaas.user.apps.yili.integration/src/com/awspaas/user/apps/integration/oauth/OauthLoginView.java @@ -0,0 +1,257 @@ +package com.awspaas.user.apps.integration.oauth; + +import com.actionsoft.bpms.bo.engine.BO; +import com.actionsoft.bpms.commons.oauth.AbstractOauth; +import com.actionsoft.bpms.org.model.DepartmentModel; +import com.actionsoft.bpms.server.RequestParams; +import com.actionsoft.bpms.server.UserContext; +import com.actionsoft.bpms.util.UtilString; +import com.actionsoft.sdk.local.SDK; +import com.actionsoft.sdk.local.api.LogAPI; +import com.actionsoft.sdk.local.api.Logger; +import com.actionsoft.sdk.local.api.ORGAPI; +import com.actionsoft.sdk.service.model.UserModel; +import com.alibaba.fastjson.JSONObject; +import com.yili.wsclient.ClientService; +import org.apache.commons.codec.binary.Base64; +import org.apache.commons.lang.StringUtils; + +import java.io.IOException; +import java.io.UnsupportedEncodingException; +import java.text.SimpleDateFormat; +import java.util.Date; + +/** + * OA系统 跳转登陆PAl + * + * @author lihy + */ + +public class OauthLoginView extends AbstractOauth { + private Logger logger = LogAPI.getLogger(OauthLoginView.class); + + static String clientId = "oaprocess"; + static String clientSecret = "qwer1234"; + /** + * 这个方法代表是否有登录授权页,返回的值取决于三方系统提供的 SSO 认证方式。一类认 证方式如 Oauth2.0 + * 认证,需要先跳转到三方系统的登录授权页面,授权成功后再跳转到调 用方指定的页面,这类认证方式下,hasOauthPage()方法需要返回 true。 + * 另外一类认证时不 需要跳转到登录授权页, 会直接传过来 ticket 或者 token 参数, hasOauthPage()方法需要返 回 false。 + * + * @return + */ + @Override + public boolean hasOauthPage() { + return false; + } + + /** + * 如果 hasOauthPage()方法返回的值是 false, 返回 null 即可。 如果 hasOauthPage()方法返回 的值是 + * true,则此处返回三方系统的登录授权页地址。 + * @param requestParams + * @return + */ + @Override + public String getOauthPage(RequestParams requestParams) { + return null; + } + @Override + public String validate(RequestParams params) throws IOException { + BO bo = new BO(); + String id = params.get("id"); + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + long begintime = System.currentTimeMillis(); + bo.set("BEGIN_TIME",sdf.format(new Date())); + String userid = ""; + long login_end_time = 0L; + if (StringUtils.isNotEmpty(params.get("casaccount"))){ + BO detail = SDK.getBOAPI().query("BO_EU_OA_RESON", true).addQuery("LOGINID=", params.get("casaccount")).detail(); + String workcode = ""; + if (detail!=null){ + workcode= detail.getString("WORKCODE"); + }else { + workcode= params.get("casaccount"); + } + + login_end_time = System.currentTimeMillis(); + bo.set("END_TIME",login_end_time); + bo.set("USER_ID",params.get("casaccount")); + UserContext userContext = UserContext.fromUID("admin"); + SDK.getBOAPI().createDataBO("BO_EU_OA_LOGIN",bo,userContext); + if (("5af46cd5-a1bc-4125-a144-86d1a199eec1").equals(id)){ + try { + setUserLog(params.get("casaccount"),"1"); + }catch (Exception e){ + + } + } + return workcode; + + } + + if (StringUtils.isNotEmpty(params.get("usercode"))){ + BO detail = SDK.getBOAPI().query("BO_EU_OA_RESON", true).addQuery("LOGINID=", params.get("usercode")).detail(); + String workcode = ""; + if (detail!=null){ + workcode = detail.getString("WORKCODE"); + }else { + workcode = params.get("usercode"); + } + login_end_time = System.currentTimeMillis(); + bo.set("END_TIME",sdf.format(new Date())); + bo.set("USER_ID",params.get("usercode")); + UserContext userContext = UserContext.fromUID("admin"); + SDK.getBOAPI().createDataBO("BO_EU_OA_LOGIN",bo,userContext); + if (("5af46cd5-a1bc-4125-a144-86d1a199eec1").equals(id)){ + try { + setUserLog(params.get("usercode"),"1"); + }catch (Exception e){ + + } + } + return workcode; + } + + + logger.info("单点登录验证---------"+params); + try { + + long loginbegintime = System.currentTimeMillis(); + bo.set("LOGIN_BEGIN_TIME",sdf.format(new Date())); + String redirect_uri = params.get("code"); + + + if(StringUtils.isEmpty(redirect_uri)){ + logger.error("跳转地址为空,请重新输入"); + return null; + } + + + App app = new App(); + String tokens = app.getTokens("http://10.114.11.135:8088/portal/yiliView.html", redirect_uri); + if(StringUtils.isEmpty(tokens)){ + logger.error("获取token为空,请重新输入登录信息获取code"); + return null; + }else { + JSONObject jsonObjects = JSONObject.parseObject(tokens); + String access_token = jsonObjects.getString("access_token"); + String userInfo = app.getUserInfo(access_token); + + if (StringUtils.isNotEmpty(userInfo)){ + JSONObject json = JSONObject.parseObject(userInfo); + //System.out.println("json-=====>>>>"+json); + if (StringUtils.isNotEmpty(json.getString("employeenumber"))){ + //System.out.println("userid》》》》》》》》》》"+json.getString("employeenumber")); + if (("5af46cd5-a1bc-4125-a144-86d1a199eec1").equals(id)){ + try { + setUserLog(json.getString("employeenumber"),"1"); + }catch (Exception e){ + + } + } + + userid = json.getString("employeenumber"); + login_end_time = System.currentTimeMillis(); + bo.set("END_TIME",sdf.format(new Date())); + bo.set("SCENDTIME",(login_end_time-loginbegintime)); + bo.set("LOGIN_END_TIME",sdf.format(new Date())); + bo.set("USER_ID",userid); + UserContext userContext = UserContext.fromUID("admin"); + SDK.getBOAPI().createDataBO("BO_EU_OA_LOGIN",bo,userContext); + + BO detail = SDK.getBOAPI().query("BO_EU_OA_RESON", true).addQuery("LOGINID=", json.getString("employeenumber")).detail(); + String workcode = ""; + if(detail!=null){ + workcode = detail.getString("WORKCODE"); + }else { + workcode = json.getString("employeenumber"); + } + + return workcode; + } + } + + } + + + + } catch (Exception e) { + logger.error("统一身份认证失败!", e); + } + return null; + } + + + + public long getCookieTime(UserModel user) { + //System.out.println("session时间>>>>>>>>>>"+user.getSessionTime()); +//下面的值代表与 AWS PaaS 会话过期时间一致, +//因平台会话过期时间以分钟计,所以需要乘以 60 + return 0; + } + + /** + * 统一身份认证接口 + * @param1 webserviceUrl 身份认证接口地址 + * @param2 casaccount 登录账号 OA账号 + * @param3 appaccount 应用系统登录账号 + * @param4 appid 应用系统id + * @param5 validcode 验证码 + * @return true/false + */ + public static String getToken(String casaccount,String appaccount,String appid,String validcode) { + //身份认证接口地址 + String webserviceUrl = SDK.getAppAPI().getProperty("com.awspaas.user.apps.yili.integration", "webserviceUrl"); + String checkLogin = ClientService.checkLogin(webserviceUrl,casaccount,appaccount,appid,validcode); + return checkLogin ; + } + + + + public static String geAuthorization(String clientId, String clientSecret) { + try { + byte[] key = (clientId + ":" + clientSecret).getBytes("utf-8"); + String cc = new String(Base64.encodeBase64(key), "utf-8"); + // String cc = new String(java.util.Base64.getEncoder().encode(key), "utf-8"); + return "Basic " + cc; + } catch (UnsupportedEncodingException e) { + e.printStackTrace(); + return ""; + } + } + + + + /** + * 用户登录日志 + * @param userid + * @param logType + */ + public void setUserLog(String userid,String logType) { + System.err.println("用户登录记录存入日志========>"+userid+"_类型:"+logType); + if (UtilString.isNotEmpty(userid)) { + String logTime = new SimpleDateFormat("yyyy-MM-dd").format(new Date()); + BO bo = new BO(); + /*String slq = "SELECT ID,LOGINCOUNTS FROM BO_EU_USER_LOGIN_LOG WHERE LOGINUSERNAME = '"+userid+"' AND LOGINTIME = '"+logTime+"'"; + List maps = DBSql.getMaps(slq); + if(maps.size()!=0) { + bo = SDK.getBOAPI().get("BO_EU_USER_LOGIN_LOG", maps.get(0).getString("ID")); + bo.set("LOGINCOUNTS", maps.get(0).getInt("LOGINCOUNTS")+1); + SDK.getBOAPI().update("BO_EU_USER_LOGIN_LOG", bo); + }else {*/ + ORGAPI orgapi = SDK.getORGAPI(); + com.actionsoft.bpms.org.model.UserModel user = orgapi.getUser(userid); + DepartmentModel departmentByUser = orgapi.getDepartmentByUser(userid); + bo.set("LOGINUSERNAME", userid); + bo.set("USERBUNAME",user.getExt4()); + bo.set("USERPOST",user.getPositionName()); + bo.set("USERDEPTNAME", departmentByUser.getPathNameOfCache()); + bo.set("LOGINTIME", logTime); + bo.set("LOGINCOUNTS", 1); + bo.set("LOGTYPE", Integer.valueOf(logType)); + + SDK.getBOAPI().createDataBO("BO_EU_USER_LOGIN_LOG", bo, UserContext.fromUID("admin")); + //} + } + } + +} diff --git a/com.awspaas.user.apps.yili.integration/src/com/awspaas/user/apps/integration/plugins/Plugins.java b/com.awspaas.user.apps.yili.integration/src/com/awspaas/user/apps/integration/plugins/Plugins.java index aa2362d4..ff3d6856 100644 --- a/com.awspaas.user.apps.yili.integration/src/com/awspaas/user/apps/integration/plugins/Plugins.java +++ b/com.awspaas.user.apps.yili.integration/src/com/awspaas/user/apps/integration/plugins/Plugins.java @@ -10,6 +10,7 @@ import com.actionsoft.apps.resource.plugin.profile.OauthPluginProfile; import com.actionsoft.apps.resource.plugin.profile.ProcessPublicEventPluginProfile; import com.awspaas.user.apps.integration.oa.TaskListener; import com.awspaas.user.apps.integration.oauth.OauthLogin; +import com.awspaas.user.apps.integration.oauth.OauthLoginView; import com.awspaas.user.apps.integration.oauth.ProcessOathLogin; /** @@ -25,6 +26,7 @@ public class Plugins implements PluginListener { list.add(new ProcessPublicEventPluginProfile(TaskListener.class.getName(), "待办推送监听器")); list.add(new OauthPluginProfile("oauthLogin", OauthLogin.class.getName(), "OA系统 跳转登陆PAl")); list.add(new OauthPluginProfile("processOathLogin", ProcessOathLogin.class.getName(), "流程中心发布")); + list.add(new OauthPluginProfile("oauthLoginView", OauthLoginView.class.getName(), "OA系统跳转文件查询页面")); return list; }