diff --git a/src/main/java/com/cm/population/controller/api/residential/ResidentialController.java b/src/main/java/com/cm/population/controller/api/residential/ResidentialController.java index d0576f4..1fdbcb6 100644 --- a/src/main/java/com/cm/population/controller/api/residential/ResidentialController.java +++ b/src/main/java/com/cm/population/controller/api/residential/ResidentialController.java @@ -246,4 +246,11 @@ public class ResidentialController extends AbstractController { return new SuccessResult(); } + @ApiOperation(value = "房屋房主信息数据修复", notes = "房屋房主信息数据修复接口") + @GetMapping("dataCover") + public SuccessResult dataCover() { + residentialService.dataCover(); + return new SuccessResult(); + } + } \ No newline at end of file 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 9517cd3..80b06d2 100644 --- a/src/main/java/com/cm/population/dao/house/IHouseDao.java +++ b/src/main/java/com/cm/population/dao/house/IHouseDao.java @@ -10,6 +10,7 @@ import com.cm.population.pojo.dtos.population.PopulationDTO; import com.cm.population.pojo.pos.house.HousePO; import org.springframework.stereotype.Repository; +import java.util.HashMap; import java.util.List; import java.util.Map; @@ -128,4 +129,6 @@ public interface IHouseDao { List listForAll(Map params); List getBatch(Map params); + + List getUserHouse(HashMap objectObjectHashMap); } \ No newline at end of file diff --git a/src/main/java/com/cm/population/dao/residential/IResidentialDao.java b/src/main/java/com/cm/population/dao/residential/IResidentialDao.java index 5d30eee..2a2c31c 100644 --- a/src/main/java/com/cm/population/dao/residential/IResidentialDao.java +++ b/src/main/java/com/cm/population/dao/residential/IResidentialDao.java @@ -5,6 +5,8 @@ import com.cm.common.exception.SaveException; import com.cm.common.exception.SearchException; import com.cm.common.exception.UpdateException; import com.cm.population.pojo.bos.residential.ResidentialBO; +import com.cm.population.pojo.dtos.house.HouseDTO; +import com.cm.population.pojo.dtos.populationinfo.PopulationInfoBaseDTO; import com.cm.population.pojo.dtos.residential.ResidentialDTO; import com.cm.population.pojo.pos.residential.ResidentialPO; import org.springframework.stereotype.Repository; @@ -120,4 +122,10 @@ public interface IResidentialDao { String getCommunityId(String community); String getStreetId(String street); + + PopulationInfoBaseDTO getPopu(Map params); + + PopulationInfoBaseDTO getPopu2(Map params); + + void updateHouse(Map params); } \ No newline at end of file diff --git a/src/main/java/com/cm/population/service/residential/IResidentialService.java b/src/main/java/com/cm/population/service/residential/IResidentialService.java index 804f723..e66eca0 100644 --- a/src/main/java/com/cm/population/service/residential/IResidentialService.java +++ b/src/main/java/com/cm/population/service/residential/IResidentialService.java @@ -188,4 +188,9 @@ public interface IResidentialService { String getCommunityId(String community); String getStreetId(String street); + + /** + * 房屋房主信息数据修复 + */ + void dataCover(); } \ No newline at end of file diff --git a/src/main/java/com/cm/population/service/residential/impl/ResidentialServiceImpl.java b/src/main/java/com/cm/population/service/residential/impl/ResidentialServiceImpl.java index 931d0a1..a4e07cc 100644 --- a/src/main/java/com/cm/population/service/residential/impl/ResidentialServiceImpl.java +++ b/src/main/java/com/cm/population/service/residential/impl/ResidentialServiceImpl.java @@ -8,19 +8,25 @@ import com.cm.common.token.app.AppTokenManager; import com.cm.common.token.app.entity.AppTokenUser; import com.cm.common.utils.HashMapUtil; import com.cm.common.utils.UUIDUtil; +import com.cm.population.dao.house.IHouseDao; +import com.cm.population.dao.populationinfo.IPopulationInfoDao; import com.cm.population.dao.residential.IResidentialDao; import com.cm.population.pojo.bos.residential.ResidentialBO; +import com.cm.population.pojo.dtos.house.HouseDTO; +import com.cm.population.pojo.dtos.populationinfo.PopulationInfoBaseDTO; import com.cm.population.pojo.dtos.residential.ResidentialDTO; import com.cm.population.pojo.pos.residential.ResidentialPO; import com.cm.population.pojo.vos.residential.ResidentialVO; import com.cm.population.service.residential.IResidentialService; import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; +import com.google.common.collect.Lists; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.util.*; +import java.util.concurrent.*; /** * @ClassName: ResidentialServiceImpl @@ -34,6 +40,10 @@ public class ResidentialServiceImpl extends AbstractService implements IResident @Autowired private IResidentialDao residentialDao; + @Autowired + private IHouseDao houseDao; + @Autowired + private IPopulationInfoDao populationInfoDao; @Override public void save(ResidentialVO residentialVO) { @@ -153,7 +163,7 @@ public class ResidentialServiceImpl extends AbstractService implements IResident @Override public List list(Map params) { - if(null != params.get("myself")) { + if (null != params.get("myself")) { UserInfoBO userInfoBO = this.securityComponent.getCurrentUser(); params.put("creator", userInfoBO.getUserId()); } @@ -194,4 +204,198 @@ public class ResidentialServiceImpl extends AbstractService implements IResident return residentialDao.getStreetId(street); } + /** + * 房屋房主信息数据修复 + */ + @Override + public void dataCover() { + // 获取所有房屋数据 + List houseDTOS = houseDao.getUserHouse(new HashMap<>()); + + /*for (HouseDTO houseDTO : houseDTOS) { + if(StringUtils.isNotEmpty(houseDTO.getDocumentNum())) { + Map params = new HashMap<>(); + String documentNum = houseDTO.getDocumentNum(); + String phone = houseDTO.getPhone(); + params.put("idcard", houseDTO.getDocumentNum()); + params.put("phone", houseDTO.getPhone()); + + PopulationInfoBaseDTO populationInfoBaseDTO; + if(houseDTO.getDocumentNum().indexOf('*') != -1) { + populationInfoBaseDTO = residentialDao.getPopu(params); + }else { + populationInfoBaseDTO = residentialDao.getPopu2(params); + } + if(null != populationInfoBaseDTO) { + params.put("homeowner", populationInfoBaseDTO.getName()); + params.put("ownerPopulationId", populationInfoBaseDTO.getPopulationInfoId()); + params.put("documentNum", populationInfoBaseDTO.getIdcard()); + params.put("phone", populationInfoBaseDTO.getPhone()); + + params.put("documentNum11", documentNum); + params.put("phone11", phone); + params.put("houseId", houseDTO.getHouseId()); + residentialDao.updateHouse(params); + } + params.remove("idcard"); + params.remove("phone"); + params.remove("documentNum11"); + params.remove("phone11"); + } + + if(StringUtils.isNotEmpty(houseDTO.getCustodianDocumentNum())) { + Map params = new HashMap<>(); + String documentNum = houseDTO.getCustodianDocumentNum(); + String phone = houseDTO.getCustodianPhone(); + + params.put("idcard", houseDTO.getCustodianDocumentNum()); + params.put("phone", houseDTO.getCustodianPhone()); + + PopulationInfoBaseDTO populationInfoBaseDTO; + if(houseDTO.getCustodianDocumentNum().indexOf('*') != -1) { + populationInfoBaseDTO = residentialDao.getPopu(params); + }else { + populationInfoBaseDTO = residentialDao.getPopu2(params); + } + if(null != populationInfoBaseDTO) { + params.put("custodian", populationInfoBaseDTO.getName()); + params.put("custodianPopulationId", populationInfoBaseDTO.getPopulationInfoId()); + params.put("custodianDocumentNum", populationInfoBaseDTO.getIdcard()); + params.put("custodianPhone", populationInfoBaseDTO.getPhone()); + + params.put("custodianDocumentNum11", documentNum); + params.put("custodianPhone11", phone); + params.put("houseId", houseDTO.getHouseId()); + residentialDao.updateHouse(params); + } + params.remove("custodianDocumentNum11"); + params.remove("custodianPhone11"); + params.remove("idcard"); + params.remove("phone"); + } + }*/ + + int size = houseDTOS.size(); + int numThreads = size / 500 + (size % 500 == 0 ? 0 : 1); // 计算需要的线程数 + numThreads = numThreads == 0 ? 1 : numThreads; + + ExecutorService executorService = Executors.newFixedThreadPool(numThreads); + List>> futures = new ArrayList<>(); + + // 将populationInfoIds分割成多个子列表,每个子列表由一个任务处理 + int chunkSize = (int) Math.ceil((double) houseDTOS.size() / numThreads); + chunkSize = chunkSize == 0 ? 1 : chunkSize; + List> chunks = Lists.partition(houseDTOS, chunkSize); + + for (List chunk : chunks) { + Callable> task = () -> { + List output = new ArrayList<>(); + for (HouseDTO houseDTO : chunk) { + if (StringUtils.isNotEmpty(houseDTO.getDocumentNum())) { + Map params = new HashMap<>(); + + params.put("houseId", houseDTO.getHouseId()); + + String documentNum = houseDTO.getDocumentNum(); + String phone = houseDTO.getPhone(); + params.put("idcard", houseDTO.getDocumentNum()); + params.put("phone", houseDTO.getPhone()); + + PopulationInfoBaseDTO populationInfoBaseDTO; + if (houseDTO.getDocumentNum().indexOf('*') != -1) { + populationInfoBaseDTO = residentialDao.getPopu(params); + } else { + populationInfoBaseDTO = residentialDao.getPopu2(params); + } + if (null != populationInfoBaseDTO) { + params.put("homeowner", populationInfoBaseDTO.getName()); + params.put("ownerPopulationId", populationInfoBaseDTO.getPopulationInfoId()); + params.put("documentNum", populationInfoBaseDTO.getIdcard()); + params.put("phone", populationInfoBaseDTO.getPhone()); + + params.put("documentNum11", documentNum); + params.put("phone11", phone); + residentialDao.updateHouse(params); + } else { + params.remove("phone"); + if (houseDTO.getDocumentNum().indexOf('*') != -1) { + populationInfoBaseDTO = residentialDao.getPopu(params); + } else { + populationInfoBaseDTO = residentialDao.getPopu2(params); + } + if (null != populationInfoBaseDTO) { + params.put("homeowner", populationInfoBaseDTO.getName()); + params.put("ownerPopulationId", populationInfoBaseDTO.getPopulationInfoId()); + params.put("documentNum", populationInfoBaseDTO.getIdcard()); + params.put("phone", populationInfoBaseDTO.getPhone()); + + params.put("documentNum11", documentNum); + params.put("phone11", phone); + residentialDao.updateHouse(params); + } + } + params.remove("idcard"); + params.remove("phone"); + params.remove("documentNum11"); + params.remove("phone11"); + } + + if (StringUtils.isNotEmpty(houseDTO.getCustodianDocumentNum())) { + Map params = new HashMap<>(); + + params.put("houseId", houseDTO.getHouseId()); + + String documentNum = houseDTO.getCustodianDocumentNum(); + String phone = houseDTO.getCustodianPhone(); + + params.put("idcard", houseDTO.getCustodianDocumentNum()); + params.put("phone", houseDTO.getCustodianPhone()); + + PopulationInfoBaseDTO populationInfoBaseDTO; + if (houseDTO.getCustodianDocumentNum().indexOf('*') != -1) { + populationInfoBaseDTO = residentialDao.getPopu(params); + } else { + populationInfoBaseDTO = residentialDao.getPopu2(params); + } + if (null != populationInfoBaseDTO) { + params.put("custodian", populationInfoBaseDTO.getName()); + params.put("custodianPopulationId", populationInfoBaseDTO.getPopulationInfoId()); + params.put("custodianDocumentNum", populationInfoBaseDTO.getIdcard()); + params.put("custodianPhone", populationInfoBaseDTO.getPhone()); + + params.put("custodianDocumentNum11", documentNum); + params.put("custodianPhone11", phone); + residentialDao.updateHouse(params); + } else { + params.remove("phone"); + if (houseDTO.getCustodianDocumentNum().indexOf('*') != -1) { + populationInfoBaseDTO = residentialDao.getPopu(params); + } else { + populationInfoBaseDTO = residentialDao.getPopu2(params); + } + if (null != populationInfoBaseDTO) { + params.put("custodian", populationInfoBaseDTO.getName()); + params.put("custodianPopulationId", populationInfoBaseDTO.getPopulationInfoId()); + params.put("custodianDocumentNum", populationInfoBaseDTO.getIdcard()); + params.put("custodianPhone", populationInfoBaseDTO.getPhone()); + + params.put("custodianDocumentNum11", documentNum); + params.put("custodianPhone11", phone); + residentialDao.updateHouse(params); + } + } + params.remove("custodianDocumentNum11"); + params.remove("custodianPhone11"); + params.remove("idcard"); + params.remove("phone"); + } + } + return output; + }; + futures.add(executorService.submit(task)); + } + + executorService.shutdown(); // 关闭线程池 + } + } \ 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 73cf3eb..5c4299d 100644 --- a/src/main/resources/mybatis/mapper/house/house-mapper.xml +++ b/src/main/resources/mybatis/mapper/house/house-mapper.xml @@ -1208,4 +1208,62 @@ + + \ No newline at end of file diff --git a/src/main/resources/mybatis/mapper/residential/residential-mapper.xml b/src/main/resources/mybatis/mapper/residential/residential-mapper.xml index e4f11d3..0e3424c 100644 --- a/src/main/resources/mybatis/mapper/residential/residential-mapper.xml +++ b/src/main/resources/mybatis/mapper/residential/residential-mapper.xml @@ -2,6 +2,28 @@ + + + + + + + + + + + + + + + + + + + + + + @@ -437,4 +459,131 @@ SELECT community_id FROM d_community WHERE community_name = #{community} and is_delete = 0 + + + + + + UPDATE + house_house + SET + + owner_population_id = #{ownerPopulationId}, + + + homeowner = #{homeowner}, + + + document_id = #{documentId}, + + + document_name = #{documentName}, + + + document_num = #{documentNum}, + + + phone = #{phone}, + + + custodian_population_id = #{custodianPopulationId}, + + + custodian = #{custodian}, + + + custodian_document_id = #{custodianDocumentId}, + + + custodian_document_name = #{custodianDocumentName}, + + + custodian_document_num = #{custodianDocumentNum}, + + + custodian_phone = #{custodianPhone}, + + house_id = house_id + where + house_id = #{houseId} + + + \ No newline at end of file