| | |
| | | <mapper namespace="com.ruoyi.system.mapper.HospDataMapper"> |
| | | |
| | | <resultMap type="HospData" id="HospDataResult"> |
| | | <result property="hospId" column="HospID" /> |
| | | <result property="hospName" column="HospName" /> |
| | | <result property="hospCityId" column="HospCityID" /> |
| | | <result property="hospShort" column="HospShort" /> |
| | | <result property="hopsProvince" column="HopsProvince" /> |
| | | <result property="hopsCity" column="HopsCity" /> |
| | | <result property="hopsArea" column="HopsArea" /> |
| | | <result property="hospAddress" column="HospAddress" /> |
| | | <result property="hospTel" column="HospTEL" /> |
| | | <result property="hospUnitId" column="HospUnitID" /> |
| | | <result property="hospState" column="HospState" /> |
| | | <result property="hospOaId" column="HospOAID" /> |
| | | <result property="hospIntroducerId" column="HospIntroducerID" /> |
| | | <result property="hospIntroducerDate" column="HospIntroducerDate" /> |
| | | <result property="hospLevel" column="HospLevel" /> |
| | | <result property="hospId" column="legacy_hosp_id" /> |
| | | <result property="hospName" column="hosp_name" /> |
| | | <result property="hospCityId" column="hosp_city_id" /> |
| | | <result property="hospShort" column="hosp_short" /> |
| | | <result property="hopsProvince" column="hops_province" /> |
| | | <result property="hopsCity" column="hops_city" /> |
| | | <result property="hopsArea" column="hops_area" /> |
| | | <result property="hospAddress" column="hosp_address" /> |
| | | <result property="hospTel" column="hosp_tel" /> |
| | | <result property="hospUnitId" column="hosp_unit_id" /> |
| | | <result property="hospState" column="hosp_state" /> |
| | | <result property="hospOaId" column="hosp_oa_id" /> |
| | | <result property="hospIntroducerId" column="hosp_introducer_id" /> |
| | | <result property="hospIntroducerDate" column="hosp_introducer_date" /> |
| | | <result property="hospLevel" column="hosp_level" /> |
| | | </resultMap> |
| | | |
| | | <select id="searchHospitals" resultMap="HospDataResult"> |
| | | SELECT TOP 100 |
| | | HospID, HospName, HospCityID, HospShort, |
| | | HopsProvince, HopsCity, HopsArea, HospAddress, |
| | | HospTEL, HospUnitID, HospState, HospOAID, |
| | | HospIntroducerID, HospIntroducerDate, HospLevel |
| | | FROM HospData |
| | | WHERE 1=1 |
| | | SELECT legacy_hosp_id, hosp_name, hosp_city_id, hosp_short, |
| | | hops_province, hops_city, hops_area, hosp_address, |
| | | hosp_tel, hosp_unit_id, hosp_state, hosp_oa_id, |
| | | hosp_introducer_id, hosp_introducer_date, hosp_level |
| | | FROM tb_hosp_data |
| | | WHERE status = '0' |
| | | <!-- 有 keyword 就只用 keyword,不用 region --> |
| | | <if test="keyword != null and keyword != ''"> |
| | | AND ( |
| | | HopsProvince LIKE '%' + #{keyword} + '%' |
| | | OR HopsCity LIKE '%' + #{keyword} + '%' |
| | | OR HopsArea LIKE '%' + #{keyword} + '%' |
| | | OR HospAddress LIKE '%' + #{keyword} + '%' |
| | | OR HospName LIKE '%' + #{keyword} + '%' |
| | | OR HospShort LIKE '%' + #{keyword} + '%' |
| | | hops_province LIKE CONCAT('%', #{keyword}, '%') |
| | | OR hops_city LIKE CONCAT('%', #{keyword}, '%') |
| | | OR hops_area LIKE CONCAT('%', #{keyword}, '%') |
| | | OR hosp_address LIKE CONCAT('%', #{keyword}, '%') |
| | | OR hosp_name LIKE CONCAT('%', #{keyword}, '%') |
| | | OR hosp_short LIKE CONCAT('%', #{keyword}, '%') |
| | | ) |
| | | </if> |
| | | <!-- 没有 keyword 时才用 region --> |
| | | <if test="(keyword == null or keyword == '') and (region != null and region != '')"> |
| | | AND ( |
| | | HopsProvince LIKE '%' + #{region} + '%' |
| | | OR HopsCity LIKE '%' + #{region} + '%' |
| | | OR HopsArea LIKE '%' + #{region} + '%' |
| | | OR HospAddress LIKE '%' + #{region} + '%' |
| | | OR HospName LIKE '%' + #{region} + '%' |
| | | OR HospShort LIKE '%' + #{region} + '%' |
| | | hops_province LIKE CONCAT('%', #{region}, '%') |
| | | OR hops_city LIKE CONCAT('%', #{region}, '%') |
| | | OR hops_area LIKE CONCAT('%', #{region}, '%') |
| | | OR hosp_address LIKE CONCAT('%', #{region}, '%') |
| | | OR hosp_name LIKE CONCAT('%', #{region}, '%') |
| | | OR hosp_short LIKE CONCAT('%', #{region}, '%') |
| | | ) |
| | | </if> |
| | | AND (HospState IS NULL OR HospState = 1) |
| | | ORDER BY HospName |
| | | AND (hosp_state IS NULL OR hosp_state = 1) |
| | | ORDER BY |
| | | CASE WHEN hosp_name = '家中' THEN 0 ELSE 1 END, |
| | | hosp_name |
| | | </select> |
| | | |
| | | <select id="selectHospDataById" parameterType="Integer" resultMap="HospDataResult"> |
| | | SELECT |
| | | HospID, HospName, HospCityID, HospShort, |
| | | HopsProvince, HopsCity, HopsArea, HospAddress, |
| | | HospTEL, HospUnitID, HospState, HospOAID, |
| | | HospIntroducerID, HospIntroducerDate, HospLevel |
| | | FROM HospData |
| | | WHERE HospID = #{hospId} |
| | | legacy_hosp_id, hosp_name, hosp_city_id, hosp_short, |
| | | hops_province, hops_city, hops_area, hosp_address, |
| | | hosp_tel, hosp_unit_id, hosp_state, hosp_oa_id, |
| | | hosp_introducer_id, hosp_introducer_date, hosp_level |
| | | FROM tb_hosp_data |
| | | WHERE legacy_hosp_id = #{hospId} |
| | | </select> |
| | | |
| | | |
| | | <select id="getHomeHospId" resultType="java.lang.Integer"> |
| | | select legacy_hosp_id from tb_hosp_data where hosp_name='家中' |
| | | </select> |
| | | |
| | | |
| | | <!-- 根据医院ID列表查询医院信息 --> |
| | | <select id="selectHospDataByIds" resultMap="HospDataResult"> |
| | | SELECT |
| | | legacy_hosp_id, hosp_name, hosp_city_id, hosp_short, |
| | | hops_province, hops_city, hops_area, hosp_address, |
| | | hosp_tel, hosp_unit_id, hosp_state, hosp_oa_id, |
| | | hosp_introducer_id, hosp_introducer_date, hosp_level |
| | | FROM tb_hosp_data |
| | | WHERE legacy_hosp_id IN |
| | | <foreach collection="hospIds" item="hospId" open="(" separator="," close=")"> |
| | | #{hospId} |
| | | </foreach> |
| | | <if test="region != null and region != ''"> |
| | | AND ( |
| | | hops_province LIKE CONCAT('%', #{region}, '%') |
| | | OR hops_city LIKE CONCAT('%', #{region}, '%') |
| | | OR hosp_short LIKE CONCAT('%', #{region}, '%') |
| | | OR hops_area LIKE CONCAT('%', #{region}, '%') |
| | | OR hosp_address LIKE CONCAT('%', #{region}, '%') |
| | | OR hosp_name LIKE CONCAT('%', #{region}, '%') |
| | | ) |
| | | </if> |
| | | AND (hosp_state IS NULL OR hosp_state = 1) |
| | | ORDER BY hosp_name |
| | | </select> |
| | | |
| | | <!-- 根据部门区域配置查询医院(支持多级区域过滤) --> |
| | | <select id="searchHospitalsByDeptRegion" resultMap="HospDataResult"> |
| | | SELECT DISTINCT |
| | | h.legacy_hosp_id, h.hosp_name, h.hosp_city_id, h.hosp_short, |
| | | h.hops_province, h.hops_city, h.hops_area, h.hosp_address, |
| | | h.hosp_tel, h.hosp_unit_id, h.hosp_state, h.hosp_oa_id, |
| | | h.hosp_introducer_id, h.hosp_introducer_date, h.hosp_level |
| | | FROM tb_hosp_data h |
| | | WHERE (h.hosp_state IS NULL OR h.hosp_state = 1) |
| | | AND h.status = '0' |
| | | AND EXISTS ( |
| | | SELECT 1 FROM sys_dept_region r |
| | | WHERE r.dept_id = #{deptId} |
| | | AND r.status = '0' |
| | | AND ( |
| | | -- 区域类型:地域范围匹配 |
| | | (r.region_type = 'AREA' AND ( |
| | | -- 省份匹配(为空则跳过) |
| | | (r.province IS NULL OR r.province = '' OR h.hops_province LIKE CONCAT('%', r.province, '%')) |
| | | -- 城市匹配(为空则跳过) |
| | | AND (r.city IS NULL OR r.city = '' OR h.hops_city LIKE CONCAT('%', r.city, '%')) |
| | | -- 县/区匹配(为空则跳过) |
| | | AND (r.area IS NULL OR r.area = '' OR h.hops_area LIKE CONCAT('%', r.area, '%')) |
| | | -- 详细地址匹配(为空则跳过) |
| | | AND (r.address IS NULL OR r.address = '' OR h.hosp_address LIKE CONCAT('%', r.address, '%')) |
| | | )) |
| | | -- 区域类型:指定医院匹配 |
| | | OR (r.region_type = 'HOSPITAL' AND r.hospital_name IS NOT NULL AND r.hospital_name != '' AND ( |
| | | h.hosp_name LIKE CONCAT('%', r.hospital_name, '%') |
| | | OR h.hosp_short LIKE CONCAT('%', r.hospital_name, '%') |
| | | )) |
| | | ) |
| | | ) |
| | | <!-- 关键词搜索 --> |
| | | <if test="keyword != null and keyword != ''"> |
| | | AND ( |
| | | h.hops_province LIKE CONCAT('%', #{keyword}, '%') |
| | | OR h.hops_city LIKE CONCAT('%', #{keyword}, '%') |
| | | OR h.hops_area LIKE CONCAT('%', #{keyword}, '%') |
| | | OR h.hosp_address LIKE CONCAT('%', #{keyword}, '%') |
| | | OR h.hosp_name LIKE CONCAT('%', #{keyword}, '%') |
| | | OR h.hosp_short LIKE CONCAT('%', #{keyword}, '%') |
| | | ) |
| | | </if> |
| | | ORDER BY |
| | | CASE WHEN h.hosp_name = '家中' THEN 0 ELSE 1 END, |
| | | h.hosp_name |
| | | </select> |
| | | </mapper> |