src/main/java/org/springblade/modules/house/controller/HouseController.java
@@ -303,4 +303,14 @@ return R.data(houseService.getHouseLabelStatistic(house)); } /** * 房屋标签初始化处置-根据有租客的,初始成出租,有业主没租客的初始化成自主,业主都没的就是闲置 * @return */ @GetMapping("/initHouseLabelBind") @ApiOperation(value = "房屋标签初始化处置") public R initHouseLabelBind(HouseVO house) { return R.status(houseService.initHouseLabelBind(house)); } } src/main/java/org/springblade/modules/house/mapper/HouseMapper.java
@@ -144,4 +144,19 @@ * @return */ List<HouseVO> getAllList(@Param("i") int i,@Param("size") int size); /** * 查询无房屋状态的房屋数量 * @param house * @return */ int getNotBindLabelHouseNum(HouseVO house); /** * 查询无房屋状态的房屋列表集合 * @param i * @param size * @return */ List<HouseVO> getNotBindLabelHouseList(@Param("i") int i,@Param("size") int size); } src/main/java/org/springblade/modules/house/mapper/HouseMapper.xml
@@ -922,5 +922,60 @@ limit #{i},#{size} </select> <!--查询无房屋状态的房屋数量--> <select id="getNotBindLabelHouseNum" resultType="java.lang.Integer"> select count(*) from ( SELECT jh.house_code, case when c.house_code is not null then 1 when a.house_code is not null and b.house_code is null then 2 when b.house_code is not null then 3 end as status FROM jczz_house jh left join ( select house_code from jczz_household where is_deleted = 0 and relationship = 1 and house_code is not null and house_code != '' GROUP BY house_code ) a on a.house_code = jh.house_code left join ( select house_code from jczz_household where is_deleted = 0 and relationship = 18 and house_code is not null and house_code != '' GROUP BY house_code ) b on b.house_code = jh.house_code left join ( select house_code from jczz_household where is_deleted = 0 and relationship is null or (relationship!=1 and relationship!=18) and house_code is not null and house_code != '' GROUP BY house_code ) c on c.house_code = jh.house_code ) d left join jczz_user_house_label juhl on d.house_code = juhl.house_code and lable_type = 2 where juhl.id is null and status is not null </select> <!--查询无房屋状态的房屋列表集合--> <select id="getNotBindLabelHouseList" resultType="org.springblade.modules.house.vo.HouseVO"> select d.* from ( SELECT jh.house_code, case when c.house_code is not null then 1 when a.house_code is not null and b.house_code is null then 2 when b.house_code is not null then 3 end as status FROM jczz_house jh left join ( select house_code from jczz_household where is_deleted = 0 and relationship = 1 and house_code is not null and house_code != '' GROUP BY house_code ) a on a.house_code = jh.house_code left join ( select house_code from jczz_household where is_deleted = 0 and relationship = 18 and house_code is not null and house_code != '' GROUP BY house_code ) b on b.house_code = jh.house_code left join ( select house_code from jczz_household where is_deleted = 0 and relationship is null or (relationship!=1 and relationship!=18) and house_code is not null and house_code != '' GROUP BY house_code ) c on c.house_code = jh.house_code ) d left join jczz_user_house_label juhl on d.house_code = juhl.house_code and lable_type = 2 where juhl.id is null and status is not null limit #{i},#{size} </select> </mapper> src/main/java/org/springblade/modules/house/service/IHouseService.java
@@ -130,4 +130,11 @@ * @return */ List<HouseVO> getAllList(int i, int size); /** * 房屋标签初始化处置-根据有租客的,初始成出租,有业主没租客的初始化成自主,业主都没的就是闲置 * @param house * @return */ boolean initHouseLabelBind(HouseVO house); } src/main/java/org/springblade/modules/house/service/impl/HouseServiceImpl.java
@@ -954,4 +954,61 @@ public List<HouseVO> getAllList(int i, int size) { return baseMapper.getAllList(i,size); } /** * 房屋标签初始化处置-根据有租客的,初始成出租,有业主没租客的初始化成自主,业主都没的就是闲置 * @param house * @return */ @Override public boolean initHouseLabelBind(HouseVO house) { IUserHouseLabelService userHouseLabelService = SpringUtils.getBean(IUserHouseLabelService.class); // 查询无房屋状态的房屋数量 int total = baseMapper.getNotBindLabelHouseNum(house); int size = 1000; int num = total / size; for (int i = 1; i <= num + 1; i++) { // 查询无房屋状态的房屋列表集合 List<HouseVO> houseVOList = baseMapper.getNotBindLabelHouseList((i - 1) * size, size); for (HouseVO houseEntity : houseVOList) { //处理状态 UserHouseLabelEntity houseLabelEntity = new UserHouseLabelEntity(); houseLabelEntity.setHouseCode(houseEntity.getHouseCode()); houseLabelEntity.setLableType(2); houseLabelEntity.setCreateTime(new Date()); if (houseEntity.getStatus()==1) { // 闲置 houseLabelEntity.setColor("green"); houseLabelEntity.setLabelName("闲置"); houseLabelEntity.setLabelId(1037L); } if (houseEntity.getStatus()==2) { // 自住 houseLabelEntity.setColor("blue"); houseLabelEntity.setLabelName("自住"); houseLabelEntity.setLabelId(1038L); } if (houseEntity.getStatus()==3) { // 出租 houseLabelEntity.setColor("yellow"); houseLabelEntity.setLabelName("出租"); houseLabelEntity.setLabelId(1039L); } // 查询当前房屋是否已有,有则更新,无则新增 QueryWrapper<UserHouseLabelEntity> wrapper = new QueryWrapper<>(); wrapper.eq("house_code",houseEntity.getHouseCode()) .eq("lable_type",2); UserHouseLabelEntity userHouseLabelEntity = userHouseLabelService.getOne(wrapper); if (null!=userHouseLabelEntity){ // 更新 houseLabelEntity.setId(userHouseLabelEntity.getId()); userHouseLabelService.updateById(houseLabelEntity); }else { // 新增 userHouseLabelService.save(houseLabelEntity); } } } return true; } } src/main/java/org/springblade/modules/house/vo/HouseVO.java
@@ -83,4 +83,9 @@ private String communityCode; private List<UserHouseLabelVO> userHouseLabelVOList = new ArrayList<>(); /** * 标签id */ private Integer status; }