<?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.hzya.frame.sys.proofDetail.dao.impl.ProofDetailDaoImpl">
	<resultMap id="get-ProofDetailEntity-result" type="com.hzya.frame.sys.proofDetail.entity.ProofDetailEntity">
		<!--主键ID -->
		<result property="id" column="id" />
		<!--formmain_id -->
		<result property="formmain_id" column="formmain_id" />
		<!--摘要 -->
		<result property="abstract_msg" column="abstract_msg" />
		<!--科目 -->
		<result property="subject" column="subject" />
		<!--项目 -->
		<result property="project" column="project" />
		<!--项目显示 -->
		<result property="project_flag" column="project_flag" />
		<!--供应商 -->
		<result property="supplier" column="supplier" />
		<!--供应商显示 -->
		<result property="supplier_flag" column="supplier_flag" />
		<!--客户 -->
		<result property="client" column="client" />
		<!--客户显示 -->
		<result property="client_flag" column="client_flag" />
		<!--业务员 -->
		<result property="salesman" column="salesman" />
		<!--业务员显示 -->
		<result property="salesman_flag" column="salesman_flag" />
		<!--部门 -->
		<result property="section" column="section" />
		<!--部门显示 -->
		<result property="section_flag" column="section_flag" />
		<!--贷方金额 -->
		<result property="credit_amount" column="credit_amount" />
		<!--借方金额 -->
		<result property="debit_amount" column="debit_amount" />
		<!--方向 -->
		<result property="direction" column="direction" />
		<!--排序 -->
		<result property="sorts" column="sorts" />
		<!--创建人id -->
		<result property="create_user_id" column="create_user_id" />
		<!--创建时间 -->
		<result property="create_time" column="create_time" />
		<!--修改人id -->
		<result property="modify_user_id" column="modify_user_id" />
		<!--修改时间 -->
		<result property="modify_time" column="modify_time" />
		<!--状态(Y正常N删除) -->
		<result property="sts" column="sts" />
		<!--组织机构ID -->
		<result property="org_id" column="org_id" />
	</resultMap>

	<sql id="ProofDetailEntity_Base_Column_List">
		id,
		formmain_id,
		abstract_msg,
		subject,
		project,
		project_flag,
		supplier,
		supplier_flag,
		client,
		client_flag,
		salesman,
		salesman_flag,
		section,
		section_flag,
		credit_amount,
		debit_amount,
		direction,
		sorts,
		create_user_id,
		create_time,
		modify_user_id,
		modify_time,
		sts,
		org_id
	</sql>

	<!--通过ID获取数据 -->
	<select id="entity_get" resultMap="get-ProofDetailEntity-result">
		select
		<include refid="ProofDetailEntity_Base_Column_List" />
		from sys_proof_detail where id = #{ id } and sts='Y'
	</select>

	<!-- 查询 采用==查询 -->
	<select id="entity_list_base" resultMap="get-ProofDetailEntity-result" parameterType="com.hzya.frame.sys.proofDetail.entity.ProofDetailEntity">
		select
		<include refid="ProofDetailEntity_Base_Column_List" />
		from sys_proof_detail
		<trim prefix="where" prefixOverrides="and">
			<if test="id != null and id !='' ">id = #{id} </if>
			<if test="formmain_id != null and formmain_id !='' "> and formmain_id = #{formmain_id}</if>
			<if test="abstract_msg != null and abstract_msg !='' "> and abstract_msg = #{abstract_msg}</if>
			<if test="subject != null and subject !='' "> and subject = #{subject}</if>
			<if test="project != null and project !='' "> and project = #{project}</if>
			<if test="project_flag != null and project_flag !='' "> and project_flag = #{project_flag}</if>
			<if test="supplier != null and supplier !='' "> and supplier = #{supplier}</if>
			<if test="supplier_flag != null and supplier_flag !='' "> and supplier_flag = #{supplier_flag}</if>
			<if test="client != null and client !='' "> and client = #{client}</if>
			<if test="client_flag != null and client_flag !='' "> and client_flag = #{client_flag}</if>
			<if test="salesman != null and salesman !='' "> and salesman = #{salesman}</if>
			<if test="salesman_flag != null and salesman_flag !='' "> and salesman_flag = #{salesman_flag}</if>
			<if test="section != null and section !='' "> and section = #{section}</if>
			<if test="section_flag != null and section_flag !='' "> and section_flag = #{section_flag}</if>
			<if test="credit_amount != null "> and credit_amount = #{credit_amount}</if>
			<if test="debit_amount != null "> and debit_amount = #{debit_amount}</if>
			<if test="direction != null and direction !='' "> and direction = #{direction}</if>
			<if test="sorts != null "> and sorts = #{sorts}</if>
			<if test="create_user_id != null and create_user_id !='' "> and create_user_id = #{create_user_id}</if>
			<if test="create_time != null "> and create_time = #{create_time}</if>
			<if test="modify_user_id != null and modify_user_id !='' "> and modify_user_id = #{modify_user_id}</if>
			<if test="modify_time != null "> and modify_time = #{modify_time}</if>
			<if test="sts != null and sts !='' "> and sts = #{sts}</if>
			<if test="org_id != null and org_id !='' "> and org_id = #{org_id}</if>
			and sts='Y'
		</trim>
		<if test=" sort == null or sort == ''.toString()  "> order by sorts asc</if>
		<if test=" sort !='' and sort!=null and order !='' and order!=null ">order by ${sort} ${order}</if>
	</select>

	<!-- 查询符合条件的数量 -->
	<select id="entity_count" resultType="Integer" parameterType="com.hzya.frame.sys.proofDetail.entity.ProofDetailEntity">
		select count(1) from sys_proof_detail
		<trim prefix="where" prefixOverrides="and">
			<if test="id != null and id !='' ">id = #{id} </if>
			<if test="formmain_id != null and formmain_id !='' "> and formmain_id = #{formmain_id} </if>
			<if test="abstract_msg != null and abstract_msg !='' "> and abstract_msg = #{abstract_msg} </if>
			<if test="subject != null and subject !='' "> and subject = #{subject} </if>
			<if test="project != null and project !='' "> and project = #{project} </if>
			<if test="project_flag != null and project_flag !='' "> and project_flag = #{project_flag} </if>
			<if test="supplier != null and supplier !='' "> and supplier = #{supplier} </if>
			<if test="supplier_flag != null and supplier_flag !='' "> and supplier_flag = #{supplier_flag} </if>
			<if test="client != null and client !='' "> and client = #{client} </if>
			<if test="client_flag != null and client_flag !='' "> and client_flag = #{client_flag} </if>
			<if test="salesman != null and salesman !='' "> and salesman = #{salesman} </if>
			<if test="salesman_flag != null and salesman_flag !='' "> and salesman_flag = #{salesman_flag} </if>
			<if test="section != null and section !='' "> and section = #{section} </if>
			<if test="section_flag != null and section_flag !='' "> and section_flag = #{section_flag} </if>
			<if test="credit_amount != null "> and credit_amount = #{credit_amount}  </if>
			<if test="debit_amount != null "> and debit_amount = #{debit_amount}  </if>
			<if test="direction != null and direction !='' "> and direction = #{direction} </if>
			<if test="sorts != null "> and sorts = #{sorts}  </if>
			<if test="create_user_id != null and create_user_id !='' "> and create_user_id = #{create_user_id} </if>
			<if test="create_time != null "> and create_time = #{create_time}  </if>
			<if test="modify_user_id != null and modify_user_id !='' "> and modify_user_id = #{modify_user_id} </if>
			<if test="modify_time != null "> and modify_time = #{modify_time}  </if>
			<if test="sts != null and sts !='' "> and sts = #{sts} </if>
			<if test="org_id != null and org_id !='' "> and org_id = #{org_id} </if>
			and sts='Y'
		</trim>
		<if test=" sort ==''.toString() "> order by sorts asc</if>
		<if test=" sort !='' and sort!=null and order !='' and order!=null "> order by ${sort} ${order}</if>
	</select>

	<!-- 分页查询列表 采用like格式 -->
	<select id="entity_list_like" resultMap="get-ProofDetailEntity-result" parameterType="com.hzya.frame.sys.proofDetail.entity.ProofDetailEntity">
		select
		<include refid="ProofDetailEntity_Base_Column_List" />
		from sys_proof_detail
		<trim prefix="where" prefixOverrides="and">
			<if test="id != null and id !='' "> id like concat('%',#{id},'%') </if>
			<if test="formmain_id != null and formmain_id !='' "> and formmain_id like concat('%',#{formmain_id},'%') </if>
			<if test="abstract_msg != null and abstract_msg !='' "> and abstract_msg like concat('%',#{abstract_msg},'%') </if>
			<if test="subject != null and subject !='' "> and subject like concat('%',#{subject},'%') </if>
			<if test="project != null and project !='' "> and project like concat('%',#{project},'%') </if>
			<if test="project_flag != null and project_flag !='' "> and project_flag like concat('%',#{project_flag},'%') </if>
			<if test="supplier != null and supplier !='' "> and supplier like concat('%',#{supplier},'%') </if>
			<if test="supplier_flag != null and supplier_flag !='' "> and supplier_flag like concat('%',#{supplier_flag},'%') </if>
			<if test="client != null and client !='' "> and client like concat('%',#{client},'%') </if>
			<if test="client_flag != null and client_flag !='' "> and client_flag like concat('%',#{client_flag},'%') </if>
			<if test="salesman != null and salesman !='' "> and salesman like concat('%',#{salesman},'%') </if>
			<if test="salesman_flag != null and salesman_flag !='' "> and salesman_flag like concat('%',#{salesman_flag},'%') </if>
			<if test="section != null and section !='' "> and section like concat('%',#{section},'%') </if>
			<if test="section_flag != null and section_flag !='' "> and section_flag like concat('%',#{section_flag},'%') </if>
			<if test="credit_amount != null "> and credit_amount = #{credit_amount}</if>
			<if test="debit_amount != null "> and debit_amount = #{debit_amount}</if>
			<if test="direction != null and direction !='' "> and direction like concat('%',#{direction},'%') </if>
			<if test="sorts != null "> and sorts = #{sorts}</if>
			<if test="create_user_id != null and create_user_id !='' "> and create_user_id like concat('%',#{create_user_id},'%') </if>
			<if test="create_time != null and create_time !='' "> and create_time like concat('%',#{create_time},'%') </if>
			<if test="modify_user_id != null and modify_user_id !='' "> and modify_user_id like concat('%',#{modify_user_id},'%') </if>
			<if test="modify_time != null and modify_time !='' "> and modify_time like concat('%',#{modify_time},'%') </if>
			<if test="sts != null and sts !='' "> and sts like concat('%',#{sts},'%') </if>
			<if test="org_id != null and org_id !='' "> and org_id like concat('%',#{org_id},'%') </if>
			and sts='Y'
		</trim>
		<if test=" sort ==''.toString() "> order by sorts asc</if>
		<if test=" sort !='' and sort!=null and order !='' and order!=null ">order by  ${sort} ${order}</if>
	</select>

	<!-- 查询列表 字段采用or格式 -->
	<select id="entity_list_or" resultMap="get-ProofDetailEntity-result" parameterType="com.hzya.frame.sys.proofDetail.entity.ProofDetailEntity">
		select
		<include refid="ProofDetailEntity_Base_Column_List" />
		from sys_proof_detail
		<trim prefix="where" prefixOverrides="or">
			<if test="id != null and id !='' ">id = #{id} </if>
			<if test="formmain_id != null and formmain_id !='' "> or formmain_id = #{formmain_id} </if>
			<if test="abstract_msg != null and abstract_msg !='' "> or abstract_msg = #{abstract_msg} </if>
			<if test="subject != null and subject !='' "> or subject = #{subject} </if>
			<if test="project != null and project !='' "> or project = #{project} </if>
			<if test="project_flag != null and project_flag !='' "> or project_flag = #{project_flag} </if>
			<if test="supplier != null and supplier !='' "> or supplier = #{supplier} </if>
			<if test="supplier_flag != null and supplier_flag !='' "> or supplier_flag = #{supplier_flag} </if>
			<if test="client != null and client !='' "> or client = #{client} </if>
			<if test="client_flag != null and client_flag !='' "> or client_flag = #{client_flag} </if>
			<if test="salesman != null and salesman !='' "> or salesman = #{salesman} </if>
			<if test="salesman_flag != null and salesman_flag !='' "> or salesman_flag = #{salesman_flag} </if>
			<if test="section != null and section !='' "> or section = #{section} </if>
			<if test="section_flag != null and section_flag !='' "> or section_flag = #{section_flag} </if>
			<if test="credit_amount != null "> or credit_amount = #{credit_amount}</if>
			<if test="debit_amount != null "> or debit_amount = #{debit_amount}</if>
			<if test="direction != null and direction !='' "> or direction = #{direction} </if>
			<if test="sorts != null "> or sorts = #{sorts}</if>
			<if test="create_user_id != null and create_user_id !='' "> or create_user_id = #{create_user_id} </if>
			<if test="create_time != null and create_time !='' "> or create_time = #{create_time} </if>
			<if test="modify_user_id != null and modify_user_id !='' "> or modify_user_id = #{modify_user_id} </if>
			<if test="modify_time != null and modify_time !='' "> or modify_time = #{modify_time} </if>
			<if test="sts != null and sts !='' "> or sts = #{sts} </if>
			<if test="org_id != null and org_id !='' "> or org_id = #{org_id} </if>
			and sts='Y'
		</trim>
		<if test=" sort ==''.toString() "> order by sorts asc</if>
		<if test=" sort !='' and sort!=null and order !='' and order!=null ">order by  ${sort} ${order}</if>
	</select>
	<!-- 新增 -->
	<insert id="entity_insert" parameterType="com.hzya.frame.sys.proofDetail.entity.ProofDetailEntity">
		insert into sys_proof_detail(
		<trim suffix="" suffixOverrides=",">
			<if test="id != null and id !='' "> id, </if>
			<if test="formmain_id != null and formmain_id !='' "> formmain_id, </if>
			<if test="abstract_msg != null and abstract_msg !='' "> abstract_msg, </if>
			<if test="subject != null and subject !='' "> subject, </if>
			<if test="project != null and project !='' "> project, </if>
			<if test="project_flag != null and project_flag !='' "> project_flag, </if>
			<if test="supplier != null and supplier !='' "> supplier, </if>
			<if test="supplier_flag != null and supplier_flag !='' "> supplier_flag, </if>
			<if test="client != null and client !='' "> client, </if>
			<if test="client_flag != null and client_flag !='' "> client_flag, </if>
			<if test="salesman != null and salesman !='' "> salesman, </if>
			<if test="salesman_flag != null and salesman_flag !='' "> salesman_flag, </if>
			<if test="section != null and section !='' "> section, </if>
			<if test="section_flag != null and section_flag !='' "> section_flag, </if>
			<if test="credit_amount != null ">credit_amount,</if>
			<if test="debit_amount != null ">debit_amount,</if>
			<if test="direction != null and direction !='' "> direction, </if>
			<if test="sorts != null ">sorts,</if>
			<if test="create_user_id != null and create_user_id !='' "> create_user_id, </if>
			<if test="modify_user_id != null and modify_user_id !='' "> modify_user_id, </if>
			<if test="org_id != null and org_id !='' "> org_id, </if>
			create_time,
			modify_time,
			sts
		</trim>
		)values
		(
		<trim suffix="" suffixOverrides=",">
			<if test="id != null and id !='' "> #{id}, </if>
			<if test="formmain_id != null and formmain_id !='' "> #{formmain_id}, </if>
			<if test="abstract_msg != null and abstract_msg !='' "> #{abstract_msg}, </if>
			<if test="subject != null and subject !='' "> #{subject}, </if>
			<if test="project != null and project !='' "> #{project}, </if>
			<if test="project_flag != null and project_flag !='' "> #{project_flag}, </if>
			<if test="supplier != null and supplier !='' "> #{supplier}, </if>
			<if test="supplier_flag != null and supplier_flag !='' "> #{supplier_flag}, </if>
			<if test="client != null and client !='' "> #{client}, </if>
			<if test="client_flag != null and client_flag !='' "> #{client_flag}, </if>
			<if test="salesman != null and salesman !='' "> #{salesman}, </if>
			<if test="salesman_flag != null and salesman_flag !='' "> #{salesman_flag}, </if>
			<if test="section != null and section !='' "> #{section}, </if>
			<if test="section_flag != null and section_flag !='' "> #{section_flag}, </if>
			<if test="credit_amount != null ">#{credit_amount},</if>
			<if test="debit_amount != null ">#{debit_amount},</if>
			<if test="direction != null and direction !='' "> #{direction}, </if>
			<if test="sorts != null ">#{sorts},</if>
			<if test="create_user_id != null and create_user_id !='' "> #{create_user_id}, </if>
			<if test="modify_user_id != null and modify_user_id !='' "> #{modify_user_id}, </if>
			<if test="org_id != null and org_id !='' "> #{org_id}, </if>
			<if test="create_time != null "> #{create_time} ,</if>
			<if test="modify_time != null "> #{modify_time},</if>
			'Y'
		</trim>
		)
	</insert>

	<!-- 修改 -->
	<update id="entity_update" parameterType="com.hzya.frame.sys.proofDetail.entity.ProofDetailEntity">
		update sys_proof_detail set
		<trim suffix="" suffixOverrides=",">
			<if test="id != null and id !='' "> id = #{id},</if>
			<if test="formmain_id != null and formmain_id !='' "> formmain_id = #{formmain_id},</if>
			<if test="abstract_msg != null and abstract_msg !='' "> abstract_msg = #{abstract_msg},</if>
			<if test="subject != null and subject !='' "> subject = #{subject},</if>
			<if test="project != null and project !='' "> project = #{project},</if>
			<if test="project_flag != null and project_flag !='' "> project_flag = #{project_flag},</if>
			<if test="supplier != null and supplier !='' "> supplier = #{supplier},</if>
			<if test="supplier_flag != null and supplier_flag !='' "> supplier_flag = #{supplier_flag},</if>
			<if test="client != null and client !='' "> client = #{client},</if>
			<if test="client_flag != null and client_flag !='' "> client_flag = #{client_flag},</if>
			<if test="salesman != null and salesman !='' "> salesman = #{salesman},</if>
			<if test="salesman_flag != null and salesman_flag !='' "> salesman_flag = #{salesman_flag},</if>
			<if test="section != null and section !='' "> section = #{section},</if>
			<if test="section_flag != null and section_flag !='' "> section_flag = #{section_flag},</if>
			<if test="credit_amount != null ">credit_amount = #{credit_amount},</if>
			<if test="debit_amount != null ">debit_amount = #{debit_amount},</if>
			<if test="direction != null and direction !='' "> direction = #{direction},</if>
			<if test="sorts != null ">sorts = #{sorts},</if>
			<if test="create_user_id != null and create_user_id !='' "> create_user_id = #{create_user_id},</if>
			<if test="modify_user_id != null and modify_user_id !='' "> modify_user_id = #{modify_user_id},</if>
			<if test="org_id != null and org_id !='' "> org_id = #{org_id},</if>
			<if test="modify_time != null "> modify_time =#{modify_time}  </if>
			<if test="modify_time  == null "> modify_time = now()</if>
		</trim>
		where id = #{id}
	</update>

	<!-- 逻辑删除 -->
	<update id="entity_logicDelete" parameterType="com.hzya.frame.sys.proofDetail.entity.ProofDetailEntity">
		update sys_proof_detail set
		sts='N',modify_time = now(),modify_user_id = #{modify_user_id} where
		id = #{id}
	</update>

	<!-- 逻辑删除多条件 -->
	<update id="entity_logicDelete_Multi_Condition" parameterType="com.hzya.frame.sys.proofDetail.entity.ProofDetailEntity">
		update sys_proof_detail set
		sts='N',modify_time = now(),modify_user_id = #{modify_user_id} 
		<trim prefix="where" prefixOverrides="and">
			<if test="id != null and id !='' ">id = #{id} </if>
			<if test="formmain_id != null and formmain_id !='' "> and formmain_id = #{formmain_id}</if>
			<if test="abstract_msg != null and abstract_msg !='' "> and abstract_msg = #{abstract_msg}</if>
			<if test="subject != null and subject !='' "> and subject = #{subject}</if>
			<if test="project != null and project !='' "> and project = #{project}</if>
			<if test="project_flag != null and project_flag !='' "> and project_flag = #{project_flag}</if>
			<if test="supplier != null and supplier !='' "> and supplier = #{supplier}</if>
			<if test="supplier_flag != null and supplier_flag !='' "> and supplier_flag = #{supplier_flag}</if>
			<if test="client != null and client !='' "> and client = #{client}</if>
			<if test="client_flag != null and client_flag !='' "> and client_flag = #{client_flag}</if>
			<if test="salesman != null and salesman !='' "> and salesman = #{salesman}</if>
			<if test="salesman_flag != null and salesman_flag !='' "> and salesman_flag = #{salesman_flag}</if>
			<if test="section != null and section !='' "> and section = #{section}</if>
			<if test="section_flag != null and section_flag !='' "> and section_flag = #{section_flag}</if>
			<if test="credit_amount != null "> and credit_amount = #{credit_amount}</if>
			<if test="debit_amount != null "> and debit_amount = #{debit_amount}</if>
			<if test="direction != null and direction !='' "> and direction = #{direction}</if>
			<if test="sorts != null "> and sorts = #{sorts}</if>
			<if test="create_user_id != null and create_user_id !='' "> and create_user_id = #{create_user_id}</if>
			<if test="create_time != null and create_time !='' "> and create_time = #{create_time}</if>
			<if test="modify_user_id != null and modify_user_id !='' "> and modify_user_id = #{modify_user_id}</if>
			<if test="modify_time != null and modify_time !='' "> and modify_time = #{modify_time}</if>
			<if test="sts != null and sts !='' "> and sts = #{sts}</if>
			<if test="org_id != null and org_id !='' "> and org_id = #{org_id}</if>
		</trim>
	</update>

	<!-- 物理删除 -->
	<delete id="entity_delete" parameterType="com.hzya.frame.sys.proofDetail.entity.ProofDetailEntity">
		delete from sys_proof_detail where id =#{id}
	</delete>
</mapper>
