shiyunteng
2026-10-30 145580fd820bb31334f2e71643413e846b7ce904
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
<?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.by4cloud.platformx.business.mapper.ContractSubjectMatterMapper">
 
  <resultMap id="contractSubjectMatterMap" type="com.by4cloud.platformx.business.entity.ContractSubjectMatter">
        <id property="id" column="id"/>
        <result property="compId" column="comp_id"/>
        <result property="acceptTime" column="accept_time"/>
        <result property="actualDeliveryDate" column="actual_delivery_date"/>
        <result property="attachmentUrl" column="attachment_url"/>
        <result property="brand" column="brand"/>
        <result property="category" column="category"/>
        <result property="contractId" column="contract_id"/>
        <result property="contractName" column="contract_name"/>
        <result property="deliveryPlace" column="delivery_place"/>
        <result property="deliveryStatus" column="delivery_status"/>
        <result property="description" column="description"/>
        <result property="isAccepted" column="is_accepted"/>
        <result property="materialCode" column="material_code"/>
        <result property="materialInternalName" column="material_internal_name"/>
        <result property="materialName" column="material_name"/>
        <result property="plannedDeliveryDate" column="planned_delivery_date"/>
        <result property="quantity" column="quantity"/>
        <result property="sortOrder" column="sort_order"/>
        <result property="specification" column="specification"/>
        <result property="taxAmount" column="tax_amount"/>
        <result property="taxRate" column="tax_rate"/>
        <result property="totalAmount" column="total_amount"/>
        <result property="totalAmountExcludingTax" column="total_amount_excluding_tax"/>
        <result property="unit" column="unit"/>
        <result property="unitPrice" column="unit_price"/>
        <result property="warrantyPeriod" column="warranty_period"/>
        <result property="createBy" column="create_by"/>
        <result property="createTime" column="create_time"/>
        <result property="updateBy" column="update_by"/>
        <result property="updateTime" column="update_time"/>
        <result property="delFlag" column="del_flag"/>
  </resultMap>
    <select id="gcpbkwcqk" resultType="com.by4cloud.platformx.business.vo.GcpbkwcqkItemVo">
        SELECT
            d.dict_name AS bkmc,
            IFNULL(sum(c.unit_price*c.quantity),0) AS wc
        FROM
            bip_dict d
                LEFT JOIN
            contract_subject_matter c
 
            ON
                d.dict_code = c.product_section and c.del_flag = '0'
                LEFT JOIN
            contract c1
            ON
                c.contract_id = c1.id and c1.del_flag = '0'
                    and c1.sign_date &gt;= #{monstart}
                    and c1.sign_date &lt;= #{monend}
        WHERE
            d.dict_key = 'zb-cpbk'
        GROUP BY
            d.dict_name, d.dict_key;
 
    </select>
    <select id="gcpbkwcqkBySK" resultType="com.by4cloud.platformx.business.vo.GcpbkwcqkItemVo">
        SELECT
            d.dict_name AS bkmc,
            IFNULL(ROUND(SUM(
                                     IFNULL(pay.total_paid, 0) *
                                     (agg.sub_total / NULLIF(IFNULL(c1.amount, 0), 0))
                             ), 2), 0) AS wc
        FROM
            bip_dict d
                LEFT JOIN (
                SELECT
                    c.product_section,
                    c.contract_id,
                    SUM(c.unit_price * c.quantity) AS sub_total
                FROM
                    contract_subject_matter c
                WHERE
                    c.del_flag = '0'
                GROUP BY
                    c.product_section, c.contract_id
            ) agg ON d.dict_code = agg.product_section
                LEFT JOIN
            contract c1
            ON
                        agg.contract_id = c1.id
                    AND c1.del_flag = '0'
                LEFT JOIN (
                SELECT
                    contract_id,
                    SUM(payment_amount) AS total_paid
                FROM
                    payment_slip
                WHERE
                    del_flag = '0'
                  and payment_time &gt;= #{monstart}
                  and payment_time &lt;= #{monend}
                GROUP BY
                    contract_id
            ) pay ON c1.id = pay.contract_id
        WHERE
            d.dict_key = 'zb-cpbk'
        GROUP BY
            d.dict_name;
 
    </select>
    <select id="sckfzdgzwcqk" resultType="com.by4cloud.platformx.business.vo.GcpbkwcqkItemVo">
        SELECT
            '石煤机' dw,
            d.dict_code `code`,
            d.dict_name AS xm,
            IFNULL(sum(c.unit_price*c.quantity),0) AS wc
        FROM
            bip_dict d
                LEFT JOIN
            contract_subject_matter c
 
            ON
                        d.dict_code = c.product_section and c.del_flag = '0'
                    AND (c.comp_id = 2089995177814495234 or c.comp_id = 2089996921978040321 or c.comp_id = 2089997578009128962 or c.comp_id = 2101966257365045249)
                LEFT JOIN
            contract c1
            ON
                c.contract_id = c1.id and c1.del_flag = '0'
                    and c1.sign_date &gt;= #{monstart}
                    and c1.sign_date &lt;= #{monend}
        WHERE
            d.dict_key = 'zb-ywxm'
          AND (d.comp_id = 2089995177814495234 or d.comp_id = 2089996921978040321 or d.comp_id = 2089997578009128962 or d.comp_id = 2101966257365045249)
        GROUP BY
            d.dict_name,d.dict_code, d.dict_key
        union all
        SELECT
            '石工泵' dw,
            d.dict_code `code`,
            d.dict_name AS bkmc,
            IFNULL(sum(c.unit_price*c.quantity),0) AS wc
        FROM
            bip_dict d
                LEFT JOIN
            contract_subject_matter c
 
            ON
                        d.dict_code = c.product_section and c.del_flag = '0'
                    AND c.comp_id = 2056556196124250113
                LEFT JOIN
            contract c1
            ON
                c.contract_id = c1.id and c1.del_flag = '0'
                    and c1.sign_date &gt;= #{monstart}
                    and c1.sign_date &lt;= #{monend}
        WHERE
            d.dict_key = 'zb-ywxm'
          AND d.comp_id = 2056556196124250113
        GROUP BY
            d.dict_name,d.dict_code, d.dict_key
        union all
        SELECT
            '邢台厂' dw,
            d.dict_code `code`,
            d.dict_name AS bkmc,
            IFNULL(sum(c.unit_price*c.quantity),0) AS wc
        FROM
            bip_dict d
                LEFT JOIN
            contract_subject_matter c
 
            ON
                        d.dict_code = c.product_section and c.del_flag = '0'
                    AND c.comp_id = 2056556317461270529
                LEFT JOIN
            contract c1
            ON
                c.contract_id = c1.id and c1.del_flag = '0'
                    and c1.sign_date &gt;= #{monstart}
                    and c1.sign_date &lt;= #{monend}
        WHERE
            d.dict_key = 'zb-ywxm'
          AND d.comp_id = 2056556317461270529
        GROUP BY
            d.dict_name,d.dict_code, d.dict_key
        union all
        SELECT
            '通方厂' dw,
            d.dict_code `code`,
            d.dict_name AS bkmc,
            IFNULL(sum(c.unit_price*c.quantity),0) AS wc
        FROM
            bip_dict d
                LEFT JOIN
            contract_subject_matter c
 
            ON
                        d.dict_code = c.product_section and c.del_flag = '0'
                    AND c.comp_id = 2056556421857497090
                LEFT JOIN
            contract c1
            ON
                c.contract_id = c1.id and c1.del_flag = '0'
                    and c1.sign_date &gt;= #{monstart}
                    and c1.sign_date &lt;= #{monend}
        WHERE
            d.dict_key = 'zb-ywxm'
          AND d.comp_id = 2056556421857497090
        GROUP BY
            d.dict_name,d.dict_code, d.dict_key
 
    </select>
    <select id="cpxzhtwcqk" resultType="com.by4cloud.platformx.business.vo.CpxssrwcqkItemVo">
        SELECT
            d.dict_name AS xm,
            IFNULL( sum( c.quantity ), 0 ) AS xsl,
            IFNULL( sum( c.unit_price * c.quantity ), 0 ) AS xssr
        FROM
            bip_dict d
                LEFT JOIN contract_subject_matter c ON d.dict_code = c.product_category
                AND c.del_flag = '0'
                LEFT JOIN contract c1 ON c.contract_id = c1.id
                AND c1.del_flag = '0'
                and c1.sign_date &gt;= #{monstart}
                and c1.sign_date &lt;= #{monend}
        WHERE
            d.dict_key = 'zb-cpmc'
              and d.comp_id = 2089995177814495234
        GROUP BY
            d.dict_name,
            d.dict_key;
    </select>
 
</mapper>