bns_jjsp_service/securityControl-modules/securityControl-decision/target/classes/mapper/ProjectQualityMapper.xml

258 lines
15 KiB
XML

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.sercurityControl.decision.mapper.ProjectQualityMapper">
<select id="getProjectList" resultType="com.sercurityControl.decision.domain.ProjectQuality">
select a.*,ifnull(sum(b.two),0) as two_num,ifnull(sum(b.three),0) as three_num,
ifnull(sum(b.four),0) as four_num,ifnull(sum(b.five),0) as five_num
from (select any_value(tcm.build_unit) as build_org_name,any_value(tcm.bid_name) as project_name,
count(team_name) as team_num,sum(sg_num) as people_num,ANY_value(tcm.sgdw) as sgdw,bid_code as bid_no
from t_class_metting tcm
<where>
and work_day = current_date
<if test="projectName != null and projectName != ''"> and bid_name like concat('%',#{projectName},'%')</if>
<if test="buildOrgNo != null and buildOrgNo != ''"> and org = #{buildOrgNo}</if>
</where>
group by tcm.bid_code) a
left join
(select IF(tti.job_risk_fc_level_num = '2级',1,0) as two,
IF(tti.job_risk_fc_level_num = '3级',1,0) as three,
IF(tti.job_risk_fc_level_num = '4级',1,0) as four,
IF(tti.job_risk_fc_level_num = '5级',1,0) as five,
tcm.bid_code
from t_class_metting tcm
inner join t_ticket_info tti on tcm.ticket_id = tti.id
<where>
and work_day = current_date
<if test="projectName != null and projectName != ''"> and bid_name like concat('%',#{projectName},'%')</if>
<if test="buildOrgNo != null and buildOrgNo != ''"> and org = #{buildOrgNo}</if>
</where>
) b on a.bid_no = b.bid_code
group by a.bid_no
</select>
<select id="getTeamList" resultType="com.sercurityControl.decision.domain.Sgbz">
select tcm.work_manager as bz_name ,work_manager_phone as bz_phone,tcm.class_id,
bid_name as project_name,sg_num as people_num,work_day,
tti.job_risk_fc_level_num as risk_grade,job_lx ,job_gx,job_site
from t_class_metting tcm
left join t_ticket_info tti on tcm.ticket_id = tti.id
<where>
and tcm.work_day = current_date
and tcm.bid_code = #{bidNo}
<if test="name != null and name != ''"> and tcm.work_manager like concat('%',#{name},'%')</if>
<if test="riskGrade != null and riskGrade != ''"> and tti.job_risk_fc_level_num = #{riskGrade}</if>
</where>
</select>
<select id="getPlanDetail" resultType="com.sercurityControl.decision.domain.Sgbz">
select tcm.build_unit as build_org_name,bid_name as project_name,sgdw,job_leader,ticket_id,
job_security,work_day,job_site,job_lx,job_gx,job_risk_fc_level_num as risk_grade,
tcm.team_name,work_manager as bz_name ,work_manager_phone as bz_phone,
(select jp.name from t_class_metting_people tp inner join jj_person jp on tp.id_number = jp.bak_ic where tp.class_id = tcm.class_id and tp.people_type in ('4115','49') limit 1) as bz_aq,
(select jp.name from t_class_metting_people tp inner join jj_person jp on tp.id_number = jp.bak_ic where tp.class_id = tcm.class_id and tp.people_type in ('4116','50') limit 1) as bz_zj
from t_class_metting tcm
left join t_ticket_info tti on tcm.ticket_id = tti.id
where tcm.class_id = #{classId}
</select>
<select id="getXcgkList" resultType="com.sercurityControl.decision.domain.Sgbz">
select tcm.build_unit as build_org_name,tcm.bid_name as project_name,job_address,job_content,any_value(td.state) as is_online,
group_concat(DISTINCT ttip.user_name SEPARATOR ',') as job_people,job_risk_fc_level_num as risk_grade, tcm.puid,work_manager as bz_name,
sum(TIMESTAMPDIFF(minute,tdu.up_time,IFNULL(tdu.down_time,concat(tdu.create_day,' 23:59:00')))) as online_time,
count(tpa.id) as people_num
from t_class_metting tcm
left join t_ticket_info tti on tcm.ticket_id = tti.id
left join t_device td on td.puid = tcm.puid
left join t_ticket_info_people ttip on tti.id = ttip.ticket_id
left join t_person_attendance tpa on tpa.id_card = ttip.id_number and tpa.create_time = current_date
left join t_device_updown tdu on tdu.puid = tcm.puid
<where>
and tcm.work_day = current_date
<if test="name != null and name != ''"> and tcm.work_manager like concat('%',#{name},'%')</if>
<if test="projectName != null and projectName != ''"> and tcm.bid_name like concat('%',#{projectName},'%')</if>
<if test="buildOrgNo != null and buildOrgNo != ''"> and tcm.org = #{buildOrgNo}</if>
</where>
group by tcm.class_id
</select>
<select id="getPlanZxList" resultType="com.sercurityControl.decision.domain.PlanZx">
select jwp.build_unit as build_org_name,tti.job_leader as bz_name,
jwp.project_name,tti.job_gx as today_gx,jwp.work_gx as week_gx,
tti.job_site as today_site,jwp.position as week_site,tti.job_lx as today_lx,jwp.work_type as week_lx
from jj_week_plan jwp
inner join t_ticket_info tti on tti.bid_no = jwp.bid_no
<where>
and jwp.end_date >= current_date and (tti.job_actual_end_time is null or tti.job_actual_end_time >= current_date)
<if test="projectName != null and projectName != ''"> and jwp.project_name like concat('%',#{projectName},'%')</if>
<if test="buildOrgNo != null and buildOrgNo != ''"> and jwp.build_no = #{buildOrgNo}</if>
</where>
</select>
<select id="getGuGanList" resultType="com.sercurityControl.decision.domain.Gjgwzc">
select * from (
select tti.project_name,tti.id,tti.job_leader as bz_name,city_name as build_org_name,
(select 1 from t_ticket_info_people ttip where tti.id = ttip.ticket_id and ttip.people_type = '班长兼指挥' limit 1) as bz,
(select 1 from t_ticket_info_people ttip where tti.id = ttip.ticket_id and ttip.people_type = '班组安全员' limit 1) as aq,
(select 1 from t_ticket_info_people ttip where tti.id = ttip.ticket_id and ttip.people_type = '班组技术兼质检员' limit 1) as js,
(select 1 from t_ticket_info_people ttip where tti.id = ttip.ticket_id and ttip.people_type = '牵张机械操作手' limit 1) as jxcz
from t_ticket_info tti
left join sys_org on org_id = tti.build_org_no
where (job_actual_end_time is null or job_actual_end_time >= current_date)
<if test="projectName != null and projectName != ''"> and tti.project_name like concat('%',#{projectName},'%')</if>
<if test="buildOrgNo != null and buildOrgNo != ''"> and tti.build_org_no = #{buildOrgNo}</if>
) a
where bz is not null or aq is not null or js is not null or jxcz is not null
</select>
<select id="getExistZc" resultType="java.lang.String">
select 1
from t_ticket_info_people ttip
where people_type = #{peopleType} and ticket_id = #{ticketId}
and EXISTS (select 1 from t_person_attendance tpa where tpa.id_card =ttip.id_number and tpa.create_time = current_date) limit 1
</select>
<select id="getTeamZzList" resultType="com.sercurityControl.decision.domain.Gjgwzc">
select tti.project_name,tti.job_leader as bz_name,city_name as build_org_name,
'具有资质' as bz,'具有资质' as aq,'具有资质' as js,'具有资质' as jxcz
from t_ticket_info tti
left join sys_org on org_id = tti.build_org_no
where (job_actual_end_time is null or job_actual_end_time >= current_date)
<if test="projectName != null and projectName != ''"> and tti.project_name like concat('%',#{projectName},'%')</if>
<if test="buildOrgNo != null and buildOrgNo != ''"> and tti.build_org_no = #{buildOrgNo}</if>
</select>
<select id="getYbryList" resultType="com.sercurityControl.decision.domain.Gjgwzc">
select build_unit as build_org_name,work_manager as bz_name ,work_manager_num as id ,
bid_name as project_name,job_risk_fc_level_num as risk_grade
from t_class_metting tcm
left join t_ticket_info tti on tcm.ticket_id = tti.id
<where>
and (job_actual_end_time is null or job_actual_end_time >= current_date)
<if test="projectName != null and projectName != ''"> and tti.project_name like concat('%',#{projectName},'%')</if>
<if test="buildOrgNo != null and buildOrgNo != ''"> and tti.build_org_no = #{buildOrgNo}</if>
</where>
</select>
<select id="getWorkTeamPeopleNum" resultType="java.util.Map">
SELECT sum(b.num) as num, sum(b.num2) as num2
from (
select COUNT(cp.id_number) num, 0 num2
FROM (
select class_id, sg_num, create_time
from t_class_metting
WHERE work_manager_num = #{id} AND work_day = CURRENT_DATE()
AND del_flag = '0'
ORDER BY create_time desc
LIMIT 1
) cm
left join t_class_metting_people cp on cm.class_id = cp.class_id
union all
select 0, COUNT(cp.id_number) num
FROM (
select class_id, sg_num, create_time, (curdate() - INTERVAL 1 DAY)
from t_class_metting
WHERE work_manager_num = #{id} AND work_day = (curdate() - INTERVAL 1 DAY)
AND del_flag = '0'
ORDER BY create_time desc
LIMIT 1
) cm
left join t_class_metting_people cp on cm.class_id = cp.class_id
) b
</select>
<select id="getXczyList" resultType="com.sercurityControl.decision.domain.Sgbz">
select tcm.build_unit as build_org_name ,bid_name as project_name, work_manager as bz_name , work_manager_phone as bz_phone,work_day,
count(tcmp.id) as people_num,tcm.class_id,
job_lx,job_gx,job_site ,tti.job_risk_fc_level_num as risk_grade
from t_class_metting tcm
left join t_ticket_info tti on tcm.ticket_id = tti.id
left join t_class_metting_people tcmp on tcmp.class_id = tcm.class_id
<where>
and work_day = current_date
<if test="projectName != null and projectName != ''"> and tcm.bid_name like concat('%',#{projectName},'%')</if>
<if test="buildOrgNo != null and buildOrgNo != ''"> and tcm.org = #{buildOrgNo}</if>
</where>
group by tcm.class_id
</select>
<select id="getClassKqNum" resultType="java.lang.String">
select count(1)
from t_class_metting_people tcmp
inner join t_person_attendance tpa on tpa.id_card = tcmp.id_number and tpa.create_time = current_date
where tcmp.class_id = #{classId}
</select>
<select id="getTicketPeople" resultType="java.lang.String">
select group_concat(DISTINCT user_name SEPARATOR ',')
from t_ticket_info_people
where ticket_id = #{ticketId}
</select>
<select id="getGjzgList" resultType="com.sercurityControl.decision.domain.SeriousPeccancy">
select build_unit as build_org_name,bid_name as project_name,work_manager as bz_name,
content,tnv.create_time as supervise_date,rec_time,job_risk_fc_level_num as risk_grade,
tnv.status,count(tp.id) as photo_num,group_concat(DISTINCT image_path SEPARATOR ',') as image_path
from t_class_metting tcm
inner join t_notice_voi tnv on tnv.class_id = tcm.class_id
left join t_ticket_info tti on tcm.ticket_id = tti.id
left join t_notice_voi_photo tp on tnv.id = tp.noti_id and tp.image_type = '1'
<where>
<if test="projectName != null and projectName != ''"> and tcm.bid_name like concat('%',#{projectName},'%')</if>
<if test="buildOrgNo != null and buildOrgNo != ''"> and tcm.org = #{buildOrgNo}</if>
</where>
group by tnv.id
order by supervise_date desc
</select>
<select id="getTeamSgfxList" resultType="com.sercurityControl.decision.domain.Sgfx">
select a.* ,ifnull(b.wzg,0) as wzg,ifnull(c.zgbhg,0) as zgbhg,'0' as yqzg
from (
select any_value(build_unit) as build_org_name,tcm.bid_code as bid_no,any_value(bid_name) as project_name,count(distinct tcm.team_name) as team_num ,count(tnv.id) as sg_num
from t_class_metting tcm
inner join t_notice_voi tnv on tnv.class_id = tcm.class_id and tnv.is_flag = '0'
<where>
<if test="projectName != null and projectName != ''"> and tcm.bid_name like concat('%',#{projectName},'%')</if>
<if test="buildOrgNo != null and buildOrgNo != ''"> and tcm.org = #{buildOrgNo}</if>
</where>
group by tcm.bid_code) a
left join (
select 1 as wzg ,tcm.bid_code
from t_class_metting tcm
inner join t_notice_voi tnv on tnv.class_id = tcm.class_id and tnv.is_flag = '0'
where tnv.status = '1'
group by tcm.bid_code ) b on a.bid_no = b.bid_code
left join (
select 1 as zgbhg ,tcm.bid_code
from t_class_metting tcm
inner join t_notice_voi tnv on tnv.class_id = tcm.class_id and tnv.is_flag = '0'
where tnv.status = '3'
group by tcm.bid_code ) c on a.bid_no = b.bid_code
</select>
<select id="getBzSgfxList" resultType="com.sercurityControl.decision.domain.Sgfx">
select a.* ,ifnull(b.wzg,0) as wzg,ifnull(c.zgbhg,0) as zgbhg,'0' as yqzg
from (
select any_value(build_unit) as build_org_name,any_value(work_manager) as bz_name,any_value(tcm.bid_name) as project_name,count(tnv.id) as sg_num,tcm.team_name
from t_class_metting tcm
inner join t_notice_voi tnv on tnv.class_id = tcm.class_id and tnv.is_flag = '0'
where tcm.bid_code = #{bidNo}
<if test="name != null and name != ''"> and tcm.work_manager concat('%',#{name},'%')</if>
group by tcm.team_name) a
left join (
select 1 as wzg ,tcm.team_name
from t_class_metting tcm
inner join t_notice_voi tnv on tnv.class_id = tcm.class_id and tnv.is_flag = '0'
where tcm.bid_code = #{bidNo} and tnv.status = '1'
group by tcm.team_name
) b on b.team_name = a.team_name
left join (
select 1 as zgbhg ,tcm.team_name
from t_class_metting tcm
inner join t_notice_voi tnv on tnv.class_id = tcm.class_id and tnv.is_flag = '0'
where tcm.bid_code = #{bidNo} and tnv.status = '3'
group by tcm.team_name
) c on c.team_name = a.team_name
</select>
</mapper>