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.

117 lines
3.6 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.DimGridDao">
<select id="getLastCreatedGridDimEntity" resultType="com.epmet.entity.stats.DimGridEntity">
SELECT *
FROM dim_grid
WHERE DEL_FLAG = 0
ORDER BY CREATED_TIME DESC
LIMIT 1
</select>
<select id="getGridListByCustomerId" resultType="com.epmet.entity.stats.DimGridEntity">
SELECT
ID,
CUSTOMER_ID,
AGENCY_ID,
GRID_NAME
FROM
dim_grid
WHERE
DEL_FLAG = 0
AND CUSTOMER_ID = #{customerId,jdbcType=VARCHAR}
</select>
5 years ago
<select id="selectAgencyGridInfo" resultType="com.epmet.dto.group.result.AgencyGridInfoResultDTO" parameterType="com.epmet.dto.group.AgencyDTO">
<foreach collection="formDTO" item="agency" separator=" UNION ALL ">
SELECT
id AS gridId,
agency_id AS agencyId
FROM
dim_grid
WHERE
del_flag = '0'
AND customer_id = #{agency.customerId}
AND agency_id = #{agency.id}
</foreach>
</select>
<!-- 根据当前机关ID查询下级机关ID -->
<select id="selectSubAgencyId" resultType="com.epmet.dto.group.result.SubAgencyIdResultDTO" parameterType="com.epmet.dto.group.AgencyDTO">
<foreach collection="formDTO" item="agency" separator=" UNION ALL ">
SELECT
#{agency.id} AS agencyId,
id AS subAgencyId
FROM
dim_agency
WHERE
del_flag = '0'
AND customer_id = #{agency.customerId}
AND pid = #{agency.id}
</foreach>
</select>
<select id="getLastUpdatedGridDim" resultType="com.epmet.entity.stats.DimGridEntity">
select id,
grid_name,
customer_id,
agency_id,
area_code,
del_flag,
revision,
created_by,
created_time,
updated_by,
updated_time
from dim_grid
order by UPDATED_TIME desc
limit 1;
</select>
5 years ago
<!-- 查询网格属于哪个机关 -->
<select id="selectGridBelongAgencyInfo" resultType="com.epmet.dto.stats.result.GridBelongAgencyResultDTO">
SELECT
dg.id AS gridId,
dg.AGENCY_ID AS agencyId,
da.PID AS parentId,
da.pids
5 years ago
FROM
dim_grid dg
LEFT JOIN dim_agency da ON da.id = dg.agency_id
WHERE
dg.DEL_FLAG = '0'
AND da.DEL_FLAG = '0'
AND
(
<foreach collection="gridIds" item="gridId" separator=" OR ">
dg.id = #{gridId}
</foreach>
)
</select>
<select id="selectGridAttributes" resultType="com.epmet.dto.stats.result.GridAttributesResultDTO">
SELECT
dg.id AS gridId,
dg.AGENCY_ID AS agencyId,
da.PID AS parentId,
da.PIDS
FROM
dim_grid dg
LEFT JOIN dim_agency da ON da.id = dg.agency_id
WHERE
dg.DEL_FLAG = '0'
AND da.DEL_FLAG = '0'
AND da.CUSTOMER_ID = #{customerId}
<if test="null != gridIds and gridIds.size() > 0">
AND
(
<foreach collection="gridIds" item="gridId" separator=" OR ">
dg.id = #{gridId}
</foreach>
)
</if>
</select>
</mapper>