Aggregation.newAggregation( Aggregation.match(criteria), Aggregation.project("createtime") .andExpression("substr(createtime,0,7)").as("month") .andExpression("{$toDouble: '$aa'}").as("aa"), Aggregation.group("subsn","month") .sum("aa").as("aa")
通过.andExpression("{$toDouble: '$aa'}").as("aa")方式 将名字为aa的字段由字符转换成double类型,如此在使用sum函数时候不会出现为0的情况