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

125 lines
5.4 KiB
Java

package com.gunshi.project.xyt.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.gunshi.project.xyt.entity.so.CommonDataPageSo;
import com.gunshi.project.xyt.entity.vo.ProjectEventsVo;
import com.gunshi.project.xyt.model.ProjectEvents;
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;
import java.util.List;
@Mapper
public interface ProjectEventsMapper extends BaseMapper<ProjectEvents> {
@Select("""
<script>
select t.id,t.events_date,t.events_desc,1 as type from public.project_events t
<where>
<if test="obj.dateSo != null and obj.dateSo.start != null">
t.events_date <![CDATA[>=]]> #{obj.dateSo.start}
</if>
<if test="obj.dateSo != null and obj.dateSo.end != null">
and t.events_date <![CDATA[<=]]> #{obj.dateSo.end}
</if>
</where>
</script>
""")
List<ProjectEventsVo> eventList(@Param("obj") CommonDataPageSo page);
@Select("""
<script>
select t.id,t.report_time as eventsDate,t.maintain_content as eventsDesc,3 as type from public.maintain_service t
<where>
<if test="obj.dateSo != null and obj.dateSo.start != null">
t.report_time <![CDATA[>=]]> #{obj.dateSo.start}
</if>
<if test="obj.dateSo != null and obj.dateSo.end != null">
and t.report_time <![CDATA[<=]]> #{obj.dateSo.end}
</if>
</where>
</script>
""")
List<ProjectEventsVo> maintainList(@Param("obj") CommonDataPageSo page);
@Select("""
<script>
select t.id,t.identify_date as eventsDate,t.main_problem as eventsDesc,4 as type from public.safety_identify t
<where>
<if test="obj.dateSo != null and obj.dateSo.start != null">
t.identify_date <![CDATA[>=]]> #{obj.dateSo.start}
</if>
<if test="obj.dateSo != null and obj.dateSo.end != null">
and t.identify_date <![CDATA[<=]]> #{obj.dateSo.end}
</if>
</where>
</script>
""")
List<ProjectEventsVo> safetyList(@Param("obj") CommonDataPageSo page);
@Select("""
<script>
select t.id,t.start_date as eventsDate,t.construct_content as eventsDesc,5 as type from public.safety_reinforcement t
<where>
<if test="obj.dateSo != null and obj.dateSo.start != null">
t.start_date <![CDATA[>=]]> #{obj.dateSo.start}
</if>
<if test="obj.dateSo != null and obj.dateSo.end != null">
and t.start_date <![CDATA[<=]]> #{obj.dateSo.end}
</if>
</where>
</script>
""")
List<ProjectEventsVo> reinforceList(@Param("obj") CommonDataPageSo page);
@Select("""
<script>
with m1 as (
select t.* 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.dateSo != null and obj.dateSo.start != null">
m1.report_date <![CDATA[>=]]> #{obj.dateSo.start}
</if>
<if test="obj.dateSo != null and obj.dateSo.end != null">
and m1.report_date <![CDATA[<=]]> #{obj.dateSo.end}
</if>
</where>
order by m1.report_date desc
</script>
""")
List<TermiteSurvey> termiteList(@Param("obj") CommonDataPageSo page);
@Select("""
<script>
select id from public.termite_survey_detail where survey_id = #{id}
</script>
""")
List<Long> queryTermiteDetail(@Param("id") Long id);
@Select("""
<script>
select t.id,t.start_time as eventsDate,t.dispatch_detail as eventsDesc,2 as type from public.dispatch_record t
<where>
<if test="obj.dateSo != null and obj.dateSo.start != null">
t.start_time <![CDATA[>=]]> #{obj.dateSo.start}
</if>
<if test="obj.dateSo != null and obj.dateSo.end != null">
and t.start_time <![CDATA[<=]]> #{obj.dateSo.end}
</if>
</where>
</script>
""")
List<ProjectEventsVo> dispatchList(@Param("obj") CommonDataPageSo page);
}