zhongrj
2023-11-17 bc670e87f764e250a54b1687dedbe0df135b411f
房屋树查询新增,房屋,住户,租赁查询修改
26 files modified
5 files renamed
1 files added
642 ■■■■ changed files
src/main/java/org/springblade/common/utils/NodeTreeUtil.java 41 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/doorplateAddress/controller/DoorplateAddressController.java 19 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/doorplateAddress/mapper/DoorplateAddressMapper.java 17 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/doorplateAddress/mapper/DoorplateAddressMapper.xml 65 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/doorplateAddress/service/IDoorplateAddressService.java 13 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/doorplateAddress/service/impl/DoorplateAddressServiceImpl.java 113 ●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/doorplateAddress/vo/DoorplateAddressVOTree.java 2 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/house/controller/HouseController.java 34 ●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/house/controller/HouseRentalController.java 5 ●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/house/controller/HouseholdController.java 6 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/house/entity/HouseEntity.java 2 ●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/house/excel/HouseExcel.java 8 ●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/house/excel/HouseHoldExcel.java 2 ●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/house/excel/HouseHoldImporter.java 2 ●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/house/excel/HouseImporter.java 4 ●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/house/excel/HouseRentalExcel.java 2 ●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/house/mapper/HouseMapper.java 16 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/house/mapper/HouseMapper.xml 122 ●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/house/mapper/HouseRentalMapper.java 3 ●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/house/mapper/HouseRentalMapper.xml 21 ●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/house/mapper/HouseholdMapper.java 4 ●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/house/mapper/HouseholdMapper.xml 24 ●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/house/service/IHouseRentalService.java 4 ●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/house/service/IHouseService.java 13 ●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/house/service/IHouseholdService.java 2 ●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/house/service/impl/HouseRentalServiceImpl.java 4 ●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/house/service/impl/HouseServiceImpl.java 49 ●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/house/service/impl/HouseholdServiceImpl.java 2 ●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/house/vo/HouseRentalTenantVO.java 5 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/house/vo/HouseTree.java 23 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/house/vo/HouseVO.java 5 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/house/vo/HouseholdVO.java 10 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/common/utils/NodeTreeUtil.java
@@ -2,6 +2,9 @@
import org.springblade.common.node.TreeIntegerNode;
import org.springblade.common.node.TreeNode;
import org.springblade.modules.doorplateAddress.vo.DoorplateAddressVOTree;
import org.springblade.modules.house.vo.HouseTree;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
@@ -31,4 +34,42 @@
        }
        return tree;
    }
    /**
     * 树转换
     * @param treeMap
     * @return
     */
    public static List<DoorplateAddressVOTree> getAddressNodeTree(Map<String, DoorplateAddressVOTree> treeMap){
        List<DoorplateAddressVOTree> tree = new ArrayList<>();
        if (treeMap.size() > 1) {
            treeMap.forEach((code, treeNode) -> {
                if (treeMap.containsKey(treeNode.getParentCode())) {
                    treeMap.get(treeNode.getParentCode()).getChildren().add(treeNode);
                } else {
                    tree.add(treeNode);
                }
            });
        }
        return tree;
    }
    /**
     * 树转换
     * @param treeMap
     * @return
     */
    public static List<HouseTree> getHouseTree(Map<String, HouseTree> treeMap){
        List<HouseTree> tree = new ArrayList<>();
        if (treeMap.size() > 1) {
            treeMap.forEach((code, treeNode) -> {
                if (treeMap.containsKey(treeNode.getParentCode())) {
                    treeMap.get(treeNode.getParentCode()).getChildren().add(treeNode);
                } else {
                    tree.add(treeNode);
                }
            });
        }
        return tree;
    }
}
src/main/java/org/springblade/modules/doorplateAddress/controller/DoorplateAddressController.java
@@ -180,6 +180,16 @@
    }
    /**
     * 获取房屋树--数据有问题暂时不用2023/11/16
     * @param houseParam
     * @return
     */
    @GetMapping("/getHouseTree")
    public R getHouseTree(HouseParam houseParam){
        return R.data(doorplateAddressService.getHouseTree(houseParam));
    }
    /**
     * 根据参数获取地址详情
     * @return
     */
