|
|
|
@ -54,68 +54,24 @@
|
|
|
|
|
</select>
|
|
|
|
|
<select id="selectAllServicesCount"
|
|
|
|
|
resultType="com.ruoyi.jjh.ent.entity.response.JServicesListCountResponse">
|
|
|
|
|
# SELECT
|
|
|
|
|
# IFNULL( ROUND( SUM( a.revenue ) / 100000, 1 ), '-' ) AS allRevenue,
|
|
|
|
|
# IFNULL( ROUND( a.add_value, 1 ), '-' ) AS addValue,
|
|
|
|
|
# a.type AS servicesType,
|
|
|
|
|
# b.qyCount AS qyCount
|
|
|
|
|
# FROM
|
|
|
|
|
# j_total_revenue a
|
|
|
|
|
# LEFT JOIN ( SELECT a.services_type, count( * ) AS qyCount FROM j_services_list a GROUP BY a.services_type ) AS b ON a.type = b.services_type
|
|
|
|
|
# WHERE
|
|
|
|
|
# a.years = YEAR (NOW()) - 1
|
|
|
|
|
# GROUP BY
|
|
|
|
|
# a.type,
|
|
|
|
|
# b.qyCount
|
|
|
|
|
-- 使用外部查询进行排序
|
|
|
|
|
SELECT * FROM (
|
|
|
|
|
-- 查询 YEAR(NOW()) - 1 数据
|
|
|
|
|
SELECT
|
|
|
|
|
IFNULL(ROUND(a.revenue / 100000, 1), '-') AS allRevenue,
|
|
|
|
|
IFNULL(ROUND(a.add_value, 1), '-') AS addValue,
|
|
|
|
|
IFNULL( ROUND( a.revenue / 100000, 1 ), '-' ) AS allRevenue,
|
|
|
|
|
IFNULL( ROUND( a.add_value, 1 ), '-' ) AS addValue,
|
|
|
|
|
a.type AS servicesType,
|
|
|
|
|
CASE
|
|
|
|
|
WHEN a.type = 3 THEN
|
|
|
|
|
(SELECT COUNT(*) FROM bms_enterprise_basic_info WHERE type = 1)
|
|
|
|
|
ELSE b.qyCount
|
|
|
|
|
END AS qyCount
|
|
|
|
|
FROM
|
|
|
|
|
j_total_revenue a
|
|
|
|
|
LEFT JOIN (
|
|
|
|
|
SELECT a.services_type, COUNT(*) AS qyCount
|
|
|
|
|
FROM j_services_list a
|
|
|
|
|
where years = YEAR(now()) -1
|
|
|
|
|
GROUP BY a.services_type
|
|
|
|
|
) AS b ON a.type = b.services_type
|
|
|
|
|
WHERE
|
|
|
|
|
a.years = YEAR(NOW()) - 1
|
|
|
|
|
|
|
|
|
|
-- 使用 UNION ALL 查询 YEAR(NOW()) - 2 数据,仅当 YEAR(NOW()) - 1 数据为空时执行
|
|
|
|
|
UNION ALL
|
|
|
|
|
|
|
|
|
|
SELECT
|
|
|
|
|
IFNULL(ROUND(a.revenue / 100000, 1), '-') AS allRevenue,
|
|
|
|
|
IFNULL(ROUND(a.add_value, 1), '-') AS addValue,
|
|
|
|
|
a.type AS servicesType,
|
|
|
|
|
CASE
|
|
|
|
|
WHEN a.type = 3 THEN
|
|
|
|
|
(SELECT COUNT(*) FROM bms_enterprise_basic_info WHERE type = 1)
|
|
|
|
|
ELSE b.qyCount
|
|
|
|
|
( SELECT COUNT(*) FROM bms_enterprise_basic_info WHERE type LIKE '%1%' )
|
|
|
|
|
WHEN a.type = 1 THEN
|
|
|
|
|
( SELECT COUNT(*) FROM bms_enterprise_basic_info WHERE type LIKE '%5%' )
|
|
|
|
|
WHEN a.type = 2 THEN
|
|
|
|
|
( SELECT COUNT(*) FROM bms_enterprise_basic_info WHERE type LIKE '%7%' )
|
|
|
|
|
WHEN a.type = 4 THEN
|
|
|
|
|
( SELECT COUNT(*) FROM bms_enterprise_basic_info WHERE type LIKE '%6%' ) ELSE 0
|
|
|
|
|
END AS qyCount
|
|
|
|
|
FROM
|
|
|
|
|
j_total_revenue a
|
|
|
|
|
LEFT JOIN (
|
|
|
|
|
SELECT a.services_type, COUNT(*) AS qyCount
|
|
|
|
|
FROM j_services_list a
|
|
|
|
|
GROUP BY a.services_type
|
|
|
|
|
) AS b ON a.type = b.services_type
|
|
|
|
|
WHERE
|
|
|
|
|
a.years = YEAR(NOW()) - 2
|
|
|
|
|
AND NOT EXISTS (
|
|
|
|
|
SELECT 1
|
|
|
|
|
FROM j_total_revenue a1
|
|
|
|
|
WHERE a1.years = YEAR(NOW()) - 1
|
|
|
|
|
)
|
|
|
|
|
j_total_revenue a WHERE a.years = YEAR(NOW()) - 1
|
|
|
|
|
) AS result
|
|
|
|
|
ORDER BY FIELD(result.servicesType, 3, 1, 2, 4);
|
|
|
|
|
</select>
|
|
|
|
|