|
|
@@ -3,113 +3,118 @@
|
|
|
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
|
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
|
|
<mapper namespace="com.jzg.console.mapper.ReportSearchConfigurationMapper">
|
|
|
+
|
|
|
<select id="getSearchConfigurationList"
|
|
|
resultType="com.jzg.commons.entity.report.dto.ReportSearchConfigurationDto">
|
|
|
SELECT
|
|
|
- b.search_key AS 'key',
|
|
|
- b.search_name AS label,
|
|
|
- b.show_type AS inputType,
|
|
|
- CASE
|
|
|
- WHEN (SELECT select_type FROM report_page_set_search_param
|
|
|
- WHERE report_configuration_id = a.report_configuration_id
|
|
|
- AND router_path_key = #{ routerPath }) IS NOT NULL THEN
|
|
|
- (SELECT select_type FROM report_page_set_search_param
|
|
|
- WHERE report_configuration_id = a.report_configuration_id
|
|
|
- AND router_path_key = #{ routerPath })
|
|
|
- ELSE a.select_type
|
|
|
- END AS selectType,
|
|
|
- b.search_sql AS searchSql,
|
|
|
- b.id AS id,
|
|
|
- a.show_flag AS showFlag,
|
|
|
- CASE
|
|
|
- WHEN (
|
|
|
- SELECT COUNT(0)
|
|
|
- FROM report_page_set_search_param
|
|
|
- WHERE report_configuration_id = a.report_configuration_id
|
|
|
- AND router_path_key = #{ routerPath }
|
|
|
- ) > 0 THEN true
|
|
|
- ELSE false
|
|
|
- END AS defaultFlag,
|
|
|
- CASE
|
|
|
- WHEN (
|
|
|
- SELECT COUNT(0)
|
|
|
- FROM report_page_select_disable
|
|
|
- WHERE report_configuration_id = a.report_configuration_id
|
|
|
- AND router_path_key = #{ routerPath }
|
|
|
- ) > 0 THEN true
|
|
|
- ELSE false
|
|
|
- END AS selectFlag,
|
|
|
- false AS isShowDelIcon
|
|
|
+ b.search_key AS 'key',
|
|
|
+ b.search_name AS label,
|
|
|
+ b.show_type AS inputType,
|
|
|
+ CASE
|
|
|
+ WHEN (SELECT select_type FROM report_page_set_search_param
|
|
|
+ WHERE report_configuration_id = a.report_configuration_id
|
|
|
+ AND router_path_key = #{ routerPath } AND is_delete = 0) IS NOT NULL THEN
|
|
|
+ (SELECT select_type FROM report_page_set_search_param
|
|
|
+ WHERE report_configuration_id = a.report_configuration_id
|
|
|
+ AND router_path_key = #{ routerPath } AND is_delete = 0)
|
|
|
+ ELSE a.select_type
|
|
|
+ END AS selectType,
|
|
|
+ b.search_sql AS searchSql,
|
|
|
+ b.id AS id,
|
|
|
+ a.show_flag AS showFlag,
|
|
|
+ CASE
|
|
|
+ WHEN (
|
|
|
+ SELECT COUNT(0)
|
|
|
+ FROM report_page_set_search_param
|
|
|
+ WHERE report_configuration_id = a.report_configuration_id
|
|
|
+ AND router_path_key = #{ routerPath } AND is_delete = 0 ) > 0 THEN true
|
|
|
+ ELSE false
|
|
|
+ END AS defaultFlag,
|
|
|
+ CASE
|
|
|
+ WHEN (
|
|
|
+ SELECT COUNT(0)
|
|
|
+ FROM report_page_select_disable
|
|
|
+ WHERE report_configuration_id = a.report_configuration_id
|
|
|
+ AND router_path_key = #{ routerPath } AND is_delete = 0 ) > 0 THEN true
|
|
|
+ ELSE false
|
|
|
+ END AS selectFlag,
|
|
|
+ false AS isShowDelIcon
|
|
|
FROM
|
|
|
- report_page_set_search_param a
|
|
|
- LEFT JOIN report_search_configuration b ON a.report_configuration_id = b.id
|
|
|
- WHERE
|
|
|
- a.router_path_key = 'common'
|
|
|
- ORDER BY
|
|
|
- a.sort
|
|
|
+ report_page_set_search_param a
|
|
|
+ LEFT JOIN report_search_configuration b
|
|
|
+ ON a.report_configuration_id = b.id AND b.is_delete = 0
|
|
|
+ <where>
|
|
|
+ AND a.is_delete = 0
|
|
|
+ <if test="routerPath != null and routerPath != ''">
|
|
|
+ AND a.router_path_key = 'common'
|
|
|
+ </if>
|
|
|
+ </where>
|
|
|
+ ORDER BY a.sort
|
|
|
</select>
|
|
|
|
|
|
<select id="selectDictListByCode" resultType="com.jzg.commons.entity.report.dto.ReportDictDto">
|
|
|
SELECT
|
|
|
- p.VALUE AS value,
|
|
|
- p.label AS label
|
|
|
+ p.VALUE AS value,
|
|
|
+ p.label AS label
|
|
|
FROM
|
|
|
- sys_dict p
|
|
|
- LEFT JOIN sys_dict_type c ON p.type_code = c.dict_code
|
|
|
- WHERE
|
|
|
- c.dict_code = #{distCode}
|
|
|
- ORDER BY
|
|
|
- p.sort
|
|
|
+ sys_dict p
|
|
|
+ LEFT JOIN sys_dict_type c ON p.type_code = c.dict_code AND c.is_delete = 0
|
|
|
+ <where>
|
|
|
+ AND p.is_delete = 0
|
|
|
+ <if test="distCode != null and distCode != ''">
|
|
|
+ AND c.dict_code = #{distCode}
|
|
|
+ </if>
|
|
|
+ </where>
|
|
|
+ ORDER BY p.sort
|
|
|
</select>
|
|
|
+
|
|
|
<select id="getSecondLevelAreaList" resultType="com.jzg.commons.entity.po.SysArea">
|
|
|
- SELECT
|
|
|
- *
|
|
|
- FROM
|
|
|
- sys_area
|
|
|
- WHERE
|
|
|
- `level` IN (1,2)
|
|
|
+ SELECT *
|
|
|
+ FROM sys_area
|
|
|
+ <where>
|
|
|
+ AND is_delete = 0
|
|
|
+ AND `level` IN (1,2)
|
|
|
+ </where>
|
|
|
</select>
|
|
|
+
|
|
|
<select id="getDeptListByUserId" resultType="com.jzg.commons.entity.po.SysDept">
|
|
|
- SELECT
|
|
|
- *
|
|
|
- FROM
|
|
|
- sys_dept
|
|
|
- WHERE
|
|
|
- system_code =(
|
|
|
- SELECT
|
|
|
- sys_code
|
|
|
- FROM
|
|
|
- sys_system
|
|
|
- WHERE
|
|
|
- user_id = #{userId}
|
|
|
+ SELECT *
|
|
|
+ FROM sys_dept
|
|
|
+ <where>
|
|
|
+ AND is_delete = 0
|
|
|
+ AND system_code = (
|
|
|
+ SELECT sys_code
|
|
|
+ FROM sys_system
|
|
|
+ WHERE user_id = #{userId}
|
|
|
+ AND is_delete = 0
|
|
|
)
|
|
|
- order by id
|
|
|
+ </where>
|
|
|
+ ORDER BY id
|
|
|
</select>
|
|
|
+
|
|
|
<select id="queryCompanyListByUserId" resultType="com.jzg.commons.entity.report.dto.ReportDictDto">
|
|
|
SELECT
|
|
|
- id AS VALUE,
|
|
|
- NAME AS label
|
|
|
- FROM
|
|
|
- esm_ins_company
|
|
|
- WHERE
|
|
|
- id IN (
|
|
|
- SELECT
|
|
|
- bus_id
|
|
|
- FROM
|
|
|
- sys_system_bus_perms_link
|
|
|
- WHERE
|
|
|
- perms_id =(
|
|
|
- SELECT
|
|
|
- p.id
|
|
|
- FROM
|
|
|
- sys_system_bus_perms p
|
|
|
- LEFT JOIN sys_system ss ON p.system_code = ss.sys_code
|
|
|
- WHERE
|
|
|
- ss.user_id = #{userId}
|
|
|
- )
|
|
|
- AND bus_code = 'quoteCompany'
|
|
|
+ id AS VALUE,
|
|
|
+ NAME AS label
|
|
|
+ FROM esm_ins_company
|
|
|
+ <where>
|
|
|
+ AND is_delete = 0
|
|
|
+ AND id IN (
|
|
|
+ SELECT bus_id
|
|
|
+ FROM sys_system_bus_perms_link
|
|
|
+ WHERE is_delete = 0
|
|
|
+ AND bus_code = 'quoteCompany'
|
|
|
+ AND perms_id = (
|
|
|
+ SELECT p.id
|
|
|
+ FROM sys_system_bus_perms p
|
|
|
+ LEFT JOIN sys_system ss ON p.system_code = ss.sys_code AND ss.is_delete = 0
|
|
|
+ WHERE p.is_delete = 0
|
|
|
+ AND ss.user_id = #{userId}
|
|
|
+ )
|
|
|
)
|
|
|
+ </where>
|
|
|
</select>
|
|
|
+
|
|
|
<select id="getPartnerCompanyListByCompanyId" resultType="com.jzg.commons.entity.report.dto.ReportDictDto">
|
|
|
WITH RECURSIVE company_hierarchy AS (
|
|
|
SELECT
|
|
|
@@ -117,90 +122,93 @@
|
|
|
name,
|
|
|
parent_id,
|
|
|
1 AS level
|
|
|
- FROM
|
|
|
- esm_ins_company
|
|
|
- WHERE
|
|
|
- id = #{companyId}
|
|
|
- AND is_delete = 0
|
|
|
+ FROM esm_ins_company
|
|
|
+ WHERE id = #{companyId}
|
|
|
+ AND is_delete = 0
|
|
|
UNION ALL
|
|
|
- SELECT
|
|
|
- c.id,
|
|
|
- c.name,
|
|
|
- c.parent_id,
|
|
|
- ch.level + 1 AS level
|
|
|
- FROM
|
|
|
- esm_ins_company c
|
|
|
- INNER JOIN company_hierarchy ch ON c.parent_id = ch.id
|
|
|
- WHERE
|
|
|
- c.is_delete = 0
|
|
|
- AND ch.level <![CDATA[< ]]> 3
|
|
|
+ SELECT
|
|
|
+ c.id,
|
|
|
+ c.name,
|
|
|
+ c.parent_id,
|
|
|
+ ch.level + 1 AS level
|
|
|
+ FROM esm_ins_company c
|
|
|
+ INNER JOIN company_hierarchy ch ON c.parent_id = ch.id
|
|
|
+ WHERE c.is_delete = 0
|
|
|
+ AND ch.level <![CDATA[< ]]> 3
|
|
|
)
|
|
|
SELECT
|
|
|
- id as value,
|
|
|
- name as label,
|
|
|
+ id AS value,
|
|
|
+ name AS label,
|
|
|
parent_id,
|
|
|
level
|
|
|
- FROM
|
|
|
- company_hierarchy
|
|
|
- WHERE
|
|
|
- level = 3;
|
|
|
+ FROM company_hierarchy
|
|
|
+ WHERE level = 3
|
|
|
</select>
|
|
|
+
|
|
|
<select id="getSearchDefaultList"
|
|
|
resultType="com.jzg.commons.entity.report.dto.ReportSearchConfigurationDto">
|
|
|
SELECT
|
|
|
- b.search_key AS 'key',
|
|
|
- b.search_name AS label,
|
|
|
- b.show_type AS inputType,
|
|
|
- b.select_type AS selectType,
|
|
|
- b.search_sql AS searchSql,
|
|
|
- b.id AS id,
|
|
|
- a.show_flag AS showFlag,
|
|
|
- true as defaultFlag,
|
|
|
- true as selectFlag,
|
|
|
- false AS isShowDelIcon
|
|
|
- FROM
|
|
|
- report_page_set_search_param a
|
|
|
- LEFT JOIN report_search_configuration b ON a.report_configuration_id = b.id
|
|
|
- WHERE
|
|
|
- a.router_path_key = #{ routerKey }
|
|
|
- ORDER BY
|
|
|
- a.sort
|
|
|
+ b.search_key AS 'key',
|
|
|
+ b.search_name AS label,
|
|
|
+ b.show_type AS inputType,
|
|
|
+ b.select_type AS selectType,
|
|
|
+ b.search_sql AS searchSql,
|
|
|
+ b.id AS id,
|
|
|
+ a.show_flag AS showFlag,
|
|
|
+ true AS defaultFlag,
|
|
|
+ true AS selectFlag,
|
|
|
+ false AS isShowDelIcon
|
|
|
+ FROM report_page_set_search_param a
|
|
|
+ LEFT JOIN report_search_configuration b
|
|
|
+ ON a.report_configuration_id = b.id
|
|
|
+ AND b.is_delete = 0
|
|
|
+ <where>
|
|
|
+ AND a.is_delete = 0
|
|
|
+ <if test="routerKey != null and routerKey != ''">
|
|
|
+ AND a.router_path_key = #{ routerKey }
|
|
|
+ </if>
|
|
|
+ </where>
|
|
|
+ ORDER BY a.sort
|
|
|
</select>
|
|
|
|
|
|
- <select id="getUserIdByUserName"
|
|
|
- resultType="java.lang.String">
|
|
|
- SELECT
|
|
|
- id
|
|
|
- FROM
|
|
|
- sys_user
|
|
|
- WHERE
|
|
|
- mobile = #{ userId }
|
|
|
+ <select id="getUserIdByUserName" resultType="java.lang.String">
|
|
|
+ SELECT id
|
|
|
+ FROM sys_user
|
|
|
+ <where>
|
|
|
+ AND is_delete = 0
|
|
|
+ AND account_status = 1
|
|
|
+ <if test="userId != null and userId != ''">
|
|
|
+ AND mobile = #{ userId }
|
|
|
+ </if>
|
|
|
+ </where>
|
|
|
</select>
|
|
|
|
|
|
<select id="getUserByUserId" resultType="java.lang.String">
|
|
|
- SELECT
|
|
|
- sys_code
|
|
|
- FROM
|
|
|
- sys_system
|
|
|
- WHERE
|
|
|
- user_id = (
|
|
|
- SELECT
|
|
|
- id
|
|
|
- FROM
|
|
|
- sys_user
|
|
|
- WHERE
|
|
|
- mobile = #{ userId }
|
|
|
- )
|
|
|
+ SELECT sys_code
|
|
|
+ FROM sys_system
|
|
|
+ <where>
|
|
|
+ AND is_delete = 0
|
|
|
+ AND user_id = (
|
|
|
+ SELECT id
|
|
|
+ FROM sys_user
|
|
|
+ WHERE is_delete = 0
|
|
|
+ AND account_status = 1
|
|
|
+ AND mobile = #{ userId }
|
|
|
+ )
|
|
|
+ </where>
|
|
|
</select>
|
|
|
|
|
|
<select id="getUserByPhone" resultType="java.lang.String">
|
|
|
- SELECT
|
|
|
- sys_code
|
|
|
- FROM
|
|
|
- sys_system
|
|
|
- WHERE
|
|
|
- user_id = #{ userId }
|
|
|
+ SELECT sys_code
|
|
|
+ FROM sys_system
|
|
|
+ <where>
|
|
|
+ AND is_delete = 0
|
|
|
+ <if test="userId != null">
|
|
|
+ AND user_id = #{userId}
|
|
|
+ </if>
|
|
|
+ </where>
|
|
|
</select>
|
|
|
+
|
|
|
<select id="getUserListBySystemCode" resultType="com.jzg.commons.entity.report.dto.UserTreeDto">
|
|
|
WITH RECURSIVE org_hierarchy AS (
|
|
|
SELECT
|
|
|
@@ -215,10 +223,12 @@
|
|
|
CAST(o.id AS CHAR) AS org_path
|
|
|
FROM sys_organization o
|
|
|
LEFT JOIN sys_user_jzg_info u ON o.manager_id = u.id AND u.is_delete = 0
|
|
|
- WHERE o.system_code = #{systemCode}
|
|
|
- AND o.is_delete = 0
|
|
|
+ WHERE o.is_delete = 0
|
|
|
+ AND o.system_code = #{systemCode}
|
|
|
AND u.id != 'admin'
|
|
|
+
|
|
|
UNION ALL
|
|
|
+
|
|
|
SELECT
|
|
|
o.id AS org_id,
|
|
|
o.name AS org_name,
|
|
|
@@ -232,10 +242,10 @@
|
|
|
FROM sys_organization o
|
|
|
INNER JOIN org_hierarchy oh ON o.dept_id = oh.org_id
|
|
|
LEFT JOIN sys_user_jzg_info u ON o.manager_id = u.id AND u.is_delete = 0
|
|
|
- WHERE o.system_code = #{systemCode}
|
|
|
- AND o.is_delete = 0
|
|
|
+ WHERE o.is_delete = 0
|
|
|
+ AND o.system_code = #{systemCode}
|
|
|
AND u.id != 'admin'
|
|
|
- )
|
|
|
+ )
|
|
|
SELECT DISTINCT
|
|
|
p.id as id,
|
|
|
p.name as name,
|
|
|
@@ -273,9 +283,12 @@
|
|
|
0 AS is_manager,
|
|
|
oh.org_path AS hierarchy_path
|
|
|
FROM sys_organization_user_link ul
|
|
|
- INNER JOIN sys_user_jzg_info u ON ul.user_id = u.id AND u.is_delete = 0
|
|
|
+ INNER JOIN sys_user_jzg_info u
|
|
|
+ ON ul.user_id = u.id
|
|
|
+ AND u.is_delete = 0
|
|
|
INNER JOIN org_hierarchy oh ON ul.organization_id = oh.org_id
|
|
|
WHERE ul.user_id != CAST(oh.manager_id AS CHAR)
|
|
|
+ AND ul.is_delete = 0
|
|
|
|
|
|
UNION ALL
|
|
|
SELECT
|
|
|
@@ -313,12 +326,16 @@
|
|
|
oh.org_path AS hierarchy_path,
|
|
|
oh.parent_org_id
|
|
|
FROM sys_organization_user_link ul
|
|
|
- INNER JOIN sys_user_jzg_info u ON ul.user_id = u.id AND u.is_delete = 0
|
|
|
+ INNER JOIN sys_user_jzg_info u
|
|
|
+ ON ul.user_id = u.id
|
|
|
+ AND u.is_delete = 0
|
|
|
INNER JOIN org_hierarchy oh ON ul.organization_id = oh.org_id
|
|
|
- WHERE ul.user_id != CAST(oh.manager_id AS CHAR) AND oh.parent_org_id IS NOT NULL
|
|
|
+ WHERE ul.user_id != CAST(oh.manager_id AS CHAR)
|
|
|
+ AND oh.parent_org_id IS NOT NULL
|
|
|
+ AND ul.is_delete = 0
|
|
|
) sub
|
|
|
INNER JOIN org_hierarchy oh ON sub.parent_org_id = oh.org_id
|
|
|
) p
|
|
|
ORDER BY p.hierarchy_path, p.is_manager DESC;
|
|
|
</select>
|
|
|
-</mapper>
|
|
|
+</mapper>
|