提交 | 用户 | age
|
a6a76f
|
1 |
package com.yc.service.panel; |
F |
2 |
|
|
3 |
import com.yc.entity.FormLoadParameterEntity; |
|
4 |
import com.yc.factory.FactoryBean; |
|
5 |
import com.yc.sdk.shopping.util.SettingKey; |
|
6 |
import com.yc.service.BaseService; |
|
7 |
import com.yc.service.impl.DBHelper; |
|
8 |
import com.yc.utils.SessionKey; |
|
9 |
|
|
10 |
import oracle.net.aso.b; |
|
11 |
|
|
12 |
import org.apache.commons.collections.map.HashedMap; |
|
13 |
import org.springframework.beans.factory.annotation.Autowired; |
|
14 |
import org.springframework.jdbc.BadSqlGrammarException; |
|
15 |
import org.springframework.stereotype.Service; |
|
16 |
import javax.servlet.http.HttpServletRequest; |
|
17 |
import javax.servlet.http.HttpSession; |
|
18 |
import java.net.URLDecoder; |
|
19 |
import java.net.URLEncoder; |
|
20 |
import java.sql.SQLException; |
|
21 |
import java.util.*; |
|
22 |
import java.util.regex.Matcher; |
|
23 |
import java.util.regex.Pattern; |
|
24 |
import java.util.stream.Collectors; |
|
25 |
|
|
26 |
/** |
|
27 |
* |
|
28 |
* @author pengbei |
|
29 |
* |
|
30 |
*/ |
|
31 |
@Service("PanelManage") |
|
32 |
public class PanelManageImpl implements PanelManageDao { |
|
33 |
@Autowired |
|
34 |
SqlDBHelperIfc sqlDBHelperIfc; |
|
35 |
@Autowired |
|
36 |
SystemSettingsDao systemSettingsBo; |
|
37 |
@Autowired |
|
38 |
GfieldApprovedButtonIfc gButtonIfc; |
|
39 |
|
|
40 |
// 针对多表 |
|
41 |
private List<Map<String, Object>> multiList = new ArrayList<>(); |
|
42 |
|
|
43 |
/** |
|
44 |
* 获得页面上真正显示的Id (不是数据库的列字段了) |
|
45 |
* |
|
46 |
* @param filed 匹配数控字段的map集合的Key |
|
47 |
* @param mapValue 数据库字段 |
|
48 |
* @return 网页的控件Id |
|
49 |
*/ |
|
50 |
public String getMapsKay(Map<String, Map<String, String>> maplist, String filed, String mapValue) { |
|
51 |
String yeId = ""; |
|
52 |
for (String key : maplist.keySet()) { |
|
53 |
if (maplist.get(key).get(filed).trim().equals(mapValue)) { |
|
54 |
yeId = key; |
|
55 |
break; |
|
56 |
} |
|
57 |
} |
|
58 |
return yeId; |
|
59 |
} |
|
60 |
|
|
61 |
/** |
|
62 |
* 加载单据信息 |
|
63 |
*/ |
|
64 |
// @Override |
|
65 |
public List<Map<String, Object>> getFromEnd(String sql, String tableis, String where, int formType, |
|
66 |
HttpServletRequest request) throws Exception { |
|
67 |
HttpSession session = request.getSession(); |
|
68 |
sql = getRepSql(sql); |
|
69 |
List<Map<String, Object>> listInfo = null; |
|
70 |
Map<String, Object> mapDoc = null; |
|
71 |
String lookUpSql = ""; |
|
72 |
try { |
|
73 |
where = isSpecialChar(where) ? URLEncoder.encode(where, "UTF-8") : where; // xin 2020-5-19 10:14:20 |
|
74 |
where = URLDecoder.decode(where, "utf-8");// by danaus 2020/5/1 23:02 |
|
75 |
} catch (Exception e) {// 出错表示不需要解码 |
|
76 |
} |
|
77 |
if (";22;18;19;7;".indexOf(";" + String.valueOf(formType) + ";") != -1) {// 类型窗体处理 |
|
78 |
try { |
|
79 |
listInfo = new ArrayList<Map<String, Object>>(); |
|
80 |
where = where.replaceAll("like", ";pb#").replaceAll("=", ";pb#").replace("@~", "").replaceAll("'", ""); |
|
81 |
String[] valueS = where.split("and"); |
|
82 |
String[] cols = null; |
|
83 |
HashMap<String, Object> map = new HashMap<String, Object>(); |
|
84 |
for (int i = 0; i < valueS.length; i++) { |
|
85 |
cols = valueS[i].split(";pb#"); |
|
86 |
if (cols.length > 1) { |
|
87 |
map.put(cols[0].trim().toLowerCase(), cols[1].trim()); |
|
88 |
} else { |
|
89 |
|
|
90 |
} |
|
91 |
} |
|
92 |
map.put("doc_size", 0);// 让其赋默认值 |
|
93 |
listInfo.add(map); |
|
94 |
} catch (ArrayIndexOutOfBoundsException e) {// 数组越界异常捕获 |
|
95 |
throw e; |
|
96 |
} catch (Exception e) { |
|
97 |
throw e; |
|
98 |
} |
|
99 |
} else { |
|
100 |
try { |
|
101 |
lookUpSql = sql + tableis + ((where != null && !where.equals("")) ? " where " + where : ""); |
|
102 |
lookUpSql = lookUpSql.replace("!", ""); |
|
103 |
listInfo = sqlDBHelperIfc.getHashMapObj(lookUpSql);// 获取对应单号数据 |
|
104 |
mapDoc = (listInfo != null && listInfo.size() > 0) ? listInfo.get(0) : new HashMap<String, Object>(); |
|
105 |
Pattern pattern = Pattern.compile("\\w+doccode\\s*="); |
|
106 |
if (";5;8;16;496;498;".indexOf(";" + String.valueOf(formType) + ";") != -1) {// 加入同一筛选条件下的上下单号 |
|
107 |
if (listInfo.size() > 0) { |
|
108 |
String nextSql = ""; |
|
109 |
Matcher matcher = pattern.matcher(lookUpSql.toLowerCase()); |
|
110 |
if (matcher.find()) { |
|
111 |
lookUpSql = lookUpSql.toLowerCase().replace(matcher.group(), "doccode="); |
|
112 |
} |
|
113 |
StringBuffer docAndDoc = new StringBuffer(); |
|
114 |
// 去掉空格,by danaus 2020/12/3 16:02 |
|
115 |
nextSql = lookUpSql.toLowerCase().replaceAll("doccode\\s*=\\s*'.*?'", "1=1") |
|
116 |
.replaceFirst("top\\s*\\d*\\s*\\*", "top 1 doccode ") + " order by doccode asc "; |
|
117 |
docAndDoc.append(getSqlDoc(nextSql, session));// 第一单 |
|
118 |
|
|
119 |
nextSql = lookUpSql.toLowerCase().replaceAll("doccode\\s*=\\s*", "doccode < ") |
|
120 |
.replaceFirst("top\\s*\\d*\\s*\\*", "top 1 doccode ") + " order by doccode desc "; |
|
121 |
docAndDoc.append(";").append(getSqlDoc(nextSql, session));// 上一单 |
|
122 |
|
|
123 |
nextSql = docAndDoc.toString(); |
|
124 |
mapDoc.put("updoc", nextSql); |
|
125 |
docAndDoc.delete(0, docAndDoc.length()); |
|
126 |
|
|
127 |
nextSql = lookUpSql.toLowerCase().replaceAll("doccode\\s*=\\s*\\S*", "1=1") |
|
128 |
.replaceFirst("top\\s*\\d*\\s*\\*", "top 1 doccode ") + " order by doccode desc "; |
|
129 |
docAndDoc.append(getSqlDoc(nextSql, session));// 最后一单 |
|
130 |
|
|
131 |
nextSql = lookUpSql.toLowerCase().replaceAll("doccode\\s*=\\s*", "doccode > ") |
|
132 |
.replaceFirst("top\\s*\\d*\\s*\\*", "top 1 doccode ") + " order by doccode asc "; |
|
133 |
docAndDoc.append(";").append(getSqlDoc(nextSql, session));// 下一单 |
|
134 |
nextSql = docAndDoc.toString(); |
|
135 |
mapDoc.put("nextdoc", nextSql); |
|
136 |
docAndDoc = null; |
|
137 |
} else { |
|
138 |
if (where.indexOf("1=2") == -1) {// 是否是新单据状态 |
|
139 |
// 上面的方法没有查到该单据并且不是新单据后,这里执行是否有权限查看或单据已经不存在的返回提示---xin |
|
140 |
// 2015-9-22 14:43:37 |
|
141 |
try { |
|
142 |
List<Map<String, Object>> isDoc = null; |
|
143 |
String w = "1=2"; |
|
144 |
Pattern pattern1 = Pattern.compile("and\\s*\\(\\s*");// 去掉and后面在()里的权限条件 |
|
145 |
Matcher matcher = pattern1.matcher(where.toLowerCase()); |
|
146 |
if (matcher.find()) { |
|
147 |
w = where.toLowerCase().split("and\\s*\\(\\s*")[0]; |
|
148 |
} else { |
|
149 |
pattern1 = Pattern.compile("doccode\\s*=\\s*\\S*"); |
|
150 |
matcher = pattern1.matcher(where.toLowerCase()); |
|
151 |
if (matcher.find()) { |
|
152 |
w = where; |
|
153 |
} |
|
154 |
} |
|
155 |
String isDoccode = sql + tableis + " where " + w;// 组装没有权限限制的sql |
|
156 |
isDoccode = isDoccode.replace("!", ""); |
|
157 |
isDoc = sqlDBHelperIfc.getHashMapObj(isDoccode);// 查询是否存在数据 |
|
158 |
if (isDoc != null && isDoc.size() > 0) {// 返回提示 |
|
159 |
throw new Exception("提示:你没有权限查看【" + w.split("'")[1] + "】的内容,请联系制单人【" |
|
160 |
+ DBHelper.getValue(isDoc.get(0), "entername") + "】"); |
|
161 |
} |
|
162 |
} catch (Exception e) { |
|
163 |
throw e; |
|
164 |
} |
|
165 |
} |
|
166 |
// if (tableis.equals("_sys_formid_Help")) { |
|
167 |
// } |
|
168 |
mapDoc.put("updoc", ";");// mapDoc 中都为小写key |
|
169 |
mapDoc.put("nextdoc", ";"); |
|
170 |
} |
|
171 |
} |
|
172 |
mapDoc.put("doc_size", listInfo.size());// 判断单据需要 |
|
173 |
mapDoc.put("yic", "t");// 这一个字段已经没有用处,新的模板里已经删除。这个字段以后需要删除掉 xin |
|
174 |
// 2019-3-1 10:10:44 |
|
175 |
listInfo.clear(); |
|
176 |
listInfo.add(mapDoc); |
|
177 |
} catch (SQLException | BadSqlGrammarException ee) { |
|
178 |
throw ee; |
|
179 |
} catch (Exception e) { |
|
180 |
throw e; |
|
181 |
} finally { |
|
182 |
} |
|
183 |
} |
|
184 |
return listInfo; |
|
185 |
} |
|
186 |
|
|
187 |
/** |
|
188 |
* 获得单号 |
|
189 |
* |
|
190 |
* @param sqlString 获得单号sql |
|
191 |
* @return 单号 |
|
192 |
* @throws SQLException |
|
193 |
*/ |
|
194 |
private String getSqlDoc(String sqlString, HttpSession session) throws SQLException { |
|
195 |
List<Map<String, Object>> listInfoDoc = null; |
|
196 |
try { |
|
197 |
// SpObserver.setDBtoInstance("_" + |
|
198 |
// session.getAttribute(SessionKey.DATA_BASE_ID)); |
|
199 |
listInfoDoc = sqlDBHelperIfc.getHashMapObj(sqlString); |
|
200 |
} catch (Exception e) { |
|
201 |
throw e; |
|
202 |
} finally { |
|
203 |
// SpObserver.setDBtoInstance(); |
|
204 |
} |
|
205 |
return listInfoDoc.size() > 0 |
|
206 |
? (listInfoDoc.get(0).get("doccode") == null ? "" : listInfoDoc.get(0).get("doccode").toString()) |
|
207 |
: ""; |
|
208 |
} |
|
209 |
|
|
210 |
/** |
|
211 |
* 替换掉sql语句中如:&formid&=9801之类的&formid&写法 此时直接可以为 formid 解决设置冲突而这样写时的错误 |
|
212 |
* |
|
213 |
* @param sql |
|
214 |
* @return |
|
215 |
*/ |
|
216 |
private String getRepSql(String sql) { |
|
217 |
Map<String, String> parm = new HashMap<String, String>(); |
|
218 |
List<String> list = DBHelper.getStrRepInfo(sql, "&"); |
|
219 |
boolean bol = ((sql.indexOf("'&") != -1 && sql.indexOf("&'") != -1) ? true : false); |
|
220 |
for (String id : list) { |
|
221 |
parm.put((bol ? "'" : "") + "&" + id + "&" + (bol ? "'" : ""), id); |
|
222 |
} |
|
223 |
sql = DBHelper.getRep(parm, sql); |
|
224 |
return sql; |
|
225 |
} |
|
226 |
|
|
227 |
/** |
|
228 |
* 复单的时候进入 |
|
229 |
*/ |
|
230 |
@Override |
|
231 |
public List<Map<String, Object>> getFromEnd(String sql, String tableis, String where, int formType, String copy, |
|
232 |
HttpServletRequest request) throws Exception { |
|
233 |
List<Map<String, Object>> lics = new ArrayList<Map<String, Object>>(); |
|
234 |
List<Map<String, Object>> lic = new ArrayList<Map<String, Object>>(); |
|
235 |
try { |
|
236 |
lic = getFromEnd(sql, tableis, where, formType, request); |
|
237 |
if (copy.equals("1") && DBHelper.getValueInt(lic.get(0), "formid") != 0) {// 复单时候进入 |
|
238 |
lics = systemSettingsBo.selectAll(Integer.parseInt(lic.get(0).get("formid").toString()), 0); |
|
239 |
@SuppressWarnings("rawtypes") |
|
240 |
Iterator iter = lic.get(0).entrySet().iterator(); |
|
241 |
while (iter.hasNext()) { |
|
242 |
@SuppressWarnings("rawtypes") |
|
243 |
Map.Entry entry = (Map.Entry) iter.next(); |
|
244 |
Object key = entry.getKey(); |
|
245 |
for (int c = 0; c < lics.size(); c++) { |
|
246 |
if ((key.toString().toLowerCase()) |
|
247 |
.equals(lics.get(c).get("fieldid").toString().toLowerCase())) { |
|
248 |
if (lics.get(c).get("iscopyexclude") == null) {//复单时是否排除 |
|
249 |
lics.get(c).put("iscopyexclude", "0"); |
|
250 |
} |
|
251 |
if (Integer.parseInt(lics.get(c).get("iscopyexclude").toString()) == 1) { |
|
252 |
lic.get(0).put(key.toString(), ""); |
|
253 |
} |
|
254 |
break; |
|
255 |
} |
|
256 |
} |
|
257 |
} |
|
258 |
} |
|
259 |
lic.get(0).put("doccode", ""); |
|
260 |
lic.get(0).put("docstatus", 0); |
|
261 |
} catch (Exception e) { |
|
262 |
throw new Exception("复单出错:" + e.getMessage()); |
|
263 |
} |
|
264 |
return lic; |
|
265 |
} |
|
266 |
|
|
267 |
/** |
|
268 |
* 返回单据状态 |
|
269 |
* |
|
270 |
*/ |
|
271 |
@Override |
|
272 |
public String getDocstatus(String where, int formid, String tabs, HttpServletRequest request) throws Exception { |
|
273 |
String docStatus = "0"; |
|
274 |
String docSql = "select top 1 docstatus from " + tabs + " where " + where; |
|
275 |
try { |
|
276 |
List<Map<String, Object>> docList = sqlDBHelperIfc.getHashMapObj(docSql); |
|
277 |
docStatus = DBHelper.getValueInt(docList.get(0), "docstatus") + ""; |
|
278 |
} catch (Exception e) { |
|
279 |
return docStatus; |
|
280 |
} finally { |
|
281 |
} |
|
282 |
return docStatus; |
|
283 |
} |
|
284 |
|
|
285 |
@Override |
|
286 |
public int getCancelButton(String sql) { |
|
287 |
BaseService b = (BaseService) FactoryBean.getBean("BaseService"); |
|
288 |
int ex = 0; |
|
289 |
// try{ |
|
290 |
ex = b.getSimpleJdbcTemplate().queryForObject(sql, Integer.class); |
|
291 |
// }catch(Exception e){ |
|
292 |
// } |
|
293 |
return ex; |
|
294 |
} |
|
295 |
|
|
296 |
/** |
|
297 |
* 针对496全是面板加载问题 wherePan 加载时得到的条件 where 9770功能号设置的关联关系 map 各个面板的集合 以功能号为key |
|
298 |
* map为值 |
|
299 |
*/ |
|
300 |
@Override |
|
301 |
public String getMultiTableWhere(String wherePan, int FT, String FK, String SeekGroupID, Boolean bol) |
|
302 |
throws Exception { |
|
303 |
try { |
|
304 |
if (bol) { |
|
305 |
for (Map<String, Object> docMap : multiList) { |
|
306 |
if (DBHelper.getValueInt(docMap, "formid") == FT) { |
|
307 |
wherePan = SeekGroupID + "='" + DBHelper.getValue(docMap, FK) + "'"; |
|
308 |
break; |
|
309 |
} |
|
310 |
} |
|
311 |
} else { |
|
312 |
multiList.clear(); |
|
313 |
} |
|
314 |
} catch (Exception e) { |
|
315 |
return wherePan; |
|
316 |
} finally { |
|
317 |
|
|
318 |
} |
|
319 |
return wherePan;// 返回关联关系后的where条件。 |
|
320 |
} |
|
321 |
|
|
322 |
@Override |
|
323 |
public void getMultiTableList(Map<String, Object> multi) { |
|
324 |
this.multiList.add(multi); |
|
325 |
} |
|
326 |
|
|
327 |
/** |
|
328 |
* 判断是否含有特殊字符 |
|
329 |
* |
|
330 |
* @param str |
|
331 |
* @return true为包含,false为不包含 |
|
332 |
*/ |
|
333 |
public static boolean isSpecialChar(String str) { |
|
334 |
String regEx = "[ _`~!@#$%^&*()+=|{}':;',\\[\\].<>/?~!@#¥%……&*()——+|{}【】‘;:”“’。,、?]|\n|\r|\t"; |
|
335 |
Pattern p = Pattern.compile(regEx); |
|
336 |
Matcher m = p.matcher(str); |
|
337 |
return m.find(); |
|
338 |
} |
|
339 |
|
|
340 |
/** |
|
341 |
* 加载功能号数据信息 xin 2021-1-26 09:32:34 |
|
342 |
*/ |
|
343 |
@Override |
|
344 |
public List<Map<String, Object>> getFormLoad(FormLoadParameterEntity formLoad) throws Exception { |
|
345 |
try { |
|
346 |
List<Map<String, Object>> formList = new ArrayList<>(); |
|
347 |
Map<String, Object> map = new HashMap<String, Object>(); |
|
348 |
// 特定类型窗体处理 |
|
349 |
if (";22;18;19;7;".indexOf(";" + formLoad.getFormType() + ";") != -1 && !formLoad.isHasCopy()) { |
|
350 |
try { |
|
351 |
String where = formLoad.getSqlWhere(); |
|
352 |
where = where.replaceAll("like", ";pb#").replaceAll("=", ";pb#"); |
|
353 |
where = where.replaceAll("@~", "").replaceAll("'", ""); |
|
354 |
String[] s = where.split("and"); |
|
355 |
String[] p = null; |
|
356 |
for (int i = 0; i < s.length; i++) { |
|
357 |
p = s[i].split(";pb#"); |
|
358 |
if (p.length > 1) { |
|
359 |
map.put(p[0].trim().toLowerCase(), p[1].trim()); |
|
360 |
} else { |
|
361 |
|
|
362 |
} |
|
363 |
} |
|
364 |
map.put("doc_size", 0);// 让其赋默认值 |
|
365 |
formList.add(map); |
|
366 |
return formList; |
|
367 |
} catch (ArrayIndexOutOfBoundsException e) { |
|
368 |
throw new Exception("加载功能号数据信息【" + formLoad.getFormType() + "】类型时,条件值出现数组越界。"); |
|
369 |
} catch (Exception e) { |
|
370 |
throw new Exception("加载功能号数据信息【" + formLoad.getFormType() + "】类型时出错。"); |
|
371 |
} |
|
372 |
} |
|
373 |
boolean hasData = ((";5;8;16;496;498;".indexOf(";" + formLoad.getFormType() + ";") != -1) ? true : false);// 是否为单据类型数据 |
|
374 |
// 表示已读 xin 2021-1-26 16:29:16 |
|
375 |
String readSql = "set nocount on \n " |
|
376 |
+ "update a set a.isread=1 from t219001 a where a.usercode='" |
|
377 |
+ formLoad.getSession().getAttribute(SessionKey.USERCODE) + "' " + "and a.formid=" |
|
378 |
+ formLoad.getFormId() + " and a.formtype=" + formLoad.getFormType() + " and a.doccode='" |
|
379 |
+ formLoad.getDoccode() + "' \n "; |
|
380 |
|
|
381 |
String sql = formLoad.getSql() + formLoad.getTableName() |
|
382 |
+ (!"".equals(formLoad.getSqlWhere()) ? " where " + formLoad.getSqlWhere() : ""); |
|
383 |
sql = sql.replace("!", ""); |
|
384 |
List<Map<String, Object>> list = sqlDBHelperIfc.getHashMapObj((hasData ? readSql : "") + sql);// 获取对应单号数据信息 |
|
385 |
if (list != null && list.size() > 0) {// 查询到单据信息的时候 |
|
386 |
map.putAll(list.get(0));// 把数据信息赋给map |
|
387 |
// 如果是复单进入 |
|
388 |
if (formLoad.isHasCopy() && formLoad.getFormId() != 0) { |
|
389 |
List<Map<String, Object>> fieldList = systemSettingsBo.selectAll(formLoad.getFormId(), 0); |
|
390 |
for(Map<String, Object> fMap : fieldList) { |
|
391 |
//iscopyexclude表示复单时是否排除这个字段,1表示需要排除掉 |
|
392 |
if(DBHelper.getValueInt(fMap, "iscopyexclude")==1) { |
9cf04d
|
393 |
String value=DBHelper.getValue(map, DBHelper.getValue(fMap, "fieldid")); |
X |
394 |
if(!"".equals(value)){ |
|
395 |
map.put(DBHelper.getValue(fMap, "fieldid").toLowerCase(), "");//直接赋空值 |
|
396 |
} |
a6a76f
|
397 |
} |
F |
398 |
} |
|
399 |
map.put("doccode", ""); |
|
400 |
map.put("docstatus", 0); |
|
401 |
formList.add(map); |
|
402 |
return formList; |
|
403 |
} |
|
404 |
// 是单据类型数据 |
|
405 |
if (hasData) { |
|
406 |
String nextSql = ""; |
|
407 |
Pattern pattern = Pattern.compile("\\w+doccode\\s*="); |
|
408 |
Matcher matcher = pattern.matcher(sql.toLowerCase()); |
|
409 |
if (matcher.find()) { |
|
410 |
sql = sql.toLowerCase().replace(matcher.group(), "doccode="); |
|
411 |
} |
|
412 |
StringBuffer docAndDoc = new StringBuffer(); |
|
413 |
// 去掉空格,by danaus 2020/12/3 16:02 |
|
414 |
nextSql = sql.toLowerCase().replaceAll("doccode\\s*=\\s*'.*?'", "1=1") |
|
415 |
.replaceFirst("top\\s*\\d*\\s*\\*", "top 1 doccode ") + " order by doccode asc "; |
|
416 |
docAndDoc.append(getSqlDoc(nextSql, formLoad.getSession()));// 第一单 |
|
417 |
|
|
418 |
nextSql = sql.toLowerCase().replaceAll("doccode\\s*=\\s*", "doccode < ") |
|
419 |
.replaceFirst("top\\s*\\d*\\s*\\*", "top 1 doccode ") + " order by doccode desc "; |
|
420 |
docAndDoc.append(";").append(getSqlDoc(nextSql, formLoad.getSession()));// 上一单 |
|
421 |
|
|
422 |
nextSql = docAndDoc.toString(); |
|
423 |
map.put("updoc", nextSql); |
|
424 |
docAndDoc.delete(0, docAndDoc.length()); |
|
425 |
|
|
426 |
nextSql = sql.toLowerCase().replaceAll("doccode\\s*=\\s*\\S*", "1=1") |
|
427 |
.replaceFirst("top\\s*\\d*\\s*\\*", "top 1 doccode ") + " order by doccode desc "; |
|
428 |
docAndDoc.append(getSqlDoc(nextSql, formLoad.getSession()));// 最后一单 |
|
429 |
|
|
430 |
nextSql = sql.toLowerCase().replaceAll("doccode\\s*=\\s*", "doccode > ") |
|
431 |
.replaceFirst("top\\s*\\d*\\s*\\*", "top 1 doccode ") + " order by doccode asc "; |
|
432 |
docAndDoc.append(";").append(getSqlDoc(nextSql, formLoad.getSession()));// 下一单 |
|
433 |
nextSql = docAndDoc.toString(); |
|
434 |
map.put("nextdoc", nextSql); |
|
435 |
} else {// 查询不到单据信息 |
|
436 |
if (!"".equals(formLoad.getDoccode())) {// 有单号。但是查询不到数据 |
|
437 |
sql = formLoad.getSql() + formLoad.getTableName() + " where doccode='" + formLoad.getDoccode() |
|
438 |
+ "'"; |
|
439 |
List<Map<String, Object>> docList = sqlDBHelperIfc.getHashMapObj(sql);// 获取对应单号数据信息 |
|
440 |
if (docList != null && docList.size() > 0) {// 单号能查询到数据,说明之前的查询设置了权限。当前的账号没权限查看 |
|
441 |
throw new Exception("提示:你没有权限查看【" + formLoad.getDoccode() + "】的内容,请联系制单人【" |
|
442 |
+ DBHelper.getValue(docList.get(0), "entername") + "】"); |
|
443 |
} |
|
444 |
} |
|
445 |
} |
|
446 |
} |
|
447 |
map.put("doc_size", list.size());// 判断单据需要 |
|
448 |
formList.add(map); |
|
449 |
return formList; |
|
450 |
} catch (Exception e) { |
|
451 |
throw e; |
|
452 |
} |
|
453 |
} |
|
454 |
|
|
455 |
/** |
|
456 |
* OA审核加载新界面数据 xin 2021-2-1 09:33:18 |
4bfacf
|
457 |
* @param formId |
a6a76f
|
458 |
* @param docState |
F |
459 |
* @param doccode |
|
460 |
* @param request |
|
461 |
* @return |
|
462 |
* @throws Exception |
|
463 |
*/ |
|
464 |
public List<Object> getOAVerifyMethod(int formId, int docState, String doccode, |
|
465 |
HttpServletRequest request) throws Exception { |
|
466 |
try { |
|
467 |
List<Object> lMap = new ArrayList<>(); |
|
468 |
List<Map<String, Object>> bList = gButtonIfc.getTopOaButton(formId);// 获取审核按钮集合 |
|
469 |
if (bList != null && bList.size() > 0) { |
|
470 |
List<List<Map<String, Object>>> oList = new ArrayList<>();// 存放排序好的审核按钮 |
|
471 |
List<Map<String, Object>> listInfo = new ArrayList<>();// 存放当前单据的详细信息数据 |
|
472 |
String but = "declare ";// 声明属性 |
|
473 |
String sql = "";// 查询当前单据能显示出来的审核按钮 |
|
474 |
String gets = "";// 返回声明的属性值 |
|
475 |
String HDTable = "";// 当前单据查询的表 |
|
476 |
String upId = ""; |
|
477 |
for (Map<String, Object> butMap : bList) { // 这里对审核按钮进行排序组装处理 |
|
478 |
String id = DBHelper.getValue(butMap, "fieldid"); |
|
479 |
if (!upId.equals(id)) { |
|
480 |
List<Map<String, Object>> fList = new ArrayList<>(); |
|
481 |
fList = bList.stream().filter(b -> id.equals(b.get("fieldid"))).collect(Collectors.toList()); |
|
482 |
if (fList.size() > 0) { |
|
483 |
oList.add(fList); |
|
484 |
upId = id; |
|
485 |
} |
|
486 |
} |
|
487 |
} |
|
488 |
Map<String, Object> sysMap = systemSettingsBo.getFormIdInTable(formId);// 获取审核的单据表名 |
|
489 |
if (sysMap != null) { |
|
490 |
HDTable = DBHelper.getValue(sysMap, "HDTable").trim();// 获取表名 |
|
491 |
// 获取当前单据的详细信息数据 |
|
492 |
listInfo = sqlDBHelperIfc |
|
493 |
.getHashMapObj("select * from " + HDTable + " where doccode='" + doccode + "'"); |
|
494 |
} |
|
495 |
// 遍历组装需要查询的审核按钮 |
|
496 |
for (int i = 0; i < bList.size(); i++) { |
|
497 |
Map<String, Object> map = bList.get(i); |
|
498 |
but += "@but" + DBHelper.getValue(map, "buttonID") + " int"; |
|
499 |
sql += "@but" + DBHelper.getValue(map, "buttonID") + "= (case when " |
|
500 |
+ (DBHelper.getValueInt(map, "editStatus") == 0 ? "" |
|
501 |
: "DocStatus in (" + DBHelper.getValueInt(map, "editStatus") + ") and ") |
|
502 |
+ (!"".equals(DBHelper.getValue(map, "showItemExpression")) |
|
503 |
? DBHelper.getValRepShi(formId, DBHelper.getValue(map, "showItemExpression"), |
|
504 |
request.getSession(), listInfo.get(0), false)// 这里需要对设置有会话值或替换值进行处理 |
|
505 |
: "curchecker like '%," + request.getSession().getAttribute(SessionKey.USERCODE) |
|
506 |
+ ",%'") |
|
507 |
+ " then 1 else 0 end ) \n"; |
|
508 |
gets += "@but" + DBHelper.getValue(map, "buttonID") + " as '" + DBHelper.getValue(map, "buttonID") |
|
509 |
+ "'"; |
|
510 |
if ((i + 1) < bList.size()) { |
|
511 |
but += ","; |
|
512 |
sql += ","; |
|
513 |
gets += ","; |
|
514 |
} |
|
515 |
} |
|
516 |
// 组装sql语句 |
|
517 |
sql = but + "\n set nocount on \n select " + sql + " from " + HDTable + " where DocCode='" + doccode |
|
518 |
+ "' \n" + "select " + gets; |
|
519 |
// 获取到当前单据显示出来的审核按钮 。0表示不需要显示,1表示要显示。 |
|
520 |
List<Map<String, Object>> listbut = sqlDBHelperIfc.getHashMapObj(sql); |
|
521 |
if (listbut != null && listbut.size() > 0) { |
|
522 |
// 组装 |
|
523 |
lMap = getButList(oList, listbut.get(0), listInfo.get(0), request); |
|
524 |
} |
|
525 |
return lMap; |
|
526 |
} else { |
|
527 |
throw new Exception("获取不到当前单据的审核按钮信息。"); |
|
528 |
} |
|
529 |
} catch (Exception e) { |
|
530 |
throw e; |
|
531 |
} |
|
532 |
} |
|
533 |
|
|
534 |
/** |
|
535 |
* 组装审核按钮 |
|
536 |
* @param oList |
|
537 |
* @param mapbut |
|
538 |
* @param mapInfo |
|
539 |
* @param request |
|
540 |
* @return |
|
541 |
*/ |
|
542 |
private List<Object> getButList(List<List<Map<String, Object>>> oList,Map<String, Object> mapbut, Map<String, Object> mapInfo, |
4bfacf
|
543 |
HttpServletRequest request) throws SQLException { |
a6a76f
|
544 |
try { |
F |
545 |
String userCode = (String) request.getSession().getAttribute(SessionKey.USERCODE); |
|
546 |
List<Object> buttons = new ArrayList<>(); |
|
547 |
List<Object> nameList = new ArrayList<>(); |
|
548 |
List<Object> oaButList = new ArrayList<>(); |
|
549 |
List<Object> dataList = new ArrayList<>(); |
|
550 |
Boolean bol = false; |
|
551 |
for (List<Map<String, Object>> butList : oList) { |
|
552 |
List<String> name = new ArrayList<>(); |
|
553 |
List<Object> clickList = new ArrayList<>(); |
|
554 |
List<Object> date = new ArrayList<>(); |
|
555 |
List<Map<String, Object>> but = new ArrayList<>(); |
|
556 |
String ccusercodes = ""; |
4bfacf
|
557 |
String id=""; |
a6a76f
|
558 |
for (Map<String, Object> buttonMap : butList) { |
F |
559 |
int state = DBHelper.getValueInt(mapbut, DBHelper.getValue(buttonMap, "buttonID"));// 按状态,0表示不显示,1表示显示。 |
|
560 |
if (state == 1) {// 显示状态进入 |
|
561 |
// 是当前审核人的话 bol=true |
|
562 |
bol = (DBHelper.getValueInt(buttonMap, "editStatus") == DBHelper.getValueInt(mapInfo, |
|
563 |
"DocStatus") ? true : bol); |
|
564 |
// 当前审核人审核结束后,但是撤销按钮有显示的话 bol=true |
|
565 |
if(DBHelper.getValue(mapInfo, "CurChecked").contains(userCode) && !DBHelper.getValue(mapInfo, "CurChecker").contains(userCode)) { |
|
566 |
bol=true; |
|
567 |
} |
|
568 |
if (name.size() == 0) { |
4bfacf
|
569 |
String namev=DBHelper.getValue(buttonMap, "fieldName"); |
X |
570 |
if(namev.indexOf("!")!=-1){//有查询 |
|
571 |
String sql=DBHelper.getValRepShi(namev, request.getSession(), mapInfo, false); |
|
572 |
List<Map<String, Object>> listbut = sqlDBHelperIfc.getHashMapObj(sql.replace("!", "")); |
|
573 |
name.add(DBHelper.getValue(listbut.get(0), ""));// 显示的审核名 |
|
574 |
}else{ |
|
575 |
name.add(namev);// 显示的审核名 |
|
576 |
} |
a6a76f
|
577 |
} |
F |
578 |
if (clickList.size() == 0) {// 显示当前审核页卡的按钮 |
|
579 |
clickList.add((bol ? "layui-show" : "")); |
4bfacf
|
580 |
id=DBHelper.getValue(buttonMap, "fieldid").toLowerCase(); |
X |
581 |
clickList.add(id);// 字段 |
a6a76f
|
582 |
ccusercodes = DBHelper.getValue(buttonMap, "fieldid").toLowerCase().replace("memo", |
F |
583 |
"ccusercodes"); |
|
584 |
clickList.add(ccusercodes);// 抄送字段 |
|
585 |
} |
|
586 |
// 查询按钮集合中是否有当前字段,有则在此上加按钮 |
|
587 |
String onclick = ""; |
|
588 |
String pawString = (DBHelper.getValueInt(buttonMap, "isShowPwdEdit") == 1) ? "true" : "false";// 弹出密码框 |
|
589 |
String ReturnCurChecker = DBHelper.getValue(buttonMap, "ReturnCurChecker"); |
|
590 |
String ReturnCurCheckerName = DBHelper.getValue(buttonMap, "ReturnCurCheckerName"); |
|
591 |
boolean isInspection = (DBHelper.getValueInt(buttonMap, "isInspection") == 1 ? true : false);// 是否禁止必录检查 |
|
592 |
String getBtnStr = pawString + ",'" + DBHelper.getValueInt(buttonMap, "formid") + "'," + "'" |
|
593 |
+ SettingKey.getHostUrl(request) + "/',this," + isInspection + ",'" |
|
594 |
+ DBHelper.getValue(buttonMap, "ExternalURL") + "'," |
|
595 |
+ DBHelper.getValueInt(buttonMap, "UrlShowLocation") + "," |
|
596 |
+ DBHelper.getValue(buttonMap, "buttonID"); |
|
597 |
String url1 = DBHelper.getValueInt(buttonMap, "FT") + "/" |
|
598 |
+ DBHelper.getValueInt(buttonMap, "FTFormType") + "/index.jsp"; |
|
599 |
switch (DBHelper.getValueInt(buttonMap, "SelectChecker")) { |
|
600 |
case 0: |
|
601 |
onclick = "window.parent.getBtn(" + getBtnStr + ");"; |
|
602 |
break; |
|
603 |
case 1: |
|
604 |
onclick = "window.parent.createPopSelect('" + ReturnCurChecker + "','" |
|
605 |
+ ReturnCurCheckerName + "'," + getBtnStr + ");"; |
|
606 |
break; |
|
607 |
case 2: |
|
608 |
onclick = "window.parent.mulChoice2('" + DBHelper.getValue(buttonMap, "FK") + "','" |
|
609 |
+ DBHelper.getValue(buttonMap, "SeekGroupID") + "','" |
|
610 |
+ DBHelper.getValue(buttonMap, "sPremissField") + "','" |
|
611 |
+ DBHelper.getValue(buttonMap, "dPremissField") + "','" |
|
612 |
+ DBHelper.getValue(buttonMap, "FKeFilter") + "','" + SettingKey.getHostUrl(request) |
|
613 |
+ "/app'+spellPath+'" + url1 + "'," + getBtnStr + ");"; |
|
614 |
break; |
|
615 |
default: |
|
616 |
break; |
|
617 |
} |
|
618 |
String par = DBHelper.getValue(buttonMap, "fieldid").toLowerCase() + ";" |
|
619 |
+ DBHelper.getValue(buttonMap, "docitem"); |
|
620 |
Map<String, Object> parMap = new HashMap<>(); |
|
621 |
parMap.put("click", |
4bfacf
|
622 |
"getccusercodes('"+id+"','" + ccusercodes + "');window.parent.setOa('" + par + "');" + onclick); |
a6a76f
|
623 |
parMap.put("butname", DBHelper.getValue(buttonMap, "ButtonName")); |
F |
624 |
parMap.put("iocn", getIocnText(DBHelper.getValueInt(buttonMap, "docitem"))); |
|
625 |
parMap.put("id", DBHelper.getValueInt(buttonMap, "buttonID")); |
|
626 |
but.add(parMap); |
|
627 |
} |
|
628 |
if (date.size() == 0) {// 显示流程跟踪 |
4bfacf
|
629 |
String namev=DBHelper.getValue(buttonMap, "fieldName"); |
X |
630 |
if(namev.indexOf("!")!=-1){//有查询 |
|
631 |
String sql=DBHelper.getValRepShi(namev, request.getSession(), mapInfo, false); |
|
632 |
List<Map<String, Object>> listbut = sqlDBHelperIfc.getHashMapObj(sql.replace("!", "")); |
|
633 |
date.add(DBHelper.getValue(listbut.get(0), "")); |
|
634 |
}else{ |
|
635 |
date.add(namev); |
|
636 |
} |
a6a76f
|
637 |
String userName = DBHelper.getValue(mapInfo, |
F |
638 |
DBHelper.getValue(buttonMap, "fieldid").toLowerCase().replace("memo", "username")); |
|
639 |
String dates = DBHelper.getValue(mapInfo, |
|
640 |
DBHelper.getValue(buttonMap, "fieldid").toLowerCase().replace("memo", "date")); |
|
641 |
date.add(bol ? "" : userName); |
|
642 |
date.add(bol ? "" : dates); |
|
643 |
date.add(bol ? "" : "process-active"); |
|
644 |
date.add(bol ? "" : DBHelper.getValue(mapInfo, DBHelper.getValue(buttonMap, "fieldid"))); |
|
645 |
} |
|
646 |
} |
|
647 |
if (name != null && name.size() == 1) { |
|
648 |
name.add((bol ? "layui-this" : ""));// 显示当前审核页卡 |
|
649 |
nameList.add(name); |
|
650 |
} |
|
651 |
if (clickList != null && clickList.size() > 0) { |
|
652 |
clickList.add(but); |
|
653 |
oaButList.add(clickList); |
|
654 |
} |
|
655 |
if (date != null && date.size() > 0) { |
|
656 |
dataList.add(date); |
|
657 |
} |
|
658 |
} |
|
659 |
// 下面的顺序不能乱,会影响界面显示 |
|
660 |
buttons.add(nameList); |
|
661 |
buttons.add(oaButList); |
|
662 |
buttons.add(dataList); |
|
663 |
return buttons; |
|
664 |
} catch (Exception e) { |
|
665 |
throw e; |
|
666 |
} |
|
667 |
} |
|
668 |
|
|
669 |
/** |
|
670 |
* 获取审核按钮图标 |
|
671 |
* @param docitem |
|
672 |
* @return |
|
673 |
*/ |
|
674 |
private String getIocnText(int docitem) { |
|
675 |
String iocn = ""; |
|
676 |
switch (docitem) { |
|
677 |
case 10: |
|
678 |
iocn="icon-tongguo";//通过 |
|
679 |
break; |
|
680 |
case 20: |
|
681 |
iocn="icon-bohui";//驳回 |
|
682 |
break; |
|
683 |
case 30: |
|
684 |
iocn="icon-bohuidao";//驳回上一级 |
|
685 |
break; |
|
686 |
case 40: |
|
687 |
iocn="icon-chexiao";//撤销 |
|
688 |
break; |
|
689 |
case 50: |
|
690 |
iocn="icon-baocun";//保存 |
|
691 |
break; |
|
692 |
default: |
|
693 |
break; |
|
694 |
} |
|
695 |
return iocn; |
|
696 |
} |
|
697 |
} |