private void processGetPreviousPeriodFunc(Map<String, String> expressionInfo, List<Condition> conditionList) { String expressionFunc = expressionInfo.get(this.expression); if (expressionFunc != null && expressionFunc.contains("getPreviousPeriod")) { String regex = "(getPreviousPeriod\\()([\\,\\+\\-\\*\\/\\(\\)_A-Za-z0-9\\u4e00-\\u9fa5\\.]+)(,)([0-9]+)"; Pattern pattern = Pattern.compile(regex); Matcher matcher = pattern.matcher(expressionFunc);//getPreviousPeriod(sum(Fields.prime_cost_07),1) for (; matcher.find(); ) { String expression = matcher.group(2); String tbAndHbNum = matcher.group(4);//分组字段,1代表同比,2代表环比 for (int i = 0; i < conditionList.size(); i++) { Condition condition = conditionList.get(i); if (condition.getDataType().contains("date")) { if (condition.getValues() != null && condition.getValues().size() == 1) { String currDate = condition.getValues().get(0); if ("1".equals(tbAndHbNum)) {//同比 currDate = DateUtil.yearAddNum(currDate, -1); } else if ("2".equals(tbAndHbNum)) {//环比 currDate = DateUtil.monthAddNum(currDate, -1); } condition.getValues().set(0, currDate); condition.setValue(currDate); } } } expressionInfo.put(this.expression, expression); return; } } }
原文地址:https://www.cnblogs.com/zzq-include/p/12640951.html
时间: 2024-10-19 15:10:14