Ruoyi Vue版集成JFlowSpringBoot(成功版)

1.下载https://gitee.com/kikock/RuoYi-JFlow的源码,以及ruoyi-vue源码,ruoyi-jflow只是一个参考,因为他不是ruoyi-vue版


2.修改WF/Comm/Gener.js.
所有url增加从cookie里面获取Token,添加GetCookie函数,参考如下:

$.ajax({
                type: 'post',
                async: false,
                xhrFields: {
                    withCredentials: true
                },
                crossDomain: true,
                url: dynamicHandler + "?DoType=Entity_Init&EnName=" + self.enName + "&PKVal=" + self.pkval + "&t=" + new Date().getTime()+"&token="+getCookie("Admin-Token"),
                ***: ''
});

添加getcookie函数

//获取cookie
function getCookie(cookie_name) {
    var allcookies = document.cookie;
    //索引长度,开始索引的位置
    var cookie_pos = allcookies.indexOf(cookie_name);

    // 如果找到了索引,就代表cookie存在,否则不存在
    if (cookie_pos != -1) {
        // 把cookie_pos放在值的开始,只要给值加1即可
        //计算取cookie值得开始索引,加的1为“=”
        cookie_pos = cookie_pos + cookie_name.length + 1;
        //计算取cookie值得结束索引
        var cookie_end = allcookies.indexOf(";", cookie_pos);

        if (cookie_end == -1) {
            cookie_end = allcookies.length;

        }
        //得到想要的cookie的值
        var value = unescape(allcookies.substring(cookie_pos, cookie_end));
    }
    return value;
}


3.修改WF/Scripts/config.js,修改projectname

function basePath() {
    //获取当前网址,如: http://localhost:80/jflow-web/index.jsp
    var curPath = window.document.location.href;
    //获取主机地址之后的目录,如: jflow-web/index.jsp  
    var pathName = window.document.location.pathname;
    var pos = curPath.indexOf(pathName);
    //获取主机地址,如: http://localhost:80  
    var localhostPaht = curPath.substring(0, pos);
    //获取带"/"的项目名,如:/jflow-web
    //var projectName = pathName.substring(0, pathName.substr(1).indexOf('/') + 1);
    var projectName ='';

    return localhostPaht + projectName;

}


4.修改WebUser.java的GetSessionByKey()做了修改

/**
     * 通过key,取出session.
     *
     * @param key         key
     * @param isNullAsVal 如果是Null, 返回的值.
     * @return
     */
    public static String GetSessionByKey(String key, String isNullAsVal) {
//		return GetSessionByKey(key, isNullAsVal, false);
//	}
//
//	/**
//	 * 通过key,取出session.
//	 *
//	 * @param key key
//	 * @param isNullAsVal 如果是Null, 返回的值.
//	 * @return
//	 */
//	public static String GetSessionByKey(String key, String isNullAsVal, boolean isChinese) {
//		try {
        if (getIsBSMode() && null != ContextHolderUtils.getRequest() && null != ContextHolderUtils.getSession()) {
            //Object value = ContextHolderUtils.getSession().getAttribute(key);
            Object value=null;
            if (key=="No") {
                value = ContextHolderUtils.getLoginUser(ServletUtils.getParameter("token")).getUsername();
            }
            else if (key=="Name"){
                value = ContextHolderUtils.getLoginUser(ServletUtils.getParameter("token")).getUser().getNickName();
            }
            else if (key=="FK_DeptName"){
                value = "100";
            }
            else if (key=="FK_DeptNameOfFull"){
                value = "组织架构";
            }
            String str = value == null ? "" : String.valueOf(value);
            if (StringHelper.isNullOrEmpty(str)) {
                //astra.zhao 2019-04-08 modified 注释了str = 'admin'
                str = isNullAsVal;
                //str = "admin";
            }
            return str;
        } else {
            if ((Current.Session.get(key) == null || Current.Session.get(key).toString().equals("")) && isNullAsVal != null) {
                //astra.zhao 2019-04-08 modified 注释了str = 'admin'
                return isNullAsVal;
                //return "admin";
            } else {
                //astra.zhao 2019-04-08 modified 注释了str = 'admin'
                //String str = (String) Current.Session.get(key);
                String str =  ContextHolderUtils.getLoginUser(ServletUtils.getParameter("token")).getUsername();
                return str;
                //return "admin";
            }
        }
//		} catch (UnsupportedEncodingException e) {
//			return isNullAsVal;
//		}
    }


5.修改WF/HttpHandle/WF_Comm.java
6.修改DBAccess.java的RunSQL_200705_MySQL方法,(上述这两个方法省略,只是集成报错后,进行修改,可以在控制台看到具体错误)

7.将jflow-core作为一个module模块包,编译后,添加到spring boot项目中,添加jar包<dependency>
    <groupId>jflow-core</groupId>
    <artifactId>jflow-core</artifactId>
    <version>1.1.0-SNAPSHOT</version>
</dependency>

8.spring boot的项目中添加yaml文件的mvc配置
mvc:
    ### request url .do后缀支持
    pathmatch:
      use-suffix-pattern: true
      #      静态文件
      static-path-pattern: /JFlow/**
    resources:
      static-locations: classpath:/JFlow/
    view:
      prefix: /JFlow/

猜你喜欢

转载自blog.csdn.net/penker_zhao/article/details/107150616