TreatySoaInfoMapper.xml
20.3 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
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
<?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="cn.com.polysoft.template.dao.TreatySoaInfoMapper" >
<insert id="saveTreatySoaInfo" keyProperty="recordId" useGeneratedKeys="true" parameterType="cn.com.polysoft.template.entity.TreatySoaInfoEntity">
insert into treaty_soa_info(
record_id,
treaty_name,
treaty_no,
uw_year,
treaty_period_start,
treaty_period_end,
account_category,
account_no,
account_period,
class_code,
account_currency,
reins_code,
reins_name,
vat_flag,
your_share,
ri_premium,
ri_commission,
tax,
fee_of_uw,
fee_of_loss,
paid_loss,
cash_loss,
survey_fee,
premium_reserves_petained,
loss_reserves_retained,
profit_commission,
interest,
engineering_fee,
brokerage,
vat,
vat_surtax,
vat_deducion,
brokerage_vat,
balance,
outstanding_losses,
exchangerate_cny,
premium_cny,
vat_cny,
issue_date,
remarks,
creator,
authorizer,
create_time,
check_status,
send_date,
business_treaty_no,
business_treaty_name,
serial_number,
batch_id,
itemid,
fail_reason,
settle_date,
other_itemid
) values (
#{recordId},
#{treatyName},
#{treatyNo},
#{uwYear},
#{treatyPeriodStart},
#{treatyPeriodEnd},
#{accountCategory},
#{accountNo},
#{accountPeriod},
#{classCode},
#{accountCurrency},
#{reinsCode},
#{reinsName},
#{vatFlag},
#{yourShare},
#{riPremium},
#{riCommission},
#{tax},
#{feeOfUw},
#{feeOfLoss},
#{paidLoss},
#{cashLoss},
#{surveyFee},
#{premiumReservesPetained},
#{lossReservesRetained},
#{profitCommission},
#{interest},
#{engineeringFee},
#{brokerage},
#{vat},
#{vatSurtax},
#{vatDeducion},
#{brokerageVat},
#{balance},
#{outstandingLosses},
#{exchangerateCny},
#{premiumCny},
#{vatCny},
#{issueDate},
#{remarks},
#{creator},
#{authorizer},
#{createTime},
#{checkStatus},
#{sendDate},
#{businessTreatyNo},
#{businessTreatyName},
#{serialNumber},
#{batchId},
#{itemid},
#{failReason},
#{settleDate},
#{otherItemid}
)
</insert>
<select id="queryByCondition" resultType="cn.com.polysoft.template.entity.TreatySoaInfoEntity">
select * from treaty_soa_info t where 1 = 1 and t.check_status = #{checkStatus} and send_date = #{checkDate} and t.bill_num is null
</select>
<select id="queryByCondition2" resultType="cn.com.polysoft.template.entity.TreatySoaInfoEntity">
select * from treaty_soa_info t where 1 = 1 and t.check_status = #{checkStatus} and t.record_id = #{billId} and t.bill_num is null
</select>
<select id="queryCheckData" resultType="cn.com.polysoft.template.entity.TreatySoaInfoEntity">
select * from treaty_soa_info t where 1 = 1 and t.check_status = #{checkStatus} and send_date = #{checkDate} and t.account_currency = #{accountCurrency}
</select>
<select id="queryCurrency" resultType="cn.com.polysoft.template.entity.TreatySoaInfoEntity">
select t.account_currency from treaty_soa_info t where t.check_status = #{checkStatus} and t.send_date = #{checkDate} group by t.account_currency
</select>
<select id="queryCurrency3" resultType="cn.com.polysoft.template.entity.TreatySoaInfoEntity">
select t.batch_id from treaty_soa_info t where t.send_date = #{checkDate}
</select>
<update id="updateFailReason">
update treaty_soa_info set fail_reason = #{failReason},check_status = #{checkStatus} where serial_number = #{serialNumber}
</update>
<update id="updateBillNum">
update treaty_soa_info set bill_num = #{billNum},check_status = #{checkStatus},submit_business_time=#{submitTime} where serial_number = #{serialNumber}
</update>
<select id="queryCountByCheckDate" parameterType="String" resultType="int">
select count(1) num from treaty_soa_info where send_date = #{checkDate} and check_status = #{checkStatus}
</select>
<!--<update id="updateCheckStatus">-->
<!--update treaty_soa_info set check_status = #{checkStatus},check_time = now() where record_id = #{recordId}-->
<!--</update>-->
<update id="updateCheckStatus">
update treaty_soa_info set check_status = #{checkStatus},fail_reason = #{msg},check_time = #{timestamp} where record_id = #{recordId}
</update>
<select id="querySumByCurrencyAndCheckDate" resultType="cn.com.polysoft.template.dto.property.CheckDetailInfoDTO">
select t.currency,sum(cast(t.balance as numeric)) balance,sum(cast(t.ri_premium as numeric)) ri_premium,
sum(t.ri_commission) ri_commission,sum(t.tax) tax,sum(t.fee_of_uw) fee_of_uw,
sum(t.fee_of_loss) fee_of_loss,sum(t.paid_loss) paid_loss,sum(t.cash_loss) cash_loss,
sum(t.survey_fee) survey_fee,sum(t.premium_reserves_retained) premium_reserves_retained,
sum(t.loss_reserves_retained) loss_reserves_retained,sum(t.profit_commission) profit_commission,
sum(t.interest) interest,sum(t.engineering_fee) engineering_fee,sum(t.brokerage) brokerage,
sum(t.vat) vat,sum(t.vat_surtax) vat_surtax,sum(t.vat_deducion) vat_deducion,sum(t.brokerage_vat) brokerage_vat,
sum(t.outstanding_losses) outstanding_losses
from installment_details t
inner join treaty_soa_info a on t.treaty_fac_id = a.record_id and t.bill_type = #{billType} and t.currency_type = #{currencyType}
where a.send_date = #{checkDate} and t.currency = #{currency} and (a.check_status = #{checkStatusInit} or a.check_status = #{checkStatusFail})
group by t.currency
</select>
<select id="querySumByCurrencyAndCheckDateOfTreaty" resultType="cn.com.polysoft.template.dto.property.CheckDetailInfoDTO">
SELECT s.balance FROM treaty_soa_info s
WHERE
s.send_date = #{checkDate}
AND s.account_currency = #{currency}
AND (
s.check_status = #{checkStatusInit}
OR s.check_status = #{checkStatusFail}
)
</select>
<select id="selectTreatySoaInfo" resultType="cn.com.polysoft.template.entity.TreatySoaInfoEntity">
select * from treaty_soa_info t where t.check_status = #{checkStatus}
</select>
<select id="queryListByCondition" parameterType="cn.com.polysoft.template.dto.property.QueryListDTO" resultType="cn.com.polysoft.template.vo.PropertyDataListVO">
select t.record_id,t.batch_id,t.account_no,t.treaty_no,t.bill_num,t.business_treaty_no,
<!--case when t.account_category = '01' then '季度账单'
when t.account_category = '02' then '特殊账单'
when t.account_category = '03' then '超赔预付保费账单'
when t.account_category = '04' then '超赔调整保费账单'
when t.account_category = '05' then '超赔赔款账单'
when t.account_category = '06' then '损失分担账单'
when t.account_category = '07' then '关门账单' else '' end--> account_category,
'合约账单' account_type,to_char(t.create_time,'yyyy-MM-dd') create_time,to_char(t.check_time,'yyyy-MM-dd') check_time,
<!--case when t.check_status = '-1' then '财险账单接收失败'
when t.check_status = '0' then '财险账单接收成功'
when t.check_status = '1' then '核查成功'
when t.check_status = '2' then '核查失败' to_date(to_char(t.submit_business_time,'yyyy-MM-dd'),'yyyy-MM-dd')
when t.check_status = '3' then '业务系统处理成功'
when t.check_status = '4' then '业务系统处理失败' else '' end--> fail_reason check_status,
t.check_status check_status_code,to_char(t.submit_business_time,'yyyy-MM-dd HH24:mm:ss')submit_business_time
from treaty_soa_info t
<where>
<if test="batchId != null and batchId != ''">and t.batch_id like #{batchId}</if>
<if test="treatyNo != null and treatyNo != ''">and t.treaty_no like #{treatyNo}</if>
<if test="businessTreatyNo != null and businessTreatyNo != ''">and t.business_treaty_no like #{businessTreatyNo}</if>
<if test="accountNo != null and accountNo != ''">and t.account_no like #{accountNo}</if>
<if test="currency != null and currency != ''">and t.account_currency = #{currency}</if>
<if test="accountCategory != null and accountCategory != ''">and t.account_category = #{accountCategory}</if>
<if test="checkTimeStart != null and checkTimeStart != ''">and to_date(to_char(t.check_time,'yyyy-MM-dd'),'yyyy-MM-dd') >= to_date(#{checkTimeStart},'yyyy-MM-dd')</if>
<if test="checkTimeEnd != null and checkTimeEnd != ''">and to_date(to_char(t.check_time,'yyyy-MM-dd'),'yyyy-MM-dd') <= to_date(#{checkTimeEnd},'yyyy-MM-dd')</if>
<if test="checkStatus != null and checkStatus != ''">and t.check_status = #{checkStatus}</if>
<if test="pageType==1 and checkStatus == null ">and t.check_status in ('3','4')</if>
<if test="pageType==1 and checkStatus == '' ">and t.check_status in ('3','4')</if>
<if test="createTimeStart != null and createTimeStart != ''">and to_date(to_char(t.create_time,'yyyy-MM-dd'),'yyyy-MM-dd') >= to_date(#{createTimeStart},'yyyy-MM-dd')</if>
<if test="createTimeEnd != null and createTimeEnd != ''">and to_date(to_char(t.create_time,'yyyy-MM-dd'),'yyyy-MM-dd') <= to_date(#{createTimeEnd},'yyyy-MM-dd')</if>
<if test="billNum != null and billNum != ''">and t.bill_num like #{billNum}</if>
<if test="submitBusinessTimeStart != null and submitBusinessTimeStart != ''">and to_date(to_char(t.submit_business_time,'yyyy-MM-dd'),'yyyy-MM-dd') >= to_date(#{submitBusinessTimeStart},'yyyy-MM-dd')</if>
<if test="submitBusinessTimeEnd != null and submitBusinessTimeEnd != ''">and to_date(to_char(t.submit_business_time,'yyyy-MM-dd'),'yyyy-MM-dd') <= to_date(#{submitBusinessTimeEnd},'yyyy-MM-dd')</if>
</where>
order by t.create_time desc,t.account_no
</select>
<select id="getFailReasonByCondition" resultType="string">
select t.fail_reason from treaty_soa_info t where t.batch_id = #{batchId} and t.account_no = #{accountNo}
</select>
<select id="getInfoById" resultType="cn.com.polysoft.template.vo.TreatySoaInfoVO">
select t.record_id,t.batch_id,'合约账单' account_type,
case when t.account_category = '01' then '季度账单'
when t.account_category = '02' then '特殊账单'
when t.account_category = '03' then '超赔预付保费账单'
when t.account_category = '04' then '超赔调整保费账单'
when t.account_category = '05' then '超赔赔款账单'
when t.account_category = '06' then '损失分担账单'
when t.account_category = '07' then '关门账单' else '' end account_category_name,
t.account_category,t.itemid,
t.account_no,t.uw_year,t.account_period,t.account_currency,t.treaty_no,
t.treaty_name,t.class_code,t.treaty_period_start,t.treaty_period_end,
t.creator,t.vat_flag,t.your_share,t.authorizer,t.issue_date,
to_char(t.create_time,'yyyy-MM-dd') create_time,to_char(t.check_time,'yyyy-MM-dd') check_time,
to_char(t.submit_business_time,'yyyy-MM-dd') submit_business_time,
t.ri_premium,t.vat,t.balance,t.exchangerate_cny,t.premium_cny,t.vat_cny,t.outstanding_losses,
t.ri_commission,t.paid_loss,t.premium_reserves_petained,t.fee_of_uw,t.cash_loss,
t.loss_reserves_retained,t.fee_of_loss,t.tax,t.remarks,t.profit_commission,t.interest,
t.engineering_fee,t.survey_fee,t.business_treaty_no,t.business_treaty_name,b.startdate myPeriodStart,
b.enddate myPeriodEnd,t.settle_date,t.bill_num
from treaty_soa_info t
left join inwardtreatyinfo b on t.business_treaty_no = b.treatyid
where t.record_id = #{recordId}
</select>
<update id="updateTreatyInfo" parameterType="cn.com.polysoft.template.dto.property.TreatySoaInfoDTO">
update treaty_soa_info
<set>
<!--<if test="treatyName != null" and treatyName != ''>treaty_name = #{treatyName},</if>-->
<!--<if test="treatyName == null or treatyName == ''">treaty_name = null,</if>-->
<!--<if test="treatyNo != null">treaty_no = #{treatyNo},</if>-->
<if test="uwYear != null and uwYear != ''">uw_year = #{uwYear},</if>
<if test="uwYear == null or uwYear == ''">uw_year = #{uwYear},</if>
<!--<if test="treatyPeriodStart != null">treaty_period_start = #{treatyPeriodStart},</if>-->
<!--<if test="treatyPeriodEnd != null">treaty_period_end = #{treatyPeriodEnd},</if>-->
<if test="accountCategory != null and accountCategory != ''">account_category = #{accountCategory},</if>
<if test="accountCategory == null or accountCategory == ''">account_category = null,</if>
<!--<if test="accountNo != null">account_no = #{accountNo},</if>-->
<if test="accountPeriod != null and accountPeriod != ''">account_period = #{accountPeriod},</if>
<if test="accountPeriod == null or accountPeriod == ''">account_period = null,</if>
<!--<if test="classCode != null">class_code = #{classCode},</if>-->
<if test="accountCurrency != null and accountCurrency != ''">account_currency = #{accountCurrency},</if>
<if test="accountCurrency == null or accountCurrency == ''">account_currency = null,</if>
<!--<if test="reinsCode != null">reins_code = #{reinsCode},</if>-->
<!--<if test="reinsName != null">reins_name = #{reinsName},</if>-->
<if test="vatFlag != null and vatFlag != ''">vat_flag = #{vatFlag},</if>
<if test="vatFlag == null or vatFlag == ''">vat_flag = null,</if>
<if test="yourShare != null or yourShare == null">your_share = #{yourShare},</if>
<if test="riPremium != null or riPremium == null">ri_premium = #{riPremium},</if>
<if test="riCommission != null or riCommission == null">ri_commission = #{riCommission},</if>
<if test="tax != null or tax == null">tax = #{tax},</if>
<if test="feeOfUw != null or feeOfUw == null">fee_of_uw = #{feeOfUw},</if>
<if test="feeOfLoss != null or feeOfLoss == null">fee_of_loss = #{feeOfLoss},</if>
<if test="paidLoss != null or paidLoss == null">paid_loss = #{paidLoss},</if>
<if test="cashLoss != null or cashLoss == null">cash_loss = #{cashLoss},</if>
<if test="surveyFee != null or surveyFee == null">survey_fee = #{surveyFee},</if>
<if test="premiumReservesPetained != null or premiumReservesPetained == null">premium_reserves_petained = #{premiumReservesPetained},</if>
<if test="lossReservesRetained != null or lossReservesRetained == null">loss_reserves_retained = #{lossReservesRetained},</if>
<if test="profitCommission != null or profitCommission == null">profit_commission = #{profitCommission},</if>
<if test="engineeringFee != null or engineeringFee == null">engineering_fee = #{engineeringFee},</if>
<!--<if test="brokerage != null">brokerage = #{brokerage},</if>-->
<if test="vat != null or vat == null">vat = #{vat},</if>
<!--<if test="vatSurtax != null">vat_surtax = #{vatSurtax},</if>-->
<!--<if test="vatDeducion != null">vat_deducion = #{vatDeducion},</if>-->
<!--<if test="brokerageVat != null">brokerage_vat = #{brokerageVat},</if>-->
<if test="balance != null or balance == null">balance = #{balance},</if>
<if test="outstandingLosses != null or outstandingLosses == null">outstanding_losses = #{outstandingLosses},</if>
<if test="exchangerateCny != null or exchangerateCny == null">exchangerate_cny = #{exchangerateCny},</if>
<if test="premiumCny != null or premiumCny == null">premium_cny = #{premiumCny},</if>
<if test="vatCny != null or vatCny == null">vat_cny = #{vatCny},</if>
<!--<if test="issueDate != null">issue_date = #{issueDate},</if>-->
<if test="remarks != null and remarks != ''">remarks = #{remarks},</if>
<if test="remarks == null or remarks == ''">remarks = null,</if>
<!--<if test="creator != null">creator = #{creator},</if>-->
<!--<if test="authorizer != null">authorizer = #{authorizer},</if>-->
<if test="settleDate != null and settleDate != ''">settle_date = #{settleDate},</if>
<if test="settleDate == null or settleDate == ''">settle_date = null,</if>
<if test="itemid != null and itemid !=''">itemid = #{itemid},</if>
<if test="itemid == null or itemid == ''">itemid = null,</if>
<if test="interest != null or interest == null">interest = #{interest},</if>
<if test="businessTreatyNo != null and businessTreatyNo != ''">business_treaty_no = #{businessTreatyNo},</if>
<if test="businessTreatyNo == null or businessTreatyNo == ''">business_treaty_no = null,</if>
<if test="businessTreatyName != null and businessTreatyName != ''">business_treaty_name = #{businessTreatyName},</if>
<if test="businessTreatyName == null or businessTreatyName == ''">business_treaty_name = null,</if>
</set>
where record_id = #{recordId}
</update>
<select id="queryBatchId" resultType="cn.com.polysoft.template.entity.TreatySoaInfoEntity">
select t.* from treaty_soa_info t where t.account_no=#{accountNo}
</select>
<select id="getByRecordId" resultType="cn.com.polysoft.template.entity.TreatySoaInfoEntity">
select * from treaty_soa_info t where t.record_id = #{recordId}
</select>
<select id="getStatusByBatchId" resultType="cn.com.polysoft.template.entity.TreatySoaInfoEntity">
select check_status from treaty_soa_info t where t.batch_id = #{batchId} group by check_status
</select>
<select id="getfailReasonByBatchIdStatus" resultType="cn.com.polysoft.template.entity.TreatySoaInfoEntity">
select t.fail_reason from treaty_soa_info t where t.check_status = #{checkStatus} and t.batch_id = #{batchId} GROUP by t.fail_reason
</select>
<select id="getfailData" resultType="cn.com.polysoft.template.entity.TreatySoaInfoEntity">
SELECT * FROM treaty_soa_info s WHERE (s.ri_premium is null or s.ri_premium = '0')
AND (s.ri_commission is null or s.ri_commission = '0')
AND (s.tax is null or s.tax = '0')
AND (s.fee_of_uw is null or s.fee_of_uw = '0')
AND (s.fee_of_loss is null or s.fee_of_loss = '0')
AND (s.paid_loss is null or s.paid_loss = '0')
AND (s.cash_loss is null or s.cash_loss = '0')
AND (s.survey_fee is null or s.survey_fee = '0')
AND (s.premium_reserves_petained is null or s.premium_reserves_petained = '0')
AND (s.loss_reserves_retained is null or s.loss_reserves_retained = '0')
AND (s.profit_commission is null or s.profit_commission = '0')
AND (s.interest is null or s.interest = '0')
AND (s.engineering_fee is null or s.engineering_fee = '0')
AND (s.brokerage is null or s.brokerage = '0')
AND (s.vat is null or s.vat = '0')
AND (s.vat_surtax is null or s.vat_surtax = '0')
AND (s.vat_deducion is null or s.vat_deducion = '0')
AND (s.brokerage_vat is null or s.brokerage_vat = '0')
AND (s.brokerage_vat is null or s.brokerage_vat = '0')
AND s.balance='0'
AND s.outstanding_losses!='0'
<!--AND s.treaty_no !='OP201905'-->
</select>
<select id="getStatusListByBatchId" resultType="cn.com.polysoft.template.entity.TreatySoaInfoEntity">
select check_status from treaty_soa_info t where t.batch_id = #{batchId} GROUP BY check_status
</select>
</mapper>