使用
@J4EName("查询日期")
private Date inrq;
这种描述,导出的数据字段名还是inrq,不是 查询日期 的名字
@J4EIgnore
private long tel;
不是导出时表示可以不导出该字段吗,怎么还是有呢?
这些操作该怎么写才生效?
谢谢
J4EConf j4eConf = J4EConf.from(Sys_user.class);
j4eConf.setUse2007(true);
List<J4EColumn> jcols = j4eConf.getColumns();
for (J4EColumn j4eColumn : jcols) {
if ("updatedBy".equals(j4eColumn.getFieldName()) || "updatedAt".equals(j4eColumn.getFieldName()) || "createdBy".equals(j4eColumn.getFieldName()) || "createdAt".equals(j4eColumn.getFieldName()) || "delFlag".equals(j4eColumn.getFieldName())) {
j4eColumn.setIgnore(true);
}
}
Cnd cnd = Cnd.NEW();
if (shiroUtil.hasRole(PlatformConstant.PLATFORM_ROLE_SYSADMIN_NAME)) {
if (Strings.isNotBlank(unitid) && !"root".equals(unitid)) {
cnd.and("unitid", "=", unitid);
}
} else {
Sys_user user = (Sys_user) shiroUtil.getPrincipal();
if (Strings.isNotBlank(unitid) && !"root".equals(unitid)) {
Sys_unit unit = sysUnitService.fetch(unitid);
if (unit == null || !unit.getPath().startsWith(user.getUnit().getPath())) {
//防止有人越级访问
throw Lang.makeThrow(Mvcs.getMessage(req, "system.error.invalid"));
} else {
cnd.and("unitid", "=", unitid);
}
} else {
cnd.and("unitid", "=", user.getUnitid());
}
}
if (Strings.isNotBlank(username)) {
cnd.and(Cnd.likeEX("username", username));
}
if (Strings.isNotBlank(loginname)) {
cnd.and(Cnd.likeEX("loginname", loginname));
}
if (Strings.isNotBlank(email)) {
cnd.and(Cnd.likeEX("email", email));
}
if (Strings.isNotBlank(mobile)) {
cnd.and(Cnd.likeEX("mobile", mobile));
}
cnd.and("delFlag", "=", false);
if (Strings.isNotBlank(pageOrderName) && Strings.isNotBlank(pageOrderBy)) {
cnd.orderBy(pageOrderName, PageUtil.getOrder(pageOrderBy));
}
OutputStream out = response.getOutputStream();
response.setHeader("content-type", "application/shlnd.ms-excel;charset=utf-8");
response.setHeader("content-disposition", "attachment; filename=" + new String("sys_user".getBytes(), "ISO-8859-1") + ".xlsx");
J4E.toExcel(out, sysUserService.query(cnd), j4eConf);
String filename="找猫资源取数.xlsx";
SimpleDateFormat dft=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
J4EConf j4eConf = J4EConf.from(hzunregonuresult.class);
j4eConf.setUse2007(true);
List jcols = j4eConf.getColumns();
for (J4EColumn j4eColumn : jcols) {
if ("password".equals(j4eColumn.getFieldName())|| "dt".equals(j4eColumn.getFieldName())|| "tel".equals(j4eColumn.getFieldName())|| "id".equals(j4eColumn.getFieldName()) || "errormessage".equals(j4eColumn.getFieldName()) || "sn".equals(j4eColumn.getFieldName()) || "authtime".equals(j4eColumn.getFieldName()) || "inid".equals(j4eColumn.getFieldName()))
{
j4eColumn.setIgnore(true);
}
}
List Hzunregonuresult =dao.query(hzunregonuresult.class, Cnd.wrap("inrq between '"+dft.format(begtime)+ "' and '"+dft.format(endtime)+"' AND ((rtrim(loid) =rtrim(inloid) and inloid !='') or (inmac!='' and (rtrim(mac) like '%'+rtrim(inmac) +'%' or(replace(rtrim(mac),'-','') like '%'+substring(replace(rtrim(inmac),'-',''),1,4)+'%' )))) order by inrq"));
//List Hzunregonuresult =Daos.ext(dao, FieldFilter.locked(hzunregonuresult.class, "^errormessage|sn|authtime|dt|id|inid|tel|password$")).query(hzunregonuresult.class, Cnd.wrap("inrq between '"+dft.format(begtime)+ "' and '"+dft.format(endtime)+"' AND ((rtrim(loid) =rtrim(inloid) and inloid !='') or (inmac!='' and (rtrim(mac) like '%'+rtrim(inmac) +'%' or(replace(rtrim(mac),'-','') like '%'+substring(replace(rtrim(inmac),'-',''),1,4)+'%' )))) order by inrq"));
OutputStream out = response.getOutputStream();
response.setHeader("content-type", "application/shlnd.ms-excel;charset=utf-8");
response.setHeader("content-disposition", "attachment; filename=" + new String(filename.getBytes(), "ISO-8859-1"));
J4E.toExcel(out, Hzunregonuresult, j4eConf);
执行到这里报这个错:
20-02-26 23:37:22.850 DEBUG [http-nio-8089-exec-34] SELECT * FROM hzonumessage.dbo.unregonuresult WHERE inrq between '2020-02-24 00:00:01' and '2020-02-26 23:59:59' AND ((rtrim(loid) =rtrim(inloid) and inloid !='') or (inmac!='' and (rtrim(mac) like '%'+rtrim(inmac) +'%' or(replace(rtrim(mac),'-','') like '%'+substring(replace(rtrim(inmac),'-',''),1,4)+'%' )))) order by inrq
20-02-26 23:37:41.382 WARN [http-nio-8089-exec-34] Error@/zytj/tjzyexcel :
java.lang.NoClassDefFoundError: org/apache/xmlbeans/XmlObject
at org.nutz.integration.json4excel.J4E.toExcel(J4E.java:74)
at main.zytjaction.tjzyexcel(zytjaction.java:117)
at main.zytjaction$FM$tjzyexcel$3d880d84aaf0dbc9ee5a0dc78658722c.invoke(zytjaction.java)
at org.nutz.mvc.impl.processor.MethodInvokeProcessor.process(MethodInvokeProcessor.java:31)
at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
at org.nutz.mvc.impl.processor.AdaptorProcessor.process(AdaptorProcessor.java:38)
at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
at org.nutz.mvc.impl.processor.ActionFiltersProcessor.process(ActionFiltersProcessor.java:58)
at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
at org.nutz.mvc.impl.processor.ModuleProcessor.process(ModuleProcessor.java:123)
at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
at org.nutz.mvc.impl.processor.EncodingProcessor.process(EncodingProcessor.java:27)
at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
at org.nutz.mvc.impl.processor.UpdateRequestAttributesProcessor.process(UpdateRequestAttributesProcessor.java:15)
at org.nutz.mvc.impl.NutActionChain.doChain(NutActionChain.java:44)
at org.nutz.mvc.impl.ActionInvoker.invoke(ActionInvoker.java:67)
at org.nutz.mvc.ActionHandler.handle(ActionHandler.java:31)
at org.nutz.mvc.NutFilter.doFilter(NutFilter.java:202)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:199)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:543)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:139)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:81)
at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:688)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343)
at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:609)
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65)
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:818)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1623)
at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.ClassNotFoundException: org.apache.xmlbeans.XmlObject
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1358)
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1180)
... 37 more
20-02-26 23:37:41.382 WARN [http-nio-8089-exec-33] Error@/zytj/tjzyexcel :
java.lang.NoClassDefFoundError: org/apache/xmlbeans/XmlObject
at org.nutz.integration.json4excel.J4E.toExcel(J4E.java:74)
at main.zytjaction.tjzyexcel(zytjaction.java:117)
at main.zytjaction$FM$tjzyexcel$3d880d84aaf0dbc9ee5a0dc78658722c.invoke(zytjaction.java)
at org.nutz.mvc.impl.processor.MethodInvokeProcessor.process(MethodInvokeProcessor.java:31)
at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
at org.nutz.mvc.impl.processor.AdaptorProcessor.process(AdaptorProcessor.java:38)
at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
at org.nutz.mvc.impl.processor.ActionFiltersProcessor.process(ActionFiltersProcessor.java:58)
at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
at org.nutz.mvc.impl.processor.ModuleProcessor.process(ModuleProcessor.java:123)
at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
at org.nutz.mvc.impl.processor.EncodingProcessor.process(EncodingProcessor.java:27)
at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
at org.nutz.mvc.impl.processor.UpdateRequestAttributesProcessor.process(UpdateRequestAttributesProcessor.java:15)
at org.nutz.mvc.impl.NutActionChain.doChain(NutActionChain.java:44)
at org.nutz.mvc.impl.ActionInvoker.invoke(ActionInvoker.java:67)
at org.nutz.mvc.ActionHandler.handle(ActionHandler.java:31)
at org.nutz.mvc.NutFilter.doFilter(NutFilter.java:202)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:199)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:543)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:139)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:81)
at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:688)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343)
at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:609)
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65)
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:818)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1623)
at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.ClassNotFoundException: org.apache.xmlbeans.XmlObject
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1358)
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1180)
... 37 more
看网上的描述所添加xmlbeans-maven-plugin-2.3.0.jar可以解决问题,加了还是不信,还有生么问题吗?
Hzunregonuresult调试有150条记录
非常感谢!!
<!-- json4excel,poi -->
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>${poi.version}</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>${poi.version}</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml-schemas</artifactId>
<version>${poi.version}</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>ooxml-schemas</artifactId>
<version>1.3</version>
</dependency>