ReplaceOperation.jsp
9.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
<%@ 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\"}");
}
%>