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
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
<?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="SP_boHuiListQuery">
        <![CDATA[
 
SELECT
scco_id,
scch_id,
scco_scch_id,
scco_org_id,
scco_flow_role,
scco_flow_state,
scch_title,
scca_name,
a.scrt_begin,
a.scrt_end,
a.scrt_over,
scch_state,
recode.scfr_task_date,
recode.scfr_tasker,
tijiao.scfr_task_date as bh_submit_date,
(
    SELECT GROUP_CONCAT(aa.sccf_role) from
        (
            SELECT
                sccf_scch_id,sccf_role,sccf_order
            from sc_check_flow
            ORDER BY sccf_order
        ) aa
    WHERE
        aa.sccf_scch_id = co.scco_scch_id
        AND (sccf_role is not NULL or sccf_role <> '')
) rolenames
from sc_check_org co
LEFT JOIN sc_check on scco_scch_id = scch_id
LEFT JOIN sc_category on scca_id = scch_scca_id
LEFT JOIN 
(
    select * from (
    select 
        scrt_begin,scrt_end,scrt_over,scrt_scco_id,sccf_order
    from sc_role_date 
    LEFT JOIN sc_check_flow on sccf_id=scrt_sccf_id
    WHERE 1=1
    <<and scrt_org_id = :orgId>>
    order by sccf_order
    ) as aa
    GROUP BY  aa.scrt_scco_id
) as a on a.scrt_scco_id=scco_id
LEFT JOIN 
(
    select * from (
        select scfr_scco_id,scfr_task_date,scfr_tasker,scfr_org_id from sc_check_flow_record
        LEFT JOIN sc_check_flow on sccf_id=scfr_sccf_id
        where 1=1
        <<and scfr_org_id = :orgId>>
        order by scfr_task_date desc 
    ) as temp_record
    group by temp_record.scfr_scco_id
 
) as recode on recode.scfr_scco_id=co.scco_id
LEFT JOIN 
(
    select * from (
        select scfr_scco_id,scfr_task_date,scfr_tasker,scfr_org_id from sc_check_flow_record
        LEFT JOIN sc_check_flow on sccf_id=scfr_sccf_id
        where 1=1
        <<and scfr_org_id = :orgId>>
        <<and sccf_role in (:sccfRole)>>
        order by scfr_task_date desc 
    ) as temp_tijiao
    GROUP BY  temp_tijiao.scfr_scco_id
) as tijiao on tijiao.scfr_scco_id=co.scco_id
 
WHERE 1=1
and scco_flow_state <>100
<<and scco_flow_role in (:sccfRole)>>
<<and scch_state <> :scchState>>
<<and scco_org_id = :orgId>>
<<and scco_flow_state = :sccoFlowState1>>
<<and scco_flow_state > :sccoFlowState2>>
<<and scca_name = :sccaName>>
and ##CONDITIONS##
GROUP BY co.scco_id
order by a.scrt_begin desc
 
        ]]>
    </sql-query>
</hibernate-mapping>