|
@@ -13,7 +13,7 @@
|
13
|
13
|
SELECT
|
14
|
14
|
t1.orgId,
|
15
|
15
|
t1.orgName,
|
16
|
|
- t1.outPlanNumber staticRawGrainPlanQuantity,
|
|
16
|
+ t1.plan_quantity staticRawGrainPlanQuantity,
|
17
|
17
|
(t1.sealing_quantity + t2.quantity)/(t1.outPlanNumber + t2.inPlanNumber) staticRawGrainCompletionRate,
|
18
|
18
|
t1.standard_value staticRawGrainCostStandard,
|
19
|
19
|
(t1.outPlanNumber + t2.inPlanNumber) * t1.standard_value staticRawGrainSubsidy,
|
|
@@ -22,7 +22,22 @@
|
22
|
22
|
t3.standard_value dynamicRawGrainCostStandard,
|
23
|
23
|
(t3.outPlanNumber + t4.inPlanNumber) * t3.standard_value dynamicRawGrainSubsidy,
|
24
|
24
|
t1.planYear,
|
25
|
|
- t1.remarks remark
|
|
25
|
+ t1.remarks remark,
|
|
26
|
+ t5.processedGrainPlanQuantity,
|
|
27
|
+ t5.processedGrainCostStandard,
|
|
28
|
+ t5.processedGrainSubsidy,
|
|
29
|
+ t5.otherSubsidy,
|
|
30
|
+ (
|
|
31
|
+ (
|
|
32
|
+ (
|
|
33
|
+ t1.outPlanNumber + t2.inPlanNumber
|
|
34
|
+ ) * t1.standard_value
|
|
35
|
+ ) + (
|
|
36
|
+ (
|
|
37
|
+ t3.outPlanNumber + t4.inPlanNumber
|
|
38
|
+ ) * t3.standard_value
|
|
39
|
+ ) + t5.processedGrainSubsidy + t5.otherSubsidy
|
|
40
|
+ ) subsidySubtotal
|
26
|
41
|
FROM
|
27
|
42
|
(
|
28
|
43
|
SELECT
|
|
@@ -30,9 +45,9 @@
|
30
|
45
|
oi.org_name orgName,
|
31
|
46
|
bri.plan_number outPlanNumber,
|
32
|
47
|
bri.plan_year planYear,
|
33
|
|
- bro.plan_quantity,
|
34
|
|
- bro.sealing_quantity,
|
35
|
|
- bfcs.standard_value,
|
|
48
|
+ SUM(bro.plan_quantity) plan_quantity,
|
|
49
|
+ SUM(bro.sealing_quantity) sealing_quantity,
|
|
50
|
+ SUM(bfcs.standard_value) standard_value,
|
36
|
51
|
bro.remarks
|
37
|
52
|
FROM
|
38
|
53
|
biz_rp_issuance bri
|
|
@@ -46,16 +61,18 @@
|
46
|
61
|
AND brr.rotation_year = YEAR (NOW())
|
47
|
62
|
AND bri.plan_year = YEAR (NOW())
|
48
|
63
|
AND bfcs.standard_type = 1
|
|
64
|
+ GROUP BY
|
|
65
|
+ bro.org_id
|
49
|
66
|
) t1
|
50
|
67
|
LEFT JOIN (
|
51
|
68
|
SELECT
|
52
|
69
|
brin.org_id orgId,
|
53
|
70
|
oi.org_name orgName,
|
54
|
71
|
bri.plan_number inPlanNumber,
|
55
|
|
- bfcs.standard_value,
|
|
72
|
+ SUM(bfcs.standard_value) standard_value,
|
56
|
73
|
bri.plan_year planYear,
|
57
|
|
- brin.plan_quantity,
|
58
|
|
- brin.quantity
|
|
74
|
+ SUM(brin.plan_quantity) plan_quantity,
|
|
75
|
+ SUM(brin.quantity) quantity
|
59
|
76
|
FROM
|
60
|
77
|
biz_rp_issuance bri
|
61
|
78
|
INNER JOIN depot_qh.business_rp_report brr ON bri.rp_report_id = brr.id
|
|
@@ -68,6 +85,8 @@
|
68
|
85
|
AND brr.rotation_year = YEAR (NOW())
|
69
|
86
|
AND bri.plan_year = YEAR (NOW())
|
70
|
87
|
AND bfcs.standard_type = 1
|
|
88
|
+ GROUP BY
|
|
89
|
+ brin.org_id
|
71
|
90
|
) t2 ON t1.orgId = t2.orgId
|
72
|
91
|
LEFT JOIN (
|
73
|
92
|
SELECT
|
|
@@ -75,9 +94,9 @@
|
75
|
94
|
oi.org_name orgName,
|
76
|
95
|
bri.plan_number outPlanNumber,
|
77
|
96
|
bri.plan_year planYear,
|
78
|
|
- bro.plan_quantity,
|
79
|
|
- bro.sealing_quantity,
|
80
|
|
- bfcs.standard_value
|
|
97
|
+ SUM(bro.plan_quantity) plan_quantity,
|
|
98
|
+ SUM(bro.sealing_quantity) sealing_quantity,
|
|
99
|
+ SUM(bfcs.standard_value) standard_value
|
81
|
100
|
FROM
|
82
|
101
|
biz_rp_issuance bri
|
83
|
102
|
INNER JOIN depot_qh.business_rp_report brr ON bri.rp_report_id = brr.id
|
|
@@ -90,16 +109,18 @@
|
90
|
109
|
AND brr.rotation_year = YEAR (NOW())
|
91
|
110
|
AND bri.plan_year = YEAR (NOW())
|
92
|
111
|
AND bfcs.standard_type = 1
|
|
112
|
+ GROUP BY
|
|
113
|
+ bro.org_id
|
93
|
114
|
) t3 ON t1.orgId = t2.orgId AND t2.orgId = t3.orgId
|
94
|
115
|
LEFT JOIN (
|
95
|
116
|
SELECT
|
96
|
117
|
brin.org_id orgId,
|
97
|
118
|
oi.org_name orgName,
|
98
|
119
|
bri.plan_number inPlanNumber,
|
99
|
|
- bfcs.standard_value,
|
|
120
|
+ SUM(bfcs.standard_value) standard_value,
|
100
|
121
|
bri.plan_year planYear,
|
101
|
|
- brin.plan_quantity,
|
102
|
|
- brin.quantity
|
|
122
|
+ SUM(brin.plan_quantity) plan_quantity,
|
|
123
|
+ SUM(brin.quantity) quantity
|
103
|
124
|
FROM
|
104
|
125
|
biz_rp_issuance bri
|
105
|
126
|
INNER JOIN depot_qh.business_rp_report brr ON bri.rp_report_id = brr.id
|
|
@@ -112,6 +133,30 @@
|
112
|
133
|
AND brr.rotation_year = YEAR (NOW())
|
113
|
134
|
AND bri.plan_year = YEAR (NOW())
|
114
|
135
|
AND bfcs.standard_type = 1
|
115
|
|
- ) t4 ON t3.orgId = t4.orgId
|
|
136
|
+ GROUP BY
|
|
137
|
+ brin.org_id
|
|
138
|
+ ) t4 ON t1.orgId = t4.orgId
|
|
139
|
+ LEFT JOIN (
|
|
140
|
+ SELECT
|
|
141
|
+ gp.id,
|
|
142
|
+ gp.org_id,
|
|
143
|
+ gp.plan_quantity processedGrainPlanQuantity,
|
|
144
|
+ (
|
|
145
|
+ gp.completion_quantity / gp.plan_quantity
|
|
146
|
+ ) * 100 processedGrainCompletionRate,
|
|
147
|
+ cs.standard_value processedGrainCostStandard,
|
|
148
|
+ (
|
|
149
|
+ gp.plan_quantity * cs.standard_value
|
|
150
|
+ ) processedGrainSubsidy,
|
|
151
|
+ '0' otherSubsidy
|
|
152
|
+ FROM
|
|
153
|
+ depot_qh.business_pg_gops_plan gp
|
|
154
|
+ LEFT JOIN depot_qh.business_fs_cost_standard cs ON gp.org_id = cs.org_id
|
|
155
|
+ WHERE
|
|
156
|
+ gp.plan_type = 1
|
|
157
|
+ AND cs.standard_type = 1
|
|
158
|
+ GROUP BY
|
|
159
|
+ cs.org_id
|
|
160
|
+ ) t5 ON t1.orgId = t5.org_id
|
116
|
161
|
</select>
|
117
|
162
|
</mapper>
|