提交 | 用户 | age
|
a6a76f
|
1 |
/* |
F |
2 |
* (#)TreeGrid.java 1.0 2011-3-3 2011-3-3 |
|
3 |
*/ |
|
4 |
package com.yc.action.grid; |
|
5 |
|
|
6 |
import com.yc.action.BaseAction; |
|
7 |
import com.yc.exception.ApplicationException; |
|
8 |
import com.yc.factory.FactoryBean; |
|
9 |
import com.yc.multiData.SpObserver; |
|
10 |
import com.yc.service.build.type.T_22_Ifc; |
|
11 |
import com.yc.service.grid.GridServiceIfc; |
|
12 |
import com.yc.service.impl.DBHelper; |
|
13 |
import com.yc.utils.EncodeUtil; |
|
14 |
import com.yc.utils.FileUtil; |
|
15 |
import com.yc.utils.YCBase64; |
|
16 |
import org.apache.commons.lang.StringUtils; |
|
17 |
import org.springframework.beans.factory.annotation.Autowired; |
|
18 |
import org.springframework.dao.DataAccessException; |
|
19 |
import org.springframework.dao.EmptyResultDataAccessException; |
|
20 |
import org.springframework.jdbc.support.rowset.SqlRowSet; |
|
21 |
import org.springframework.jdbc.support.rowset.SqlRowSetMetaData; |
|
22 |
import org.springframework.stereotype.Service; |
|
23 |
|
|
24 |
import java.io.File; |
|
25 |
import java.io.UnsupportedEncodingException; |
|
26 |
import java.sql.SQLException; |
5f1f90
|
27 |
import java.util.ArrayList; |
a6a76f
|
28 |
import java.util.HashMap; |
F |
29 |
import java.util.List; |
|
30 |
import java.util.Map; |
|
31 |
import java.util.regex.Pattern; |
|
32 |
|
|
33 |
|
|
34 |
/*** |
|
35 |
* TreeGrid表格生成, |
|
36 |
* |
|
37 |
* |
|
38 |
* @author 邓文峰 2011-3-3 |
|
39 |
**/ |
|
40 |
@SuppressWarnings("all") |
|
41 |
@Service("treeGrid") |
|
42 |
public class TreeGrid extends BaseAction implements TreeGridIfc { |
|
43 |
private static final int GRID_HEIGHT = 300; |
|
44 |
/** |
|
45 |
* 表格处理的业务类 |
|
46 |
*/ |
|
47 |
@Autowired |
|
48 |
private GridServiceIfc gridService;//表格处理的业务类 |
|
49 |
|
|
50 |
//static String domain= AttachmentConfig.get("attachment.server"); |
|
51 |
|
|
52 |
/** |
|
53 |
* 取得与树设置有关的字段名, |
|
54 |
* 格式:树1字段1;树1字段2,树2字段1;树2字段2 |
|
55 |
* by danaus 2018-11-20 支持3类型显示多树功能而修改 |
|
56 |
**/ |
|
57 |
private synchronized String getTreeFields(int formid, String dbid) { |
|
58 |
try { |
|
59 |
SpObserver.setDBtoInstance("_" + dbid); |
|
60 |
return gridService.getSimpleJdbcTemplate().queryForObject("SELECT stuff((SELECT',' + CONVERT(VARCHAR, nodeid) FROM _systreeset where formid=? FOR XML PATH ('')),1,1,'') ", new Object[]{formid}, String.class); |
|
61 |
} finally { |
|
62 |
SpObserver.setDBtoInstance(); |
|
63 |
} |
|
64 |
} |
|
65 |
|
|
66 |
/** |
|
67 |
* 根据功能号取得格线高度 |
|
68 |
**/ |
|
69 |
public synchronized int getGrigHieght(int formID, int type, String dbid) { |
|
70 |
if (type != 8) { |
|
71 |
try { |
|
72 |
SpObserver.setDBtoInstance("_" + dbid); |
|
73 |
Integer in = gridService.getSimpleJdbcTemplate().queryForObject("select GridHeight from gform where formid=" + formID, Integer.class); |
|
74 |
return in == null ? 0 : in; |
|
75 |
} finally { |
|
76 |
SpObserver.setDBtoInstance(); |
|
77 |
} |
|
78 |
} else if (type == 8) {//3表结构 |
|
79 |
int temp = 0; |
|
80 |
int tg = 0; |
|
81 |
List<Map> list = null; |
|
82 |
try { |
|
83 |
SpObserver.setDBtoInstance("_" + dbid); |
|
84 |
list = gridService.getThreeTableInfo(formID); |
|
85 |
} finally { |
|
86 |
SpObserver.setDBtoInstance(); |
|
87 |
} |
|
88 |
if (list.size() == 0) { |
|
89 |
throw new ApplicationException("三表关联未设置好--9825"); |
|
90 |
} |
|
91 |
for (Map map : list) { |
|
92 |
temp = (Integer) map.get("DetailFormID"); |
|
93 |
tg = (map.get("gridHeight") == null) ? 0 : (Integer) map.get("gridHeight"); |
|
94 |
} |
|
95 |
list = null; |
|
96 |
try { |
|
97 |
SpObserver.setDBtoInstance("_" + dbid); |
|
98 |
int h = gridService.getSimpleJdbcTemplate().queryForObject("select GridHeight from gform where formid=" + formID, Integer.class); |
|
99 |
if (tg == 0) |
|
100 |
tg = gridService.getSimpleJdbcTemplate().queryForObject("select GridHeight from gform where formid=" + temp, Integer.class); |
|
101 |
return (tg == 0 ? GRID_HEIGHT : tg) + (h == 0 ? GRID_HEIGHT : h); |
|
102 |
} finally { |
|
103 |
SpObserver.setDBtoInstance(); |
|
104 |
} |
|
105 |
} else { |
|
106 |
return 0; |
|
107 |
} |
|
108 |
} |
|
109 |
|
|
110 |
/** |
|
111 |
* 根据类型选用不同的字段作为排序 |
|
112 |
* |
|
113 |
* @return 1表示清单,2表示明细 |
|
114 |
**/ |
|
115 |
private int setOrderName(TreeGridDTO dto) { |
|
116 |
|
|
117 |
switch (dto.winType) { |
|
118 |
case 9: |
|
119 |
case 15: |
|
120 |
case 17: |
|
121 |
case 499: |
|
122 |
case 497: |
|
123 |
if (dto.conNum == 0) { |
|
124 |
//isList=t |
|
125 |
return 1; |
|
126 |
} else |
|
127 |
return 2; |
|
128 |
case 1: |
|
129 |
if (dto.b497 || dto.b499) |
|
130 |
return 2; |
|
131 |
else |
|
132 |
return 1; |
|
133 |
default: |
|
134 |
return 1; |
|
135 |
} |
|
136 |
} |
|
137 |
|
|
138 |
private int setToolAdd(TreeGridDTO dto) { |
|
139 |
switch (dto.winType) { |
|
140 |
case 9: |
|
141 |
case 15: |
|
142 |
case 17: |
|
143 |
case 499: |
|
144 |
case 497: |
|
145 |
if (dto.conNum == 0) |
|
146 |
return 1; |
|
147 |
else |
|
148 |
return 2; |
|
149 |
case 18: |
|
150 |
case 38: |
|
151 |
case 19: |
|
152 |
return 1; |
|
153 |
default: |
|
154 |
return 2; |
|
155 |
} |
|
156 |
} |
|
157 |
|
|
158 |
//只有明细表才需要执行,其他的都只是输出{} |
|
159 |
private String setToolAddForNew(TreeGridDTO dto) { |
|
160 |
if (dto.postStatusAddNew) return "<%=bdMap.toString()%>"; |
|
161 |
switch (dto.winType) { |
|
162 |
case 9: |
|
163 |
case 15: |
|
164 |
case 17: |
|
165 |
case 499: |
|
166 |
case 497: |
|
167 |
if (dto.conNum == 0) |
|
168 |
return "{}"; |
|
169 |
else |
|
170 |
return "<%=bdMap.toString()%>"; |
|
171 |
case 18: |
|
172 |
case 38: |
|
173 |
case 19: |
|
174 |
return "{}"; |
|
175 |
default: |
|
176 |
return "{}"; |
|
177 |
} |
|
178 |
} |
|
179 |
|
|
180 |
/** |
|
181 |
* 根据窗体类型取得应当读取哪一个表的数据. |
|
182 |
**/ |
|
183 |
private synchronized int setGetPrivaryTable(int winType) { |
|
184 |
switch (winType) { |
|
185 |
case 5: |
|
186 |
case 9: |
02a0e6
|
187 |
case 20: |
a6a76f
|
188 |
case 30: |
F |
189 |
case 301: |
|
190 |
case 10: |
|
191 |
case 19: |
|
192 |
case 304: |
|
193 |
return 1;//从表 |
|
194 |
case 8://三表 |
|
195 |
return 2; |
|
196 |
default: |
|
197 |
return 0; |
|
198 |
} |
|
199 |
} |
|
200 |
|
|
201 |
/** |
|
202 |
* 是否为单据类型, |
|
203 |
**/ |
|
204 |
private synchronized boolean isDanJun(TreeGridDTO dto) { |
|
205 |
if (dto.winType == 15 || dto.winType == 9 || dto.winType == 17 || dto.winType == 499 || dto.winType == 497) |
|
206 |
return true; |
|
207 |
else |
|
208 |
return false; |
|
209 |
} |
|
210 |
|
|
211 |
/** |
|
212 |
* 根据功能号取得主从表名称 -----9801信息---增加新窗体类型都需要增加相应判断 |
|
213 |
**/ |
|
214 |
public String getTableName(int formid, String winType, TreeGridDTO dto) { |
|
215 |
SqlRowSet gform = null; |
|
216 |
try { |
|
217 |
SpObserver.setDBtoInstance("_" + dto.dbid); |
|
218 |
gform = gridService.getGformByFormID(formid); |
|
219 |
} finally { |
|
220 |
SpObserver.setDBtoInstance(); |
|
221 |
} |
|
222 |
String[] temp = winType.split("\\|"); |
|
223 |
dto.winType = Integer.parseInt(temp[0]); |
|
224 |
dto.conNum = temp.length > 1 ? Integer.parseInt(temp[1]) : 0; |
|
225 |
if (!gform.wasNull()) { |
|
226 |
gform.first(); |
|
227 |
dto.HDTable = gform.getString("hdtable"); |
|
228 |
dto.dataformid = (gform.getString("dataformid") == null || gform.getString("dataformid").length() == 0 || gform.getString("dataformid").equalsIgnoreCase("0")) ? "" : (gform.getString("dataformid") + (!this.isDanJun(dto) ? "" : "@p@" + gform.getInt("predocstatus"))); |
|
229 |
dto.tranformid = (gform.getString("dataformid") == null || gform.getString("dataformid").length() == 0 || gform.getString("dataformid").equalsIgnoreCase("0")) ? "" : (gform.getString("dataformid")); |
|
230 |
dto.DTtable = gform.getString("dttable"); |
|
231 |
dto.frozencols = gform.getInt("frozencols"); |
|
232 |
dto.formname = gform.getString("formname"); |
|
233 |
dto.gantt = gform.getBoolean("isGantt");//是否为甘特图类型的功能号 |
|
234 |
dto.predocstatus = gform.getInt("predocstatus");//确认前状态,为了给格线在确认后不能再修改(新增,修改,删除) by 2013-02-01 |
493df4
|
235 |
dto.postDocStatus = gform.getInt("postdocstatus");//确认后状态,为了给格线在确认后不能再修改(新增,修改,删除) by 2013-02-01 |
a6a76f
|
236 |
dto.rowcopyfields = gform.getString("rowcopyfields");//行复制时排除字段 |
F |
237 |
dto.pageSize = gform.getInt("pageSize");//页记录数 |
|
238 |
dto.autopaging = gform.getInt("autopaging");//是否分页 |
|
239 |
dto.optype = gform.getInt("optype");//功能号权限 |
|
240 |
dto.lockGridSort = gform.getInt("LockGridSort");//冻结列排序 |
|
241 |
dto.colset = gform.getInt("isShowCell");//是否显示列过滤 |
|
242 |
dto.mainCol = gform.getString("byGroup");//树分组显示字段 |
|
243 |
dto.isFilter = gform.getInt("isFilter");//是否打开过滤功能 |
|
244 |
boolean blactions = gform.getBoolean("addNewRow");//直接增行 |
|
245 |
// try { |
|
246 |
// dto.postStatusAddNew=gform.getInt("PostStatusGridAddNew");//根据状态值是否可以显示增行按钮,用在OA审核中 |
|
247 |
// }catch(Exception e) { |
|
248 |
// dto.postStatusAddNew=0; |
|
249 |
// } |
|
250 |
if (blactions) dto.actions = "<Actions OnClickButtonAdd=\"AddRowEnd\" />"; |
|
251 |
dto.defaultRowCount = gform.getInt("DefaultRowCount");//格线默认加载时显示行数 |
|
252 |
if (!"".equalsIgnoreCase(dto.tolkey) && (dto.b497 || dto.b499) && dto.PriFormID > 0) {//是多表的情况 且是第一个子功能号 |
|
253 |
|
|
254 |
SqlRowSet f = null; |
|
255 |
try { |
|
256 |
SpObserver.setDBtoInstance("_" + dto.dbid); |
|
257 |
f = gridService.getGformByFormID(dto.PriFormID); |
|
258 |
} finally { |
|
259 |
SpObserver.setDBtoInstance(); |
|
260 |
} |
|
261 |
if (!f.wasNull()) { |
|
262 |
f.first(); |
|
263 |
dto.rowcopyformids = f.getString("rowcopyformids");//复单时排除功能号 |
|
264 |
} |
|
265 |
|
|
266 |
} else { |
|
267 |
dto.rowcopyformids = gform.getString("rowcopyformids");//复单时排除功能号 |
|
268 |
} |
|
269 |
if (dto.gridHeight == 0) dto.gridHeight = gform.getInt("GridHeight");//表格高度 |
|
270 |
dto.glcodefield = gform.getString("glcodefield");//会计科目需要的字段 |
|
271 |
if (!this.isNullOrEmptry(dto.glcodefield)) {//格式:主表汇总,明细表汇总|平衡字段|平衡值公式字段 |
|
272 |
List<Map<String, Object>> map = null; |
|
273 |
try { |
|
274 |
SpObserver.setDBtoInstance("_" + dto.dbid); |
|
275 |
map = gridService.getSimpleJdbcTemplate().queryForList("select MasterSumFields,DetailSumFields from _sysmasterdetail where FormID=?", dto.formID); |
|
276 |
} finally { |
|
277 |
SpObserver.setDBtoInstance(); |
|
278 |
} |
|
279 |
if (map.size() > 0) { |
|
280 |
Map<String, Object> m = map.get(0); |
|
281 |
dto.gltotal = m.get("MasterSumFields") + "," + m.get("DetailSumFields") + "|" + gform.getString("checkblncfields") + "|" + gform.getString("chkFormula"); |
|
282 |
m = null; |
|
283 |
} |
|
284 |
map = null; |
|
285 |
} |
|
286 |
dto.index1 = gform.getString("index1");//列表的排序字段-9类型 |
|
287 |
dto.index2 = gform.getString("index2");//明细表的排序字段-5类型 |
|
288 |
dto.formdatafilters = gform.getString("formdatafilters") == null ? "" : this.replaceBlank(gform.getString("formdatafilters")); |
|
289 |
dto.ProcGroupafterSavedoc = gform.getString("ProcGroupafterSavedoc") == null ? "" : this.replaceBlank(gform.getString("ProcGroupafterSavedoc")); |
|
290 |
dto.trangroup = gform.getString("transgroupcode") == null ? "" : gform.getString("transgroupcode"); |
|
291 |
dto.DealAfterDocSave = gform.getString("DealAfterDocSave") == null ? "" : this.replaceBlank(gform.getString("DealAfterDocSave")); |
|
292 |
|
|
293 |
dto.cancelProc = gform.getString("CancelBtnProcName") == null ? "" : this.replaceBlank(gform.getString("CancelBtnProcName")); |
|
294 |
|
|
295 |
dto.revokeProc = gform.getString("RevokeBtnProcName") == null ? "" : this.replaceBlank(gform.getString("RevokeBtnProcName")); |
|
296 |
|
|
297 |
dto.cancelisSave = gform.getBoolean("CancelIsSave") ? 1 : 0; |
|
298 |
dto.isExchangeDataWithHost = gform.getBoolean("isExchangeDataWithHost") ? 1 : 0; |
|
299 |
|
|
300 |
if (dto.winType == 0 || dto.winType == 7 || dto.winType == 1 || dto.winType == 5 || (dto.winType == 9 && dto.conNum == 0) || dto.winType == 3 || dto.winType == 4 || |
|
301 |
dto.winType == 17 || dto.winType == 302 || dto.winType == 19 || |
|
302 |
(dto.winType == 499 && dto.conNum == 0) || |
|
303 |
(dto.winType == 497 && dto.conNum == 0) || |
|
304 |
(dto.winType == 15 && (dto.conNum == 0 || dto.conNum == 2))) { |
|
305 |
dto.table = dto.HDTable; |
|
306 |
dto.isList = true; |
|
307 |
} else { |
|
308 |
dto.table = dto.DTtable; |
|
309 |
} |
|
310 |
|
|
311 |
gform = null; |
|
312 |
return dto.table; |
|
313 |
} else |
|
314 |
return null; |
|
315 |
} |
|
316 |
|
2e60c6
|
317 |
public void getFirstField(TreeGridDTO dto) throws DataAccessException, SQLException { |
a6a76f
|
318 |
|
2e60c6
|
319 |
List<String> keys = null; |
a6a76f
|
320 |
try { |
F |
321 |
SpObserver.setDBtoInstance("_" + dto.dbid); |
2e60c6
|
322 |
keys = gridService.getPrimaryKey(dto.table); |
a6a76f
|
323 |
} finally { |
F |
324 |
SpObserver.setDBtoInstance(); |
|
325 |
} |
2e60c6
|
326 |
if(keys!=null) { |
a6a76f
|
327 |
for (String str : keys) { |
F |
328 |
if ("".equals(dto.field)) |
|
329 |
dto.field += str; |
|
330 |
else |
|
331 |
dto.field += ";" + str; |
|
332 |
} |
|
333 |
} |
|
334 |
dto.primeKey = dto.field; |
|
335 |
} |
|
336 |
|
|
337 |
private void print(String root, TreeGridDTO dto) throws DataAccessException, SQLException {//输出表格 |
|
338 |
String sql = "select top 1 fieldid from gfield where formid=? and HeadFlag=? and ShowOnGrid=1 order by statisid desc"; |
|
339 |
if (dto.winType != 9 && dto.winType != 15) {//针对只生成一个表格的情况,17类型由于第二个没有表格所以也存在这里了 |
|
340 |
try { |
|
341 |
SpObserver.setDBtoInstance("_" + dto.dbid); |
|
342 |
dto.gfields = gridService.getGfiledByFormID9(dto.formID, this.setGetPrivaryTable(dto.winType));//取得所有字段信息 增加类型 |
|
343 |
} finally { |
|
344 |
SpObserver.setDBtoInstance(); |
|
345 |
} |
|
346 |
} else { |
|
347 |
if (dto.winType == 15 && dto.conNum == 1) { |
|
348 |
List<Map> list = null; |
|
349 |
try { |
|
350 |
SpObserver.setDBtoInstance("_" + dto.dbid); |
|
351 |
list = gridService.getThreeTableInfo(dto.formID); |
|
352 |
} finally { |
|
353 |
SpObserver.setDBtoInstance(); |
|
354 |
} |
|
355 |
if (list.size() == 0) { |
ba6749
|
356 |
throw new ApplicationException(";;" + dto.formID + "-三表关联未设置好,请在9825功能号维护好"); |
F |
357 |
} |
|
358 |
if (list.size() >1) { |
|
359 |
throw new ApplicationException(";;" + dto.formID + "-三表关联存在多条记录,请在9825功能号维护好"); |
a6a76f
|
360 |
} |
F |
361 |
for (Map map : list) { |
|
362 |
int temp = (Integer) map.get("DetailFormID"); |
|
363 |
dto.masterKey = (String) map.get("MasterKeys"); |
|
364 |
dto.detailKey = (String) map.get("DetailKeys"); |
|
365 |
dto.formID3 = temp; |
|
366 |
dto.tempGridHeight = (map.get("gridHeight") == null) ? 0 : (Integer) map.get("gridHeight"); |
|
367 |
} |
|
368 |
list = null; |
|
369 |
} |
|
370 |
if (dto.conNum < 2) { |
|
371 |
try { |
|
372 |
SpObserver.setDBtoInstance("_" + dto.dbid); |
|
373 |
dto.gfields = gridService.getGfiledByFormID9(dto.formID, dto.conNum);//取得所有字段信息 |
|
374 |
dto.lastField = gridService.getSimpleJdbcTemplate().queryForObject(sql, new Object[]{dto.formID, 1}, String.class); |
|
375 |
} catch (DataAccessException e) { |
|
376 |
dto.lastField = ""; |
|
377 |
throw new ApplicationException(dto.formID + "-列表没设置需要显示的字段,请在9802重新设置"); |
|
378 |
|
|
379 |
} finally { |
|
380 |
SpObserver.setDBtoInstance(); |
|
381 |
} |
|
382 |
} else {//三表中的第三张表 |
|
383 |
dto.minID = dto.formID;//为了生成页面时取第一表的功能号 |
|
384 |
dto.formID = dto.formID3; |
|
385 |
try { |
|
386 |
SpObserver.setDBtoInstance("_" + dto.dbid); |
|
387 |
dto.gfields = gridService.getGfiledByFormID9(dto.formID, 0);//取得所有 字段信息 |
|
388 |
dto.lastField = gridService.getSimpleJdbcTemplate().queryForObject(sql, new Object[]{dto.formID, 0}, String.class); |
|
389 |
} finally { |
|
390 |
SpObserver.setDBtoInstance(); |
|
391 |
} |
|
392 |
} |
|
393 |
} |
|
394 |
//try { |
|
395 |
this.getTableName(dto.formID, dto.winType + "|" + dto.conNum, dto);// 增加类型 |
|
396 |
if (dto.table == null) throw new ApplicationException(dto.formID + "--未设置明细表,请在9802设置后重新生成!"); |
493df4
|
397 |
if (dto.winType == 1 && ("".equals(dto.table) || dto.table == null)) { |
F |
398 |
throw new ApplicationException(dto.formID + ",类型:" + dto.winType + "--未设置主表,请在9801设置后重新生成!"); |
525df2
|
399 |
} |
a6a76f
|
400 |
if (dto.isTable) { |
F |
401 |
this.getFirstField(dto); |
|
402 |
} |
|
403 |
if (dto.conNum >= 2) |
|
404 |
if (dto.tempGridHeight != 0) dto.gridHeight = dto.tempGridHeight; |
|
405 |
|
|
406 |
gridConfig(root, dto); |
|
407 |
createCoumtHeader(dto); |
|
408 |
//} catch (Exception e) { |
|
409 |
// e.printStackTrace(); |
|
410 |
//} |
|
411 |
} |
|
412 |
|
|
413 |
private synchronized void fillColumnNumTree(int num, TreeGridDTO dto) {//根据最大行值填充列 |
|
414 |
StringBuilder mps = new StringBuilder(); |
|
415 |
int j = 0; |
|
416 |
//dto.gfields.first(); |
|
417 |
try { |
|
418 |
//do{ |
|
419 |
for (Map<String, Object> map : dto.gfields) { |
|
420 |
|
|
421 |
if ("1".equalsIgnoreCase(map.get("ShowOnGrid") + "")) { |
|
422 |
String dec = map.get("gridcaption") == null ? "" : map.get("gridcaption") + "";//表格描述 |
|
423 |
String fieldname = map.get("fieldname") == null ? "" : map.get("fieldname") + "";//字段描述 |
|
424 |
String id = map.get("fieldid") + "";//字段名 |
|
425 |
if (id.equalsIgnoreCase("id")) id = "_ycid_";//避免id与格线中的id冲突而增加,页面返回时需要转换 |
|
426 |
String cap = (dec == null || "".equalsIgnoreCase(dec)) ? fieldname : dec;//如果没定义表描述就取字段名称作为表格显示字段 |
|
427 |
if (cap == null || cap == "" || cap.length() == 0) cap = id; |
|
428 |
String[] temp = cap.split("\\|");//分割字符串,外表|接收数据|外表字段 |
|
429 |
int tempN = this.getColumnNumOf(temp[0], dto.tempStr, 0, dto);//取得当前列最大行数是多少. |
|
430 |
int colNum = this.getColumnNum(temp[0], dto.tempStr, 0, temp[0], 0, dto);//跨列值 |
|
431 |
int ts = num - temp.length; |
|
432 |
StringBuilder mp = new StringBuilder(); |
|
433 |
if (j != 0) mps.append("'"); |
|
434 |
if (tempN == num && temp.length < num) {//全行都有但长度不够需要在后面补足 |
|
435 |
for (int i = 0; i < ts; i++) { |
|
436 |
mp.append("|¥"); |
|
437 |
} |
|
438 |
mps.append(cap + mp.toString()); |
|
439 |
|
|
440 |
} else { |
|
441 |
if (colNum > 1) { |
|
442 |
for (int i = 0; i < ts; i++) { |
|
443 |
mp.append("|¥"); |
|
444 |
} |
|
445 |
mps.append(cap + mp.toString()); |
|
446 |
} else { |
|
447 |
for (int i = 0; i < ts; i++) { |
|
448 |
mp.append("¥|"); |
|
449 |
} |
|
450 |
mps.append(mp.toString() + cap); |
|
451 |
} |
|
452 |
} |
|
453 |
j++; |
|
454 |
mp = null; |
|
455 |
} |
|
456 |
} |
|
457 |
//while(dto.gfields.next()); |
|
458 |
} catch (Exception e) { |
|
459 |
//System.out.println(e+"错误3"); |
|
460 |
} |
|
461 |
dto.tempStr = mps.toString(); |
|
462 |
mps = null; |
|
463 |
} |
|
464 |
|
|
465 |
/** |
|
466 |
* 获取当前表定义的列格式最大数,作为自定义表头列分割的依据 |
|
467 |
* 循环gfields集合中{表格|描述}字段值,分割”|”生成数组,返回最大数组长度,及取得表所有字段描述和长度分布情况 |
|
468 |
* |
|
469 |
* @return int 最大值 |
|
470 |
*/ |
|
471 |
private synchronized int getMaxColumnNum(TreeGridDTO dto) { |
|
472 |
int num = 0; |
|
473 |
int j = 0; |
|
474 |
//dto.gfields.first(); |
|
475 |
try { |
|
476 |
//do{ |
|
477 |
for (Map<String, Object> map : dto.gfields) { |
|
478 |
if (GridUtils.prossRowSetDataType_Int(map, "ShowOnGrid") > 0) { |
|
479 |
String dec = map.get("gridcaption") == null ? "" : map.get("gridcaption") + "";//表格描述 |
|
480 |
String fieldname = map.get("fieldname") == null ? "" : map.get("fieldname") + "";//字段描述 |
|
481 |
String id = map.get("fieldid") + "";//字段名 |
|
482 |
if (id.equalsIgnoreCase("id")) id = "_ycid_";//避免id与格线中的id冲突而增加,页面返回时需要转换 |
|
483 |
String cap = (dec == null || "".equals(dec)) ? fieldname : dec;//如果没定义表描述就取字段名称作为表格显示字段 |
|
484 |
if (cap == null || cap == "" || cap.length() == 0) cap = id; |
|
485 |
String[] temp = cap.split("\\|");//分割字符串,外表|接收数据|外表字段 |
|
486 |
if (j != 0) dto.tempStr += "'";//特殊分隔符 |
|
487 |
dto.tempStr += cap; |
|
488 |
if (!dto.decMap.containsKey(temp[0])) {//不存在这个key时放到map保存 |
|
489 |
dto.decMap.put(temp[0], temp.length);//保存字段分割最大长度 |
|
490 |
} else if (temp.length > dto.decMap.get(temp[0])) {//当前值比map里的值大时候,换为新值 |
|
491 |
dto.decMap.remove(temp[0]); |
|
492 |
dto.decMap.put(temp[0], temp.length); |
|
493 |
} |
|
494 |
if (num < temp.length) { |
|
495 |
num = temp.length; |
|
496 |
} |
|
497 |
j++; |
|
498 |
} |
|
499 |
} |
|
500 |
//while(dto.gfields.next()); |
|
501 |
} catch (Exception e) { |
|
502 |
//System.out.println(e+"错误4"); |
|
503 |
} |
|
504 |
return num; |
|
505 |
} |
|
506 |
|
|
507 |
/** |
|
508 |
* 查找类似“表格|显示,表格|描述,表格|类型,表格|长度”中表格出现的次数 |
|
509 |
* |
|
510 |
* @param String colName---列名称 |
|
511 |
* @param String gridcaption---列名称的组合串,在getMaxColumnNum方法生成 |
|
512 |
*/ |
|
513 |
private synchronized int getColumnNum(String colName, String gridcaption, int index, String per, int m, TreeGridDTO dto) { |
|
514 |
if (colName.equalsIgnoreCase("¥")) return 0; |
|
515 |
int num = 0; |
|
516 |
String temp1 = colName; |
|
517 |
String temp2 = dto.tempStr; |
|
518 |
String[] temp3 = temp2.split("'"); |
|
519 |
String temp4 = "";//保存前一个值 |
|
520 |
int j = 0; |
|
521 |
for (int k = 0; k < temp3.length; k++) { |
|
522 |
j++; |
|
523 |
String s = temp3[k]; |
|
524 |
String[] ts = s.split("\\|"); |
|
525 |
if (ts.length < index + 1) continue; |
|
526 |
if (ts[index].equalsIgnoreCase(temp1.toLowerCase()) && per.equals(ts[index == 0 ? 0 : index - 1]) && j >= m) {//判断需要计算的列的前一个值与当前列的前一个列是否相同 |
|
527 |
num++; |
|
528 |
temp4 = ts[index]; |
|
529 |
} else if (temp4 != "" && !temp4.equals(ts[index])) {//不匹配时 |
|
530 |
break; |
|
531 |
} else { |
|
532 |
continue; |
|
533 |
} |
|
534 |
} |
|
535 |
temp3 = null; |
|
536 |
temp1 = null; |
|
537 |
temp2 = null; |
|
538 |
return num; |
|
539 |
} |
|
540 |
|
|
541 |
/** |
|
542 |
* 查找类似“表格|显示,表格|描述,表格|类型,表格|长度”中在表格所属的最大行数 |
|
543 |
* |
|
544 |
* @param String colName---列名称 |
|
545 |
* @param String gridcaption---列名称的组合串,在getMaxColumnNum方法生成 |
|
546 |
*/ |
|
547 |
private synchronized int getColumnNumOf(String colName, String gridcaption, int index, TreeGridDTO dto) { |
|
548 |
int num = 0; |
|
549 |
int temp = 0;//临时值 |
|
550 |
String temp1 = colName;//列名 |
|
551 |
String temp2 = dto.tempStr;//列串 |
|
552 |
String[] temp3 = temp2.split("'");//分割为数组 |
|
553 |
String temp4 = "";//保存前一个值 |
|
554 |
int j = 0; |
|
555 |
for (int k = 0; k < temp3.length; k++) { |
|
556 |
String s = temp3[k]; |
|
557 |
String[] ts = s.split("\\|"); |
|
558 |
if (ts.length < index + 1) continue; |
|
559 |
if (ts[index].equalsIgnoreCase(temp1) && (temp4 == "" || temp4.equalsIgnoreCase(ts[index]))) { |
|
560 |
temp = ts.length; |
|
561 |
temp4 = ts[index]; |
|
562 |
if (temp > num) num = temp; |
|
563 |
} else if (temp4 != "" && !temp4.equalsIgnoreCase(ts[index])) {//不匹配时 |
|
564 |
break; |
|
565 |
} else { |
|
566 |
continue; |
|
567 |
} |
|
568 |
} |
|
569 |
temp3 = null; |
|
570 |
temp1 = null; |
|
571 |
temp2 = null; |
|
572 |
return num; |
|
573 |
} |
|
574 |
|
|
575 |
/** |
493df4
|
576 |
* 判断当前生成的表格是属于列表还是明细,因为只有是明细表的标题才需要加必填星号 |
F |
577 |
* |
|
578 |
* @param dto |
|
579 |
* @return |
|
580 |
*/ |
|
581 |
private String getDetailGridTitle(TreeGridDTO dto, boolean keyInput, String id) { |
|
582 |
if (!keyInput) return " "; |
|
583 |
boolean isDeatail = false; |
|
584 |
switch (dto.winType) { |
|
585 |
case 1: |
|
586 |
case 10: |
|
587 |
case 3: |
|
588 |
case 7: |
|
589 |
case 301: |
|
590 |
case 302: |
|
591 |
case 304: |
|
592 |
isDeatail = true; |
|
593 |
break; |
|
594 |
case 9: |
|
595 |
if (dto.conNum == 1) isDeatail = true; |
|
596 |
break; |
|
597 |
case 15: |
|
598 |
if (dto.conNum > 0) isDeatail = true; |
|
599 |
break; |
|
600 |
case 497: |
|
601 |
if (dto.conNum == 1) isDeatail = true; |
|
602 |
break; |
|
603 |
} |
|
604 |
return isDeatail ? (id.toLowerCase() + "HtmlPostfix=\"<span style='color:white;'> *</span>\"") : " "; |
|
605 |
} |
|
606 |
|
|
607 |
/** |
a6a76f
|
608 |
* 动态根据表描述字段的如下规律 |
F |
609 |
* 表格|显示|表格|描述|表格|类型|表格|长度 |
|
610 |
* 外表|表号|外表|类型|外表|清空关联 |
|
611 |
* 生成跨行跨列的表头格式生成 |
|
612 |
* 首先是查找最大跨行数,由最大跨行数得到需要输出多少行 |
|
613 |
* 再一行行的输出每列信息,在每列输出时需要根据表描述字段决定跨行跨列设置 |
|
614 |
* 全局控制都是根据分割表描述字段所得的数组来处理 |
|
615 |
* |
|
616 |
* @return String 表头html代码 |
|
617 |
**/ |
|
618 |
private void createCoumtHeader(TreeGridDTO dto) throws DataAccessException { //生成自定义表头 |
|
619 |
StringBuilder gridHeader = new StringBuilder();//表头html |
|
620 |
int num = getMaxColumnNum(dto);//返回需要分行,分列的值 |
|
621 |
this.fillColumnNumTree(num, dto); |
|
622 |
String temID = "";//保存之前字段描述值,以便当下一次与这个值相等时可以跳过不输出 |
|
623 |
String temPa = "";//temID的上级值,区分{外表|接收数据|自身字段,外表|条件|自身字段 }情况 |
|
624 |
String top = ""; |
|
625 |
String[] str = dto.tempStr.split("'");//填充后的列格式 |
|
626 |
for (int i = 0; i < num; i++) {//循环分行取值 |
|
627 |
int k = 0; |
|
628 |
//dto.gfields.first(); |
|
629 |
if (dto.gantt && !dto.isList && i == 0) |
|
630 |
gridHeader.append("<Header id='id' "); |
|
631 |
else |
|
632 |
gridHeader.append("<Header " + ((i == num - 1) ? "id='Header' " : " Spanned='1' ")); |
|
633 |
//do{ |
|
634 |
for (int y = 0; y < dto.gfields.size(); y++) { |
|
635 |
Map<String, Object> map = dto.gfields.get(y); |
|
636 |
if (GridUtils.prossRowSetDataType_Boolean(map, "ShowOnGrid")) {//设置为隐藏 |
|
637 |
String dec = GridUtils.prossRowSetDataType_String(map, "gridcaption");//表格描述 |
|
638 |
String fieldname = GridUtils.prossRowSetDataType_String(map, "fieldname");//字段描述 |
493df4
|
639 |
boolean keyInput = GridUtils.prossRowSetDataType_Boolean(map, "KeyInput");//是否必填 |
176de8
|
640 |
String id = (map.get("fieldid") + "").trim();//字段名,去掉空格 |
a6a76f
|
641 |
if (id.equalsIgnoreCase("id") && (!dto.gantt)) id = "_ycid_";//避免id与格线中的id冲突而增加,页面返回时需要转换 |
F |
642 |
String temp = (dec == null || "".equalsIgnoreCase(dec)) ? fieldname : dec;//如果没定义表描述就取字段名称作为表格显示字段 |
|
643 |
if (temp == null || temp == "" || temp.length() == 0) temp = id; |
|
644 |
String[] capf = temp.split("\\|");//分割字符串,外表|接收数据|外表字段 去掉 .replaceAll("'", "\\\\'"),因为用""括进来了,为的就是动态标题传参数有单引号的情况 |
|
645 |
String[] cap = str[k].split("\\|"); |
|
646 |
if (cap[i].trim().indexOf("!") == 0) {//动态标题,替换参数 |
|
647 |
if (k > 0 && dto.setInfo_dy.length() > 1 && cap[i].indexOf("@") > -1) dto.setInfo_dy += ","; |
|
648 |
this.prossIntoSessionForFilter_dy(cap[i], dto); |
|
649 |
|
|
650 |
} |
|
651 |
k++; |
|
652 |
boolean flag = false;//标记是否需要隐藏 |
|
653 |
String show = ""; |
|
654 |
String hidden = ""; |
|
655 |
int colNum = 0; |
|
656 |
if (i > 0 && cap.length > 1 && i < cap.length) { |
|
657 |
if (!cap[i].equalsIgnoreCase("¥") && temID.equalsIgnoreCase(cap[i]) && temPa.equalsIgnoreCase(cap[i - 1]) && top.equalsIgnoreCase(cap[0])) { |
|
658 |
continue;//只输出一个,表格|显示,表格|描述,表格|类型,表格|长度 |
|
659 |
} |
|
660 |
} |
|
661 |
try { |
|
662 |
colNum = this.getColumnNum(cap[i], dto.tempStr, i, i == 0 ? cap[0] : cap[i - 1], k, dto);//取得跨列值 |
|
663 |
if (colNum == 0) flag = true;//表示存在¥,则不需要显示 |
|
664 |
|
493df4
|
665 |
show = id.toLowerCase() + "=\"" + this.getFormCap(cap[i]) + "\" " + getDetailGridTitle(dto, keyInput, id) + id.toLowerCase() + "Align='Center' " + (colNum > 1 ? (" " + id.toLowerCase() + "Span='" + colNum + "' ") : ""); |
a6a76f
|
666 |
hidden = id.toLowerCase() + "Visible='-1' "; |
F |
667 |
if (flag) |
|
668 |
gridHeader.append(hidden); |
|
669 |
else |
|
670 |
gridHeader.append(show); |
|
671 |
} catch (Exception e) { |
|
672 |
throw new ApplicationException(dto.formID + "-字段设置有问题-" + id); |
|
673 |
} |
|
674 |
flag = false; |
|
675 |
top = capf[0];//取得第一个字段值 |
|
676 |
if (i < capf.length) temID = capf[i]; |
|
677 |
if (i > 0 && i < capf.length) temPa = capf[i - 1];//得到上级值 |
|
678 |
} |
|
679 |
} |
|
680 |
//while(dto.gfields.next()); |
|
681 |
if (!dto.isList && dto.gantt) gridHeader.append(" G='Gantt'"); |
|
682 |
gridHeader.append(" />\n"); |
|
683 |
} |
|
684 |
try { |
|
685 |
if (gridHeader.length() > 0) dto.header = gridHeader.substring(0, gridHeader.length() - 1); |
|
686 |
|
|
687 |
} catch (Exception e) { |
|
688 |
throw new ApplicationException("生成格线表头出错,因为格线所有栏位都设为不显示"); |
|
689 |
} finally { |
|
690 |
gridHeader = null; |
|
691 |
dto.gfields = null; |
|
692 |
} |
|
693 |
} |
|
694 |
|
|
695 |
; |
|
696 |
|
|
697 |
/** |
|
698 |
* 根据当前值是否有特定标记@day,@moth,@year,等。以替换成真实值 |
|
699 |
*/ |
|
700 |
private synchronized String getFormCap(String id) { |
|
701 |
String s = id.toLowerCase().trim(); |
|
702 |
String[] day = null; |
|
703 |
if (s.indexOf("@day") > -1) {//日 |
|
704 |
|
|
705 |
if (s.indexOf("+") > -1) { |
|
706 |
day = s.split("\\+"); |
|
707 |
} else if (s.indexOf("-") > -1) {//-号 |
|
708 |
day = s.split("\\-"); |
|
709 |
day[1] = "-" + day[1]; |
|
710 |
} else { |
|
711 |
day = s.split("\\+"); |
|
712 |
} |
|
713 |
if (day.length > 1) { |
|
714 |
return "#GT.getDay(" + Integer.parseInt(day[1]) + ")"; |
|
715 |
} else { |
|
716 |
return "#GT.getDay(0)"; |
|
717 |
} |
|
718 |
|
|
719 |
} else if (id.toLowerCase().indexOf("@month") > -1) {//月 |
|
720 |
if (s.indexOf("+") > -1) { |
|
721 |
day = s.split("\\+"); |
|
722 |
} else if (s.indexOf("-") > -1) {//-号 |
|
723 |
day = s.split("\\-"); |
|
724 |
day[1] = "-" + day[1]; |
|
725 |
} else { |
|
726 |
day = s.split("\\+"); |
|
727 |
} |
|
728 |
if (day.length > 1) { |
|
729 |
return "#GT.getMonth(" + Integer.parseInt(day[1]) + ")"; |
|
730 |
} else { |
|
731 |
return "#GT.getMonth(0)"; |
|
732 |
} |
|
733 |
} else if (id.toLowerCase().indexOf("@quarter") > -1) {//季 |
|
734 |
return id; |
|
735 |
} else if (id.toLowerCase().indexOf("@year") > -1) {//年 |
|
736 |
|
|
737 |
if (s.indexOf("+") > -1) { |
|
738 |
day = s.split("\\+"); |
|
739 |
} else if (s.indexOf("-") > -1) {//-号 |
|
740 |
day = s.split("\\-"); |
|
741 |
day[1] = "-" + day[1]; |
|
742 |
} else { |
|
743 |
day = s.split("\\+"); |
|
744 |
} |
|
745 |
if (day.length > 1) { |
|
746 |
return "#GT.getYear(" + Integer.parseInt(day[1]) + ")"; |
|
747 |
} else { |
|
748 |
return "#GT.getYear(0)"; |
|
749 |
} |
|
750 |
} else { |
|
751 |
return id.replaceAll("<", "<").replaceAll(">", ">"); |
|
752 |
} |
|
753 |
|
|
754 |
} |
|
755 |
|
|
756 |
/** |
|
757 |
* 取得自动编号的类型 |
|
758 |
*/ |
|
759 |
private synchronized List getAutoCodeType(int formid, String dbid) { |
|
760 |
try { |
|
761 |
SpObserver.setDBtoInstance("_" + dbid); |
|
762 |
String sql = "select precodetype,codelength,preFixcode from gform where formid=?"; |
|
763 |
return gridService.getJdbcTemplate().queryForList(sql, new Object[]{formid}); |
|
764 |
} finally { |
|
765 |
SpObserver.setDBtoInstance(); |
|
766 |
} |
|
767 |
} |
|
768 |
|
|
769 |
private List getCodeInfo(int formid, String dbid) { |
|
770 |
try { |
|
771 |
SpObserver.setDBtoInstance("_" + dbid); |
|
772 |
String sql = "select g.formid,g.codelength,g.preFixcode,g.precodetype,c.Formtype,c.Curcode,c.Fieldid from gform g,_sysautocode c where g.formid=c.formid and g.formid=?"; |
|
773 |
return gridService.getJdbcTemplate().queryForList(sql, new Object[]{formid}); |
|
774 |
} finally { |
|
775 |
SpObserver.setDBtoInstance(); |
|
776 |
} |
|
777 |
} |
|
778 |
|
|
779 |
/** |
|
780 |
* 查找字符串中是否存在指定的内容 |
|
781 |
* 返回需要替换的字段名 |
|
782 |
*/ |
|
783 |
private synchronized String getString(String str) { |
|
784 |
Pattern p = Pattern.compile("@\\w+"); |
|
785 |
String s = ""; |
|
786 |
java.util.regex.Matcher propsMatcher = p.matcher(str != null ? str.toLowerCase() : ""); |
|
787 |
while (propsMatcher.find()) { |
|
788 |
s += propsMatcher.group() + ";"; |
|
789 |
} |
|
790 |
return s; |
|
791 |
} |
|
792 |
|
|
793 |
/** |
|
794 |
* 填充参数值列表,下拉列表控件时,需要填充数据,用作2类型控件 |
|
795 |
* |
|
796 |
* @param type 控件类型 |
|
797 |
* @param ft --参数号 |
|
798 |
* @return |
|
799 |
*/ |
|
800 |
private StringBuilder fillFT(int type, int ft, String sql, TreeGridDTO dto) { |
|
801 |
StringBuilder sb = new StringBuilder(); |
|
802 |
SqlRowSet rst = null; |
|
803 |
try { |
|
804 |
SpObserver.setDBtoInstance("_" + dto.dbid); |
|
805 |
rst = gridService.getFTData(ft); |
|
806 |
} finally { |
|
807 |
SpObserver.setDBtoInstance(); |
|
808 |
} |
|
809 |
sb.append(""); |
|
810 |
boolean flag = false; |
a58a39
|
811 |
if (type == 31 || type == 2 || type == 35 || type == 43 || type == 30 || type == 32|| type == 46) {//2,类型,31类型下拉列表控件时,为三种情况,一个是静态sql,一个是动态sql,需要用页面的值替换再用ajax提交返回,另一个就是表号生成 |
a6a76f
|
812 |
StringBuilder id = new StringBuilder(); |
F |
813 |
StringBuilder value = new StringBuilder(); |
|
814 |
if (type != 30 && type != 32) { |
|
815 |
id.append("| "); |
|
816 |
value.append("| "); |
|
817 |
} |
|
818 |
try { |
|
819 |
if (sql != null && sql != "" && sql.length() > 0) {//有sql参数 |
|
820 |
if (sql.indexOf("&") > -1 || sql.indexOf("@") > -1) {//表示需要在页面替换参数,取页面值,ajax提交填充 |
|
821 |
this.prossIntoSession(getString(sql), dto); |
|
822 |
sb.append("dySql=\"" + sql + "\""); |
|
823 |
} else { |
|
824 |
if (type == 2) { |
|
825 |
SqlRowSet set = null; |
|
826 |
try { |
|
827 |
SpObserver.setDBtoInstance("_" + dto.dbid); |
|
828 |
set = gridService.getJdbcTemplate().queryForRowSet(sql); |
|
829 |
} finally { |
|
830 |
SpObserver.setDBtoInstance(); |
|
831 |
} |
|
832 |
if (!set.wasNull()) { |
|
833 |
while (set.next()) { |
|
834 |
id.append("|").append(this.replaceBlank(set.getString(1))); |
|
835 |
value.append("|").append(this.replaceBlank(set.getString(2))); |
|
836 |
} |
|
837 |
set = null; |
|
838 |
} |
|
839 |
} else {//31,35 |
|
840 |
sb.append("dySql=\"" + sql + "\""); |
|
841 |
} |
|
842 |
} |
|
843 |
|
|
844 |
|
|
845 |
flag = true; |
|
846 |
} |
|
847 |
if (!flag) { |
|
848 |
if (!rst.wasNull()) { |
|
849 |
while (rst.next()) { |
|
850 |
id.append("|").append(this.replaceBlank(rst.getString("interValue"))); |
a58a39
|
851 |
if(type==46){ |
F |
852 |
value.append("|").append("<div style="background:").append(rst.getString("interValue")).append("">").append(" </div>"); |
|
853 |
}else { |
|
854 |
value.append("|").append(this.replaceBlank(rst.getString("dictvalue"))); |
|
855 |
} |
a6a76f
|
856 |
} |
F |
857 |
} |
|
858 |
} |
|
859 |
|
|
860 |
} catch (Exception e) { |
493df4
|
861 |
throw new ApplicationException(e.getMessage()); |
a6a76f
|
862 |
} finally { |
F |
863 |
rst = null; |
|
864 |
} |
|
865 |
if (type == 31) |
|
866 |
if (ft != 0)//有表号才会有新增选项 |
|
867 |
sb.append(" EnumKeys='").append(id.toString() + "|-add-").append("' Enum='").append(value.toString() + "|<<新增>>").append("' "); |
|
868 |
else//当没表号表示不需要新增选项 |
|
869 |
sb.append(" EnumKeys='").append(id.toString()).append("' Enum='").append(value.toString()).append("' "); |
|
870 |
else { |
|
871 |
if (type != 35) { |
|
872 |
sb.append(" EnumKeys='").append(id.toString()).append("' Enum='").append(value.toString()).append("' "); |
|
873 |
} |
|
874 |
} |
|
875 |
if (type == 35) {//可编辑列表,值与键需要一样 |
493df4
|
876 |
sb.append(" Button='Defaults' Defaults='").append(("|".equals(value.toString().trim()) ? "" : value.toString())).append("' "); |
a6a76f
|
877 |
} |
F |
878 |
if (type == 43 || type == 30) { |
|
879 |
sb.append(" Range='1' "); |
|
880 |
} |
|
881 |
|
|
882 |
id = null; |
|
883 |
value = null; |
|
884 |
} |
|
885 |
return sb; |
|
886 |
} |
|
887 |
|
|
888 |
private synchronized String setJsName(TreeGridDTO dto) { |
|
889 |
return "grid_" + dto.formID + "_" + dto.winType + ".xml"; |
|
890 |
} |
|
891 |
|
|
892 |
/** |
|
893 |
* 生成页面时需要检查的关键字段名,避免生成格线有问题 |
|
894 |
*/ |
|
895 |
private synchronized boolean checkKey(String id) { |
|
896 |
String[] keys = {"_ycid_", "added", "Deleted", "Changed", "Moved", "Panel", "Prev", "Next", "id"}; |
|
897 |
for (String k : keys) { |
|
898 |
if (k.equalsIgnoreCase(id)) { |
|
899 |
return true; |
|
900 |
} |
|
901 |
} |
|
902 |
return false; |
|
903 |
} |
|
904 |
|
|
905 |
private String getFileter(TreeGridDTO dto) { |
|
906 |
StringBuffer temp = new StringBuffer(); |
|
907 |
temp.append(""); |
|
908 |
try { |
|
909 |
// dto.gfields.first(); |
|
910 |
// do{ |
|
911 |
for (int y = 0; y < dto.gfields.size(); y++) { |
|
912 |
Map<String, Object> map = dto.gfields.get(y); |
|
913 |
String top = this.replaceBlank(GridUtils.prossRowSetDataType_String(map, "SeekGroupID") + "".toLowerCase()); |
|
914 |
String sf = this.replaceBlank(GridUtils.prossRowSetDataType_String(map, "HyperlinkSPremissField") + "".toLowerCase()); |
|
915 |
String ft = this.replaceBlank(GridUtils.prossRowSetDataType_String(map, "HyperlinkFT") + "".toLowerCase()); |
|
916 |
String initValue = this.replaceBlank(GridUtils.prossRowSetDataType_String(map, "initValue") + ""); |
|
917 |
|
|
918 |
if (top.length() > 0) |
|
919 |
temp.append(top).append(";"); |
|
920 |
if (sf.length() > 0) |
|
921 |
temp.append(sf).append(";"); |
|
922 |
if (ft.length() > 0) |
|
923 |
temp.append(ft).append(";"); |
|
924 |
if (initValue.length() > 0) |
|
925 |
temp.append(initValue).append(";"); |
|
926 |
} |
|
927 |
//while(dto.gfields.next()); |
|
928 |
} catch (ArrayIndexOutOfBoundsException e) { |
|
929 |
throw new ApplicationException("读取不到" + dto.formID + "在9802里面的字段信息,请检查9802是否已做了相关设置"); |
|
930 |
} |
|
931 |
return temp.toString(); |
|
932 |
} |
|
933 |
|
|
934 |
/** |
|
935 |
* sugg--列表显示的字段 |
|
936 |
* backFilds-取外表字段,以便选择后返回哪些值。 |
|
937 |
* tp ---自表字段,返回给哪些字段 |
|
938 |
*/ |
|
939 |
public String getSuggestFilds(String fromid, int type, String sugg, String backFilds, String to, String form, boolean one, int rod, String dbid, String sf, String df) {//取得需要的字段名称 |
|
940 |
int flg = this.setGetPrivaryTable(type); |
5f1f90
|
941 |
// StringBuffer sb = new StringBuffer(); //舍弃这属性 xin 2021-3-23 14:42:37 |
a6a76f
|
942 |
StringBuffer exps = new StringBuffer(); |
F |
943 |
String sql = " select FieldID,fieldname,GridCaption,ShowOnGrid,showFieldValueExpression from gfield where formid=? and HeadFlag=? order by statisid asc"; |
|
944 |
List<Map<String, Object>> list = null; |
|
945 |
try { |
|
946 |
SpObserver.setDBtoInstance("_" + dbid); |
|
947 |
list = gridService.getSimpleJdbcTemplate().queryForList(sql, new Object[]{fromid, flg}); |
|
948 |
} finally { |
|
949 |
SpObserver.setDBtoInstance(); |
|
950 |
} |
|
951 |
String[] tem = sugg.replaceAll(",", ";").split(";"); |
|
952 |
int i = 0; |
|
953 |
String str = "";//保存哪些字段是隐藏的 |
|
954 |
|
5f1f90
|
955 |
//下面添加的titleLis属性用来处理层的标题 xin 2021-3-23 14:39:52 |
493df4
|
956 |
List<Map<String, Object>> titleLis = new ArrayList<>(); |
a6a76f
|
957 |
for (String s : tem) { |
F |
958 |
for (Map<String, Object> map : list) { |
b9e8fc
|
959 |
if (s.trim().equalsIgnoreCase((String) map.get("FieldID"))) { |
493df4
|
960 |
Map<String, Object> titleMap = new HashMap<>(); |
5f1f90
|
961 |
titleMap.put("field", s.toLowerCase()); |
X |
962 |
titleMap.put("title", map.get("fieldname") == null |
|
963 |
? (String) map.get("GridCaption") : (String) map.get("fieldname")); |
b2d631
|
964 |
// titleMap.put("width", 100); |
5f1f90
|
965 |
titleMap.put("align", "center"); |
X |
966 |
if ((Integer) (map.get("ShowOnGrid") == null ? 0 : map.get("ShowOnGrid")) == 1) { |
|
967 |
// sb.append("<th width=\"\">").append(map.get("fieldname") == null ? (String) map.get("GridCaption") : (String) map.get("fieldname")).append("</th>"); |
493df4
|
968 |
} else { |
5f1f90
|
969 |
if (str == "") { |
a6a76f
|
970 |
str += map.get("FieldID"); |
493df4
|
971 |
} else { |
a6a76f
|
972 |
str += ";" + map.get("FieldID"); |
5f1f90
|
973 |
} |
X |
974 |
// sb.append("<th width=\"\" style=\"display:none;\">").append(map.get("fieldname") == null ? (String) map.get("GridCaption") : (String) map.get("fieldname")).append("</th>"); |
|
975 |
titleMap.put("hide", true);//隐藏字段 |
a6a76f
|
976 |
} |
5f1f90
|
977 |
titleLis.add(titleMap);//获取标题信息 |
a6a76f
|
978 |
//取权限表达式输出到页面 |
F |
979 |
String strexp = GridUtils.prossRowSetDataType_String(map, "showFieldValueExpression"); |
|
980 |
if (!"".equalsIgnoreCase(strexp)) { |
|
981 |
|
|
982 |
if (exps.length() == 0) |
|
983 |
exps.append(s + "|").append(strexp).append(";"); |
|
984 |
else |
|
985 |
exps.append(";").append(s + "|").append(strexp); |
|
986 |
} |
|
987 |
|
|
988 |
break; |
|
989 |
} |
|
990 |
} |
|
991 |
|
|
992 |
i++; |
|
993 |
} |
|
994 |
String strexps = ""; |
|
995 |
try { |
|
996 |
strexps = new String(YCBase64.encode(exps.toString().getBytes())); |
|
997 |
} catch (Exception e) { |
|
998 |
// TODO Auto-generated catch block |
|
999 |
e.printStackTrace(); |
|
1000 |
} |
|
1001 |
String json = "{\"data\":\";" + str + ";\",\"backfilds\":\"" + backFilds + "\",\"sf\":\"" + sf + "\",\"df\":\"" + df + "\",\"to\":\"" + to + "\",\"form\":\"" + form + "\",\"exp\":\"" + strexps + "\",\"one\":\"" + (one ? 1 : 0) + "\"}"; |
5f1f90
|
1002 |
// 注释这个返回值,重新返回一个 xin 2021-3-23 14:32:35 |
X |
1003 |
// return "<div id=\"T_" + fromid + "_10" + rod + "div\" style=\"z-index:9999;display:none;position:absolute;height:300px;overflow:auto;\"><table data='" + json + "' id=\"T_" + fromid + "_10" + rod + "CDiv\" class=\"hovertable\"><tr>" + |
|
1004 |
// sb.toString() + "</tr></table></div>\t\n"; |
|
1005 |
return "<div id=\"T_" + fromid + "_10" + rod + "div\" style=\"z-index:9999;display:none;position:absolute;height:320px;overflow:auto;\">" + |
493df4
|
1006 |
"<table data-datas=\"" + json.replaceAll("\"", "'") + "\" data-title=\"" + GridUtils.toJson(titleLis).replaceAll("\"", "'") + "\" " + |
5f1f90
|
1007 |
"id=\"T_" + fromid + "_10" + rod + "CDiv\" lay-filter=\"T_" + fromid + "_10" + rod + "CDiv\" class=\"hovertable\">" + |
X |
1008 |
"</table></div>\t\n"; |
a6a76f
|
1009 |
} |
F |
1010 |
|
|
1011 |
/** |
|
1012 |
* 处理9802里面设置了取值的字段但又不需要显示的所有字段 |
|
1013 |
* 针对超链接的参数进行处理 |
|
1014 |
*/ |
|
1015 |
private Map<String, String> prossDisable(TreeGridDTO dto) { |
|
1016 |
Map<String, String> map = new HashMap<String, String>(); |
|
1017 |
//dto.gfields.first(); |
|
1018 |
//do{ |
|
1019 |
for (int y = 0; y < dto.gfields.size(); y++) { |
|
1020 |
Map<String, Object> map1 = dto.gfields.get(y); |
|
1021 |
String ft = GridUtils.prossRowSetDataType_String(map1, "HyperlinkFT"); |
|
1022 |
String type = GridUtils.prossRowSetDataType_String(map1, "HyperlinkFTFormType"); |
|
1023 |
String field = GridUtils.prossRowSetDataType_String(map1, "HyperlinkSPremissField"); |
|
1024 |
String filter = GridUtils.prossRowSetDataType_String(map1, "HyperlinkEFilter"); |
|
1025 |
pullValue(map, ft); |
|
1026 |
pullValue(map, type); |
|
1027 |
pullValue(map, field); |
|
1028 |
pullValue(map, filter); |
|
1029 |
|
|
1030 |
} |
|
1031 |
//while(dto.gfields.next()); |
|
1032 |
return map; |
|
1033 |
|
|
1034 |
} |
|
1035 |
|
|
1036 |
private void pullValue(Map<String, String> m, String ft) { |
|
1037 |
if (ft != null && !"".equalsIgnoreCase(ft)) { |
|
1038 |
ft = ft.replaceAll(",", ";"); |
|
1039 |
String[] str = ft.split(";"); |
|
1040 |
for (String s : str) { |
|
1041 |
m.put(s, "1"); |
|
1042 |
} |
|
1043 |
} |
|
1044 |
} |
|
1045 |
|
|
1046 |
/** |
|
1047 |
* grid定义数据集及列定义 |
|
1048 |
*/ |
|
1049 |
private void gridConfig(String root, TreeGridDTO dto) throws DataAccessException { |
|
1050 |
|
|
1051 |
StringBuilder left = new StringBuilder();//leftcols定义 |
|
1052 |
StringBuilder cols = new StringBuilder();//列定义json |
|
1053 |
StringBuilder formn = new StringBuilder();//自定义公式 |
|
1054 |
StringBuilder values = new StringBuilder();//初始值 |
|
1055 |
StringBuilder sumfu = new StringBuilder();//统计公式 |
|
1056 |
StringBuilder valExp = new StringBuilder();//权限控制值 |
|
1057 |
StringBuilder cssExp = new StringBuilder();//css控制值 |
|
1058 |
StringBuilder tipsExp = new StringBuilder();//提示信息 |
|
1059 |
StringBuilder msgInfo = new StringBuilder();//错误提示信息 |
|
1060 |
StringBuilder exportInfo = new StringBuilder();//保存导出字段 |
|
1061 |
StringBuilder rowCopys = new StringBuilder();//保存复单时排除字段,读9802 |
|
1062 |
//StringBuilder exportTitle=new StringBuilder();//保存导出文件名称,在生成下载的excel文件时候用到 |
|
1063 |
|
|
1064 |
//List<Integer> sugId=new ArrayList<Integer>();//保存生成div的功能号,以便排队生成相同的div |
|
1065 |
dto.filter = new StringBuilder();//过滤设置,读9802 |
|
1066 |
dto.filter.append("<Filter id=\"Filter1\" Height=\"22\" "); |
|
1067 |
// |
|
1068 |
exportInfo.append(dto.formname.replaceAll("-", "_")).append("-");//取得功能号名称 |
|
1069 |
StringBuilder SumFieldInfo = new StringBuilder(); |
|
1070 |
int rod = 0;//42类型生成的索引值,由于分布式部署的原因,需要确保生成的索引值都是一样才能在页面加载时,不管加载到那一个节点也是正确的 |
|
1071 |
try { |
|
1072 |
int index = 0;//标记当前位置 |
|
1073 |
String firstID = "";//第一个字段名称 |
|
1074 |
SqlRowSetMetaData metaData = null; |
|
1075 |
if (dto.winType != 18 && dto.winType != 38 && dto.winType != 19) { |
|
1076 |
try { |
|
1077 |
SpObserver.setDBtoInstance("_" + dto.dbid); |
|
1078 |
metaData = gridService.getMetaData(dto.table.split("\\|")[0]);//元数据 |
|
1079 |
} finally { |
|
1080 |
SpObserver.setDBtoInstance(); |
|
1081 |
} |
|
1082 |
} |
|
1083 |
List typeInfo = null; |
|
1084 |
try { |
|
1085 |
SpObserver.setDBtoInstance("_" + dto.dbid); |
|
1086 |
typeInfo = gridService.getColumnsTypeInfo(dto.table.split("\\|")[0]); |
|
1087 |
} finally { |
|
1088 |
SpObserver.setDBtoInstance(); |
|
1089 |
} |
|
1090 |
Map<String, String> len = new HashMap<String, String>(); |
|
1091 |
if (!dto.isList) {//只有是有明细表才需要有长度限制 |
|
1092 |
String lengthInfo = null; |
|
1093 |
try { |
|
1094 |
SpObserver.setDBtoInstance("_" + dto.dbid); |
|
1095 |
lengthInfo = gridService.getTypeLengthInfo(dto.table.split("\\|")[0]); |
|
1096 |
} finally { |
|
1097 |
SpObserver.setDBtoInstance(); |
|
1098 |
} |
|
1099 |
if (lengthInfo != null) { |
|
1100 |
String[] tem = lengthInfo.split(","); |
|
1101 |
for (String s : tem) { |
|
1102 |
String[] ss = s.split("-"); |
|
1103 |
if (ss.length < 3) |
|
1104 |
len.put(ss[0].toLowerCase(), ss[1]); |
|
1105 |
else |
|
1106 |
len.put(ss[0].toLowerCase(), ss[2]); |
|
1107 |
} |
|
1108 |
} |
|
1109 |
} |
|
1110 |
//String fileter=this.getFileter();//保存需要隐藏输出的字段,只取自身字段 |
|
1111 |
boolean iscopy = false;//标记当前9802是否有复制时排除字段,为了兼用不存在出错的情况 |
|
1112 |
boolean isref = false;//标记当前9802是否有自动刷新和加载到页面的字段,为了兼用不存在出错的情况 |
|
1113 |
int fumIndex = 0;//标记导出时候字段位置 |
d89677
|
1114 |
int tabColIndex = 0;//标记导出字段在汇总列的位置 |
a6a76f
|
1115 |
Map<String, String> vMap = this.prossDisable(dto); |
F |
1116 |
//dto.gfields.first(); |
|
1117 |
// do{ |
|
1118 |
for (int i = 0; i < dto.gfields.size(); i++) { |
|
1119 |
boolean fileterID = false;//标记为需要隐藏输出 |
|
1120 |
Map<String, Object> map = dto.gfields.get(i); |
|
1121 |
// //----处理动态sql |
|
1122 |
// Map<String,String> map9801= SqlFormatUtils.createSQLFormat(map,9801); |
|
1123 |
// Map<String,String> map9802= SqlFormatUtils.createSQLFormat(map,9802); |
|
1124 |
// //----- |
176de8
|
1125 |
String id = org.apache.commons.lang3.StringUtils.trim(GridUtils.prossRowSetDataType_String(map, "fieldid"));//字段名 |
a6a76f
|
1126 |
String dec = GridUtils.prossRowSetDataType_String(map, "gridcaption");//表格描述 |
F |
1127 |
String fieldname = GridUtils.prossRowSetDataType_String(map, "fieldname");//字段描述 |
|
1128 |
String temp = (dec == null || "".equalsIgnoreCase(dec)) ? fieldname : dec;//如果没定义表描述就取字段名称作为表格显示字段 |
|
1129 |
if (this.checkKey(id.toLowerCase())) { |
|
1130 |
msgInfo.append("警告:格线所用字段不能使用[" + id + "]关键字!"); |
|
1131 |
} |
|
1132 |
if (id.equalsIgnoreCase("id") && (!dto.gantt)) id = "_ycid_";//避免id与格线中的id冲突而增加,页面返回时需要转换 |
|
1133 |
if (temp == null || "".equalsIgnoreCase(temp) || temp.length() == 0) temp = id; |
|
1134 |
if (firstID == "") firstID = id; |
|
1135 |
int type = GridUtils.prossRowSetDataType_Int(map, "gridcontroltype");//表格单元格控件类型 |
|
1136 |
int ft = GridUtils.prossRowSetDataType_Int(map, "ft");//外表|表号 |
|
1137 |
int wiType = GridUtils.prossRowSetDataType_Int(map, "FTFormType");//外表|窗体类型 |
|
1138 |
int width = GridUtils.prossRowSetDataType_Int(map, "GridLength");//单元格宽度 |
|
1139 |
if (width == 0) { |
|
1140 |
width = 100; |
|
1141 |
} else { |
|
1142 |
width *= 10; |
|
1143 |
} |
|
1144 |
if (width < 100 && width > 50) width = 100; |
|
1145 |
if (width < 50) width = 50; |
|
1146 |
int calcuField = GridUtils.prossRowSetDataType_Int(map, "calcuField");//自定义公式|1,表示是否当前字段变化后需要重新计算包括有这个字段的所有公式内容 |
|
1147 |
String fua = GridUtils.prossRowSetDataType_String(map, "formula");//自定义公式 |
|
1148 |
if (fua != null && !"".equalsIgnoreCase(fua)) { |
|
1149 |
this.prossIntoSessionForFilter(fua, dto); |
|
1150 |
} |
|
1151 |
String value = GridUtils.prossRowSetDataType_String(map, "initValue");//初始值 |
|
1152 |
String emptyrefdata = GridUtils.prossRowSetDataType_String(map, "emptyrefdata");//清空关联 |
|
1153 |
int SumField = GridUtils.prossRowSetDataType_Int(map, "SumField");//统计方式 |
|
1154 |
String funclinkname = GridUtils.prossRowSetDataType_String(map, "funclinkname");//自定义统计公式 |
|
1155 |
boolean activefuns = GridUtils.prossRowSetDataType_Boolean(map, "activefuns");//公式是否生效 |
|
1156 |
boolean ShowOnGrid = GridUtils.prossRowSetDataType_Boolean(map, "ShowOnGrid");//是否显示 |
|
1157 |
boolean KeyInput = GridUtils.prossRowSetDataType_Boolean(map, "KeyInput");//是否必录 |
|
1158 |
String passwordchar = GridUtils.prossRowSetDataType_String(map, "passwordchar");//是否为密码字符 |
|
1159 |
String displayformat = GridUtils.prossRowSetDataType_String(map, "displayformat");//数字格式 |
|
1160 |
String ef = GridUtils.prossRowSetDataType_String(map, "eFilter"); |
|
1161 |
boolean readOnly = GridUtils.prossRowSetDataType_Boolean(map, "ReadOnly");//只读 |
|
1162 |
boolean dataLink = GridUtils.prossRowSetDataType_Boolean(map, "DataLink");//感应字段 |
|
1163 |
boolean uppercase = GridUtils.prossRowSetDataType_Boolean(map, "uppercase");//大写 |
|
1164 |
String ValueExp = GridUtils.prossRowSetDataType_String(map, "showFieldValueExpression");//权限控制是否显示该值 |
|
1165 |
String editStatus = GridUtils.prossRowSetDataType_String(map, "editStatus");//权限控制是否显示该值 |
|
1166 |
boolean oneRec = GridUtils.prossRowSetDataType_Boolean(map, "return_one_record");//是否返回到单记录 |
|
1167 |
boolean onlyOne = GridUtils.prossRowSetDataType_Boolean(map, "onlyOne");//只返回单条记录 |
|
1168 |
String sqlScript = this.replaceBlank(GridUtils.prossRowSetDataType_String(map, "SqlScript"));// 控件sql |
|
1169 |
String sqlWhere = this.replaceBlank(GridUtils.prossRowSetDataType_String(map, "sqlWhere"));// 下拉控件(31),编辑状态时需要附加这个条件 |
|
1170 |
this.prossIntoSessionForFilter_dy(sqlWhere, dto); |
|
1171 |
boolean rowspan = GridUtils.prossRowSetDataType_Boolean(map, "rowSpan");//是否合并行 |
|
1172 |
boolean isExport = GridUtils.prossRowSetDataType_Boolean(map, "isExport");//是否导出 |
|
1173 |
boolean statisFlag = GridUtils.prossRowSetDataType_Boolean(map, "StatisFlag");//是否可查询 |
|
1174 |
boolean cpltrow = GridUtils.prossRowSetDataType_Boolean(map, "copyfromlastrow");//插入时从上行复制 |
|
1175 |
String cs = GridUtils.prossRowSetDataType_String(map, "stylecss");//css样式 |
|
1176 |
String tips = GridUtils.prossRowSetDataType_String(map, "TipsExpression"); |
|
1177 |
valExp.append((ValueExp != null && !"".equalsIgnoreCase(ValueExp)) ? id + "|" + this.replaceBlank(ValueExp) + ";" : ""); |
|
1178 |
cssExp.append((cs != null && !"".equalsIgnoreCase(cs)) ? id + "|" + this.replaceBlank(cs.replaceAll(";", "~")) + ";" : ""); |
|
1179 |
tipsExp.append((tips != null && !"".equalsIgnoreCase(tips)) ? id + "|" + this.replaceBlank(tips.replaceAll(";", "~")) + ";" : ""); |
|
1180 |
String cellAlign = GridUtils.prossRowSetDataType_String(map, "cellAlign");//单元格对齐属性 |
|
1181 |
//int expTitle=GridUtils.prossRowSetDataType_Int(map,"exportTitle");//下载文件名称 |
|
1182 |
String dataType = ""; |
|
1183 |
int dIndex = 1; |
|
1184 |
if (metaData != null) { |
|
1185 |
dIndex = this.getType(metaData, id);//取得每个字段的数据类型,1数字 ,3字符,4日期 |
|
1186 |
switch (dIndex) { |
|
1187 |
case 1: |
|
1188 |
dataType = "n";//数值 |
|
1189 |
break; |
|
1190 |
case 3: |
|
1191 |
dataType = "s";//字符串 |
|
1192 |
break; |
|
1193 |
case 4: |
|
1194 |
dataType = "d";//时间 |
|
1195 |
break; |
|
1196 |
} |
|
1197 |
} |
|
1198 |
|
|
1199 |
int isAudit = 0; |
|
1200 |
//if(ShowOnGrid&&statisFlag)//可显示且可查询 |
|
1201 |
setFilter(id.toLowerCase(), type, dto.filter, dIndex); |
|
1202 |
try { |
|
1203 |
if (!iscopy) { |
|
1204 |
boolean isCopyExclude = GridUtils.prossRowSetDataType_Boolean(map, "isCopyExclude");//复单时是否排除 |
|
1205 |
if (isCopyExclude) |
|
1206 |
rowCopys.append(id.toLowerCase()).append(";"); |
|
1207 |
} |
|
1208 |
//是否审计,1: |
|
1209 |
//表示当前字段分二种情况来处理, |
|
1210 |
//第一个情况是值没变化的 情况 下只作为后期审计查询的唯一条件,附加进有变化的审计字段的行,插入数据表 |
|
1211 |
//第二个情况是值有变化的情况下,除了作为后期审计查询的唯一条件,附加进有变化的审计字段的行,也需要记录本身的新旧值变化的情况 |
|
1212 |
//第三种情况是删行的情况下,也需要记录本身的新旧值变化的情况 |
|
1213 |
//2: |
|
1214 |
//只作为有变化的情况的审计字段,记录新旧值插入数据表 |
|
1215 |
isAudit = GridUtils.prossRowSetDataType_Int(map, "audit"); |
|
1216 |
} catch (Exception e) { |
|
1217 |
iscopy = true; |
|
1218 |
isAudit = 0; |
|
1219 |
} |
|
1220 |
boolean isLoad = false; |
|
1221 |
try { |
|
1222 |
if (!isref) { |
|
1223 |
if (dto.order == 1//表示是列表的情况(很少存在需要取隐藏字段值的情况) by 2015-4-7 去掉这个限制 |
|
1224 |
&& (type == 33 || type == 34 || type == 36 || type == 38 || type == 41)) |
|
1225 |
isLoad = false; |
|
1226 |
else |
|
1227 |
isLoad = GridUtils.prossRowSetDataType_Boolean(map, "isLoad");//是否加载到页面 |
|
1228 |
} |
|
1229 |
//在超接连中有参数,需要再判断是否需要加载到页面 |
|
1230 |
if (vMap.containsKey(id.toLowerCase())) { |
|
1231 |
isLoad = true; |
|
1232 |
|
|
1233 |
} |
|
1234 |
} catch (Exception e) { |
|
1235 |
isref = true; |
|
1236 |
} |
|
1237 |
|
|
1238 |
if (cellAlign == null || cellAlign.length() == 0) cellAlign = "Center"; |
|
1239 |
|
|
1240 |
if (!this.checkFormat(displayformat)) |
|
1241 |
msgInfo.append(id + "-的格式设置不正确,存在连续二个分隔符,[" + displayformat + "]"); |
|
1242 |
|
|
1243 |
if (displayformat != null && displayformat.contains("#")) |
|
1244 |
msgInfo.append(id + "-的格式设置不正确,不能以#号分隔,[" + displayformat + "]"); |
|
1245 |
|
|
1246 |
//上面的都是读取9802的设置信息,接下来的才是逻辑处理 |
|
1247 |
|
|
1248 |
boolean listShow = ((dto.order == 1//表示是列表的情况(很少存在需要取隐藏字段值的情况) by 2015-4-7 去掉这个限制 |
|
1249 |
// &&(type==33||type==34||type==36||type==38||type==41) |
|
1250 |
&& (dto.winType == 9 || dto.winType == 15 || dto.winType == 17 || |
|
1251 |
dto.winType == 499 || dto.winType == 497) |
|
1252 |
)) ? true : false; |
|
1253 |
//增加作为主键时,但没勾选上加载到页面时,也需要生成出来。 |
|
1254 |
boolean isprimeKey = false; |
|
1255 |
if ((";" + dto.primeKey.toLowerCase()).contains(";" + id.toLowerCase() + ";")) |
|
1256 |
isprimeKey = true;//判断是主键,不管有没选上加载到页面都需要生成到页面 |
|
1257 |
|
|
1258 |
if (!isprimeKey && (!isLoad || listShow)) {//不加载到页面或是列表的情况 |
|
1259 |
if ((!isref && !isLoad |
|
1260 |
&& !id.equalsIgnoreCase("doccode")//这二个字段特殊,需要区别对待,需要取出来 |
|
1261 |
&& !id.equalsIgnoreCase("docdate")) |
|
1262 |
//|| |
|
1263 |
//(!ShowOnGrid&&listShow)//表示不选显示,但又是列情的情况则不需要理会是否加载到页面的选项,也就是在列表的情况下,不选显示的优先级高 |
|
1264 |
|| |
|
1265 |
(dto.winType != 18 && !dataLink && !ShowOnGrid) |
|
1266 |
) continue;//条件为在9802中设置不显示且是在明细表的情况下才输出显示 |
|
1267 |
|
|
1268 |
|
|
1269 |
} |
|
1270 |
//检查当前是否有会计科目设置 |
|
1271 |
if (!this.isNullOrEmptry(dto.glcodefield)) { |
|
1272 |
if (id.toLowerCase().matches("cv\\d{1}") || id.toLowerCase().matches("cv\\d{1}name")) { |
|
1273 |
type = -3;//会计核算之用 |
|
1274 |
} |
|
1275 |
} |
|
1276 |
|
|
1277 |
if (dto.order == 1 && "".equalsIgnoreCase(dto.orderFiled)) {//排序字段 |
|
1278 |
if (id.equalsIgnoreCase("doccode")) { |
|
1279 |
dto.orderFiled = id + " desc"; |
|
1280 |
} |
|
1281 |
if (id.equalsIgnoreCase("docdate")) { |
|
1282 |
dto.orderFiled = dto.orderFiled.length() == 0 ? id + " desc" : "," + id + " desc"; |
|
1283 |
} |
|
1284 |
} else if (dto.order == 2 && "".equalsIgnoreCase(dto.orderFiled)) { |
|
1285 |
if (id.equalsIgnoreCase("docitem")) |
|
1286 |
dto.orderFiled = id + " asc"; |
|
1287 |
} |
|
1288 |
if (!dataLink) {//不感应但可能数据库存在有字段 |
|
1289 |
if (gridService.getColumnInfo(dto.table, id.toLowerCase()) == 1) {//存在,表示要在页面显示出来,但在新增,修改时需要过滤 |
|
1290 |
dataLink = true; |
|
1291 |
dto.columns = id.toLowerCase() + ","; |
|
1292 |
} |
|
1293 |
} |
|
1294 |
|
493df4
|
1295 |
if (fua != null && !fua.equalsIgnoreCase("") && activefuns && calcuField != 0) { |
a6a76f
|
1296 |
formn.append(id.toLowerCase()).append("@p@").append(fua).append(":"); |
F |
1297 |
} |
|
1298 |
if (value != null && !value.equalsIgnoreCase("")) {//自动编号功能 |
|
1299 |
if (value.equalsIgnoreCase("autocode")) { |
|
1300 |
List<Map> ct = this.getAutoCodeType(dto.formID, dto.dbid); |
|
1301 |
if (ct.size() == 0) msgInfo.append(id + "字段设置autocode,但没在9801进行相关设置!"); |
|
1302 |
Map ma = ct.get(0); |
|
1303 |
if (ma.get("precodetype") == null || ma.get("codelength") == null || ma.get("preFixcode") == null) |
|
1304 |
msgInfo.append(id + "-字段设置autocode,但没在9801对【precodetype,preFixcode,codelength】进行相关设置!"); |
|
1305 |
if ((Integer) ma.get("precodetype") == 1) { |
|
1306 |
List<Map<String, Object>> li = this.getCodeInfo(dto.formID, dto.dbid); |
|
1307 |
if (li.size() == 0) msgInfo.append(id + "字段设置autocode,但没在[_sysautocode]表进行相关设置!"); |
|
1308 |
Map map1 = li.get(0); |
|
1309 |
value = "autocode|1|" + (Integer) map1.get("formid") + "," + (Integer) map1.get("Formtype") + "," + (String) map1.get("Fieldid") + "," + (Integer) map1.get("codelength") + "," + (String) map1.get("preFixcode"); |
|
1310 |
map1 = null; |
|
1311 |
} else if ((Integer) ma.get("precodetype") == 2) { |
|
1312 |
try { |
|
1313 |
SpObserver.setDBtoInstance("_" + dto.dbid); |
|
1314 |
String table = gridService.getTreeTable(dto.formID);//TODO 暂时只取第一个,以后需要修正能处理多树的情况 |
|
1315 |
String[] strings = table.split(";");//TODO 以后去掉 |
|
1316 |
value = "autocode|2|~," + (Integer) ma.get("codelength") + ",#," + (String) ma.get("preFixcode") + "," + strings[0]; |
|
1317 |
} finally { |
|
1318 |
SpObserver.setDBtoInstance(); |
|
1319 |
} |
|
1320 |
} |
|
1321 |
values.append(id.toLowerCase()).append("#").append(value).append("&p&"); |
|
1322 |
ma = null; |
|
1323 |
} else if (!value.equalsIgnoreCase("@now") && (value.indexOf("@") > -1 || value.indexOf("!") > -1)) {//替换成当前session的值 |
|
1324 |
//@now 表示需要取当前时间,所以通过js调用 |
|
1325 |
String temp1 = DBHelper.getValRep(value, false); |
|
1326 |
values.append(id.toLowerCase()).append("#").append(temp1).append("&p&"); |
|
1327 |
} else |
|
1328 |
values.append(id.toLowerCase()).append("#").append(value).append("&p&"); |
|
1329 |
} |
d89677
|
1330 |
if (SumField != 0) { |
a6a76f
|
1331 |
sumfu.append(id.toLowerCase()).append("#").append(SumField).append(":").append(funclinkname.replaceAll(",", "@p@")).append(",");//自定义公式有可能存在有,号需要处理 |
d89677
|
1332 |
tabColIndex++; |
F |
1333 |
} |
|
1334 |
if (isExport) { |
|
1335 |
if (displayformat != null && !displayformat.isEmpty()) { |
|
1336 |
exportInfo.append(id.toLowerCase()).append("#").append(temp.replaceAll("-", "_")).append("#").append(displayformat.replaceAll("-", "~")).append(";");//-转成~是为了兼容之前的代码 |
|
1337 |
}else { |
|
1338 |
exportInfo.append(id.toLowerCase()).append("#").append(temp.replaceAll("-", "_")).append(";"); |
|
1339 |
} |
|
1340 |
if (SumField > 0) { |
|
1341 |
SumFieldInfo.append(id.toLowerCase()).append("#").append(SumField).append("|").append(funclinkname).append("|").append(fumIndex).append("_T_").append(tabColIndex-1).append("|").append((displayformat != null && !displayformat.isEmpty()) ? displayformat.replaceAll("-", "~") : "0").append(";"); |
|
1342 |
} |
|
1343 |
fumIndex++; |
|
1344 |
} |
|
1345 |
|
|
1346 |
if ((passwordchar != null && !"".equalsIgnoreCase(passwordchar) && "1".equalsIgnoreCase(passwordchar))) { |
a6a76f
|
1347 |
type = 101; |
d89677
|
1348 |
} |
a6a76f
|
1349 |
//控件类型 |
F |
1350 |
String typeName = Control.getTypeName(type == 0 ? 1 : type, typeInfo, id, displayformat, dto.winType); |
|
1351 |
StringBuilder sb = new StringBuilder(); |
|
1352 |
if (type == 9 || type == 40) { |
|
1353 |
if (dto.picFild != null && dto.picFild != "") { |
|
1354 |
if (!dto.picFild.contains(id + ";")) |
|
1355 |
dto.picFild += id.toLowerCase() + ";";//保存是哪一个字段是图片字段 |
|
1356 |
} else { |
a58a39
|
1357 |
dto.picFild += id.toLowerCase() + ";";//用来保存是哪一个字段是图片字段 |
a6a76f
|
1358 |
} |
F |
1359 |
sb.append(" CanFocus='0' ");//图片不需要取得焦点,避免在进入编辑状态时上传图片,返回不显示的问题 |
|
1360 |
sb.append(" showType='" + (type == 9 ? 0 : 2) + "' ");//以后增加格线支持多附件显示需要用到,区别出到时应该取哪一个附件表(_sys_Attachment9,_sys_Attachment)的数据 |
|
1361 |
} |
a58a39
|
1362 |
if (type == 2 || type == 35 || type == 31 || type == 43 || type == 30 || type == 32|| type == 46) { |
F |
1363 |
if(!(type==46&&ft==0&&org.apache.commons.lang3.StringUtils.isBlank(sqlScript))){ |
|
1364 |
//46控件没有2,31的设置选项则不用在这里生成下拉列表 |
|
1365 |
sb = fillFT(type, ft, sqlScript, dto);//2类型 |
|
1366 |
sb.append(" CanEmpty='0' "); |
|
1367 |
dto.foot2 += id.toLowerCase() + ";";//解决针对2,35类型有值时候统计列会显示出来的问题 |
|
1368 |
dto.footb.append(id.toLowerCase()).append("Type='Text' ").append(id.toLowerCase()).append("Button='' ");//汇总页需要屏蔽单元格类型为Text |
|
1369 |
} |
a6a76f
|
1370 |
} |
F |
1371 |
if (isAudit != 0) sb.append(" audit='").append(isAudit).append("'");//增加审计标记 |
a58a39
|
1372 |
if (rowspan) {//合并行q |
a6a76f
|
1373 |
sb.append(" Spanned='1' ");//表示需要合并 |
F |
1374 |
dto.rowspanStr += id + ";";//保存需要合并的字段,加载时需要用到 |
|
1375 |
} |
a58a39
|
1376 |
if (type == 3 || type == 31 || type == -3 || type == 42) { //3类型 |
a6a76f
|
1377 |
String suggest = this.replaceBlank(GridUtils.prossRowSetDataType_String(map, "SuggestFileds").replaceAll("\\bid\\b", "_ycid_").toLowerCase()); |
F |
1378 |
String RelationField = this.replaceBlank(GridUtils.prossRowSetDataType_String(map, "RelationField").replaceAll("\\bid\\b", "_ycid_").toLowerCase()); |
|
1379 |
if ("".equalsIgnoreCase(suggest) && type == 42) |
|
1380 |
msgInfo.append(temp + "字段为42类型控件,但列表字段[SuggestFileds]未设置"); |
|
1381 |
//String path="/"+dto.verNo+ft+"/"+wiType+"/"; |
|
1382 |
String path = "app#spellPath#" + ft + "/" + wiType + "/index.jsp";//#spellPath#在页面js替换, 解决定制页面生成时,数据源用了当前而造成移植到其他系统不对的问题 |
|
1383 |
String top = this.replaceBlank(GridUtils.prossRowSetDataType_String(map, "SeekGroupID").replaceAll("\\bid\\b", "_ycid_").toLowerCase()); |
|
1384 |
String form = this.replaceBlank(GridUtils.prossRowSetDataType_String(map, "FK").replaceAll("\\bid\\b", "_ycid_").toLowerCase()); |
|
1385 |
String sf = this.replaceBlank(GridUtils.prossRowSetDataType_String(map, "sPremissField").replaceAll("\\bid\\b", "_ycid_").toLowerCase()); |
|
1386 |
String df = this.replaceBlank(GridUtils.prossRowSetDataType_String(map, "dPremissField").replaceAll("\\bid\\b", "_ycid_").toLowerCase()); |
493df4
|
1387 |
int scanCodeField = GridUtils.prossRowSetDataType_Int(map, "ScanCodeField");//APP扫码|3类型控件扫码录入功能 |
F |
1388 |
if (StringUtils.isNotBlank(top) && StringUtils.isBlank(form)) { |
|
1389 |
throw new ApplicationException("【9802】里【" + id + "】设置了【外表|接收自身字段名】,则【外表|接收外表字段名】不能为空"); |
a6a76f
|
1390 |
} |
493df4
|
1391 |
if (StringUtils.isNotBlank(sf) && StringUtils.isBlank(df)) { |
F |
1392 |
throw new ApplicationException("【9802】里【" + id + "】设置了【外表|自身条件字段名】,则【外表|外表条件字段名】不能为空"); |
a6a76f
|
1393 |
} |
F |
1394 |
sb.append(" formid='").append(ft) |
|
1395 |
.append("' toParm=\"").append(top) |
|
1396 |
.append("\" formParm=\"").append(form) |
|
1397 |
.append("\" sField=\"").append(sf) |
|
1398 |
.append("\" dField=\"").append(df) |
|
1399 |
.append("\" id='").append(id.toLowerCase()) |
|
1400 |
.append("' wtype='").append(wiType) |
|
1401 |
.append("' oneRec='").append(oneRec ? 1 : 0) |
|
1402 |
.append("' onlyOne='").append(onlyOne ? 1 : 0) |
|
1403 |
.append("' sqlWhere=\"").append(sqlWhere)// by danaus 2019/12/20 15:28 |
|
1404 |
.append("\" path='").append(path) |
0b5ba8
|
1405 |
.append("' scanCodeField='").append(scanCodeField) |
a6a76f
|
1406 |
.append(uppercase ? "' uppercase='" + uppercase : "") |
F |
1407 |
.append("' eFilter=\"").append(ef == null ? "" : (ef.replaceAll("'", "\\\\'").replaceAll("\n\t", ""))).append("\""); |
|
1408 |
String sug = ""; |
|
1409 |
if (!"".equalsIgnoreCase(suggest)) {//加上自动补全功能 |
|
1410 |
if (!"".equalsIgnoreCase(RelationField)) {//关联查询字段 |
|
1411 |
sb.append(" refield='").append(RelationField + "'"); |
|
1412 |
} |
|
1413 |
//去掉重复字段 |
|
1414 |
String[] temp1 = suggest.toLowerCase().split(";"); |
|
1415 |
|
|
1416 |
for (String s : temp1) { |
|
1417 |
if (sug.indexOf(s + ";") < 0) { |
|
1418 |
sug += s + ";"; |
|
1419 |
|
|
1420 |
} |
|
1421 |
} |
|
1422 |
sug = sug.substring(0, sug.length() - 1); |
|
1423 |
sb.append(" suggest='" + sug + "'"); |
|
1424 |
//生成显示的数据名称 |
|
1425 |
rod++;//生成100之内的随机数 |
|
1426 |
sb.append(" rand='10" + rod + "'"); |
|
1427 |
dto.sugList.append(this.getSuggestFilds(ft + "", wiType, sug, sug, top, form, oneRec, rod, dto.dbid, sf, df)); |
|
1428 |
} |
29a282
|
1429 |
if (type == -3) {//表示为辅助核算 |
a6a76f
|
1430 |
sb.append(" curType='gl' "); |
29a282
|
1431 |
} |
F |
1432 |
if (type == 3 || type == -3) { |
a6a76f
|
1433 |
sb.append(" Button='/images/ppp.gif' WidthPad='20'"); |
29a282
|
1434 |
} |
d24ea3
|
1435 |
|
a6a76f
|
1436 |
this.prossIntoSession(top, dto); |
F |
1437 |
this.prossIntoSession(form, dto); |
|
1438 |
this.prossIntoSession(sf, dto); |
|
1439 |
this.prossIntoSession(df, dto); |
|
1440 |
this.prossIntoSessionForFilter(ef, dto); |
|
1441 |
dto.footb.append(id.toLowerCase()).append("Type='Text' ").append(id.toLowerCase()).append("Button='' ");//汇总页需要屏蔽单元格类型为Text |
|
1442 |
|
|
1443 |
} else if (type == 6) { |
|
1444 |
sb.append(" CanEmpty='0' ");//解决在只读时候,没值会显示不正确的情况 |
|
1445 |
dto.footb.append(id.toLowerCase()).append("Type='Text' ");//汇总页需要屏蔽单元格类型为Text |
|
1446 |
} else if (type == 1 || type == 0 || type == 7) { |
|
1447 |
sb.append(uppercase ? " uppercase='" + uppercase + "'" : ""); |
|
1448 |
|
|
1449 |
} else if (type == 9) {//图片控件 |
|
1450 |
sb.append(" Button='/images/d.jpg' WidthPad='20' "); |
d24ea3
|
1451 |
dto.footb.append(id.toLowerCase()).append("Type='Text' ").append(id.toLowerCase()).append("Button='' ");//汇总页需要屏蔽单元格类型为Text |
F |
1452 |
}else if (type == 46) {//颜色控件 |
|
1453 |
sb.append(" colType='46' "); |
|
1454 |
dto.footb.append(id.toLowerCase()).append("Type='Text' ").append(id.toLowerCase()).append("Button='' ");//汇总页需要屏蔽单元格类型为Text |
|
1455 |
}else if (type == 47) {//进度条控件 |
|
1456 |
sb.append(" colType='47' "); |
a6a76f
|
1457 |
dto.footb.append(id.toLowerCase()).append("Type='Text' ").append(id.toLowerCase()).append("Button='' ");//汇总页需要屏蔽单元格类型为Text |
F |
1458 |
} |
|
1459 |
if (type != 2 && type != 31) {//下拉类型的不需要显示 |
|
1460 |
if (len.get(id.toLowerCase()) != null && Integer.parseInt(len.get(id.toLowerCase())) > 0) { //存在varchar(max),nvarchar(max)的情况 |
|
1461 |
|
|
1462 |
String rep = "^\\\\\\s*[\\\\\\s\\\\\\S]{0," + len.get(id.toLowerCase()) + "}\\\\\\s*\\$"; |
|
1463 |
sb.append(" EditMask='").append(rep).append("' ") |
|
1464 |
.append(" Tsize='").append(len.get(id.toLowerCase())).append("' ") |
|
1465 |
.append(" Tip='").append("最长").append(len.get(id.toLowerCase())) |
|
1466 |
.append("个字符(每汉字占2个字符)'"); |
|
1467 |
} |
|
1468 |
} |
|
1469 |
sb.append(calcuField != 0 ? " calcuField='" + calcuField + "'" : ""); |
|
1470 |
sb.append(KeyInput ? " KeyIn='1'" : "").append(" dataType='").append(dataType).append("' "); |
|
1471 |
if (emptyrefdata != null && !emptyrefdata.equalsIgnoreCase("") && !emptyrefdata.equalsIgnoreCase("0") && type != 6) |
|
1472 |
sb.append(" emptyrefdata='").append(this.replaceBlank(emptyrefdata)).append("'");//增加清空关联 |
|
1473 |
if (!this.isNullOrEmptry(GridUtils.prossRowSetDataType_String(map, "HyperlinkFT")) && !this.isNullOrEmptry(GridUtils.prossRowSetDataType_String(map, "HyperlinkFTFormType"))) { |
|
1474 |
//判断22类型的主表是不是自定义.do。 |
|
1475 |
String execdo = ""; |
|
1476 |
if ("22".equals(GridUtils.prossRowSetDataType_String(map, "HyperlinkFTFormType")) |
|
1477 |
&& org.apache.commons.lang.StringUtils.isNumeric(GridUtils.prossRowSetDataType_String(map, "HyperlinkFT"))) { |
|
1478 |
T_22_Ifc t22ifc = (T_22_Ifc) FactoryBean.getBean("T_22_Impl"); |
|
1479 |
execdo = t22ifc.getProcName(GridUtils.prossRowSetDataType_String(map, "HyperlinkFT")); |
|
1480 |
if (execdo != null && !"".equals(execdo)) { |
|
1481 |
execdo = (execdo.indexOf(".do") != -1 ? execdo : ""); |
|
1482 |
} |
|
1483 |
} |
|
1484 |
String efl = this.replaceBlank(GridUtils.prossRowSetDataType_String(map, "HyperlinkEFilter").toLowerCase()); |
|
1485 |
String op = this.replaceBlank(GridUtils.prossRowSetDataType_String(map, "Hyperlinkmode").toLowerCase()); |
|
1486 |
int save = GridUtils.prossRowSetDataType_Int(map, "isAutoSaved"); |
|
1487 |
// String openType=this.prossRowSetDataType_String(map,"openType")==null?"0":this.replaceBlank(this.prossRowSetDataType_String(map,"openType").toLowerCase()); |
|
1488 |
String sf = this.replaceBlank(GridUtils.prossRowSetDataType_String(map, "HyperlinkSPremissField").replaceAll("\\bid\\b", "_ycid_").toLowerCase()); |
|
1489 |
String df = this.replaceBlank(GridUtils.prossRowSetDataType_String(map, "HyperlinkDPremissField").replaceAll("\\bid\\b", "_ycid_").toLowerCase()); |
e1b640
|
1490 |
int autoref = 0; |
a6a76f
|
1491 |
try { |
e1b640
|
1492 |
autoref = GridUtils.prossRowSetDataType_Int(map, "isAutoRefresh"); |
a6a76f
|
1493 |
} catch (Exception e) { |
F |
1494 |
|
|
1495 |
} |
|
1496 |
sb.append(" Fformid='").append(this.replaceBlank(GridUtils.prossRowSetDataType_String(map, "HyperlinkFT").toLowerCase())) |
|
1497 |
.append("' FsField=\"").append(sf) |
|
1498 |
.append("\" FdField=\"").append(df) |
e1b640
|
1499 |
.append("\" Fref=\"").append(autoref) |
a6a76f
|
1500 |
// .append("\" FopenType=\"").append(openType)//增加弹出层的功能 1表示正常的页卡,2表示弹出层显示 |
F |
1501 |
.append("\" Fwtype='").append(GridUtils.prossRowSetDataType_String(map, "HyperlinkFTFormType")) |
|
1502 |
.append("' Fop='").append(op == null ? "0" : (op.replaceAll("'", "\\\\'").replaceAll("\n\t", ""))) |
|
1503 |
.append("' Fsave='").append(save) |
|
1504 |
.append("' Fexec='").append(execdo) |
|
1505 |
.append("' FeFilter=\"").append(efl == null ? "" : (efl.replaceAll("'", "\\\\'").replaceAll("\n\t", ""))).append("\""); |
|
1506 |
this.prossIntoSession(sf, dto); |
|
1507 |
this.prossIntoSession(df, dto); |
|
1508 |
this.prossIntoSessionForFilter(efl, dto); |
|
1509 |
} |
|
1510 |
if ((dto.order == 1 && id.equalsIgnoreCase("doccode") && this.isNullOrEmptry(GridUtils.prossRowSetDataType_String(map, "HyperlinkFT")) && this.isNullOrEmptry(GridUtils.prossRowSetDataType_String(map, "HyperlinkFTFormType")))//当是单据时候增加对doccode字段自动超链接 |
|
1511 |
) { |
|
1512 |
sb.append(" Fformid='").append(dto.formID) |
|
1513 |
.append("' FsField=\"").append("doccode") |
|
1514 |
.append("\" FdField=\"").append("doccode") |
|
1515 |
.append("\" Fwtype='").append(dto.othType) |
|
1516 |
.append("' FeFilter=\"").append("\""); |
|
1517 |
} |
|
1518 |
if (ShowOnGrid && id.equalsIgnoreCase(dto.lastField.toLowerCase())) sb.append(" ent='1' ");//增加标记为最后一个字段 |
|
1519 |
if (index < dto.frozencols) {// |
493df4
|
1520 |
left.append("<C " + showMenuName(dec, dto.colset) + " CaseSensitive='0' Name='").append(id.toLowerCase()).append("'").append(" cpltrow='").append(cpltrow ? 1 : 0).append("' CanEdit='").append(readOnly ? 0 : 1).append("' Type='").append(typeName).append("' ") |
a6a76f
|
1521 |
.append((editStatus == "" || editStatus == null) ? "" : " editStatus='" + editStatus + "'") |
a58a39
|
1522 |
.append(ShowOnGrid ? "" : " Visible='0' noItemShow='1' ")//noItemShow用于格线列显示 |
a6a76f
|
1523 |
.append(fileterID ? " Visible='0' " : ""); |
F |
1524 |
if (!dto.isList && dto.gantt && "subtask".equalsIgnoreCase(id.toLowerCase())) |
|
1525 |
left.append(" CanGroup='2' GroupChar='/' GroupEmpty='0' "); |
|
1526 |
left.append((displayformat != null && !"".equalsIgnoreCase(displayformat) && !"0".equalsIgnoreCase(displayformat)) ? (" Format='" + displayformat + "'" + ("Date".equalsIgnoreCase(typeName) ? " EditFormat='" + displayformat + "'" : "")) : ("Date".equalsIgnoreCase(typeName) ? " Format='yyyy-MM-dd' EditFormat='yyyy-MM-dd'" : "")) |
|
1527 |
.append(" CanEmpty='1' Align='").append(cellAlign).append("' Width='").append(width).append("' ").append(sb.toString() + "/>\n"); |
|
1528 |
if (ValueExp != null && !"".equalsIgnoreCase(ValueExp)) {//增加一个有权限控制的关联字段 |
|
1529 |
left.append("<C CaseSensitive='0' Name='").append(id.toLowerCase()).append("_expr'") |
|
1530 |
.append(" Visible='0' ") |
|
1531 |
.append(" />\n"); |
|
1532 |
} |
493df4
|
1533 |
if (!fileterID && ShowOnGrid) index++; |
a6a76f
|
1534 |
} else { |
493df4
|
1535 |
cols.append("<C " + showMenuName(dec, dto.colset) + " CaseSensitive='0' Name='").append(id.toLowerCase()).append("'").append(" cpltrow='").append(cpltrow ? 1 : 0).append("' CanEdit='").append(readOnly ? 0 : 1).append("' Type='").append(typeName).append("' ") |
a6a76f
|
1536 |
.append((editStatus == "" || editStatus == null) ? "" : " editStatus='" + editStatus + "'") |
a58a39
|
1537 |
.append(ShowOnGrid ? "" : " Visible='0' noItemShow='1' ") |
a6a76f
|
1538 |
|
F |
1539 |
.append(fileterID ? " Visible='0' " : ""); |
|
1540 |
if (!dto.isList && dto.gantt && "subtask".equalsIgnoreCase(id.toLowerCase())) |
|
1541 |
cols.append(" CanGroup='2' GroupChar='/' GroupEmpty='0' "); |
|
1542 |
cols.append((displayformat != null && !"".equalsIgnoreCase(displayformat) && !"0".equalsIgnoreCase(displayformat)) ? (" Format='" + displayformat + "'" + ("Date".equalsIgnoreCase(typeName) ? " EditFormat='" + displayformat + "'" : "")) : ("Date".equalsIgnoreCase(typeName) ? " Format='yyyy-MM-dd' EditFormat='yyyy-MM-dd'" : "")) |
|
1543 |
.append(" CanEmpty='1' Align='").append(cellAlign).append("' Width='").append(width).append("' ").append(sb.toString() + "/>\n"); |
|
1544 |
if (ValueExp != null && !"".equalsIgnoreCase(ValueExp)) {//增加一个有权限控制的关联字段 |
|
1545 |
cols.append("<C CaseSensitive='0' Name='").append(id.toLowerCase()).append("_expr'") |
|
1546 |
.append(" Visible='0' ") |
|
1547 |
.append(" />\n"); |
|
1548 |
|
|
1549 |
} |
|
1550 |
} |
|
1551 |
|
|
1552 |
} |
|
1553 |
//while(dto.gfields.next()); |
|
1554 |
if ("".equalsIgnoreCase(dto.orderFiled)) dto.orderFiled = firstID + " desc"; |
|
1555 |
dto.expr = valExp.length() > 0 ? valExp.substring(0, valExp.length() - 1) : ""; |
|
1556 |
dto.cspr = cssExp.length() > 0 ? cssExp.substring(0, cssExp.length() - 1) : ""; |
|
1557 |
dto.tipspr = tipsExp.length() > 0 ? tipsExp.substring(0, tipsExp.length() - 1) : ""; |
|
1558 |
if (cols.length() == 0 && !dto.gantt) { |
|
1559 |
msgInfo.append(dto.formID + "-格线未设置显示字段或9801定义的冻结列数大于需要显示的列数或加载项(isLoad)未勾选!"); |
|
1560 |
} |
|
1561 |
if (cols.length() > 0) |
|
1562 |
dto.colsConfig = cols.substring(0, cols.length() - 1); |
|
1563 |
dto.LeftCols = left.length() > 0 ? "<LeftCols>" + left.substring(0, left.length() - 1) + "</LeftCols>" : ""; |
|
1564 |
dto.formula = formn.length() > 1 ? formn.substring(0, formn.length() - 1) : ""; |
|
1565 |
dto.initValue = values.length() > 1 ? values.substring(0, values.length() - 3) : ""; |
|
1566 |
dto.totalCols = sumfu.length() > 1 ? sumfu.substring(0, sumfu.length() - 1) : ""; |
|
1567 |
if (!iscopy && rowCopys != null) { |
|
1568 |
dto.rowcopyfields = rowCopys.length() > 1 ? rowCopys.substring(0, rowCopys.length() - 1) : ""; |
|
1569 |
} |
|
1570 |
if (dto.totalCols == "") { |
|
1571 |
dto.foot = ""; |
|
1572 |
dto.foot2 = ""; |
|
1573 |
}//当没有统计列时候不需要显示 |
|
1574 |
else { |
|
1575 |
dto.foot = "<Foot><I id=\"Fix1\" CanEdit='0' " + dto.footb.toString() + "/></Foot>"; |
|
1576 |
} |
|
1577 |
|
|
1578 |
if ((exportInfo.lastIndexOf("-") + 1) < exportInfo.length()) { |
|
1579 |
int tsm = dto.conNum == 0 ? dto.winType : dto.othType; |
|
1580 |
exportInfo.append("-").append(tsm).append("-").append(SumFieldInfo.toString());//后面跟窗体类型 |
|
1581 |
// String titles=""; |
|
1582 |
// if(exportTitle.length()>0) { |
|
1583 |
// titles=exportTitle.toString(); |
|
1584 |
// if(titles.lastIndexOf(";")>0) titles=titles.substring(0, titles.length()-1); |
|
1585 |
// } |
|
1586 |
// titles=titles+"@p@"+exportInfo.toString(); |
|
1587 |
FileUtil.writeFile(exportInfo.toString(), root.replaceAll("\\\\", "/") + File.separator + dto.verNo + "/" + dto.formID + "/" + tsm + "/data");//写到文件里面 |
|
1588 |
} |
|
1589 |
if (msgInfo.length() > 0) throw new ApplicationException(msgInfo.toString()); |
|
1590 |
} catch (ArrayIndexOutOfBoundsException e1) { |
|
1591 |
throw new ApplicationException("读取不到" + dto.formID + "在9802里面的字段信息,请检查9802是否已做了相关设置"); |
|
1592 |
} catch (Exception e) { |
|
1593 |
e.printStackTrace(); |
|
1594 |
throw new ApplicationException(e.getCause() == null ? e.getMessage() + "\n" + msgInfo.toString() + "_" + dto.dbid : e.getCause().getMessage() + "\n" + msgInfo.toString() + "_" + dto.dbid); |
|
1595 |
} finally { |
|
1596 |
left = null; |
|
1597 |
cols = null; |
|
1598 |
formn = null; |
|
1599 |
values = null; |
|
1600 |
sumfu = null; |
|
1601 |
valExp = null; |
|
1602 |
msgInfo = null; |
|
1603 |
} |
493df4
|
1604 |
} |
F |
1605 |
|
|
1606 |
private String showMenuName(String caption, int isShowCell) { |
|
1607 |
//设置了显示列功能才执行 |
|
1608 |
return (isShowCell == 1 && org.apache.commons.lang3.StringUtils.isNotBlank(caption)) ? (" MenuName='" + caption + "' ") : " "; |
a6a76f
|
1609 |
} |
F |
1610 |
|
|
1611 |
private void setFilter(String id, int type, StringBuilder filter, int dIndex) { |
|
1612 |
switch (type) { |
|
1613 |
|
|
1614 |
case 1: |
|
1615 |
case 7: |
|
1616 |
if (dIndex == 4)//是日期类型,虽然定义为1类型也显示日期 |
|
1617 |
filter.append(id).append("Range=\"1\" ") |
|
1618 |
.append(id).append("Filter=\"0\" ") |
|
1619 |
.append(id).append("ShowMenu=\"0\" "); |
|
1620 |
else |
|
1621 |
filter.append(id).append("Range=\"1\" ") |
|
1622 |
.append(id).append("Filter=\"0\" ") |
|
1623 |
.append(id).append("ShowMenu=\"1\" "); |
|
1624 |
break; |
|
1625 |
case 5: |
|
1626 |
filter.append(id).append("Range=\"1\" ") |
|
1627 |
.append(id).append("Filter=\"0\" ") |
|
1628 |
.append(id).append("ShowMenu=\"0\" "); |
|
1629 |
break; |
|
1630 |
case 2: |
|
1631 |
case 31: |
|
1632 |
case 35: |
a58a39
|
1633 |
case 46: |
a6a76f
|
1634 |
filter.append(id).append("Range=\"1\" ") |
F |
1635 |
|
a58a39
|
1636 |
.append(id).append("Type='Text' ") |
a6a76f
|
1637 |
.append(id).append("ShowMenu=\"1\" "); |
F |
1638 |
break; |
|
1639 |
case 3: |
|
1640 |
filter.append(id).append("Range=\"1\" ") |
|
1641 |
.append(id).append("Button='' ") |
a58a39
|
1642 |
.append(id).append("Type='Text' ") |
a6a76f
|
1643 |
.append(id).append("ShowMenu=\"1\" "); |
F |
1644 |
break; |
|
1645 |
case 9: |
|
1646 |
case 19: |
|
1647 |
case 40: |
|
1648 |
filter.append(id).append("CanEdit='0' ") |
|
1649 |
.append(id).append("Button='' ") |
|
1650 |
.append(id).append("Type='Text' ") |
|
1651 |
.append(id).append("ShowMenu='0' "); |
|
1652 |
break; |
|
1653 |
case 6: |
29a282
|
1654 |
filter.append(id).append("CanEmpty=\"1\" ") |
a6a76f
|
1655 |
.append(id).append("ShowMenu=\"0\" "); |
F |
1656 |
break; |
|
1657 |
} |
|
1658 |
|
|
1659 |
} |
|
1660 |
|
|
1661 |
/** |
|
1662 |
* 把需要从会话中替换的值写到页面里 |
|
1663 |
**/ |
|
1664 |
private void prossIntoSession(String str, TreeGridDTO dto) { |
|
1665 |
if (str != null && str.length() > 0) { |
|
1666 |
StringBuilder sb = new StringBuilder(); |
|
1667 |
String[] s = str.split(";"); |
|
1668 |
int index = 0; |
|
1669 |
String kk = "";//中间变量 |
|
1670 |
for (String te : s) { |
|
1671 |
if (te.indexOf("@") == 0) {//需要从会话里读 |
|
1672 |
//处理会话值为空的情况,导致页面js的json对象出现脚本错误 |
|
1673 |
String temp = "<%=(session.getAttribute(\"" + te.toLowerCase() + "\")==null||((String)session.getAttribute(\"" + te.toLowerCase() + "\")).length()==0)?\"\":session.getAttribute(\"" + te.toLowerCase() + "\")%>";//DBHelper.getValRep(te.toLowerCase(),false); |
|
1674 |
|
|
1675 |
if (te.equalsIgnoreCase(kk)) continue; |
|
1676 |
kk = te; |
|
1677 |
if (index > 0) sb.append(","); |
|
1678 |
if (dto.setInfo != null && dto.setInfo.trim().length() > 0 && index == 0) dto.setInfo += ","; |
|
1679 |
sb.append(te.replaceAll("'", "").replaceAll("@", "").toLowerCase()) |
|
1680 |
.append(":") |
|
1681 |
.append("'") |
|
1682 |
.append(temp) |
|
1683 |
.append("'");//还原引号是因为需要引号括起来,在页面才不会出现脚本错误 |
|
1684 |
index++; |
|
1685 |
} |
|
1686 |
} |
|
1687 |
|
|
1688 |
dto.setInfo += sb.toString(); |
|
1689 |
} |
|
1690 |
} |
|
1691 |
|
|
1692 |
/** |
|
1693 |
* 把需要从会话中替换的值写到页面里 ,适用是自定义条件的情况 |
|
1694 |
* 也就是一条sql语句中需要查出来替换,isnull(cccode,'')='@cccode' |
|
1695 |
**/ |
|
1696 |
private void prossIntoSessionForFilter(String str, TreeGridDTO dto) { |
|
1697 |
if (str != null && str.length() > 0) { |
|
1698 |
StringBuilder sb = new StringBuilder(); |
|
1699 |
Pattern p = Pattern.compile("@.*?\\w+");// 匹配以@开头的单词 |
|
1700 |
java.util.regex.Matcher propsMatcher = p.matcher(str); |
|
1701 |
int index = 0; |
|
1702 |
String kk = ""; |
|
1703 |
String kt = ""; |
|
1704 |
while (propsMatcher.find()) { |
|
1705 |
String te = propsMatcher.group(); |
|
1706 |
|
|
1707 |
String temp = "<%=(session.getAttribute(\"" + te.toLowerCase() + "\")==null||((String)session.getAttribute(\"" + te.toLowerCase() + "\")).length()==0)?\"\":session.getAttribute(\"" + te.toLowerCase() + "\")%>";//DBHelper.getValRep(te.toLowerCase(),false); |
|
1708 |
if (te.equalsIgnoreCase(kk)) continue; |
|
1709 |
if (dto.setInfo.indexOf(kt + ":") > 0) continue; |
|
1710 |
kk = te; |
|
1711 |
if (index > 0) sb.append(","); |
|
1712 |
if (dto.setInfo != null && dto.setInfo.trim().length() > 0 && index == 0) dto.setInfo += ","; |
|
1713 |
kt = te.replaceAll("@", "").toLowerCase(); |
|
1714 |
sb.append(te.replaceAll("@", "").toLowerCase()) |
|
1715 |
.append(":") |
|
1716 |
.append("'") |
|
1717 |
.append(temp) |
|
1718 |
.append("'"); |
|
1719 |
index++; |
|
1720 |
} |
|
1721 |
|
|
1722 |
dto.setInfo += sb.toString(); |
|
1723 |
} |
|
1724 |
} |
|
1725 |
|
|
1726 |
private void prossIntoSessionForFilter_dy(String str, TreeGridDTO dto) { |
|
1727 |
if (str != null && str.length() > 0) { |
|
1728 |
StringBuilder sb = new StringBuilder(); |
|
1729 |
Pattern p = Pattern.compile("@.*?\\w+");// 匹配以@开头的单词 |
|
1730 |
java.util.regex.Matcher propsMatcher = p.matcher(str); |
|
1731 |
int index = 0; |
|
1732 |
String kk = ""; |
|
1733 |
while (propsMatcher.find()) { |
|
1734 |
String te = propsMatcher.group(); |
|
1735 |
|
|
1736 |
String temp = "<%=(session.getAttribute(\"" + te.toLowerCase() + "\")==null||((String)session.getAttribute(\"" + te.toLowerCase() + "\")).length()==0)?\"\":session.getAttribute(\"" + te.toLowerCase() + "\")%>";//DBHelper.getValRep(te.toLowerCase(),false); |
|
1737 |
if (te.equalsIgnoreCase(kk)) continue; |
|
1738 |
kk = te; |
|
1739 |
if (index > 0) sb.append(","); |
|
1740 |
sb.append(te.replaceAll("@", "").toLowerCase()) |
|
1741 |
.append(":") |
|
1742 |
.append("'") |
|
1743 |
.append(temp) |
|
1744 |
.append("'"); |
|
1745 |
index++; |
176de8
|
1746 |
} |
F |
1747 |
if (org.apache.commons.lang3.StringUtils.isNotBlank(sb.toString())) { |
|
1748 |
if(!"".equalsIgnoreCase(dto.setInfo_dy)) { |
493df4
|
1749 |
dto.setInfo_dy += ","; |
a6a76f
|
1750 |
} |
176de8
|
1751 |
dto.setInfo_dy += sb.toString(); |
a6a76f
|
1752 |
} |
F |
1753 |
} |
|
1754 |
} |
|
1755 |
|
|
1756 |
/** |
|
1757 |
* 处理生成多表结构中的多表格 |
|
1758 |
**/ |
|
1759 |
public void setTabPage(int formType, int height, int count, TreeGridDTO dto) { |
|
1760 |
dto.tabPage = formType; |
|
1761 |
dto.gridHeight = height; |
|
1762 |
dto.masterKey = count == 0 ? "" : count + ""; |
|
1763 |
dto.b499 = true; |
|
1764 |
} |
|
1765 |
|
|
1766 |
public void setTabPage497(int type, int height1, String indexs, String tolkey, int formid, int index, TreeGridDTO dto) { |
|
1767 |
dto.tabPage = type; |
|
1768 |
dto.gridHeight = height1; |
|
1769 |
dto.masterKey = indexs; |
|
1770 |
dto.b497 = true; |
|
1771 |
dto.b499 = true; |
|
1772 |
dto.tolkey = tolkey; |
|
1773 |
dto.PriFormID = formid;//取得主功能号里面的排除功能号和字段列表用 by 11-5-28 |
|
1774 |
dto.PriIndex = index; |
|
1775 |
} |
|
1776 |
|
|
1777 |
/** |
|
1778 |
* 根据不同类型决定不同的排序规则 |
|
1779 |
* //1,读取9801设置, |
|
1780 |
* //2,根据不同类型再进行不同的设置(单据清单desc,明细 以docitem asc,) |
|
1781 |
* //3,对于不是上面的二种情况不用排序 |
|
1782 |
*/ |
|
1783 |
private String setOrderBy(TreeGridDTO dto) { |
|
1784 |
String temp = ""; |
|
1785 |
if (dto.order == 1 && dto.index1 != null && !dto.index1.isEmpty()) { //9801 主表 |
|
1786 |
temp = setSqlOrderBy(dto.index1, " asc"); |
|
1787 |
} else if (dto.order == 2 && dto.index2 != null && !dto.index2.isEmpty()) {//明细表 |
|
1788 |
temp = setSqlOrderBy(dto.index2, " asc"); |
|
1789 |
} else { |
|
1790 |
if (dto.field.isEmpty()) |
|
1791 |
temp = dto.orderFiled; |
|
1792 |
else { |
|
1793 |
//处理8类型第三表的排序不是默认的docitm的情况,也就是9801定义有排序 |
493df4
|
1794 |
if (dto.winType == 15 && dto.order == 2 && org.apache.commons.lang3.StringUtils.isNotBlank(dto.index1)) { |
a6a76f
|
1795 |
temp = setSqlOrderBy(dto.index1, " asc"); |
493df4
|
1796 |
} else { |
a6a76f
|
1797 |
temp = setSqlOrderBy(dto.field, dto.order == 1 ? " desc" : " asc"); |
F |
1798 |
} |
|
1799 |
} |
|
1800 |
} |
|
1801 |
dto.field = ""; |
|
1802 |
if ("".equalsIgnoreCase(temp)) return ""; |
|
1803 |
String[] s = temp.replaceAll(",", " ").split("\\s+");// |
|
1804 |
String cols = "SortCols='"; |
|
1805 |
String types = "SortTypes='"; |
|
1806 |
for (int j = 0; j < s.length; j += 2) { |
|
1807 |
if (j > 0) { |
|
1808 |
cols += ","; |
|
1809 |
types += ","; |
|
1810 |
} |
|
1811 |
cols += s[j].equalsIgnoreCase("_ycid_") ? "id" : s[j]; |
|
1812 |
types += "asc".equalsIgnoreCase(s[j + 1]) ? "0" : "1"; |
|
1813 |
} |
|
1814 |
return cols + "' " + types + "'"; |
|
1815 |
|
|
1816 |
} |
|
1817 |
|
|
1818 |
private String setSqlOrderBy(String index22, String x) {//x为desc,asc |
|
1819 |
String temp = ""; |
|
1820 |
index22 = index22.replaceAll(";", ","); |
|
1821 |
String[] sorts = index22.split(","); |
|
1822 |
int index = 0; |
|
1823 |
for (String s : sorts) { |
|
1824 |
String[] str = s.split("\\s"); |
|
1825 |
if (str.length == 2) { |
|
1826 |
if (index > 0) |
|
1827 |
temp += "," + str[0] + " " + str[1]; |
|
1828 |
else |
|
1829 |
temp += str[0] + " " + str[1]; |
|
1830 |
} else { |
|
1831 |
if (index > 0) |
|
1832 |
temp += "," + str[0] + " " + x; |
|
1833 |
else |
|
1834 |
temp += str[0] + " " + x; |
|
1835 |
} |
|
1836 |
index++; |
|
1837 |
} |
|
1838 |
return temp; |
|
1839 |
} |
|
1840 |
|
|
1841 |
/** |
|
1842 |
* 设置表格高度 |
|
1843 |
*/ |
|
1844 |
private String setGridHight(TreeGridDTO dto) { |
|
1845 |
if (((dto.winType != 1 || dto.winType != 10) && dto.order == 2) && dto.gridHeight == 0) |
|
1846 |
dto.gridHeight = GRID_HEIGHT; |
|
1847 |
String temp = dto.gridHeight > 0 ? dto.gridHeight + "px" : GRID_HEIGHT + "px"; |
|
1848 |
dto.gridHeight = 0; |
|
1849 |
return temp; |
|
1850 |
} |
|
1851 |
|
|
1852 |
/* (non-Javadoc) |
|
1853 |
* @see com.yc.action.grid.TreeGridIfc#createGrid(int, int, java.lang.String, java.lang.String, java.lang.String[]) |
|
1854 |
*/ |
|
1855 |
@Override |
|
1856 |
public void createGrid(int type, int formID, String root, String path, String fileName[], String tempPath, String pst, TMuiDTO dt, String dbid) throws DataAccessException, SQLException { |
|
1857 |
try { |
|
1858 |
StringBuilder sb = new StringBuilder();//总的js |
|
1859 |
StringBuilder jsp = new StringBuilder();//总的jsp |
|
1860 |
StringBuilder main = new StringBuilder();//临时main标记 |
|
1861 |
StringBuilder hd = new StringBuilder();//临时header标记 |
|
1862 |
TreeGridDTO dto = new TreeGridDTO(); |
|
1863 |
String refgrid = "";//保存需要引用多少个grid |
|
1864 |
dto.verNo = path.replaceAll("\\\\", "/");//系统号+版本号+语言 |
|
1865 |
dto.formID = formID; |
|
1866 |
dto.winType = type; |
|
1867 |
dto.othType = 0; |
|
1868 |
dto.dbid = dbid; |
|
1869 |
if (dt != null) {//把多表的值传过来填充 |
493df4
|
1870 |
this.setTabPage497(dt.type, dt.height1, dt.indexs, dt.tolkey, dt.fromid, dt.index, dto); |
a6a76f
|
1871 |
this.setXxk(dt.xxk, dto); |
493df4
|
1872 |
dto.formTabName = dt.formTabName; |
a6a76f
|
1873 |
} |
F |
1874 |
if (dt != null && dt.addnew) |
|
1875 |
dto.postStatusAddNew = dt.addnew; |
|
1876 |
int ty = gridService.getwinType(dto.winType); |
|
1877 |
if (ty == 4 || ty == 5) { |
|
1878 |
dto.isTable = false; |
|
1879 |
dto.action = ty == 4 ? "func" : "proc"; |
|
1880 |
} |
|
1881 |
String hasGrid = ""; |
|
1882 |
int num = 1;//循环次数 |
|
1883 |
if (dto.winType == 9) { |
|
1884 |
num = 2; |
|
1885 |
dto.othType = 5; |
|
1886 |
} |
|
1887 |
if (dto.winType == 17) { |
|
1888 |
num = 1; |
|
1889 |
dto.othType = 16; |
|
1890 |
hasGrid = "0"; |
|
1891 |
} |
|
1892 |
if (dto.winType == 15) { |
|
1893 |
num = 3; |
|
1894 |
dto.othType = 8; |
|
1895 |
dto.muilGrid = true; |
|
1896 |
}//三表有关联 |
|
1897 |
if (dto.winType == 152) { |
|
1898 |
num = 3; |
|
1899 |
dto.othType = 151; |
|
1900 |
dto.muilGrid = true; |
|
1901 |
}//三表无关联 |
|
1902 |
if (dto.winType == 499 || dto.winType == 498) { |
|
1903 |
dto.othType = 498; |
|
1904 |
hasGrid = "many"; |
|
1905 |
}//多表 |
|
1906 |
if (dto.winType == 497 || dto.winType == 496) { |
|
1907 |
dto.othType = 496; |
|
1908 |
hasGrid = "many"; |
|
1909 |
}//多表且有关联 |
|
1910 |
|
|
1911 |
for (int i = 0; i < num; i++) { |
|
1912 |
if (dto.winType == 3 || dto.winType == 4 || dto.winType == 30 || dto.winType == 301) {//树类型,需要生成与树相关的值 |
|
1913 |
dto.treefield = this.getTreeFields(formID, dto.dbid); |
|
1914 |
} |
|
1915 |
String str = FileUtil.readFile(tempPath + "/grid.jsp");//页面模板 |
|
1916 |
if (dto.muilGrid && i == 0) jsp.append(str).append("\n"); //先保存好模板,以便生成多表时候用 |
|
1917 |
dto.conNum = i; |
|
1918 |
dto.order = setOrderName(dto); |
|
1919 |
this.print(root, dto); |
|
1920 |
String strJs = FileUtil.readFile(tempPath + (((dto.gantt && dto.order == 2) || (dto.gantt && dto.winType == 18)) ? "/grid_Gantt.js" : "/grid.js"));//页面js |
|
1921 |
String[] ver = dto.verNo.split("/"); |
|
1922 |
String ddsave = ""; |
|
1923 |
try { |
|
1924 |
if (dto.DealAfterDocSave != null && dto.DealAfterDocSave.trim().length() > 0) |
|
1925 |
ddsave = "&DealAfterDocSave=" + this.replaceBlank(EncodeUtil.base64Encode(dto.DealAfterDocSave)); |
|
1926 |
} catch (UnsupportedEncodingException e) { |
|
1927 |
throw new ApplicationException("加密保存后执行组出错-" + dto.DealAfterDocSave); |
|
1928 |
} |
|
1929 |
try { |
|
1930 |
String js = FileUtil.readFile(tempPath + (((dto.gantt && dto.order == 2) || (dto.gantt && dto.winType == 18)) ? "/gridDef_Gantt.xml" : "/gridDef.xml"));//js结构 |
|
1931 |
js = js |
|
1932 |
.replaceAll("@id", "T_" + dto.formID)//功能号 |
|
1933 |
.replaceAll("@lang", ver[ver.length - 1])//语言 |
|
1934 |
.replaceAll("@Cols", dto.colsConfig + "")//列定义 |
|
1935 |
.replaceAll("@LeftCols", dto.LeftCols + "")//列定义 |
|
1936 |
.replaceAll("@Header", dto.header.replaceAll("\\$", "\\\\\\$") + "")//列标题,转义$为\$ |
|
1937 |
.replaceAll("@minHeight", GRID_HEIGHT + "")//最小高度 |
|
1938 |
.replaceAll("@formidType", dto.winType + "|" + i)//当前grid的窗体类型 |
|
1939 |
.replaceAll("@formid", dto.formID + "")//当前grid的功能号 |
|
1940 |
.replaceAll("@formula", this.replaceBlank(dto.formula))//自定义公式 //增加判断是否存在死循环的可能 |
|
1941 |
.replaceAll("@rowSpan", this.replaceBlank(dto.rowspanStr))//合并行的字段 |
|
1942 |
.replaceAll("@totalCols", this.replaceBlank(dto.totalCols))//统计列 |
|
1943 |
.replaceAll("@rowcopyfields", dto.rowcopyfields == null ? "" : this.replaceBlank(dto.rowcopyfields)) |
|
1944 |
.replaceAll("@rowcopyformids", dto.rowcopyformids == null ? "" : this.replaceBlank(dto.rowcopyformids)) |
|
1945 |
.replaceAll("@t302", dto.winType == 302 ? true + "" : false + "")//302类型 |
|
1946 |
.replaceAll("@t15", (dto.winType == 15 && dto.conNum == 1) ? true + "" : false + "")//15类型中单击查询第二个grid |
|
1947 |
.replaceAll("@gType", (dto.tabPage > 0) ? ((dto.tabPage == 77 || dto.tabPage == 7) ? "77" : (dto.b497 ? 497 : 499) + "") : dto.winType + "")//当前grid的窗体类型 |
|
1948 |
.replaceAll("@Disabled", (dto.winType == 18 && dto.gantt) ? "GanttDisabled=\"2\"" : "") |
|
1949 |
.replaceAll("@glcodefield", dto.glcodefield == null ? "" : dto.glcodefield + "") |
|
1950 |
.replaceAll("@treefield", this.replaceBlank(dto.treefield))//用在格线对应字段没设置初始值时,需要从树里取得值,所以需要在这里 |
|
1951 |
.replaceAll("@expr", this.replaceBlank(dto.expr.replaceAll("<", "<").replaceAll(">", ">"))) |
|
1952 |
.replaceAll("@css", this.replaceBlank(dto.cspr)) |
|
1953 |
.replaceAll("@tips", this.replaceBlank(dto.tipspr)) |
|
1954 |
.replaceAll("@tolkey", this.replaceBlank(dto.tolkey)) |
|
1955 |
.replaceAll("@colns", this.replaceBlank(dto.columns)) |
|
1956 |
.replaceAll("@MainCol", (dto.mainCol == null || "".equalsIgnoreCase(dto.mainCol)) ? "" : "MainCol='" + dto.mainCol.toLowerCase() + "'") |
|
1957 |
.replaceAll("@isNine", ((dto.othType > 0) && i == 0) ? ("/" + dto.verNo + dto.formID + "/" + dto.othType + "/index.jsp") : "null")//双击打开 |
|
1958 |
.replaceAll("@nineType", dto.othType + "")////双击打开页面指定的类型 |
|
1959 |
.replaceAll("@keyid", (dto.b499 || dto.b497) ? (dto.masterKey.trim().equalsIgnoreCase(",") ? "" : dto.masterKey.trim()) : (dto.masterKey + "," + dto.detailKey).trim().equalsIgnoreCase(",") ? "" : (dto.masterKey + "," + dto.detailKey)) |
|
1960 |
.replaceAll("@Sorting", (dto.lockGridSort == 0 ? 1 : 0) + "")//取相反值,因为是冻结排序 |
|
1961 |
.replaceAll("@Sort", this.replaceBlank(this.setOrderBy(dto)))//主键列,可以有多个,以"|"分隔 |
|
1962 |
.replaceAll("@foot", this.replaceBlank(dto.foot))//汇总列 |
|
1963 |
.replaceAll("@panelID", dto.PriIndex + "")//针对77类型取哪一个面板数据进行过滤 |
|
1964 |
.replaceAll("@ycadd", this.setToolAdd(dto) == 2 ? "Add, " : "")//清单和查询页面不需要增行和删行 |
|
1965 |
.replaceAll("@predocstatus", dto.predocstatus + "")//确认前状态值 |
493df4
|
1966 |
.replaceAll("@postdocstatus", dto.postDocStatus + "")//确认后状态值 |
a6a76f
|
1967 |
.replaceAll("@Columns", dto.colset == 1 ? "Columns," : "")//列过滤 |
F |
1968 |
.replaceAll("@Actions", dto.actions)// |
|
1969 |
.replace("@Tree", (dto.conNum == 0 || (dto.mainCol == null || "".equalsIgnoreCase(dto.mainCol))) ? "" : " AddChild,")// |
|
1970 |
.replace("@isTree", (dto.conNum == 0 || (dto.mainCol == null || "".equalsIgnoreCase(dto.mainCol))) ? "0" : "1") |
|
1971 |
.replace("@formTabName", dto.formTabName) |
|
1972 |
.replaceAll("@primeKey", (dto.primeKey == null || "".equalsIgnoreCase(dto.primeKey)) ? "" : dto.primeKey + ";") |
|
1973 |
.replaceAll("@Filter", (dto.isFilter == 1) ? dto.filter.append(" />").toString() : "")//DIV |
|
1974 |
.replaceAll("@defaultRowCount", dto.order == 2 ? dto.defaultRowCount + "" : "0")//格线默认行数 |
|
1975 |
.replaceAll("@gltotal", this.replaceBlank(dto.gltotal));//辅助核算需要的汇兑,平衡字段 |
|
1976 |
strJs = strJs |
|
1977 |
.replaceAll("@dataformid", (i == 0) ? (dto.dataformid != "" ? "&dataformid=" + this.replaceBlank(dto.dataformid) : "") : "")//dataformid功能,i==0表示只有单据清单才需要过滤 |
|
1978 |
|
|
1979 |
.replaceAll("@tranformid", (dto.tranformid != "" ? "&tranformid=" + this.replaceBlank(dto.tranformid) : ""))//dataformid功能,确认时候调用来断定 |
|
1980 |
.replaceAll("@action", dto.action) |
|
1981 |
.replaceAll("@lang", ver[ver.length - 1])//语言 |
|
1982 |
.replaceAll("@foot2", this.replaceBlank(dto.foot2)) |
|
1983 |
.replaceAll("@_ycaddnew_@", this.setToolAddForNew(dto))//当前用户是否存在OA审核按钮,其中有为1的则格线需要显示增行按钮 |
|
1984 |
//.replaceAll("@_attachment_server_@", domain==null?"":domain)//附件服务器地址 |
|
1985 |
.replaceAll("@picFild", this.replaceBlank("&picFild=" + dto.picFild)) |
|
1986 |
.replaceAll("@TBCols", "&tbCols=" + EncodeUtil.base64Encode(this.replaceBlank(dto.totalCols)))//统计列 |
|
1987 |
.replaceAll("@initValue", this.replaceBlank(dto.initValue))//初始值 |
|
1988 |
.replaceAll("@verNo", this.replaceBlank(dto.verNo))//系统号+版本号+语言 |
|
1989 |
.replaceAll("@setInfo", this.replaceBlank(dto.setInfo_dy.length() > 0 ? (dto.setInfo.length() > 0 ? dto.setInfo + "," + dto.setInfo_dy : dto.setInfo_dy) : dto.setInfo))//会话信息 |
|
1990 |
.replaceAll("@optype", this.replaceBlank(dto.optype + ""))//权限信息 |
|
1991 |
.replaceAll("@num", setGridNum(dto)) |
|
1992 |
.replaceAll("@fileTime", this.setFilePath(path.replaceAll("\\\\", "/"), this.setJsName(dto), pst, dto)) |
|
1993 |
.replaceAll("@divID", "T_" + dto.formID)//div所在的id |
|
1994 |
.replaceAll("@trangroup", dto.trangroup)//过帐类型 |
|
1995 |
.replaceAll("@layout", this.setJsName(dto))//js文件名称 |
|
1996 |
.replaceAll("@hasGrid", hasGrid)//js文件名称 |
|
1997 |
.replaceAll("@isTree", (dto.mainCol == null || "".equalsIgnoreCase(dto.mainCol)) ? "" : "&isTree=1") |
|
1998 |
.replaceAll("@winType", dto.winType + "@p@" + i)//表的顺序 0表示读取主表 1表示读取从表 |
|
1999 |
.replaceAll("@id", dto.formID + "")//功能号 |
|
2000 |
.replaceAll("@DealAfterDocSave", ddsave)//保存时执行 |
|
2001 |
.replaceAll("@CancelProc", "&cancelProc=" + this.replaceBlank(EncodeUtil.base64Encode(dto.cancelProc)) + "&cancelisSave=" + dto.cancelisSave + "&isExchangeDataWithHost=" + dto.isExchangeDataWithHost)//取消确认 |
|
2002 |
.replaceAll("@revokeProc", "&revokeProc=" + this.replaceBlank(EncodeUtil.base64Encode(dto.revokeProc)))//审核撤回 |
|
2003 |
.replaceAll("@pageSize", this.replaceBlank(dto.pageSize + ""))// |
|
2004 |
.replaceAll("@paging", "&autopaging=" + this.replaceBlank((dto.autopaging == 1 ? 3 : 2) + ""))// |
|
2005 |
.replaceAll("@formdatafilters", this.replaceBlank(i == 0 ? dto.formdatafilters.replaceAll("'", "\\\\'").replaceAll("%", "@~") : ""))//i==0表示只有单据清单才需要过滤 |
|
2006 |
.replaceAll("@ProcGroupafterSavedoc", (dto.othType > 0 && i > 0 && dto.ProcGroupafterSavedoc != null && dto.ProcGroupafterSavedoc.trim().length() > 0) ? "&ProcGroupafterSavedoc=" + dto.ProcGroupafterSavedoc : ""); |
|
2007 |
String tableType = null; |
|
2008 |
try { |
|
2009 |
SpObserver.setDBtoInstance("_" + dto.dbid); |
|
2010 |
tableType = this.gridService.getSimpleJdbcTemplate().queryForObject("select TABLE_TYPE from information_schema.TABLES where table_name=?", new Object[]{dto.table.split("\\|")[0]}, String.class); |
|
2011 |
} catch (DataAccessException e) { |
|
2012 |
if (e instanceof EmptyResultDataAccessException) { |
|
2013 |
tableType = ""; |
|
2014 |
} else { |
|
2015 |
throw e; |
|
2016 |
} |
|
2017 |
|
|
2018 |
} finally { |
|
2019 |
SpObserver.setDBtoInstance(); |
|
2020 |
} |
|
2021 |
if (dto.conNum != 0 && ("BASE TABLE".equals(tableType) || "VIEW".equals(tableType))) {//表示为基本表,需要有主键 |
|
2022 |
if ((dto.primeKey == null || "".equalsIgnoreCase(dto.primeKey))) |
|
2023 |
throw new ApplicationException(dto.formID + "-" + dto.table + "表没有设置主键!"); |
|
2024 |
} |
|
2025 |
|
|
2026 |
//-------------------- |
|
2027 |
String hi = this.setGridHight(dto); |
ac6f6a
|
2028 |
dto.headerDiv = "\n<div id=\"T_" + dto.formID + "\" style=\"margin:5px 10px 0px 10px;width: 98%; height: " + hi + ";" + ((dto.b497 && dto.PriFormID == 0 || dto.b499 && dto.PriFormID == 0) && dto.xxk == 0 ? "display:none" : "") + "\"></div>";//增加多表加载时不显示所有格线 |
a6a76f
|
2029 |
if ((i <= 1 && !dto.muilGrid) || (dto.muilGrid && i < 1 && num < 4)) {//不是多表,只需要生成一个gt-grid 单表,清单表(二表,三表,多表) |
F |
2030 |
if ((dto.winType != 7 && dto.winType != 77) && (dto.b497 && dto.PriFormID == -1 || dto.b499 && dto.PriFormID == -1)) {//表示496,498多表的第一个表 |
|
2031 |
int value = Integer.parseInt(dto.tolkey); |
|
2032 |
String create = ""; |
|
2033 |
for (int v = 1; v <= value; v++) |
|
2034 |
create += "create" + v + "(where,flag,cp);";//为了引用其它grid,3表 |
|
2035 |
strJs = strJs.replaceAll("@create", create); |
|
2036 |
} else { |
|
2037 |
if (dto.winType == 15) {//表示15类型的第二表需要增加一个定时执行功能,以便处理第三表的过滤问题 |
|
2038 |
//create1(where,flag,cp); |
|
2039 |
if (i == 1) { |
|
2040 |
strJs = strJs.replaceAll("@create", "var def=jQuery.Deferred();\n setTimeout(function() {def.resolve('ok');}, 3000);"); |
|
2041 |
|
|
2042 |
} |
|
2043 |
} |
|
2044 |
//前端处理,通过从表调用过滤 避免主表还没加载完的情况 by danaus 2021/1/28 16:05 |
|
2045 |
// else if (dto.b497) {//表示多表增加一个定时执行功能,以便处理关联表的过滤问题 |
|
2046 |
// strJs = strJs.replaceAll("@create", "setTimeout(function() {mygrid" + setGridNum(dto) + ".setFilter496();}, 3000);"); |
|
2047 |
// } |
|
2048 |
strJs = strJs.replaceAll("@create", ""); |
|
2049 |
|
|
2050 |
} |
|
2051 |
str = str |
|
2052 |
.replaceAll("@main", strJs) |
|
2053 |
.replaceAll("@head", dto.headerDiv)//DIV |
|
2054 |
.replaceAll("@suggstDiv", dto.sugList.toString())//自动补全 |
|
2055 |
.replaceAll("@gridconnum", String.valueOf(dto.conNum));//判断单表用来计算grid高度需要。。。替换grid.jsp里面的@gridconnum |
|
2056 |
FileUtil.writeFile(js, root.replaceAll("\\\\", "/") + File.separatorChar + this.setFilePath(path.replaceAll("\\\\", "/"), this.setJsName(dto), pst, dto));//生成新页面js |
|
2057 |
FileUtil.writeFile(str, root.replaceAll("\\\\", "/") + File.separatorChar + this.setFilePath(path.replaceAll("\\\\", "/"), fileName[0], pst, dto));//生成新页面 |
|
2058 |
} else {//多表,整个页面生成多个表格 |
|
2059 |
if (refgrid != "") refgrid += ","; |
|
2060 |
refgrid += ("T_" + dto.formID);//为了引用其它grid,3表 |
|
2061 |
if (!"".equalsIgnoreCase(setGridNum(dto))) { |
|
2062 |
if (dto.winType == 15) {//表示15类型的第二表需要增加一个定时执行功能,以便处理第三表的过滤问题 |
|
2063 |
if (i == 2) { |
|
2064 |
strJs = strJs.replaceAll("@create", " var def=jQuery.Deferred(); \n setTimeout(function() { def.resolve('ok');}, 3000);"); |
|
2065 |
strJs = strJs.replaceAll("@jspromise", " return def;"); |
|
2066 |
} |
|
2067 |
} |
|
2068 |
|
|
2069 |
strJs = strJs.replaceAll("@create", ""); |
|
2070 |
|
|
2071 |
//create+="setTimeout(function() {create"+setGridNum()+"(where,flag,cp);}, 1000);"; |
|
2072 |
if (Integer.parseInt(setGridNum(dto)) == 1 && dto.winType == 15) { |
|
2073 |
// dto.create+=" setTimeout(function() {create"+setGridNum(dto)+"(where,flag,cp);}, 500);"; |
|
2074 |
dto.create += " var def=jQuery.Deferred(); setTimeout(function() {def.resolve('ok');}, 2000);"; |
|
2075 |
|
|
2076 |
} else |
|
2077 |
dto.create += "create" + setGridNum(dto) + "(where,flag,cp);";//为了引用其它grid,3表 |
|
2078 |
|
|
2079 |
} |
|
2080 |
main.append(strJs).append("\n"); |
|
2081 |
hd.append(dto.headerDiv).append("\n"); |
|
2082 |
|
|
2083 |
FileUtil.writeFile(js, root.replaceAll("\\\\", "/") + File.separatorChar + this.setFilePath(path.replaceAll("\\\\", "/"), this.setJsName(dto), pst, dto));//生成各个表的js |
|
2084 |
} |
|
2085 |
dto.gfields = null; |
|
2086 |
} catch (Exception e) { |
|
2087 |
throw new ApplicationException(e.toString()); |
|
2088 |
} |
|
2089 |
} |
|
2090 |
if (dto.muilGrid && dto.conNum > 1) {//多表,需要把几个gt-grid生成在同一个页面 |
|
2091 |
String strd = jsp.toString() |
|
2092 |
|
|
2093 |
.replaceAll("@main", main.toString().replaceAll("@refgrid", refgrid)).replaceAll("@create", dto.create) |
|
2094 |
.replaceAll("@head", hd.toString())//自定义表头 |
|
2095 |
.replaceAll("@suggstDiv", dto.sugList.toString())//自动补全 |
|
2096 |
.replaceAll("@gridconnum", String.valueOf(dto.conNum));//判断多表用来计算grid高度需要。。。替换grid.jsp里面的@gridconnum |
|
2097 |
FileUtil.writeFile(strd, root.replaceAll("\\\\", "/") + this.setFilePath(path.replaceAll("\\\\", "/"), fileName[0], pst, dto));//生成新页面 |
|
2098 |
} |
|
2099 |
sb = null; |
|
2100 |
jsp = null; |
|
2101 |
main = null; |
|
2102 |
hd = null; |
|
2103 |
} catch (DataAccessException e) { |
|
2104 |
throw new ApplicationException(e.toString()); |
|
2105 |
} |
|
2106 |
} |
|
2107 |
|
|
2108 |
/** |
|
2109 |
* 解决5,9 16,17 8,15的关联生成问题 |
|
2110 |
* |
|
2111 |
* @param root TODO |
|
2112 |
**/ |
|
2113 |
private String setFilePath(String p, String name, String root, TreeGridDTO dto) { |
|
2114 |
StringBuilder sb = new StringBuilder(); |
|
2115 |
if (!dto.b497 || !dto.b499) |
|
2116 |
root = sb.append("/").append(dto.minID == 0 ? dto.formID : dto.minID).append("/").append(dto.conNum == 0 ? dto.winType : dto.othType).append("/").toString(); |
|
2117 |
return new StringBuilder().append(p).append(root).append(name).toString(); |
|
2118 |
} |
|
2119 |
|
|
2120 |
/** |
|
2121 |
* 根据当前grid的次数而生成需要的标记,以区别同一页面不同grid的引用 |
|
2122 |
*/ |
|
2123 |
private String setGridNum(TreeGridDTO dto) { |
|
2124 |
if (dto.b497 || dto.b499) |
|
2125 |
return dto.PriIndex == 0 ? "" : dto.PriIndex + ""; |
|
2126 |
else |
|
2127 |
return dto.conNum <= 1 ? "" : (dto.conNum - 1) + ""; |
|
2128 |
} |
|
2129 |
|
|
2130 |
@Override |
|
2131 |
public void setTabPage(int type, int height1, String indexs, String tolkey, int formid, int index, TreeGridDTO dto) { |
|
2132 |
dto.tabPage = type; |
|
2133 |
dto.gridHeight = height1; |
|
2134 |
dto.masterKey = indexs; |
|
2135 |
dto.b497 = true; |
|
2136 |
dto.tolkey = tolkey; |
|
2137 |
dto.PriFormID = formid;//取得主功能号里面的排除功能号和字段列表用 by 11-5-28 |
|
2138 |
dto.PriIndex = index; |
|
2139 |
} |
|
2140 |
|
|
2141 |
@Override |
|
2142 |
public Grid getGridInfo(int formid, String type, boolean excel, TreeGridDTO dto) { |
|
2143 |
Grid grid = new Grid(); |
|
2144 |
this.getTableName(formid, type, dto);//type:"9|0" |
|
2145 |
grid.setFormID(formid); |
|
2146 |
grid.setWinType(type); |
|
2147 |
String ddsave = ""; |
|
2148 |
grid.setExcel(excel); |
|
2149 |
try { |
|
2150 |
if (dto.DealAfterDocSave != null && dto.DealAfterDocSave.trim().length() > 0) |
|
2151 |
ddsave = EncodeUtil.base64Encode(dto.DealAfterDocSave); |
|
2152 |
} catch (UnsupportedEncodingException e) { |
|
2153 |
throw new ApplicationException("加密保存后执行组出错-" + dto.DealAfterDocSave); |
|
2154 |
} |
|
2155 |
grid.setDealAfterDocSave(ddsave); |
|
2156 |
if (dto.ProcGroupafterSavedoc != null && !"".equals(dto.ProcGroupafterSavedoc)) { |
|
2157 |
grid.setProcGroupafterSavedoc(Integer.parseInt(dto.ProcGroupafterSavedoc)); |
|
2158 |
} |
|
2159 |
grid.setTrangroup(dto.trangroup);//过账逻辑号 |
|
2160 |
return grid; |
|
2161 |
} |
|
2162 |
|
|
2163 |
@Override |
|
2164 |
public void setXxk(int xxk, TreeGridDTO dto) { |
|
2165 |
// TODO Auto-generated method stub |
|
2166 |
dto.xxk = xxk; |
|
2167 |
} |
|
2168 |
} |