@@ -189,4 +199,13 @@
        return R.data(detail);
    }
    /**
     * 数据处理
     * @return
     */
    @GetMapping("/dataHandle")
    public R dataHandle(){
        return R.data(doorplateAddressService.dataHandle());
    }
}
src/main/java/org/springblade/modules/doorplateAddress/mapper/DoorplateAddressMapper.java
@@ -20,6 +20,7 @@
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import liquibase.pro.packaged.P;
import org.apache.ibatis.annotations.MapKey;
import org.apache.ibatis.annotations.Param;
import org.springblade.common.node.TreeNode;
import org.springblade.modules.doorplateAddress.entity.DoorplateAddressEntity;
@@ -29,6 +30,7 @@
import org.springblade.modules.house.vo.HouseParam;
import java.util.List;
import java.util.Map;
/**
 * 门牌地址表(总台账数据) Mapper 接口
@@ -147,4 +149,19 @@
     * @return
     */
    List<DoorplateAddressEntity> getAllDoorplateAddress(@Param("name") String name);
    /**
     * 获取房屋树
     * @param houseParam
     * @param list
     * @return
     */
    @MapKey("code")
    Map<String, DoorplateAddressVOTree> getHouseTree(@Param("houseParam") HouseParam houseParam,
                                                     @Param("list") List<String> list);
    /**
     * 查询所有户室数据
     * @return
     */
    List<DoorplateAddressEntity> getHouseList();
}
src/main/java/org/springblade/modules/doorplateAddress/mapper/DoorplateAddressMapper.xml
@@ -260,4 +260,69 @@
        select * from jczz_doorplate_address where nei_name = #{name}
    </select>
    <!--获取房屋树-->
    <select id="getHouseTree" resultType="org.springblade.modules.doorplateAddress.vo.DoorplateAddressVOTree">
        SELECT
        aoi_code as code,
        aoi_name as name,
        nei_code as parentCode
        FROM jczz_doorplate_address
        WHERE nei_code = #{houseParam.code}
        and aoi_code is not null and aoi_code !=''
        and aoi_name is not null and aoi_name !=''
        GROUP BY aoi_code,aoi_name,nei_code
        <include refid="filterHouseGrid"/>
        union all
        (
        SELECT
        building_code as code,
        building_name as name,
        aoi_code as parentCode
        FROM jczz_doorplate_address
        WHERE nei_code = #{houseParam.code}
          and building_code is not null and building_code !=''
          and building_name is not null and building_name !=''
          GROUP BY building_code,building_name,aoi_code
        <include refid="filterHouseGrid"/>
        )
        union all
        (
        select
        jda.unit_code as code,
        ifnull(jda.unit_name,"一单元") name,
        jda.building_code as parentCode
        from jczz_doorplate_address jda
        where 1=1
        and floor != ''
        and house_name != ''
        and doorplate_type = '户室牌'
        and nei_code = #{houseParam.code}
        <include refid="filterHouseGrid"/>
        group by unit_name,unit_code,building_code
        )
        union all
        (
        select
        jda.address_code as code,
        jda.house_name as name,
        jda.unit_code as parentCode
        from jczz_doorplate_address jda
        where 1=1
        and floor != ''
        and house_name != ''
        and doorplate_type = '户室牌'
        and nei_code = #{houseParam.code}
        <include refid="filterHouseGrid"/>
        )
    </select>
    <!--查询所有户室数据-->
    <select id="getHouseList" resultType="org.springblade.modules.doorplateAddress.entity.DoorplateAddressEntity">
        select * from jczz_doorplate_address
        where 1=1 and doorplate_type = '户室牌'
        and address_code not in (
            select house_code from jczz_house
        )
    </select>
</mapper>
src/main/java/org/springblade/modules/doorplateAddress/service/IDoorplateAddressService.java
@@ -85,4 +85,17 @@
     * @return
     */
    List<DoorplateAddressEntity> getAllDoorplateAddress(String name);
    /**
     * 获取房屋树
     * @param houseParam
     * @return
     */
    List<DoorplateAddressVOTree> getHouseTree(HouseParam houseParam);
    /**
     * 数据处理
     * @return
     */
    Object dataHandle();
}
src/main/java/org/springblade/modules/doorplateAddress/service/impl/DoorplateAddressServiceImpl.java
@@ -16,12 +16,14 @@
 */
package org.springblade.modules.doorplateAddress.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import liquibase.repackaged.org.apache.commons.lang3.StringUtils;
import org.springblade.common.constant.DictConstant;
import org.springblade.common.node.TreeNode;
import org.springblade.common.utils.NodeTreeUtil;
import org.springblade.core.secure.utils.AuthUtil;
import org.springblade.modules.doorplateAddress.entity.DoorplateAddressEntity;
import org.springblade.modules.doorplateAddress.mapper.DoorplateAddressMapper;
@@ -30,7 +32,9 @@
import org.springblade.modules.doorplateAddress.vo.DoorplateAddressVOTree;
import org.springblade.modules.doorplateAddress.vo.FuncNode;
import org.springblade.modules.grid.service.IGridService;
import org.springblade.modules.house.entity.HouseEntity;
import org.springblade.modules.house.service.IHouseRentalService;
import org.springblade.modules.house.service.IHouseService;
import org.springblade.modules.house.service.IHouseholdService;
import org.springblade.modules.house.vo.HouseParam;
import org.springblade.modules.house.vo.HouseRentalVO;
@@ -53,6 +57,9 @@
    @Autowired
    private IPlaceService placeService;
    @Autowired
    private IHouseService houseService;
    @Autowired
    private IHouseholdService householdService;
