gunshi-project-ss/src/main/java/com/gunshi/project/xyt/mapper/TermiteSurveyMapper.java

51 lines
1.9 KiB
Java
Raw Normal View History

2024-08-28 15:20:16 +08:00
package com.gunshi.project.xyt.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
2024-08-28 16:50:58 +08:00
import com.gunshi.file.model.FileDescriptor;
2024-08-28 15:20:16 +08:00
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;
2024-08-28 16:50:58 +08:00
import java.util.List;
2024-08-28 15:20:16 +08:00
/**
* :
* 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);
2024-08-28 16:50:58 +08:00
@Select("""
<script>
select *,file_size as fileLength from public.file_descriptor where group_id = #{groupId}
2024-08-28 16:50:58 +08:00
</script>
""")
List<FileDescriptor> queryFileList(@Param("groupId") String groupId);
2024-08-28 15:20:16 +08:00
}