<?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.yeejoin.amos.fas.business.dao.mapper.RiskFactorMapper">
	<!--统计-->
	<select id="countPageData" resultType="long">
		SELECT
		count(1) AS total_num
		FROM
		f_risk_factor a
	<trim prefix="WHERE" prefixOverrides="AND ">
		<if test="name!=null"> and a.name like concat(concat("%",#{name}),"%")</if>
	</trim>
	</select>
	<!--分页查询 -->
	<select id="queryRiskFactorPage" resultType="java.util.HashMap">
		SELECT
			a.id,
			a.name,
			a.accident_type_id as accidentTypeId,
			d.name as accidentName,
			a.type,
			a.dept_id as deptId,
			a.create_by as createBy,
			a.create_date as createDate,
			a.remark
		FROM
		f_risk_factor a
		left join f_accident_type d on a.accident_type_id = d.id
		<trim prefix="WHERE" prefixOverrides="AND ">
			<if test="name!=null"> and a.name like concat(concat("%",#{name}),"%")</if>
		</trim>
		order by a.id
		<choose>
	     <when test="pageSize==-1"></when>
	     <when test="pageSize!=-1">limit #{offset},#{pageSize}</when>  
	    </choose>
	</select>
	
		<!--统计重复数据-->
	<select id="countRepeatData" resultType="long">
		SELECT
		count(1) AS total_num
		FROM
		f_risk_factor a
	<trim prefix="WHERE" prefixOverrides="AND ">
		<if test="id != null"> and a.id != #{id} </if>
		<if test="orgCode != null"> and a.org_code locate(#{orgCode},a.org_code)  <![CDATA[>]]> 0  </if>
		<if test="name != null"> and a.name = #{name} </if>
	</trim>
	</select>
</mapper>