默认登录地址:
http://localhost:8080/jasperserver-pro/login.html
默认账号/密码:jasperadmin/jasperadmin
PDF中文不能打印
-
打开Jaspersoft Studio中 window-> Preferences->Jaspersoft -> fonts
-
add From Path ->C:\Windows\Fonts,将系统自带的字体添加到JasperStudio中
-
全选字体, export 将字体打包
-
将打包好的字体jar包放入JasperReports Servers lib(D:\Jaspersoft\jasperreports-server-cp-7.8.0\apache-tomcat\webapps\jasperserver\WEB-INF\lib)文件中
-
修该D:\Jaspersoft\jasperreports-server-cp-7.8.0\apache-tomcat\webapps\jasperserver\WEB-INF\classes\jasperreports.properties 文件
添加字体配置 net.sf.jasperreports.web.resource.pattern.fonts=fonts/.*
JasperReports Servers API
获取服务信息
get: http://192.168.200.73:8080/jasperserver/rest_v2/serverInfo
返回值:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<serverInfo>
<build>BUILD_DATE_STAMP_BUILD_TIME_STAMP</build>
<dateFormatPattern>yyyy-MM-dd</dateFormatPattern>
<datetimeFormatPattern>yyyy-MM-dd'T'HH:mm:ss</datetimeFormatPattern>
<edition>CE</edition>
<version>7.8.0</version>
</serverInfo>
登陆
get方式登陆例子
get:http://192.168.200.73:8080/jasperserver/rest_v2/login?j_username=jasperadmin&j_password=jasperadmin
j_username 用户名
j_password 密码
POST方式登陆例子
POST: 192.168.200.73:8080/jasperserver/rest_v2/login
Content-Type: application/x-www-form-urlencoded
j_username:jasperadmin
j_password:jasperadmin
返回值
HTTP/1.1 200 OK
Server: Apache-Coyote/1.1
Set-Cookie: JSESSIONID=52E79BCEE51381DF32637EC69AD698AE; Path=/jasperserver
Content-Length: 0
Date: Fri, 3 Aug 2018 01:52:48 GMT
登出
get: http://192.168.200.73:8080/jasperserver/logout.html
带账号密码访问报表
浏览器中报表运行的地址 + get: http://27.151.113.65:30007/jasperserver/flow.html?_flowId=searchFlow&mode=library&j_username=courtuser&j_password=courtuser
浏览器中报表运行的地址 + &j_username=courtuser&j_password=courtuser
&j_username=用户名&j_password=密码
角色
ROLE_USER 可登录用户角色(新建的用户只有授予这个权限才能登陆)
ROLE_ANONYMOUS 匿名访问
ROLE_ADMINISTRATOR 管理员角色
时间范围
-----------------------------------------默认的函数---------------------------------------
开始日期
<parameter name="startDate" class="java.util.Date">
<parameterDescription><![CDATA[开始日期]]></parameterDescription>
<defaultValueExpression><![CDATA[DATE(YEAR(TODAY( )),MONTH(TODAY( )),1)]]></defaultValueExpression>
</parameter>
结束日期
<parameter name="endDate" class="java.util.Date">
<parameterDescription><![CDATA[截止日期]]></parameterDescription>
<defaultValueExpression><![CDATA[TODAY( )]]></defaultValueExpression>
</parameter>
--------------------------------------------Java时间类-----------------------------------
开始时间 上个月的第一天 0点 2020/09/01 00:00:00
<parameter name="startDate" class="java.util.Date">
<defaultValueExpression><![CDATA[java.util.Date.from(java.time.LocalDate.now().minusMonths(1).with(java.time.temporal.TemporalAdjusters.firstDayOfMonth()).atStartOfDay().toInstant(java.time.ZoneOffset.ofHours(8)))]]></defaultValueExpression>
</parameter>
结束时间 当前时间 23点 2020/10/10 23:59:59
<parameter name="endDate" class="java.util.Date">
<defaultValueExpression><![CDATA[java.util.Date.from(java.time.LocalDate.now().atTime(java.time.LocalTime.MAX).toInstant(java.time.ZoneOffset.ofHours(8)))]]></defaultValueExpression>
</parameter>
------------------------------------------jasperreport提供的时间类(推荐)------------------------------------------
<parameter name="startDate" class="java.util.Date">
<defaultValueExpression><![CDATA[(new net.sf.jasperreports.types.date.DateRangeBuilder("MONTH-1")).toDateRange().getStart()]]></defaultValueExpression>
</parameter>
<parameter name="endDate" class="java.util.Date">
<defaultValueExpression><![CDATA[new net.sf.jasperreports.types.date.DateRangeBuilder("MONTH-1").toDateRange().getEnd()]]></defaultValueExpression>
</parameter>
<queryString language="SQL">
<![CDATA[SELECT
convert(varchar(10),createTime,111) date,
SUM(receivePayment) JE,
SUM(amount) JF
FROM
FA_Court.dbo.ReduceIntegralDetail
where BookCourtId is NULL
and States = '1'
and createTime > '2020-09-15 00:10:48'
and $X{BETWEEN, createTime, startDate, endDate}
GROUP by convert(varchar(10),createTime,111)]]>
</queryString>
-------------------------------------------------------时间格式拼接---------------------------------------------
YEAR($P{startDate})+ "-" + String.format("%02d", MONTH($P{startDate})) + "-" + String.format("%02d", DAY($P{startDate})) + " 00:00:00"
YEAR($P{endDate})+ "-" + String.format("%02d", MONTH($P{endDate})) + "-" + String.format("%02d", DAY($P{endDate})) + " 23:59:59"
列合计
-
新建求和变量(Variable)
报表 --> Outlin --> fx Variables --> Create Variables
属性 解释 事例 Name 变量名 SUM_1 value class name 变量类型 java.lang.Integer Calculation 计算方式 sum Expression 表达式 $F{星期一} -
将定义好的变量放置到 Summary块中
nginx 访问 jasperserver 登陆后一直刷新
开启跨域 : underscores_in_headers on
#user nobody;
worker_processes 1;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
#log_format main '$remote_addr - $remote_user [$time_local] "$request" '
# '$status $body_bytes_sent "$http_referer" '
# '"$http_user_agent" "$http_x_forwarded_for"';
#access_log logs/access.log main;
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
##负载均衡 一个域名配置多个地址 jasperserver weight 是权重
upstream jasperserver{
server 192.168.200.2:8080 max_fails=1 fail_timeout=30s weight=2;
ip_hash;
}
#gzip on;
underscores_in_headers on; # 开启跨域
# http://27.151.113.65:30004/foensport/login
# http://27.151.113.65:30007/foensport/login
server {
#站点监听端口
listen 30007;
#站点访问域名
server_name 192.168.200.2;
#编码格式,避免url参数乱码
charset utf-8;
#access_log logs/host.access.log main;
#location / {
# root html;
# index index.html index.htm;
#}
# 体奋安育场馆报表
location /jasperserver/ {
proxy_pass http://jasperserver/jasperserver/;
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
#location ~ \.php$ {
# root html;
# fastcgi_pass 127.0.0.1:9000;
# fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
# include fastcgi_params;
#}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}
# another virtual host using mix of IP-, name-, and port-based configuration
#
#server {
# listen 8000;
# listen somename:8080;
# server_name somename alias another.alias;
# location / {
# root html;
# index index.html index.htm;
# }
#}
# HTTPS server
#
#server {
# listen 443 ssl;
# server_name localhost;
# ssl_certificate cert.pem;
# ssl_certificate_key cert.key;
# ssl_session_cache shared:SSL:1m;
# ssl_session_timeout 5m;
# ssl_ciphers HIGH:!aNULL:!MD5;
# ssl_prefer_server_ciphers on;
# location / {
# root html;
# index index.html index.htm;
# }
#}
}
网友评论