Merge remote-tracking branch 'origin/upgrade' into upgrade
This commit is contained in:
commit
ff3c2f88fb
@ -159,4 +159,12 @@ public class PopulationController extends AbstractController {
|
||||
return populationService.findPopulation(page);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "房屋列表(房主)", notes = "房屋列表(房主)接口")
|
||||
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
|
||||
@GetMapping("houseOwner")
|
||||
public List<HouseDTO> houseOwner() {
|
||||
Map<String, Object> params = requestParams();
|
||||
return populationService.houseOwner(params);
|
||||
}
|
||||
|
||||
}
|
@ -131,4 +131,8 @@ public interface IHouseDao {
|
||||
List<HouseDTO> getBatch(Map<String, Object> params);
|
||||
|
||||
List<HouseDTO> getUserHouse(HashMap<Object, Object> objectObjectHashMap);
|
||||
|
||||
List<HouseDTO> getNoOwnerList(Map<String, Object> params);
|
||||
|
||||
List<HouseDTO> getHasOwnerList(Map<String, Object> params);
|
||||
}
|
@ -212,7 +212,7 @@ public interface IPopulationService {
|
||||
* @param page
|
||||
* @return
|
||||
*/
|
||||
SuccessResultList<List<PopulationDTO>> findPopulation(ListPage pag);
|
||||
SuccessResultList<List<PopulationDTO>> findPopulation(ListPage page);
|
||||
|
||||
/**
|
||||
* 搬离房屋
|
||||
@ -220,4 +220,6 @@ public interface IPopulationService {
|
||||
void updateOuthouseTrue(String token, List<String> populationIds) ;
|
||||
|
||||
SuccessResultList<List<PopulationDTO>> listPageAll(ListPage page);
|
||||
|
||||
List<HouseDTO> houseOwner(Map<String, Object> params);
|
||||
}
|
@ -30,6 +30,7 @@ import org.springframework.util.CollectionUtils;
|
||||
import javax.mail.search.SearchException;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.*;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
@ -640,4 +641,87 @@ public class PopulationServiceImpl extends AbstractService implements IPopulatio
|
||||
return new SuccessResultList<>(populationDTOs, pageInfo.getPageNum(), pageInfo.getTotal());
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<HouseDTO> houseOwner(Map<String, Object> params) {
|
||||
// 获取没有房主的房屋
|
||||
List<HouseDTO> noHomeOwner = houseDao.getNoOwnerList(params);
|
||||
// 获取有房主的房屋
|
||||
List<HouseDTO> hasHomeOwner = houseDao.getHasOwnerList(params);
|
||||
|
||||
this.setHomeOwner(noHomeOwner, params);
|
||||
|
||||
List<HouseDTO> houseDTOs = new ArrayList<>();
|
||||
houseDTOs.addAll(noHomeOwner);
|
||||
houseDTOs.addAll(hasHomeOwner);
|
||||
|
||||
System.out.println(houseDTOs.size());
|
||||
|
||||
return houseDTOs;
|
||||
}
|
||||
|
||||
/**
|
||||
* 遍历房屋信息
|
||||
* 存在房主信息,不做处理
|
||||
* 不存在房主信息,则查找房屋同住人,将第一个人填充成为房主
|
||||
*
|
||||
* @param houseDTOList
|
||||
* @param params
|
||||
*/
|
||||
private void setHomeOwner(List<HouseDTO> houseDTOList, Map<String, Object> params) {
|
||||
// 遍历房屋信息
|
||||
// 存在房主信息,不做处理
|
||||
// 不存在房主信息,则查找房屋同住人,将第一个人填充成为房主
|
||||
int size = houseDTOList.size();
|
||||
// 计算需要的线程数
|
||||
int numThreads = size / 2500 + (size % 2500 == 0 ? 0 : 1);
|
||||
numThreads = numThreads == 0 ? 1 : numThreads;
|
||||
ExecutorService executorService = Executors.newFixedThreadPool(numThreads);
|
||||
// 获取base
|
||||
List<Future<Void>> futures = new ArrayList<>();
|
||||
|
||||
// 将houseDTOs分割成多个子列表,每个子列表由一个任务处理
|
||||
int chunkSize = (int) Math.ceil((double) houseDTOList.size() / numThreads);
|
||||
chunkSize = chunkSize == 0 ? 1 : chunkSize;
|
||||
List<List<HouseDTO>> chunks = Lists.partition(houseDTOList, chunkSize);
|
||||
|
||||
for (List<HouseDTO> chunk : chunks) {
|
||||
Future<Void> future = executorService.submit(() -> {
|
||||
for (HouseDTO houseDTO : chunk) {
|
||||
params.put("houseId", houseDTO.getHouseId());
|
||||
try {
|
||||
if (StringUtils.isEmpty(houseDTO.getHomeowner())) {
|
||||
// 获取同住人
|
||||
List<PopulationDTO> populationDTOList = list(params);
|
||||
if (!CollectionUtils.isEmpty(populationDTOList)) {
|
||||
PopulationDTO populationDTO = populationDTOList.get(0);
|
||||
houseDTO.setHomeowner(populationDTO.getName());
|
||||
houseDTO.setOwnerPopulationId(populationDTO.getPopulationInfoId());
|
||||
houseDTO.setDocumentNum(populationDTO.getCardNum());
|
||||
houseDTO.setPhone(populationDTO.getPhone());
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
// 处理或记录异常
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
});
|
||||
futures.add(future);
|
||||
}
|
||||
|
||||
// 等待所有异步任务完成
|
||||
for (Future<Void> future : futures) {
|
||||
try {
|
||||
future.get();
|
||||
} catch (Exception e) {
|
||||
// 处理异常
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
// 关闭线程池
|
||||
executorService.shutdown();
|
||||
}
|
||||
|
||||
}
|
@ -1266,4 +1266,236 @@
|
||||
OR (t1.custodian_document_num IS NOT NULL AND t1.custodian_document_num <> '')
|
||||
</select>
|
||||
|
||||
<select id="getHasOwnerList" parameterType="map" resultMap="houseDTO">
|
||||
SELECT
|
||||
t1.house_id,
|
||||
t1.street,
|
||||
t1.street_name,
|
||||
t1.community,
|
||||
t1.community_name,
|
||||
t1.residential_id,
|
||||
t1.residential_name,
|
||||
t1.building_id,
|
||||
t1.building_name,
|
||||
t1.affiliation_unit,
|
||||
t1.affiliation_floors,
|
||||
t1.house_num,
|
||||
t1.category_id,
|
||||
t1.category_name,
|
||||
t1.nature_id,
|
||||
t1.nature_name,
|
||||
t1.type_id,
|
||||
t1.type_name,
|
||||
t1.structure_id,
|
||||
t1.structure_name,
|
||||
t1.building_purpose_id,
|
||||
t1.building_purpose_name,
|
||||
t1.room_num,
|
||||
t1.room_area,
|
||||
t1.room_use_id,
|
||||
t1.room_use_name,
|
||||
t1.danger_id,
|
||||
t1.danger_name,
|
||||
t1.certificate_num,
|
||||
t1.registration_date,
|
||||
t1.affiliated_unit,
|
||||
t1.is_rental,
|
||||
t1.is_vacant,
|
||||
t1.is_self,
|
||||
t1.lodge_type_id,
|
||||
t1.lodge_type_name,
|
||||
t1.rental_purposes,
|
||||
t1.owner_population_id,
|
||||
t1.homeowner,
|
||||
t1.document_id,
|
||||
t1.document_name,
|
||||
t1.document_num,
|
||||
t1.phone,
|
||||
t1.owner_population_id,
|
||||
t1.custodian,
|
||||
t1.custodian_document_id,
|
||||
t1.custodian_document_name,
|
||||
t1.custodian_document_num,
|
||||
t1.custodian_phone,
|
||||
t1.relationship_homeowner,
|
||||
t1.creator,
|
||||
t1.gmt_create,
|
||||
t1.modifier,
|
||||
t1.gmt_modified,
|
||||
t1.is_delete,
|
||||
1
|
||||
FROM
|
||||
house_house t1
|
||||
WHERE
|
||||
t1.is_delete = 0
|
||||
AND (homeowner is NOT NULL AND homeowner <![CDATA[<>]]> '')
|
||||
<if test="creator != null and creator != ''">
|
||||
AND t1.creator = #{creator}
|
||||
</if>
|
||||
<if test="street != null and street != ''">
|
||||
AND street = #{street}
|
||||
</if>
|
||||
<if test="streetName != null and streetName != ''">
|
||||
AND street_name = #{streetName}
|
||||
</if>
|
||||
<if test="community != null and community != ''">
|
||||
AND community = #{community}
|
||||
</if>
|
||||
<if test="communityName != null and communityName != ''">
|
||||
AND community_name = #{communityName}
|
||||
</if>
|
||||
<if test="residentialId != null and residentialId != ''">
|
||||
AND residential_id = #{residentialId}
|
||||
</if>
|
||||
<if test="residentialName != null and residentialName != ''">
|
||||
AND residential_name = #{residentialName}
|
||||
</if>
|
||||
<if test="buildingId != null and buildingId != ''">
|
||||
AND building_id = #{buildingId}
|
||||
</if>
|
||||
<if test="buildingName != null and buildingName != ''">
|
||||
AND building_name = #{buildingName}
|
||||
</if>
|
||||
<if test="affiliationUnit != null and affiliationUnit != ''">
|
||||
AND affiliation_unit = #{affiliationUnit}
|
||||
</if>
|
||||
<if test="affiliationFloors != null and affiliationFloors != ''">
|
||||
AND affiliation_floors = #{affiliationFloors}
|
||||
</if>
|
||||
<if test="houseNum != null and houseNum != ''">
|
||||
AND house_num = #{houseNum}
|
||||
</if>
|
||||
<if test="isRental != null">
|
||||
AND is_rental = #{isRental}
|
||||
</if>
|
||||
<if test="isVacant != null">
|
||||
AND is_vacant = #{isVacant}
|
||||
</if>
|
||||
<if test="isSelf != null">
|
||||
AND is_self = #{isSelf}
|
||||
</if>
|
||||
<if test="keywords != null and keywords != ''">
|
||||
AND (
|
||||
t1.house_num LIKE CONCAT('%', #{keywords}, '%')
|
||||
)
|
||||
</if>
|
||||
ORDER BY (affiliation_unit + 0), (affiliation_floors + 0), (house_num + 0) ASC
|
||||
</select>
|
||||
|
||||
<select id="getNoOwnerList" parameterType="map" resultMap="houseDTO">
|
||||
SELECT
|
||||
t1.house_id,
|
||||
t1.street,
|
||||
t1.street_name,
|
||||
t1.community,
|
||||
t1.community_name,
|
||||
t1.residential_id,
|
||||
t1.residential_name,
|
||||
t1.building_id,
|
||||
t1.building_name,
|
||||
t1.affiliation_unit,
|
||||
t1.affiliation_floors,
|
||||
t1.house_num,
|
||||
t1.category_id,
|
||||
t1.category_name,
|
||||
t1.nature_id,
|
||||
t1.nature_name,
|
||||
t1.type_id,
|
||||
t1.type_name,
|
||||
t1.structure_id,
|
||||
t1.structure_name,
|
||||
t1.building_purpose_id,
|
||||
t1.building_purpose_name,
|
||||
t1.room_num,
|
||||
t1.room_area,
|
||||
t1.room_use_id,
|
||||
t1.room_use_name,
|
||||
t1.danger_id,
|
||||
t1.danger_name,
|
||||
t1.certificate_num,
|
||||
t1.registration_date,
|
||||
t1.affiliated_unit,
|
||||
t1.is_rental,
|
||||
t1.is_vacant,
|
||||
t1.is_self,
|
||||
t1.lodge_type_id,
|
||||
t1.lodge_type_name,
|
||||
t1.rental_purposes,
|
||||
t1.owner_population_id,
|
||||
t1.homeowner,
|
||||
t1.document_id,
|
||||
t1.document_name,
|
||||
t1.document_num,
|
||||
t1.phone,
|
||||
t1.owner_population_id,
|
||||
t1.custodian,
|
||||
t1.custodian_document_id,
|
||||
t1.custodian_document_name,
|
||||
t1.custodian_document_num,
|
||||
t1.custodian_phone,
|
||||
t1.relationship_homeowner,
|
||||
t1.creator,
|
||||
t1.gmt_create,
|
||||
t1.modifier,
|
||||
t1.gmt_modified,
|
||||
t1.is_delete,
|
||||
1
|
||||
FROM
|
||||
house_house t1
|
||||
WHERE
|
||||
t1.is_delete = 0
|
||||
AND (homeowner is NULL OR homeowner = '')
|
||||
<if test="creator != null and creator != ''">
|
||||
AND t1.creator = #{creator}
|
||||
</if>
|
||||
<if test="street != null and street != ''">
|
||||
AND street = #{street}
|
||||
</if>
|
||||
<if test="streetName != null and streetName != ''">
|
||||
AND street_name = #{streetName}
|
||||
</if>
|
||||
<if test="community != null and community != ''">
|
||||
AND community = #{community}
|
||||
</if>
|
||||
<if test="communityName != null and communityName != ''">
|
||||
AND community_name = #{communityName}
|
||||
</if>
|
||||
<if test="residentialId != null and residentialId != ''">
|
||||
AND residential_id = #{residentialId}
|
||||
</if>
|
||||
<if test="residentialName != null and residentialName != ''">
|
||||
AND residential_name = #{residentialName}
|
||||
</if>
|
||||
<if test="buildingId != null and buildingId != ''">
|
||||
AND building_id = #{buildingId}
|
||||
</if>
|
||||
<if test="buildingName != null and buildingName != ''">
|
||||
AND building_name = #{buildingName}
|
||||
</if>
|
||||
<if test="affiliationUnit != null and affiliationUnit != ''">
|
||||
AND affiliation_unit = #{affiliationUnit}
|
||||
</if>
|
||||
<if test="affiliationFloors != null and affiliationFloors != ''">
|
||||
AND affiliation_floors = #{affiliationFloors}
|
||||
</if>
|
||||
<if test="houseNum != null and houseNum != ''">
|
||||
AND house_num = #{houseNum}
|
||||
</if>
|
||||
<if test="isRental != null">
|
||||
AND is_rental = #{isRental}
|
||||
</if>
|
||||
<if test="isVacant != null">
|
||||
AND is_vacant = #{isVacant}
|
||||
</if>
|
||||
<if test="isSelf != null">
|
||||
AND is_self = #{isSelf}
|
||||
</if>
|
||||
<if test="keywords != null and keywords != ''">
|
||||
AND (
|
||||
t1.house_num LIKE CONCAT('%', #{keywords}, '%')
|
||||
)
|
||||
</if>
|
||||
ORDER BY (affiliation_unit + 0), (affiliation_floors + 0), (house_num + 0) ASC
|
||||
</select>
|
||||
|
||||
</mapper>
|
Loading…
Reference in New Issue
Block a user