btxtgxq-system-city/src/main/resources/mybatis/mapper/datarelease/datarelease-mapper.xml
2022-11-30 00:37:10 +08:00

328 lines
10 KiB
XML

<?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.cm.systemcity.dao.datarelease.IDataReleaseDao">
<select id="listHandleCaseByUserId" parameterType="string" resultType="map">
SELECT
*
FROM
city_report_case_handle
WHERE
creator = #{userId}
</select>
<select id="listDepartmentByUserId" parameterType="string" resultType="map">
SELECT
t1.department_id departmentId,
t2.department_name departmentName
FROM
sys_department_user t1
LEFT JOIN sys_department t2 ON t1.department_id = t2.department_id
WHERE
t1.user_id = #{userId}
</select>
<select id="getUserRoleForCheckNPerson" parameterType="string" resultType="map">
SELECT
*
FROM
sys_role_user
WHERE
user_id = #{userId}
AND role_id = 'bc405346-8714-4ded-89ac-9cc4d755f66a'
</select>
<select id="listUserByGridId" parameterType="string" resultType="map">
SELECT
t2.user_id userId,
t2.user_name userName,
t2.user_username userAccount,
t2.user_phone userPhone
FROM
map_grid_relation t1
LEFT JOIN sys_user t2 on t1.relation_id = t2.user_id
WHERE
t1.grid_id = #{gridId}
AND t2.is_delete = '0'
</select>
<select id="getDataArea" parameterType="map" resultType="map">
select * from data_area where area_id = #{areaId}
</select>
<select id="countOfBasePopulation" parameterType="map" resultType="integer">
SELECT
count(*) counts
FROM
gen_base_population_info t1
LEFT JOIN data_area t2 ON t1.area_id = t2.area_id
where
t1.is_delete = '0'
<if test="areaParentId != null and areaParentId != ''">
AND t2.area_parent_id = #{areaParentId}
</if>
</select>
<select id="listHouse" parameterType="map" resultType="integer">
select count(*) from city_building_house
where is_delete = 0
and city_building_id = #{cityBuildingId}
AND
city_building_id IN
<foreach collection="buildingIds" index="index" open="(" separator="," close=")">
#{buildingIds[${index}]}
</foreach>
</select>
<select id="listBuilding" parameterType="map" resultType="map">
select * from city_building
where is_delete = 0
and district_id = #{districtId}
</select>
<select id="listDistrict" parameterType="map" resultType="map">
select * from city_district
where is_delete = 0
and area_id = #{areaId}
</select>
<select id="countOfCommunityBoss" parameterType="map" resultType="map">
select DISTINCT
community_boss_user_id
from
city_community_boss
where
is_delete = 0
and area_id = #{areaId}
</select>
<select id="listMapGridRelation" parameterType="map" resultType="map">
select * from map_grid_relation
where relation_id = #{relationId}
</select>
<select id="getDepartment" parameterType="map" resultType="map">
select * from sys_department
where is_delete = '0'
and department_id = #{departmentId}
</select>
<select id="listMapGrid" parameterType="map" resultType="map">
select *
from map_grid
where
is_delete = '0'
<if test="gridId !=null and gridId !=''">
and grid_id = #{gridId}
</if>
<if test="areaCode !=null and areaCode !=''">
and area_code LIKE CONCAT('%',CONCAT(#{areaCode}, '%'))
</if>
</select>
<select id="listMapGridPoint" parameterType="map" resultType="map">
select
lng,
lat
from map_grid_point
where
grid_id = #{gridId}
</select>
<select id="getAreaInfoFromCityDict" parameterType="map" resultType="map">
SELECT * FROM
city_dict
WHERE
is_delete = '0'
AND dict_parent_id = #{dictParentId}
</select>
<select id="getCommunityInfo" parameterType="map" resultType="map">
SELECT * FROM
city_community
WHERE
is_delete = '0'
<if test="areaId != null and areaId !=''">
AND area_id = #{areaId}
</if>
<if test="communityName != null and communityName !=''">
AND community_name = #{communityName}
</if>
ORDER BY community_order ASC
</select>
<!-- 查询上报案件 -->
<select id="listReportCase" parameterType="map" resultType="map">
SELECT
*
FROM
city_report_case
WHERE
is_delete = '0'
<if test="caseFlowType != null and caseFlowType != ''">
AND FIND_IN_SET(case_flow_type, #{caseFlowType})
</if>
<if test="caseStatus != null and caseStatus != ''">
AND FIND_IN_SET(case_status, #{caseStatus})
</if>
<if test="caseTypeId != null and caseTypeId != ''">
AND FIND_IN_SET(case_type_id, #{caseTypeId})
</if>
<if test="dataCatalog != null and dataCatalog == 'dept'">
AND case_flow_type = '1'
</if>
<if test="dataCatalog != null and dataCatalog == 'street'">
AND case_flow_type = '2'
AND case_reporter NOT LIKE CONCAT('%',CONCAT('微信', '%'))
</if>
<if test="dataCatalog != null and dataCatalog == 'person'">
AND case_flow_type = '2'
AND case_reporter LIKE CONCAT('%',CONCAT('微信', '%'))
</if>
<if test="gmtCreateLike != null and gmtCreateLike != ''">
AND gmt_create LIKE CONCAT('%',CONCAT(#{gmtCreateLike}, '%'))
</if>
<if test="gmtModified != null and gmtModified != ''">
AND gmt_modified LIKE CONCAT('%',CONCAT(#{gmtModified}, '%'))
</if>
<if test="areaId != null and areaId !=''">
AND area_id = #{areaId}
</if>
<if test="caseStatusCompareUp != null and caseStatusCompareUp !=''">
AND case_status <![CDATA[>=]]> #{caseStatusCompareUp}
</if>
<if test="startTime != null and startTime !=''">
AND gmt_create <![CDATA[>=]]> #{startTime}
</if>
<if test="endTime != null and endTime !=''">
AND gmt_create <![CDATA[<=]]> #{endTime}
</if>
<if test="modifiedStr != null and modifiedStr !=''">
AND gmt_modified <![CDATA[>=]]> #{modifiedStr}
</if>
<if test="modifiedEnd != null and modifiedEnd !=''">
AND gmt_modified <![CDATA[<=]]> #{modifiedEnd}
</if>
<if test="creator != null and creator !=''">
AND creator = #{userId}
</if>
ORDER BY gmt_create DESC
</select>
<select id="listSpecialReportCase" parameterType="map" resultType="map">
SELECT
*
FROM
city_special_report_case
WHERE
is_delete = '0'
<if test="caseStatus != null and caseStatus != ''">
AND case_status = #{caseStatus}
</if>
<if test="gmtModified != null and gmtModified != ''">
AND gmt_modified LIKE CONCAT('%',CONCAT(#{gmtModified}, '%'))
</if>
<if test="areaId != null and areaId !=''">
AND area_id = #{areaId}
</if>
</select>
<select id="getCaseTypeTop10" parameterType="map" resultType="map">
SELECT
t1.case_type_id caseTypeId,
t2.dict_name dictName,
COUNT(t1.case_type_id) caseTypeCount
FROM
city_report_case t1
LEFT JOIN city_dict t2 ON t1.case_type_id = t2.dict_id
WHERE
t1.is_delete = '0'
AND t1.case_status = '6'
GROUP BY
t1.case_type_id,
t2.dict_name
ORDER BY
caseTypeCount DESC
LIMIT 0,10
</select>
<select id="listReportCaseLog" parameterType="map" resultType="map">
SELECT
t1.option_type optionType,
t1.user_name userName,
t1.gmt_create gmtCreate,
t2.case_content caseContent,
t2.case_number caseNumber
FROM
city_report_case_log t1
LEFT JOIN city_report_case t2 ON t1.case_id = t2.report_case_id
ORDER BY
t1.gmt_create DESC
LIMIT 0,10
</select>
<select id="listUserDynamicPosition" parameterType="map" resultType="map">
SELECT
creator,
user_name
FROM
city_user_location
WHERE
gmt_create <![CDATA[ >= ]]> #{timeStr}
AND gmt_create <![CDATA[ <= ]]> #{timeEnd}
GROUP BY
creator,user_name
</select>
<select id="listCaseInMap" parameterType="map" resultType="map">
SELECT
report_case_id,
case_reporter,
case_content,
case_longitude,
case_latitude,
gmt_create
FROM
city_report_case
WHERE
case_status = '2'
<if test="startTime != null and startTime != ''">
AND LEFT(gmt_create, 10) <![CDATA[ >= ]]> #{startTime}
</if>
<if test="endTime != null and endTime != ''">
AND LEFT(gmt_create, 10) <![CDATA[ <= ]]> #{endTime}
</if>
ORDER BY
gmt_create DESC
</select>
<select id="listUserLocation" parameterType="map" resultType="map">
SELECT
t1.user_name,
t1.creator
FROM
city_user_location t1
WHERE
t1.gmt_create <![CDATA[ >= ]]> #{startTime}
AND t1.gmt_create <![CDATA[ <= ]]> #{endTime}
<if test="userName != null and userName != ''">
AND t1.user_name = #{userName}
</if>
GROUP BY t1.user_name, t1.creator
</select>
<select id="getLastUserLocationInfo" parameterType="map" resultType="map">
SELECT
t1.*,
t2.user_avatar,
t2.user_phone,
t2.user_username
FROM
city_user_location t1
INNER JOIN sys_user t2 ON t1.creator = t2.user_id
WHERE
t1.creator = #{userId}
ORDER BY t1.gmt_create desc
limit 1
</select>
</mapper>