Commit e9123a3a authored by 张俊's avatar 张俊

房屋查询bug处理

parent b5abc4cf
...@@ -37,7 +37,7 @@ public class FwxxController { ...@@ -37,7 +37,7 @@ public class FwxxController {
@GetMapping("queryFwjh") @GetMapping("queryFwjh")
@ApiOperation(value = "列表", notes = "房屋列表", response = FwxxEntity.class) @ApiOperation(value = "列表", notes = "房屋列表", response = FwxxEntity.class)
public R queryFwjh(FwxxEntity fwxxEntity) { public R queryFwjh(FwxxEntity fwxxEntity) {
return R.ok().put("data", fwxxService.queryFwjh(fwxxEntity)); return R.ok().put("data", fwxxService.queryFwjh1(fwxxEntity));
} }
// 根据单元查询出房屋列表 // 根据单元查询出房屋列表
......
package io.renren.modules.app.dao; package io.renren.modules.app.dao;
import com.baomidou.mybatisplus.mapper.BaseMapper;
import io.renren.modules.app.entity.FwxxEntity; import io.renren.modules.app.entity.FwxxEntity;
import io.renren.modules.app.entity.XlkEntity;
import io.renren.modules.app.entity.YwpzEntity; import io.renren.modules.app.entity.YwpzEntity;
import io.renren.modules.app.entity.YwpzmxEntity; import io.renren.modules.app.entity.YwpzmxEntity;
import io.renren.modules.app.entity.ZhxxEntity; import io.renren.modules.app.entity.ZhxxEntity;
import com.baomidou.mybatisplus.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import java.util.Collection;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
...@@ -64,6 +63,8 @@ public interface FwxxDao extends BaseMapper<FwxxEntity> { ...@@ -64,6 +63,8 @@ public interface FwxxDao extends BaseMapper<FwxxEntity> {
// 查询单元信息 // 查询单元信息
List<FwxxEntity> queryFwjhDy(FwxxEntity fwxxEntity); List<FwxxEntity> queryFwjhDy(FwxxEntity fwxxEntity);
List<FwxxEntity> queryByMhList(@Param("mhList") Collection<String> mhList);
// 查询房屋信息 // 查询房屋信息
List<FwxxEntity> queryFwjhFw(Map<String, Object> pd); List<FwxxEntity> queryFwjhFw(Map<String, Object> pd);
...@@ -83,6 +84,8 @@ public interface FwxxDao extends BaseMapper<FwxxEntity> { ...@@ -83,6 +84,8 @@ public interface FwxxDao extends BaseMapper<FwxxEntity> {
YwpzEntity selectshzt(String id); YwpzEntity selectshzt(String id);
List<YwpzEntity> selectshztByFwbmList(@Param("fwbmList") List<String> fwbmList);
void PLINSERTFwxx(FwxxEntity fwxxEntity); void PLINSERTFwxx(FwxxEntity fwxxEntity);
void updatezhxxhs(ZhxxEntity zhxxEntity); void updatezhxxhs(ZhxxEntity zhxxEntity);
......
...@@ -22,6 +22,7 @@ public interface FwxxService extends IService<FwxxEntity> { ...@@ -22,6 +22,7 @@ public interface FwxxService extends IService<FwxxEntity> {
// 查询房屋图 // 查询房屋图
List<Map<String, Object>> queryFwjh(FwxxEntity fwxxEntity); List<Map<String, Object>> queryFwjh(FwxxEntity fwxxEntity);
List<Map<String, Object>> queryFwjh1(FwxxEntity fwxxEntity);
// 根据单元查询出房屋列表 // 根据单元查询出房屋列表
PageInfo<FwxxEntity> queryByPage(FwxxEntity fwxxEntity); PageInfo<FwxxEntity> queryByPage(FwxxEntity fwxxEntity);
......
package io.renren.modules.app.service.impl; package io.renren.modules.app.service.impl;
import com.baomidou.mybatisplus.service.impl.ServiceImpl; import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo; import com.github.pagehelper.PageInfo;
import io.renren.modules.app.dao.FwxxDao; import io.renren.modules.app.dao.FwxxDao;
import io.renren.modules.app.entity.FwxxEntity; import io.renren.modules.app.entity.FwxxEntity;
import io.renren.modules.app.entity.XlkEntity;
import io.renren.modules.app.entity.YwpzEntity; import io.renren.modules.app.entity.YwpzEntity;
import io.renren.modules.app.entity.YwpzmxEntity; import io.renren.modules.app.entity.YwpzmxEntity;
import io.renren.modules.app.entity.ZhxxEntity; import io.renren.modules.app.entity.ZhxxEntity;
import io.renren.modules.app.service.FwxxService; import io.renren.modules.app.service.FwxxService;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang.ObjectUtils; import org.apache.commons.lang.ObjectUtils;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.Arrays; import java.util.*;
import java.util.HashMap; import java.util.stream.Collectors;
import java.util.List;
import java.util.Map;
@Service("fwxxService") @Service("fwxxService")
public class FwxxServiceImpl extends ServiceImpl<FwxxDao, FwxxEntity> implements FwxxService { public class FwxxServiceImpl extends ServiceImpl<FwxxDao, FwxxEntity> implements FwxxService {
...@@ -177,6 +172,77 @@ public class FwxxServiceImpl extends ServiceImpl<FwxxDao, FwxxEntity> implements ...@@ -177,6 +172,77 @@ public class FwxxServiceImpl extends ServiceImpl<FwxxDao, FwxxEntity> implements
return returnlist; return returnlist;
} }
public List<Map<String, Object>> queryFwjh1(FwxxEntity fwxxEntity) {
// 返回list集合
List<Map<String, Object>> returnlist = new ArrayList<Map<String, Object>>();
// 根据栋号获取单元,查询本栋楼的所有单元
List<FwxxEntity> dhlist = baseMapper.queryFwjhDy(fwxxEntity);
// 单元编码
Set<String> fwdybmList = dhlist.stream().map(FwxxEntity::getFwdybm).collect(Collectors.toSet());
// 查询单元的所有楼层信息。mh:门号,单元编码
List<FwxxEntity> fwxxEntityList = baseMapper.queryByMhList(fwdybmList);
// 按门号分组
Map<String, List<FwxxEntity>> fwxxMap = fwxxEntityList.stream().collect(Collectors.groupingBy(FwxxEntity::getMh));
// 获取每个单元的楼层,每个单元的楼层可能会不一样
// 按楼层分组
/*Map<Integer, List<FwxxEntity>> lcMap = fwxxEntityList.stream().collect(Collectors.groupingBy(FwxxEntity::getLc));
Set<Integer> lcSet = lcMap.keySet();*/
// 筛选出已缴的数据
List<FwxxEntity> yjFwxxList = fwxxEntityList.stream().filter(f -> "1".equals(f.getSfyj())).collect(Collectors.toList());
Map<String, YwpzEntity> ywpzEntityMap = new HashMap<>();
if (CollectionUtils.isNotEmpty(yjFwxxList))
{
List<YwpzEntity> ywpzEntityList = baseMapper.selectshztByFwbmList(yjFwxxList.stream().map(FwxxEntity::getFwbm).collect(Collectors.toList()));
ywpzEntityMap = ywpzEntityList.stream().collect(Collectors.toMap(YwpzEntity::getFwbm, y -> y, (y1, y2) -> y1));
}
for (FwxxEntity fwxx : dhlist)
{
// 返回Map集合
Map<String, Object> map = new HashMap<>();
// 获取单元名称
map.put("dymc", fwxx.getDymc());
// 接受楼层
List<Object> list = new ArrayList<Object>();
// 获取本单元的房屋
List<FwxxEntity> currentMhList = fwxxMap.get(fwxx.getFwdybm());
if (CollectionUtils.isNotEmpty(currentMhList)){
// 获取每个单元的楼层,每个单元的楼层可能会不一样
Set<Integer> lcSet = currentMhList.stream().map(FwxxEntity::getLc).collect(Collectors.toSet());
// 每个楼层的信息
for (Integer lc : lcSet)
{
Map<String, Object> fwmap = new HashMap<>();
fwmap.put("lc", lc);
// 本楼层的房屋数据
List<FwxxEntity> fwlist = currentMhList.stream().filter(c -> c.getLc().equals(lc)).collect(Collectors.toList());
for (FwxxEntity f : fwlist)
{
YwpzEntity ywpzEntity = ywpzEntityMap.get(f.getFwbm());
if (ywpzEntity != null)
{
if ("1".equals(ywpzEntity.getShzt()))
{
f.setSfyfh("1");
}
else
{
f.setSfyfh("0");
}
}
}
// 单元房屋
fwmap.put("fwxx", fwlist);
list.add(fwmap);
}
}
map.put("lcxx", list);
returnlist.add(map);
}
return returnlist;
}
public static Boolean isObjectNotEmpty(Object obj) { public static Boolean isObjectNotEmpty(Object obj) {
String str = ObjectUtils.toString(obj, ""); String str = ObjectUtils.toString(obj, "");
return StringUtils.isNotBlank(str); return StringUtils.isNotBlank(str);
......
...@@ -266,6 +266,22 @@ ...@@ -266,6 +266,22 @@
SELECT dymc,fwdybm FROM DYXX WHERE dhbm = #{dhbm} SELECT dymc,fwdybm FROM DYXX WHERE dhbm = #{dhbm}
</select> </select>
<select id="queryByMhList" parameterType="string"
resultType="io.renren.modules.app.entity.FwxxEntity">
SELECT * FROM fwxx WHERE 1 = 1
<choose>
<when test="mhList != null and mhList.size() > 0">
and mh in
<foreach collection="mhList" item="mh" open="(" separator="," close=")">
#{mh}
</foreach>
</when>
<otherwise>
and 1 = 2
</otherwise>
</choose>
</select>
<!-- 查询房屋信息 --> <!-- 查询房屋信息 -->
<select id="queryFwjhFw" parameterType="java.util.Map" <select id="queryFwjhFw" parameterType="java.util.Map"
resultType="io.renren.modules.app.entity.FwxxEntity"> resultType="io.renren.modules.app.entity.FwxxEntity">
...@@ -299,6 +315,31 @@ ...@@ -299,6 +315,31 @@
select * from ywpz where djbh=#{id} select * from ywpz where djbh=#{id}
</select> </select>
<select id="selectshztByFwbmList" parameterType="java.lang.String"
resultType="io.renren.modules.app.entity.YwpzEntity">
SELECT
ywpz.*, ywpzmx.fwbm
FROM
ywpzmx ywpzmx
JOIN ywpz ywpz ON ywpz.djbh = ywpzmx.djbh
WHERE 1 = 1
<if test="fwbmList != null and fwbmList.size() > 0">
and ywpzmx.fwbm in
<foreach collection="fwbmList" item="fwbm" open="(" separator="," close=")">
#{fwbm}
</foreach>
</if>
AND CASE LENGTH(ywpzmx.djbh)
WHEN 20 THEN
SUBSTR(ywpzmx.djbh FROM 1 FOR 2) = '03'
WHEN 17 THEN
SUBSTR(ywpzmx.djbh FROM 5 FOR 2) = '03'
ELSE
''
END
GROUP BY ywpz.djbh
</select>
<select id="selectmhxq" parameterType="java.lang.String" <select id="selectmhxq" parameterType="java.lang.String"
resultType="io.renren.modules.app.entity.FwxxEntity"> resultType="io.renren.modules.app.entity.FwxxEntity">
select xqbm,xqmc from xqxx where 1=1 select xqbm,xqmc from xqxx where 1=1
......
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