/** * 计算@SYSDT公式 * * @param cf * @return */ public String eval_SYSDT(String cf) { String regex = "@SYSDT\\(\"[yMdhmsiH年月日时分秒: -]*\"\\)"; // 匹配@VALUE公式 Pattern p = Pattern.compile(regex); Matcher mt = p.matcher(cf); while (mt.find()) { String group = mt.group(); String fm = group.substring(group.indexOf("\"") + 1, group.lastIndexOf("\"")); String dt = DateUtils.getDate(fm); cf = mt.replaceFirst("\"" + dt + "\""); mt = p.matcher(cf); } return cf; }
/** 描述:初始化起始时间到终止时间之间的每天的值 时间:2010-5-5 作者:童贝 参数:keyMap 查询条件集合,flflag 分类标识,item 选择的字段 返回值: 抛出异常: */ public List<Map<String, String>> initQssjToZzsjData( Map<String, String> keyMap, String flflag, String item) { List<Map<String, String>> result = new ArrayList<Map<String, String>>(); String startNian = keyMap.get(TjInterFace.SNIAN); String startYue = keyMap.get(TjInterFace.SYUE); String startRi = keyMap.get(TjInterFace.SRI); String endNian = keyMap.get(TjInterFace.ENIAN); String endYue = keyMap.get(TjInterFace.EYUE); String endRi = keyMap.get(TjInterFace.ERI); if ("1".equals(flflag)) { while (true) { if (startNian.equals(endNian) && startYue.equals(endYue)) { int start = new Integer(startRi); int end = new Integer(endRi); for (int i = start; i <= end; i++) { Map<String, String> map = new HashMap<String, String>(); map.put(TjInterFace.NIAN, startNian); map.put(TjInterFace.YUE, startYue); map.put(TjInterFace.RI, i + ""); map.put(item, "0"); result.add(map); } break; } else { int start = new Integer(startRi); // 本月的最后一天 String lastDate = DateUtils.getLastDate(startNian + "-" + startYue + "-1"); String endDate = DateUtils.getDate(DateUtils.StrToDate(lastDate, ""), "dd"); endDate = (endDate.charAt(0) == '0' ? endDate.substring(1) : endDate); int end = new Integer(endDate); for (int i = start; i <= end; i++) { Map<String, String> map = new HashMap<String, String>(); map.put(TjInterFace.NIAN, startNian); map.put(TjInterFace.YUE, startYue); map.put(TjInterFace.RI, i + ""); map.put(item, "0"); result.add(map); } // 把日期往后推一个月 Date curDate = DateUtils.StrToDate(startNian + "-" + startYue + "-" + startRi, "yyyy-MM-dd"); String nextDate = DateUtils.getNextDate(curDate, 1, "yyyy-MM-dd"); startNian = DateUtils.getDate(DateUtils.StrToDate(nextDate, ""), "yyyy"); startYue = DateUtils.getDate(DateUtils.StrToDate(nextDate, ""), "MM"); startYue = (startYue.charAt(0) == '0' ? startYue.substring(1) : startYue); startRi = "1"; } } } else if ("2".equals(flflag)) { while (true) { if (startNian.equals(endNian)) { int start = new Integer(startYue); int end = new Integer(endYue); for (int i = start; i <= end; i++) { Map<String, String> map = new HashMap<String, String>(); map.put(TjInterFace.NIAN, startNian); map.put(TjInterFace.YUE, i + ""); map.put(item, "0"); result.add(map); } break; } else { int start = new Integer(startYue); int end = 12; for (int i = start; i <= end; i++) { Map<String, String> map = new HashMap<String, String>(); map.put(TjInterFace.NIAN, startNian); map.put(TjInterFace.YUE, i + ""); map.put(item, "0"); result.add(map); } // 直接是下一年 startNian = new Integer(new Integer(startNian) + 1).toString(); // 下一年的第一个月 startYue = "1"; } } } else if ("3".equals(flflag)) { int start = new Integer(startNian); int end = new Integer(endNian); for (int i = start; i <= end; i++) { Map<String, String> map = new HashMap<String, String>(); map.put(TjInterFace.NIAN, i + ""); map.put(item, "0"); result.add(map); } } return result; }