You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
274 lines
15 KiB
274 lines
15 KiB
|
4 years ago
|
<?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.ruoyi.stocksystem.mapper.StocksMapper">
|
||
|
|
|
||
|
|
<resultMap type="Stocks" id="StocksResult">
|
||
|
|
<result property="id" column="id" />
|
||
|
|
<result property="code" column="code" />
|
||
|
|
<result property="name" column="name" />
|
||
|
|
<result property="blemind2" column="blemind2" />
|
||
|
|
<result property="blemind3" column="blemind3" />
|
||
|
|
<result property="listdate" column="listdate" />
|
||
|
|
<result property="tradeDay" column="trade_day" />
|
||
|
|
<result property="stradeDay" column="strade_day" />
|
||
|
|
<result property="open" column="open" />
|
||
|
|
<result property="close" column="close" />
|
||
|
|
<result property="high" column="high" />
|
||
|
|
<result property="low" column="low" />
|
||
|
|
<result property="islimit" column="islimit" />
|
||
|
|
<result property="isdrop" column="isdrop" />
|
||
|
|
<result property="differrange" column="differrange" />
|
||
|
|
<result property="tradeDays" column="trade_days" />
|
||
|
|
<result property="volumn" column="volumn" />
|
||
|
|
<result property="amount" column="amount" />
|
||
|
|
<result property="differrange10" column="differrange10" />
|
||
|
|
<result property="differrange20" column="differrange20" />
|
||
|
|
<result property="differrange60" column="differrange60" />
|
||
|
|
<result property="avgVolume20" column="avg_volume20" />
|
||
|
|
<result property="freefloatMarketValue" column="freefloat_market_value" />
|
||
|
|
<result property="totalMarketValue" column="total_market_value" />
|
||
|
|
<result property="agenciesHold" column="agencies_hold" />
|
||
|
|
<result property="blemindCount" column="blemind_count" />
|
||
|
|
<result property="listdate" column="listdate" />
|
||
|
|
<result property="blemindsCount" column="blemindsCount" />
|
||
|
|
</resultMap>
|
||
|
|
|
||
|
|
<resultMap id="StocksStockBasicResult" type="Stocks" extends="StocksResult">
|
||
|
|
<collection property="stockBasicList" notNullColumn="sub_id" javaType="java.util.List" resultMap="StockBasicResult" />
|
||
|
|
</resultMap>
|
||
|
|
|
||
|
|
|
||
|
|
<sql id="selectStocksVo">
|
||
|
|
select id, code, trade_day, open, close, differrange, trade_days, volumn, amount, differrange10, differrange20, differrange60, avg_volume20, freefloat_market_value, total_market_value, agencies_hold from stocks
|
||
|
|
</sql>
|
||
|
|
|
||
|
|
<select id="selectStocksList" parameterType="Stocks" resultMap="StocksResult">
|
||
|
|
<include refid="selectStocksVo"/>
|
||
|
|
<where>
|
||
|
|
<if test="code != null and code != ''"> and code = #{code}</if>
|
||
|
|
<if test="tradeDay != null "> and trade_day = #{tradeDay}</if>
|
||
|
|
<if test="open != null "> and open = #{open}</if>
|
||
|
|
<if test="close != null "> and close = #{close}</if>
|
||
|
|
<if test="differrange != null "> and differrange = #{differrange}</if>
|
||
|
|
<if test="tradeDays != null "> and trade_days = #{tradeDays}</if>
|
||
|
|
<if test="volumn != null "> and volumn = #{volumn}</if>
|
||
|
|
<if test="amount != null "> and amount = #{amount}</if>
|
||
|
|
<if test="differrange10 != null "> and differrange10 = #{differrange10}</if>
|
||
|
|
<if test="differrange20 != null "> and differrange20 = #{differrange20}</if>
|
||
|
|
<if test="differrange60 != null "> and differrange60 = #{differrange60}</if>
|
||
|
|
<if test="avgVolume20 != null "> and avg_volume20 = #{avgVolume20}</if>
|
||
|
|
<if test="freefloatMarketValue != null "> and freefloat_market_value = #{freefloatMarketValue}</if>
|
||
|
|
<if test="totalMarketValue != null "> and total_market_value = #{totalMarketValue}</if>
|
||
|
|
<if test="agenciesHold != null "> and agencies_hold = #{agenciesHold}</if>
|
||
|
|
</where>
|
||
|
|
</select>
|
||
|
|
|
||
|
|
<select id="selectStocksListB" parameterType="Stocks" resultMap="StocksResult">
|
||
|
|
select a.code , a.trade_day , a.open, a.close, a.differrange, a.trade_days, a.volumn, a.amount, a.differrange10, a.differrange20, a.differrange60, a.avg_volume20, a.freefloat_market_value, a.total_market_value, a.agencies_hold,
|
||
|
|
b.name as name, b.blemind2 as blemind2, b.blemind3 as blemind3, b.listdate as listdate
|
||
|
|
from stocks a
|
||
|
|
left join stock_basis b on b.code = a.code
|
||
|
|
where a.trade_day = #{tradeDay}
|
||
|
|
</select>
|
||
|
|
|
||
|
|
<select id="selectStocksListSort" parameterType="Stocks" resultMap="StocksResult">
|
||
|
|
select a.code , a.trade_day , a.open, a.close, a.differrange, a.trade_days, a.volumn, a.amount, a.differrange10, a.differrange20, a.differrange60, a.avg_volume20, a.freefloat_market_value, a.total_market_value, a.agencies_hold,
|
||
|
|
b.name as name, b.blemind2 as blemind2, b.blemind3 as blemind3, b.listdate as listdate
|
||
|
|
from stocks a
|
||
|
|
left join stock_basis b on b.code = a.code
|
||
|
|
<where>
|
||
|
|
<if test="tradeDay != null "> and a.trade_day = #{tradeDay}</if>
|
||
|
|
<if test="tradeDays != null "> and a.trade_days >= #{tradeDays}</if>
|
||
|
|
<if test="differrange10 != null "> and a.differrange10 = #{differrange10}</if>
|
||
|
|
<if test="differrange20 != null "> and a.differrange20 = #{differrange20}</if>
|
||
|
|
<if test="differrange60 != null "> and a.differrange60 = #{differrange60}</if>
|
||
|
|
<if test="agenciesHold != null "> and a.agencies_hold >= #{agenciesHold}</if>
|
||
|
|
</where>
|
||
|
|
</select>
|
||
|
|
|
||
|
|
<select id="selectGroupStocksList" parameterType="Stocks" resultMap="StocksResult">
|
||
|
|
select blemind2 ,COUNT(blemind2) as blemind_count from (select s.code, sb.blemind2 as blemind2 from stocks s, stock_basis sb WHERE s.`code` = sb.`code` and s.trade_day = #{tradeDay}) temp GROUP BY blemind2 ORDER BY blemind_count DESC
|
||
|
|
</select>
|
||
|
|
|
||
|
|
<select id="selectStocksById" parameterType="Long" resultMap="StocksStockBasicResult">
|
||
|
|
select a.id, a.code, a.trade_day, a.open, a.close, a.differrange, a.trade_days, a.volumn, a.amount, a.differrange10, a.differrange20, a.differrange60, a.avg_volume20, a.freefloat_market_value, a.total_market_value, a.agencies_hold,
|
||
|
|
b.id as sub_id, b.code as sub_code, b.name as sub_name, b.blemind2 as sub_blemind2, b.blemind3 as sub_blemind3, b.listdate as sub_listdate
|
||
|
|
from stocks a
|
||
|
|
left join stock_basis b on b.code = a.id
|
||
|
|
where a.id = #{id}
|
||
|
|
</select>
|
||
|
|
|
||
|
|
<select id="selectStocksByCode" parameterType="Stocks" resultMap="StocksResult">
|
||
|
|
select id, code, trade_day, open, close, differrange, trade_days, volumn, amount, differrange10, differrange20, differrange60, avg_volume20, freefloat_market_value, total_market_value, agencies_hold from stocks where code = #{code} and trade_day = #{tradeDay}
|
||
|
|
</select>
|
||
|
|
|
||
|
|
<insert id="insertStocks" parameterType="Stocks" useGeneratedKeys="true" keyProperty="id">
|
||
|
|
insert into stocks
|
||
|
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||
|
|
<if test="code != null and code != ''">code,</if>
|
||
|
|
<if test="tradeDay != null">trade_day,</if>
|
||
|
|
<if test="open != null">open,</if>
|
||
|
|
<if test="close != null">close,</if>
|
||
|
|
<if test="high != null">high,</if>
|
||
|
|
<if test="low != null">low,</if>
|
||
|
|
<if test="islimit != null">islimit,</if>
|
||
|
|
<if test="isdrop != null">isdrop,</if>
|
||
|
|
<if test="differrange != null">differrange,</if>
|
||
|
|
<if test="tradeDays != null">trade_days,</if>
|
||
|
|
<if test="volumn != null">volumn,</if>
|
||
|
|
<if test="amount != null">amount,</if>
|
||
|
|
<if test="differrange10 != null">differrange10,</if>
|
||
|
|
<if test="differrange20 != null">differrange20,</if>
|
||
|
|
<if test="differrange60 != null">differrange60,</if>
|
||
|
|
<if test="avgVolume20 != null">avg_volume20,</if>
|
||
|
|
<if test="freefloatMarketValue != null">freefloat_market_value,</if>
|
||
|
|
<if test="totalMarketValue != null">total_market_value,</if>
|
||
|
|
<if test="agenciesHold != null">agencies_hold,</if>
|
||
|
|
</trim>
|
||
|
|
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||
|
|
<if test="code != null and code != ''">#{code},</if>
|
||
|
|
<if test="tradeDay != null">#{tradeDay},</if>
|
||
|
|
<if test="open != null">#{open},</if>
|
||
|
|
<if test="close != null">#{close},</if>
|
||
|
|
<if test="high != null">#{high},</if>
|
||
|
|
<if test="low != null">#{low},</if>
|
||
|
|
<if test="islimit != null">#{islimit},</if>
|
||
|
|
<if test="isdrop != null">#{isdrop},</if>
|
||
|
|
<if test="differrange != null">#{differrange},</if>
|
||
|
|
<if test="tradeDays != null">#{tradeDays},</if>
|
||
|
|
<if test="volumn != null">#{volumn},</if>
|
||
|
|
<if test="amount != null">#{amount},</if>
|
||
|
|
<if test="differrange10 != null">#{differrange10},</if>
|
||
|
|
<if test="differrange20 != null">#{differrange20},</if>
|
||
|
|
<if test="differrange60 != null">#{differrange60},</if>
|
||
|
|
<if test="avgVolume20 != null">#{avgVolume20},</if>
|
||
|
|
<if test="freefloatMarketValue != null">#{freefloatMarketValue},</if>
|
||
|
|
<if test="totalMarketValue != null">#{totalMarketValue},</if>
|
||
|
|
<if test="agenciesHold != null">#{agenciesHold},</if>
|
||
|
|
</trim>
|
||
|
|
</insert>
|
||
|
|
|
||
|
|
<update id="updateStocks" parameterType="Stocks">
|
||
|
|
update stocks
|
||
|
|
<trim prefix="SET" suffixOverrides=",">
|
||
|
|
<if test="code != null and code != ''">code = #{code},</if>
|
||
|
|
<if test="tradeDay != null">trade_day = #{tradeDay},</if>
|
||
|
|
<if test="open != null">open = #{open},</if>
|
||
|
|
<if test="close != null">close = #{close},</if>
|
||
|
|
<if test="high != null">high = #{high},</if>
|
||
|
|
<if test="low != null">low = #{low},</if>
|
||
|
|
<if test="islimit != null">islimit = #{islimit},</if>
|
||
|
|
<if test="isdrop != null">isdrop = #{isdrop},</if>
|
||
|
|
<if test="differrange != null">differrange = #{differrange},</if>
|
||
|
|
<if test="tradeDays != null">trade_days = #{tradeDays},</if>
|
||
|
|
<if test="volumn != null">volumn = #{volumn},</if>
|
||
|
|
<if test="amount != null">amount = #{amount},</if>
|
||
|
|
<if test="differrange10 != null">differrange10 = #{differrange10},</if>
|
||
|
|
<if test="differrange20 != null">differrange20 = #{differrange20},</if>
|
||
|
|
<if test="differrange60 != null">differrange60 = #{differrange60},</if>
|
||
|
|
<if test="avgVolume20 != null">avg_volume20 = #{avgVolume20},</if>
|
||
|
|
<if test="freefloatMarketValue != null">freefloat_market_value = #{freefloatMarketValue},</if>
|
||
|
|
<if test="totalMarketValue != null">total_market_value = #{totalMarketValue},</if>
|
||
|
|
<if test="agenciesHold != null">agencies_hold = #{agenciesHold},</if>
|
||
|
|
</trim>
|
||
|
|
where trade_day = #{tradeDay} and code = #{code}
|
||
|
|
</update>
|
||
|
|
|
||
|
|
<delete id="deleteStocksById" parameterType="Long">
|
||
|
|
delete from stocks where id = #{id}
|
||
|
|
</delete>
|
||
|
|
|
||
|
|
<delete id="deleteStocksByIds" parameterType="String">
|
||
|
|
delete from stocks where id in
|
||
|
|
<foreach item="id" collection="array" open="(" separator="," close=")">
|
||
|
|
#{id}
|
||
|
|
</foreach>
|
||
|
|
</delete>
|
||
|
|
|
||
|
|
<delete id="deleteStockBasicByCodes" parameterType="String">
|
||
|
|
delete from stock_basis where code in
|
||
|
|
<foreach item="code" collection="array" open="(" separator="," close=")">
|
||
|
|
#{code}
|
||
|
|
</foreach>
|
||
|
|
</delete>
|
||
|
|
|
||
|
|
<delete id="deleteStockBasicByCode" parameterType="Long">
|
||
|
|
delete from stock_basis where code = #{code}
|
||
|
|
</delete>
|
||
|
|
|
||
|
|
<insert id="batchStockBasic">
|
||
|
|
insert into stock_basis( id, code, name, blemind2, blemind3, listdate) values
|
||
|
|
<foreach item="item" index="index" collection="list" separator=",">
|
||
|
|
( #{item.id}, #{item.code}, #{item.name}, #{item.blemind2}, #{item.blemind3}, #{item.listdate})
|
||
|
|
</foreach>
|
||
|
|
</insert>
|
||
|
|
|
||
|
|
<select id="selectStockBasicByCode" parameterType="String" resultMap="StocksResult">
|
||
|
|
select name, code, blemind2, blemind3 from stock_basis where code = #{code}
|
||
|
|
</select>
|
||
|
|
|
||
|
|
<select id="selectStockBasicList" parameterType="Stocks" resultMap="StocksResult">
|
||
|
|
select name, code, blemind2, blemind3 from stock_basis
|
||
|
|
</select>
|
||
|
|
|
||
|
|
<insert id="insertStockBasic" parameterType="Stocks" useGeneratedKeys="true" keyProperty="id">
|
||
|
|
insert into stock_basis
|
||
|
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||
|
|
<if test="code != null">code,</if>
|
||
|
|
<if test="name != null">name,</if>
|
||
|
|
<if test="blemind2 != null">blemind2,</if>
|
||
|
|
<if test="blemind3 != null">blemind3,</if>
|
||
|
|
<if test="listdate != null">listdate,</if>
|
||
|
|
</trim>
|
||
|
|
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||
|
|
<if test="code != null">#{code},</if>
|
||
|
|
<if test="name != null">#{name},</if>
|
||
|
|
<if test="blemind2 != null">#{blemind2},</if>
|
||
|
|
<if test="blemind3 != null">#{blemind3},</if>
|
||
|
|
<if test="listdate != null">#{listdate},</if>
|
||
|
|
</trim>
|
||
|
|
</insert>
|
||
|
|
|
||
|
|
<update id="updateStockBasic" parameterType="Stocks">
|
||
|
|
update stock_basis
|
||
|
|
<trim prefix="SET" suffixOverrides=",">
|
||
|
|
<if test="code != null">code = #{code},</if>
|
||
|
|
<if test="name != null">name = #{name},</if>
|
||
|
|
<if test="blemind2 != null">blemind2 = #{blemind2},</if>
|
||
|
|
<if test="blemind3 != null">blemind3 = #{blemind3},</if>
|
||
|
|
<if test="listdate != null">listdate = #{listdate},</if>
|
||
|
|
</trim>
|
||
|
|
where code = #{code}
|
||
|
|
</update>
|
||
|
|
|
||
|
|
<select id="selectStocksDistributionSubtract" parameterType="Stocks" resultType="int">
|
||
|
|
select count(code) as dcount from stocks
|
||
|
|
<where>
|
||
|
|
<if test="tradeDay != null "> and trade_day = #{tradeDay}</if>
|
||
|
|
<if test="differrange != null "> and differrange > #{differrange}</if>
|
||
|
|
</where>
|
||
|
|
</select>
|
||
|
|
|
||
|
|
<select id="selectStocksDistributionEqual" parameterType="Stocks" resultType="int">
|
||
|
|
select count(code) as dcount from stocks
|
||
|
|
<where>
|
||
|
|
<if test="tradeDay != null "> and trade_day = #{tradeDay}</if>
|
||
|
|
<if test="differrange != null "> and differrange = #{differrange}</if>
|
||
|
|
</where>
|
||
|
|
</select>
|
||
|
|
|
||
|
|
<select id="selectGroupStocksLimit" parameterType="Stocks" resultMap="StocksResult">
|
||
|
|
select sb.blemind2 as blemind2 ,COUNT(blemind2) as blemindsCount from stocks sl,stock_basis sb
|
||
|
|
where sl.`code` = sb.`code` and sl.trade_day = #{tradeDay} and sl.isdrop=#{isdrop} and sl.islimit=#{islimit} GROUP BY blemind2 ORDER BY blemindsCount DESC limit 10;
|
||
|
|
</select>
|
||
|
|
|
||
|
|
<select id="selectStockHistory" parameterType="Stocks" resultMap="StocksResult">
|
||
|
|
select trade_day,code,open,close,high,low, volumn,differrange from stocks where trade_day BETWEEN '2021-01-01' and #{tradeDay} and `code`=#{code} ORDER BY trade_day desc;
|
||
|
|
</select>
|
||
|
|
|
||
|
|
<select id="selectStocksForHigh" parameterType="Stocks" resultMap="StocksResult">
|
||
|
|
select trade_day,code,open,MAX(close) as close,high,low,differrange20 from stocks where trade_day BETWEEN #{stradeDay} and #{tradeDay} GROUP BY code ORDER BY differrange20 desc;
|
||
|
|
</select>
|
||
|
|
</mapper>
|