日照智慧社区接口服务
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

319 lines
10 KiB

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.epmet.dao.stats.DimAgencyDao">
<insert id="insertOne">
INSERT INTO dim_agency(id, agency_name, customer_id, pid, pids, all_parent_name, level, del_flag, revision, created_by,
created_time, updated_by, updated_time)
VALUE (#{id}, #{agencyName}, #{customerId}, #{pid}, #{pids}, #{allParentName}, #{level}, #{delFlag}, #{revision}, #{createdBy}, #{createdTime}, #{updatedBy}, #{updatedTime})
</insert>
<select id="selectDimAgencyList" resultType="com.epmet.dto.stats.DimAgencyDTO">
SELECT
id,
agency_name,
customer_id,
pid,
pids,
all_parent_name,
`level`
FROM
dim_agency
WHERE
del_flag = '0'
AND AGENCY_DIM_TYPE = 'all'
<if test="customerId != null and customerId.trim() != ''">
AND customer_id = #{customerId}
</if>
</select>
<resultMap id="treeMap" type="com.epmet.dto.AgencySubTreeDto">
<id column="agencyId" property="agencyId" />
<result column="agencyName" property="agencyName"/>
<result column="customer_Id" property="customerId" />
<result column="PID" property="pid" />
<result column="LEVEL" property="level" />
<collection property="gridIds" ofType="java.lang.String">
<constructor>
<arg column="gridId"/>
</constructor>
</collection>
<collection property="subAgencies" column="agencyId"
ofType="com.epmet.dto.AgencySubTreeDto" select="selectSubAgencyByPid"></collection>
</resultMap>
<!-- 获取所有机关 递归入口 -->
<select id="selectAllAgency" resultMap="treeMap">
SELECT
agency.ID AS agencyId,
agency.AGENCY_NAME AS agencyName,
grid.ID AS gridId,
agency.CUSTOMER_ID,
agency.PID,
agency.LEVEL
FROM
dim_agency agency
LEFT JOIN dim_grid grid ON agency.ID = grid.AGENCY_ID
AND grid.DEL_FLAG = '0'
WHERE
agency.DEL_FLAG = '0'
AND
agency.AGENCY_DIM_TYPE = 'all'
<if test='null != customerId and "" != customerId'>
AND agency.CUSTOMER_ID = #{customerId}
</if>
ORDER BY
agency.CUSTOMER_ID,
agency.PID
</select>
<!-- 根据PID获取下级机关 递归传递 -->
<select id="selectSubAgencyByPid" resultMap="treeMap" parameterType="string">
SELECT
agency.id AS agencyId,
agency.AGENCY_NAME AS agencyName,-- agency.PID,agency.PIDS ,
grid.ID AS gridId, -- ,GRID_NAME
agency.CUSTOMER_ID,
agency.PID,
agency.LEVEL
FROM
dim_agency agency
LEFT JOIN dim_grid grid ON agency.ID = grid.AGENCY_ID
AND grid.DEL_FLAG = '0'
WHERE
agency.DEL_FLAG = '0'
AND
agency.PID = #{pid}
AND
agency.AGENCY_DIM_TYPE = 'all'
ORDER BY
agency.CUSTOMER_ID,
agency.ID,
grid.ID
</select>
<!-- 获取顶级机关 递归入口 -->
<select id="selectTopAgency" resultMap="treeMap">
SELECT
agency.ID AS agencyId,
agency.AGENCY_NAME AS agencyName,
grid.ID AS gridId,
agency.CUSTOMER_ID,
agency.PID,
agency.LEVEL
FROM
dim_agency agency
LEFT JOIN dim_grid grid ON agency.ID = grid.AGENCY_ID
AND grid.DEL_FLAG = '0'
WHERE
agency.DEL_FLAG = '0'
AND
agency.PID = '0'
AND
agency.AGENCY_DIM_TYPE = 'all'
<if test='null != customerId and "" != customerId'>
AND agency.CUSTOMER_ID = #{customerId}
</if>
ORDER BY
agency.CUSTOMER_ID,
agency.PID
</select>
<select id="getAgencyListByCustomerId" resultType="com.epmet.entity.stats.DimAgencyEntity">
SELECT
ID,
CUSTOMER_ID,
PID,
AGENCY_NAME,
LEVEL
FROM
dim_agency
WHERE
DEL_FLAG = '0'
AND CUSTOMER_ID = #{customerId,jdbcType=VARCHAR}
AND AGENCY_DIM_TYPE = 'all'
</select>
<resultMap id="treeMapWithDept" type="com.epmet.dto.AgencySubDeptTreeDto">
<id column="agencyId" property="agencyId" />
<result column="agencyName" property="agencyName"/>
<result column="customer_Id" property="customerId" />
<result column="PID" property="pid" />
<result column="LEVEL" property="level" />
<collection property="gridIds" ofType="java.lang.String">
<constructor>
<arg column="gridId"/>
</constructor>
</collection>
<collection property="deptIds" ofType="java.lang.String">
<constructor>
<arg column="deptId"/>
</constructor>
</collection>
<collection property="subAgencies" column="agencyId"
ofType="com.epmet.dto.AgencySubDeptTreeDto" select="selectSubAgencyWithDeptByPid"></collection>
</resultMap>
<!-- 带部门 获取所有机关 递归入口 -->
<select id="selectAllAgencyWithDept" resultMap="treeMapWithDept">
SELECT
agency.ID AS agencyId,
agency.AGENCY_NAME AS agencyName,
grid.ID AS gridId,
agency.CUSTOMER_ID,
agency.PID,
agency.LEVEL,
dept.ID AS deptId
FROM
dim_agency agency
LEFT JOIN dim_grid grid ON agency.ID = grid.AGENCY_ID
AND grid.DEL_FLAG = '0'
LEFT JOIN dim_department dept ON agency.ID = dept.AGENCY_ID
AND dept.DEL_FLAG = '0'
WHERE
agency.DEL_FLAG = '0'
ORDER BY
agency.CUSTOMER_ID,
agency.PID
</select>
<!-- 带部门 根据PID获取下级机关 递归传递 -->
<select id="selectSubAgencyWithDeptByPid" resultMap="treeMapWithDept" parameterType="string">
SELECT
agency.id AS agencyId,
agency.AGENCY_NAME AS agencyName,-- agency.PID,agency.PIDS ,
grid.ID AS gridId, -- ,GRID_NAME
agency.CUSTOMER_ID,
agency.PID,
agency.LEVEL,
dept.ID AS deptId
FROM
dim_agency agency
LEFT JOIN dim_grid grid ON agency.ID = grid.AGENCY_ID
AND grid.DEL_FLAG = '0'
LEFT JOIN dim_department dept ON agency.ID = dept.AGENCY_ID
AND dept.DEL_FLAG = '0'
WHERE
agency.DEL_FLAG = '0'
AND agency.PID = #{pid}
ORDER BY
agency.CUSTOMER_ID,
agency.ID,
grid.ID
</select>
<!-- 带部门 获取顶级机关 递归入口 -->
<select id="selectTopAgencyWithDept" resultMap="treeMapWithDept">
SELECT
agency.ID AS agencyId,
agency.AGENCY_NAME AS agencyName,
grid.ID AS gridId,
agency.CUSTOMER_ID,
agency.PID,
agency.LEVEL,
dept.ID AS deptId
FROM
dim_agency agency
LEFT JOIN dim_grid grid ON agency.ID = grid.AGENCY_ID
AND grid.DEL_FLAG = '0'
LEFT JOIN dim_department dept ON agency.ID = dept.AGENCY_ID
AND dept.DEL_FLAG = '0'
WHERE
agency.DEL_FLAG = '0'
AND
agency.PID = '0'
ORDER BY
agency.CUSTOMER_ID,
agency.PID
</select>
<!-- 查询所有客户的机关数据 -->
<select id="selectDimAgencyByCustomerId" resultType="com.epmet.dto.stats.DimAgencyDTO">
SELECT
id AS id,
customer_id AS customerId,
level AS level,
pid AS pid,
pids AS pids
FROM
dim_agency
WHERE
del_flag = '0'
AND AGENCY_DIM_TYPE = 'all'
AND customer_id = #{customerId}
</select>
<select id="getPidByAgencyId" resultType="java.lang.String" parameterType="java.lang.String">
SELECT
pid
FROM
dim_agency
WHERE
del_flag = '0'
AND id = #{agencyId}
</select>
<select id="getLatestCreatedAgencyDimEntity" resultType="com.epmet.entity.stats.DimAgencyEntity">
SELECT id,
agency_name,
customer_id,
pid,
pids,
all_parent_name,
level,
del_flag,
revision,
created_by,
created_time,
updated_by,
updated_time,
agency_dim_type
FROM dim_agency
ORDER BY CREATED_TIME DESC
LIMIT 1
</select>
<!-- 最后一次更新的时间-->
<select id="getLatestUpdatedAgencyDimEntity" resultType="com.epmet.entity.stats.DimAgencyEntity">
select id,
agency_name,
customer_id,
pid,
pids,
all_parent_name,
level,
del_flag,
revision,
created_by,
created_time,
updated_by,
updated_time,
agency_dim_type
from dim_agency
order by UPDATED_TIME desc
limit 1
</select>
<!-- 查询pid信息 -->
<select id="selectAgencyInfo" resultType="com.epmet.dto.extract.result.AgencyInfoResultDTO">
SELECT
id AS agencyId,
pid
FROM
dim_agency
WHERE
del_flag = '0'
AND
(
<foreach collection="agencyIds" item="item" separator=" OR ">
id = #{item}
</foreach>
)
</select>
</mapper>