解决mybatis-plus使用函数导致执行sql报错问题
错误提示信息
### Error querying database. Cause: com.baomidou.mybatisplus.core.exceptions.MybatisPlusException: Failed to process, Error SQL: with actual as (
select materialapplyid,sum(IFNULL(loadnum, 0)) num from loadcar_bwrj GROUP BY materialapplyid
),
load_capacity as (
select materialapplyid,sum(IFNULL(car.load_capacity, 0)) num
from loadcar_bwrj loadcar
left join carmanager_bwrj car on loadcar.carid = car.id
group by materialapplyid
),
diff_minute as (
select task.materialapplyid,TIMESTAMPDIFF(MINUTE, task.endtime, apply.usetime) diffMinute
from transportationtask_bwrj task
left join materialapply_bwrj apply on task.materialapplyid = apply.id
),
top1 as (
select
car.car_no,
DATE_FORMAT(task.endtime, '%Y-%m-%d') monthDay,
count(1) totalCount,
count(case when (diff.diffMinute <= 30 and diff.diffMinute >= -30) then 1 else null end) onTimeCount,
count(case when actual.num <= capacity.num then 1 else null end) fullLoadCount,
sum(actual.num) actual_num,
sum(capacity.num) load_capacity_num
from transportationtask_bwrj task
left join diff_minute diff on diff.materialapplyid = task.materialapplyid
left join actual actual on actual.materialapplyid = task.materialapplyid
left join load_capacity capacity on capacity.materialapplyid = task.materialapplyid
left join taskplan_bwrj plan on plan.transportationtaskid = task.id
left join carmanager_bwrj car on car.id = plan.carid
where task.`status` = 6
GROUP BY plan.carid, monthDay
)
select
car_no,
convert(onTimeCount*100/totalCount,decimal(15,2)) on_time_percent,
convert(fullLoadCount*100/totalCount,decimal(15,2)) full_load_percent,
convert(actual_num*100/load_capacity_num,decimal(15,2)) capacity_percent,
monthDay month_day
from top1
### Cause: com.baomidou.mybatisplus.core.exceptions.MybatisPlusException: Failed to process, Error SQL: with actual as (
select materialapplyid,sum(IFNULL(loadnum, 0)) num from loadcar_bwrj GROUP BY materialapplyid
),
load_capacity as (
select materialapplyid,sum(IFNULL(car.load_capacity, 0)) num
from loadcar_bwrj loadcar
left join carmanager_bwrj car on loadcar.carid = car.id
group by materialapplyid
),
diff_minute as (
select task.materialapplyid,TIMESTAMPDIFF(MINUTE, task.endtime, apply.usetime) diffMinute
from transportationtask_bwrj task
left join materialapply_bwrj apply on task.materialapplyid = apply.id
),
top1 as (
select
car.car_no,
DATE_FORMAT(task.endtime, '%Y-%m-%d') monthDay,
count(1) totalCount,
count(case when (diff.diffMinute <= 30 and diff.diffMinute >= -30) then 1 else null end) onTimeCount,
count(case when actual.num <= capacity.num then 1 else null end) fullLoadCount,
sum(actual.num) actual_num,
sum(capacity.num) load_capacity_num
from transportationtask_bwrj task
left join diff_minute diff on diff.materialapplyid = task.materialapplyid
left join actual actual on actual.materialapplyid = task.materialapplyid
left join load_capacity capacity on capacity.materialapplyid = task.materialapplyid
left join taskplan_bwrj plan on plan.transportationtaskid = task.id
left join carmanager_bwrj car on car.id = plan.carid
where task.`status` = 6
GROUP BY plan.carid, monthDay
)
select
car_no,
convert(onTimeCount*100/totalCount,decimal(15,2)) on_time_percent,
convert(fullLoadCount*100/totalCount,decimal(15,2)) full_load_percent,
convert(actual_num*100/load_capacity_num,decimal(15,2)) capacity_percent,
monthDay month_day
from top1
org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.exceptions.PersistenceException:
### Error querying database. Cause: com.baomidou.mybatisplus.core.exceptions.MybatisPlusException: Failed to process, Error SQL: with actual as (
select materialapplyid,sum(IFNULL(loadnum, 0)) num from loadcar_bwrj GROUP BY materialapplyid
),
load_capacity as (
select materialapplyid,sum(IFNULL(car.load_capacity, 0)) num
from loadcar_bwrj loadcar
left join carmanager_bwrj car on loadcar.carid = car.id
group by materialapplyid
),
diff_minute as (
select task.materialapplyid,TIMESTAMPDIFF(MINUTE, task.endtime, apply.usetime) diffMinute
from transportationtask_bwrj task
left join materialapply_bwrj apply on task.materialapplyid = apply.id
),
top1 as (
select
car.car_no,
DATE_FORMAT(task.endtime, '%Y-%m-%d') monthDay,
count(1) totalCount,
count(case when (diff.diffMinute <= 30 and diff.diffMinute >= -30) then 1 else null end) onTimeCount,
count(case when actual.num <= capacity.num then 1 else null end) fullLoadCount,
sum(actual.num) actual_num,
sum(capacity.num) load_capacity_num
from transportationtask_bwrj task
left join diff_minute diff on diff.materialapplyid = task.materialapplyid
left join actual actual on actual.materialapplyid = task.materialapplyid
left join load_capacity capacity on capacity.materialapplyid = task.materialapplyid
left join taskplan_bwrj plan on plan.transportationtaskid = task.id
left join carmanager_bwrj car on car.id = plan.carid
where task.`status` = 6
GROUP BY plan.carid, monthDay
)
select
car_no,
convert(onTimeCount*100/totalCount,decimal(15,2)) on_time_percent,
convert(fullLoadCount*100/totalCount,decimal(15,2)) full_load_percent,
convert(actual_num*100/load_capacity_num,decimal(15,2)) capacity_percent,
monthDay month_day
from top1
### Cause: com.baomidou.mybatisplus.core.exceptions.MybatisPlusException: Failed to process, Error SQL: with actual as (
select materialapplyid,sum(IFNULL(loadnum, 0)) num from loadcar_bwrj GROUP BY materialapplyid
),
load_capacity as (
select materialapplyid,sum(IFNULL(car.load_capacity, 0)) num
from loadcar_bwrj loadcar
left join carmanager_bwrj car on loadcar.carid = car.id
group by materialapplyid
),
diff_minute as (
select task.materialapplyid,TIMESTAMPDIFF(MINUTE, task.endtime, apply.usetime) diffMinute
from transportationtask_bwrj task
left join materialapply_bwrj apply on task.materialapplyid = apply.id
),
top1 as (
select
car.car_no,
DATE_FORMAT(task.endtime, '%Y-%m-%d') monthDay,
count(1) totalCount,
count(case when (diff.diffMinute <= 30 and diff.diffMinute >= -30) then 1 else null end) onTimeCount,
count(case when actual.num <= capacity.num then 1 else null end) fullLoadCount,
sum(actual.num) actual_num,
sum(capacity.num) load_capacity_num
from transportationtask_bwrj task
left join diff_minute diff on diff.materialapplyid = task.materialapplyid
left join actual actual on actual.materialapplyid = task.materialapplyid
left join load_capacity capacity on capacity.materialapplyid = task.materialapplyid
left join taskplan_bwrj plan on plan.transportationtaskid = task.id
left join carmanager_bwrj car on car.id = plan.carid
where task.`status` = 6
GROUP BY plan.carid, monthDay
)
select
car_no,
convert(onTimeCount*100/totalCount,decimal(15,2)) on_time_percent,
convert(fullLoadCount*100/totalCount,decimal(15,2)) full_load_percent,
convert(actual_num*100/load_capacity_num,decimal(15,2)) capacity_percent,
monthDay month_day
from top1
at org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:96)
at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:441)
at com.sun.proxy.$Proxy136.selectList(Unknown Source)
at org.mybatis.spring.SqlSessionTemplate.selectList(SqlSessionTemplate.java:224)
at com.baomidou.mybatisplus.core.override.MybatisMapperMethod.executeForIPage(MybatisMapperMethod.java:121)
at com.baomidou.mybatisplus.core.override.MybatisMapperMethod.execute(MybatisMapperMethod.java:85)
at com.baomidou.mybatisplus.core.override.MybatisMapperProxy$PlainMethodInvoker.invoke(MybatisMapperProxy.java:148)
at com.baomidou.mybatisplus.core.override.MybatisMapperProxy.invoke(MybatisMapperProxy.java:89)
at com.sun.proxy.$Proxy292.selectCarOnTime(Unknown Source)
at org.jeecg.modules.fuda.service.impl.DailyReportServiceImpl.selectCarOnTime(DailyReportServiceImpl.java:24)
at org.jeecg.modules.fuda.controller.DailyReportController.queryPageList(DailyReportController.java:53)
at org.jeecg.modules.fuda.controller.DailyReportController$$FastClassBySpringCGLIB$$552edaa8.invoke(<generated>)
at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218)
at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:771)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163)
at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749)
at org.springframework.aop.aspectj.MethodInvocationProceedingJoinPoint.proceed(MethodInvocationProceedingJoinPoint.java:88)
at org.jeecg.common.aspect.DictAspect.doAround(DictAspect.java:55)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethodWithGivenArgs(AbstractAspectJAdvice.java:644)
at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethod(AbstractAspectJAdvice.java:633)
at org.springframework.aop.aspectj.AspectJAroundAdvice.invoke(AspectJAroundAdvice.java:70)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749)
at org.springframework.aop.aspectj.MethodInvocationProceedingJoinPoint.proceed(MethodInvocationProceedingJoinPoint.java:88)
at org.jeecg.common.aspect.AutoLogAspect.around(AutoLogAspect.java:57)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethodWithGivenArgs(AbstractAspectJAdvice.java:644)
at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethod(AbstractAspectJAdvice.java:633)
at org.springframework.aop.aspectj.AspectJAroundAdvice.invoke(AspectJAroundAdvice.java:70)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:175)
at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749)
at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:95)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749)
at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:691)
at org.jeecg.modules.fuda.controller.DailyReportController$$EnhancerBySpringCGLIB$$76afadb6.queryPageList(<generated>)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:190)
at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:138)
at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:105)
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:878)
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:792)
at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1040)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:943)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1006)
at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:898)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:626)
at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:883)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:733)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.apache.shiro.web.servlet.ProxiedFilterChain.doFilter(ProxiedFilterChain.java:61)
at org.apache.shiro.web.servlet.AdviceFilter.executeChain(AdviceFilter.java:108)
at org.apache.shiro.web.servlet.AdviceFilter.doFilterInternal(AdviceFilter.java:137)
at org.apache.shiro.web.servlet.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:125)
at org.apache.shiro.web.servlet.ProxiedFilterChain.doFilter(ProxiedFilterChain.java:66)
at org.apache.shiro.web.servlet.AdviceFilter.executeChain(AdviceFilter.java:108)
at org.apache.shiro.web.servlet.AdviceFilter.doFilterInternal(AdviceFilter.java:137)
at org.apache.shiro.web.servlet.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:125)
at org.apache.shiro.web.servlet.ProxiedFilterChain.doFilter(ProxiedFilterChain.java:66)
at org.apache.shiro.web.servlet.AbstractShiroFilter.executeChain(AbstractShiroFilter.java:450)
at org.apache.shiro.web.servlet.AbstractShiroFilter$1.call(AbstractShiroFilter.java:365)
at org.apache.shiro.subject.support.SubjectCallable.doCall(SubjectCallable.java:90)
at org.apache.shiro.subject.support.SubjectCallable.call(SubjectCallable.java:83)
at org.apache.shiro.subject.support.DelegatingSubject.execute(DelegatingSubject.java:387)
at org.apache.shiro.web.servlet.AbstractShiroFilter.doFilterInternal(AbstractShiroFilter.java:362)
at org.apache.shiro.web.servlet.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:125)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.springframework.web.filter.CorsFilter.doFilterInternal(CorsFilter.java:92)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at com.alibaba.druid.support.http.WebStatFilter.doFilter(WebStatFilter.java:124)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.springframework.boot.actuate.web.trace.servlet.HttpTraceFilter.doFilterInternal(HttpTraceFilter.java:88)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:100)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:93)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.springframework.boot.actuate.metrics.web.servlet.WebMvcMetricsFilter.doFilterInternal(WebMvcMetricsFilter.java:93)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119)
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:202)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:97)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:542)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:143)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:78)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343)
at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:374)
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65)
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:868)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1590)
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: org.apache.ibatis.exceptions.PersistenceException:
### Error querying database. Cause: com.baomidou.mybatisplus.core.exceptions.MybatisPlusException: Failed to process, Error SQL: with actual as (
select materialapplyid,sum(IFNULL(loadnum, 0)) num from loadcar_bwrj GROUP BY materialapplyid
),
load_capacity as (
select materialapplyid,sum(IFNULL(car.load_capacity, 0)) num
from loadcar_bwrj loadcar
left join carmanager_bwrj car on loadcar.carid = car.id
group by materialapplyid
),
diff_minute as (
select task.materialapplyid,TIMESTAMPDIFF(MINUTE, task.endtime, apply.usetime) diffMinute
from transportationtask_bwrj task
left join materialapply_bwrj apply on task.materialapplyid = apply.id
),
top1 as (
select
car.car_no,
DATE_FORMAT(task.endtime, '%Y-%m-%d') monthDay,
count(1) totalCount,
count(case when (diff.diffMinute <= 30 and diff.diffMinute >= -30) then 1 else null end) onTimeCount,
count(case when actual.num <= capacity.num then 1 else null end) fullLoadCount,
sum(actual.num) actual_num,
sum(capacity.num) load_capacity_num
from transportationtask_bwrj task
left join diff_minute diff on diff.materialapplyid = task.materialapplyid
left join actual actual on actual.materialapplyid = task.materialapplyid
left join load_capacity capacity on capacity.materialapplyid = task.materialapplyid
left join taskplan_bwrj plan on plan.transportationtaskid = task.id
left join carmanager_bwrj car on car.id = plan.carid
where task.`status` = 6
GROUP BY plan.carid, monthDay
)
select
car_no,
convert(onTimeCount*100/totalCount,decimal(15,2)) on_time_percent,
convert(fullLoadCount*100/totalCount,decimal(15,2)) full_load_percent,
convert(actual_num*100/load_capacity_num,decimal(15,2)) capacity_percent,
monthDay month_day
from top1
### Cause: com.baomidou.mybatisplus.core.exceptions.MybatisPlusException: Failed to process, Error SQL: with actual as (
select materialapplyid,sum(IFNULL(loadnum, 0)) num from loadcar_bwrj GROUP BY materialapplyid
),
load_capacity as (
select materialapplyid,sum(IFNULL(car.load_capacity, 0)) num
from loadcar_bwrj loadcar
left join carmanager_bwrj car on loadcar.carid = car.id
group by materialapplyid
),
diff_minute as (
select task.materialapplyid,TIMESTAMPDIFF(MINUTE, task.endtime, apply.usetime) diffMinute
from transportationtask_bwrj task
left join materialapply_bwrj apply on task.materialapplyid = apply.id
),
top1 as (
select
car.car_no,
DATE_FORMAT(task.endtime, '%Y-%m-%d') monthDay,
count(1) totalCount,
count(case when (diff.diffMinute <= 30 and diff.diffMinute >= -30) then 1 else null end) onTimeCount,
count(case when actual.num <= capacity.num then 1 else null end) fullLoadCount,
sum(actual.num) actual_num,
sum(capacity.num) load_capacity_num
from transportationtask_bwrj task
left join diff_minute diff on diff.materialapplyid = task.materialapplyid
left join actual actual on actual.materialapplyid = task.materialapplyid
left join load_capacity capacity on capacity.materialapplyid = task.materialapplyid
left join taskplan_bwrj plan on plan.transportationtaskid = task.id
left join carmanager_bwrj car on car.id = plan.carid
where task.`status` = 6
GROUP BY plan.carid, monthDay
)
select
car_no,
convert(onTimeCount*100/totalCount,decimal(15,2)) on_time_percent,
convert(fullLoadCount*100/totalCount,decimal(15,2)) full_load_percent,
convert(actual_num*100/load_capacity_num,decimal(15,2)) capacity_percent,
monthDay month_day
from top1
at org.apache.ibatis.exceptions.ExceptionFactory.wrapException(ExceptionFactory.java:30)
at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:153)
at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:145)
at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:140)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:427)
... 124 common frames omitted
Caused by: com.baomidou.mybatisplus.core.exceptions.MybatisPlusException: Failed to process, Error SQL: with actual as (
select materialapplyid,sum(IFNULL(loadnum, 0)) num from loadcar_bwrj GROUP BY materialapplyid
),
load_capacity as (
select materialapplyid,sum(IFNULL(car.load_capacity, 0)) num
from loadcar_bwrj loadcar
left join carmanager_bwrj car on loadcar.carid = car.id
group by materialapplyid
),
diff_minute as (
select task.materialapplyid,TIMESTAMPDIFF(MINUTE, task.endtime, apply.usetime) diffMinute
from transportationtask_bwrj task
left join materialapply_bwrj apply on task.materialapplyid = apply.id
),
top1 as (
select
car.car_no,
DATE_FORMAT(task.endtime, '%Y-%m-%d') monthDay,
count(1) totalCount,
count(case when (diff.diffMinute <= 30 and diff.diffMinute >= -30) then 1 else null end) onTimeCount,
count(case when actual.num <= capacity.num then 1 else null end) fullLoadCount,
sum(actual.num) actual_num,
sum(capacity.num) load_capacity_num
from transportationtask_bwrj task
left join diff_minute diff on diff.materialapplyid = task.materialapplyid
left join actual actual on actual.materialapplyid = task.materialapplyid
left join load_capacity capacity on capacity.materialapplyid = task.materialapplyid
left join taskplan_bwrj plan on plan.transportationtaskid = task.id
left join carmanager_bwrj car on car.id = plan.carid
where task.`status` = 6
GROUP BY plan.carid, monthDay
)
select
car_no,
convert(onTimeCount*100/totalCount,decimal(15,2)) on_time_percent,
convert(fullLoadCount*100/totalCount,decimal(15,2)) full_load_percent,
convert(actual_num*100/load_capacity_num,decimal(15,2)) capacity_percent,
monthDay month_day
from top1
at com.baomidou.mybatisplus.core.toolkit.ExceptionUtils.mpe(ExceptionUtils.java:39)
at com.baomidou.mybatisplus.extension.parser.JsqlParserSupport.parserSingle(JsqlParserSupport.java:52)
at com.baomidou.mybatisplus.extension.plugins.inner.TenantLineInnerInterceptor.beforeQuery(TenantLineInnerInterceptor.java:65)
at com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor.intercept(MybatisPlusInterceptor.java:78)
at org.apache.ibatis.plugin.Plugin.invoke(Plugin.java:62)
at com.sun.proxy.$Proxy358.query(Unknown Source)
at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:151)
... 131 common frames omitted
可以看到是因为 TenantLineInnerInterceptor 导致的错误
增加注解:
@InterceptorIgnore(tenantLine = "1")
IPage<CarOnTimeVO> selectCarOnTime(Page<CarOnTimeVO> page, @Param("month") String month);