40 lines
1.6 KiB
Java
40 lines
1.6 KiB
Java
|
|
package com.gunshi.project.xyt.mapper;
|
||
|
|
|
||
|
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||
|
|
import com.gunshi.project.xyt.entity.so.TermiteSurveyPageSo;
|
||
|
|
import com.gunshi.project.xyt.model.TermiteSurvey;
|
||
|
|
import org.apache.ibatis.annotations.Mapper;
|
||
|
|
import org.apache.ibatis.annotations.Param;
|
||
|
|
import org.apache.ibatis.annotations.Select;
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 描述: 白蚁普查
|
||
|
|
* author: xusan
|
||
|
|
* date: 2024-08-28 10:29:58
|
||
|
|
*/
|
||
|
|
@Mapper
|
||
|
|
public interface TermiteSurveyMapper extends BaseMapper<TermiteSurvey> {
|
||
|
|
|
||
|
|
@Select("""
|
||
|
|
<script>
|
||
|
|
with m1 as (
|
||
|
|
select t.*,to_char(t.report_date,'YYYY') as year from public.termite_survey t),
|
||
|
|
m2 as (select survey_id,count(is_harm) as harmNum from termite_survey_detail where is_harm = 1 GROUP BY survey_id),
|
||
|
|
m3 as (select survey_id,count(is_handle) as handleNum from termite_survey_detail where is_handle = 1 GROUP BY survey_id)
|
||
|
|
select m1.*,m2.harmNum,m3.handleNum from m1
|
||
|
|
left join m2 on m1.id = m2.survey_id
|
||
|
|
left join m3 on m1.id = m3.survey_id
|
||
|
|
<where>
|
||
|
|
<if test="obj.year != null ">
|
||
|
|
m1.year = #{obj.year}
|
||
|
|
</if>
|
||
|
|
<if test="obj.isHarm != null ">
|
||
|
|
m2.harmNum > 0
|
||
|
|
</if>
|
||
|
|
</where>
|
||
|
|
order by m1.report_date desc
|
||
|
|
</script>
|
||
|
|
""")
|
||
|
|
Page<TermiteSurvey> pageQuery(Page<TermiteSurvey> page,@Param("obj") TermiteSurveyPageSo page1);
|
||
|
|
}
|