Commit e9123a3a authored by 张俊's avatar 张俊

房屋查询bug处理

parent b5abc4cf
......@@ -37,7 +37,7 @@ public class FwxxController {
@GetMapping("queryFwjh")
@ApiOperation(value = "列表", notes = "房屋列表", response = FwxxEntity.class)
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;
import com.baomidou.mybatisplus.mapper.BaseMapper;
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.YwpzmxEntity;
import io.renren.modules.app.entity.ZhxxEntity;
import com.baomidou.mybatisplus.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.Collection;
import java.util.List;
import java.util.Map;
......@@ -25,7 +24,7 @@ public interface FwxxDao extends BaseMapper<FwxxEntity> {
/**
* 分页模糊查询
*
*
* @param fwxxEntity
* @return
*/
......@@ -64,6 +63,8 @@ public interface FwxxDao extends BaseMapper<FwxxEntity> {
// 查询单元信息
List<FwxxEntity> queryFwjhDy(FwxxEntity fwxxEntity);
List<FwxxEntity> queryByMhList(@Param("mhList") Collection<String> mhList);
// 查询房屋信息
List<FwxxEntity> queryFwjhFw(Map<String, Object> pd);
......@@ -83,6 +84,8 @@ public interface FwxxDao extends BaseMapper<FwxxEntity> {
YwpzEntity selectshzt(String id);
List<YwpzEntity> selectshztByFwbmList(@Param("fwbmList") List<String> fwbmList);
void PLINSERTFwxx(FwxxEntity fwxxEntity);
void updatezhxxhs(ZhxxEntity zhxxEntity);
......@@ -92,6 +95,6 @@ public interface FwxxDao extends BaseMapper<FwxxEntity> {
FwxxEntity selectfwxx(String id);
List<YwpzEntity> selectfwdjxx(String id);
YwpzmxEntity selectfwsfjq(String id);
}
......@@ -22,6 +22,7 @@ public interface FwxxService extends IService<FwxxEntity> {
// 查询房屋图
List<Map<String, Object>> queryFwjh(FwxxEntity fwxxEntity);
List<Map<String, Object>> queryFwjh1(FwxxEntity fwxxEntity);
// 根据单元查询出房屋列表
PageInfo<FwxxEntity> queryByPage(FwxxEntity fwxxEntity);
......@@ -49,7 +50,7 @@ public interface FwxxService extends IService<FwxxEntity> {
/**
* 查询是否有项目
*
*
* @param dwbm
* @return
*/
......@@ -57,12 +58,12 @@ public interface FwxxService extends IService<FwxxEntity> {
// 删除单位
int deleteFromSfdw(@Param("dwbm") String dwbm);
void PLINSERTFwxx(FwxxEntity fwxxEntity);
void updatezhxxhs(ZhxxEntity zhxxEntity);
ZhxxEntity selectzhxxhs(String id);
List<YwpzEntity> selectdjxxbyfw(String id);
}
package io.renren.modules.app.service.impl;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import io.renren.modules.app.dao.FwxxDao;
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.YwpzmxEntity;
import io.renren.modules.app.entity.ZhxxEntity;
import io.renren.modules.app.service.FwxxService;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang.ObjectUtils;
import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
import java.util.stream.Collectors;
@Service("fwxxService")
public class FwxxServiceImpl extends ServiceImpl<FwxxDao, FwxxEntity> implements FwxxService {
......@@ -154,17 +149,17 @@ public class FwxxServiceImpl extends ServiceImpl<FwxxDao, FwxxEntity> implements
for(FwxxEntity f: fwlist){
if("1".equals(f.getSfyj())){
List<YwpzEntity> ys=baseMapper.selectfwdjbh(f.getFwbm());
YwpzEntity y1=baseMapper.selectshzt(ys.get(0).getDjbh());
if(isObjectNotEmpty(y1)==false||isObjectNotEmpty(ys.get(0))==false){
YwpzEntity y1=baseMapper.selectshzt(ys.get(0).getDjbh());
if(isObjectNotEmpty(y1)==false||isObjectNotEmpty(ys.get(0))==false){
}else{
if("1".equals(y1.getShzt())){
f.setSfyfh("1");
}else{
if("1".equals(y1.getShzt())){
f.setSfyfh("1");
}else{
f.setSfyfh("0");
}
f.setSfyfh("0");
}
}
}
}
// 单元房屋
......@@ -176,7 +171,78 @@ public class FwxxServiceImpl extends ServiceImpl<FwxxDao, FwxxEntity> implements
}
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) {
String str = ObjectUtils.toString(obj, "");
return StringUtils.isNotBlank(str);
......@@ -187,7 +253,7 @@ public class FwxxServiceImpl extends ServiceImpl<FwxxDao, FwxxEntity> implements
public FwxxEntity queryDhsj(FwxxEntity fwxxEntity) {
return baseMapper.queryDhsj(fwxxEntity);
}
/**
* 查询是否存在项目
*/
......@@ -208,19 +274,19 @@ public class FwxxServiceImpl extends ServiceImpl<FwxxDao, FwxxEntity> implements
@Override
public void PLINSERTFwxx(FwxxEntity fwxxEntity) {
baseMapper.PLINSERTFwxx(fwxxEntity);
}
@Override
public void updatezhxxhs(ZhxxEntity zhxxEntity) {
baseMapper.updatezhxxhs(zhxxEntity);
}
@Override
public ZhxxEntity selectzhxxhs(String id) {
return baseMapper.selectzhxxhs(id);
}
......@@ -229,7 +295,7 @@ public class FwxxServiceImpl extends ServiceImpl<FwxxDao, FwxxEntity> implements
FwxxEntity f=baseMapper.selectfwxx(id);
List<YwpzEntity> ys=new ArrayList<YwpzEntity>();
if("1".equals(f.getSfyj())){
ys=baseMapper.selectfwdjxx(id);
ys=baseMapper.selectfwdjxx(id);
}
return ys;
}
......
......@@ -5,7 +5,7 @@
<select id="queryByPage" parameterType="io.renren.modules.app.entity.FwxxEntity"
resultType="io.renren.modules.app.entity.FwxxEntity">
resultType="io.renren.modules.app.entity.FwxxEntity">
select * from fwxx where 1=1
......@@ -157,25 +157,25 @@
<insert id="PLINSERTFwxx" parameterType="io.renren.modules.app.entity.FwxxEntity">
INSERT INTO
fwxx(dhbm,cczh,fwbm,mphm,lc,hx,fwxz,ssdj,mj,fwje,gfrq,lfmj,lfdj,lfje,zjk,hxt,xm,sfzh,lxdh,jjze,grje,dwje,dqye,sfsc,mh,grjjl,jsbz,gzdbm,ggsy,zqje,ljlx,ncye,xhje,xhjx,htbh,fpbh,zjlb,dz,bz,jcbzbm,fwyt,spzt,yzkm)
fwxx(dhbm,cczh,fwbm,mphm,lc,hx,fwxz,ssdj,mj,fwje,gfrq,lfmj,lfdj,lfje,zjk,hxt,xm,sfzh,lxdh,jjze,grje,dwje,dqye,sfsc,mh,grjjl,jsbz,gzdbm,ggsy,zqje,ljlx,ncye,xhje,xhjx,htbh,fpbh,zjlb,dz,bz,jcbzbm,fwyt,spzt,yzkm)
VALUES
(#{dhbm},#{cczh},#{fwbm},#{mphm},#{lcs},#{hx},#{fwxz},#{ssdj},#{mj},#{fwje},#{gfrq},#{lfmj},#{lfdj},#{lfje},#{zjk},#{hxt},#{xm},#{sfzh},#{lxdh},#{jjze},#{grje},#{dwje},#{dqye},#{sfsc},#{fwdybm},#{grjjl},#{jsbz},#{gzdbm},#{ggsy},#{zqje},#{ljlx},#{ncye},#{xhje},#{xhjx},#{htbh},#{fpbh},#{zjlb},#{dz},#{bz},#{jcbzbm},#{fwyt},#{spzt},#{yzkm})
(#{dhbm},#{cczh},#{fwbm},#{mphm},#{lcs},#{hx},#{fwxz},#{ssdj},#{mj},#{fwje},#{gfrq},#{lfmj},#{lfdj},#{lfje},#{zjk},#{hxt},#{xm},#{sfzh},#{lxdh},#{jjze},#{grje},#{dwje},#{dqye},#{sfsc},#{fwdybm},#{grjjl},#{jsbz},#{gzdbm},#{ggsy},#{zqje},#{ljlx},#{ncye},#{xhje},#{xhjx},#{htbh},#{fpbh},#{zjlb},#{dz},#{bz},#{jcbzbm},#{fwyt},#{spzt},#{yzkm})
</insert>
<!-- 修改 -->
<update id="updateFwxx" parameterType="io.renren.modules.app.entity.FwxxEntity">
update fwxx set
dhbm=#{dhbm},cczh=#{cczh},fwbm=#{fwbm},mphm=#{mphm},lc=#{lc},hx=#{hx},fwxz=#{fwxz},ssdj=#{ssdj},
mj=#{mj},fwje=#{fwje},gfrq=#{gfrq},xm=#{xm},
sfzh=#{sfzh},lxdh=#{lxdh},grjjl=#{grjjl},
jsbz=#{jsbz},gzdbm='0001',
htbh=#{htbh},fpbh=#{fpbh},zjlb=#{zjlb},dz=#{dz},bz=#{bz},fwyt=#{fwyt},dwjjl=#{dwjjl}
dhbm=#{dhbm},cczh=#{cczh},fwbm=#{fwbm},mphm=#{mphm},lc=#{lc},hx=#{hx},fwxz=#{fwxz},ssdj=#{ssdj},
mj=#{mj},fwje=#{fwje},gfrq=#{gfrq},xm=#{xm},
sfzh=#{sfzh},lxdh=#{lxdh},grjjl=#{grjjl},
jsbz=#{jsbz},gzdbm='0001',
htbh=#{htbh},fpbh=#{fpbh},zjlb=#{zjlb},dz=#{dz},bz=#{bz},fwyt=#{fwyt},dwjjl=#{dwjjl}
where fwbm=#{fwbm}
</update>
<!-- 单个查询 -->
<select id="selectByXxId" parameterType="io.renren.modules.app.entity.FwxxEntity"
resultType="io.renren.modules.app.entity.FwxxEntity">
resultType="io.renren.modules.app.entity.FwxxEntity">
SELECT
distinct
f.dhbm,f.xm,z.dhmc,x.xmmc,s.dwmc,s.dwbm,f.cczh,f.fwbm,f.mphm,f.lc,f.hx,f.fwxz,d.value,f.ssdj,f.mj,f.fwje,f.gfrq,f.sfyj,f.lfmj,f.lfdj,f.lfje,f.zjk,f.hxt,f.xm,f.sfzh,f.lxdh,f.jjze,f.grje,f.dwje,f.dqye,f.sfsc,f.mh,f.grjjl,f.jsbz,f.gzdbm,f.ggsy,f.zqje,f.ljlx,f.ncye,f.xhje,f.xhjx,f.htbh,f.fpbh,f.zjlb,f.dz,f.bz,f.jcbzbm,f.fwyt,f.spzt,f.yzkm
......@@ -190,12 +190,12 @@
<!-- 获取最新的房屋编码 -->
<select id="querydhbm" resultType="string">
SELECT fwbm FROM fwxx ORDER BY
fwbm DESC LIMIT 1
fwbm DESC LIMIT 1
</select>
<!-- 查询户数和楼层数 -->
<select id="queryDyxx" parameterType="io.renren.modules.app.entity.FwxxEntity"
resultType="io.renren.modules.app.entity.FwxxEntity">
resultType="io.renren.modules.app.entity.FwxxEntity">
SELECT a.DHBM,b.DHMC,a.FWDYBM,a.DYMC,a.HS,a.LCS
FROM DYXX a left join
ZHXX b on a.dhbm = b.dhbm WHERE 1=1
......@@ -206,17 +206,17 @@
<!-- 新增小区集合 -->
<select id="selectxq" parameterType="java.util.Map"
resultType="io.renren.modules.app.entity.FwxxEntity">
resultType="io.renren.modules.app.entity.FwxxEntity">
select XQBM,XQMC from XQXX where XQBM in (select XQBM from
XM where XMBM in
(select XMBM from ZHXX where DHBM in (select DHBM from
DYXX where
FWDYBM not in (select MH from FWXX))))
XM where XMBM in
(select XMBM from ZHXX where DHBM in (select DHBM from
DYXX where
FWDYBM not in (select MH from FWXX))))
</select>
<!-- 新增项目集合 -->
<select id="selectxm" parameterType="java.util.Map"
resultType="io.renren.modules.app.entity.FwxxEntity">
resultType="io.renren.modules.app.entity.FwxxEntity">
select XMBM,XMMC from XM where 1=1
<if test=" xqbm != null and xqbm != '' ">
and XQBM = #{xqbm}
......@@ -227,7 +227,7 @@
<!-- 新增栋号集合 -->
<select id="selectlz" parameterType="java.util.Map"
resultType="io.renren.modules.app.entity.FwxxEntity">
resultType="io.renren.modules.app.entity.FwxxEntity">
select DHBM,DHMC from ZHXX where 1=1
<if test=" xmbm != null and xmbm != '' ">
and XMBM = #{xmbm}
......@@ -238,7 +238,7 @@
<!-- 新增单元集合 -->
<select id="selectdy" parameterType="java.util.Map"
resultType="io.renren.modules.app.entity.FwxxEntity">
resultType="io.renren.modules.app.entity.FwxxEntity">
select fwdybm,DYMC,HS from DYXX where 1=1
<if test=" dhbm != null and dhbm != '' ">
and DHBM = #{dhbm}
......@@ -248,59 +248,100 @@
<!--户型 -->
<select id="hx" parameterType="java.util.Map"
resultType="io.renren.modules.app.entity.FwxxEntity">
resultType="io.renren.modules.app.entity.FwxxEntity">
SELECT id AS hx,VALUE AS hxmc FROM sys_dict WHERE TYPE
='04'
='04'
</select>
<!-- 房屋性质 -->
<select id="fmxz" parameterType="java.util.Map"
resultType="io.renren.modules.app.entity.FwxxEntity">
resultType="io.renren.modules.app.entity.FwxxEntity">
SELECT id AS fwxz,VALUE AS fwxzmc FROM sys_dict WHERE TYPE
='01'
='01'
</select>
<!-- 查询单元信息 -->
<select id="queryFwjhDy" parameterType="io.renren.modules.app.entity.FwxxEntity"
resultType="io.renren.modules.app.entity.FwxxEntity">
resultType="io.renren.modules.app.entity.FwxxEntity">
SELECT dymc,fwdybm FROM DYXX WHERE dhbm = #{dhbm}
</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"
resultType="io.renren.modules.app.entity.FwxxEntity">
resultType="io.renren.modules.app.entity.FwxxEntity">
SELECT mphm,fwbm,lc,sfyj,sfsc FROM fwxx WHERE mh =
#{fwdybm} AND lc =
#{lc}
#{fwdybm} AND lc =
#{lc}
</select>
<!-- 根据单元编码查询房屋楼层数集合 -->
<select id="queryDylcs" parameterType="java.util.Map"
resultType="java.lang.Integer">
resultType="java.lang.Integer">
SELECT lc FROM fwxx WHERE mh = #{fwdybm} GROUP BY lc order
by lc desc
by lc desc
</select>
<!-- 根据栋号获取信息 -->
<select id="queryDhsj" parameterType="io.renren.modules.app.entity.FwxxEntity"
resultType="io.renren.modules.app.entity.FwxxEntity">
resultType="io.renren.modules.app.entity.FwxxEntity">
select YZKM from ZHXX where dhbm=#{dhbm}
</select>
<select id="selectfwdjbh" parameterType="java.lang.String"
resultType="io.renren.modules.app.entity.YwpzEntity">
resultType="io.renren.modules.app.entity.YwpzEntity">
select djbh from ywpzmx where fwbm=#{id} and case
LENGTH(djbh) when 20 then SUBSTR(djbh FROM 1 FOR 2)='03' when 17 then
SUBSTR(djbh FROM 5 FOR 2)='03' else '' end
LENGTH(djbh) when 20 then SUBSTR(djbh FROM 1 FOR 2)='03' when 17 then
SUBSTR(djbh FROM 5 FOR 2)='03' else '' end
</select>
<select id="selectshzt" parameterType="java.lang.String"
resultType="io.renren.modules.app.entity.YwpzEntity">
resultType="io.renren.modules.app.entity.YwpzEntity">
select * from ywpz where djbh=#{id}
</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"
resultType="io.renren.modules.app.entity.FwxxEntity">
resultType="io.renren.modules.app.entity.FwxxEntity">
select xqbm,xqmc from xqxx where 1=1
<if test=" _pt!=null and _pt!=''">
and xqmc like '%${_pt}%' or xqbm like '%${_pt}%'
......@@ -313,24 +354,24 @@
</update>
<select id="selectzhxxhs" parameterType="java.lang.String"
resultType="io.renren.modules.app.entity.ZhxxEntity">
resultType="io.renren.modules.app.entity.ZhxxEntity">
select hs from zhxx where dhbm=#{id}
</select>
<select id="selectfwxx" parameterType="java.lang.String"
resultType="io.renren.modules.app.entity.FwxxEntity">
resultType="io.renren.modules.app.entity.FwxxEntity">
select sfyj from fwxx where fwbm=#{id}
</select>
<select id="selectfwdjxx" parameterType="java.lang.String"
resultType="io.renren.modules.app.entity.YwpzEntity">
resultType="io.renren.modules.app.entity.YwpzEntity">
select y.djbh,y.djrq,h.yhmc,j.billname,j.billcode,y.je,y.zph,y.bz from
ywpz y,h_jsfs j,yhxx h where y.bank_code=h.yhbm and j.billcode=y.jsfs
and y.djbh in(select djbh from ywpzmx where (SUBSTR(djbh FROM 1 FOR
ywpz y,h_jsfs j,yhxx h where y.bank_code=h.yhbm and j.billcode=y.jsfs
and y.djbh in(select djbh from ywpzmx where (SUBSTR(djbh FROM 1 FOR
2)='03' or SUBSTR(djbh FROM 5 FOR 2)='03') and fwbm=#{id}) order by y.djrq desc
</select>
<select id="selectfwsfjq" parameterType="java.lang.String" resultType="io.renren.modules.app.entity.YwpzmxEntity">
select sum(je) je from ywpzmx where (SUBSTR(djbh FROM 5 FOR 2)='03' || SUBSTR(djbh FROM 1 FOR 2)='03') and fwbm=#{id}
</select>
......
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