WCurrentMapper.xml
6 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
<?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.WCurrentDao">
<!-- 通用查询映射结果 -->
<resultMap id="BaseResultMap" type="com.hotent.chkpower.model.WCurrent">
<id column="ID_" property="id" />
<result column="REF_ID_" property="refId" />
<result column="F_account_balance" property="fAccountBalance" />
<result column="F_available_balance" property="fAvailableBalance" />
<result column="F_freeze_amount" property="fFreezeAmount" />
<result column="F_freezing" property="fFreezing" />
<result column="F_notes" property="fNotes" />
<result column="F_create_time" property="fCreateTime" />
<result column="F_create_by" property="fCreateBy" />
<result column="F_create_id" property="fCreateId" />
<result column="F_corp_ope_status" property="fCorpOpeStatus" />
<result column="F_treasurer" property="fTreasurer" />
<result column="F_account_name" property="fAccountName" />
<result column="F_account_bank_name" property="fAccountBankName" />
<result column="F_bank_account" property="fBankAccount" />
<result column="F_account_nature" property="fAccountNature" />
<result column="F_currency" property="fCurrency" />
<result column="F_use_status" property="fUseStatus" />
<result column="F_form_data_rev_" property="fFormDataRev" />
<result column="F_org_name" property="fOrgName" />
<result column="F_org_id" property="fOrgId" />
<result column="F_date" property="fDate" />
<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_by_id" property="fInspById" />
<result column="F_update_by" property="fUpdateBy" />
<result column="F_update_id" property="fUpdateId" />
<result column="F_update_time" property="fUpdateTime" />
<result column="F_insp_status_name" property="fInspStatusName" />
<result column="F_insp_id" property="fInspId" />
<result column="F_org_type" property="fOrgType" />
</resultMap>
<!-- 通用查询结果列 -->
<sql id="Base_Column_List">
ID_, REF_ID_, F_account_balance, F_available_balance, F_freeze_amount, F_freezing, F_notes, F_create_time, F_create_by, F_create_id, F_corp_ope_status, F_treasurer, F_account_name, F_account_bank_name, F_bank_account, F_account_nature, F_currency, F_use_status, F_form_data_rev_, F_org_name, F_org_id, F_date, F_insp_time, F_insp_notes, F_insp_by, F_insp_by_id, F_update_by, F_update_id, F_update_time, F_insp_status_name, F_insp_id, F_org_type
</sql>
<select id="selectPage" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from
w_current
${ew.customSqlSegment}
</select>
<select id="selectList" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from
w_current
${ew.customSqlSegment}
</select>
<select id="selectById" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from
w_current
where
ID_ = #{id}
</select>
<select id="getHistoricalDetail" resultMap="BaseResultMap">
SELECT org.ID_ as F_org_id,org.NAME_ as F_org_name,acc.F_org_type,
acc.F_corp_ope_status,acc.F_cashier_name as F_treasurer,acc.F_account_name,acc.F_account_bank_name,acc.F_bank_account,acc.F_account_nature,acc.F_currency,acc.F_use_status,
zh.F_account_balance, zh.F_available_balance, zh.F_freeze_amount, zh.F_freezing, zh.F_notes
FROM uc_org org
JOIN w_bank_account acc ON acc.F_org_id= org.ID_
LEFT JOIN (
SELECT c1.F_org_id, c1.F_bank_account, c1.F_date, c1.F_account_balance, c1.F_available_balance, c1.F_freeze_amount, c1.F_freezing, c1.F_notes,c1.id_
FROM w_current c1
JOIN (
SELECT c3.F_org_id, c3.F_bank_account,max(c3.id_) as id_ FROM w_current c3
JOIN (
SELECT DISTINCT F_org_id, F_bank_account, MAX(F_date) as MaxDate
FROM w_current
GROUP BY F_org_id, F_bank_account
) c4 ON c3.F_org_id = c4.F_org_id AND c3.F_bank_account = c4.F_bank_account AND c3.F_date = c4.MaxDate
GROUP BY c3.F_org_id, c3.F_bank_account
) c2
ON c1.F_org_id = c2.F_org_id AND c1.F_bank_account = c2.F_bank_account AND c1.id_ = c2.id_
) zh on zh.F_org_id = acc.F_org_id and zh.F_bank_account = acc.F_bank_account
WHERE 1=1 AND ACC.F_use_status !='停用'
<if test="orgIdList != null and orgIdList.size() > 0">
and org.ID_ in
<foreach collection="orgIdList" separator="," item="orgId" open="(" close=")">
#{orgId}
</foreach>
</if>
<if test="orgIdList == null or orgIdList.size() == 0">
and 1=2
</if>
</select>
<select id="getCurrentAccountBalanceList" resultType="java.util.HashMap">
SELECT org.ID_ as F_org_id,org.NAME_ as F_org_name,orgParams.VALUE_ as F_org_type,org.ORDER_NO_,YE.F_account_balance
FROM uc_org org
JOIN uc_org_params orgParams on orgParams.ORG_ID_= org.ID_
LEFT JOIN (
SELECT F_org_id, F_org_name,SUM(F_account_balance) AS F_account_balance
FROM w_current
WHERE DATE(F_date) =DATE(#{fDate})
GROUP BY F_org_id, F_org_name
) YE ON YE.F_org_id = org.ID_
WHERE 1=1
AND orgParams.VALUE_ !=''
AND orgParams.VALUE_ = #{fOrgType}
ORDER BY orgParams.VALUE_,org.ORDER_NO_ ASC
</select>
<select id="getCurrentOrgTypeList" resultType="java.lang.String">
SELECT orgParams.VALUE_ AS orgType
FROM uc_org org
JOIN uc_org_params orgParams on orgParams.ORG_ID_= org.ID_
WHERE 1=1
AND orgParams.VALUE_ !=''
AND orgParams.VALUE_ IS NOT NULL
GROUP BY orgParams.VALUE_
ORDER BY MAX(org.ORDER_NO_) ASC
</select>
</mapper>