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

84 lines
5.3 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.SafeRiskMapper">
<select id="getMonitorList" resultType="com.sercurityControl.decision.domain.vo.SafeRiskVo">
select zyp.job_name as ticket_name, zyp.job_num as number,zyp.job_leader, zyp.job_gx,zyp.job_site,
job_risk_fc_level_num as risk_grade, t.mac_id as bm_code, bz.puid,
zyp.project_name
from t_ticket_info zyp
left join sgwpdm_bz_baill_mill bz on bz.BID_NO = zyp.BID_NO
left join t_device t on t.puid = bz.puid
<where>
<if test="projectName != null and projectName != ''">and zyp.`project_name` like concat('%',#{projectName},'%') </if>
<if test="buildOrgNo != null and buildOrgNo != ''">and zyp.`build_org_no` = #{buildOrgNo} </if>
<if test="riskGrade != null and riskGrade != ''">and zyp.`job_risk_fc_level_num` = concat(#{riskGrade},'级') </if>
</where>
</select>
<select id="getList" resultType="com.sercurityControl.decision.domain.qo.SafeRiskQo">
select id, project_name, ticket_name, risk_grade, number, job_leader, job_site, job_gx,
risk_cb, yj_date, status, date(create_time) as create_time,
case
when change_date is null then '0'
when change_date is not null and change_date &lt;= change_term then '1'
when change_date is not null and change_date > change_term then '2'
end as change_status
from decision_safe_risk
<where>
<if test=" flag == '4'.toString()">and important = '1' </if>
<if test=" flag == '5'.toString()">and `status` = '1' </if>
<if test="projectName != null and projectName != ''">and `project_name` like concat('%',#{projectName},'%') </if>
<if test="riskGrade != null and riskGrade != ''">and risk_grade = #{riskGrade} </if>
<choose>
<when test="changeStatus == '0'.toString()">and change_date is null </when>
<when test="changeStatus == '1'.toString()">and change_date is not null and change_date &lt;= change_term</when>
<when test="changeStatus == '2'.toString()">and change_date is not null and change_date > change_term</when>
</choose>
<if test="startDate != null and startDate != ''">and yj_date >= #{startDate} and yj_date &lt;= #{endDate}</if>
</where>
order by risk_cb desc
</select>
<select id="getDetail" resultType="com.sercurityControl.decision.domain.SafeRisk">
select id, project_name, ticket_name, risk_grade, number, job_leader, job_site, job_gx, bz_team, risk_cb, manage_control,
supplement_measure, important, yj_date, change_term, change_content, change_date, status
from decision_safe_risk
where id = #{id}
</select>
<insert id="insert">
insert into decision_safe_risk (id, project_name, project_no, ticket_name, risk_grade, number, job_leader,
job_site, job_gx, bz_team, risk_cb, manage_control, supplement_measure,
important, yj_date, change_term, status, create_time, update_time)
values (#{id},#{projectName},#{projectNo},#{ticketName},#{riskGrade},#{number},#{jobLeader},
#{jobSite},#{jobGx},#{bzTeam},#{riskCb},#{manageControl},#{supplementMeasure},
#{important},#{yjDate},#{changeTerm},#{status},now(),now())
</insert>
<update id="update">
update decision_safe_risk
<set>
<if test="projectName != null and projectName != ''">project_name = #{projectName}, </if>
<if test="ticketName != null and ticketName != ''">ticket_name = #{ticketName}, </if>
<if test="riskGrade != null and riskGrade != ''">risk_grade = #{riskGrade}, </if>
<if test="number != null and number != ''">`number` = #{number}, </if>
<if test="jobLeader != null and jobLeader != ''">job_leader = #{jobLeader}, </if>
<if test="jobSite != null and jobSite != ''">job_site = #{jobSite}, </if>
<if test="jobGx != null and jobGx != ''">job_gx = #{jobGx}, </if>
<if test="bzTeam != null and bzTeam != ''">bz_team = #{bzTeam}, </if>
<if test="riskCb != null and riskCb != ''">risk_cb = #{riskCb}, </if>
<if test="manageControl != null and manageControl != ''">manage_control = #{manageControl}, </if>
<if test="supplementMeasure != null and supplementMeasure != ''">supplement_measure = #{supplementMeasure}, </if>
<if test="important != null and important != ''">important = #{important}, </if>
<if test="yjDate != null and yjDate != ''">yj_date = #{yjDate}, </if>
<if test="changeTerm != null and changeTerm != ''">change_term = #{changeTerm}, </if>
<if test="status != null and status != ''">`status` = #{status}, </if>
<if test="changeContent != null and changeContent != ''">change_content = #{changeContent},</if>
<if test="changeDate != null and changeDate != ''">change_date = current_date,</if>
update_time = now()
</set>
where id = #{id}
</update>
</mapper>