jl-jjsp-service/securityControl-modules/securityControl-proteam/target/classes/mapper/ProDataMapper.xml

520 lines
24 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.proteam.mapper.ProDataMapper">
<select id="getProList" resultType="com.sercurityControl.proteam.domain.ProData"
parameterType="com.sercurityControl.proteam.domain.ProData">
select
so.city_name orgName,jdc.`value` proType,
jsi.single_project_name bidName,jsi.`safety_project_status` state
,jsi.single_project_code bidCode
from jj_single_info jsi
left join sys_org so on so.org_id=jsi.build_unit_code
left join jj_data_code jdc on jdc.code_value=jsi.single_project_type and jdc.`code`='single_project_type'
<if test='isSup=="3"'>
<if test="currentUserOrgId!=null and currentUserOrgId!=''">
and jsi.build_unit_code=#{currentUserOrgId}
</if>
</if>
<if test="buildUnitList!=null and buildUnitList!='' ">
and jsi.build_unit_code in(
<foreach collection="buildUnitList" item="item" separator=",">
#{item}
</foreach>
)
</if>
<if test="bidCodeList!=null and bidCodeList!='' ">
and jsi.single_project_code in(
<foreach collection="bidCodeList" item="item" separator=",">
#{item}
</foreach>
)
</if>
<if test="status!=null and status!=''">
and jsi.`safety_project_status`=#{status}
</if>
<if test="proDetailType!=null and proDetailType!=''">
and jsi.single_project_type = #{proDetailType}
</if>
</select>
<select id="getClassLists" resultType="com.sercurityControl.proteam.domain.ClassData"
parameterType="com.sercurityControl.proteam.domain.ProData">
select jcm.id,jcm.re_assessment_risk_level,jcmi.work_manage workManager,jdc.`value` riskLevel,
jcmi.work_manage_phone workManagerPhone, if(td.state = '1', '在线', '不在线') AS sgStatus,
CONCAT(jt.planned_start_date, '~',jt.planned_end_date ) AS workDay
FROM jj_class_meetting jcm
left join jj_class_metting_info jcmi on jcm.id =jcmi.class_id
left join jj_ticket jt on jt.id=jcm.ticket_id and jt.delete_flag=0
left join jj_data_code jdc on jdc.code_value=jcm.re_assessment_risk_level and jdc.`code`='risk_level'
left join jj_ball jbl on jbl.id=jcm.camera_id2 and jbl.delete_flag=0
left join t_device td on td.t_code=jbl.camera_no and td.is_flag=0
WHERE jcm.delete_flag=0 and jcm.current_constr_date=CURRENT_DATE()
and jcm.bidding_section_code=#{bidCode}
<if test="org != null and org != ''">
AND jcm.build_unit_code=#{org}
</if>
<if test="riskLevel!=null and riskLevel!=''">
AND jcm.re_assessment_risk_level = #{riskLevel}
</if>
<if test="sgStatus!=null and sgStatus!=''">
and td.state = #{sgStatus}
</if>
<if test="keyWord != null and keyWord != ''">
ANd (sd.`name` LIKE CONCAT('%',#{keyWord},'%') or jcmi.work_manage LIKE CONCAT('%',#{keyWord},'%'))
</if>
</select>
<select id="getTicketLists" resultType="com.sercurityControl.proteam.domain.TicketData"
parameterType="com.sercurityControl.proteam.domain.TicketData">
select CONCAT(jt.planned_start_date, '~',jt.planned_end_date ) AS format,jtp.real_name
,jt.working_team_name foreman,jt.id
from jj_ticket jt
left join jj_ticket_people jtp on jt.id =jtp.ticket_id and jtp.position_code='0900101'
LEFT JOIN sys_org AS so ON so.org_id = jt.build_unit_code
left join jj_class_meetting jcm on jcm.ticket_id=jt.id and jcm.delete_flag=0 and jcm.current_constr_date=CURRENT_DATE()
WHERE jt.delete_flag=0 and
jcm.id is not null and
jt.bidding_section_code=#{bidCode}
<if test="org != null and org != ''">
AND jt.build_unit_code=#{org}
</if>
<if test="keyWord!=null and keyWord!='' ">
and(
jt.working_team_name like concat('%',concat(#{keyWord},'%'))
)
</if>
</select>
<select id="getBasicInfoData" resultType="com.sercurityControl.proteam.domain.ProDataNum">
SELECT IFNULL(SUM(zjnum),0) zjnum, IFNULL(SUM(ssNum),0) ssNum, IFNULL(SUM(ejfxNum),0) ejfxNum, IFNULL(SUM(sjfxNum),0) sjfxNum,
IFNULL(SUM(fffNum),0) fffNum, IFNULL(SUM(wjfxNum),0) wjfxNum, IFNULL(SUM(workTeam),0) teamNum,IFNULL(SUM(sgNum),0) sgNum
FROM (
-- 在建工程
select IFNULL(COUNT(bidding_section_code),0) 'zjnum',0 'ssNum',0 'ejfxNum',0 'sjfxNum',0 'fffNum',0 'wjfxNum' ,0 'workTeam',0 'sgNum'
from jj_bid_info jdi
where jdi.safety_project_status='02' and jdi.delete_flag=0
<if test='isSup=="3"'>
<if test="currentUserOrgId!=null and currentUserOrgId!=''">
and jdi.build_unit_code=#{currentUserOrgId}
</if>
</if>
<if test="buildUnitList!=null and buildUnitList!='' ">
and jdi.build_unit_code in(
<foreach collection="buildUnitList" item="item" separator=",">
#{item}
</foreach>
)
</if>
union All
-- 实施工程数量
select 0,IFNULL(COUNT(distinct jcm.bidding_section_code),0) 'ssNum',0,0,0,0,0,0
from jj_class_meetting jcm
where jcm.current_constr_date=CURRENT_DATE() and jcm.delete_flag=0
<if test='isSup=="3"'>
<if test="currentUserOrgId!=null and currentUserOrgId!=''">
and jcm.build_unit_code=#{currentUserOrgId}
</if>
</if>
<if test="buildUnitList!=null and buildUnitList!='' ">
and jcm.build_unit_code in(
<foreach collection="buildUnitList" item="item" separator=",">
#{item}
</foreach>
)
</if>
union ALL
-- 二级风险
SELECT 0,0,IFNULL(COUNT(id),0) 'ejfxNum',0,0,0,0,0
FROM jj_class_meetting
where current_constr_date=DATE_FORMAT(now(),'%Y-%m-%d')
and re_assessment_risk_level in('2','二级') AND delete_flag=0
<if test='isSup=="3"'>
<if test="currentUserOrgId!=null and currentUserOrgId!=''">
and build_unit_code=#{currentUserOrgId}
</if>
</if>
<if test="buildUnitList!=null and buildUnitList!='' ">
and build_unit_code in(
<foreach collection="buildUnitList" item="item" separator=",">
#{item}
</foreach>
)
</if>
union ALL
-- 三级风险
SELECT 0,0,0, IFNULL(COUNT(id),0) 'sjfxNum',0,0 ,0,0
FROM jj_class_meetting
where current_constr_date=DATE_FORMAT(now(),'%Y-%m-%d') and re_assessment_risk_level in('3','三级') AND delete_flag=0
<if test='isSup=="3"'>
<if test="currentUserOrgId!=null and currentUserOrgId!=''">
and build_unit_code=#{currentUserOrgId}
</if>
</if>
<if test="buildUnitList!=null and buildUnitList!='' ">
and build_unit_code in(
<foreach collection="buildUnitList" item="item" separator=",">
#{item}
</foreach>
)
</if>
union ALL
-- 四季风险
SELECT 0,0,0,0, IFNULL(COUNT(id),0) 'fffNum' ,0,0,0
FROM jj_class_meetting
where current_constr_date=DATE_FORMAT(now(),'%Y-%m-%d') and re_assessment_risk_level in('4','四级') AND delete_flag=0
<if test='isSup=="3"'>
<if test="currentUserOrgId!=null and currentUserOrgId!=''">
and build_unit_code=#{currentUserOrgId}
</if>
</if>
<if test="buildUnitList!=null and buildUnitList!='' ">
and build_unit_code in(
<foreach collection="buildUnitList" item="item" separator=",">
#{item}
</foreach>
)
</if>
union ALL
-- 五级风险
SELECT 0,0,0,0,0, IFNULL(COUNT(id),0) 'wjfxNum' ,0,0
FROM jj_class_meetting
where current_constr_date=DATE_FORMAT(now(),'%Y-%m-%d') and re_assessment_risk_level in('5','五级') AND delete_flag=0
<if test='isSup=="3"'>
<if test="currentUserOrgId!=null and currentUserOrgId!=''">
and build_unit_code=#{currentUserOrgId}
</if>
</if>
<if test="buildUnitList!=null and buildUnitList!='' ">
and build_unit_code in(
<foreach collection="buildUnitList" item="item" separator=",">
#{item}
</foreach>
)
</if>
union ALL
-- 班组数量
select 0,0,0,0,0,0,count(distinct jcmi.team_id) workTeam,0
from jj_class_meetting cm
left join jj_class_metting_info jcmi on jcmi.class_id=cm.id
where current_constr_date=DATE_FORMAT(now(),'%Y-%m-%d')
<if test='isSup=="3"'>
<if test="currentUserOrgId!=null and currentUserOrgId!=''">
and build_unit_code=#{currentUserOrgId}
</if>
</if>
<if test="buildUnitList!=null and buildUnitList!='' ">
and build_unit_code in(
<foreach collection="buildUnitList" item="item" separator=",">
#{item}
</foreach>
)
</if>
union ALL
-- 施工人数
select 0,0,0,0,0,0,0,CAST(SUM(cm.current_constr_headcount)AS UNSIGNED) workTeam
from jj_class_meetting cm
where CURRENT_DATE=DATE_FORMAT(now(),'%Y-%m-%d')
<if test='isSup=="3"'>
<if test="currentUserOrgId!=null and currentUserOrgId!=''">
and cm.build_unit_code=#{currentUserOrgId}
</if>
</if>
<if test="buildUnitList!=null and buildUnitList!='' ">
and build_unit_code in(
<foreach collection="buildUnitList" item="item" separator=",">
#{item}
</foreach>
)
</if>
)B
</select>
<select id="getProject" resultType="com.sercurityControl.proteam.domain.ProData">
SELECT distinct bid_no AS proCode, bid_name AS bidName
FROM jj_bid_project
<where>
<if test="isSup == 3">
build_no = #{currentUserOrgId}
</if>
</where>
</select>
<!-- 工程下拉选 -->
<select id="getProjectSelect" resultType="com.sercurityControl.proteam.domain.ProData">
SELECT distinct single_project_code AS proCode, single_project_name AS proName
FROM jj_single_project
<where>
<if test="isSup == 3">
build_unit_code = #{currentUserOrgId}
</if>
</where>
</select>
<select id="getProdDetail" resultType="com.sercurityControl.proteam.domain.ProData"
parameterType="com.sercurityControl.proteam.domain.ProData">
select jbi.bidding_section_name proName,so.city_name orgName,jbi.bidding_section_code bidCode
from jj_bid_info jbi
LEFT JOIN sys_org so on so.org_id=jbi.build_unit_code
where jbi.bidding_section_code=#{bidCode} and jbi.delete_flag=0
</select>
<select id="getProWorkTeam" resultType="com.sercurityControl.proteam.domain.ProData" parameterType="com.sercurityControl.proteam.domain.ProData">
SELECT jtt.id teamId,jtp.id_card idNumber,ju.mobile ,jtt.working_team_name teamName,jtt.team_status status,
jtp.real_name fzrName,jti.import_team importTeam,jti.zhpj
from jj_team jtt
left join jj_team_info jti on jti.team_id=jtt.id
left join jj_team_people jtp on jtp.team_id=jtt.id and jtp.position_code='0900101' and jtp.delete_flag=0
left join jj_user ju on ju.id=jtp.personnel_id and ju.delete_flag=0
WHERE jtt.delete_flag=0 and jtt.bidding_section_code=#{bidCode}
<if test="keyWord!=null and keyWord!=''">
and (
jtt.working_team_name like concat('%',#{keyWord},'%') or
ju.mobile like concat('%',#{keyWord},'%') or
jtp.real_name like concat('%',#{keyWord},'%')
)
</if>
</select>
<!--工程维护分页查询-->
<select id="getProjectPreservation" resultType="com.sercurityControl.proteam.domain.vo.PreservationVo" parameterType="com.sercurityControl.proteam.domain.vo.PreservationVo">
select id,unit ,aq_code ,pro_name ,zsgcfw ,gcgm ,aqzj ,org ,jldw ,sgdw ,gcwz ,jhkgsj ,jhjgsj ,gcjd ,gczt ,risklevel ,risk_ly ,update_time ,next_time ,next_import,remarks
from bns_project
where del_flag='0'
<if test="unit!=null and unit!=''">
and unit like concat('%',concat(#{unit},'%'))
</if>
<if test="pro_name!=null and pro_name!=''">
and pro_name like concat('%',concat(#{pro_name},'%'))
</if>
<if test="gcgm!=null and gcgm!=''">
and gcgm like concat('%',concat(#{gcgm},'%'))
</if>
<if test="gcwz!=null and gcwz!=''">
and gcwz like concat('%',concat(#{gcwz},'%'))
</if>
<if test="sgdw!=null and sgdw!=''">
and sgdw like concat('%',concat(#{sgdw},'%'))
</if>
<if test="keyWord!=null and keyWord!=''">
and (
unit like concat('%',concat(#{keyWord},'%')) or
pro_name like concat('%',concat(#{keyWord},'%'))
)
</if>
</select>
<!--通过id查询详情-->
<select id="getPreservation" resultType="com.sercurityControl.proteam.domain.vo.PreservationVo" parameterType="String">
select id,unit ,aq_code ,pro_name ,zsgcfw ,gcgm ,aqzj ,
org ,jldw ,sgdw ,gcwz ,jhkgsj ,jhjgsj ,gcjd ,gczt ,risklevel ,risk_ly ,update_time ,next_time ,next_import,remarks
from bns_project
where id=#{id}
</select>
<update id="deletePreservation" parameterType="String">
update bns_project set del_flag='1' WHERE id=#{id}
</update>
<update id="deleteAllPreservation" parameterType="com.sercurityControl.proteam.domain.vo.PreservationVo">
update bns_project set del_flag='1' WHERE del_flag='0'
</update>
<!--插入-->
<insert id="insertPreservation" parameterType="com.sercurityControl.proteam.domain.vo.PreservationVo">
insert into
bns_project(unit ,aq_code ,pro_name ,zsgcfw ,gcgm ,aqzj ,
org ,jldw ,sgdw ,gcwz ,jhkgsj ,jhjgsj ,gcjd ,gczt ,risklevel ,risk_ly ,update_time ,next_time ,next_import,remarks,del_flag)
VALUE (
#{unit}, #{aq_code}, #{pro_name}, #{zsgcfw}, #{gcgm},#{aqzj}, #{org}, #{jldw}, #{sgdw}, #{gcwz}, #{jhkgsj}, #{jhjgsj},
#{gcjd},#{gczt},#{risklevel},#{risk_ly},#{update_time},#{next_time},#{next_import}, #{remarks},'0'
)
</insert>
<!--修改-->
<update id="updatePreservation" parameterType="com.sercurityControl.proteam.domain.vo.PreservationVo" >
update bns_project
<set>
<if test="unit !=null and unit !=''">
,unit=#{unit}
</if>
<if test="aq_code !=null and aq_code !=''">
,aq_code=#{aq_code}
</if>
<if test="pro_name !=null and pro_name !=''">
,pro_name=#{pro_name}
</if>
<if test="zsgcfw !=null and zsgcfw !=''">
,zsgcfw=#{zsgcfw}
</if>
<if test="gcgm !=null and gcgm !=''">
,gcgm=#{gcgm}
</if>
<if test="aqzj !=null and aqzj !=''">
,aqzj=#{aqzj}
</if>
<if test="org !=null and org !=''">
,org=#{org}
</if>
<if test="jldw !=null and jldw !=''">
,jldw=#{jldw}
</if>
<if test="sgdw !=null and sgdw !=''">
,sgdw=#{sgdw}
</if>
<if test="gcwz !=null and gcwz !=''">
,gcwz=#{gcwz}
</if>
<if test="jhkgsj !=null and jhkgsj !=''">
,jhkgsj=#{jhkgsj}
</if>
<if test="jhjgsj !=null and jhjgsj !=''">
,jhjgsj=#{jhjgsj}
</if>
<if test="gcjd !=null and gcjd !=''">
,gcjd=#{gcjd}
</if>
<if test="gczt !=null and gczt !=''">
,gczt=#{gczt}
</if>
<if test="risklevel !=null and risklevel !=''">
,risklevel=#{risklevel}
</if>
<if test="risk_ly !=null and risk_ly !=''">
,risk_ly=#{risk_ly}
</if>
<if test="update_time !=null and update_time !=''">
,update_time=#{update_time}
</if>
<if test="next_time !=null and next_time !=''">
,next_time=#{next_time}
</if>
<if test="next_import !=null and next_import !=''">
,next_import=#{next_import}
</if>
<if test="remarks !=null and remarks !=''">
,remarks=#{remarks}
</if>
</set>
WHERE id=#{id}
</update>
<insert id="addImportData" >
INSERT INTO bns_project(unit ,aq_code ,pro_name ,zsgcfw ,gcgm ,aqzj ,
org ,jldw ,sgdw ,gcwz ,jhkgsj ,jhjgsj ,gcjd ,gczt ,risklevel ,risk_ly ,update_time ,next_time ,next_import,remarks,del_flag) VALUES
<foreach collection="list" item="item" separator=",">
(
#{item.unit}, #{item.aq_code}, #{item.pro_name}, #{item.zsgcfw}, #{item.gcgm},#{item.aqzj}, #{item.org}, #{item.jldw}, #{item.sgdw}, #{item.gcwz}, #{item.jhkgsj}, #{item.jhjgsj},
#{item.gcjd},#{item.gczt},#{item.risklevel},#{item.risk_ly},#{item.update_time},#{item.next_time},#{item.next_import},#{item.remarks}, '0'
)
</foreach>
</insert>
<!--根据单项编码获取站班会施工人数-->
<select id="getClassPeople" resultType="java.lang.String">
select concat(IFNULL(COUNT(jcm.id),0),"/",IFNULL(SUM(current_constr_headcount),0))
from jj_class_meetting jcm
WHERE jcm.current_constr_date=CURRENT_DATE() and jcm.delete_flag=0
and jcm.bidding_section_code=#{bidCode}
UNION ALL
select concat(IFNULL(COUNT(jcm.id),0),"/",IFNULL(SUM(current_constr_headcount),0))
from jj_class_meetting jcm
WHERE jcm.current_constr_date= DATE_FORMAT(curdate() - INTERVAL 1 DAY, '%Y-%m-%d')
and jcm.delete_flag=0 and jcm.bidding_section_code=#{bidCode}
UNION ALL
select IFNULL(COUNT(jcm.id),0)
from jj_class_meetting jcm
WHERE jcm.current_constr_date=CURRENT_DATE() and jcm.delete_flag=0
and jcm.re_assessment_risk_level='2' and jcm.bidding_section_code=#{bidCode}
UNION ALL
select IFNULL(COUNT(jcm.id),0)
from jj_class_meetting jcm
WHERE jcm.current_constr_date=CURRENT_DATE() and jcm.delete_flag=0
and jcm.re_assessment_risk_level='3' and jcm.bidding_section_code=#{bidCode}
UNION ALL
select IFNULL(COUNT(jcm.id),0)
from jj_class_meetting jcm
WHERE jcm.current_constr_date=CURRENT_DATE() and jcm.delete_flag=0
and jcm.re_assessment_risk_level='4' and jcm.bidding_section_code=#{bidCode}
UNION ALL
select IFNULL(COUNT(jcm.id),0)
from jj_class_meetting jcm
WHERE jcm.current_constr_date=CURRENT_DATE() and jcm.delete_flag=0
and jcm.re_assessment_risk_level='5' and jcm.bidding_section_code=#{bidCode}
union ALL
select IFNULL(COUNT(jtt.id),0)
from jj_team jtt
where jtt.delete_flag=0 and jtt.team_status='01'
and jtt.bidding_section_code=#{bidCode}
union ALL
select IFNULL(COUNT(tnv.id),0)
from t_notice_voi tnv
WHERE tnv.`status` IN ('1','2','3','4','5') AND (tnv.sup_type IS NULL OR tnv.sup_type = '1')
AND tnv.bid_code=#{bidCode}
</select>
<select id="getUserList" resultType="com.sercurityControl.proteam.domain.JjUser">
select jdp.bidding_section_code bidCode ,jdp.department_type type ,
job_code ,job_name ,ju.real_name,ju.mobile
from jj_dept_gc_project jdp
left join jj_prj_enginnering_experience jpe on jpe.project_department_id=jdp.id and jpe.delete_flag=0
left join jj_user ju on ju.id=jpe.personnel_id and ju.delete_flag=0
where jdp.d_delete_flag=0
AND job_code in('0400101','0600103','0700101') -- 业主项目经理 、项目安全总监、'施工项目经理'
and jdp.bidding_section_code=#{bidCode}
</select>
<select id="getUnit" resultType="com.sercurityControl.proteam.domain.JjUser">
select ju.unit_name name,jdp.department_type type
from jj_dept_gc_project jdp
INNER JOIN jj_unit ju on ju.unit_code=jdp.affiliation_code and ju.delete_flag=0
where jdp.department_type='2' -- 监理单位
and jdp.single_project_code=#{bidCode}
union ALL
select ju.unit_name,jdp.department_type
from jj_dept_gc_project jdp
INNER JOIN jj_unit ju on ju.unit_code=jdp.affiliation_code and ju.delete_flag=0
where jdp.department_type='0' -- 施工单位
and jdp.single_project_code=#{bidCode}
</select>
<select id="getWeekList" resultType="java.lang.String">
select IFNULL(COUNT(jcm.id),0)
from jj_class_meetting jcm
WHERE jcm.delete_flag=0
and jcm.re_assessment_risk_level='2'
and jcm.current_constr_date between DATE(subdate(curdate()-1,date_format(curdate()-1,'%w')-1))
and DATE(subdate(curdate()-1,date_format(curdate()-1,'%w')-7))
and jcm.single_project_code=#{bidCode}
UNION ALL
select IFNULL(COUNT(jcm.id),0)
from jj_class_meetting jcm
WHERE jcm.delete_flag=0
and jcm.re_assessment_risk_level='3'
and jcm.current_constr_date between DATE(subdate(curdate()-1,date_format(curdate()-1,'%w')-1))
and DATE(subdate(curdate()-1,date_format(curdate()-1,'%w')-7))
and jcm.single_project_code=#{bidCode}
UNION ALL
select IFNULL(COUNT(jcm.id),0)
from jj_class_meetting jcm
WHERE jcm.delete_flag=0
and jcm.re_assessment_risk_level='4'
and jcm.current_constr_date between DATE(subdate(curdate()-1,date_format(curdate()-1,'%w')-1))
and DATE(subdate(curdate()-1,date_format(curdate()-1,'%w')-7))
and jcm.single_project_code=#{bidCode}
UNION ALL
select IFNULL(COUNT(jcm.id),0)
from jj_class_meetting jcm
WHERE jcm.delete_flag=0
and jcm.re_assessment_risk_level='5'
and jcm.current_constr_date between DATE(subdate(curdate()-1,date_format(curdate()-1,'%w')-1))
and DATE(subdate(curdate()-1,date_format(curdate()-1,'%w')-7))
and jcm.single_project_code=#{bidCode}
UNION ALL
select IFNULL(SUM(current_constr_headcount),0)
from jj_class_meetting jcm
WHERE jcm.current_constr_date=CURRENT_DATE() and jcm.delete_flag=0
and jcm.single_project_code=#{bidCode}
</select>
</mapper>