From f719b2f6f51dda0e2ac3abf53315845cc6af3b72 Mon Sep 17 00:00:00 2001 From: Renpc-kilig <308442850@qq.com> Date: Fri, 24 Nov 2023 16:51:28 +0800 Subject: [PATCH 1/4] =?UTF-8?q?=E4=BC=98=E5=8C=96=E4=BB=A5=E4=BA=BA?= =?UTF-8?q?=E6=89=BE=E6=88=BF=EF=BC=8C=E4=BB=A5=E6=88=BF=E6=89=BE=E4=BA=BA?= =?UTF-8?q?=20=20--renpc?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cm/population/dao/house/IHouseDao.java | 2 + .../dao/population/IPopulationDao.java | 2 + .../populationinfo/IPopulationInfoDao.java | 2 + .../service/house/IHouseService.java | 2 + .../service/house/impl/HouseServiceImpl.java | 15 +- .../impl/PopulationServiceImpl.java | 189 ++++++++++++++++-- .../IPopulationInfoService.java | 1 + .../impl/PopulationInfoServiceImpl.java | 7 + .../mybatis/mapper/house/house-mapper.xml | 77 +++++-- .../mapper/population/population-mapper.xml | 46 +++++ .../populationinfo/population-info-mapper.xml | 94 +++++++++ 11 files changed, 400 insertions(+), 37 deletions(-) diff --git a/src/main/java/com/cm/population/dao/house/IHouseDao.java b/src/main/java/com/cm/population/dao/house/IHouseDao.java index e14cf6e..9517cd3 100644 --- a/src/main/java/com/cm/population/dao/house/IHouseDao.java +++ b/src/main/java/com/cm/population/dao/house/IHouseDao.java @@ -126,4 +126,6 @@ public interface IHouseDao { List findPopulation(Map params); List listForAll(Map params); + + List getBatch(Map params); } \ No newline at end of file diff --git a/src/main/java/com/cm/population/dao/population/IPopulationDao.java b/src/main/java/com/cm/population/dao/population/IPopulationDao.java index 05c8e5c..9ba48c1 100644 --- a/src/main/java/com/cm/population/dao/population/IPopulationDao.java +++ b/src/main/java/com/cm/population/dao/population/IPopulationDao.java @@ -134,4 +134,6 @@ public interface IPopulationDao { List listAll(Map params); void updateBindTime(Map params); + + List listBatch(Map params); } \ No newline at end of file diff --git a/src/main/java/com/cm/population/dao/populationinfo/IPopulationInfoDao.java b/src/main/java/com/cm/population/dao/populationinfo/IPopulationInfoDao.java index 062df2b..d903b29 100644 --- a/src/main/java/com/cm/population/dao/populationinfo/IPopulationInfoDao.java +++ b/src/main/java/com/cm/population/dao/populationinfo/IPopulationInfoDao.java @@ -120,4 +120,6 @@ public interface IPopulationInfoDao { PopulationInfoBaseDTO getBase(Map params); void updateCreator(Map params); + + List getBatch(Map params); } \ No newline at end of file diff --git a/src/main/java/com/cm/population/service/house/IHouseService.java b/src/main/java/com/cm/population/service/house/IHouseService.java index 7af35cb..95fe289 100644 --- a/src/main/java/com/cm/population/service/house/IHouseService.java +++ b/src/main/java/com/cm/population/service/house/IHouseService.java @@ -232,4 +232,6 @@ public interface IHouseService { * @param autoHouseDTO */ void saveAuto(String token, AutoHouseDTO autoHouseDTO); + + List getBatch(List houseIds); } \ No newline at end of file diff --git a/src/main/java/com/cm/population/service/house/impl/HouseServiceImpl.java b/src/main/java/com/cm/population/service/house/impl/HouseServiceImpl.java index 15c2cfe..1ad670e 100644 --- a/src/main/java/com/cm/population/service/house/impl/HouseServiceImpl.java +++ b/src/main/java/com/cm/population/service/house/impl/HouseServiceImpl.java @@ -19,7 +19,6 @@ import com.cm.population.pojo.dtos.residential.ResidentialDTO; import com.cm.population.pojo.pos.house.HousePO; import com.cm.population.pojo.vos.building.BuildingBatchVO; import com.cm.population.pojo.vos.house.HouseVO; -import com.cm.population.pojo.vos.population.PopulationVO; import com.cm.population.service.building.IBuildingService; import com.cm.population.service.house.IHouseService; import com.cm.population.service.population.IPopulationService; @@ -29,19 +28,12 @@ import com.github.pagehelper.PageInfo; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; -import org.springframework.util.CollectionUtils; -import java.sql.Connection; -import java.sql.DriverManager; -import java.sql.PreparedStatement; -import java.sql.SQLException; import java.util.ArrayList; -import java.util.Collections; import java.util.List; import java.util.Map; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; -import java.util.stream.Collectors; /** * @ClassName: HouseServiceImpl @@ -603,4 +595,11 @@ public class HouseServiceImpl extends AbstractService implements IHouseService { } } + @Override + public List getBatch(List houseIds) { + Map params = getHashMap(2); + params.put("houseIds", houseIds); + return houseDao.getBatch(params); + } + } \ No newline at end of file diff --git a/src/main/java/com/cm/population/service/population/impl/PopulationServiceImpl.java b/src/main/java/com/cm/population/service/population/impl/PopulationServiceImpl.java index 19d4781..2a7378c 100644 --- a/src/main/java/com/cm/population/service/population/impl/PopulationServiceImpl.java +++ b/src/main/java/com/cm/population/service/population/impl/PopulationServiceImpl.java @@ -16,6 +16,7 @@ import com.cm.population.pojo.dtos.population.PopulationInfoHouseDTO; import com.cm.population.pojo.dtos.populationinfo.PopulationInfoBaseDTO; import com.cm.population.pojo.dtos.populationinfo.PopulationInfoDTO; import com.cm.population.pojo.pos.population.PopulationPO; +import com.cm.population.pojo.vos.house.HouseVO; import com.cm.population.pojo.vos.population.PopulationVO; import com.cm.population.service.house.IHouseService; import com.cm.population.service.population.IPopulationService; @@ -32,6 +33,9 @@ import sun.security.krb5.internal.PAData; import javax.mail.search.SearchException; import java.util.*; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.stream.Collectors; /** * @ClassName: PopulationServiceImpl @@ -60,15 +64,15 @@ public class PopulationServiceImpl extends AbstractService implements IPopulatio params.put("outHouse", "0"); List list = populationDao.listAll(params); Map map = new HashMap<>(); - for(PopulationDTO dto : list) { + for (PopulationDTO dto : list) { map.put(dto.getPopulationInfoId(), dto); } // 1. 判断创建房屋时,是否有人员信息一起 // 2. 有的话,删除旧的人员信息,并录入新的人员信息 - if(!CollectionUtils.isEmpty(populationVOList)) { + if (!CollectionUtils.isEmpty(populationVOList)) { for (PopulationVO populationVO : populationVOList) { // 2.将搬离的改掉 - if("1".equals(populationVO.getOutHouse())) { + if ("1".equals(populationVO.getOutHouse())) { update(populationVO.getPopulationId(), populationVO); map.remove(populationVO.getPopulationInfoId()); } @@ -81,12 +85,12 @@ public class PopulationServiceImpl extends AbstractService implements IPopulatio } } // 删除旧的所有的入住信息 - if(isAllData) { + if (isAllData) { populationDao.deleteByHouseId(houseId); - }else{ + } else { // 剔除已存在的人员的再次新增 Iterator iterator = populationVOList.iterator(); - while(iterator.hasNext()) { + while (iterator.hasNext()) { PopulationVO vo = iterator.next(); if (map.get(vo.getPopulationInfoId()) != null) { // 更新绑定事件 @@ -100,7 +104,7 @@ public class PopulationServiceImpl extends AbstractService implements IPopulatio } // 保存新的入住信息 for (PopulationVO populationVO : populationVOList) { - if(!"1".equals(populationVO.getOutHouse())) { + if (!"1".equals(populationVO.getOutHouse())) { populationVO.setHouseId(houseId); save(token, populationVO); } @@ -142,7 +146,7 @@ public class PopulationServiceImpl extends AbstractService implements IPopulatio params.put("outHouse", 0); // 解除脱敏 - if(null != params.get("populationInfoId") && StringUtils.isNotEmpty(params.get("populationInfoId").toString())) { + if (null != params.get("populationInfoId") && StringUtils.isNotEmpty(params.get("populationInfoId").toString())) { PopulationInfoDTO populationInfoDTO = populationInfoService.get(populationVO.getPopulationInfoId()); params.put("name", populationInfoDTO.getName()); params.put("cardNum", populationInfoDTO.getIdcard()); @@ -290,14 +294,14 @@ public class PopulationServiceImpl extends AbstractService implements IPopulatio @Override public Boolean hasUser(Map params) { - if(null == params.get("populationInfoId")) { + if (null == params.get("populationInfoId")) { try { throw new SearchException("人员信息ID不能为空"); } catch (SearchException e) { e.printStackTrace(); } } - if(null == params.get("houseId")) { + if (null == params.get("houseId")) { try { throw new SearchException("房屋信息ID不能为空"); } catch (SearchException e) { @@ -306,13 +310,13 @@ public class PopulationServiceImpl extends AbstractService implements IPopulatio } Integer count = populationDao.count(params); - if(count > 0) { + if (count > 0) { return true; } return false; } - @Override + /*@Override public SuccessResultList> findHouse(ListPage page) { PageHelper.startPage(page.getPage(), page.getRows()); List populationDTOList = list(page.getParams()); @@ -345,6 +349,96 @@ public class PopulationServiceImpl extends AbstractService implements IPopulatio } PageInfo pageInfo = new PageInfo<>(populationDTOList); return new SuccessResultList<>(populationDTOList, pageInfo.getPageNum(), pageInfo.getTotal()); + }*/ + + @Override + public SuccessResultList> findHouse(ListPage page) { + PageHelper.startPage(page.getPage(), page.getRows()); + // List populationDTOList = list(page.getParams()); + List populationDTOList = listBatch(page.getParams()); + + List populationInfoIds = new ArrayList<>(); + List houseIds = new ArrayList<>(); + for (PopulationDTO populationDTO : populationDTOList) { + if (StringUtils.isNotEmpty(populationDTO.getPopulationInfoId())) { + populationInfoIds.add(populationDTO.getPopulationInfoId()); + } + if (StringUtils.isNotEmpty(populationDTO.getHouseId())) { + houseIds.add(populationDTO.getHouseId()); + } + } + + // 一次性获取所有的人口信息 + List populationInfoDTOs = populationInfoService.getBatch(populationInfoIds); + // 一次性获取所有的房屋信息 + List houseDTOs = houseService.getBatch(houseIds); + + Map populationInfoMap = null; + Map houseMap = null; + if (!CollectionUtils.isEmpty(populationInfoDTOs)) { + populationInfoMap = populationInfoDTOs.stream() + .collect(Collectors.toMap(PopulationInfoDTO::getPopulationInfoId, + populationInfoDTO -> populationInfoDTO)); + } + + if (!CollectionUtils.isEmpty(houseDTOs)) { + houseMap = houseDTOs.stream() + .collect(Collectors.toMap(HouseDTO::getHouseId, + houseDTO -> houseDTO)); + } + + for (PopulationDTO populationDTO : populationDTOList) { + if (StringUtils.isNotEmpty(populationDTO.getPopulationInfoId())) { + PopulationInfoDTO populationInfoDTO; + if (null != populationInfoMap) { + populationInfoDTO = populationInfoMap + .get(populationDTO.getPopulationInfoId()); + if (null != populationInfoDTO) { + populationInfoService.getTuoMin(populationInfoDTO); + } + } else { + populationInfoDTO = setPopulationInfo(populationDTO); + } + populationDTO.setPopulationInfoDTO(populationInfoDTO); + } else { + PopulationInfoDTO populationInfoDTO = setPopulationInfo(populationDTO); + populationDTO.setPopulationInfoDTO(populationInfoDTO); + } + + if (null != houseMap) { + HouseDTO houseDTO = houseMap.get(populationDTO.getHouseId()); + if (null != houseDTO) { + if (1 == houseDTO.getIsRental()) { + houseDTO.setHouseType("出租房"); + } + if (1 == houseDTO.getIsVacant()) { + houseDTO.setHouseType("空置房"); + } + if (0 == houseDTO.getIsRental() && 0 == houseDTO.getIsVacant()) { + houseDTO.setHouseType("自住房"); + } + populationDTO.setHouseDTO(houseDTO); + } + } + } + + PageInfo pageInfo = new PageInfo<>(populationDTOList); + return new SuccessResultList<>(populationDTOList, pageInfo.getPageNum(), pageInfo.getTotal()); + } + + private PopulationInfoDTO setPopulationInfo(PopulationDTO populationDTO) { + PopulationInfoDTO populationInfoDTO = new PopulationInfoDTO(); + populationInfoDTO.setIdcard(populationDTO.getCardNum()); + populationInfoDTO.setName(populationDTO.getName()); + populationInfoDTO.setPhone(populationDTO.getPhone()); + populationInfoDTO.setIdcardType("身份证"); + populationInfoService.getTuoMin(populationInfoDTO); + return populationInfoDTO; + } + + private List listBatch(Map params) { + List list = populationDao.listBatch(params); + return list; } @Override @@ -352,9 +446,72 @@ public class PopulationServiceImpl extends AbstractService implements IPopulatio PageHelper.startPage(page.getPage(), page.getRows()); List overList = houseDao.findPopulation(page.getParams()); - // 获取人口详情 + List populationInfoIds = new ArrayList<>(); + List houseIds = new ArrayList<>(); for (PopulationDTO populationDTO : overList) { - if(StringUtils.isNotEmpty(populationDTO.getPopulationInfoId())) { + if (StringUtils.isNotEmpty(populationDTO.getPopulationInfoId())) { + populationInfoIds.add(populationDTO.getPopulationInfoId()); + } + if (StringUtils.isNotEmpty(populationDTO.getHouseId())) { + houseIds.add(populationDTO.getHouseId()); + } + } + + // 一次性获取所有的人口信息 + List populationInfoDTOs = populationInfoService.getBatch(populationInfoIds); + // 一次性获取所有的房屋信息 + List houseDTOs = houseService.getBatch(houseIds); + + + Map populationInfoMap = null; + Map houseMap = null; + if (!CollectionUtils.isEmpty(populationInfoDTOs)) { + populationInfoMap = populationInfoDTOs.stream() + .collect(Collectors.toMap(PopulationInfoDTO::getPopulationInfoId, + populationInfoDTO -> populationInfoDTO)); + } + + if (!CollectionUtils.isEmpty(houseDTOs)) { + houseMap = houseDTOs.stream() + .collect(Collectors.toMap(HouseDTO::getHouseId, + houseDTO -> houseDTO)); + } + + for (PopulationDTO populationDTO : overList) { + if (StringUtils.isNotEmpty(populationDTO.getPopulationInfoId())) { + PopulationInfoDTO populationInfoDTO; + if(null != populationInfoMap) { + populationInfoDTO = populationInfoMap.get(populationDTO.getPopulationInfoId()); + populationInfoService.getTuoMin(populationInfoDTO); + }else { + populationInfoDTO = setPopulationInfo(populationDTO); + } + + PopulationInfoHouseDTO populationInfoHouseDTO = new PopulationInfoHouseDTO(); + BeanUtils.copyProperties(populationInfoDTO, populationInfoHouseDTO); + + + // 获取人员 + PopulationInfoBaseDTO base = populationInfoService.getBase(populationDTO.getPopulationInfoId()); + // populationInfoService.getTuoMin(base); + populationInfoHouseDTO.setPopulationInfoBaseDTO(base); + + populationDTO.setPopulationInfoHouseDTO(populationInfoHouseDTO); + populationDTO.setPopulationInfoDTO(populationInfoDTO); + }else { + PopulationInfoDTO populationInfoDTO = setPopulationInfo(populationDTO); + populationDTO.setPopulationInfoDTO(populationInfoDTO); + } + + if(null != houseMap) { + HouseDTO houseDTO = houseMap.get(populationDTO.getHouseId()); + populationDTO.setHouseDTO(houseDTO); + } + } + + // 获取人口详情 + /*for (PopulationDTO populationDTO : overList) { + if (StringUtils.isNotEmpty(populationDTO.getPopulationInfoId())) { PopulationInfoDTO populationInfoDTO = populationInfoService.get(populationDTO.getPopulationInfoId()); PopulationInfoHouseDTO populationInfoHouseDTO = new PopulationInfoHouseDTO(); BeanUtils.copyProperties(populationInfoDTO, populationInfoHouseDTO); @@ -369,10 +526,10 @@ public class PopulationServiceImpl extends AbstractService implements IPopulatio // 获取房屋详情 HouseDTO houseDTO = houseService.get(populationDTO.getHouseId()); - if(null != houseDTO) { + if (null != houseDTO) { populationDTO.setHouseDTO(houseDTO); } - } + }*/ PageInfo pageInfo = new PageInfo<>(overList); return new SuccessResultList<>(overList, pageInfo.getPageNum(), pageInfo.getTotal()); diff --git a/src/main/java/com/cm/population/service/populationinfo/IPopulationInfoService.java b/src/main/java/com/cm/population/service/populationinfo/IPopulationInfoService.java index 02662f4..d9dbd35 100644 --- a/src/main/java/com/cm/population/service/populationinfo/IPopulationInfoService.java +++ b/src/main/java/com/cm/population/service/populationinfo/IPopulationInfoService.java @@ -216,4 +216,5 @@ public interface IPopulationInfoService { void updateCreator(String populationInfoId, String creator); + List getBatch(List populationInfoIds); } \ No newline at end of file diff --git a/src/main/java/com/cm/population/service/populationinfo/impl/PopulationInfoServiceImpl.java b/src/main/java/com/cm/population/service/populationinfo/impl/PopulationInfoServiceImpl.java index daf6946..1a74f83 100644 --- a/src/main/java/com/cm/population/service/populationinfo/impl/PopulationInfoServiceImpl.java +++ b/src/main/java/com/cm/population/service/populationinfo/impl/PopulationInfoServiceImpl.java @@ -581,4 +581,11 @@ public class PopulationInfoServiceImpl extends AbstractService implements IPopul populationInfoDao.updateCreator(params); } + @Override + public List getBatch(List populationInfoIds) { + Map params = getHashMap(2); + params.put("populationInfoIds", populationInfoIds); + return populationInfoDao.getBatch(params); + } + } \ No newline at end of file diff --git a/src/main/resources/mybatis/mapper/house/house-mapper.xml b/src/main/resources/mybatis/mapper/house/house-mapper.xml index 494d10b..51699a1 100644 --- a/src/main/resources/mybatis/mapper/house/house-mapper.xml +++ b/src/main/resources/mybatis/mapper/house/house-mapper.xml @@ -1027,19 +1027,6 @@ AND is_vacant = #{isVacant} - - AND ( - t1.id LIKE CONCAT('%', #{keywords}, '%') - ) - - - AND - LEFT(t1.gmt_create, 10) = ]]> #{startTime} - - - AND - LEFT(t1.gmt_create, 10) #{endTime} - AND t1.house_id IN @@ -1078,4 +1065,68 @@ (t1.affiliation_unit + 0), (t1.affiliation_floors + 0), (t1.house_num + 0) ASC + + + \ No newline at end of file diff --git a/src/main/resources/mybatis/mapper/population/population-mapper.xml b/src/main/resources/mybatis/mapper/population/population-mapper.xml index 02a0096..ec94ec2 100644 --- a/src/main/resources/mybatis/mapper/population/population-mapper.xml +++ b/src/main/resources/mybatis/mapper/population/population-mapper.xml @@ -444,4 +444,50 @@ + + \ No newline at end of file diff --git a/src/main/resources/mybatis/mapper/populationinfo/population-info-mapper.xml b/src/main/resources/mybatis/mapper/populationinfo/population-info-mapper.xml index 371aaad..2350928 100644 --- a/src/main/resources/mybatis/mapper/populationinfo/population-info-mapper.xml +++ b/src/main/resources/mybatis/mapper/populationinfo/population-info-mapper.xml @@ -1266,4 +1266,98 @@ 1 = 1 + + + + \ No newline at end of file From a61ad138416ad1df0875e6216e65ff5ade4f5b32 Mon Sep 17 00:00:00 2001 From: Renpc-kilig <308442850@qq.com> Date: Fri, 24 Nov 2023 17:44:33 +0800 Subject: [PATCH 2/4] =?UTF-8?q?=E4=BC=98=E5=8C=96=E4=BB=A5=E4=BA=BA?= =?UTF-8?q?=E6=89=BE=E6=88=BF=EF=BC=8C=E4=BB=A5=E6=88=BF=E6=89=BE=E4=BA=BA?= =?UTF-8?q?=20=20--renpc?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pojo/dtos/population/PopulationDTO.java | 23 ++--- .../impl/PopulationServiceImpl.java | 95 ++++++++++++++----- 2 files changed, 82 insertions(+), 36 deletions(-) diff --git a/src/main/java/com/cm/population/pojo/dtos/population/PopulationDTO.java b/src/main/java/com/cm/population/pojo/dtos/population/PopulationDTO.java index 7feddfd..5e928e6 100644 --- a/src/main/java/com/cm/population/pojo/dtos/population/PopulationDTO.java +++ b/src/main/java/com/cm/population/pojo/dtos/population/PopulationDTO.java @@ -1,6 +1,7 @@ package com.cm.population.pojo.dtos.population; import com.cm.population.pojo.dtos.house.HouseDTO; +import com.cm.population.pojo.dtos.populationinfo.PopulationInfoBaseDTO; import com.cm.population.pojo.dtos.populationinfo.PopulationInfoDTO; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; @@ -44,10 +45,10 @@ public class PopulationDTO { private Integer isDelete; @ApiModelProperty(name = "houseDTO", value = "房屋详情") private HouseDTO houseDTO; - @ApiModelProperty(name = "populationInfoHouseDTO", value = "人口详情") - private PopulationInfoHouseDTO populationInfoHouseDTO; - @ApiModelProperty(name = "populationInfoDTO", value = "人口详情") + @ApiModelProperty(name = "populationInfoDTO", value = "人员基本信息") private PopulationInfoDTO populationInfoDTO; + @ApiModelProperty(name = "populationInfoBaseDTO", value = "人员基本信息") + private PopulationInfoBaseDTO populationInfoBaseDTO; public String getPopulationId() { return populationId == null ? "" : populationId.trim(); @@ -161,14 +162,6 @@ public class PopulationDTO { this.houseDTO = houseDTO; } - public PopulationInfoHouseDTO getPopulationInfoHouseDTO() { - return populationInfoHouseDTO; - } - - public void setPopulationInfoHouseDTO(PopulationInfoHouseDTO populationInfoHouseDTO) { - this.populationInfoHouseDTO = populationInfoHouseDTO; - } - public PopulationInfoDTO getPopulationInfoDTO() { return populationInfoDTO; } @@ -176,4 +169,12 @@ public class PopulationDTO { public void setPopulationInfoDTO(PopulationInfoDTO populationInfoDTO) { this.populationInfoDTO = populationInfoDTO; } + + public PopulationInfoBaseDTO getPopulationInfoBaseDTO() { + return populationInfoBaseDTO; + } + + public void setPopulationInfoBaseDTO(PopulationInfoBaseDTO populationInfoBaseDTO) { + this.populationInfoBaseDTO = populationInfoBaseDTO; + } } diff --git a/src/main/java/com/cm/population/service/population/impl/PopulationServiceImpl.java b/src/main/java/com/cm/population/service/population/impl/PopulationServiceImpl.java index 2a7378c..34d0926 100644 --- a/src/main/java/com/cm/population/service/population/impl/PopulationServiceImpl.java +++ b/src/main/java/com/cm/population/service/population/impl/PopulationServiceImpl.java @@ -10,18 +10,15 @@ import com.cm.population.dao.house.IHouseDao; import com.cm.population.dao.population.IPopulationDao; import com.cm.population.pojo.bos.population.PopulationBO; import com.cm.population.pojo.dtos.house.HouseDTO; -import com.cm.population.pojo.dtos.population.HouseUserDTO; import com.cm.population.pojo.dtos.population.PopulationDTO; import com.cm.population.pojo.dtos.population.PopulationInfoHouseDTO; import com.cm.population.pojo.dtos.populationinfo.PopulationInfoBaseDTO; import com.cm.population.pojo.dtos.populationinfo.PopulationInfoDTO; import com.cm.population.pojo.pos.population.PopulationPO; -import com.cm.population.pojo.vos.house.HouseVO; import com.cm.population.pojo.vos.population.PopulationVO; import com.cm.population.service.house.IHouseService; import com.cm.population.service.population.IPopulationService; import com.cm.population.service.populationinfo.IPopulationInfoService; -import com.cm.population.service.populationinfo.impl.PopulationInfoServiceImpl; import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; import org.apache.commons.lang3.StringUtils; @@ -29,12 +26,10 @@ import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.util.CollectionUtils; -import sun.security.krb5.internal.PAData; import javax.mail.search.SearchException; import java.util.*; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; +import java.util.concurrent.*; import java.util.stream.Collectors; /** @@ -436,6 +431,16 @@ public class PopulationServiceImpl extends AbstractService implements IPopulatio return populationInfoDTO; } + private PopulationInfoBaseDTO setPopulationBaseInfo(PopulationDTO populationDTO) { + PopulationInfoBaseDTO populationInfoDTO = new PopulationInfoBaseDTO(); + populationInfoDTO.setIdcard(populationDTO.getCardNum()); + populationInfoDTO.setName(populationDTO.getName()); + populationInfoDTO.setPhone(populationDTO.getPhone()); + populationInfoDTO.setIdcardType("身份证"); + populationInfoService.getTuoMin(populationInfoDTO); + return populationInfoDTO; + } + private List listBatch(Map params) { List list = populationDao.listBatch(params); return list; @@ -462,9 +467,35 @@ public class PopulationServiceImpl extends AbstractService implements IPopulatio // 一次性获取所有的房屋信息 List houseDTOs = houseService.getBatch(houseIds); + // 获取base + List populationInfoBaseDTOs = new ArrayList<>(); + int size = populationInfoIds.size(); + int numThreads = size / 2 + (size % 2 == 0 ? 0 : 1); // 计算需要的线程数 + ExecutorService executorService = Executors.newFixedThreadPool(numThreads); + + Callable> task = () -> { + List output = new ArrayList<>(); + for (String str : populationInfoIds) { + PopulationInfoBaseDTO base = populationInfoService.getBase(str); + output.add(base); + } + return output; + }; + + Future> futureResult = executorService.submit(task); + try { + List result = futureResult.get(); + populationInfoBaseDTOs.addAll(result); + executorService.shutdown(); + } catch (InterruptedException e) { + e.printStackTrace(); + } catch (ExecutionException e) { + e.printStackTrace(); + } Map populationInfoMap = null; Map houseMap = null; + Map baseMap = null; if (!CollectionUtils.isEmpty(populationInfoDTOs)) { populationInfoMap = populationInfoDTOs.stream() .collect(Collectors.toMap(PopulationInfoDTO::getPopulationInfoId, @@ -477,33 +508,29 @@ public class PopulationServiceImpl extends AbstractService implements IPopulatio houseDTO -> houseDTO)); } + if (!CollectionUtils.isEmpty(populationInfoBaseDTOs)) { + baseMap = populationInfoBaseDTOs.stream() + .collect(Collectors.toMap(PopulationInfoBaseDTO::getPopulationInfoId, + baseDTO -> baseDTO)); + } + for (PopulationDTO populationDTO : overList) { if (StringUtils.isNotEmpty(populationDTO.getPopulationInfoId())) { - PopulationInfoDTO populationInfoDTO; - if(null != populationInfoMap) { - populationInfoDTO = populationInfoMap.get(populationDTO.getPopulationInfoId()); - populationInfoService.getTuoMin(populationInfoDTO); + PopulationInfoBaseDTO populationInfoBaseDTO=null; + if (null != baseMap) { + // 获取人员 + populationInfoBaseDTO = baseMap.get(populationDTO.getPopulationInfoId()); }else { - populationInfoDTO = setPopulationInfo(populationDTO); + populationInfoBaseDTO = setPopulationBaseInfo(populationDTO); } - - PopulationInfoHouseDTO populationInfoHouseDTO = new PopulationInfoHouseDTO(); - BeanUtils.copyProperties(populationInfoDTO, populationInfoHouseDTO); - - - // 获取人员 - PopulationInfoBaseDTO base = populationInfoService.getBase(populationDTO.getPopulationInfoId()); - // populationInfoService.getTuoMin(base); - populationInfoHouseDTO.setPopulationInfoBaseDTO(base); - - populationDTO.setPopulationInfoHouseDTO(populationInfoHouseDTO); - populationDTO.setPopulationInfoDTO(populationInfoDTO); - }else { + populationInfoService.getTuoMin(populationInfoBaseDTO); + populationDTO.setPopulationInfoBaseDTO(populationInfoBaseDTO); + } else { PopulationInfoDTO populationInfoDTO = setPopulationInfo(populationDTO); populationDTO.setPopulationInfoDTO(populationInfoDTO); } - if(null != houseMap) { + if (null != houseMap) { HouseDTO houseDTO = houseMap.get(populationDTO.getHouseId()); populationDTO.setHouseDTO(houseDTO); } @@ -555,4 +582,22 @@ public class PopulationServiceImpl extends AbstractService implements IPopulatio return new SuccessResultList<>(populationDTOs, pageInfo.getPageNum(), pageInfo.getTotal()); } + public class getBase implements Runnable { + private List dataList; + private List baseDTOList; + + public getBase(List dataList, List baseDTOList) { + this.dataList = dataList; + this.baseDTOList = baseDTOList; + } + + @Override + public void run() { + for (String s : dataList) { + PopulationInfoBaseDTO base = populationInfoService.getBase(s); + baseDTOList.add(base); + } + } + } + } \ No newline at end of file From c4882be424ca469bc4f817cb37dd9fb8655dca5f Mon Sep 17 00:00:00 2001 From: Renpc-kilig <308442850@qq.com> Date: Fri, 24 Nov 2023 17:56:09 +0800 Subject: [PATCH 3/4] =?UTF-8?q?=E4=BC=98=E5=8C=96=E4=BB=A5=E4=BA=BA?= =?UTF-8?q?=E6=89=BE=E6=88=BF=EF=BC=8C=E4=BB=A5=E6=88=BF=E6=89=BE=E4=BA=BA?= =?UTF-8?q?=20=20--renpc?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/population/impl/PopulationServiceImpl.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/cm/population/service/population/impl/PopulationServiceImpl.java b/src/main/java/com/cm/population/service/population/impl/PopulationServiceImpl.java index 34d0926..4e5852d 100644 --- a/src/main/java/com/cm/population/service/population/impl/PopulationServiceImpl.java +++ b/src/main/java/com/cm/population/service/population/impl/PopulationServiceImpl.java @@ -523,11 +523,11 @@ public class PopulationServiceImpl extends AbstractService implements IPopulatio }else { populationInfoBaseDTO = setPopulationBaseInfo(populationDTO); } - populationInfoService.getTuoMin(populationInfoBaseDTO); + // populationInfoService.getTuoMin(populationInfoBaseDTO); populationDTO.setPopulationInfoBaseDTO(populationInfoBaseDTO); } else { - PopulationInfoDTO populationInfoDTO = setPopulationInfo(populationDTO); - populationDTO.setPopulationInfoDTO(populationInfoDTO); + PopulationInfoBaseDTO populationInfoBaseDTO = setPopulationBaseInfo(populationDTO); + populationDTO.setPopulationInfoBaseDTO(populationInfoBaseDTO); } if (null != houseMap) { From 024e5ab28080d3c895749eba5ac842a0c400c4b6 Mon Sep 17 00:00:00 2001 From: TS-QD1 Date: Fri, 24 Nov 2023 18:34:11 +0800 Subject: [PATCH 4/4] =?UTF-8?q?=E5=90=8E=E5=8F=B0=E8=BF=90=E8=A1=8C?= =?UTF-8?q?=E5=8C=BA=E5=9F=9F=E5=88=9D=E5=A7=8B=E5=8C=96=E5=B7=A5=E4=BD=9C?= =?UTF-8?q?=EF=BC=8C=E5=A4=84=E7=90=86=E5=AE=9E=E4=BD=93=E7=B1=BB=E4=B8=AD?= =?UTF-8?q?null=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/population/PopulationController.java | 14 ++-- .../populationinfo/PopulationInfoBaseDTO.java | 9 ++- .../impl/PopulationServiceImpl.java | 4 +- .../com/cm/population/utils/AreaUtils.java | 64 ++++++++++--------- .../templates/house/list-summary.html | 8 ++- 5 files changed, 54 insertions(+), 45 deletions(-) diff --git a/src/main/java/com/cm/population/controller/api/population/PopulationController.java b/src/main/java/com/cm/population/controller/api/population/PopulationController.java index 859f304..232a3ad 100644 --- a/src/main/java/com/cm/population/controller/api/population/PopulationController.java +++ b/src/main/java/com/cm/population/controller/api/population/PopulationController.java @@ -139,13 +139,13 @@ public class PopulationController extends AbstractController { @GetMapping("findHouse") public SuccessResultList> findHouse(ListPage page) { Map params = requestParams(); - if(null == params.get("keywords")) { - try { - throw new SearchException("身份证号/手机号/姓名不能为空"); - } catch (SearchException e) { - e.printStackTrace(); - } - } +// if(null == params.get("keywords")) { +// try { +// throw new SearchException("身份证号/手机号/姓名不能为空"); +// } catch (SearchException e) { +// e.printStackTrace(); +// } +// } page.setParams(params); return populationService.findHouse(page); } diff --git a/src/main/java/com/cm/population/pojo/dtos/populationinfo/PopulationInfoBaseDTO.java b/src/main/java/com/cm/population/pojo/dtos/populationinfo/PopulationInfoBaseDTO.java index 1408dc1..355cc17 100644 --- a/src/main/java/com/cm/population/pojo/dtos/populationinfo/PopulationInfoBaseDTO.java +++ b/src/main/java/com/cm/population/pojo/dtos/populationinfo/PopulationInfoBaseDTO.java @@ -95,7 +95,7 @@ public class PopulationInfoBaseDTO { } public String getHealthStatus() { - return healthStatus; + return healthStatus == null ? "" : healthStatus; } public void setHealthStatus(String healthStatus) { @@ -103,7 +103,7 @@ public class PopulationInfoBaseDTO { } public String getIsMinority() { - if(getAge() < 18) { + if (getAge() < 18) { return "是"; } return "否"; @@ -114,7 +114,7 @@ public class PopulationInfoBaseDTO { } public String getIsSeriousIllness() { - if(getHealthStatus().contains("重病")) { + if (getHealthStatus().contains("重病")) { return "是"; } return "否"; @@ -125,6 +125,9 @@ public class PopulationInfoBaseDTO { } public Integer getAge() { + if (StringUtils.isBlank(this.getBirthday())) { + return 0; + } LocalDate birthDate = LocalDate.parse(this.birthday); Period period = Period.between(birthDate, LocalDate.now()); return period.getYears(); diff --git a/src/main/java/com/cm/population/service/population/impl/PopulationServiceImpl.java b/src/main/java/com/cm/population/service/population/impl/PopulationServiceImpl.java index 4e5852d..b8a3da2 100644 --- a/src/main/java/com/cm/population/service/population/impl/PopulationServiceImpl.java +++ b/src/main/java/com/cm/population/service/population/impl/PopulationServiceImpl.java @@ -516,11 +516,11 @@ public class PopulationServiceImpl extends AbstractService implements IPopulatio for (PopulationDTO populationDTO : overList) { if (StringUtils.isNotEmpty(populationDTO.getPopulationInfoId())) { - PopulationInfoBaseDTO populationInfoBaseDTO=null; + PopulationInfoBaseDTO populationInfoBaseDTO = null; if (null != baseMap) { // 获取人员 populationInfoBaseDTO = baseMap.get(populationDTO.getPopulationInfoId()); - }else { + } else { populationInfoBaseDTO = setPopulationBaseInfo(populationDTO); } // populationInfoService.getTuoMin(populationInfoBaseDTO); diff --git a/src/main/java/com/cm/population/utils/AreaUtils.java b/src/main/java/com/cm/population/utils/AreaUtils.java index 130db51..4f099f3 100644 --- a/src/main/java/com/cm/population/utils/AreaUtils.java +++ b/src/main/java/com/cm/population/utils/AreaUtils.java @@ -31,17 +31,19 @@ public class AreaUtils { @PostConstruct public void init() { - PopulationInfoStaticService = PopulationInfoService; - initArea0(); - initArea1(); - initArea2(); - initArea3(); - initArea4(); - aree.put(0, area0); - aree.put(1, area1); - aree.put(2, area2); - aree.put(3, area3); - aree.put(4, area4); + new Thread(() -> { + PopulationInfoStaticService = PopulationInfoService; + initArea0(); + initArea1(); + initArea2(); + initArea3(); + initArea4(); + aree.put(0, area0); + aree.put(1, area1); + aree.put(2, area2); + aree.put(3, area3); + aree.put(4, area4); + }).start(); } public List getList(String id) { @@ -50,7 +52,7 @@ public class AreaUtils { Integer level = -1; Integer subCount = 0; // 确定级别 - if (!StringUtils.isEmpty(id) ) { + if (!StringUtils.isEmpty(id)) { AreaZtreeDTO areaDTO = PopulationInfoStaticService.getAreaByAreaId(id); level = Integer.valueOf(areaDTO.getAreaLevel()); subCount = areaDTO.getSubCount(); @@ -58,11 +60,11 @@ public class AreaUtils { Map dataMap = aree.get(level + 1); if (dataMap != null) { // 找出所有的子类 - for(Map.Entry m : dataMap.entrySet()) { + for (Map.Entry m : dataMap.entrySet()) { AreaZtreeDTO ztreeDTO = m.getValue(); String pId = ztreeDTO.getpId(); String title = ztreeDTO.getTitle(); - if(!StringUtils.isEmpty(id) && pId.equals(id)) { + if (!StringUtils.isEmpty(id) && pId.equals(id)) { if (StringUtils.isEmpty(title)) { ArrayList names = new ArrayList<>(); getParent(level, names, id); @@ -74,14 +76,14 @@ public class AreaUtils { break; } } - if(StringUtils.isEmpty(id)) { + if (StringUtils.isEmpty(id)) { ztreeDTO.setTitle(ztreeDTO.getName()); list.add(ztreeDTO); } } } - return list; + return list; } // 递归拼接全名称 @@ -89,11 +91,11 @@ public class AreaUtils { Map dataMap = aree.get(level); if (level > -1 && dataMap != null) { level--; - for(Map.Entry m : dataMap.entrySet()) { + for (Map.Entry m : dataMap.entrySet()) { String id = m.getValue().getId(); - if(pId.equals(id)) { + if (pId.equals(id)) { names.add(0, m.getValue().getName()); - getParent(level, names, m.getValue().getpId()); + getParent(level, names, m.getValue().getpId()); break; } } @@ -103,8 +105,8 @@ public class AreaUtils { private static void initArea0() { List dto = PopulationInfoStaticService.getAreaListByLevel("0", -1); - for(AreaZtreeDTO areaDTO : dto) { - if (areaDTO.getSubCount() > 0 ) { + for (AreaZtreeDTO areaDTO : dto) { + if (areaDTO.getSubCount() > 0) { areaDTO.setIsParent(true); } area0.put(areaDTO.getId(), areaDTO); @@ -113,8 +115,8 @@ public class AreaUtils { private static void initArea1() { List dto = PopulationInfoStaticService.getAreaListByLevel("1", -1); - for(AreaZtreeDTO areaDTO : dto) { - if (areaDTO.getSubCount() > 0 ) { + for (AreaZtreeDTO areaDTO : dto) { + if (areaDTO.getSubCount() > 0) { areaDTO.setIsParent(true); } area1.put(areaDTO.getId(), areaDTO); @@ -123,8 +125,8 @@ public class AreaUtils { private static void initArea2() { List dto = PopulationInfoStaticService.getAreaListByLevel("2", -1); - for(AreaZtreeDTO areaDTO : dto) { - if (areaDTO.getSubCount() > 0 ) { + for (AreaZtreeDTO areaDTO : dto) { + if (areaDTO.getSubCount() > 0) { areaDTO.setIsParent(true); } area2.put(areaDTO.getId(), areaDTO); @@ -132,10 +134,10 @@ public class AreaUtils { } private static void initArea3() { - for(int i = 0 ; i < 9 ; i++ ) { + for (int i = 0; i < 9; i++) { List dto = PopulationInfoStaticService.getAreaListByLevel("3", i); - for(AreaZtreeDTO areaDTO : dto) { - if (areaDTO.getSubCount() > 0 ) { + for (AreaZtreeDTO areaDTO : dto) { + if (areaDTO.getSubCount() > 0) { areaDTO.setIsParent(true); } area3.put(areaDTO.getId(), areaDTO); @@ -144,10 +146,10 @@ public class AreaUtils { } private static void initArea4() { - for(int i = 0 ; i < 67 ; i++ ) { + for (int i = 0; i < 67; i++) { List dto = PopulationInfoStaticService.getAreaListByLevel("4", i); - for(AreaZtreeDTO areaDTO : dto) { - if (areaDTO.getSubCount() > 0 ) { + for (AreaZtreeDTO areaDTO : dto) { + if (areaDTO.getSubCount() > 0) { areaDTO.setIsParent(true); } area4.put(areaDTO.getId(), areaDTO); diff --git a/src/main/resources/templates/house/list-summary.html b/src/main/resources/templates/house/list-summary.html index 3d6f13a..3cdbef2 100644 --- a/src/main/resources/templates/house/list-summary.html +++ b/src/main/resources/templates/house/list-summary.html @@ -407,12 +407,16 @@ var renderMain = function() { var main = ''; $.each(data.floors, function(index, item) { - var units = ''; $.each(item.units, function(jndex, jtem) { - var houses = ''; if(jtem.houses.length > data.units[jndex].maxHouseCount) { data.units[jndex].maxHouseCount = jtem.houses.length; } + }); + }); + $.each(data.floors, function(index, item) { + var units = ''; + $.each(item.units, function(jndex, jtem) { + var houses = ''; $.each(jtem.houses, function(kndex, ktem) { var option = ktem.isCreator === 1 ? `