/* * Decompiled with CFR 0.152. * * Could not load the following classes: * cn.sinobest.framework.comm.Environment * cn.sinobest.framework.comm.exception.AppException * cn.sinobest.framework.comm.iface.IDAO * cn.sinobest.framework.comm.iface.IDTO * cn.sinobest.framework.security.SecurityDes * cn.sinobest.framework.service.tags.Glt * cn.sinobest.framework.service.tags.GltService * cn.sinobest.framework.service.tags.Gt * cn.sinobest.framework.service.tags.Gt$GtType * cn.sinobest.framework.service.tags.GtService$DictComparator * cn.sinobest.framework.util.ConfUtil * cn.sinobest.framework.util.Util * com.opensymphony.xwork2.util.ValueStack * org.apache.commons.lang3.StringUtils * org.apache.struts2.ServletActionContext * org.springframework.beans.BeanUtils * org.springframework.beans.factory.annotation.Autowired * org.springframework.stereotype.Service */ package cn.sinobest.framework.service.tags; import cn.sinobest.framework.comm.Environment; import cn.sinobest.framework.comm.exception.AppException; import cn.sinobest.framework.comm.iface.IDAO; import cn.sinobest.framework.comm.iface.IDTO; import cn.sinobest.framework.security.SecurityDes; import cn.sinobest.framework.service.tags.Glt; import cn.sinobest.framework.service.tags.GltService; import cn.sinobest.framework.service.tags.Gt; import cn.sinobest.framework.service.tags.GtService; import cn.sinobest.framework.util.ConfUtil; import cn.sinobest.framework.util.Util; import com.opensymphony.xwork2.util.ValueStack; import java.lang.reflect.Array; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; import java.util.Collections; import java.util.HashMap; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import org.apache.commons.lang3.StringUtils; import org.apache.struts2.ServletActionContext; import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @Service public class GtService { @Autowired IDAO commDAO; @Autowired GltService gltService; private static final DictComparator DICTCOMPARATOR = new DictComparator(); private static final String EMPTY_STR = " "; private static final String LABEL = "label"; private static final String TYPE = "type"; private static final String COLSPAN = "colspan"; private static final String ROWSPAN = "rowspan"; private static final String PNAME = "pname"; private static final String DNAME = "dname"; private static final String GT = "gt"; public static List parseHiddenStr(String source) { if (source == null || source.trim().length() == 0) { return null; } return Arrays.asList(source.split("\\|")); } private static Map extractLabel8Composite(Map source) { HashMap labelCompoment = new HashMap(source); labelCompoment.put(TYPE, Gt.GtType.LABEL); labelCompoment.remove(PNAME); int i_colspan = (Integer)source.get(COLSPAN); switch (i_colspan) { case 0: { break; } default: { labelCompoment.put(COLSPAN, 1); } } return labelCompoment; } public List>>> parseRenderStr(String source) throws AppException { ArrayList>>> row_list = null; if (source == null || source.trim().length() == 0) { return null; } String nnVld = ConfUtil.getSysParam((String)"VLD_NN_STYLE", (String)"v1"); source = source.replaceAll("\n", ""); String[] rows = source.split("\\|\\|"); row_list = new ArrayList>>>(rows.length); int i = 0; while (i < rows.length) { String[] cols = rows[i].split("\\|"); ArrayList column_list = new ArrayList(cols.length); ArrayList> compoment_list = new ArrayList>(1); int j = 0; while (j < cols.length) { Map labelCompoment; HashMap col_rst = new HashMap(); String[] attrs = cols[j].split("\\*"); int k = 0; while (k < attrs.length) { String attr = attrs[k]; int pos = attr.indexOf(61); if (pos == -1) { throw new AppException("EFW0107", null, new Object[]{attr}); } col_rst.put(attr.substring(0, pos).trim(), attr.substring(pos + 1).trim()); ++k; } if (!col_rst.containsKey(TYPE)) { throw new AppException("EFW0108", null, new Object[]{cols[j]}); } String type = col_rst.get(TYPE).toString(); if ("05q".equals(type) && !col_rst.containsKey("initshow")) { col_rst.put("initshow", Environment.getDefaultGt05qShow()); } if (type.length() > 2) { col_rst.put("subtype", type.substring(2)); } else if (type.length() != 2) { throw new AppException("EFW0109", null, new Object[]{type}); } Gt.GtType t = Gt.GtType.valueOfCode((String)type.substring(0, 2)); col_rst.put(TYPE, t); t.evalExt(col_rst); if (Gt.GtType.NESTTABLE == t) { Gt nestGt = this.getGt((String)col_rst.get(GT), ""); col_rst.put(GT, nestGt); } if (!col_rst.containsKey(ROWSPAN)) { col_rst.put(ROWSPAN, 1); } else { try { int i_rowspan = Integer.parseInt((String)col_rst.get(ROWSPAN)); if (i_rowspan == 0) { throw new AppException("EFW0110", null, new Object[]{cols[j]}); } col_rst.put(ROWSPAN, i_rowspan); } catch (NumberFormatException numberFormatException) { throw new AppException("EFW0111", null, new Object[]{cols[j]}); } } if (!col_rst.containsKey(COLSPAN)) { col_rst.put(COLSPAN, 1); } else { try { int i_colspan = Integer.parseInt((String)col_rst.get(COLSPAN)); if (i_colspan == 0 && j == 0) { throw new AppException("EFW0112", null, new Object[]{cols[j]}); } col_rst.put(COLSPAN, i_colspan); } catch (NumberFormatException numberFormatException) { throw new AppException("EFW0113", null, new Object[]{cols[j]}); } } String vld = (String)col_rst.get("vld"); col_rst.put("nClass", ""); if (!Util.isEmpty((String)vld)) { String[] vldStrs; if (vld.indexOf("nn") > -1) { if (nnVld.equals("v1")) { col_rst.put("nClass", "tdprompt_n"); } else if (nnVld.equals("v2")) { col_rst.put("nClass", "tdprompt_n_v2"); } else if (nnVld.equals("v3")) { col_rst.put("nClass", "tdprompt_n_v3"); } } if (vld.indexOf("sn") > -1) { col_rst.put("nClass", "tdprompt_sn"); } String[] name_validStrs = vld.split("="); String vldStr = vld; if (name_validStrs.length == 2) { vldStr = name_validStrs[1]; } String[] stringArray = vldStrs = vldStr.split("\\+"); int n = vldStrs.length; int n2 = 0; while (n2 < n) { String validateStr = stringArray[n2]; if (validateStr.startsWith("l") && col_rst.get("maxlength") == null) { int pos1 = validateStr.indexOf("("); int pos2 = validateStr.indexOf("-"); int pos3 = validateStr.indexOf(")"); String bitL2 = ""; bitL2 = pos2 != -1 ? validateStr.substring(pos2 + 1, pos3) : validateStr.substring(pos1 + 1, pos3); if (!Util.isEmpty((String)bitL2)) { col_rst.put("maxlength", bitL2); } } ++n2; } } if ((Integer)col_rst.get(COLSPAN) != 0) { if (t.isComposite() && col_rst.containsKey(LABEL)) { compoment_list = new ArrayList(1); labelCompoment = GtService.extractLabel8Composite(col_rst); compoment_list.add(labelCompoment); column_list.add(compoment_list); } compoment_list = new ArrayList(1); compoment_list.add(col_rst); column_list.add(compoment_list); } else { if (t.isComposite() && col_rst.containsKey(LABEL)) { labelCompoment = GtService.extractLabel8Composite(col_rst); compoment_list.add(labelCompoment); } compoment_list.add(col_rst); } ++j; } row_list.add(column_list); ++i; } return row_list; } private static int compomentColSpan(Map compoment) { return (Integer)compoment.get(COLSPAN); } private static int compomentRowSpan(Map compoment) { return (Integer)compoment.get(ROWSPAN); } public static void fillCollumn(Gt gt) { int rowIndex = 0; List renders = gt.getRenders(); int[] colNums = new int[renders.size()]; for (List row : renders) { for (List col : row) { int colSpan = GtService.compomentColSpan((Map)col.get(0)); int rowSpan = GtService.compomentRowSpan((Map)col.get(0)); if (rowSpan + rowIndex > colNums.length) { throw new AppException("EFW0114", null, new Object[]{rowSpan}); } int tmpColNum = 0; while (tmpColNum < rowSpan) { int n = rowIndex + tmpColNum; colNums[n] = colNums[n] + colSpan; ++tmpColNum; } } ++rowIndex; } int maxColNum = 0; int[] nArray = colNums; int n = colNums.length; int col = 0; while (col < n) { int iColNum = nArray[col]; maxColNum = Math.max(maxColNum, iColNum); ++col; } gt.setColNum(maxColNum); rowIndex = 0; while (rowIndex < colNums.length) { if (colNums[rowIndex] != maxColNum) { ArrayList empty_td_list = new ArrayList(1); HashMap empty_td = new HashMap(); empty_td.put(LABEL, EMPTY_STR); empty_td.put(COLSPAN, maxColNum - colNums[rowIndex]); empty_td.put(TYPE, Gt.GtType.LABEL); empty_td.put(ROWSPAN, 1); empty_td_list.add(empty_td); ((List)renders.get(rowIndex)).add(empty_td_list); } ++rowIndex; } } public static String parseWhereCls(String whereCls, String query) { return whereCls.replace("?", query.replaceAll("'", "''")); } public Map prepareGlt(Gt gt, Map whereClsMap, Map valueMap, Map gltMap) throws AppException { if (gltMap == null) { gltMap = new HashMap(); } if (whereClsMap == null) { whereClsMap = Collections.EMPTY_MAP; } for (List row : gt.getRenders()) { for (List col : row) { for (Map comp : col) { Object tmp_code; String glt_id; if (Gt.GtType.NESTTABLE == comp.get(TYPE)) { gltMap.putAll(this.prepareGlt((Gt)comp.get(GT), whereClsMap, valueMap, gltMap)); continue; } if (Gt.GtType.COMBOBOX != comp.get(TYPE) && Gt.GtType.INPUT != comp.get(TYPE) && Gt.GtType.TEXTAREA != comp.get(TYPE) || !"q".equals(comp.get("subtype")) || gltMap.containsKey(glt_id = (String)comp.get("glt"))) continue; Glt glt_conf = null; Object[] comp_glt = new Object[2]; gltMap.put(glt_id, comp_glt); glt_conf = this.gltService.getGlt(glt_id, ""); comp_glt[0] = glt_conf; if (valueMap.get(comp.get(PNAME)) == null || (tmp_code = valueMap.get(comp.get(PNAME))) == null) continue; String code = null; if (tmp_code.getClass().isArray()) { if (Array.getLength(tmp_code) == 0 || Array.get(tmp_code, 0) == null) continue; code = Array.get(tmp_code, 0).toString(); } else { code = tmp_code.toString(); } if ("u".equals(glt_conf.getType())) continue; String whereCls = (String)whereClsMap.get(glt_id); whereCls = whereCls == null ? "1=1" : GtService.parseWhereCls((String)whereClsMap.get(glt_id), code); List rows = this.gltService.getRowData(glt_conf, whereCls, whereClsMap, 1, 1); if (row == null || row.isEmpty()) continue; comp_glt[1] = rows.get(0); } } } return gltMap; } public Map>> getDicts(Gt gt, Map datas, Map whereClsMap, Map>> dictsMap) throws AppException { if (dictsMap == null) { dictsMap = new HashMap>>(); } if (whereClsMap == null) { whereClsMap = Collections.EMPTY_MAP; } for (List row : gt.getRenders()) { for (List col : row) { for (Map comp : col) { String value; if (Gt.GtType.NESTTABLE == comp.get(TYPE)) { this.getDicts((Gt)comp.get(GT), datas, whereClsMap, dictsMap); continue; } if (!comp.containsKey(DNAME) || dictsMap.containsKey(value = (String)comp.get(DNAME))) continue; Map dictMap = null; if (value.startsWith("dyndict_")) { if (datas != null && datas.containsKey(value)) { dictMap = (Map)datas.get(value); } if (dictMap == null) { dictMap = ConfUtil.getDynDict((String)value, (String)((String)whereClsMap.get(value)), (String)gt.getDsId()); } } else if (value.indexOf(64) == -1) { dictMap = ConfUtil.getDict((String)value); } else { String[] subs = value.split("\\@"); dictMap = ConfUtil.getSubDict((String)subs[0], (String)subs[1]); } if (dictMap == null) continue; dictsMap.put(value, GtService.dictSort(dictMap)); } } } return dictsMap; } public static Map> dictSort(Map> dictMap) { ArrayList> dictList = new ArrayList>(dictMap.values()); Collections.sort(dictList, DICTCOMPARATOR); dictMap = new LinkedHashMap>(); for (Map map : dictList) { dictMap.put((String)map.get("AAA102"), map); } return dictMap; } public Map getData(Gt gt, Map datas, ValueStack stack, Map defv) { Collection pnames = GtService.requiredPnames4Value(gt, null); HashMap rst = new HashMap(pnames.size(), 1.0f); for (String key : pnames) { if (datas != null && datas.containsKey(key)) { rst.put(key, datas.get(key)); continue; } Object tmp = null; if (stack != null) { tmp = stack.findValue("#parameters['" + key + "']"); } if (tmp != null) { rst.put(key, tmp); continue; } if (defv == null) continue; rst.put(key, defv.get(key)); } return rst; } public static Collection requiredPnames4Value(Gt gt, Collection collectedPnames) { if (collectedPnames == null) { collectedPnames = new ArrayList(); } if (gt.getHiddens() != null) { collectedPnames.addAll(gt.getHiddens()); } for (List row : gt.getRenders()) { for (List col : row) { for (Map comp : col) { if (Gt.GtType.NESTTABLE == comp.get(TYPE)) { GtService.requiredPnames4Value((Gt)comp.get(GT), collectedPnames); continue; } if (!comp.containsKey(PNAME) || collectedPnames.contains(comp.get(PNAME))) continue; collectedPnames.add((String)comp.get(PNAME)); if (Gt.GtType.COMBOBOX != comp.get(TYPE) || !"q".equals(comp.get("subtype"))) continue; collectedPnames.add("_DIC_" + (String)comp.get(PNAME)); } } } return collectedPnames; } public Map getInitData(String renderExtend, String id, Map datas, Map whereClsMap, Map>> dictsMap, ValueStack stack, Map defv, String dsId) { Gt gtcache = this.getGt(id, dsId); Gt gt = new Gt(); BeanUtils.copyProperties((Object)gtcache, (Object)gt); if (renderExtend != null && renderExtend.length() > 0) { gt.setRenders(this.parseRenderStr(renderExtend)); } Map>> dicts = this.getDicts(gt, datas, whereClsMap, dictsMap); Map data = this.getData(gt, datas, stack, defv); Map gtlMap = this.prepareGlt(gt, whereClsMap, data, null); HashMap args = new HashMap(3); args.put(GT, gt); args.put("dicts", dicts); args.put("data", data); args.put("gtlMap", gtlMap); args.put("actionType", gt.getActionType()); args.put("actionID", gt.getActionID()); return args; } public Gt getGt(String id, String dsId) throws AppException { if (ConfUtil.getGenTblConf((String)id) != null) { return (Gt)ConfUtil.getGenTblConf((String)id); } HashMap paramsMap = new HashMap(); paramsMap.put("ID", id); Gt gt = new Gt(); try { List rst = this.commDAO.select("FW_CONFIG.FW_GENTBL_CONF_Q", paramsMap); if (rst.isEmpty()) { throw new AppException("EFW0115", null, new Object[]{id}); } Map gt_conf = (Map)rst.get(0); gt.setId((String)gt_conf.get("ID")); gt.setDescription((String)gt_conf.get("DESCRIPTION")); gt.setRenders(this.parseRenderStr((String)gt_conf.get("RENDERSTR"))); gt.setHiddens(GtService.parseHiddenStr((String)gt_conf.get("HIDDENSTR"))); gt.setBae001((String)gt_conf.get("BAE001")); gt.setBae002((String)gt_conf.get("BAE002")); gt.setBae003((String)gt_conf.get("BAE003")); gt.setActionID((String)gt_conf.get("ACTIONID")); gt.setActionType((String)gt_conf.get("ACTIONTYPE")); if (StringUtils.isNotBlank((CharSequence)dsId)) { gt.setDsId(dsId); } } catch (AppException e) { throw e; } catch (Exception exception) { throw new AppException("EFW0116", null, new Object[]{id}); } GtService.fillCollumn(gt); ConfUtil.setGenTblConf((String)id, (Object)gt); return gt; } public boolean isSysPermitArchive() { String permitArchive = ConfUtil.getSysParamOnly((String)"permitArchive", (String)""); return permitArchive.equals("") || permitArchive.equalsIgnoreCase("true"); } public String getArchiveUrl() { return ConfUtil.getParam((String)"ARCHIVEURL", (String)""); } public boolean getHasArchive(String id) { Map dict = null; try { dict = ConfUtil.getDictKeyItemCode((String)"GT_ARCHIVE"); } catch (Exception exception) { dict = null; return false; } return dict != null && dict.get(id) != null; } public List> getFwQuerySql(IDTO dto) { String whereCls = (String)dto.getValue("WHERECLS"); String id = (String)dto.getValue("ID"); if (Environment.isEncryptWhere().booleanValue()) { String wherekey = (String)ServletActionContext.getRequest().getSession(true).getAttribute("whereCls_key"); if (Util.isEmpty((String)wherekey)) { throw new AppException("\u65e0\u6cd5\u83b7\u53d6where\u6761\u4ef6\u52a0\u5bc6\u5bc6\u94a5"); } try { SecurityDes de = new SecurityDes(); whereCls = de.des(wherekey, de.HexTostring(whereCls), false); Util.validateQueryStringSafty((String)whereCls); de = null; } catch (Exception e) { throw new AppException("\u89e3\u5bc6where\u6761\u4ef6\u51fa\u9519", e.getLocalizedMessage()); } } String dsId = ((String)Util.nvl((Object)dto.getValue("DSID"), (String)"ds")).toLowerCase(); List list = ConfUtil.getQuerySQLResult((String)id, (String)whereCls, (String)dsId); return list; } }