码迷,mamicode.com
首页 > 其他好文 > 详细

虽然垃圾,以后用得到在翻一翻,优化下

时间:2020-04-06 11:54:26      阅读:69      评论:0      收藏:0      [点我收藏+]

标签:set   UNC   分组   bsp   mat   period   contain   oid   ring   

 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;
            }
        }

    }

 

虽然垃圾,以后用得到在翻一翻,优化下

标签:set   UNC   分组   bsp   mat   period   contain   oid   ring   

原文地址:https://www.cnblogs.com/zzq-include/p/12640951.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!