trust-apply-ext-mapper.xml
7.92 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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
<?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">
<!-- 托管信息附加表(在交易系统oracle库的hs_asset用户下) @author 仝玉甫 -->
<mapper namespace="com.cjs.cms.dao.ration.TrustApplyExtDao">
<!-- 查询指定藏品的客户同意配售数量 -->
<select id="queryAggreeCount" parameterType="string" resultType="int">
SELECT SUM(A.APPROVAL_COUNT)
FROM HS_ASSET.TRUSTAPPLY A, HS_ASSET.TRUSTAPPLY_EXT E
WHERE A.APPLY_NO = E.APPLY_NO AND E.AGGREE_STATUS = '1' AND A.OTC_CODE = #{value}
</select>
<!-- 查询指定藏品的客户同意配售列表 -->
<select id="queryAggreeList" parameterType="string" resultType="TrustApplyExtInfo">
SELECT A.FUND_ACCOUNT, A.APPLY_NO, A.OTC_CODE, A.OTC_NAME, A.APPLY_COUNT,
A.APPROVAL_COUNT, A.BACK_AMOUNT, A.PRE_IN_AMOUNT, A.APPLY_TYPE,
E.AGGREE_STATUS, E.AGGREE_DATE, E.AGGREE_TIME
FROM HS_ASSET.TRUSTAPPLY A, HS_ASSET.TRUSTAPPLY_EXT E
WHERE A.APPLY_NO = E.APPLY_NO AND E.AGGREE_STATUS = '1' AND A.OTC_CODE = #{value}
AND A.APPLY_TYPE = '4'
ORDER BY E.AGGREE_DATE, E.AGGREE_TIME
</select>
<!-- 查询指定单号托管信息 -->
<select id="queryTrunstApply" parameterType="string" resultType="TrustApplyExtInfo">
SELECT A.FUND_ACCOUNT, A.APPLY_NO, A.OTC_CODE, A.OTC_NAME, A.APPLY_COUNT,
A.APPROVAL_COUNT, A.BACK_AMOUNT, A.PRE_IN_AMOUNT, A.APPLY_TYPE, A.ISSUE_PRICE
FROM HS_ASSET.TRUSTAPPLY A
WHERE A.APPLY_NO = #{value}
</select>
<!-- 修改配售状态(0:待同意;1:待交割;2:已入库) -->
<update id="updateAggreeStatus" parameterType="string">
UPDATE HS_ASSET.TRUSTAPPLY_EXT SET AGGREE_STATUS = #{aggreeStatus}
WHERE APPLY_NO = #{applyNo}
</update>
<!-- 查询还未同意配售的用户列表 -->
<select id="queryUserListNotAgree" parameterType="string" resultType="map">
SELECT DISTINCT(T.FUND_ACCOUNT)
FROM HS_ASSET.TRUSTAPPLY T
WHERE T.OTC_CODE = #{otcCode} AND T.APPLY_TYPE = '4'
AND T.APPLY_NO NOT IN (SELECT E.APPLY_NO FROM HS_ASSET.TRUSTAPPLY_EXT E)
ORDER BY T.FUND_ACCOUNT DESC
</select>
<select id="queryTotalCount" parameterType="string" resultType="int">
SELECT NVL(SUM(A.APPROVAL_COUNT),0)
FROM HS_ASSET.TRUSTAPPLY A, HS_ASSET.TRUSTAPPLY_EXT E
WHERE A.APPLY_NO = E.APPLY_NO AND A.OTC_CODE = #{value}
</select>
<!-- 查询用户同意与否状况 -->
<select id="queryAgreeInfoByConditions" parameterType="map" resultType="map">
<include refid="common.pageStart" />
SELECT T.OTC_CODE, T.OTC_NAME, T.FUND_ACCOUNT, T.CLIENT_NAME,
T.APPLY_NO, T.INNERCIRCULAT_NO, T.APPROVAL_COUNT, T.TELPHONE, E.RETURN_STATUS
FROM HS_ASSET.TRUSTAPPLY T
LEFT JOIN HS_ASSET.TRUSTAPPLY_EXT E
ON T.APPLY_NO = E.APPLY_NO
<include refid="agreeCondition" />
ORDER BY T.APPLY_NO DESC
<include refid="common.pageEnd" />
</select>
<!-- 查询用户同意与否数量 -->
<select id="queryAgreeInfoAmount" parameterType="map" resultType="int">
SELECT COUNT(1) from HS_ASSET.TRUSTAPPLY T LEFT JOIN HS_ASSET.TRUSTAPPLY_EXT E
ON T.APPLY_NO = E.APPLY_NO
<include refid="agreeCondition" />
</select>
<sql id="agreeCondition">
WHERE 1=1
<foreach collection="direct" open="and (" close=")" item="dir" separator="or">
otc_code = #{dir}
</foreach>
<if test="otcCode != null and otcCode != ''">
AND T.OTC_CODE = #{otcCode}
</if>
<if test="otcName != null and otcName != ''">
AND T.OTC_NAME = #{otcName}
</if>
<if test="fundAccount != null and fundAccount != ''">
AND T.FUND_ACCOUNT = #{fundAccount}
</if>
<if test="clientName != null and clientName != ''">
AND T.CLIENT_NAME = #{clientName}
</if>
<if test="applyNo != null and applyNo != ''">
AND T.APPLY_NO = #{applyNo}
</if>
<if test="innercirculatNo != null and innercirculatNo != ''">
AND T.INNERCIRCULAT_NO = #{innercirculatNo}
</if>
<if test="agree != null and agree != ''">
<if test="agree == 1">
AND T.APPLY_NO IN (SELECT E.APPLY_NO FROM HS_ASSET.TRUSTAPPLY_EXT E)
AND (T.APPLY_TYPE = '4' OR T.APPLY_TYPE = '5' OR T.APPLY_TYPE = '6')
</if>
<if test="agree == 0">
AND T.APPLY_NO NOT IN (SELECT E.APPLY_NO FROM HS_ASSET.TRUSTAPPLY_EXT E)
AND (T.APPLY_TYPE = '4' OR T.APPLY_TYPE = '5')
</if>
</if>
<if test="agree == ''">
AND T.APPLY_TYPE NOT IN ('1', '3', '7')
</if>
</sql>
<!-- 查询通过数量统计 -->
<select id="querySumApprovalCount" parameterType="map" resultType="int">
SELECT NVL(SUM(T.APPROVAL_COUNT),0) FROM HS_ASSET.TRUSTAPPLY T
LEFT JOIN HS_ASSET.TRUSTAPPLY_EXT E
ON T.APPLY_NO = E.APPLY_NO
<include refid="agreeCondition" />
</select>
<!-- 再托管_查询再托管申请通过总量 -->
<select id="queryApplyTotal" parameterType="map" resultType="int">
SELECT NVL(SUM(T.APPROVAL_COUNT),0) FROM HS_ASSET.TRUSTAPPLY_EXT E
LEFT JOIN HS_ASSET.TRUSTAPPLY T ON T.APPLY_NO = E.APPLY_NO
WHERE E.AGGREE_STATUS = '1'
AND T.OTC_CODE = #{otcCode}
AND E.AGGREE_DATE between #{startDate} and #{endDate}
</select>
<!-- 插入托管信息ext表 -->
<insert id="insertTrustApplyExt" parameterType="TrustApplyExtInfo">
insert into hs_asset.trustapply_ext (APPLY_NO, AGGREE_STATUS, AGGREE_DATE,
AGGREE_TIME, RETURN_STATUS)
values(#{applyNo}, #{aggreeStatus}, #{aggreeDate}, #{aggreeTime}, #{returnStatus})
</insert>
<delete id="deleExtByOtcCode" parameterType="java.lang.String">
DELETE FROM HS_ASSET.TRUSTAPPLY_EXT WHERE APPLY_NO IN
(SELECT APPLY_NO FROM HS_ASSET.TRUSTAPPLY T WHERE T.OTC_CODE = #{value})
</delete>
<insert id="insertExtByCode" parameterType="java.lang.String">
insert into HS_ASSET.TRUSTAPPLY_EXT
(APPLY_NO, AGGREE_STATUS, AGGREE_DATE, AGGREE_TIME, RETURN_STATUS)
SELECT APPLY_NO,
'1' as AGGREE_STATUS,
to_number(to_char(sysdate, 'yyyymmdd')) as AGGREE_DATE,
substr(to_char(sysdate, 'yyyymmdd hh24miss'), 10, 14) AGGREE_TIME,
'0' as RETURN_STATUS
from HS_ASSET.TRUSTAPPLY
WHERE OTC_CODE = #{value} and APPLY_TYPE in ('0','2','4','5','6')
</insert>
<sql id="applyCondition">
<if test="otcCode != null and otcCode != ''">
AND T.OTC_CODE = #{otcCode}
</if>
<if test="otcName != null and otcName != ''">
AND T.OTC_NAME = #{otcName}
</if>
<if test="fundAccount != null and fundAccount != ''">
AND T.FUND_ACCOUNT = #{fundAccount}
</if>
<if test="clientName != null and clientName != ''">
AND T.CLIENT_NAME = #{clientName}
</if>
<if test="innercirculatNo != null and innercirculatNo != ''">
AND T.INNERCIRCULAT_NO = #{innercirculatNo}
</if>
<if test="applyType != null and applyType != ''">
AND T.apply_type = #{applyType}
</if>
<if test="startDate != null and startDate != ''"> and to_date(t.apply_date,'yyyy-mm-dd')>=to_date(#{startDate},'yyyy-mm-dd') </if>
<if test="endDate != null and endDate != ''"> <![CDATA[and to_date(t.apply_date,'yyyy-mm-dd')<=to_date(#{endDate},'yyyy-mm-dd') ]]></if>
</sql>
<!-- 查看在入库申请 -->
<select id="searchPick" parameterType="map" resultType="map">
<include refid="common.pageStart" />
select t.* from HS_ASSET.TRUSTAPPLY t ,HS_ASSET.TRUSTAPPLY_EXT b
where t.APPLY_NO=b.APPLY_NO and b.IS_PACK_TRUST='1'
<include refid="applyCondition" />
order by t.APPLY_NO desc
<include refid="common.pageEnd" />
</select>
<select id="searchPickTotal" parameterType="map" resultType="int">
select count(1) from (select t.* from HS_ASSET.TRUSTAPPLY t ,HS_ASSET.TRUSTAPPLY_EXT b
where t.APPLY_NO=b.APPLY_NO and b.IS_PACK_TRUST='1'
<include refid="applyCondition" />
)
</select>
<!-- 导出未确权的文件 -->
<select id="exportPick" parameterType="map" resultType="map">
select t.OTC_CODE,t.APPROVAL_COUNT ,t.APPLY_NO , t.OTC_ACCOUNT from HS_ASSET.TRUSTAPPLY t ,HS_ASSET.TRUSTAPPLY_EXT b
where t.APPLY_NO=b.APPLY_NO and b.IS_PACK_TRUST='1'
and t.apply_type='5'
</select>
<!-- 修改状态为已经确权 -->
<update id="updatePick" parameterType="String">
update HS_ASSET.TRUSTAPPLY set apply_type='6' where APPLY_NO=#{applyNo}
</update>
</mapper>