liuxiaolong
2019-05-09 0d1d88cdb668e75ea8609417ac18ae19947e9525
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
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC 
    "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
    "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
 
<hibernate-mapping>
    <sql-query name="ProcureListQuery">
        <![CDATA[
 
SELECT
    cgpd_remark,
    bbpr_brand,
    cgpr_recive_author,
    cgpr_id,
    cgpr_sn,
    cgpr_weizhi,
    bbbp_name,
    bbpr_sn,
    bbpr_name,
    cgpr_author,
    cgpd_size,
    cgpd_entry_size,
    count(bbit_id+bbit_cged_id) scan_size,
    cgpd_price,
    cgpd_price * cgpd_entry_size cgpd_subtotal,
    cgpr_order_date,
    cgpd_finish_state,
    cgpr_require_date,
    cgpr_flow_state,
    cgpr_state,
    (select prfl_name from pr_flow where prfl_order>cgpr_flow_state and prfl_category='采购流程' and prfl_state='有效' and prfl_locationid=:locationid order by prfl_order limit 1)
    as cgpr_flow_state_ch
FROM
    cg_procure
LEFT JOIN cg_procure_detail ON cgpr_id = cgpd_cgpr_id
LEFT JOIN bb_business_partner ON cgpr_bbbp_id = bbbp_id
LEFT JOIN bb_product ON cgpd_bbpr_id = bbpr_id
LEFT JOIN bb_product_item on bbit_cgpd_id = cgpd_id
WHERE
    1 = 1
<<and (cgpr_sn like concat('%',:procureInfo,'%') or bbbp_name like concat('%',:procureInfo,'%') or cgpr_weizhi like concat('%',:procureInfo,'%') or bbpr_sn like concat('%',:procureInfo,'%') or bbpr_code like concat('%',:procureInfo,'%') or bbpr_name like concat('%',:procureInfo,'%')       )>>
<<and cgpr_order_date>=:beginOrderDate>>
<<and cgpr_order_date<=:endOrderDate>>
<<and cgpr_sn like concat('%',:cgprSn,'%')>>
<<and bbbp_name like concat('%',:bbbpName,'%')>>
<<and bbpr_sn like concat('%',:bbprSn,'%')>>
<<and bbpr_code like concat('%',:bbprCode,'%')>>
<<and bbpr_name like concat('%',:bbprName,'%')>>
<<and cgpd_locationid=:locationid>>
<<and cgpr_locationid=:locationid>>
<<and bbpr_locationid=:locationid>>
<<and (bbit_locationid=:locationid or bbit_locationid is null)>>
<<and cgpd_finish_state=:cgpdFinishState>>
<<and cgpr_weizhi = :cgprWeizhi>>
   and ##CONDITIONS##
group by cgpd_id
order by cgpr_sn desc,cgpd_did
 
        ]]>
    </sql-query>
</hibernate-mapping>