cloudroam
2025-03-10 c306cba52bcc3e2c423f77d4a52c35ad04c52038
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
<?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.jsh.erp.datasource.mappers.AccountHeadMapperEx">
 
    <resultMap extends="com.jsh.erp.datasource.mappers.AccountHeadMapper.BaseResultMap" id="ResultMapEx" type="com.jsh.erp.datasource.entities.AccountHeadVo4ListEx">
        <result column="OrganName" jdbcType="VARCHAR" property="organName" />
        <result column="HandsPersonName" jdbcType="VARCHAR" property="handsPersonName" />
        <result column="userName" jdbcType="VARCHAR" property="userName" />
        <result column="AccountName" jdbcType="VARCHAR" property="accountName" />
    </resultMap>
 
    <select id="selectByConditionAccountHead" parameterType="com.jsh.erp.datasource.entities.AccountHeadExample" resultMap="ResultMapEx">
        select distinct ah.*, s.supplier OrganName, p.Name HandsPersonName, u.username userName, a.Name AccountName
        from jsh_account_head ah
        left join jsh_account_item ai on ah.id=ai.header_id and ifnull(ai.delete_flag,'0') !='1'
        left join jsh_depot_head dh on dh.id=ai.bill_id and ifnull(dh.delete_flag,'0') !='1'
        left join jsh_supplier s on ah.organ_id=s.id and ifnull(s.delete_Flag,'0') !='1'
        left join jsh_user u on ah.creator=u.id and ifnull(u.delete_flag,'0') !='1'
        left join jsh_person p on ah.hands_person_id=p.id and ifnull(p.delete_Flag,'0') !='1'
        left join jsh_account a on ah.account_id=a.id and ifnull(a.delete_Flag,'0') !='1'
        where 1=1
        <if test="billNo != null">
            <bind name="bindBillNo" value="'%'+billNo+'%'"/>
            and ah.bill_no like #{bindBillNo}
        </if>
        <if test="type != null">
            and ah.type=#{type}
        </if>
        <if test="beginTime != null">
            and ah.bill_time &gt;= #{beginTime}
        </if>
        <if test="endTime != null">
            and ah.bill_time &lt;= #{endTime}
        </if>
        <if test="organId != null">
            and ah.organ_id=#{organId}
        </if>
        <if test="handsPersonId != null">
            and ah.hands_person_id=#{handsPersonId}
        </if>
        <if test="creator != null">
            and ah.creator=#{creator}
        </if>
        <if test="creatorArray != null">
            and ah.creator in (
            <foreach collection="creatorArray" item="creator" separator=",">
                #{creator}
            </foreach>
            )
        </if>
        <if test="accountId != null">
            and ah.account_id=#{accountId}
        </if>
        <if test="status != null and status != ''">
            and ah.status=#{status}
        </if>
        <if test="remark != null and remark !=''">
            <bind name="bindRemark" value="'%'+remark+'%'"/>
            and ah.remark like #{bindRemark}
        </if>
        <if test="number != null and number !=''">
            <if test="number == 'QiChu'">
                and ai.bill_id is null
            </if>
            <if test="number != 'QiChu'">
                <bind name="bindNumber" value="'%'+number+'%'"/>
                and dh.number like #{bindNumber}
            </if>
        </if>
        and ifnull(ah.delete_flag,'0') !='1'
        order by ah.id desc
        <if test="offset != null and rows != null">
            limit #{offset},#{rows}
        </if>
    </select>
 
 
    <select id="countsByAccountHead" resultType="java.lang.Long">
        SELECT
        COUNT(1) from
        (select distinct ah.* FROM jsh_account_head ah
        left join jsh_account_item ai on ah.id=ai.header_id and ifnull(ai.delete_flag,'0') !='1'
        left join jsh_depot_head dh on dh.id=ai.bill_id and ifnull(dh.delete_flag,'0') !='1'
        WHERE 1=1
        <if test="billNo != null">
            <bind name="bindBillNo" value="'%'+billNo+'%'"/>
            and ah.bill_no like #{bindBillNo}
        </if>
        <if test="type != null">
            and ah.type=#{type}
        </if>
        <if test="beginTime != null">
            and ah.bill_time &gt;= #{beginTime}
        </if>
        <if test="endTime != null">
            and ah.bill_time &lt;= #{endTime}
        </if>
        <if test="organId != null">
            and ah.organ_id=#{organId}
        </if>
        <if test="handsPersonId != null">
            and ah.hands_person_id=#{handsPersonId}
        </if>
        <if test="creator != null">
            and ah.creator=#{creator}
        </if>
        <if test="creatorArray != null">
            and ah.creator in (
            <foreach collection="creatorArray" item="creator" separator=",">
                #{creator}
            </foreach>
            )
        </if>
        <if test="accountId != null">
            and ah.account_id=#{accountId}
        </if>
        <if test="status != null and status != ''">
            and ah.status=#{status}
        </if>
        <if test="remark != null and remark !=''">
            <bind name="bindRemark" value="'%'+remark+'%'"/>
            and ah.remark like #{bindRemark}
        </if>
        <if test="number != null and number !=''">
            <if test="number == 'QiChu'">
                and ai.bill_id is null
            </if>
            <if test="number != 'QiChu'">
                <bind name="bindNumber" value="'%'+number+'%'"/>
                and dh.number like #{bindNumber}
            </if>
        </if>
        and ifnull(ah.delete_flag,'0') !='1') tb
    </select>
 
    <select id="getDetailByNumber" parameterType="com.jsh.erp.datasource.entities.AccountHeadExample" resultMap="ResultMapEx">
        select ah.*, s.supplier OrganName, p.Name HandsPersonName, a.Name AccountName
        from jsh_account_head ah
        left join jsh_supplier s on ah.organ_id=s.id and ifnull(s.delete_Flag,'0') !='1'
        left join jsh_person p on ah.hands_person_id=p.id and ifnull(p.delete_Flag,'0') !='1'
        left join jsh_account a on ah.account_id=a.id and ifnull(a.delete_Flag,'0') !='1'
        where 1=1
        <if test="billNo != null">
            and ah.bill_no = #{billNo}
        </if>
        and ifnull(ah.delete_flag,'0') !='1'
    </select>
    <update id="batchDeleteAccountHeadByIds">
        update jsh_account_head
        set delete_flag='1'
        where 1=1
        and id in (
        <foreach collection="ids" item="id" separator=",">
            #{id}
        </foreach>
        )
    </update>
    <select id="getAccountHeadListByAccountIds"  resultMap="com.jsh.erp.datasource.mappers.AccountHeadMapper.BaseResultMap">
        select
        <include refid="com.jsh.erp.datasource.mappers.AccountHeadMapper.Base_Column_List" />
        from jsh_account_head
        where 1=1
        and account_id in (
        <foreach collection="accountIds" item="accountId" separator=",">
            #{accountId}
        </foreach>
        )
        and ifnull(delete_flag,'0') !='1'
    </select>
    <select id="getAccountHeadListByOrganIds"  resultMap="com.jsh.erp.datasource.mappers.AccountHeadMapper.BaseResultMap">
        select
        <include refid="com.jsh.erp.datasource.mappers.AccountHeadMapper.Base_Column_List" />
        from jsh_account_head
        where 1=1
        and organ_id in (
        <foreach collection="organIds" item="organId" separator=",">
            #{organId}
        </foreach>
        )
        and ifnull(delete_flag,'0') !='1'
    </select>
    <select id="getAccountHeadListByHandsPersonIds"  resultMap="com.jsh.erp.datasource.mappers.AccountHeadMapper.BaseResultMap">
        select
        <include refid="com.jsh.erp.datasource.mappers.AccountHeadMapper.Base_Column_List" />
        from jsh_account_head
        where 1=1
        and hands_person_id in (
        <foreach collection="handsPersonIds" item="handsPersonId" separator=",">
            #{handsPersonId}
        </foreach>
        )
        and ifnull(delete_flag,'0') !='1'
    </select>
 
    <select id="getFinancialBillNoByBillIdList" resultType="com.jsh.erp.datasource.entities.AccountItem">
        select ai.bill_id from jsh_account_head ah
        left join jsh_account_item ai on ah.id=ai.header_id and ifnull(ai.delete_flag,'0') !='1'
        where 1=1
        <if test="idList.size()>0">
            and ai.bill_id in
            <foreach collection="idList" item="item" index="index" separator="," open="(" close=")">
                #{item}
            </foreach>
        </if>
        and ifnull(ah.delete_flag,'0') !='1'
    </select>
 
    <select id="getFinancialBillNoByBillId" resultType="com.jsh.erp.datasource.entities.AccountHead">
        select ah.bill_no from jsh_account_head ah
        left join jsh_account_item ai on ah.id=ai.header_id and ifnull(ai.delete_flag,'0') !='1'
        where ai.bill_id=#{billId}
        and ifnull(ah.delete_flag,'0') !='1'
    </select>
 
    <select id="getFinancialAllPriceByOrganId" resultType="java.math.BigDecimal">
        select ifnull(sum(ah.total_price),0) allPrice from jsh_account_head ah
        where ah.organ_id=#{organId}
        and ah.type = '收预付款'
        and ifnull(ah.delete_flag,'0') !='1'
    </select>
</mapper>