Merge branch 'dev'

This commit is contained in:
wangliwen 2022-11-29 08:57:04 +08:00
commit cfe4c79d5e
3 changed files with 230 additions and 87 deletions

View File

@ -0,0 +1,2 @@
ALTER TABLE `sys_user`
ADD INDEX `idx_dept_id`(`dept_id`);

View File

@ -0,0 +1,2 @@
ALTER TABLE `sys_user`
ADD INDEX `idx_dept_id`(`dept_id`);

View File

@ -699,46 +699,74 @@
</select> </select>
<select id="getDistrictFundStatement" resultType="java.util.Map"> <select id="getDistrictFundStatement" resultType="java.util.Map">
( SELECT
srg.id AS "districtId ",
srg.NAME AS "districtName",
convert(IFNULL(SUM( taa.apply_price ), 0) / 10000, decimal(15, 1)) AS "applyPrice",
srg.sort
FROM
( SELECT id, NAME, sort FROM sys_region WHERE tree_level = 3 AND 9 >= sort ) srg
LEFT JOIN sys_dept sd ON sd.district = srg.id
LEFT JOIN sys_user su ON su.dept_id = sd.id
LEFT JOIN t_ability_application taa ON taa.user_id = su.id
WHERE
taa.del_flag = 0
AND taa.approve_status IN ( '通过', '审核中' )
GROUP BY
srg.id
) UNION ALL
SELECT SELECT
id AS "districtId", districtId,
NAME AS "districtName", districtName,
0 AS "applyPrice", SUM(applyPrice) AS "applyPrice"
sort
FROM FROM
sys_region (
SELECT
srg.id AS "districtId",
srg.NAME AS "districtName",
CONVERT (
IFNULL( SUM( taa.apply_price ), 0 ) / 10000,
DECIMAL ( 15, 1 )) AS "applyPrice",
srg.sort
FROM
( SELECT id, NAME, sort FROM sys_region WHERE tree_level = 3 AND 9 >= sort ) srg
LEFT JOIN sys_dept sd ON sd.district = srg.id
LEFT JOIN tb_data_resource tdr ON tdr.dept_id = sd.id
LEFT JOIN (
SELECT
resource_id,
SUM( apply_price ) AS "apply_price"
FROM
t_ability_application taa
WHERE
taa.del_flag = 0
AND taa.approve_status IN ( '通过', '审核中' )
GROUP BY
resource_id
) taa ON taa.resource_id = tdr.id
GROUP BY
srg.id UNION ALL
SELECT
tmb.district AS "districtId",
srg.NAME AS "districtName",
SUM( tmb.applyPrice ) AS "applyPrice",
srg.sort
FROM
(
SELECT
sd.id AS "deptId",
tmb.dept AS "deptName",
CONVERT (
IFNULL( SUM( tmb.apply_price ), 0 ) / 10000,
DECIMAL ( 15, 1 )) AS "applyPrice",
sd.district
FROM
t_meetingroom_book tmb
LEFT JOIN ( SELECT id, NAME, district FROM sys_dept ) sd ON tmb.dept = sd.NAME
WHERE
tmb.state IN ( 0, 2 )
GROUP BY
sd.id,
tmb.dept
) tmb
LEFT JOIN ( SELECT id, NAME, tree_level, sort FROM sys_region ) srg ON tmb.district = srg.id
WHERE
srg.tree_level = 3
GROUP BY
tmb.district
) temp
WHERE WHERE
tree_level = 3 temp.districtId IS NOT NULL
AND 9 >= sort
AND id NOT IN (
SELECT
srg.id
FROM
( SELECT id, NAME, sort FROM sys_region WHERE tree_level = 3 AND 9 >= sort ) srg
LEFT JOIN sys_dept sd ON sd.district = srg.id
LEFT JOIN sys_user su ON su.dept_id = sd.id
LEFT JOIN t_ability_application taa ON taa.user_id = su.id
WHERE
taa.del_flag = 0
AND taa.approve_status IN ( '通过', '审核中' )
GROUP BY GROUP BY
srg.id temp.districtId,
) ORDER BY sort temp.districtName,
temp.sort
ORDER BY
temp.sort
</select> </select>
<select id="getComponentFundStatement" resultType="java.util.Map"> <select id="getComponentFundStatement" resultType="java.util.Map">
@ -797,6 +825,7 @@
WHERE WHERE
tdr.del_flag = 0 tdr.del_flag = 0
ORDER BY taa.price DESC ORDER BY taa.price DESC
LIMIT 30
</select> </select>
@ -814,64 +843,117 @@
<select id="getProvideDeptFundStatement" resultType="java.util.Map"> <select id="getProvideDeptFundStatement" resultType="java.util.Map">
SELECT SELECT
sd.id AS "deptId", deptId,
sd.NAME AS "deptName", deptName,
COUNT( tdr.id ) AS "resourceCount", SUM( resourceCount ) AS "resourceCount",
convert(IFNULL( SUM( taa.price ), 0 ) / 10000, decimal(15,1)) AS "applyPrice" SUM( applyPrice ) AS "applyPrice"
FROM FROM
sys_dept sd (
LEFT JOIN tb_data_resource tdr ON tdr.dept_id = sd.id
LEFT JOIN (
SELECT SELECT
resource_id, sd.id AS "deptId",
SUM( apply_price ) AS "price", sd.NAME AS "deptName",
COUNT( resource_id ) AS "applyCount" COUNT( tdr.id ) AS "resourceCount",
CONVERT (
IFNULL( SUM( taa.price ), 0 ) / 10000,
DECIMAL ( 15, 1 )) AS "applyPrice"
FROM FROM
t_ability_application taa sys_dept sd
LEFT JOIN tb_data_resource tdr ON tdr.dept_id = sd.id
LEFT JOIN (
SELECT
resource_id,
SUM( apply_price ) AS "price",
COUNT( resource_id ) AS "applyCount"
FROM
t_ability_application taa
WHERE
taa.del_flag = 0
AND taa.approve_status IN ( '通过', '审核中' )
GROUP BY
resource_id
) taa ON taa.resource_id = tdr.id
WHERE WHERE
taa.del_flag = 0 tdr.del_flag = 0
AND taa.approve_status IN ( '通过', '审核中' ) AND sd.type = 2
GROUP BY GROUP BY
resource_id sd.id UNION ALL
) taa ON taa.resource_id = tdr.id SELECT
WHERE 1067246875800000066 AS "deptId",
tdr.del_flag = 0 '青岛市大数据发展管理局' AS "deptName",
AND sd.type = 2 ( SELECT COUNT( id ) FROM t_meetingroom ) AS "resourceCount",
CONVERT (
IFNULL( SUM( tmb.apply_price ), 0 ) / 10000,
DECIMAL ( 15, 1 )) AS "applyPrice"
FROM
t_meetingroom tm
LEFT JOIN t_meetingroom_book tmb ON tmb.room_id = tm.id
WHERE
tm.del_flag = 0
AND tmb.state IN ( 0, 2 )
) temp
GROUP BY GROUP BY
sd.id deptId,
deptName
ORDER BY ORDER BY
applyPrice DESC SUM( applyPrice ) DESC
LIMIT 10 LIMIT 10
</select> </select>
<select id="getApplyDeptFundStatement" resultType="java.util.Map"> <select id="getApplyDeptFundStatement" resultType="java.util.Map">
SELECT SELECT
sd.id AS "deptId", deptId,
sd.NAME AS "deptName", deptName,
SUM( taa.applyCount ) AS "applyCount", SUM( applyCount ) AS "applyCount",
convert(IFNULL( SUM( taa.price ), 0 ) / 10000, decimal(15,1)) AS "applyPrice" SUM( applyPrice ) AS "applyPrice"
FROM FROM
( (
SELECT SELECT
SUM( apply_price ) AS "price", sd.id AS "deptId",
COUNT( id ) AS "applyCount", sd.NAME AS "deptName",
user_id SUM( taa.applyCount ) AS "applyCount",
CONVERT (
IFNULL( SUM( taa.price ), 0 ) / 10000,
DECIMAL ( 15, 1 )) AS "applyPrice"
FROM FROM
t_ability_application taa (
SELECT
SUM( apply_price ) AS "price",
COUNT( id ) AS "applyCount",
user_id
FROM
t_ability_application taa
WHERE
taa.del_flag = 0
AND taa.approve_status IN ( '通过', '审核中' )
GROUP BY
user_id
) taa
LEFT JOIN sys_user su ON taa.user_id = su.id
LEFT JOIN sys_dept sd ON su.dept_id = sd.id
WHERE WHERE
taa.del_flag = 0 sd.type = 2
AND taa.approve_status IN ( '通过', '审核中' )
GROUP BY GROUP BY
user_id sd.id UNION ALL
) taa SELECT
LEFT JOIN sys_user su ON taa.user_id = su.id sd.id AS "deptId",
LEFT JOIN sys_dept sd ON su.dept_id = sd.id tmb.dept AS "deptName",
WHERE COUNT( tmb.id ) AS "applyCount",
sd.type = 2 CONVERT (
IFNULL( SUM( tmb.apply_price ), 0 ) / 10000,
DECIMAL ( 15, 1 )) AS "applyPrice"
FROM
t_meetingroom_book tmb
LEFT JOIN ( SELECT id, NAME FROM sys_dept ) sd ON tmb.dept = sd.NAME
WHERE
tmb.state IN ( 0, 2 )
GROUP BY
sd.id,
tmb.dept
) temp
GROUP BY GROUP BY
sd.id deptName, deptId
ORDER BY ORDER BY
applyPrice DESC SUM( applyPrice ) DESC
LIMIT 10 LIMIT 10
</select> </select>
@ -896,21 +978,78 @@
<select id="getApplyDistrictFundStatement" resultType="java.util.Map"> <select id="getApplyDistrictFundStatement" resultType="java.util.Map">
SELECT SELECT
srg.id AS "districtId ", districtId,
srg.NAME AS "districtName", districtName,
IFNULL(SUM(taa.applyCount), 0) AS "applyCount", SUM( applyCount ),
convert(IFNULL( SUM( taa.apply_price ), 0 ) / 10000, decimal(15,1)) AS "applyPrice", SUM( applyPrice )
srg.sort
FROM FROM
( SELECT id, NAME, sort FROM sys_region WHERE tree_level = 3 AND 9 >= sort ) srg (
LEFT JOIN sys_dept sd ON sd.district = srg.id SELECT
LEFT JOIN tb_data_resource tdr ON tdr.dept_id = sd.id srg.id AS "districtId",
LEFT JOIN (SELECT resource_id, SUM(apply_price) AS "apply_price", COUNT(id) AS "applyCount" FROM t_ability_application taa WHERE srg.NAME AS "districtName",
taa.del_flag = 0 IFNULL( SUM( taa.applyCount ), 0 ) AS "applyCount",
AND taa.approve_status IN ( '通过', '审核中' ) GROUP BY resource_id ) taa ON taa.resource_id = tdr.id CONVERT (
IFNULL( SUM( taa.apply_price ), 0 ) / 10000,
DECIMAL ( 15, 1 )) AS "applyPrice",
srg.sort
FROM
( SELECT id, NAME, sort FROM sys_region WHERE tree_level = 3 AND 9 >= sort ) srg
LEFT JOIN sys_dept sd ON sd.district = srg.id
LEFT JOIN tb_data_resource tdr ON tdr.dept_id = sd.id
LEFT JOIN (
SELECT
resource_id,
SUM( apply_price ) AS "apply_price",
COUNT( id ) AS "applyCount"
FROM
t_ability_application taa
WHERE
taa.del_flag = 0
AND taa.approve_status IN ( '通过', '审核中' )
GROUP BY
resource_id
) taa ON taa.resource_id = tdr.id
GROUP BY
srg.id UNION ALL
SELECT
tmb.district AS "districtId",
srg.NAME AS "districtName",
SUM( tmb.applyCount ) AS "applyCount",
SUM( tmb.applyPrice ) AS "applyPrice",
srg.sort
FROM
(
SELECT
sd.id AS "deptId",
tmb.dept AS "deptName",
COUNT( tmb.id ) AS "applyCount",
CONVERT (
IFNULL( SUM( tmb.apply_price ), 0 ) / 10000,
DECIMAL ( 15, 1 )) AS "applyPrice",
sd.district
FROM
t_meetingroom_book tmb
LEFT JOIN ( SELECT id, NAME, district FROM sys_dept ) sd ON tmb.dept = sd.NAME
WHERE
tmb.state IN ( 0, 2 )
GROUP BY
sd.id,
tmb.dept
) tmb
LEFT JOIN ( SELECT id, NAME, tree_level, sort FROM sys_region ) srg ON tmb.district = srg.id
WHERE
srg.tree_level = 3
GROUP BY
tmb.district
) temp
WHERE
temp.districtId IS NOT NULL
GROUP BY GROUP BY
srg.id temp.districtId,
ORDER BY srg.sort temp.districtName,
temp.sort
ORDER BY
temp.sort
</select> </select>