|
...
|
...
|
@@ -141,90 +141,97 @@ |
|
141
|
141
|
<!-- </where>-->
|
|
142
|
142
|
<!-- </select>-->
|
|
143
|
143
|
|
|
144
|
|
- <select id="findById" resultType="com.lframework.xingyun.sc.entity.OrderDetailReport">
|
|
145
|
|
- <include refid="OrderDetailReport_sql"/>
|
|
146
|
|
- <where>
|
|
147
|
|
- <if test="id != null and id != ''">
|
|
148
|
|
- AND tb.id = #{id}
|
|
149
|
|
- </if>
|
|
150
|
|
- </where>
|
|
151
|
|
- </select>
|
|
152
|
|
-
|
|
153
|
|
- <sql id="OrderDetailReport_query_sql">
|
|
154
|
|
- SELECT *
|
|
155
|
|
- FROM (
|
|
|
144
|
+ <sql id="OrderDetailReport_detail_select_sql">
|
|
156
|
145
|
SELECT
|
|
157
|
|
- tb.id,
|
|
158
|
|
- tb.purchase_order_line_id,
|
|
159
|
|
- tb.order_no,
|
|
160
|
|
- tb.order_date,
|
|
161
|
|
- tb.workshop_id,
|
|
162
|
|
- ws.name AS workshop_name,
|
|
163
|
|
- tb.dept_name,
|
|
164
|
|
- tb.region_name,
|
|
165
|
|
- tb.ordering_unit_name,
|
|
166
|
|
- tb.industry,
|
|
167
|
|
- tb.brand,
|
|
168
|
|
- tb.thickness,
|
|
169
|
|
- tb.thickness_tol_pos,
|
|
170
|
|
- tb.thickness_tol_neg,
|
|
171
|
|
- tb.width,
|
|
172
|
|
- tb.width_tol_pos,
|
|
173
|
|
- tb.width_tol_neg,
|
|
174
|
|
- tb.length,
|
|
175
|
|
- tb.length_tol_pos,
|
|
176
|
|
- tb.length_tol_neg,
|
|
177
|
|
- tb.status,
|
|
178
|
|
- tb.quantity,
|
|
179
|
|
- tb.suggested_price,
|
|
180
|
|
- tb.delivery_date,
|
|
181
|
|
- tb.assessment_exceeds_agreement,
|
|
182
|
|
- tb.sales_price,
|
|
183
|
|
- tb.price_list_no,
|
|
184
|
|
- tb.packaging_fee,
|
|
185
|
|
- tb.invoicing_status,
|
|
186
|
|
- tb.piece_weight_header,
|
|
187
|
|
- tb.surface,
|
|
188
|
|
- tb.tolerance,
|
|
189
|
|
- tb.performance,
|
|
190
|
|
- tb.packaging,
|
|
191
|
|
- tb.remarks,
|
|
192
|
|
- tb.shipping_cost,
|
|
193
|
|
- tb.return_shipping_cost,
|
|
194
|
|
- tb.customer_type,
|
|
195
|
|
- tb.quality,
|
|
196
|
|
- tb.contract_type,
|
|
197
|
|
- tb.stock_up_company_name,
|
|
198
|
|
- tb.order_type,
|
|
199
|
|
- tb.show_order,
|
|
200
|
|
- tb.type,
|
|
201
|
|
- tb.production_process,
|
|
202
|
|
- tb.create_by_id,
|
|
203
|
|
- tb.create_by,
|
|
204
|
|
- tb.update_by_id,
|
|
205
|
|
- tb.update_by,
|
|
206
|
|
- tb.create_time,
|
|
207
|
|
- tb.update_time,
|
|
208
|
|
- cs.short_name AS customer_short_name,
|
|
209
|
|
- poi.settlement_terms AS settlement_terms,
|
|
210
|
|
- poi.execution_standard AS execution_standard,
|
|
211
|
|
- poi.execution_standard_remarks AS execution_standard_remarks,
|
|
212
|
|
- CASE
|
|
213
|
|
- WHEN c.type = 'PROCESS_STD_AGMT' THEN pl.product_id
|
|
214
|
|
- ELSE cl.product_id
|
|
215
|
|
- END AS structure_report_used,
|
|
216
|
|
- c.type AS contract_type_code,
|
|
217
|
|
- c.special_terms AS special_requirements,
|
|
218
|
|
- c.create_by AS contract_create_by,
|
|
219
|
|
- MAX(tb.create_time) OVER (PARTITION BY tb.order_no, tb.purchase_order_line_id) AS group_latest_time
|
|
220
|
|
- FROM order_detail_report tb
|
|
221
|
|
- LEFT JOIN base_data_workshop ws ON ws.id = tb.workshop_id
|
|
222
|
|
- LEFT JOIN tbl_purchase_order_line pol ON pol.id = tb.purchase_order_line_id
|
|
|
146
|
+ t.id,
|
|
|
147
|
+ t.purchase_order_line_id,
|
|
|
148
|
+ t.order_no,
|
|
|
149
|
+ t.order_date,
|
|
|
150
|
+ t.workshop_id,
|
|
|
151
|
+ ws.name AS workshop_name,
|
|
|
152
|
+ t.dept_name,
|
|
|
153
|
+ t.region_name,
|
|
|
154
|
+ t.ordering_unit_name,
|
|
|
155
|
+ t.industry,
|
|
|
156
|
+ t.brand,
|
|
|
157
|
+ t.thickness,
|
|
|
158
|
+ t.thickness_tol_pos,
|
|
|
159
|
+ t.thickness_tol_neg,
|
|
|
160
|
+ t.width,
|
|
|
161
|
+ t.width_tol_pos,
|
|
|
162
|
+ t.width_tol_neg,
|
|
|
163
|
+ t.length,
|
|
|
164
|
+ t.length_tol_pos,
|
|
|
165
|
+ t.length_tol_neg,
|
|
|
166
|
+ t.status,
|
|
|
167
|
+ t.quantity,
|
|
|
168
|
+ t.suggested_price,
|
|
|
169
|
+ t.delivery_date,
|
|
|
170
|
+ t.assessment_exceeds_agreement,
|
|
|
171
|
+ t.sales_price,
|
|
|
172
|
+ t.price_list_no,
|
|
|
173
|
+ t.packaging_fee,
|
|
|
174
|
+ t.invoicing_status,
|
|
|
175
|
+ t.piece_weight_header,
|
|
|
176
|
+ t.surface,
|
|
|
177
|
+ t.tolerance,
|
|
|
178
|
+ t.performance,
|
|
|
179
|
+ t.packaging,
|
|
|
180
|
+ t.remarks,
|
|
|
181
|
+ t.shipping_cost,
|
|
|
182
|
+ t.return_shipping_cost,
|
|
|
183
|
+ t.customer_type,
|
|
|
184
|
+ t.quality,
|
|
|
185
|
+ t.contract_type,
|
|
|
186
|
+ t.stock_up_company_name,
|
|
|
187
|
+ t.order_type,
|
|
|
188
|
+ t.show_order,
|
|
|
189
|
+ t.type,
|
|
|
190
|
+ t.production_process,
|
|
|
191
|
+ t.create_by_id,
|
|
|
192
|
+ t.create_by,
|
|
|
193
|
+ t.update_by_id,
|
|
|
194
|
+ t.update_by,
|
|
|
195
|
+ t.create_time,
|
|
|
196
|
+ t.update_time,
|
|
|
197
|
+ cs.short_name AS customer_short_name,
|
|
|
198
|
+ poi.settlement_terms AS settlement_terms,
|
|
|
199
|
+ poi.execution_standard AS execution_standard,
|
|
|
200
|
+ poi.execution_standard_remarks AS execution_standard_remarks,
|
|
|
201
|
+ CASE
|
|
|
202
|
+ WHEN c.type = 'PROCESS_STD_AGMT' THEN pl.product_id
|
|
|
203
|
+ ELSE cl.product_id
|
|
|
204
|
+ END AS structure_report_used,
|
|
|
205
|
+ c.type AS contract_type_code,
|
|
|
206
|
+ c.special_terms AS special_requirements,
|
|
|
207
|
+ c.create_by AS contract_create_by
|
|
|
208
|
+ FROM order_detail_report t
|
|
|
209
|
+ LEFT JOIN base_data_workshop ws ON ws.id = t.workshop_id
|
|
|
210
|
+ LEFT JOIN tbl_purchase_order_line pol ON pol.id = t.purchase_order_line_id
|
|
223
|
211
|
LEFT JOIN purchase_order_info poi ON poi.id = pol.purchase_order_id
|
|
224
|
212
|
LEFT JOIN tbl_contract_distributor_standard c ON c.id = poi.contract_id
|
|
225
|
213
|
LEFT JOIN base_data_customer_short cs ON cs.customer_id = poi.ordering_unit
|
|
226
|
214
|
LEFT JOIN tbl_contract_distributor_line cl ON cl.id = pol.contract_distributor_line_id
|
|
227
|
215
|
LEFT JOIN tbl_contract_std_processing_line pl ON pl.id = pol.contract_distributor_line_id
|
|
|
216
|
+ </sql>
|
|
|
217
|
+
|
|
|
218
|
+ <sql id="OrderDetailReport_page_id_from_sql">
|
|
|
219
|
+ FROM order_detail_report tb
|
|
|
220
|
+ LEFT JOIN (
|
|
|
221
|
+ SELECT
|
|
|
222
|
+ order_no,
|
|
|
223
|
+ purchase_order_line_id,
|
|
|
224
|
+ MAX(create_time) AS group_latest_time
|
|
|
225
|
+ FROM order_detail_report
|
|
|
226
|
+ GROUP BY order_no, purchase_order_line_id
|
|
|
227
|
+ ) grp ON grp.order_no = tb.order_no
|
|
|
228
|
+ AND grp.purchase_order_line_id = tb.purchase_order_line_id
|
|
|
229
|
+ LEFT JOIN tbl_purchase_order_line pol ON pol.id = tb.purchase_order_line_id
|
|
|
230
|
+ LEFT JOIN purchase_order_info poi ON poi.id = pol.purchase_order_id
|
|
|
231
|
+ LEFT JOIN tbl_contract_distributor_standard c ON c.id = poi.contract_id
|
|
|
232
|
+ </sql>
|
|
|
233
|
+
|
|
|
234
|
+ <sql id="OrderDetailReport_page_id_where_sql">
|
|
228
|
235
|
<where>
|
|
229
|
236
|
<if test="vo.ids != null and !vo.ids.isEmpty()">
|
|
230
|
237
|
AND tb.id IN
|
|
...
|
...
|
@@ -261,7 +268,7 @@ |
|
261
|
268
|
</if>
|
|
262
|
269
|
<if test="vo.orderDateEnd != null">
|
|
263
|
270
|
<![CDATA[
|
|
264
|
|
- AND tb.order_date <= #{vo.orderDateEnd}
|
|
|
271
|
+ AND tb.order_date <= #{vo.orderDateEnd}
|
|
265
|
272
|
]]>
|
|
266
|
273
|
</if>
|
|
267
|
274
|
<if test="vo.createTimeStart != null">
|
|
...
|
...
|
@@ -269,7 +276,7 @@ |
|
269
|
276
|
</if>
|
|
270
|
277
|
<if test="vo.createTimeEnd != null">
|
|
271
|
278
|
<![CDATA[
|
|
272
|
|
- AND tb.create_time <= #{vo.createTimeEnd}
|
|
|
279
|
+ AND tb.create_time <= #{vo.createTimeEnd}
|
|
273
|
280
|
]]>
|
|
274
|
281
|
</if>
|
|
275
|
282
|
<if test="vo.thickness != null and vo.thickness != ''">
|
|
...
|
...
|
@@ -282,9 +289,9 @@ |
|
282
|
289
|
AND tb.status = #{vo.status}
|
|
283
|
290
|
</if>
|
|
284
|
291
|
<if test="vo.inventoryUnlockedOnly != null and vo.inventoryUnlockedOnly">
|
|
285
|
|
- AND c.type IN ('DIST_STOCK_CONTRACT','INTL_INVENTORY_AGMT')
|
|
286
|
|
- AND c.status ='FORMAL'
|
|
287
|
|
- AND poi.type='PRODUCTION'
|
|
|
292
|
+ AND c.type IN ('DIST_STOCK_CONTRACT', 'INTL_INVENTORY_AGMT')
|
|
|
293
|
+ AND c.status = 'FORMAL'
|
|
|
294
|
+ AND poi.type = 'PRODUCTION'
|
|
288
|
295
|
AND (c.price_spec_locked = 0 OR c.price_spec_locked IS NULL)
|
|
289
|
296
|
</if>
|
|
290
|
297
|
<if test="vo.excludeInventoryUnlocked != null and vo.excludeInventoryUnlocked">
|
|
...
|
...
|
@@ -325,19 +332,49 @@ |
|
325
|
332
|
</choose>
|
|
326
|
333
|
</if>
|
|
327
|
334
|
</where>
|
|
328
|
|
- ) t
|
|
|
335
|
+ </sql>
|
|
|
336
|
+
|
|
|
337
|
+ <sql id="OrderDetailReport_page_id_order_sql">
|
|
329
|
338
|
ORDER BY
|
|
330
|
|
- t.group_latest_time DESC,
|
|
331
|
|
- t.order_no ASC,
|
|
332
|
|
- t.purchase_order_line_id ASC,
|
|
333
|
|
- t.show_order ASC
|
|
|
339
|
+ grp.group_latest_time DESC,
|
|
|
340
|
+ tb.order_no ASC,
|
|
|
341
|
+ tb.purchase_order_line_id ASC,
|
|
|
342
|
+ tb.show_order ASC
|
|
334
|
343
|
</sql>
|
|
335
|
344
|
|
|
336
|
|
- <select id="query" resultMap="OrderDetailReport">
|
|
337
|
|
- <include refid="OrderDetailReport_query_sql"/>
|
|
|
345
|
+ <select id="findById" resultMap="OrderDetailReport">
|
|
|
346
|
+ <include refid="OrderDetailReport_detail_select_sql"/>
|
|
|
347
|
+ <where>
|
|
|
348
|
+ <if test="id != null and id != ''">
|
|
|
349
|
+ AND t.id = #{id}
|
|
|
350
|
+ </if>
|
|
|
351
|
+ </where>
|
|
|
352
|
+ </select>
|
|
|
353
|
+
|
|
|
354
|
+ <select id="queryPageIds" resultType="java.lang.String">
|
|
|
355
|
+ SELECT tb.id
|
|
|
356
|
+ <include refid="OrderDetailReport_page_id_from_sql"/>
|
|
|
357
|
+ <include refid="OrderDetailReport_page_id_where_sql"/>
|
|
|
358
|
+ <include refid="OrderDetailReport_page_id_order_sql"/>
|
|
|
359
|
+ </select>
|
|
|
360
|
+
|
|
|
361
|
+ <select id="authQueryPageIds" resultType="java.lang.String">
|
|
|
362
|
+ SELECT tb.id
|
|
|
363
|
+ <include refid="OrderDetailReport_page_id_from_sql"/>
|
|
|
364
|
+ <include refid="OrderDetailReport_page_id_where_sql"/>
|
|
|
365
|
+ <include refid="OrderDetailReport_page_id_order_sql"/>
|
|
338
|
366
|
</select>
|
|
339
|
367
|
|
|
340
|
|
- <select id="authQuery" resultMap="OrderDetailReport">
|
|
341
|
|
- <include refid="OrderDetailReport_query_sql"/>
|
|
|
368
|
+ <select id="queryByIds" resultMap="OrderDetailReport">
|
|
|
369
|
+ <include refid="OrderDetailReport_detail_select_sql"/>
|
|
|
370
|
+ WHERE t.id IN
|
|
|
371
|
+ <foreach collection="ids" item="id" open="(" separator="," close=")">
|
|
|
372
|
+ #{id}
|
|
|
373
|
+ </foreach>
|
|
|
374
|
+ ORDER BY FIELD(t.id,
|
|
|
375
|
+ <foreach collection="ids" item="id" separator=",">
|
|
|
376
|
+ #{id}
|
|
|
377
|
+ </foreach>
|
|
|
378
|
+ )
|
|
342
|
379
|
</select>
|
|
343
|
380
|
</mapper> |
...
|
...
|
|