ReplaceOperation.jsp 9.16 KB
<%@ page language="java" contentType="text/html; charset=UTF-8" %>
<%@ include file="/templetecheck/filecheck/CheckUserIsSysadmin.jsp" %>
<%@ page import="weaver.general.Util" %>
<%@ page import="weaver.templetecheck.filecheck.ReplaceOperation" %>
<jsp:useBean id="rs" class="weaver.conn.RecordSet" scope="page"/>
<jsp:useBean id="rs1" class="weaver.conn.RecordSet" scope="page"/>
<%
    String rulefrom = Util.null2String(request.getParameter("rulefrom"));
    boolean res = true;
    ReplaceOperation operation = new ReplaceOperation();

    if ("specialfilecheck".equalsIgnoreCase(rulefrom)) {
        String ids = operation.formatIds(Util.null2String(request.getParameter("ids")).trim());
        String filepath = Util.null2String(request.getParameter("filepath")).replaceAll("\\\\+","/").trim();
        String ruleids = operation.formatIds(Util.null2String(request.getParameter("ruleids")).trim());
        String sqlwhere = "";
        if (!"".equals(ids)) {
            sqlwhere += " and id in(" + ids + ") ";
            //sqlwhere += " and filepath in (select distinct filepath from upgradecheckresult where id in (" + ids + "))";
        }
        if (!"".equals(ruleids)) {
            sqlwhere += " and ruleid in (" + ruleids + ") ";
        }
        if (!"".equals(filepath)) {
            sqlwhere += " and filepath like '%" + filepath + "%'";
        }
        String queryIds = "";
        if (!"".equals(sqlwhere)) {
            String ids_sql = "select id from upgradecheckresult where 1=1 " + sqlwhere;
            new BaseBean().writeLog("=======指定文件检测替换查询id范围sql" + ids_sql);
            rs.execute(ids_sql);
            while (rs.next()) {
                queryIds = queryIds + rs.getString("id") + ",";
            }
        }

        if (!"".equals(sqlwhere) && "".equals(queryIds)) {
            new BaseBean().writeLog("=======流程模板替换出错,sqlwhere存在,但是结果为空.sqlwhere:" + sqlwhere);
        } else {
            res = operation.replaceSpecialFile(operation.formatIds(queryIds));
        }
    } else if ("mobilemode".equalsIgnoreCase(rulefrom)) {
        String ismodeormobilemodeflag = Util.null2String(request.getParameter("ismodeormobilemodeflag"));
        String ids = operation.formatIds(Util.null2String(request.getParameter("ids")).trim());
        String queryIds = "";
        String sqlwhere = "";
        String ruleids = operation.formatIds(Util.null2String(request.getParameter("ruleids")).trim());
        String workflowname = Util.null2String(request.getParameter("workflowname")).trim();
        String nodename = Util.null2String(request.getParameter("nodename")).trim();
        if (!"".equals(ids)) {
            sqlwhere += " and id in(" + ids + ") ";
        }
        if (!"".equals(ruleids)) {
            sqlwhere += " and ruleid in (" + ruleids + ") ";
        }
        if (!"".equals(workflowname)) {
            sqlwhere += " and workflowname like '%" + workflowname + "%' ";
        }
        if (!"".equals(nodename)) {
            sqlwhere += " and nodename like '%" + nodename + "%'";
        }

        if (!"1".equals(ismodeormobilemodeflag)) {//由于分页控件限制,对于组合索引的表,无法获取唯一值,需要反向查一下,但如果是明细中的单个替换,则不需要反向查
            rs.execute("select distinct nodehtmllayoutid,detailtype from checkmobilemoderesult where 1=1 "+sqlwhere);
            while (rs.next()) {
                String nodehtmllayoutid_t = Util.null2String(rs.getString("nodehtmllayoutid"));
                String detailtype_t = Util.null2String(rs.getString("detailtype"));
                if (!"".equals(nodehtmllayoutid_t) && !"".equals(detailtype_t)) {
                    String ids_sql = "select id from checkmobilemoderesult where nodehtmllayoutid='" + nodehtmllayoutid_t + "' and detailtype='" + detailtype_t + "'";
                    new BaseBean().writeLog("=======移动建模替换查询id范围sql" + ids_sql);
                    rs1.execute(ids_sql);
                    while (rs1.next()) {
                        queryIds = queryIds + rs1.getString("id") + ",";
                    }
                }
            }
        }else{
            queryIds = ids;
        }
        if(!"1".equals(ismodeormobilemodeflag)&&!"".equals(sqlwhere)&& "".equals(queryIds)) {
            new BaseBean().writeLog("=======流程模板替换出错,sqlwhere存在,但是结果为空.sqlwhere:" + sqlwhere);
        }else{
            res = operation.replaceModeOrMobilemode(operation.formatIds(queryIds), "checkmobilemoderesult");
        }

    } else if ("mode".equalsIgnoreCase(rulefrom)) {
        String ismodeormobilemodeflag = Util.null2String(request.getParameter("ismodeormobilemodeflag"));
        String ids = operation.formatIds(Util.null2String(request.getParameter("ids")).trim());
        String queryIds = "";
        String sqlwhere = "";
        String ruleids = operation.formatIds(Util.null2String(request.getParameter("ruleids")).trim());
        String workflowname = Util.null2String(request.getParameter("workflowname")).trim();
        String nodename = Util.null2String(request.getParameter("nodename")).trim();
        if (!"".equals(ids)) {
            sqlwhere += " and id in(" + ids + ") ";
        }
        if (!"".equals(ruleids)) {
            sqlwhere += " and ruleid in (" + ruleids + ") ";
        }
        if (!"".equals(workflowname)) {
            sqlwhere += " and workflowname like '%" + workflowname + "%' ";
        }
        if (!"".equals(nodename)) {
            sqlwhere += " and nodename like '%" + nodename + "%'";
        }
        if (!"1".equals(ismodeormobilemodeflag)) {//由于分页控件限制,对于组合索引的表,无法获取唯一值,需要反向查一下,但如果是明细中的单个替换,则不需要反向查
            rs.execute("select distinct nodehtmllayoutid,detailtype from upgradecheckmoderesult where 1=1 "+sqlwhere);
            while (rs.next()) {
                String nodehtmllayoutid_t = Util.null2String(rs.getString("nodehtmllayoutid"));
                String detailtype_t = Util.null2String(rs.getString("detailtype"));
                if (!"".equals(nodehtmllayoutid_t) && !"".equals(detailtype_t)) {
                    String ids_sql = "select id from upgradecheckmoderesult where nodehtmllayoutid='" + nodehtmllayoutid_t + "' and detailtype='" + detailtype_t + "'";
                    new BaseBean().writeLog("=======建模替换查询id范围sql" + ids_sql);
                    rs1.execute(ids_sql);
                    while (rs1.next()) {
                        queryIds = queryIds + rs1.getString("id") + ",";
                    }
                }
            }
        }else{
            queryIds = ids;
        }
        if(!"1".equals(ismodeormobilemodeflag)&&!"".equals(sqlwhere)&& "".equals(queryIds)) {
            new BaseBean().writeLog("=======流程模板替换出错,sqlwhere存在,但是结果为空.sqlwhere:" + sqlwhere);
        }else {
            res = operation.replaceModeOrMobilemode(operation.formatIds(queryIds), "upgradecheckmoderesult");
        }
    } else if ("workflow".equalsIgnoreCase(rulefrom)) {//流程检测模板的id
        String nodehtmllayoutids = operation.formatIds(Util.null2String(request.getParameter("nodehtmllayoutids"))).trim();
        String ruleids = Util.null2String(operation.formatIds(request.getParameter("ruleids"))).trim();
        String workflowname = Util.null2String(request.getParameter("workflowname")).trim();
        String nodename = Util.null2String(request.getParameter("nodename")).trim();
        String rulename = Util.null2String(request.getParameter("rulename")).trim();
        String ids = operation.formatIds(Util.null2String(request.getParameter("ids")).trim());
        String queryIds = "";
        String sqlwhere = "";
        if (!"".equals(ids)) {
            sqlwhere += " and id in(" + ids + ") ";
        }
        if (!"".equals(nodehtmllayoutids)) {
            sqlwhere += " and nodehtmllayoutid in (" + nodehtmllayoutids + ") ";
        }
        if (!"".equals(ruleids)) {
            sqlwhere += " and ruleid in (" + ruleids + ") ";
        }
        if (!"".equals(workflowname)) {
            sqlwhere += " and workflowname like ('%" + workflowname + "%') ";
        }
        if (!"".equals(rulename)) {
            sqlwhere += " and  rulename like ('%" + rulename + "%') ";
        }
        if (!"".equals(nodename)) {
            sqlwhere += " and nodename like ('%" + nodename + "%') ";
        }
        if (!"".equals(sqlwhere)) {
            String ids_sql ="select id from upgradecheckworkflowresult where 1=1 " + sqlwhere;
            new BaseBean().writeLog("=======流程模板替换查询id范围sql" + ids_sql);
            rs.execute(ids_sql);
            while (rs.next()) {
                queryIds = queryIds + rs.getString("id") + ",";
            }
        }
        if (!"".equals(sqlwhere) && "".equals(queryIds)) {
            new BaseBean().writeLog("=======流程模板替换出错,sqlwhere存在,但是结果为空.sqlwhere:" + sqlwhere);
        } else {
            res = operation.replaceWorkflow(operation.formatIds(queryIds), ruleids);
        }
    }

    if (res) {
        out.print("{\"status\":\"ok\"}");
    } else {
        out.print("{\"status\":\"no\"}");
    }
%>