WDailyFundsMapper.xml
8.87 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
<?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.hotent.chkpower.dao.WDailyFundsDao">
<!-- 通用查询映射结果 -->
<resultMap id="BaseResultMap" type="com.hotent.chkpower.model.WDailyFunds">
<id column="ID_" property="id" />
<result column="REF_ID_" property="refId" />
<result column="F_date" property="fDate" />
<result column="F_org_name" property="fOrgName" />
<result column="F_org_id" property="fOrgId" />
<result column="F_org_type" property="fOrgType" />
<result column="F_yesterday_account_balance" property="fYesterdayAccountBalance" />
<result column="F_today_account_balance" property="fTodayAccountBalance" />
<result column="F_account_balance_difference" property="fAccountBalanceDifference" />
<result column="F_today_net_cash_flow" property="fTodayNetCashFlow" />
<result column="F_today_freeze_amount" property="fTodayFreezeAmount" />
<result column="F_today_freezing" property="fTodayFreezing" />
<result column="F_insp_status_name" property="fInspStatusName" />
<result column="F_insp_time" property="fInspTime" />
<result column="F_insp_notes" property="fInspNotes" />
<result column="F_insp_by" property="fInspBy" />
<result column="F_insp_id" property="fInspId" />
<result column="F_create_by" property="fCreateBy" />
<result column="F_create_id" property="fCreateId" />
<result column="F_create_time" property="fCreateTime" />
<result column="F_update_by" property="fUpdateBy" />
<result column="F_update_id" property="fUpdateId" />
<result column="F_update_time" property="fUpdateTime" />
<result column="F_form_data_rev_" property="fFormDataRev" />
<result column="F_order_no" property="fOrderNo" />
</resultMap>
<!-- 通用查询结果列 -->
<sql id="Base_Column_List">
ID_, REF_ID_, F_date, F_org_name, F_org_id, F_org_type, F_yesterday_account_balance, F_today_account_balance, F_account_balance_difference, F_today_net_cash_flow, F_today_freeze_amount, F_today_freezing, F_insp_status_name, F_insp_time, F_insp_notes, F_insp_by, F_insp_id, F_create_by, F_create_id, F_create_time, F_update_by, F_update_id, F_update_time, F_form_data_rev_, F_order_no
</sql>
<select id="selectPage" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from
w_daily_funds
${ew.customSqlSegment}
</select>
<select id="selectList" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from
w_daily_funds
${ew.customSqlSegment}
</select>
<select id="selectById" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from
w_daily_funds
where
ID_ = #{id}
</select>
<insert id="insertInitWDailyFunds">
INSERT into w_daily_funds(ID_,F_date,F_org_id,F_org_name,F_org_type,F_order_no,F_insp_status_name)
SELECT REPLACE(UUID(), '-', '') as ID_,#{fDate,jdbcType=TIMESTAMP} as F_date,org.ID_ as F_org_id,org.NAME_ as F_org_name,orgParams.VALUE_ as F_org_type,org.ORDER_NO_ as F_order_no,'待复核' as F_insp_status_name
FROM uc_org org
JOIN uc_org_params orgParams on orgParams.ORG_ID_= org.ID_
WHERE orgParams.VALUE_ !='' and orgParams.VALUE_ IS NOT NULL
</insert>
<update id="updateInitWDailyFundByOrgsDate">
UPDATE w_daily_funds funds SET
F_yesterday_account_balance =(
SELECT SUM(c.F_account_balance)
FROM w_current c
WHERE F_date =(SELECT DATE_SUB(funds.F_date, INTERVAL 1 DAY))
AND c.F_org_id = funds.F_org_id
),
F_today_account_balance =(
SELECT SUM(c.F_account_balance)
FROM w_current c
WHERE c.F_date =funds.F_date
AND c.F_org_id = funds.F_org_id
),
F_today_net_cash_flow= (
SELECT SUM(c.F_total_net_cash_flow) * 10000
FROM w_finance c
WHERE c.F_date = funds.F_date
AND c.F_org_id = funds.F_org_id
),
F_today_freeze_amount=(
SELECT SUM(c.F_freeze_amount)
FROM w_current c
WHERE c.F_date = funds.F_date
AND c.F_org_id = funds.F_org_id
),
F_today_freezing=(
SELECT SUM(c.F_freezing)
FROM w_current c
WHERE c.F_date = funds.F_date
AND c.F_org_id = funds.F_org_id
),
F_account_balance_difference = (IFNULL(funds.F_today_account_balance,0)- IFNULL(funds.F_yesterday_account_balance,0)),
F_update_by = #{fUpdateBy,jdbcType=VARCHAR},
F_update_id = #{fUpdateId,jdbcType=VARCHAR},
F_update_time = #{fUpdateTime,jdbcType=TIMESTAMP},
f_insp_status_name = '待复核',
f_insp_time = null,
f_insp_notes = null
WHERE funds.F_date = #{fDate,jdbcType=TIMESTAMP}
<if test="wCurrentList != null and wCurrentList.size() > 0">
and funds.F_org_id in
<foreach collection="wCurrentList" separator="," item="item" open="(" close=")">
#{item.F_org_id}
</foreach>
</if>
</update>
<update id="updateInitWDailyFundByDate">
UPDATE w_daily_funds funds SET
F_yesterday_account_balance =(
SELECT SUM(c.F_account_balance)
FROM w_current c
WHERE F_date =(SELECT DATE_SUB(funds.F_date, INTERVAL 1 DAY))
AND c.F_org_id = funds.F_org_id
),
F_today_account_balance =(
SELECT SUM(c.F_account_balance)
FROM w_current c
WHERE c.F_date =funds.F_date
AND c.F_org_id = funds.F_org_id
),
F_today_net_cash_flow= (
SELECT SUM(c.F_total_net_cash_flow) * 10000
FROM w_finance c
WHERE c.F_date = funds.F_date
AND c.F_org_id = funds.F_org_id
),
F_today_freeze_amount=(
SELECT SUM(c.F_freeze_amount)
FROM w_current c
WHERE c.F_date = funds.F_date
AND c.F_org_id = funds.F_org_id
),
F_today_freezing=(
SELECT SUM(c.F_freezing)
FROM w_current c
WHERE c.F_date = funds.F_date
AND c.F_org_id = funds.F_org_id
),
F_account_balance_difference = (IFNULL(funds.F_today_account_balance,0)- IFNULL(funds.F_yesterday_account_balance,0))
WHERE funds.F_date = #{fDate,jdbcType=TIMESTAMP}
</update>
<!-- <select id="selectWDailyFundsCount" resultType="java.lang.Integer">-->
<!-- SELECT COUNT(ID_) FROM w_daily_funds WHERE DATE(F_date) = DATE(#{fDate,jdbcType=TIMESTAMP})-->
<!-- </select>-->
<!-- <select id="selectWDailyFundsNews" resultType="com.hotent.chkpower.model.WDailyFunds">-->
<!-- SELECT funds.F_date,funds.id_,funds.F_org_id,funds.F_org_name ,-->
<!-- jrye.F_today_account_balance,zrye.F_yesterday_account_balance,(IFNULL(jrye.F_today_account_balance,0) - IFNULL(zrye.F_yesterday_account_balance,0)) as F_account_balance_difference-->
<!-- ,jxjl.F_today_net_cash_flow,jrye.F_today_freeze_amount,jrye.F_today_freezing-->
<!-- FROM w_daily_funds funds-->
<!-- LEFT JOIN (-->
<!-- SELECT F_org_id,SUM(F_account_balance) AS F_today_account_balance,SUM(F_freeze_amount) as F_today_freeze_amount,SUM(F_freezing) AS F_today_freezing-->
<!-- FROM w_current-->
<!-- WHERE DATE(F_date) =DATE(#{fDate,jdbcType=TIMESTAMP})-->
<!-- GROUP BY F_org_id-->
<!-- ) jrye on jrye.F_org_id = funds.F_org_id-->
<!-- LEFT JOIN (-->
<!-- SELECT F_org_id,SUM(F_account_balance) AS F_yesterday_account_balance-->
<!-- FROM w_current-->
<!-- WHERE DATE(F_date) =(SELECT DATE_SUB(DATE(#{fDate,jdbcType=TIMESTAMP}), INTERVAL 1 DAY))-->
<!-- GROUP BY F_org_id-->
<!-- ) zrye on zrye.F_org_id = funds.F_org_id-->
<!-- LEFT JOIN (-->
<!-- SELECT F_org_id, SUM(F_total_net_cash_flow) as F_today_net_cash_flow-->
<!-- FROM w_finance WHERE DATE(F_date) =DATE(#{fDate,jdbcType=TIMESTAMP})-->
<!-- GROUP BY F_org_id-->
<!-- ) jxjl on jxjl.F_org_id = funds.F_org_id-->
<!-- WHERE DATE(funds.F_date) =DATE(#{fDate,jdbcType=TIMESTAMP})-->
<!-- <if test="wCurrentList != null and wCurrentList.size() > 0">-->
<!-- and funds.F_org_id in-->
<!-- <foreach collection="wCurrentList" separator="," item="item" open="(" close=")">-->
<!-- #{item.F_org_id}-->
<!-- </foreach>-->
<!-- </if>-->
<!-- </select>-->
<!-- <select id="getDailyFundsByDateList" resultType="java.util.HashMap">-->
<!-- SELECT * FROM w_daily_funds-->
<!-- WHERE F_org_type =#{fOrgType} and DATE(F_date) =DATE(#{fDate})-->
<!-- ORDER BY F_order_no asc-->
<!-- </select>-->
</mapper>