<%@ page contentType="text/html;charset=UTF-8" language="java"%>
<%--<%@ include file="/systeminfo/init_wev8.jsp" %>--%>

<%@ page import="weaver.general.Util" %>
<%@ page import="java.util.Map" %>

<%@ page import="weaver.general.BaseBean" %>
<%@ page import="weaver.hrm.User" %>
<%@ page import="weaver.hrm.HrmUserVarify" %>
<%@ page import="weaver.interfaces.encode.AES_IV" %>
<%@ page import="com.engine.common.util.ParamUtil" %>
<%@ page import="weaver.conn.RecordSet" %>
<%@ page import="com.wbi.util.StringUtil" %>
<jsp:useBean id="rs" class="weaver.conn.RecordSet" scope="page" />
<jsp:useBean id="RecordSet" class="weaver.conn.RecordSet" scope="page" />
<jsp:useBean id="RecordSet1" class="weaver.conn.RecordSet" scope="page" />

<%
    BaseBean bb = new BaseBean();
    String mhurlId = "";
    String mhurl = "";
    String encodeResultStr = "";
    try {
        User user = HrmUserVarify.getUser(request,response);
        String loginid = user.getLoginid();
        Map<String, Object> paramMap = ParamUtil.request2Map(request);
        mhurlId = (String) paramMap.get("mhurlId");
        mhurl = getSysUrl(mhurlId);
        AES_IV aesIV = new AES_IV();
        // AES的密钥长度最好是16位(不是必须)
        String password = "ecology_nsh_2021";
        // AES的向量长度必须为16位
        String iv = "weaver_nsyh_2021";
        aesIV.setPwd(password);
        aesIV.setIv(iv);
        // 加密
        encodeResultStr = aesIV.encode(loginid);
        // out.println(mhurl);
        response.sendRedirect(mhurl+"loginid="+encodeResultStr);

    }catch (Exception E){
        bb.writeLog("mhxxerror====>"+E.getMessage());
        if (StringUtil.isBlank(mhurl)){
            out.print("跳转失败:未查询到系统ID对应的跳转链接(02002)");
        }else {
            response.sendRedirect(mhurl);
        }

    }
    %>

<%!
    public static String getSysUrl(String sysid){
        RecordSet rs = new RecordSet();
        String url = "-1";
        //查询建模
        rs.executeQuery("select * from uf_otherSysInfo where id = ?" ,sysid);
        if (rs.next()){
            url = Util.null2String(rs.getString("xtdz"));
        }else {
            return "-1";
        }
        url = url.trim();
        if (!StringUtil.isBlank(url)){
            //判断是否带?号
            if (url.indexOf("?") == -1){
                url = url+"?";
            }else{
                url = url+"&";
            }
        };
        return url;
    }
%>