groovy命令行有一个参数-c 用于设定字符集,在程序中的sql里面有中文的条件,因此在linux环境下执行的时侯需用如下命令:
groovy -c GBK ThirdStat.groovy
ThirdStat.groovy的代码片段如下
groovy -c GBK ThirdStat.groovy
ThirdStat.groovy的代码片段如下
def folder_name="待冲印相册"
int i=0;
def sqlStmt="""
select yy.user_name,yy.create_time u_time,yy.needprint,oo.id oid,oo.detail_count,(case when oo.order_type=3 then 1 else (case when oo.order_type=1 then 2 else '' end) end) zzz,oo.create_time o_time from
(select uu.id,uu.user_name,uu.create_time,count(f.id) needprint from (select u.id id ,u.user_name,u.create_time from
users u join channel_user a on u.user_name=a.user_name
) uu left join folder dd on uu.id=dd.user_id left join file f on dd.id=f.folder_id
where dd.name=$folder_name group by uu.id
) yy left join orders oo on yy.id=oo.user_id
"""
sql.eachRow(sqlStmt){ row ->
......
}