优化房屋汇总列表执行速度 --renpc

This commit is contained in:
Renpc-kilig 2023-11-21 17:04:12 +08:00
parent 7946224c1b
commit f96265706c
5 changed files with 47 additions and 7 deletions

View File

@ -124,4 +124,6 @@ public interface IHouseDao {
* @return * @return
*/ */
List<PopulationDTO> findPopulation(Map<String, Object> params); List<PopulationDTO> findPopulation(Map<String, Object> params);
List<HouseDTO> listForAll(Map<String, Object> params);
} }

View File

@ -129,6 +129,8 @@ public class HouseDTO {
private String houseType; private String houseType;
@ApiModelProperty(name = "populationVOList", value = "同住人信息") @ApiModelProperty(name = "populationVOList", value = "同住人信息")
private List<PopulationDTO> populationDTOList; private List<PopulationDTO> populationDTOList;
@ApiModelProperty(name = "count", value = "房屋人员")
private Integer count;
public String getHouseId() { public String getHouseId() {
return houseId; return houseId;
@ -577,4 +579,12 @@ public class HouseDTO {
public void setPopulationDTOList(List<PopulationDTO> populationDTOList) { public void setPopulationDTOList(List<PopulationDTO> populationDTOList) {
this.populationDTOList = populationDTOList; this.populationDTOList = populationDTOList;
} }
public Integer getCount() {
return count;
}
public void setCount(Integer count) {
this.count = count;
}
} }

View File

@ -262,7 +262,7 @@ public class HouseServiceImpl extends AbstractService implements IHouseService {
batchHouseDTO.setUnitCount(unitNum.toString()); batchHouseDTO.setUnitCount(unitNum.toString());
// 获取当前楼栋下的所有房屋信息 // 获取当前楼栋下的所有房屋信息
List<HouseDTO> houseDTOList = houseDao.list(params); List<HouseDTO> houseDTOList = houseDao.listForAll(params);
List<BatchHouseDTO.Floor> floorList = new ArrayList<>(); List<BatchHouseDTO.Floor> floorList = new ArrayList<>();
for (int i = 1; i <= floorsNum; i++) { for (int i = 1; i <= floorsNum; i++) {
@ -281,7 +281,7 @@ public class HouseServiceImpl extends AbstractService implements IHouseService {
BatchHouseDTO.House house = new BatchHouseDTO.House(); BatchHouseDTO.House house = new BatchHouseDTO.House();
if (null != houseDTO.getAffiliationFloors()) { if (null != houseDTO.getAffiliationFloors()) {
if (i == Integer.valueOf(houseDTO.getAffiliationFloors())) { if (i == Integer.valueOf(houseDTO.getAffiliationFloors())) {
if (null != houseDTO.getAffiliatedUnit()) { if (null != houseDTO.getAffiliationUnit()) {
if (j == Integer.valueOf(houseDTO.getAffiliationUnit())) { if (j == Integer.valueOf(houseDTO.getAffiliationUnit())) {
house.setIsCreator(0); house.setIsCreator(0);
house.setPopulationCount(0); house.setPopulationCount(0);
@ -291,9 +291,9 @@ public class HouseServiceImpl extends AbstractService implements IHouseService {
if (userId.equals(houseDTO.getCreator()) || isAdmin()) { if (userId.equals(houseDTO.getCreator()) || isAdmin()) {
house.setIsCreator(1); house.setIsCreator(1);
// 获取当前房屋内的人数 // 获取当前房屋内的人数
params.put("houseId", houseDTO.getHouseId()); /*params.put("houseId", houseDTO.getHouseId());
Integer count = populationService.count(params); Integer count = populationService.count(params);*/
house.setPopulationCount(count); house.setPopulationCount(houseDTO.getCount());
} }
houseList.add(house); houseList.add(house);
} }

View File

@ -361,7 +361,7 @@ public class PopulationServiceImpl extends AbstractService implements IPopulatio
// 获取人员 // 获取人员
PopulationInfoBaseDTO base = populationInfoService.getBase(populationDTO.getPopulationInfoId()); PopulationInfoBaseDTO base = populationInfoService.getBase(populationDTO.getPopulationInfoId());
populationInfoService.getTuoMin(base); // populationInfoService.getTuoMin(base);
populationInfoHouseDTO.setPopulationInfoBaseDTO(base); populationInfoHouseDTO.setPopulationInfoBaseDTO(base);
populationDTO.setPopulationInfoHouseDTO(populationInfoHouseDTO); populationDTO.setPopulationInfoHouseDTO(populationInfoHouseDTO);

View File

@ -57,6 +57,7 @@
<result column="is_delete" property="isDelete"/> <result column="is_delete" property="isDelete"/>
<result column="street" property="street"/> <result column="street" property="street"/>
<result column="street_name" property="streetName"/> <result column="street_name" property="streetName"/>
<result column="count" property="count"/>
</resultMap> </resultMap>
<resultMap id="houseBO" type="com.cm.population.pojo.bos.house.HouseBO"> <resultMap id="houseBO" type="com.cm.population.pojo.bos.house.HouseBO">
@ -795,7 +796,7 @@
hp.population_info_id = #{populationInfoId} hp.population_info_id = #{populationInfoId}
) )
</if> </if>
ORDER BY house_num ASC ORDER BY affiliation_unit, affiliation_floors, house_num ASC
</select> </select>
<!-- 房院管理列表 --> <!-- 房院管理列表 -->
@ -1054,4 +1055,31 @@
</if> </if>
</select> </select>
<select id="listForAll" parameterType="map" resultMap="houseDTO">
SELECT
t1.house_id,
t1.building_id,
t1.affiliation_unit,
t1.affiliation_floors,
t1.house_num,
t1.creator,
t1.gmt_create,
COUNT(t2.house_id) as count,
1
FROM
house_house t1 LEFT JOIN house_population t2 ON t1.house_id = t2.house_id
WHERE
t1.is_delete = 0
<if test="buildingId != null and buildingId != ''">
AND building_id = #{buildingId}
</if>
GROUP BY t1.house_id,
t1.building_id,
t1.affiliation_unit,
t1.affiliation_floors,
t1.house_num,
t1.creator,
t1.gmt_create
</select>
</mapper> </mapper>