otc-entrust-batch-mapper.xml
3.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
<?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">
<!-- 当天委托交易(hs_otc.otcentrust) @author tongyufu -->
<mapper namespace="com.cjs.cms.dao.trade.OtcEntrustBatchDao">
<sql id="otc_entrust_field">
E.OTC_CODE, E.OTC_NAME, E.OTC_PROP, E.ENTRUST_PRICE, E.ENTRUST_AMOUNT, E.ENTRUST_STATUS,
E.BUSINESS_PRICE, E.BUSINESS_AMOUNT, E.BUSINESS_BALANCE, E.CURR_DATE, E.CURR_TIME,
E.SUCCESS, E.T2RESULT, E.POSITION_STR, E.OP_STATION, E.FUND_ACCOUNT, E.OTC_ACCOUNT
</sql>
<insert id="save" parameterType="OtcEntrustBatchInfo">
INSERT INTO HS_ASSET.OTCENTRUST_BATCH (OTC_CODE, OTC_NAME, OTC_PROP, ENTRUST_PRICE,
BUSINESS_PRICE, BUSINESS_AMOUNT, BUSINESS_BALANCE, CURR_DATE, CURR_TIME,
ENTRUST_AMOUNT, ENTRUST_STATUS, SUCCESS, T2RESULT, POSITION_STR, OP_STATION,
FUND_ACCOUNT, OTC_ACCOUNT, CLIENT_ID)
VALUES (#{otcCode}, #{otcName}, #{otcProp}, #{entrustPrice}, #{businessPrice},
#{businessAmount}, #{businessBalance}, #{currDate}, #{currTime}, #{entrustAmount},
#{entrustStatus}, #{success}, #{t2Result}, #{positionStr}, #{opStation},
#{fundAccount}, #{otcAccount}, #{fundAccount})
</insert>
<!-- 查询指定op_station的下单日期 -->
<select id="queryCurrDate" resultType="map" parameterType="map">
SELECT E.OP_STATION, E.CURR_DATE
FROM HS_ASSET.OTCENTRUST_BATCH E
WHERE E.SUCCESS = '1' AND E.OP_STATION IN
<foreach collection="opStations" item="opStation" open="(" close=")" separator=",">#{opStation}</foreach>
<![CDATA[AND E.CURR_DATE <= ]]> #{initDate}
</select>
<sql id="searchCondition">
where 1 = 1
<if test="fundAccount != null and fundAccount != ''"> and e.fund_account = #{fundAccount} </if>
<if test="otcCode != null and otcCode != ''"> and e.otc_code = #{otcCode} </if>
<if test="success != null and success != ''"> and e.success = #{success} </if>
<if test="otcProp != null and otcProp != ''"> and e.otc_prop = #{otcProp} </if>
<if test="startDate != null and startDate != ''">
<![CDATA[and e.curr_date >= #{startDate}]]>
</if>
<if test="endDate != null and endDate != ''">
<![CDATA[and e.curr_date <= #{endDate}]]>
</if>
</sql>
<select id="search" parameterType="map" resultType="OtcEntrustBatchInfo">
<include refid="common.pageStart"/>
SELECT <include refid="otc_entrust_field" />
FROM (
SELECT * FROM HS_ASSET.OTCENTRUST_BATCH
UNION ALL
SELECT * FROM HS_ASSET.HIS_OTCENTRUST_BATCH) E
<include refid="searchCondition" />
ORDER BY E.CURR_DATE DESC, E.CURR_TIME
<include refid="common.pageEnd"/>
</select>
<select id="searchTotal" parameterType="map" resultType="int">
SELECT COUNT(*)
FROM (
SELECT * FROM HS_ASSET.OTCENTRUST_BATCH
UNION ALL
SELECT * FROM HS_ASSET.HIS_OTCENTRUST_BATCH) E
<include refid="searchCondition" />
</select>
<!-- 备份委托记录 -->
<insert id="backupsEntrust" parameterType="int">
INSERT INTO HS_ASSET.HIS_OTCENTRUST_BATCH
SELECT * FROM HS_ASSET.OTCENTRUST_BATCH E
<![CDATA[WHERE E.CURR_DATE <= ]]> #{value}
</insert>
<!-- 删除已备份数据 -->
<delete id="deleteToBackups" parameterType="int">
DELETE HS_ASSET.OTCENTRUST_BATCH E
<![CDATA[WHERE E.CURR_DATE <= ]]> #{value}
</delete>
</mapper>