Files
intc-cloud/intc-modules/intc-invest/src/main/resources/mapper/invest/FuturesDailyHistoryMapper.xml

245 lines
11 KiB
XML

<?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.intc.invest.mapper.FuturesDailyHistoryMapper">
<resultMap type="FuturesDailyHistoryVo" id="FuturesDailyHistoryResult">
<result property="id" column="id" />
<result property="tsCode" column="ts_code" />
<result property="tradeDate" column="trade_date" />
<result property="preClose" column="pre_close" />
<result property="preSettle" column="pre_settle" />
<result property="open" column="open" />
<result property="high" column="high" />
<result property="low" column="low" />
<result property="close" column="close" />
<result property="settle" column="settle" />
<result property="change1" column="change1" />
<result property="vol" column="vol" />
<result property="amount" column="amount" />
<result property="change2" column="change2" />
<result property="oi" column="oi" />
<result property="oiChg" column="oi_chg" />
<result property="delvSettle" column="delv_settle" />
<result property="remark" column="remark" />
<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="delFlag" column="del_flag" />
<result property="futureId" column="future_id" />
<result property="futureName" column="future_name" />
<result property="exchangeName" column="exchange_name" />
</resultMap>
<sql id="selectFuturesDailyHistoryVo">
select
a.id,
a.ts_code,
a.trade_date,
a.future_id,
a.pre_close,
a.pre_settle,
a.open,
a.high,
a.low,
a.close,
a.settle,
a.change1,
a.vol,
a.amount,
a.change2,
a.oi,
a.oi_chg,
a.delv_settle,
a.remark,
a.create_by,
a.create_time,
a.update_by,
a.update_time,
a.del_flag,
ifbi.name as future_name,
ie.short_name as exchange_name
from
futures_daily_history a
left join invest_future_base_infor ifbi on
ifbi.id = a.future_id
left join invest_future_standard_infor ifsi on
ifsi.id = ifbi.standard_id
left join invest_exchange ie on
ie.id = ifsi.exchange_id
</sql>
<select id="selectFuturesDailyHistoryList" parameterType="FuturesDailyHistoryDto" resultMap="FuturesDailyHistoryResult">
<include refid="selectFuturesDailyHistoryVo"/>
<where>
a.del_flag='0'
<if test="tsCode != null and tsCode != ''"> and (a.ts_code like '%'|| #{tsCode}||'%' or ifbi.name like '%'|| #{tsCode}||'%')</if>
<if test="endTime!=null and endTime !=''">
and #{endTime}>=to_char(a.trade_date, 'yyyy-MM-dd')
</if>
<if test="startTime!=null and startTime !=''">
and to_char(a.trade_date, 'yyyy-MM-dd')>=#{startTime}
</if>
<if test="tradeDate != null and tradeDate != ''"> and a.trade_date = #{tradeDate}</if>
<if test="preClose != null and preClose != ''"> and a.pre_close = #{preClose}</if>
<if test="preSettle != null and preSettle != ''"> and a.pre_settle = #{preSettle}</if>
<if test="open != null and open != ''"> and a.open = #{open}</if>
<if test="high != null and high != ''"> and a.high = #{high}</if>
<if test="low != null and low != ''"> and a.low = #{low}</if>
<if test="close != null and close != ''"> and a.close = #{close}</if>
<if test="settle != null and settle != ''"> and a.settle = #{settle}</if>
<if test="change1 != null and change1 != ''"> and a.change1 = #{change1}</if>
<if test="vol != null and vol != ''"> and a.vol = #{vol}</if>
<if test="amount != null and amount != ''"> and a.amount = #{amount}</if>
<if test="change2 != null and change2 != ''"> and a.change2 = #{change2}</if>
<if test="oi != null and oi != ''"> and a.oi = #{oi}</if>
<if test="oiChg != null and oiChg != ''"> and a.oi_chg = #{oiChg}</if>
<if test="delvSettle != null and delvSettle != ''"> and a.delv_settle = #{delvSettle}</if>
</where>
order by a.trade_date desc,a.ts_code
</select>
<select id="selectFuturesDailyHistoryById" parameterType="String" resultMap="FuturesDailyHistoryResult">
<include refid="selectFuturesDailyHistoryVo"/>
where a.id = #{id}
</select>
<insert id="insertFuturesDailyHistory" parameterType="FuturesDailyHistory">
insert into futures_daily_history
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">id,</if>
<if test="tsCode != null">ts_code,</if>
<if test="tradeDate != null">trade_date,</if>
<if test="preClose != null">pre_close,</if>
<if test="preSettle != null">pre_settle,</if>
<if test="open != null">open,</if>
<if test="high != null">high,</if>
<if test="low != null">low,</if>
<if test="close != null">close,</if>
<if test="settle != null">settle,</if>
<if test="change1 != null">change1,</if>
<if test="vol != null">vol,</if>
<if test="amount != null">amount,</if>
<if test="change2 != null">change2,</if>
<if test="oi != null">oi,</if>
<if test="oiChg != null">oi_chg,</if>
<if test="delvSettle != null">delv_settle,</if>
<if test="remark != null">remark,</if>
<if test="createBy != null">create_by,</if>
<if test="createTime != null">create_time,</if>
<if test="updateBy != null">update_by,</if>
<if test="updateTime != null">update_time,</if>
<if test="delFlag != null">del_flag,</if>
<if test="futureId != null">future_id,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">#{id},</if>
<if test="tsCode != null">#{tsCode},</if>
<if test="tradeDate != null">#{tradeDate},</if>
<if test="preClose != null">#{preClose},</if>
<if test="preSettle != null">#{preSettle},</if>
<if test="open != null">#{open},</if>
<if test="high != null">#{high},</if>
<if test="low != null">#{low},</if>
<if test="close != null">#{close},</if>
<if test="settle != null">#{settle},</if>
<if test="change1 != null">#{change1},</if>
<if test="vol != null">#{vol},</if>
<if test="amount != null">#{amount},</if>
<if test="change2 != null">#{change2},</if>
<if test="oi != null">#{oi},</if>
<if test="oiChg != null">#{oiChg},</if>
<if test="delvSettle != null">#{delvSettle},</if>
<if test="remark != null">#{remark},</if>
<if test="createBy != null">#{createBy},</if>
<if test="createTime != null">#{createTime},</if>
<if test="updateBy != null">#{updateBy},</if>
<if test="updateTime != null">#{updateTime},</if>
<if test="delFlag != null">#{delFlag},</if>
<if test="futureId != null">#{futureId},</if>
</trim>
</insert>
<update id="updateFuturesDailyHistory" parameterType="FuturesDailyHistory">
update futures_daily_history
<trim prefix="SET" suffixOverrides=",">
<if test="tsCode != null">ts_code = #{tsCode},</if>
<if test="tradeDate != null">trade_date = #{tradeDate},</if>
<if test="preClose != null">pre_close = #{preClose},</if>
<if test="preSettle != null">pre_settle = #{preSettle},</if>
<if test="open != null">open = #{open},</if>
<if test="high != null">high = #{high},</if>
<if test="low != null">low = #{low},</if>
<if test="close != null">close = #{close},</if>
<if test="settle != null">settle = #{settle},</if>
<if test="change1 != null">change1 = #{change1},</if>
<if test="vol != null">vol = #{vol},</if>
<if test="amount != null">amount = #{amount},</if>
<if test="change2 != null">change2 = #{change2},</if>
<if test="oi != null">oi = #{oi},</if>
<if test="oiChg != null">oi_chg = #{oiChg},</if>
<if test="delvSettle != null">delv_settle = #{delvSettle},</if>
<if test="remark != null">remark = #{remark},</if>
<if test="createBy != null">create_by = #{createBy},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="updateBy != null">update_by = #{updateBy},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
<if test="delFlag != null">del_flag = #{delFlag},</if>
<if test="futureId != null">future_id = #{futureId},</if>
</trim>
where id = #{id}
</update>
<delete id="deleteFuturesDailyHistoryById" parameterType="String">
delete from futures_daily_history where id = #{id}
</delete>
<delete id="deleteFuturesDailyHistoryByIds" parameterType="String">
delete from futures_daily_history where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
<update id="removeFuturesDailyHistoryById" parameterType="String">
update futures_daily_history set del_flag='1' where id = #{id}
</update>
<update id="removeFuturesDailyHistoryByIds" parameterType="String">
update futures_daily_history set del_flag='1' where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</update>
<insert id="batchInsertFuturesDailyHistory">
insert into futures_daily_history(id, future_id, ts_code, trade_date,pre_close,pre_settle, open, high, low, close, settle, change1, change2, vol, amount, oi, oi_chg, delv_settle, remark, create_by, create_time, update_by, update_time) values
<foreach item="item" index="index" collection="list" separator=",">
(#{item.id},
#{item.futureId},
#{item.tsCode},
#{item.tradeDate},
#{item.preClose},
#{item.preSettle},
#{item.open},
#{item.high},
#{item.low},
#{item.close},
#{item.settle},
#{item.change1},
#{item.change2},
#{item.vol},
#{item.amount},
#{item.oi},
#{item.oiChg},
#{item.delvSettle},
#{item.remark},
#{item.createBy},
#{item.createTime},
#{item.updateBy},
#{item.updateTime})
</foreach>
</insert>
</mapper>