lin
2024-04-13 ea806c12de1e9760fc71d53e3a456b6137822845
轮播图过滤
4 files modified
82 ■■■■■ changed files
src/main/java/org/springblade/modules/district/mapper/DistrictMapper.xml 6 ●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/rotation/mapper/RotationMapper.xml 13 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/rotation/service/impl/RotationServiceImpl.java 3 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/system/service/impl/RegionServiceImpl.java 60 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/district/mapper/DistrictMapper.xml
@@ -61,7 +61,7 @@
        parent_code as parentId,
        name,
        remark aoiCode
        FROM blade_region where district_code = '361102000000'
        FROM blade_region where district_code like concat('361102','%')
        union all
        (
        select
@@ -70,10 +70,10 @@
        name,
        aoi_code aoiCode
        from jczz_district
        where is_deleted = 0
        where is_deleted = 0 and community_code like concat('361102','%')
        <if test="district.districtIdList!=null and district.districtIdList.size() > 0">
            and id in
            <foreach collection="district.districtIdList" item="item" separator ="," open="("  close=")">
            <foreach collection="district.districtIdList" item="item" separator="," open="(" close=")">
                #{item}
            </foreach>
        </if>
src/main/java/org/springblade/modules/rotation/mapper/RotationMapper.xml
@@ -39,15 +39,17 @@
            and jr.community_code like concat('%',#{rotation.regionCode},'%')
        </if>
        <if test="rotation.rotationRange != null  and rotation.rotationRange != ''"> and jr.rotation_range = #{rotation.rotationRange}</if>
        <if test="rotation.articleId != null "> and jr.article_id = #{rotation.articleId}</if>
        <if test="rotation.publicFlag != null "> and jr.public_flag = #{rotation.publicFlag}</if>
        <if test="rotation.rotationRange != null  and rotation.rotationRange != ''">and jr.rotation_range =
            #{rotation.rotationRange}
        </if>
        <if test="rotation.articleId != null ">and jr.article_id = #{rotation.articleId}</if>
        <if test="rotation.publicFlag != null ">and jr.public_flag = #{rotation.publicFlag}</if>
        <if test="rotation.districtIdList != null and rotation.districtIdList.size() > 0 ">
            and (jr.rotation_range like
            <foreach collection="rotation.districtIdList" separator=" or jr.rotation_range like" item="id">'%${id}%'
            </foreach>
            )
            ) or jr.rotation_range is null
        </if>
        <if test="isAdministrator==2">
@@ -79,6 +81,9 @@
                    </if>
                    <if test="rotation.roleName=='inhabitant'">
                        and jr.type = 3
                        <if test="rotation.districtIdList == null ">
                            and jr.rotation_range is null
                        </if>
                    </if>
                </when>
                <otherwise>
src/main/java/org/springblade/modules/rotation/service/impl/RotationServiceImpl.java
@@ -21,6 +21,7 @@
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.apache.commons.lang3.StringUtils;
import org.springblade.common.param.CommonParamSet;
import org.springblade.common.utils.AuthUtils;
import org.springblade.common.utils.RoleUtil;
import org.springblade.common.utils.SpringUtils;
import org.springblade.core.secure.utils.AuthUtil;
@@ -107,6 +108,8 @@
        if (rotationVOList.size() == 0) {
            // 如果没有对应的轮播图,则采用系统默认的
            rotation.setType(3);
            rotation.setPublicFlag(2);
            rotation.setDistrictIdList(null);
            rotationVOList = baseMapper.selectRotationPage(page,
                rotation,
                1,
src/main/java/org/springblade/modules/system/service/impl/RegionServiceImpl.java
@@ -25,6 +25,7 @@
import org.apache.logging.log4j.util.Strings;
import org.springblade.common.cache.SysCache;
import org.springblade.common.node.TreeStringNode;
import org.springblade.common.utils.AuthUtils;
import org.springblade.common.utils.NodeTreeUtil;
import org.springblade.core.log.exception.ServiceException;
import org.springblade.core.secure.utils.AuthUtil;
@@ -141,11 +142,11 @@
     */
    @Override
    public List<TreeStringNode> getTree(RegionParamVO region) {
        List<String> regionChildCodesList = SysCache.getRegionChildCodesByDeptId(AuthUtil.getDeptId(),null);
        Integer isAdministrator = AuthUtil.isAdministrator()==true?1:2;
        if (null!=region.getDeptNature()){
        List<String> regionChildCodesList = SysCache.getRegionChildCodesByDeptId(AuthUtil.getDeptId(), null);
        Integer isAdministrator = AuthUtils.isAdministratorOrAdmin(AuthUtil.getUserRole()) == true ? 1 : 2;
        if (null != region.getDeptNature()) {
            // 公安
            if (region.getDeptNature()==1){
            if (region.getDeptNature() == 1) {
                // 查询公安对应的辖区树
                return NodeTreeUtil.getStringNodeTree(baseMapper.getPoliceTreeList());
            }
@@ -155,7 +156,7 @@
            }
        }
        // 非公安
        return NodeTreeUtil.getStringNodeTree(baseMapper.getTreeList(region,regionChildCodesList,isAdministrator));
        return NodeTreeUtil.getStringNodeTree(baseMapper.getTreeList(region, regionChildCodesList, isAdministrator));
    }
    /**
@@ -167,7 +168,7 @@
    @Override
    public List<TreeStringNode> getTownTree(String code) {
        String regionCode = null;
        if (!AuthUtil.isAdministrator() && !AuthUtil.isAdmin()){
        if (!AuthUtil.isAdministrator() && !AuthUtil.isAdmin()) {
            Dept dept = deptService.getById(AuthUtil.getDeptId());
            if (null != dept) {
                regionCode = dept.getRegionCode();
@@ -199,21 +200,21 @@
        // 遍历处理
        for (Region region : regionList) {
            // 设置code
            region.setCode(StringUtils.rightPad(region.getCode(),12,"0"));
            region.setCode(StringUtils.rightPad(region.getCode(), 12, "0"));
            // 设置parent_code
            region.setParentCode(StringUtils.rightPad(region.getParentCode(),12,"0"));
            region.setParentCode(StringUtils.rightPad(region.getParentCode(), 12, "0"));
            // 设置Ancestors
            setAncestors(region);
            // 设置ProvinceCode
            region.setProvinceCode(StringUtils.rightPad(region.getProvinceCode(),12,"0"));
            region.setProvinceCode(StringUtils.rightPad(region.getProvinceCode(), 12, "0"));
            // 设置CityCode
            region.setCityCode(StringUtils.rightPad(region.getCityCode(),12,"0"));
            region.setCityCode(StringUtils.rightPad(region.getCityCode(), 12, "0"));
            // 设置DistrictCode
            region.setDistrictCode(StringUtils.rightPad(region.getDistrictCode(),12,"0"));
            region.setDistrictCode(StringUtils.rightPad(region.getDistrictCode(), 12, "0"));
            // 设置TownCode
            region.setTownCode(StringUtils.rightPad(region.getTownCode(),12,"0"));
            region.setTownCode(StringUtils.rightPad(region.getTownCode(), 12, "0"));
            // 设置VillageCode
            region.setVillageCode(StringUtils.rightPad(region.getVillageCode(),12,"0"));
            region.setVillageCode(StringUtils.rightPad(region.getVillageCode(), 12, "0"));
            // 更新
            updateById(region);
        }
@@ -221,34 +222,36 @@
    /**
     * Ancestors 字段处理
     *
     * @param region
     */
    private void setAncestors(Region region) {
        String[] split = region.getAncestors().split(",");
        List<String> list = new ArrayList<>();
        for (String s : split) {
            list.add(StringUtils.rightPad(s,12,"0"));
            list.add(StringUtils.rightPad(s, 12, "0"));
        }
        region.setAncestors(Strings.join(list, ','));
    }
    /**
     * 查询下级区域(拼接网格)
     *
     * @param regionCode
     * @return
     */
    @Override
    public List<Region> getRegionChild(String regionCode,String communityCode) {
    public List<Region> getRegionChild(String regionCode, String communityCode) {
        // 创建区域对象
        List<Region> list = new ArrayList<>();
        // 查询公安相关的区域数据
        List<Region> regionList = baseMapper.getPoliceList(communityCode);
        if (regionList.size()>0) {
            List<Region> policeList = treeRegionList(regionList,regionCode, list);
        if (regionList.size() > 0) {
            List<Region> policeList = treeRegionList(regionList, regionCode, list);
            list.addAll(policeList);
        }
        // 查询综治区域集合
        List<Region> regionChildList = baseMapper.getRegionChildList(regionCode,null,null);
        List<Region> regionChildList = baseMapper.getRegionChildList(regionCode, null, null);
        list.addAll(regionChildList);
        //  返回
        return list;
@@ -256,17 +259,18 @@
    /**
     * 获取民警下级区域
     *
     * @param regionCode
     * @return
     */
    @Override
    public List<Region> getPoliceRegionChild(String regionCode,String communityCode) {
    public List<Region> getPoliceRegionChild(String regionCode, String communityCode) {
        // 创建区域对象
        List<Region> list = new ArrayList<>();
        // 查询公安相关的区域数据
        List<Region> regionList = baseMapper.getPoliceList(communityCode);
        if (regionList.size()>0) {
            List<Region> policeList = treeRegionList(regionList,regionCode, list);
        if (regionList.size() > 0) {
            List<Region> policeList = treeRegionList(regionList, regionCode, list);
            list.addAll(policeList);
        }
        //  返回
@@ -275,6 +279,7 @@
    /**
     * 获取综治下级区域
     *
     * @param regionCode
     * @return
     */
@@ -282,7 +287,7 @@
    public List<Region> getGridRegionChild(String regionCode, String communityCode, String roleName) {
        // 创建区域对象
        List<Region> list = new ArrayList<>();
        if (!Strings.isBlank(roleName) && roleName.equals("wgy")){
        if (!Strings.isBlank(roleName) && roleName.equals("wgy")) {
            // 查询综治区域集合
            List<Region> regionChildList = baseMapper.getGridRegionChildList(regionCode);
            list.addAll(regionChildList);
@@ -293,7 +298,7 @@
                List<Region> policeList = treeRegionList(regionList,regionCode, list);
                list.addAll(policeList);
            }
        }else {
        } else {
            // 查询综治区域集合
            List<Region> regionChildList = baseMapper.getRegionChildList(regionCode, communityCode, roleName);
            list.addAll(regionChildList);
@@ -304,18 +309,19 @@
    /**
     * 获取某个父节点下面的所有子节点
     *
     * @param regionList
     * @param parentCode
     * @param list
     * @return
     */
    public static List<Region> treeRegionList( List<Region> regionList, String parentCode,List<Region> list){
        for(Region region: regionList){
    public static List<Region> treeRegionList(List<Region> regionList, String parentCode, List<Region> list) {
        for (Region region : regionList) {
            //遍历出父id等于参数的id,add进子节点集合
            if(region.getParentCode().equals(parentCode)){
            if (region.getParentCode().equals(parentCode)) {
                list.add(region);
                //递归遍历下一级
                treeRegionList(regionList,region.getCode(),list);
                treeRegionList(regionList, region.getCode(), list);
            }
            if(region.getCode().equals(parentCode)){
                // 本身也加入