|
|
@@ -7,8 +7,8 @@
|
|
|
<resultMap type="com.zd.laboratory.domain.LabHazardSubjectRelation" id="LabHazardSubjectRelationResult">
|
|
|
<result property="id" column="id"/>
|
|
|
<result property="hazardId" column="hazard_id"/>
|
|
|
-<!-- <result property="containerId" column="container_id"/>-->
|
|
|
- <result property="hazardType" column="hazard_type" typeHandler="org.apache.ibatis.type.EnumOrdinalTypeHandler" />
|
|
|
+ <!-- <result property="containerId" column="container_id"/>-->
|
|
|
+ <result property="hazardType" column="hazard_type" typeHandler="org.apache.ibatis.type.EnumOrdinalTypeHandler"/>
|
|
|
<result property="hazardId" column="hazard_id"/>
|
|
|
<result property="subjectId" column="subject_id"/>
|
|
|
<result property="identify" column="identify"/>
|
|
|
@@ -22,10 +22,20 @@
|
|
|
</resultMap>
|
|
|
|
|
|
<sql id="AllField">
|
|
|
- id, hazard_id, container_id, subject_id, identify, create_time,x_point,y_point
|
|
|
+ id
|
|
|
+ , hazard_id, container_id, subject_id, identify, create_time,x_point,y_point
|
|
|
</sql>
|
|
|
<sql id="selectLabHazardSubjectRelationVo">
|
|
|
- select id, hazard_id, hazard_type,x_point,y_point, subject_id, identify, create_time,another_name,another_code
|
|
|
+ select id,
|
|
|
+ hazard_id,
|
|
|
+ hazard_type,
|
|
|
+ x_point,
|
|
|
+ y_point,
|
|
|
+ subject_id,
|
|
|
+ identify,
|
|
|
+ create_time,
|
|
|
+ another_name,
|
|
|
+ another_code
|
|
|
from lab_hazard_subject_relation
|
|
|
</sql>
|
|
|
|
|
|
@@ -38,9 +48,9 @@
|
|
|
<if test="subjectId != null ">and subject_id = #{subjectId}</if>
|
|
|
</where>
|
|
|
</select>
|
|
|
-<!-- 查询实验室危险品数量 -->
|
|
|
+ <!-- 查询实验室危险品数量 -->
|
|
|
<select id="queryCountBySubIds" resultType="com.zd.system.api.entity.CommonCount">
|
|
|
- select count(id) count,lhsr.subject_id as id from lab_hazard_subject_relation lhsr
|
|
|
+ select count(id) count,lhsr.subject_id as id from lab_hazard_subject_relation lhsr
|
|
|
where lhsr.subject_id in
|
|
|
<foreach item="id" collection="array" open="(" separator="," close=")">
|
|
|
#{id}
|
|
|
@@ -48,18 +58,18 @@
|
|
|
GROUP BY lhsr.subject_id
|
|
|
</select>
|
|
|
|
|
|
- <select id="selectLabHazardSubjectRelationById" resultMap="LabHazardSubjectRelationResult">
|
|
|
+ <select id="selectLabHazardSubjectRelationById" resultMap="LabHazardSubjectRelationResult">
|
|
|
<include refid="selectLabHazardSubjectRelationVo"/>
|
|
|
where id = #{id}
|
|
|
</select>
|
|
|
|
|
|
<select id="queryLabByHazardId" resultMap="LabHazardSubjectRelationResult">
|
|
|
select
|
|
|
- sr.id, sr.hazard_id, sr.subject_id, sr.identify, sr.create_time,
|
|
|
+ sr.id, sr.hazard_id, sr.subject_id, sr.identify, sr.create_time,
|
|
|
sr.x_point,sr.y_point,
|
|
|
- s.name as subjectName
|
|
|
+ s.name as subjectName
|
|
|
from
|
|
|
- lab_hazard_subject_relation sr left join lab_subject s on sr.subject_id = s.id
|
|
|
+ lab_hazard_subject_relation sr left join lab_subject s on sr.subject_id = s.id
|
|
|
<where>
|
|
|
<if test="hazardId != null">
|
|
|
and sr.hazard_id = #{hazardId}
|
|
|
@@ -78,7 +88,9 @@
|
|
|
</select>
|
|
|
|
|
|
<select id="queryChNameByHazardId" resultType="java.lang.String">
|
|
|
- select ch_name as chName from lab_hazard where id = #{hazardId}
|
|
|
+ select ch_name as chName
|
|
|
+ from lab_hazard
|
|
|
+ where id = #{hazardId}
|
|
|
</select>
|
|
|
|
|
|
<insert id="insertLabHazardSubjectRelation" parameterType="com.zd.laboratory.domain.LabHazardSubjectRelation">
|
|
|
@@ -113,16 +125,20 @@
|
|
|
</insert>
|
|
|
|
|
|
<insert id="insertOrUpdateBatch" keyProperty="id" useGeneratedKeys="true">
|
|
|
- insert into lab_hazard_subject_relation(id, hazard_id,hazard_type , subject_id, identify,x_point,y_point,create_time,another_name
|
|
|
+ insert into lab_hazard_subject_relation(id, hazard_id,hazard_type , subject_id,
|
|
|
+ identify,x_point,y_point,create_time,another_name
|
|
|
,another_code,user_id)
|
|
|
values
|
|
|
<foreach collection="entities" item="entity" separator=",">
|
|
|
- (#{entity.id}, #{entity.hazardId}, #{entity.hazardType}, #{entity.subjectId}, #{entity.identify},#{entity.xPoint},#{entity.yPoint}
|
|
|
+ (#{entity.id}, #{entity.hazardId}, #{entity.hazardType}, #{entity.subjectId},
|
|
|
+ #{entity.identify},#{entity.xPoint},#{entity.yPoint}
|
|
|
,NOW(),#{entity.anotherName},#{entity.anotherCode},#{entity.userId})
|
|
|
</foreach>
|
|
|
on duplicate key update
|
|
|
- hazard_id = values(hazard_id) , hazard_type = values(hazard_type) , subject_id = values(subject_id) , identify = values(identify), x_point = values(x_point), y_point = values(y_point)
|
|
|
- , create_time = values(NOW()), another_name = values(another_name), another_code = values(another_code), user_id = values(user_id)
|
|
|
+ hazard_id = values(hazard_id) , hazard_type = values(hazard_type) , subject_id = values(subject_id) , identify =
|
|
|
+ values(identify), x_point = values(x_point), y_point = values(y_point)
|
|
|
+ , create_time = values(NOW()), another_name = values(another_name), another_code = values(another_code), user_id
|
|
|
+ = values(user_id)
|
|
|
</insert>
|
|
|
|
|
|
<update id="updateLabHazardSubjectRelation" parameterType="com.zd.laboratory.domain.LabHazardSubjectRelation">
|
|
|
@@ -138,7 +154,7 @@
|
|
|
where id = #{id}
|
|
|
</update>
|
|
|
|
|
|
- <delete id="deleteLabHazardSubjectRelationById" >
|
|
|
+ <delete id="deleteLabHazardSubjectRelationById">
|
|
|
delete
|
|
|
from lab_hazard_subject_relation
|
|
|
where id = #{id}
|
|
|
@@ -150,14 +166,29 @@
|
|
|
#{id}
|
|
|
</foreach>
|
|
|
</delete>
|
|
|
-<!-- 删除指定实验室下的危险品关系 -->
|
|
|
- <delete id="deleteSubLabHazardSubjectRelationByIds" >
|
|
|
- delete from lab_hazard_subject_relation where subject_id =#{subId} and id in
|
|
|
+ <!-- 删除指定实验室下的危险品关系 -->
|
|
|
+ <delete id="deleteSubLabHazardSubjectRelationByIds">
|
|
|
+ delete from lab_hazard_subject_relation where subject_id =#{subId} and id in
|
|
|
<foreach item="id" collection="ids" open="(" separator="," close=")">
|
|
|
#{id}
|
|
|
</foreach>
|
|
|
</delete>
|
|
|
<delete id="deleteBySubId">
|
|
|
- delete from lab_hazard_subject_relation where subject_id = #{subId}
|
|
|
+ delete
|
|
|
+ from lab_hazard_subject_relation
|
|
|
+ where subject_id = #{subId}
|
|
|
</delete>
|
|
|
+
|
|
|
+ <select id="relationBigViewCount" parameterType="com.zd.laboratory.domain.LabHazardSubjectRelation"
|
|
|
+ resultType="com.zd.laboratory.domain.LabHazardSubjectRelation">
|
|
|
+ select dept_name deptName, hazard_type_mode hazardTypeMode, hazard_type_mode_name hazardTypeModeName, count(1) totalNum
|
|
|
+ from (
|
|
|
+ select sr.subject_id, su.`name`, d.dept_name, d.dept_id, h.hazard_type_mode, h.hazard_type_mode_name
|
|
|
+ from lab_hazard_subject_relation sr
|
|
|
+ INNER JOIN lab_subject su on sr.subject_id = su.id
|
|
|
+ INNER JOIN sys_dept d on d.dept_id = su.dept_id
|
|
|
+ INNER JOIN lab_hazard h on sr.hazard_id = h.id
|
|
|
+ ) t
|
|
|
+ GROUP BY dept_id, hazard_type_mode
|
|
|
+ </select>
|
|
|
</mapper>
|