@@ -183,13 +190,7 @@
    public Object getHousesList(HouseParam houseParam) {
        List<TreeNode> list = new ArrayList<>();
        Map<String, Object> map = new HashMap<>(2);
        List<String> stringList = new ArrayList<>();
        if (null!=houseParam.getRoleName() && !houseParam.getRoleName().equals("")){
            if (houseParam.getRoleName().equals("网格员")){
                // 查询对应的房屋地址code
                stringList = gridService.getAddressCodeListByUserId(AuthUtil.getUserId());
            }
        }
        List<String> stringList = getHouseCodeList(houseParam);
        // 查小区,场所
        if (houseParam.getType()==1){
            // 根据社区名称查询小区集合
@@ -213,13 +214,7 @@
     * @return
     */
    private Map<String, Object> getHouseLevelData(HouseParam houseParam, Map<String, Object> map) {
        List<String> stringList = new ArrayList<>();
        if (null!=houseParam.getRoleName() && !houseParam.getRoleName().equals("")){
            if (houseParam.getRoleName().equals("网格员")){
                // 查询对应的房屋地址code
                stringList = gridService.getAddressCodeListByUserId(AuthUtil.getUserId());
            }
        }
        List<String> stringList = getHouseCodeList(houseParam);
        // 判断地址类型
        if (houseParam.getAddressType()==1) {
            List<FuncNode> aoiList = new ArrayList<>();
@@ -258,13 +253,7 @@
     * @return
     */
    private Object getBuildLevelData(HouseParam houseParam,Map<String, Object> map) {
        List<String> stringList = new ArrayList<>();
        if (null!=houseParam.getRoleName() && !houseParam.getRoleName().equals("")){
            if (houseParam.getRoleName().equals("网格员")){
                // 查询对应的房屋地址code
                stringList = gridService.getAddressCodeListByUserId(AuthUtil.getUserId());
            }
        }
        List<String> stringList = getHouseCodeList(houseParam);
        // 判断 code 长度,如果 code 长度大于 12 则为小区查楼栋/商铺,否则则按社区查街路巷
        if (houseParam.getCode().length()>12){
            List<TreeNode> aoiList = new ArrayList<>();
@@ -300,8 +289,8 @@
    /**
     * 查询户室及住户相关信息,单元中包含住户
     * @param name
     * @param code
     * @param houseParam
     * @param stringList
     * @return
     */
    private List<FuncNode> getUnitHouseholdList(HouseParam houseParam,List<String> stringList) {
@@ -479,4 +468,82 @@
    public List<DoorplateAddressEntity> getAllDoorplateAddress(String name) {
        return baseMapper.getAllDoorplateAddress(name);
    }
    /**
     * 获取房屋树
     * @param houseParam
     * @return
     */
    @Override
    public List<DoorplateAddressVOTree> getHouseTree(HouseParam houseParam) {
        List<String> stringList = getHouseCodeList(houseParam);
        // 根据社区居委会编号获取对应的小区/楼栋/单元/户室
        return NodeTreeUtil.getAddressNodeTree(baseMapper.getHouseTree(houseParam,stringList));
    }
    /**
     * 根据角色获取地址编号集合
     * @param houseParam
     * @return
     */
    private List<String> getHouseCodeList(HouseParam houseParam) {
        List<String> stringList = new ArrayList<>();
        if (null != houseParam.getRoleName() && !houseParam.getRoleName().equals("")) {
            if (houseParam.getRoleName().equals("网格员")) {
                // 查询对应的房屋地址code
                stringList = gridService.getAddressCodeListByUserId(AuthUtil.getUserId());
            }
        }
        return stringList;
    }
    /**
     * 数据处理
     * @return
     */
    @Override
    public Object dataHandle() {
        // 处理户室数据
        handleHouseData();
        return null;
    }
    /**
     * 处理房屋数据
     */
    private void handleHouseData() {
        // 查询所有户室数据
        List<DoorplateAddressEntity> list = baseMapper.getHouseList();
        // 需要新增的房屋 list
        List<HouseEntity> houseList = new ArrayList<>();
        // 处理户室数据
        for (DoorplateAddressEntity doorplateAddressEntity : list) {
            // 查询是否已存在,存在就插入,不存在则插入
            QueryWrapper<HouseEntity> wrapper = new QueryWrapper<>();
            wrapper.eq("house_code",doorplateAddressEntity.getAddressCode())
                .eq("is_deleted",0);
            HouseEntity one = houseService.getOne(wrapper);
            if (null==one){
                HouseEntity houseEntity = new HouseEntity();
                houseEntity.setHouseCode(doorplateAddressEntity.getAddressCode());
                houseEntity.setDistrictCode(doorplateAddressEntity.getAoiCode());
                houseEntity.setDistrictName(doorplateAddressEntity.getAoiName());
                houseEntity.setHouseName(doorplateAddressEntity.getAddressName());
                houseEntity.setFloor(Integer.parseInt(doorplateAddressEntity.getFloor()));
                houseEntity.setBuilding(doorplateAddressEntity.getBuildingName());
                houseEntity.setUnit(doorplateAddressEntity.getUnitName());
                houseEntity.setRoom(doorplateAddressEntity.getHouseName());
                houseEntity.setBuildingNo(doorplateAddressEntity.getBuildingCode());
                houseEntity.setCreateUser(AuthUtil.getUserId().toString());
                houseEntity.setCreateTime(new Date());
                houseEntity.setUpdateUser(AuthUtil.getUserId().toString());
                houseEntity.setUpdateTime(new Date());
                // 加入集合
                houseList.add(houseEntity);
            }
        }
        // 批量插入
        houseService.saveBatch(houseList);
    }
}
src/main/java/org/springblade/modules/doorplateAddress/vo/DoorplateAddressVOTree.java
@@ -20,6 +20,8 @@
    private String code;
    private String parentCode;
    private List<DoorplateAddressVOTree> children;
}
src/main/java/org/springblade/modules/house/controller/HouseController.java
@@ -26,15 +26,16 @@
import javax.validation.Valid;
import org.springblade.core.excel.util.ExcelUtil;
import org.springblade.core.secure.BladeUser;
import org.springblade.core.mp.support.Condition;
import org.springblade.core.mp.support.Query;
import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.DateUtil;
import org.springblade.core.tool.utils.Func;
import org.springblade.modules.house.vo.HouseholdVO;
import org.springblade.modules.system.excel.HouseExcel;
import org.springblade.modules.system.excel.HouseHoldExcel;
import org.springblade.modules.house.excel.HouseImporter;
import org.springblade.modules.house.vo.HouseParam;
import org.springblade.modules.house.excel.HouseExcel;
import org.springblade.modules.system.excel.UserExcel;
import org.springblade.modules.system.excel.UserImporter;
import org.springframework.web.bind.annotation.*;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.springblade.modules.house.entity.HouseEntity;
@@ -42,6 +43,7 @@
import org.springblade.modules.house.wrapper.HouseWrapper;
import org.springblade.modules.house.service.IHouseService;
import org.springblade.core.boot.ctrl.BladeController;
import org.springframework.web.multipart.MultipartFile;
import java.util.List;
@@ -157,15 +159,35 @@
    /**
     * 导出用户
     * 导出房屋
     */
    @GetMapping("export-house")
    @ApiOperationSupport(order = 13)
    @ApiOperation(value = "导出房屋", notes = "传入user")
    public void exportUser(HouseVO household, HttpServletResponse response) {
    public void exportHouse(HouseVO household, HttpServletResponse response) {
        List<HouseExcel> list = houseService.export(household);
        ExcelUtil.export(response, "房屋数据" + DateUtil.time(), "房屋数据表", list, HouseExcel.class);
    }
    /**
     * 导入房屋
     */
    @GetMapping("import-house")
    public R importHouse(MultipartFile file, Integer isCovered) {
        HouseImporter houseImporter = new HouseImporter(houseService, isCovered == 1);
        ExcelUtil.save(file, houseImporter, HouseExcel.class);
        return R.success("操作成功");
    }
    /**
     * 查询房屋树
     * @param houseParam
     * @return
     */
    @GetMapping("/getHouseTree")
    public R getHouseTree(HouseParam houseParam) {
        return R.data(houseService.getHouseTree(houseParam));
    }
}
src/main/java/org/springblade/modules/house/controller/HouseRentalController.java
@@ -26,7 +26,6 @@
import javax.validation.Valid;
import org.springblade.core.excel.util.ExcelUtil;
import org.springblade.core.secure.BladeUser;
import org.springblade.core.mp.support.Condition;
import org.springblade.core.mp.support.Query;
import org.springblade.core.secure.utils.AuthUtil;
@@ -34,9 +33,7 @@
import org.springblade.core.tool.utils.DateUtil;
import org.springblade.core.tool.utils.Func;
import org.springblade.modules.house.vo.HouseRentalTenantVO;
import org.springblade.modules.house.vo.HouseVO;
import org.springblade.modules.system.excel.HouseExcel;
import org.springblade.modules.system.excel.HouseRentalExcel;
import org.springblade.modules.house.excel.HouseRentalExcel;
import org.springframework.web.bind.annotation.*;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.springblade.modules.house.entity.HouseRentalEntity;
src/main/java/org/springblade/modules/house/controller/HouseholdController.java
@@ -31,10 +31,8 @@
import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.DateUtil;
import org.springblade.core.tool.utils.Func;
import org.springblade.modules.system.excel.UserExcel;
import org.springblade.modules.system.excel.HouseHoldExcel;
import org.springblade.modules.system.excel.HouseHoldImporter;
import org.springblade.modules.system.excel.UserImporter;
import org.springblade.modules.house.excel.HouseHoldExcel;
import org.springblade.modules.house.excel.HouseHoldImporter;
import org.springframework.web.bind.annotation.*;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.springblade.modules.house.entity.HouseholdEntity;
src/main/java/org/springblade/modules/house/entity/HouseEntity.java
@@ -119,7 +119,7 @@
     * 幢编号
     */
    @ApiModelProperty(value = "幢编号")
    private Integer buildingNo;
    private String buildingNo;
    /**
     * 图片URLS
     */
src/main/java/org/springblade/modules/house/excel/HouseExcel.java
File was renamed from src/main/java/org/springblade/modules/system/excel/HouseExcel.java
@@ -1,4 +1,4 @@
package org.springblade.modules.system.excel;
package org.springblade.modules.house.excel;
import com.alibaba.excel.annotation.ExcelProperty;
import com.alibaba.excel.annotation.write.style.ColumnWidth;
@@ -12,7 +12,7 @@
import java.util.Date;
/**
 * UserExcel
 * HouseExcel
 *
 * @author Chill
 */
@@ -23,10 +23,6 @@
public class HouseExcel implements Serializable {
    private static final long serialVersionUID = 2L;
    /** 主键id */
    @ExcelProperty( "主键ID")
    private Long id;
    /** 门牌地址编码 */
    @ExcelProperty( "门牌地址编码")
src/main/java/org/springblade/modules/house/excel/HouseHoldExcel.java
File was renamed from src/main/java/org/springblade/modules/system/excel/HouseHoldExcel.java
@@ -1,4 +1,4 @@
package org.springblade.modules.system.excel;
package org.springblade.modules.house.excel;
import com.alibaba.excel.annotation.ExcelIgnore;
import com.alibaba.excel.annotation.ExcelProperty;
src/main/java/org/springblade/modules/house/excel/HouseHoldImporter.java
File was renamed from src/main/java/org/springblade/modules/system/excel/HouseHoldImporter.java
@@ -14,7 +14,7 @@
 *  this software without specific prior written permission.
 *  Author: Chill 庄骞 (smallchill@163.com)
 */
package org.springblade.modules.system.excel;
package org.springblade.modules.house.excel;
import lombok.RequiredArgsConstructor;
import org.springblade.core.excel.support.ExcelImporter;
src/main/java/org/springblade/modules/house/excel/HouseImporter.java
File was renamed from src/main/java/org/springblade/modules/system/excel/HouseImporter.java
@@ -14,12 +14,12 @@
 *  this software without specific prior written permission.
 *  Author: Chill 庄骞 (smallchill@163.com)
 */
package org.springblade.modules.system.excel;
package org.springblade.modules.house.excel;
import lombok.RequiredArgsConstructor;
import org.springblade.core.excel.support.ExcelImporter;
import org.springblade.modules.house.excel.HouseExcel;
import org.springblade.modules.house.service.IHouseService;
import org.springblade.modules.house.service.IHouseholdService;
import java.util.List;
src/main/java/org/springblade/modules/house/excel/HouseRentalExcel.java
File was renamed from src/main/java/org/springblade/modules/system/excel/HouseRentalExcel.java
@@ -1,4 +1,4 @@
package org.springblade.modules.system.excel;
package org.springblade.modules.house.excel;
import com.alibaba.excel.annotation.ExcelProperty;
import com.alibaba.excel.annotation.write.style.ColumnWidth;
src/main/java/org/springblade/modules/house/mapper/HouseMapper.java
@@ -16,14 +16,18 @@
 */
package org.springblade.modules.house.mapper;
import org.apache.ibatis.annotations.MapKey;
import org.apache.ibatis.annotations.Param;
import org.springblade.modules.house.entity.HouseEntity;
import org.springblade.modules.house.vo.HouseParam;
import org.springblade.modules.house.vo.HouseTree;
import org.springblade.modules.house.vo.HouseVO;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.springblade.modules.system.excel.HouseExcel;
import org.springblade.modules.house.excel.HouseExcel;
import java.util.List;
import java.util.Map;
/**
 * 房屋 Mapper 接口
@@ -50,4 +54,14 @@
    HouseVO getHouseDetail(@Param("house") HouseVO house);
    List<HouseExcel> export(HouseVO household);
    /**
     * 查询房屋树
     * @param houseParam
     * @param list
     * @return
     */
    @MapKey(value = "code")
    Map<String, HouseTree> getHouseTree(@Param("houseParam") HouseParam houseParam,
                                        @Param("list") List<String> list);
}
src/main/java/org/springblade/modules/house/mapper/HouseMapper.xml
@@ -27,6 +27,25 @@
        <result column="is_deleted" property="isDeleted"/>
    </resultMap>
    <!--过滤网格数据-->
    <sql id="filterHouseGrid">
        <if test="houseParam.roleName!=null and houseParam.roleName!=''">
            <if test="houseParam.roleName=='网格员'">
                <choose>
                    <when test="list != null and list.size()>0">
                        and house_code in
                        <foreach collection="list" item="houseCode" separator ="," open="("  close=")">
                            #{houseCode}
                        </foreach>
                    </when>
                    <otherwise>
                        and house_code in ('')
                    </otherwise>
                </choose>
            </if>
        </if>
    </sql>
    <sql id="selectHouse">
        select
            id,
@@ -66,31 +85,25 @@
    </resultMap>
    <!--自定义分页列表-->
    <select id="selectHousePage" resultMap="houseResultMap">
        <include refid="selectHouse"/>
        <where>
            <if test="house.id != null "> and id = #{house.id}</if>
            <if test="house.houseCode != null  and house.houseCode != ''"> and house_code = #{house.houseCode}</if>
            <if test="house.districtCode != null  and house.districtCode != ''"> and district_code = #{house.districtCode}</if>
            <if test="house.districtName != null  and house.districtName != ''"> and district_name = #{house.districtName}</if>
            <if test="house.houseName != null  and house.houseName != ''"> and house_name = #{house.houseName}</if>
            <if test="house.phone != null  and house.phone != ''"> and phone = #{house.phone}</if>
            <if test="house.area != null "> and area = #{house.area}</if>
            <if test="house.propertyPrice != null "> and property_price = #{house.propertyPrice}</if>
            <if test="house.serviceDue != null "> and service_due = #{house.serviceDue}</if>
            <if test="house.floor != null "> and floor = #{house.floor}</if>
            <if test="house.building != null  and house.building != ''"> and building = #{house.building}</if>
            <if test="house.unit != null  and house.unit != ''"> and unit = #{house.unit}</if>
            <if test="house.room != null  and house.room != ''"> and room = #{house.room}</if>
            <if test="house.buildingNo != null "> and building_no = #{house.buildingNo}</if>
            <if test="house.imageUrls != null  and house.imageUrls != ''"> and image_urls = #{house.imageUrls}</if>
            <if test="house.createUser != null  and house.createUser != ''"> and create_user = #{house.createUser}</if>
            <if test="house.createTime != null "> and create_time = #{house.createTime}</if>
            <if test="house.updateUser != null  and house.updateUser != ''"> and update_user = #{house.updateUser}</if>
            <if test="house.updateTime != null "> and update_time = #{house.updateTime}</if>
            <if test="house.remark != null  and house.remark != ''"> and remark = #{house.remark}</if>
            <if test="house.isDeleted != null "> and is_deleted = #{house.isDeleted}</if>
        </where>
    <select id="selectHousePage" resultType="org.springblade.modules.house.vo.HouseVO">
        select *,concat(building," ",unit," ",room) as address from jczz_house
        where is_deleted = 0
        <if test="house.id != null "> and id = #{house.id}</if>
        <if test="house.houseCode != null  and house.houseCode != ''"> and house_code = #{house.houseCode}</if>
        <if test="house.districtCode != null  and house.districtCode != ''"> and district_code = #{house.districtCode}</if>
        <if test="house.districtName != null  and house.districtName != ''">
            and district_name like concat('%',#{house.districtName},'%')
         </if>
        <if test="house.houseName != null  and house.houseName != ''"> and house_name = #{house.houseName}</if>
        <if test="house.phone != null  and house.phone != ''"> and phone = #{house.phone}</if>
        <if test="house.area != null "> and area = #{house.area}</if>
        <if test="house.propertyPrice != null "> and property_price = #{house.propertyPrice}</if>
        <if test="house.serviceDue != null "> and service_due = #{house.serviceDue}</if>
        <if test="house.floor != null "> and floor = #{house.floor}</if>
        <if test="house.building != null  and house.building != ''"> and building = #{house.building}</if>
        <if test="house.unit != null  and house.unit != ''"> and unit = #{house.unit}</if>
        <if test="house.room != null  and house.room != ''"> and room = #{house.room}</if>
        <if test="house.buildingNo != null "> and building_no = #{house.buildingNo}</if>
    </select>
    <!--房屋自定义详情查询-->
@@ -105,7 +118,7 @@
    </select>
    <select id="export" resultType="org.springblade.modules.system.excel.HouseExcel">
    <select id="export" resultType="org.springblade.modules.house.excel.HouseExcel">
        <include refid="selectHouse"/>
        <where>
            <if test="id != null "> and id = #{id}</if>
@@ -134,4 +147,61 @@
    </select>
    <!--获取房屋树-->
    <select id="getHouseTree" resultType="org.springblade.modules.house.vo.HouseTree">
        SELECT
        district_code as code,
        district_name as name,
        jda.nei_code as parentCode
        FROM jczz_house jh
        left join
        (select nei_code,aoi_code from jczz_doorplate_address where nei_code = #{houseParam.code} group by nei_code,aoi_code) jda
        on jda.aoi_code = jh.district_code
        WHERE jda.nei_code = #{houseParam.code}
        <include refid="filterHouseGrid"/>
        GROUP BY district_code,district_name,nei_code
        union all
        (
        SELECT
        building as code,
        building as name,
        district_code as parentCode
        FROM jczz_house jh
        left join
        (select nei_code,aoi_code from jczz_doorplate_address where nei_code = #{houseParam.code} group by nei_code,aoi_code) jda
        on jda.aoi_code = jh.district_code
        WHERE jda.nei_code = #{houseParam.code}
        <include refid="filterHouseGrid"/>
        GROUP BY building,district_code
        )
        union all
        (
        select
        unit as code,
        unit name,
        building as parentCode
        FROM jczz_house jh
        left join
        (select nei_code,aoi_code from jczz_doorplate_address where nei_code = #{houseParam.code} group by nei_code,aoi_code) jda
        on jda.aoi_code = jh.district_code
        WHERE jda.nei_code = #{houseParam.code}
        <include refid="filterHouseGrid"/>
        group by unit,building
        )
        union all
        (
        select
        room as code,
        room name,
        unit as parentCode
        FROM jczz_house jh
        left join
        (select nei_code,aoi_code from jczz_doorplate_address where nei_code = #{houseParam.code} group by nei_code,aoi_code) jda
        on jda.aoi_code = jh.district_code
        WHERE jda.nei_code = #{houseParam.code}
        <include refid="filterHouseGrid"/>
        )
    </select>
</mapper>
src/main/java/org/springblade/modules/house/mapper/HouseRentalMapper.java
@@ -16,7 +16,6 @@
 */
package org.springblade.modules.house.mapper;
import liquibase.pro.packaged.P;
import org.apache.ibatis.annotations.Param;
import org.springblade.modules.house.entity.HouseRentalEntity;
import org.springblade.modules.house.vo.HouseRentalStatistics;
@@ -24,7 +23,7 @@
import org.springblade.modules.house.vo.HouseRentalVO;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.springblade.modules.system.excel.HouseRentalExcel;
import org.springblade.modules.house.excel.HouseRentalExcel;
import java.util.List;
src/main/java/org/springblade/modules/house/mapper/HouseRentalMapper.xml
@@ -56,9 +56,14 @@
    <!--自定义列表查询-->
    <select id="selectHouseRentalPage" resultType="org.springblade.modules.house.vo.HouseRentalTenantVO">
        SELECT jhr.*,jda.address_name as houseName,b.tenantName,b.phone
        SELECT jhr.*,jda.address_name as houseName,b.tenantName,b.phone,
        concat(jh.district_name," ",jh.building," ",unit," ",room) as address,
        case when TIMESTAMPDIFF( MONTH, jhr.rental_time, jhr.due_time )>= 8 then 1
             when TIMESTAMPDIFF( MONTH, jhr.rental_time, jhr.due_time )&lt;4 then 3
             else 2 end as dldType
        FROM jczz_house_rental jhr
        LEFT JOIN jczz_doorplate_address jda ON jda.address_code = jhr.house_code
        JOIN jczz_doorplate_address jda ON jda.address_code = jhr.house_code
        JOIN jczz_house jh ON jh.house_code = jhr.house_code
        LEFT JOIN (
            SELECT jht.housing_rental_id,jht.name as tenantName,jht.phone
            FROM jczz_house_tenant jht RIGHT JOIN (
@@ -92,8 +97,14 @@
        <if test="vo.tenantName != null and vo.tenantName != ''">
            AND b.tenantName LIKE CONCAT('%',#{vo.tenantName},'%')
        </if>
        <if test="vo.tenantName != null and vo.tenantName != ''">
            AND b.tenantName LIKE CONCAT('%',#{vo.tenantName},'%')
        <if test="vo.tenantRelationship != null">
            AND jhr.tenant_relationship = #{vo.tenantRelationship}
        </if>
        <if test="vo.houseStatus != null">
            AND jhr.house_status = #{vo.houseStatus}
        </if>
        <if test="vo.rentalUse != null">
            AND jhr.rental_use = #{vo.rentalUse}
        </if>
        <if test="vo.dldType != null">
            <if test="vo.dldType ==1 ">
@@ -196,7 +207,7 @@
    </select>
    <select id="export" resultType="org.springblade.modules.system.excel.HouseRentalExcel">
    <select id="export" resultType="org.springblade.modules.house.excel.HouseRentalExcel">
        <include refid="selectHouseRental"/>
        <where>
src/main/java/org/springblade/modules/house/mapper/HouseholdMapper.java
@@ -22,7 +22,7 @@
import org.springblade.modules.house.vo.HouseholdVO;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.springblade.modules.system.excel.HouseHoldExcel;
import org.springblade.modules.house.excel.HouseHoldExcel;
import java.util.List;
@@ -41,7 +41,7 @@
     * @param household
     * @return
     */
    List<HouseholdVO> selectHouseholdPage(IPage page, HouseholdVO household);
    List<HouseholdVO> selectHouseholdPage(IPage page,@Param("household") HouseholdVO household);
    /**
src/main/java/org/springblade/modules/house/mapper/HouseholdMapper.xml
@@ -87,8 +87,26 @@
    </resultMap>
    <!--自定义分页数据查询-->
    <select id="selectHouseholdPage" resultMap="householdResultMap">
        select * from jczz_household where is_deleted = 0
    <select id="selectHouseholdPage" resultType="org.springblade.modules.house.vo.HouseholdVO">
        select
        jh.*,
        jhs.district_name aoiName,
        concat(jhs.building," ",unit," ",room) as address
        from
        jczz_household jh join jczz_house jhs on jh.house_code = jhs.house_code and jhs.is_deleted = 0
        where jh.is_deleted = 0
        <if test="household.name!=null and household.name !=''">
            and jh.name like concat('%',#{household.name},'%')
        </if>
        <if test="household.phoneNumber!=null and household.phoneNumber !=''">
            and jh.phone_number like concat('%',#{household.phoneNumber},'%')
        </if>
        <if test="household.idCard!=null and household.idCard !=''">
            and jh.id_card like concat('%',#{household.idCard},'%')
        </if>
        <if test="household.aoiName!=null and household.aoiName !=''">
            and jhs.district_name like concat('%',#{household.aoiName},'%')
        </if>
    </select>
    <!--查询房屋集合信息-->
@@ -128,7 +146,7 @@
        and jh.id = #{household.id}
    </select>
    <select id="export" resultType="org.springblade.modules.system.excel.HouseHoldExcel">
    <select id="export" resultType="org.springblade.modules.house.excel.HouseHoldExcel">
        <include refid="selectHousehold"/>
        <where>
            <if test="id != null "> and id = #{id}</if>
src/main/java/org/springblade/modules/house/service/IHouseRentalService.java
@@ -18,12 +18,10 @@
import com.baomidou.mybatisplus.extension.service.IService;
import org.springblade.modules.house.entity.HouseRentalEntity;
import org.springblade.modules.house.vo.HouseRentalStatistics;
import org.springblade.modules.house.vo.HouseRentalTenantVO;
import org.springblade.modules.house.vo.HouseRentalVO;
import org.springblade.core.mp.base.BaseService;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.springblade.modules.system.excel.HouseRentalExcel;
import org.springblade.modules.house.excel.HouseRentalExcel;
import java.util.List;
src/main/java/org/springblade/modules/house/service/IHouseService.java
@@ -18,11 +18,11 @@
import com.baomidou.mybatisplus.extension.service.IService;
import org.springblade.modules.house.entity.HouseEntity;
import org.springblade.modules.house.vo.HouseParam;
import org.springblade.modules.house.vo.HouseTree;
import org.springblade.modules.house.vo.HouseVO;
import org.springblade.core.mp.base.BaseService;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.springblade.modules.system.excel.HouseExcel;
import org.springblade.modules.system.excel.HouseHoldExcel;
import org.springblade.modules.house.excel.HouseExcel;
import java.util.List;
@@ -60,4 +60,11 @@
    void importUserHouse(List<HouseExcel> data, Boolean isCovered);
    List<HouseExcel> export(HouseVO household);
    /**
     * 查询房屋树
     * @param houseParam
     * @return
     */
    List<HouseTree> getHouseTree(HouseParam houseParam);
}
src/main/java/org/springblade/modules/house/service/IHouseholdService.java
@@ -21,7 +21,7 @@
import org.springblade.modules.house.entity.HouseholdEntity;
import org.springblade.modules.house.vo.HouseholdVO;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.springblade.modules.system.excel.HouseHoldExcel;
import org.springblade.modules.house.excel.HouseHoldExcel;
import java.util.List;
src/main/java/org/springblade/modules/house/service/impl/HouseRentalServiceImpl.java
@@ -29,8 +29,7 @@
import org.springblade.modules.house.mapper.HouseRentalMapper;
import org.springblade.modules.house.service.IHouseRentalService;
import org.springblade.modules.house.vo.HouseTenantVO;
import org.springblade.modules.system.excel.HouseExcel;
import org.springblade.modules.system.excel.HouseRentalExcel;
import org.springblade.modules.house.excel.HouseRentalExcel;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.core.metadata.IPage;
@@ -39,7 +38,6 @@
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
src/main/java/org/springblade/modules/house/service/impl/HouseServiceImpl.java
@@ -18,20 +18,22 @@
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springblade.common.utils.NodeTreeUtil;
import org.springblade.core.secure.utils.AuthUtil;
import org.springblade.core.tool.utils.BeanUtil;
import org.springblade.modules.grid.service.IGridService;
import org.springblade.modules.house.entity.HouseEntity;
import org.springblade.modules.house.entity.HouseholdEntity;
import org.springblade.modules.house.vo.HouseParam;
import org.springblade.modules.house.vo.HouseTree;
import org.springblade.modules.house.vo.HouseVO;
import org.springblade.modules.house.mapper.HouseMapper;
import org.springblade.modules.house.service.IHouseService;
import org.springblade.core.mp.base.BaseServiceImpl;
import org.springblade.modules.label.service.ILabelService;
import org.springblade.modules.system.excel.HouseExcel;
import org.springblade.modules.system.excel.HouseHoldExcel;
import org.springblade.modules.house.excel.HouseExcel;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.core.metadata.IPage;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
@@ -43,6 +45,10 @@
 */
@Service
public class HouseServiceImpl extends ServiceImpl<HouseMapper, HouseEntity> implements IHouseService {
    @Autowired
    private IGridService gridService;
    @Override
    public IPage<HouseVO> selectHousePage(IPage<HouseVO> page, HouseVO house) {
@@ -80,6 +86,11 @@
    }
    /**
     * 导入房屋数据
     * @param data
     * @param isCovered
     */
    @Override
    public void importUserHouse(List<HouseExcel> data, Boolean isCovered) {
        data.forEach(houseExcel -> {
@@ -93,4 +104,32 @@
        List<HouseExcel> houseExcels = baseMapper.export(household);
        return houseExcels;
    }
    /**
     * 查询房屋树
     * @param houseParam
     * @return
     */
    @Override
    public List<HouseTree> getHouseTree(HouseParam houseParam) {
        List<String> houseCodeList = getHouseCodeList(houseParam);
        return NodeTreeUtil.getHouseTree(baseMapper.getHouseTree(houseParam,houseCodeList));
    }
    /**
     * 根据角色获取地址编号集合
     * @param houseParam
     * @return
     */
    private List<String> getHouseCodeList(HouseParam houseParam) {
        List<String> stringList = new ArrayList<>();
        if (null != houseParam.getRoleName() && !houseParam.getRoleName().equals("")) {
            if (houseParam.getRoleName().equals("网格员")) {
                // 查询对应的房屋地址code
                stringList = gridService.getAddressCodeListByUserId(AuthUtil.getUserId());
            }
        }
        return stringList;
    }
}
src/main/java/org/springblade/modules/house/service/impl/HouseholdServiceImpl.java
@@ -25,7 +25,7 @@
import org.springblade.modules.house.mapper.HouseholdMapper;
import org.springblade.modules.house.service.IHouseholdService;
import org.springblade.modules.system.entity.DictBiz;
import org.springblade.modules.system.excel.HouseHoldExcel;
import org.springblade.modules.house.excel.HouseHoldExcel;
import org.springblade.modules.system.service.IDictBizService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
src/main/java/org/springblade/modules/house/vo/HouseRentalTenantVO.java
@@ -31,5 +31,10 @@
     */
    private String roleName;
    /**
     * 拼接地址
     */
    private String address;
}
src/main/java/org/springblade/modules/house/vo/HouseTree.java
New file
@@ -0,0 +1,23 @@
package org.springblade.modules.house.vo;
import lombok.Data;
import java.util.ArrayList;
import java.util.List;
@Data
public class HouseTree {
    private static final long serialVersionUID = 1L;
    private String name;
    private String code;
    private String parentCode;
    private boolean hashChild;
    private List<HouseTree> children = new ArrayList<>();
}
src/main/java/org/springblade/modules/house/vo/HouseVO.java
@@ -35,5 +35,10 @@
public class HouseVO extends HouseEntity {
    private static final long serialVersionUID = 1L;
    /**
     * 拼接地址
     */
    private String address;
    private List<HouseLabelVO> houseLabelVOList = new ArrayList<>();
}
src/main/java/org/springblade/modules/house/vo/HouseholdVO.java
@@ -41,6 +41,16 @@
    private String roleRelationName;
    /**
     * 小区名称
     */
    private String aoiName;
    /**
     * 地址
     */
    private String address;
    /**
     * 标签
     */
    private List<HouseholdLabelVO> householdLabelList = new ArrayList<>();