<?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.hundsun.cloudtrade.match.dao.IDayHoldDao">
<sql id="insertIntoHoldSql">
INSERT INTO tb_day_hold (
firm_account ,
seat_no ,
stock_account ,
exchange_type ,
stock_name ,
stock_code ,
amount ,
market_value ,
position_str
)VALUES (
#{firm_account } ,
#{seat_no } ,
#{stock_account } ,
#{exchange_type } ,
#{stock_name } ,
#{stock_code } ,
<choose>
<when test="occur_amount != null and occur_amount != '' ">
#{occur_amount } ,
</when>
<when test="amount != null and amount != '' ">
#{amount } ,
</when>
<otherwise>
0,
</otherwise>
</choose>
#{market_value } ,
#{position_str }
)
</sql>
<insert id="addOrUpdateOne_addAmount" parameterType="com.hundsun.cloudtrade.match.domain.DayHoldDomain">
<include refid="insertIntoHoldSql"></include>
<![CDATA[
ON DUPLICATE KEY UPDATE
amount = amount + VALUES(amount)
;
]]>
</insert>
<insert id="addOrUpdateOne_amount" parameterType="com.hundsun.cloudtrade.match.domain.DayHoldDomain">
<include refid="insertIntoHoldSql"></include>
<![CDATA[
ON DUPLICATE KEY UPDATE
amount = VALUES(amount) , seat_no = VALUES(seat_no)
;
]]>
</insert>
<select id="qryMultiRecords"
parameterType="com.hundsun.cloudtrade.match.dto.req.QryHoldReq"
resultType="com.hundsun.cloudtrade.match.domain.DayHoldDomain">
SELECT
firm_account ,
seat_no ,
stock_account ,
exchange_type ,
stock_name ,
stock_code ,
amount ,
market_value ,
position_str
<choose>
<!-- 查询历史持仓表 -->
<when test="hold_date != null and hold_date != '' ">
,hold_date FROM tb_history_hold
</when>
<!-- 查询当日持仓 -->
<otherwise>
,'' hold_date FROM tb_day_hold
</otherwise>
</choose>
WHERE firm_account = #{firm_account}
<if test="seat_no != null and seat_no != '' ">
AND seat_no = #{seat_no}
</if>
<if test="exchange_type != null and exchange_type != '' ">
AND exchange_type = #{exchange_type}
</if>
<if test="stock_account != null and stock_account != '' ">
AND stock_account = #{stock_account}
</if>
<if test="position_str != null and position_str != '' ">
AND position_str = #{position_str}
</if>
ORDER BY stock_code DESC
<if test="req_number != null and req_number != '' ">
LIMIT 0,#{req_number}
</if>
;
</select>
<delete id="delMultiRecords" parameterType="com.hundsun.cloudtrade.match.dto.req.DelHoldsReq">
<![CDATA[
DELETE FROM tb_history_hold WHERE firm_account = #{firm_account};
DELETE FROM tb_day_hold WHERE firm_account = #{firm_account};
]]>
</delete>
</mapper>
数据源的配置:
jdbc.url=jdbc:mysql://10.20.135.32:8066/TESTDB?autoReconnect=true&allowMultiQueries=true
jdbc.username=root
jdbc.password=123456
jdbc.driverClass=com.mysql.jdbc.Driver
注意 allowMultiQueries=true 说明允许了多个 sql 语句的同时操作