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

125 lines
5.4 KiB
Java
Raw Normal View History

2024-08-20 15:58:52 +08:00
package com.gunshi.project.xyt.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
2024-09-24 13:33:32 +08:00
import com.gunshi.project.xyt.entity.so.CommonDataPageSo;
import com.gunshi.project.xyt.entity.vo.ProjectEventsVo;
2024-08-20 15:58:52 +08:00
import com.gunshi.project.xyt.model.ProjectEvents;
2024-09-24 14:28:14 +08:00
import com.gunshi.project.xyt.model.TermiteSurvey;
2024-08-20 15:58:52 +08:00
import org.apache.ibatis.annotations.Mapper;
2024-09-24 13:33:32 +08:00
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import java.util.List;
2024-08-20 15:58:52 +08:00
@Mapper
public interface ProjectEventsMapper extends BaseMapper<ProjectEvents> {
2024-09-24 13:33:32 +08:00
@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>
2024-09-24 14:28:14 +08:00
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
2024-09-24 13:33:32 +08:00
<where>
2024-09-24 14:28:14 +08:00
<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}
2024-09-24 14:28:14 +08:00
</if>
2024-09-24 13:33:32 +08:00
</where>
2024-09-24 14:28:14 +08:00
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}
2024-09-24 13:33:32 +08:00
</script>
""")
2024-09-24 14:28:14 +08:00
List<Long> queryTermiteDetail(@Param("id") Long id);
2024-11-13 14:24:31 +08:00
@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);
2024-08-20 15:58:52 +08:00
}