<?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.seeyon.dao.impl.SeeYonDaoImpl">
	<resultMap id="get-SeeyonEntity-result" type="com.hzya.frame.seeyon.entity.SeeyonEntity">
		<result property="id" column="id" />
		<result property="field0026" column="field0026" />
		<result property="field0001" column="field0001" />
		<result property="field0003" column="field0003" />
		<result property="field0016" column="field0016" />
		<result property="field0002" column="field0002" />
		<result property="field0004" column="field0004" />
		<result property="field0005" column="field0005" />
		<result property="field0006" column="field0006" />
		<result property="field0015" column="field0015" />
		<result property="field0009" column="field0009" />
		<result property="field0010" column="field0010" />
		<result property="field0012" column="field0012" />
		<result property="field0013" column="field0013" />
		<result property="field0027" column="field0027" />
		<result property="field0008" column="field0008" />
		<result property="field0032" column="field0032" />
		<result property="field0033" column="field0033" />
		<result property="field0034" column="field0034" />
		<result property="field0035" column="field0035" />
		<result property="field0038" column="field0038" />
		<result property="field0039" column="field0039" />
		<result property="field0044" column="field0044" />
		<result property="field0047" column="field0047" />
		<result property="field0048" column="field0048" />
		<result property="field0049" column="field0049" />
		<result property="field0050" column="field0050" />
		<result property="field0054" column="field0054" />
		<result property="field0055" column="field0055" />
		<result property="field0056" column="field0056" />
		<result property="field0057" column="field0057" />
		<result property="field0017" column="field0017" />
		<result property="field0018" column="field0018" />
		<result property="field0019" column="field0019" />
		<result property="field0021" column="field0021" />
		<result property="field0022" column="field0022" />
		<result property="field0023" column="field0023" />
		<result property="field0024" column="field0024" />
		<result property="field0025" column="field0025" />
		<result property="field0036" column="field0036" />
		<result property="field0037" column="field0037" />
		<result property="field0040" column="field0040" />
		<result property="field0041" column="field0041" />
		<result property="field0042" column="field0042" />
		<result property="field0051" column="field0051" />
		<result property="field0052" column="field0052" />
		<result property="field0053" column="field0053" />
		<result property="field0067" column="field0067" />
		<result property="field0066" column="field0066" />
		<result property="formmian_id" column="formmian_id" />
		<result property="file_url" column="file_url" />
		<result property="filename" column="filename" />
		<result property="attachment_size" column="attachment_size" />
		<result property="loginName" column="loginName" />
		<result property="dduid" column="dduid" />
		<result property="field0137" column="field0137" />
		<result property="field0264" column="field0264" />
		<result property="summary_id" column="summary_id" />
		<result property="name" column="name" />
		<result property="pk_corp" column="pk_corp" />
		<result property="field0120" column="field0120" />
		<result property="field0121" column="field0121" />
		<result property="details_id" column="details_id" />
		<result property="da_id" column="da_id" />
		<result property="field0066Id" column="field0066_id" />
		<result property="field0047Id" column="field0047_id" />
		<result property="field0034Id" column="field0034_id" />
		<result property="field0103" column="field0103" />
	</resultMap>

	<sql id="SeeyonEntity_Base_Column_List">
		id
	</sql>

	<sql id="SeeyonEntity_Base_Column_List_details">
		splitbank,bankaccno,name,code
	</sql>




	<!-- 查询 采用==查询 -->
	<select id="entity_list_base_formson_0324" resultMap="get-SeeyonEntity-result" parameterType="com.hzya.frame.seeyon.entity.SeeyonEntity">
		select
		body.id,
		field0017,
		field0018,
		field0019,
		field0021,
		field0022,
		field0023,
		field0024,
		field0025,
		item.code as field0036,
		field0037,
		field0040,
		field0041,
		field0042,
		field0051

		from formson_0324 body
		left join ctp_enum_item item on body.field0036 = item.id
		<trim prefix="where" prefixOverrides="and">
			<if test="id != null and id !=''">formmain_id=#{id}</if>
		</trim>
	</select>
	<!-- 查询 采用==查询 -->
	<select id="entity_list_base_formson_0352" resultMap="get-SeeyonEntity-result" parameterType="com.hzya.frame.seeyon.entity.SeeyonEntity">
		select
		body.id,
		item.SHOWVALUE as field0052,
		field0053

		from formson_0352 body
		left join ctp_enum_item item on body.field0052 = item.id
		<trim prefix="where" prefixOverrides="and">
			<if test="id != null and id !=''">formmain_id=#{id}</if>
		</trim>
	</select>
	<!-- 查询 采用==查询 -->
	<select id="entity_list_base_main" resultMap="get-SeeyonEntity-result" parameterType="com.hzya.frame.seeyon.entity.SeeyonEntity">
		select
			main.id,
			field0026,
			field0001,
			field0003,
			field0016,
			field0002,
			field0004,
			field0005,
			item1.SHOWVALUE as field0006,
			field0015,
			field0009,
			field0010,
			item2.SHOWVALUE as field0012,
			field0013,
			item3.SHOWVALUE as field0027,
			field0008,
			field0032,
			field0033,
			item4.SHOWVALUE as field0034,
			item5.SHOWVALUE as field0035,
			field0038,
			field0039,
			field0044,
			item6.SHOWVALUE as field0047,
			field0048,
			item7.SHOWVALUE as field0049,
			item8.SHOWVALUE as field0050,
			field0054,
			field0055,
			field0056,
			field0057,
			field0063,
			field0064,
			field0065,
			item9.SHOWVALUE as field0066,
			field0067,
			sm_user.loginName,
			sm_user.dduid,
			field0103,
			field0034 as field0034_id,
			field0047 as field0047_id,
			field0066 as field0066_id
			from formmain_0323 main
			left join ctp_enum_item item1 on main.field0006 = item1.id
			left join ctp_enum_item item2 on main.field0012 = item2.id
			left join ctp_enum_item item3 on main.field0027 = item3.id
			left join ctp_enum_item item4 on main.field0034 = item4.id
			left join ctp_enum_item item5 on main.field0035 = item5.id
			left join ctp_enum_item item6 on main.field0047 = item6.id
			left join ctp_enum_item item7 on main.field0049 = item7.id
			left join ctp_enum_item item8 on main.field0050 = item8.id
			left join ctp_enum_item item9 on main.field0066 = item9.id
			left join v_user_view_all sm_user on sm_user.id = main.start_member_id
		where 1=1
 		AND field0003 = '345678'
			and (field0103 is null or main.modify_date >= #{updateTime})
	</select>

	<!-- 查询 采用==查询 -->
	<select id="entity_list_base_ctp_attachment" resultMap="get-SeeyonEntity-result" parameterType="com.hzya.frame.seeyon.entity.SeeyonEntity">
		select * FROM ctp_attachment where sub_reference = #{sub_reference}
	</select>

	<!-- 查询 查询付款单中电子回单为null得 -->
	<select id="entity_list_base_formmain_0327" resultMap="get-SeeyonEntity-result" parameterType="com.hzya.frame.seeyon.entity.SeeyonEntity">
		select -- top 5.
			   main.id,
			   main.field0264,
			   col.id as summary_id,
			   formson.field0137 -- 付款账号
		from formmain_0327  main
				 left join formson_0329 formson on formson.formmain_id=main.id
				 left join col_summary col on col.form_recordid=main.id
		where main.field0264 is null
		  and CONVERT(varchar,main.start_date,120) > '2023-11-02 10:05'
		  and formmain_id='6385523488104860827'
		group by main.id,formson.field0137,main.field0264,col.id
	</select>

	<!-- 查询 根据付款方id查询v_user_view_all中得名称 -->
	<select id="entity_list_base_field0258" resultMap="get-SeeyonEntity-result" parameterType="com.hzya.frame.seeyon.entity.SeeyonEntity">
		select name from v_user_view_all where staffID=#{id}
	</select>

	<!-- 查询 查询速网U8C中所有组织-->
	<select id="entity_list_base_corp" resultMap="get-SeeyonEntity-result" parameterType="com.hzya.frame.seeyon.entity.SeeyonEntity">
		select pk_corp from bd_corp;
	</select>

	<!-- 查询 根据销售订单单据编码查询销售档案主键-->
	<select id="entity_list_base_formmain_0237" resultMap="get-SeeyonEntity-result" parameterType="com.hzya.frame.seeyon.entity.SeeyonEntity">
		select id as da_id from formmain_0237 where field0010=#{field0010}
	</select>

	<!-- 修改 付款单中的电子回单字段-->
	<update id="entity_update_formmain_0327" parameterType="com.hzya.frame.seeyon.entity.SeeyonEntity">
		update formmain_0327 set field0264 = #{field0264} where id = #{id}
	</update>

	<!-- 修改 -->
	<update id="entity_update" parameterType="com.hzya.frame.seeyon.entity.SeeyonEntity">
		update formmain_0323 set field0067 = 'Y'
		where id = #{id}
	</update>

	<!-- 修改 修改OA字段为速网U8C销售订单主键 -->
	<update id="entity_update_formmain_0237" parameterType="com.hzya.frame.seeyon.entity.SeeyonEntity">
		update formmain_0237 set field0120 = #{field0120}
		where field0010 = #{field0010}
	</update>

	<!-- 修改 修改OA字段为速网U8C销售订单明细主键 -->
	<update id="entity_update_formson_0238" parameterType="com.hzya.frame.seeyon.entity.SeeyonEntity">
		update formson_0238 set field0121 = #{field0121}
		where field0012 = #{field0012} and formmain_id=#{formmain_id}
	</update>

	<!-- 修改 修改付款单报销单等单据的推送状态 -->
	<update id="entity_update_push" parameterType="com.hzya.frame.seeyon.entity.SeeyonEntity">
		update ${tableName} set ${pushField} = #{pushValue}
		where id=#{id}
	</update>
</mapper>

