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
<?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="IoOpeningClosingQuery">
        <![CDATA[
 
 
SELECT
    bbpr_id
    bbpr_name,
    bbpr_brief_name,
    bbpr_style,
    bbpr_unit,
    bbpr_second_unit,
    bbpr_second_size,
    bbpr_remark,
    0.0 opening_size,
    sum(cgsd_amount_w) in_size,
  sum(iodd_size) out_size,
    0.0 ending_size,
    0.0 opening_reject_size,
    sum(cgsd_reject_amount) in_reject_size,
    0.0 out_reject_size,
    0.0 ending_reject_size
FROM
    bb_product a
LEFT JOIN bb_branch ON bbbr_id = bbpr_bbbr_id
left join bb_product_invertory on bbiv_bbpr_id=a.bbpr_id
left join cg_stuff_entry_detail on cgsd_bbpr_id=bbpr_id
left join cg_stuff_entry se on cgse_id=cgsd_cgse_id
left join io_deliver_detail on iodd_bbpr_id=bbpr_id
left join io_deliver d on iode_id=iodd_iode_id
WHERE
    1 = 1
    <<and bbiv_factory_id=:factoryId>>
    <<and se.factory_id=:factoryId>>
    <<and d.factory_id=:factoryId>>
    <<and bbpr_bbbr_id in (:bbprBbbrId)>>
    <<and (bbpr_name like concat("%", :bbprName, "%") or bbpr_brief_name  like concat("%", :bbprName, "%") )>>
    <<and bbpr_style like concat("%", :bbprStyle, "%") >>
    <<and bbpr_unit = (:bbprUnit)>>
    <<and bbpr_grammage = (:bbprGrammage)>>
    <<and iode_send_date>=CONCAT(:beginDate, ' 00:00:00')>>
    <<and cgse_entry_date>=CONCAT(:beginDate, ' 00:00:00')>>
    <<and iode_send_date<=CONCAT(:endDate, ' 23:59:29')>>
    <<and cgse_entry_date>=CONCAT(:endDate, ' 23:59:29')>>
group by bbpr_id
 
        ]]>
    </sql-query>
</hibernate-mapping>