以房找人bug修改 --renpc
This commit is contained in:
parent
c884d12a85
commit
b520ff9905
@ -112,12 +112,12 @@ public class PopulationInfoBaseDTO {
|
|||||||
this.healthStatus = healthStatus;
|
this.healthStatus = healthStatus;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getIsMinority() {
|
/*public String getIsMinority() {
|
||||||
if (getAge() < 18) {
|
if (getAge() < 18) {
|
||||||
return "是";
|
return "是";
|
||||||
}
|
}
|
||||||
return "否";
|
return "否";
|
||||||
}
|
}*/
|
||||||
|
|
||||||
public void setIsMinority(String isMinority) {
|
public void setIsMinority(String isMinority) {
|
||||||
this.isMinority = isMinority;
|
this.isMinority = isMinority;
|
||||||
@ -134,14 +134,14 @@ public class PopulationInfoBaseDTO {
|
|||||||
this.isSeriousIllness = isSeriousIllness;
|
this.isSeriousIllness = isSeriousIllness;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Integer getAge() {
|
/*public Integer getAge() {
|
||||||
if (StringUtils.isBlank(this.getBirthday())) {
|
if (StringUtils.isBlank(this.getBirthday())) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
LocalDate birthDate = LocalDate.parse(this.birthday);
|
LocalDate birthDate = LocalDate.parse(this.birthday);
|
||||||
Period period = Period.between(birthDate, LocalDate.now());
|
Period period = Period.between(birthDate, LocalDate.now());
|
||||||
return period.getYears();
|
return period.getYears();
|
||||||
}
|
}*/
|
||||||
|
|
||||||
public void setAge(Integer age) {
|
public void setAge(Integer age) {
|
||||||
this.age = age;
|
this.age = age;
|
||||||
|
@ -21,6 +21,7 @@ import com.cm.population.service.population.IPopulationService;
|
|||||||
import com.cm.population.service.populationinfo.IPopulationInfoService;
|
import com.cm.population.service.populationinfo.IPopulationInfoService;
|
||||||
import com.github.pagehelper.PageHelper;
|
import com.github.pagehelper.PageHelper;
|
||||||
import com.github.pagehelper.PageInfo;
|
import com.github.pagehelper.PageInfo;
|
||||||
|
import com.google.common.collect.Lists;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.springframework.beans.BeanUtils;
|
import org.springframework.beans.BeanUtils;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
@ -470,27 +471,40 @@ public class PopulationServiceImpl extends AbstractService implements IPopulatio
|
|||||||
int size = populationInfoIds.size();
|
int size = populationInfoIds.size();
|
||||||
int numThreads = size / 2 + (size % 2 == 0 ? 0 : 1); // 计算需要的线程数
|
int numThreads = size / 2 + (size % 2 == 0 ? 0 : 1); // 计算需要的线程数
|
||||||
ExecutorService executorService = Executors.newFixedThreadPool(numThreads);
|
ExecutorService executorService = Executors.newFixedThreadPool(numThreads);
|
||||||
|
List<Future<List<PopulationInfoBaseDTO>>> futures = new ArrayList<>();
|
||||||
|
|
||||||
Callable<List<PopulationInfoBaseDTO>> task = () -> {
|
// 将populationInfoIds分割成多个子列表,每个子列表由一个任务处理
|
||||||
List<PopulationInfoBaseDTO> output = new ArrayList<>();
|
int chunkSize = (int) Math.ceil((double) populationInfoIds.size() / numThreads);
|
||||||
for (String str : populationInfoIds) {
|
List<List<String>> chunks = Lists.partition(populationInfoIds, chunkSize);
|
||||||
PopulationInfoBaseDTO base = populationInfoService.getBase(str);
|
|
||||||
output.add(base);
|
|
||||||
}
|
|
||||||
return output;
|
|
||||||
};
|
|
||||||
|
|
||||||
Future<List<PopulationInfoBaseDTO>> futureResult = executorService.submit(task);
|
for (List<String> chunk : chunks) {
|
||||||
try {
|
Callable<List<PopulationInfoBaseDTO>> task = () -> {
|
||||||
List<PopulationInfoBaseDTO> result = futureResult.get();
|
List<PopulationInfoBaseDTO> output = new ArrayList<>();
|
||||||
populationInfoBaseDTOs.addAll(result);
|
for (String str : chunk) {
|
||||||
executorService.shutdown();
|
try {
|
||||||
} catch (InterruptedException e) {
|
PopulationInfoBaseDTO base = populationInfoService.getBase(str);
|
||||||
e.printStackTrace();
|
output.add(base);
|
||||||
} catch (ExecutionException e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
// 处理或记录异常
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return output;
|
||||||
|
};
|
||||||
|
futures.add(executorService.submit(task));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 等待所有任务完成并合并结果
|
||||||
|
for (Future<List<PopulationInfoBaseDTO>> future : futures) {
|
||||||
|
try {
|
||||||
|
populationInfoBaseDTOs.addAll(future.get());
|
||||||
|
} catch (InterruptedException | ExecutionException e) {
|
||||||
|
// 处理或记录异常
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
executorService.shutdown(); // 关闭线程池
|
||||||
|
|
||||||
Map<String, HouseDTO> houseMap = null;
|
Map<String, HouseDTO> houseMap = null;
|
||||||
Map<String, PopulationInfoBaseDTO> baseMap = null;
|
Map<String, PopulationInfoBaseDTO> baseMap = null;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user