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
62
63
<?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
    cgsd_id,
    iodd_id,
    cgsd_amount_w,
    iodd_type,
    iodd_size,
    cgsd_reject_amount,
    bbpr_id,
    bbpr_id iocd_bbpr_id,
    bbpr_name,
    bbpr_brief_name,
    bbpr_style,
    bbpr_unit,
    bbpr_second_unit,
    bbpr_second_size,
    bbpr_remark,
    ifnull(iocd_closing_size,0) iocd_opening_size,
    0.0 iocd_in_size,
      0.0 iocd_out_size,
    0.0 iocd_closing_size,
    ifnull(iocd_closing_reject_size,0) iocd_opening_reject_size,
    0.0 iocd_in_reject_size,
    0.0 iocd_out_reject_size,
    0.0 iocd_closing_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
left join io_opening_closing_detail on iocd_bbpr_id=bbpr_id
left join io_opening_closing on iocd_iooc_id=iooc_id
WHERE
    1 = 1
    <<and (bbiv_factory_id=:factoryId or bbiv_factory_id is null)>>
    <<and (se.factory_id=:factoryId or se.factory_id is null)>>
    <<and (d.factory_id=:factoryId or d.factory_id is null)>>
    <<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') or iode_send_date is null)>>
    <<and (cgse_entry_date>=CONCAT(:beginDate, ' 00:00:00') or cgse_entry_date is null)>>
    <<and (iode_send_date<=CONCAT(:endDate, ' 23:59:29') or iode_send_date is null)>>
    <<and (cgse_entry_date<=CONCAT(:endDate, ' 23:59:29') or cgse_entry_date is null)>>
    <<and iooc_year_month is null or iooc_year_month=:yearMonthPrev>>
 
 
        ]]>
    </sql-query>
</hibernate-mapping>