| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526 |
- /*
- * 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<String> parseHiddenStr(String source) {
- if (source == null || source.trim().length() == 0) {
- return null;
- }
- return Arrays.asList(source.split("\\|"));
- }
- private static Map<String, Object> extractLabel8Composite(Map<String, Object> source) {
- HashMap<String, Object> labelCompoment = new HashMap<String, Object>(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<List<List<Map<String, Object>>>> parseRenderStr(String source) throws AppException {
- ArrayList<List<List<Map<String, Object>>>> 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<List<List<Map<String, Object>>>>(rows.length);
- int i = 0;
- while (i < rows.length) {
- String[] cols = rows[i].split("\\|");
- ArrayList column_list = new ArrayList(cols.length);
- ArrayList<Map<String, Object>> compoment_list = new ArrayList<Map<String, Object>>(1);
- int j = 0;
- while (j < cols.length) {
- Map<String, Object> labelCompoment;
- HashMap<String, Object> col_rst = new HashMap<String, Object>();
- 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<String, Object> compoment) {
- return (Integer)compoment.get(COLSPAN);
- }
- private static int compomentRowSpan(Map<String, Object> 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<String, Object> empty_td = new HashMap<String, Object>();
- 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<String, Object[]> prepareGlt(Gt gt, Map<String, String> whereClsMap, Map<String, Object> valueMap, Map<String, Object[]> gltMap) throws AppException {
- if (gltMap == null) {
- gltMap = new HashMap<String, Object[]>();
- }
- 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<String, Map<String, Map<String, String>>> getDicts(Gt gt, Map<String, Object> datas, Map<String, String> whereClsMap, Map<String, Map<String, Map<String, String>>> dictsMap) throws AppException {
- if (dictsMap == null) {
- dictsMap = new HashMap<String, Map<String, Map<String, String>>>();
- }
- 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<String, Map<String, String>> dictSort(Map<String, Map<String, String>> dictMap) {
- ArrayList<Map<String, String>> dictList = new ArrayList<Map<String, String>>(dictMap.values());
- Collections.sort(dictList, DICTCOMPARATOR);
- dictMap = new LinkedHashMap<String, Map<String, String>>();
- for (Map map : dictList) {
- dictMap.put((String)map.get("AAA102"), map);
- }
- return dictMap;
- }
- public Map<String, Object> getData(Gt gt, Map<String, Object> datas, ValueStack stack, Map<String, Object> defv) {
- Collection<String> pnames = GtService.requiredPnames4Value(gt, null);
- HashMap<String, Object> rst = new HashMap<String, Object>(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<String> requiredPnames4Value(Gt gt, Collection<String> collectedPnames) {
- if (collectedPnames == null) {
- collectedPnames = new ArrayList<String>();
- }
- 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<String, Object> getInitData(String renderExtend, String id, Map<String, Object> datas, Map<String, String> whereClsMap, Map<String, Map<String, Map<String, String>>> dictsMap, ValueStack stack, Map<String, Object> 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<String, Map<String, Map<String, String>>> dicts = this.getDicts(gt, datas, whereClsMap, dictsMap);
- Map<String, Object> data = this.getData(gt, datas, stack, defv);
- Map<String, Object[]> gtlMap = this.prepareGlt(gt, whereClsMap, data, null);
- HashMap<String, Object> args = new HashMap<String, Object>(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<String, String> paramsMap = new HashMap<String, String>();
- 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<Map<String, String>> 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;
- }
- }
|