<?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.ruoyi.project.tr.riskList.mapper.RiskListMapper">
|
|
<resultMap type="com.ruoyi.project.tr.riskList.domain.RiskList" id="RiskListResult">
|
<result property="riskListId" column="risk_list_id" />
|
<result property="createBy" column="create_by" />
|
<result property="createTime" column="create_time" />
|
<result property="updateBy" column="update_by" />
|
<result property="updateTime" column="update_time" />
|
<result property="remark" column="remark" />
|
<result property="riskListNum" column="risk_list_num" />
|
<result property="riskListName" column="risk_list_name" />
|
<result property="riskListIsSpecial" column="risk_list_is_special" />
|
<result property="riskListImgUrl" column="risk_list_img_url" />
|
<result property="riskListDeviceType" column="risk_list_device_type" />
|
<result property="riskListDeviceModel" column="risk_list_device_model" />
|
<result property="riskListWorkType" column="risk_list_work_type" />
|
<result property="riskListWorkFrequency" column="risk_list_work_frequency" />
|
<result property="riskListCraftsType" column="risk_list_crafts_type" />
|
<result property="riskListCraftsDescription" column="risk_list_crafts_description" />
|
<result property="regionId" column="region_id" />
|
<result property="regionName" column="region_name" />
|
<result property="deptId" column="dept_id" />
|
<result property="deptName" column="dept_name" />
|
<result property="riskTypeName" column="risk_type_name" />
|
<result property="userId" column="user_id" />
|
<result property="userName" column="user_name" />
|
<result property="riskType" column="risk_type" />
|
<result property="companyId" column="company_id" />
|
<result property="isEvaluation" column="is_evaluation" />
|
</resultMap>
|
|
<resultMap type="com.ruoyi.project.tr.riskList.domain.RiskListByCrafts" id="CraftsResult">
|
<result property="riskListId" column="risk_list_id" />
|
<result property="createBy" column="create_by" />
|
<result property="createTime" column="create_time" />
|
<result property="updateBy" column="update_by" />
|
<result property="updateTime" column="update_time" />
|
<result property="remark" column="remark" />
|
<result property="riskListNum" column="risk_list_num" />
|
<result property="riskListName" column="risk_list_name" />
|
<result property="riskListIsSpecial" column="risk_list_is_special" />
|
<result property="riskListCraftsDescription" column="risk_list_crafts_description" />
|
<result property="regionName" column="region_name" />
|
<result property="deptName" column="dept_name" />
|
<result property="userName" column="user_name" />
|
</resultMap>
|
|
<resultMap type="com.ruoyi.project.tr.riskList.domain.RiskListByDevice" id="DeviceResult">
|
<result property="riskListId" column="risk_list_id" />
|
<result property="createBy" column="create_by" />
|
<result property="createTime" column="create_time" />
|
<result property="updateBy" column="update_by" />
|
<result property="updateTime" column="update_time" />
|
<result property="remark" column="remark" />
|
<result property="riskListNum" column="risk_list_num" />
|
<result property="riskListName" column="risk_list_name" />
|
<result property="riskListIsSpecial" column="risk_list_is_special" />
|
<result property="riskListDeviceModel" column="risk_list_device_model" />
|
<result property="regionName" column="region_name" />
|
<result property="deptName" column="dept_name" />
|
<result property="riskTypeName" column="risk_type_name" />
|
<result property="userName" column="user_name" />
|
</resultMap>
|
|
<resultMap type="com.ruoyi.project.tr.riskList.domain.RiskListByWork" id="WorkResult">
|
<result property="riskListId" column="risk_list_id" />
|
<result property="createBy" column="create_by" />
|
<result property="createTime" column="create_time" />
|
<result property="updateBy" column="update_by" />
|
<result property="updateTime" column="update_time" />
|
<result property="remark" column="remark" />
|
<result property="riskListNum" column="risk_list_num" />
|
<result property="riskListName" column="risk_list_name" />
|
<result property="riskListIsSpecial" column="risk_list_is_special" />
|
<result property="riskListWorkFrequency" column="risk_list_work_frequency" />
|
<result property="regionName" column="region_name" />
|
<result property="deptName" column="dept_name" />
|
<result property="userName" column="user_name" />
|
<result property="riskTypeName" column="risk_type_name" />
|
</resultMap>
|
|
|
<sql id="selectRiskListVo">
|
SELECT trl.risk_list_id, trl.create_by, trl.create_time, trl.update_by,
|
trl.update_time, trl.remark, trl.risk_list_num, trl.risk_list_name,
|
trl.risk_list_is_special, trl.risk_list_img_url, trl.risk_list_device_type,
|
trl.risk_list_device_model, trl.risk_list_work_type, trl.risk_list_work_frequency,
|
trl.risk_list_crafts_type, trl.risk_list_crafts_description, trl.region_id,tr.region_name,
|
trl.dept_id, su.user_name, trl.user_id, sd.dept_name, trl.risk_type, trl.company_id,trt.risk_type_name,
|
(SELECT COUNT(1) FROM tr_risk_evaluation_plan AS p WHERE trl.`risk_list_id` = p.evaluation_risk_id AND p.stage_status = 4 ) AS is_evaluation
|
FROM tr_risk_list trl
|
LEFT JOIN sys_user su ON trl.user_id = su.user_id
|
LEFT JOIN sys_dept sd ON trl.dept_id = sd.dept_id
|
LEFT JOIN tr_region tr ON trl.region_id = tr.region_id
|
LEFT JOIN tr_risk_type trt ON (trl.risk_list_device_type = trt.risk_type_id OR trl.risk_list_work_type = trt.risk_type_id OR trl.risk_list_crafts_type = trt.risk_type_id)
|
|
</sql>
|
|
<select id="selectRiskListList" parameterType="RiskList" resultMap="RiskListResult">
|
<include refid="selectRiskListVo"/>
|
<where>
|
<if test="riskListId != null "> and trl.risk_list_id = #{riskListId}</if>
|
<if test="createBy != null and createBy != ''"> and trl.create_by like concat('%', #{createBy}, '%')</if>
|
<if test="params.beginCreateTime != null and params.beginCreateTime != '' and params.endCreateTime != null and params.endCreateTime != ''">
|
and trl.create_time between #{params.beginCreateTime} and #{params.endCreateTime}
|
</if>
|
<if test="riskListNum != null and riskListNum != ''"> and trl.risk_list_num = #{riskListNum}</if>
|
<if test="riskListName != null and riskListName != ''"> and trl.risk_list_name like concat('%', #{riskListName}, '%')</if>
|
<if test="riskListIsSpecial != null "> and trl.risk_list_is_special = #{riskListIsSpecial}</if>
|
<if test="riskListImgUrl != null and riskListImgUrl != ''"> and trl.risk_list_img_url = #{riskListImgUrl}</if>
|
<if test="riskListDeviceType != null "> and trl.risk_list_device_type = #{riskListDeviceType}</if>
|
<if test="riskListDeviceModel != null and riskListDeviceModel != ''"> and trl.risk_list_device_model = #{riskListDeviceModel}</if>
|
<if test="riskListWorkType != null "> and trl.risk_list_work_type = #{riskListWorkType}</if>
|
<if test="riskListWorkFrequency != null "> and trl.risk_list_work_frequency = #{riskListWorkFrequency}</if>
|
<if test="riskListCraftsType != null "> and trl.risk_list_crafts_type = #{riskListCraftsType}</if>
|
<if test="riskListCraftsDescription != null and riskListCraftsDescription != ''"> and trl.risk_list_crafts_description = #{riskListCraftsDescription}</if>
|
<if test="regionId != null and regionId != ''"> and trl.region_id = #{regionId}</if>
|
<if test="deptId != null "> and trl.dept_id = #{deptId}</if>
|
<if test="userId != null "> and trl.user_id = #{userId}</if>
|
<if test="riskType != null "> and trl.risk_type = #{riskType}</if>
|
<if test="companyId != null "> and trl.company_id = #{companyId}</if>
|
<if test="isEvaluation != null and isEvaluation == 0"> and (SELECT COUNT(1) FROM tr_risk_evaluation_plan AS p WHERE trl.`risk_list_id` = p.evaluation_risk_id AND p.stage_status = 4 ) = 0</if>
|
<if test="isEvaluation != null and isEvaluation == 1"> and (SELECT COUNT(1) FROM tr_risk_evaluation_plan AS p WHERE trl.`risk_list_id` = p.evaluation_risk_id AND p.stage_status = 4 ) > 0</if>
|
|
<if test="regionName != null and regionName != ''"> and tr.region_name like concat('%', #{regionName}, '%')</if>
|
<if test="deptName != null and deptName != ''"> and sd.dept_name like concat('%', #{deptName}, '%')</if>
|
</where>
|
</select>
|
|
<!--工艺节点 的导出查询-->
|
<select id="selectRiskListByCrafts" parameterType="RiskList" resultMap="CraftsResult">
|
<include refid="selectRiskListVo"/>
|
<where>
|
<if test="riskListId != null "> and trl.risk_list_id = #{riskListId}</if>
|
<if test="createBy != null and createBy != ''"> and trl.create_by like concat('%', #{createBy}, '%')</if>
|
<if test="params.beginCreateTime != null and params.beginCreateTime != '' and params.endCreateTime != null and params.endCreateTime != ''">
|
and trl.create_time between #{params.beginCreateTime} and #{params.endCreateTime}
|
</if>
|
<if test="riskListNum != null and riskListNum != ''"> and trl.risk_list_num = #{riskListNum}</if>
|
<if test="riskListName != null and riskListName != ''"> and trl.risk_list_name like concat('%', #{riskListName}, '%')</if>
|
<if test="riskListIsSpecial != null "> and trl.risk_list_is_special = #{riskListIsSpecial}</if>
|
<if test="riskListImgUrl != null and riskListImgUrl != ''"> and trl.risk_list_img_url = #{riskListImgUrl}</if>
|
<if test="riskListDeviceType != null "> and trl.risk_list_device_type = #{riskListDeviceType}</if>
|
<if test="riskListDeviceModel != null and riskListDeviceModel != ''"> and trl.risk_list_device_model = #{riskListDeviceModel}</if>
|
<if test="riskListWorkType != null "> and trl.risk_list_work_type = #{riskListWorkType}</if>
|
<if test="riskListWorkFrequency != null "> and trl.risk_list_work_frequency = #{riskListWorkFrequency}</if>
|
<if test="riskListCraftsType != null "> and trl.risk_list_crafts_type = #{riskListCraftsType}</if>
|
<if test="riskListCraftsDescription != null and riskListCraftsDescription != ''"> and trl.risk_list_crafts_description = #{riskListCraftsDescription}</if>
|
<if test="regionId != null and regionId != ''"> and trl.region_id = #{regionId}</if>
|
<if test="deptId != null "> and trl.dept_id = #{deptId}</if>
|
<if test="userId != null "> and trl.user_id = #{userId}</if>
|
<if test="riskType != null "> and trl.risk_type = #{riskType}</if>
|
<if test="companyId != null "> and trl.company_id = #{companyId}</if>
|
<if test="isEvaluation != null and isEvaluation == 0"> and (SELECT COUNT(1) FROM tr_risk_evaluation_plan AS p WHERE trl.`risk_list_id` = p.evaluation_risk_id AND p.stage_status = 4 ) = 0</if>
|
<if test="isEvaluation != null and isEvaluation == 1"> and (SELECT COUNT(1) FROM tr_risk_evaluation_plan AS p WHERE trl.`risk_list_id` = p.evaluation_risk_id AND p.stage_status = 4 ) > 0</if>
|
|
<if test="regionName != null and regionName != ''"> and tr.region_name like concat('%', #{regionName}, '%')</if>
|
<if test="deptName != null and deptName != ''"> and sd.dept_name like concat('%', #{deptName}, '%')</if>
|
</where>
|
</select>
|
|
<select id="selectRiskListByDevice" parameterType="RiskList" resultMap="DeviceResult">
|
<include refid="selectRiskListVo"/>
|
<where>
|
<if test="riskListId != null "> and trl.risk_list_id = #{riskListId}</if>
|
<if test="createBy != null and createBy != ''"> and trl.create_by like concat('%', #{createBy}, '%')</if>
|
<if test="params.beginCreateTime != null and params.beginCreateTime != '' and params.endCreateTime != null and params.endCreateTime != ''">
|
and trl.create_time between #{params.beginCreateTime} and #{params.endCreateTime}
|
</if>
|
<if test="riskListNum != null and riskListNum != ''"> and trl.risk_list_num = #{riskListNum}</if>
|
<if test="riskListName != null and riskListName != ''"> and trl.risk_list_name like concat('%', #{riskListName}, '%')</if>
|
<if test="riskListIsSpecial != null "> and trl.risk_list_is_special = #{riskListIsSpecial}</if>
|
<if test="riskListImgUrl != null and riskListImgUrl != ''"> and trl.risk_list_img_url = #{riskListImgUrl}</if>
|
<if test="riskListDeviceType != null "> and trl.risk_list_device_type = #{riskListDeviceType}</if>
|
<if test="riskListDeviceModel != null and riskListDeviceModel != ''"> and trl.risk_list_device_model = #{riskListDeviceModel}</if>
|
<if test="riskListWorkType != null "> and trl.risk_list_work_type = #{riskListWorkType}</if>
|
<if test="riskListWorkFrequency != null "> and trl.risk_list_work_frequency = #{riskListWorkFrequency}</if>
|
<if test="riskListCraftsType != null "> and trl.risk_list_crafts_type = #{riskListCraftsType}</if>
|
<if test="riskListCraftsDescription != null and riskListCraftsDescription != ''"> and trl.risk_list_crafts_description = #{riskListCraftsDescription}</if>
|
<if test="regionId != null and regionId != ''"> and trl.region_id = #{regionId}</if>
|
<if test="deptId != null "> and trl.dept_id = #{deptId}</if>
|
<if test="userId != null "> and trl.user_id = #{userId}</if>
|
<if test="riskType != null "> and trl.risk_type = #{riskType}</if>
|
<if test="companyId != null "> and trl.company_id = #{companyId}</if>
|
<if test="isEvaluation != null and isEvaluation == 0"> and (SELECT COUNT(1) FROM tr_risk_evaluation_plan AS p WHERE trl.`risk_list_id` = p.evaluation_risk_id AND p.stage_status = 4 ) = 0</if>
|
<if test="isEvaluation != null and isEvaluation == 1"> and (SELECT COUNT(1) FROM tr_risk_evaluation_plan AS p WHERE trl.`risk_list_id` = p.evaluation_risk_id AND p.stage_status = 4 ) > 0</if>
|
|
<if test="regionName != null and regionName != ''"> and tr.region_name like concat('%', #{regionName}, '%')</if>
|
<if test="deptName != null and deptName != ''"> and sd.dept_name like concat('%', #{deptName}, '%')</if>
|
</where>
|
</select>
|
|
<select id="selectRiskListByWork" parameterType="RiskList" resultMap="WorkResult">
|
<include refid="selectRiskListVo"/>
|
<where>
|
<if test="riskListId != null "> and trl.risk_list_id = #{riskListId}</if>
|
<if test="createBy != null and createBy != ''"> and trl.create_by like concat('%', #{createBy}, '%')</if>
|
<if test="params.beginCreateTime != null and params.beginCreateTime != '' and params.endCreateTime != null and params.endCreateTime != ''">
|
and trl.create_time between #{params.beginCreateTime} and #{params.endCreateTime}
|
</if>
|
<if test="riskListNum != null and riskListNum != ''"> and trl.risk_list_num = #{riskListNum}</if>
|
<if test="riskListName != null and riskListName != ''"> and trl.risk_list_name like concat('%', #{riskListName}, '%')</if>
|
<if test="riskListIsSpecial != null "> and trl.risk_list_is_special = #{riskListIsSpecial}</if>
|
<if test="riskListImgUrl != null and riskListImgUrl != ''"> and trl.risk_list_img_url = #{riskListImgUrl}</if>
|
<if test="riskListDeviceType != null "> and trl.risk_list_device_type = #{riskListDeviceType}</if>
|
<if test="riskListDeviceModel != null and riskListDeviceModel != ''"> and trl.risk_list_device_model = #{riskListDeviceModel}</if>
|
<if test="riskListWorkType != null "> and trl.risk_list_work_type = #{riskListWorkType}</if>
|
<if test="riskListWorkFrequency != null "> and trl.risk_list_work_frequency = #{riskListWorkFrequency}</if>
|
<if test="riskListCraftsType != null "> and trl.risk_list_crafts_type = #{riskListCraftsType}</if>
|
<if test="riskListCraftsDescription != null and riskListCraftsDescription != ''"> and trl.risk_list_crafts_description = #{riskListCraftsDescription}</if>
|
<if test="regionId != null and regionId != ''"> and trl.region_id = #{regionId}</if>
|
<if test="deptId != null "> and trl.dept_id = #{deptId}</if>
|
<if test="userId != null "> and trl.user_id = #{userId}</if>
|
<if test="riskType != null "> and trl.risk_type = #{riskType}</if>
|
<if test="companyId != null "> and trl.company_id = #{companyId}</if>
|
<if test="isEvaluation != null and isEvaluation == 0"> and (SELECT COUNT(1) FROM tr_risk_evaluation_plan AS p WHERE trl.`risk_list_id` = p.evaluation_risk_id AND p.stage_status = 4 ) = 0</if>
|
<if test="isEvaluation != null and isEvaluation == 1"> and (SELECT COUNT(1) FROM tr_risk_evaluation_plan AS p WHERE trl.`risk_list_id` = p.evaluation_risk_id AND p.stage_status = 4 ) > 0</if>
|
|
<if test="regionName != null and regionName != ''"> and tr.region_name like concat('%', #{regionName}, '%')</if>
|
<if test="deptName != null and deptName != ''"> and sd.dept_name like concat('%', #{deptName}, '%')</if>
|
</where>
|
</select>
|
|
<select id="selectRiskListById" parameterType="Long" resultMap="RiskListResult">
|
<include refid="selectRiskListVo"/>
|
where risk_list_id = #{riskListId}
|
</select>
|
<!-- todo -->
|
<insert id="insertRiskList" parameterType="RiskList" useGeneratedKeys="true" keyProperty="riskListId">
|
insert into tr_risk_list
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
<if test="createBy != null and createBy != ''">create_by,</if>
|
<if test="createTime != null ">create_time,</if>
|
<if test="updateBy != null and updateBy != ''">update_by,</if>
|
<if test="updateTime != null ">update_time,</if>
|
<if test="remark != null and remark != ''">remark,</if>
|
<if test="riskListNum != null and riskListNum != ''">risk_list_num,</if>
|
<if test="riskListName != null and riskListName != ''">risk_list_name,</if>
|
<if test="riskListIsSpecial != null ">risk_list_is_special,</if>
|
<if test="riskListImgUrl != null and riskListImgUrl != ''">risk_list_img_url,</if>
|
<if test="riskListDeviceType != null ">risk_list_device_type,</if>
|
<if test="riskListDeviceModel != null and riskListDeviceModel != ''">risk_list_device_model,</if>
|
<if test="riskListWorkType != null ">risk_list_work_type,</if>
|
<if test="riskListWorkFrequency != null ">risk_list_work_frequency,</if>
|
<if test="riskListCraftsType != null ">risk_list_crafts_type,</if>
|
<if test="riskListCraftsDescription != null and riskListCraftsDescription != ''">risk_list_crafts_description,</if>
|
<if test="regionId != null and regionId != ''">region_id,</if>
|
<if test="deptId != null ">dept_id,</if>
|
<if test="userId != null ">user_id,</if>
|
<if test="riskType != null ">risk_type,</if>
|
<if test="companyId != null ">company_id,</if>
|
</trim>
|
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
<if test="createBy != null and createBy != ''">#{createBy},</if>
|
<if test="createTime != null ">#{createTime},</if>
|
<if test="updateBy != null and updateBy != ''">#{updateBy},</if>
|
<if test="updateTime != null ">#{updateTime},</if>
|
<if test="remark != null and remark != ''">#{remark},</if>
|
<if test="riskListNum != null and riskListNum != ''">#{riskListNum},</if>
|
<if test="riskListName != null and riskListName != ''">#{riskListName},</if>
|
<if test="riskListIsSpecial != null ">#{riskListIsSpecial},</if>
|
<if test="riskListImgUrl != null and riskListImgUrl != ''">#{riskListImgUrl},</if>
|
<if test="riskListDeviceType != null ">#{riskListDeviceType},</if>
|
<if test="riskListDeviceModel != null and riskListDeviceModel != ''">#{riskListDeviceModel},</if>
|
<if test="riskListWorkType != null ">#{riskListWorkType},</if>
|
<if test="riskListWorkFrequency != null ">#{riskListWorkFrequency},</if>
|
<if test="riskListCraftsType != null ">#{riskListCraftsType},</if>
|
<if test="riskListCraftsDescription != null and riskListCraftsDescription != ''">#{riskListCraftsDescription},</if>
|
<if test="regionId != null and regionId != ''">#{regionId},</if>
|
<if test="deptId != null ">#{deptId},</if>
|
<if test="userId != null ">#{userId},</if>
|
<if test="riskType != null ">#{riskType},</if>
|
<if test="companyId != null ">#{companyId},</if>
|
</trim>
|
</insert>
|
|
<update id="updateRiskList" parameterType="RiskList">
|
update tr_risk_list
|
<trim prefix="SET" suffixOverrides=",">
|
<if test="createBy != null and createBy != ''">create_by = #{createBy},</if>
|
<if test="createTime != null ">create_time = #{createTime},</if>
|
<if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
|
<if test="updateTime != null ">update_time = #{updateTime},</if>
|
<if test="remark != null">remark = #{remark},</if>
|
<if test="riskListNum != null and riskListNum != ''">risk_list_num = #{riskListNum},</if>
|
<if test="riskListName != null and riskListName != ''">risk_list_name = #{riskListName},</if>
|
<if test="riskListIsSpecial != null">risk_list_is_special = #{riskListIsSpecial},</if>
|
<if test="riskListImgUrl != null">risk_list_img_url = #{riskListImgUrl},</if>
|
<if test="riskListDeviceType != null ">risk_list_device_type = #{riskListDeviceType},</if>
|
<if test="riskListDeviceModel != null and riskListDeviceModel != ''">risk_list_device_model = #{riskListDeviceModel},</if>
|
<if test="riskListWorkType != null ">risk_list_work_type = #{riskListWorkType},</if>
|
<if test="riskListWorkFrequency != null ">risk_list_work_frequency = #{riskListWorkFrequency},</if>
|
<if test="riskListCraftsType != null ">risk_list_crafts_type = #{riskListCraftsType},</if>
|
<if test="riskListCraftsDescription != null and riskListCraftsDescription != ''">risk_list_crafts_description = #{riskListCraftsDescription},</if>
|
<if test="regionId != null and regionId != ''">region_id = #{regionId},</if>
|
<if test="deptId != null ">dept_id = #{deptId},</if>
|
<if test="userId != null ">user_id = #{userId},</if>
|
<if test="riskType != null ">risk_type = #{riskType},</if>
|
<if test="companyId != null ">company_id = #{companyId},</if>
|
</trim>
|
where risk_list_id = #{riskListId}
|
</update>
|
|
<delete id="deleteRiskListById" parameterType="Long">
|
delete from tr_risk_list where risk_list_id = #{riskListId}
|
</delete>
|
|
<delete id="deleteRiskListByIds" parameterType="String">
|
delete from tr_risk_list where risk_list_id in
|
<foreach item="riskListId" collection="array" open="(" separator="," close=")">
|
#{riskListId}
|
</foreach>
|
</delete>
|
|
|
<!-- RiskList getInfoByRiskId(String riskId);-->
|
<select id="getInfoByRiskId" parameterType="RiskList" resultMap="RiskListResult">
|
select * from tr_risk_list where risk_list_id = #{riskId}
|
</select>
|
|
<!-- RiskList getInfoByRiskListId(Long riskUnitId);-->
|
<select id="getInfoByRiskListId" parameterType="RiskList" resultMap="RiskListResult">
|
select * from tr_risk_list where risk_list_id = #{riskUnitId} and user_id is not null
|
</select>
|
</mapper>
|