Commit f1e1cf19 authored by zhangch's avatar zhangch

优化省市区数据加载问题,增加树形结构返回数据以及一次性返回全部数据接口

parent 78baaeee
......@@ -4,6 +4,7 @@ import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.hungraim.ltc.pojo.vo.disable.DisableExamineInfoVO;
import com.hungraim.ltc.pojo.vo.disable.DisableVO;
import com.hungraim.ltc.pojo.vo.disable.DistrictTreeVo;
import com.hungraim.ltc.service.DisableService;
import com.hungraim.ltc.pojo.entity.disable.*;
import com.hungraim.ltc.util.Result;
......@@ -41,6 +42,28 @@ public class DisableController {
}
/**
* 获取所有省市区街道数据
*
* @return 返回树形结构省市区数据
*/
@RequestMapping("/allDistrict")
public Result allDistrict() {
List<DistrictTreeVo> districtTreeVos = disableService.allDistrict();
return Result.success(districtTreeVos);
}
/**
* 获取所有省市区街道数据,以树形结构返回
*
* @return 返回树形结构省市区数据
*/
@RequestMapping("/allTreeDistrict")
public Result allTreeDistrict() {
List<DistrictTreeVo> districtTreeVos = disableService.getAllDistrictTreeData();
return Result.success(districtTreeVos);
}
/**
* 查询所有父机构
*/
@RequestMapping("/fndOrganRoot")
......@@ -84,7 +107,7 @@ public class DisableController {
* 查询护理机构下所有子机构id
*
* @param organId 机构id
* @return 机构及所有子机构id,以逗号分隔,如果没有子机构则只返回机构id
* @return 机构及所有子机构id, 以逗号分隔, 如果没有子机构则只返回机构id
*/
@RequestMapping("/subsidiariesOrganId")
public Result<String> subsidiariesOrganId(String organId) {
......
......@@ -2,9 +2,13 @@ package com.hungraim.ltc.dao;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.hungraim.ltc.pojo.entity.disable.ChFndDistrict;
import com.hungraim.ltc.pojo.vo.disable.DistrictTreeVo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;
import java.util.List;
/**
* 省市区Mapper
*
......@@ -13,4 +17,32 @@ import org.springframework.stereotype.Repository;
@Mapper
@Repository
public interface FndDistrictMapper extends BaseMapper<ChFndDistrict> {
/**
* 获取所有地区的树形结构数据
*
* @return 返回树形结构数据
*/
List<DistrictTreeVo> getAllDistrictTreeData();
/**
* 根据parentCode查询节点
*
* @return 返回节点列表
*/
List<DistrictTreeVo> getAreaChildByParentCode(@Param("districtCode") String districtCode, @Param("districtLevel") Integer districtLevel);
/**
* 根据parendtCode查询街道数据
*
* @return 返回节点列表
*/
List<DistrictTreeVo> getStreetList(@Param("districtCode") String districtCode);
/**
* 一次性加载出所有的数据,包括街道数据
*
* @return 返回数据列表
*/
List<DistrictTreeVo> getAllDistrictAndStreetData();
}
......@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.hungraim.ltc.pojo.vo.disable.DisableExamineInfoVO;
import com.hungraim.ltc.pojo.vo.disable.DisableVO;
import com.hungraim.ltc.pojo.entity.disable.*;
import com.hungraim.ltc.pojo.vo.disable.DistrictTreeVo;
import org.springframework.stereotype.Service;
import java.util.List;
......@@ -80,9 +81,23 @@ public interface DisableService {
* 查询护理机构下所有子机构id
*
* @param organId 机构id
* @return 机构及所有子机构id,以逗号分隔,如果没有子机构则只返回机构id
* @return 机构及所有子机构id, 以逗号分隔, 如果没有子机构则只返回机构id
*/
String subsidiariesOrganId(String organId);
void updateDisable(ChDisableApply chDisableApply);
/**
* 获取所有省市区街道数据
*
* @return 返回树形结构省市区数据
*/
List<DistrictTreeVo> allDistrict();
/**
* 获取所有省市区街道数据,以树形结构返回
*
* @return 返回树形结构省市区数据
*/
List<DistrictTreeVo> getAllDistrictTreeData();
}
......@@ -9,6 +9,7 @@ import com.hungraim.ltc.pojo.entity.assessment.ChAprTask;
import com.hungraim.ltc.pojo.entity.disable.*;
import com.hungraim.ltc.pojo.vo.disable.DisableExamineInfoVO;
import com.hungraim.ltc.pojo.vo.disable.DisableVO;
import com.hungraim.ltc.pojo.vo.disable.DistrictTreeVo;
import com.hungraim.ltc.pojo.vo.disable.ExamineRecord;
import com.hungraim.ltc.service.DisableService;
import org.apache.commons.lang.StringUtils;
......@@ -206,4 +207,14 @@ public class DisableServiceImpl implements DisableService {
public void updateDisable(ChDisableApply chDisableApply) {
disableApplyMapper.updateById(chDisableApply);
}
@Override
public List<DistrictTreeVo> allDistrict() {
return districtMapper.getAllDistrictAndStreetData();
}
@Override
public List<DistrictTreeVo> getAllDistrictTreeData() {
return districtMapper.getAllDistrictTreeData();
}
}
\ No newline at end of file
<?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.hungraim.ltc.dao.FndDistrictMapper">
<resultMap id="areawithChildMap" type="com.hungraim.ltc.pojo.vo.disable.DistrictTreeVo">
<id column="DISTRICT_CODE" property="districtCode"/>
<result column="DISTRICT_LEVEL" property="districtLevel"/>
<result column="DISTRICT_NAME" property="districtName"/>
<result column="PARENT_DISTIRCT_CODE" property="parentDistrictCode"/>
<collection property="childDistrict" column="{districtCode=DISTRICT_CODE,districtLevel=DISTRICT_LEVEL}"
select="com.hungraim.ltc.dao.FndDistrictMapper.getAreaChildByParentCode">
</collection>
<collection property="childStreet" column="DISTRICT_CODE"
select="com.hungraim.ltc.dao.FndDistrictMapper.getStreetList">
</collection>
</resultMap>
<resultMap id="streetMap" type="com.hungraim.ltc.pojo.vo.disable.DistrictTreeVo">
<id column="STREET_CODE" property="districtCode"/>
<result column="STREET_NAME" property="districtName"/>
<result column="AREA_CODE" property="parentDistrictCode"/>
</resultMap>
<sql id="Base_column">
DISTRICT_CODE,DISTRICT_LEVEL,DISTRICT_NAME,PARENT_DISTIRCT_CODE
</sql>
<select id="getAreaChildByParentCode" resultMap="areawithChildMap">
SELECT
<include refid="Base_column"/>
FROM CH_FND_DISTRICT
WHERE PARENT_DISTIRCT_CODE = #{districtCode} AND DISTRICT_LEVEL = #{districtLevel} + 1 AND IS_VALID = 'Y'
</select>
<select id="getAllDistrictTreeData" resultMap="areawithChildMap">
SELECT
<include refid="Base_column"/>
FROM CH_FND_DISTRICT WHERE PARENT_DISTIRCT_CODE IS NULL AND IS_VALID = 'Y' AND DISTRICT_LEVEL = 1
</select>
<select id="getStreetList" resultMap="streetMap">
SELECT *
FROM CH_FND_STREET
WHERE AREA_CODE = #{districtCode}
AND IS_VALID = 0
</select>
<select id="getAllDistrictAndStreetData" resultType="com.hungraim.ltc.pojo.vo.disable.DistrictTreeVo">
SELECT DISTRICT_CODE districtCode,
DISTRICT_LEVEL districtLevel,
DISTRICT_NAME districtName,
PARENT_DISTIRCT_CODE parentDistrictCode
FROM CH_FND_DISTRICT
WHERE IS_VALID = 'Y'
UNION
SELECT STREET_CODE districtCode,
NULL districtLevel,
STREET_NAME districtName,
AREA_CODE parentDistrictCode
FROM CH_FND_STREET
WHERE IS_VALID = 0
</select>
</mapper>
\ No newline at end of file
package com.hungraim.ltc.pojo.vo.disable;
import lombok.Data;
import java.util.List;
@Data
public class DistrictTreeVo {
/**
* 区域code
*/
private String districtCode;
/**
* 区域级别:1省2地级市3县4街道
*/
private Integer districtLevel = 4;
/**
* 区域名称
*/
private String districtName;
/**
* 父级id
*/
private String parentDistrictCode;
/**
* 省市区子节点
*/
private List<DistrictTreeVo> childDistrict;
/**
* 街道子节点
*/
private List<DistrictTreeVo> childStreet;
}
......@@ -78,6 +78,7 @@ public class SvrProgramListVo {
/**
* 创建时间(分配时间)
*/
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date effTime;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment