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

433 lines
19 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.TeamMapper">
<resultMap type="com.sercurityControl.proteam.domain.TeamData" id="TeamDataMap">
<result column="id_number" property="idNumber"/>
<result column="phone" property="phone"/>
<result column="team_name" property="teamName"/>
<result column="fzr_name" property="fzrName"/>
<result column="class_id" property="classId"/>
<result column="y_class_id" property="yClassId"/>
<result column="day_num" property="dayNum"/>
<result column="ye_num" property="yeNum"/>
<result column="status" property="status"/>
<result column="pro_name" property="proName"/>
<result column="sign_name" property="signName"/>
<result column="bid_name" property="bidName"/>
<result column="content" property="content"/>
<result column="work_time" property="workTime"/>
<result column="update_day" property="updateDay"/>
<result column="import_team" property="importTeam"/>
<result column="zhpj" property="zhpj"/>
</resultMap>
<resultMap type="com.sercurityControl.proteam.domain.TeamEvaData" id="TeamEvaDataMap">
<result column="id" property="id"/>
<result column="id_number" property="idNumber"/>
<result column="aqwm" property="aqwm"/>
<result column="jsmm" property="jsmm"/>
<result column="sgaq" property="sgaq"/>
<result column="zhpj" property="zhpj"/>
<result column="content" property="content"/>
<result column="createt_time" property="createtTime"/>
<result column="createt_day" property="createtDay"/>
<result column="lable" property="labelName"/>
</resultMap>
<sql id="SelectBaseMap">
SELECT tw.id_number,
tw.phone, tw.team_name, tw.fzr_name, tw.class_id,
tw.y_class_id,tw.day_num, tw.ye_num,
CASE tw.status
WHEN '0' THEN '未施工'
WHEN '1' THEN '在施工'
WHEN '2' THEN '暂停'
WHEN '3' THEN '完工' END AS status,
tw.pro_name, tw.sign_name, tw.bid_name, tw.content, tw.work_time, tw.update_day,
tw.import_team, tw.zhpj,
(select count(*) from t_notice_voi where t_notice_voi.class_id = tw.class_id) AS vzNum,
tc.ticket_no AS ticketNo
FROM t_work_team as tw
LEFT JOIN t_class_metting AS tc ON tc.class_id = tw.class_id
LEFT JOIN t_class_metting_check tcmc ON tc.class_id = tcmc.class_id
</sql>
<sql id="SelectBaseEvaMap">
SELECT te.id,
te.id_number,
jtp.real_name AS fzrName,
tw.working_team_name AS teamName,
te.zhpj,
te.content,
su.user_name AS userId,
te.createt_time,
te.createt_day,
ttl.lable
FROM t_team_eva as te
LEFT JOIN sys_user su ON su.id = te.user_id
LEFT JOIN jj_team tw ON tw.id = te.team_id
LEFT join jj_team_people jtp on jtp.team_id=tw.id and jtp.position_code ='0900101'
LEFT JOIN t_team_label ttl ON te.team_id = ttl.id AND te.createt_time = ttl.create_time
</sql>
<insert id="insertTeamEva">
INSERT INTO t_team_eva (id_number, aqwm, jsmm, sgaq, zhpj, content, user_id, createt_time, createt_day, zbh_id,
team_name,team_id)
VALUES (#{idNumber}, #{aqwm}, #{jsmm}, #{sgaq}, #{zhpj}, #{content}, #{userId}, #{createtTime}, #{createtDay},
#{classId}, #{teamName},#{teamId});
</insert>
<insert id="insertTeamBlack" parameterType="com.sercurityControl.proteam.domain.TeamEvaData">
INSERT INTO t_black_team (id_number, black_time, remarks, operator, operat_time, status)
VALUES (#{idNumber}, #{createtTime}, #{content}, #{userId}, #{createtDay}, '0');
</insert>
<!--添加班组评价标签-->
<insert id="addTeamLabel">
INSERT INTO t_lable(name,create_time,user_id)
VALUES (
#{labelName},#{createTime},#{userId}
)
</insert>
<!--添加班组标签信息数据-->
<insert id="addTeamLabelData">
INSERT INTO t_team_label(id,lable,user_id,user_name,create_time) VALUES (
#{teamId},#{labelName},#{userId},#{userName},#{createtDay}
)
</insert>
<update id="deleteTeamBlack">
UPDATE t_black_team
SET status = '1'
WHERE id = #{id}
</update>
<update id="updateTeamEva" parameterType="com.sercurityControl.proteam.domain.TeamEvaData">
UPDATE jj_team_info set zhpj=#{zhpj},import_team=#{aqwm}
where team_id=#{teamId}
</update>
<update id="updateClasscheck" parameterType="com.sercurityControl.proteam.domain.TeamEvaData">
UPDATE t_class_metting_check
set is_pj='1'
WHERE class_id = #{classId}
</update>
<delete id="delTeamLabel">
DELETE FROM t_lable WHERE name = #{labelName}
</delete>
<!--查询班组 的班组长-->
<select id="getTeamLeader" parameterType="com.sercurityControl.proteam.domain.TeamData" resultType="com.sercurityControl.proteam.domain.TeamData">
select jtp.real_name fzrName,jtp.id_card idNumber,ju.mobile phone
FROM jj_team_people jtp
left join jj_user ju on ju.id=jtp.personnel_id and ju.delete_flag=0
where jtp.position_code='0900101' and jtp.delete_flag=0
and jtp.team_id=#{teamId}
limit 1
</select>
<select id="getTeamList" resultType="com.sercurityControl.proteam.domain.TeamData">
select jteam.id teamId ,jteam.working_team_name teamName ,jtmi.zhpj
,jteam.team_status status ,jbp.BIDDING_SECTION_NAME proName
FROM jj_team as jteam
left join jj_team_info jtmi on jtmi.team_id=jteam.id
left join jj_bidding_project jbp on jteam.bidding_section_code=jbp.bidding_section_code and jbp.DELETE_FLAG=0
WHERE jteam.delete_flag=0
<if test="isSup == 3">
AND jteam.build_unit_code = #{currentUserOrgId}
</if>
<if test="orgId != null and orgId != ''">
AND jteam.build_unit_code=#{orgId}
</if>
<if test="teamName != null and teamName != ''">
AND jteam.working_team_name LIKE CONCAT('%',#{teamName},'%')
</if>
<if test="proName != null and proName != ''">
AND jbp.BIDDING_SECTION_NAME LIKE CONCAT('%',#{proName},'%')
</if>
<if test="status != null and status != ''">
AND jteam.team_status IN (
<foreach collection="teamStatus" item="item" separator=",">
#{item}
</foreach>
)
</if>
<if test="keyWord != null and keyWord != ''">
AND( jbp.BIDDING_SECTION_NAME LIKE CONCAT('%',#{keyWord},'%')
or jteam.working_team_name LIKE CONCAT('%',#{keyWord},'%')
)
</if>
ORDER BY jtmi.zhpj desc
</select>
<select id="getTeamEvaList" resultMap="TeamEvaDataMap">
SELECT te.id,
te.id_number,
jtp.real_name AS fzrName,
tw.working_team_name AS teamName,
te.zhpj,
te.content,
ju.mobile phone,
su.user_name AS userId,
te.createt_time,
te.createt_day,
ttl.lable
FROM t_team_eva as te
LEFT JOIN sys_user su ON su.id = te.user_id
LEFT JOIN jj_team tw ON tw.id = te.team_id
LEFT join jj_team_people jtp on jtp.team_id=tw.id and jtp.position_code ='0900101'
left join jj_user ju on ju.id=jtp.personnel_id
LEFT JOIN t_team_label ttl ON te.team_id = ttl.id AND te.createt_time = ttl.create_time
WHERE te.team_id = #{teamId}
<if test="userId != null and userId != ''">
AND su.user_name LIKE CONCAT('%',#{userId},'%')
</if>
<if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
and DATE_FORMAT(te.createt_time,'%Y-%m-%d') between #{startTime} and #{endTime}
</if>
ORDER BY te.createt_time DESC
</select>
<select id="getTeamBlackList" resultType="com.sercurityControl.proteam.domain.TeamBlackData">
SELECT any_value(operator) AS teamName,
any_value(id_number) AS idNumber,
any_value(black_time) AS createtTime,
any_value(SUM(operat_time)) AS phone
FROM t_black_team
Where 1=1
<if test="teamName != null and teamName != ''">
AND operator LIKE CONCAT('%',#{teamName},'%')
</if>
GROUP BY id_number
<if test="status!=null and status!='' ">
<if test='status=="1"'>
HAVING phone &gt;6 and phone &lt;12
</if>
<if test='status=="2"'>
HAVING phone &gt;=12
</if>
</if>
<if test="status==null or status=='' ">
HAVING phone &gt; 6
</if>
ORDER BY phone DESC
</select>
<select id="getTeamScoreList" resultType="java.lang.String">
SELECT operat_time
FROM t_black_team
WHERE id_number = #{idNumber}
</select>
<select id="getClassList" resultType="com.sercurityControl.proteam.domain.ClassData"
parameterType="com.sercurityControl.proteam.domain.ClassData">
select
tc.id AS classId,
so.city_name AS org, jdc.`value` riskLevel,
tc.bidding_section_name AS bidName,
ju.unit_name AS sgdw,
tc.re_assessment_risk_level ,
IFNULL( jcmi.work_manage,'') AS workManager,
jcmi.work_manage_phone AS workManagerPhone,
tc.current_constr_date AS workDay,
tc.current_constr_headcount AS sgNum,
CASE tc.current_construction_status
WHEN '01' THEN '开工'
WHEN '02' THEN '暂停'
WHEN '03' THEN '作业中'
WHEN '04' THEN '完工'
END AS sgStatus,
jcmi.work_site AS workPosition,
jbl.camera_no cameraNo, td.mac_id AS macId,
td.state AS ballStatus, td.puid AS puid,
td.t_code AS tCode, td.tw_code AS twCode, td.td_code AS tdCode,
td.pass_way AS passWay, tc.delete_flag AS delFlag,
tc.bidding_section_code AS bidCode
FROM jj_class_meetting tc
left join jj_ball jbl on tc.camera_id2=jbl.id
left join t_device td on td.t_code=jbl.camera_no AND td.is_flag = '0'
left join jj_unit ju on ju.unified_social_credit_id=tc.constr_unified_social_credit_id and ju.delete_flag=0
left join jj_unit ju2 on ju2.unified_social_credit_id=tc.supervision_social_credit_code and ju2.delete_flag=0
left join jj_class_metting_info jcmi on tc.id=jcmi.class_id
LEFT JOIN t_class_metting_check tcmc ON tc.id = tcmc.class_id
LEFT JOIN sys_org AS so ON so.org_id = tc.build_unit_code
LEFT JOIN jj_data_code AS jdc ON jdc.code_value=tc.re_assessment_risk_level
and jdc.`code`='risk_level'
WHERE 1 = 1
<if test="org!=null and org!=''">
AND so.org_id IN (
<foreach collection="orgList" item="item" separator=",">
#{item}
</foreach>
)
</if>
<if test="workManager != null and workManager != ''">
AND jcmi.work_manage LIKE CONCAT('%',#{workManager},'%')
</if>
<if test="bidName != null and bidName != ''">
AND tc.bidding_section_name LIKE CONCAT('%',#{bidName},'%')
</if>
<if test="sgdw != null and sgdw != ''">
AND ju.unit_name LIKE CONCAT('%',#{sgdw},'%')
</if>
<if test="riskLevel != null and riskLevel != ''">
AND tc.re_assessment_risk_level IN (
<foreach collection="riskList" item="item" separator=",">
#{item}
</foreach>
)
</if>
<if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
and DATE_FORMAT(tc.current_constr_date,'%Y-%m-%d') between #{startTime} and #{endTime}
</if>
<if test="macId != null and macId != ''">
AND td.mac_id LIKE CONCAT('%',#{macId},'%')
</if>
order by tc.delete_flag
</select>
<select id="getOrgSelected" resultType="java.util.Map">
select org_id AS code,
city_name AS name
from sys_org
where is_active = 1
</select>
<!-- 根据传入的参数查询下拉选择数据 -->
<select id="getSelectParams" resultType="java.util.Map">
SELECT sd1.id AS `key`,sd1.`name` AS `value`,sd1.code AS code
FROM sys_dist sd1
LEFT JOIN sys_dist sd2 ON sd2.id = sd1.p_id
WHERE 1=1 and sd1.is_flag=0
<if test="code != null and code != ''">
AND sd2.CODE = #{code}
</if>
</select>
<select id="getPerNum" resultType="java.lang.String">
select IFNULL( count(distinct jcmi.team_id),0)
from jj_class_meetting jcm
LEFT JOIN jj_class_metting_info jcmi on jcmi.class_id=jcm.id
where jcm.current_constr_date=CURRENT_DATE() and jcm.delete_flag=0
UNION ALL
select IFNULL( count(distinct jcmi.team_id),0)
from jj_class_meetting jcm
LEFT JOIN jj_class_metting_info jcmi on jcmi.class_id=jcm.id
where jcm.current_constr_date=CURRENT_DATE() and jcm.current_construction_status in('01') and jcm.delete_flag=0
UNION ALL
select IFNULL(count( distinct jcmi.personnel_id),0)
from jj_class_meetting jcm
left join jj_class_meeting_people jcmi on jcmi.tool_box_talk_id=jcm.id and jcmi.position_flag=1
where jcm.current_constr_date=CURRENT_DATE() and jcm.delete_flag=0
UNION ALL
select IFNULL(count( distinct jcmi.personnel_id),0)
from jj_class_meetting jcm
left join jj_class_meeting_people jcmi on jcmi.tool_box_talk_id=jcm.id and jcmi.position_flag=1
where jcm.current_constr_date=CURRENT_DATE() and jcm.current_construction_status in('01') and jcm.delete_flag=0
UNION ALL
select count(jt.id)
from jj_team jt
left JOIN jj_class_metting_info jcmi on jcmi.team_id=jt.id
LEFT JOIN jj_class_meetting jcm on jcmi.class_id=jcm.id
where jcm.id is null and jt.team_status='01' and jcm.current_constr_date=CURRENT_DATE()
UNION ALL
select count(jt.id)
from jj_team jt
where jt.team_status='01' and DATE_FORMAT(jt.create_time, '%Y-%m-%d') = CURRENT_DATE()
UNION ALL
select count(distinct jcmi.team_id)
from jj_class_meetting jcm
LEFT JOIN jj_class_metting_info jcmi on jcmi.class_id=jcm.id
where jcm.current_constr_date between (curdate() - INTERVAL 30 DAY) and CURRENT_DATE()
UNION ALL
select IFNULL(count( distinct jcmi.personnel_id),0)
from jj_class_meetting jcm
left join jj_class_meeting_people jcmi on jcmi.tool_box_talk_id=jcm.id and jcmi.position_flag=1
where jcm.current_constr_date between (curdate() - INTERVAL 30 DAY) and CURRENT_DATE()
</select>
<!--查询一个月施工人数-->
<select id="getMonthPeopleNum" resultType="Integer">
SELECT SUM(cm.current_constr_headcount)
FROM jj_class_meetting cm
where cm.delete_flag=0
and cm.current_constr_date between (curdate() - INTERVAL 30 DAY) and date_format(SYSDATE(), '%Y-%m-%d')
</select>
<select id="getTeamPeople" resultType="com.sercurityControl.proteam.domain.PeopleEntity"
parameterType="com.sercurityControl.proteam.domain.PeopleEntity">
SELECT distinct jcmi.team_name AS teamName,
jdc.`value` AS type,
tp.real_name As name,
tp.id_card AS card,
'' AS photo,
0 AS achievement,
0 AS examination,
0 AS insurance,
0 AS points
FROM jj_class_meeting_people tp
left join jj_class_meetting jcm on jcm.id =tp.tool_box_talk_id and jcm.current_constr_date=CURRENT_DATE()
and jcm.delete_flag=0
LEFT JOIN jj_class_metting_info jcmi on jcmi.class_id=jcm.id
left join jj_data_code jdc on jdc.code_value=tp.position_code and jdc.`code`='POSITION_CODE'
where jcmi.team_id=#{teamId} and tp.delete_flag=0
<if test="card != null and card != ''">
AND tp.id_card LIKE CONCAT('%',#{card},'%')
</if>
<if test="name != null and name != ''">
AND tp.real_name LIKE CONCAT('%',#{name},'%')
</if>
<if test="type != null and type != ''">
AND jdc.`value` = #{type}
</if>
<if test="keyWord != null and keyWord != ''">
AND(tp.id_card LIKE CONCAT('%',#{keyWord},'%') or tp.real_name LIKE CONCAT('%',#{keyWord},'%'))
</if>
</select>
<select id="getAvg" resultType="java.lang.Integer"
parameterType="com.sercurityControl.proteam.domain.TeamEvaData">
SELECT ROUND(AVG(zhpj), 2)
from t_team_eva
WHERE id_number = #{idNumber}
</select>
<!--班组评价标签是否存在-->
<select id="labelIsRepeat" resultType="java.lang.Integer">
SELECT COUNT(*) FROM t_lable WHERE name = #{labelName}
</select>
<!--获取班组评价标签-->
<select id="getTeamLabel" resultType="com.sercurityControl.proteam.domain.vo.TeamLabelVo">
SELECT id,name AS labelName
FROM t_lable
ORDER BY create_time
</select>
<!--查询班组标签真实ID-->
<select id="getTeamLabelIds" resultType="java.lang.Integer">
SELECT id FROM t_lable
<where>
<if test="labelNameList == null">
name = '-1'
</if>
<if test="labelNameList != null">
AND `name` IN
<foreach collection="labelNameList" separator="," open="(" close=")" item="item">
#{item}
</foreach>
</if>
</where>
</select>
<!--获取班组历史违章数量-->
<select id="getTeamVoiNum" resultType="java.lang.Integer">
SELECT COUNT(*)
FROM t_notice_voi tnv
WHERE team_id = #{teamId} AND tnv.`status` NOT IN ('7','8') AND (tnv.sup_type IS NULL OR tnv.sup_type = '1')
</select>
<select id="getTodayNum" resultType="java.lang.Integer">
select IFNULL( current_constr_headcount,0)
FROM jj_class_meetting jcm
left join jj_class_metting_info jcmi on jcmi.class_id=jcm.id
where jcm.current_constr_date=CURRENT_DATE()
and jcmi.team_id=#{teamId}
ORDER BY jcm.work_start_time desc
limit 1
</select>
<select id="getYesNum" resultType="java.lang.Integer">
select IFNULL( current_constr_headcount,0)
FROM jj_class_meetting jcm
left join jj_class_metting_info jcmi on jcmi.class_id=jcm.id
where jcm.current_constr_date= DATE_SUB(CURDATE(), INTERVAL 1 DAY)
and jcmi.team_id=#{teamId}
ORDER BY jcm.work_start_time desc
limit 1
</select>
</mapper>